| | |
| | | // FlgStopManufacure(this.newList, this.oldMap); |
| | | //SFDC停止预警 lt 20211015 add end |
| | | FlgStopManufacure(); |
| | | |
| | | } |
| | | |
| | | //SFDC停止预警 lt 20210922 add start |
| | |
| | | |
| | | // SWAG-BHE9GK LHJ 竞争对手产品自动编码 Start |
| | | private void SetCompetitorCode() { |
| | | Boolean SelctFlg = False; |
| | | Boolean SelctFlg = false; |
| | | list<AggregateResult> proList; |
| | | //带量采购修改 start fy |
| | | list<AggregateResult> proListsc; |
| | |
| | | // nObj.Competitor_product_dummy__c=System.Label.ProductRecordTypeID.contains(RecordTypeString); |
| | | // if (nObj.Competitor_product_dummy__c) { |
| | | if (System.Label.ProductRecordTypeID.contains(RecordTypeString)) { |
| | | SelctFlg = True; |
| | | SelctFlg = true; |
| | | } |
| | | //带量采购修改 end fy |
| | | } |
| | | if (SelctFlg) { |
| | | proList = [Select Max(ProductCode) PC From Product2 Where ProductCode Like 'SD%' and ProductCode!='SD999999']; |
| | | 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')); |
| | | } |
| | | // proListsc = [Select Max(ProductCode) PC From Product2 Where ProductCode Like 'SC%']; |
| | | // if (proListsc != null && proListsc.size() > 0) { |
| | | // strPCsc = String.valueof(proListsc[0].get('PC')); |
| | | // } |
| | | List<Product2> lastPro = [ |
| | | SELECT Id, ProductCode |
| | | FROM Product2 |
| | | WHERE ProductCode LIKE 'SC%' |
| | | ORDER BY ProductCode DESC |
| | | LIMIT 1 |
| | | ]; |
| | | strPCsc = lastPro != null && lastPro.size() > 0 ? lastPro[0].ProductCode : ''; |
| | | //带量采购 end fy |
| | | } |
| | | for (Product2 nObj : newList) { |
| | |
| | | } |
| | | // SWAG-BHE9GK LHJ 竞争对手产品自动编码 End |
| | | |
| | | |
| | | //WLIG-CKKA4M xxf 【委托】【产品主数据】注册证更新后部分字段信息未自动代入 Start |
| | | private void AutomaticallyBringData() { |
| | | List<String> noNewList = new List<String>(); |
| | |
| | | } |
| | | } |
| | | 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]; |
| | | 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; |
| | | } |
| | |
| | | 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) {//市场保修对象 |
| | | 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){//服务保修对象 |
| | | 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;//市场保修开始日 |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | // WLIG-CKKA4M xxf 【委托】【产品主数据】注册证更新后部分字段信息未自动代入 end |
| | | |
| | | private void beforeSetValue() { |
| | | |
| | | for (Product2 nObj : newList) { |
| | | //CHAN-B8GCBB |
| | | if (nObj.WhiteSpace__c == true) { |
| | |
| | | |
| | | nObj.Fixture_Model_No_T__c = nObj.Fixture_Model_No_F__c; |
| | | // CBPR LHJ |
| | | if (Trigger.isInsert || |
| | | (Trigger.isUpdate && nObj.SFDA_Status_New__c != oldMap.get(nObj.id).SFDA_Status_New__c)) { |
| | | if (Trigger.isInsert || (Trigger.isUpdate && nObj.SFDA_Status_New__c != oldMap.get(nObj.id).SFDA_Status_New__c)) { |
| | | nObj.SFDA_Status__c = nobj.SFDA_Status_New__c; |
| | | if (nobj.SFDA_Status_New__c == '新製品申請中' || nobj.SFDA_Status_New__c == '準備中') { |
| | | nObj.SFDA_Status__c = '停止'; |
| | |
| | | |
| | | // SWAG-BHE9GK LHJ 竞争对手产品自动编码 Start |
| | | if (Trigger.isInsert) { |
| | | |
| | | } |
| | | // SWAG-BHE9GK LHJ 竞争对手产品自动编码 End |
| | | } |
| | |
| | | |
| | | //SFDC停止预警 lt 20210914 add start |
| | | private static void Calculate_AverageMonthSales(List<Product2> newList,Map<Id, Product2> oldMap){ |
| | | |
| | | //符合条件的 旧 产品List |
| | | List<Id> oproList = new List<Id>(); |
| | | //符合条件的 新旧 产品Id List 作为条件 |
| | |
| | | System.debug('标识'+term.CalMonthSalesFLG__c); |
| | | System.debug('新库存'+term.StorageStatusNo__c); |
| | | System.debug('旧库存'+oldMap.get(term.Id).StorageStatusNo__c); |
| | | if(term.M_BC_Stop_manufacure__c != null && term.SFDA_Status__c != '停止' && (term.StorageStatusNo__c != oldMap.get(term.Id).StorageStatusNo__c || term.CalMonthSalesFLG__c == true)){ |
| | | if ( |
| | | term.M_BC_Stop_manufacure__c != null && |
| | | term.SFDA_Status__c != '停止' && |
| | | (term.StorageStatusNo__c != oldMap.get(term.Id).StorageStatusNo__c || |
| | | term.CalMonthSalesFLG__c == true) |
| | | ) { |
| | | if(term.Correspond_Code__c != null){ |
| | | matMap.put((String)term.Id,(String)term.Correspond_Code__c); |
| | | conList.add(term.Correspond_Code__c); |
| | |
| | | Map<String,List<ProductMonthlySales__c>> msMap = new Map<String,List<ProductMonthlySales__c>>(); |
| | | |
| | | if(conList.size()>0){ |
| | | List<ProductMonthlySales__c> msList = [Select Id, MonthSales__c, CurrentMonth__c, CurrentDate__c, |
| | | CurrentYear__c, ProductM__c, Product2Model__c, |
| | | List<ProductMonthlySales__c> msList = [ |
| | | SELECT |
| | | Id, |
| | | MonthSales__c, |
| | | CurrentMonth__c, |
| | | CurrentDate__c, |
| | | CurrentYear__c, |
| | | ProductM__c, |
| | | Product2Model__c, |
| | | ProductM__r.StorageStatusNo__c, |
| | | ProductM__r.M_BC_Stop_manufacure__c |
| | | From ProductMonthlySales__c |
| | | Where ProductM__c in: conList |
| | | Order by CurrentDate__c DESC]; |
| | | FROM ProductMonthlySales__c |
| | | WHERE ProductM__c IN :conList |
| | | ORDER BY CurrentDate__c DESC |
| | | ]; |
| | | //双层循环 产品==>月销量 |
| | | for(Id pro : conList){ |
| | | for(ProductMonthlySales__c mms : msList){ |
| | |
| | | msMap.put(pro, pmsaleList); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | if(msMap.size() > 0){ |
| | | System.debug('产品月销量msMap为'+msMap); |
| | | for(Id res : oproList){ |
| | | |
| | | //a旧 月销量和 ; b新 月销量和 ; c商(平均月销量) ; x商四舍五入 ; |
| | | //y 库存/平均月销量天数 ; z 天数 四舍五入 |
| | | Decimal c = 0, y = 0; |
| | |
| | | b += msMap.get(matMap.get(res))[i].MonthSales__c; |
| | | System.debug('新的大于十二'+b); |
| | | } |
| | | } |
| | | else{ |
| | | } else { |
| | | for(ProductMonthlySales__c nms : msMap.get(matMap.get(res))){ |
| | | b+=nms.MonthSales__c; |
| | | System.debug('新的小于十二遍历全部'+b); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | System.debug('旧'+a); |
| | | System.debug('除法足c'+c); |
| | | System.debug('四舍五入x'+x); |
| | | |
| | | } |
| | | //月销量不足12个月 |
| | | else{ |
| | |
| | | zMap.put(res,z); |
| | | System.debug('天数y'+y); |
| | | System.debug('四舍五入z'+z); |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | update finList; |
| | | } |
| | | |
| | | } |
| | | //SFDC停止预警 lt 20210914 add end |
| | | |
| | |
| | | //SFDC停止预警 lt 20211015 add end |
| | | private void FlgStopManufacure(){ |
| | | for(Product2 pts : newList){ |
| | | |
| | | Product2 oldPts = oldMap.get(pts.Id); |
| | | |
| | | if(pts.M_BC_Stop_manufacure__c != oldPts.M_BC_Stop_manufacure__c){ |
| | |
| | | List<PCLLostProduct__c> updateplpList = new List<PCLLostProduct__c>(); |
| | | |
| | | for(Product2 pro : newList){ |
| | | if(pro.RecordTypeId == System.Label.Pro_RecordType && |
| | | 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)){ |
| | | 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 ]; |
| | | 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 = '主机'; |
| | |
| | | } |
| | | |
| | | update updateplpList; |
| | | |
| | | } |
| | | //20230506 lt DB202304618804 包含超声 end |
| | | |
| | | } |