From d8dc84a3d56df839895f1c417a4d9cbee763d262 Mon Sep 17 00:00:00 2001
From: 高章伟 <gaozhangwei@prec-tech.com>
Date: 星期五, 03 三月 2023 14:50:59 +0800
Subject: [PATCH] gzw 测试环境代码更新

---
 force-app/main/default/classes/SelectAssetEstimateController.cls |   99 +++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 82 insertions(+), 17 deletions(-)

diff --git a/force-app/main/default/classes/SelectAssetEstimateController.cls b/force-app/main/default/classes/SelectAssetEstimateController.cls
index 4c9749c..1fb6516 100644
--- a/force-app/main/default/classes/SelectAssetEstimateController.cls
+++ b/force-app/main/default/classes/SelectAssetEstimateController.cls
@@ -545,9 +545,6 @@
         //HWAG-B399Q8 2018/08/20  娣诲姞涓�棰濆瀛楁 IS_Clone_After_Decide__c start
         this.estimate = [SELECT Id, Name, Maintenance_Contract__c, Estimation_Decision__c, CreatedDate, Service_Contract_Staff__c,
                          JingliApprovalManager__c, BuchangApprovalManager__c, ZongjianApprovalManager__c, Finally_Approved_Staff__c,
-                         //LJPH-C95AQ2 ly 20211207 Start
-                         JingliApprovalManager__r.Name, BuchangApprovalManager__r.Name,
-                         //LJPH-C95AQ2 ly 20211207 End
                          Contract_Esti_Start_Date__c, Contract_Esti_End_Date__c, Contract_Range__c, Contract_Start_Date__c, Contract_End_Date__c,
                          Maintenance_Contract_Status__c, Discount_reason__c, Improve_ConsumptionRate_Idea__c, Process_Status__c,
                          Estimate_Trial_Money__c, Maintenance_Price__c, Department__c, PrintDate__c, Quote_Date__c, Submit_quotation_day__c,
@@ -861,11 +858,7 @@
     // 鍙栧緱鍒嗛〉鏁版嵁
     private void setPageRecord() {
         checkIdList = new List<String> ();
-        for (AssetInfo ass : this.checkedAssets) {
-            if (!ass.isManual) {
-                checkIdList.add(ass.rec.Id);
-            }
-        }
+        
 
         if ((currPage * selctRecordNum) <= 2000) {
             String notInId = '(\'';
@@ -1950,6 +1943,7 @@
             this.estimate.Contract_Range__c.addError('蹇呴』杈撳叆鍚堝悓鏈堟暟!');
             return null;
         }
+        NextMaintenanceContract();
         //add by rentx 2020-11-13 LJPH-BV93RZ end
         // add 缁翠慨鍚堝悓鎶ヤ环锛屼繚瀛樻椂锛屾妸璁板綍绫诲瀷璧嬪�间竴涓� 2021.6.8 fxk start
         Id Maintenance_Contract = Schema.SObjectType.Maintenance_Contract_Estimate__c.getRecordTypeInfosByDeveloperName().get('Maintenance_Quote').getRecordTypeId();
@@ -2125,7 +2119,8 @@
      * 姹哄畾銉°偨銉冦儔
      */
     public PageReference decide() {
-        System.debug('decide start');
+        System.debug('decide start');         
+        NextMaintenanceContract();
         inDicideFlag = true;
         // TODO check decide 璧勬牸
         Savepoint sp = Database.setSavepoint();
@@ -2138,6 +2133,49 @@
         }
 
         return null;
+    }
+    //  public PageReference dosomething() {
+    //     System.debug('dosomething start');
+    //     NextMaintenanceContract();
+    //     return null;
+    // }
+    public void NextMaintenanceContract() {
+            // 20220810 璇环2鏈熷紑鍙�
+        List<String> asslocalList = new List<String>();
+        List<String> mcalocalList = new List<String>();
+        Map<Id, Maintenance_Contract__c> map3 = new Map<Id, Maintenance_Contract__c>();
+        
+        List<Maintenance_Contract_Asset__c> mcaupdateList = new List<Maintenance_Contract_Asset__c>();
+        for (AssetInfo ass : this.checkedAssets) {
+            if (!ass.isManual) {
+                asslocalList.add(ass.rec.Id);
+                map3.put(ass.rec.Id,this.contract);
+            }
+        }
+        System.debug('asslocalList====%%%' +asslocalList);
+         List<Maintenance_Contract_Asset__c> mcalist1 = [select id,Asset__c,Next_Maintenance_Contract__c,Maintenance_Contract__c
+                                             from Maintenance_Contract_Asset__c
+                                            where id in (select CurrentContract_F_asset__c
+                                                                from asset
+                                                                where id in :asslocalList and CurrentContract_F_asset__c!=null)];
+            System.debug('mcalist1====%%%' +mcalist1);
+            System.debug('map3====%%%' +map3);
+        for (Maintenance_Contract_Asset__c mca : mcalist1) {
+            Maintenance_Contract_Asset__c mca3 = new Maintenance_Contract_Asset__c();
+            if (map3.containsKey(mca.Asset__c)) {
+                mca3.id = mca.id;
+                mca3.Next_Maintenance_Contract__c = map3.get(mca.Asset__c).id;
+                System.debug('mca3.id====%%%' +mca3.id);
+                if (mca3.id!=null&&!mcaupdateList.contains(mca3)) {
+                    mcaupdateList.add(mca3);
+                }
+            }
+        }
+        System.debug('mcaupdateList====%%%' +mcaupdateList);
+        if (mcaupdateList!=null&&!mcaupdateList.isEmpty()) {
+            update mcaupdateList;
+        }    
+        System.debug('鏇存柊瀹屾垚mcaupdateList');
     }
 
     public PageReference decideCancle() {
@@ -2467,10 +2505,6 @@
                 this.contract.Contract_End_Date__c = this.estimate.Contract_End_Date__c;
                 this.contract.JingliApprovalManager__c = this.estimate.JingliApprovalManager__c;
                 this.contract.BuchangApprovalManager__c = this.estimate.BuchangApprovalManager__c;
-                //LJPH-C95AQ2 ly 20211207 Start
-                this.contract.JingliApprovalManager_Txt__c = this.estimate.JingliApprovalManager__r.Name;
-                this.contract.BuchangApprovalManager_Txt__c = this.estimate.BuchangApprovalManager__r.Name;
-                //LJPH-C95AQ2 ly 20211207 End
                 this.contract.ZongjianApprovalManager__c = this.estimate.ZongjianApprovalManager__c;
                 this.contract.Finally_Approved_Staff__c = this.estimate.Finally_Approved_Staff__c;
                 this.contract.TKZongjianApprovalManager__c = this.estimate.TKZongjianApprovalManager__c;
@@ -2485,10 +2519,6 @@
                 this.contract.Contract_End_Date__c = this.estimate.Contract_End_Date__c;
                 this.contract.JingliApprovalManager__c = this.estimate.JingliApprovalManager__c;
                 this.contract.BuchangApprovalManager__c = this.estimate.BuchangApprovalManager__c;
-                //LJPH-C95AQ2 ly 20211207 Start
-                this.contract.JingliApprovalManager_Txt__c = this.estimate.JingliApprovalManager__r.Name;
-                this.contract.BuchangApprovalManager_Txt__c = this.estimate.BuchangApprovalManager__r.Name;
-                //LJPH-C95AQ2 ly 20211207 End
                 this.contract.ZongjianApprovalManager__c = this.estimate.ZongjianApprovalManager__c;
                 this.contract.Finally_Approved_Staff__c = this.estimate.Finally_Approved_Staff__c;
                 this.contract.TKZongjianApprovalManager__c = this.estimate.TKZongjianApprovalManager__c;
@@ -2569,6 +2599,7 @@
             this.estimate.Contract_Range__c.addError('蹇呴』杈撳叆鍚堝悓鏈堟暟!');
             return null;
         }
+        NextMaintenanceContract();
         //add by rentx 2020-11-13 LJPH-BV93RZ end
         if (syncEstimate(false, false)) {
             PageReference ret = null;
@@ -3037,6 +3068,40 @@
         i++;
         i++;
         i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
         SelectAssetEstimateController saec = new SelectAssetEstimateController();
         saec.targetEstimateId = strId;
         saec.isPageAction = true;

--
Gitblit v1.9.1