From 97f7784fde3e9fd5fa23c8a589a6ad7488022533 Mon Sep 17 00:00:00 2001
From: chenjingwu <chenjingwu@prec-tech.com>
Date: 星期二, 23 四月 2024 10:40:53 +0800
Subject: [PATCH] 123

---
 force-app/main/default/classes/MaintenanceProductDataController.cls |   60 +++++++++++++++++++++++++++++++-----------------------------
 1 files changed, 31 insertions(+), 29 deletions(-)

diff --git a/force-app/main/default/classes/MaintenanceProductDataController.cls b/force-app/main/default/classes/MaintenanceProductDataController.cls
index 414afbb..a345123 100644
--- a/force-app/main/default/classes/MaintenanceProductDataController.cls
+++ b/force-app/main/default/classes/MaintenanceProductDataController.cls
@@ -527,7 +527,37 @@
                     ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,  '杩樻病鏈変笂浼犻檮浠讹紝璇蜂笂浼犻檮浠讹紒'));
                 } 
             }
-            //System.debug('============02:'+mpdDetailsRecords);    
+            //System.debug('============02:'+mpdDetailsRecords);   
+            if(mpdDetailsRecords.size() > 0){
+                // 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
+            } 
         }    
     }
     // 妫�绱�
@@ -656,9 +686,6 @@
                 //20200618 绫诲瀷涓�鑷翠笉涓�鑷翠笉鑳戒繚瀛� add start
                 Boolean isWarning = false;
                 String  contentWarning = '';
-                // chenjingwu 3+2澶氬勾淇濅慨 20240417 start 
-                List<String> idList = new List<String>();
-                // chenjingwu 3+2澶氬勾淇濅慨 20240417 end
                 for (MaintenanceProductDataDetailsInfo ass : mpdDetailsRecordsView)  {
                     Roll = Roll+1;
                     if(ass.check == true){
@@ -672,9 +699,6 @@
                         InsAfterDel.Maintenance_Product_Data__c = mpd_Name[0].id;
                         InsAfterDel.Name = mpd_Name[0].Name + '-'+ str;
                         InsAfterDel.ProductsID__c = ass.Prod.id;
-                        // chenjingwu 3+2澶氬勾淇濅慨 20240417 start 
-                        idList.add(ass.Prod.id);
-                        // chenjingwu 3+2澶氬勾淇濅慨 20240417 end
                         switch on RecordTypeName {
                             when 'ImportantProduct'{
                                 //InsAfterDel.RecordTypeName__c = 'ImportantProduct';
@@ -868,28 +892,6 @@
                         Ins.add(InsAfterDel);     
                     }
                 }
-                // 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
                 if(isWarning){
                     return null;
                 }else{

--
Gitblit v1.9.1