From 4ba1330f78729fd2b653a4767c906a8960270624 Mon Sep 17 00:00:00 2001
From: chenjingwu <chenjingwu@prec-tech.com>
Date: 星期二, 23 四月 2024 16:00:09 +0800
Subject: [PATCH] 123

---
 force-app/main/default/classes/MaintenanceProductDataController.cls |   64 ++++++++++++++++++++++++++++---
 1 files changed, 57 insertions(+), 7 deletions(-)

diff --git a/force-app/main/default/classes/MaintenanceProductDataController.cls b/force-app/main/default/classes/MaintenanceProductDataController.cls
index a1bad1c..e667e98 100644
--- a/force-app/main/default/classes/MaintenanceProductDataController.cls
+++ b/force-app/main/default/classes/MaintenanceProductDataController.cls
@@ -49,6 +49,12 @@
     public String soql {get;set;}
     //---
     
+    // chenjingwu 3+2澶氬勾淇濅慨 start
+    public List<MultiYearWarranty__c> muList { get; set; }
+    public Map<String,List<MultiYearWarranty__c>> muMap { get; set; }
+    public Map<String,Integer> muCountMap {get; set; }
+    // chenjingwu 3+2澶氬勾淇濅慨 end
+
      /*****************鐢婚潰琛ㄧずBean******************/
     //private List<MaintenanceProductDataDetailsInfo> mpdDerdetailsRecords = new List<MaintenanceProductDataDetailsInfo>();
     public  List<MaintenanceProductDataDetailsInfo> mpdDetailsRecordsView { get; set; }//椤甸潰鐨勬槑缁�
@@ -164,6 +170,7 @@
                     // 20221020 ljh SWAG-CJ98AJ start
                     mpdDetailsRecordsView[i].mpdrdd.suitDepartment__c = mpdDetailsRecordsView[i].Prod.suitDepartment__c;
                     // 20221020 ljh SWAG-CJ98AJ end
+                    mpdDetailsRecordsView[i].mpdrdd.LastbuyProductFLG__c = mpdDetailsRecordsView[i].Prod.LastbuyProductFLG__c;//kk lastbuy add 20240329 add 
                 }
                 if(RecordTypeName.equals('GuranteeMain')){
                     Integer Entend_gurantee_period_all =  mpdDetailsRecordsView[i].Prod.Entend_gurantee_period_all__c.intValue();
@@ -315,13 +322,13 @@
         if(profileId.equals(System.Label.ProfileId_EquCenAdminPic)){
             profileName = '2B3';
         }
-        if(profileId.equals('00e10000000xno4AAA')){
+        if(profileId.equals(System.Label.profileId_2F3)){//niwu -00eC600000004OXIAY 
             profileName = '2F3';//鏈嶅姟
         }
-        if(profileId.equals('00e10000000xyViAAI')){
+        if(profileId.equals(System.Label.ProfileId_2M5)){
             profileName = '2M5';//浜у搧
         }
-        if (profileId.equals('00e10000000xno9AAA')) {
+        if (profileId.equals(System.Label.ProfileId_2F4)) { //niwu  - 00eC600000004OZIAY
             profileName = '2F4';//鎶�鏈帹杩涢儴
         }
         if(String.isBlank(id)&&String.isBlank(RecordTypeName)){
@@ -356,6 +363,8 @@
             fsTemp += 'YY';
             fsTempOld += 'YY';
         }*/
+        System.debug('RecordTypeName>>>>>>> ' + RecordTypeName);
+        System.debug('profileName>>>>>>> ' + profileName);
         if(RecordTypeName.equals('GuranteeMain')&&profileName.equals('2M5')){
             fsTemp += 'FW';
             fsTempOld += 'FW';
@@ -418,6 +427,9 @@
         }else{
             List<Maintenance_Product_Data_Details__c> mpdDetailsSelected = new List<Maintenance_Product_Data_Details__c>();
             String mpdsoql = 'select Id ,Name,GuranteeTypeP__c,ProductCode_Ext__c ,ProductsID__c,Maintenance_Product_Data__c,ProductsID__r.Name  ';
+            //kk lastbuy add 20240328 start 
+            mpdsoql += ' ,ProductsID__r.LastbuyProductFLG__c,LastbuyProductFLG__c';
+            //kk lastbuy add 20240328 end
             for (Integer i=0;i<column.size();i++) {
                 mpdsoql += ',' + column[i];
             }
@@ -515,11 +527,42 @@
                     ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,  '杩樻病鏈変笂浼犻檮浠讹紝璇蜂笂浼犻檮浠讹紒'));
                 } 
             }
-            //System.debug('============02:'+mpdDetailsRecords);    
+            //System.debug('============02:'+mpdDetailsRecords);   
+            if(mpdDetailsRecords.size() > 0 && RecordTypeName.equals('GuranteeMain')){
+                // chenjingwu 3+2澶氬勾淇濅慨 20240417 start 
+                List<String> idList = new List<String>();
+                for(MpdDetailsInfo mp :mpdDetailsRecords){
+                    idList.add(mp.mpded.ProductsID__c);
+                }
+                // chenjingwu 3+2澶氬勾淇濅慨 20240417 end
+                // chenjingwu 3+2澶氬勾淇濅慨 20240417 start 
+                muCountMap = new Map<String,Integer>();
+                muList = [select Id,AgeLimit__c,MultiOneYearWarrantyPrice__c,AmountWithheld__c,ProductName__r.Name,ProductName__c from MultiYearWarranty__c where ProductName__c in: idList order By ProductName__c];
+                  for(AggregateResult  objAgr: [select ProductName__c,COUNT(Id) total from MultiYearWarranty__c where ProductName__c in:idList group by ProductName__c]){
+                    muCountMap.put((String)objAgr.get('ProductName__c'), (Integer)objAgr.get('total') + 1);
+                  }
+                  muMap = new Map<String,List<MultiYearWarranty__c>>();
+                for(String id: idList){
+                    List<MultiYearWarranty__c> mus = new List<MultiYearWarranty__c>();
+                    for(MultiYearWarranty__c mu: muList){
+                        if(id == mu.ProductName__c){
+                            mus.add(mu);
+                        }
+                    }
+                    mus.add(new MultiYearWarranty__c(ProductName__c = id));
+                    muMap.put(id,mus);
+                }
+                System.debug('chenjingwu=>' + muCountMap);
+                System.debug('chenjingwu=>' + muMap);
+                System.debug('chenjingwu=>' + mpdDetailsRecordsView);
+                
+                // chenjingwu 3+2澶氬勾淇濅慨   20240417 end
+            } 
         }    
     }
     // 妫�绱�
     public void searchMaintenanceProductDataDetails() {
+        System.debug('enter searchMaintenanceProductDataDetails');   
         Map<String, String> selectedIdMap = new Map<String, String>();
         Map<String,MaintenanceProductDataDetailsInfo> midMaprecord = new Map<String,MaintenanceProductDataDetailsInfo>();
         mpdDetailsRecordsView = new List<MaintenanceProductDataDetailsInfo>();
@@ -530,7 +573,9 @@
         //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error,  '=====soql:'+soql));
         size =Integer.valueOf(System.Label.mpddetLimitsize);
         initStandardController();
-        product2Selected = Database.query(soql);    
+        product2Selected = Database.query(soql); 
+        System.debug('product2Selected size = ' + product2Selected.size());   
+        System.debug('product2Selected = ' + product2Selected);
         for (Integer i = 0; i < product2Selected.size(); i++) {
             midMaprecord.put(product2Selected[i].Id, new MaintenanceProductDataDetailsInfo(product2Selected[i]));
         }
@@ -663,12 +708,14 @@
                                 InsAfterDel.Dealer_special_Object__c = ass.mpdrdd.Dealer_special_Object__c;
                                 InsAfterDel.Key_product_147P__c = ass.mpdrdd.Key_product_147P__c;
                                 InsAfterDel.Important_Endopartner_product__c = ass.mpdrdd.Important_Endopartner_product__c;
+                                InsAfterDel.LastbuyProductFLG__c = ass.mpdrdd.LastbuyProductFLG__c; //kk lastbuy 20240319 add
                                 //old鏁版嵁
                                 //InsAfterDel.Tier1_Category_Old__c = ass.Prod.Tier1_Category__c;
                                 InsAfterDel.ENG_DeaerProFlag_Old__c = ass.Prod.ENG_DeaerProFlag__c;
                                 InsAfterDel.Dealer_special_Object_Old__c = ass.Prod.Dealer_special_Object__c;
                                 InsAfterDel.Key_product_147P_Old__c = ass.Prod.Key_product_147P__c;
                                 InsAfterDel.Important_Endopartner_product_Old__c = ass.Prod.Important_Endopartner_product__c;
+                                InsAfterDel.LastbuyProductFLG_Old__c = ass.Prod.LastbuyProductFLG__c; //kk lastbuy 20240319 add
 
                                 // FY23淇敼 WLIG-CFV4AV 閲嶇偣浜у搧缁存姢锛堟柊锛塻tart
                                 InsAfterDel.Key_product_155P__c = ass.mpdrdd.Key_product_155P__c;
@@ -857,6 +904,7 @@
                 }
             }
         }catch(Exception e){
+            System.debug('chenjingwu==>' + e.getMessage());
             ApexPages.addMessages(e);
             Database.rollback(sp);
             return null;
@@ -912,6 +960,8 @@
                                 // 20221020 ljh SWAG-CJ98AJ start
                                 upMpd.suitDepartment__c = ass.mpded.suitDepartment__c;
                                 // 20221020 ljh SWAG-CJ98AJ end
+                                //kk lastbuy add 20240329 start 
+                                upMpd.LastbuyProductFLG__c = ass.mpded.LastbuyProductFLG__c;
                             }
                             when 'GuranteeMain'{
                                 upMpd.Entend_gurantee_period__c=ass.mpded.Entend_gurantee_period__c;
@@ -1244,7 +1294,7 @@
             }
         }*/
 
-        String soql = 'select Id ,ProductCode_Ext__c,Name   ';
+        String soql = 'select Id ,ProductCode_Ext__c,Name,LastbuyProductFLG__c   ';
         if(!RecordTypeName.equals('GuranteeMain') && !RecordTypeName.equals('GuranteePrice') ){
             for (Integer i=0;i<column.size();i++) {soql += ',' + column[i];
             }
@@ -1290,7 +1340,7 @@
             soql += ' AND (GuranteeType__c like \'%'+ String.escapeSingleQuotes(GuranteeType.replaceAll('%', '\\%')) + '%\')';
         }
         soql += ' Limit 400';
-        //System.debug('soql +++++++++++  ' + soql );
+        System.debug('soql +++++++++++  ' + soql );
         return soql;
     }
      // 鏄剧ず鏁版嵁鏉℃暟淇℃伅

--
Gitblit v1.9.1