| | |
| | | // SWAG-BHE9GK LHJ 竞争对手产品自动编码 Start |
| | | SetCompetitorCode(); |
| | | // SWAG-BHE9GK LHJ 竞争对手产品自动编码 End |
| | | // WLIG-CKKA4M xxf 【委托】【产品主数据】注册证更新后部分字段信息未自动代入 Start |
| | | AutomaticallyBringData(); |
| | | // WLIG-CKKA4M xxf 【委托】【产品主数据】注册证更新后部分字段信息未自动代入 End |
| | | } |
| | | protected override void beforeUpdate() { |
| | | beforeSetValue(); |
| | |
| | | //SFDC停止预警 lt 20210922 add start |
| | | protected override void afterUpdate(){ |
| | | Calculate_AverageMonthSales(this.newList, this.oldMap); |
| | | AssignmentUltrasonic(this.newList, this.oldMap); //20230506 lt DB202304618804 包含超声 add |
| | | } |
| | | //SFDC停止预警 lt 20210922 add end |
| | | |
| | |
| | | private void SetCompetitorCode() { |
| | | Boolean SelctFlg = False; |
| | | list<AggregateResult> proList; |
| | | //带量采购修改 start fy |
| | | list<AggregateResult> proListsc; |
| | | //带量采购修改 end fy |
| | | String strPC = ''; |
| | | //带量采购修改 start fy |
| | | String strPCsc = ''; |
| | | //带量采购修改 end fy |
| | | Integer i = 1; |
| | | |
| | | String ProductRecordTypes = System.Label.ProductRecordTypeID; |
| | | String[] RecordTypes = String.isNotBlank(ProductRecordTypes) ? ProductRecordTypes.split(',') : null; |
| | | |
| | | for (Product2 nObj : newList) { |
| | | if (nObj.Competitor_product_dummy__c) { |
| | | //带量采购修改 start fy |
| | | String RecordTypeString = ''; |
| | | if(nObj.RecordTypeId!=null){ |
| | | RecordTypeString=String.valueof(nObj.RecordTypeId).substring(0,15); |
| | | } |
| | | // nObj.Competitor_product_dummy__c=System.Label.ProductRecordTypeID.contains(RecordTypeString); |
| | | // if (nObj.Competitor_product_dummy__c) { |
| | | if (System.Label.ProductRecordTypeID.contains(RecordTypeString)) { |
| | | SelctFlg = True; |
| | | } |
| | | //带量采购修改 end fy |
| | | } |
| | | if (SelctFlg) { |
| | | proList = [Select Max(ProductCode) PC From Product2 Where ProductCode Like 'SD%']; |
| | | proList = [Select Max(ProductCode) PC From Product2 Where ProductCode Like 'SD%' and ProductCode!='SD999999']; |
| | | if (proList != null && proList.size() > 0) { |
| | | strPC = String.valueof(proList[0].get('PC')); |
| | | } |
| | | //带量采购 start fy |
| | | proListsc = [Select Max(ProductCode) PC From Product2 Where ProductCode Like 'SC%']; |
| | | if (proListsc != null && proListsc.size() > 0) { |
| | | strPCsc = String.valueof(proListsc[0].get('PC')); |
| | | } |
| | | //带量采购 end fy |
| | | } |
| | | for (Product2 nObj : newList) { |
| | | if (nObj.Competitor_product_dummy__c && strPC.length() == 8 |
| | | && proList != null && proList.size() > 0 ) { |
| | | Integer num = Integer.valueOf(strPC.SubString(2,strPC.length())) + i; |
| | | nObj.ProductCode = 'SD' + String.valueOf(num).leftpad(6,'0'); |
| | | //带量采购 start fy |
| | | String RecordTypeString = ''; |
| | | if(nObj.RecordTypeId!=null){ |
| | | RecordTypeString=String.valueof(nObj.RecordTypeId).substring(0,15); |
| | | } |
| | | // if (nObj.Competitor_product_dummy__c && strPC.length() == 8 |
| | | // if (System.Label.ProductRecordTypeID.contains(RecordTypeString) && strPC.length() == 8 |
| | | if (System.Label.ProductRecordTypeID.contains(RecordTypeString)) { |
| | | //带量采购 end fy |
| | | // && proList != null && proList.size() > 0 ) { |
| | | // Integer num = Integer.valueOf(strPC.SubString(2,strPC.length())) + i; |
| | | Integer num = String.isNotBlank(strPC) ? Integer.valueOf(strPC.SubString(2,strPC.length())) + i : i; |
| | | //带量采购 start fy |
| | | Integer numsc = String.isNotBlank(strPCsc) ? Integer.valueOf(strPCsc.SubString(2,strPCsc.length())) + i : i; |
| | | // if(RecordTypeString=='0129D000001NacC'){ |
| | | if(RecordTypes != null && RecordTypes.size() > 1 && RecordTypeString == RecordTypes[1]){ |
| | | nObj.ProductCode = 'SC' + String.valueOf(numsc).leftpad(8,'0'); |
| | | }else{ |
| | | nObj.ProductCode = 'SD' + String.valueOf(num).leftpad(6,'0'); |
| | | } |
| | | //带量采购 end fy |
| | | // nObj.ProductCode = 'SD' + String.valueOf(num).leftpad(6,'0'); |
| | | i++; |
| | | } |
| | | } |
| | | } |
| | | // SWAG-BHE9GK LHJ 竞争对手产品自动编码 End |
| | | |
| | | |
| | | //WLIG-CKKA4M xxf 【委托】【产品主数据】注册证更新后部分字段信息未自动代入 Start |
| | | private void AutomaticallyBringData() { |
| | | List<String> noNewList = new List<String>(); |
| | | for(Product2 prd : newList){ |
| | | if (prd.Asset_Model_No__c != null) { |
| | | noNewList.add(prd.Asset_Model_No__c); |
| | | } |
| | | } |
| | | if (!noNewList.isEmpty()) { |
| | | |
| | | List<Product2> prdList = [select Id, Name,Asset_Model_No__c,MDM_Name__c, |
| | | Maintenance_Price_Year__c,Extend_new_product_gurantee_MD__c, |
| | | Extend_Gurantee_Start_MD__c,Extend_Gurantee_End_MD__c, |
| | | Entend_gurantee_period_MD__c,Extend_new_product_gurantee__c, |
| | | Extend_Gurantee_Start__c,Extend_Gurantee_End__c,Entend_gurantee_period__c, |
| | | CanNotCancelledGurantee__c,Service_Category1__c, |
| | | Service_Category2__c,Service_Category3__c, |
| | | Service_Category4__c,Service_Category5__c, |
| | | Service_Category6__c,Service_Category7__c, |
| | | Can_Repair__c,RepairListPriceLevelA__c, |
| | | RepairListPriceLevelB__c,RepairListPriceLevelC__c, |
| | | PartSupplyFinishDate__c,EndSaleDate__c,ProductClass__c,ProductCategory__c, |
| | | Period_Filter_Classify1__c,Period_Filter_Classify2__c,Period_Filter_Classify3__c, |
| | | Intra_Trade_Service_RMB_Date1__c,Intra_Trade_Service_RMB_Date2__c, |
| | | Intra_Trade_Service_RMB_EndDate1__c,Intra_Trade_Service_RMB_EndDate2__c, |
| | | Intra_Trade_Service_RMB_1__c,Intra_Trade_Service_RMB_2__c |
| | | from Product2 |
| | | where Asset_Model_No__c in :noNewList |
| | | order by CreatedDate desc]; |
| | | if (prdList.isEmpty()) { |
| | | return; |
| | | } |
| | | Map<String, Product2> prdMap = new Map<String, Product2>(); |
| | | for (Product2 pro2 : prdList) { |
| | | if (!prdMap.isEmpty() && prdMap.containskey(pro2.Asset_Model_No__c)) { |
| | | } else { |
| | | prdMap.put(pro2.Asset_Model_No__c, pro2); |
| | | } |
| | | } |
| | | |
| | | for(Product2 prd : newList){ |
| | | if (prdMap.containskey(prd.Asset_Model_No__c)){ |
| | | prd.Maintenance_Price_Year__c = prdMap.get(prd.Asset_Model_No__c).Maintenance_Price_Year__c;//维修合同报价 |
| | | prd.CanNotCancelledGurantee__c = prdMap.get(prd.Asset_Model_No__c).CanNotCancelledGurantee__c;//不可取消多年保修 |
| | | prd.ProductClass__c = prdMap.get(prd.Asset_Model_No__c).ProductClass__c;//市场产品类别 |
| | | prd.ProductCategory__c = prdMap.get(prd.Asset_Model_No__c).ProductCategory__c;//市场区分 |
| | | prd.Extend_new_product_gurantee_MD__c = prdMap.get(prd.Asset_Model_No__c).Extend_new_product_gurantee_MD__c;//市场保修对象 |
| | | prd.Extend_new_product_gurantee__c = prdMap.get(prd.Asset_Model_No__c).Extend_new_product_gurantee__c;//服务保修对象 |
| | | if (prdMap.get(prd.Asset_Model_No__c).Extend_new_product_gurantee_MD__c == true) {//市场保修对象 |
| | | prd.Entend_gurantee_period_MD__c = prdMap.get(prd.Asset_Model_No__c).Entend_gurantee_period_MD__c;//市场保修期(年) |
| | | } |
| | | if(prdMap.get(prd.Asset_Model_No__c).Extend_new_product_gurantee__c == true){//服务保修对象 |
| | | prd.Entend_gurantee_period__c = prdMap.get(prd.Asset_Model_No__c).Entend_gurantee_period__c;//服务保修期(年) |
| | | } |
| | | prd.Extend_Gurantee_Start_MD__c = prdMap.get(prd.Asset_Model_No__c).Extend_Gurantee_Start_MD__c;//市场保修开始日 |
| | | prd.Extend_Gurantee_End_MD__c = prdMap.get(prd.Asset_Model_No__c).Extend_Gurantee_End_MD__c;//市场保修结束日 |
| | | prd.Extend_Gurantee_Start__c = prdMap.get(prd.Asset_Model_No__c).Extend_Gurantee_Start__c;//服务保修开始日 |
| | | prd.Extend_Gurantee_End__c = prdMap.get(prd.Asset_Model_No__c).Extend_Gurantee_End__c;//服务保修结束日 |
| | | prd.Service_Category1__c = prdMap.get(prd.Asset_Model_No__c).Service_Category1__c;//第1服务分类 |
| | | prd.Service_Category2__c = prdMap.get(prd.Asset_Model_No__c).Service_Category2__c; |
| | | prd.Service_Category3__c = prdMap.get(prd.Asset_Model_No__c).Service_Category3__c; |
| | | prd.Service_Category4__c = prdMap.get(prd.Asset_Model_No__c).Service_Category4__c; |
| | | prd.Service_Category5__c = prdMap.get(prd.Asset_Model_No__c).Service_Category5__c; |
| | | prd.Service_Category6__c = prdMap.get(prd.Asset_Model_No__c).Service_Category6__c; |
| | | prd.Service_Category7__c = prdMap.get(prd.Asset_Model_No__c).Service_Category7__c; |
| | | prd.Can_Repair__c = prdMap.get(prd.Asset_Model_No__c).Can_Repair__c;//是否可维修 |
| | | prd.RepairListPriceLevelA__c = prdMap.get(prd.Asset_Model_No__c).RepairListPriceLevelA__c;//A(W)级维修参考价格 |
| | | prd.RepairListPriceLevelB__c = prdMap.get(prd.Asset_Model_No__c).RepairListPriceLevelB__c; |
| | | prd.RepairListPriceLevelC__c = prdMap.get(prd.Asset_Model_No__c).RepairListPriceLevelC__c; |
| | | prd.PartSupplyFinishDate__c = prdMap.get(prd.Asset_Model_No__c).PartSupplyFinishDate__c;//零件停止供应日期 |
| | | prd.EndSaleDate__c = prdMap.get(prd.Asset_Model_No__c).EndSaleDate__c;//停止销售日期 |
| | | prd.Period_Filter_Classify1__c = prdMap.get(prd.Asset_Model_No__c).Period_Filter_Classify1__c;//营业统计分类1 |
| | | prd.Period_Filter_Classify2__c = prdMap.get(prd.Asset_Model_No__c).Period_Filter_Classify2__c;//营业统计分类2 |
| | | prd.Period_Filter_Classify3__c = prdMap.get(prd.Asset_Model_No__c).Period_Filter_Classify3__c;//营业统计分类3 |
| | | prd.Intra_Trade_Service_RMB_Date1__c = prdMap.get(prd.Asset_Model_No__c).Intra_Trade_Service_RMB_Date1__c;//多年保价格有效开始日1 |
| | | prd.Intra_Trade_Service_RMB_Date2__c = prdMap.get(prd.Asset_Model_No__c).Intra_Trade_Service_RMB_Date2__c;//多年保价格有效开始日2 |
| | | prd.Intra_Trade_Service_RMB_EndDate1__c = prdMap.get(prd.Asset_Model_No__c).Intra_Trade_Service_RMB_EndDate1__c;//多年保价格有效结束日1 |
| | | prd.Intra_Trade_Service_RMB_EndDate2__c = prdMap.get(prd.Asset_Model_No__c).Intra_Trade_Service_RMB_EndDate2__c;//多年保价格有效结束日2 |
| | | prd.Intra_Trade_Service_RMB_1__c = prdMap.get(prd.Asset_Model_No__c).Intra_Trade_Service_RMB_1__c;//多年保价格1 |
| | | prd.Intra_Trade_Service_RMB_2__c = prdMap.get(prd.Asset_Model_No__c).Intra_Trade_Service_RMB_2__c;//多年保价格2 |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | // WLIG-CKKA4M xxf 【委托】【产品主数据】注册证更新后部分字段信息未自动代入 end |
| | | |
| | | private void beforeSetValue() { |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | //20230506 lt DB202304618804 包含超声 start |
| | | private static void AssignmentUltrasonic(List<Product2> newList,Map<Id, Product2> oldMap){ |
| | | List<String> proIdList = new List<String>(); |
| | | List<PCLLostProduct__c> updateplpList = new List<PCLLostProduct__c>(); |
| | | |
| | | for(Product2 pro : newList){ |
| | | if(pro.RecordTypeId == System.Label.Pro_RecordType && |
| | | (pro.Lost_Product_Differ__c != oldMap.get(pro.Id).Lost_Product_Differ__c || |
| | | pro.Lost_Product_Category__c != oldMap.get(pro.Id).Lost_Product_Category__c)){ |
| | | proIdList.add(pro.Id); |
| | | } |
| | | } |
| | | |
| | | List<PCLLostProduct__c> plpList = [Select Id, LostProduct__c, ProductClass__c, ProductCategory__c |
| | | From PCLLostProduct__c |
| | | Where LostProduct__c in: proIdList ]; |
| | | if(plpList.size() > 0 ){ |
| | | for(PCLLostProduct__c plp : plpList){ |
| | | plp.ProductClass__c = '主机'; |
| | | plp.ProductCategory__c = '超声主机'; |
| | | updateplpList.add(plp); |
| | | } |
| | | } |
| | | |
| | | update updateplpList; |
| | | |
| | | } |
| | | //20230506 lt DB202304618804 包含超声 end |
| | | |
| | | } |