From f7da22d3d9ee245ba7b6efe658ecfa149a6b2ec7 Mon Sep 17 00:00:00 2001
From: chenjingwu <chenjingwu@prec-tech.com>
Date: 星期四, 25 四月 2024 17:12:59 +0800
Subject: [PATCH] 123

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

diff --git a/force-app/main/default/classes/MaintenanceProductDataController.cls b/force-app/main/default/classes/MaintenanceProductDataController.cls
index bf2d773..b5351b5 100644
--- a/force-app/main/default/classes/MaintenanceProductDataController.cls
+++ b/force-app/main/default/classes/MaintenanceProductDataController.cls
@@ -556,7 +556,9 @@
                         if(exList.size() <= 0){
                             exViewList.add(new ExMpdDetailsInfo());
                         }
-                        exList.add(new ExMpdDetailsInfo());
+                        ExMpdDetailsInfo exd = new ExMpdDetailsInfo();
+                        exd.mpdrdd.ProductsID__c = id;
+                        exList.add(exd);
                         muCountMap.put(id,exList.size());
                         muCountViewMap.put(id,exViewList.size());
                         exmpdDetailsRecordsMap.put(id,exList);
@@ -1171,11 +1173,46 @@
                         }
                         Ins.add(upMpd);    
                     }
+                    List<Maintenance_Product_Data_Details__c> exIntList = new List<Maintenance_Product_Data_Details__c>();
+                    List<Maintenance_Product_Data_Details__c> exDetailList = new List<Maintenance_Product_Data_Details__c>();
+                    if(RecordTypeName.equals('GuranteeMain')){
+                        List<Maintenance_Product_Data__c> mpd_Name = new List<Maintenance_Product_Data__c>();
+                        mpd_Name = [SELECT id,Name FROM Maintenance_Product_Data__c WHERE id =:id];
+                        exDetailList = [SELECT id,Name FROM Maintenance_Product_Data_Details__c where Maintenance_Product_Data__c =:id and RecordTypeId = '012C50000000jefIAA'];
+                        Integer str = 0;
+                        for(List<ExMpdDetailsInfo> li: exmpdDetailsRecordsMap.values()){
+                            for(ExMpdDetailsInfo ex: li){
+                                if(ex.mpdrdd.AgeLimit__c > 0){
+                                    Maintenance_Product_Data_Details__c InsAfterDel = new Maintenance_Product_Data_Details__c();
+                                    InsAfterDel.Maintenance_Product_Data__c = mpd_Name[0].id;
+                                    InsAfterDel.Name = mpd_Name[0].Name + '-ex'+ str;
+                                    InsAfterDel.AgeLimit__c = ex.mpdrdd.AgeLimit__c;
+                                    InsAfterDel.MultiYearWarranty__c = ex.mpdrdd.MultiYearWarranty__c;
+                                    InsAfterDel.MultiOneYearWarrantyPrice__c = ex.mpdrdd.MultiOneYearWarrantyPrice__c;
+                                    InsAfterDel.AmountWithheld__c = ex.mpdrdd.AmountWithheld__c;
+                                    InsAfterDel.ProductsID__c = ex.mpdrdd.ProductsID__c;
+
+                                    InsAfterDel.AgeLimit_Old__c = ex.Prod.AgeLimit__c;
+                                    InsAfterDel.MultiOneYearWarrantyPrice_Old__c = ex.Prod.MultiOneYearWarrantyPrice__c;
+                                    InsAfterDel.AmountWithheld_Old__c = ex.Prod.AmountWithheld__c;
+                                    InsAfterDel.RecordTypeId = '012C50000000jefIAA';
+                                    exIntList.add(InsAfterDel);
+                                    str++;
+                                }
+                            }
+                        }
+                    // chenjingwu 3+2澶氬勾淇濅慨   20240417 end
+                   }
+                   System.debug('chenjingwu=>' + exIntList);
                     if(isWarning){
                         return null;
                     }else{
                         if(Ins.size()>0){
                             update Ins;
+                            if(exIntList.size() > 0){
+                                delete exDetailList;
+                                upsert exIntList;
+                            }
                             return UnabletoEdit();
                         }
                         else{ 
@@ -1354,6 +1391,20 @@
         ref.setRedirect(true);
         return ref;
     }
+    public String ProId {get;set;}
+    public Integer index{get;set;}
+    public PageReference addEx(){
+        ExMpdDetailsInfo ex = new ExMpdDetailsInfo();
+        ex.mpdrdd.ProductsID__c = ProId;
+        exmpdDetailsRecordsMap.get(ProId).add(ex);
+        muCountMap.get(ProId); 
+        return null;
+    }
+    public PageReference deleteEx(){
+        exmpdDetailsRecordsMap.get(ProId).remove(index);
+        muCountMap.get(ProId); 
+        return null;
+    }
     
     //鎼滅储鏃剁殑sql
     public String makeSoql(String Family,String Category2,String Category3,String Category4,String Category5,String CateName,String ProductCode_Ext,String GuranteeType){

--
Gitblit v1.9.1