| | |
| | | } |
| | | |
| | | global void execute(Database.BatchableContext BC, List<sObject> dcList) { |
| | | |
| | | List<Account_Number_of_target__c> upsertList = new List<Account_Number_of_target__c>(); |
| | | //WLIG-BZD684 【委托】H层客户 战略科室 病例数自运行 gwy 2021-03-25 start |
| | | List<Account_Number_of_case__c> insertNextList = new List<Account_Number_of_case__c>(); |
| | |
| | | } |
| | | |
| | | public static List<Account_Number_of_target__c> main(List<sObject> dcList) { |
| | | system.debug('==dcList=='+dcList.size()+'======'+dcList); |
| | | //以战略科室得形式,一次进来1条数据 |
| | | List<Account2__c> acc2List = [select id, |
| | | Account_Org__c, |
| | | Account_Org__r.Department_Class_Label__c, |
| | |
| | | OPD_ESG400__c, |
| | | OPD_TB__c, |
| | | // LHJ End |
| | | //20220602 WLIG-CEWDWS you start |
| | | OPD_TB_0520__c, |
| | | OPD_TB_0535__c, |
| | | //20220602 WLIG-CEWDWS you end |
| | | Opp_Actual_ThousandY__c, |
| | | BO_Forecast_ThousandY__c, |
| | | OP_ThousandY__c, |
| | |
| | | Delivery_cnt_OTVS300__c, |
| | | Delivery_cnt_ESG400__c, |
| | | Delivery_cnt_TB__c, |
| | | //20220602 WLIG-CEWDWS you start |
| | | Delivery_cnt_TB_0520__c, |
| | | Delivery_cnt_TB_0535__c, |
| | | //20220602 WLIG-CEWDWS you end |
| | | Opp_cnt_290MiroBF__c, |
| | | Opp_cnt_290MiroGI__c, |
| | | Opp_cnt_290MiroGI_CF__c, |
| | |
| | | Opp_cnt_OTVS300__c, |
| | | Opp_cnt_ESG400__c, |
| | | Opp_cnt_TB__c, |
| | | //20220602 WLIG-CEWDWS you start |
| | | Opp_cnt_TB_0520__c, |
| | | Opp_cnt_TB_0535__c, |
| | | //20220602 WLIG-CEWDWS you end |
| | | Order_cnt_290MiroBF__c, |
| | | Order_cnt_290MiroGI__c, |
| | | Order_cnt_290MiroGI_CF__c, |
| | |
| | | Order_cnt_OTVS300__c, |
| | | Order_cnt_ESG400__c, |
| | | Order_cnt_TB__c, |
| | | //20220602 WLIG-CEWDWS you start |
| | | Order_cnt_TB_0520__c, |
| | | Order_cnt_TB_0535__c, |
| | | //20220602 WLIG-CEWDWS you end |
| | | Rental_Cnt_290MiroBF__c, |
| | | Rental_Cnt_290MiroGI__c, |
| | | Rental_Cnt_290MiroGI_CF__c, |
| | |
| | | Asset_Cnt_OTVS300__c, |
| | | Asset_Cnt_OTVS400__c, |
| | | Asset_Cnt_TB__c, |
| | | //20220602 WLIG-CEWDWS you start |
| | | Asset_Cnt_TB_0520__c, |
| | | Asset_Cnt_TB_0535__c, |
| | | //20220602 WLIG-CEWDWS you end |
| | | Asset_Cnt_USG400__c, |
| | | //SWAG-C9WCE5 战略科室和目标客户设定页面增加字段 lt 20211228 start |
| | | AllHostsNumber__c, |
| | | RivalHostsNumber__c |
| | | //SWAG-C9WCE5 战略科室和目标客户设定页面增加字段 lt 20211228 end |
| | | //SWAG-BSC5WP you-20201021 start |
| | | //SWAG-BSC5WP you-20201021 end |
| | | //20230222 DB202302339407 you start |
| | | ,LostPrices__c |
| | | ,Dealer_Final_Price__c |
| | | ,HospitalTransactionAmount__c |
| | | //20230222 DB202302339407 you end |
| | | //20230327 DB202303372329 you start |
| | | ,OP_ThousandY_Order__c |
| | | ,OrderThisYearQY__c |
| | | ,Opportunity__c |
| | | //20230327 DB202303372329 you end |
| | | from Account2__c |
| | | where Account_Org__c = :dcList]; |
| | | |
| | | // 2018年7月12日 SWAG-B2D4QK 从Account中获取 提案目标客户等5个字段 by 张玉山 |
| | | list<Account> accs = [select Id, Proposal_target_customer__c, Submit_proposal_document_SD__c, |
| | | Submit_proposal_document__c, Proposal_target_customer_number__c, |
| | |
| | | } |
| | | List<Account_Number_of_target__c> upsertList = new List<Account_Number_of_target__c>(); |
| | | |
| | | //20230224 you start DB202302339407 战略科室其他的统计到普外 |
| | | system.debug('==test0==='+acc2List.size()+'========='+acc2List); |
| | | //Map<String, Account2__c> acc2QTMap = new Map<String, Account2__c>(); |
| | | Map<String, String> acc2QTMap1 = new Map<String, String>(); |
| | | Map<String, String> acc2QTMap2 = new Map<String, String>(); |
| | | for (Account2__c acc1 : acc2List) { |
| | | String dclabel1 = acc1.Account_Org__r.Department_Class_Label__c;//战略科室分类 |
| | | //if(null!= dclabel1 && ''!=dclabel1 && dclabel1=='其他'){ |
| | | // acc2QTMap.put(acc1.Account_Org__r.ParentId, acc1);//只有战略科室是其他的(客户id,客户2) |
| | | // system.debug('==test1==='+acc2QTMap); |
| | | //} |
| | | if(null!= dclabel1 && ''!=dclabel1 && dclabel1=='普外科'){ |
| | | acc2QTMap1.put(acc1.Account_Org__c,acc1.Account_Org__r.ParentId); |
| | | acc2QTMap2.put(acc1.Account_Org__r.ParentId,acc1.Account_Org__c); |
| | | } |
| | | |
| | | } |
| | | system.debug(acc2QTMap1+'===test7===='+acc2QTMap1.values()); |
| | | List<Account2__c> acc3List = [select id, |
| | | Account_Org__c, Account_Org__r.ParentId,LostPrices__c,Dealer_Final_Price__c,HospitalTransactionAmount__c from Account2__c where Account_Org__r.ParentId in :acc2QTMap1.values() and Account_Org__r.Department_Class_Label__c='其他']; |
| | | Map<String, Account2__c> acc2QTMap3 = new Map<String, Account2__c>(); |
| | | for(Account2__c acc3 : acc3List){ |
| | | acc2QTMap3.put(acc2QTMap2.get(acc3.Account_Org__r.ParentId), acc3); |
| | | } |
| | | |
| | | system.debug('==test6==='+acc2QTMap3); |
| | | //20230224 you end DB202302339407 |
| | | for (Account2__c acc2 : acc2List) { |
| | | String dclabel = acc2.Account_Org__r.Department_Class_Label__c;//战略科室分类 |
| | | Account_Number_of_target__c accTar = new Account_Number_of_target__c(); |
| | |
| | | accTar.OPD_amount_GFUCT260__c = acc2.OPD_GFUCT260__c; |
| | | accTar.OPD_amount_OTVS300__c = acc2.OPD_OTV_S300__c; |
| | | accTar.OPD_amount_ESG400__c = acc2.OPD_ESG400__c; |
| | | accTar.OPD_amount_TB__c = acc2.OPD_TB__c; |
| | | //20220602 WLIG-CEWDWS you start |
| | | //accTar.OPD_amount_TB__c = acc2.OPD_TB__c; |
| | | accTar.OPD_amount_TB_0520__c = acc2.OPD_TB_0520__c; |
| | | accTar.OPD_amount_TB_0535__c = acc2.OPD_TB_0535__c; |
| | | //20220602 WLIG-CEWDWS you end |
| | | // 202020604 LHJ SWAG-BQ75WE End |
| | | |
| | | // SWAG-BC832V 从客户2 保存至目标客户:CYF start |
| | |
| | | accTar.Opportunity_ThousandY__c = acc2.Opportunity_ThousandY__c; |
| | | accTar.Amount_Without_Tax_Thousand__c = acc2.Amount_Without_Tax_Thousand__c; |
| | | |
| | | //20230327 DB202303372329 you start |
| | | accTar.OP_ThousandY_Order__c = acc2.OP_ThousandY_Order__c; |
| | | accTar.OrderThisYearQY__c = acc2.OrderThisYearQY__c; |
| | | accTar.Opportunity__c = acc2.Opportunity__c; |
| | | //20230327 DB202303372329 you end |
| | | |
| | | //20220111 SWAG-C8MBB6 加7.询价 lt start |
| | | accTar.AllOP_ThousandY__c = acc2.AllOP_ThousandY__c; |
| | | //20220111 SWAG-C8MBB6 加7.询价 lt end |
| | | |
| | | //20230222 DB202302339407 you start |
| | | accTar.LostPrices__c = acc2.LostPrices__c; |
| | | accTar.Dealer_Final_Price__c = acc2.Dealer_Final_Price__c; |
| | | accTar.HospitalTransactionAmount__c = acc2.HospitalTransactionAmount__c; |
| | | //战略科室其他的统计到普外 |
| | | if(dclabel == '普外科'){ |
| | | |
| | | if(null!=acc2QTMap3 && acc2QTMap3.containsKey(acc2.Account_Org__c)){ |
| | | system.debug('==test3==='+acc2.Dealer_Final_Price__c+'==test3==='+acc2QTMap3.get(acc2.Account_Org__c).Dealer_Final_Price__c); |
| | | //accTar.LostPricesqt__c = acc2.LostPrices__c ==null ? 0 :acc2.LostPrices__c + acc2QTMap3.get(acc2.Account_Org__c).LostPrices__c == null ? 0 : acc2QTMap3.get(acc2.Account_Org__c).LostPrices__c; |
| | | //accTar.Dealer_Final_Priceqt__c = acc2.Dealer_Final_Price__c ==null ? 0 : acc2.Dealer_Final_Price__c + acc2QTMap3.get(acc2.Account_Org__c).Dealer_Final_Price__c ==null ? 0:acc2QTMap3.get(acc2.Account_Org__c).Dealer_Final_Price__c; |
| | | //accTar.HospitalTransactionAmountqt__c = acc2.HospitalTransactionAmount__c ==null ? 0 : acc2.HospitalTransactionAmount__c + acc2QTMap3.get(acc2.Account_Org__c).HospitalTransactionAmount__c ==null ? 0:acc2QTMap3.get(acc2.Account_Org__c).HospitalTransactionAmount__c; |
| | | //accTar.LostPricesqt__c = acc2.LostPrices__c+ acc2QTMap3.get(acc2.Account_Org__c).LostPrices__c; |
| | | //accTar.Dealer_Final_Priceqt__c = acc2.Dealer_Final_Price__c + acc2QTMap3.get(acc2.Account_Org__c).Dealer_Final_Price__c; |
| | | //accTar.HospitalTransactionAmountqt__c = acc2.HospitalTransactionAmount__c + acc2QTMap3.get(acc2.Account_Org__c).HospitalTransactionAmount__c; |
| | | Decimal a1 = acc2.LostPrices__c == null ? 0 : acc2.LostPrices__c; |
| | | Decimal a2 = acc2QTMap3.get(acc2.Account_Org__c).LostPrices__c == null ? 0 : acc2QTMap3.get(acc2.Account_Org__c).LostPrices__c; |
| | | Decimal a3 = acc2.Dealer_Final_Price__c == null ? 0 : acc2.Dealer_Final_Price__c; |
| | | Decimal a4 = acc2QTMap3.get(acc2.Account_Org__c).Dealer_Final_Price__c == null ? 0 : acc2QTMap3.get(acc2.Account_Org__c).Dealer_Final_Price__c; |
| | | Decimal a5 = acc2.HospitalTransactionAmount__c == null ? 0 : acc2.HospitalTransactionAmount__c; |
| | | Decimal a6 = acc2QTMap3.get(acc2.Account_Org__c).HospitalTransactionAmount__c == null ? 0 : acc2QTMap3.get(acc2.Account_Org__c).HospitalTransactionAmount__c; |
| | | accTar.LostPricesqt__c = a1 + a2; |
| | | accTar.Dealer_Final_Priceqt__c = a3 + a4; |
| | | accTar.HospitalTransactionAmountqt__c = a5 +a6; |
| | | |
| | | } |
| | | }else{ |
| | | system.debug('==test4==='+dclabel); |
| | | accTar.LostPricesqt__c = acc2.LostPrices__c; |
| | | accTar.Dealer_Final_Priceqt__c = acc2.Dealer_Final_Price__c; |
| | | accTar.HospitalTransactionAmountqt__c = acc2.HospitalTransactionAmount__c; |
| | | } |
| | | |
| | | //20230222 DB202302339407 you end |
| | | |
| | | // SWAG-BD24SU 发货数备份到目标客户 start |
| | | accTar.Delivery_cnt_3D__c = acc2.Delivery_cnt_3D__c; |
| | | accTar.Delivery_cnt_CYF__c = acc2.Delivery_cnt_CYF__c; |
| | |
| | | accTar.Delivery_cnt_GFUCT260__c = acc2.Delivery_cnt_GFUCT260__c; |
| | | accTar.Delivery_cnt_OTVS300__c = acc2.Delivery_cnt_OTVS300__c; |
| | | accTar.Delivery_cnt_ESG400__c = acc2.Delivery_cnt_ESG400__c; |
| | | accTar.Delivery_cnt_TB__c = acc2.Delivery_cnt_TB__c; |
| | | //20220602 WLIG-CEWDWS you start |
| | | //accTar.Delivery_cnt_TB__c = acc2.Delivery_cnt_TB__c; |
| | | accTar.Delivery_cnt_TB_0520__c = acc2.Delivery_cnt_TB_0520__c; |
| | | accTar.Delivery_cnt_TB_0535__c = acc2.Delivery_cnt_TB_0535__c; |
| | | //20220602 WLIG-CEWDWS you end |
| | | // 202020604 LHJ SWAG-BQ75WE End |
| | | |
| | | accTar.Order_cnt_290Miro__c = acc2.Order_cnt_290Miro__c; |
| | |
| | | accTar.Order_cnt_GFUCT260__c = acc2.Order_cnt_GFUCT260__c; |
| | | accTar.Order_cnt_OTVS300__c = acc2.Order_cnt_OTVS300__c; |
| | | accTar.Order_cnt_ESG400__c = acc2.Order_cnt_ESG400__c; |
| | | accTar.Order_cnt_TB__c = acc2.Order_cnt_TB__c; |
| | | //20220602 WLIG-CEWDWS you start |
| | | //accTar.Order_cnt_TB__c = acc2.Order_cnt_TB__c; |
| | | accTar.Order_cnt_TB_0520__c = acc2.Order_cnt_TB_0520__c; |
| | | accTar.Order_cnt_TB_0535__c = acc2.Order_cnt_TB_0535__c; |
| | | //20220602 WLIG-CEWDWS you end |
| | | // 202020604 LHJ SWAG-BQ75WE End |
| | | accTar.Opp_cnt_3D__c = acc2.Opp_cnt_3D__c; |
| | | accTar.Opp_cnt_CHS400XZ__c = acc2.Opp_cnt_CHS400XZ__c; |
| | |
| | | accTar.Opp_cnt_GFUCT260__c = acc2.Opp_cnt_GFUCT260__c; |
| | | accTar.Opp_cnt_OTVS300__c = acc2.Opp_cnt_OTVS300__c; |
| | | accTar.Opp_cnt_ESG400__c = acc2.Opp_cnt_ESG400__c; |
| | | accTar.Opp_cnt_TB__c = acc2.Opp_cnt_TB__c; |
| | | //20220602 WLIG-CEWDWS you start |
| | | //accTar.Opp_cnt_TB__c = acc2.Opp_cnt_TB__c; |
| | | accTar.Opp_cnt_TB_0520__c = acc2.Opp_cnt_TB_0520__c; |
| | | accTar.Opp_cnt_TB_0535__c = acc2.Opp_cnt_TB_0535__c; |
| | | //20220602 WLIG-CEWDWS you end |
| | | // 202020604 LHJ SWAG-BQ75WE End |
| | | |
| | | //SWAG-C9WCE5 战略科室和目标客户设定页面增加字段 lt 20211228 start |
| | |
| | | accTar.Asset_Cnt_OTVS190__c = acc2.Asset_Cnt_OTVS190__c==0?null:acc2.Asset_Cnt_OTVS190__c; |
| | | accTar.Asset_Cnt_OTVS300__c = acc2.Asset_Cnt_OTVS300__c==0?null:acc2.Asset_Cnt_OTVS300__c; |
| | | accTar.Asset_Cnt_OTVS400__c = acc2.Asset_Cnt_OTVS400__c==0?null:acc2.Asset_Cnt_OTVS400__c; |
| | | accTar.Asset_Cnt_TB__c = acc2.Asset_Cnt_TB__c==0?null:acc2.Asset_Cnt_TB__c; |
| | | //20220602 WLIG-CEWDWS you start |
| | | //accTar.Asset_Cnt_TB__c = acc2.Asset_Cnt_TB__c==0?null:acc2.Asset_Cnt_TB__c; |
| | | accTar.Asset_Cnt_TB_0520__c = acc2.Asset_Cnt_TB_0520__c==0?null:acc2.Asset_Cnt_TB_0520__c; |
| | | accTar.Asset_Cnt_TB_0535__c = acc2.Asset_Cnt_TB_0535__c==0?null:acc2.Asset_Cnt_TB_0535__c; |
| | | //20220602 WLIG-CEWDWS you end |
| | | accTar.Asset_Cnt_USG400__c = acc2.Asset_Cnt_USG400__c==0?null:acc2.Asset_Cnt_USG400__c; |
| | | //SWAG-BSC5WP you-20201021 end |
| | | Date nowDate = Date.today(); |