From 1312ba82d4c880bdb5357d28e0d4af5b285f610f Mon Sep 17 00:00:00 2001
From: 高章伟 <gaozhangwei@prec-tech.com>
Date: 星期四, 10 三月 2022 15:54:39 +0800
Subject: [PATCH] 最近一月修改内容

---
 force-app/main/default/classes/NewQuoteEntryController.cls |  118 +++++++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 94 insertions(+), 24 deletions(-)

diff --git a/force-app/main/default/classes/NewQuoteEntryController.cls b/force-app/main/default/classes/NewQuoteEntryController.cls
index 2547ecc..9228377 100644
--- a/force-app/main/default/classes/NewQuoteEntryController.cls
+++ b/force-app/main/default/classes/NewQuoteEntryController.cls
@@ -11,6 +11,8 @@
   //public Id qlistId { get; set; }
   //lastbuy  2022/2/9 fy start
   public Boolean filg { get; set; }
+  public Integer flglastbuy { get; set; }
+  public String errorProductmodel { get; set; }
   //lastbuy  2022/2/9 fy end
 
   public String excel_text { get; set; }
@@ -406,6 +408,8 @@
          ,PricebookEntry.Product2.Intra_Trade_Foreign_RMB__c
          //NoDiscount 閲戦锛圲SD锛�
          ,PricebookEntry.Product2.NoDiscount_Foreign__c 
+         //fy 棰勭暀浜у搧鏍囪瘑
+         ,PricebookEntry.Product2.LastbuyProductFLG__c
          ,Quote.Opportunity.Trade__c 
          //澶栬锤澶氬勾淇� 2021/01/04 绮剧悽鎶�鏈� wql end
 
@@ -902,6 +906,8 @@
                                //澶栬锤澶氬勾淇� 2021/01/04 绮剧悽鎶�鏈� wql start
                                //缁翠慨鍚堝悓鎶ヤ环锛圲SD锛�
                                ,Repair_Contract_USD__c
+                               //fy 棰勭暀浜у搧鏍囪瘑
+                               ,LastbuyProductFLG__c
                                //璁℃彁閲戦锛堜笉鍚◣锛孶SD锛�
                                ,Intra_Trade_Foreign_RMB__c
                                //NoDiscount 閲戦锛圲SD锛�
@@ -1781,9 +1787,20 @@
       errormessage = null;
       //20220214 fy lastbuy start 
       if(!ReservedProductVerification()){
-        errorflg = true;
-        errormessage =  '浜у搧鏁伴噺涓嶅彲瓒呰繃浜у搧棰勭暀鏁伴噺' ;
-        return null;
+        system.debug('flglastbuy++++'+flglastbuy);
+        if(flglastbuy==1){
+          errorflg = true;
+          errormessage =  '棰勭暀浜у搧琛ㄤ腑娌℃湁褰曞叆璇ユ姤浠风殑棰勭暀浜у搧' ;
+          return null;
+        }else if(flglastbuy==2){
+          errorflg = true;
+          errormessage =  errorProductmodel+'浜у搧鏁伴噺涓嶅彲瓒呰繃浜у搧棰勭暀鏁伴噺' ;
+          return null;
+        }else if(flglastbuy==3){
+          errorflg = true;
+          errormessage =  '棰勭暀浜у搧'+errorProductmodel+'鏈綍鍏ラ鐣欎骇鍝佽〃';
+          return null;
+        }
       }
       //20220214 fy lastbuy end
       // 2022-01-12 ssm 鎶ヤ环璁$畻check
@@ -2084,7 +2101,9 @@
       // 銇撱亾銈掍慨姝c仐銇熴倝銆丯FM007.trigger銈傝纰鸿獚
       prd2LatestValMap = new Map<Id, Product2>();
       integer cntPrd2 = 0;
-      for (Product2 prd2 : [Select Id, Estimation_Entry_Possibility__c, SFDA_Status__c, Packing_list_manual__c
+      for (Product2 prd2 : [Select Id, Estimation_Entry_Possibility__c, SFDA_Status__c, Packing_list_manual__c,
+      //fy 棰勭暀浜у搧鏍囪瘑
+      LastbuyProductFLG__c
                             From Product2 Where Id IN :product2Ids]) {
         cntPrd2 = cntPrd2   +   1;
         if (prd2.Estimation_Entry_Possibility__c != '鈼�') {
@@ -3122,31 +3141,82 @@
   }
   //lastbuy  2022/2/9 fy start
   public boolean ReservedProductVerification() {
+
     filg=true;
     Map<string,QuoteLineItem> quotlinitMap = new Map<string,QuoteLineItem>();
-    List<Id> lastProductFLGList = new List<Id>();
-    for(QELine qli : activities){
-      lastProductFLGList.add(qli.pageObject.PricebookEntry.Product2Id);
-      quotlinitMap.put(qli.pageObject.PricebookEntry.Product2Id,qli.pageObject);
+    List<Id> lastProductFLGListId = new List<Id>();
+    List<QuoteLineItem> lastProductFLGList = new List<QuoteLineItem>();
+    List<QuoteLineItem> act = new List<QuoteLineItem>();
+    List<QuoteLineItem> act2 = new List<QuoteLineItem>();
+    for(QELine aaa :activities){
+      if(aaa.pageObject.PricebookEntry.Product2Id!=null){
+        act.add(aaa.pageObject);
+      }
     }
-    System.debug('activities!!!'+activities);
+    act2=act.deepClone();
+    Map<String,QuoteLineItem> map1 = new Map<String,QuoteLineItem>();
+    System.debug('activities1111111111112涓烘墍褰撲负澶氬!!!'+activities);
+    integer i =0;
+    for(QuoteLineItem pspsc :act2){
+      if(pspsc.PricebookEntry.Product2Id!=null){
+        if(map1.containsKey(pspsc.PricebookEntry.Product2Id)){
+          QuoteLineItem quoteLine = map1.get(pspsc.PricebookEntry.Product2Id);
+          quoteLine.Quantity__c =quoteLine.Quantity__c+pspsc.Quantity__c;
+          map1.put(pspsc.PricebookEntry.Product2Id,quoteLine);
+        }else{
+          map1.put(pspsc.PricebookEntry.Product2Id,pspsc);
+        }
+        System.debug('34499879!!!'+activities);
+      }
+    }
+    System.debug('3434343!!!'+activities);
+    System.debug('5656565!!!'+map1);
+    for (QuoteLineItem value : map1.values()) {
+      if(value.PricebookEntry.Product2.LastbuyProductFLG__c){
+        lastProductFLGListId.add(value.PricebookEntry.Product2Id);
+        quotlinitMap.put(value.PricebookEntry.Product2Id,value);
+        lastProductFLGList.add(value);
+      }
+    }
+    System.debug('activities++++!!!'+activities);
+    System.debug('activities!!!'+map1.values());
     System.debug('oppId!!!'+oppId);
-    System.debug('lastProductFLGList!!!'+lastProductFLGList);
-    if(lastProductFLGList!=null){
-        List<LastbuyProduct__c> LastbuyObjList=[select id,LastbuyQuantity__c,InquiryCode__c,ProductName__c,effectiveFLG__c from LastbuyProduct__c where InquiryCode__c= : oppId and ProductName__c in :lastProductFLGList and effectiveFLG__c = true];
-        if(LastbuyObjList!=null){
-            for(LastbuyProduct__c lastbuypr :LastbuyObjList){
-              Decimal quoteLItemNum=0;
-              if(quotlinitMap.containsKey(lastbuypr.ProductName__c)){
-                  quoteLItemNum=quotlinitMap.get(lastbuypr.ProductName__c).Quantity__c;
-              }else{
-                  continue;
-              }
-              if(lastbuypr.LastbuyQuantity__c<quoteLItemNum){
-                filg=false;
-                break;
-              }
+    System.debug('lastProductFLGList!!!'+lastProductFLGListId);
+    if(lastProductFLGListId!=null&&lastProductFLGListId.size()!=0){
+        List<LastbuyProduct__c> LastbuyObjList=[select id,LastbuyQuantity__c,InquiryCode__c,ProductName__c,effectiveFLG__c from LastbuyProduct__c where InquiryCode__c= : oppId and ProductName__c in :lastProductFLGListId and effectiveFLG__c = true];
+        Map<string,LastbuyProduct__c> LastbuyObjMap = new Map<string,LastbuyProduct__c>();
+        System.debug('LastbuyObjList+++++!!!'+LastbuyObjList);
+        if(LastbuyObjList!=null&&LastbuyObjList.size()!=0){
+          for(LastbuyProduct__c lastbuypr :LastbuyObjList){
+            LastbuyObjMap.put(lastbuypr.ProductName__c,lastbuypr);
+          }
+        }else{
+          flglastbuy=1;
+          filg=false;
+          return filg;
+        }
+        System.debug('LastbuyObjMap!!!'+LastbuyObjMap);
+        System.debug('lastProductFLGList+++++++!!!'+lastProductFLGList);
+        if(lastProductFLGList!=null&&lastProductFLGList.size()!=0){
+          for(QuoteLineItem lastbuypr :lastProductFLGList){
+            Decimal quoteLItemNum=0;
+            if(LastbuyObjMap.containsKey(lastbuypr.PricebookEntry.Product2Id)){
+                quoteLItemNum=LastbuyObjMap.get(lastbuypr.PricebookEntry.Product2Id).LastbuyQuantity__c;
+                System.debug('quoteLItemNum!!!'+quoteLItemNum);
+                System.debug('lastbuypr.pageObject.Quantity__c+++!!!'+lastbuypr.Quantity__c);
+                if(lastbuypr.Quantity__c>quoteLItemNum){
+                  errorProductmodel=lastbuypr.Asset_Model_No__c;
+                  flglastbuy=2;
+                  filg=false;
+                  break;
+                }
+            }else{
+              errorProductmodel=lastbuypr.Asset_Model_No__c;
+              flglastbuy=3;
+              filg=false;
+              break;
             }
+          }
         }
     }
     system.debug('filg====='+filg);

--
Gitblit v1.9.1