| | |
| | | // 既存目标数据 |
| | | private Map<String, Opportunity> oppMap; |
| | | private Map<Id, OpportunityLineItem> oliMap; |
| | | 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','ENG1','ENG2'}; |
| | | |
| | | // 当前年度 |
| | | private Integer iYear; |
| | |
| | | } |
| | | |
| | | global Database.QueryLocator start(Database.BatchableContext BC) { |
| | | query = 'select key__c,Amount__c,user_Alias__c,SAP_Province__c,Is_Processing__c,iYear__c,Use_Start_Date__c from Amount_Major_Product__c where Is_Processing__c = true'; |
| | | query = 'select key__c,Amount__c,user_Alias__c,SAP_Province__c,TargetType__c,remarks__c,Is_Processing__c,iYear__c,Use_Start_Date__c from Amount_Major_Product__c where Is_Processing__c = true'; |
| | | return Database.getQueryLocator(query); |
| | | } |
| | | global void execute(Database.BatchableContext BC, List<Amount_Major_Product__c> Amount_Major_Products) { |
| | |
| | | opp.Amount = Amount_Major_Product.Amount__c / proportionSumMap.get(target_category); |
| | | opp.Target_category__c = '担当目标'; |
| | | opp.SAP_Province__c = Amount_Major_Product.SAP_Province__c; |
| | | opp.TargetType__c = Amount_Major_Product.TargetType__c; |
| | | opp.remarks__c = Amount_Major_Product.remarks__c; // 20230510 ljh |
| | | opp.RecordTypeId = rt.Id; |
| | | opp.OCM_Target_period__c = String.valueOf(integer.valueOf(Amount_Major_Product.iYear__c) - 1867 + 'P'); |
| | | opp.CurrencyIsoCode = 'CNY'; |
| | |
| | | opp.Amount = Amount_Major_Product.Amount__c / proportionSumMap.get(target_category); |
| | | opp.Target_category__c = '担当目标'; |
| | | opp.SAP_Province__c = Amount_Major_Product.SAP_Province__c; |
| | | opp.TargetType__c = Amount_Major_Product.TargetType__c; |
| | | opp.remarks__c = Amount_Major_Product.remarks__c;// 20230510 ljh |
| | | opp.RecordTypeId = rt.Id; |
| | | opp.OCM_Target_period__c = String.valueOf(integer.valueOf(Amount_Major_Product.iYear__c) - 1867 + 'P'); |
| | | opp.CurrencyIsoCode = 'CNY'; |
| | |
| | | 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 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 you end ENG拆分为ENG1和ENG2 |
| | | } |
| | | //初始化既存目标数据 |
| | | oppMap = new Map<String, Opportunity>(); |
| | |
| | | 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,TargetType__c, RecordTypeId, OCM_Target_period__c |
| | | from Opportunity |
| | | where Target_category__c = '担当目标' |
| | | and RecordTypeId = :rt.Id |