From 0b831950f1dda4cd12cf1dac4f95753d350347db Mon Sep 17 00:00:00 2001 From: 李彤 <litong@prec-tech.com> Date: 星期三, 08 三月 2023 16:19:21 +0800 Subject: [PATCH] 失单金额 --- force-app/main/default/classes/LostCancelReportOppBatch.cls | 297 ++++++++++++++++++++++++++++--------------------- force-app/main/default/classes/LostCancelReportHandler.cls | 11 + 2 files changed, 181 insertions(+), 127 deletions(-) diff --git a/force-app/main/default/classes/LostCancelReportHandler.cls b/force-app/main/default/classes/LostCancelReportHandler.cls index bfdf8a2..a864cd5 100644 --- a/force-app/main/default/classes/LostCancelReportHandler.cls +++ b/force-app/main/default/classes/LostCancelReportHandler.cls @@ -322,10 +322,19 @@ // } //澶卞崟鎬婚噾棰� //opp.LostPrices__c=lcr.PCLLostBrand__r.Lost_cancel_report__r.LostTotalAmount__c;//20230215 lt DB202302247719 娉ㄩ噴 - opp.LostPrices__c=lcr.PCLLostBrand__r.Lost_cancel_report__r.TotalAmountLost__c; //20230215 lt DB202302247719 + // opp.LostPrices__c=lcr.PCLLostBrand__r.Lost_cancel_report__r.TotalAmountLost__c; //20230215 lt DB202302247719 opp.of_lost_system_processor__c=lcr.PCLLostBrand__r.Lost_cancel_report__r.of_lost_system_processor__c; } } + //20230215 lt DB202302247719 start + if(arrMap.get(lcro).TotalAmountLost__c != null){ + if(opp.LostPrices__c == null){ + opp.LostPrices__c = 0; + } + opp.LostPrices__c+=arrMap.get(lcro).TotalAmountLost__c; + } + //20230215 lt DB202302247719 end + // 20221202 ljh DB202211594688 start System.debug('zheli00:'+oppIdPZSet+'~'+opp.Id); if(oppIdPZSet.contains(opp.Id)){ diff --git a/force-app/main/default/classes/LostCancelReportOppBatch.cls b/force-app/main/default/classes/LostCancelReportOppBatch.cls index 5ea2249..8765955 100644 --- a/force-app/main/default/classes/LostCancelReportOppBatch.cls +++ b/force-app/main/default/classes/LostCancelReportOppBatch.cls @@ -141,160 +141,205 @@ global void execute(Database.BatchableContext BC, List<Lost_cancel_report__c> scope) { // List<String> reportIdList=new List<String>();//20230215 lt DB202302247719 娉ㄩ噴 - Set<String> reportIdList = new Set<String>();//20230215 lt DB202302247719 + Set<String> oppIdList = new Set<String>();//20230215 lt DB202302247719 for (Lost_cancel_report__c report : scope) { // reportIdList.add(report.Id); //20230215 lt DB202302247719 娉ㄩ噴 - reportIdList.add(report.Opportunity__c); //20230215 lt DB202302247719 + oppIdList.add(report.Opportunity__c); //20230215 lt DB202302247719 } - List<PCLLostProduct__c> pclLpList=[select - id, // 澶卞崟鍨嬪彿id - Quantity__c, // 澶卞崟鏁伴噺 - LostProductName__c, // 澶卞崟瀵规墜鍨嬪彿 - LostProductMannual__c, // 澶卞崟瀵规墜鍨嬪彿锛堟墜鍔級 - PCLLostBrand__r.Lost_By_Company__c, // 澶卞崟鍝佺墝 - PCLLostBrand__r.Lost_reason_main__c, // 澶卞崟鍘熷洜锛堜富锛� - PCLLostBrand__r.Lost_Reason_Sub__c, // 澶卞崟鍘熷洜锛堟锛� - PCLLostBrand__r.Lost_By_Company_Mannual__c, // 澶卞崟鍝佺墝锛堟墜鍔級 - PCLLostBrand__r.Agency__r.Name, // 涓爣缁忛攢鍟� - PCLLostBrand__r.AgencyMannual__c, // 涓爣缁忛攢鍟嗭紙鎵嬪姩锛� - PCLLostBrand__r.Lost_cancel_report__r.LostType__c, // 澶卞崟绫诲瀷 - PCLLostBrand__r.Lost_cancel_report__r.LostTotalAmount__c, // 澶卞崟鎬婚噾棰� - PCLLostBrand__r.Lost_cancel_report__r.TotalAmountLost__c, // 澶卞崟鎬婚噾棰濓紙涓嶅惈绋庯級 //20230215 lt DB202302247719 - PCLLostBrand__r.Lost_cancel_report__r.of_lost_system_processor__c, // 澶卞崟涓绘満鍙版暟 - PCLLostBrand__r.Lost_cancel_report__r.Opportunity__c - from - PCLLostProduct__c - where - PCLLostBrand__r.Lost_cancel_report__r.Opportunity__c in :reportIdList]; + //DB202302247719 娉ㄩ噴 lt 娉ㄩ噴鍘熷洜锛欴B202302247719璇鹃鍒峰け鍗曟姤鍛婃暟鎹彧鍒峰け鍗曢噾棰� + // List<PCLLostProduct__c> pclLpList=[select + // id, // 澶卞崟鍨嬪彿id + // Quantity__c, // 澶卞崟鏁伴噺 + // LostProductName__c, // 澶卞崟瀵规墜鍨嬪彿 + // LostProductMannual__c, // 澶卞崟瀵规墜鍨嬪彿锛堟墜鍔級 + // PCLLostBrand__r.Lost_By_Company__c, // 澶卞崟鍝佺墝 + // PCLLostBrand__r.Lost_reason_main__c, // 澶卞崟鍘熷洜锛堜富锛� + // PCLLostBrand__r.Lost_Reason_Sub__c, // 澶卞崟鍘熷洜锛堟锛� + // PCLLostBrand__r.Lost_By_Company_Mannual__c, // 澶卞崟鍝佺墝锛堟墜鍔級 + // PCLLostBrand__r.Agency__r.Name, // 涓爣缁忛攢鍟� + // PCLLostBrand__r.AgencyMannual__c, // 涓爣缁忛攢鍟嗭紙鎵嬪姩锛� + // PCLLostBrand__r.Lost_cancel_report__r.LostType__c, // 澶卞崟绫诲瀷 + // PCLLostBrand__r.Lost_cancel_report__r.LostTotalAmount__c, // 澶卞崟鎬婚噾棰� + // PCLLostBrand__r.Lost_cancel_report__r.TotalAmountLost__c, // 澶卞崟鎬婚噾棰濓紙涓嶅惈绋庯級 //20230215 lt DB202302247719 + // PCLLostBrand__r.Lost_cancel_report__r.of_lost_system_processor__c, // 澶卞崟涓绘満鍙版暟 + // PCLLostBrand__r.Lost_cancel_report__r.Opportunity__c + // from + // PCLLostProduct__c + // where + // PCLLostBrand__r.Lost_cancel_report__r.Opportunity__c in :reportIdList]; //20230215 lt DB202302247719 PCLLostBrand__r.Lost_cancel_report__c ---update--- PCLLostBrand__r.Lost_cancel_report__r.Opportunity__c - - // 鍒濆鍖栦繚瀛樺弬鏁� - Map<String, Opportunity> opp_map = new Map<String, Opportunity>(); - Map<String, String> prod_map = new Map<String, String>(); - Map<String, String> agency_map = new Map<String, String>(); + List<Lost_cancel_report__c> lcrList = [SELECT Id, Opportunity__c, TotalAmountLost__c + FROM Lost_cancel_report__c + WHERE Opportunity__c in :oppIdList]; + //DB202302247719 娉ㄩ噴 lt 娉ㄩ噴鍘熷洜锛欴B202302247719璇鹃鍒峰け鍗曟姤鍛婃暟鎹彧鍒峰け鍗曢噾棰� - // 寰幆鏁寸悊鏁版嵁 - for (PCLLostProduct__c lost : pclLpList) { - // 鍒ゆ柇鏄惁鍙敤鏁版嵁 - // if (String.isBlank(lost.LostProductName__c) && String.isBlank(lost.LostProductMannual__c)) { - // continue; - // } + //DB202302247719 lt start + Map<String, Opportunity> opp_map = new Map<String, Opportunity>(); + + for (Lost_cancel_report__c lcr : lcrList){ // 璇环id - String opp_id = lost.PCLLostBrand__r.Lost_cancel_report__r.Opportunity__c; + String opp_id = lcr.Opportunity__c; + // 璇环 Opportunity opp = opp_map.get(opp_id); if (opp == null) { opp = new Opportunity(); opp.Id = opp_id; - opp.of_lost_system_processor__c = 0; opp_map.put(opp_id, opp); } - //20230215 lt DB202302247719 start - opp.LostPrices__c += lost.PCLLostBrand__r.Lost_cancel_report__r.TotalAmountLost__c; // 澶卞崟閲戦 - - //DB202302247719 娉ㄩ噴 lt 娉ㄩ噴鍘熷洜锛欴B202302247719璇鹃鍒峰け鍗曟姤鍛婃暟鎹彧鍒峰け鍗曢噾棰� - // 璧嬪�� - // opp.LostTypeText__c = lost.PCLLostBrand__r.Lost_cancel_report__r.LostType__c; // 澶卞崟绫诲瀷 - // //opp.LostPrices__c = lost.PCLLostBrand__r.Lost_cancel_report__r.LostTotalAmount__c; // 澶卞崟閲戦 - // opp.Lost_reason_main__c = lost.PCLLostBrand__r.Lost_reason_main__c; // 澶卞崟鍘熷洜锛堜富锛� - // opp.Lost_Reason_Sub__c = lost.PCLLostBrand__r.Lost_Reason_Sub__c; // 澶卞崟鐞嗙敱锛堟锛� - // opp.of_lost_system_processor__c += lost.Quantity__c; // 澶卞崟涓绘満鍙版暟锛堢疮鍔狅級 - - - // 澶卞崟浜у搧123 start - // if (opp.CompetitorProduct1__c == null) { - // opp.CompetitorProduct1__c = lost_product_name(lost.LostProductName__c, lost.LostProductMannual__c); - // }else if (opp.CompetitorProduct2__c == null) { - // opp.CompetitorProduct2__c = lost_product_name(lost.LostProductName__c, lost.LostProductMannual__c); - // }else if (opp.CompetitorProduct3__c == null) { - // opp.CompetitorProduct3__c = lost_product_name(lost.LostProductName__c, lost.LostProductMannual__c); - // } - // 澶卞崟浜у搧123 end - - // 澶卞崟鍝佺墝 - // opp.PCLLostBrands__c = lost_brand_name(opp.PCLLostBrands__c, lost.PCLLostBrand__r.Lost_By_Company__c, lost.PCLLostBrand__r.Lost_By_Company_Mannual__c); - - // 涓爣缁忛攢鍟� - // opp.Agencies__c = lost_agency_name(opp.Agencies__c, lost.PCLLostBrand__r.Agency__r.Name, lost.PCLLostBrand__r.AgencyMannual__c); - //DB202302247719 娉ㄩ噴 lt - //20230215 lt DB202302247719 end + System.debug('---lt123---璇环澶卞崟閲戦---'+opp.LostPrices__c); + System.debug('---lt123---澶卞崟鎬婚噾棰濓紝鍗冨厓涓嶅惈绋�---'+lcr.TotalAmountLost__c); + if(lcr.TotalAmountLost__c != null){ + if(opp.LostPrices__c == null){ + opp.LostPrices__c = 0; + } + opp.LostPrices__c += lcr.TotalAmountLost__c; // 澶卞崟閲戦 + System.debug('---lt123---绱姞鍚庤浠峰け鍗曢噾棰�---'+opp.LostPrices__c); + } } + //DB202302247719 lt end + + //DB202302247719 娉ㄩ噴 lt 娉ㄩ噴鍘熷洜锛欴B202302247719璇鹃鍒峰け鍗曟姤鍛婃暟鎹彧鍒峰け鍗曢噾棰� + // // 鍒濆鍖栦繚瀛樺弬鏁� + // Map<String, Opportunity> opp_map = new Map<String, Opportunity>(); + // Map<String, String> prod_map = new Map<String, String>(); + // Map<String, String> agency_map = new Map<String, String>(); + + // // 寰幆鏁寸悊鏁版嵁 + // for (PCLLostProduct__c lost : pclLpList) { + // // 鍒ゆ柇鏄惁鍙敤鏁版嵁 + // // if (String.isBlank(lost.LostProductName__c) && String.isBlank(lost.LostProductMannual__c)) { + // // continue; + // // } + // // 璇环id + // String opp_id = lost.PCLLostBrand__r.Lost_cancel_report__r.Opportunity__c; + // // 璇环 + // Opportunity opp = opp_map.get(opp_id); + // if (opp == null) { + // opp = new Opportunity(); + // opp.Id = opp_id; + // opp.of_lost_system_processor__c = 0; + // opp_map.put(opp_id, opp); + // } + + // //20230215 lt DB202302247719 start + // System.debug('---lt123---璇环澶卞崟閲戦---'+opp.LostPrices__c); + // System.debug('---lt123---澶卞崟鎬婚噾棰濓紝鍗冨厓涓嶅惈绋�---'+lost.PCLLostBrand__r.Lost_cancel_report__r.TotalAmountLost__c); + + // if(lost.PCLLostBrand__r.Lost_cancel_report__r.TotalAmountLost__c != null){ + // if(opp.LostPrices__c == null){ + // opp.LostPrices__c = 0; + // } + // opp.LostPrices__c += lost.PCLLostBrand__r.Lost_cancel_report__r.TotalAmountLost__c; // 澶卞崟閲戦 + // } + + // //DB202302247719 娉ㄩ噴 lt 娉ㄩ噴鍘熷洜锛欴B202302247719璇鹃鍒峰け鍗曟姤鍛婃暟鎹彧鍒峰け鍗曢噾棰� + // // 璧嬪�� + // // opp.LostTypeText__c = lost.PCLLostBrand__r.Lost_cancel_report__r.LostType__c; // 澶卞崟绫诲瀷 + // // //opp.LostPrices__c = lost.PCLLostBrand__r.Lost_cancel_report__r.LostTotalAmount__c; // 澶卞崟閲戦 + // // opp.Lost_reason_main__c = lost.PCLLostBrand__r.Lost_reason_main__c; // 澶卞崟鍘熷洜锛堜富锛� + // // opp.Lost_Reason_Sub__c = lost.PCLLostBrand__r.Lost_Reason_Sub__c; // 澶卞崟鐞嗙敱锛堟锛� + // // opp.of_lost_system_processor__c += lost.Quantity__c; // 澶卞崟涓绘満鍙版暟锛堢疮鍔狅級 + + + // // 澶卞崟浜у搧123 start + // // if (opp.CompetitorProduct1__c == null) { + // // opp.CompetitorProduct1__c = lost_product_name(lost.LostProductName__c, lost.LostProductMannual__c); + // // }else if (opp.CompetitorProduct2__c == null) { + // // opp.CompetitorProduct2__c = lost_product_name(lost.LostProductName__c, lost.LostProductMannual__c); + // // }else if (opp.CompetitorProduct3__c == null) { + // // opp.CompetitorProduct3__c = lost_product_name(lost.LostProductName__c, lost.LostProductMannual__c); + // // } + // // 澶卞崟浜у搧123 end + + // // 澶卞崟鍝佺墝 + // // opp.PCLLostBrands__c = lost_brand_name(opp.PCLLostBrands__c, lost.PCLLostBrand__r.Lost_By_Company__c, lost.PCLLostBrand__r.Lost_By_Company_Mannual__c); + + // // 涓爣缁忛攢鍟� + // // opp.Agencies__c = lost_agency_name(opp.Agencies__c, lost.PCLLostBrand__r.Agency__r.Name, lost.PCLLostBrand__r.AgencyMannual__c); + // //DB202302247719 娉ㄩ噴 lt + // //20230215 lt DB202302247719 end + + // } + //DB202302247719 娉ㄩ噴 lt 娉ㄩ噴鍘熷洜锛欴B202302247719璇鹃鍒峰け鍗曟姤鍛婃暟鎹彧鍒峰け鍗曢噾棰� System.debug(opp_map); StaticParameter.EscapeOppandStaTrigger = true; //20230215 lt DB202302247719 update opp_map.values(); StaticParameter.EscapeOppandStaTrigger = true; //20230215 lt DB202302247719 } + //DB202302247719 娉ㄩ噴 lt 娉ㄩ噴鍘熷洜锛欴B202302247719璇鹃鍒峰け鍗曟姤鍛婃暟鎹彧鍒峰け鍗曢噾棰� // 澶卞崟瀵规墜鍨嬪彿 - private String lost_product_name(String lost_product, String lost_product_mannual) { - if (String.isBlank(lost_product) && String.isNotBlank(lost_product_mannual)) { - return lost_product_mannual; - } - return lost_product; - } + // private String lost_product_name(String lost_product, String lost_product_mannual) { + // if (String.isBlank(lost_product) && String.isNotBlank(lost_product_mannual)) { + // return lost_product_mannual; + // } + // return lost_product; + // } - // 澶卞崟鍝佺墝 - private String lost_brand_name(String lost_brand_in_opp, String lost_brand, String lost_brand_mannual) { - // 鍒濆鍖栧弬鏁� - String plus = ''; - // 鍒ゆ柇 - // SWAG-CCC6F6 2022-04-22 ssm start - // 璇环涓婇兘鍙樉绀洪�夐」鍒楄〃鐨勫�硷紝涓嶉渶瑕佹墜鍔ㄧ殑鍊� - // if ('鍏朵粬'.equals(lost_brand) && String.isNotBlank(lost_brand_mannual)) { - // plus = lost_brand_mannual; - // } else { - // plus = lost_brand; - // } - plus = lost_brand; - // SWAG-CCC6F6 2022-04-22 ssm end - // 鍒濆鍖栬繑鍥炲�� - if (String.isBlank(lost_brand_in_opp)) { - lost_brand_in_opp = ''; - } - // 鎷兼帴 - if (String.isNotBlank(plus) && !lost_brand_in_opp.contains(plus)) { - // 澧炲姞鍒嗛殧鏍囪瘑 - if (String.isNotBlank(lost_brand_in_opp)) { - lost_brand_in_opp += ','; - } - lost_brand_in_opp += plus; - } - return lost_brand_in_opp; - } + // // 澶卞崟鍝佺墝 + // private String lost_brand_name(String lost_brand_in_opp, String lost_brand, String lost_brand_mannual) { + // // 鍒濆鍖栧弬鏁� + // String plus = ''; + // // 鍒ゆ柇 + // // SWAG-CCC6F6 2022-04-22 ssm start + // // 璇环涓婇兘鍙樉绀洪�夐」鍒楄〃鐨勫�硷紝涓嶉渶瑕佹墜鍔ㄧ殑鍊� + // // if ('鍏朵粬'.equals(lost_brand) && String.isNotBlank(lost_brand_mannual)) { + // // plus = lost_brand_mannual; + // // } else { + // // plus = lost_brand; + // // } + // plus = lost_brand; + // // SWAG-CCC6F6 2022-04-22 ssm end + // // 鍒濆鍖栬繑鍥炲�� + // if (String.isBlank(lost_brand_in_opp)) { + // lost_brand_in_opp = ''; + // } + // // 鎷兼帴 + // if (String.isNotBlank(plus) && !lost_brand_in_opp.contains(plus)) { + // // 澧炲姞鍒嗛殧鏍囪瘑 + // if (String.isNotBlank(lost_brand_in_opp)) { + // lost_brand_in_opp += ','; + // } + // lost_brand_in_opp += plus; + // } + // return lost_brand_in_opp; + // } - // 涓爣缁忛攢鍟� - private String lost_agency_name(String lost_agency_in_opp, String lost_agency, String lost_agency_mannual) { - // 鍒濆鍖栧弬鏁� - String plus = ''; - // 鍒ゆ柇 - // SWAG-CCC6F6 2022-04-22 ssm start - // 璇环涓婇兘鍙樉绀洪�夐」鍒楄〃鐨勫�硷紝涓嶉渶瑕佹墜鍔ㄧ殑鍊� - // if ('瀵规墜缁忛攢鍟�'.equals(lost_agency) && String.isNotBlank(lost_agency_mannual)) { - // plus = lost_agency_mannual; - // } else { - // plus = lost_agency; - // } - plus = lost_agency; - // SWAG-CCC6F6 2022-04-22 ssm end - // 鍒濆鍖栬繑鍥炲�� - if (String.isBlank(lost_agency_in_opp)) { - lost_agency_in_opp = ''; - } - // 鎷兼帴 - if (String.isNotBlank(plus) && !lost_agency_in_opp.contains(plus)) { - // 澧炲姞鍒嗛殧鏍囪瘑 - if (String.isNotBlank(lost_agency_in_opp)) { - lost_agency_in_opp += ','; - } - lost_agency_in_opp += plus; - } - return lost_agency_in_opp; - } + // // 涓爣缁忛攢鍟� + // private String lost_agency_name(String lost_agency_in_opp, String lost_agency, String lost_agency_mannual) { + // // 鍒濆鍖栧弬鏁� + // String plus = ''; + // // 鍒ゆ柇 + // // SWAG-CCC6F6 2022-04-22 ssm start + // // 璇环涓婇兘鍙樉绀洪�夐」鍒楄〃鐨勫�硷紝涓嶉渶瑕佹墜鍔ㄧ殑鍊� + // // if ('瀵规墜缁忛攢鍟�'.equals(lost_agency) && String.isNotBlank(lost_agency_mannual)) { + // // plus = lost_agency_mannual; + // // } else { + // // plus = lost_agency; + // // } + // plus = lost_agency; + // // SWAG-CCC6F6 2022-04-22 ssm end + // // 鍒濆鍖栬繑鍥炲�� + // if (String.isBlank(lost_agency_in_opp)) { + // lost_agency_in_opp = ''; + // } + // // 鎷兼帴 + // if (String.isNotBlank(plus) && !lost_agency_in_opp.contains(plus)) { + // // 澧炲姞鍒嗛殧鏍囪瘑 + // if (String.isNotBlank(lost_agency_in_opp)) { + // lost_agency_in_opp += ','; + // } + // lost_agency_in_opp += plus; + // } + // return lost_agency_in_opp; + // } + //DB202302247719 娉ㄩ噴 lt 娉ㄩ噴鍘熷洜锛欴B202302247719璇鹃鍒峰け鍗曟姤鍛婃暟鎹彧鍒峰け鍗曢噾棰� global void finish(Database.BatchableContext BC) { -- Gitblit v1.9.1