| | |
| | | } |
| | | // 本部プルダウン |
| | | public static List<SelectOption> salesDptOpts { get; private set; } |
| | | public static List<SelectOption> options;//<DB202303443108 20230410 you start |
| | | |
| | | |
| | | static { |
| | | salesDptOpts = new List<SelectOption>(); |
| | | salesDptOpts.add(new SelectOption('', '--无--')); |
| | |
| | | salesDptOpts.add(new SelectOption('4.西南', '4.西南')); |
| | | salesDptOpts.add(new SelectOption('5.华东', '5.华东')); |
| | | salesDptOpts.add(new SelectOption('6.华南', '6.华南')); |
| | | |
| | | ////<DB202303443108 20230410 you start 今年还是只显示6大本部,暂时注释 |
| | | //options= FixtureUtil.getPlickList('User', 'Dept__c'); |
| | | //for (SelectOption op : options) { |
| | | // if (String.isNotBlank(op.getValue())) { |
| | | // //if(op.getValue()=='能量事业本部'){ |
| | | // // salesDptOpts.add(new SelectOption('能量事业本部','7.能量')); |
| | | // //}else{ |
| | | // salesDptOpts.add(new SelectOption(op.getValue(),op.getValue())); |
| | | // //} |
| | | |
| | | // } |
| | | //} |
| | | ////<DB202303443108 20230410 you end |
| | | |
| | | } |
| | | |
| | | // 职种 |
| | | public static List<SelectOption> userJobCategorys { get; private set; } |
| | | static { |
| | | // DB202303443108 20230407 you start 职种-->SFDC-职种 |
| | | userJobCategorys = new List<SelectOption>(); |
| | | userJobCategorys.add(new SelectOption('', '--无--')); |
| | | userJobCategorys.add(new SelectOption('销售推广', '销售推广')); |
| | | userJobCategorys.add(new SelectOption('销售市场', '销售市场')); |
| | | userJobCategorys.add(new SelectOption('销售推广', '推广')); |
| | | userJobCategorys.add(new SelectOption('销售市场', '营业市场')); |
| | | //userJobCategorys.add(new SelectOption('销售服务', '服务')); |
| | | userJobCategorys.add(new SelectOption('营业助理', '营业助理')); |
| | | userJobCategorys.add(new SelectOption('行政助理', '行政助理')); |
| | | //userJobCategorys.add(new SelectOption('其他', '其他')); |
| | | } |
| | | |
| | | // 现在年度 |
| | |
| | | // 个人目标(SetPersonalTarget):隐藏OTH。 |
| | | // CHAN-BBLCYP 20190509 LHJ Start |
| | | //private static String[] amountCategory = new String[] {'GI','ET','BF','GS','URO','GYN','ENT'}; |
| | | private static String[] amountCategory = new String[] {'GI', 'ET', 'BF', 'GS', 'URO', 'GYN', 'ENT', 'ENG'}; |
| | | //private static String[] amountCategory = new String[] {'GI', 'ET', 'BF', 'GS', 'URO', 'GYN', 'ENT', 'ENG'}; |
| | | // CHAN-BBLCYP 20190509 LHJ End |
| | | |
| | | // DB202303443108 20230407 you start |
| | | private static String[] amountCategory = new String[] {'GI', 'ET', 'BF', 'GS', 'URO', 'GYN', 'ENT', 'ENG1','ENG2'}; |
| | | // DB202303443108 20230407 you end |
| | | //CHAN-BDQBLX 20210125 you start |
| | | private List<Amount_Major_Product__c> upsertAMPList ;//= new List<Amount_Major_Product__c>(); |
| | | private Map<String, Amount_Major_Product__c> Amount_Major_ProductMap1; |
| | |
| | | //public Blob csvFileBody {get; set;} |
| | | public string csvAsString {get; set;} |
| | | public String[] csvFileLines {get; set;} |
| | | // DB202303443108 20230407 you start |
| | | //wangweipeng 20210616 新加负责产品分类(兼) 导出导入表头 |
| | | private static String[] titlepage = new String[] {'本部', '省', '角色', '担当', '职位', '负责产品分类(主)', '负责产品分类(兼)', 'GI', 'ET', 'BF', 'GS', 'URO', 'GYN', 'ENT', 'ENG'}; |
| | | //private static String[] titlepage = new String[] {'本部', '省', '角色', '担当', '职位', '负责产品分类(主)', '负责产品分类(兼)','目标类型', 'GI', 'ET', 'BF', 'GS', 'URO', 'GYN', 'ENT', 'ENG1', 'ENG2'}; |
| | | private static String[] titlepage = new String[] {'本部', '省', '担当', '职位', '负责产品分类(主)', '负责产品分类(兼)','目标类型', 'GI', 'ET', 'BF', 'GS', 'URO', 'GYN', 'ENT', 'ENG1', 'ENG2','备注'};//20230510 ljh |
| | | |
| | | // DB202303443108 20230407 you end |
| | | public Integer detailCountLimit{get;private set;} |
| | | //CHAN-BDQBLX 20210125 you end |
| | | |
| | |
| | | doubleOTH.add(Double.valueOf(strOTH)); |
| | | } |
| | | proportion.put('OTH', doubleOTH); |
| | | |
| | | String strObjectiveProportionENG = System.Label.ObjectiveProportionENG; |
| | | List<String> objectiveProportionENG = strObjectiveProportionENG.split(','); |
| | | List<Double> doubleENG = new List<Double>(); |
| | | for (String strENG : objectiveProportionENG) { |
| | | doubleENG.add(Double.valueOf(strENG)); |
| | | // DB202303443108 20230407 you start ENG拆分为ENG1和ENG2 |
| | | String strObjectiveProportionENG1 = System.Label.ObjectiveProportionENG; |
| | | List<String> objectiveProportionENG1 = strObjectiveProportionENG1.split(','); |
| | | List<Double> doubleENG1 = new List<Double>(); |
| | | for (String strENG1 : objectiveProportionENG1) { |
| | | doubleENG1.add(Double.valueOf(strENG1)); |
| | | } |
| | | proportion.put('ENG', doubleENG); |
| | | proportion.put('ENG1', doubleENG1); |
| | | |
| | | String strObjectiveProportionENG2 = System.Label.ObjectiveProportionENG; |
| | | List<String> objectiveProportionENG2 = strObjectiveProportionENG2.split(','); |
| | | List<Double> doubleENG2 = new List<Double>(); |
| | | for (String strENG2 : objectiveProportionENG2) { |
| | | doubleENG2.add(Double.valueOf(strENG2)); |
| | | } |
| | | proportion.put('ENG2', doubleENG2); |
| | | // DB202303443108 20230407 you end |
| | | } |
| | | // 職位 |
| | | if (plist == null) { |
| | |
| | | // plist.add(new Position('副部长', false)); |
| | | // plist.add(new Position('部长', false)); |
| | | plist.add(new Position('经理级', true)); |
| | | plist.add(new Position('总监级', false)); |
| | | plist.add(new Position('总监级', true)); |
| | | plist.add(new Position('总裁级', true)); |
| | | //20220402 lt SWAG-CD28H3 【委托】【期初修改4月6日开始修改】目标录入相关判断修改 start |
| | | } |
| | | |
| | | // 当前用户信息 |
| | | if (loginUser == null) { |
| | | loginUser = [Select Id, Salesdepartment__c, Province__c, ProfileId, Job_Category__c From User where Id = :Userinfo.getUserId()]; |
| | | loginUser.Job_Category__c = null; |
| | | loginUser = [Select Id, Salesdepartment__c,Dept__c, Province__c, ProfileId, SFDCPosition_C__c From User where Id = :Userinfo.getUserId()]; |
| | | loginUser.SFDCPosition_C__c = null; |
| | | } |
| | | //adminDpt = loginUser.Dept__c; |
| | | adminDpt = loginUser.Salesdepartment__c; |
| | | if (String.isBlank(adminDpt) |
| | | && (loginUser.ProfileId == System.Label.ProfileId_SystemAdmin |
| | | || loginUser.ProfileId == System.Label.ProfileId_103 |
| | | ) |
| | | ) { |
| | | adminDpt = '4.华东'; |
| | | adminDpt = '5.华东';//'医疗华东营业本部'; |
| | | } |
| | | |
| | | //repFlg =adminDpt; |
| | | // province = loginUser.Province__c; |
| | | users = this.getUserList(false, false, true); |
| | |
| | | string[] titlecsv = csvFileLines[0].trim().split(',');// |
| | | system.debug(titlecsv + '==titlepage==' + titlepage); |
| | | for (integer j = 0; j < titlecsv.size(); j++) { |
| | | if (!titlepage.contains(titlecsv[j])) { |
| | | // 20230515 ljh lightning模式导出有空格 start |
| | | // if (!titlepage.contains(titlecsv[j])) { |
| | | if (!titlepage.contains(titlecsv[j].trim())) { |
| | | // 20230515 ljh lightning模式导出有空格 end |
| | | system.debug('表头不一致得列===' + titlecsv[j]); |
| | | ValFlag = true; |
| | | exportByVal = '表头不一致,请严格按照导出模板填写'; |
| | | break; |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | Set<String> zzs = new Set<String>();//职种 |
| | | |
| | | for (Integer i = 1; i < csvFileLines.size(); i++) { |
| | | System.debug('zheli472:'+csvFileLines[i]); |
| | | // 20230515 ljh 千分位 start |
| | | String p = '\"([^\"]*)\"' ; |
| | | Pattern PP = Pattern.compile(p); |
| | | Matcher matcher1 = PP.matcher(csvFileLines[i]); |
| | | while(matcher1.find()) |
| | | { |
| | | String old = matcher1.group(0); |
| | | String repNew = matcher1.group(0).replaceAll(',','').trim(); |
| | | csvFileLines[i] = csvFileLines[i].replace(old,repNew); |
| | | } |
| | | // 20230515 ljh 千分位 end |
| | | string[] csvRecordData = csvFileLines[i].split(','); |
| | | if (csvRecordData.size() > 0) { |
| | | String bu = csvRecordData[0].replace(' ', ''); |
| | | String sf = csvRecordData[1].replace(' ', ''); |
| | | String dandang = csvRecordData[3].replace(' ', ''); |
| | | String zw = csvRecordData[4].replace(' ', ''); |
| | | String bu = csvRecordData[0].replace(' ', '');//本部 |
| | | String sf = csvRecordData[1].replace(' ', '');//省 |
| | | //隐藏角色 |
| | | //String dandang = csvRecordData[3].replace(' ', '');//担当 |
| | | //String zw = csvRecordData[4].replace(' ', '');//通用职级 |
| | | String dandang = csvRecordData[2].replace(' ', '');//担当 |
| | | String zw = csvRecordData[3].replace(' ', '');//通用职级 |
| | | String key_flg = (bu + sf + dandang + zw).replaceAll('"', ''); |
| | | UserInfoList.add(key_flg); |
| | | szMap.put(key_flg, csvRecordData); |
| | |
| | | Map<String, User> userMap = new Map<String, User>(); |
| | | for (User userl : userList) { |
| | | yydds.add(userl.Sales_Speciality__c);//医院担当 |
| | | zzs.add(userl.Job_Category__c);//职种 |
| | | zzs.add(userl.SFDCPosition_C__c);//职种 |
| | | userMap.put(userl.UserInfos__c, userl); |
| | | |
| | | } |
| | | /** |
| | | 角色隐藏暂时注释 |
| | | Integer Target_Number = 7;//目标类型 |
| | | Integer GI_Number = 8; |
| | | Integer ET_Number = 9; |
| | | Integer BF_Number = 10; |
| | | Integer GS_Number = 11; |
| | | Integer URO_Number = 12; |
| | | Integer GYN_Number = 13; |
| | | Integer ENT_Number = 14; |
| | | // DB202303443108 20230407 you start |
| | | Integer ENG1_Number = 15; |
| | | Integer ENG2_Number = 16; |
| | | // DB202303443108 20230407 you end |
| | | **/ |
| | | Integer Target_Number = 6;//目标类型 |
| | | Integer GI_Number = 7; |
| | | Integer ET_Number = 8; |
| | | Integer BF_Number = 9; |
| | |
| | | Integer URO_Number = 11; |
| | | Integer GYN_Number = 12; |
| | | Integer ENT_Number = 13; |
| | | Integer ENG_Number = 14; |
| | | |
| | | // DB202303443108 20230407 you start |
| | | Integer ENG1_Number = 14; |
| | | Integer ENG2_Number = 15; |
| | | // DB202303443108 20230407 you end |
| | | Integer Remarks_Number = 16;//20230510 ljh |
| | | upsertAMPList = new List<Amount_Major_Product__c>();//初始化,解决重复导入数据 id重复得问题 |
| | | for (String key : szMap.keySet()) { |
| | | //取用户的Id |
| | |
| | | |
| | | List<String> csvRecordData = szMap.get(key); |
| | | Amount_Major_Product__c upsertAMP = new Amount_Major_Product__c(); |
| | | |
| | | String Target_Type = String.isNotBlank(csvRecordData[Target_Number]) && String.isNotBlank(csvRecordData[Target_Number].replaceAll('"', '')) ? String.valueof(csvRecordData[Target_Number].replaceAll('"', '')) : ''; |
| | | // 20230510 ljh start |
| | | String remarks = String.isNotBlank(csvRecordData[Remarks_Number]) && String.isNotBlank(csvRecordData[Remarks_Number].replaceAll('"', '')) ? String.valueof(csvRecordData[Remarks_Number].replaceAll('"', '')) : ''; |
| | | // 20230510 ljh start |
| | | //获取导入数量 |
| | | Decimal GI_Amount = String.isNotBlank(csvRecordData[GI_Number]) && String.isNotBlank(csvRecordData[GI_Number].replaceAll('"', '')) ? Decimal.valueof(csvRecordData[GI_Number].replaceAll('"', '')) : 0.00; |
| | | // 20230515 ljh 千分位 start |
| | | // Decimal GI_Amount = String.isNotBlank(csvRecordData[GI_Number]) && String.isNotBlank(csvRecordData[GI_Number].replaceAll('"', '')) ? Decimal.valueof(csvRecordData[GI_Number].replaceAll('"', '')) : 0.00; |
| | | Decimal GI_Amount = String.isNotBlank(csvRecordData[GI_Number]) && String.isNotBlank(csvRecordData[GI_Number].replaceAll('"', '')) ? Decimal.valueof(csvRecordData[GI_Number].replaceAll('"', '').trim()) : 0.00; |
| | | // 20230515 ljh 千分位 end |
| | | DataSplicing(GI_Amount,userid + '_GI',Amount_Major_ProductMap1,userinfors,Target_Type,remarks); |
| | | |
| | | DataSplicing(GI_Amount,userid + '_GI',Amount_Major_ProductMap1,userinfors); |
| | | // 20230515 ljh 千分位 start |
| | | // Decimal ET_Amount = String.isNotBlank(csvRecordData[ET_Number]) && String.isNotBlank(csvRecordData[ET_Number].replaceAll('"', '')) ? Decimal.valueOf(csvRecordData[ET_Number].replaceAll('"', '')) : 0.00; |
| | | Decimal ET_Amount = String.isNotBlank(csvRecordData[ET_Number]) && String.isNotBlank(csvRecordData[ET_Number].replaceAll('"', '')) ? Decimal.valueOf(csvRecordData[ET_Number].replaceAll('"', '').trim()) : 0.00; |
| | | // 20230515 ljh 千分位 end |
| | | DataSplicing(ET_Amount,userid + '_ET',Amount_Major_ProductMap1,userinfors,Target_Type,remarks); |
| | | |
| | | Decimal ET_Amount = String.isNotBlank(csvRecordData[ET_Number]) && String.isNotBlank(csvRecordData[ET_Number].replaceAll('"', '')) ? Decimal.valueOf(csvRecordData[ET_Number].replaceAll('"', '')) : 0.00; |
| | | DataSplicing(ET_Amount,userid + '_ET',Amount_Major_ProductMap1,userinfors); |
| | | // 20230515 ljh 千分位 start |
| | | // Decimal BF_Amount = String.isNotBlank(csvRecordData[BF_Number]) && String.isNotBlank(csvRecordData[BF_Number].replaceAll('"', '')) ? Decimal.valueOf(csvRecordData[BF_Number].replaceAll('"', '')) : 0.00; |
| | | Decimal BF_Amount = String.isNotBlank(csvRecordData[BF_Number]) && String.isNotBlank(csvRecordData[BF_Number].replaceAll('"', '')) ? Decimal.valueOf(csvRecordData[BF_Number].replaceAll('"', '').trim()) : 0.00; |
| | | // 20230515 ljh 千分位 end |
| | | DataSplicing(BF_Amount,userid + '_BF',Amount_Major_ProductMap1,userinfors,Target_Type,remarks); |
| | | |
| | | Decimal BF_Amount = String.isNotBlank(csvRecordData[BF_Number]) && String.isNotBlank(csvRecordData[BF_Number].replaceAll('"', '')) ? Decimal.valueOf(csvRecordData[BF_Number].replaceAll('"', '')) : 0.00; |
| | | DataSplicing(BF_Amount,userid + '_BF',Amount_Major_ProductMap1,userinfors); |
| | | |
| | | Decimal GS_Amount = String.isNotBlank(csvRecordData[GS_Number]) && String.isNotBlank(csvRecordData[GS_Number].replaceAll('"', '')) ? Decimal.valueOf(csvRecordData[GS_Number].replaceAll('"', '')) : 0.00; |
| | | DataSplicing(GS_Amount,userid + '_GS',Amount_Major_ProductMap1,userinfors); |
| | | |
| | | Decimal URO_Amount = String.isNotBlank(csvRecordData[URO_Number]) && String.isNotBlank(csvRecordData[URO_Number].replaceAll('"', '')) ? Decimal.valueOf(csvRecordData[URO_Number].replaceAll('"', '')) : 0.00; |
| | | DataSplicing(URO_Amount,userid + '_URO',Amount_Major_ProductMap1,userinfors); |
| | | |
| | | Decimal GYN_Amount = String.isNotBlank(csvRecordData[GYN_Number]) && String.isNotBlank(csvRecordData[GYN_Number].replaceAll('"', '')) ? Decimal.valueOf(csvRecordData[GYN_Number].replaceAll('"', '')) : 0.00; |
| | | DataSplicing(GYN_Amount,userid + '_GYN',Amount_Major_ProductMap1,userinfors); |
| | | |
| | | Decimal ENT_Amount = String.isNotBlank(csvRecordData[ENT_Number]) && String.isNotBlank(csvRecordData[ENT_Number].replaceAll('"', '')) ? Decimal.valueOf(csvRecordData[ENT_Number].replaceAll('"', '')) : 0.00; |
| | | DataSplicing(ENT_Amount,userid + '_ENT',Amount_Major_ProductMap1,userinfors); |
| | | system.debug('ENG_Number--->'+csvRecordData[ENG_Number]); |
| | | // 20230515 ljh 千分位 start |
| | | // Decimal GS_Amount = String.isNotBlank(csvRecordData[GS_Number]) && String.isNotBlank(csvRecordData[GS_Number].replaceAll('"', '')) ? Decimal.valueOf(csvRecordData[GS_Number].replaceAll('"', '')) : 0.00; |
| | | Decimal GS_Amount = String.isNotBlank(csvRecordData[GS_Number]) && String.isNotBlank(csvRecordData[GS_Number].replaceAll('"', '')) ? Decimal.valueOf(csvRecordData[GS_Number].replaceAll('"', '').trim()) : 0.00; |
| | | // 20230515 ljh 千分位 end |
| | | DataSplicing(GS_Amount,userid + '_GS',Amount_Major_ProductMap1,userinfors,Target_Type,remarks); |
| | | // 20230515 ljh 千分位 start |
| | | // Decimal URO_Amount = String.isNotBlank(csvRecordData[URO_Number]) && String.isNotBlank(csvRecordData[URO_Number].replaceAll('"', '')) ? Decimal.valueOf(csvRecordData[URO_Number].replaceAll('"', '')) : 0.00; |
| | | Decimal URO_Amount = String.isNotBlank(csvRecordData[URO_Number]) && String.isNotBlank(csvRecordData[URO_Number].replaceAll('"', '')) ? Decimal.valueOf(csvRecordData[URO_Number].replaceAll('"', '').trim()) : 0.00; |
| | | // 20230515 ljh 千分位 end |
| | | DataSplicing(URO_Amount,userid + '_URO',Amount_Major_ProductMap1,userinfors,Target_Type,remarks); |
| | | // 20230515 ljh 千分位 start |
| | | // Decimal GYN_Amount = String.isNotBlank(csvRecordData[GYN_Number]) && String.isNotBlank(csvRecordData[GYN_Number].replaceAll('"', '')) ? Decimal.valueOf(csvRecordData[GYN_Number].replaceAll('"', '')) : 0.00; |
| | | Decimal GYN_Amount = String.isNotBlank(csvRecordData[GYN_Number]) && String.isNotBlank(csvRecordData[GYN_Number].replaceAll('"', '')) ? Decimal.valueOf(csvRecordData[GYN_Number].replaceAll('"', '').trim()) : 0.00; |
| | | // 20230515 ljh 千分位 end |
| | | DataSplicing(GYN_Amount,userid + '_GYN',Amount_Major_ProductMap1,userinfors,Target_Type,remarks); |
| | | // 20230515 ljh 千分位 start |
| | | // Decimal ENT_Amount = String.isNotBlank(csvRecordData[ENT_Number]) && String.isNotBlank(csvRecordData[ENT_Number].replaceAll('"', '')) ? Decimal.valueOf(csvRecordData[ENT_Number].replaceAll('"', '')) : 0.00; |
| | | Decimal ENT_Amount = String.isNotBlank(csvRecordData[ENT_Number]) && String.isNotBlank(csvRecordData[ENT_Number].replaceAll('"', '')) ? Decimal.valueOf(csvRecordData[ENT_Number].replaceAll('"', '').trim()) : 0.00; |
| | | // 20230515 ljh 千分位 end |
| | | DataSplicing(ENT_Amount,userid + '_ENT',Amount_Major_ProductMap1,userinfors,Target_Type,remarks); |
| | | system.debug('ENG1_Number--->'+csvRecordData[ENG1_Number]); |
| | | //因为最后一列数据有空格,所以加.trim() |
| | | Decimal ENG_Amount = String.isNotBlank(csvRecordData[ENG_Number]) && String.isNotBlank(csvRecordData[ENG_Number].replaceAll('"', ''))? Decimal.valueOf(csvRecordData[ENG_Number].replaceAll('"', '').trim()) : 0.00; |
| | | // DB202303443108 20230407 you start |
| | | Decimal ENG1_Amount = String.isNotBlank(csvRecordData[ENG1_Number]) && String.isNotBlank(csvRecordData[ENG1_Number].replaceAll('"', ''))? Decimal.valueOf(csvRecordData[ENG1_Number].replaceAll('"', '').trim()) : 0.00; |
| | | // Decimal.valueOf(String str) |
| | | DataSplicing(ENG_Amount,userid + '_ENG',Amount_Major_ProductMap1,userinfors); |
| | | DataSplicing(ENG1_Amount,userid + '_ENG1',Amount_Major_ProductMap1,userinfors,Target_Type,remarks); |
| | | |
| | | Decimal ENG2_Amount = String.isNotBlank(csvRecordData[ENG2_Number]) && String.isNotBlank(csvRecordData[ENG2_Number].replaceAll('"', ''))? Decimal.valueOf(csvRecordData[ENG2_Number].replaceAll('"', '').trim()) : 0.00; |
| | | DataSplicing(ENG2_Amount,userid + '_ENG2',Amount_Major_ProductMap1,userinfors,Target_Type,remarks); |
| | | |
| | | // DB202303443108 20230407 you end |
| | | |
| | | |
| | | |
| | |
| | | return null; |
| | | } |
| | | // 最终得数据处理, |
| | | private void DataSplicing(Decimal amount, String key, Map<String, Amount_Major_Product__c> ampMap,User userinfors ) {//去进行最终数据得插入,更新或删除操作 |
| | | // 20230510 ljh start |
| | | // private void DataSplicing(Decimal amount, String key, Map<String, Amount_Major_Product__c> ampMap,User userinfors,String Target_Type) {//去进行最终数据得插入,更新或删除操作 |
| | | private void DataSplicing(Decimal amount, String key, Map<String, Amount_Major_Product__c> ampMap,User userinfors,String Target_Type,String remarks) {//去进行最终数据得插入,更新或删除操作 |
| | | // 20230510 ljh end |
| | | Amount_Major_Product__c upsertAMP = new Amount_Major_Product__c(); |
| | | Amount_Major_Product__c Amount_Major_Product = Amount_Major_ProductMap.get(key); |
| | | system.debug('==amount=='+amount+'==key=='+key+'==ampMap=='+ampMap+'==userinfors=='+userinfors+'\n'); |
| | | //system.debug('==amount=='+amount+'==key=='+key+'==ampMap=='+ampMap+'==userinfors=='+userinfors+'==Target_Type=='+Target_Type+'\n'); |
| | | if (ampMap.containskey(key)) { |
| | | upsertAMP = ampMap.get(key); |
| | | if (amount > 0) { |
| | | if(amount!=upsertAMP.Amount__c){ |
| | | // 20230510 ljh update start |
| | | // if(amount!=upsertAMP.Amount__c){ |
| | | if(amount!=upsertAMP.Amount__c || Target_Type!=upsertAMP.TargetType__c ||remarks!=upsertAMP.remarks__c){ |
| | | // 20230510 ljh update end |
| | | upsertAMP.Amount__c = amount; |
| | | upsertAMP.Use_Start_Date__c = userinfors.Use_Start_Date__c; |
| | | upsertAMP.Is_Processing__c = true; |
| | | upsertAMP.TargetType__c = Target_Type; |
| | | upsertAMP.remarks__c = remarks;// 20230510 ljh |
| | | upsertAMPList.add(upsertAMP); |
| | | //更新 |
| | | } |
| | |
| | | //不用删除了,允许 数据是空的存在 |
| | | upsertAMP.Amount__c = null; |
| | | upsertAMP.Is_Processing__c = true; |
| | | upsertAMP.TargetType__c = Target_Type;// 20230510 ljh |
| | | upsertAMP.remarks__c = remarks;// 20230510 ljh |
| | | upsertAMPList.add(upsertAMP); |
| | | } |
| | | } else { |
| | |
| | | upsertAMP.Use_Start_Date__c = userinfors.Use_Start_Date__c; |
| | | upsertAMP.iYear__c = iYear; |
| | | upsertAMP.Is_Processing__c = true; |
| | | upsertAMP.TargetType__c = Target_Type; |
| | | upsertAMP.remarks__c = remarks;// 20230510 ljh |
| | | upsertAMPList.add(upsertAMP); |
| | | } else { |
| | | //允许 数据是空的存在 |
| | |
| | | upsertAMP.Use_Start_Date__c = userinfors.Use_Start_Date__c; |
| | | upsertAMP.iYear__c = iYear; |
| | | upsertAMP.Is_Processing__c = true; |
| | | upsertAMP.TargetType__c = Target_Type; |
| | | upsertAMP.remarks__c = remarks;// 20230510 ljh |
| | | upsertAMPList.add(upsertAMP); |
| | | } |
| | | } |
| | |
| | | Amount_Major_ProductMap1 = new Map<String, Amount_Major_Product__c>(); |
| | | |
| | | list<Amount_Major_Product__c> Existed_Amount_Major_Products = [select key__c, Amount__c, user_Alias__c, |
| | | Is_Processing__c, iYear__c from Amount_Major_Product__c where iYear__c = : iYear and SAP_Province__c in :sfs]; |
| | | Is_Processing__c, iYear__c,TargetType__c,remarks__c from Amount_Major_Product__c where iYear__c = : iYear and SAP_Province__c in :sfs]; |
| | | //system.debug('Existed_Amount_Major_Products' + Existed_Amount_Major_Products); |
| | | |
| | | for ( Amount_Major_Product__c Amount_Major_Product : Existed_Amount_Major_Products ) { |
| | |
| | | } |
| | | } |
| | | private List<User> getUserList(List<String> UserInfoList) {//根据上传文件中得本部,省份,担当,职位 得到了user 信息 |
| | | String soql = 'select Id, UserInfos__c, Salesdepartment__c, Province__c, Alias, Product_specialist_incharge_product__c,Responsible_for_Products_Concurrently__c, Use_Start_Date__c,' |
| | | + ' ProfileId, Profile.Name, UserRoleId, UserRole.Name, Sales_Speciality__c, HR_Post__c,Job_Category__c' |
| | | String soql = 'select Id, UserInfos__c, Salesdepartment__c,Dept__c, Province__c, Alias, Product_specialist_incharge_product__c,Responsible_for_Products_Concurrently__c, Use_Start_Date__c,' |
| | | + ' ProfileId, Profile.Name, UserRoleId, UserRole.Name, Sales_Speciality__c, HR_Post__c,SFDCPosition_C__c' |
| | | + ' from User where IsActive = true and Test_staff__c = false and UserType = \'Standard\' ' |
| | | + ' and Salesdepartment__c <> \'7.能量\' ' |
| | | + ' and UserInfos__c IN :UserInfoList order by Salesdepartment__c, Province__c'; |
| | |
| | | } |
| | | |
| | | list<Amount_Major_Product__c> Existed_Amount_Major_Products = [select key__c, Amount__c, user_Alias__c, |
| | | Is_Processing__c, iYear__c from Amount_Major_Product__c where iYear__c = : iYear ]; |
| | | //system.debug('Existed_Amount_Major_Products' + Existed_Amount_Major_Products); |
| | | Is_Processing__c, iYear__c,TargetType__c,remarks__c from Amount_Major_Product__c where iYear__c = : iYear ]; |
| | | //system.debug('iYear===' + iYear); |
| | | if (Existed_Amount_Major_Products.size() <= 0 ) { |
| | | return false; |
| | | } |
| | |
| | | break; |
| | | } |
| | | } |
| | | //system.debug('==flag=='+flag); |
| | | if (flag) { |
| | | Amount_Major_ProductMap.put(Amount_Major_Product.key__c, Amount_Major_Product); |
| | | } |
| | |
| | | } |
| | | //ApexPages.addmessage(new ApexPages.message('aa')); |
| | | //'Amount_Major_ProductMap' + Amount_Major_ProductMap.keySet() |
| | | //system.debug(Amount_Major_ProductMap+'Existed_Amount_Major_Products==' + Amount_Major_ProductMap.keySet()); |
| | | return true; |
| | | } |
| | | |
| | | // ユーザの検索 |
| | | private List<User> getUserList(Boolean searchByDpt, Boolean searchByProvince, Boolean defaultSearch) { |
| | | String soql = 'select Id, Salesdepartment__c, Province__c, Alias, Product_specialist_incharge_product__c,Responsible_for_Products_Concurrently__c, Use_Start_Date__c,' |
| | | system.debug('进来了'); |
| | | String soql = 'select Id, Salesdepartment__c,Dept__c, Province__c, Alias, Product_specialist_incharge_product__c,Responsible_for_Products_Concurrently__c, Use_Start_Date__c,' |
| | | + ' ProfileId, Profile.Name, UserRoleId, UserRole.Name, Sales_Speciality__c, HR_Post__c' |
| | | + ' from User where IsActive = true and Test_staff__c = false and UserType = \'Standard\' ' |
| | | // CHAN-BBLCYP 20190509 LHJ Start |
| | |
| | | //wangweipeng SWAG-C6V8W5 2021/09/16 end |
| | | |
| | | // 职种 |
| | | if (defaultSearch || String.isBlank(loginUser.Job_Category__c)) { |
| | | soql += ' and (Job_Category__c = \'销售推广\' or Job_Category__c = \'销售市场\')'; |
| | | if (defaultSearch || String.isBlank(loginUser.SFDCPosition_C__c)) { |
| | | soql += ' and (SFDCPosition_C__c = \'销售推广\' or SFDCPosition_C__c = \'销售市场\' or SFDCPosition_C__c = \'营业助理\' or SFDCPosition_C__c = \'行政助理\')';// or SFDCPosition_C__c = \'销售服务\' or SFDCPosition_C__c = \'其他\' |
| | | } else { |
| | | soql += ' and Job_Category__c = \'' + loginUser.Job_Category__c + '\''; |
| | | soql += ' and SFDCPosition_C__c = \'' + loginUser.SFDCPosition_C__c + '\''; |
| | | } |
| | | // 本部にて検索の場合、省を無視 |
| | | if (searchByDpt) { |
| | |
| | | if (String.isBlank(salesDpt) && String.isBlank(loginUser.Province__c)) { |
| | | soql += ' and Salesdepartment__c = \'' + adminDpt + '\''; |
| | | } |
| | | if(String.isBlank(salesDpt) ){ |
| | | soql += ' and (Salesdepartment__c = \'1.华北\' or Salesdepartment__c = \'2.东北\' or Salesdepartment__c = \'3.西北\' or Salesdepartment__c = \'4.西南\' or Salesdepartment__c = \'5.华东\' or Salesdepartment__c = \'6.华南\')'; |
| | | } |
| | | if (searchByProvince) { |
| | | salesDpt = adminDpt; |
| | | } |
| | | |
| | | |
| | | // 職位条件 |
| | | List<String> positionNames = new List<String>(); |
| | | String s1 = '经理'; |
| | | String s2 = '总监'; |
| | | String s3 = '总裁'; |
| | | for (Position p : plist) { |
| | | if (p.check) { |
| | | //positionNames.add(p.positionName); |
| | |
| | | for (Integer i = 0; i < positionNames.size(); i++) { |
| | | if (i == positionNames.size() - 1) { |
| | | //20220517 lt SWAG-CD28H3 Start |
| | | if(positionNames[i] != '经理级' && positionNames[i] != '总监级'){ |
| | | if(positionNames[i] != '经理级' && positionNames[i] != '总监级' && positionNames[i] != '总裁级'){ |
| | | soql += ' HR_Post__c = \'' + positionNames[i] + '\''; |
| | | } |
| | | else if(positionNames[i] == '经理级'){ |
| | |
| | | soql += ' HR_Post__c like \'%' + s2 + '%\''; |
| | | } |
| | | //20220517 lt SWAG-CD28H3 End |
| | | else if(positionNames[i] == '总裁级'){ |
| | | soql += ' HR_Post__c like \'%' + s3 + '%\''; |
| | | } |
| | | } else { |
| | | //20220517 lt SWAG-CD28H3 Start |
| | | if(positionNames[i] != '经理级' && positionNames[i] != '总监级'){ |
| | | if(positionNames[i] != '经理级' && positionNames[i] != '总监级' && positionNames[i] != '总裁级'){ |
| | | soql += ' HR_Post__c = \'' + positionNames[i] + '\' or'; |
| | | } |
| | | else if(positionNames[i] == '经理级'){ |
| | |
| | | soql += ' HR_Post__c like \'%' + s2 + '%\' or'; |
| | | } |
| | | //20220517 lt SWAG-CD28H3 End |
| | | else if(positionNames[i] == '总裁级'){ |
| | | soql += ' HR_Post__c like \'%' + s3 + '%\' or'; |
| | | } |
| | | } |
| | | } |
| | | soql += ')'; |
| | |
| | | Opportunity[] opportunitys = [select |
| | | Id, OwnerId, Opportunity_Category__c, Proportion__c, CloseDate, |
| | | Amount, Objective__c, Target_category__c, |
| | | SAP_Province__c, RecordTypeId, OCM_Target_period__c |
| | | SAP_Province__c, RecordTypeId, OCM_Target_period__c,TargetType__c,remarks__c |
| | | from Opportunity |
| | | where Target_category__c = '担当目标' |
| | | and RecordTypeId = :rt.Id |
| | |
| | | //--------------20200605 ljh end start ------ |
| | | // 当前年度没有数据时,显示信息 |
| | | //&& opportunitys.size() <= 0 Existed_Amount_Major_Products.size()<=0 |
| | | system.debug('==currentPeriodOld=='+currentPeriodOld); |
| | | if (opportunitys.size() <= 0 && isPast && iYear < currentYear) { |
| | | ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.INFO, '没有上年度的数据。'); |
| | | ApexPages.addMessage(msg); |
| | |
| | | for (Integer j = 0; j < amountCategory.size(); j++) { |
| | | String key = users[u].Id + '_' + amountCategory[j] ; |
| | | if (Amount_Major_ProductMap.containsKey(key)) { |
| | | |
| | | Amount_Major_Product__c Amount_Major_Product = Amount_Major_ProductMap.get(key); |
| | | dataBean.amount[j].Amount = Amount_Major_Product.Amount__c; |
| | | //dataBean.opportunity.TargetType__c = Amount_Major_Product.TargetType__c; |
| | | dataBean.opportunity.TargetType__c = String.isNotBlank(Amount_Major_Product.TargetType__c) ? Amount_Major_Product.TargetType__c : '个人'; |
| | | system.debug(Amount_Major_ProductMap.get(key)+'==key====='+key+'==='+Amount_Major_Product.Amount__c+'=='+Amount_Major_Product.TargetType__c); |
| | | dataBean.opportunity.remarks__c = Amount_Major_Product.remarks__c;// 20230510 ljh start |
| | | } else { |
| | | dataBean.opportunity.TargetType__c = '个人'; |
| | | // dataBean.amount[j].Amount = null; |
| | | dataBean.opportunity.remarks__c = '';// 20230510 ljh start |
| | | } |
| | | |
| | | } |
| | | // 2020/06/05 SWAG-BQ7CM9 与既有中间表数据进行对比,然后更新至visualforce page by ljh end |
| | | dataBeans.add(dataBean); |
| | | } |
| | | system.debug('==dataBeans=='+dataBeans); |
| | | } |
| | | |
| | | // 実際の保存ロジック |
| | |
| | | if (Amount_Major_ProductMap.containsKey(key)) { |
| | | //临时表已经有了 |
| | | Amount_Major_Product__c Amount_Major_Product = Amount_Major_ProductMap.get(key); |
| | | |
| | | if (Amount_Major_Product.Amount__c == db.amount[j].Amount) { |
| | | // 20230510 ljh start |
| | | // if (Amount_Major_Product.Amount__c == db.amount[j].Amount) { |
| | | if (Amount_Major_Product.Amount__c == db.amount[j].Amount && Amount_Major_Product.TargetType__c == db.opportunity.TargetType__c && Amount_Major_Product.remarks__c == db.opportunity.remarks__c) { |
| | | // 20230510 ljh end |
| | | continue; |
| | | } else { |
| | | Amount_Major_Product.Amount__c = db.amount[j].Amount; |
| | | Amount_Major_Product.TargetType__c = db.opportunity.TargetType__c; |
| | | Amount_Major_Product.remarks__c = db.opportunity.remarks__c; // 20230510 ljh |
| | | Amount_Major_Product.user_Alias__c = db.user.Alias; |
| | | Amount_Major_Product.SAP_Province__c = db.user.Province__c; |
| | | Amount_Major_Product.Use_Start_Date__c = db.user.Use_Start_Date__c; |
| | |
| | | if (oppMap.containskey(keyOpp)) { |
| | | opp = oppMap.get(keyOpp); |
| | | //if (opp.Proportion__c != proportion.get(amountC)[i]) { |
| | | if (opp.Amount != db.amount[j].Amount) { |
| | | // 20230510 ljh start |
| | | // if (opp.Amount != db.amount[j].Amount) { |
| | | if (opp.Amount != db.amount[j].Amount || opp.TargetType__c != db.opportunity.TargetType__c || opp.remarks__c != db.opportunity.remarks__c) { |
| | | // 20230510 ljh end |
| | | proportionChanged = true; |
| | | break; |
| | | } |
| | | } else { |
| | | if (db.amount[j].Amount != null) { |
| | | // 20230510 ljh start |
| | | // if (db.amount[j].Amount != null) { |
| | | if (db.amount[j].Amount != null || db.opportunity.TargetType__c != null || db.opportunity.remarks__c != null) { |
| | | // 20230510 ljh end |
| | | proportionChanged = true; |
| | | break; |
| | | } |
| | |
| | | Amount_Major_Product__c Amount_Major_Product = new Amount_Major_Product__c(); |
| | | Amount_Major_Product.key__c = key; |
| | | Amount_Major_Product.Amount__c = db.amount[j].Amount; |
| | | Amount_Major_Product.TargetType__c = db.opportunity.TargetType__c; |
| | | Amount_Major_Product.remarks__c = db.opportunity.remarks__c; // 20230510 ljh |
| | | Amount_Major_Product.user_Alias__c = db.user.Alias; |
| | | Amount_Major_Product.SAP_Province__c = db.user.Province__c; |
| | | Amount_Major_Product.Use_Start_Date__c = db.user.Use_Start_Date__c; |
| | |
| | | public Opportunity[] amount { get; set; } |
| | | // 是否变化 0:无 1:有 |
| | | public String isChanged { get; set; } |
| | | //目标类型 |
| | | public Opportunity opportunity { get; set; } |
| | | |
| | | // 20230510 ljh start |
| | | // 备注 |
| | | public String remarks { get; set; } |
| | | // 20230510 ljh end |
| | | // 构造方法 |
| | | DataBean(User user, Map<String, Opportunity> oppMap, Integer iYear) { |
| | | this.user = user; |
| | | this.amount = new List<Opportunity>(); |
| | | this.isChanged = '0'; |
| | | |
| | | |
| | | this.opportunity = new Opportunity(); |
| | | this.opportunity.TargetType__c = '个人'; |
| | | this.remarks = ''; // 20230510 ljh add |
| | | // 按金额分类,查找数据,并设值 |
| | | for (Integer i = 0; i < amountCategory.size(); i++) { |
| | | String amountC = amountCategory[i]; |
| | |
| | | if (oppMap.containskey(key)) { |
| | | //a.Amount = oppMap.get(key).Amount; |
| | | amountSum += oppMap.get(key).Objective__c == null ? 0 : oppMap.get(key).Objective__c; |
| | | this.opportunity.TargetType__c = oppMap.get(key).TargetType__c; |
| | | this.opportunity.remarks__c = oppMap.get(key).remarks__c;// 20230510 ljh start |
| | | }else{ |
| | | this.opportunity.TargetType__c = '个人'; |
| | | this.opportunity.remarks__c = ''; // 20230510 ljh start |
| | | } |
| | | } |
| | | if (amountSum > 0) { |