From 02ddc35714cbd1688b7cb057f770f1410de79dab Mon Sep 17 00:00:00 2001
From: buli <137736985@qq.com>
Date: 星期五, 11 三月 2022 12:19:33 +0800
Subject: [PATCH] PIPL Updated Code 20220311
---
force-app/main/default/triggers/NFM007.trigger | 72 +++++++++++++++++++++++++++---------
1 files changed, 54 insertions(+), 18 deletions(-)
diff --git a/force-app/main/default/triggers/NFM007.trigger b/force-app/main/default/triggers/NFM007.trigger
index 550b86f..d49fe61 100644
--- a/force-app/main/default/triggers/NFM007.trigger
+++ b/force-app/main/default/triggers/NFM007.trigger
@@ -57,6 +57,9 @@
Id,
SFDA_Status__c,
PricebookEntry.Product2Id
+ //lastbuy 2022/2/9 fy start
+ ,Asset_Model_No__c
+ //lastbuy 2022/2/9 fy end
// CHAN-BTF4XQ start
// 棰濆妫�绱骇鍝佹爣鍑嗗畾浠峰拰浜у搧鎴愭湰
,Product_Cost__c,Product_ListPrice__c,Quantity__c
@@ -77,7 +80,16 @@
}
// CHAN-BTF4XQ end
//lastbuy 2022/2/9 fy start
- quotlinitMap.put(qli.PricebookEntry.Product2Id,qli);
+ if(qli.PricebookEntry.Product2Id!=null){
+ if(quotlinitMap.containsKey(qli.PricebookEntry.Product2Id)){
+ QuoteLineItem quoteLine = quotlinitMap.get(qli.PricebookEntry.Product2Id);
+ quoteLine.Quantity__c +=qli.Quantity__c;
+ quotlinitMap.put(qli.PricebookEntry.Product2Id,quoteLine);
+ }else{
+ quotlinitMap.put(qli.PricebookEntry.Product2Id,qli);
+ }
+ }
+ // quotlinitMap.put(qli.PricebookEntry.Product2Id,qli);
//lastbuy 2022/2/9 fy end
}
if( CntCostOrListPrice > 0){
@@ -86,7 +98,9 @@
//CHAN-BWH2YW 20201221 you 鍔� 瀛楁 Correspond_Code__r start
//lastbuy 2022/2/9 fy
//鏂板棰勭暀浜у搧瀛楁LastbuyProductFLG__c
- List<String> lastProductFLGList= new List<String>();
+ List<String> lastProductFLGIdList= new List<String>();
+ List<Product2> lastProductFLGList = new List<Product2>();
+ List<Product2> lastProductFLGListtest = new List<Product2>();
for (Product2 prd2: [Select Id,LastbuyProductFLG__c, Estimation_Entry_Possibility__c, SFDA_Status__c,Packing_list_manual__c,Correspond_Code__r.Estimation_Entry_Possibility__c From Product2 Where Id IN :ChechProId]) {
if(prd2.Estimation_Entry_Possibility__c != '鈼�'){
@@ -97,34 +111,56 @@
}
//CHAN-BWH2YW 20201221 you 鍔� 瀛楁 Correspond_Code__r end
}
+ lastProductFLGListtest.add(prd2);
//lastbuy 2022/2/9 fy start
if(prd2.LastbuyProductFLG__c){
- lastProductFLGList.add(prd2.Id);
+ lastProductFLGIdList.add(prd2.Id);
+ lastProductFLGList.add(prd2);
}
//lastbuy 2022/2/9 fy end
}
//lastbuy 2022/2/9 fy start
List<LastbuyProduct__c> upLastbuyObjList = new List<LastbuyProduct__c>();
- if(lastProductFLGList!=null){
- List<LastbuyProduct__c> LastbuyObjList=[select id,LastbuyQuantity__c,InquiryCode__c,ProductName__c from LastbuyProduct__c where InquiryCode__c= : opp.Id and ProductName__c in :lastProductFLGList];
- if(LastbuyObjList!=null){
+ if(lastProductFLGIdList!=null && lastProductFLGIdList.size() !=0){
+ List<LastbuyProduct__c> LastbuyObjList=[select id,LastbuyQuantity__c,InquiryCode__c,ProductName__c,effectiveFLG__c from LastbuyProduct__c where InquiryCode__c= : opp.Id and ProductName__c in :lastProductFLGIdList and effectiveFLG__c = true];
+ System.debug('bbbbbbbbbbbbbbb==='+lastProductFLGIdList);
+ Map<string,LastbuyProduct__c> LastbuyObjMap = new Map<string,LastbuyProduct__c>();
+ if(LastbuyObjList!=null&&LastbuyObjList.size()!=0){
for(LastbuyProduct__c lastbuypr :LastbuyObjList){
- Decimal quoteLItemNum=0;
- if(quotlinitMap.containsKey(lastbuypr.ProductName__c)){
- quoteLItemNum=quotlinitMap.get(lastbuypr.ProductName__c).Quantity__c;
- }else{
- continue;
+ LastbuyObjMap.put(lastbuypr.ProductName__c,lastbuypr);
+ }
+ System.debug('fffffffffffffff==='+LastbuyObjList);
+ if(lastProductFLGList!=null && lastProductFLGList.size() !=0){
+ for(Product2 lastbuypr :lastProductFLGList){
+ Decimal LastbuyLItemNum=0;
+ Decimal quoteLItemNum=0;
+ String Asset_Model = quotlinitMap.get(lastbuypr.Id).Asset_Model_No__c;
+ if(LastbuyObjMap.containsKey(lastbuypr.Id)){
+ LastbuyProduct__c lastbuyobj = LastbuyObjMap.get(lastbuypr.Id);
+ if(quotlinitMap.containsKey(lastbuypr.Id)){
+ LastbuyLItemNum=LastbuyObjMap.get(lastbuypr.Id).LastbuyQuantity__c;
+ quoteLItemNum=quotlinitMap.get(lastbuypr.Id).Quantity__c;
+ if(quoteLItemNum>LastbuyLItemNum){
+ opp.addError(Asset_Model+'浜у搧鏁伴噺涓嶅彲瓒呰繃浜у搧棰勭暀鏁伴噺');
+ }else{
+ lastbuyobj.ActualQuantity__c=quoteLItemNum;
+ lastbuyobj.effectiveFLG__c=false;
+ upLastbuyObjList.add(lastbuyobj);
+ }
+ }
+ }else{
+ opp.addError('棰勭暀浜у搧'+Asset_Model+'鏈綍鍏ラ鐣欎骇鍝佽〃');
+ System.debug('asdasdfasdfadsf閿欒鎻愮ず');
+ }
+ System.debug('cccccccccccccc==='+lastbuypr);
}
- if(lastbuypr.LastbuyQuantity__c<quoteLItemNum){
- opp.addError('浜у搧鏁伴噺涓嶅彲瓒呰繃浜у搧棰勭暀鏁伴噺');
- }else{
- lastbuypr.ActualQuantity__c=quoteLItemNum;
- upLastbuyObjList.add(lastbuypr);
- }
+ System.debug('aaaaaaaaaaaaaa==='+LastbuyObjList);
+
}
}else{
- opp.addError('棰勭暀琛ㄤ腑杩樻病鏈夋暟鎹�');
+ opp.addError('棰勭暀浜у搧琛ㄤ腑娌℃湁褰曞叆璇ヨ浠风殑棰勭暀浜у搧');
}
+
}
System.debug('upLastbuyObjList==='+upLastbuyObjList);
if(upLastbuyObjList!=null){
--
Gitblit v1.9.1