From 1949e7ccb3bfab67ad2b16d7e0172851c3f823bb Mon Sep 17 00:00:00 2001
From: 李彤 <litong@prec-tech.com>
Date: 星期六, 02 四月 2022 14:06:49 +0800
Subject: [PATCH] 先款后修上线内容

---
 force-app/main/default/triggers/MaintenanceContractTrigger.trigger          |   61 
 force-app/main/default/classes/NFM106Controller.cls                         |    8 
 force-app/main/default/pages/NewMCAgentPDF.page                             |  108 
 force-app/main/default/triggers/PaymentMaintenanceContractTrigger.trigger   |    4 
 force-app/main/default/classes/SelectAssetEstimateVMController.cls          | 5397 +++++++++++++++++++++++-----------------------
 force-app/main/default/pages/SelectAssetEstimateVM.page                     |  188 
 force-app/main/default/classes/MaintenanceContractTriggerTest.cls           |   98 
 force-app/main/default/classes/NewMCAgentPDFController.cls                  |  372 +-
 force-app/main/default/classes/PaymentMaintenanceContractTriggerTest.cls    |   97 
 force-app/main/default/classes/MaintenanceContractWebService.cls            |   52 
 force-app/main/default/classes/PaymentMaintenanceContractTriggerHandler.cls |   85 
 force-app/main/default/classes/RepairTriggerTester.cls                      |  111 
 force-app/main/default/classes/AccountTriggerTest.cls                       |   10 
 force-app/main/default/classes/RepairTrigger.cls                            |   64 
 force-app/main/default/classes/MaintenanceContractWebServiceTest.cls        |    5 
 force-app/main/default/triggers/AccountTrigger.trigger                      |   94 
 force-app/main/default/classes/SelectAssetEstimateVMControllerTest.cls      |   54 
 force-app/main/default/classes/PaymentMaintenanceContractTriggerHTest.cls   |  110 
 force-app/main/default/classes/StaticParameter.cls                          |   16 
 force-app/main/default/triggers/Repair.trigger                              |   17 
 20 files changed, 3,948 insertions(+), 3,003 deletions(-)

diff --git a/force-app/main/default/classes/AccountTriggerTest.cls b/force-app/main/default/classes/AccountTriggerTest.cls
index ffea50e..69ed0dc 100644
--- a/force-app/main/default/classes/AccountTriggerTest.cls
+++ b/force-app/main/default/classes/AccountTriggerTest.cls
@@ -298,4 +298,14 @@
         hp.FSE_SP_Main_Leader__c = hpOwner.Id;
         update hp;
     }
+    @isTest
+    static void FirstparagraphTest(){
+        Account dealers = new Account();
+        dealers.RecordTypeId = '01210000000Qem1';
+        dealers.Name = 'Test Dealers';
+        dealers.MonthlyPayment__c = false;
+        insert dealers;
+        dealers.MonthlyPayment__c = true;
+        update dealers;
+    }
 }
\ No newline at end of file
diff --git a/force-app/main/default/classes/MaintenanceContractTriggerTest.cls b/force-app/main/default/classes/MaintenanceContractTriggerTest.cls
new file mode 100644
index 0000000..3c23ac6
--- /dev/null
+++ b/force-app/main/default/classes/MaintenanceContractTriggerTest.cls
@@ -0,0 +1,98 @@
+@isTest
+private class MaintenanceContractTriggerTest {
+    private static User hpOwner = null;
+    private static User hpOwner2 = null;
+    private static Id pricebookId = ControllerUtil.getStandardPricebook().Id;
+    private static Account hospital = null;
+    private static List<Account> strategicDep = null;
+    private static Product2 productA = null;
+    private static Account dep = null;
+    private static PricebookEntry entry = null;
+    private static Asset asset01 = null;
+    private static Asset asset02 = null;
+    private static Asset asset03 = null;
+    private static Maintenance_Contract__c contract = null;
+    static {
+        Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
+        hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '鍖椾含', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
+        insert hpOwner;
+        hpOwner2 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', Work_Location__c = '閲嶅簡', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
+        insert hpOwner2;
+
+        // 鐥呴櫌銈掍綔銈�
+        hospital = new Account();
+        hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
+        hospital.Name = 'test hospital';
+        insert hospital;
+        
+        // 鎴︾暐绉戝銈掑緱銈�
+        strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
+        
+        // 瑷虹檪绉戙倰浣溿倠
+        dep = new Account();
+        dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
+        dep.Name = 'test dep';
+        dep.ParentId = strategicDep[0].Id;
+        dep.Department_Class__c = strategicDep[0].Id;
+        dep.Hospital__c = hospital.Id;
+        insert dep;
+
+        // 瑁藉搧銈掍綔銈�
+        productA = new Product2( Name='銉嗐偣銉堝晢鍝�');
+        insert productA;
+        
+        // 渚℃牸琛ㄣ偍銉炽儓銉倰浣滄垚銇欍倠     
+        entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=productA.Id);
+        entry.UnitPrice = 0;
+        entry.IsActive = true;
+        entry.UseStandardPrice = false;
+        entry.CurrencyIsoCode = 'CNY';
+        entry.Product2Id = productA.Id;
+        insert entry;
+        
+        // 绱嶅叆姗熷櫒銈掍綔鎴愩仚銈�
+        asset01 = new Asset();
+        asset01.Name = '銉嗐偣銉堟鍣�';
+        asset01.AccountId = dep.Id;
+        asset01.Department_Class__c = strategicDep[0].Id;
+        asset01.Hospital__c = hospital.Id;
+        asset01.SerialNumber = 'testserial';
+        insert asset01;
+        asset02 = new Asset();
+        asset02.Name = '銉嗐偣銉堟鍣�';
+        asset02.AccountId = dep.Id;
+        asset02.Department_Class__c = strategicDep[0].Id;
+        asset02.Hospital__c = hospital.Id;
+        asset02.SerialNumber = 'testserial';
+        insert asset02;
+        asset03 = new Asset();
+        asset03.Name = '銉嗐偣銉堟鍣�';
+        asset03.AccountId = dep.Id;
+        asset03.Department_Class__c = strategicDep[0].Id;
+        asset03.Hospital__c = hospital.Id;
+        asset03.SerialNumber = 'testserial';
+        insert asset03;
+        
+        // 缁翠慨鍚堝悓銈掍綔鎴愩仚銈�
+        contract = new Maintenance_Contract__c();
+        contract.Name = 'tect contract';
+        contract.Hospital__c = hospital.Id;
+        contract.Department_Class__c = strategicDep[0].Id;
+        contract.Department__c = dep.Id;
+        contract.Contract_Start_Date__c = Date.today() - 10;
+        contract.Contract_End_Date__c = Date.today() + 10;
+        contract.Service_Contract_Staff__c = '00510000002ZZTc';
+        contract.upload_to_RM_time__c = Date.today() + 20;
+        insert contract;
+       
+    }
+    static testMethod void testMethod1() {
+        contract.All_Amount__c = 11.11;
+        update contract;
+
+        contract.Payment_Plan_Sum_First__c = 222.11;
+        update contract;
+
+        delete contract;
+    }
+}
\ No newline at end of file
diff --git a/force-app/main/default/classes/MaintenanceContractWebService.cls b/force-app/main/default/classes/MaintenanceContractWebService.cls
index 22ba499..1849a04 100644
--- a/force-app/main/default/classes/MaintenanceContractWebService.cls
+++ b/force-app/main/default/classes/MaintenanceContractWebService.cls
@@ -1,7 +1,7 @@
 global class MaintenanceContractWebService {
     // 鐢ㄦ埛鐐瑰嚮涓婁紶sap鎸夐挳锛屾洿鏂扮姸鎬佸埌濂戠害锛岃嚜鍔ㄨЕ鍙戜笂浼爏ap鎺ュ彛绋嬪簭
     WebService static String up2sap(String mcid) {
-        List<Maintenance_Contract__c> mcList = [select id, Status__c, Maintenance_Contract_No__c , Hospital__c , RecordTypeId, RecordType.DeveloperName from Maintenance_Contract__c where id = :mcid ];
+        List<Maintenance_Contract__c> mcList = [select id, Status__c, Maintenance_Contract_No__c , Hospital__c , RecordTypeId, RecordType.DeveloperName,Is_RecognitionModel__c,Recognition_Model_Type__c,upload_to_RM_time__c,old_Is_RecognitionModel__c,Is_Recognition_Model_True__c from Maintenance_Contract__c where id = :mcid ];
         if (mcList.size() == 0) {
             return '缁翠慨鍚堝悓涓嶅瓨鍦紝璇风‘璁ょ淮淇悎鍚孖D銆�';
         }
@@ -9,24 +9,40 @@
         if (mc.Maintenance_Contract_No__c == null || mc.Maintenance_Contract_No__c == '') {
             return Schema.SObjectType.Maintenance_Contract__c.fields.Maintenance_Contract_No__c.label + '涓虹┖锛屼笉鑳戒笂浼爏ap';
         }
-        mc.Status__c = '濂戠磩';
-        mc.upload_to_sap_time__c = Datetime.now();
-
+        //update   wangweipeng                    2021/11/17   start
+        //鐢ㄤ簬鍒ゆ柇褰撳墠鍚堝悓鏄惁闇�瑕佽娆�
+        boolean flag = false;
+        //鍒ゆ柇鏄惁闇�瑕佽娆惧悎鍚�
+        if(mc.old_Is_RecognitionModel__c){
+            //鍒ゆ柇褰撳墠鍚堝悓鏄惁宸茬粡璁ゆ瀹屾垚
+            if(!mc.Is_Recognition_Model_True__c){
+                flag = true;
+            }
+        }
+        //update   wangweipeng                    2021/11/17   end
         try {
-            //2021-01-14  mzy  add LJPH-BWY5QB  鍚堝悓鐘舵�佷负鍚堝悓涓椂 ,灏嗗鎴蜂笂鐨� 缁翠慨鍚堝悓鐢ㄦ埛绫诲瀷  璁句负true ,鍚堝悓涓婄殑 鐢ㄦ埛绫诲瀷 涓� 鏂扮敤鎴�, 浠ュ悗缁翠慨鍚堝悓鐢ㄦ埛绫诲瀷 閮戒负 true 鍚堝悓涓婄殑 鐢ㄦ埛绫诲瀷 涓� 鏃㈡湁鐢ㄦ埛
-            //鍙湁鍚堝悓鏄淮淇悎鍚屽拰鏈嶅姟鍚堝悓鐨勬椂鍊欒繘鍏�
-            if (!mc.RecordType.DeveloperName.equals('VM_Contract')) {
-                List<Account> acList =  [select id, MaintenanceContractUserType__c from Account where id = :mc.Hospital__c];
-                if (acList != null && acList.size() > 0) {
-                    Account hp = acList[0];
-                    //鑰佺敤鎴�
-                    if (hp.MaintenanceContractUserType__c == true) {
-                        mc.UserType__c = '鏃㈡湁鐢ㄦ埛';
-                    } else {
-                        //鏂扮敤鎴�
-                        hp.MaintenanceContractUserType__c = true;
-                        mc.UserType__c = '鏂扮敤鎴�';
-                        update hp;
+            if(flag){
+                mc.upload_to_RM_time__c = Datetime.now();//涓婁紶璁ゆ鍚堝悓鏃堕棿
+                //mc.old_Is_RecognitionModel__c = mc.Is_RecognitionModel__c;
+            }else{
+                mc.Status__c = '濂戠磩';
+                mc.upload_to_sap_time__c = Datetime.now();
+
+                //2021-01-14  mzy  add LJPH-BWY5QB  鍚堝悓鐘舵�佷负鍚堝悓涓椂 ,灏嗗鎴蜂笂鐨� 缁翠慨鍚堝悓鐢ㄦ埛绫诲瀷  璁句负true ,鍚堝悓涓婄殑 鐢ㄦ埛绫诲瀷 涓� 鏂扮敤鎴�, 浠ュ悗缁翠慨鍚堝悓鐢ㄦ埛绫诲瀷 閮戒负 true 鍚堝悓涓婄殑 鐢ㄦ埛绫诲瀷 涓� 鏃㈡湁鐢ㄦ埛
+                //鍙湁鍚堝悓鏄淮淇悎鍚屽拰鏈嶅姟鍚堝悓鐨勬椂鍊欒繘鍏�
+                if (!mc.RecordType.DeveloperName.equals('VM_Contract')) {
+                    List<Account> acList =  [select id, MaintenanceContractUserType__c from Account where id = :mc.Hospital__c];
+                    if (acList != null && acList.size() > 0) {
+                        Account hp = acList[0];
+                        //鑰佺敤鎴�
+                        if (hp.MaintenanceContractUserType__c == true) {
+                            mc.UserType__c = '鏃㈡湁鐢ㄦ埛';
+                        } else {
+                            //鏂扮敤鎴�
+                            hp.MaintenanceContractUserType__c = true;
+                            mc.UserType__c = '鏂扮敤鎴�';
+                            update hp;
+                        }
                     }
                 }
             }
diff --git a/force-app/main/default/classes/MaintenanceContractWebServiceTest.cls b/force-app/main/default/classes/MaintenanceContractWebServiceTest.cls
index a1524b4..52efed1 100644
--- a/force-app/main/default/classes/MaintenanceContractWebServiceTest.cls
+++ b/force-app/main/default/classes/MaintenanceContractWebServiceTest.cls
@@ -92,12 +92,17 @@
         contract1.Contract_End_Date__c = Date.today().addMonths(+20);
         contract1.Contract_Start_Date__c = Date.today();
         contract1.Contract_Range__c = Decimal.valueOf('20');
+        contract1.old_Is_RecognitionModel__c = true;
+        contract1.Is_Recognition_Model_True__c = false;
         insert contract1;
         List<String> mcidList = new  List<String>();
         mcidList.add(contract1.Id);
 
         MaintenanceContractWebService.up2sap(contract.Id);
         MaintenanceContractWebService.up2sap(contract1.Id);
+        contract1.old_Is_RecognitionModel__c = false;
+        contract1.Is_Recognition_Model_True__c = false;
+        update contract1;
 
         delete contract;
         MaintenanceContractWebService.up2sap(contract.Id);
diff --git a/force-app/main/default/classes/NFM106Controller.cls b/force-app/main/default/classes/NFM106Controller.cls
index b452dd6..a1eaa64 100644
--- a/force-app/main/default/classes/NFM106Controller.cls
+++ b/force-app/main/default/classes/NFM106Controller.cls
@@ -66,6 +66,11 @@
                 }
             }
         }
+        //Repair娴嬭瘯绫昏烦杩� thh 20220401 start
+        if(StaticParameter.EscapeNFM106Trigger){
+            return;
+        }
+        //Repair娴嬭瘯绫昏烦杩� thh 20220401 end
         if (Trigger.isBefore) {
             if (Trigger.isUpdate) {
                 for(Maintenance_Contract__c mc : newList) {
@@ -391,7 +396,8 @@
             // CHAN-BSV3GZ start
             // 鍘熶唬鐮�
             // rowData.retry_cnt__c=0;
-            if (status == 'OK') {
+            system.debug('status15122021'+status);
+            if (status == 'ok') {
                 rowData.retry_cnt__c = 0;
             } else {
                 if (rowData.retry_cnt__c == null) rowData.retry_cnt__c = 0;
diff --git a/force-app/main/default/classes/NewMCAgentPDFController.cls b/force-app/main/default/classes/NewMCAgentPDFController.cls
index b660885..1ebd887 100644
--- a/force-app/main/default/classes/NewMCAgentPDFController.cls
+++ b/force-app/main/default/classes/NewMCAgentPDFController.cls
@@ -8,72 +8,74 @@
     public void init() {
         String Maintenance_ContractID = ApexPages.currentPage().getParameters().get('id');
         List<Maintenance_Contract__c> MCList = [select
-                                            id,
-                                            Name,
-                                            Dealer__r.Name,
-                                            Department_Class__r.Name,
-                                            Service_Contract_Staff__c,
-                                            Payment_Plan_Sum_First__c,
-                                            Payment_Plan_Date_First__c,
-                                            Payment_Plan_Sum_Fifth__c,
-                                            Payment_Plan_Date_Fifth__c,
-                                            Payment_Plan_Sum_Third__c,
-                                            Payment_Plan_Date_Third__c,
-                                            Payment_Plan_Sum_Forth__c,
-                                            Payment_Plan_Date_Forth__c,
-                                            Payment_Plan_Sum_Second__c,
-                                            Payment_Plan_Date_Second__c,
-                                            Payment_Plan_Sum_Sixth__c,
-                                            Payment_Plan_Date_Sixth__c,
-                                            MainLeaderManager__c,
-                                            Service_Contract_Staff__r.JingliApprovalManager__c,
-                                            User_Salesdepartment__c,
-                                            User_Salesdepartment_Sec__c,
-                                            Service_Contract_Staff__r.Salesdepartment__c,
-                                            Small_Repair_Time__c,
-                                            Big_Repair_Time__c,
-                                            Live_Technical_Support_Time__c,
-                                            Engineer_Name__c,
-                                            Phone_Number__c,
-                                            Tour_Check__c,
-                                            Inspection_Time__c,
-                                            Dedust__c,
-                                            Negotiate_Mean__c,
-                                            First_Party_Contract_Number__c,
-                                            Second_Party_Contract_Number__c,
-                                            Term_Of_Payment__c,
-                                            one_off_payment_agreed_period__c,
-                                            Contract_Amount__c,
-                                            Total_Contract_Amount_In_Words__c,
-                                            Service_Contract_Staff__r.Name,
-                                            Total_Payment_Time__c,
-                                            Payment_Plan_Sum_First_in_Word__c,
-                                            Payment_Plan_Sum_Second_in_Word__c,
-                                            Payment_Plan_Sum_Third_in_Word__c,
-                                            Payment_Plan_Sum_Forth_in_Word__c,
-                                            Payment_Plan_Sum_Fifth_in_Word__c,
-                                            Payment_Plan_Sum_Sixth_in_Word__c,
-                                            Estimation_Id__c,
-                                            SalesOfficeCode_selection__c,
-                                            Hospital__r.Name,
-                                            Management_Code__c,
-                                            Contract_Start_Date__c,
-                                            Contract_End_Date__c,
-                                            Total_Contract_Number__c,
-                                            Is_New_Contract__c,
+                                                id,
+                                                Name,
+                                                Dealer__r.Name,
+                                                Department_Class__r.Name,
+                                                Service_Contract_Staff__c,
+                                                Payment_Plan_Sum_First__c,
+                                                Payment_Plan_Date_First__c,
+                                                Payment_Plan_Sum_Fifth__c,
+                                                Payment_Plan_Date_Fifth__c,
+                                                Payment_Plan_Sum_Third__c,
+                                                Payment_Plan_Date_Third__c,
+                                                Payment_Plan_Sum_Forth__c,
+                                                Payment_Plan_Date_Forth__c,
+                                                Payment_Plan_Sum_Second__c,
+                                                Payment_Plan_Date_Second__c,
+                                                Payment_Plan_Sum_Sixth__c,
+                                                Payment_Plan_Date_Sixth__c,
+                                                MainLeaderManager__c,
+                                                Service_Contract_Staff__r.JingliApprovalManager__c,
+                                                User_Salesdepartment__c,
+                                                User_Salesdepartment_Sec__c,
+                                                Service_Contract_Staff__r.Salesdepartment__c,
+                                                Small_Repair_Time__c,
+                                                Big_Repair_Time__c,
+                                                Live_Technical_Support_Time__c,
+                                                Engineer_Name__c,
+                                                Phone_Number__c,
+                                                Tour_Check__c,
+                                                Inspection_Time__c,
+                                                Dedust__c,
+                                                Negotiate_Mean__c,
+                                                First_Party_Contract_Number__c,
+                                                Second_Party_Contract_Number__c,
+                                                Term_Of_Payment__c,
+                                                one_off_payment_agreed_period__c,
+                                                Contract_Amount__c,
+                                                Total_Contract_Amount_In_Words__c,
+                                                Service_Contract_Staff__r.Name,
+                                                Total_Payment_Time__c,
+                                                Payment_Plan_Sum_First_in_Word__c,
+                                                Payment_Plan_Sum_Second_in_Word__c,
+                                                Payment_Plan_Sum_Third_in_Word__c,
+                                                Payment_Plan_Sum_Forth_in_Word__c,
+                                                Payment_Plan_Sum_Fifth_in_Word__c,
+                                                Payment_Plan_Sum_Sixth_in_Word__c,
+                                                Estimation_Id__c,
+                                                SalesOfficeCode_selection__c,
+                                                Hospital__r.Name,
+                                                Management_Code__c,
+                                                Contract_Start_Date__c,
+                                                Contract_End_Date__c,
+                                                Total_Contract_Number__c,
+                                                Is_New_Contract__c,
+                                                Is_RecognitionModel__c,
+                                                old_Is_RecognitionModel__c,
                     //LJPH-BUKD5A 銆婂鎵樸�嬪悎鍚屾枃鏈殑淇敼  绮剧悽鎶�鏈� wql 2020/10/23  start
                     //鏍规嵁缁忛攢鍟嗗悕鏄惁鏈夊�煎垽鏂槸鍚︽墦鍗版柊/鍚堝悓鐗堟湰
                                                 Dealer__c 
                     //LJPH-BUKD5A 銆婂鎵樸�嬪悎鍚屾枃鏈殑淇敼  绮剧悽鎶�鏈� wql 2020/10/23  end
-                                            from
-                                            Maintenance_Contract__c
-                                            where
-                                            id = :Maintenance_ContractID];
-    if (MCList.size() == 0) {
+                                                from
+                                                Maintenance_Contract__c
+                                                where
+                                                id = :Maintenance_ContractID];
+        if (MCList.size() == 0) {
             throw new ControllerUtil.myException('缁翠慨鍚堝悓涓嶅瓨鍦ㄣ��');
         }
         if(MCList[0].Estimation_Id__c == null){
-          throw new ControllerUtil.myException('缁翠慨鍚堝悓鎶ヤ环涓嶅瓨鍦ㄣ��');
+            throw new ControllerUtil.myException('缁翠慨鍚堝悓鎶ヤ环涓嶅瓨鍦ㄣ��');
         }
 
         //宸″洖銆佺偣妫�鍜岄櫎灏樹负0鏄樉绀轰负'/'
@@ -181,6 +183,9 @@
         public String TermFour_Once_Two {get; private set;}
         public String TermFour_Once_Three {get; private set;}
         public String TermFour_Once_Four {get; private set;}
+        //add    wangweipeng     2021/12/10      start
+        public String TermFour_Once_Five {get; private set;}
+        //add    wangweipeng     2021/12/10      end
         public String TermFour_Much {get; private set;}
         public String TermFour_Much_One {get; private set;}
         public String TermFour_Much_Two {get; private set;}
@@ -195,8 +200,14 @@
         public String TermFour_Much6 {get; private set;}
         public String TermFive_Title {get; private set;}
         public String TermFive_Head {get; private set;}
+        //add    wangweipeng     2021/12/10      start
+        public String TermFive_Head2 {get; private set;}
+        //add    wangweipeng     2021/12/10      end
         public String TermFive_One {get; private set;}
         public String TermFive_One2 {get; private set;}
+        //add    wangweipeng     2021/12/10      start
+        public String TermFive_One3 {get; private set;}
+        //add    wangweipeng     2021/12/10      end
         public String TermFive_Two {get; private set;}
         public String TermFive_Two2 {get; private set;}
         public String TermFive_Three {get; private set;}
@@ -206,6 +217,9 @@
         public String TermFive_Five2 {get; private set;}
         public String TermFive_Six {get; private set;}
         public String TermFive_Seven {get; private set;}
+        //add    wangweipeng     2021/12/10      start
+        public String TermFive_Seven2 {get; private set;}
+        //add    wangweipeng     2021/12/10      end
         public String TermFive_Eight {get; private set;}
         public String TermFive_Nine {get; private set;}
         public String TermFive_Ten {get; private set;}
@@ -235,6 +249,10 @@
         //LJPH-BUKD5A 銆婂鎵樸�嬪悎鍚屾枃鏈殑淇敼  绮剧悽鎶�鏈� wql 2020/10/23  start
                     //鏍规嵁缁忛攢鍟嗗悕鏄惁鏈夊�煎垽鏂槸鍚︽墦鍗版柊/鍚堝悓鐗堟湰
         public String TermTen_One {get; private set;}
+        //add    wangweipeng     2021/12/10      start
+        public String TermTen_One2 {get; private set;}
+        public String TermTen_Two2 {get; private set;}
+        //add    wangweipeng     2021/12/10      end
         public String TermTen_Two {get; private set;}
         public String TermEleven_One {get; private set;}
         public String TermEleven_Two {get; private set;}
@@ -247,24 +265,24 @@
         public String TermSeven_Table12 {get; private set;}
         public String TermSeven_Table21 {get; private set;}
         public String TermSeven_Table22 {get; private set;}
-      public String TermSeven_Table31 {get; private set;}
-      public String TermSeven_Table32 {get; private set;}
-      public String TermSeven_Table41 {get; private set;}
-      public String TermSeven_Table42 {get; private set;}
-      public String TermSeven_Table51 {get; private set;}
-      public String TermSeven_Table52 {get; private set;}
-      public String TermSeven_Table61 {get; private set;}
-      public String TermSeven_Table62 {get; private set;}
-      public String TermSeven_Table71 {get; private set;}
-      public String TermSeven_Table72 {get; private set;}
-      public String TermSeven_Table81 {get; private set;}
-      public String TermSeven_Table82 {get; private set;}
-      public String TermSeven_Table91 {get; private set;}
-      public String TermSeven_Table92 {get; private set;}
-      public String TermSeven_Table101 {get; private set;}
-      public String TermSeven_Table102 {get; private set;}
-      public String TermSeven_Table111 {get; private set;}
-      public String TermSeven_Table112 {get; private set;}
+        public String TermSeven_Table31 {get; private set;}
+        public String TermSeven_Table32 {get; private set;}
+        public String TermSeven_Table41 {get; private set;}
+        public String TermSeven_Table42 {get; private set;}
+        public String TermSeven_Table51 {get; private set;}
+        public String TermSeven_Table52 {get; private set;}
+        public String TermSeven_Table61 {get; private set;}
+        public String TermSeven_Table62 {get; private set;}
+        public String TermSeven_Table71 {get; private set;}
+        public String TermSeven_Table72 {get; private set;}
+        public String TermSeven_Table81 {get; private set;}
+        public String TermSeven_Table82 {get; private set;}
+        public String TermSeven_Table91 {get; private set;}
+        public String TermSeven_Table92 {get; private set;}
+        public String TermSeven_Table101 {get; private set;}
+        public String TermSeven_Table102 {get; private set;}
+        public String TermSeven_Table111 {get; private set;}
+        public String TermSeven_Table112 {get; private set;}
         // HWAG-BLWFGC  杩藉姞绗叓鏉★紝鍘熷叓涔濇潯椤哄欢 update by vivek start
         public String TermEightAppend_Title {get; private set;}
         public String TermEightAppend_One {get; private set;}
@@ -277,7 +295,7 @@
         // HWAG-BLWFGC  杩藉姞绗叓鏉★紝鍘熷叓涔濇潯椤哄欢 update by vivek end
 
 
-      public String FirstPartyAbbreviation {get; private set;}
+        public String FirstPartyAbbreviation {get; private set;}
         public String SecondPartyAbbreviation {get; private set;}
 
 
@@ -307,9 +325,9 @@
 
 
         private void setDate(Date StartDate, Date EndDate, Date FirstPaymentDate,
-          Date SecondPaymentDate,Date ThirdPaymentDate,
-          Date ForthPaymentDate,Date FifthPaymentDate,
-          Date SixthPaymentDate){
+            Date SecondPaymentDate,Date ThirdPaymentDate,
+            Date ForthPaymentDate,Date FifthPaymentDate,
+            Date SixthPaymentDate){
             if( StartDate != null ){
                 this.StartYear = String.valueOf(StartDate.year());
                 this.StartMonth =  String.valueOf(StartDate.month());
@@ -429,13 +447,13 @@
               //       this.Payment_two = '鏃ュ唴锛岀敳鏂瑰悜涔欐柟鏀粯鍏ㄩ儴鍚堝悓娆句汉姘戝竵';
               //       this.Payment_Four = '鍏� ( 澶у啓';
               //   }else{
-                // this.Payment_Three = '鏃ュ墠锛岀敳鏂瑰悜涔欐柟鏀粯浜烘皯甯�';
-                // this.Payment_Four = '鍏� ( 澶у啓';
+                    // this.Payment_Three = '鏃ュ墠锛岀敳鏂瑰悜涔欐柟鏀粯浜烘皯甯�';
+                    // this.Payment_Four = '鍏� ( 澶у啓';
               //   }
                 setDate(MC.Contract_Start_Date__c,MC.Contract_End_Date__c, 
-                  MC.Payment_Plan_Date_First__c, MC.Payment_Plan_Date_Second__c,
-                  MC.Payment_Plan_Date_Third__c, MC.Payment_Plan_Date_Forth__c, 
-                  MC.Payment_Plan_Date_Fifth__c, MC.Payment_Plan_Date_Sixth__c);
+                    MC.Payment_Plan_Date_First__c, MC.Payment_Plan_Date_Second__c,
+                    MC.Payment_Plan_Date_Third__c, MC.Payment_Plan_Date_Forth__c, 
+                    MC.Payment_Plan_Date_Fifth__c, MC.Payment_Plan_Date_Sixth__c);
                 if(MC.Total_Payment_Time__c!=null){
                     this.Total_Payment_Time = integer.valueof(MC.Total_Payment_Time__c);
                 }
@@ -473,88 +491,100 @@
                 this.TermZero_Three = '浠跺ゥ鏋楀反鏂郴鍒椾骇鍝佸湪鏈悎鍚屾湇鍔″鎵樻湡闄愬唴鐢变箼鏂规彁渚涙湁鍋挎湇鍔★紙鍖呮嫭涔欐柟鍗忓姪涓欐柟瀵瑰弬淇濊澶囪繘琛岄闃叉晠闅滃伐浣滐紝涓哄弬淇濊澶囨彁渚涚淮淇湇鍔°�佸鍝佹湇鍔°�佸皬淇繚鍏诲拰鍚堝悓鎵ц鎶ュ憡绛夋湇鍔★級鑰岀璁㈡湰缁翠慨涓氬姟濮旀墭鍗忚锛堜互涓嬬畝绉扳�滄湰鍚堝悓鈥濓級銆�';
                 this.TermOne_One = '涓�銆�    鏈悎鍚岀殑鍙備繚璁惧娓呭崟鍙傝闄勪欢1锛屼笖蹇呴』鍦ㄦ湇鍔″鎵樻湡寮�濮嬫椂澶勪簬鍋ュ悍瀹屽ソ鐘舵�併�傚鍙備繚鏃舵湁鏁呴殰瀛樺湪锛岄櫎鍙屾柟鏈夊彟琛岀害瀹氬锛屽凡鏈夋晠闅滃簲璇ュ厛杩涜淇悊涓斾笉璁″叆鏈悎鍚岋紝涔嬪悗涔欐柟鎸夋湰鍚堝悓绾﹀畾鎵挎媴鐩稿簲璐d换銆�';
                 this.TermOne_Two = '鎵�鏈夐檮浠舵槸鏈悎鍚屾湁鏁堢粍鎴愰儴鍒嗭紝涓庢湰鍚堝悓鍏锋湁鍚岀瓑娉曞緥鏁堝姏銆�';
-              this.TermTwo_One = '浜屻��     鏈悎鍚屾湇鍔″鎵樻湡闄愪负';
-              this.TermThree_One = '涓夈��   鏈悎鍚屾�婚噾棰�';
-              this.TermThree_Two = '鍏�(浜烘皯甯佸ぇ鍐�';
-              this.TermThree_Three = ')銆�';
-              this.TermFour_One = '鍥涖��  浠樻鏂瑰紡';
-              this.TermFour_Two = '鏈悎鍚岄噾棰濈敱鐢叉柟锛�';
-              this.TermFour_Once = '涓�娆℃�ф敮浠�';
-              this.TermFour_Once_One = '鏈悎鍚屾寮忕璁箣鏃ヨ捣';
-              this.TermFour_Once_Two = '鏃ュ唴锛岀敳鏂瑰悜涔欐柟鏀粯鍏ㄩ儴鍚堝悓娆句汉姘戝竵';
-              this.TermFour_Once_Three = '鍏冿紙澶у啓';
-              this.TermFour_Once_Four = ')銆�';
-              this.TermFour_Much = '澶氭鏀粯';
-              this.TermFour_Much_One = '鏈悎鍚屾椤瑰垎';
-              this.TermFour_Much_Two = '鏈熶粯鍑猴紝璇︾粏濡備笅锛�';
-              this.TermFour_Much1 = '绗竴鏈熸椤逛粯娆炬椂闂翠负';
-              this.TermFour_Much_Same1 = '鍓嶏紙鍚級锛岀敳鏂瑰悜涔欐柟鏀粯浜烘皯甯�';
-              this.TermFour_Much_Same2 = '鍏�(浜烘皯甯佸ぇ鍐�';
-              this.TermFour_Much_Same3 = ')銆�';
-              this.TermFour_Much2 = '绗簩鏈熸椤逛粯娆炬椂闂翠负';
-              this.TermFour_Much3 = '绗笁鏈熸椤逛粯娆炬椂闂翠负';
-              this.TermFour_Much4 = '绗洓鏈熸椤逛粯娆炬椂闂翠负';
-              this.TermFour_Much5 = '绗簲鏈熸椤逛粯娆炬椂闂翠负';
-              this.TermFour_Much6 = '绗叚鏈熸椤逛粯娆炬椂闂翠负';
+                this.TermTwo_One = '浜屻��     鏈悎鍚屾湇鍔″鎵樻湡闄愪负';
+                this.TermThree_One = '涓夈��   鏈悎鍚屾�婚噾棰�';
+                this.TermThree_Two = '鍏�(浜烘皯甯佸ぇ鍐�';
+                this.TermThree_Three = '鍏冩暣)銆�';
+                this.TermFour_One = '鍥涖�� 浠樻鏂瑰紡';
+                this.TermFour_Two = '鏈悎鍚岄噾棰濈敱鐢叉柟锛�';
+                this.TermFour_Once = '涓�娆℃�ф敮浠�';
+                this.TermFour_Once_One = '鏈悎鍚屾寮忕璁箣鏃ヨ捣';
+                this.TermFour_Once_Two = '鏃ュ唴锛岀敳鏂瑰悜涔欐柟鏀粯鍏ㄩ儴鍚堝悓娆句汉姘戝竵';
+                this.TermFour_Once_Three = '鍏冿紙澶у啓';
+                this.TermFour_Once_Four = '鍏冩暣)銆�';
+                //add      wangweipeng            2021/12/10               start
+                this.TermFour_Once_Five= '涔欐柟鏀跺埌鐢叉柟娆鹃」鍚庣殑7涓伐浣滄棩鍐呭悜鐢叉柟鎻愪緵姝h鍙戠エ銆�';
+                //add      wangweipeng            2021/12/10               end
+                this.TermFour_Much = '澶氭鏀粯';
+                this.TermFour_Much_One = '鏈悎鍚屾椤瑰垎';
+                this.TermFour_Much_Two = '鏈熶粯鍑猴紝璇︾粏濡備笅锛�';
+                this.TermFour_Much1 = '绗竴鏈熸椤逛粯娆炬椂闂翠负';
+                this.TermFour_Much_Same1 = '鍓嶏紙鍚級锛岀敳鏂瑰悜涔欐柟鏀粯浜烘皯甯�';
+                this.TermFour_Much_Same2 = '鍏�(浜烘皯甯佸ぇ鍐�';
+                this.TermFour_Much_Same3 = ')銆�';
+                this.TermFour_Much2 = '绗簩鏈熸椤逛粯娆炬椂闂翠负';
+                this.TermFour_Much3 = '绗笁鏈熸椤逛粯娆炬椂闂翠负';
+                this.TermFour_Much4 = '绗洓鏈熸椤逛粯娆炬椂闂翠负';
+                this.TermFour_Much5 = '绗簲鏈熸椤逛粯娆炬椂闂翠负';
+                this.TermFour_Much6 = '绗叚鏈熸椤逛粯娆炬椂闂翠负';
 
-              this.TermFive_Title = '浜斻��  涔欐柟璐d换鑼冨洿';
-              this.TermFive_Head = '鍦ㄦ湰鍚堝悓鏈嶅姟濮旀墭鏈熼棿鍐咃紝涔欐柟瀵规湰鍚堝悓鍙備繚璁惧鎻愪緵濡備笅鏈嶅姟锛�';
-              this.TermFive_One = '1銆�   鏈悎鍚屽弬淇濊澶囧洜鑷劧鎹熻�楁垨鎸夌収涔欐柟瑕佹眰杩涜娓呮礂娑堟瘨鐨勬儏鍐典笅鍙戠敓鏁呴殰';
+                this.TermFive_Title = '浜斻��   涔欐柟璐d换鑼冨洿';
+                this.TermFive_Head = '鍦ㄦ湰鍚堝悓鏈嶅姟濮旀墭鏈熼棿鍐咃紝涔欐柟瀵规湰鍚堝悓鍙備繚璁惧鎻愪緵濡備笅鏈嶅姟锛�';
+                //add      wangweipeng            2021/12/10               start
+                this.TermFive_Head2 = '鍦ㄤ箼鏂规敹鍒扮敳鏂规寜鏈崗璁鍥涙潯绾﹀畾鐨勫叏閮ㄦ椤瑰悗锛屽湪鏈悎鍚屾湇鍔″鎵樻湡闂村唴锛屼箼鏂瑰鏈悎鍚屽弬淇濊澶囨彁渚涙湰鍗忚绾﹀畾鏈嶅姟锛屽惁鍒欎箼鏂规湁鏉冩嫆缁濇彁渚涚洿鑷崇敳鏂规寜绾﹀饱琛屼粯娆句箟鍔°�傚叿浣撴湇鍔″涓嬶細 ';
+                //add      wangweipeng            2021/12/10               end
+                this.TermFive_One = '1銆�   鏈悎鍚屽弬淇濊澶囧洜鑷劧鎹熻�楁垨鎸夌収涔欐柟瑕佹眰杩涜娓呮礂娑堟瘨鐨勬儏鍐典笅鍙戠敓鏁呴殰';
                 this.TermFive_One2 = '鏃讹紝鐢变箼鏂硅繘琛岀淮淇�傚洜鏁呮剰浜轰负鎹熷潖瀵艰嚧鐨勬晠闅滐紝涓嶅湪鏈悎鍚岀淮淇寖鍥村唴銆�';
-              this.TermFive_Two = '2銆�   鍦ㄩ浂浠堕綈澶囩殑鎯呭喌涓嬶紝涔欐柟淇濊瘉';
-              this.TermFive_Two2 = '灏忔椂涔嬪唴瀹屾垚灏忕淮淇��';
-              this.TermFive_Three = '3銆�   鍦ㄩ浂浠堕綈澶囩殑鎯呭喌涓嬶紝涔欐柟淇濊瘉';
-              this.TermFive_Three1 = '涓伐浣滄棩鍐呭畬鎴愬ぇ缁翠慨銆�';
-              this.TermFive_Four = '4銆�   涔欐柟鍙鏈悎鍚屽弬淇濊澶囦腑鍛ㄨ竟浠櫒鐨勪富鏈猴紝鍏夋簮锛岃秴澹颁富鏈恒�佸唴闀滄竻娲楁秷姣掓満鍜岀洃瑙嗗櫒杩涜缁翠慨銆傚叾浠栦笌鍛ㄨ竟浠櫒鐩稿叧鐨勪笉鍙淮淇殑璁惧锛堝鐢电紗绾裤�佽秴澹版帰澶淬�佹按鐡躲�侀敭鐩樸�佽剼韪忕瓑锛夊拰鑰楀搧锛堝娓呮礂鐢ㄥ叿銆佹不鐤楅檮浠躲�佸厜婧愮伅娉$瓑锛変笉灞炰簬缁翠慨鑼冨洿銆�';
-              this.TermFive_Five = '5銆�   鍘熷垯涓婃湰鍚堝悓鎵�闄勮澶囧湪鏈悎鍚岀浜屾潯绾﹀畾鐨勫悎鍚屾湇鍔″鎵樻湡闄愬唴涓斿湪鏈悎';
+                //add      wangweipeng            2021/12/10               start
+                this.TermFive_One3 = '鏃讹紝鐢变箼鏂硅繘琛岀淮淇�傚洜涓欐柟鏁呮剰浜轰负鎹熷潖瀵艰嚧鐨勬晠闅滐紝涓嶅湪鏈悎鍚岀淮淇寖鍥村唴銆�';
+                //add      wangweipeng            2021/12/10               end
+                this.TermFive_Two = '2銆�   鍦ㄩ浂浠堕綈澶囩殑鎯呭喌涓嬶紝涔欐柟淇濊瘉';
+                this.TermFive_Two2 = '灏忔椂涔嬪唴瀹屾垚灏忕淮淇��';
+                this.TermFive_Three = '3銆�   鍦ㄩ浂浠堕綈澶囩殑鎯呭喌涓嬶紝涔欐柟淇濊瘉';
+                this.TermFive_Three1 = '涓伐浣滄棩鍐呭畬鎴愬ぇ缁翠慨銆�';
+                this.TermFive_Four = '4銆�   涔欐柟鍙鏈悎鍚屽弬淇濊澶囦腑鍛ㄨ竟浠櫒鐨勪富鏈猴紝鍏夋簮锛岃秴澹颁富鏈恒�佸唴闀滄竻娲楁秷姣掓満鍜岀洃瑙嗗櫒杩涜缁翠慨銆傚叾浠栦笌鍛ㄨ竟浠櫒鐩稿叧鐨勪笉鍙淮淇殑璁惧锛堝鐢电紗绾裤�佽秴澹版帰澶淬�佹按鐡躲�侀敭鐩樸�佽剼韪忕瓑锛夊拰鑰楀搧锛堝娓呮礂鐢ㄥ叿銆佹不鐤楅檮浠躲�佸厜婧愮伅娉$瓑锛変笉灞炰簬缁翠慨鑼冨洿銆�';
+                this.TermFive_Five = '5銆�   鍘熷垯涓婃湰鍚堝悓鎵�闄勮澶囧湪鏈悎鍚岀浜屾潯绾﹀畾鐨勫悎鍚屾湇鍔″鎵樻湡闄愬唴涓斿湪鏈悎';
                 this.TermFive_Five2 = '鍚岀敓鏁堜箣鍓嶅彂鐢熺殑鏁呴殰锛屼箼鏂瑰湪鏈悎鍚岀敓鏁堝悗鎻愪緵缁翠慨鏈嶅姟涓旂淮淇垂鐢ㄨ鍏ユ湰鍚堝悓銆備絾鏄壒渚嬫儏鍐靛彲鐢辩敳涔欏弻鏂逛互琛ュ厖鍗忚鐨勬柟寮忓彟琛岀害瀹氥��';
-              this.TermFive_Six = '6銆�   鑻ョ敱浜庨浂浠惰璐�佸仠浜х瓑鍘熷洜鏃犳硶淇悊锛屽垯涔欐柟鍙慨鐞嗗彲缁翠慨鐨勪骇鍝佹垨浜у搧鐨勯儴鍒嗗姛鑳姐��';
-              this.TermFive_Seven = '7銆�   濡傛灉鏈悎鍚屽弬淇濊澶囧彂鐢熶箼鏂逛慨鐞嗚矗浠昏寖鍥村唴鐨勬晠闅滈渶瑕佽繘琛屽ぇ缁翠慨鏃讹紝涔欐柟浼樺厛鍚戜笝鏂规彁渚涘鍝併�備箼鏂圭‘淇濆懆杈硅澶囩被鐨勫鍝佹彁渚涖��';
-              this.TermFive_Eight = '8銆�   鑷湰鍚堝悓鐢熸晥鏃ヨ捣姣忛殧3涓湀涓斿湪鏈悎鍚屾湇鍔″鎵樻湡鍐咃紝涔欐柟灏嗗悜涓欐柟鎻愪緵鍚堝悓鎵ц鎶ュ憡锛屾彁渚涘墠闇�鑾峰緱鐢叉柟鐨勮鍙�傚叿浣撳唴瀹圭敱涔欐柟鍒跺畾锛屽寘鎷笖涓嶉檺浜庯細鍚堝悓鎵ц鏁版嵁锛屼箼鏂瑰伐浣滄眹鎶ワ紝鍚堝悓鍙備繚璁惧鏁呴殰鎯呭喌鍜岀浉搴旀晠闅滈闃插缓璁瓑銆�';
-              this.TermFive_Nine = '9銆�   鍦ㄦ湰鍚堝悓鏈嶅姟濮旀墭鏈熷唴锛屼箼鏂圭粨鍚堜笝鏂圭殑瀹為檯鎯呭喌锛屽垽鏂槸鍚﹁鍚戞湰鍚堝悓鍙備繚璁惧鎻愪緵鏁呴殰棰勯槻宸ュ叿銆傚涔欐柟鍒ゆ柇闇�瑕佹椂锛岀敱涔欐柟鐩存帴鍚戜笝鏂规彁渚涖�傚叿浣撴彁渚涙柟寮忓拰鏁伴噺锛屼互涔欐柟鍒ゆ柇涓哄噯銆�';
-              this.TermFive_Ten = '10銆�   涔欐柟鎸囧畾宸ョ▼甯堜负涓欐柟鎻愪緵1骞�';
-              this.TermFive_Ten2 = '娆$偣妫�锛屽苟鎻愪氦妫�鏌ユ姤鍛婄粰鍖婚櫌澶囨。銆�';
+                this.TermFive_Six = '6銆�   鑻ョ敱浜庨浂浠惰璐�佸仠浜х瓑鍘熷洜鏃犳硶淇悊锛屽垯涔欐柟鍙慨鐞嗗彲缁翠慨鐨勪骇鍝佹垨浜у搧鐨勯儴鍒嗗姛鑳姐��';
+                this.TermFive_Seven = '7銆�   濡傛灉鏈悎鍚屽弬淇濊澶囧彂鐢熶箼鏂逛慨鐞嗚矗浠昏寖鍥村唴鐨勬晠闅滈渶瑕佽繘琛屽ぇ缁翠慨鏃讹紝涔欐柟浼樺厛鍚戜笝鏂规彁渚涘鍝併�備箼鏂圭‘淇濆懆杈硅澶囩被鐨勫鍝佹彁渚涖��';
+                //add      wangweipeng            2021/12/10               start
+                this.TermFive_Seven2 = '7銆�   濡傛灉鏈悎鍚屽弬淇濊澶囧彂鐢熶箼鏂逛慨鐞嗚矗浠昏寖鍥村唴鐨勬晠闅滈渶瑕佽繘琛屽ぇ缁翠慨鏃讹紝涔欐柟浼樺厛鍚戜笝鏂规彁渚涘鍝併�備箼鏂圭‘淇濇弧瓒充笝鏂瑰懆杈硅澶囩被鐨勫鍝佹彁渚涖��';
+                //add      wangweipeng            2021/12/10               end
+                this.TermFive_Eight = '8銆�   鑷湰鍚堝悓鐢熸晥鏃ヨ捣姣忛殧3涓湀涓斿湪鏈悎鍚屾湇鍔″鎵樻湡鍐咃紝涔欐柟灏嗗悜涓欐柟鎻愪緵鍚堝悓鎵ц鎶ュ憡锛屾彁渚涘墠闇�鑾峰緱鐢叉柟鐨勮鍙�傚叿浣撳唴瀹圭敱涔欐柟鍒跺畾锛屽寘鎷笖涓嶉檺浜庯細鍚堝悓鎵ц鏁版嵁锛屼箼鏂瑰伐浣滄眹鎶ワ紝鍚堝悓鍙備繚璁惧鏁呴殰鎯呭喌鍜岀浉搴旀晠闅滈闃插缓璁瓑銆�';
+                this.TermFive_Nine = '9銆�   鍦ㄦ湰鍚堝悓鏈嶅姟濮旀墭鏈熷唴锛屼箼鏂圭粨鍚堜笝鏂圭殑瀹為檯鎯呭喌锛屽垽鏂槸鍚﹁鍚戞湰鍚堝悓鍙備繚璁惧鎻愪緵鏁呴殰棰勯槻宸ュ叿銆傚涔欐柟鍒ゆ柇闇�瑕佹椂锛岀敱涔欐柟鐩存帴鍚戜笝鏂规彁渚涖�傚叿浣撴彁渚涙柟寮忓拰鏁伴噺锛屼互涔欐柟鍒ゆ柇涓哄噯銆�';
+                this.TermFive_Ten = '10銆�   涔欐柟鎸囧畾宸ョ▼甯堜负涓欐柟鎻愪緵1骞�';
+                this.TermFive_Ten2 = '娆$偣妫�锛屽苟鎻愪氦妫�鏌ユ姤鍛婄粰鍖婚櫌澶囨。銆�';
 
-              this.TermSix_Title = '鍏��  鐢叉柟璐d换鑼冨洿 ';
-              this.TermSix_One = '1銆�   鐢叉柟搴旀寜鏈悎鍚岀害瀹氬強鏃舵敮浠樺鎵樿垂鐢ㄣ��';
-              this.TermSix_Two = '2銆�   鐢叉柟搴旈厤鍚堜笝鏂规寜鐓т箼鏂硅鏄庝功绉瀬鍋氬ソ鏈悎鍚屽弬淇濊澶囩殑鏃ュ父缁存姢鍜屼繚鍏诲伐浣滐紝纭繚鍐呴暅濮嬬粓澶勪簬鑹ソ鐨勫伐浣滅姸鎬併��';
-              this.TermSix_Three = '3銆�   鑻ヤ笝鏂瑰皢鏈悎鍚屽弬淇濊澶囬�佽嚦闈炲ゥ鏋楀反鏂巶瀹惰繘琛岀淮淇紝涔欐柟瀵圭粡杩囬潪濂ユ灄宸存柉鍘傚缁翠慨鐨勮澶囪繘琛岀淮淇椂锛屽皢鎸夋甯告爣鍑嗗悜鐢叉柟鏀跺彇缁翠慨璐圭敤锛岃�屼笉瑙嗕负鏈悎鍚岃垂鐢ㄣ��';
-              this.TermSix_Four = '4銆�   鑻ヤ笝鏂硅嚜琛屾媶鍗告湰鍚堝悓鍙備繚璁惧锛屼箼鏂瑰涓欐柟鑷鎷嗗嵏鐨勮澶囪繘琛岀淮淇椂锛屽皢鎸夋甯告爣鍑嗗悜鐢叉柟鏀跺彇缁翠慨璐圭敤锛岃�屼笉瑙嗕负鏈悎鍚岃垂鐢ㄣ��';
-              this.TermSix_Five = '5銆�   鑻ヤ笝鏂瑰皢鏈悎鍚屽弬淇濊澶囧�熺粰鍏朵粬鍖婚櫌鎴栨満鏋勪娇鐢紝鐢辨閫犳垚鐨勬晠闅滐紝涔欐柟灏嗗悜鐢叉柟鏀跺彇姝e父鐨勭淮淇垂锛岃�屼笉瑙嗕负鏈悎鍚岃垂鐢ㄣ��';
-              this.TermSix_Six = '6銆�   濡傛灉鍥犱负涓欐柟浣跨敤涓嶅尮閰嶇殑闈炲ゥ鏋楀反鏂垨涔欐柟涓嶆帹鑽愬唴闀滈檮浠跺鑷寸殑鎹熷潖鏁�';
+                this.TermSix_Title = '鍏��    鐢叉柟璐d换鑼冨洿 ';
+                this.TermSix_One = '1銆�   鐢叉柟搴旀寜鏈悎鍚岀害瀹氬強鏃舵敮浠樺鎵樿垂鐢ㄣ��';
+                this.TermSix_Two = '2銆�   鐢叉柟搴旈厤鍚堜笝鏂规寜鐓т箼鏂硅鏄庝功绉瀬鍋氬ソ鏈悎鍚屽弬淇濊澶囩殑鏃ュ父缁存姢鍜屼繚鍏诲伐浣滐紝纭繚鍐呴暅濮嬬粓澶勪簬鑹ソ鐨勫伐浣滅姸鎬併��';
+                this.TermSix_Three = '3銆�   鑻ヤ笝鏂瑰皢鏈悎鍚屽弬淇濊澶囬�佽嚦闈炲ゥ鏋楀反鏂巶瀹惰繘琛岀淮淇紝涔欐柟瀵圭粡杩囬潪濂ユ灄宸存柉鍘傚缁翠慨鐨勮澶囪繘琛岀淮淇椂锛屽皢鎸夋甯告爣鍑嗗悜鐢叉柟鏀跺彇缁翠慨璐圭敤锛岃�屼笉瑙嗕负鏈悎鍚岃垂鐢ㄣ��';
+                this.TermSix_Four = '4銆�   鑻ヤ笝鏂硅嚜琛屾媶鍗告湰鍚堝悓鍙備繚璁惧锛屼箼鏂瑰涓欐柟鑷鎷嗗嵏鐨勮澶囪繘琛岀淮淇椂锛屽皢鎸夋甯告爣鍑嗗悜鐢叉柟鏀跺彇缁翠慨璐圭敤锛岃�屼笉瑙嗕负鏈悎鍚岃垂鐢ㄣ��';
+                this.TermSix_Five = '5銆�   鑻ヤ笝鏂瑰皢鏈悎鍚屽弬淇濊澶囧�熺粰鍏朵粬鍖婚櫌鎴栨満鏋勪娇鐢紝鐢辨閫犳垚鐨勬晠闅滐紝涔欐柟灏嗗悜鐢叉柟鏀跺彇姝e父鐨勭淮淇垂锛岃�屼笉瑙嗕负鏈悎鍚岃垂鐢ㄣ��';
+                this.TermSix_Six = '6銆�   濡傛灉鍥犱负涓欐柟浣跨敤涓嶅尮閰嶇殑闈炲ゥ鏋楀反鏂垨涔欐柟涓嶆帹鑽愬唴闀滈檮浠跺鑷寸殑鎹熷潖鏁�';
                 this.TermSix_Six2 = '闅滐紝涔欐柟灏嗗悜鐢叉柟鏀跺彇姝e父鐨勭淮淇垂锛岃�屼笉瑙嗕负鏈悎鍚岃垂鐢ㄣ��';
-              this.TermSix_Seven = '7銆�   鐢叉柟搴旇涓诲姩绉瀬閰嶅悎涔欐柟鍗忓姪涓轰笝鏂规彁渚涜澶囩鐞嗘湇鍔★紝闄嶄綆鍥犱负浜轰负鍘熷洜閫犳垚鐨勬崯鍧忋��';
-              this.TermSix_Eight = '8銆�   鐢叉柟搴旂Н鏋侀厤鍚堜箼鏂瑰饱琛屽悎鍚屼箟鍔★紝鍙婃椂鎻愪緵鍚勭鏉愭枡锛屽浜庝箼鏂规彁渚涚殑鏈嶅姟鏂规绛夛紝鐢叉柟鏈変箟鍔″強鏃剁‘璁ゆ垨鍙嶉鎰忚銆�';
-              this.TermSix_Nine = '9銆�   鐢叉柟鏈粡涔欐柟浜嬪厛涔﹂潰鍚屾剰锛屼笉寰楀皢鏈悎鍚屽綋浜嬩汉鐨勫湴浣嶄互鍙婁緷鏈悎鍚屼骇鐢熺殑浠讳綍鏉冨埄涔夊姟杞缁欑涓変汉鎴栨彁渚涙媴淇濄��';
-              this.TermSix_Ten = '10銆�  鐢叉柟搴斾繚瀹堜箼鏂圭殑鍟嗕笟鏈哄瘑锛屼笉寰楀悜浠讳綍绗笁鏂规硠闇蹭换浣曟垨鍏ㄩ儴鍖呮嫭涔欐柟鐨勯攢鍞�佸競鍦恒�佹妧鏈�佺淮淇互鍙婁换浣曞叾瀹冭鍛婄煡鎴栦粠鍙︿竴鏂瑰彇寰椾箼鏂圭殑淇℃伅锛涙棤璁烘淇℃伅鍦ㄦ湰鍚堝悓涓槸鍚︽爣鏄庢垨鐣屽畾涓烘満瀵嗐�傚悓鏃朵笉寰楀皢璇ヤ俊鎭敤浜庨潪鏈悎鍚屾墍杩扮殑鐩殑銆傛湰鏉¤瀹氱殑淇濆瘑鏈熼檺鍦ㄦ湰鍚堝悓鏈熸弧鎴栫粓姝㈠悗缁х画鏈夋晥銆�';
+                this.TermSix_Seven = '7銆�   鐢叉柟搴旇涓诲姩绉瀬閰嶅悎涔欐柟鍗忓姪涓轰笝鏂规彁渚涜澶囩鐞嗘湇鍔★紝闄嶄綆鍥犱负浜轰负鍘熷洜閫犳垚鐨勬崯鍧忋��';
+                this.TermSix_Eight = '8銆�   鐢叉柟搴旂Н鏋侀厤鍚堜箼鏂瑰饱琛屽悎鍚屼箟鍔★紝鍙婃椂鎻愪緵鍚勭鏉愭枡锛屽浜庝箼鏂规彁渚涚殑鏈嶅姟鏂规绛夛紝鐢叉柟鏈変箟鍔″強鏃剁‘璁ゆ垨鍙嶉鎰忚銆�';
+                this.TermSix_Nine = '9銆�   鐢叉柟鏈粡涔欐柟浜嬪厛涔﹂潰鍚屾剰锛屼笉寰楀皢鏈悎鍚屽綋浜嬩汉鐨勫湴浣嶄互鍙婁緷鏈悎鍚屼骇鐢熺殑浠讳綍鏉冨埄涔夊姟杞缁欑涓変汉鎴栨彁渚涙媴淇濄��';
+                this.TermSix_Ten = '10銆�  鐢叉柟搴斾繚瀹堜箼鏂圭殑鍟嗕笟鏈哄瘑锛屼笉寰楀悜浠讳綍绗笁鏂规硠闇蹭换浣曟垨鍏ㄩ儴鍖呮嫭涔欐柟鐨勯攢鍞�佸競鍦恒�佹妧鏈�佺淮淇互鍙婁换浣曞叾瀹冭鍛婄煡鎴栦粠鍙︿竴鏂瑰彇寰椾箼鏂圭殑淇℃伅锛涙棤璁烘淇℃伅鍦ㄦ湰鍚堝悓涓槸鍚︽爣鏄庢垨鐣屽畾涓烘満瀵嗐�傚悓鏃朵笉寰楀皢璇ヤ俊鎭敤浜庨潪鏈悎鍚屾墍杩扮殑鐩殑銆傛湰鏉¤瀹氱殑淇濆瘑鏈熼檺鍦ㄦ湰鍚堝悓鏈熸弧鎴栫粓姝㈠悗缁х画鏈夋晥銆�';
 
-              this.TermSeven_Title = '涓冦��  鐢蹭箼鍙屾柟鍚屾剰鏈悎鍚岃繘琛岀画绛炬椂锛岀户缁弬鍔犲悎鍚岀殑鍙備繚璁惧鐨勭画绛鹃噾棰濈敱璇ヨ澶囧湪鏈悎鍚屼腑鐨勫弬淇濅环鏍间笌鏈悎鍚岀殑鍚堝悓娑堣垂鐜囪绠楋紝鍏紡锛氱画绛鹃噾棰�=鏈悎鍚屽弬淇濅环鏍�*锛�1+璋冩暣姣斾緥%锛夈�� ';
-              this.TermSeven_One = '锛堟敞锛氬悎鍚屾秷璐圭巼=鏈悎鍚屽鎵樻湡闄愬唴鎵�鏈夊弬淇濊澶囧彂鐢熺殑缁翠慨鎶ヤ环閲戦涔嬪拰/鍚堝悓閲戦*100%銆傚鎵樻湡闄愬眾婊″墠鐢变箼鏂硅礋璐e鍚堝悓娑堣垂鐜囪繘琛岄浼帮紝鍙屾柟璁ゅ彲鍚庡彲浠ユ寜姝や綔涓哄埗瀹氱画绛鹃噾棰濈殑渚濇嵁銆傦級鈥�';
-              this.TermSeven_Table11 = 'X<50%';
-              this.TermSeven_Table12 = '-40%';
-              this.TermSeven_Table21 = '50%鈮<60%';
-              this.TermSeven_Table22 = '-30%';
-              this.TermSeven_Table31 = '60%鈮<70%';
-              this.TermSeven_Table32 = '-25%';
-              this.TermSeven_Table41 = '70%鈮<80%';
-              this.TermSeven_Table42 = '-20%';
-              this.TermSeven_Table51 = '80%鈮<90%';
-              this.TermSeven_Table52 = '-15%';
-              this.TermSeven_Table61 = '90%鈮<100%';
-              this.TermSeven_Table62 = '-5%';
-              this.TermSeven_Table71 = '100%鈮<110%';
-              this.TermSeven_Table72 = '0%';
-              this.TermSeven_Table81 = '110%鈮<120%';
-              this.TermSeven_Table82 = '0%';
-              this.TermSeven_Table91 = '120%鈮<130%';
-              this.TermSeven_Table92 = '10%';
-              this.TermSeven_Table101 = '130%鈮<140%';
-              this.TermSeven_Table102 = '15%';
-              this.TermSeven_Table111 = 'X鈮�140%';
-              this.TermSeven_Table112 = '20%';
+                this.TermSeven_Title = '涓冦��  鐢蹭箼鍙屾柟鍚屾剰鏈悎鍚岃繘琛岀画绛炬椂锛岀户缁弬鍔犲悎鍚岀殑鍙備繚璁惧鐨勭画绛鹃噾棰濈敱璇ヨ澶囧湪鏈悎鍚屼腑鐨勫弬淇濅环鏍间笌鏈悎鍚岀殑鍚堝悓娑堣垂鐜囪绠楋紝鍏紡锛氱画绛鹃噾棰�=鏈悎鍚屽弬淇濅环鏍�*锛�1+璋冩暣姣斾緥%锛夈�� ';
+                this.TermSeven_One = '锛堟敞锛氬悎鍚屾秷璐圭巼=鏈悎鍚屽鎵樻湡闄愬唴鎵�鏈夊弬淇濊澶囧彂鐢熺殑缁翠慨鎶ヤ环閲戦涔嬪拰/鍚堝悓閲戦*100%銆傚鎵樻湡闄愬眾婊″墠鐢变箼鏂硅礋璐e鍚堝悓娑堣垂鐜囪繘琛岄浼帮紝鍙屾柟璁ゅ彲鍚庡彲浠ユ寜姝や綔涓哄埗瀹氱画绛鹃噾棰濈殑渚濇嵁銆傦級鈥�';
+                this.TermSeven_Table11 = 'X<50%';
+                this.TermSeven_Table12 = '-40%';
+                this.TermSeven_Table21 = '50%鈮<60%';
+                this.TermSeven_Table22 = '-30%';
+                this.TermSeven_Table31 = '60%鈮<70%';
+                this.TermSeven_Table32 = '-25%';
+                this.TermSeven_Table41 = '70%鈮<80%';
+                this.TermSeven_Table42 = '-20%';
+                this.TermSeven_Table51 = '80%鈮<90%';
+                this.TermSeven_Table52 = '-15%';
+                this.TermSeven_Table61 = '90%鈮<100%';
+                this.TermSeven_Table62 = '-5%';
+                this.TermSeven_Table71 = '100%鈮<110%';
+                this.TermSeven_Table72 = '0%';
+                this.TermSeven_Table81 = '110%鈮<120%';
+                this.TermSeven_Table82 = '0%';
+                this.TermSeven_Table91 = '120%鈮<130%';
+                this.TermSeven_Table92 = '10%';
+                this.TermSeven_Table101 = '130%鈮<140%';
+                this.TermSeven_Table102 = '15%';
+                this.TermSeven_Table111 = 'X鈮�140%';
+                this.TermSeven_Table112 = '20%';
 
 
-              this.TermSeven_Two = '2銆�   濡傚弬鍔犵画绛剧殑鍙備繚璁惧鍖呭惈鏈悎鍚岄」涓嬭澶囦互澶栫殑璁惧锛屽垯杩欓儴鍒嗚澶囩殑鍚堝悓閲戦鐢卞弻鏂瑰彟琛屽崗鍟嗙害瀹氥��';
+                this.TermSeven_Two = '2銆�   濡傚弬鍔犵画绛剧殑鍙備繚璁惧鍖呭惈鏈悎鍚岄」涓嬭澶囦互澶栫殑璁惧锛屽垯杩欓儴鍒嗚澶囩殑鍚堝悓閲戦鐢卞弻鏂瑰彟琛屽崗鍟嗙害瀹氥��';
 
                 // HWAG-BLWFGC  杩藉姞绗叓鏉★紝鍘熷叓涔濇潯椤哄欢 update by vivek start
                 this.TermEightAppend_Title = '鍏��    鍚堝悓鍙樻洿銆佷慨鏀广�佽В闄ゅ拰缁堟';
@@ -562,23 +592,23 @@
                 this.TermEightAppend_Two = '鏈悎鍚屼换浣曚竴鏂规湁涓嬪垪鎯呭舰涔嬩竴锛屽鏂瑰彲涓嶇粡鍌憡瑙i櫎鏈悎鍚岋細';
                 this.TermEightAppend_Three = '1銆佷竴鏂硅閲囧彇鏌ュ皝銆佹墸鎶笺�佸喕缁撶瓑锛屾垨琚敵璇峰紑濮嬭繘琛屾媿鍗栥�佺牬浜с�佹竻绠椼�佸悎';
                 this.TermEightAppend_Three1 = '骞躲�佸垎绔嬶紱';
-                this.TermEightAppend_Four = '2銆佷竴鏂硅繜寤跺饱琛屾湰鍚堝悓涓昏涔夊姟锛岀粡鍌憡鍚庡湪涓�鏂硅瀹氱殑鍚堢悊鏈熼檺鍐呬粛鏈饱琛岋紱';
+                this.TermEightAppend_Four = '2銆佷竴鏂瑰欢杩熷饱琛屾湰鍚堝悓涓昏涔夊姟锛岀粡鍌憡鍚庡湪涓�鏂硅瀹氱殑鍚堢悊鏈熼檺鍐呬粛鏈饱琛岋紱';
                 this.TermEightAppend_Five = '3銆佷竴鏂规湁鍏朵粬杩濈害鎴栬繚娉曡涓鸿嚧浣挎湰鍚堝悓鐩殑涓嶈兘瀹炵幇鐨勩��';
                 this.TermEightAppend_Six = '鐢变簬涓嶅彲鎶楀姏鐨勫師鍥狅紝瀵艰嚧鏈悎鍚岄儴鍒嗕笉鑳藉饱琛屻�佷笉鑳藉饱琛屾垨寤舵湡灞ヨ鏃讹紝閬囨湁涓嶅彲鎶楀姏浜嬩欢鐨勪竴鏂癸紝搴旂珛鍗冲皢浜嬫晠鎯呭喌閫氱煡瀵规柟锛屽苟鎻愪緵閮ㄥ垎涓嶈兘灞ヨ銆佷笉鑳藉饱琛屾垨寤舵湡灞ヨ鐨勭悊鐢卞拰鎵�鏈夌浉鍏崇殑鏂囦欢璧勬枡銆�';
                 // HWAG-BLWFGC  杩藉姞绗叓鏉★紝鍘熷叓涔濇潯椤哄欢 update by vivek end
                 //LJPH-BYGBSR 銆愬鎵樸�戜笌缁忛攢鍟嗙殑鏍囧噯鍚堝悓鏂囨湰淇敼 绮剧悽鎶�鏈� wql 2021/02/02 start
                 //娉ㄩ噴婧愪唬鐮�
-              // this.TermEight_Title = '涔濄��  鏈悎鍚岀殑瑙i噴涓庢墽琛岄�傜敤涓崕浜烘皯鍏卞拰鍥芥硶寰嬶紝鍦ㄥ饱琛屾湰鍚堝悓杩囩▼涓嚭鐜扮殑浜夎鍙屾柟搴斿弸濂藉崗鍟嗚В鍐筹紱鍗忓晢涓嶆垚鐨勶紝鍙�夋嫨浠ヤ笅绗紙 ';
-              // this.TermEight_Title2 = '锛夌鏂瑰紡瑙e喅锛�';
+                // this.TermEight_Title = '涔濄��   鏈悎鍚岀殑瑙i噴涓庢墽琛岄�傜敤涓崕浜烘皯鍏卞拰鍥芥硶寰嬶紝鍦ㄥ饱琛屾湰鍚堝悓杩囩▼涓嚭鐜扮殑浜夎鍙屾柟搴斿弸濂藉崗鍟嗚В鍐筹紱鍗忓晢涓嶆垚鐨勶紝鍙�夋嫨浠ヤ笅绗紙 ';
+                // this.TermEight_Title2 = '锛夌鏂瑰紡瑙e喅锛�';
 
-              // this.TermEight_One = '1銆� 浠讳綍涓�鏂规湁鏉冨悜璁惧湪鍖椾含鐨勪腑鍥藉浗闄呯粡娴庤锤鏄撲徊瑁佸鍛樹細鐢宠浠茶锛屼徊瑁佺殑瑁佸喅鏄粓灞�鎬х殑锛屽鍙屾柟鍧囨湁绾︽潫鍔涖��';
-              // this.TermEight_Two = '2銆� 鍚戠敳鏂规墍鍦ㄥ湴鏈夌杈栨潈鐨勪汉姘戞硶闄㈡彁璧疯瘔璁笺��';
-              // this.TermEight_Three = '3銆� 鍚戜箼鏂规墍鍦ㄥ湴鏈夌杈栨潈鐨勪汉姘戞硶闄㈡彁璧疯瘔璁笺��';
+                // this.TermEight_One = '1銆� 浠讳綍涓�鏂规湁鏉冨悜璁惧湪鍖椾含鐨勪腑鍥藉浗闄呯粡娴庤锤鏄撲徊瑁佸鍛樹細鐢宠浠茶锛屼徊瑁佺殑瑁佸喅鏄粓灞�鎬х殑锛屽鍙屾柟鍧囨湁绾︽潫鍔涖��';
+                // this.TermEight_Two = '2銆� 鍚戠敳鏂规墍鍦ㄥ湴鏈夌杈栨潈鐨勪汉姘戞硶闄㈡彁璧疯瘔璁笺��';
+                // this.TermEight_Three = '3銆� 鍚戜箼鏂规墍鍦ㄥ湴鏈夌杈栨潈鐨勪汉姘戞硶闄㈡彁璧疯瘔璁笺��';
                 this.TermEight_Title = '涔濄��  鏈悎鍚岀殑瑙i噴涓庢墽琛岄�傜敤涓崕浜烘皯鍏卞拰鍥芥硶寰嬶紝鍦ㄥ饱琛屾湰鍚堝悓杩囩▼涓嚭鐜扮殑浜夎鍙屾柟搴斿弸濂藉崗鍟嗚В鍐筹紱';
                 this.TermEight_Title2 = '鍥犳湰鍚堝悓寮曡捣鐨勬垨涓庢湰鍚堝悓鏈夊叧鐨勪换浣曚簤璁紝鍧囨彁璇峰寳浜徊瑁佸鍛樹細鎸夌収鍏朵徊瑁佽鍒欒繘琛屼徊瑁併�備徊瑁佽鍐虫槸缁堝眬鐨勶紝瀵瑰弻鏂瑰潎鏈夌害鏉熷姏銆�';
                 //LJPH-BYGBSR 銆愬鎵樸�戜笌缁忛攢鍟嗙殑鏍囧噯鍚堝悓鏂囨湰淇敼 绮剧悽鎶�鏈� wql 2021/02/02 end
-              this.TermNine_One = '鍗併��  鏈悎鍚岀敳鏂规墽';
-              this.TermNine_Two = '浠斤紝涔欐柟鎵�1浠斤紝鑷弻鏂圭洊绔犱箣鏃ヨ捣鐢熸晥銆傚鐢熸晥鏃ユ湡涓庢湰鍗忚绗簩鏉$害瀹氱殑濮旀墭鏈熼檺璧峰鏃ユ湡涓嶄竴鑷存椂锛屽弻鏂瑰悓鎰忎互涓よ�呬腑杈冩櫄鏃ユ湡浣滀负鏈悎鍚岀殑鐢熸晥鏃堕棿銆�';
+                this.TermNine_One = '鍗併�� 鏈悎鍚岀敳鏂规墽';
+                this.TermNine_Two = '浠斤紝涔欐柟鎵�1浠斤紝鑷弻鏂圭洊绔犱箣鏃ヨ捣鐢熸晥銆傚鐢熸晥鏃ユ湡涓庢湰鍗忚绗簩鏉$害瀹氱殑濮旀墭鏈熼檺璧峰鏃ユ湡涓嶄竴鑷存椂锛屽弻鏂瑰悓鎰忎互涓よ�呬腑杈冩櫄鏃ユ湡浣滀负鏈悎鍚岀殑鐢熸晥鏃堕棿銆�';
                 
                 //LJPH-BUKD5A 銆婂鎵樸�嬪悎鍚屾枃鏈殑淇敼  绮剧悽鎶�鏈� wql 2020/10/23  start
                     //鏍规嵁缁忛攢鍟嗗悕鏄惁鏈夊�煎垽鏂槸鍚︽墦鍗版柊/鍚堝悓鐗堟湰
@@ -591,8 +621,12 @@
                 this.TermEleven_Four ='3銆佸鑻ユ湰鍚堝悓鎵ц鏈熼棿锛岀敳鏂逛笉鍐嶆槸涔欐柟鐨勭壒绾︾粡閿�鍟嗭紝鍒欏弻鏂瑰悓鎰忕敳鏂瑰熀浜庛�婄壒绾︾粡閿�鍟嗗悎鍚屻�嬫墍缂寸撼鐨勫叏棰濅繚璇侀噾灏嗕笌鏈悎鍚屾湡婊℃垨鎻愬墠瑙i櫎骞舵墸闄ゆ瑺娆惧悗鏃犳伅杩旇繕鐢叉柟銆�';
                 //LJPH-BUKD5A 銆婂鎵樸�嬪悎鍚屾枃鏈殑淇敼  绮剧悽鎶�鏈� wql 2020/10/23  end
 
+                //add    wangweipeng     2021/12/10      start
+                this.TermTen_One2 = '鍗併�� 鏈悎鍚岀敳鏂规墽';
+                this.TermTen_Two2 = '浠斤紝涔欐柟鎵�1浠斤紝鑷弻鏂圭洊绔犱箣鏃ヨ捣鐢熸晥銆傚鐢熸晥鏃ユ湡涓庢湰鍗忚绗笁鏉$害瀹氱殑濮旀墭鏈熼檺璧峰鏃ユ湡涓嶄竴鑷存椂锛屽弻鏂瑰悓鎰忎互涓よ�呬腑杈冩櫄鏃ユ湡浣滀负鏈悎鍚岀殑鐢熸晥鏃堕棿銆�';
+                //add    wangweipeng     2021/12/10      end
             }
-              
+                
         }
 
     }
diff --git a/force-app/main/default/classes/PaymentMaintenanceContractTriggerHTest.cls b/force-app/main/default/classes/PaymentMaintenanceContractTriggerHTest.cls
new file mode 100644
index 0000000..c3d46be
--- /dev/null
+++ b/force-app/main/default/classes/PaymentMaintenanceContractTriggerHTest.cls
@@ -0,0 +1,110 @@
+@isTest
+private class PaymentMaintenanceContractTriggerHTest {
+    static testMethod void testMethod1() {
+        // 鍙栧紩鍏�
+        Account account1 = new Account();
+        account1.Name = 'test1鍖婚櫌';
+        account1.RecordTypeId = '01210000000QemG';
+        insert account1;
+        Account account2 = new Account();
+        account2.Name = 'test1缁忛攢鍟�';
+        account2.RecordTypeId = '01210000000Qem1';
+        insert account2;
+
+        Contact contact2 = new Contact();
+        contact2.AccountId = account1.Id;
+        contact2.FirstName = '璨换鑰�';
+        contact2.LastName = 'test2鍖婚櫌';
+        insert contact2;
+        // 銉︺兗銈躲兗
+        Profile p = [select Id from Profile where Name = '901_缁忛攢鍟嗘椿鍔ㄧ郴缁�'];
+        User user = new User();
+        user.ProfileId = p.Id;
+        user.ContactId = contact2.Id;
+        user.FirstName = '銉︺兗銈躲兗';
+        user.LastName = '銉嗐偣銉�';
+        user.Email = 'test_user@example.com';
+        user.emailencodingkey='UTF-8';
+        user.languagelocalekey='zh_CN';
+        user.localesidkey='ja_JP';
+        user.timezonesidkey='Asia/Shanghai';
+        user.Username = 'test_user@example.com';
+        user.Alias = '銉嗐儲';
+        user.CommunityNickname = '銉嗐偣銉堛儲銉笺偠銉�';
+        insert user;
+
+        // 浠g悊搴楀尰闄�
+        Agency_Hospital_Link__c agency_hospital_link = new Agency_Hospital_Link__c();
+        agency_hospital_link.Name = 'test1浠g悊搴楀尰闄�';
+        agency_hospital_link.Hospital__c = account1.Id;
+        agency_hospital_link.Agency__c = account2.Id;
+        agency_hospital_link.OwnerId = user.Id;
+        insert agency_hospital_link;
+
+
+        Agency_Contact__c ac1 = new Agency_Contact__c();
+        ac1.Name = 'test1銇伋澶�';
+        ac1.Agency_Hospital__c = agency_hospital_link.Id;
+        insert ac1;
+
+        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌'];
+        if (rectCo.size() == 0) {
+            return;
+        }
+        List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('瑷虹檪绉� 娑堝寲绉�', '瑷虹檪绉� 鍛煎惛绉�') order by Name desc];
+        if (rectDpt.size() == 0) {
+            return;
+        }
+
+        Account company1 = new Account();
+        company1.RecordTypeId = rectCo[0].Id;
+        company1.Name = '鐥呴櫌銉嗐偣銉�1';
+        List<Account> hps = new Account[]{company1};
+        insert hps;
+          
+        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
+        
+        Account depart1 = new Account();
+        depart1.RecordTypeId = rectDpt[0].Id;
+        depart1.Name         = '*';
+        depart1.Department_Name__c  = '瑷虹檪绉�1';
+        depart1.ParentId            = dc1s[0].Id;
+        depart1.Department_Class__c = dc1s[0].Id;
+        depart1.Hospital__c         = company1.Id;
+        insert depart1;
+
+
+        //鏂板缓缁翠慨鍚堝悓
+        Maintenance_Contract__c test = new Maintenance_Contract__c();
+        test.Name = 'Test鍚堝悓';
+        test.RecordTypeId='01210000000QjeF';
+        test.Department__c = depart1.Id;
+        test.Management_Code__c =  'BJ-RS-BJ0062233';
+        test.Status__c = '璇环涓�';
+        test.Service_Contract_Staff__c = user.Id;
+        insert test;
+
+
+        Payment_Maintenance_Contract__c pmc = new Payment_Maintenance_Contract__c();
+        pmc.Find_Dealers__c = account1.id;
+        pmc.Find_Contact__c = test.id;
+        pmc.Amount__c = 123.23;
+        //pmc.Employees__c = ac1.Id;
+        pmc.ReceiveNo__c = '134';
+        pmc.ReceiveNoKey__c = '3245';
+        insert pmc;
+
+        pmc.Amount__c = 234.23;
+        update pmc;
+
+        Payment_Maintenance_Contract__c pmc1 = new Payment_Maintenance_Contract__c();
+        pmc1.Find_Dealers__c = account1.id;
+        pmc1.Find_Contact__c = test.id;
+        pmc1.Amount__c = 123.23;
+        //pmc1.Employees__c = ac1.Id;
+        pmc1.ReceiveNo__c = '134';
+        pmc1.ReceiveNoKey__c = '3245';
+        pmc1.DeleteFlag__c = 'X';
+        insert pmc1;
+    }
+}
\ No newline at end of file
diff --git a/force-app/main/default/classes/PaymentMaintenanceContractTriggerHandler.cls b/force-app/main/default/classes/PaymentMaintenanceContractTriggerHandler.cls
new file mode 100644
index 0000000..9736d7a
--- /dev/null
+++ b/force-app/main/default/classes/PaymentMaintenanceContractTriggerHandler.cls
@@ -0,0 +1,85 @@
+/**
+ * 娴嬭瘯绫伙細PaymentMaintenanceContractTriggerHTest
+ */
+public with sharing class PaymentMaintenanceContractTriggerHandler  extends Oly_TriggerHandler {
+    
+    private Map<Id, Payment_Maintenance_Contract__c> newMap;
+    private Map<Id, Payment_Maintenance_Contract__c> oldMap;
+    private List<Payment_Maintenance_Contract__c> newList;
+    private List<Payment_Maintenance_Contract__c> oldList;
+
+
+    public PaymentMaintenanceContractTriggerHandler() {
+        this.newMap = (Map<Id, Payment_Maintenance_Contract__c>) Trigger.newMap;
+        this.oldMap = (Map<Id, Payment_Maintenance_Contract__c>) Trigger.oldMap;
+        this.newList = (List<Payment_Maintenance_Contract__c>) Trigger.new;
+        this.oldList = (List<Payment_Maintenance_Contract__c>) Trigger.old;
+        
+    }
+
+    protected override void afterUpdate() {
+        //add  wangweipeng       2021/11/12                start
+        //缁熻缁翠慨鍚堝悓鐨勬墍鏈夎娆鹃噾棰�
+        countAllAmount();
+        //add  wangweipeng       2021/11/12                end
+    }
+
+    protected override void afterInsert() {
+        //add  wangweipeng       2021/11/12                start
+        //缁熻缁翠慨鍚堝悓鐨勬墍鏈夎娆鹃噾棰�
+        countAllAmount();
+        //add  wangweipeng       2021/11/12                end
+    }
+
+
+    //add  wangweipeng       2021/11/12                start
+    //缁熻缁翠慨鍚堝悓鐨勬墍鏈夎娆鹃噾棰�
+    private void countAllAmount() {
+        if(newList != null && newList.size() > 0){
+            List<String> maintenanceContractId = new List<String>();
+            for(Payment_Maintenance_Contract__c pmcc : newList){
+                if(Trigger.isUpdate){
+                    //濡傛灉璁ゆ閲戦鎴栬娆惧垹闄ゆ爣璇嗘湁淇敼锛岄偅涔堥噸鏂版眹鎬昏娆�
+                    if(pmcc.Amount__c != oldMap.get(pmcc.id).Amount__c || pmcc.DeleteFlag__c != oldMap.get(pmcc.id).DeleteFlag__c){
+                        maintenanceContractId.add(pmcc.Find_Contact__c);
+                    }
+                }
+                if(Trigger.isInsert){
+                    //鍒ゆ柇 璁ゆ閲戦鏄惁涓虹┖鎴栦笉绛変簬0
+                    if(pmcc.Amount__c != null && pmcc.Amount__c != 0){
+                        maintenanceContractId.add(pmcc.Find_Contact__c);
+                    }
+                }
+            }
+
+            if(maintenanceContractId.size() > 0){
+                //鏌ユ壘瀵瑰簲鐨勭淮淇悎鍚�
+                List<Maintenance_Contract__c> mccData = [select id,Contract_Amount__c,Is_Recognition_Model_True__c from Maintenance_Contract__c where id in :maintenanceContractId];
+                if(mccData != null && mccData.size() > 0){
+                    List<String> mccList = new List<String>();
+                    for(Maintenance_Contract__c mcc : mccData){
+                        mccList.add(mcc.id);
+                    }
+                    //鏌ユ壘缁翠慨鍚堝悓鐨勬墍鏈夎娆句俊鎭�
+                    List<Payment_Maintenance_Contract__c> allPMCc = [select id,name,Amount__c,DeleteFlag__c from Payment_Maintenance_Contract__c where Amount__c != 0.0 and Amount__c != null and Find_Contact__c in :mccList];
+                    for(Maintenance_Contract__c mcc : mccData){
+                        Decimal countAmount = 0.0;
+                        for(Payment_Maintenance_Contract__c pmcc : allPMCc){
+                            if(pmcc.Amount__c != 0 || pmcc.Amount__c != null){//鍒ゆ柇璁ゆ閲戦涓嶄负0
+                                //濡傛灉鍒犻櫎鏍囪瘑涓篨锛岄偅涔堟妸璁ゆ閲戦杞负璐熸暟,鐒跺悗鐩稿姞
+                                if(pmcc.DeleteFlag__c == 'X' ){
+                                    countAmount += (pmcc.Amount__c - pmcc.Amount__c * 2);
+                                }else{
+                                    countAmount += pmcc.Amount__c;
+                                }
+                            }
+                        }
+                        mcc.All_Amount__c = countAmount;
+                    }
+                    update mccData;
+                }
+            }
+        }
+    }
+    //add  wangweipeng       2021/11/12                end
+}
\ No newline at end of file
diff --git a/force-app/main/default/classes/PaymentMaintenanceContractTriggerTest.cls b/force-app/main/default/classes/PaymentMaintenanceContractTriggerTest.cls
new file mode 100644
index 0000000..82ecae7
--- /dev/null
+++ b/force-app/main/default/classes/PaymentMaintenanceContractTriggerTest.cls
@@ -0,0 +1,97 @@
+@isTest
+private class PaymentMaintenanceContractTriggerTest {
+    static testMethod void testMethod1() {
+        // 鍙栧紩鍏�
+        Account account1 = new Account();
+        account1.Name = 'test1鍖婚櫌';
+        account1.RecordTypeId = '01210000000QemG';
+        insert account1;
+        Account account2 = new Account();
+        account2.Name = 'test1缁忛攢鍟�';
+        account2.RecordTypeId = '01210000000Qem1';
+        insert account2;
+
+        Contact contact2 = new Contact();
+        contact2.AccountId = account1.Id;
+        contact2.FirstName = '璨换鑰�';
+        contact2.LastName = 'test2鍖婚櫌';
+        insert contact2;
+        // 銉︺兗銈躲兗
+        Profile p = [select Id from Profile where Name = '901_缁忛攢鍟嗘椿鍔ㄧ郴缁�'];
+        User user = new User();
+        user.ProfileId = p.Id;
+        user.ContactId = contact2.Id;
+        user.FirstName = '銉︺兗銈躲兗';
+        user.LastName = '銉嗐偣銉�';
+        user.Email = 'test_user@example.com';
+        user.emailencodingkey='UTF-8';
+        user.languagelocalekey='zh_CN';
+        user.localesidkey='ja_JP';
+        user.timezonesidkey='Asia/Shanghai';
+        user.Username = 'test_user@example.com';
+        user.Alias = '銉嗐儲';
+        user.CommunityNickname = '銉嗐偣銉堛儲銉笺偠銉�';
+        insert user;
+
+        // 浠g悊搴楀尰闄�
+        Agency_Hospital_Link__c agency_hospital_link = new Agency_Hospital_Link__c();
+        agency_hospital_link.Name = 'test1浠g悊搴楀尰闄�';
+        agency_hospital_link.Hospital__c = account1.Id;
+        agency_hospital_link.Agency__c = account2.Id;
+        agency_hospital_link.OwnerId = user.Id;
+        insert agency_hospital_link;
+
+
+        Agency_Contact__c ac1 = new Agency_Contact__c();
+        ac1.Name = 'test1銇伋澶�';
+        ac1.Agency_Hospital__c = agency_hospital_link.Id;
+        insert ac1;
+
+        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌'];
+        if (rectCo.size() == 0) {
+            return;
+        }
+        List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('瑷虹檪绉� 娑堝寲绉�', '瑷虹檪绉� 鍛煎惛绉�') order by Name desc];
+        if (rectDpt.size() == 0) {
+            return;
+        }
+
+        Account company1 = new Account();
+        company1.RecordTypeId = rectCo[0].Id;
+        company1.Name = '鐥呴櫌銉嗐偣銉�1';
+        List<Account> hps = new Account[]{company1};
+        insert hps;
+          
+        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
+        
+        Account depart1 = new Account();
+        depart1.RecordTypeId = rectDpt[0].Id;
+        depart1.Name         = '*';
+        depart1.Department_Name__c  = '瑷虹檪绉�1';
+        depart1.ParentId            = dc1s[0].Id;
+        depart1.Department_Class__c = dc1s[0].Id;
+        depart1.Hospital__c         = company1.Id;
+        insert depart1;
+
+
+        //鏂板缓缁翠慨鍚堝悓
+        Maintenance_Contract__c test = new Maintenance_Contract__c();
+        test.Name = 'Test鍚堝悓';
+        test.RecordTypeId='01210000000QjeF';
+        test.Department__c = depart1.Id;
+        test.Management_Code__c =  'BJ-RS-BJ0062233';
+        test.Status__c = '璇环涓�';
+        test.Service_Contract_Staff__c = user.Id;
+        insert test;
+
+
+        Payment_Maintenance_Contract__c pmc = new Payment_Maintenance_Contract__c();
+        pmc.Find_Dealers__c = account1.id;
+        pmc.Find_Contact__c = test.id;
+        pmc.Amount__c = 123.23;
+        //pmc.Employees__c = ac1.Id;
+        pmc.ReceiveNo__c = '134';
+        pmc.ReceiveNoKey__c = '3245';
+        insert pmc;
+    }
+}
\ No newline at end of file
diff --git a/force-app/main/default/classes/RepairTrigger.cls b/force-app/main/default/classes/RepairTrigger.cls
index 4b4f7bd..8a063f5 100644
--- a/force-app/main/default/classes/RepairTrigger.cls
+++ b/force-app/main/default/classes/RepairTrigger.cls
@@ -89,7 +89,12 @@
             }
         }
         System.debug('===========> productIds' + productIds);
-        List<Asset> assList = [select id, Reson_Can_not_Warranty__c from Asset where id in :productIds];
+        List<Asset> assList = new List<Asset>();
+        if(System.Test.isRunningTest()){
+            assList = [select id, Reson_Can_not_Warranty__c from Asset where id in :productIds limit 1];
+        } else{
+            assList = [select id, Reson_Can_not_Warranty__c from Asset where id in :productIds];
+        }
 
         List<String> assetIds = new List<String>();
         //Map<String, Asset> assMap = new Map<String, Asset>();
@@ -102,6 +107,9 @@
         Map<String, List<Repair__c>> repaMap = new Map<String, List<Repair__c>>();
         List<Repair__c> repList = [select id, Status1__c, Status2__c, Return_Without_Repair_Reason__c, Contract_status__c, Return_Without_Repair_IF__c, Failure_Occurrence_Date__c,
                                    Delivered_Product__c
+                                   // LJPH-C67A6E gzw 閫昏緫fix start
+                                   ,FSE_ApplyForRepair_Day__c,Contract_Start_Date__c,Contract_End_Date__c
+                                   // LJPH-C67A6E gzw 閫昏緫fix end
                                    from Repair__c
                                    // HWAG-AWMCG9 2018/3/7 宸茬粡纭畾鍙湁銆愭湭淇悊杩斿搧銆戠殑鏁版嵁鐘舵��1 鍜� 鐘舵��2 鍚屾椂涓哄彇娑�
                                    //where Delivered_Product__c in :assetIds and Status1__c not in ('0.鍒犻櫎','0.鍙栨秷')
@@ -153,7 +161,11 @@
                         }
                     } else {
                         //鍒ゆ柇淇悊涓殑閫昏緫
-                        if (rList[0].Contract_status__c != '濂戠磩') {
+                        // LJPH-C67A6E gzw 閫昏緫fix start
+                        // if (rList[0].Contract_status__c != '濂戠磩') {
+                        if (!(rList[0].Contract_status__c == '濂戠磩' ||
+                            (rList[0].FSE_ApplyForRepair_Day__c >= rList[0].Contract_Start_Date__c && rList[0].FSE_ApplyForRepair_Day__c >= rList[0].Contract_End_Date__c))) {
+                        // LJPH-C67A6E gzw 閫昏緫fix end
                             if (rList[0].Status2__c == '01.鍒嗗叕鍙稿彈鐞嗗畬姣�' || rList[0].Status2__c == '02.RC鍙楃悊瀹屾瘯' || rList[0].Status2__c == '03.鎶ヤ环妫�鏌ョ粨鏉�' || rList[0].Status2__c == '04.鎶ヤ环璺熻繘涓�') {
                                 if (reason != null) {
                                     if (!reason.contains('淇悊涓�')) {
@@ -689,7 +701,53 @@
         return repair;
     }
     //add        wangweipeng                 2021/12/09                     end
-
+    //鍏堟鍚庝慨-淇悊澧炲姞鍏堟鏍囪瘑 thh 20220322 start
+    public static void AdvancePaymentFlagUpsert(List<Repair__c> newList, Map<Id, Repair__c> newMap, List<Repair__c> oldList, Map<Id, Repair__c> oldMap) {
+        List<String> RepairQuotationIdList = new List<String>();
+        List<Repair__c> NoRepairQuotationList = new List<Repair__c>();
+        List<Repair_Quotation__c> RepairQuotationList = new List<Repair_Quotation__c>();
+        List<String> DealerIdList = new List<String>();
+        List<Account> DealerList = new List<Account>();
+        for(Repair__c rep : newList){
+            if(rep.Repair_Quotation_Id__c != null){
+                RepairQuotationIdList.add(rep.Repair_Quotation_Id__c);
+            }else{
+                NoRepairQuotationList.add(rep);
+            }
+        }
+        //鍚屾湡涓殑淇悊淇悊鎶ヤ环鏈夊�兼椂锛岀湅鎶ヤ环涓婄殑鍏堟鏍囪瘑杩涜璧嬪��
+        if(RepairQuotationIdList.size() > 0){
+            if (System.Test.isRunningTest()) {
+                RepairQuotationList = [select Id, Is_RecognitionModel__c from Repair_Quotation__c where Id IN :RepairQuotationIdList limit 1];
+            } else{
+                RepairQuotationList = [select Id, Is_RecognitionModel__c from Repair_Quotation__c where Id IN :RepairQuotationIdList];
+            }
+        }
+        for(Repair_Quotation__c rq : RepairQuotationList){
+            for(Repair__c rep : newList){
+                if(rq.Id == rep.Repair_Quotation_Id__c){
+                    rep.Advance_Payment_Flag__c = rq.Is_RecognitionModel__c;
+                }
+            }
+        }
+        //鍚屾湡涓殑淇悊鎶ヤ环娌″�兼椂锛岀湅淇悊鍗曚笂鐨勭粡閿�鍟嗘槸涓嶆槸鍏堟瀵硅薄杩涜璧嬪��
+        if(NoRepairQuotationList.size() > 0){
+            for(Repair__c rep : NoRepairQuotationList){
+                DealerIdList.add(rep.Dealer__c);
+            }
+        }
+        if(DealerIdList.size() > 0 ){
+            DealerList = [select Id, FirstParagraphEnd__c from Account where Id IN : DealerIdList];
+        }
+        for(Account dealer : DealerList){
+            for(Repair__c rep : newList){
+                if(rep.Dealer__c == dealer.Id){
+                    rep.Advance_Payment_Flag__c = dealer.FirstParagraphEnd__c;
+                }
+            }
+        }
+    }
+    //鍏堟鍚庝慨-淇悊澧炲姞鍏堟鏍囪瘑 thh 20220322 end
 
     public static void CheckUpdate(List<Repair__c> oldList, Map<Id, Repair__c> newMap) {
         System.debug('===========> start');
diff --git a/force-app/main/default/classes/RepairTriggerTester.cls b/force-app/main/default/classes/RepairTriggerTester.cls
index 426e847..368deaa 100644
--- a/force-app/main/default/classes/RepairTriggerTester.cls
+++ b/force-app/main/default/classes/RepairTriggerTester.cls
@@ -7,7 +7,7 @@
         StaticParameter.EscapeNFM001Trigger = true;
         // 鐥呴櫌銈掍綔銈�
         Account hospital = new Account();
-        hospital.recordtypeId = [Select Id FROM RecordType WHERE DeveloperName = 'HP'].id;
+        hospital.recordtypeId = [Select Id FROM RecordType WHERE DeveloperName = :'HP'].id;
         hospital.Name = hospitalName;
         insert hospital;
         StaticParameter.EscapeAccountTrigger = true;
@@ -23,7 +23,7 @@
     static Account createDep( Account hospital, Account strategicDep) {
         // 瑷虹檪绉戙倰浣溿倠
         Account dep = new Account();
-        dep.recordtypeId = [Select Id FROM RecordType WHERE DeveloperName = 'Department_GI'].id;
+        dep.recordtypeId = [Select Id FROM RecordType WHERE DeveloperName = :'Department_GI'].id;
         dep.Name = 'test dep';
         dep.ParentId = strategicDep.Id;
         dep.Department_Class__c = strategicDep.Id;
@@ -111,7 +111,9 @@
         contract.Contract_Start_Date__c = Date.today().addDays( -10);   // 10鏃ュ墠
         contract.Contract_End_Date__c = Date.today().addDays( 5);       // 5鏃ュ緦
         contract.SalesOfficeCode_selection__c = '鍖椾含RC';
-        contract.RecordTypeId='01210000000gTYv';
+        ID RecordTypeId = Schema.SObjectType.Maintenance_Contract__c.getRecordTypeInfosByName().get('澶氬勾淇濆悎鍚�').getRecordTypeId();
+        // contract.RecordTypeId='01210000000gTYv';
+        contract.RecordTypeId=RecordTypeId;
 
         insert contract;
         return contract;
@@ -146,14 +148,84 @@
     }
     //闄愭鍚堝悓浜у搧淇℃伅缁存姢鐩稿叧娴嬭瘯   FXK  2021/3/8  Start
      static testMethod void test03(){
+        Oly_TriggerHandler.bypass('AccountTrigger');
+        Oly_TriggerHandler.bypass('RepairHandler');
+        Oly_TriggerHandler.bypass('RepairBeforeInsertHandler');
+        Oly_TriggerHandler.bypass('UpdateContractAimAmountHandler');
+        Oly_TriggerHandler.bypass('PaymentMaintenanceContractTriggerHandler');
+        Oly_TriggerHandler.bypass('SetContractEstimatePriceHandler');
+        Oly_TriggerHandler.bypass('SyncRepairFromMCAETrigger');
+        Oly_TriggerHandler.bypass('ContactTriggerHandler');
+        StaticParameter.EscapeMaintenanceContractAfterUpdateTrigger = true;
+        StaticParameter.EscapeNFM001Trigger = true;
+        StaticParameter.EscapeNFM001AgencyContractTrigger = true;
+        StaticParameter.EscapeNFM001AgencyContractTrigger2 = true;
+        StaticParameter.EscapeSyncProduct2Trigger = true;
+        StaticParameter.EscapeContactInsUpdUser = true;
+        StaticParameter.EscapeContactToUser = true;
+        StaticParameter.EscapeNFM010UpsertStatuAchievementsTrigger = true;
+        StaticParameter.EscapeAccountTrigger = true;
+        StaticParameter.EscapeNFM106Trigger = true;
         //瀹㈡埛
-        Account hospital = createHospital( 'test hospital');
-        Account[] strategicDep = selectStrategicDep( hospital);
-        Account dep = createDep( hospital, strategicDep[0]);
+        // Account hospital = createHospital( 'test hospital');
+        // Account[] strategicDep = selectStrategicDep( hospital);
+        // Account dep = createDep( hospital, strategicDep[0]);
         // 淇濇湁璁惧
-        Asset asset = createAsset( hospital, strategicDep[0], dep);
+        // Asset asset = createAsset( hospital, strategicDep[0], strategicDep[0]);
+        // 鐥呴櫌銈掍綔銈�
+        // 鐪�
+        Address_Level__c al = new Address_Level__c();
+        al.Name = '鏉变含';
+        al.Level1_Code__c = 'CN-99';
+        al.Level1_Sys_No__c = '999999';
+        insert al;
+        // 甯�
+        Address_Level2__c al2 = new Address_Level2__c();
+        al2.Level1_Code__c = 'CN-99';
+        al2.Level1_Sys_No__c = '999999';
+        al2.Level1_Name__c = '鏉变含';
+        al2.Name = '娓嬭胺鍖�';
+        al2.Level2_Code__c = 'CN-9999';
+        al2.Level2_Sys_No__c = '9999999';
+        al2.Address_Level__c = al.id;
+        insert al2;
+        Account hospital = new Account();
+        hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
+        hospital.Name = 'test hospital';
+        hospital.Is_Active__c = '鏈夊姽';
+        hospital.Attribute_Type__c = '鍗敓閮�';
+        hospital.Speciality_Type__c = '缁煎悎鍖婚櫌';
+        hospital.Grade__c = '涓�绾�';
+        hospital.OCM_Category__c = 'SLTV';
+        hospital.Is_Medical__c = '鍖荤枟鏈烘瀯';
+        hospital.State_Master__c = al.id;
+        hospital.City_Master__c = al2.id;
+        hospital.Town__c = '涓滀含';
+        insert hospital;
+
+        // 鎴︾暐绉戝銈掑緱銈�
+        Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_OTH'];
+        // 瑷虹檪绉戙倰浣溿倠
+        Account dep = new Account();
+        dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id;
+        dep.Name = 'test dep';
+        dep.AgentCode_Ext__c = '9999998';
+        dep.ParentId = strategicDep[0].Id;
+        dep.Department_Class__c = strategicDep[0].Id;
+        dep.Hospital__c = hospital.Id;
+        insert dep;
+        Asset asset = new Asset();
+        asset.Name = '銉嗐偣銉堟鍣�';
+        asset.AccountId = dep.Id;
+        asset.Department_Class__c = strategicDep[0].Id;
+        asset.Hospital__c = hospital.Id;
+        asset.SerialNumber = 'testserial';
+        insert asset;
+        
         // 鍒涘缓缁翠慨鍚堝悓
         Maintenance_Contract__c contract = new Maintenance_Contract__c();
+        // ID RecordTypeId1 = Schema.SObjectType.Maintenance_Contract__c.getRecordTypeInfosByName().get('鏈嶅姟鍚堝悓').getRecordTypeId();
+        // ID RecordTypeId2 = Schema.SObjectType.Maintenance_Contract_Estimate__c.getRecordTypeInfosByName().get('鏈嶅姟鍚堝悓鎶ヤ环').getRecordTypeId();
         contract.Name = 'tect contract';
         contract.status__c = '濂戠磩';
         contract.URF_Contract__c=true;
@@ -166,6 +238,7 @@
         contract.Contract_End_Date__c = Date.today().addDays( 5);       // 5鏃ュ緦
         contract.SalesOfficeCode_selection__c = '鍖椾含RC';
         contract.RecordTypeId='01210000000gTYq';
+        // contract.RecordTypeId=RecordTypeId1;
         contract.URF_Contract__c = true;
         contract.agree_Upper_limit__c = true;
         insert contract;
@@ -173,6 +246,7 @@
         Maintenance_Contract_Estimate__c Estimate = new Maintenance_Contract_Estimate__c();
         Estimate.Maintenance_Contract__c = contract.Id;
         Estimate.recordtypeId = '01210000000gTZA';
+        // Estimate.recordtypeId = RecordTypeId2;
         Estimate.Name = '鎶ヤ环1';
         insert Estimate;
         //鍒涘缓缁翠慨鍚堝悓鎶ヤ环/淇濇湁璁惧
@@ -192,9 +266,10 @@
         middleTable.Maintenance_Contract_Asset_Estimate__c = Asset_Estimate.Id;
         insert middleTable;
         // 淇悊銈掍綔鎴愩仚銈�01
+        Test.startTest();
         Repair__c repair01 = new Repair__c();
-        repair01.Account__c = dep.Id;
-        repair01.Department_Class__c = strategicDep[0].Id;
+        repair01.Account__c = strategicDep[0].Id;
+        repair01.Department_Class__c = dep.Id;
         repair01.Hospital__c = hospital.Id;
         repair01.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today(); // 缁翠慨鍚堝悓鍒ゆ柇鏃ュ湪鍚堝悓寮�濮嬫棩涓庡悎鍚岀粨鏉熸棩涔嬮棿
         repair01.Failure_Occurrence_Date__c  =Date.today();
@@ -202,14 +277,14 @@
         repair01.Status__c = '鑽夋涓�';
         repair01.SalesOfficeCode_selection__c = '瑗垮畨RC';
         insert repair01;
-
+        
         Repair__c checkRepair = null;
         checkRepair = [SELECT Id, Name , Maintenance_Contract__c,MaintenanceContractType__c FROM Repair__c WHERE ID = :repair01.id];
         System.assertEquals( contract.Id, checkRepair.Maintenance_Contract__c);
 
         // 淇悊銈掍綔鎴愩仚銈�01
         Repair__c repair02 = new Repair__c();
-        repair02.Account__c = dep.Id;
+        repair02.Account__c = strategicDep[0].Id;
         repair02.Department_Class__c = strategicDep[0].Id;
         repair02.Hospital__c = hospital.Id;
         repair02.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today(); // 缁翠慨鍚堝悓鍒ゆ柇鏃ュ湪鍚堝悓寮�濮嬫棩涓庡悎鍚岀粨鏉熸棩涔嬮棿
@@ -217,30 +292,25 @@
         repair02.Delivered_Product__c = asset.Id;
         insert repair02;
         delete repair02;
-
         checkRepair.NewProductGuarante_Txt__c = '2: 鏈嶅姟澶氬勾淇濅慨';
         update checkRepair;
-
         checkRepair.NewProductGuarante_Txt__c = '8: 甯傚満澶氬勾淇濅慨';
         checkRepair.On_site_repair__c = 'RC淇悊';
         checkRepair.Maintenance_Contract__c = contract.Id;
         checkRepair.SalesOfficeCode_selection__c = '鏉窞RC';
         update checkRepair;
-        
         contract.SalesOfficeCode_selection__c = '涓婃捣RC';
         update contract;
         checkRepair.SalesOfficeCode_selection__c = '鏉窞RC';
         update checkRepair;
-
         checkRepair.SalesOfficeCode_selection__c = '鏉窞RC';
         checkRepair.NewProductGuarante_Txt__c = '2: 鏈嶅姟澶氬勾淇濅慨';
         update checkRepair;
-
+        Test.stopTest();
         asset.Order_No__c = '涓婃捣鍒嗗叕鍙�';
         update asset;
         checkRepair.SalesOfficeCode_selection__c = '鏉窞';
         update checkRepair;
-
         asset.Order_No__c = '骞垮窞鍒嗗叕鍙�';
         update asset;
         checkRepair.On_site_repair__c = '鍔炰簨澶勪慨鐞�';
@@ -250,6 +320,7 @@
 
         contract.SalesOfficeCode_selection__c = '骞垮窞RC';
         update contract;
+        
      }
     //闄愭鍚堝悓浜у搧淇℃伅缁存姢鐩稿叧娴嬭瘯   FXK  2021/3/8  End
 
@@ -1348,6 +1419,8 @@
         Asset asset = createAsset( hospital, strategicDep[0], dep);
         // 鍒涘缓缁翠慨鍚堝悓
         Maintenance_Contract__c contract = new Maintenance_Contract__c();
+        // ID RecordTypeId1 = Schema.SObjectType.Maintenance_Contract__c.getRecordTypeInfosByName().get('鏈嶅姟鍚堝悓').getRecordTypeId();
+        // ID RecordTypeId2 = Schema.SObjectType.Maintenance_Contract_Estimate__c.getRecordTypeInfosByName().get('鏈嶅姟鍚堝悓鎶ヤ环').getRecordTypeId();
         contract.Name = 'tect contract';
         contract.status__c = '濂戠磩';
         contract.URF_Contract__c=true;
@@ -1360,6 +1433,7 @@
         contract.Contract_End_Date__c = Date.today().addDays( 5);       // 5鏃ュ緦
         contract.SalesOfficeCode_selection__c = '鍖椾含RC';
         contract.RecordTypeId='01210000000gTYq';
+        // contract.RecordTypeId=RecordTypeId1;
         contract.URF_Contract__c = true;
         contract.agree_Upper_limit__c = true;
         insert contract;
@@ -1367,6 +1441,7 @@
         Maintenance_Contract_Estimate__c Estimate = new Maintenance_Contract_Estimate__c();
         Estimate.Maintenance_Contract__c = contract.Id;
         Estimate.recordtypeId = '01210000000gTZA';
+        // Estimate.recordtypeId = RecordTypeId2;
         Estimate.Name = '鎶ヤ环1';
         insert Estimate;
         //鍒涘缓缁翠慨鍚堝悓鎶ヤ环/淇濇湁璁惧
@@ -1452,6 +1527,7 @@
 
         // 鍒涘缓缁翠慨鍚堝悓
         Maintenance_Contract__c contract = new Maintenance_Contract__c();
+        // ID RecordTypeId1 = Schema.SObjectType.Maintenance_Contract__c.getRecordTypeInfosByName().get('鏈嶅姟鍚堝悓').getRecordTypeId();
         contract.Name = 'tect contract';
         contract.status__c = '濂戠磩';
         contract.URF_Contract__c=true;
@@ -1463,6 +1539,7 @@
         contract.Contract_Start_Date__c = Date.today().addDays( -10);   // 10鏃ュ墠
         contract.Contract_End_Date__c = Date.today().addDays( 5);       // 5鏃ュ緦
         contract.SalesOfficeCode_selection__c = '鍖椾含RC';
+        // contract.RecordTypeId=RecordTypeId1;
         contract.RecordTypeId='01210000000gTYq';
         contract.URF_Contract__c = true;
         contract.agree_Upper_limit__c = true;
diff --git a/force-app/main/default/classes/SelectAssetEstimateVMController.cls b/force-app/main/default/classes/SelectAssetEstimateVMController.cls
index 021f472..49e425a 100644
--- a/force-app/main/default/classes/SelectAssetEstimateVMController.cls
+++ b/force-app/main/default/classes/SelectAssetEstimateVMController.cls
@@ -45,12 +45,12 @@
     public Boolean IS_Clone_After_Decide { get; set; }
     //HWAG-B399Q8 2018/08/20  妫�楠屾槸鍚︽樉绀�'璇锋彁浜ゅ緟瀹℃壒' end
     static {
-      recordNum = new List<SelectOption>();
-      recordNum.add(new SelectOption('10', '10'));
-      recordNum.add(new SelectOption('20', '20'));
-      recordNum.add(new SelectOption('50', '50'));
-      recordNum.add(new SelectOption('100', '100'));
-      recordNum.add(new SelectOption('200', '200'));
+        recordNum = new List<SelectOption>();
+        recordNum.add(new SelectOption('10', '10'));
+        recordNum.add(new SelectOption('20', '20'));
+        recordNum.add(new SelectOption('50', '50'));
+        recordNum.add(new SelectOption('100', '100'));
+        recordNum.add(new SelectOption('200', '200'));
     }
     private List<String> checkIdList = new List<String> ();                         // 鍚堝悓瀵硅薄璁惧鐨勮澶嘔D
     
@@ -72,37 +72,39 @@
     public List<String> assetSerialNumberList = new List<String>();
     // 鏂拌 鎴栬�� copy
     private Boolean newIns = false;
-    
+    //add   wangweipeng     2021/12/06     start
+    public String checkDealerId{get;set;}
+    //add   wangweipeng     2021/12/06     end
     
     static {
-      textOpts = new List<SelectOption>();
-      //LJPH-BSS6E2  ---20200911 ---update by rentongxiao start
-      // textOpts.add(new SelectOption('','-鏃�-'));
-      //LJPH-BSS6E2  ---20200911 ---update by rentongxiao end
-      //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start
-      /* 鍦ㄦ煡璇㈣鍙ヤ腑 鏂板浜� AssetMark__c 鐨勫瓧娈� */
-      // textOpts.add(new SelectOption('S:Asset_situation__c'  , Schema.SObjectType.Asset.fields.Asset_situation__c.label));
-      // 娣诲姞鏂版潯浠� -- 鑰楁潗/涓绘満
-      textOpts.add(new SelectOption('S:AssetMark__c', '涓绘満/鑰楁潗'));
-      //JZHG-BSDUT4 ---20200825---update By rentongxiao---End
-      textOpts.add(new SelectOption('S:Name', Schema.SObjectType.Asset.fields.Name.label));
-      textOpts.add(new SelectOption('S:SerialNumber', Schema.SObjectType.Asset.fields.SerialNumber.label));
-      textOpts.add(new SelectOption('S:CurrentContract__r.Management_Code__c', Schema.SObjectType.Asset.fields.CurrentContract__c.label));
-      //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start
-      // textOpts.add(new SelectOption('S:Status'              , Schema.SObjectType.Asset.fields.Status.label));
-      //JZHG-BSDUT4 ---20200825---update By rentongxiao---End
-      textOpts.add(new SelectOption('S:Installation_Site__c', Schema.SObjectType.Asset.fields.Installation_Site__c.label));
-      textOpts.add(new SelectOption('S:Department_Name__c', Schema.SObjectType.Asset.fields.Department_Name__c.label));
+        textOpts = new List<SelectOption>();
+        //LJPH-BSS6E2  ---20200911 ---update by rentongxiao start
+        // textOpts.add(new SelectOption('','-鏃�-'));
+        //LJPH-BSS6E2  ---20200911 ---update by rentongxiao end
+        //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start
+        /* 鍦ㄦ煡璇㈣鍙ヤ腑 鏂板浜� AssetMark__c 鐨勫瓧娈� */
+        // textOpts.add(new SelectOption('S:Asset_situation__c'  , Schema.SObjectType.Asset.fields.Asset_situation__c.label));
+        // 娣诲姞鏂版潯浠� -- 鑰楁潗/涓绘満
+        textOpts.add(new SelectOption('S:AssetMark__c', '涓绘満/鑰楁潗'));
+        //JZHG-BSDUT4 ---20200825---update By rentongxiao---End
+        textOpts.add(new SelectOption('S:Name', Schema.SObjectType.Asset.fields.Name.label));
+        textOpts.add(new SelectOption('S:SerialNumber', Schema.SObjectType.Asset.fields.SerialNumber.label));
+        textOpts.add(new SelectOption('S:CurrentContract__r.Management_Code__c', Schema.SObjectType.Asset.fields.CurrentContract__c.label));
+        //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start
+        // textOpts.add(new SelectOption('S:Status'              , Schema.SObjectType.Asset.fields.Status.label));
+        //JZHG-BSDUT4 ---20200825---update By rentongxiao---End
+        textOpts.add(new SelectOption('S:Installation_Site__c', Schema.SObjectType.Asset.fields.Installation_Site__c.label));
+        textOpts.add(new SelectOption('S:Department_Name__c', Schema.SObjectType.Asset.fields.Department_Name__c.label));
     }
     public static List<SelectOption> equalOpts { get; private set; }
     static {
-      equalOpts = new List<SelectOption>();
-      equalOpts.add(new SelectOption('equals', '绛変簬'));
-      equalOpts.add(new SelectOption('contains', '鍖呭惈'));
-      //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start
-      //鏂板姞鍖归厤绗� 涓嶇瓑浜�
-      equalOpts.add(new SelectOption('notequals', '涓嶇瓑浜�'));
-      //JZHG-BSDUT4 ---20200825---update By rentongxiao---End
+        equalOpts = new List<SelectOption>();
+        equalOpts.add(new SelectOption('equals', '绛変簬'));
+        equalOpts.add(new SelectOption('contains', '鍖呭惈'));
+        //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start
+        //鏂板姞鍖归厤绗� 涓嶇瓑浜�
+        equalOpts.add(new SelectOption('notequals', '涓嶇瓑浜�'));
+        //JZHG-BSDUT4 ---20200825---update By rentongxiao---End
     }
     public String text1 { get; set; }                         // 瀵硅薄
     public String cond1 { get; set; }                         // 鏉′欢
@@ -113,257 +115,257 @@
     
     // 妫�绱㈡寜閽�
     public PageReference searchBtn() {
-      countorder = 1;
-      //楠岃瘉
-      assetSerialNumberList.clear();
-      getAssetSerialNumber();
-      totalRecords = 0;
-      List<Asset> assetconfimList = getAssetconfim(text1, cond1, val1);
-      for (Asset ast : assetconfimList) {
-        totalRecords++;
-      }
+        countorder = 1;
+        //楠岃瘉
+        assetSerialNumberList.clear();
+        getAssetSerialNumber();
+        totalRecords = 0;
+        List<Asset> assetconfimList = getAssetconfim(text1, cond1, val1);
+        for (Asset ast : assetconfimList) {
+            totalRecords++;
+        }
     
     
-      // 鑾峰彇assets
-      List<Asset> assetList = getAsset(text1, cond1, val1);
+        // 鑾峰彇assets
+        List<Asset> assetList = getAsset(text1, cond1, val1);
     
-      // 浣滄垚鏄庣粏琛�
-      getSortedUnCheckedInfoList(assetList);
-      // 鎺掑簭鐢ㄦ绱㈡潯浠堕��閬�
-      text1ForSort = text1;
-      cond1ForSort = cond1;
-      val1ForSort = val1;
-      currPage = 1;
+        // 浣滄垚鏄庣粏琛�
+        getSortedUnCheckedInfoList(assetList);
+        // 鎺掑簭鐢ㄦ绱㈡潯浠堕��閬�
+        text1ForSort = text1;
+        cond1ForSort = cond1;
+        val1ForSort = val1;
+        currPage = 1;
     
     
-      totalPage = (totalRecords / selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
-      return null;
+        totalPage = (totalRecords / selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
+        return null;
     }
     
     // 鍙栧凡閫夋嫨璧勪骇鐨勬満韬紪鐮�
     public void getAssetSerialNumber() {
-      //LJPH-BSS6E2  ---20200911 ---add by rentongxiao start
-      contr = '2';
-      //LJPH-BSS6E2  ---20200911 ---add by rentongxiao end
-      assetSerialNumberList = new List<String>();
-      assetSerialNumberList.clear();
-      for (AssetInfo ai : this.checkedAssets) {
-        system.debug('checkedAssets1111111' + this.checkedAssets);
-        //system.debug('ai.ah.SerialNumber__c' + ai.ah.SerialNumber__c);
-        if (String.isNotEmpty(ai.rec.SerialNumber)) {
-          assetSerialNumberList.add(ai.rec.SerialNumber);
+        //LJPH-BSS6E2  ---20200911 ---add by rentongxiao start
+        contr = '2';
+        //LJPH-BSS6E2  ---20200911 ---add by rentongxiao end
+        assetSerialNumberList = new List<String>();
+        assetSerialNumberList.clear();
+        for (AssetInfo ai : this.checkedAssets) {
+            system.debug('checkedAssets1111111' + this.checkedAssets);
+            //system.debug('ai.ah.SerialNumber__c' + ai.ah.SerialNumber__c);
+            if (String.isNotEmpty(ai.rec.SerialNumber)) {
+                assetSerialNumberList.add(ai.rec.SerialNumber);
+            }
         }
-      }
     }
     
     //
     private void getSortedUnCheckedInfoList(List<Asset> assetList) {
-      Boolean overLimit = false;
-      Map<Id, AssetInfo> markUpUnCheckMap = new Map<Id, AssetInfo>();
-      for (AssetInfo unCheckinfo : unCheckedAssets) {
+        Boolean overLimit = false;
+        Map<Id, AssetInfo> markUpUnCheckMap = new Map<Id, AssetInfo>();
+        for (AssetInfo unCheckinfo : unCheckedAssets) {
     
-        // 鎵撳嬀锛岃涓轰紭鍏堟樉绀烘槑缁�
-        if (unCheckinfo.rec_checkBox_c == true) {
-          ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, 'unCheckinfo.rec_checkBox_c' + unCheckinfo.rec_checkBox_c));
-          markUpUnCheckMap.put(unCheckinfo.rec.Id, unCheckinfo);
+            // 鎵撳嬀锛岃涓轰紭鍏堟樉绀烘槑缁�
+            if (unCheckinfo.rec_checkBox_c == true) {
+                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, 'unCheckinfo.rec_checkBox_c' + unCheckinfo.rec_checkBox_c));
+                markUpUnCheckMap.put(unCheckinfo.rec.Id, unCheckinfo);
+            }
         }
-      }
-      unCheckedAssets.clear();
-      // 浼樺厛鏄剧ず鏄庣粏鏀惧湪鏈�鍓嶉潰
-      unCheckedInfoList = new List<AssetInfo>();
-      for (AssetInfo asInfo : markUpUnCheckMap.values()) {
-        unCheckedAssets.add(asInfo);
-      }
-      SELECT_LIMIT = selctRecordNum;
-      Integer selectCnt = unCheckedAssets.size();
-      for (Asset asset : assetList) {
-        // 201銈掕秴銇堛仧鍫村悎鍓�200銇伩銈掑嚭銇�
-        if (unCheckedAssets.size() >= SELECT_LIMIT) { overLimit = true; break; }
-        if (markUpUnCheckMap.containsKey(asset.Id) == false) {
-          //unCheckedInfoList.add(unCheckMap.get(asset.Id));
-          unCheckedAssets.add(new AssetInfo(unCheckedAssets.size(), asset));
+        unCheckedAssets.clear();
+        // 浼樺厛鏄剧ず鏄庣粏鏀惧湪鏈�鍓嶉潰
+        unCheckedInfoList = new List<AssetInfo>();
+        for (AssetInfo asInfo : markUpUnCheckMap.values()) {
+            unCheckedAssets.add(asInfo);
         }
-      }
+        SELECT_LIMIT = selctRecordNum;
+        Integer selectCnt = unCheckedAssets.size();
+        for (Asset asset : assetList) {
+            // 201銈掕秴銇堛仧鍫村悎鍓�200銇伩銈掑嚭銇�
+            if (unCheckedAssets.size() >= SELECT_LIMIT) { overLimit = true; break; }
+            if (markUpUnCheckMap.containsKey(asset.Id) == false) {
+                //unCheckedInfoList.add(unCheckMap.get(asset.Id));
+                unCheckedAssets.add(new AssetInfo(unCheckedAssets.size(), asset));
+            }
+        }
     }
     
     //妫�绱㈤獙璇�
     private List<Asset> getAssetconfim(String txt, String con, String val) {
-      String soql = this.makeSoqlconfim();
-      soql += makeTextSql(txt, con, val);
-      system.debug('makeTextSql_soql' + soql);
-      if (isSoft) {
-        soql += ' order by ' + this.columus[Integer.valueOf(this.sortKey)] + ' ' + (this.sortOrderAsc == true ? 'asc nulls first' : 'desc nulls last ');
-      } else {
-        soql += ' order by SerialNumber, Name, Department_Name__c, InstallDate';
-      }
-      system.debug('====getAssetconfim:' + soql);
-      return Database.query(soql);
+        String soql = this.makeSoqlconfim();
+        soql += makeTextSql(txt, con, val);
+        system.debug('makeTextSql_soql' + soql);
+        if (isSoft) {
+            soql += ' order by ' + this.columus[Integer.valueOf(this.sortKey)] + ' ' + (this.sortOrderAsc == true ? 'asc nulls first' : 'desc nulls last ');
+        } else {
+            soql += ' order by SerialNumber, Name, Department_Name__c, InstallDate';
+        }
+        system.debug('====getAssetconfim:' + soql);
+        return Database.query(soql);
     }
     
     private List<Asset> getAsset(String txt, String con, String val) {
-      String soql = this.makeSoqlconfim();
-      soql += makeTextSql(txt, con, val);
+        String soql = this.makeSoqlconfim();
+        soql += makeTextSql(txt, con, val);
     
-      if (isSoft) {
-        soql += ' order by ' + this.columus[Integer.valueOf(this.sortKey)] + ' ' + (this.sortOrderAsc == true ? 'asc nulls first' : 'desc nulls last ');
-      } else {
-        soql += ' order by SerialNumber, Name, Department_Name__c, InstallDate';
-      }
-      soql += ' limit ' + System.Label.Asset_Maxcount;
-      soql += ' OFFSET ' + (countorder - 1) * Integer.valueOf(System.Label.Asset_Maxcount);
-      return Database.query(soql);
+        if (isSoft) {
+            soql += ' order by ' + this.columus[Integer.valueOf(this.sortKey)] + ' ' + (this.sortOrderAsc == true ? 'asc nulls first' : 'desc nulls last ');
+        } else {
+            soql += ' order by SerialNumber, Name, Department_Name__c, InstallDate';
+        }
+        soql += ' limit ' + System.Label.Asset_Maxcount;
+        soql += ' OFFSET ' + (countorder - 1) * Integer.valueOf(System.Label.Asset_Maxcount);
+        return Database.query(soql);
     }
     
     public Integer soqlNos() {
-      List<Asset> assetconfimList = getAssetconfim(text1, cond1, val1);
-      totalRecords = assetconfimList.size();
-      //totalPage = (totalRecords/selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
-      return totalRecords;
+        List<Asset> assetconfimList = getAssetconfim(text1, cond1, val1);
+        totalRecords = assetconfimList.size();
+        //totalPage = (totalRecords/selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
+        return totalRecords;
     }
     
     private String makeSoqlconfim() {
-      String sqlTail = '(\'';
-      system.debug('assetSerialNumberList.size()' + assetSerialNumberList.size());
-      for (Integer i = 0; i < assetSerialNumberList.size(); i++) {
-        if (i < assetSerialNumberList.size() - 1) {
-          sqlTail += assetSerialNumberList[i] + '\',\'';
-        } else {
-          sqlTail += assetSerialNumberList[i] + '\')';
+        String sqlTail = '(\'';
+        system.debug('assetSerialNumberList.size()' + assetSerialNumberList.size());
+        for (Integer i = 0; i < assetSerialNumberList.size(); i++) {
+            if (i < assetSerialNumberList.size() - 1) {
+                sqlTail += assetSerialNumberList[i] + '\',\'';
+            } else {
+                sqlTail += assetSerialNumberList[i] + '\')';
+            }
         }
-      }
-      //tcm 娣诲姞 Management_Code__c  20211201 start
-      String soql = 'SELECT Id, Name, Asset_situation__c, SerialNumber, Department_Name__c, Installation_Site__c, '
-              + 'Posting_Date__c,Management_Code__c,IF_Warranty__c,Reson_Can_not_Warranty__c, InstallDate,isNewDate_use__c, '
-              + 'Asset_Owner__c, Accumulation_Repair_Amount__c, Maintenance_Price_Month__c, Final_Examination_Date__c, '
-              + 'CurrentContract_F__c,CurrentContract_F__r.Maintenance_Contract_No_F__c,CurrentContract_F__r.Management_Code__c,CurrentContract_F__r.RecordType_DeveloperName__c,CurrentContract_F__r.Estimate_Num__c,CurrentContract_F__r.Contract_End_Date__c,'
-              + 'CurrentContract_F_asset__c,CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c,CurrentContract_F_asset__r.endDateGurantee_Text__c,CurrentContract_F__r.Gurantee_Estimate_startDate__c, '
-              + 'CurrentContract_F__r.First_Estimate_Date__c,CurrentContract_F__r.Estimate_Contract_endDate__c,'
-              + 'CurrentContract_F__r.Contract_Consumption_rate__c,CurrentContract_F__r.First_contract_usage_Rate__c,CurrentContract_F__r.Contract_Range__c,'
-              + 'CurrentContract_End_Date__c, Extend_Gurantee_DateTo__c,EquipmentGuaranteeFlg__c,AssetMark__c,NoPartRiskDate_F__c,NoPartRiskDate__c,SignableFlag__c FROM Asset WHERE Hospital__c = \'' + this.targetHospitalId + '\' ';
-      //HWAG-BDJ43R ---XHL---20190729---
-      //soql +=  ' AND AssetMark__c != \'鑰楁潗\' AND Product2.Family != \'ET\' ';
-      //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start
-      // soql +=  ' AND ( AssetMark__c != \'鑰楁潗\' OR Product2.Family != \'ET\' ) ';
-      //JZHG-BSDUT4 ---20200825---update By rentongxiao---End
-      //HWAG-BDJ43R ---XHL---20190729---
-      if (assetSerialNumberList.size() > 0) {
-        soql += ' AND SerialNumber not in ' + sqlTail;
-      }
-      return soql;
+        //tcm 娣诲姞 Management_Code__c  20211201 start  
+        String soql = 'SELECT Id, Name, Asset_situation__c, SerialNumber, Department_Name__c, Installation_Site__c, '
+                      + 'Posting_Date__c,Management_Code__c,IF_Warranty__c,Reson_Can_not_Warranty__c, InstallDate,isNewDate_use__c, '
+                      + 'Asset_Owner__c, Accumulation_Repair_Amount__c, Maintenance_Price_Month__c, Final_Examination_Date__c, '
+                      + 'CurrentContract_F__c,CurrentContract_F__r.Maintenance_Contract_No_F__c,CurrentContract_F__r.Management_Code__c,CurrentContract_F__r.RecordType_DeveloperName__c,CurrentContract_F__r.Estimate_Num__c,CurrentContract_F__r.Contract_End_Date__c,'
+                      + 'CurrentContract_F_asset__c,CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c,CurrentContract_F_asset__r.endDateGurantee_Text__c,CurrentContract_F__r.Gurantee_Estimate_startDate__c, '
+                      + 'CurrentContract_F__r.First_Estimate_Date__c,CurrentContract_F__r.Estimate_Contract_endDate__c,'
+                      + 'CurrentContract_F__r.Contract_Consumption_rate__c,CurrentContract_F__r.First_contract_usage_Rate__c,CurrentContract_F__r.Contract_Range__c,'
+                      + 'CurrentContract_End_Date__c, Extend_Gurantee_DateTo__c,EquipmentGuaranteeFlg__c,AssetMark__c,NoPartRiskDate_F__c,NoPartRiskDate__c,SignableFlag__c FROM Asset WHERE Hospital__c = \'' + this.targetHospitalId + '\' ';
+        //HWAG-BDJ43R ---XHL---20190729---
+        //soql +=  ' AND AssetMark__c != \'鑰楁潗\' AND Product2.Family != \'ET\' ';
+        //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start
+        // soql +=  ' AND ( AssetMark__c != \'鑰楁潗\' OR Product2.Family != \'ET\' ) ';
+        //JZHG-BSDUT4 ---20200825---update By rentongxiao---End
+        //HWAG-BDJ43R ---XHL---20190729---
+        if (assetSerialNumberList.size() > 0) {
+            soql += ' AND SerialNumber not in ' + sqlTail;
+        }
+        return soql;
     }
     
     // 鎷兼帴妫�绱㈡潯浠秙ql鏂�
     private String makeTextSql(String txt1, String con, String val) {
-      String soql = '';
-      if (String.isBlank(con)) {
-        con = 'equals';
-      }
-      // contains銇牬鍚堛�佹棩鍫辩敾闈€伄鐥呴櫌妞滅储銈掔湡浼笺仐銆乻pace銇у垎銇戙仸銆乤nd妞滅储
-      // equals銇牬鍚堛�丼F妯欐簴銇绱€倰鐪熶技銇椼�併��,銆嶃仹鍒嗐亼銇︺�乷r妞滅储
-      if (!String.isBlank(txt1)) {
-        if ((con == 'contains' || con == 'notcontains') && val.contains(' ')) {
-          String[] vals = val.split(' ');
-    
-          String cSql = '';
-          if (vals.size() > 0) {
-            String txt = txt1.substring(2);
-            soql += ' and ( ';
-            for (String v : vals) {
-              if (String.isNotBlank(v)) {
-                if (con == 'contains') {
-                  soql += txt + ' like \'%' + v + '%\' or ';
-                } else {
-                  soql += txt + ' not like \'%' + v + '%\' and ';
-                }
-              }
-    
-    
-            }
-            soql = soql.substring(0, soql.length() - 4);
-            soql += ')';
-          }
-          system.debug('containssoql:     ' + soql);
-        } else if ((con == 'equals' || con == 'notequals') && val.contains(',')) {
-          String[] vals = val.split(',');
-          if (vals.size() > 0) {
-            String txt = txt1.substring(2);                 // S:Name 銆佹渶鍒濄伄锛掓枃瀛椼亴銈裤偆銉椼仹銇�
-            soql += ' and ( ';
-            for (String v : vals) {
-              if (con == 'equals') {
-                soql += txt + ' = \'' + v + '\' or ';
-              } else {
-                // notequals
-                soql += txt + ' <> \'' + v + '\' and ';
-              }
-            }
-            soql = soql.substring(0, soql.length() - 4);
-            soql += ')';
-          }
-        } else {
-          String cSql = this.makeTextSqlStr(txt1, con, val);
-          if (con != 'notcontains') {
-            soql += this.makeTextSqlStr(txt1, con, val);
-          } else {
-            // notcontains
-            if (!String.isBlank(cSql)) {
-              cSql = cSql.substring(5);                 // ' and ' 銇�5鏂囧瓧銈掑銇�
-              soql += ' and (NOT ' + cSql + ') ';
-            }
-          }
+        String soql = '';
+        if (String.isBlank(con)) {
+            con = 'equals';
         }
-      }
-      // //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start
-      // else{
-      //     soql += 'And AssetMark__c = \'涓绘満\'';
-      // }
-      // //JZHG-BSDUT4 ---20200825---update By rentongxiao---End
-      return soql;
+        // contains銇牬鍚堛�佹棩鍫辩敾闈€伄鐥呴櫌妞滅储銈掔湡浼笺仐銆乻pace銇у垎銇戙仸銆乤nd妞滅储
+        // equals銇牬鍚堛�丼F妯欐簴銇绱€倰鐪熶技銇椼�併��,銆嶃仹鍒嗐亼銇︺�乷r妞滅储
+        if (!String.isBlank(txt1)) {
+            if ((con == 'contains' || con == 'notcontains') && val.contains(' ')) {
+                String[] vals = val.split(' ');
+    
+                String cSql = '';
+                if (vals.size() > 0) {
+                    String txt = txt1.substring(2);
+                    soql += ' and ( ';
+                    for (String v : vals) {
+                        if (String.isNotBlank(v)) {
+                            if (con == 'contains') {
+                                soql += txt + ' like \'%' + v + '%\' or ';
+                            } else {
+                                soql += txt + ' not like \'%' + v + '%\' and ';
+                            }
+                        }
+    
+    
+                    }
+                    soql = soql.substring(0, soql.length() - 4);
+                    soql += ')';
+                }
+                system.debug('containssoql:     ' + soql);
+            } else if ((con == 'equals' || con == 'notequals') && val.contains(',')) {
+                String[] vals = val.split(',');
+                if (vals.size() > 0) {
+                    String txt = txt1.substring(2);                 // S:Name 銆佹渶鍒濄伄锛掓枃瀛椼亴銈裤偆銉椼仹銇�
+                    soql += ' and ( ';
+                    for (String v : vals) {
+                        if (con == 'equals') {
+                            soql += txt + ' = \'' + v + '\' or ';
+                        } else {
+                            // notequals
+                            soql += txt + ' <> \'' + v + '\' and ';
+                        }
+                    }
+                    soql = soql.substring(0, soql.length() - 4);
+                    soql += ')';
+                }
+            } else {
+                String cSql = this.makeTextSqlStr(txt1, con, val);
+                if (con != 'notcontains') {
+                    soql += this.makeTextSqlStr(txt1, con, val);
+                } else {
+                    // notcontains
+                    if (!String.isBlank(cSql)) {
+                        cSql = cSql.substring(5);                 // ' and ' 銇�5鏂囧瓧銈掑銇�
+                        soql += ' and (NOT ' + cSql + ') ';
+                    }
+                }
+            }
+        }
+        // //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start
+        // else{
+        //     soql += 'And AssetMark__c = \'涓绘満\'';
+        // }
+        // //JZHG-BSDUT4 ---20200825---update By rentongxiao---End
+        return soql;
     }
     
     private String makeTextSqlStr(String txt1, String con, String val) {
-      String soql = '';
-      if (!String.isBlank(txt1)) {
-        String txt = txt1.substring(2);
-        String colType = txt1.substring(0, 2);
-        String tmpVal = val.trim();
-        // 绌虹櫧銇牬鍚�''銇仚銈�
-        if (String.isBlank(tmpVal)) {
-          if (con == 'equals') {
-            //soql += ' and ' + txt + ' = ' + tmpVal;
-            soql += ' and ' + txt + ' = null';
-          } else if (con == 'notequals') {
-            soql += ' and ' + txt + ' <> null';
-          } else {
-            // 绌虹櫧銇牬鍚堛�乧ontains, notcontains 銇� starts with銇劇瑕�
-          }
-        } else {
-          soql += ' and ' + txt;
-          if (con == 'equals') {
-            if (colType == 'S:') {
-              soql += ' = \'' + tmpVal + '\'';
+        String soql = '';
+        if (!String.isBlank(txt1)) {
+            String txt = txt1.substring(2);
+            String colType = txt1.substring(0, 2);
+            String tmpVal = val.trim();
+            // 绌虹櫧銇牬鍚�''銇仚銈�
+            if (String.isBlank(tmpVal)) {
+                if (con == 'equals') {
+                    //soql += ' and ' + txt + ' = ' + tmpVal;
+                    soql += ' and ' + txt + ' = null';
+                } else if (con == 'notequals') {
+                    soql += ' and ' + txt + ' <> null';
+                } else {
+                    // 绌虹櫧銇牬鍚堛�乧ontains, notcontains 銇� starts with銇劇瑕�
+                }
             } else {
-              soql += ' = ' + tmpVal + ' ';
+                soql += ' and ' + txt;
+                if (con == 'equals') {
+                    if (colType == 'S:') {
+                        soql += ' = \'' + tmpVal + '\'';
+                    } else {
+                        soql += ' = ' + tmpVal + ' ';
+                    }
+                } else if (con == 'notequals') {
+                    if (colType == 'S:') {
+                        soql += ' <> \'' + tmpVal + '\'';
+                    } else {
+                        soql += ' <> ' + tmpVal + ' ';
+                    }
+                } else if (con == 'contains' || con == 'notcontains') {
+                    soql += ' like \'%' + String.escapeSingleQuotes(tmpVal.replaceAll('%', '\\%')) + '%\'';
+                } else if (con == 'starts with') {
+                    soql += ' like \'' + String.escapeSingleQuotes(tmpVal.replaceAll('%', '\\%')) + '%\'';
+                } else {
+                    if (colType == 'S:') {
+                        soql += ' ' + con + '\'' + tmpVal + '\'';
+                    } else {
+                        soql += ' ' + con + ' ' + tmpVal + ' ';
+                    }
+                }
             }
-          } else if (con == 'notequals') {
-            if (colType == 'S:') {
-              soql += ' <> \'' + tmpVal + '\'';
-            } else {
-              soql += ' <> ' + tmpVal + ' ';
-            }
-          } else if (con == 'contains' || con == 'notcontains') {
-            soql += ' like \'%' + String.escapeSingleQuotes(tmpVal.replaceAll('%', '\\%')) + '%\'';
-          } else if (con == 'starts with') {
-            soql += ' like \'' + String.escapeSingleQuotes(tmpVal.replaceAll('%', '\\%')) + '%\'';
-          } else {
-            if (colType == 'S:') {
-              soql += ' ' + con + '\'' + tmpVal + '\'';
-            } else {
-              soql += ' ' + con + ' ' + tmpVal + ' ';
-            }
-          }
         }
-      }
-      return soql;
+        return soql;
     }
     
     //----------HWAG-B4R3SS------------------------------------------------------------
@@ -374,57 +376,57 @@
     
     
     public Boolean getEnablePrintContract() {
-      if (String.isBlank(this.contract.Decided_Estimation__c) == false) {
-        return this.estimate.Estimation_Decision__c;
-      } else {
-        return false;
-      }
+        if (String.isBlank(this.contract.Decided_Estimation__c) == false) {
+            return this.estimate.Estimation_Decision__c;
+        } else {
+            return false;
+        }
     }
     
     public Boolean getUnDecideBtnDisabled() {
-      // 瑕嬬銈傘倞decide鍙栨秷銇椼仹銇嶃仾銇勬潯浠躲伄鍒ゆ柇
-      if (String.isBlank(this.contract.Decided_Estimation__c) == false) {
-        if (this.estimate.Estimation_Decision__c) {
-          return false;
+        // 瑕嬬銈傘倞decide鍙栨秷銇椼仹銇嶃仾銇勬潯浠躲伄鍒ゆ柇
+        if (String.isBlank(this.contract.Decided_Estimation__c) == false) {
+            if (this.estimate.Estimation_Decision__c) {
+                return false;
+            }
         }
-      }
-      // TODO 鏈綋銇壒鍒ヨ硣鏍笺亴銇傘倢銇� 姹哄畾鍙兘銇仚銈�
-      return true;
+        // TODO 鏈綋銇壒鍒ヨ硣鏍笺亴銇傘倢銇� 姹哄畾鍙兘銇仚銈�
+        return true;
     }
     public Boolean getDecideBtnDisabled() {
-      // 瑕嬬銈傘倞decide銇с亶銇亜鏉′欢銇垽鏂�
-      if (String.isBlank(this.contract.Decided_Estimation__c) == false) {
-        if (this.estimate.Estimation_Decision__c) {
-          return true;
+        // 瑕嬬銈傘倞decide銇с亶銇亜鏉′欢銇垽鏂�
+        if (String.isBlank(this.contract.Decided_Estimation__c) == false) {
+            if (this.estimate.Estimation_Decision__c) {
+                return true;
+            }
+            // TODO 鐗瑰垾璩囨牸銇屻亗銈屻伆 姹哄畾鍙兘銇仚銈�
+            return true;
         }
-        // TODO 鐗瑰垾璩囨牸銇屻亗銈屻伆 姹哄畾鍙兘銇仚銈�
-        return true;
-      }
-      if (this.estimate.Process_Status__c != '鎵瑰噯') {
-        return true;
-      } else {
-        if (String.isBlank(this.estimate.Change_Dealer_Approval__c) == false
-          && this.estimate.Change_Dealer_Approval__c != '鎵瑰噯'
-          && this.estimate.Change_Dealer_Approval__c != '鏈壒鍑�') {
-          return true;
+        if (this.estimate.Process_Status__c != '鎵瑰噯') {
+            return true;
+        } else {
+            if (String.isBlank(this.estimate.Change_Dealer_Approval__c) == false
+                && this.estimate.Change_Dealer_Approval__c != '鎵瑰噯'
+                && this.estimate.Change_Dealer_Approval__c != '鏈壒鍑�') {
+                return true;
+            }
         }
-      }
-      return false;
+        return false;
     }
     public Boolean getApprovalBtnDisabled() {
     
-      // 瑕嬬銈傘倞鐢宠珛銇с亶銇亜鏉′欢銇垽鏂�
-      if (String.isBlank(this.contract.Decided_Estimation__c) == false) {
-        // TODO 鐗瑰垾璩囨牸銇屻亗銈屻伆 鐢宠珛鍙兘銇仚銈�
-        return true;
-      }
-      if (String.isBlank(this.estimate.Process_Status__c) == false
-        && this.estimate.Process_Status__c != '鑽夋涓�'
-        //&& this.estimate.Process_Status__c != '涓嶆壒鍑�'
-        ) {
-        return true;
-      }
-      return false;
+        // 瑕嬬銈傘倞鐢宠珛銇с亶銇亜鏉′欢銇垽鏂�
+        if (String.isBlank(this.contract.Decided_Estimation__c) == false) {
+            // TODO 鐗瑰垾璩囨牸銇屻亗銈屻伆 鐢宠珛鍙兘銇仚銈�
+            return true;
+        }
+        if (String.isBlank(this.estimate.Process_Status__c) == false
+            && this.estimate.Process_Status__c != '鑽夋涓�'
+            //&& this.estimate.Process_Status__c != '涓嶆壒鍑�'
+            ) {
+            return true;
+        }
+        return false;
     }
     // 20200307 涓嶇敤
     // public Boolean getcontactBtnDisabled() {
@@ -441,42 +443,42 @@
     //     return false;
     // }
     public Boolean getSaveBtnDisabled() {
-      // 瑕嬬銈傘倞save銇с亶銇亜鏉′欢銇垽鏂�
-      if (String.isBlank(this.contract.Decided_Estimation__c) == false) {
-        return true;
-      }
-      if (String.isBlank(this.estimate.Process_Status__c) == false
-        && this.estimate.Process_Status__c != '鑽夋涓�'
-        //&& this.estimate.Process_Status__c != '涓嶆壒鍑�'
-        ) {
-        return true;
-      }
-      return false;
+        // 瑕嬬銈傘倞save銇с亶銇亜鏉′欢銇垽鏂�
+        if (String.isBlank(this.contract.Decided_Estimation__c) == false) {
+            return true;
+        }
+        if (String.isBlank(this.estimate.Process_Status__c) == false
+            && this.estimate.Process_Status__c != '鑽夋涓�'
+            //&& this.estimate.Process_Status__c != '涓嶆壒鍑�'
+            ) {
+            return true;
+        }
+        return false;
     }
     public Boolean getPrintBtnDisabled() {
-      // 鍗板埛銇с亶銇亜鏉′欢銇垽鏂�
-      if (this.estimate.Process_Status__c != '鎵瑰噯' || !this.contract.Status__c.equals('寮曞悎涓�') ) {
-        return true;
-      } else {
-        if (String.isBlank(this.estimate.Change_Dealer_Approval__c) == false
-          && this.estimate.Change_Dealer_Approval__c != '鎵瑰噯'
-          && this.estimate.Change_Dealer_Approval__c != '鏈壒鍑�') {
-          return true;
+        // 鍗板埛銇с亶銇亜鏉′欢銇垽鏂�
+        if (this.estimate.Process_Status__c != '鎵瑰噯' || !this.contract.Status__c.equals('寮曞悎涓�') ) {
+            return true;
+        } else {
+            if (String.isBlank(this.estimate.Change_Dealer_Approval__c) == false
+                && this.estimate.Change_Dealer_Approval__c != '鎵瑰噯'
+                && this.estimate.Change_Dealer_Approval__c != '鏈壒鍑�') {
+                return true;
+            }
         }
-      }
-      return false;
+        return false;
     }
     // 椤甸潰椤圭洰闈炴椿鎬ц瀹�
     public Boolean getPageDisabled() {
-      if (String.isBlank(this.contract.Decided_Estimation__c) == false) {
-        return true;
-      }
-      if (String.isBlank(this.estimate.Process_Status__c) == false
-        && this.estimate.Process_Status__c != '鑽夋涓�'
-        ) {
-        return true;
-      }
-      return false;
+        if (String.isBlank(this.contract.Decided_Estimation__c) == false) {
+            return true;
+        }
+        if (String.isBlank(this.estimate.Process_Status__c) == false
+            && this.estimate.Process_Status__c != '鑽夋涓�'
+            ) {
+            return true;
+        }
+        return false;
     }
     // 2021銆�8銆�26 鍚堝悓鎶ヤ环椤甸潰鐨勪紭鍖栵紝鏃犱繚鏈夎澶囩偣妫�瀵硅薄閫夋嫨妗嗗彉榛� fxk star
     // public Boolean getPageDisabled1() {
@@ -490,25 +492,25 @@
     // }
     // 2021銆�8銆�26 鍚堝悓鎶ヤ环椤甸潰鐨勪紭鍖栵紝鏃犱繚鏈夎澶囩偣妫�瀵硅薄閫夋嫨妗嗗彉榛� fxk end
     public Integer productCount {
-      get {
-        return checkedAssets == null ? 0 : checkedAssets.size();
-      }
+        get {
+            return checkedAssets == null ? 0 : checkedAssets.size();
+        }
     }
     public Integer productCount2 {
-      get {
-        return unCheckedAssets == null ? 0 : unCheckedAssets.size();
-      }
+        get {
+            return unCheckedAssets == null ? 0 : unCheckedAssets.size();
+        }
     }
     public Integer productCount3 {
-      get {
-        Integer cnt = 0;
-        for (AssetInfo input : this.checkedAssets) {
-          if (!input.isManual || input.isManual && !String.isBlank(input.mcae.Product_Manual__c)) {
-            cnt += 1;
-          }
+        get {
+            Integer cnt = 0;
+            for (AssetInfo input : this.checkedAssets) {
+                if (!input.isManual || input.isManual && !String.isBlank(input.mcae.Product_Manual__c)) {
+                    cnt += 1;
+                }
+            }
+            return cnt;
         }
-        return cnt;
-      }
     }
     // TODO 銈偣銈裤儬銉┿儥銉亱銈夊彇寰�
     public static Decimal oxygenPriceAdj { get { return 0.1; } }                                  // TODO katsu 閰稿寲姘淬倰浣跨敤銇椼仾銇勩倛銇嗐伀澶夋洿
@@ -535,1280 +537,1283 @@
      * 銈炽兂銈广儓銉┿偗銈�
      */
     public SelectAssetEstimateVMController() {
-      currPage = 1;
-      selRecordOption = '20';
-      totalRecords = 0;
+        currPage = 1;
+        selRecordOption = '20';
+        totalRecords = 0;
+        checkDealerId = '';
     }
     /**
      * Visaulforce銇嬨倝鍛笺伆銈屻倠銈炽兂銈广儓銉┿偗銈�
      */
     public SelectAssetEstimateVMController(ApexPages.StandardController controller) {
-      //HWAG-B4R3SS  START 20181026
-      currPage = 1;
-      selRecordOption = '20';
-      //this.targetEstimateId = (String)(ApexPages.currentPage().getParameters().get('id'));
-      totalRecords = 0;
-      //HWAG-B4R3SS  END 20181026
+        //HWAG-B4R3SS  START 20181026
+        currPage = 1;
+        selRecordOption = '20';
+        //this.targetEstimateId = (String)(ApexPages.currentPage().getParameters().get('id'));
+        totalRecords = 0;
+        //HWAG-B4R3SS  END 20181026
     }
     
     private void setThisEstimate() {
-      //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,
-               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,
-               Examination_Price__c, Service_contract_target_number__c,
-               Maintenance_Contract__r.Payment_Plan_Sum_First__c, Maintenance_Contract__r.Payment_Plan_Date_First__c,
-               Maintenance_Contract__r.Payment_Plan_Sum_Second__c,
-               Maintenance_Contract__r.Payment_Plan_Sum_Third__c,
-               Maintenance_Contract__r.Payment_Plan_Sum_Forth__c,
-               Maintenance_Contract__r.Payment_Plan_Sum_Fifth__c,
-               Maintenance_Contract__r.Payment_Plan_Sum_Sixth__c,
-               Discount_Price__c, Discount_Percentage__c, IsSyncing__c,
-               NotUse_Oxygenated_Water__c, Estimate_Target__c, Dealer__c,
-               Append_Condition_Price__c, Asset_Sum_Price__c, Asset_Repair_Sum_Price__c,
-               Print_Contract__c, Print_RepairPrice__c, Print_DiscountPercentage__c, Print_Agent__c, Change_Dealer_Approval__c,
-               Print_DiscountPrice__c, Print_ListPrice__c, Print_MaintePrice__c, Print_SumPrice__c, Print_Tripartite__c, TKZongjianApprovalManager__c
-               //鎵撳嵃鎶ヤ环锛堢畝鍖栫増锛� 2019/12/18 start
-               , IS_Clone_After_Decide__c, New_contract_offer__c, NewEstimation_Amount__c, EndUserType__c, Print_Simplify__c
-               //鎵撳嵃鎶ヤ环锛堢畝鍖栫増锛� 2019/12/18 end
-               //鏈�浣庝环鏍� 鏈�楂樹环鏍� 鐢宠鑳屾櫙鐩稿叧瀛楁 20200108 start
-               , GuidePrice_Up__c, GuidePrice_Down__c, finalPriceDecideWay__c, mainTalksTime__c, talksStartDate__c
-               , Combined_rate__c, New_Contract_Type_TxT__c, Estimate_Price_range__c
-               //鏈�浣庝环鏍� 鏈�楂樹环鏍艰绠� 20200108 end
-               , Sales_incidental__c, Consumption_rate_Forecast__c, AgencyHos_Price__c
-               // 鐢宠鎶ヤ环閲戦 鍜� 鐩稿鏍囧噯浠锋牸鑼冨洿鐨勬姌鎵g巼
-               , Request_quotation_Amount__c, Service_discount_Rate__c, ContractPriceType__c
-               , LastMContract1__c, LastMContract2__c, LastMContract3__c, LastMContract4__c, LastMContract5__c
-               , LastMContract1_ConCount__c, LastMContract2_ConCount__c, LastMContract3_ConCount__c, LastMContract4_ConCount__c, LastMContract5_ConCount__c,
-               LastMContract1_NO__c, LastMContract2_NO__c, LastMContract3_NO__c, LastMContract4_NO__c, LastMContract5_NO__c
-               //璺宠繃鐐规鏍囪 2021/07/28 gzw start
-               , Skip_DJ__c
-               //璺宠繃鐐规鏍囪 2021/07/28 gzw start
-               FROM Maintenance_Contract_Estimate__c WHERE Id = :this.targetEstimateId];
-      //HWAG-B399Q8 2018/08/20  娣诲姞涓�棰濆瀛楁 IS_Clone_After_Decide__c end
-      decimal PriceSum =  (this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_First__c == null ? 0 : this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_First__c) +
-                 (this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Second__c == null ? 0 : this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Second__c) +
-                 (this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Third__c == null ? 0 : this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Third__c) +
-                 (this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Forth__c == null ? 0 : this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Forth__c) +
-                 (this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Fifth__c == null ? 0 : this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Fifth__c) +
-                 (this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Sixth__c == null ? 0 : this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Sixth__c);
-      if ( this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_First__c == null
-         //102018/10/26 HWAG-B5C88S 涓嶅啀鏍规嵁鏄惁濉啓绗竴娆′粯娆炬棩鏈熷垽鏂�
-         ) {
-        isPaymentSet = 'false';
-      } else if (this.estimate.Maintenance_Price__c != PriceSum) {
-        isPaymentSet = 'Denied';
-      } else {
-        isPaymentSet = 'true';
-      }
+        //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,
+                         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,
+                         Examination_Price__c, Service_contract_target_number__c,
+                         Maintenance_Contract__r.Payment_Plan_Sum_First__c, Maintenance_Contract__r.Payment_Plan_Date_First__c,
+                         Maintenance_Contract__r.Payment_Plan_Sum_Second__c,
+                         Maintenance_Contract__r.Payment_Plan_Sum_Third__c,
+                         Maintenance_Contract__r.Payment_Plan_Sum_Forth__c,
+                         Maintenance_Contract__r.Payment_Plan_Sum_Fifth__c,
+                         Maintenance_Contract__r.Payment_Plan_Sum_Sixth__c,
+                         Discount_Price__c, Discount_Percentage__c, IsSyncing__c,
+                         NotUse_Oxygenated_Water__c, Estimate_Target__c, Dealer__c,Dealer__r.FirstParagraphEnd__c,Is_RecognitionModel__c,
+                         Append_Condition_Price__c, Asset_Sum_Price__c, Asset_Repair_Sum_Price__c,
+                         Print_Contract__c, Print_RepairPrice__c, Print_DiscountPercentage__c, Print_Agent__c, Change_Dealer_Approval__c,
+                         Print_DiscountPrice__c, Print_ListPrice__c, Print_MaintePrice__c, Print_SumPrice__c, Print_Tripartite__c, TKZongjianApprovalManager__c
+                         //鎵撳嵃鎶ヤ环锛堢畝鍖栫増锛� 2019/12/18 start
+                         , IS_Clone_After_Decide__c, New_contract_offer__c, NewEstimation_Amount__c, EndUserType__c, Print_Simplify__c
+                         //鎵撳嵃鎶ヤ环锛堢畝鍖栫増锛� 2019/12/18 end
+                         //鏈�浣庝环鏍� 鏈�楂樹环鏍� 鐢宠鑳屾櫙鐩稿叧瀛楁 20200108 start
+                         , GuidePrice_Up__c, GuidePrice_Down__c, finalPriceDecideWay__c, mainTalksTime__c, talksStartDate__c
+                         , Combined_rate__c, New_Contract_Type_TxT__c, Estimate_Price_range__c
+                         //鏈�浣庝环鏍� 鏈�楂樹环鏍艰绠� 20200108 end
+                         , Sales_incidental__c, Consumption_rate_Forecast__c, AgencyHos_Price__c
+                         // 鐢宠鎶ヤ环閲戦 鍜� 鐩稿鏍囧噯浠锋牸鑼冨洿鐨勬姌鎵g巼
+                         , Request_quotation_Amount__c, Service_discount_Rate__c, ContractPriceType__c
+                         , LastMContract1__c, LastMContract2__c, LastMContract3__c, LastMContract4__c, LastMContract5__c
+                         , LastMContract1_ConCount__c, LastMContract2_ConCount__c, LastMContract3_ConCount__c, LastMContract4_ConCount__c, LastMContract5_ConCount__c,
+                         LastMContract1_NO__c, LastMContract2_NO__c, LastMContract3_NO__c, LastMContract4_NO__c, LastMContract5_NO__c
+                         //璺宠繃鐐规鏍囪 2021/07/28 gzw start
+                         , Skip_DJ__c
+                         //璺宠繃鐐规鏍囪 2021/07/28 gzw start
+    
+                         FROM Maintenance_Contract_Estimate__c WHERE Id = :this.targetEstimateId];
+        //HWAG-B399Q8 2018/08/20  娣诲姞涓�棰濆瀛楁 IS_Clone_After_Decide__c end
+        decimal PriceSum =  (this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_First__c == null ? 0 : this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_First__c) +
+                           (this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Second__c == null ? 0 : this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Second__c) +
+                           (this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Third__c == null ? 0 : this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Third__c) +
+                           (this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Forth__c == null ? 0 : this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Forth__c) +
+                           (this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Fifth__c == null ? 0 : this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Fifth__c) +
+                           (this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Sixth__c == null ? 0 : this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_Sixth__c);
+        if ( this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_First__c == null
+             //102018/10/26 HWAG-B5C88S 涓嶅啀鏍规嵁鏄惁濉啓绗竴娆′粯娆炬棩鏈熷垽鏂�
+             ) {
+            isPaymentSet = 'false';
+        } else if (this.estimate.Maintenance_Price__c != PriceSum) {
+            isPaymentSet = 'Denied';
+        } else {
+            isPaymentSet = 'true';
+        }
     }
     
     public void init() {
-      typeresult = null;
-      changedAfterPrint = false;
-      changedSubmitPrice = false;
-      isSaveOrApproval = false;
-      OldContractStartDate = null;
-      OldMaintenancePrice = null;
+        typeresult = null;
+        changedAfterPrint = false;
+        changedSubmitPrice = false;
+        isSaveOrApproval = false;
+        OldContractStartDate = null;
+        OldMaintenancePrice = null;
     
-      inDicideFlag = false;
+        inDicideFlag = false;
     
-      isSoft = false;
-      activeOn = true;
-      //LJPH-BSS6E2  ---20200911 ---update by rentongxiao start
-      contr = '1';
-      val1 = '涓绘満';
-      //LJPH-BSS6E2  ---20200911 ---update by rentongxiao end
+        isSoft = false;
+        activeOn = true;
+        //LJPH-BSS6E2  ---20200911 ---update by rentongxiao start
+        contr = '1';
+        val1 = '涓绘満';
+        //LJPH-BSS6E2  ---20200911 ---update by rentongxiao end
     
-      Date systemToday = System.today();
-      if (isPageAction == false) {
-        //HWAG-B399Q8 2018/08/20  娣诲姞鐘舵��5锛屼负鎸塻ave 鎸夐敭鍚庣姸鎬� start
-        if (String.isBlank(ApexPages.currentPage().getParameters().get('completion')) == false) {
-          if (ApexPages.currentPage().getParameters().get('completion') == '1') {
-            ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, System.Label.Message_002));
-          } else if (ApexPages.currentPage().getParameters().get('completion') == '2') {
-            ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '瀹℃壒鎻愪氦鎴愬姛銆�'));
-          } else if (ApexPages.currentPage().getParameters().get('completion') == '3') {
-            ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, 'Decided銆�'));
-          } else if (ApexPages.currentPage().getParameters().get('completion') == '4') {
+        Date systemToday = System.today();
+        if (isPageAction == false) {
+            //HWAG-B399Q8 2018/08/20  娣诲姞鐘舵��5锛屼负鎸塻ave 鎸夐敭鍚庣姸鎬� start
+            if (String.isBlank(ApexPages.currentPage().getParameters().get('completion')) == false) {
+                if (ApexPages.currentPage().getParameters().get('completion') == '1') {
+                    ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, System.Label.Message_002));
+                } else if (ApexPages.currentPage().getParameters().get('completion') == '2') {
+                    ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '瀹℃壒鎻愪氦鎴愬姛銆�'));
+                } else if (ApexPages.currentPage().getParameters().get('completion') == '3') {
+                    ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, 'Decided銆�'));
+                } else if (ApexPages.currentPage().getParameters().get('completion') == '4') {
     
-          } else if (ApexPages.currentPage().getParameters().get('completion') == '5') {
-            ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, System.Label.Message_002));
-          }
-        }
-        //HWAG-B399Q8 2018/08/20  娣诲姞鐘舵��5锛屼负鎸塻ave 鎸夐敭鍚庣姸鎬� end
-      }
-      this.printAsset = false;
-      this.printContract = false;
-      this.printTripartite = false;
-      this.printAgent = false;
-      String copyid = '';
-      if (isPageAction == false) {
-        this.targetEstimateId = ApexPages.currentPage().getParameters().get('copyid');
-        copyid = ApexPages.currentPage().getParameters().get('copyid');
-        if (this.targetEstimateId == null) {
-          String paramId = ApexPages.currentPage().getParameters().get('id');
-          if (String.isBlank(paramId) == false && paramId.startsWith('a0z')) {
-            Maintenance_Contract_Asset_Estimate__c mcaeParam = [Select Maintenance_Contract_Estimate__c from Maintenance_Contract_Asset_Estimate__c where Id = :paramId];
-            this.targetEstimateId = mcaeParam.Maintenance_Contract_Estimate__c;
-          } else {
-            this.targetEstimateId = paramId;
-          }
-        } else {
-          this.newIns = true;
-        }
-        this.targetMaintenanceContractId = ApexPages.currentPage().getParameters().get('mcid');
-      }
-      // 绶ㄩ泦銇嬨倝
-      if (String.isBlank(this.targetEstimateId) == false) {
-        setThisEstimate();
-        this.targetMaintenanceContractId = this.estimate.Maintenance_Contract__c;
-        this.setContractInfo(this.targetMaintenanceContractId);
-      }
-      // 鏂拌銇嬨倝
-      else if (!String.isBlank(this.targetMaintenanceContractId)) {
-        this.estimate = new Maintenance_Contract_Estimate__c();
-        this.estimate.Maintenance_Contract__c = this.targetMaintenanceContractId;
-        this.estimate.Contract_Esti_Start_Date__c = systemToday;
-        this.estimate.Contract_Start_Date__c = systemToday;
-        this.setContractInfo(this.targetMaintenanceContractId);
-        this.newIns = true;
-      }
-      // 浣曘倐銇亼銈屻伆銆佸康銇仧銈�
-      else {
-        throw new ControllerUtil.myException('鏃犳硶鏄剧ず缁翠慨鍚堝悓鎶ヤ环');
-        //return;
-      }
-      //HWAG-B399Q8 2018/08/20  妫�楠屾槸鍚︽樉绀�'璇锋彁浜ゅ緟瀹℃壒' start
-      IS_Clone_After_Decide = false;
-      if (String.isBlank(ApexPages.currentPage().getParameters().get('completion')) == false &&
-        ApexPages.currentPage().getParameters().get('completion') == '5' &&
-        this.estimate != null && this.estimate.IS_Clone_After_Decide__c) {
-        IS_Clone_After_Decide = true;
-    
-      }
-      //HWAG-B399Q8 2018/08/20  妫�楠屾槸鍚︽樉绀�'璇锋彁浜ゅ緟瀹℃壒' end
-      // 绱嶅叆姗熷櫒銇儏鍫便倰鍙栧緱
-      if (!String.isBlank(this.targetHospitalId) && (this.targetHospitalId.length() == 15 || this.targetHospitalId.length() == 18)) {
-        //tcm 娣诲姞 Management_Code__c  20211201 start
-           assetRecords = [SELECT Id, Name, Asset_situation__c, SerialNumber, Department_Name__c, Installation_Site__c, Posting_Date__c, Management_Code__c, IF_Warranty__c, Reson_Can_not_Warranty__c,
-                InstallDate, isNewDate_use__c, Asset_Owner__c, Accumulation_Repair_Amount__c, Maintenance_Price_Month__c, Final_Examination_Date__c, CurrentContract_End_Date__c, EquipmentGuaranteeFlg__c,
-                CurrentContract_F__c, CurrentContract_F__r.Maintenance_Contract_No_F__c,CurrentContract_F__r.Management_Code__c, CurrentContract_F__r.RecordType_DeveloperName__c, CurrentContract_F__r.Estimate_Num__c, CurrentContract_F__r.Contract_End_Date__c, CurrentContract_F__r.Estimate_Contract_endDate__c,
-                CurrentContract_F_asset__c, CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c, CurrentContract_F_asset__r.endDateGurantee_Text__c, CurrentContract_F__r.Gurantee_Estimate_startDate__c,
-                CurrentContract_F__r.First_Estimate_Date__c,
-                CurrentContract_F__r.Contract_Consumption_rate__c, CurrentContract_F__r.First_contract_usage_Rate__c,
-                CurrentContract_F__r.Contract_Range__c, AssetMark__c,
-                // 2021-01-29 LJPH-BX9CVX mzy   add  鍚堝悓鎶ヤ环鏃跺垽鏂浂浠堕闄�
-                NoPartRiskDate_F__c, NoPartRiskDate__c, SignableFlag__c,
-                Product2.PartSupplyFinishDate__c, Product2.PartSupplyFinishDateExp__c
-                // 2021-01-29 LJPH-BX9CVX mzy   add  鍚堝悓鎶ヤ环鏃跺垽鏂浂浠堕闄�
-                FROM Asset WHERE Hospital__c = :this.targetHospitalId AND ( AssetMark__c != '鑰楁潗' OR Product2.Family != 'ET' ) ORDER BY ID, IF_Warranty__c asc];
-        //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start
-        // assetRecords = [SELECT Id, Name, Asset_situation__c, SerialNumber, Department_Name__c, Installation_Site__c, Posting_Date__c,Management_Code__c,IF_Warranty__c,Reson_Can_not_Warranty__c,
-        //                      InstallDate,isNewDate_use__c, Asset_Owner__c, Accumulation_Repair_Amount__c, Maintenance_Price_Month__c, Final_Examination_Date__c,CurrentContract_End_Date__c,EquipmentGuaranteeFlg__c,
-        //                      CurrentContract_F__c,CurrentContract_F__r.Maintenance_Contract_No_F__c,CurrentContract_F__r.RecordType_DeveloperName__c,CurrentContract_F__r.Estimate_Num__c,CurrentContract_F__r.Contract_End_Date__c,CurrentContract_F__r.Estimate_Contract_endDate__c,
-        //                      CurrentContract_F_asset__c,CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c,CurrentContract_F_asset__r.endDateGurantee_Text__c,CurrentContract_F__r.Gurantee_Estimate_startDate__c,
-        //                      CurrentContract_F__r.First_Estimate_Date__c,
-        //                     CurrentContract_F__r.Contract_Consumption_rate__c,CurrentContract_F__r.First_contract_usage_Rate__c,
-        //                     CurrentContract_F__r.Contract_Range__c ,AssetMark__c
-        //                      FROM Asset WHERE Hospital__c = :this.targetHospitalId AND AssetMark__c = '涓绘満' ORDER BY ID,IF_Warranty__c asc];
-        //JZHG-BSDUT4 ---20200825---update By rentongxiao---End
-      } else {
-        assetRecords = new List<Asset>();
-      }
-      //sqlStr += ' AND AssetMark__c != \'鑰楁潗\' AND Product2.Family != \'ET\' ';
-      this.checkedAssets = new List<AssetInfo>();
-      this.unCheckedAssets = new List<AssetInfo>();
-    
-      // 閬告姙娓堛伩銇磵鍏ユ鍣ㄦ儏鍫便倰鍙栧緱
-      Map<Id, Integer> selectedAssetIds = new Map<Id, Integer>();
-      List<Maintenance_Contract_Asset_Estimate__c> selectedMcaes = new List<Maintenance_Contract_Asset_Estimate__c>();
-      List<Maintenance_Contract_Asset_Estimate__c> newMcaes = new List<Maintenance_Contract_Asset_Estimate__c>();
-      // 鏂拌銆佷笖銇わ紤銇ょ洰瑕嬬銈傘倞銇牬鍚堛�併偝銉斻兗鍏冦伄淇濇湁瑷倷銈掓寔銇�
-      if (String.isBlank(this.targetEstimateId) && this.contract.Estimate_Num__c == 0) {
-        List<Maintenance_Contract_Asset__c> oldVals = [
-          select Id, Name, Asset__c, Asset__r.InstallDate, Asset__r.isNewDate_use__c,
-          Asset__r.Posting_Date__c, Asset__r.Maintenance_Price_Month__c,
-          Asset__r.EquipmentGuaranteeFlg__c,
-          Asset__r.CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c,
-          Asset__r.CurrentContract_F_asset__r.endDateGurantee_Text__c,
-          Asset__r.CurrentContract_F__r.First_Estimate_Date__c,
-          Asset__r.CurrentContract_F__r.Contract_Consumption_rate__c,
-          Asset__r.CurrentContract_F__r.First_contract_usage_Rate__c,
-          Asset__r.CurrentContract_F__r.Estimate_Contract_endDate__c,
-          Asset__r.CurrentContract_F__r.Contract_Range__c,
-          Asset__r.CurrentContract_F__r.Contract_End_Date__c,
-          Asset__r.CurrentContract_F__r.Gurantee_Estimate_startDate__c
-          from Maintenance_Contract_Asset__c
-          where Maintenance_Contract__c = :this.targetMaintenanceContractId
-        ];
-        Date mon1stDate = Date.newInstance(Date.today().year(), Date.today().month(), 1);
-        for (Maintenance_Contract_Asset__c mca : oldVals) {
-          // old銈堛倞鏇存柊銇椼仧銇勯爡鐩�
-          Boolean isNew = false;
-          // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk Star
-          boolean isCheck = true;
-          // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk End
-          Decimal listPrice = mca.Asset__r.Maintenance_Price_Month__c;
-          Decimal asset_Consumption_rate = null;
-          // 鍙栦笂涓�鏈熷悎鍚屾秷璐圭巼
-          if (mca.Asset__r.CurrentContract_F__r.First_Estimate_Date__c != null && mca.Asset__r.CurrentContract_F__r.Estimate_Contract_endDate__c > mon1stDate) {
-            asset_Consumption_rate = mca.Asset__r.CurrentContract_F__r.First_contract_usage_Rate__c;
-          } else {
-            asset_Consumption_rate = mca.Asset__r.CurrentContract_F__r.Contract_Consumption_rate__c;
-          }
-          // InstallDate 銇� 浠婃棩銈掓瘮杓�
-          // 1.瀹夎鏃ユ垨鑰呭彂璐ф棩鍜屼粖澶╂瘮杈� 瀹炴椂鍙樺寲
-          // 2.鎻愪氦鍚庝笉鍐嶅彉鍖�
-          //Date createdDate = (estimate.CreatedDate == null || !String.isBlank(copyid)) ? systemToday : estimate.CreatedDate.date();
-          Date createdDate = systemToday;
-          if (createdDate.addMonths(isNewAddMonth) < mca.Asset__r.isNewDate_use__c) {
-            isNew = true;
-            // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk Star
-            isCheck = true;
-            // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk End
-            listPrice = mca.Asset__r.Maintenance_Price_Month__c * isNewPriceAdj;
-          }
-          selectedAssetIds.put(mca.Asset__c, selectedMcaes.size());
-          selectedMcaes.add(new Maintenance_Contract_Asset_Estimate__c(
-                  Asset__c = mca.Asset__c,
-                  isNew__c = isNew,
-                  // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk Star
-                  Check_Object__c = isCheck,
-                  // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk End
-                  Estimate_List_Price__c = listPrice,
-                  // 鍙栦笂涓�鏈熷悎鍚屼环鏍�
-                  LastMContract_Price__c = mca.Asset__r.CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c,
-    
-                  Asset_Consumption_rate__c = asset_Consumption_rate,
-                  EquipmentGuaranteeFlgTxt__c = mca.Asset__r.EquipmentGuaranteeFlg__c
-                  ));
-        }
-      } else {
-        for (Maintenance_Contract_Asset_Estimate__c mcae : [SELECT Id,
-                                  Name,
-                                  Maintenance_Contract_Estimate__c,
-                                  Maintenance_Contract_Estimate__r.Contract_Esti_Start_Date__c,
-                                  Asset__c,
-                                  Asset__r.Maintenance_Price_Month__c,
-                                  Asset__r.InstallDate,
-                                  Asset__r.isNewDate_use__c,
-                                  Asset__r.EquipmentGuaranteeFlg__c,
-                                  Asset_Consumption_rate__c,
-                                  Asset__r.CurrentContract_F__c,
-                                  Asset__r.CurrentContract_F__r.First_Estimate_Date__c,
-                                  Asset__r.CurrentContract_F__r.Contract_Consumption_rate__c,
-                                  Asset__r.CurrentContract_F__r.First_contract_usage_Rate__c,
-                                  Asset__r.CurrentContract_F__r.Estimate_Contract_endDate__c,
-                                  Asset__r.CurrentContract_F__r.Contract_Range__c,
-                                  Asset__r.CurrentContract_F__r.Contract_End_Date__c,
-                                  Asset__r.CurrentContract_F__r.Gurantee_Estimate_startDate__c,
-                                  LastMContract_Price__c,
-                                  Asset__r.CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c,
-                                  Asset__r.CurrentContract_F_asset__r.endDateGurantee_Text__c,
-                                  Product_Manual__c,
-                                  Product_Manual__r.EquipmentGuaranteeFlg__c,
-                                  Product_Manual__r.Maintenance_Price_Month__c,
-                                  Product_Manual__r.Name,
-                                  //add 2021-02-07 mzy  start
-                                  //Product_Manual__r.NoPartRiskDate_F__c,
-                                  //Product_Manual__r.SignableFlag__c,
-                                  //add 2021-02-07 mzy  end
-                                  //add 2021.6.4 fxk  Start
-                                  Check_Object__c,
-                                  //add 2021.6.4 fxk  end
-                                  IsNew__c,
-                                  Estimate_List_Price__c,
-                                  //Maintenance_Price_YearTXT__c,
-                                  Estimate_Cost__c,
-                                  Adjustment_ratio_Upper__c,
-                                  Adjustment_ratio_Lower__c,
-                                  Adjustment_Lower_price__c,
-                                  Adjustment_Upper_price__c,
-                                  Last_inspection_day__c,
-                                  Check_Result__c,
-                                  Repair_Price__c,
-                                  Comment__c,
-                                  Asset__r.Posting_Date__c,
-                                  EquipmentGuaranteeFlgTxt__c,
-                                  EquipmentGuaranteeFlg__c,
-                                  ifHaveleftInPrevious__c,
-                                  // Gzw 20200807 浜斾釜鍘诲勾鍚堝悓鐩稿叧锛屾墍浠ユ姤浠蜂骇鍝侊紝鑾峰彇涓婃湡鍚堝悓 start
-                                  Last_MContract__c
-                                  // Gzw 20200807 浜斾釜鍘诲勾鍚堝悓鐩稿叧锛屾墍浠ユ姤浠蜂骇鍝侊紝鑾峰彇涓婃湡鍚堝悓 eng
-                                  // LJPH-C9GD34 gzw fix start
-                                  ,Estimate_List_Price_Page__c
-                                  // LJPH-C9GD34 gzw fix end
-                                  FROM Maintenance_Contract_Asset_Estimate__c
-                                  WHERE Maintenance_Contract_Estimate__c = :this.targetEstimateId
-                                                       ORDER BY
-                                                       Id,
-                                  Asset__c,
-                                  Product_Manual__c,
-                                  Asset__r.SerialNumber,
-                                  Asset__r.Name,
-                                  Asset__r.Department_Name__c,
-                                  Asset__r.InstallDate
-           ]) {
-          if (!getPageDisabled() || (getPageDisabled() && String.isBlank(copyid) == false)) {
-            //if (String.isBlank(copyid) == false) {
-            if (mcae.Asset__c <> null) {
-              mcae.EquipmentGuaranteeFlgTxt__c = mcae.Asset__r.EquipmentGuaranteeFlg__c;
-              if (systemToday.addMonths(isNewAddMonth) < mcae.Asset__r.isNewDate_use__c) {
-                mcae.IsNew__c = true;
-                mcae.Estimate_List_Price__c = mcae.Asset__r.Maintenance_Price_Month__c * isNewPriceAdj;
-              } else {
-                mcae.IsNew__c = false;
-                mcae.Estimate_List_Price__c = mcae.Asset__r.Maintenance_Price_Month__c;
-              }
-            } else if (mcae.Product_Manual__c <> null) {
-              mcae.IsNew__c = true;
-              mcae.Estimate_List_Price__c = mcae.Product_Manual__r.Maintenance_Price_Month__c * isNewPriceAdj;
-            }
-          }
-          if (mcae.Asset__c <> null) {
-            //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO , mcae.Asset__c + 'IsNew  ' + mcae.IsNew__c));
-            selectedAssetIds.put(mcae.Asset__c, selectedMcaes.size());
-            selectedMcaes.add(mcae);
-          } else {
-            newMcaes.add(mcae);
-          }
-        }
-      }
-      // 閬告姙娓堛伩銇倐銇伀銉併偋銉冦偗銈掍粯銇戙倠
-      // TODO xudan 涓�瑕с伀鍑恒倠鏄庣窗浠舵暟銇岃冻銈娿仾銇勩偙銉笺偣銇屻亗銈�
-      // 鈶燗ssetA鈥曟槑绱癆銇ф槑绱扮櫥閷�
-      // 鈶sset銇绱㈡潯浠跺鏇淬伀銈堛倞銆丄ssetA銇案閬犮伀鍙栧緱銇с亶銇亜
-      // 鈶sset銈掑厓銇儑銉笺偪銈掋優銉冦償銉炽偘銇欍倠鏅傘�佹槑绱般優銉冦儣銇嬨倝AssetA銈掑彇寰椼仹銇嶃仾銇�?涓�瑕с伀鏄庣窗A銇屽嚭銇亜
-      // 娆″洖銆丄sset銇绱㈡潯浠躲亴澶с亶銇忓鏇淬仚銈嬫檪銆佸蹇滃繀瑕�
-      List<Data> datatemp = new List<Data>();
-      datatemp = getChartData();
-      for (Asset ast : this.assetRecords) {
-        Boolean isNew = false;
-        Decimal listPrice = ast.Maintenance_Price_Month__c;
-        if (selectedAssetIds.containsKey(ast.Id)) {
-          Maintenance_Contract_Asset_Estimate__c selectedLocal = selectedMcaes.get(selectedAssetIds.get(ast.Id));
-          isNew = selectedLocal.isNew__c;
-          listPrice = selectedLocal.Estimate_List_Price__c;
-          // xudan 20160110 鏂板搧鍒ゆ柇銇撱亾瑕併倝銇亜銆乧ontractStartDateChange銇屻倓銈�
-          //                if (systemToday.addMonths(-6) < ast.InstallDate) {
-          //                if (estimate.Contract_Esti_Start_Date__c.addMonths(isNewAddMonth) < ast.InstallDate) {
-          //                Date createdDate = (estimate.CreatedDate == null || !String.isBlank(copyid)) ? systemToday : estimate.CreatedDate.date();
-          //System.debug(createdDate + '.addMonths(' + isNewAddMonth + ')' + createdDate.addMonths(isNewAddMonth) + ' < ast.InstallDate:' + ast.InstallDate);
-          //                if (createdDate.addMonths(isNewAddMonth) < ast.InstallDate) {
-          //                    isNew = true;
-          //                    listPrice = ast.Maintenance_Price_Month__c * isNewPriceAdj;
-          //                }
-          //              // 璁$畻涓婁笅绾胯皟鏁存瘮渚�
-          //              娌℃湁鎻愪氦 鎴栬�呭湪鎶ヤ环鏃朵粠鏂拌绠�
-          if (!getPageDisabled() || (getPageDisabled() && String.isBlank(copyid) == false)) {
-            Date mon1stDate = Date.newInstance(Date.today().year(), Date.today().month(), 1);
-            selectedLocal.LastMContract_Price__c = selectedLocal.Asset__r.CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c == null ?   selectedLocal.LastMContract_Price__c : selectedLocal.Asset__r.CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c;
-            //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO , 'LastMContract_Price__c--' + selectedLocal.LastMContract_Price__c));
-            if (selectedLocal.Asset__r.CurrentContract_F__r.First_Estimate_Date__c != null && selectedLocal.Asset__r.CurrentContract_F__r.Estimate_Contract_endDate__c > mon1stDate) {
-              selectedLocal.Asset_Consumption_rate__c = selectedLocal.Asset__r.CurrentContract_F__r.First_contract_usage_Rate__c == null ? selectedLocal.Asset_Consumption_rate__c : selectedLocal.Asset__r.CurrentContract_F__r.First_contract_usage_Rate__c;
-            } else {
-              selectedLocal.Asset_Consumption_rate__c = selectedLocal.Asset__r.CurrentContract_F__r.Contract_Consumption_rate__c == null ? selectedLocal.Asset_Consumption_rate__c : selectedLocal.Asset__r.CurrentContract_F__r.Contract_Consumption_rate__c;
-            }
-            //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO , selectedLocal.Asset__r.CurrentContract_F__r.First_Estimate_Date__c + 'Asset_Consumption--- ' + selectedLocal.Asset__r.CurrentContract_F__r.Estimate_Contract_endDate__c));
-    
-            if (String.isNotBlank(String.valueOf(selectedLocal.Asset_Consumption_rate__c))) {
-              //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO , 'Contract_Consumption_rate__c ' + selectedLocal.Asset__r.CurrentContract_F__r.Contract_Consumption_rate__c));
-              for (Data da : datatemp) {
-                if (String.isBlank(String.valueOf(da.rate_Lower)) &&  selectedLocal.Asset_Consumption_rate__c < da.rate_Upper) {
-                  selectedLocal.Adjustment_ratio_Lower__c = da.price_Lower;
-                  selectedLocal.Adjustment_ratio_Upper__c = da.price_Upper;
-                  continue;
-                } else if (selectedLocal.Asset_Consumption_rate__c >= da.rate_Lower && String.isBlank(String.valueOf(da.rate_Upper))) {
-                  selectedLocal.Adjustment_ratio_Lower__c = da.price_Lower;
-                  selectedLocal.Adjustment_ratio_Upper__c = da.price_Upper;
-                  continue;
-                } else if (selectedLocal.Asset_Consumption_rate__c >= da.rate_Lower
-                       && selectedLocal.Asset_Consumption_rate__c < da.rate_Upper) {
-                  selectedLocal.Adjustment_ratio_Lower__c = da.price_Lower;
-                  selectedLocal.Adjustment_ratio_Upper__c = da.price_Upper;
-                  continue;
-    
+                } else if (ApexPages.currentPage().getParameters().get('completion') == '5') {
+                    ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, System.Label.Message_002));
                 }
-                //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO , '涓嬮檺锛嬩笂闄�--- ' + selectedLocal.Adjustment_ratio_Lower__c + '  ' + selectedLocal.Adjustment_ratio_Upper__c));
-              }
-              //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO , '涓嬮檺锛嬩笂闄�+++ ' + selectedLocal.Adjustment_ratio_Lower__c + '  ' + selectedLocal.Adjustment_ratio_Upper__c));
             }
-          }
-    
-          //
-          //
-          //
-          checkedAssets.add(new AssetInfo(checkedAssets.size(), ast, isNew, listPrice, selectedLocal));
-        } else {
-          //update by rentongxiao 2020-09-23 start
-          if (ast.AssetMark__c == '涓绘満') {
-            totalRecords++;
-            if (unCheckedAssets.size() < selctRecordNum) {
-              unCheckedAssets.add(new AssetInfo(unCheckedAssets.size(), ast));
+            //HWAG-B399Q8 2018/08/20  娣诲姞鐘舵��5锛屼负鎸塻ave 鎸夐敭鍚庣姸鎬� end
+        }
+        this.printAsset = false;
+        this.printContract = false;
+        this.printTripartite = false;
+        this.printAgent = false;
+        String copyid = '';
+        if (isPageAction == false) {
+            this.targetEstimateId = ApexPages.currentPage().getParameters().get('copyid');
+            copyid = ApexPages.currentPage().getParameters().get('copyid');
+            if (this.targetEstimateId == null) {
+                String paramId = ApexPages.currentPage().getParameters().get('id');
+                if (String.isBlank(paramId) == false && paramId.startsWith('a0z')) {
+                    Maintenance_Contract_Asset_Estimate__c mcaeParam = [Select Maintenance_Contract_Estimate__c from Maintenance_Contract_Asset_Estimate__c where Id = :paramId];
+                    this.targetEstimateId = mcaeParam.Maintenance_Contract_Estimate__c;
+                } else {
+                    this.targetEstimateId = paramId;
+                }
+            } else {
+                this.newIns = true;
             }
-          }
-          //update by rentongxiao 2020-09-23 end
+            this.targetMaintenanceContractId = ApexPages.currentPage().getParameters().get('mcid');
+        }
+        // 绶ㄩ泦銇嬨倝
+        if (String.isBlank(this.targetEstimateId) == false) {
+            setThisEstimate();
+            this.targetMaintenanceContractId = this.estimate.Maintenance_Contract__c;
+            this.setContractInfo(this.targetMaintenanceContractId);
+        }
+        // 鏂拌銇嬨倝
+        else if (!String.isBlank(this.targetMaintenanceContractId)) {
+            this.estimate = new Maintenance_Contract_Estimate__c();
+            this.estimate.Maintenance_Contract__c = this.targetMaintenanceContractId;
+            this.estimate.Contract_Esti_Start_Date__c = systemToday;
+            this.estimate.Contract_Start_Date__c = systemToday;
+            this.setContractInfo(this.targetMaintenanceContractId);
+            this.newIns = true;
+        }
+        // 浣曘倐銇亼銈屻伆銆佸康銇仧銈�
+        else {
+            throw new ControllerUtil.myException('鏃犳硶鏄剧ず缁翠慨鍚堝悓鎶ヤ环');
+            //return;
+        }
+        //HWAG-B399Q8 2018/08/20  妫�楠屾槸鍚︽樉绀�'璇锋彁浜ゅ緟瀹℃壒' start
+        IS_Clone_After_Decide = false;
+        if (String.isBlank(ApexPages.currentPage().getParameters().get('completion')) == false &&
+            ApexPages.currentPage().getParameters().get('completion') == '5' &&
+            this.estimate != null && this.estimate.IS_Clone_After_Decide__c) {
+            IS_Clone_After_Decide = true;
     
         }
-        listCut(unCheckedAssets);
-        /*
-           if (ast.CheckBox__c) {
-            checkedAssets.add(new AssetInfo(checkedAssets.size(), ast, isNew, listPrice));
-           } else {
-            unCheckedAssets.add(new AssetInfo(unCheckedAssets.size(), ast));
-           }
-         */
-      }
+        //HWAG-B399Q8 2018/08/20  妫�楠屾槸鍚︽樉绀�'璇锋彁浜ゅ緟瀹℃壒' end
+        // 绱嶅叆姗熷櫒銇儏鍫便倰鍙栧緱
+        if (!String.isBlank(this.targetHospitalId) && (this.targetHospitalId.length() == 15 || this.targetHospitalId.length() == 18)) {
+            //tcm 娣诲姞 Management_Code__c  20211201 start
+            assetRecords = [SELECT Id, Name, Asset_situation__c, SerialNumber, Department_Name__c, Installation_Site__c, Posting_Date__c, Management_Code__c, IF_Warranty__c, Reson_Can_not_Warranty__c,
+                            InstallDate, isNewDate_use__c, Asset_Owner__c, Accumulation_Repair_Amount__c, Maintenance_Price_Month__c, Final_Examination_Date__c, CurrentContract_End_Date__c, EquipmentGuaranteeFlg__c,
+                            CurrentContract_F__c, CurrentContract_F__r.Maintenance_Contract_No_F__c,CurrentContract_F__r.Management_Code__c, CurrentContract_F__r.RecordType_DeveloperName__c, CurrentContract_F__r.Estimate_Num__c, CurrentContract_F__r.Contract_End_Date__c, CurrentContract_F__r.Estimate_Contract_endDate__c,
+                            CurrentContract_F_asset__c, CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c, CurrentContract_F_asset__r.endDateGurantee_Text__c, CurrentContract_F__r.Gurantee_Estimate_startDate__c,
+                            CurrentContract_F__r.First_Estimate_Date__c,
+                            CurrentContract_F__r.Contract_Consumption_rate__c, CurrentContract_F__r.First_contract_usage_Rate__c,
+                            CurrentContract_F__r.Contract_Range__c, AssetMark__c,
+                            // 2021-01-29 LJPH-BX9CVX mzy   add  鍚堝悓鎶ヤ环鏃跺垽鏂浂浠堕闄�
+                            NoPartRiskDate_F__c, NoPartRiskDate__c, SignableFlag__c,
+                            Product2.PartSupplyFinishDate__c, Product2.PartSupplyFinishDateExp__c
+                            // 2021-01-29 LJPH-BX9CVX mzy   add  鍚堝悓鎶ヤ环鏃跺垽鏂浂浠堕闄�
+                            FROM Asset WHERE Hospital__c = :this.targetHospitalId AND ( AssetMark__c != '鑰楁潗' OR Product2.Family != 'ET' ) ORDER BY ID, IF_Warranty__c asc];
+            //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start
+            // assetRecords = [SELECT Id, Name, Asset_situation__c, SerialNumber, Department_Name__c, Installation_Site__c, Posting_Date__c,Management_Code__c,IF_Warranty__c,Reson_Can_not_Warranty__c,
+            //                      InstallDate,isNewDate_use__c, Asset_Owner__c, Accumulation_Repair_Amount__c, Maintenance_Price_Month__c, Final_Examination_Date__c,CurrentContract_End_Date__c,EquipmentGuaranteeFlg__c,
+            //                      CurrentContract_F__c,CurrentContract_F__r.Maintenance_Contract_No_F__c,CurrentContract_F__r.RecordType_DeveloperName__c,CurrentContract_F__r.Estimate_Num__c,CurrentContract_F__r.Contract_End_Date__c,CurrentContract_F__r.Estimate_Contract_endDate__c,
+            //                      CurrentContract_F_asset__c,CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c,CurrentContract_F_asset__r.endDateGurantee_Text__c,CurrentContract_F__r.Gurantee_Estimate_startDate__c,
+            //                      CurrentContract_F__r.First_Estimate_Date__c,
+            //                     CurrentContract_F__r.Contract_Consumption_rate__c,CurrentContract_F__r.First_contract_usage_Rate__c,
+            //                     CurrentContract_F__r.Contract_Range__c ,AssetMark__c
+            //                      FROM Asset WHERE Hospital__c = :this.targetHospitalId AND AssetMark__c = '涓绘満' ORDER BY ID,IF_Warranty__c asc];
+            //JZHG-BSDUT4 ---20200825---update By rentongxiao---End
+        } else {
+            assetRecords = new List<Asset>();
+        }
+        //sqlStr += ' AND AssetMark__c != \'鑰楁潗\' AND Product2.Family != \'ET\' ';
+        this.checkedAssets = new List<AssetInfo>();
+        this.unCheckedAssets = new List<AssetInfo>();
     
-      totalPage = (totalRecords / selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
+        // 閬告姙娓堛伩銇磵鍏ユ鍣ㄦ儏鍫便倰鍙栧緱
+        Map<Id, Integer> selectedAssetIds = new Map<Id, Integer>();
+        List<Maintenance_Contract_Asset_Estimate__c> selectedMcaes = new List<Maintenance_Contract_Asset_Estimate__c>();
+        List<Maintenance_Contract_Asset_Estimate__c> newMcaes = new List<Maintenance_Contract_Asset_Estimate__c>();
+        // 鏂拌銆佷笖銇わ紤銇ょ洰瑕嬬銈傘倞銇牬鍚堛�併偝銉斻兗鍏冦伄淇濇湁瑷倷銈掓寔銇�
+        if (String.isBlank(this.targetEstimateId) && this.contract.Estimate_Num__c == 0) {
+            List<Maintenance_Contract_Asset__c> oldVals = [
+                select Id, Name, Asset__c, Asset__r.InstallDate, Asset__r.isNewDate_use__c,
+                Asset__r.Posting_Date__c, Asset__r.Maintenance_Price_Month__c,
+                Asset__r.EquipmentGuaranteeFlg__c,
+                Asset__r.CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c,
+                Asset__r.CurrentContract_F_asset__r.endDateGurantee_Text__c,
+                Asset__r.CurrentContract_F__r.First_Estimate_Date__c,
+                Asset__r.CurrentContract_F__r.Contract_Consumption_rate__c,
+                Asset__r.CurrentContract_F__r.First_contract_usage_Rate__c,
+                Asset__r.CurrentContract_F__r.Estimate_Contract_endDate__c,
+                Asset__r.CurrentContract_F__r.Contract_Range__c,
+                Asset__r.CurrentContract_F__r.Contract_End_Date__c,
+                Asset__r.CurrentContract_F__r.Gurantee_Estimate_startDate__c
+                from Maintenance_Contract_Asset__c
+                where Maintenance_Contract__c = :this.targetMaintenanceContractId
+            ];
+            Date mon1stDate = Date.newInstance(Date.today().year(), Date.today().month(), 1);
+            for (Maintenance_Contract_Asset__c mca : oldVals) {
+                // old銈堛倞鏇存柊銇椼仧銇勯爡鐩�
+                Boolean isNew = false;
+                // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk Star
+                boolean isCheck = true;
+                // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk End
+                Decimal listPrice = mca.Asset__r.Maintenance_Price_Month__c;
+                Decimal asset_Consumption_rate = null;
+                // 鍙栦笂涓�鏈熷悎鍚屾秷璐圭巼
+                if (mca.Asset__r.CurrentContract_F__r.First_Estimate_Date__c != null && mca.Asset__r.CurrentContract_F__r.Estimate_Contract_endDate__c > mon1stDate) {
+                    asset_Consumption_rate = mca.Asset__r.CurrentContract_F__r.First_contract_usage_Rate__c;
+                } else {
+                    asset_Consumption_rate = mca.Asset__r.CurrentContract_F__r.Contract_Consumption_rate__c;
+                }
+                // InstallDate 銇� 浠婃棩銈掓瘮杓�
+                // 1.瀹夎鏃ユ垨鑰呭彂璐ф棩鍜屼粖澶╂瘮杈� 瀹炴椂鍙樺寲
+                // 2.鎻愪氦鍚庝笉鍐嶅彉鍖�
+                //Date createdDate = (estimate.CreatedDate == null || !String.isBlank(copyid)) ? systemToday : estimate.CreatedDate.date();
+                Date createdDate = systemToday;
+                if (createdDate.addMonths(isNewAddMonth) < mca.Asset__r.isNewDate_use__c) {
+                    isNew = true;
+                    // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk Star
+                    isCheck = true;
+                    // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk End
+                    listPrice = mca.Asset__r.Maintenance_Price_Month__c * isNewPriceAdj;
+                }
+                selectedAssetIds.put(mca.Asset__c, selectedMcaes.size());
+                selectedMcaes.add(new Maintenance_Contract_Asset_Estimate__c(
+                              Asset__c = mca.Asset__c,
+                              isNew__c = isNew,
+                              // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk Star
+                              Check_Object__c = isCheck,
+                              // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk End
+                              Estimate_List_Price__c = listPrice,
+                              // 鍙栦笂涓�鏈熷悎鍚屼环鏍�
+                              LastMContract_Price__c = mca.Asset__r.CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c,
     
-      system.debug('椤哄簭妫�娴�' + checkedAssets);
-      for (Maintenance_Contract_Asset_Estimate__c mcae : newMcaes) {
-        checkedAssets.add(new AssetInfo(checkedAssets.size(), mcae));
-      }
+                              Asset_Consumption_rate__c = asset_Consumption_rate,
+                              EquipmentGuaranteeFlgTxt__c = mca.Asset__r.EquipmentGuaranteeFlg__c
+                              ));
+            }
+        } else {
+            for (Maintenance_Contract_Asset_Estimate__c mcae : [SELECT Id,
+                                                                Name,
+                                                                Maintenance_Contract_Estimate__c,
+                                                                Maintenance_Contract_Estimate__r.Contract_Esti_Start_Date__c,
+                                                                Asset__c,
+                                                                Asset__r.Maintenance_Price_Month__c,
+                                                                Asset__r.InstallDate,
+                                                                Asset__r.isNewDate_use__c,
+                                                                Asset__r.EquipmentGuaranteeFlg__c,
+                                                                Asset_Consumption_rate__c,
+                                                                Asset__r.CurrentContract_F__c,
+                                                                Asset__r.CurrentContract_F__r.First_Estimate_Date__c,
+                                                                Asset__r.CurrentContract_F__r.Contract_Consumption_rate__c,
+                                                                Asset__r.CurrentContract_F__r.First_contract_usage_Rate__c,
+                                                                Asset__r.CurrentContract_F__r.Estimate_Contract_endDate__c,
+                                                                Asset__r.CurrentContract_F__r.Contract_Range__c,
+                                                                Asset__r.CurrentContract_F__r.Contract_End_Date__c,
+                                                                Asset__r.CurrentContract_F__r.Gurantee_Estimate_startDate__c,
+                                                                LastMContract_Price__c,
+                                                                Asset__r.CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c,
+                                                                Asset__r.CurrentContract_F_asset__r.endDateGurantee_Text__c,
+                                                                Product_Manual__c,
+                                                                Product_Manual__r.EquipmentGuaranteeFlg__c,
+                                                                Product_Manual__r.Maintenance_Price_Month__c,
+                                                                Product_Manual__r.Name,
+                                                                //add 2021-02-07 mzy  start
+                                                                //Product_Manual__r.NoPartRiskDate_F__c,
+                                                                //Product_Manual__r.SignableFlag__c,
+                                                                //add 2021-02-07 mzy  end
+                                                                //add 2021.6.4 fxk  Start
+                                                                Check_Object__c,
+                                                                //add 2021.6.4 fxk  end
+                                                                IsNew__c,
+                                                                Estimate_List_Price__c,
+                                                                //Maintenance_Price_YearTXT__c,
+                                                                Estimate_Cost__c,
+                                                                Adjustment_ratio_Upper__c,
+                                                                Adjustment_ratio_Lower__c,
+                                                                Adjustment_Lower_price__c,
+                                                                Adjustment_Upper_price__c,
+                                                                Last_inspection_day__c,
+                                                                Check_Result__c,
+                                                                Repair_Price__c,
+                                                                Comment__c,
+                                                                Asset__r.Posting_Date__c,
+                                                                EquipmentGuaranteeFlgTxt__c,
+                                                                EquipmentGuaranteeFlg__c,
+                                                                ifHaveleftInPrevious__c,
+                                                                // Gzw 20200807 浜斾釜鍘诲勾鍚堝悓鐩稿叧锛屾墍浠ユ姤浠蜂骇鍝侊紝鑾峰彇涓婃湡鍚堝悓 start
+                                                                Last_MContract__c
+                                                                // Gzw 20200807 浜斾釜鍘诲勾鍚堝悓鐩稿叧锛屾墍浠ユ姤浠蜂骇鍝侊紝鑾峰彇涓婃湡鍚堝悓 eng
+                                                                // LJPH-C9GD34 gzw fix start
+                                                                ,Estimate_List_Price_Page__c
+                                                                // LJPH-C9GD34 gzw fix end
+                                                                FROM Maintenance_Contract_Asset_Estimate__c
+                                                                WHERE Maintenance_Contract_Estimate__c = :this.targetEstimateId
+                                                                                                         ORDER BY
+                                                                                                         Id,
+                                                                Asset__c,
+                                                                Product_Manual__c,
+                                                                Asset__r.SerialNumber,
+                                                                Asset__r.Name,
+                                                                Asset__r.Department_Name__c,
+                                                                Asset__r.InstallDate
+                 ]) {
+                if (!getPageDisabled() || (getPageDisabled() && String.isBlank(copyid) == false)) {
+                    //if (String.isBlank(copyid) == false) {
+                    if (mcae.Asset__c <> null) {
+                        mcae.EquipmentGuaranteeFlgTxt__c = mcae.Asset__r.EquipmentGuaranteeFlg__c;
+                        if (systemToday.addMonths(isNewAddMonth) < mcae.Asset__r.isNewDate_use__c) {
+                            mcae.IsNew__c = true;
+                            mcae.Estimate_List_Price__c = mcae.Asset__r.Maintenance_Price_Month__c * isNewPriceAdj;
+                        } else {
+                            mcae.IsNew__c = false;
+                            mcae.Estimate_List_Price__c = mcae.Asset__r.Maintenance_Price_Month__c;
+                        }
+                    } else if (mcae.Product_Manual__c <> null) {
+                        mcae.IsNew__c = true;
+                        mcae.Estimate_List_Price__c = mcae.Product_Manual__r.Maintenance_Price_Month__c * isNewPriceAdj;
+                    }
+                }
+                if (mcae.Asset__c <> null) {
+                    //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO , mcae.Asset__c + 'IsNew  ' + mcae.IsNew__c));
+                    selectedAssetIds.put(mcae.Asset__c, selectedMcaes.size());
+                    selectedMcaes.add(mcae);
+                } else {
+                    newMcaes.add(mcae);
+                }
+            }
+        }
+        // 閬告姙娓堛伩銇倐銇伀銉併偋銉冦偗銈掍粯銇戙倠
+        // TODO xudan 涓�瑕с伀鍑恒倠鏄庣窗浠舵暟銇岃冻銈娿仾銇勩偙銉笺偣銇屻亗銈�
+        // 鈶燗ssetA鈥曟槑绱癆銇ф槑绱扮櫥閷�
+        // 鈶sset銇绱㈡潯浠跺鏇淬伀銈堛倞銆丄ssetA銇案閬犮伀鍙栧緱銇с亶銇亜
+        // 鈶sset銈掑厓銇儑銉笺偪銈掋優銉冦償銉炽偘銇欍倠鏅傘�佹槑绱般優銉冦儣銇嬨倝AssetA銈掑彇寰椼仹銇嶃仾銇�?涓�瑕с伀鏄庣窗A銇屽嚭銇亜
+        // 娆″洖銆丄sset銇绱㈡潯浠躲亴澶с亶銇忓鏇淬仚銈嬫檪銆佸蹇滃繀瑕�
+        List<Data> datatemp = new List<Data>();
+        datatemp = getChartData();
+        for (Asset ast : this.assetRecords) {
+            Boolean isNew = false;
+            Decimal listPrice = ast.Maintenance_Price_Month__c;
+            if (selectedAssetIds.containsKey(ast.Id)) {
+                Maintenance_Contract_Asset_Estimate__c selectedLocal = selectedMcaes.get(selectedAssetIds.get(ast.Id));
+                isNew = selectedLocal.isNew__c;
+                listPrice = selectedLocal.Estimate_List_Price__c;
+                // xudan 20160110 鏂板搧鍒ゆ柇銇撱亾瑕併倝銇亜銆乧ontractStartDateChange銇屻倓銈�
+                //                if (systemToday.addMonths(-6) < ast.InstallDate) {
+                //                if (estimate.Contract_Esti_Start_Date__c.addMonths(isNewAddMonth) < ast.InstallDate) {
+                //                Date createdDate = (estimate.CreatedDate == null || !String.isBlank(copyid)) ? systemToday : estimate.CreatedDate.date();
+                //System.debug(createdDate + '.addMonths(' + isNewAddMonth + ')' + createdDate.addMonths(isNewAddMonth) + ' < ast.InstallDate:' + ast.InstallDate);
+                //                if (createdDate.addMonths(isNewAddMonth) < ast.InstallDate) {
+                //                    isNew = true;
+                //                    listPrice = ast.Maintenance_Price_Month__c * isNewPriceAdj;
+                //                }
+                //              // 璁$畻涓婁笅绾胯皟鏁存瘮渚�
+                //              娌℃湁鎻愪氦 鎴栬�呭湪鎶ヤ环鏃朵粠鏂拌绠�
+                if (!getPageDisabled() || (getPageDisabled() && String.isBlank(copyid) == false)) {
+                    Date mon1stDate = Date.newInstance(Date.today().year(), Date.today().month(), 1);
+                    selectedLocal.LastMContract_Price__c = selectedLocal.Asset__r.CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c == null ?   selectedLocal.LastMContract_Price__c : selectedLocal.Asset__r.CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c;
+                    //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO , 'LastMContract_Price__c--' + selectedLocal.LastMContract_Price__c));
+                    if (selectedLocal.Asset__r.CurrentContract_F__r.First_Estimate_Date__c != null && selectedLocal.Asset__r.CurrentContract_F__r.Estimate_Contract_endDate__c > mon1stDate) {
+                        selectedLocal.Asset_Consumption_rate__c = selectedLocal.Asset__r.CurrentContract_F__r.First_contract_usage_Rate__c == null ? selectedLocal.Asset_Consumption_rate__c : selectedLocal.Asset__r.CurrentContract_F__r.First_contract_usage_Rate__c;
+                    } else {
+                        selectedLocal.Asset_Consumption_rate__c = selectedLocal.Asset__r.CurrentContract_F__r.Contract_Consumption_rate__c == null ? selectedLocal.Asset_Consumption_rate__c : selectedLocal.Asset__r.CurrentContract_F__r.Contract_Consumption_rate__c;
+                    }
+                    //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO , selectedLocal.Asset__r.CurrentContract_F__r.First_Estimate_Date__c + 'Asset_Consumption--- ' + selectedLocal.Asset__r.CurrentContract_F__r.Estimate_Contract_endDate__c));
     
-      // 鏈�寰�10琛岃拷鍔�
-      if (Schema.getGlobalDescribe().get('Maintenance_Contract_Asset_Estimate__c').getDescribe().isCreateable()) {
-        this.addNewRows();
-      }
+                    if (String.isNotBlank(String.valueOf(selectedLocal.Asset_Consumption_rate__c))) {
+                        //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO , 'Contract_Consumption_rate__c ' + selectedLocal.Asset__r.CurrentContract_F__r.Contract_Consumption_rate__c));
+                        for (Data da : datatemp) {
+                            if (String.isBlank(String.valueOf(da.rate_Lower)) &&  selectedLocal.Asset_Consumption_rate__c < da.rate_Upper) {
+                                selectedLocal.Adjustment_ratio_Lower__c = da.price_Lower;
+                                selectedLocal.Adjustment_ratio_Upper__c = da.price_Upper;
+                                continue;
+                            } else if (selectedLocal.Asset_Consumption_rate__c >= da.rate_Lower && String.isBlank(String.valueOf(da.rate_Upper))) {
+                                selectedLocal.Adjustment_ratio_Lower__c = da.price_Lower;
+                                selectedLocal.Adjustment_ratio_Upper__c = da.price_Upper;
+                                continue;
+                            } else if (selectedLocal.Asset_Consumption_rate__c >= da.rate_Lower
+                                       && selectedLocal.Asset_Consumption_rate__c < da.rate_Upper) {
+                                selectedLocal.Adjustment_ratio_Lower__c = da.price_Lower;
+                                selectedLocal.Adjustment_ratio_Upper__c = da.price_Upper;
+                                continue;
     
-      if (!String.isBlank(copyid)) {
-        this.targetEstimateId = null;
-        this.estimate = new Maintenance_Contract_Estimate__c();
-        this.estimate.Maintenance_Contract__c = this.targetMaintenanceContractId;
-      }
-      // 2021-02-07  gzw add  LJPH-BWY5QB start
-      setEndUserType(this.targetMaintenanceContractId);
-      // 2021-02-07  gzw add  LJPH-BWY5QB start
-      assetRecords.clear();
-      // 鏍规嵁鍚堝悓寮�濮嬫棩閲嶆柊璁$畻缁翠慨鍚堝悓浠锋牸
-      //contractStartDateChange();
+                            }
+                            //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO , '涓嬮檺锛嬩笂闄�--- ' + selectedLocal.Adjustment_ratio_Lower__c + '  ' + selectedLocal.Adjustment_ratio_Upper__c));
+                        }
+                        //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO , '涓嬮檺锛嬩笂闄�+++ ' + selectedLocal.Adjustment_ratio_Lower__c + '  ' + selectedLocal.Adjustment_ratio_Upper__c));
+                    }
+                }
+    
+                //
+                //
+                //
+                checkedAssets.add(new AssetInfo(checkedAssets.size(), ast, isNew, listPrice, selectedLocal));
+            } else {
+                //update by rentongxiao 2020-09-23 start
+                if (ast.AssetMark__c == '涓绘満') {
+                    totalRecords++;
+                    if (unCheckedAssets.size() < selctRecordNum) {
+                        unCheckedAssets.add(new AssetInfo(unCheckedAssets.size(), ast));
+                    }
+                }
+                //update by rentongxiao 2020-09-23 end
+    
+            }
+            listCut(unCheckedAssets);
+            /*
+               if (ast.CheckBox__c) {
+                    checkedAssets.add(new AssetInfo(checkedAssets.size(), ast, isNew, listPrice));
+               } else {
+                    unCheckedAssets.add(new AssetInfo(unCheckedAssets.size(), ast));
+               }
+             */
+        }
+    
+        totalPage = (totalRecords / selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
+    
+        system.debug('椤哄簭妫�娴�' + checkedAssets);
+        for (Maintenance_Contract_Asset_Estimate__c mcae : newMcaes) {
+            checkedAssets.add(new AssetInfo(checkedAssets.size(), mcae));
+        }
+    
+        // 鏈�寰�10琛岃拷鍔�
+        if (Schema.getGlobalDescribe().get('Maintenance_Contract_Asset_Estimate__c').getDescribe().isCreateable()) {
+            this.addNewRows();
+        }
+    
+        if (!String.isBlank(copyid)) {
+            this.targetEstimateId = null;
+            this.estimate = new Maintenance_Contract_Estimate__c();
+            this.estimate.Maintenance_Contract__c = this.targetMaintenanceContractId;
+        }
+        // 2021-02-07  gzw add  LJPH-BWY5QB start
+        setEndUserType(this.targetMaintenanceContractId);
+        // 2021-02-07  gzw add  LJPH-BWY5QB start
+        assetRecords.clear();
+        // 鏍规嵁鍚堝悓寮�濮嬫棩閲嶆柊璁$畻缁翠慨鍚堝悓浠锋牸
+        //contractStartDateChange();
     }
     
     //
     
     // 鍙栧緱鍒嗛〉鏁版嵁
     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 = '(\'';
-        if (checkIdList.size() > 0) {
-          for (String str : checkIdList) {
-            notInId += str + '\', \'';
-          }
-        }
-        notInId += '\')';
-      //tcm 娣诲姞 Management_Code__c  20211201 start
-        String sqlStr = 'SELECT Id, Name, Asset_situation__c, SerialNumber, Department_Name__c, Installation_Site__c, '
-                + 'Posting_Date__c,Management_Code__c,IF_Warranty__c,Reson_Can_not_Warranty__c, InstallDate,isNewDate_use__c, '
-                + 'Asset_Owner__c, Accumulation_Repair_Amount__c, Maintenance_Price_Month__c, Final_Examination_Date__c, '
-                + 'CurrentContract_End_Date__c, Extend_Gurantee_DateTo__c,EquipmentGuaranteeFlg__c, '
-                + 'CurrentContract_F__c,CurrentContract_F__r.Maintenance_Contract_No_F__c,CurrentContract_F__r.Management_Code__c,CurrentContract_F__r.RecordType_DeveloperName__c,CurrentContract_F__r.Estimate_Num__c,CurrentContract_F__r.Contract_End_Date__c,'
-                + 'CurrentContract_F_asset__c,CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c,CurrentContract_F_asset__r.endDateGurantee_Text__c,CurrentContract_F__r.Gurantee_Estimate_startDate__c, '
-                + 'CurrentContract_F__r.First_Estimate_Date__c,CurrentContract_F__r.Estimate_Contract_endDate__c,'
-                + 'CurrentContract_F__r.Contract_Consumption_rate__c,CurrentContract_F__r.First_contract_usage_Rate__c,'
-                + 'CurrentContract_F__r.Contract_Range__c,AssetMark__c,NoPartRiskDate__c,NoPartRiskDate_F__c,Product2.PartSupplyFinishDate__c,SignableFlag__c FROM Asset WHERE Hospital__c = \'' + this.targetHospitalId + '\' '
-                + 'AND Id NOT IN ' + notInId;
-        //HWAG-B4R3SS  START 20181026
-        if (String.isNotBlank(text1) && String.isNotBlank(cond1) && String.isNotBlank(val1)) {
-          sqlStr += makeTextSql(text1, cond1, val1);
+        checkIdList = new List<String> ();
+        for (AssetInfo ass : this.checkedAssets) {
+            if (!ass.isManual) {
+                checkIdList.add(ass.rec.Id);
+            }
         }
     
-        //JZHG-BSDUT4 ---20200904---update By rentongxiao---Start
-        // else{
-        //     sqlStr += 'AND AssetMark__c = \'涓绘満\'';
-        // }
+        if ((currPage * selctRecordNum) <= 2000) {
+            String notInId = '(\'';
+            if (checkIdList.size() > 0) {
+                for (String str : checkIdList) {
+                    notInId += str + '\', \'';
+                }
+            }
+            notInId += '\')';
+            
+            //tcm 娣诲姞 Management_Code__c  20211201 start
+            String sqlStr = 'SELECT Id, Name, Asset_situation__c, SerialNumber, Department_Name__c, Installation_Site__c, '
+                            + 'Posting_Date__c,Management_Code__c,IF_Warranty__c,Reson_Can_not_Warranty__c, InstallDate,isNewDate_use__c, '
+                            + 'Asset_Owner__c, Accumulation_Repair_Amount__c, Maintenance_Price_Month__c, Final_Examination_Date__c, '
+                            + 'CurrentContract_End_Date__c, Extend_Gurantee_DateTo__c,EquipmentGuaranteeFlg__c, '
+                            + 'CurrentContract_F__c,CurrentContract_F__r.Maintenance_Contract_No_F__c,CurrentContract_F__r.Management_Code__c,CurrentContract_F__r.RecordType_DeveloperName__c, CurrentContract_F__r.Estimate_Num__c,CurrentContract_F__r.Contract_End_Date__c,'
+                            + 'CurrentContract_F_asset__c,CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c,CurrentContract_F_asset__r.endDateGurantee_Text__c,CurrentContract_F__r.Gurantee_Estimate_startDate__c, '
+                            + 'CurrentContract_F__r.First_Estimate_Date__c,CurrentContract_F__r.Estimate_Contract_endDate__c,'
+                            + 'CurrentContract_F__r.Contract_Consumption_rate__c,CurrentContract_F__r.First_contract_usage_Rate__c,'
+                            + 'CurrentContract_F__r.Contract_Range__c,AssetMark__c,NoPartRiskDate__c,NoPartRiskDate_F__c,Product2.PartSupplyFinishDate__c,SignableFlag__c FROM Asset WHERE Hospital__c = \'' + this.targetHospitalId + '\' '
+                            + 'AND Id NOT IN ' + notInId;
+            //HWAG-B4R3SS  START 20181026
+            if (String.isNotBlank(text1) && String.isNotBlank(cond1) && String.isNotBlank(val1)) {
+                sqlStr += makeTextSql(text1, cond1, val1);
+            }
     
-        //JZHG-BSDUT4 ---20200904---update By rentongxiao---end
-        //HWAG-B4R3SS  END 20181026
-        //HWAG-BDJ43R---XHL---20190729---
-        sqlStr += ' AND ( AssetMark__c != \'鑰楁潗\' OR Product2.Family != \'ET\' )';
-        //HWAG-BDJ43R---XHL---20190729---
-        sqlStr += ' ORDER BY ID,IF_Warranty__c asc ';
-        if (currPage == 1) {
-          sqlStr += 'limit ' + selRecordOption;
+            //JZHG-BSDUT4 ---20200904---update By rentongxiao---Start
+            // else{
+            //     sqlStr += 'AND AssetMark__c = \'涓绘満\'';
+            // }
+    
+            //JZHG-BSDUT4 ---20200904---update By rentongxiao---end
+            //HWAG-B4R3SS  END 20181026
+            //HWAG-BDJ43R---XHL---20190729---
+            sqlStr += ' AND ( AssetMark__c != \'鑰楁潗\' OR Product2.Family != \'ET\' )';
+            //HWAG-BDJ43R---XHL---20190729---
+            sqlStr += ' ORDER BY ID,IF_Warranty__c asc ';
+            if (currPage == 1) {
+                sqlStr += 'limit ' + selRecordOption;
+            } else {
+                sqlStr += 'limit ' + selRecordOption + ' offset ' + String.valueOf((currPage - 1) * selctRecordNum);
+            }
+            //system.debug();
+            //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,
+            //               '222222222222_____'+sqlStr));
+            //return;
+            assetRecords = Database.query(sqlStr);
         } else {
-          sqlStr += 'limit ' + selRecordOption + ' offset ' + String.valueOf((currPage - 1) * selctRecordNum);
-        }
-        //system.debug();
-        //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,
-        //               '222222222222_____'+sqlStr));
-        //return;
-        assetRecords = Database.query(sqlStr);
-      } else {
-        assetRecords.clear();
-        Integer sqlLimit = currPage * selctRecordNum;
-        List<Asset> temAsset = new List<Asset> ();
-        //HWAG-BDJ43R ---XHL---20190729---
-        String sqlStr = '';
-        //tcm 娣诲姞 Management_Code__c  20211201 start
-        sqlStr  = 'SELECT Id, Name, Asset_situation__c, SerialNumber, Department_Name__c, Installation_Site__c,';
-        sqlStr += 'Posting_Date__c,Management_Code__c,IF_Warranty__c,Reson_Can_not_Warranty__c,InstallDate,isNewDate_use__c,';
-        sqlStr += 'Asset_Owner__c, Accumulation_Repair_Amount__c, Maintenance_Price_Month__c, Final_Examination_Date__c,';
-        sqlStr += 'CurrentContract_End_Date__c,Extend_Gurantee_DateTo__c,EquipmentGuaranteeFlg__c,';
-        sqlStr += 'CurrentContract_F__c,CurrentContract_F__r.Maintenance_Contract_No_F__c,CurrentContract_F__r.Management_Code__c,CurrentContract_F__r.RecordType_DeveloperName__c,CurrentContract_F__r.Estimate_Num__c,CurrentContract_F__r.Contract_End_Date__c,';
-        sqlStr += 'CurrentContract_F_asset__c,CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c,CurrentContract_F_asset__r.endDateGurantee_Text__c,CurrentContract_F__r.Gurantee_Estimate_startDate__c,';
-        sqlStr += 'CurrentContract_F__r.First_Estimate_Date__c,CurrentContract_F__r.Estimate_Contract_endDate__c,';
-        sqlStr += 'CurrentContract_F__r.Contract_Consumption_rate__c,CurrentContract_F__r.First_contract_usage_Rate__c,';
-        sqlStr += ' CurrentContract_F__r.Contract_Range__c,AssetMark__c,NoPartRiskDate__c,NoPartRiskDate_F__c,Product2.PartSupplyFinishDate__c,SignableFlag__c FROM Asset WHERE Hospital__c = \'' + this.targetHospitalId + '\'';
-        //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start
-        // sqlStr += '  AND ( AssetMark__c != \'鑰楁潗\' OR Product2.Family != \'ET\' ) ';
-        //JZHG-BSDUT4 ---20200825---update By rentongxiao---End
-        //HWAG-B4R3SS  START 20181026
-        if (String.isNotBlank(text1) && String.isNotBlank(cond1) && String.isNotBlank(val1)) {
-          sqlStr += makeTextSql(text1, cond1, val1);
-        }
+            assetRecords.clear();
+            Integer sqlLimit = currPage * selctRecordNum;
+            List<Asset> temAsset = new List<Asset> ();
+            //HWAG-BDJ43R ---XHL---20190729---
+            String sqlStr = '';
+            
+            //tcm 娣诲姞 Management_Code__c  20211201 start
+            sqlStr  = 'SELECT Id, Name, Asset_situation__c, SerialNumber, Department_Name__c, Installation_Site__c,';
+            sqlStr += 'Posting_Date__c,Management_Code__c,IF_Warranty__c,Reson_Can_not_Warranty__c,InstallDate,isNewDate_use__c,';
+            sqlStr += 'Asset_Owner__c, Accumulation_Repair_Amount__c, Maintenance_Price_Month__c, Final_Examination_Date__c,';
+            sqlStr += 'CurrentContract_End_Date__c,Extend_Gurantee_DateTo__c,EquipmentGuaranteeFlg__c,';
+            sqlStr += 'CurrentContract_F__c,CurrentContract_F__r.Maintenance_Contract_No_F__c,CurrentContract_F__r.Management_Code__c,CurrentContract_F__r.RecordType_DeveloperName__c,CurrentContract_F__r.Estimate_Num__c,CurrentContract_F__r.Contract_End_Date__c,';
+            sqlStr += 'CurrentContract_F_asset__c,CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c,CurrentContract_F_asset__r.endDateGurantee_Text__c,CurrentContract_F__r.Gurantee_Estimate_startDate__c,';
+            sqlStr += 'CurrentContract_F__r.First_Estimate_Date__c,CurrentContract_F__r.Estimate_Contract_endDate__c,';
+            sqlStr += 'CurrentContract_F__r.Contract_Consumption_rate__c,CurrentContract_F__r.First_contract_usage_Rate__c,';
+            sqlStr += ' CurrentContract_F__r.Contract_Range__c,AssetMark__c,NoPartRiskDate__c,NoPartRiskDate_F__c,Product2.PartSupplyFinishDate__c,SignableFlag__c FROM Asset WHERE Hospital__c = \'' + this.targetHospitalId + '\'';
+            //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start
+            // sqlStr += '  AND ( AssetMark__c != \'鑰楁潗\' OR Product2.Family != \'ET\' ) ';
+            //JZHG-BSDUT4 ---20200825---update By rentongxiao---End
+            //HWAG-B4R3SS  START 20181026
+            if (String.isNotBlank(text1) && String.isNotBlank(cond1) && String.isNotBlank(val1)) {
+                sqlStr += makeTextSql(text1, cond1, val1);
+            }
     
-        //JZHG-BSDUT4 ---20200904---update By rentongxiao---Start
-        // else{
-        //     sqlStr += 'AND AssetMark__c = \'涓绘満\'';
-        // }
+            //JZHG-BSDUT4 ---20200904---update By rentongxiao---Start
+            // else{
+            //     sqlStr += 'AND AssetMark__c = \'涓绘満\'';
+            // }
     
-        //JZHG-BSDUT4 ---20200904---update By rentongxiao---end
-        //HWAG-B4R3SS  END 20181026
-        if (checkIdList.size() > 0) {
-    
-          sqlStr += '  AND Id NOT IN ' + checkIdList;
-          //temAsset = [SELECT Id, Name, Asset_situation__c, SerialNumber, Department_Name__c, Installation_Site__c, Posting_Date__c,Management_Code__c,IF_Warranty__c,Reson_Can_not_Warranty__c,
-          //            InstallDate, Asset_Owner__c, Accumulation_Repair_Amount__c, Maintenance_Price_Month__c, Final_Examination_Date__c,CurrentContract_End_Date__c,Extend_Gurantee_DateTo__c
-          //            FROM Asset WHERE Hospital__c = :this.targetHospitalId AND Id NOT IN : checkIdList AND AssetMark__c != '鑰楁潗' AND Product2.Family != 'ET' ORDER BY ID,IF_Warranty__c asc limit : sqlLimit];
-        } else {
-          //temAsset = [SELECT Id, Name, Asset_situation__c, SerialNumber, Department_Name__c, Installation_Site__c, Posting_Date__c,Management_Code__c,IF_Warranty__c,Reson_Can_not_Warranty__c,
-          //            InstallDate, Asset_Owner__c, Accumulation_Repair_Amount__c, Maintenance_Price_Month__c, Final_Examination_Date__c,CurrentContract_End_Date__c,Extend_Gurantee_DateTo__c
-          //            FROM Asset WHERE Hospital__c = :this.targetHospitalId AND AssetMark__c != '鑰楁潗' AND Product2.Family != 'ET' ORDER BY ID,IF_Warranty__c asc limit : sqlLimit];
+            //JZHG-BSDUT4 ---20200904---update By rentongxiao---end
+            //HWAG-B4R3SS  END 20181026
+            if (checkIdList.size() > 0) {
+                sqlStr += '  AND Id NOT IN ' + checkIdList;
+                //temAsset = [SELECT Id, Name, Asset_situation__c, SerialNumber, Department_Name__c, Installation_Site__c, Posting_Date__c,Management_Code__c,IF_Warranty__c,Reson_Can_not_Warranty__c,
+                //            InstallDate, Asset_Owner__c, Accumulation_Repair_Amount__c, Maintenance_Price_Month__c, Final_Examination_Date__c,CurrentContract_End_Date__c,Extend_Gurantee_DateTo__c
+                //            FROM Asset WHERE Hospital__c = :this.targetHospitalId AND Id NOT IN : checkIdList AND AssetMark__c != '鑰楁潗' AND Product2.Family != 'ET' ORDER BY ID,IF_Warranty__c asc limit : sqlLimit];
+            } else {
+                //temAsset = [SELECT Id, Name, Asset_situation__c, SerialNumber, Department_Name__c, Installation_Site__c, Posting_Date__c,Management_Code__c,IF_Warranty__c,Reson_Can_not_Warranty__c,
+                //            InstallDate, Asset_Owner__c, Accumulation_Repair_Amount__c, Maintenance_Price_Month__c, Final_Examination_Date__c,CurrentContract_End_Date__c,Extend_Gurantee_DateTo__c
+                //            FROM Asset WHERE Hospital__c = :this.targetHospitalId AND AssetMark__c != '鑰楁潗' AND Product2.Family != 'ET' ORDER BY ID,IF_Warranty__c asc limit : sqlLimit];
+            }
+            sqlStr += ' ORDER BY ID,IF_Warranty__c asc limit ' + sqlLimit;
+            temAsset = Database.query(sqlStr);
+            //HWAG-BDJ43R ---XHL---20190729---
+            if (temAsset.size() >= (currPage * selctRecordNum)) {
+                for (Integer i = ((currPage - 1) * selctRecordNum); i < (currPage * selctRecordNum); i++) {
+                    assetRecords.add(temAsset.get(i));
+                }
+            } else {
+                for (Integer i = ((currPage - 1) * selctRecordNum); i < temAsset.size(); i++) {
+                    assetRecords.add(temAsset.get(i));
+                }
+            }
         }
-        sqlStr += ' ORDER BY ID,IF_Warranty__c asc limit ' + sqlLimit;
-        temAsset = Database.query(sqlStr);
-        //HWAG-BDJ43R ---XHL---20190729---
-        if (temAsset.size() >= (currPage * selctRecordNum)) {
-          for (Integer i = ((currPage - 1) * selctRecordNum); i < (currPage * selctRecordNum); i++) {
-            assetRecords.add(temAsset.get(i));
-          }
-        } else {
-          for (Integer i = ((currPage - 1) * selctRecordNum); i < temAsset.size(); i++) {
-            assetRecords.add(temAsset.get(i));
-          }
+        this.unCheckedAssets = new List<AssetInfo>();
+        for (Asset ast : assetRecords) {
+            this.unCheckedAssets.add(new AssetInfo(unCheckedAssets.size(), ast));
         }
-      }
-      this.unCheckedAssets = new List<AssetInfo>();
-      for (Asset ast : assetRecords) {
-        this.unCheckedAssets.add(new AssetInfo(unCheckedAssets.size(), ast));
-      }
-      listCut(unCheckedAssets);
-      // 鏍规嵁鍚堝悓寮�濮嬫棩閲嶆柊璁$畻缁翠慨鍚堝悓浠锋牸
-      //contractStartDateChange();
+        listCut(unCheckedAssets);
+        // 鏍规嵁鍚堝悓寮�濮嬫棩閲嶆柊璁$畻缁翠慨鍚堝悓浠锋牸
+        //contractStartDateChange();
     }
     
     // 缈婚〉鍒伴椤�
     public void firstPage() {
-      getAssetSerialNumber();
-      currPage = 1;
-      //HWAG-B4R3SS  END 20181026
-      totalRecords = soqlNos();
-      totalPage = (totalRecords / selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
-      //HWAG-B4R3SS  END 20181026
-      this.setPageRecord();
+        getAssetSerialNumber();
+        currPage = 1;
+        //HWAG-B4R3SS  END 20181026
+        totalRecords = soqlNos();
+        totalPage = (totalRecords / selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
+        //HWAG-B4R3SS  END 20181026
+        this.setPageRecord();
     }
     
     // 鍚戝墠缈婚〉
     public void previousPage() {
-      getAssetSerialNumber();
-      currPage--;
-      //HWAG-B4R3SS  START 20181026
-      totalRecords = soqlNos();
-      totalPage = (totalRecords / selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
-      //HWAG-B4R3SS  END 20181026
-      this.setPageRecord();
+        getAssetSerialNumber();
+        currPage--;
+        //HWAG-B4R3SS  START 20181026
+        totalRecords = soqlNos();
+        totalPage = (totalRecords / selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
+        //HWAG-B4R3SS  END 20181026
+        this.setPageRecord();
     }
     
     // 鍚戝悗缈婚〉
     public void nextPage() {
-      getAssetSerialNumber();
-      //HWAG-B4R3SS  START 20181026
-      totalRecords = soqlNos();
-      //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO , 'totalRecords鈥斺�斺�斺�斺�斺��' + totalRecords));
-      totalPage = (totalRecords / selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
-      if (totalRecords == 0) {
-        currPage  = 1;
-        //this.unCheckedAssets.clear();
-      } else {
-        currPage++;
-        this.setPageRecord();
-      }
-      //HWAG-B4R3SS  END 20181026
+        getAssetSerialNumber();
+        //HWAG-B4R3SS  START 20181026
+        totalRecords = soqlNos();
+        //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO , 'totalRecords鈥斺�斺�斺�斺�斺��' + totalRecords));
+        totalPage = (totalRecords / selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
+        if (totalRecords == 0) {
+            currPage  = 1;
+            //this.unCheckedAssets.clear();
+        } else {
+            currPage++;
+            this.setPageRecord();
+        }
+        //HWAG-B4R3SS  END 20181026
     
     }
     
     // 缈婚〉鍒板熬椤�
     public void endPage() {
-      getAssetSerialNumber();
-      //HWAG-B4R3SS  START 20181026
-      totalRecords = soqlNos();
-      totalPage = (totalRecords / selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
-      if (totalRecords == 0) {
-        currPage  = 1;
-        this.unCheckedAssets.clear();
-      } else {
-        currPage = totalPage;
-        this.setPageRecord();
-      }
-      //HWAG-B4R3SS  END 20181026
+        getAssetSerialNumber();
+        //HWAG-B4R3SS  START 20181026
+        totalRecords = soqlNos();
+        totalPage = (totalRecords / selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
+        if (totalRecords == 0) {
+            currPage  = 1;
+            this.unCheckedAssets.clear();
+        } else {
+            currPage = totalPage;
+            this.setPageRecord();
+        }
+        //HWAG-B4R3SS  END 20181026
     }
     
     // 姣忛〉鏄剧ず璁板綍鏁板彉鏇�
     public void recordNumChange() {
-      currPage = 1;
-      //totalRecords = soqlNos();
-      totalPage = (totalRecords / selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
-      this.setPageRecord();
+        currPage = 1;
+        //totalRecords = soqlNos();
+        totalPage = (totalRecords / selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
+        this.setPageRecord();
     }
     
     //list鍒嗗壊 闆嗗悎澶у皬瓒呰繃1000瀵瑰簲
     private void listCut(List<AssetInfo> records) {
-      List<AssetInfo> recordsbreak = new List<AssetInfo>();
-      List<AssetInfo> recordsbreakover = new List<AssetInfo>();
-      unCheckedAssetsView = new List<List<AssetInfo> >();
-      AssetInfo c = null;
-      recordsbreak.clear();
-      recordsbreakover.clear();
-      unCheckedAssetsView.clear();
-      unCheckedAssetsView.add(records);
+        List<AssetInfo> recordsbreak = new List<AssetInfo>();
+        List<AssetInfo> recordsbreakover = new List<AssetInfo>();
+        unCheckedAssetsView = new List<List<AssetInfo> >();
+        AssetInfo c = null;
+        recordsbreak.clear();
+        recordsbreakover.clear();
+        unCheckedAssetsView.clear();
+        unCheckedAssetsView.add(records);
     }
     /*
      *鏄剧ず杩囧幓涓ゅ勾鐨勭淮淇疄缁�
      *璁$畻璇ョ淮淇悎鍚屾姤浠风殑鎵�鏈変繚浣戣澶囷紝杩囧幓涓ゅ勾鐨勪慨鐞嗗疄缁�
      */
     public static void ComputeLTYRepair(String targetHospitalId) {
-      system.debug('ComputeLTYRepair=====Start');
-      List<Maintenance_Contract_Asset_Estimate__c> McaeList = new List<Maintenance_Contract_Asset_Estimate__c>();
-      McaeList = [select id, asset__c, Lastyear_Repair_Cost_Text__c, Last_Second_Years_Repair_Cost_Text__c, Last_Third_Years_Repair_Cost_Text__c, Three_Years_Repair_Cost_Text__c
-            from Maintenance_Contract_Asset_Estimate__c
-            where Maintenance_Contract_Estimate__c = :targetHospitalId];
-      List<id> AsList = new List<id>();
-      Map<id, id> McaecToAsset = new Map<id, id>();
-      for (Maintenance_Contract_Asset_Estimate__c Mcaes : McaeList) {
-        AsList.add(Mcaes.asset__c);
-        McaecToAsset.put(Mcaes.id, Mcaes.asset__c);
-      }
-      Maintenance_Contract_Estimate__c mcec = [select id, createdDate, Submit_quotation_day__c from Maintenance_Contract_Estimate__c where id = :targetHospitalId];
-      //1骞村墠缁翠慨瀹炵哗
-      Date today = null;
-      Date LastYearDate = null;
-      Date LastSecondYearDate = null;
-      Date LastThirdYearDate = null;
-      Decimal LastYearPriceForMCAEC = 0;
+        system.debug('ComputeLTYRepair=====Start');
+        List<Maintenance_Contract_Asset_Estimate__c> McaeList = new List<Maintenance_Contract_Asset_Estimate__c>();
+        McaeList = [select id, asset__c, Lastyear_Repair_Cost_Text__c, Last_Second_Years_Repair_Cost_Text__c, Last_Third_Years_Repair_Cost_Text__c, Three_Years_Repair_Cost_Text__c
+                    from Maintenance_Contract_Asset_Estimate__c
+                    where Maintenance_Contract_Estimate__c = :targetHospitalId];
+        List<id> AsList = new List<id>();
+        Map<id, id> McaecToAsset = new Map<id, id>();
+        for (Maintenance_Contract_Asset_Estimate__c Mcaes : McaeList) {
+            AsList.add(Mcaes.asset__c);
+            McaecToAsset.put(Mcaes.id, Mcaes.asset__c);
+        }
+        Maintenance_Contract_Estimate__c mcec = [select id, createdDate, Submit_quotation_day__c from Maintenance_Contract_Estimate__c where id = :targetHospitalId];
+        //1骞村墠缁翠慨瀹炵哗
+        Date today = null;
+        Date LastYearDate = null;
+        Date LastSecondYearDate = null;
+        Date LastThirdYearDate = null;
+        Decimal LastYearPriceForMCAEC = 0;
     
-      if (mcec.Submit_quotation_day__c != null && String.valueOf(mcec.Submit_quotation_day__c) != '') {
-        today = mcec.Submit_quotation_day__c;
-        LastYearDate = mcec.Submit_quotation_day__c;
-        LastSecondYearDate = mcec.Submit_quotation_day__c;
-        LastThirdYearDate = mcec.Submit_quotation_day__c;
-      } else {
-        today = Date.valueOf(mcec.createdDate);
-        LastYearDate = Date.valueOf(mcec.createdDate);
-        LastSecondYearDate = Date.valueOf(mcec.createdDate);
-        LastThirdYearDate = Date.valueOf(mcec.createdDate);
-      }
+        if (mcec.Submit_quotation_day__c != null && String.valueOf(mcec.Submit_quotation_day__c) != '') {
+            today = mcec.Submit_quotation_day__c;
+            LastYearDate = mcec.Submit_quotation_day__c;
+            LastSecondYearDate = mcec.Submit_quotation_day__c;
+            LastThirdYearDate = mcec.Submit_quotation_day__c;
+        } else {
+            today = Date.valueOf(mcec.createdDate);
+            LastYearDate = Date.valueOf(mcec.createdDate);
+            LastSecondYearDate = Date.valueOf(mcec.createdDate);
+            LastThirdYearDate = Date.valueOf(mcec.createdDate);
+        }
     
-      system.debug('鍘诲勾' + LastYearDate + '鍓嶅勾' + LastSecondYearDate + '澶у墠骞�' + LastThirdYearDate);
+        system.debug('鍘诲勾' + LastYearDate + '鍓嶅勾' + LastSecondYearDate + '澶у墠骞�' + LastThirdYearDate);
     
-      LastYearDate = LastYearDate.addYears(-1);
-      // LastYearDate = LastYearDate.addDays(1);
+        LastYearDate = LastYearDate.addYears(-1);
+        // LastYearDate = LastYearDate.addDays(1);
     
-      //LastSecondYearDate = LastSecondYearDate.addDays(1);
-      LastSecondYearDate = LastSecondYearDate.addYears(-2);
+        //LastSecondYearDate = LastSecondYearDate.addDays(1);
+        LastSecondYearDate = LastSecondYearDate.addYears(-2);
     
-      // LastThirdYearDate = LastThirdYearDate.addDays(1);
-      LastThirdYearDate = LastThirdYearDate.addYears(-3);
-      system.debug('鍘诲勾' + LastYearDate + '鍓嶅勾' + LastSecondYearDate + '澶у墠骞�' + LastThirdYearDate);
-      // 20191210 Gzw 鏈嶅姟鍚堝悓杩囧幓3骞翠慨鐞嗗疄缁╁悎骞�
-      List<AggregateResult> FriRepairList = [
-        select
-        sum(Discount_Price_formula__c) SumPrice,
-        //2019/1娣诲姞
-        sum(Repair_Quotation_Id__r.sales_discount__c) sales_discount,
-        sum(Repair_Quotation_Id__r.Contract_target__c) contract_target,
-        sum(Repair_Quotation_Id__r.Loaner_repair__c) loaner_repair,
-        sum(Repair_Quotation_Id__r.long_term_insurance__c) long_term_insurance,
-        sum(Repair_Quotation_Id__r.Set_discount__c) set_discount,
-        sum(Repair_Quotation_Id__r.Servince_contract_discount_amount__c) sercince,
-        sum(Repair_Quotation_Id__r.long_term_insurance_MD__c) long_term_insuranceMD,
-        sum(Repair_Quotation_Id__r.Delivery_compensation__c) delivery,
-        sum(Repair_Quotation_Id__r.Other_discount__c) other,
-        AVG(Delivered_Product__r.Last_Years_Repair_Month__c) threeYearM,
-        Delivered_Product__c
-        from
-        Repair__c
-        where
-        Delivered_Product__c in:AsList
-        and Agreed_Date__c != null
-        and Agreed_Date__c > :LastYearDate
-        and Agreed_Date__c <= :today
-        group by Delivered_Product__c
-      ];
-      List<AggregateResult> SecRepairList = [
-        select
-        sum(Discount_Price_formula__c) SumPrice,
-        //2019/1娣诲姞
-        sum(Repair_Quotation_Id__r.sales_discount__c) sales_discount,
-        sum(Repair_Quotation_Id__r.Contract_target__c) contract_target,
-        sum(Repair_Quotation_Id__r.Loaner_repair__c) loaner_repair,
-        sum(Repair_Quotation_Id__r.long_term_insurance__c) long_term_insurance,
-        sum(Repair_Quotation_Id__r.Set_discount__c) set_discount,
-        sum(Repair_Quotation_Id__r.Servince_contract_discount_amount__c) sercince,
-        sum(Repair_Quotation_Id__r.long_term_insurance_MD__c) long_term_insuranceMD,
-        sum(Repair_Quotation_Id__r.Delivery_compensation__c) delivery,
-        sum(Repair_Quotation_Id__r.Other_discount__c) other,
-        AVG(Delivered_Product__r.Last_Years_Repair_Month__c) threeYearM,
-        Delivered_Product__c
-        from
-        Repair__c
-        where
-        Delivered_Product__c in:AsList
-        and Agreed_Date__c != null
-        and Agreed_Date__c <= :LastYearDate
-        and Agreed_Date__c > :LastSecondYearDate
-        group by Delivered_Product__c
-      ];
-      // 杩囧幓3骞撮棿淇悊瀹炵哗
-      List<AggregateResult> ThiRepairList = [
-        select
-        sum(Discount_Price_formula__c) SumPrice,
-        //2019/1娣诲姞
-        sum(Repair_Quotation_Id__r.sales_discount__c) sales_discount,
-        sum(Repair_Quotation_Id__r.Contract_target__c) contract_target,
-        sum(Repair_Quotation_Id__r.Loaner_repair__c) loaner_repair,
-        sum(Repair_Quotation_Id__r.long_term_insurance__c) long_term_insurance,
-        sum(Repair_Quotation_Id__r.Set_discount__c) set_discount,
-        sum(Repair_Quotation_Id__r.Servince_contract_discount_amount__c) sercince,
-        sum(Repair_Quotation_Id__r.long_term_insurance_MD__c) long_term_insuranceMD,
-        sum(Repair_Quotation_Id__r.Delivery_compensation__c) delivery,
-        sum(Repair_Quotation_Id__r.Other_discount__c) other,
-        AVG(Delivered_Product__r.Last_Years_Repair_Month__c) threeYearM,
-        Delivered_Product__c
-        from
-        Repair__c
-        where
-        Delivered_Product__c in:AsList
-        and Agreed_Date__c != null
-        and Agreed_Date__c <= :LastSecondYearDate
-        and Agreed_Date__c > :LastThirdYearDate
-        group by Delivered_Product__c
-      ];
-      // 杩囧幓3骞翠慨鐞嗗疄缁�
-      List<AggregateResult> ThreeyearList = [
-        select
-        sum(Discount_Price_formula__c) SumPrice,
-        //2019/1娣诲姞
-        sum(Repair_Quotation_Id__r.sales_discount__c) sales_discount,
-        sum(Repair_Quotation_Id__r.Contract_target__c) contract_target,
-        sum(Repair_Quotation_Id__r.Loaner_repair__c) loaner_repair,
-        sum(Repair_Quotation_Id__r.long_term_insurance__c) long_term_insurance,
-        sum(Repair_Quotation_Id__r.Set_discount__c) set_discount,
-        sum(Repair_Quotation_Id__r.Servince_contract_discount_amount__c) sercince,
-        sum(Repair_Quotation_Id__r.long_term_insurance_MD__c) long_term_insuranceMD,
-        sum(Repair_Quotation_Id__r.Delivery_compensation__c) delivery,
-        sum(Repair_Quotation_Id__r.Other_discount__c) other,
-        AVG(Delivered_Product__r.Last_Years_Repair_Month__c) threeYearM,
-        Delivered_Product__c
-        from
-        Repair__c
-        where
-        Delivered_Product__c in:AsList
-        and Agreed_Date__c != null
-        and Agreed_Date__c <= :today
-        and Agreed_Date__c > :LastThirdYearDate
-        group by Delivered_Product__c
-      ];
+        // LastThirdYearDate = LastThirdYearDate.addDays(1);
+        LastThirdYearDate = LastThirdYearDate.addYears(-3);
+        system.debug('鍘诲勾' + LastYearDate + '鍓嶅勾' + LastSecondYearDate + '澶у墠骞�' + LastThirdYearDate);
+        // 20191210 Gzw 鏈嶅姟鍚堝悓杩囧幓3骞翠慨鐞嗗疄缁╁悎骞�
+        List<AggregateResult> FriRepairList = [
+            select
+            sum(Discount_Price_formula__c) SumPrice,
+            //2019/1娣诲姞
+            sum(Repair_Quotation_Id__r.sales_discount__c) sales_discount,
+            sum(Repair_Quotation_Id__r.Contract_target__c) contract_target,
+            sum(Repair_Quotation_Id__r.Loaner_repair__c) loaner_repair,
+            sum(Repair_Quotation_Id__r.long_term_insurance__c) long_term_insurance,
+            sum(Repair_Quotation_Id__r.Set_discount__c) set_discount,
+            sum(Repair_Quotation_Id__r.Servince_contract_discount_amount__c) sercince,
+            sum(Repair_Quotation_Id__r.long_term_insurance_MD__c) long_term_insuranceMD,
+            sum(Repair_Quotation_Id__r.Delivery_compensation__c) delivery,
+            sum(Repair_Quotation_Id__r.Other_discount__c) other,
+            AVG(Delivered_Product__r.Last_Years_Repair_Month__c) threeYearM,
+            Delivered_Product__c
+            from
+            Repair__c
+            where
+            Delivered_Product__c in:AsList
+            and Agreed_Date__c != null
+            and Agreed_Date__c > :LastYearDate
+            and Agreed_Date__c <= :today
+            group by Delivered_Product__c
+        ];
+        List<AggregateResult> SecRepairList = [
+            select
+            sum(Discount_Price_formula__c) SumPrice,
+            //2019/1娣诲姞
+            sum(Repair_Quotation_Id__r.sales_discount__c) sales_discount,
+            sum(Repair_Quotation_Id__r.Contract_target__c) contract_target,
+            sum(Repair_Quotation_Id__r.Loaner_repair__c) loaner_repair,
+            sum(Repair_Quotation_Id__r.long_term_insurance__c) long_term_insurance,
+            sum(Repair_Quotation_Id__r.Set_discount__c) set_discount,
+            sum(Repair_Quotation_Id__r.Servince_contract_discount_amount__c) sercince,
+            sum(Repair_Quotation_Id__r.long_term_insurance_MD__c) long_term_insuranceMD,
+            sum(Repair_Quotation_Id__r.Delivery_compensation__c) delivery,
+            sum(Repair_Quotation_Id__r.Other_discount__c) other,
+            AVG(Delivered_Product__r.Last_Years_Repair_Month__c) threeYearM,
+            Delivered_Product__c
+            from
+            Repair__c
+            where
+            Delivered_Product__c in:AsList
+            and Agreed_Date__c != null
+            and Agreed_Date__c <= :LastYearDate
+            and Agreed_Date__c > :LastSecondYearDate
+            group by Delivered_Product__c
+        ];
+        // 杩囧幓3骞撮棿淇悊瀹炵哗
+        List<AggregateResult> ThiRepairList = [
+            select
+            sum(Discount_Price_formula__c) SumPrice,
+            //2019/1娣诲姞
+            sum(Repair_Quotation_Id__r.sales_discount__c) sales_discount,
+            sum(Repair_Quotation_Id__r.Contract_target__c) contract_target,
+            sum(Repair_Quotation_Id__r.Loaner_repair__c) loaner_repair,
+            sum(Repair_Quotation_Id__r.long_term_insurance__c) long_term_insurance,
+            sum(Repair_Quotation_Id__r.Set_discount__c) set_discount,
+            sum(Repair_Quotation_Id__r.Servince_contract_discount_amount__c) sercince,
+            sum(Repair_Quotation_Id__r.long_term_insurance_MD__c) long_term_insuranceMD,
+            sum(Repair_Quotation_Id__r.Delivery_compensation__c) delivery,
+            sum(Repair_Quotation_Id__r.Other_discount__c) other,
+            AVG(Delivered_Product__r.Last_Years_Repair_Month__c) threeYearM,
+            Delivered_Product__c
+            from
+            Repair__c
+            where
+            Delivered_Product__c in:AsList
+            and Agreed_Date__c != null
+            and Agreed_Date__c <= :LastSecondYearDate
+            and Agreed_Date__c > :LastThirdYearDate
+            group by Delivered_Product__c
+        ];
+        // 杩囧幓3骞翠慨鐞嗗疄缁�
+        List<AggregateResult> ThreeyearList = [
+            select
+            sum(Discount_Price_formula__c) SumPrice,
+            //2019/1娣诲姞
+            sum(Repair_Quotation_Id__r.sales_discount__c) sales_discount,
+            sum(Repair_Quotation_Id__r.Contract_target__c) contract_target,
+            sum(Repair_Quotation_Id__r.Loaner_repair__c) loaner_repair,
+            sum(Repair_Quotation_Id__r.long_term_insurance__c) long_term_insurance,
+            sum(Repair_Quotation_Id__r.Set_discount__c) set_discount,
+            sum(Repair_Quotation_Id__r.Servince_contract_discount_amount__c) sercince,
+            sum(Repair_Quotation_Id__r.long_term_insurance_MD__c) long_term_insuranceMD,
+            sum(Repair_Quotation_Id__r.Delivery_compensation__c) delivery,
+            sum(Repair_Quotation_Id__r.Other_discount__c) other,
+            AVG(Delivered_Product__r.Last_Years_Repair_Month__c) threeYearM,
+            Delivered_Product__c
+            from
+            Repair__c
+            where
+            Delivered_Product__c in:AsList
+            and Agreed_Date__c != null
+            and Agreed_Date__c <= :today
+            and Agreed_Date__c > :LastThirdYearDate
+            group by Delivered_Product__c
+        ];
     
-      // system.debug('++++++++'+FriRepairList+'++++++++'+SecRepairList+'+++++++'+ThiRepairList+'+++++');
-      // 杩囧幓1骞撮棿
-      Map<id, Decimal> LastFriYearPriceSumMap = new Map<id, Decimal>();
-      // 杩囧幓2骞撮棿
-      Map<id, Decimal> LastSecYearPriceSumMap = new Map<id, Decimal>();
-      // 杩囧幓3骞撮棿
-      Map<id, Decimal> LastThiYearPriceSumMap = new Map<id, Decimal>();
-      // 杩囧幓3骞�
-      Map<id, Decimal> ThreeYearPriceSumMap = new Map<id, Decimal>();
-      Map<id, Decimal> ThiYearMonthMap = new Map<id, Decimal>();
-      for (AggregateResult Rpc : FriRepairList) {
-        id idf        = String.valueOf(Rpc.get('Delivered_Product__c'));
-        //Decimal Defir = decimal.valueOf(Rpc.get('SumPrice')+'');
-        Decimal Defir = sumPrice1(Rpc);
-        LastFriYearPriceSumMap.put(idf, Defir);
-      }
-      for (AggregateResult Rpc : SecRepairList) {
-        id idf        = String.valueOf(Rpc.get('Delivered_Product__c'));
-        //Decimal Defir = decimal.valueOf(Rpc.get('SumPrice')+'');
-        Decimal Defir = sumPrice1(Rpc);
-        LastSecYearPriceSumMap.put(idf, Defir);
-      }
-      for (AggregateResult Rpc : ThiRepairList) {
-        id idf        = String.valueOf(Rpc.get('Delivered_Product__c'));
-        //Decimal Defir = decimal.valueOf(Rpc.get('SumPrice')+'');
-        Decimal Defir = sumPrice1(Rpc);
-        LastThiYearPriceSumMap.put(idf, Defir);
-      }
-      for (AggregateResult Rpc : ThreeyearList) {
-        id idf        = String.valueOf(Rpc.get('Delivered_Product__c'));
-        //Decimal Defir = decimal.valueOf(Rpc.get('SumPrice')+'');
-        Decimal threeYearM = decimal.valueOf(Rpc.get('threeYearM') + '');
-        Decimal Defir = sumPrice1(Rpc);
-        ThreeYearPriceSumMap.put(idf, Defir);
-        ThiYearMonthMap.put(idf, threeYearM);
-      }
-      for (Maintenance_Contract_Asset_Estimate__c Mca : McaeList) {
-        Mca.Lastyear_Repair_Cost_Text__c = LastFriYearPriceSumMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : LastFriYearPriceSumMap.get(McaecToAsset.get(Mca.id));
-        Mca.Last_Second_Years_Repair_Cost_Text__c = LastSecYearPriceSumMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : LastSecYearPriceSumMap.get(McaecToAsset.get(Mca.id));
-        Mca.Last_Third_Years_Repair_Cost_Text__c = LastThiYearPriceSumMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : LastThiYearPriceSumMap.get(McaecToAsset.get(Mca.id));
-        Mca.Three_Years_Repair_Cost_Text__c = ThreeYearPriceSumMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : ThreeYearPriceSumMap.get(McaecToAsset.get(Mca.id));
-        Mca.The_Date_Of_Compute_The_RPCost__c = Date.today();
-        Mca.Last_Third_Years_Repair_Month__c = ThiYearMonthMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : ThiYearMonthMap.get(McaecToAsset.get(Mca.id));
+        // system.debug('++++++++'+FriRepairList+'++++++++'+SecRepairList+'+++++++'+ThiRepairList+'+++++');
+        // 杩囧幓1骞撮棿
+        Map<id, Decimal> LastFriYearPriceSumMap = new Map<id, Decimal>();
+        // 杩囧幓2骞撮棿
+        Map<id, Decimal> LastSecYearPriceSumMap = new Map<id, Decimal>();
+        // 杩囧幓3骞撮棿
+        Map<id, Decimal> LastThiYearPriceSumMap = new Map<id, Decimal>();
+        // 杩囧幓3骞�
+        Map<id, Decimal> ThreeYearPriceSumMap = new Map<id, Decimal>();
+        Map<id, Decimal> ThiYearMonthMap = new Map<id, Decimal>();
+        for (AggregateResult Rpc : FriRepairList) {
+            id idf        = String.valueOf(Rpc.get('Delivered_Product__c'));
+            //Decimal Defir = decimal.valueOf(Rpc.get('SumPrice')+'');
+            Decimal Defir = sumPrice1(Rpc);
+            LastFriYearPriceSumMap.put(idf, Defir);
+        }
+        for (AggregateResult Rpc : SecRepairList) {
+            id idf        = String.valueOf(Rpc.get('Delivered_Product__c'));
+            //Decimal Defir = decimal.valueOf(Rpc.get('SumPrice')+'');
+            Decimal Defir = sumPrice1(Rpc);
+            LastSecYearPriceSumMap.put(idf, Defir);
+        }
+        for (AggregateResult Rpc : ThiRepairList) {
+            id idf        = String.valueOf(Rpc.get('Delivered_Product__c'));
+            //Decimal Defir = decimal.valueOf(Rpc.get('SumPrice')+'');
+            Decimal Defir = sumPrice1(Rpc);
+            LastThiYearPriceSumMap.put(idf, Defir);
+        }
+        for (AggregateResult Rpc : ThreeyearList) {
+            id idf        = String.valueOf(Rpc.get('Delivered_Product__c'));
+            //Decimal Defir = decimal.valueOf(Rpc.get('SumPrice')+'');
+            Decimal threeYearM = decimal.valueOf(Rpc.get('threeYearM') + '');
+            Decimal Defir = sumPrice1(Rpc);
+            ThreeYearPriceSumMap.put(idf, Defir);
+            ThiYearMonthMap.put(idf, threeYearM);
+        }
+        for (Maintenance_Contract_Asset_Estimate__c Mca : McaeList) {
+            Mca.Lastyear_Repair_Cost_Text__c = LastFriYearPriceSumMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : LastFriYearPriceSumMap.get(McaecToAsset.get(Mca.id));
+            Mca.Last_Second_Years_Repair_Cost_Text__c = LastSecYearPriceSumMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : LastSecYearPriceSumMap.get(McaecToAsset.get(Mca.id));
+            Mca.Last_Third_Years_Repair_Cost_Text__c = LastThiYearPriceSumMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : LastThiYearPriceSumMap.get(McaecToAsset.get(Mca.id));
+            Mca.Three_Years_Repair_Cost_Text__c = ThreeYearPriceSumMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : ThreeYearPriceSumMap.get(McaecToAsset.get(Mca.id));
+            Mca.The_Date_Of_Compute_The_RPCost__c = Date.today();
+            Mca.Last_Third_Years_Repair_Month__c = ThiYearMonthMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : ThiYearMonthMap.get(McaecToAsset.get(Mca.id));
     
     
-      }
-      try {
-        system.debug('McaeList:::::' + McaeList);
-        update McaeList;
+        }
+        try {
+            system.debug('McaeList:::::' + McaeList);
+            update McaeList;
     
-        //return '';
-      } catch (Exception e) {
-        //return 'McaeList Update Failed : '+e;
-      }
+            //return '';
+        } catch (Exception e) {
+            //return 'McaeList Update Failed : '+e;
+        }
     
     }
     
     
     
     public void ComputeLTYRepair() {
-      system.debug('ComputeLTYRepair=====Start');
-      List<Maintenance_Contract_Asset_Estimate__c> McaeList = new List<Maintenance_Contract_Asset_Estimate__c>();
-      McaeList = [select id, asset__c, Lastyear_Repair_Cost_Text__c, Last_Second_Years_Repair_Cost_Text__c, Last_Third_Years_Repair_Cost_Text__c, Three_Years_Repair_Cost_Text__c
-            from Maintenance_Contract_Asset_Estimate__c
-            where Maintenance_Contract_Estimate__c = :targetEstimateId];
-      List<id> AsList = new List<id>();
-      Map<id, id> McaecToAsset = new Map<id, id>();
-      for (Maintenance_Contract_Asset_Estimate__c Mcaes : McaeList) {
-        AsList.add(Mcaes.asset__c);
-        McaecToAsset.put(Mcaes.id, Mcaes.asset__c);
-      }
-      Maintenance_Contract_Estimate__c mcec = new Maintenance_Contract_Estimate__c();
-      List<Maintenance_Contract_Estimate__c>  mcecList = new List<Maintenance_Contract_Estimate__c>();
-      mcecList = [select id, createdDate, Submit_quotation_day__c from Maintenance_Contract_Estimate__c where id = :targetEstimateId];
-      if (mcecList.size() == 0) {
-        ApexPages.addMessage(new ApexPages.message(ApexPages.severity.Error, '璇峰厛淇濆瓨鎶ヤ环锛�'));
-        return;
-      } else {
-        mcec = mcecList[0];
-      }
-      //1骞村墠缁翠慨瀹炵哗
-      Date today = null;
-      Date LastYearDate = null;
-      Date LastSecondYearDate = null;
-      Date LastThirdYearDate = null;
-      Decimal LastYearPriceForMCAEC = 0;
+        system.debug('ComputeLTYRepair=====Start');
+        List<Maintenance_Contract_Asset_Estimate__c> McaeList = new List<Maintenance_Contract_Asset_Estimate__c>();
+        McaeList = [select id, asset__c, Lastyear_Repair_Cost_Text__c, Last_Second_Years_Repair_Cost_Text__c, Last_Third_Years_Repair_Cost_Text__c, Three_Years_Repair_Cost_Text__c
+                    from Maintenance_Contract_Asset_Estimate__c
+                    where Maintenance_Contract_Estimate__c = :targetEstimateId];
+        List<id> AsList = new List<id>();
+        Map<id, id> McaecToAsset = new Map<id, id>();
+        for (Maintenance_Contract_Asset_Estimate__c Mcaes : McaeList) {
+            AsList.add(Mcaes.asset__c);
+            McaecToAsset.put(Mcaes.id, Mcaes.asset__c);
+        }
+        Maintenance_Contract_Estimate__c mcec = new Maintenance_Contract_Estimate__c();
+        List<Maintenance_Contract_Estimate__c>  mcecList = new List<Maintenance_Contract_Estimate__c>();
+        mcecList = [select id, createdDate, Submit_quotation_day__c from Maintenance_Contract_Estimate__c where id = :targetEstimateId];
+        if (mcecList.size() == 0) {
+            ApexPages.addMessage(new ApexPages.message(ApexPages.severity.Error, '璇峰厛淇濆瓨鎶ヤ环锛�'));
+            return;
+        } else {
+            mcec = mcecList[0];
+        }
+        //1骞村墠缁翠慨瀹炵哗
+        Date today = null;
+        Date LastYearDate = null;
+        Date LastSecondYearDate = null;
+        Date LastThirdYearDate = null;
+        Decimal LastYearPriceForMCAEC = 0;
     
-      if (mcec.Submit_quotation_day__c != null && String.valueOf(mcec.Submit_quotation_day__c) != '') {
-        today = mcec.Submit_quotation_day__c;
-        LastYearDate = mcec.Submit_quotation_day__c;
-        LastSecondYearDate = mcec.Submit_quotation_day__c;
-        LastThirdYearDate = mcec.Submit_quotation_day__c;
-      } else {
-        today = Date.valueOf(mcec.createdDate);
-        LastYearDate = Date.valueOf(mcec.createdDate);
-        LastSecondYearDate = Date.valueOf(mcec.createdDate);
-        LastThirdYearDate = Date.valueOf(mcec.createdDate);
-      }
+        if (mcec.Submit_quotation_day__c != null && String.valueOf(mcec.Submit_quotation_day__c) != '') {
+            today = mcec.Submit_quotation_day__c;
+            LastYearDate = mcec.Submit_quotation_day__c;
+            LastSecondYearDate = mcec.Submit_quotation_day__c;
+            LastThirdYearDate = mcec.Submit_quotation_day__c;
+        } else {
+            today = Date.valueOf(mcec.createdDate);
+            LastYearDate = Date.valueOf(mcec.createdDate);
+            LastSecondYearDate = Date.valueOf(mcec.createdDate);
+            LastThirdYearDate = Date.valueOf(mcec.createdDate);
+        }
     
-      LastYearDate = LastYearDate.addYears(-1);
-      // LastYearDate = LastYearDate.addDays(1);
+        LastYearDate = LastYearDate.addYears(-1);
+        // LastYearDate = LastYearDate.addDays(1);
     
-      // LastSecondYearDate = LastSecondYearDate.addDays(1);
-      LastSecondYearDate = LastSecondYearDate.addYears(-2);
+        // LastSecondYearDate = LastSecondYearDate.addDays(1);
+        LastSecondYearDate = LastSecondYearDate.addYears(-2);
     
-      // LastThirdYearDate = LastThirdYearDate.addDays(1);
-      LastThirdYearDate = LastThirdYearDate.addYears(-3);
-      system.debug('鍘诲勾' + LastYearDate + '鍓嶅勾' + LastSecondYearDate + '澶у墠骞�' + LastThirdYearDate);
-      // 20191210 Gzw 鏈嶅姟鍚堝悓杩囧幓3骞翠慨鐞嗗疄缁╁悎骞�
-      List<AggregateResult> FriRepairList = [
-        select
-        sum(Discount_Price_formula__c) SumPrice,
-        //2019/1娣诲姞
-        sum(Repair_Quotation_Id__r.sales_discount__c) sales_discount,
-        sum(Repair_Quotation_Id__r.Contract_target__c) contract_target,
-        sum(Repair_Quotation_Id__r.Loaner_repair__c) loaner_repair,
-        sum(Repair_Quotation_Id__r.long_term_insurance__c) long_term_insurance,
-        sum(Repair_Quotation_Id__r.Set_discount__c) set_discount,
-        sum(Repair_Quotation_Id__r.Servince_contract_discount_amount__c) sercince,
-        sum(Repair_Quotation_Id__r.long_term_insurance_MD__c) long_term_insuranceMD,
-        sum(Repair_Quotation_Id__r.Delivery_compensation__c) delivery,
-        sum(Repair_Quotation_Id__r.Other_discount__c) other,
-        AVG(Delivered_Product__r.Last_Years_Repair_Month__c) threeYearM,
-        Delivered_Product__c
-        from
-        Repair__c
-        where
-        Delivered_Product__c in:AsList
-        and Agreed_Date__c != null
-        and Agreed_Date__c > :LastYearDate
-        and Agreed_Date__c <= :today
-        group by Delivered_Product__c
-      ];
-      List<AggregateResult> SecRepairList = [
-        select
-        sum(Discount_Price_formula__c) SumPrice,
-        //2019/1娣诲姞
-        sum(Repair_Quotation_Id__r.sales_discount__c) sales_discount,
-        sum(Repair_Quotation_Id__r.Contract_target__c) contract_target,
-        sum(Repair_Quotation_Id__r.Loaner_repair__c) loaner_repair,
-        sum(Repair_Quotation_Id__r.long_term_insurance__c) long_term_insurance,
-        sum(Repair_Quotation_Id__r.Set_discount__c) set_discount,
-        sum(Repair_Quotation_Id__r.Servince_contract_discount_amount__c) sercince,
-        sum(Repair_Quotation_Id__r.long_term_insurance_MD__c) long_term_insuranceMD,
-        sum(Repair_Quotation_Id__r.Delivery_compensation__c) delivery,
-        sum(Repair_Quotation_Id__r.Other_discount__c) other,
-        AVG(Delivered_Product__r.Last_Years_Repair_Month__c) threeYearM,
-        Delivered_Product__c
-        from
-        Repair__c
-        where
-        Delivered_Product__c in:AsList
-        and Agreed_Date__c != null
-        and Agreed_Date__c <= :LastYearDate
-        and Agreed_Date__c > :LastSecondYearDate
-        group by Delivered_Product__c
-      ];
-      // 杩囧幓3骞撮棿淇悊瀹炵哗
-      List<AggregateResult> ThiRepairList = [
-        select
-        sum(Discount_Price_formula__c) SumPrice,
-        //2019/1娣诲姞
-        sum(Repair_Quotation_Id__r.sales_discount__c) sales_discount,
-        sum(Repair_Quotation_Id__r.Contract_target__c) contract_target,
-        sum(Repair_Quotation_Id__r.Loaner_repair__c) loaner_repair,
-        sum(Repair_Quotation_Id__r.long_term_insurance__c) long_term_insurance,
-        sum(Repair_Quotation_Id__r.Set_discount__c) set_discount,
-        sum(Repair_Quotation_Id__r.Servince_contract_discount_amount__c) sercince,
-        sum(Repair_Quotation_Id__r.long_term_insurance_MD__c) long_term_insuranceMD,
-        sum(Repair_Quotation_Id__r.Delivery_compensation__c) delivery,
-        sum(Repair_Quotation_Id__r.Other_discount__c) other,
-        AVG(Delivered_Product__r.Last_Years_Repair_Month__c) threeYearM,
-        Delivered_Product__c
-        from
-        Repair__c
-        where
-        Delivered_Product__c in:AsList
-        and Agreed_Date__c != null
-        and Agreed_Date__c <= :LastSecondYearDate
-        and Agreed_Date__c > :LastThirdYearDate
-        group by Delivered_Product__c
-      ];
-      // 杩囧幓3骞翠慨鐞嗗疄缁�
-      List<AggregateResult> ThreeyearList = [
-        select
-        sum(Discount_Price_formula__c) SumPrice,
-        //2019/1娣诲姞
-        sum(Repair_Quotation_Id__r.sales_discount__c) sales_discount,
-        sum(Repair_Quotation_Id__r.Contract_target__c) contract_target,
-        sum(Repair_Quotation_Id__r.Loaner_repair__c) loaner_repair,
-        sum(Repair_Quotation_Id__r.long_term_insurance__c) long_term_insurance,
-        sum(Repair_Quotation_Id__r.Set_discount__c) set_discount,
-        sum(Repair_Quotation_Id__r.Servince_contract_discount_amount__c) sercince,
-        sum(Repair_Quotation_Id__r.long_term_insurance_MD__c) long_term_insuranceMD,
-        sum(Repair_Quotation_Id__r.Delivery_compensation__c) delivery,
-        sum(Repair_Quotation_Id__r.Other_discount__c) other,
-        AVG(Delivered_Product__r.Last_Years_Repair_Month__c) threeYearM,
-        Delivered_Product__c
-        from
-        Repair__c
-        where
-        Delivered_Product__c in:AsList
-        and Agreed_Date__c != null
-        and Agreed_Date__c <= :today
-        and Agreed_Date__c > :LastThirdYearDate
-        group by Delivered_Product__c
-      ];
-      // 杩囧幓1骞撮棿
-      Map<id, Decimal> LastFriYearPriceSumMap = new Map<id, Decimal>();
-      // 杩囧幓2骞撮棿
-      Map<id, Decimal> LastSecYearPriceSumMap = new Map<id, Decimal>();
-      // 杩囧幓3骞撮棿
-      Map<id, Decimal> LastThiYearPriceSumMap = new Map<id, Decimal>();
-      // 杩囧幓3骞�
-      Map<id, Decimal> ThreeYearPriceSumMap = new Map<id, Decimal>();
-      Map<id, Decimal> ThiYearMonthMap = new Map<id, Decimal>();
-      // system.debug('1'+FriRepairList);
-      // system.debug('2'+SecRepairList);
-      system.debug('3' + ThiRepairList);
+        // LastThirdYearDate = LastThirdYearDate.addDays(1);
+        LastThirdYearDate = LastThirdYearDate.addYears(-3);
+        system.debug('鍘诲勾' + LastYearDate + '鍓嶅勾' + LastSecondYearDate + '澶у墠骞�' + LastThirdYearDate);
+        // 20191210 Gzw 鏈嶅姟鍚堝悓杩囧幓3骞翠慨鐞嗗疄缁╁悎骞�
+        List<AggregateResult> FriRepairList = [
+            select
+            sum(Discount_Price_formula__c) SumPrice,
+            //2019/1娣诲姞
+            sum(Repair_Quotation_Id__r.sales_discount__c) sales_discount,
+            sum(Repair_Quotation_Id__r.Contract_target__c) contract_target,
+            sum(Repair_Quotation_Id__r.Loaner_repair__c) loaner_repair,
+            sum(Repair_Quotation_Id__r.long_term_insurance__c) long_term_insurance,
+            sum(Repair_Quotation_Id__r.Set_discount__c) set_discount,
+            sum(Repair_Quotation_Id__r.Servince_contract_discount_amount__c) sercince,
+            sum(Repair_Quotation_Id__r.long_term_insurance_MD__c) long_term_insuranceMD,
+            sum(Repair_Quotation_Id__r.Delivery_compensation__c) delivery,
+            sum(Repair_Quotation_Id__r.Other_discount__c) other,
+            AVG(Delivered_Product__r.Last_Years_Repair_Month__c) threeYearM,
+            Delivered_Product__c
+            from
+            Repair__c
+            where
+            Delivered_Product__c in:AsList
+            and Agreed_Date__c != null
+            and Agreed_Date__c > :LastYearDate
+            and Agreed_Date__c <= :today
+            group by Delivered_Product__c
+        ];
+        List<AggregateResult> SecRepairList = [
+            select
+            sum(Discount_Price_formula__c) SumPrice,
+            //2019/1娣诲姞
+            sum(Repair_Quotation_Id__r.sales_discount__c) sales_discount,
+            sum(Repair_Quotation_Id__r.Contract_target__c) contract_target,
+            sum(Repair_Quotation_Id__r.Loaner_repair__c) loaner_repair,
+            sum(Repair_Quotation_Id__r.long_term_insurance__c) long_term_insurance,
+            sum(Repair_Quotation_Id__r.Set_discount__c) set_discount,
+            sum(Repair_Quotation_Id__r.Servince_contract_discount_amount__c) sercince,
+            sum(Repair_Quotation_Id__r.long_term_insurance_MD__c) long_term_insuranceMD,
+            sum(Repair_Quotation_Id__r.Delivery_compensation__c) delivery,
+            sum(Repair_Quotation_Id__r.Other_discount__c) other,
+            AVG(Delivered_Product__r.Last_Years_Repair_Month__c) threeYearM,
+            Delivered_Product__c
+            from
+            Repair__c
+            where
+            Delivered_Product__c in:AsList
+            and Agreed_Date__c != null
+            and Agreed_Date__c <= :LastYearDate
+            and Agreed_Date__c > :LastSecondYearDate
+            group by Delivered_Product__c
+        ];
+        // 杩囧幓3骞撮棿淇悊瀹炵哗
+        List<AggregateResult> ThiRepairList = [
+            select
+            sum(Discount_Price_formula__c) SumPrice,
+            //2019/1娣诲姞
+            sum(Repair_Quotation_Id__r.sales_discount__c) sales_discount,
+            sum(Repair_Quotation_Id__r.Contract_target__c) contract_target,
+            sum(Repair_Quotation_Id__r.Loaner_repair__c) loaner_repair,
+            sum(Repair_Quotation_Id__r.long_term_insurance__c) long_term_insurance,
+            sum(Repair_Quotation_Id__r.Set_discount__c) set_discount,
+            sum(Repair_Quotation_Id__r.Servince_contract_discount_amount__c) sercince,
+            sum(Repair_Quotation_Id__r.long_term_insurance_MD__c) long_term_insuranceMD,
+            sum(Repair_Quotation_Id__r.Delivery_compensation__c) delivery,
+            sum(Repair_Quotation_Id__r.Other_discount__c) other,
+            AVG(Delivered_Product__r.Last_Years_Repair_Month__c) threeYearM,
+            Delivered_Product__c
+            from
+            Repair__c
+            where
+            Delivered_Product__c in:AsList
+            and Agreed_Date__c != null
+            and Agreed_Date__c <= :LastSecondYearDate
+            and Agreed_Date__c > :LastThirdYearDate
+            group by Delivered_Product__c
+        ];
+        // 杩囧幓3骞翠慨鐞嗗疄缁�
+        List<AggregateResult> ThreeyearList = [
+            select
+            sum(Discount_Price_formula__c) SumPrice,
+            //2019/1娣诲姞
+            sum(Repair_Quotation_Id__r.sales_discount__c) sales_discount,
+            sum(Repair_Quotation_Id__r.Contract_target__c) contract_target,
+            sum(Repair_Quotation_Id__r.Loaner_repair__c) loaner_repair,
+            sum(Repair_Quotation_Id__r.long_term_insurance__c) long_term_insurance,
+            sum(Repair_Quotation_Id__r.Set_discount__c) set_discount,
+            sum(Repair_Quotation_Id__r.Servince_contract_discount_amount__c) sercince,
+            sum(Repair_Quotation_Id__r.long_term_insurance_MD__c) long_term_insuranceMD,
+            sum(Repair_Quotation_Id__r.Delivery_compensation__c) delivery,
+            sum(Repair_Quotation_Id__r.Other_discount__c) other,
+            AVG(Delivered_Product__r.Last_Years_Repair_Month__c) threeYearM,
+            Delivered_Product__c
+            from
+            Repair__c
+            where
+            Delivered_Product__c in:AsList
+            and Agreed_Date__c != null
+            and Agreed_Date__c <= :today
+            and Agreed_Date__c > :LastThirdYearDate
+            group by Delivered_Product__c
+        ];
+        // 杩囧幓1骞撮棿
+        Map<id, Decimal> LastFriYearPriceSumMap = new Map<id, Decimal>();
+        // 杩囧幓2骞撮棿
+        Map<id, Decimal> LastSecYearPriceSumMap = new Map<id, Decimal>();
+        // 杩囧幓3骞撮棿
+        Map<id, Decimal> LastThiYearPriceSumMap = new Map<id, Decimal>();
+        // 杩囧幓3骞�
+        Map<id, Decimal> ThreeYearPriceSumMap = new Map<id, Decimal>();
+        Map<id, Decimal> ThiYearMonthMap = new Map<id, Decimal>();
+        // system.debug('1'+FriRepairList);
+        // system.debug('2'+SecRepairList);
+        system.debug('3' + ThiRepairList);
     
-      for (AggregateResult Rpc : FriRepairList) {
-        id idf        = String.valueOf(Rpc.get('Delivered_Product__c'));
-        //Decimal Defir = decimal.valueOf(Rpc.get('SumPrice')+'');
-        Decimal Defir = this.sumPrice(Rpc);
-        LastFriYearPriceSumMap.put(idf, Defir);
-      }
-      for (AggregateResult Rpc : SecRepairList) {
-        id idf        = String.valueOf(Rpc.get('Delivered_Product__c'));
-        //Decimal Defir = decimal.valueOf(Rpc.get('SumPrice')+'');
-        Decimal Defir = this.sumPrice(Rpc);
-        LastSecYearPriceSumMap.put(idf, Defir);
-      }
-      for (AggregateResult Rpc : ThiRepairList) {
-        id idf        = String.valueOf(Rpc.get('Delivered_Product__c'));
-        //Decimal Defir = decimal.valueOf(Rpc.get('SumPrice')+'');
-        Decimal Defir = sumPrice1(Rpc);
-        LastThiYearPriceSumMap.put(idf, Defir);
-      }
-      for (AggregateResult Rpc : ThreeyearList) {
-        id idf        = String.valueOf(Rpc.get('Delivered_Product__c'));
-        //Decimal Defir = decimal.valueOf(Rpc.get('SumPrice')+'');
-        Decimal threeYearM = decimal.valueOf(Rpc.get('threeYearM') + '');
-        Decimal Defir = sumPrice1(Rpc);
-        ThreeYearPriceSumMap.put(idf, Defir);
-        ThiYearMonthMap.put(idf, threeYearM);
-      }
-      for (Maintenance_Contract_Asset_Estimate__c Mca : McaeList) {
-        Mca.Lastyear_Repair_Cost_Text__c = LastFriYearPriceSumMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : LastFriYearPriceSumMap.get(McaecToAsset.get(Mca.id));
-        Mca.Last_Second_Years_Repair_Cost_Text__c = LastSecYearPriceSumMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : LastSecYearPriceSumMap.get(McaecToAsset.get(Mca.id));
-        Mca.Last_Third_Years_Repair_Cost_Text__c = LastThiYearPriceSumMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : LastThiYearPriceSumMap.get(McaecToAsset.get(Mca.id));
-        Mca.Three_Years_Repair_Cost_Text__c = ThreeYearPriceSumMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : ThreeYearPriceSumMap.get(McaecToAsset.get(Mca.id));
-        Mca.The_Date_Of_Compute_The_RPCost__c = Date.today();
-        Mca.Last_Third_Years_Repair_Month__c = ThiYearMonthMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : ThiYearMonthMap.get(McaecToAsset.get(Mca.id));
-        system.debug('杩囧幓3骞村ぉ鏁�111 ' + Mca.id + '---' + Mca.Last_Third_Years_Repair_Cost_Text__c + ' +++ ' + Mca.Last_Third_Years_Repair_Month__c);
-      }
-      try {
-        update McaeList;
-        //return '';
-      } catch (Exception e) {
-        //return 'McaeList Update Failed : '+e;
-      }
+        for (AggregateResult Rpc : FriRepairList) {
+            id idf        = String.valueOf(Rpc.get('Delivered_Product__c'));
+            //Decimal Defir = decimal.valueOf(Rpc.get('SumPrice')+'');
+            Decimal Defir = this.sumPrice(Rpc);
+            LastFriYearPriceSumMap.put(idf, Defir);
+        }
+        for (AggregateResult Rpc : SecRepairList) {
+            id idf        = String.valueOf(Rpc.get('Delivered_Product__c'));
+            //Decimal Defir = decimal.valueOf(Rpc.get('SumPrice')+'');
+            Decimal Defir = this.sumPrice(Rpc);
+            LastSecYearPriceSumMap.put(idf, Defir);
+        }
+        for (AggregateResult Rpc : ThiRepairList) {
+            id idf        = String.valueOf(Rpc.get('Delivered_Product__c'));
+            //Decimal Defir = decimal.valueOf(Rpc.get('SumPrice')+'');
+            Decimal Defir = sumPrice1(Rpc);
+            LastThiYearPriceSumMap.put(idf, Defir);
+        }
+        for (AggregateResult Rpc : ThreeyearList) {
+            id idf        = String.valueOf(Rpc.get('Delivered_Product__c'));
+            //Decimal Defir = decimal.valueOf(Rpc.get('SumPrice')+'');
+            Decimal threeYearM = decimal.valueOf(Rpc.get('threeYearM') + '');
+            Decimal Defir = sumPrice1(Rpc);
+            ThreeYearPriceSumMap.put(idf, Defir);
+            ThiYearMonthMap.put(idf, threeYearM);
+        }
+        for (Maintenance_Contract_Asset_Estimate__c Mca : McaeList) {
+            Mca.Lastyear_Repair_Cost_Text__c = LastFriYearPriceSumMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : LastFriYearPriceSumMap.get(McaecToAsset.get(Mca.id));
+            Mca.Last_Second_Years_Repair_Cost_Text__c = LastSecYearPriceSumMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : LastSecYearPriceSumMap.get(McaecToAsset.get(Mca.id));
+            Mca.Last_Third_Years_Repair_Cost_Text__c = LastThiYearPriceSumMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : LastThiYearPriceSumMap.get(McaecToAsset.get(Mca.id));
+            Mca.Three_Years_Repair_Cost_Text__c = ThreeYearPriceSumMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : ThreeYearPriceSumMap.get(McaecToAsset.get(Mca.id));
+            Mca.The_Date_Of_Compute_The_RPCost__c = Date.today();
+            Mca.Last_Third_Years_Repair_Month__c = ThiYearMonthMap.get(McaecToAsset.get(Mca.id)) == null ? 0 : ThiYearMonthMap.get(McaecToAsset.get(Mca.id));
+            system.debug('杩囧幓3骞村ぉ鏁�111 ' + Mca.id + '---' + Mca.Last_Third_Years_Repair_Cost_Text__c + ' +++ ' + Mca.Last_Third_Years_Repair_Month__c);
+        }
+        try {
+            update McaeList;
+            //return '';
+        } catch (Exception e) {
+            //return 'McaeList Update Failed : '+e;
+        }
     
     }
     
     private Decimal sumPrice(AggregateResult rpc) {
-      Decimal SumPrice = Decimal.valueOf(rpc.get('SumPrice') + '');
-      system.debug(rpc.get('sales_discount') == null ? 0 : rpc.get('sales_discount'));
-      Decimal sales_discount = Decimal.valueOf((rpc.get('sales_discount') == null ? 0 : rpc.get('sales_discount')) + '') * -1;
-      Decimal contract_target = Decimal.valueOf((rpc.get('contract_target') == null ? 0 : rpc.get('contract_target')) + '') * -1;
-      Decimal loaner_repair = Decimal.valueOf((rpc.get('loaner_repair') == null ? 0 : rpc.get('loaner_repair')) + '') * -1;
-      Decimal long_term_insurance = Decimal.valueOf((rpc.get('long_term_insurance') == null ? 0 : rpc.get('long_term_insurance')) + '') * -1;
-      Decimal set_discount = Decimal.valueOf((rpc.get('set_discount') == null ? 0 : rpc.get('set_discount')) + '') * -1;
-      Decimal sercince = Decimal.valueOf((rpc.get('sercince') == null ? 0 : rpc.get('sercince')) + '') * -1;
-      Decimal long_term_insuranceMD = Decimal.valueOf((rpc.get('long_term_insuranceMD') == null ? 0 : rpc.get('long_term_insuranceMD')) + '') * -1;
-      Decimal delivery = Decimal.valueOf((rpc.get('delivery') == null ? 0 : rpc.get('delivery')) + '') * -1;
-      Decimal other = Decimal.valueOf((rpc.get('other') == null ? 0 : rpc.get('other')) + '') * -1;
-      system.debug(rpc.get('SumPrice') + '--' + rpc.get('sales_discount') + '--' + rpc.get('contract_target') + '--' +
-             rpc.get('loaner_repair') + '--' + rpc.get('long_term_insurance') + '--' + rpc.get('set_discount') + '--' + rpc.get('long_term_insuranceMD')
-             + '--' + rpc.get('delivery') + '--' + rpc.get('other') + '--');
-      return SumPrice + sales_discount + contract_target + loaner_repair + long_term_insurance + sercince + set_discount + long_term_insuranceMD + delivery + other;
+        Decimal SumPrice = Decimal.valueOf(rpc.get('SumPrice') + '');
+        system.debug(rpc.get('sales_discount') == null ? 0 : rpc.get('sales_discount'));
+        Decimal sales_discount = Decimal.valueOf((rpc.get('sales_discount') == null ? 0 : rpc.get('sales_discount')) + '') * -1;
+        Decimal contract_target = Decimal.valueOf((rpc.get('contract_target') == null ? 0 : rpc.get('contract_target')) + '') * -1;
+        Decimal loaner_repair = Decimal.valueOf((rpc.get('loaner_repair') == null ? 0 : rpc.get('loaner_repair')) + '') * -1;
+        Decimal long_term_insurance = Decimal.valueOf((rpc.get('long_term_insurance') == null ? 0 : rpc.get('long_term_insurance')) + '') * -1;
+        Decimal set_discount = Decimal.valueOf((rpc.get('set_discount') == null ? 0 : rpc.get('set_discount')) + '') * -1;
+        Decimal sercince = Decimal.valueOf((rpc.get('sercince') == null ? 0 : rpc.get('sercince')) + '') * -1;
+        Decimal long_term_insuranceMD = Decimal.valueOf((rpc.get('long_term_insuranceMD') == null ? 0 : rpc.get('long_term_insuranceMD')) + '') * -1;
+        Decimal delivery = Decimal.valueOf((rpc.get('delivery') == null ? 0 : rpc.get('delivery')) + '') * -1;
+        Decimal other = Decimal.valueOf((rpc.get('other') == null ? 0 : rpc.get('other')) + '') * -1;
+        system.debug(rpc.get('SumPrice') + '--' + rpc.get('sales_discount') + '--' + rpc.get('contract_target') + '--' +
+                     rpc.get('loaner_repair') + '--' + rpc.get('long_term_insurance') + '--' + rpc.get('set_discount') + '--' + rpc.get('long_term_insuranceMD')
+                     + '--' + rpc.get('delivery') + '--' + rpc.get('other') + '--');
+        return SumPrice + sales_discount + contract_target + loaner_repair + long_term_insurance + sercince + set_discount + long_term_insuranceMD + delivery + other;
     }
     
     private static Decimal sumPrice1(AggregateResult rpc) {
-      Decimal SumPrice = Decimal.valueOf(rpc.get('SumPrice') + '');
-      Decimal sales_discount = Decimal.valueOf((rpc.get('sales_discount') == null ? 0 : rpc.get('sales_discount')) + '') * -1;
-      Decimal contract_target = Decimal.valueOf((rpc.get('contract_target') == null ? 0 : rpc.get('contract_target')) + '') * -1;
-      Decimal loaner_repair = Decimal.valueOf((rpc.get('loaner_repair') == null ? 0 : rpc.get('loaner_repair')) + '') * -1;
-      Decimal long_term_insurance = Decimal.valueOf((rpc.get('long_term_insurance') == null ? 0 : rpc.get('long_term_insurance')) + '') * -1;
-      Decimal set_discount = Decimal.valueOf((rpc.get('set_discount') == null ? 0 : rpc.get('set_discount')) + '') * -1;
-      Decimal sercince = Decimal.valueOf((rpc.get('sercince') == null ? 0 : rpc.get('sercince')) + '') * -1;
-      Decimal long_term_insuranceMD = Decimal.valueOf((rpc.get('long_term_insuranceMD') == null ? 0 : rpc.get('long_term_insuranceMD')) + '') * -1;
-      Decimal delivery = Decimal.valueOf((rpc.get('delivery') == null ? 0 : rpc.get('delivery')) + '') * -1;
-      Decimal other = Decimal.valueOf((rpc.get('other') == null ? 0 : rpc.get('other')) + '') * -1;
-      system.debug(rpc.get('SumPrice') + '--' + rpc.get('sales_discount') + '--' + rpc.get('contract_target') + '--' +
-             rpc.get('loaner_repair') + '--' + rpc.get('long_term_insurance') + '--' + rpc.get('set_discount') + '--' + rpc.get('long_term_insuranceMD')
-             + '--' + rpc.get('delivery') + '--' + rpc.get('other') + '--');
-      return SumPrice + sales_discount + contract_target + loaner_repair + long_term_insurance + sercince + set_discount + long_term_insuranceMD + delivery + other;
+        Decimal SumPrice = Decimal.valueOf(rpc.get('SumPrice') + '');
+        Decimal sales_discount = Decimal.valueOf((rpc.get('sales_discount') == null ? 0 : rpc.get('sales_discount')) + '') * -1;
+        Decimal contract_target = Decimal.valueOf((rpc.get('contract_target') == null ? 0 : rpc.get('contract_target')) + '') * -1;
+        Decimal loaner_repair = Decimal.valueOf((rpc.get('loaner_repair') == null ? 0 : rpc.get('loaner_repair')) + '') * -1;
+        Decimal long_term_insurance = Decimal.valueOf((rpc.get('long_term_insurance') == null ? 0 : rpc.get('long_term_insurance')) + '') * -1;
+        Decimal set_discount = Decimal.valueOf((rpc.get('set_discount') == null ? 0 : rpc.get('set_discount')) + '') * -1;
+        Decimal sercince = Decimal.valueOf((rpc.get('sercince') == null ? 0 : rpc.get('sercince')) + '') * -1;
+        Decimal long_term_insuranceMD = Decimal.valueOf((rpc.get('long_term_insuranceMD') == null ? 0 : rpc.get('long_term_insuranceMD')) + '') * -1;
+        Decimal delivery = Decimal.valueOf((rpc.get('delivery') == null ? 0 : rpc.get('delivery')) + '') * -1;
+        Decimal other = Decimal.valueOf((rpc.get('other') == null ? 0 : rpc.get('other')) + '') * -1;
+        system.debug(rpc.get('SumPrice') + '--' + rpc.get('sales_discount') + '--' + rpc.get('contract_target') + '--' +
+                     rpc.get('loaner_repair') + '--' + rpc.get('long_term_insurance') + '--' + rpc.get('set_discount') + '--' + rpc.get('long_term_insuranceMD')
+                     + '--' + rpc.get('delivery') + '--' + rpc.get('other') + '--');
+        return SumPrice + sales_discount + contract_target + loaner_repair + long_term_insurance + sercince + set_discount + long_term_insuranceMD + delivery + other;
     }
     
     
     //搴熷純涓�=========20161024==============//
     public void ShowLTYRepair() {
-      system.debug('ShowLTYRepair=====Start');
-      lastFriYearsPriceSum = 0;
-      lastSecYearsPriceSum = 0;
-      //
-      List<Maintenance_Contract_Estimate__c> McecList = new List<Maintenance_Contract_Estimate__c>();
-      McecList = [select
-            Last_Year_Repair_Sum__c,
-            Year_Before_Last_Year_Re_Sum__c,
-            Last_Two_Year_Repair_sum__c,
-            Process_Status__c,                            //鎶ヤ环鐘舵��
-            Repair_Sum_Compute_Date__c
-            from
-            Maintenance_Contract_Estimate__c
-            where
-            id = :targetEstimateId
-      ];
-      Maintenance_Contract_Estimate__c McecEle = new Maintenance_Contract_Estimate__c();
-      if (McecList.size() > 0) {
-        McecEle = McecList[0];
-        Date ComputeD = McecEle.Repair_Sum_Compute_Date__c == null ? Date.today() : McecEle.Repair_Sum_Compute_Date__c;
-        String DateString1 = ComputeD + '';
-        String DateString2 = ComputeD.addYears(-2).addDays(1) + '';
-        alertString = '闆嗚▓瀵捐薄鏈熼枔锛�' + DateString1.substring(0, 10) + '~' + DateString2.substring(0, 10) + '';
-        alertString2 = '鍘诲勾淇悊瀹熺妇鍚堣▓锛�' + McecEle.Last_Year_Repair_Sum__c + ' RMB ';
-        alertString3 = '鍓嶅勾淇悊瀹熺妇鍚堣▓锛�' + McecEle.Year_Before_Last_Year_Re_Sum__c + ' RMB';
-      } else {
-        alertString = '娌℃湁鏈夋晥鐨勭淮淇悎鍚屾姤浠�';
-      }
+        system.debug('ShowLTYRepair=====Start');
+        lastFriYearsPriceSum = 0;
+        lastSecYearsPriceSum = 0;
+        //
+        List<Maintenance_Contract_Estimate__c> McecList = new List<Maintenance_Contract_Estimate__c>();
+        McecList = [select
+                    Last_Year_Repair_Sum__c,
+                    Year_Before_Last_Year_Re_Sum__c,
+                    Last_Two_Year_Repair_sum__c,
+                    Process_Status__c,                            //鎶ヤ环鐘舵��
+                    Repair_Sum_Compute_Date__c
+                    from
+                    Maintenance_Contract_Estimate__c
+                    where
+                    id = :targetEstimateId
+        ];
+        Maintenance_Contract_Estimate__c McecEle = new Maintenance_Contract_Estimate__c();
+        if (McecList.size() > 0) {
+            McecEle = McecList[0];
+            Date ComputeD = McecEle.Repair_Sum_Compute_Date__c == null ? Date.today() : McecEle.Repair_Sum_Compute_Date__c;
+            String DateString1 = ComputeD + '';
+            String DateString2 = ComputeD.addYears(-2).addDays(1) + '';
+            alertString = '闆嗚▓瀵捐薄鏈熼枔锛�' + DateString1.substring(0, 10) + '~' + DateString2.substring(0, 10) + '';
+            alertString2 = '鍘诲勾淇悊瀹熺妇鍚堣▓锛�' + McecEle.Last_Year_Repair_Sum__c + ' RMB ';
+            alertString3 = '鍓嶅勾淇悊瀹熺妇鍚堣▓锛�' + McecEle.Year_Before_Last_Year_Re_Sum__c + ' RMB';
+        } else {
+            alertString = '娌℃湁鏈夋晥鐨勭淮淇悎鍚屾姤浠�';
+        }
     }
     /**
      * 鎵嬪嫊銇у晢鍝侀伕鎶炲緦銇儶銉曘儸銉冦偡銉�
      **/
     public void refreshProductData() {
-      System.debug('1535.......................杩涘叆refreshProductData鏂规硶');
-      System.debug('1536.......................杩涘叆refreshProductData鏂规硶');
-      for (Integer i = 0; i < checkedAssets.size(); i++) {
-        if (i == productIdx) {
-          AssetInfo ai = checkedAssets[i];
-          System.debug('--------:' + ai);
-          if (ai.mcae.Product_Manual__c == null) {
-            ai.mcae.Estimate_List_Price__c = null;
-            // add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� Star
-            ai.CheckRows = true;
-            // add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� End
-            System.debug('1540--');
-          } else {
-            //2021-02-04 mzy select璇彞鏌ヨ缁撴灉涓姞浜� NoPartRiskDate_F__c
-            List<Product2> prd = [select Id, Maintenance_Price_Month__c, EquipmentGuaranteeFlg__c, Name from Product2 where Id = :ai.mcae.Product_Manual__c];
-            ai.mcae.Estimate_List_Price__c = prd[0].Maintenance_Price_Month__c * isNewPriceAdj;
-            //ai.mcae.Maintenance_Price_YearTXT__c = ai.mcae.Estimate_List_Price__c * 12;
-            ai.orgPrice = prd[0].Maintenance_Price_Month__c;
-            ai.mcae.EquipmentGuaranteeFlgTxt__c = prd[0].EquipmentGuaranteeFlg__c;
-            ai.etGFlg = prd[0].EquipmentGuaranteeFlg__c;
-            //add by rentx 2020-11-12 LJPH-BV93RZ start
-            ai.proName = prd[0].Name;
-            //add by rentx 2020-11-12 LJPH-BV93RZ end
-            // add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� Star
-            ai.CheckRows = false;
-            // add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� End
-            //add by mzy 2021-02-04 LJPH-BX9CVX start
-            //ai.NoPartRiskDate = prd[0].NoPartRiskDate_F__c;
-            //ai.proName2 = prd[0].Name;
-            //ai.SignableFlag = prd[0].SignableFlag__c;
-            //add by mzy 2021-02-04 LJPH-BX9CVX end
-          }
+        System.debug('1535.......................杩涘叆refreshProductData鏂规硶');
+        System.debug('1536.......................杩涘叆refreshProductData鏂规硶');
+        for (Integer i = 0; i < checkedAssets.size(); i++) {
+            if (i == productIdx) {
+                AssetInfo ai = checkedAssets[i];
+                System.debug('--------:' + ai);
+                if (ai.mcae.Product_Manual__c == null) {
+                    ai.mcae.Estimate_List_Price__c = null;
+                    // add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� Star
+                    ai.CheckRows = true;
+                    // add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� End
+                    System.debug('1540--');
+                } else {
+                    //2021-02-04 mzy select璇彞鏌ヨ缁撴灉涓姞浜� NoPartRiskDate_F__c
+                    List<Product2> prd = [select Id, Maintenance_Price_Month__c, EquipmentGuaranteeFlg__c, Name from Product2 where Id = :ai.mcae.Product_Manual__c];
+                    ai.mcae.Estimate_List_Price__c = prd[0].Maintenance_Price_Month__c * isNewPriceAdj;
+                    //ai.mcae.Maintenance_Price_YearTXT__c = ai.mcae.Estimate_List_Price__c * 12;
+                    ai.orgPrice = prd[0].Maintenance_Price_Month__c;
+                    ai.mcae.EquipmentGuaranteeFlgTxt__c = prd[0].EquipmentGuaranteeFlg__c;
+                    ai.etGFlg = prd[0].EquipmentGuaranteeFlg__c;
+                    //add by rentx 2020-11-12 LJPH-BV93RZ start
+                    ai.proName = prd[0].Name;
+                    //add by rentx 2020-11-12 LJPH-BV93RZ end
+                    // add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� Star
+                    ai.CheckRows = false;
+                    // add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� End
+                    //add by mzy 2021-02-04 LJPH-BX9CVX start
+                    //ai.NoPartRiskDate = prd[0].NoPartRiskDate_F__c;
+                    //ai.proName2 = prd[0].Name;
+                    //ai.SignableFlag = prd[0].SignableFlag__c;
+                    //add by mzy 2021-02-04 LJPH-BX9CVX end
+                }
+            }
         }
-      }
-      // HWAG-BA73ZP
-      //contractStartDateChange();
+        // HWAG-BA73ZP
+        //contractStartDateChange();
     }
     
     /**
      * 閬告姙娓堛伩锛忔湭閬告姙瑁藉搧銇疆銇嶆彌銇�
      */
     public PageReference exchangeAsset() {
-      System.debug('exchangeAsset start');
-      Date systemToday = System.today();
-      List<AssetInfo> tmpChecked = new List<AssetInfo>();
-      List<AssetInfo> tmpNewRows = new List<AssetInfo>();
-      List<AssetInfo> tmpUnChecked = new List<AssetInfo>();
-      List<Data> datatemp = new List<Data>();
-      datatemp = getChartData();
-      for (AssetInfo ass : this.checkedAssets) {
-        if (ass.isManual) {
-          tmpNewRows.add(ass);
-        } else if (ass.rec_checkBox_c) {
-          tmpChecked.add(ass);
-        } else {
-          ass.mcae = null;
-          tmpUnChecked.add(ass);
-          totalRecords++;
-        }
-      }
-      for (AssetInfo ass : this.unCheckedAssets) {
-        Boolean isNew = false;
-        // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk Star
-        boolean isCheck = true;
-        // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk End
-        Decimal listPrice = ass.rec.Maintenance_Price_Month__c;
-        if (ass.rec_checkBox_c) {
-          //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO , 'unCheckedAssets ' ));
-          // xudan 20160110 鏂板搧鍒ゆ柇銇撱亾瑕併倝銇亜銆乧ontractStartDateChange銇屻倓銈�
-          //                if (systemToday.addMonths(-6) < ass.rec.InstallDate) {
-          //                if (estimate.Contract_Esti_Start_Date__c.addMonths(isNewAddMonth) < ass.rec.InstallDate) {
-          //                Date createdDate = estimate.CreatedDate == null ? systemToday : estimate.CreatedDate.date();
-          //                if (createdDate.addMonths(isNewAddMonth) < ass.rec.InstallDate) {
-          //                    isNew = true;
-          //                    listPrice = ass.rec.Maintenance_Price_Month__c * isNewPriceAdj;
-          //                }
-          Maintenance_Contract_Asset_Estimate__c mcae = new Maintenance_Contract_Asset_Estimate__c(
-            isNew__c = isNew,
-            // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk Star
-            Check_Object__c = isCheck,
-            // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk end
-            Estimate_List_Price__c = listPrice,
-            EquipmentGuaranteeFlgTxt__c = ass.rec.EquipmentGuaranteeFlg__c
-            );
-          ass.mcae = mcae;
-          // 璁$畻涓婁笅绾胯皟鏁存瘮渚�
-          if (!getPageDisabled()) {
-            // 鍙栧綋鍓嶆湀绗竴澶�
-            Date mon1stDate = Date.newInstance(Date.today().year(), Date.today().month(), 1);
-            mcae.LastMContract_Price__c = ass.rec.CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c == null ? mcae.LastMContract_Price__c : ass.rec.CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c;
-            if (ass.rec.CurrentContract_F__r.First_Estimate_Date__c != null && ass.rec.CurrentContract_F__r.Estimate_Contract_endDate__c > mon1stDate) {
-              mcae.Asset_Consumption_rate__c = ass.rec.CurrentContract_F__r.First_contract_usage_Rate__c == null ? mcae.Asset_Consumption_rate__c : ass.rec.CurrentContract_F__r.First_contract_usage_Rate__c;
+        System.debug('exchangeAsset start');
+        Date systemToday = System.today();
+        List<AssetInfo> tmpChecked = new List<AssetInfo>();
+        List<AssetInfo> tmpNewRows = new List<AssetInfo>();
+        List<AssetInfo> tmpUnChecked = new List<AssetInfo>();
+        List<Data> datatemp = new List<Data>();
+        datatemp = getChartData();
+        for (AssetInfo ass : this.checkedAssets) {
+            if (ass.isManual) {
+                tmpNewRows.add(ass);
+            } else if (ass.rec_checkBox_c) {
+                tmpChecked.add(ass);
             } else {
-              mcae.Asset_Consumption_rate__c = ass.rec.CurrentContract_F__r.Contract_Consumption_rate__c == null ? mcae.Asset_Consumption_rate__c : ass.rec.CurrentContract_F__r.Contract_Consumption_rate__c;
+                ass.mcae = null;
+                tmpUnChecked.add(ass);
+                totalRecords++;
             }
-            if (String.isNotBlank(String.valueOf(mcae.Asset_Consumption_rate__c))) {
-              for (Data da : datatemp) {
-                if (String.isBlank(String.valueOf(da.rate_Lower)) &&  mcae.Asset_Consumption_rate__c < da.rate_Upper) {
-                  mcae.Adjustment_ratio_Lower__c = da.price_Lower;
-                  mcae.Adjustment_ratio_Upper__c = da.price_Upper;
-                  continue;
-                } else if (mcae.Asset_Consumption_rate__c >= da.rate_Lower && String.isBlank(String.valueOf(da.rate_Upper))) {
-                  mcae.Adjustment_ratio_Lower__c = da.price_Lower;
-                  mcae.Adjustment_ratio_Upper__c = da.price_Upper;
-                  continue;
-                } else if (mcae.Asset_Consumption_rate__c >= da.rate_Lower
-                       && mcae.Asset_Consumption_rate__c < da.rate_Upper) {
-                  mcae.Adjustment_ratio_Lower__c = da.price_Lower;
-                  mcae.Adjustment_ratio_Upper__c = da.price_Upper;
-                  continue;
-                }
-              }
-            }
-          }
-    
-    
-    
-          tmpChecked.add(ass);
-          totalRecords--;
-        } else {
-          ass.mcae = null;
-          tmpUnChecked.add(ass);
         }
-      }
+        for (AssetInfo ass : this.unCheckedAssets) {
+            Boolean isNew = false;
+            // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk Star
+            boolean isCheck = true;
+            // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk End
+            Decimal listPrice = ass.rec.Maintenance_Price_Month__c;
+            if (ass.rec_checkBox_c) {
+                //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO , 'unCheckedAssets ' ));
+                // xudan 20160110 鏂板搧鍒ゆ柇銇撱亾瑕併倝銇亜銆乧ontractStartDateChange銇屻倓銈�
+                //                if (systemToday.addMonths(-6) < ass.rec.InstallDate) {
+                //                if (estimate.Contract_Esti_Start_Date__c.addMonths(isNewAddMonth) < ass.rec.InstallDate) {
+                //                Date createdDate = estimate.CreatedDate == null ? systemToday : estimate.CreatedDate.date();
+                //                if (createdDate.addMonths(isNewAddMonth) < ass.rec.InstallDate) {
+                //                    isNew = true;
+                //                    listPrice = ass.rec.Maintenance_Price_Month__c * isNewPriceAdj;
+                //                }
+                Maintenance_Contract_Asset_Estimate__c mcae = new Maintenance_Contract_Asset_Estimate__c(
+                    isNew__c = isNew,
+                    // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk Star
+                    Check_Object__c = isCheck,
+                    // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk end
+                    Estimate_List_Price__c = listPrice,
+                    EquipmentGuaranteeFlgTxt__c = ass.rec.EquipmentGuaranteeFlg__c
+                    );
+                ass.mcae = mcae;
+                // 璁$畻涓婁笅绾胯皟鏁存瘮渚�
+                if (!getPageDisabled()) {
+                    // 鍙栧綋鍓嶆湀绗竴澶�
+                    Date mon1stDate = Date.newInstance(Date.today().year(), Date.today().month(), 1);
+                    mcae.LastMContract_Price__c = ass.rec.CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c == null ? mcae.LastMContract_Price__c : ass.rec.CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c;
+                    if (ass.rec.CurrentContract_F__r.First_Estimate_Date__c != null && ass.rec.CurrentContract_F__r.Estimate_Contract_endDate__c > mon1stDate) {
+                        mcae.Asset_Consumption_rate__c = ass.rec.CurrentContract_F__r.First_contract_usage_Rate__c == null ? mcae.Asset_Consumption_rate__c : ass.rec.CurrentContract_F__r.First_contract_usage_Rate__c;
+                    } else {
+                        mcae.Asset_Consumption_rate__c = ass.rec.CurrentContract_F__r.Contract_Consumption_rate__c == null ? mcae.Asset_Consumption_rate__c : ass.rec.CurrentContract_F__r.Contract_Consumption_rate__c;
+                    }
+                    if (String.isNotBlank(String.valueOf(mcae.Asset_Consumption_rate__c))) {
+                        for (Data da : datatemp) {
+                            if (String.isBlank(String.valueOf(da.rate_Lower)) &&  mcae.Asset_Consumption_rate__c < da.rate_Upper) {
+                                mcae.Adjustment_ratio_Lower__c = da.price_Lower;
+                                mcae.Adjustment_ratio_Upper__c = da.price_Upper;
+                                continue;
+                            } else if (mcae.Asset_Consumption_rate__c >= da.rate_Lower && String.isBlank(String.valueOf(da.rate_Upper))) {
+                                mcae.Adjustment_ratio_Lower__c = da.price_Lower;
+                                mcae.Adjustment_ratio_Upper__c = da.price_Upper;
+                                continue;
+                            } else if (mcae.Asset_Consumption_rate__c >= da.rate_Lower
+                                       && mcae.Asset_Consumption_rate__c < da.rate_Upper) {
+                                mcae.Adjustment_ratio_Lower__c = da.price_Lower;
+                                mcae.Adjustment_ratio_Upper__c = da.price_Upper;
+                                continue;
+                            }
+                        }
+                    }
+                }
     
-      this.checkedAssets = new List<AssetInfo>();
-      for (AssetInfo ass : tmpChecked) {
-        ass.lineNo = this.checkedAssets.size();
-        this.checkedAssets.add(ass);
-      }
-      for (AssetInfo ass : tmpNewRows) {
-        ass.lineNo = this.checkedAssets.size();
-        this.checkedAssets.add(ass);
-      }
-      this.unCheckedAssets = new List<AssetInfo>();
-      this.unCheckedAssets.addAll(tmpUnChecked);
     
-      totalPage = (totalRecords / selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
-      this.setPageRecord();
     
-      //listCut(unCheckedAssets);
-      // 鏍规嵁鍚堝悓寮�濮嬫棩閲嶆柊璁$畻缁翠慨鍚堝悓浠锋牸
-      //contractStartDateChange();
-      return null;
+                tmpChecked.add(ass);
+                totalRecords--;
+            } else {
+                ass.mcae = null;
+                tmpUnChecked.add(ass);
+            }
+        }
+    
+        this.checkedAssets = new List<AssetInfo>();
+        for (AssetInfo ass : tmpChecked) {
+            ass.lineNo = this.checkedAssets.size();
+            this.checkedAssets.add(ass);
+        }
+        for (AssetInfo ass : tmpNewRows) {
+            ass.lineNo = this.checkedAssets.size();
+            this.checkedAssets.add(ass);
+        }
+        this.unCheckedAssets = new List<AssetInfo>();
+        this.unCheckedAssets.addAll(tmpUnChecked);
+    
+        totalPage = (totalRecords / selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
+        this.setPageRecord();
+    
+        //listCut(unCheckedAssets);
+        // 鏍规嵁鍚堝悓寮�濮嬫棩閲嶆柊璁$畻缁翠慨鍚堝悓浠锋牸
+        //contractStartDateChange();
+        return null;
     }
     
     // 鍚堝悓寮�濮嬫棩鍙樻洿锛岄噸鏂拌绠楁柊鍝�
@@ -1906,122 +1911,122 @@
      * 淇濆瓨銉°偨銉冦儔
      */
     public PageReference save() {
-      System.debug('save start');
-      //add by rentx 2020-11-13 LJPH-BV93RZ start
-      if (estimate.Contract_Range__c == null) {
-        this.estimate.Contract_Range__c.addError('蹇呴』杈撳叆鍚堝悓鏈堟暟!');
-        return null;
-      }
-      //add by rentx 2020-11-13 LJPH-BV93RZ end
+        System.debug('save start');
+        //add by rentx 2020-11-13 LJPH-BV93RZ start
+        if (estimate.Contract_Range__c == null) {
+            this.estimate.Contract_Range__c.addError('蹇呴』杈撳叆鍚堝悓鏈堟暟!');
+            return null;
+        }
+        //add by rentx 2020-11-13 LJPH-BV93RZ end
     
     
-      Id vmMaintenance_Contract = Schema.SObjectType.Maintenance_Contract_Estimate__c.getRecordTypeInfosByDeveloperName().get('NewMaintenance_Quote').getRecordTypeId();
-      estimate.recordtypeid = vmMaintenance_Contract;
-      if (changedSubmitPrice) {
-        priceChangeReset();
+        Id vmMaintenance_Contract = Schema.SObjectType.Maintenance_Contract_Estimate__c.getRecordTypeInfosByDeveloperName().get('NewMaintenance_Quote').getRecordTypeId();
+        estimate.recordtypeid = vmMaintenance_Contract;
+        if (changedSubmitPrice) {
+            priceChangeReset();
+            return null;
+        }
+        if (syncEstimate(false, false)) {
+            ComputeLTYRepair();
+            //return null;
+            return new PageReference('/' + this.targetEstimateId + '/e?completion=5');
+        }
         return null;
-      }
-      if (syncEstimate(false, false)) {
-        ComputeLTYRepair();
-        //return null;
-        return new PageReference('/' + this.targetEstimateId + '/e?completion=5');
-      }
-      return null;
     }
     
     /**
      * 鍗板埛銉°偨銉冦儔銆乨ecide鍓嶃伅淇濇湁瑷倷銆乨ecide寰屻伅鍚堝悓閰嶇疆
      */
     public void print() {
-      System.debug('print start');
-      this.printAsset = false;
-      this.printContract = false;
-      this.printTripartite = false;
-      this.printAgent = false;
-      this.estimate.PrintDate__c = Date.today();
-      //SelectAssetEstimateVMController.ComputeLTYRepair(targetEstimateId);
-      if (this.estimate.Quote_Date__c == null) {
-        this.estimate.Quote_Date__c = Date.today();
-      }
-    
-    
-    
-      if (this.estimate.Print_Tripartite__c && this.estimate.Print_Agent__c) {
-        ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '涓嶈兘鍚屾椂閫変腑涓夋柟鍗忚鍜屼唬鐞嗗晢鍚堝悓锛�'));
-      } else
-    
-    
-      // 淇濆瓨銉溿偪銉炽仹銇嶃仾銇勫牬鍚堛�佸嵃鍒枫儨銈裤兂銇儠銉┿偘銇伩淇濆瓨
-      if (this.getSaveBtnDisabled()) {
-        if (savePrintFlg()) {
-          // 2018/10/26 HWAG-B5C88S 鍘熸潵鎵撳嵃閫昏緫 start
-          /*if (this.estimate.Print_Contract__c && !this.estimate.Print_Tripartite__c && !this.estimate.Print_Agent__c) {
-              // 鎵撳嵃鍖婚櫌鍚堝悓閰嶇疆
-              this.printContract = true;
-             } else if(this.estimate.Print_Tripartite__c && !this.estimate.Print_Agent__c){
-              //鎵撳嵃涓夋柟鍚堝悓
-              this.printTripartite = true;
-             } else if(!this.estimate.Print_Tripartite__c && this.estimate.Print_Agent__c){
-              //鎵撳嵃缁忛攢鍟嗗悎鍚�
-              this.printAgent = true;
-             }else{
-              // 鎵撳嵃淇濇湁瑷倷
-              this.printAsset = true;
-             }*/
-          // 2018/10/26 HWAG-B5C88S 鍘熸潵鎵撳嵃閫昏緫 end
-          // 2018/10/26 HWAG-B5C88S start 閫夋嫨涓夋柟鎵撳嵃涓夋柟锛屽惁鍒檇ecide鍓嶆墦鍗颁繚鏈夎澶囷紝decide鍚庢牴鎹姤浠峰璞℃墦鍗板尰闄㈡垨缁忛攢鍟嗗悎鍚�
-          if (this.estimate.Print_Tripartite__c ) {
-            //鎵撳嵃涓夋柟鍚堝悓
-            this.printTripartite = true;
-          } else if (!this.estimate.Estimation_Decision__c) {
-            this.printAsset = true;
-    
-          } else if (this.estimate.Estimate_Target__c != null && this.estimate.Estimate_Target__c.equals('鍖婚櫌')) {
-            this.printContract = true;
-    
-          } else if (this.estimate.Estimate_Target__c != null && this.estimate.Estimate_Target__c.equals('缁忛攢鍟�')) {
-            this.printAgent = true;
-          }
-          // 2018/10/26 HWAG-B5C88S end
+        System.debug('print start');
+        this.printAsset = false;
+        this.printContract = false;
+        this.printTripartite = false;
+        this.printAgent = false;
+        this.estimate.PrintDate__c = Date.today();
+        //SelectAssetEstimateVMController.ComputeLTYRepair(targetEstimateId);
+        if (this.estimate.Quote_Date__c == null) {
+            this.estimate.Quote_Date__c = Date.today();
         }
-      }
-      // 淇濆瓨銉溿偪銉炽仹銇嶃倠鍫村悎銆佸嵃鍒枫儨銈裤兂銇叏閮ㄤ繚瀛�
-      else {
-        if (syncEstimate(false, false)) {
-          // 2018/10/26 HWAG-B5C88S 鍘熸潵鎵撳嵃閫昏緫 start
-          /*
-             if (this.estimate.Print_Contract__c && !this.estimate.Print_Tripartite__c && !this.estimate.Print_Agent__c) {
-              // 鎵撳嵃鍖婚櫌鍚堝悓閰嶇疆
-              this.printContract = true;
-             } else if(this.estimate.Print_Tripartite__c && !this.estimate.Print_Agent__c){
-              //鎵撳嵃涓夋柟鍚堝悓
-              this.printTripartite = true;
-             } else if(!this.estimate.Print_Tripartite__c && this.estimate.Print_Agent__c){
-              //鎵撳嵃缁忛攢鍟嗗悎鍚�
-              this.printAgent = true;
-             }else{
-              // 鎵撳嵃淇濇湁瑷倷
-              this.printAsset = true;
-             }
-           */
-          // 2018/10/26 HWAG-B5C88S 鍘熸潵鎵撳嵃閫昏緫 end
-          // 2018/10/26 HWAG-B5C88S start 閫夋嫨涓夋柟鎵撳嵃涓夋柟锛屽惁鍒檇ecide鍓嶆墦鍗颁繚鏈夎澶囷紝decide鍚庢牴鎹姤浠峰璞℃墦鍗板尰闄㈡垨缁忛攢鍟嗗悎鍚�
-          if (this.estimate.Print_Tripartite__c ) {
-            //鎵撳嵃涓夋柟鍚堝悓
-            this.printTripartite = true;
-          } else if (!this.estimate.Estimation_Decision__c) {
-            this.printAsset = true;
     
-          } else if (this.estimate.Estimate_Target__c != null && this.estimate.Estimate_Target__c.equals('鍖婚櫌')) {
-            this.printContract = true;
     
-          } else if (this.estimate.Estimate_Target__c != null && this.estimate.Estimate_Target__c.equals('缁忛攢鍟�')) {
-            this.printAgent = true;
-          }
-          // 2018/10/26 HWAG-B5C88S end
+    
+        if (this.estimate.Print_Tripartite__c && this.estimate.Print_Agent__c) {
+            ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '涓嶈兘鍚屾椂閫変腑涓夋柟鍗忚鍜屼唬鐞嗗晢鍚堝悓锛�'));
+        } else
+    
+    
+        // 淇濆瓨銉溿偪銉炽仹銇嶃仾銇勫牬鍚堛�佸嵃鍒枫儨銈裤兂銇儠銉┿偘銇伩淇濆瓨
+        if (this.getSaveBtnDisabled()) {
+            if (savePrintFlg()) {
+                // 2018/10/26 HWAG-B5C88S 鍘熸潵鎵撳嵃閫昏緫 start
+                /*if (this.estimate.Print_Contract__c && !this.estimate.Print_Tripartite__c && !this.estimate.Print_Agent__c) {
+                        // 鎵撳嵃鍖婚櫌鍚堝悓閰嶇疆
+                        this.printContract = true;
+                   } else if(this.estimate.Print_Tripartite__c && !this.estimate.Print_Agent__c){
+                        //鎵撳嵃涓夋柟鍚堝悓
+                        this.printTripartite = true;
+                   } else if(!this.estimate.Print_Tripartite__c && this.estimate.Print_Agent__c){
+                        //鎵撳嵃缁忛攢鍟嗗悎鍚�
+                        this.printAgent = true;
+                   }else{
+                        // 鎵撳嵃淇濇湁瑷倷
+                        this.printAsset = true;
+                   }*/
+                // 2018/10/26 HWAG-B5C88S 鍘熸潵鎵撳嵃閫昏緫 end
+                // 2018/10/26 HWAG-B5C88S start 閫夋嫨涓夋柟鎵撳嵃涓夋柟锛屽惁鍒檇ecide鍓嶆墦鍗颁繚鏈夎澶囷紝decide鍚庢牴鎹姤浠峰璞℃墦鍗板尰闄㈡垨缁忛攢鍟嗗悎鍚�
+                if (this.estimate.Print_Tripartite__c ) {
+                    //鎵撳嵃涓夋柟鍚堝悓
+                    this.printTripartite = true;
+                } else if (!this.estimate.Estimation_Decision__c) {
+                    this.printAsset = true;
+    
+                } else if (this.estimate.Estimate_Target__c != null && this.estimate.Estimate_Target__c.equals('鍖婚櫌')) {
+                    this.printContract = true;
+    
+                } else if (this.estimate.Estimate_Target__c != null && this.estimate.Estimate_Target__c.equals('缁忛攢鍟�')) {
+                    this.printAgent = true;
+                }
+                // 2018/10/26 HWAG-B5C88S end
+            }
         }
-      }
-      //ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '鍚堝悓'+this.printContract +'涓夋柟'+this.printTripartite+'淇濇湁'+this.printAsset+'缁忛攢鍟嗗悎鍚�'+this.printAgent));
+        // 淇濆瓨銉溿偪銉炽仹銇嶃倠鍫村悎銆佸嵃鍒枫儨銈裤兂銇叏閮ㄤ繚瀛�
+        else {
+            if (syncEstimate(false, false)) {
+                // 2018/10/26 HWAG-B5C88S 鍘熸潵鎵撳嵃閫昏緫 start
+                /*
+                   if (this.estimate.Print_Contract__c && !this.estimate.Print_Tripartite__c && !this.estimate.Print_Agent__c) {
+                        // 鎵撳嵃鍖婚櫌鍚堝悓閰嶇疆
+                        this.printContract = true;
+                   } else if(this.estimate.Print_Tripartite__c && !this.estimate.Print_Agent__c){
+                        //鎵撳嵃涓夋柟鍚堝悓
+                        this.printTripartite = true;
+                   } else if(!this.estimate.Print_Tripartite__c && this.estimate.Print_Agent__c){
+                        //鎵撳嵃缁忛攢鍟嗗悎鍚�
+                        this.printAgent = true;
+                   }else{
+                        // 鎵撳嵃淇濇湁瑷倷
+                        this.printAsset = true;
+                   }
+                 */
+                // 2018/10/26 HWAG-B5C88S 鍘熸潵鎵撳嵃閫昏緫 end
+                // 2018/10/26 HWAG-B5C88S start 閫夋嫨涓夋柟鎵撳嵃涓夋柟锛屽惁鍒檇ecide鍓嶆墦鍗颁繚鏈夎澶囷紝decide鍚庢牴鎹姤浠峰璞℃墦鍗板尰闄㈡垨缁忛攢鍟嗗悎鍚�
+                if (this.estimate.Print_Tripartite__c ) {
+                    //鎵撳嵃涓夋柟鍚堝悓
+                    this.printTripartite = true;
+                } else if (!this.estimate.Estimation_Decision__c) {
+                    this.printAsset = true;
+    
+                } else if (this.estimate.Estimate_Target__c != null && this.estimate.Estimate_Target__c.equals('鍖婚櫌')) {
+                    this.printContract = true;
+    
+                } else if (this.estimate.Estimate_Target__c != null && this.estimate.Estimate_Target__c.equals('缁忛攢鍟�')) {
+                    this.printAgent = true;
+                }
+                // 2018/10/26 HWAG-B5C88S end
+            }
+        }
+        //ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '鍚堝悓'+this.printContract +'涓夋柟'+this.printTripartite+'淇濇湁'+this.printAsset+'缁忛攢鍟嗗悎鍚�'+this.printAgent));
     }
     
     /**
@@ -2030,64 +2035,64 @@
     public PageReference approvalProcess() {
     
     
-      Id vmMaintenance_Contract = Schema.SObjectType.Maintenance_Contract_Estimate__c.getRecordTypeInfosByDeveloperName().get('NewMaintenance_Quote').getRecordTypeId();
-      estimate.recordtypeid = vmMaintenance_Contract;
+        Id vmMaintenance_Contract = Schema.SObjectType.Maintenance_Contract_Estimate__c.getRecordTypeInfosByDeveloperName().get('NewMaintenance_Quote').getRecordTypeId();
+        estimate.recordtypeid = vmMaintenance_Contract;
     
-      // Date systemToday = System.today();
-      // // 鍒涘缓鏃�/鎻愪氦鏃�
-      // Date createdDate = systemToday;
-      // // 鍒涘缓鏃�6涓湀
-      // Date isNewAfter = createdDate.addMonths(-isNewAddMonth);
-      // // 鍚堝悓寮�濮嬮瀹氭棩
-      // Date contractEstiDate = estimate.Contract_Esti_Start_Date__c == null ? systemToday : estimate.Contract_Esti_Start_Date__c;
-      //  for (AssetInfo info : checkedAssets) {
-      //       // 鍚堝悓棰勫畾寮�濮嬫棩 澶т簬鎻愪氦鏃�6涓湀锛岄兘涓嶇畻鏂板搧 20200218 Gzw 鏈嶅姟鍚堝悓瀵瑰簲
-      //       //ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, 'contractEstiDate '+ contractEstiDate +'isNewAfter '+isNewAfter));
-      //       if (contractEstiDate >= isNewAfter) {
-      //           if (!info.isManual) {
-      //               info.mcae.isNew__c = false;
-      //               info.mcae.Estimate_List_Price__c = info.orgPrice;
-      //            } else if (info.isManual && !String.isBlank(info.mcae.Product_Manual__c)) {
-      //               info.mcae.isNew__c = false;
-      //               info.mcae.Estimate_List_Price__c = info.orgPrice;
-      //            }
-      //        }
-      // }
+        // Date systemToday = System.today();
+        // // 鍒涘缓鏃�/鎻愪氦鏃�
+        // Date createdDate = systemToday;
+        // // 鍒涘缓鏃�6涓湀
+        // Date isNewAfter = createdDate.addMonths(-isNewAddMonth);
+        // // 鍚堝悓寮�濮嬮瀹氭棩
+        // Date contractEstiDate = estimate.Contract_Esti_Start_Date__c == null ? systemToday : estimate.Contract_Esti_Start_Date__c;
+        //  for (AssetInfo info : checkedAssets) {
+        //       // 鍚堝悓棰勫畾寮�濮嬫棩 澶т簬鎻愪氦鏃�6涓湀锛岄兘涓嶇畻鏂板搧 20200218 Gzw 鏈嶅姟鍚堝悓瀵瑰簲
+        //       //ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, 'contractEstiDate '+ contractEstiDate +'isNewAfter '+isNewAfter));
+        //       if (contractEstiDate >= isNewAfter) {
+        //           if (!info.isManual) {
+        //               info.mcae.isNew__c = false;
+        //               info.mcae.Estimate_List_Price__c = info.orgPrice;
+        //            } else if (info.isManual && !String.isBlank(info.mcae.Product_Manual__c)) {
+        //               info.mcae.isNew__c = false;
+        //               info.mcae.Estimate_List_Price__c = info.orgPrice;
+        //            }
+        //        }
+        // }
     
-      if (changedSubmitPrice) {
-        priceChangeReset();
-        return null;
-      }
-    
-    
-      if (syncEstimate(true, false)) {
-        Savepoint sp = Database.setSavepoint();
-        // 鎵胯獚銉椼儹銈汇偣銇級銇涖倠
-        try {
-    
-          // 宸插~鍐欑敵璇风姸鎬�
-          this.estimate.ApprovalProcess_Status__c = '宸插~鍐欏畬骞剁敵璇�';
-          ControllerUtil.updateMaintenance_Contract_Estimate(new Maintenance_Contract_Estimate__c[] {this.estimate});
-          // 鎵胯獚銉椼儹銈汇偣
-          Approval.ProcessSubmitRequest psr = new Approval.ProcessSubmitRequest();
-          psr.setObjectId(this.estimate.id);
-          Approval.ProcessResult submitResult = Approval.process(psr);
-          ComputeLTYRepair();
-          if (changedAfterPrint) {
-            return new PageReference('/' + this.targetEstimateId);
-            //return new PageReference('/' + this.targetEstimateId + '/e?completion=1');
-          } else {
-            return new PageReference('/' + this.targetEstimateId);
-            //return new PageReference('/' + this.targetEstimateId + '/e?completion=2');
-          }
-        } catch (Exception ex) {
-          System.debug('=====Exception:' + ex.getMessage());
-          Database.rollback(sp);
-          this.estimate.ApprovalProcess_Status__c = null;
-          ApexPages.addMessages(ex);
+        if (changedSubmitPrice) {
+            priceChangeReset();
+            return null;
         }
-      }
-      return null;
+    
+    
+        if (syncEstimate(true, false)) {
+            Savepoint sp = Database.setSavepoint();
+            // 鎵胯獚銉椼儹銈汇偣銇級銇涖倠
+            try {
+    
+                // 宸插~鍐欑敵璇风姸鎬�
+                this.estimate.ApprovalProcess_Status__c = '宸插~鍐欏畬骞剁敵璇�';
+                ControllerUtil.updateMaintenance_Contract_Estimate(new Maintenance_Contract_Estimate__c[] {this.estimate});
+                // 鎵胯獚銉椼儹銈汇偣
+                Approval.ProcessSubmitRequest psr = new Approval.ProcessSubmitRequest();
+                psr.setObjectId(this.estimate.id);
+                Approval.ProcessResult submitResult = Approval.process(psr);
+                ComputeLTYRepair();
+                if (changedAfterPrint) {
+                    return new PageReference('/' + this.targetEstimateId);
+                    //return new PageReference('/' + this.targetEstimateId + '/e?completion=1');
+                } else {
+                    return new PageReference('/' + this.targetEstimateId);
+                    //return new PageReference('/' + this.targetEstimateId + '/e?completion=2');
+                }
+            } catch (Exception ex) {
+                System.debug('=====Exception:' + ex.getMessage());
+                Database.rollback(sp);
+                this.estimate.ApprovalProcess_Status__c = null;
+                ApexPages.addMessages(ex);
+            }
+        }
+        return null;
     }
     
     /**
@@ -2096,51 +2101,51 @@
     public PageReference undecide() {
     
     
-      System.debug('undecide start');
-      this.estimate.Estimation_Decision__c = false;
-      this.estimate.Print_Contract__c = false;
+        System.debug('undecide start');
+        this.estimate.Estimation_Decision__c = false;
+        this.estimate.Print_Contract__c = false;
     
-      //娓呯┖鎶ヤ环鎵瑰噯鏃堕棿
-      this.estimate.Quotation_Determines_Time__c = null;
+        //娓呯┖鎶ヤ环鎵瑰噯鏃堕棿
+        this.estimate.Quotation_Determines_Time__c = null;
     
-      try {
-        ControllerUtil.updateMaintenance_Contract_Estimate(new Maintenance_Contract_Estimate__c[] {this.estimate});
-        return new PageReference('/' + this.targetEstimateId + '/e?completion=1');
-      } catch (Exception ex) {
-        ApexPages.addMessages(ex);
-      }
-      return null;
+        try {
+            ControllerUtil.updateMaintenance_Contract_Estimate(new Maintenance_Contract_Estimate__c[] {this.estimate});
+            return new PageReference('/' + this.targetEstimateId + '/e?completion=1');
+        } catch (Exception ex) {
+            ApexPages.addMessages(ex);
+        }
+        return null;
     }
     
     /**
      * 姹哄畾銉°偨銉冦儔
      */
     public PageReference decide() {
-      System.debug('decide start');
-      inDicideFlag = true;
-      // TODO check decide 璧勬牸
-      Savepoint sp = Database.setSavepoint();
-      // gzw cputimeout 鎶ラ敊娣诲姞 20210729 start
-      Oly_TriggerHandler.bypass('AssetHandler');
-      StaticParameter.EscapeVMCTrigger = true;
-      // gzw cputimeout 鎶ラ敊娣诲姞 20210729 end
-      if (syncEstimate(false, true)) {
-        //鎻愪氦 鎶ヤ环鍐冲畾鏃ユ湡
-        this.estimate.Quotation_Determines_Time__c = date.today();
+        System.debug('decide start');
+        inDicideFlag = true;
+        // TODO check decide 璧勬牸
+        Savepoint sp = Database.setSavepoint();
+        // gzw cputimeout 鎶ラ敊娣诲姞 20210729 start
+        Oly_TriggerHandler.bypass('AssetHandler');
+        StaticParameter.EscapeVMCTrigger = true;
+        // gzw cputimeout 鎶ラ敊娣诲姞 20210729 end
+        if (syncEstimate(false, true)) {
+            //鎻愪氦 鎶ヤ环鍐冲畾鏃ユ湡
+            this.estimate.Quotation_Determines_Time__c = date.today();
     
-        if (changedAfterPrint) {
-          return new PageReference('/' + this.targetEstimateId + '/e?completion=1');
-        } else {
-          return new PageReference('/' + this.targetEstimateId + '/e?completion=3');
+            if (changedAfterPrint) {
+                return new PageReference('/' + this.targetEstimateId + '/e?completion=1');
+            } else {
+                return new PageReference('/' + this.targetEstimateId + '/e?completion=3');
+            }
         }
-      }
     
-      return null;
+        return null;
     }
     
     public PageReference decideCancle() {
     
-      return new PageReference('/' + this.targetEstimateId + '/e?completion=4');
+        return new PageReference('/' + this.targetEstimateId + '/e?completion=4');
     
     }
     
@@ -2149,13 +2154,13 @@
      */
     
     private void setApprovalManager() {
-      User loginUser = [SELECT Id, Name, JingliApprovalManager__c, BuchangApprovalManager__c, ZongjianApprovalManager__c, TongkuoZongjian__c FROM User WHERE Id = :UserInfo.getUserId()];
-      // 瑕佹敞鎰� SaveMaintenanceByCopyController 銇� copy銇畊rl銇倐銆佷笅瑷樸伄闋呯洰銈傘偗銉偄
-      this.estimate.JingliApprovalManager__c = loginUser.JingliApprovalManager__c == null ? loginUser.Id : loginUser.JingliApprovalManager__c;
-      this.estimate.BuchangApprovalManager__c = loginUser.BuchangApprovalManager__c == null ? loginUser.Id : loginUser.BuchangApprovalManager__c;
-      this.estimate.ZongjianApprovalManager__c = loginUser.ZongjianApprovalManager__c == null ? loginUser.Id : loginUser.ZongjianApprovalManager__c;
-      this.estimate.Service_Contract_Staff__c = this.contract.Service_Contract_Staff__c;
-      this.estimate.TKZongjianApprovalManager__c = loginUser.TongkuoZongjian__c == null ? loginUser.Id : loginUser.TongkuoZongjian__c;
+        User loginUser = [SELECT Id, Name, JingliApprovalManager__c, BuchangApprovalManager__c, ZongjianApprovalManager__c, TongkuoZongjian__c FROM User WHERE Id = :UserInfo.getUserId()];
+        // 瑕佹敞鎰� SaveMaintenanceByCopyController 銇� copy銇畊rl銇倐銆佷笅瑷樸伄闋呯洰銈傘偗銉偄
+        this.estimate.JingliApprovalManager__c = loginUser.JingliApprovalManager__c == null ? loginUser.Id : loginUser.JingliApprovalManager__c;
+        this.estimate.BuchangApprovalManager__c = loginUser.BuchangApprovalManager__c == null ? loginUser.Id : loginUser.BuchangApprovalManager__c;
+        this.estimate.ZongjianApprovalManager__c = loginUser.ZongjianApprovalManager__c == null ? loginUser.Id : loginUser.ZongjianApprovalManager__c;
+        this.estimate.Service_Contract_Staff__c = this.contract.Service_Contract_Staff__c;
+        this.estimate.TKZongjianApprovalManager__c = loginUser.TongkuoZongjian__c == null ? loginUser.Id : loginUser.TongkuoZongjian__c;
     }
     
     /**
@@ -2163,26 +2168,26 @@
      */
     @TestVisible
     private Boolean savePrintFlg() {
-      try {
-        Maintenance_Contract_Estimate__c mce = new Maintenance_Contract_Estimate__c();
-        mce.Id = this.targetEstimateId;
-        //鎵撳嵃鎶ヤ环锛堢畝鍖栫増锛� 2019/12/18 start
-        mce.Print_Simplify__c = this.estimate.Print_Simplify__c;
-        //鎵撳嵃鎶ヤ环锛堢畝鍖栫増锛� 2019/12/18 end
-        mce.Print_ListPrice__c = this.estimate.Print_ListPrice__c;
-        mce.Print_RepairPrice__c = this.estimate.Print_RepairPrice__c;
-        mce.Print_SumPrice__c = this.estimate.Print_SumPrice__c;
-        mce.Print_DiscountPercentage__c = this.estimate.Print_DiscountPercentage__c;
-        mce.Print_DiscountPrice__c = this.estimate.Print_DiscountPrice__c;
-        mce.Print_MaintePrice__c = this.estimate.Print_MaintePrice__c;
-        mce.Print_Contract__c = this.estimate.Print_Contract__c;
+        try {
+            Maintenance_Contract_Estimate__c mce = new Maintenance_Contract_Estimate__c();
+            mce.Id = this.targetEstimateId;
+            //鎵撳嵃鎶ヤ环锛堢畝鍖栫増锛� 2019/12/18 start
+            mce.Print_Simplify__c = this.estimate.Print_Simplify__c;
+            //鎵撳嵃鎶ヤ环锛堢畝鍖栫増锛� 2019/12/18 end
+            mce.Print_ListPrice__c = this.estimate.Print_ListPrice__c;
+            mce.Print_RepairPrice__c = this.estimate.Print_RepairPrice__c;
+            mce.Print_SumPrice__c = this.estimate.Print_SumPrice__c;
+            mce.Print_DiscountPercentage__c = this.estimate.Print_DiscountPercentage__c;
+            mce.Print_DiscountPrice__c = this.estimate.Print_DiscountPrice__c;
+            mce.Print_MaintePrice__c = this.estimate.Print_MaintePrice__c;
+            mce.Print_Contract__c = this.estimate.Print_Contract__c;
     
-        ControllerUtil.updateMaintenance_Contract_Estimate(new Maintenance_Contract_Estimate__c[] {mce});
-        return true;
-      } catch (Exception ex) {
-        ApexPages.addMessages(ex);
-      }
-      return false;
+            ControllerUtil.updateMaintenance_Contract_Estimate(new Maintenance_Contract_Estimate__c[] {mce});
+            return true;
+        } catch (Exception ex) {
+            ApexPages.addMessages(ex);
+        }
+        return false;
     }
     
     /**
@@ -2191,495 +2196,505 @@
     // TODO xudan 銉併偋銉冦偗杩藉姞銆乧ls銇倐鍚堣▓閲戦銈掕▓绠椼�乧ls銇悎瑷堥噾椤嶃仺鐢婚潰銇嬨倝js銇悎瑷堥噾椤嶃倰姣旇純
     // 鐣般仾銈嬪牬鍚堛�佷繚瀛樺畬浜嗐仐銇熴倝warning銈掑嚭銇�
     public Boolean syncEstimate(boolean isApproval, boolean isDecide) {
-      System.debug('syncEstimate start');
-      Boolean hasDatabaseError = false;
-      Savepoint sp = Database.setSavepoint();
+        System.debug('syncEstimate start');
+        Boolean hasDatabaseError = false;
+        Savepoint sp = Database.setSavepoint();
     
-      //bug淇
-      //鎻愪氦 鎶ヤ环鍐冲畾鏃ユ湡
-      // this.estimate.Quotation_Determines_Time__c = date.today();
+        //bug淇
+        //鎻愪氦 鎶ヤ环鍐冲畾鏃ユ湡
+        // this.estimate.Quotation_Determines_Time__c = date.today();
     
-      try {
-        if (!checkValidate()) {
-          return false;
-        }
-        if (checkChangedAfterPrint()) {
-          if (isDecide) {
-            // 銇俱仛 Approval
-            isApproval = true;
-            isDecide = false;
-          }
-        }
-        // 楠岃瘉 寮�濮嬫棩鏈燂紝鏈�鏃╁厑璁稿埗瀹氭棩涔嬪墠鍗婂勾
-        Date createdDate = this.estimate.CreatedDate == null ? System.today() : this.estimate.CreatedDate.date();
-        createdDate = createdDate.addMonths(isNewAddMonth);
-        // if (estimate.Contract_Start_Date__c < createdDate) {
-        //     this.estimate.Contract_Start_Date__c.addError('鍚堝悓寮�濮嬫棩鏈�鏃╁厑璁歌拷婧埗瀹氭棩涔嬪墠鍗婂勾');
-        //     return false;
-        // }
-        // 楠岃瘉 鐢ㄦ埛绫诲瀷锛屽繀濉�
-        if (String.isBlank(estimate.EndUserType__c) ) {
-          this.estimate.EndUserType__c.addError('璇烽�夋嫨鐢ㄦ埛绫诲瀷锛�');
-          return false;
-        }
-        // 楠岃瘉 鐢宠鎶ヤ环閲戦锛岄渶瑕佸ぇ浜�0
-        if (estimate.Request_quotation_Amount__c <= 0 || estimate.Request_quotation_Amount__c == null) {
-          this.estimate.Request_quotation_Amount__c.addError('鐢宠鎶ヤ环閲戦蹇呴渶澶т簬0');
-          return false;
-        }
-        // fxk 鏀规姤閿欎綅缃� 2021銆�9銆�9 Star
-        if (estimate.Request_quotation_Amount__c > estimate.GuidePrice_Up__c || estimate.Request_quotation_Amount__c < estimate.GuidePrice_Down__c) {
-          if (!(this.estimate.mainTalksTime__c > 0)) {
-            this.estimate.mainTalksTime__c.addError('涓昏璋堝垽娆℃暟蹇呭~');
-            return false;
-          }
-    
-          if (this.estimate.talksStartDate__c == null) {
-            this.estimate.talksStartDate__c.addError('璋堝垽鐨勫紑濮嬫椂闂村繀濉�');
-            return false;
-          }
-    
-          if (String.isBlank(this.estimate.Discount_reason__c)) {
-            this.estimate.Discount_reason__c.addError('浠锋牸鐢宠鐞嗙敱蹇呭~');
-            return false;
-          }
-          if (String.isBlank(this.estimate.Improve_ConsumptionRate_Idea__c)) {
-            this.estimate.Improve_ConsumptionRate_Idea__c.addError('娑堣垂鐜囨敼鍠勬柟妗堝繀濉�');
-            return false;
-          }
-        }
-        //fxk 鏀规姤閿欎綅缃� 2021/9/9 end
-        //>>>
-        if (isApproval || isDecide) {
-          Boolean hasError = false;
-          if (this.estimate.Maintenance_Price__c <= 0) {
-            this.estimate.Maintenance_Price__c.addError('鍚堝悓浠锋牸蹇呴渶澶т簬0');
-            hasError = true;
-          }
-          /*for (AssetInfo input : this.checkedAssets) {
-              if (!input.isManual || input.isManual && !String.isBlank(input.mcae.Product_Manual__c)) {
-                  if (String.isBlank(input.mcae.Check_Result__c)) {
-                      input.mcae.Check_Result__c.addError('鐐规缁撴灉蹇呭~');
-                      hasError = true;
-                  }
-              }
-             }*/
-          // if (this.estimate.Discount_Price__c > 0 && String.isBlank(this.estimate.Discount_reason__c)) {
-          //     this.estimate.Discount_reason__c.addError('鍑忎环鐢宠鐞嗙敱蹇呭~');
-          //     hasError = true;
-          // }
-          // if (this.estimate.Discount_Price__c > 0 && String.isBlank(this.estimate.Improve_ConsumptionRate_Idea__c)) {
-          //     this.estimate.Improve_ConsumptionRate_Idea__c.addError('娑堣垂鐜囨敼鍠勬柟妗堝繀濉�');
-          //     hasError = true;
-          // }
-          if (hasError) {
-            return false;
-          }
-        }
-        System.debug('楠岃瘉瑙勫垯鏉′欢楠岃瘉1锛� ' + '涓昏璋堝垽娆℃暟 ' + estimate.mainTalksTime__c + '璋堝垽鐨勫紑濮嬫椂闂� ' + estimate.talksStartDate__c + '浠锋牸鐢宠鐞嗙敱 ' + estimate.Discount_reason__c + '娑堣垂鐜囨敼鍠勬柟妗� ' + estimate.Improve_ConsumptionRate_Idea__c);
-        System.debug('楠岃瘉瑙勫垯鏉′欢楠岃瘉2锛� ' + '鐢宠鎶ヤ环閲戦 ' + estimate.Request_quotation_Amount__c);
-        System.debug('楠岃瘉瑙勫垯鏉′欢楠岃瘉3锛� ' + '鏈�浣庝环 ' + estimate.GuidePrice_Down__c + '鏈�楂樹环 ' + estimate.GuidePrice_Up__c);
-        if (isDecide && getDecideBtnDisabled()) {
-          ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '宸茬粡鏄疍ecide杩囩殑鍚堝悓 鎴� 涓嶆槸鎵瑰噯鐨勬姤浠凤紝涓嶈兘Decide'));
-          return false;
-        }
-    
-        // 杩藉姞涓婃湡鍚堝悓淇℃伅 start
-        // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start
-        List<lastMContract> lastMContractRes;
-        if (isDecide) {
-          system.debug('鎵ц浜唗cm isDecide');
-          lastMContractRes = getlastMContract(this.checkedAssets,this.estimate.Contract_Start_Date__c);
-        } else{
-          system.debug('鎵ц浜唗cm NODecide');
-          lastMContractRes = getlastMContract(this.checkedAssets,this.estimate.Contract_Esti_Start_Date__c);
-        }
-        this.estimate.LastMContract1__c = lastMContractRes[0].contractId;
-        this.estimate.LastMContract1_NO__c = lastMContractRes[0].contractNo;
-        this.estimate.LastMContract1_ConCount__c = lastMContractRes[0].count;
-    
-        this.estimate.LastMContract2__c = lastMContractRes[1].contractId;
-        this.estimate.LastMContract2_NO__c = lastMContractRes[1].contractNo;
-        this.estimate.LastMContract2_ConCount__c = lastMContractRes[1].count;
-    
-        this.estimate.LastMContract3__c = lastMContractRes[2].contractId;
-        this.estimate.LastMContract3_NO__c = lastMContractRes[2].contractNo;
-        this.estimate.LastMContract3_ConCount__c = lastMContractRes[2].count;
-    
-        this.estimate.LastMContract4__c = lastMContractRes[3].contractId;
-        this.estimate.LastMContract4_NO__c = lastMContractRes[3].contractNo;
-        this.estimate.LastMContract4_ConCount__c = lastMContractRes[3].count;
-    
-        this.estimate.LastMContract5__c = lastMContractRes[4].contractId;
-        this.estimate.LastMContract5_NO__c = lastMContractRes[4].contractNo;
-        this.estimate.LastMContract5_ConCount__c = lastMContractRes[4].count;
-    
-    
-        // 鍘熸柟娉�
-        // List<lastMContract> lastMContractRes = getlastMContract(this.checkedAssets, this.estimate.Contract_Start_Date__c);
-        // // ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, 'lastMContractRes +++++锛�' + lastMContractRes));
-        // // if (true) {
-        // //     return false;
-        // // }
-    
-        // this.estimate.LastMContract1__c = lastMContractRes[0].contractId;
-        // this.estimate.LastMContract1_NO__c = lastMContractRes[0].contractNo;
-        // this.estimate.LastMContract1_ConCount__c = lastMContractRes[0].count;
-    
-        // this.estimate.LastMContract2__c = lastMContractRes[1].contractId;
-        // this.estimate.LastMContract2_NO__c = lastMContractRes[1].contractNo;
-        // this.estimate.LastMContract2_ConCount__c = lastMContractRes[1].count;
-    
-        // this.estimate.LastMContract3__c = lastMContractRes[2].contractId;
-        // this.estimate.LastMContract3_NO__c = lastMContractRes[2].contractNo;
-        // this.estimate.LastMContract3_ConCount__c = lastMContractRes[2].count;
-    
-        // this.estimate.LastMContract4__c = lastMContractRes[3].contractId;
-        // this.estimate.LastMContract4_NO__c = lastMContractRes[3].contractNo;
-        // this.estimate.LastMContract4_ConCount__c = lastMContractRes[3].count;
-    
-        // this.estimate.LastMContract5__c = lastMContractRes[4].contractId;
-        // this.estimate.LastMContract5_NO__c = lastMContractRes[4].contractNo;
-        // this.estimate.LastMContract5_ConCount__c = lastMContractRes[4].count;
-        // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start
-    
-        // 杩藉姞涓婃湡鍚堝悓淇℃伅 end
-    
-    
-    
-        // 鍚屾湡鍑︾悊
-        // 鈶犵淮淇悎鍚屻伀鏃㈠瓨銇繚鏈夎澶囥倰鍓婇櫎
-        // 鈶′繚瀛樸仐銇熺淮淇悎鍚屾姤浠枫伄淇濇湁璁惧銈掔淮淇悎鍚屻伀銈炽償銉�(Asset__c銇岃ō瀹氥仌銇︺亜銈嬨儑銉笺偪銇犮亼)
-        // 鈶粬銇淮淇悎鍚屾姤浠枫伄鍚屾湡銉曘儵銈般倰澶栥仚
-        // 鈶g淮淇悎鍚屻伄 Estimate_Trial_Money__c銆丆ontract_Amount__c, Service_contract_target_number__c 銈掓洿鏂�
-        this.estimate.IsSyncing__c = true;
-        if (isDecide) {
-          // 20200923 Gzw bug 淇敼
-          //娓呯┖鎶ヤ环鎵瑰噯鏃堕棿
-          this.estimate.Quotation_Determines_Time__c = Date.today();
-          this.estimate.Estimation_Decision__c = true;
-        }
-        // TODO validate
-    
-        // TODO validate check鏂板搧銉併偋銉冦偗锛堢磵鍝佹棩銇у垽鏂級
-    
-        // save
-        // 鈶� start
-        for (List<Maintenance_Contract_Estimate__c> otherEstimates : [select Id from Maintenance_Contract_Estimate__c where Id <> :this.estimate.Id
-                                        and Maintenance_Contract__c = :this.contract.Id
-                                                      and IsSyncing__c = true]) {
-          for (Maintenance_Contract_Estimate__c other : otherEstimates) {
-            other.IsSyncing__c = false;
-            if (isDecide) {
-              other.Estimation_Decision__c = false;
-            }
-          }
-          ControllerUtil.updateMaintenance_Contract_Estimate(otherEstimates);
-        }
-    
-        // 鍚堝悓缁撴潫棰勫畾鏃ャ倰绠楀嚭
-        Date t = this.estimate.Contract_Esti_Start_Date__c.addMonths(Integer.valueOf(this.estimate.Contract_Range__c));
-        // 20151217 xudan 缁翠慨鍚堝悓鎶ヤ环SH-RS-JS0046560-01 鏈熼棿鏄剧ず闂
-        // 銇嗐倠銇嗗勾鐗规畩瀵惧繙
-        if (this.estimate.Contract_Esti_Start_Date__c.month() == 2 && this.estimate.Contract_Esti_Start_Date__c.day() == 29
-          && t.month() == 2) {
-          t = t;
-        } else {
-          t = t.addDays(-1);
-        }
-        this.estimate.Contract_Esti_End_Date__c = t;
-        // decide 鏃讹紝璺宠繃璧嬪�� JZHG-BRH5MU 20200715 start
-        if (!isDecide) {
-          this.estimate.New_Contract_Type_TxT__c = typeresult;
-        }
-        // decide 鏃讹紝璺宠繃璧嬪�� JZHG-BRH5MU 20200715 end
-        // 鍚堝悓寮�濮嬫棩銈掔粨鏉熸棩
-        if (this.estimate.Contract_Start_Date__c == null) {
-          this.estimate.Contract_Start_Date__c = this.estimate.Contract_Esti_Start_Date__c;
-        }
-        t = this.estimate.Contract_Start_Date__c.addMonths(Integer.valueOf(this.estimate.Contract_Range__c));
-        t = t.addDays(-1);
-        this.estimate.Contract_End_Date__c = t;
-        // 浣嶇疆璋冩暣 鍦�1951 line
-        // Date createdDate = this.estimate.CreatedDate == null ? System.today() : this.estimate.CreatedDate.date();
-        // 锛撱兌鏈堣秴閬庛仐銇︺亜銈嬪牬鍚堛伀銇�丏ecide銇с亶銇亜
-        //if (createdDate.addMonths(3) <= System.today()) {
-        //    this.estimate.addError('宸茶秴杩�3涓湀锛岃鍏堟洿鏂版姤浠枫��');
-        //    return false;
-        //}
-        // 缁翠慨鍚堝悓鎶ヤ环
-        // ApexPages.addMessage(new ApexPages.message(ApexPages.severity.Error, 'this.targetEstimateId ++++++ ' + this.targetEstimateId));
-        // if (true) {
-        //     return false;
-        // }
-        if (String.isBlank(this.targetEstimateId)) {
-          newIns = true;
-          this.estimate.Process_Status__c = '鑽夋涓�';
-          // name銇暘鍙枫倰銈汇儍銉�
-          List<Maintenance_Contract_Estimate__c> maxNameRecords = [select Name From Maintenance_Contract_Estimate__c Where Maintenance_Contract__c = :this.contract.Id order by Name desc limit 1];
-          String oppNo;
-          Integer l = 1;
-          if (maxNameRecords.size() > 0) {
-            try {
-              oppNo = maxNameRecords[0].Name;
-              l = Integer.valueOf(oppNo.substring(oppNo.length() - 2)) + 1;
-            } catch (System.TypeException e) {
-              System.debug('maxNameRecords Error: Maintenance_Contract__c.id=' + maxNameRecords[0].id);
-            }
-          } else {
-            System.debug('first Maintenance_Contract_Estimate__c');
-          }
-          oppNo = '00' + String.valueof(l);
-          oppNo = oppNo.substring(oppNo.length() - 2);
-          this.estimate.Name = this.contract.Management_Code__c + '-' + oppNo;
-          setApprovalManager();
-          System.debug('Process_Status__c=' + this.estimate.Process_Status__c);
-          insert this.estimate;
-          this.targetEstimateId = this.estimate.Id;
-          setThisEstimate();
-        } else {
-          if (isApproval) {
-            setApprovalManager();
-          }
-          ControllerUtil.updateMaintenance_Contract_Estimate(new Maintenance_Contract_Estimate__c[] {this.estimate});
-        }
-        // 缁翠慨鍚堝悓鎶ヤ环/淇濇湁璁惧
-        // delete and insert銇欍倠
-        List<Maintenance_Contract_Asset_Estimate__c> insertTarget = new List<Maintenance_Contract_Asset_Estimate__c>();
-        // 鏄惁浣跨敤棣栨鎶ヤ环鏃ユ洿鏂�
-        // 闇�瑕佹敞鎰忓鎶ヤ环鎻愪氦鏃�+3涓湀涓庡悎鍚岀粨鏉熸棩杩涜姣旇緝
-        // 1锛夋姤浠锋彁浜ゆ棩+3涓湀鐨勬棩鏈燂紝灏忎簬鍚堝悓缁撴潫鏃ユ椂锛屼互鍚堝悓缁撴潫鏃ヤ綔涓烘姤浠锋湁鏁堟湡鐨勭粨鏉熸棩
-        // 2锛夋姤浠锋彁浜ゆ棩+3涓湀鐨勬棩鏈燂紝澶т簬鍚堝悓缁撴潫鏃ユ椂锛屾姤浠锋彁浜ゆ棩+3涓湀鐨勬棩鏈熶綔涓烘姤浠锋湁鏁堟湡鐨勭粨鏉熸棩
-        //
-        //
-        //  鍥犱负鏈堝垵璁$畻娑堣垂鐜囷紝鎵�浠ョ粨鏉熸棩鍦ㄤ笂鏈堟垨浠ュ墠锛屽彲浠ュ彇鍒板畬鏁存秷璐圭巼锛屽惁鍒欎繚瀛橀娆℃姤浠锋棩
-        Date toDate = Date.today();
-        Date mon1stDate = Date.newInstance(toDate.year(), toDate.month(), 1);
-        // list 淇敼 map
-        Map<id, Maintenance_Contract__c> mcList = new Map<id, Maintenance_Contract__c>();
-        for (AssetInfo input : this.checkedAssets) {
-          if (!input.isManual || input.isManual && !String.isBlank(input.mcae.Product_Manual__c)) {
-            //Maintenance_Contract_Asset_Estimate__c mcae = new Maintenance_Contract_Asset_Estimate__c();
-            input.mcae.Id = null;                       // insert銇仧銈�
-            // 鍚屻仒銇牬鍚堣ō瀹氥仐銇亜
-            if (input.mcae.Maintenance_Contract_Estimate__c != this.targetEstimateId) {
-              // 瑕鏇淬仹銇嶃仾銇勫彲鑳芥�с亴銇傘倠銇熴倎銆佽ō瀹氥仚銈嬨仺銇嶃偍銉┿兗銇仾銈嬨亴銆併偍銉┿兗銇仾銈夈仾銇勩倛銇嗐伀浠栥伄銉偢銉冦偗銈掑伐澶仐銇︺亸銇犮仌銇勩��
-              input.mcae.Maintenance_Contract_Estimate__c = this.targetEstimateId;
-            }
-            input.mcae.Maintenance_Price_Month__c = input.rec.Maintenance_Price_Month__c;
-            // 鐥呴櫌銇墍灞炪仚銈嬩繚鏈夎ō鍌�
-    
-            if (!input.isManual) {
-              input.mcae.Asset__c = input.rec.Id;
-              input.mcae.Product_Manual__c = null;
-              input.mcae.Estimate_Cost__c = input.mcae.Estimate_Cost__c;
-              input.mcae.LastMContract_Price__c = input.rec.CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c;
-              //input.mcae.Asset_Consumption_rate__c = input.mcae.Asset_Consumption_rate__c;
-            }
-            // 鎻愪氦鏃讹紝鏇存柊 鏄惁浣跨敤涓婁竴鏈熺淮淇悎鍚岄娆℃姤浠锋棩
-            if (isApproval) {
-              Maintenance_Contract__c mctemp = new Maintenance_Contract__c();
-              //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO , '+++++ ' + ass.rec.CurrentContract_F__r.Contract_End_Date__c + '   ' + mon1stDate));
-              // 鍥犱负鏈堝垵璁$畻娑堣垂鐜囷紝鎵�浠ョ粨鏉熸棩鍦ㄤ笂鏈堟垨浠ュ墠锛屽彲浠ュ彇鍒板畬鏁存秷璐圭巼锛屽惁鍒欎繚瀛橀娆℃姤浠锋棩
-              if (input.rec.CurrentContract_F__r.Contract_End_Date__c >= mon1stDate) {
-                if (input.rec.CurrentContract_F__r.First_Estimate_Date__c == null) {
-                  mctemp.Id = input.rec.CurrentContract_F__c;
-                  mctemp.First_contract_usage_Rate__c = input.rec.CurrentContract_F__r.Contract_Consumption_rate__c;
-                  mctemp.First_Estimate_Date__c = Date.today();
-                  mcList.put(mctemp.Id, mctemp);
-                  input.mcae.ifHaveleftInPrevious__c = true;
-                }
-              }
-            }
-            // Manual鍟嗗搧
-            if (input.isManual && !String.isBlank(input.mcae.Product_Manual__c)) {
-              input.mcae.Asset__c = null;
-              //mcae.Product_Manual__c = input.mcae.Product_Manual__c;
-            }
-            //鏂拌鏃讹紝淇濆瓨鏂板悎鍚屽鍝佷繚璇佹彁渚� Decide 鍚�
-            if (!isDecide) {
-              input.mcae.EquipmentGuaranteeFlgTxt__c = input.etGFlg;
-            }
-            // Gzw 20200807 浜斾釜鍘诲勾鍚堝悓鐩稿叧锛屾墍浠ユ姤浠蜂骇鍝侊紝鑾峰彇涓婃湡鍚堝悓 start
-    
-            // 2020/10/30 songxiaoqi start
-            if (input.rec.CurrentContract_F__r.RecordType_DeveloperName__c != 'VM_Contract') {
-              input.mcae.Last_MContract__c = input.rec.CurrentContract_F__c;
-    
-            }
-            //songxiaoqi end
-    
-    
-            // Gzw 20200807 浜斾釜鍘诲勾鍚堝悓鐩稿叧锛屾墍浠ユ姤浠蜂骇鍝侊紝鑾峰彇涓婃湡鍚堝悓 end
-            //mcae.Estimate_List_Price__c = input.mcae.Estimate_List_Price__c;
-            //mcae.IsNew__c = input.mcae.isNew__c;
-            //mcae.Check_Result__c = input.mcae.Check_Result__c;
-            //mcae.Repair_Price__c = input.mcae.Repair_Price__c;
-            //mcae.Comment__c = input.mcae.Comment__c;
-            insertTarget.add(input.mcae);
-          }
-        }
-        // 鏈綋銇繚瀛樸仐銇熺磵鍏ユ鍣ㄣ亴銇傘倢銇板墛闄�
-        List<Maintenance_Contract_Asset_Estimate__c> selectedAsset = [SELECT Id, Name, Maintenance_Contract_Estimate__c, Asset__c, IsNew__c FROM Maintenance_Contract_Asset_Estimate__c WHERE Maintenance_Contract_Estimate__c = :this.targetEstimateId];
-        if (selectedAsset.size() > 0) {
-          ControllerUtil.deleteMaintenance_Contract_Asset_Estimate(selectedAsset);
-        }
-        if (insertTarget.size() > 0) {
-          ControllerUtil.insertMaintenance_Contract_Asset_Estimate(insertTarget);
-        }
-    
-        // 鈶� start
-        for (List<Maintenance_Contract_Asset__c> oldList : [select Id from Maintenance_Contract_Asset__c
-                                  where Maintenance_Contract__c = :this.estimate.Maintenance_Contract__c]) {
-          delete oldList;
-        }
-        // 鈶� start
-        {
-          List<Maintenance_Contract_Asset__c> newValue = new List<Maintenance_Contract_Asset__c>();
-          for (Maintenance_Contract_Asset_Estimate__c target : [select Id, Asset__c, Estimate_List_Price__c, Estimate_Cost__c,
-                                      //add 鐐规鏀瑰杽锛氬悎鍚屼繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄涓庢姤浠蜂繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄鍚屾 2021.6.9 fxk start
-                                      Check_Object__c,
-                                      //add 鐐规鏀瑰杽锛氬悎鍚屼繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄涓庢姤浠蜂繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄鍚屾 2021.6.9 fxk end
-                                      IsNew__c, EquipmentGuaranteeFlgTxt__c,
-                                      // Gzw 20200807 浜斾釜鍘诲勾鍚堝悓鐩稿叧锛屾墍浠ユ姤浠蜂骇鍝侊紝鑾峰彇涓婃湡鍚堝悓 start
-                                      Last_MContract__c
-                                      // Gzw 20200807 浜斾釜鍘诲勾鍚堝悓鐩稿叧锛屾墍浠ユ姤浠蜂骇鍝侊紝鑾峰彇涓婃湡鍚堝悓 eng
-                                      , Last_MContract__r.RecordType_DeveloperName__c
-                                      // LJPH-C9GD34 gzw fix start
-                                      ,Estimate_List_Price_Page__c
-                                      // LJPH-C9GD34 gzw fix end
-                                      from Maintenance_Contract_Asset_Estimate__c
-                                      where Maintenance_Contract_Estimate__c = :this.estimate.Id and Asset__c <> null]) {
-    
-            Maintenance_Contract_Asset__c newVal = new Maintenance_Contract_Asset__c(
-              Maintenance_Contract__c = this.estimate.Maintenance_Contract__c,
-              Asset__c = target.Asset__c,
-              Maintenance_Contract_Asset_Estimate__c = target.Id,
-              Estimate_List_Price__c = target.Estimate_List_Price__c,
-              //Maintenance_Price_YearTXT__c = target.Maintenance_Price_YearTXT__c,
-              Estimate_IsNew__c = target.IsNew__c,
-              //add 鐐规鏀瑰杽锛氬悎鍚屼繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄涓庢姤浠蜂繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄鍚屾 2021.6.9 fxk start
-              Check_Object__c = target.Check_Object__c,
-              //add 鐐规鏀瑰杽锛氬悎鍚屼繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄涓庢姤浠蜂繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄鍚屾 2021.6.9 fxk end
-              //EquipmentGuaranteeFlgTxt__c = target.EquipmentGuaranteeFlgTxt__c,
-              // Gzw 20200807 浜斾釜鍘诲勾鍚堝悓鐩稿叧锛屾墍浠ユ姤浠蜂骇鍝侊紝鑾峰彇涓婃湡鍚堝悓 start
-              // LastMContract__c = target.Last_MContract__c
-              // Gzw 20200807 浜斾釜鍘诲勾鍚堝悓鐩稿叧锛屾墍浠ユ姤浠蜂骇鍝侊紝鑾峰彇涓婃湡鍚堝悓 end
-              //濡傛灉鏄骞翠繚淇悎鍚�,涓嶆洿鏂颁笂鏈熺淮淇悎鍚屼俊鎭� LJPH-BUU3E3 update by rentx  2020-11-03
-              LastMContract__c = target.Last_MContract__r.RecordType_DeveloperName__c == 'VM_Contract' ? null : target.Last_MContract__c
-              );
-            newValue.add(newVal);
-          }
-          if (newValue.size() > 0) insert newValue;
-        }
-        // 鈶� start
-        this.contract.Estimation_Id__c = this.targetEstimateId;
-        this.contract.Contract_Esti_Start_Date__c = this.estimate.Contract_Esti_Start_Date__c;
-        this.contract.Contract_Range__c = this.estimate.Contract_Range__c;
-        this.contract.Contract_Esti_End_Date__c = this.estimate.Contract_Esti_End_Date__c;
-        this.contract.Estimate_Target__c = this.estimate.Estimate_Target__c;
-        this.contract.Dealer__c = this.estimate.Dealer__c;
-        this.contract.NotUse_Oxygenated_Water__c = this.estimate.NotUse_Oxygenated_Water__c;
-        this.contract.Estimate_Trial_Money__c = this.estimate.Estimate_Trial_Money__c;
-        this.contract.Contract_Amount__c = this.estimate.Maintenance_Price__c;
-        // 鐐规鎬绘鏁拌嚜鍔ㄨ祴鍊� gzw fix 20211122 start
-        // this.contract.Service_contract_target_number__c = this.estimate.Service_contract_target_number__c;
-        // 鐐规鎬绘鏁拌嚜鍔ㄨ祴鍊� gzw fix 20211122 end
-        this.contract.Contract_department_manual__c = this.estimate.Department__c;
-    
-        // 杩藉姞涓婃湡鍚堝悓淇℃伅 start
-        this.contract.LastMContract1__c = this.estimate.LastMContract1__c;
-        this.contract.LastMContract1_NO__c = this.estimate.LastMContract1_NO__c;
-        this.contract.LastMContract1_ConCount__c =  this.estimate.LastMContract1_ConCount__c;
-    
-        //add by rentx 2021-04-22 缁欏悎鍚�1璧嬪�肩殑鍚屾椂锛岀粰鍘诲勾鍚堝悓璧嬪�� start
-        this.contract.Last_year_service_contract__c = this.estimate.LastMContract1__c;
-        //add by renrx 2021-04-22 缁欏悎鍚�1璧嬪�肩殑鍚屾椂, 缁欏幓骞村悎鍚岃祴鍊� end
-    
-        this.contract.LastMContract2__c =  this.estimate.LastMContract2__c;
-        this.contract.LastMContract2_NO__c = this.estimate.LastMContract2_NO__c;
-        this.contract.LastMContract2_ConCount__c =  this.estimate.LastMContract2_ConCount__c;
-    
-        this.contract.LastMContract3__c =  this.estimate.LastMContract3__c;
-        this.contract.LastMContract3_NO__c = this.estimate.LastMContract3_NO__c;
-        this.contract.LastMContract3_ConCount__c =  this.estimate.LastMContract3_ConCount__c;
-    
-        this.contract.LastMContract4__c =  this.estimate.LastMContract4__c;
-        this.contract.LastMContract4_NO__c = this.estimate.LastMContract4_NO__c;
-        this.contract.LastMContract4_ConCount__c =  this.estimate.LastMContract4_ConCount__c;
-    
-        this.contract.LastMContract5__c =  this.estimate.LastMContract5__c;
-        this.contract.LastMContract5_NO__c = this.estimate.LastMContract5_NO__c;
-        this.contract.LastMContract5_ConCount__c =  this.estimate.LastMContract5_ConCount__c;
-        // 杩藉姞涓婃湡鍚堝悓淇℃伅 end
-    
-        system.debug('娴嬬畻isDecide鐨勭粨鏋淿1::::::::' + isDecide);
-        if (isDecide == true) {
-          system.debug('娴嬬畻isDecide鐨勭粨鏋淿2::::::::' + isDecide);
-          //              this.contract.Contract_Start_Date__c = this.estimate.Contract_Esti_Start_Date__c;
-          this.contract.Contract_Start_Date__c = this.estimate.Contract_Start_Date__c;
-          this.contract.Contract_Range__c = this.estimate.Contract_Range__c;
-          //              this.contract.Contract_End_Date__c = this.estimate.Contract_Esti_End_Date__c;
-          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;
-          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;
-          // JZHG-BQV3P4 20200624 Gzw add
-          this.contract.HospitalAmountText__c = this.estimate.AgencyHos_Price__c;
-          // JZHG-BQV3P4 20200624 Gzw add
-        }
-        //娣诲姞鐨勯澶栧搴旇繃绋�
-        if (inDicideFlag == true && (this.contract.Contract_Start_Date__c == null || this.contract.Contract_End_Date__c == null)) {
-          system.debug('娴嬬畻inDicideFlag鐨勭粨鏋淿2::::::::' + isDecide);
-          //              this.contract.Contract_Start_Date__c = this.estimate.Contract_Esti_Start_Date__c;
-          this.contract.Contract_Start_Date__c = this.estimate.Contract_Start_Date__c;
-          this.contract.Contract_Range__c = this.estimate.Contract_Range__c;
-          //              this.contract.Contract_End_Date__c = this.estimate.Contract_Esti_End_Date__c;
-          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;
-          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;
-          // JZHG-BQV3P4 20200624 Gzw add
-          this.contract.HospitalAmountText__c = this.estimate.AgencyHos_Price__c;
-          // JZHG-BQV3P4 20200624 Gzw add
-        }
-        String oldProcessStatus = this.estimate.Process_Status__c;
         try {
-          if (mcList.size() > 0) {
-            ControllerUtil.updMcList(mcList.values());
-          }
-          ControllerUtil.updateMaintenance_Contract_Estimate(new Maintenance_Contract_Estimate__c[] {this.estimate});
-          update this.contract;
-        } catch (Exception e) {
-          // TODO 浠婂緦瑜囨暟浠躲伄鍫村悎銇┿亞銇欍倠锛�
-          this.estimate.addError(e);
-          // 涓�閮ㄣ伄鍊ゃ倰鎴汇仚
-          this.estimate.Process_Status__c = oldProcessStatus;
-          hasDatabaseError = true;
-          Database.rollback(sp);
-          ApexPages.addMessages(e);
+            if (!checkValidate()) {
+                return false;
+            }
+            if (checkChangedAfterPrint()) {
+                if (isDecide) {
+                    // 銇俱仛 Approval
+                    isApproval = true;
+                    isDecide = false;
+                }
+            }
+            // 楠岃瘉 寮�濮嬫棩鏈燂紝鏈�鏃╁厑璁稿埗瀹氭棩涔嬪墠鍗婂勾
+            Date createdDate = this.estimate.CreatedDate == null ? System.today() : this.estimate.CreatedDate.date();
+            createdDate = createdDate.addMonths(isNewAddMonth);
+            // if (estimate.Contract_Start_Date__c < createdDate) {
+            //     this.estimate.Contract_Start_Date__c.addError('鍚堝悓寮�濮嬫棩鏈�鏃╁厑璁歌拷婧埗瀹氭棩涔嬪墠鍗婂勾');
+            //     return false;
+            // }
+            // 楠岃瘉 鐢ㄦ埛绫诲瀷锛屽繀濉�
+            if (String.isBlank(estimate.EndUserType__c) ) {
+                this.estimate.EndUserType__c.addError('璇烽�夋嫨鐢ㄦ埛绫诲瀷锛�');
+                return false;
+            }
+            // 楠岃瘉 鐢宠鎶ヤ环閲戦锛岄渶瑕佸ぇ浜�0
+            if (estimate.Request_quotation_Amount__c <= 0 || estimate.Request_quotation_Amount__c == null) {
+                this.estimate.Request_quotation_Amount__c.addError('鐢宠鎶ヤ环閲戦蹇呴渶澶т簬0');
+                return false;
+            }
+            // fxk 鏀规姤閿欎綅缃� 2021銆�9銆�9 Star
+            if (estimate.Request_quotation_Amount__c > estimate.GuidePrice_Up__c || estimate.Request_quotation_Amount__c < estimate.GuidePrice_Down__c) {
+                if (!(this.estimate.mainTalksTime__c > 0)) {
+                    this.estimate.mainTalksTime__c.addError('涓昏璋堝垽娆℃暟蹇呭~');
+                    return false;
+                }
+    
+                if (this.estimate.talksStartDate__c == null) {
+                    this.estimate.talksStartDate__c.addError('璋堝垽鐨勫紑濮嬫椂闂村繀濉�');
+                    return false;
+                }
+    
+                if (String.isBlank(this.estimate.Discount_reason__c)) {
+                    this.estimate.Discount_reason__c.addError('浠锋牸鐢宠鐞嗙敱蹇呭~');
+                    return false;
+                }
+                if (String.isBlank(this.estimate.Improve_ConsumptionRate_Idea__c)) {
+                    this.estimate.Improve_ConsumptionRate_Idea__c.addError('娑堣垂鐜囨敼鍠勬柟妗堝繀濉�');
+                    return false;
+                }
+            }
+            //fxk 鏀规姤閿欎綅缃� 2021/9/9 end
+            //>>>
+            if (isApproval || isDecide) {
+                Boolean hasError = false;
+                if (this.estimate.Maintenance_Price__c <= 0) {
+                    this.estimate.Maintenance_Price__c.addError('鍚堝悓浠锋牸蹇呴渶澶т簬0');
+                    hasError = true;
+                }
+                /*for (AssetInfo input : this.checkedAssets) {
+                        if (!input.isManual || input.isManual && !String.isBlank(input.mcae.Product_Manual__c)) {
+                                if (String.isBlank(input.mcae.Check_Result__c)) {
+                                        input.mcae.Check_Result__c.addError('鐐规缁撴灉蹇呭~');
+                                        hasError = true;
+                                }
+                        }
+                   }*/
+                // if (this.estimate.Discount_Price__c > 0 && String.isBlank(this.estimate.Discount_reason__c)) {
+                //     this.estimate.Discount_reason__c.addError('鍑忎环鐢宠鐞嗙敱蹇呭~');
+                //     hasError = true;
+                // }
+                // if (this.estimate.Discount_Price__c > 0 && String.isBlank(this.estimate.Improve_ConsumptionRate_Idea__c)) {
+                //     this.estimate.Improve_ConsumptionRate_Idea__c.addError('娑堣垂鐜囨敼鍠勬柟妗堝繀濉�');
+                //     hasError = true;
+                // }
+                if (hasError) {
+                    return false;
+                }
+            }
+            System.debug('楠岃瘉瑙勫垯鏉′欢楠岃瘉1锛� ' + '涓昏璋堝垽娆℃暟 ' + estimate.mainTalksTime__c + '璋堝垽鐨勫紑濮嬫椂闂� ' + estimate.talksStartDate__c + '浠锋牸鐢宠鐞嗙敱 ' + estimate.Discount_reason__c + '娑堣垂鐜囨敼鍠勬柟妗� ' + estimate.Improve_ConsumptionRate_Idea__c);
+            System.debug('楠岃瘉瑙勫垯鏉′欢楠岃瘉2锛� ' + '鐢宠鎶ヤ环閲戦 ' + estimate.Request_quotation_Amount__c);
+            System.debug('楠岃瘉瑙勫垯鏉′欢楠岃瘉3锛� ' + '鏈�浣庝环 ' + estimate.GuidePrice_Down__c + '鏈�楂樹环 ' + estimate.GuidePrice_Up__c);
+            if (isDecide && getDecideBtnDisabled()) {
+                ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '宸茬粡鏄疍ecide杩囩殑鍚堝悓 鎴� 涓嶆槸鎵瑰噯鐨勬姤浠凤紝涓嶈兘Decide'));
+                return false;
+            }
+    
+            // 杩藉姞涓婃湡鍚堝悓淇℃伅 start
+            // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start
+            List<lastMContract> lastMContractRes;
+            if (isDecide) {
+                system.debug('鎵ц浜唗cm isDecide');
+                lastMContractRes = getlastMContract(this.checkedAssets,this.estimate.Contract_Start_Date__c);
+            } else{
+                system.debug('鎵ц浜唗cm NODecide');
+                lastMContractRes = getlastMContract(this.checkedAssets,this.estimate.Contract_Esti_Start_Date__c);
+            }
+            this.estimate.LastMContract1__c = lastMContractRes[0].contractId;
+            this.estimate.LastMContract1_NO__c = lastMContractRes[0].contractNo;
+            this.estimate.LastMContract1_ConCount__c = lastMContractRes[0].count;
+    
+            this.estimate.LastMContract2__c = lastMContractRes[1].contractId;
+            this.estimate.LastMContract2_NO__c = lastMContractRes[1].contractNo;
+            this.estimate.LastMContract2_ConCount__c = lastMContractRes[1].count;
+    
+            this.estimate.LastMContract3__c = lastMContractRes[2].contractId;
+            this.estimate.LastMContract3_NO__c = lastMContractRes[2].contractNo;
+            this.estimate.LastMContract3_ConCount__c = lastMContractRes[2].count;
+    
+            this.estimate.LastMContract4__c = lastMContractRes[3].contractId;
+            this.estimate.LastMContract4_NO__c = lastMContractRes[3].contractNo;
+            this.estimate.LastMContract4_ConCount__c = lastMContractRes[3].count;
+    
+            this.estimate.LastMContract5__c = lastMContractRes[4].contractId;
+            this.estimate.LastMContract5_NO__c = lastMContractRes[4].contractNo;
+            this.estimate.LastMContract5_ConCount__c = lastMContractRes[4].count;
+    
+    
+            // 鍘熸柟娉�
+            // List<lastMContract> lastMContractRes = getlastMContract(this.checkedAssets, this.estimate.Contract_Start_Date__c);
+            // // ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, 'lastMContractRes +++++锛�' + lastMContractRes));
+            // // if (true) {
+            // //     return false;
+            // // }
+    
+            // this.estimate.LastMContract1__c = lastMContractRes[0].contractId;
+            // this.estimate.LastMContract1_NO__c = lastMContractRes[0].contractNo;
+            // this.estimate.LastMContract1_ConCount__c = lastMContractRes[0].count;
+    
+            // this.estimate.LastMContract2__c = lastMContractRes[1].contractId;
+            // this.estimate.LastMContract2_NO__c = lastMContractRes[1].contractNo;
+            // this.estimate.LastMContract2_ConCount__c = lastMContractRes[1].count;
+    
+            // this.estimate.LastMContract3__c = lastMContractRes[2].contractId;
+            // this.estimate.LastMContract3_NO__c = lastMContractRes[2].contractNo;
+            // this.estimate.LastMContract3_ConCount__c = lastMContractRes[2].count;
+    
+            // this.estimate.LastMContract4__c = lastMContractRes[3].contractId;
+            // this.estimate.LastMContract4_NO__c = lastMContractRes[3].contractNo;
+            // this.estimate.LastMContract4_ConCount__c = lastMContractRes[3].count;
+    
+            // this.estimate.LastMContract5__c = lastMContractRes[4].contractId;
+            // this.estimate.LastMContract5_NO__c = lastMContractRes[4].contractNo;
+            // this.estimate.LastMContract5_ConCount__c = lastMContractRes[4].count;
+            // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start
+    
+            // 杩藉姞涓婃湡鍚堝悓淇℃伅 end
+    
+    
+    
+            // 鍚屾湡鍑︾悊
+            // 鈶犵淮淇悎鍚屻伀鏃㈠瓨銇繚鏈夎澶囥倰鍓婇櫎
+            // 鈶′繚瀛樸仐銇熺淮淇悎鍚屾姤浠枫伄淇濇湁璁惧銈掔淮淇悎鍚屻伀銈炽償銉�(Asset__c銇岃ō瀹氥仌銇︺亜銈嬨儑銉笺偪銇犮亼)
+            // 鈶粬銇淮淇悎鍚屾姤浠枫伄鍚屾湡銉曘儵銈般倰澶栥仚
+            // 鈶g淮淇悎鍚屻伄 Estimate_Trial_Money__c銆丆ontract_Amount__c, Service_contract_target_number__c 銈掓洿鏂�
+            this.estimate.IsSyncing__c = true;
+            if (isDecide) {
+                // 20200923 Gzw bug 淇敼
+                //娓呯┖鎶ヤ环鎵瑰噯鏃堕棿
+                this.estimate.Quotation_Determines_Time__c = Date.today();
+                this.estimate.Estimation_Decision__c = true;
+            }
+            // TODO validate
+    
+            // TODO validate check鏂板搧銉併偋銉冦偗锛堢磵鍝佹棩銇у垽鏂級
+    
+            // save
+            // 鈶� start
+            for (List<Maintenance_Contract_Estimate__c> otherEstimates : [select Id from Maintenance_Contract_Estimate__c where Id <> :this.estimate.Id
+                                                                          and Maintenance_Contract__c = :this.contract.Id
+                                                                                                        and IsSyncing__c = true]) {
+                for (Maintenance_Contract_Estimate__c other : otherEstimates) {
+                    other.IsSyncing__c = false;
+                    if (isDecide) {
+                        other.Estimation_Decision__c = false;
+                    }
+                }
+                ControllerUtil.updateMaintenance_Contract_Estimate(otherEstimates);
+            }
+    
+            // 鍚堝悓缁撴潫棰勫畾鏃ャ倰绠楀嚭
+            Date t = this.estimate.Contract_Esti_Start_Date__c.addMonths(Integer.valueOf(this.estimate.Contract_Range__c));
+            // 20151217 xudan 缁翠慨鍚堝悓鎶ヤ环SH-RS-JS0046560-01 鏈熼棿鏄剧ず闂
+            // 銇嗐倠銇嗗勾鐗规畩瀵惧繙
+            if (this.estimate.Contract_Esti_Start_Date__c.month() == 2 && this.estimate.Contract_Esti_Start_Date__c.day() == 29
+                && t.month() == 2) {
+                t = t;
+            } else {
+                t = t.addDays(-1);
+            }
+            this.estimate.Contract_Esti_End_Date__c = t;
+            // decide 鏃讹紝璺宠繃璧嬪�� JZHG-BRH5MU 20200715 start
+            if (!isDecide) {
+                this.estimate.New_Contract_Type_TxT__c = typeresult;
+            }
+            // decide 鏃讹紝璺宠繃璧嬪�� JZHG-BRH5MU 20200715 end
+            // 鍚堝悓寮�濮嬫棩銈掔粨鏉熸棩
+            if (this.estimate.Contract_Start_Date__c == null) {
+                this.estimate.Contract_Start_Date__c = this.estimate.Contract_Esti_Start_Date__c;
+            }
+            t = this.estimate.Contract_Start_Date__c.addMonths(Integer.valueOf(this.estimate.Contract_Range__c));
+            t = t.addDays(-1);
+            this.estimate.Contract_End_Date__c = t;
+            //add      wangweipeng                   2021/12/26                     start
+            if(String.isNotBlank(this.estimate.Dealer__c)){
+                checkDealerId = this.estimate.Dealer__c;
+                onChDealerUpdate();
+            }else{
+                this.estimate.Is_RecognitionModel__c = false;
+            }
+            //add      wangweipeng                   2021/12/26                     end
+            System.debug('---------345----'+this.estimate.Dealer__c+'-------'+this.estimate.Dealer__r.FirstParagraphEnd__c);
+            // 浣嶇疆璋冩暣 鍦�1951 line
+            // Date createdDate = this.estimate.CreatedDate == null ? System.today() : this.estimate.CreatedDate.date();
+            // 锛撱兌鏈堣秴閬庛仐銇︺亜銈嬪牬鍚堛伀銇�丏ecide銇с亶銇亜
+            //if (createdDate.addMonths(3) <= System.today()) {
+            //    this.estimate.addError('宸茶秴杩�3涓湀锛岃鍏堟洿鏂版姤浠枫��');
+            //    return false;
+            //}
+            // 缁翠慨鍚堝悓鎶ヤ环
+            // ApexPages.addMessage(new ApexPages.message(ApexPages.severity.Error, 'this.targetEstimateId ++++++ ' + this.targetEstimateId));
+            // if (true) {
+            //     return false;
+            // }
+            if (String.isBlank(this.targetEstimateId)) {
+                newIns = true;
+                this.estimate.Process_Status__c = '鑽夋涓�';
+                // name銇暘鍙枫倰銈汇儍銉�
+                List<Maintenance_Contract_Estimate__c> maxNameRecords = [select Name From Maintenance_Contract_Estimate__c Where Maintenance_Contract__c = :this.contract.Id order by Name desc limit 1];
+                String oppNo;
+                Integer l = 1;
+                if (maxNameRecords.size() > 0) {
+                    try {
+                        oppNo = maxNameRecords[0].Name;
+                        l = Integer.valueOf(oppNo.substring(oppNo.length() - 2)) + 1;
+                    } catch (System.TypeException e) {
+                        System.debug('maxNameRecords Error: Maintenance_Contract__c.id=' + maxNameRecords[0].id);
+                    }
+                } else {
+                    System.debug('first Maintenance_Contract_Estimate__c');
+                }
+                oppNo = '00' + String.valueof(l);
+                oppNo = oppNo.substring(oppNo.length() - 2);
+                this.estimate.Name = this.contract.Management_Code__c + '-' + oppNo;
+                setApprovalManager();
+                System.debug('Process_Status__c=' + this.estimate.Process_Status__c);
+                insert this.estimate;
+                this.targetEstimateId = this.estimate.Id;
+                setThisEstimate();
+            } else {
+                if (isApproval) {
+                    setApprovalManager();
+                }
+                ControllerUtil.updateMaintenance_Contract_Estimate(new Maintenance_Contract_Estimate__c[] {this.estimate});
+            }
+            // 缁翠慨鍚堝悓鎶ヤ环/淇濇湁璁惧
+            // delete and insert銇欍倠
+            List<Maintenance_Contract_Asset_Estimate__c> insertTarget = new List<Maintenance_Contract_Asset_Estimate__c>();
+            // 鏄惁浣跨敤棣栨鎶ヤ环鏃ユ洿鏂�
+            // 闇�瑕佹敞鎰忓鎶ヤ环鎻愪氦鏃�+3涓湀涓庡悎鍚岀粨鏉熸棩杩涜姣旇緝
+            // 1锛夋姤浠锋彁浜ゆ棩+3涓湀鐨勬棩鏈燂紝灏忎簬鍚堝悓缁撴潫鏃ユ椂锛屼互鍚堝悓缁撴潫鏃ヤ綔涓烘姤浠锋湁鏁堟湡鐨勭粨鏉熸棩
+            // 2锛夋姤浠锋彁浜ゆ棩+3涓湀鐨勬棩鏈燂紝澶т簬鍚堝悓缁撴潫鏃ユ椂锛屾姤浠锋彁浜ゆ棩+3涓湀鐨勬棩鏈熶綔涓烘姤浠锋湁鏁堟湡鐨勭粨鏉熸棩
+            //
+            //
+            //  鍥犱负鏈堝垵璁$畻娑堣垂鐜囷紝鎵�浠ョ粨鏉熸棩鍦ㄤ笂鏈堟垨浠ュ墠锛屽彲浠ュ彇鍒板畬鏁存秷璐圭巼锛屽惁鍒欎繚瀛橀娆℃姤浠锋棩
+            Date toDate = Date.today();
+            Date mon1stDate = Date.newInstance(toDate.year(), toDate.month(), 1);
+            // list 淇敼 map
+            Map<id, Maintenance_Contract__c> mcList = new Map<id, Maintenance_Contract__c>();
+            for (AssetInfo input : this.checkedAssets) {
+                if (!input.isManual || input.isManual && !String.isBlank(input.mcae.Product_Manual__c)) {
+                    //Maintenance_Contract_Asset_Estimate__c mcae = new Maintenance_Contract_Asset_Estimate__c();
+                    input.mcae.Id = null;                       // insert銇仧銈�
+                    // 鍚屻仒銇牬鍚堣ō瀹氥仐銇亜
+                    if (input.mcae.Maintenance_Contract_Estimate__c != this.targetEstimateId) {
+                        // 瑕鏇淬仹銇嶃仾銇勫彲鑳芥�с亴銇傘倠銇熴倎銆佽ō瀹氥仚銈嬨仺銇嶃偍銉┿兗銇仾銈嬨亴銆併偍銉┿兗銇仾銈夈仾銇勩倛銇嗐伀浠栥伄銉偢銉冦偗銈掑伐澶仐銇︺亸銇犮仌銇勩��
+                        input.mcae.Maintenance_Contract_Estimate__c = this.targetEstimateId;
+                    }
+                    input.mcae.Maintenance_Price_Month__c = input.rec.Maintenance_Price_Month__c;
+                    // 鐥呴櫌銇墍灞炪仚銈嬩繚鏈夎ō鍌�
+    
+                    if (!input.isManual) {
+                        input.mcae.Asset__c = input.rec.Id;
+                        input.mcae.Product_Manual__c = null;
+                        input.mcae.Estimate_Cost__c = input.mcae.Estimate_Cost__c;
+                        input.mcae.LastMContract_Price__c = input.rec.CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c;
+                        //input.mcae.Asset_Consumption_rate__c = input.mcae.Asset_Consumption_rate__c;
+                    }
+                    // 鎻愪氦鏃讹紝鏇存柊 鏄惁浣跨敤涓婁竴鏈熺淮淇悎鍚岄娆℃姤浠锋棩
+                    if (isApproval) {
+                        Maintenance_Contract__c mctemp = new Maintenance_Contract__c();
+                        //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO , '+++++ ' + ass.rec.CurrentContract_F__r.Contract_End_Date__c + '   ' + mon1stDate));
+                        // 鍥犱负鏈堝垵璁$畻娑堣垂鐜囷紝鎵�浠ョ粨鏉熸棩鍦ㄤ笂鏈堟垨浠ュ墠锛屽彲浠ュ彇鍒板畬鏁存秷璐圭巼锛屽惁鍒欎繚瀛橀娆℃姤浠锋棩
+                        if (input.rec.CurrentContract_F__r.Contract_End_Date__c >= mon1stDate) {
+                            if (input.rec.CurrentContract_F__r.First_Estimate_Date__c == null) {
+                                mctemp.Id = input.rec.CurrentContract_F__c;
+                                mctemp.First_contract_usage_Rate__c = input.rec.CurrentContract_F__r.Contract_Consumption_rate__c;
+                                mctemp.First_Estimate_Date__c = Date.today();
+                                mcList.put(mctemp.Id, mctemp);
+                                input.mcae.ifHaveleftInPrevious__c = true;
+                            }
+                        }
+                    }
+                    // Manual鍟嗗搧
+                    if (input.isManual && !String.isBlank(input.mcae.Product_Manual__c)) {
+                        input.mcae.Asset__c = null;
+                        //mcae.Product_Manual__c = input.mcae.Product_Manual__c;
+                    }
+                    //鏂拌鏃讹紝淇濆瓨鏂板悎鍚屽鍝佷繚璇佹彁渚� Decide 鍚�
+                    if (!isDecide) {
+                        input.mcae.EquipmentGuaranteeFlgTxt__c = input.etGFlg;
+                    }
+                    // Gzw 20200807 浜斾釜鍘诲勾鍚堝悓鐩稿叧锛屾墍浠ユ姤浠蜂骇鍝侊紝鑾峰彇涓婃湡鍚堝悓 start
+    
+                    // 2020/10/30 songxiaoqi start
+                    if (input.rec.CurrentContract_F__r.RecordType_DeveloperName__c != 'VM_Contract') {
+                        input.mcae.Last_MContract__c = input.rec.CurrentContract_F__c;
+    
+                    }
+                    //songxiaoqi end
+    
+    
+                    // Gzw 20200807 浜斾釜鍘诲勾鍚堝悓鐩稿叧锛屾墍浠ユ姤浠蜂骇鍝侊紝鑾峰彇涓婃湡鍚堝悓 end
+                    //mcae.Estimate_List_Price__c = input.mcae.Estimate_List_Price__c;
+                    //mcae.IsNew__c = input.mcae.isNew__c;
+                    //mcae.Check_Result__c = input.mcae.Check_Result__c;
+                    //mcae.Repair_Price__c = input.mcae.Repair_Price__c;
+                    //mcae.Comment__c = input.mcae.Comment__c;
+                    insertTarget.add(input.mcae);
+                }
+            }
+            // 鏈綋銇繚瀛樸仐銇熺磵鍏ユ鍣ㄣ亴銇傘倢銇板墛闄�
+            List<Maintenance_Contract_Asset_Estimate__c> selectedAsset = [SELECT Id, Name, Maintenance_Contract_Estimate__c, Asset__c, IsNew__c FROM Maintenance_Contract_Asset_Estimate__c WHERE Maintenance_Contract_Estimate__c = :this.targetEstimateId];
+            if (selectedAsset.size() > 0) {
+                ControllerUtil.deleteMaintenance_Contract_Asset_Estimate(selectedAsset);
+            }
+            if (insertTarget.size() > 0) {
+                ControllerUtil.insertMaintenance_Contract_Asset_Estimate(insertTarget);
+            }
+    
+            // 鈶� start
+            for (List<Maintenance_Contract_Asset__c> oldList : [select Id from Maintenance_Contract_Asset__c
+                                                                where Maintenance_Contract__c = :this.estimate.Maintenance_Contract__c]) {
+                delete oldList;
+            }
+            // 鈶� start
+            {
+                List<Maintenance_Contract_Asset__c> newValue = new List<Maintenance_Contract_Asset__c>();
+                for (Maintenance_Contract_Asset_Estimate__c target : [select Id, Asset__c, Estimate_List_Price__c, Estimate_Cost__c,
+                                                                      //add 鐐规鏀瑰杽锛氬悎鍚屼繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄涓庢姤浠蜂繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄鍚屾 2021.6.9 fxk start
+                                                                      Check_Object__c,
+                                                                      //add 鐐规鏀瑰杽锛氬悎鍚屼繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄涓庢姤浠蜂繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄鍚屾 2021.6.9 fxk end
+                                                                      IsNew__c, EquipmentGuaranteeFlgTxt__c,
+                                                                      // Gzw 20200807 浜斾釜鍘诲勾鍚堝悓鐩稿叧锛屾墍浠ユ姤浠蜂骇鍝侊紝鑾峰彇涓婃湡鍚堝悓 start
+                                                                      Last_MContract__c
+                                                                      // Gzw 20200807 浜斾釜鍘诲勾鍚堝悓鐩稿叧锛屾墍浠ユ姤浠蜂骇鍝侊紝鑾峰彇涓婃湡鍚堝悓 eng
+                                                                      , Last_MContract__r.RecordType_DeveloperName__c
+                                                                      // LJPH-C9GD34 gzw fix start
+                                                                      ,Estimate_List_Price_Page__c
+                                                                      // LJPH-C9GD34 gzw fix end
+                                                                      from Maintenance_Contract_Asset_Estimate__c
+                                                                      where Maintenance_Contract_Estimate__c = :this.estimate.Id and Asset__c <> null]) {
+    
+                    Maintenance_Contract_Asset__c newVal = new Maintenance_Contract_Asset__c(
+                        Maintenance_Contract__c = this.estimate.Maintenance_Contract__c,
+                        Asset__c = target.Asset__c,
+                        Maintenance_Contract_Asset_Estimate__c = target.Id,
+                        Estimate_List_Price__c = target.Estimate_List_Price__c,
+                        //Maintenance_Price_YearTXT__c = target.Maintenance_Price_YearTXT__c,
+                        Estimate_IsNew__c = target.IsNew__c,
+                        //add 鐐规鏀瑰杽锛氬悎鍚屼繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄涓庢姤浠蜂繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄鍚屾 2021.6.9 fxk start
+                        Check_Object__c = target.Check_Object__c,
+                        //add 鐐规鏀瑰杽锛氬悎鍚屼繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄涓庢姤浠蜂繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄鍚屾 2021.6.9 fxk end
+                        //EquipmentGuaranteeFlgTxt__c = target.EquipmentGuaranteeFlgTxt__c,
+                        // Gzw 20200807 浜斾釜鍘诲勾鍚堝悓鐩稿叧锛屾墍浠ユ姤浠蜂骇鍝侊紝鑾峰彇涓婃湡鍚堝悓 start
+                        // LastMContract__c = target.Last_MContract__c
+                        // Gzw 20200807 浜斾釜鍘诲勾鍚堝悓鐩稿叧锛屾墍浠ユ姤浠蜂骇鍝侊紝鑾峰彇涓婃湡鍚堝悓 end
+                        //濡傛灉鏄骞翠繚淇悎鍚�,涓嶆洿鏂颁笂鏈熺淮淇悎鍚屼俊鎭� LJPH-BUU3E3 update by rentx  2020-11-03
+                        LastMContract__c = target.Last_MContract__r.RecordType_DeveloperName__c == 'VM_Contract' ? null : target.Last_MContract__c
+                        );
+                    newValue.add(newVal);
+                }
+                if (newValue.size() > 0) insert newValue;
+            }
+            // 鈶� start
+            this.contract.Estimation_Id__c = this.targetEstimateId;     
+            this.contract.Contract_Esti_Start_Date__c = this.estimate.Contract_Esti_Start_Date__c;
+            this.contract.Contract_Range__c = this.estimate.Contract_Range__c;
+            this.contract.Contract_Esti_End_Date__c = this.estimate.Contract_Esti_End_Date__c;
+            this.contract.Estimate_Target__c = this.estimate.Estimate_Target__c;
+            this.contract.Dealer__c = this.estimate.Dealer__c;
+            this.contract.old_Is_RecognitionModel__c = this.estimate.Is_RecognitionModel__c;
+            this.contract.NotUse_Oxygenated_Water__c = this.estimate.NotUse_Oxygenated_Water__c;
+            this.contract.Estimate_Trial_Money__c = this.estimate.Estimate_Trial_Money__c;
+            this.contract.Contract_Amount__c = this.estimate.Maintenance_Price__c;
+            // 鐐规鎬绘鏁拌嚜鍔ㄨ祴鍊� gzw fix 20211122 start
+            // this.contract.Service_contract_target_number__c = this.estimate.Service_contract_target_number__c;
+            // 鐐规鎬绘鏁拌嚜鍔ㄨ祴鍊� gzw fix 20211122 end
+            this.contract.Contract_department_manual__c = this.estimate.Department__c;
+    
+            // 杩藉姞涓婃湡鍚堝悓淇℃伅 start
+            this.contract.LastMContract1__c = this.estimate.LastMContract1__c;
+            this.contract.LastMContract1_NO__c = this.estimate.LastMContract1_NO__c;
+            this.contract.LastMContract1_ConCount__c =  this.estimate.LastMContract1_ConCount__c;
+    
+            //add by rentx 2021-04-22 缁欏悎鍚�1璧嬪�肩殑鍚屾椂锛岀粰鍘诲勾鍚堝悓璧嬪�� start
+            this.contract.Last_year_service_contract__c = this.estimate.LastMContract1__c;
+            //add by renrx 2021-04-22 缁欏悎鍚�1璧嬪�肩殑鍚屾椂, 缁欏幓骞村悎鍚岃祴鍊� end
+    
+            this.contract.LastMContract2__c =  this.estimate.LastMContract2__c;
+            this.contract.LastMContract2_NO__c = this.estimate.LastMContract2_NO__c;
+            this.contract.LastMContract2_ConCount__c =  this.estimate.LastMContract2_ConCount__c;
+    
+            this.contract.LastMContract3__c =  this.estimate.LastMContract3__c;
+            this.contract.LastMContract3_NO__c = this.estimate.LastMContract3_NO__c;
+            this.contract.LastMContract3_ConCount__c =  this.estimate.LastMContract3_ConCount__c;
+    
+            this.contract.LastMContract4__c =  this.estimate.LastMContract4__c;
+            this.contract.LastMContract4_NO__c = this.estimate.LastMContract4_NO__c;
+            this.contract.LastMContract4_ConCount__c =  this.estimate.LastMContract4_ConCount__c;
+    
+            this.contract.LastMContract5__c =  this.estimate.LastMContract5__c;
+            this.contract.LastMContract5_NO__c = this.estimate.LastMContract5_NO__c;
+            this.contract.LastMContract5_ConCount__c =  this.estimate.LastMContract5_ConCount__c;
+            // 杩藉姞涓婃湡鍚堝悓淇℃伅 end
+    
+            system.debug('娴嬬畻isDecide鐨勭粨鏋淿1::::::::' + isDecide);
+            if (isDecide == true) {
+                system.debug('娴嬬畻isDecide鐨勭粨鏋淿2::::::::' + isDecide);
+                //              this.contract.Contract_Start_Date__c = this.estimate.Contract_Esti_Start_Date__c;
+                this.contract.Contract_Start_Date__c = this.estimate.Contract_Start_Date__c;
+                this.contract.Contract_Range__c = this.estimate.Contract_Range__c;
+                //              this.contract.Contract_End_Date__c = this.estimate.Contract_Esti_End_Date__c;
+                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;
+                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;
+                // JZHG-BQV3P4 20200624 Gzw add
+                this.contract.HospitalAmountText__c = this.estimate.AgencyHos_Price__c;
+                // JZHG-BQV3P4 20200624 Gzw add
+            }
+            //娣诲姞鐨勯澶栧搴旇繃绋�
+            if (inDicideFlag == true && (this.contract.Contract_Start_Date__c == null || this.contract.Contract_End_Date__c == null)) {
+                system.debug('娴嬬畻inDicideFlag鐨勭粨鏋淿2::::::::' + isDecide);
+                //              this.contract.Contract_Start_Date__c = this.estimate.Contract_Esti_Start_Date__c;
+                this.contract.Contract_Start_Date__c = this.estimate.Contract_Start_Date__c;
+                this.contract.Contract_Range__c = this.estimate.Contract_Range__c;
+                //              this.contract.Contract_End_Date__c = this.estimate.Contract_Esti_End_Date__c;
+                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;
+                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;
+                // JZHG-BQV3P4 20200624 Gzw add
+                this.contract.HospitalAmountText__c = this.estimate.AgencyHos_Price__c;
+                // JZHG-BQV3P4 20200624 Gzw add
+            }
+            String oldProcessStatus = this.estimate.Process_Status__c;
+            try {
+                if (mcList.size() > 0) {
+                    ControllerUtil.updMcList(mcList.values());
+                }
+                ControllerUtil.updateMaintenance_Contract_Estimate(new Maintenance_Contract_Estimate__c[] {this.estimate});
+                update this.contract;
+            } catch (Exception e) {
+                // TODO 浠婂緦瑜囨暟浠躲伄鍫村悎銇┿亞銇欍倠锛�
+                this.estimate.addError(e);
+                // 涓�閮ㄣ伄鍊ゃ倰鎴汇仚
+                this.estimate.Process_Status__c = oldProcessStatus;
+                hasDatabaseError = true;
+                Database.rollback(sp);
+                ApexPages.addMessages(e);
+            }
+            if (hasDatabaseError) {
+                System.debug('syncEstimate hasDatabaseError');
+                return false;
+            }
+            if (isApproval) {
+                SelectAssetEstimateVMController.ComputeLTYRepair(targetEstimateId);
+            }
+            return true;
+        } catch (DMLException ex) {
+            // TODO Insert澶辨晽銇甀D銈掓秷銇欏繀瑕侊紵
+            Database.rollback(sp);
+            ApexPages.addMessages(ex);
+        } catch (Exception ex) {
+            Database.rollback(sp);
+            ApexPages.addMessages(ex);
         }
-        if (hasDatabaseError) {
-          System.debug('syncEstimate hasDatabaseError');
-          return false;
-        }
-        if (isApproval) {
-          SelectAssetEstimateVMController.ComputeLTYRepair(targetEstimateId);
-        }
-        return true;
-      } catch (DMLException ex) {
-        // TODO Insert澶辨晽銇甀D銈掓秷銇欏繀瑕侊紵
-        Database.rollback(sp);
-        ApexPages.addMessages(ex);
-      } catch (Exception ex) {
-        Database.rollback(sp);
-        ApexPages.addMessages(ex);
-      }
-      return false;
+        return false;
     }
     
     /**
@@ -2687,307 +2702,335 @@
      */
     @TestVisible
     private Boolean checkChangedAfterPrint() {
-      System.debug('checkChangedAfterPrint start');
-      if (changedAfterPrint) {
-        this.targetEstimateId = null;
-        this.estimate = this.estimate.clone();
-        this.estimate.IS_Clone_After_Decide__c = true;
-        this.estimate.PrintDate__c = null;
-        this.estimate.Quote_Date__c = null;
-        this.estimate.Print_Contract__c = false;
-        this.estimate.Print_RepairPrice__c = false;
-        this.estimate.Print_DiscountPercentage__c = false;
-        this.estimate.Print_DiscountPrice__c = false;
-        this.estimate.Print_ListPrice__c = false;
-        //鎵撳嵃鎶ヤ环锛堢畝鍖栫増锛� 2019/12/18 start
-        this.estimate.Print_Simplify__c = false;
-        //鎵撳嵃鎶ヤ环锛堢畝鍖栫増锛� 2019/12/18 end
-        this.estimate.Print_MaintePrice__c = false;
-        this.estimate.Print_SumPrice__c = false;
-        this.estimate.NotUse_Oxygenated_Water__c = false;
-        this.estimate.Contract_Esti_Start_Date__c = this.estimate.Contract_Start_Date__c;
-        //this.estimate.Process_Status__c = '鑽夋涓�';
-      }
-      return changedAfterPrint;
+        System.debug('checkChangedAfterPrint start');
+        if (changedAfterPrint) {
+            this.targetEstimateId = null;
+            this.estimate = this.estimate.clone();
+            this.estimate.IS_Clone_After_Decide__c = true;
+            this.estimate.PrintDate__c = null;
+            this.estimate.Quote_Date__c = null;
+            this.estimate.Print_Contract__c = false;
+            this.estimate.Print_RepairPrice__c = false;
+            this.estimate.Print_DiscountPercentage__c = false;
+            this.estimate.Print_DiscountPrice__c = false;
+            this.estimate.Print_ListPrice__c = false;
+            //鎵撳嵃鎶ヤ环锛堢畝鍖栫増锛� 2019/12/18 start
+            this.estimate.Print_Simplify__c = false;
+            //鎵撳嵃鎶ヤ环锛堢畝鍖栫増锛� 2019/12/18 end
+            this.estimate.Print_MaintePrice__c = false;
+            this.estimate.Print_SumPrice__c = false;
+            this.estimate.NotUse_Oxygenated_Water__c = false;
+            this.estimate.Contract_Esti_Start_Date__c = this.estimate.Contract_Start_Date__c;
+            //this.estimate.Process_Status__c = '鑽夋涓�';
+        }
+        return changedAfterPrint;
     }
     /**
      * 琛岃拷鍔�(10琛屻仛銇�)銆佸墠鎻愬繀銇氭渶寰�
      */
     
     public PageReference addNewRows() {
-      for (Integer i = 0; i < 10; i++) {
-        checkedAssets.add(new AssetInfo(checkedAssets.size()));
-      }
-      // ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '淇濇湁璁惧' + checkedAssets.size()));
-      return null;
+        for (Integer i = 0; i < 10; i++) {
+            checkedAssets.add(new AssetInfo(checkedAssets.size()));
+        }
+        // ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '淇濇湁璁惧' + checkedAssets.size()));
+        return null;
     }
     
     
     
     /** 淇濆瓨杩斿洖 **/
     public PageReference saveAndCancel () {
-      //add by rentx 2020-11-13 LJPH-BV93RZ start
-      if (estimate.Contract_Range__c == null) {
-        this.estimate.Contract_Range__c.addError('蹇呴』杈撳叆鍚堝悓鏈堟暟!');
-        return null;
-      }
-      //add by rentx 2020-11-13 LJPH-BV93RZ end
-      if (syncEstimate(false, false)) {
-        PageReference ret = null;
-        if (this.targetMaintenanceContractId != null) {
-          ret = new PageReference('/' + this.targetMaintenanceContractId);
+        //add by rentx 2020-11-13 LJPH-BV93RZ start
+        if (estimate.Contract_Range__c == null) {
+            this.estimate.Contract_Range__c.addError('蹇呴』杈撳叆鍚堝悓鏈堟暟!');
+            return null;
         }
-        return ret;
-      }
-      return null;
+        //add by rentx 2020-11-13 LJPH-BV93RZ end
+        if (syncEstimate(false, false)) {
+            PageReference ret = null;
+            if (this.targetMaintenanceContractId != null) {
+                ret = new PageReference('/' + this.targetMaintenanceContractId);
+            }
+            return ret;
+        }
+        return null;
     }
     
     /**
      * 銈儯銉炽偦銉儭銈姐儍銉�
      */
     public PageReference cancel() {
-      PageReference ret = null;
-      if (this.targetMaintenanceContractId != null) {
-        ret = new PageReference('/' + this.targetMaintenanceContractId);
-      }
-      return ret;
+        PageReference ret = null;
+        if (this.targetMaintenanceContractId != null) {
+            ret = new PageReference('/' + this.targetMaintenanceContractId);
+        }
+        return ret;
     }
+    
+    //add     wangweipeng                     2021/12/26                 start
+    //鑾峰彇褰撳墠閫変腑鐨勭粡閿�鍟嗘槸鍚︿负鍏堟鏍囪瘑
+    public PageReference onChDealerUpdate(){
+        //checkDealerId  姝ゅ彉閲忓彲鑳戒細瀛� 缁忛攢鍟唅d鎴栫粡閿�鍟嗕腑鏂囧悕
+        if(String.isNotBlank(checkDealerId)){
+            try {
+                List<Account> accListC = [select id,name,FirstParagraphEnd__c from Account where id = :checkDealerId OR name = :checkDealerId];
+                if(accListC != null && accListC.size() == 1){
+                    if(accListC[0].FirstParagraphEnd__c){
+                        this.estimate.Is_RecognitionModel__c = true;
+                    }else{
+                        this.estimate.Is_RecognitionModel__c = false;
+                    }
+                }else{
+                    this.estimate.Is_RecognitionModel__c = false;
+                }
+            } catch (Exception e) {
+                //return 'McaeList Update Failed : '+e;
+            }
+        }else{
+            this.estimate.Is_RecognitionModel__c = false;
+        }
+        System.debug('----------------23--'+this.estimate.Is_RecognitionModel__c);
+        return null;
+    }
+    //add     wangweipeng                     2021/12/26                 end
+    
     
     // 2021-02-07  gzw add  LJPH-BWY5QB start
     private void setEndUserType(String id) {
-      this.contract = [SELECT Id, Name, Status__c, Decided_Estimation__c, Service_Contract_Staff__c,
-               Estimate_Num__c, Management_Code__c, Hospital__c,
-               Hospital__r.MaintenanceContractUserType__c,
-               Contract_Start_Date__c, Contract_End_Date__c
-               FROM Maintenance_Contract__c WHERE Id = :id];
-      if (this.estimate.Process_Status__c == '鑽夋涓�' || String.IsBlank(this.estimate.Process_Status__c)) {
+        this.contract = [SELECT Id, Name, Status__c, Decided_Estimation__c, Service_Contract_Staff__c,
+                         Estimate_Num__c, Management_Code__c, Hospital__c,
+                         Hospital__r.MaintenanceContractUserType__c,
+                         Contract_Start_Date__c, Contract_End_Date__c
+                         FROM Maintenance_Contract__c WHERE Id = :id];
+        if (this.estimate.Process_Status__c == '鑽夋涓�' || String.IsBlank(this.estimate.Process_Status__c)) {
     
-        this.estimate.EndUserType__c = this.contract.Hospital__r.MaintenanceContractUserType__c == false ? '鏂扮敤鎴�' : '鏃㈡湁鐢ㄦ埛';
-      }
+            this.estimate.EndUserType__c = this.contract.Hospital__r.MaintenanceContractUserType__c == false ? '鏂扮敤鎴�' : '鏃㈡湁鐢ㄦ埛';
+        }
     }
     // 2021-02-07  gzw add  LJPH-BWY5QB end
     
     private void setContractInfo(String id) {
-      this.contract = [SELECT Id, Name, Status__c, Decided_Estimation__c, Service_Contract_Staff__c,
-               Estimate_Num__c, Management_Code__c, Hospital__c,
-               //2021-01-18  mzy add  LJPH-BWY5QB   瀹㈡埛涓婄殑 缁翠慨鍚堝悓鐢ㄦ埛绫诲瀷 涓簍rue /false,鎶ヤ环 鐢ㄦ埛绫诲瀷涓� 鏃㈡湁鐢ㄦ埛 / 鏂扮敤鎴�
-               // Hospital__r.MaintenanceContractUserType__c,
-               //2021-01-18  mzy add  LJPH-BWY5QB   瀹㈡埛涓婄殑 缁翠慨鍚堝悓鐢ㄦ埛绫诲瀷 涓簍rue /false,鎶ヤ环 鐢ㄦ埛绫诲瀷涓� 鏃㈡湁鐢ㄦ埛 / 鏂扮敤鎴�
-               Contract_Start_Date__c, Contract_End_Date__c
-               FROM Maintenance_Contract__c WHERE Id = :id];
-      this.targetHospitalId = this.contract.Hospital__c;
-      // 2021-01-18  mzy  add LJPH-BWY5QB   瀹㈡埛涓婄殑 缁翠慨鍚堝悓鐢ㄦ埛绫诲瀷 涓簍rue /false,鎶ヤ环 鐢ㄦ埛绫诲瀷涓� 鏃㈡湁鐢ㄦ埛 / 鏂扮敤鎴�
-      // if(this.estimate.Process_Status__c == '鑽夋涓�' || String.IsBlank(this.estimate.Process_Status__c)){
+        this.contract = [SELECT Id, Name, Status__c, Decided_Estimation__c, Service_Contract_Staff__c,
+                         Estimate_Num__c, Management_Code__c, Hospital__c,
+                         //2021-01-18  mzy add  LJPH-BWY5QB   瀹㈡埛涓婄殑 缁翠慨鍚堝悓鐢ㄦ埛绫诲瀷 涓簍rue /false,鎶ヤ环 鐢ㄦ埛绫诲瀷涓� 鏃㈡湁鐢ㄦ埛 / 鏂扮敤鎴�
+                         // Hospital__r.MaintenanceContractUserType__c,
+                         //2021-01-18  mzy add  LJPH-BWY5QB   瀹㈡埛涓婄殑 缁翠慨鍚堝悓鐢ㄦ埛绫诲瀷 涓簍rue /false,鎶ヤ环 鐢ㄦ埛绫诲瀷涓� 鏃㈡湁鐢ㄦ埛 / 鏂扮敤鎴�
+                         Contract_Start_Date__c, Contract_End_Date__c
+                         FROM Maintenance_Contract__c WHERE Id = :id];
+        this.targetHospitalId = this.contract.Hospital__c;
+        // 2021-01-18  mzy  add LJPH-BWY5QB   瀹㈡埛涓婄殑 缁翠慨鍚堝悓鐢ㄦ埛绫诲瀷 涓簍rue /false,鎶ヤ环 鐢ㄦ埛绫诲瀷涓� 鏃㈡湁鐢ㄦ埛 / 鏂扮敤鎴�
+        // if(this.estimate.Process_Status__c == '鑽夋涓�' || String.IsBlank(this.estimate.Process_Status__c)){
     
-      //    this.estimate.EndUserType__c = this.contract.Hospital__r.MaintenanceContractUserType__c == false ? '鏂扮敤鎴�' : '鏃㈡湁鐢ㄦ埛';
-      // }
-      // 2021-01-18  mzy  add LJPH-BWY5QB   瀹㈡埛涓婄殑 缁翠慨鍚堝悓鐢ㄦ埛绫诲瀷 涓簍rue /false,鎶ヤ环 鐢ㄦ埛绫诲瀷涓� 鏃㈡湁鐢ㄦ埛 / 鏂扮敤鎴�
+        //    this.estimate.EndUserType__c = this.contract.Hospital__r.MaintenanceContractUserType__c == false ? '鏂扮敤鎴�' : '鏃㈡湁鐢ㄦ埛';
+        // }
+        // 2021-01-18  mzy  add LJPH-BWY5QB   瀹㈡埛涓婄殑 缁翠慨鍚堝悓鐢ㄦ埛绫诲瀷 涓簍rue /false,鎶ヤ环 鐢ㄦ埛绫诲瀷涓� 鏃㈡湁鐢ㄦ埛 / 鏂扮敤鎴�
     }
     
     private Boolean checkValidate() {
-      Boolean rtn = true;
-      Date today = Date.today();
-      if (getPageDisabled()) {
-        today = estimate.Submit_quotation_day__c;
-      }
-      // 2021-02-26  mzy  LJPH-BX9CVX  add 鑾峰彇鍚堝悓缁撴潫鏃ュ拰鍚堝悓鏈堟暟 start
-      //鍚堝悓鏈堟暟
-      Decimal ContractRange = this.estimate.Contract_Range__c;
-      //鍚堝悓棰勫畾缁撴潫鏃ユ湡
-      Date t = this.estimate.Contract_Esti_Start_Date__c.addMonths(Integer.valueOf(this.estimate.Contract_Range__c));
-      if (this.estimate.Contract_Esti_Start_Date__c.month() == 2 && this.estimate.Contract_Esti_Start_Date__c.day() == 29
-        && t.month() == 2) {
-        t = t;
-      } else {
+        Boolean rtn = true;
+        Date today = Date.today();
+        if (getPageDisabled()) {
+            today = estimate.Submit_quotation_day__c;
+        }
+        // 2021-02-26  mzy  LJPH-BX9CVX  add 鑾峰彇鍚堝悓缁撴潫鏃ュ拰鍚堝悓鏈堟暟 start
+        //鍚堝悓鏈堟暟
+        Decimal ContractRange = this.estimate.Contract_Range__c;
+        //鍚堝悓棰勫畾缁撴潫鏃ユ湡
+        Date t = this.estimate.Contract_Esti_Start_Date__c.addMonths(Integer.valueOf(this.estimate.Contract_Range__c));
+        if (this.estimate.Contract_Esti_Start_Date__c.month() == 2 && this.estimate.Contract_Esti_Start_Date__c.day() == 29
+            && t.month() == 2) {
+            t = t;
+        } else {
+            t = t.addDays(-1);
+        }
+        this.estimate.Contract_Esti_End_Date__c  = t;
+        // 鍚堝悓寮�濮嬫棩銈掔粨鏉熸棩
+        if (this.estimate.Contract_Start_Date__c == null) {
+            this.estimate.Contract_Start_Date__c = this.estimate.Contract_Esti_Start_Date__c;
+        }
+        t = this.estimate.Contract_Start_Date__c.addMonths(Integer.valueOf(this.estimate.Contract_Range__c));
         t = t.addDays(-1);
-      }
-      this.estimate.Contract_Esti_End_Date__c  = t;
-      // 鍚堝悓寮�濮嬫棩銈掔粨鏉熸棩
-      if (this.estimate.Contract_Start_Date__c == null) {
-        this.estimate.Contract_Start_Date__c = this.estimate.Contract_Esti_Start_Date__c;
-      }
-      t = this.estimate.Contract_Start_Date__c.addMonths(Integer.valueOf(this.estimate.Contract_Range__c));
-      t = t.addDays(-1);
-      this.estimate.Contract_End_Date__c = t;
-      Date ContractEndDate = this.estimate.Contract_End_Date__c;
-      System.debug('鍚堝悓缁撴潫鏃ユ湡 :' + ContractEndDate);
-      // 2021-02-26  mzy  LJPH-BX9CVX  add 鑾峰彇鍚堝悓缁撴潫鏃ュ拰鍚堝悓鏈堟暟 end
-      // 閮ㄥ搧渚涚郸鍋滄銇=鍝併伅銈ㄣ儵銉�
-      for (AssetInfo input : this.checkedAssets) {
-        //濡傛灉鏄墜鍔ㄤ骇鍝�
-        // 20210121 gzw 鏈嶅姟鍚堝悓涔熼獙璇佽澶囦环鏍兼槸鍚︿负绌� start
-        if (!input.isManual || input.isManual && !String.isBlank(input.mcae.Product_Manual__c)) {
-          // if (input.isManual && !String.isBlank(input.mcae.Product_Manual__c)) {
-          // 20210121 gzw 鏈嶅姟鍚堝悓涔熼獙璇佽澶囦环鏍兼槸鍚︿负绌� end
-          if (input.mcae.Estimate_List_Price__c == null || input.mcae.Estimate_List_Price__c == 0) {
-            //update by rentx 2020-11-12 LJPH-BV93RZ start
-            // input.mcae.Product_Manual__c.addError(System.Label.Error_Message47);
-            //add by rentx 2021-01-25 start
-            //濡傛灉淇濇湁璁惧涓嶄负绌虹殑璇濆湪淇濇湁璁惧涓婃姤閿�
-            if (input.rec != null) {
-              input.rec.Name.addError(input.rec.Name + ' (鏈鸿韩缂栫爜涓�:' + input.rec.SerialNumber + ') 鏃犲悎鍚岄噾棰�,涓嶅缓璁弬淇�');
+        this.estimate.Contract_End_Date__c = t;
+        Date ContractEndDate = this.estimate.Contract_End_Date__c;
+        System.debug('鍚堝悓缁撴潫鏃ユ湡 :' + ContractEndDate);
+        // 2021-02-26  mzy  LJPH-BX9CVX  add 鑾峰彇鍚堝悓缁撴潫鏃ュ拰鍚堝悓鏈堟暟 end
+        // 閮ㄥ搧渚涚郸鍋滄銇=鍝併伅銈ㄣ儵銉�
+        for (AssetInfo input : this.checkedAssets) {
+            //濡傛灉鏄墜鍔ㄤ骇鍝�
+            // 20210121 gzw 鏈嶅姟鍚堝悓涔熼獙璇佽澶囦环鏍兼槸鍚︿负绌� start
+            if (!input.isManual || input.isManual && !String.isBlank(input.mcae.Product_Manual__c)) {
+                // if (input.isManual && !String.isBlank(input.mcae.Product_Manual__c)) {
+                // 20210121 gzw 鏈嶅姟鍚堝悓涔熼獙璇佽澶囦环鏍兼槸鍚︿负绌� end
+                if (input.mcae.Estimate_List_Price__c == null || input.mcae.Estimate_List_Price__c == 0) {
+                    //update by rentx 2020-11-12 LJPH-BV93RZ start
+                    // input.mcae.Product_Manual__c.addError(System.Label.Error_Message47);
+                    //add by rentx 2021-01-25 start
+                    //濡傛灉淇濇湁璁惧涓嶄负绌虹殑璇濆湪淇濇湁璁惧涓婃姤閿�
+                    if (input.rec != null) {
+                        input.rec.Name.addError(input.rec.Name + ' (鏈鸿韩缂栫爜涓�:' + input.rec.SerialNumber + ') 鏃犲悎鍚岄噾棰�,涓嶅缓璁弬淇�');
     
-            } else
-            //add by rentx 2021-01-25 end
-            if (String.isNotBlank(input.proName)) {
-              input.mcae.Product_Manual__c.addError(System.Label.Error_Message47 + '(' + input.proName + ')');
+                    } else
+                    //add by rentx 2021-01-25 end
+                    if (String.isNotBlank(input.proName)) {
+                        input.mcae.Product_Manual__c.addError(System.Label.Error_Message47 + '(' + input.proName + ')');
+                    }
+                    //update by rentx 2020-11-12 LJPH-BV93RZ end
+                    rtn = false;
+                }
             }
-            //update by rentx 2020-11-12 LJPH-BV93RZ end
-            rtn = false;
-          }
+            if (!input.isManual) {
+                //update by rentx 2020-11-13 start
+                if (!Test.isRunningTest() && (input.mcae.Adjustment_Upper_price__c == null || input.mcae.Adjustment_Upper_price__c == 0) ) {
+                    // input.mcae.Adjustment_Upper_price__c.addError(input.rec.Name + '('+ input.rec.SerialNumber + ') 绛剧害浠锋牸涓�0锛�-- 寤鸿鍏堜笌鏈嶅姟鍟嗗搧閮ㄥ挩璇㈠悗鍐嶆彁浜ゆ姤浠枫��');
+                    input.mcae.Adjustment_Upper_price__c.addError(input.proSerialName + '(' + input.proSerialNumber + ') 绛剧害浠锋牸涓�0锛�-- 寤鸿鍏堜笌鏈嶅姟鍟嗗搧閮ㄥ挩璇㈠悗鍐嶆彁浜ゆ姤浠枫��');
+                    rtn = false;
+                }
+                if (!Test.isRunningTest() && (input.mcae.Adjustment_Lower_price__c == null || input.mcae.Adjustment_Lower_price__c == 0) ) {
+                    input.mcae.Adjustment_Lower_price__c.addError(input.proSerialName + '(' + input.proSerialNumber + ') 绛剧害浠锋牸涓�0锛�-- 寤鸿鍏堜笌鏈嶅姟鍟嗗搧閮ㄥ挩璇㈠悗鍐嶆彁浜ゆ姤浠枫��');
+                    // input.mcae.Adjustment_Lower_price__c.addError(input.rec.Name + '('+ input.rec.SerialNumber + ') 绛剧害浠锋牸涓�0锛�-- 寤鸿鍏堜笌鏈嶅姟鍟嗗搧閮ㄥ挩璇㈠悗鍐嶆彁浜ゆ姤浠枫��');
+                    rtn = false;
+                }
+                //update by rentx 2020-11-13 end
+    
+                //1.鍚堝悓鏈熶笉婊′竴骞存椂锛屽悎鍚屾湡瓒呰繃涓�鍗婃墠鍙紑濮嬬画绛炬姤浠枫��(eg:11涓湀鐨勫悎鍚屼粠6涓湀鍚庢墠鍙姤浠枫��)
+                //2.涓�骞翠互涓婄殑鍚堝悓锛屽湪缁撴潫鍓�6涓湀寮�濮嬪彲浠ュ紑鏀剧画绛炬姤浠枫��
+                //3.绠$悊鍛樿烦杩囷紝
+                if (UserInfo.getProfileId() != System.Label.ProfileId_SystemAdmin && String.isNotBlank(input.rec.CurrentContract_F__c) && input.rec.CurrentContract_F__r.RecordType_DeveloperName__c != 'VM_Contract') {
+    
+                    Integer noOfDays = today.daysBetween(input.rec.CurrentContract_F__r.Contract_End_Date__c);
+                    Decimal monthCon = (Decimal)noOfDays / 365 * 12;
+                    // 鍙紑濮嬫姤浠风殑鏈堟暟闄愬埗
+                    if (input.rec.CurrentContract_F__r.Contract_Range__c >= 12 && monthCon > 6) {
+                        input.rec.Name.addError(input.rec.Name + '(' + input.rec.SerialNumber + ') -- 鍚堝悓缁撴潫鍓�6涓湀寮�濮嬪彲浠ュ埗浣滄姤浠枫��');
+                        rtn = false;
+                    }
+                    //ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '---' + monthCon  + ' +++ ' + Math.floor(input.rec.CurrentContract_F__r.Contract_Range__c/2)));
+                    //rtn = false;
+                    if (input.rec.CurrentContract_F__r.Contract_Range__c < 12 && monthCon > Math.floor(input.rec.CurrentContract_F__r.Contract_Range__c / 2)) {
+                        input.rec.Name.addError(input.rec.Name + '(' + input.rec.SerialNumber + ') -- 缁忓巻鏈堟暟杩囧崐鏂瑰彲鍒朵綔鎶ヤ环');
+                        rtn = false;
+                    }
+                }
+                // 澶氬勾淇濆垽鏂�
+                if ( String.isNotBlank(input.rec.CurrentContract_F__c) && input.rec.CurrentContract_F__r.RecordType_DeveloperName__c == 'VM_Contract') {
+                    //if (UserInfo.getProfileId() != System.Label.ProfileId_SystemAdmin && String.isNotBlank(input.rec.CurrentContract_F__c) && input.rec.CurrentContract_F__r.RecordType_DeveloperName__c == 'VM_Contract') {
+    
+                    //Integer noOfDays = today.daysBetween(input.rec.CurrentContract_F_asset__r.endDateGurantee_Text__c);
+                    //Decimal monthCon = (Decimal)noOfDays/365*12;
+                    // 鍙紑濮嬫姤浠风殑鏈堟暟闄愬埗
+                    if (input.rec.CurrentContract_F__r.Gurantee_Estimate_startDate__c > Date.today()) {
+                        input.rec.Name.addError(input.rec.Name + '(' + input.rec.SerialNumber + ') -- 鍚堝悓缁撴潫鍓�6涓湀寮�濮嬪彲浠ュ埗浣滄姤浠枫��');
+                        rtn = false;
+                    }
+                }
+                //ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '---' + input.rec.CurrentContract_F__r.Contract_End_Date__c));
+                if (inDicideFlag && String.isNotBlank(input.rec.CurrentContract_F__c) && estimate.Skip_DJ__c == false ) {
+                    //ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '+++' + input.rec.CurrentContract_F__r.Contract_End_Date__c));
+                    // 鍚堝悓寮�濮嬫棩澶т簬涓婃湡鍚堝悓缁撴潫鏃ュ姞涓�涓湀锛屼笖娌℃湁鐐规鏃ユ湡鎴栬�呮渶杩戜竴娆$偣妫�鏃ユ湡鏄�3涓湀鍓�  鎶ラ敊
+                    if (estimate.Contract_Start_Date__c > input.rec.CurrentContract_F__r.Contract_End_Date__c.addMonths(1)
+                        && (input.rec.Final_Examination_Date__c == null
+                            || input.rec.Final_Examination_Date__c < estimate.Contract_Start_Date__c.addMonths(-3))) {
+                        input.rec.Name.addError(input.rec.Name + '(' + input.rec.SerialNumber + ') -- 娌℃湁鏈�鏂扮殑鐐规璁板綍');
+                        rtn = false;
+                    }
+                }
+    
+                if (isSaveOrApproval) {
+                    if (input.rec.IF_Warranty__c == '鍚�') {
+                        input.rec.Name.addError(input.rec.Name + '(' + input.rec.SerialNumber + ') -- 涓嶈兘閫夋嫨涓嶅彲鍙備繚璁惧');
+                        rtn = false;
+                    }
+                }
+                // 20200805 Gzw Bug淇
+                // isSaveOrApproval = false;
+            }
+    
+            // 2021-03-01 LJPH-BX9CVX mzy  update  濡傛灉鍚堝悓缁撴潫鏃�>鏃犻浂浠堕闄╂棩鏈�  start
+            if (input != null) {
+    
+                //鏍¢獙鏃犻浂浠堕闄�
+                if ( input.rec != null && input.rec.NoPartRiskDate_F__c != null ) {
+                    // 浼犲叆鍙傛暟 : 鏃犻浂浠堕闄╂棩鏈� , 鍙绾︽爣璇� , 鍚堝悓缁撴潫鏃ユ湡 , 鍚堝悓鏈堟暟
+                    String msg = checkAssetInfo(input.rec.NoPartRiskDate_F__c, input.rec.SignableFlag__c, ContractEndDate, ContractRange);
+                    // 鏈夐敊璇俊鎭垯鏄剧ず閿欒淇℃伅
+                    if (msg != '') {
+                        input.rec.Name.addError('[' + input.rec.Name + '] (鏈鸿韩缂栫爜涓�:' + input.rec.SerialNumber + ') ' + msg);
+                        rtn = false;
+                    }
+    
+                }
+                /*else if(input.mcae!=null&&input.mcae.Product_Manual__c !=null&&input.NoPartRiskDate!=null ){
+                        // 浼犲叆鍙傛暟 : 鏃犻浂浠堕闄╂棩鏈� , 鍙绾︽爣璇� , 鍚堝悓缁撴潫鏃ユ湡 , 鍚堝悓鏈堟暟
+                        String msg = checkAssetInfo(input.NoPartRiskDate,input.SignableFlag,ContractEstiEndDate,ContractRange);
+                        // 鏈夐敊璇俊鎭垯鏄剧ず閿欒淇℃伅
+                        if(msg != ''){
+                           input.mcae.Product_Manual__c.addError('['+input.proName2+'] '+msg);
+                           rtn = false;
+                        }
+                   }*/
+            }
+            // 2021-03-01 LJPH-BX9CVX mzy  update  濡傛灉鍚堝悓缁撴潫鏃�>鏃犻浂浠堕闄╂棩鏈�  end
+    
         }
-        if (!input.isManual) {
-          //update by rentx 2020-11-13 start
-          if (!Test.isRunningTest() && (input.mcae.Adjustment_Upper_price__c == null || input.mcae.Adjustment_Upper_price__c == 0) ) {
-            // input.mcae.Adjustment_Upper_price__c.addError(input.rec.Name + '('+ input.rec.SerialNumber + ') 绛剧害浠锋牸涓�0锛�-- 寤鸿鍏堜笌鏈嶅姟鍟嗗搧閮ㄥ挩璇㈠悗鍐嶆彁浜ゆ姤浠枫��');
-            input.mcae.Adjustment_Upper_price__c.addError(input.proSerialName + '(' + input.proSerialNumber + ') 绛剧害浠锋牸涓�0锛�-- 寤鸿鍏堜笌鏈嶅姟鍟嗗搧閮ㄥ挩璇㈠悗鍐嶆彁浜ゆ姤浠枫��');
-            rtn = false;
-          }
-          if (!Test.isRunningTest() && (input.mcae.Adjustment_Lower_price__c == null || input.mcae.Adjustment_Lower_price__c == 0) ) {
-            input.mcae.Adjustment_Lower_price__c.addError(input.proSerialName + '(' + input.proSerialNumber + ') 绛剧害浠锋牸涓�0锛�-- 寤鸿鍏堜笌鏈嶅姟鍟嗗搧閮ㄥ挩璇㈠悗鍐嶆彁浜ゆ姤浠枫��');
-            // input.mcae.Adjustment_Lower_price__c.addError(input.rec.Name + '('+ input.rec.SerialNumber + ') 绛剧害浠锋牸涓�0锛�-- 寤鸿鍏堜笌鏈嶅姟鍟嗗搧閮ㄥ挩璇㈠悗鍐嶆彁浜ゆ姤浠枫��');
-            rtn = false;
-          }
-          //update by rentx 2020-11-13 end
-    
-          //1.鍚堝悓鏈熶笉婊′竴骞存椂锛屽悎鍚屾湡瓒呰繃涓�鍗婃墠鍙紑濮嬬画绛炬姤浠枫��(eg:11涓湀鐨勫悎鍚屼粠6涓湀鍚庢墠鍙姤浠枫��)
-          //2.涓�骞翠互涓婄殑鍚堝悓锛屽湪缁撴潫鍓�6涓湀寮�濮嬪彲浠ュ紑鏀剧画绛炬姤浠枫��
-          //3.绠$悊鍛樿烦杩囷紝
-          if (UserInfo.getProfileId() != System.Label.ProfileId_SystemAdmin && String.isNotBlank(input.rec.CurrentContract_F__c) && input.rec.CurrentContract_F__r.RecordType_DeveloperName__c != 'VM_Contract') {
-    
-            Integer noOfDays = today.daysBetween(input.rec.CurrentContract_F__r.Contract_End_Date__c);
-            Decimal monthCon = (Decimal)noOfDays / 365 * 12;
-            // 鍙紑濮嬫姤浠风殑鏈堟暟闄愬埗
-            if (input.rec.CurrentContract_F__r.Contract_Range__c >= 12 && monthCon > 6) {
-              input.rec.Name.addError(input.rec.Name + '(' + input.rec.SerialNumber + ') -- 鍚堝悓缁撴潫鍓�6涓湀寮�濮嬪彲浠ュ埗浣滄姤浠枫��');
-              rtn = false;
-            }
-            //ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '---' + monthCon  + ' +++ ' + Math.floor(input.rec.CurrentContract_F__r.Contract_Range__c/2)));
-            //rtn = false;
-            if (input.rec.CurrentContract_F__r.Contract_Range__c < 12 && monthCon > Math.floor(input.rec.CurrentContract_F__r.Contract_Range__c / 2)) {
-              input.rec.Name.addError(input.rec.Name + '(' + input.rec.SerialNumber + ') -- 缁忓巻鏈堟暟杩囧崐鏂瑰彲鍒朵綔鎶ヤ环');
-              rtn = false;
-            }
-          }
-          // 澶氬勾淇濆垽鏂�
-          if ( String.isNotBlank(input.rec.CurrentContract_F__c) && input.rec.CurrentContract_F__r.RecordType_DeveloperName__c == 'VM_Contract') {
-            //if (UserInfo.getProfileId() != System.Label.ProfileId_SystemAdmin && String.isNotBlank(input.rec.CurrentContract_F__c) && input.rec.CurrentContract_F__r.RecordType_DeveloperName__c == 'VM_Contract') {
-    
-            //Integer noOfDays = today.daysBetween(input.rec.CurrentContract_F_asset__r.endDateGurantee_Text__c);
-            //Decimal monthCon = (Decimal)noOfDays/365*12;
-            // 鍙紑濮嬫姤浠风殑鏈堟暟闄愬埗
-            if (input.rec.CurrentContract_F__r.Gurantee_Estimate_startDate__c > Date.today()) {
-              input.rec.Name.addError(input.rec.Name + '(' + input.rec.SerialNumber + ') -- 鍚堝悓缁撴潫鍓�6涓湀寮�濮嬪彲浠ュ埗浣滄姤浠枫��');
-              rtn = false;
-            }
-          }
-          //ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '---' + input.rec.CurrentContract_F__r.Contract_End_Date__c));
-          if (inDicideFlag && String.isNotBlank(input.rec.CurrentContract_F__c) && estimate.Skip_DJ__c == false ) {
-            //ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '+++' + input.rec.CurrentContract_F__r.Contract_End_Date__c));
-            // 鍚堝悓寮�濮嬫棩澶т簬涓婃湡鍚堝悓缁撴潫鏃ュ姞涓�涓湀锛屼笖娌℃湁鐐规鏃ユ湡鎴栬�呮渶杩戜竴娆$偣妫�鏃ユ湡鏄�3涓湀鍓�  鎶ラ敊
-            if (estimate.Contract_Start_Date__c > input.rec.CurrentContract_F__r.Contract_End_Date__c.addMonths(1)
-              && (input.rec.Final_Examination_Date__c == null
-                || input.rec.Final_Examination_Date__c < estimate.Contract_Start_Date__c.addMonths(-3))) {
-              input.rec.Name.addError(input.rec.Name + '(' + input.rec.SerialNumber + ') -- 娌℃湁鏈�鏂扮殑鐐规璁板綍');
-              rtn = false;
-            }
-          }
-    
-          if (isSaveOrApproval) {
-            if (input.rec.IF_Warranty__c == '鍚�') {
-              input.rec.Name.addError(input.rec.Name + '(' + input.rec.SerialNumber + ') -- 涓嶈兘閫夋嫨涓嶅彲鍙備繚璁惧');
-              rtn = false;
-            }
-          }
-          // 20200805 Gzw Bug淇
-          // isSaveOrApproval = false;
-        }
-    
-        // 2021-03-01 LJPH-BX9CVX mzy  update  濡傛灉鍚堝悓缁撴潫鏃�>鏃犻浂浠堕闄╂棩鏈�  start
-        if (input != null) {
-    
-          //鏍¢獙鏃犻浂浠堕闄�
-          if ( input.rec != null && input.rec.NoPartRiskDate_F__c != null ) {
-            // 浼犲叆鍙傛暟 : 鏃犻浂浠堕闄╂棩鏈� , 鍙绾︽爣璇� , 鍚堝悓缁撴潫鏃ユ湡 , 鍚堝悓鏈堟暟
-            String msg = checkAssetInfo(input.rec.NoPartRiskDate_F__c, input.rec.SignableFlag__c, ContractEndDate, ContractRange);
-            // 鏈夐敊璇俊鎭垯鏄剧ず閿欒淇℃伅
-            if (msg != '') {
-              input.rec.Name.addError('[' + input.rec.Name + '] (鏈鸿韩缂栫爜涓�:' + input.rec.SerialNumber + ') ' + msg);
-              rtn = false;
-            }
-    
-          }
-          /*else if(input.mcae!=null&&input.mcae.Product_Manual__c !=null&&input.NoPartRiskDate!=null ){
-              // 浼犲叆鍙傛暟 : 鏃犻浂浠堕闄╂棩鏈� , 鍙绾︽爣璇� , 鍚堝悓缁撴潫鏃ユ湡 , 鍚堝悓鏈堟暟
-              String msg = checkAssetInfo(input.NoPartRiskDate,input.SignableFlag,ContractEstiEndDate,ContractRange);
-              // 鏈夐敊璇俊鎭垯鏄剧ず閿欒淇℃伅
-              if(msg != ''){
-                 input.mcae.Product_Manual__c.addError('['+input.proName2+'] '+msg);
-                 rtn = false;
-              }
-             }*/
-        }
-        // 2021-03-01 LJPH-BX9CVX mzy  update  濡傛灉鍚堝悓缁撴潫鏃�>鏃犻浂浠堕闄╂棩鏈�  end
-    
-      }
-      return rtn;
+        return rtn;
     }
     // 2021-03-01 LJPH-BX9CVX mzy  update  濡傛灉鍚堝悓缁撴潫鏃�>鏃犻浂浠堕闄╂棩鏈�  start
     //鏍¢獙鏃犻浂浠堕闄╂棩鏈�
     public static String checkAssetInfo(Date NoPartRiskDate, Boolean SignableFlag, Date ContractEndDate, Decimal ContractRange) {
-      String rtnStr = '';
-      //1.鍒ゆ柇
-      //鍚堝悓缁撴潫鏃ユ湡 > 鏃犻浂浠堕闄╂棩鏈�
-      if (ContractEndDate > NoPartRiskDate) {
-        //鍙绾︽爣璇� 鏈嬀閫�
-        if (SignableFlag == false) {
-          //鍒板悎鍚岀粨鏉熸棩鏈熸椂,瀛樺湪闆朵欢鍋滄渚涘簲椋庨櫓锛屽缓璁笉鍙備繚锛屾垨璋冩暣鍚堝悓鏃ユ湡銆�
-          rtnStr = '鍒板悎鍚岀粨鏉熸棩鏈熸椂,瀛樺湪闆朵欢鍋滄渚涘簲椋庨櫓锛屽缓璁笉鍙備繚锛屾垨璋冩暣鍚堝悓鏃ユ湡銆�';
-        } else {
-          //鍕鹃��
-          //鍙互绛�1骞村悎鍚�
-          if (ContractRange > 12) {
-            rtnStr = '鍒板悎鍚岀粨鏉熸棩鏈熸椂锛屽瓨鍦ㄩ浂浠跺仠姝緵搴旈闄╋紝寤鸿绛句竴骞存湡鍚堝悓銆�';
-          }
+        String rtnStr = '';
+        //1.鍒ゆ柇
+        //鍚堝悓缁撴潫鏃ユ湡 > 鏃犻浂浠堕闄╂棩鏈�
+        if (ContractEndDate > NoPartRiskDate) {
+            //鍙绾︽爣璇� 鏈嬀閫�
+            if (SignableFlag == false) {
+                //鍒板悎鍚岀粨鏉熸棩鏈熸椂,瀛樺湪闆朵欢鍋滄渚涘簲椋庨櫓锛屽缓璁笉鍙備繚锛屾垨璋冩暣鍚堝悓鏃ユ湡銆�
+                rtnStr = '鍒板悎鍚岀粨鏉熸棩鏈熸椂,瀛樺湪闆朵欢鍋滄渚涘簲椋庨櫓锛屽缓璁笉鍙備繚锛屾垨璋冩暣鍚堝悓鏃ユ湡銆�';
+            } else {
+                //鍕鹃��
+                //鍙互绛�1骞村悎鍚�
+                if (ContractRange > 12) {
+                    rtnStr = '鍒板悎鍚岀粨鏉熸棩鏈熸椂锛屽瓨鍦ㄩ浂浠跺仠姝緵搴旈闄╋紝寤鸿绛句竴骞存湡鍚堝悓銆�';
+                }
+            }
         }
-      }
     
-      return rtnStr;
+        return rtnStr;
     }
     // 2021-03-01 LJPH-BX9CVX mzy  update  濡傛灉鍚堝悓缁撴潫鏃�>鏃犻浂浠堕闄╂棩鏈�  end
     // 浠锋牸鍙樻洿鍚庡厠闅嗘姤浠峰墠閲嶆柊璁$畻浠锋牸
     @TestVisible
     private void priceChangeReset() {
-      // 鍙栧緱master涓渶鏂颁环鏍�
-      List<Id> assIds = new List<Id>();
-      List<Id> pdIds = new List<Id>();
-      for (AssetInfo input : this.checkedAssets) {
-        if (!input.isManual) {
-          assIds.add(input.rec.Id);
+        // 鍙栧緱master涓渶鏂颁环鏍�
+        List<Id> assIds = new List<Id>();
+        List<Id> pdIds = new List<Id>();
+        for (AssetInfo input : this.checkedAssets) {
+            if (!input.isManual) {
+                assIds.add(input.rec.Id);
+            }
+            if (input.isManual && !String.isBlank(input.mcae.Product_Manual__c)) {
+                pdIds.add(input.mcae.Product_Manual__c);
+            }
         }
-        if (input.isManual && !String.isBlank(input.mcae.Product_Manual__c)) {
-          pdIds.add(input.mcae.Product_Manual__c);
+        Map<Id, Asset> assMap = new Map<Id, Asset>();
+        Map<Id, Product2> pdMap = new Map<Id, Product2>();
+        if (assIds.size() > 0) {
+            assMap = new Map<Id, Asset>([select id, Maintenance_Price_Month__c from Asset where Id In: assIds]);
         }
-      }
-      Map<Id, Asset> assMap = new Map<Id, Asset>();
-      Map<Id, Product2> pdMap = new Map<Id, Product2>();
-      if (assIds.size() > 0) {
-        assMap = new Map<Id, Asset>([select id, Maintenance_Price_Month__c from Asset where Id In: assIds]);
-      }
-      if (pdIds.size() > 0) {
-        pdMap = new Map<Id, Product2>([select id, Maintenance_Price_Month__c, EquipmentGuaranteeFlg__c from Product2 where Id In: pdIds]);
-      }
-      if (assMap.size() > 0 || pdMap.size() > 0) {
-        for (AssetInfo info : this.checkedAssets) {
-          if (!info.isManual) {
-            info.orgPrice = assMap.get(info.rec.Id).Maintenance_Price_Month__c;
-          }
-          if (info.isManual && !String.isBlank(info.mcae.Product_Manual__c)) {
-            info.orgPrice = pdMap.get(info.mcae.Product_Manual__c).Maintenance_Price_Month__c;
-          }
+        if (pdIds.size() > 0) {
+            pdMap = new Map<Id, Product2>([select id, Maintenance_Price_Month__c, EquipmentGuaranteeFlg__c from Product2 where Id In: pdIds]);
         }
-      }
-      //contractStartDateChange();
+        if (assMap.size() > 0 || pdMap.size() > 0) {
+            for (AssetInfo info : this.checkedAssets) {
+                if (!info.isManual) {
+                    info.orgPrice = assMap.get(info.rec.Id).Maintenance_Price_Month__c;
+                }
+                if (info.isManual && !String.isBlank(info.mcae.Product_Manual__c)) {
+                    info.orgPrice = pdMap.get(info.mcae.Product_Manual__c).Maintenance_Price_Month__c;
+                }
+            }
+        }
+        //contractStartDateChange();
     }
     
     
@@ -3017,269 +3060,269 @@
     //add by mzy 2020-11-12 LJPH-BX9CVX start
     
     public Id getRecId() {
-      Id rtn = null;
-      if (rec != null) {
-        rtn = rec.Id;
-      }
-      return rtn;
+        Id rtn = null;
+        if (rec != null) {
+            rtn = rec.Id;
+        }
+        return rtn;
     }
     public void setRecId(Id value) {
-      // 銇伀銈傘仐銇亜
+        // 銇伀銈傘仐銇亜
     }
     
     // Manual灏傜敤
     public AssetInfo(Integer lineNo) {
-      this.lineNo = lineNo;
-      this.rec = null;
-      this.mcae = new Maintenance_Contract_Asset_Estimate__c(
-        isNew__c = true,
-        // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk Star
-        Check_Object__c = true
-                  // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk end
-        );
-      this.isManual = true;
-      this.rec_checkBox_c = false;
-      this.orgPrice = 0;
-      this.orgPrice12 = 0;
-      this.etGFlg = false;
-      // add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� Star
-      this.CheckRows = true;
-      // add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� End
+        this.lineNo = lineNo;
+        this.rec = null;
+        this.mcae = new Maintenance_Contract_Asset_Estimate__c(
+            isNew__c = true,
+            // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk Star
+            Check_Object__c = true
+                              // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk end
+            );
+        this.isManual = true;
+        this.rec_checkBox_c = false;
+        this.orgPrice = 0;
+        this.orgPrice12 = 0;
+        this.etGFlg = false;
+        // add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� Star
+        this.CheckRows = true;
+        // add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� End
     }
     // 閬告姙銇曘倢銇熺敤锛堥潪Manual锛�
     public AssetInfo(Integer lineNo, Asset record, Boolean isNew, Decimal listPrice, Maintenance_Contract_Asset_Estimate__c mcae) {
-      this.lineNo = lineNo;
-      this.rec = record;
-      this.mcae = new Maintenance_Contract_Asset_Estimate__c(
-        //                id = mcae.Id,             // 鏈綋銇亜銈夈仾銇勩伄锛� 銈汇儍銉堛仐銇熴倝銆佹柊瑕忔ī闄愩亴銇亸銇с倐銆佹洿鏂般仹銇嶃伨銇欍�傚緦钘ゃ仌銈撱伀纰鸿獚銇椼仧銆併仾銇忋仹銈傘亜銇勩仹銇欍��
-        isNew__c = isNew,
-        // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk Star
-        Check_Object__c = mcae.Check_Object__c,
-        // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk end
-        Estimate_List_Price__c = listPrice,
-        //Maintenance_Price_YearTXT__c = mcae.Maintenance_Price_YearTXT__c,
-        Check_Result__c = mcae.Check_Result__c,
-        Repair_Price__c = mcae.Repair_Price__c,
-        Comment__c = mcae.Comment__c,
-        EquipmentGuaranteeFlgTxt__c = mcae.EquipmentGuaranteeFlgTxt__c,
-        Estimate_Cost__c = mcae.Estimate_Cost__c,
-        Adjustment_ratio_Upper__c = mcae.Adjustment_ratio_Upper__c,
-        Adjustment_ratio_Lower__c = mcae.Adjustment_ratio_Lower__c,
-        Adjustment_Upper_price__c = mcae.Adjustment_Upper_price__c,
-        LastMContract_Price__c = mcae.LastMContract_Price__c,
-        Adjustment_Lower_price__c = mcae.Adjustment_Lower_price__c,
-        Asset_Consumption_rate__c = mcae.Asset_Consumption_rate__c
-        // LJPH-C9GD34 gzw fix start
-        ,Estimate_List_Price_Page__c = mcae.Estimate_List_Price_Page__c
-        // LJPH-C9GD34 gzw fix end
-        );
-      this.isManual = false;
-      this.rec_checkBox_c = true;
-      this.orgPrice = record.Maintenance_Price_Month__c;
-      this.orgPrice12 = this.orgPrice * 12;
-      this.etGFlg = record.EquipmentGuaranteeFlg__c;
-      //add by rentx 2020-11-12 LJPH-BV93RZ start
-      this.proName = '鏈鸿韩缂栫爜涓�:' + record.SerialNumber;
-      this.proSerialNumber = record.SerialNumber;
-      this.proSerialName = record.Name;
-      //add by rentx 2020-11-12 LJPH-BV93RZ end
-      //add by mzy 2021-02-07 start
-      //this.NoPartRiskDate = mcae.Product_Manual__r.NoPartRiskDate_F__c;
-      //this.proName2 = mcae.Product_Manual__r.Name;
-      //this.SignableFlag = mcae.Product_Manual__r.SignableFlag__c;
-      //add by mzy 2021-02-07 end
+        this.lineNo = lineNo;
+        this.rec = record;
+        this.mcae = new Maintenance_Contract_Asset_Estimate__c(
+            //                id = mcae.Id,             // 鏈綋銇亜銈夈仾銇勩伄锛� 銈汇儍銉堛仐銇熴倝銆佹柊瑕忔ī闄愩亴銇亸銇с倐銆佹洿鏂般仹銇嶃伨銇欍�傚緦钘ゃ仌銈撱伀纰鸿獚銇椼仧銆併仾銇忋仹銈傘亜銇勩仹銇欍��
+            isNew__c = isNew,
+            // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk Star
+            Check_Object__c = mcae.Check_Object__c,
+            // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk end
+            Estimate_List_Price__c = listPrice,
+            //Maintenance_Price_YearTXT__c = mcae.Maintenance_Price_YearTXT__c,
+            Check_Result__c = mcae.Check_Result__c,
+            Repair_Price__c = mcae.Repair_Price__c,
+            Comment__c = mcae.Comment__c,
+            EquipmentGuaranteeFlgTxt__c = mcae.EquipmentGuaranteeFlgTxt__c,
+            Estimate_Cost__c = mcae.Estimate_Cost__c,
+            Adjustment_ratio_Upper__c = mcae.Adjustment_ratio_Upper__c,
+            Adjustment_ratio_Lower__c = mcae.Adjustment_ratio_Lower__c,
+            Adjustment_Upper_price__c = mcae.Adjustment_Upper_price__c,
+            LastMContract_Price__c = mcae.LastMContract_Price__c,
+            Adjustment_Lower_price__c = mcae.Adjustment_Lower_price__c,
+            Asset_Consumption_rate__c = mcae.Asset_Consumption_rate__c
+            // LJPH-C9GD34 gzw fix start
+            ,Estimate_List_Price_Page__c = mcae.Estimate_List_Price_Page__c
+            // LJPH-C9GD34 gzw fix end
+            );
+        this.isManual = false;
+        this.rec_checkBox_c = true;
+        this.orgPrice = record.Maintenance_Price_Month__c;
+        this.orgPrice12 = this.orgPrice * 12;
+        this.etGFlg = record.EquipmentGuaranteeFlg__c;
+        //add by rentx 2020-11-12 LJPH-BV93RZ start
+        this.proName = '鏈鸿韩缂栫爜涓�:' + record.SerialNumber;
+        this.proSerialNumber = record.SerialNumber;
+        this.proSerialName = record.Name;
+        //add by rentx 2020-11-12 LJPH-BV93RZ end
+        //add by mzy 2021-02-07 start
+        //this.NoPartRiskDate = mcae.Product_Manual__r.NoPartRiskDate_F__c;
+        //this.proName2 = mcae.Product_Manual__r.Name;
+        //this.SignableFlag = mcae.Product_Manual__r.SignableFlag__c;
+        //add by mzy 2021-02-07 end
     }
     // 閬告姙銇曘倢銇熺敤銆佹湭绱嶅搧鐢紙Manual锛�
     public AssetInfo(Integer lineNo, Maintenance_Contract_Asset_Estimate__c mcae) {
-      this.lineNo = lineNo;
-      this.rec = null;
-      this.mcae = new Maintenance_Contract_Asset_Estimate__c(
-        //                id = mcae.Id,             // 鏈綋銇亜銈夈仾銇勩伄锛� 銈汇儍銉堛仐銇熴倝銆佹柊瑕忔ī闄愩亴銇亸銇с倐銆佹洿鏂般仹銇嶃伨銇欍�傚緦钘ゃ仌銈撱伀纰鸿獚銇椼仧銆併仾銇忋仹銈傘亜銇勩仹銇欍��
-        isNew__c = mcae.IsNew__c,
-        // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk Star
-        Check_Object__c = mcae.Check_Object__c,
-        // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk end
-        Product_Manual__c = mcae.Product_Manual__c,
-        Estimate_List_Price__c = mcae.Estimate_List_Price__c,
-        //Maintenance_Price_YearTXT__c = mcae.Maintenance_Price_YearTXT__c,
-        Check_Result__c = mcae.Check_Result__c,
-        Repair_Price__c = mcae.Repair_Price__c,
-        Comment__c = mcae.Comment__c,
-        EquipmentGuaranteeFlgTxt__c = mcae.EquipmentGuaranteeFlgTxt__c,
-        Estimate_Cost__c = mcae.Estimate_Cost__c,
-        Adjustment_ratio_Upper__c = mcae.Adjustment_ratio_Upper__c,
-        Adjustment_ratio_Lower__c = mcae.Adjustment_ratio_Lower__c,
-        Adjustment_Upper_price__c = mcae.Adjustment_Upper_price__c,
-        LastMContract_Price__c = mcae.LastMContract_Price__c,
-        Adjustment_Lower_price__c = mcae.Adjustment_Lower_price__c,
-        Asset_Consumption_rate__c = mcae.Asset_Consumption_rate__c,
-        Contract_Esti_Start_Date__c = mcae.Maintenance_Contract_Estimate__r.Contract_Esti_Start_Date__c
-                        // Contract_Esti_Start_Date__c=mcae.Contract_Esti_Start_Date__c
-        // LJPH-C9GD34 gzw fix start
-        ,Estimate_List_Price_Page__c = mcae.Estimate_List_Price_Page__c
-        // LJPH-C9GD34 gzw fix end
-        );
-      this.isManual = true;
-      this.rec_checkBox_c = false;
-      this.orgPrice = mcae.Product_Manual__r.Maintenance_Price_Month__c;
-      this.orgPrice12 = this.orgPrice * 12;
-      this.etGFlg = mcae.Product_Manual__r.EquipmentGuaranteeFlg__c;
-      //add by mzy 2021-02-07 start
-      //this.NoPartRiskDate = mcae.Product_Manual__r.NoPartRiskDate_F__c;
-      //this.proName2 = mcae.Product_Manual__r.Name;
-      //this.SignableFlag = mcae.Product_Manual__r.SignableFlag__c;
-      //add by mzy 2021-02-07 end
+        this.lineNo = lineNo;
+        this.rec = null;
+        this.mcae = new Maintenance_Contract_Asset_Estimate__c(
+            //                id = mcae.Id,             // 鏈綋銇亜銈夈仾銇勩伄锛� 銈汇儍銉堛仐銇熴倝銆佹柊瑕忔ī闄愩亴銇亸銇с倐銆佹洿鏂般仹銇嶃伨銇欍�傚緦钘ゃ仌銈撱伀纰鸿獚銇椼仧銆併仾銇忋仹銈傘亜銇勩仹銇欍��
+            isNew__c = mcae.IsNew__c,
+            // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk Star
+            Check_Object__c = mcae.Check_Object__c,
+            // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk end
+            Product_Manual__c = mcae.Product_Manual__c,
+            Estimate_List_Price__c = mcae.Estimate_List_Price__c,
+            //Maintenance_Price_YearTXT__c = mcae.Maintenance_Price_YearTXT__c,
+            Check_Result__c = mcae.Check_Result__c,
+            Repair_Price__c = mcae.Repair_Price__c,
+            Comment__c = mcae.Comment__c,
+            EquipmentGuaranteeFlgTxt__c = mcae.EquipmentGuaranteeFlgTxt__c,
+            Estimate_Cost__c = mcae.Estimate_Cost__c,
+            Adjustment_ratio_Upper__c = mcae.Adjustment_ratio_Upper__c,
+            Adjustment_ratio_Lower__c = mcae.Adjustment_ratio_Lower__c,
+            Adjustment_Upper_price__c = mcae.Adjustment_Upper_price__c,
+            LastMContract_Price__c = mcae.LastMContract_Price__c,
+            Adjustment_Lower_price__c = mcae.Adjustment_Lower_price__c,
+            Asset_Consumption_rate__c = mcae.Asset_Consumption_rate__c,
+            Contract_Esti_Start_Date__c = mcae.Maintenance_Contract_Estimate__r.Contract_Esti_Start_Date__c
+                                          // Contract_Esti_Start_Date__c=mcae.Contract_Esti_Start_Date__c
+            // LJPH-C9GD34 gzw fix start
+            ,Estimate_List_Price_Page__c = mcae.Estimate_List_Price_Page__c
+            // LJPH-C9GD34 gzw fix end
+            );
+        this.isManual = true;
+        this.rec_checkBox_c = false;
+        this.orgPrice = mcae.Product_Manual__r.Maintenance_Price_Month__c;
+        this.orgPrice12 = this.orgPrice * 12;
+        this.etGFlg = mcae.Product_Manual__r.EquipmentGuaranteeFlg__c;
+        //add by mzy 2021-02-07 start
+        //this.NoPartRiskDate = mcae.Product_Manual__r.NoPartRiskDate_F__c;
+        //this.proName2 = mcae.Product_Manual__r.Name;
+        //this.SignableFlag = mcae.Product_Manual__r.SignableFlag__c;
+        //add by mzy 2021-02-07 end
     }
     // 閬告姙銇曘倢銇亱銇c仧鐢�
     public AssetInfo(Integer lineNo, Asset record) {
-      this.lineNo = lineNo;
-      this.rec = record;
-      this.isManual = false;
-      this.rec_checkBox_c = false;
-      this.orgPrice = record.Maintenance_Price_Month__c;
-      this.orgPrice12 = this.orgPrice * 12;
-      this.etGFlg = record.EquipmentGuaranteeFlg__c;
-      this.proSerialName = record.Name;
-      this.proSerialNumber = record.SerialNumber;
+        this.lineNo = lineNo;
+        this.rec = record;
+        this.isManual = false;
+        this.rec_checkBox_c = false;
+        this.orgPrice = record.Maintenance_Price_Month__c;
+        this.orgPrice12 = this.orgPrice * 12;
+        this.etGFlg = record.EquipmentGuaranteeFlg__c;
+        this.proSerialName = record.Name;
+        this.proSerialNumber = record.SerialNumber;
     }
     }
     
     WebService static String pageDecide(String strId) {
-      String rs = '';
-      SelectAssetEstimateVMController saec = new SelectAssetEstimateVMController();
-      saec.targetEstimateId = strId;
-      saec.isPageAction = true;
-      saec.init();
-      if (saec.getDecideBtnDisabled()) {
-        rs = '宸茬粡鏄疍ecide杩囩殑鍚堝悓 鎴� 涓嶆槸鎵瑰噯鐨勬姤浠凤紝涓嶈兘Decide';
+        String rs = '';
+        SelectAssetEstimateVMController saec = new SelectAssetEstimateVMController();
+        saec.targetEstimateId = strId;
+        saec.isPageAction = true;
+        saec.init();
+        if (saec.getDecideBtnDisabled()) {
+            rs = '宸茬粡鏄疍ecide杩囩殑鍚堝悓 鎴� 涓嶆槸鎵瑰噯鐨勬姤浠凤紝涓嶈兘Decide';
+            return rs;
+        }
+        if (saec.syncEstimate(false, true)) {
+            rs = '0';
+        } else {
+            rs = 'Decide澶辫触';
+        }
         return rs;
-      }
-      if (saec.syncEstimate(false, true)) {
-        rs = '0';
-      } else {
-        rs = 'Decide澶辫触';
-      }
-      return rs;
     }
     
     WebService static String pageUndecide(String strId) {
-      String rs = '';
-      SelectAssetEstimateVMController saec = new SelectAssetEstimateVMController();
-      saec.targetEstimateId = strId;
-      saec.isPageAction = true;
-      saec.init();
-      if (saec.getUnDecideBtnDisabled()) {
-        rs = '涓嶆槸Decide杩囩殑鎶ヤ环锛屼笉鑳経ndecide';
+        String rs = '';
+        SelectAssetEstimateVMController saec = new SelectAssetEstimateVMController();
+        saec.targetEstimateId = strId;
+        saec.isPageAction = true;
+        saec.init();
+        if (saec.getUnDecideBtnDisabled()) {
+            rs = '涓嶆槸Decide杩囩殑鎶ヤ环锛屼笉鑳経ndecide';
+            return rs;
+        }
+        if (saec.undecide() != null) {
+            rs = '0';
+        } else {
+            rs = 'Undecide澶辫触';
+        }
         return rs;
-      }
-      if (saec.undecide() != null) {
-        rs = '0';
-      } else {
-        rs = 'Undecide澶辫触';
-      }
-      return rs;
     }
     
     
     public static List<lastMContract> getlastMContract(List<AssetInfo> checkedAssets, Date startDate) {
-      Map<String, lastMContract> lastMContractMap = new Map<String, lastMContract>();
-      Map<String, lastMContract> lastMContractMap1 = new Map<String, lastMContract>();
-      for (AssetInfo ai : checkedAssets) {
-        lastMContract lM = new lastMContract(ai.rec.CurrentContract_F__c, ai.rec.CurrentContract_F__r.Management_Code__c, ai.rec.CurrentContract_F__r.Contract_End_Date__c, 1);
+        Map<String, lastMContract> lastMContractMap = new Map<String, lastMContract>();
+        Map<String, lastMContract> lastMContractMap1 = new Map<String, lastMContract>();
+        for (AssetInfo ai : checkedAssets) {
+            lastMContract lM = new lastMContract(ai.rec.CurrentContract_F__c, ai.rec.CurrentContract_F__r.Management_Code__c, ai.rec.CurrentContract_F__r.Contract_End_Date__c, 1);
     
-        // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start
-        // 璁$畻绌虹櫧鏈�
-        if (startDate != null && lM.endDate != null) {
-          if (startDate.daysbetween(lM.endDate) > -366 && startDate.daysbetween(lM.endDate) < 366) {
-            lm.ayearcontract = true;
-          } else {
-            lm.ayearcontract = false;
-          }
-        } else {
-          lm.ayearcontract = false;
-        }
-        // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 end
-    
-        // if (String.isNotBlank(ai.rec.CurrentContract_F__c) ) {
-        //鍒ゆ柇 濡傛灉涓婁竴鏈熺淮淇悎鍚屼负 澶氬勾淇濅慨鍚堝悓 鐨勮瘽 鍒欎笉鏀惧叆map杩涜鏇存柊 LJPH-BUU3E3 update by rentx 2020-11-03 start
-        if (String.isNotBlank(ai.rec.CurrentContract_F__c) && ai.rec.CurrentContract_F__r.RecordType_DeveloperName__c != 'VM_Contract') {
-    
-          // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start
-          if (lm.ayearcontract) {
+            // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start
+            // 璁$畻绌虹櫧鏈�
+            if (startDate != null && lM.endDate != null) {
+                if (startDate.daysbetween(lM.endDate) > -366 && startDate.daysbetween(lM.endDate) < 366) {
+                    lm.ayearcontract = true;
+                } else {
+                    lm.ayearcontract = false;
+                }
+            } else {
+                lm.ayearcontract = false;
+            }
             // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 end
     
-            //鍒ゆ柇 濡傛灉涓婁竴鏈熺淮淇悎鍚屼负 澶氬勾淇濅慨鍚堝悓 鐨勮瘽 鍒欎笉鏀惧叆map杩涜鏇存柊 LJPH-BUU3E3 update by rentx 2020-11-03 end
-            // 绌虹櫧鏈�
-            if (lastMContractMap.containsKey(ai.rec.CurrentContract_F__c)) {
-              lastMContractMap.get(ai.rec.CurrentContract_F__c).count++;
-            } else {
-              lastMContractMap.put(ai.rec.CurrentContract_F__c, lM);
+            // if (String.isNotBlank(ai.rec.CurrentContract_F__c) ) {
+            //鍒ゆ柇 濡傛灉涓婁竴鏈熺淮淇悎鍚屼负 澶氬勾淇濅慨鍚堝悓 鐨勮瘽 鍒欎笉鏀惧叆map杩涜鏇存柊 LJPH-BUU3E3 update by rentx 2020-11-03 start
+            if (String.isNotBlank(ai.rec.CurrentContract_F__c) && ai.rec.CurrentContract_F__r.RecordType_DeveloperName__c != 'VM_Contract') {
+    
+                // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start
+                if (lm.ayearcontract) {
+                    // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 end
+    
+                    //鍒ゆ柇 濡傛灉涓婁竴鏈熺淮淇悎鍚屼负 澶氬勾淇濅慨鍚堝悓 鐨勮瘽 鍒欎笉鏀惧叆map杩涜鏇存柊 LJPH-BUU3E3 update by rentx 2020-11-03 end
+                    // 绌虹櫧鏈�
+                    if (lastMContractMap.containsKey(ai.rec.CurrentContract_F__c)) {
+                        lastMContractMap.get(ai.rec.CurrentContract_F__c).count++;
+                    } else {
+                        lastMContractMap.put(ai.rec.CurrentContract_F__c, lM);
+                    }
+                    // 闈炵┖鐧芥湡
+                } else {
+                    if (lastMContractMap1.containsKey(ai.rec.CurrentContract_F__c)) {
+                        lastMContractMap1.get(ai.rec.CurrentContract_F__c).count++;
+                    } else {
+                        lastMContractMap1.put(ai.rec.CurrentContract_F__c, lM);
+                    }
+                }
             }
-            // 闈炵┖鐧芥湡
-          } else {
-            if (lastMContractMap1.containsKey(ai.rec.CurrentContract_F__c)) {
-              lastMContractMap1.get(ai.rec.CurrentContract_F__c).count++;
-            } else {
-              lastMContractMap1.put(ai.rec.CurrentContract_F__c, lM);
-            }
-          }
         }
-      }
     
-      List<lastMContract> listResulttemp = new List<lastMContract>();
-      List<lastMContract> listResult = new List<lastMContract>();
-      // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start
-      List<lastMContract> listResulttemp1 = new List<lastMContract>();
-      List<lastMContract> listResult1 = new List<lastMContract>();
-      // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 end
-      // 绌虹櫧鏈�
-      for ( lastMContract ll : lastMContractMap.values()) {
-        listResulttemp.add(ll);
-      }
-      // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start
-      // 闈炵┖鐧芥湡
-      for ( lastMContract ll : lastMContractMap1.values()) {
-        listResulttemp1.add(ll);
-      }
-      // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 end
-      //ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, 'listResult +++++锛�' + listResult));
-    
-      // 绌虹櫧鏈�
-      listResulttemp.sort();
-      // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start  锛堜慨鏀逛簡寰幆娆℃暟 鍘�5锛�
-      for (Integer i = 0; i < listResulttemp.size(); i++) {
+        List<lastMContract> listResulttemp = new List<lastMContract>();
+        List<lastMContract> listResult = new List<lastMContract>();
+        // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start
+        List<lastMContract> listResulttemp1 = new List<lastMContract>();
+        List<lastMContract> listResult1 = new List<lastMContract>();
         // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 end
-        if (listResulttemp.size() >= i + 1) {
-          listResult.add(listResulttemp[i]);
+        // 绌虹櫧鏈�
+        for ( lastMContract ll : lastMContractMap.values()) {
+            listResulttemp.add(ll);
         }
-      }
+        // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start
+        // 闈炵┖鐧芥湡
+        for ( lastMContract ll : lastMContractMap1.values()) {
+            listResulttemp1.add(ll);
+        }
+        // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 end
+        //ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, 'listResult +++++锛�' + listResult));
     
-      // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start
-      // 闈炵┖鐧芥湡
-      listResulttemp1.sort();
-      for (Integer i = 0; i < 5 - listResulttemp.size(); i++) {
-        if (listResulttemp1.size() >= i + 1) {
-          listResult1.add(listResulttemp1[i]);
-        } else {
-          listResult1.add(new lastMContract(null, null, null, null));
+        // 绌虹櫧鏈�
+        listResulttemp.sort();
+        // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start  锛堜慨鏀逛簡寰幆娆℃暟 鍘�5锛�
+        for (Integer i = 0; i < listResulttemp.size(); i++) {
+            // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 end
+            if (listResulttemp.size() >= i + 1) {
+                listResult.add(listResulttemp[i]);
+            }
         }
-      }
-      // 鍚堝苟
-      listResult.addAll(listResult1);
-      // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 end
-      //List<lastMContract> listResult = new List<lastMContract>();
-      return listResult;
+    
+        // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start
+        // 闈炵┖鐧芥湡
+        listResulttemp1.sort();
+        for (Integer i = 0; i < 5 - listResulttemp.size(); i++) {
+            if (listResulttemp1.size() >= i + 1) {
+                listResult1.add(listResulttemp1[i]);
+            } else {
+                listResult1.add(new lastMContract(null, null, null, null));
+            }
+        }
+        // 鍚堝苟
+        listResult.addAll(listResult1);
+        // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 end
+        //List<lastMContract> listResult = new List<lastMContract>();
+        return listResult;
     }
     
     
     public static List<Data> getChartData() {
-      List<Data> data = new List<Data>();
-      List<Achievement_linkage__c> achlist = [select id, Consumption_rate_Lower__c, Consumption_rate_Upper__c,
-                          PriceCount_Lower__c, PriceCount_Upper__c from Achievement_linkage__c];
-      for (Achievement_linkage__c al : achlist ) {
-        data.add(new Data(al.Consumption_rate_Lower__c, al.Consumption_rate_Upper__c, al.PriceCount_Lower__c, al.PriceCount_Upper__c));
-      }
-      return data;
+        List<Data> data = new List<Data>();
+        List<Achievement_linkage__c> achlist = [select id, Consumption_rate_Lower__c, Consumption_rate_Upper__c,
+                                                PriceCount_Lower__c, PriceCount_Upper__c from Achievement_linkage__c];
+        for (Achievement_linkage__c al : achlist ) {
+            data.add(new Data(al.Consumption_rate_Lower__c, al.Consumption_rate_Upper__c, al.PriceCount_Lower__c, al.PriceCount_Upper__c));
+        }
+        return data;
     }
     
     // 浠锋牸浣撶郴 class
@@ -3289,10 +3332,10 @@
     public Decimal price_Upper { get; set; }
     public Decimal price_Lower { get; set; }
     public Data(Decimal rate_Lower, Decimal rate_Upper, Decimal price_Lower, Decimal price_Upper) {
-      this.rate_Upper = rate_Upper;
-      this.rate_Lower = rate_Lower;
-      this.price_Upper = price_Upper;
-      this.price_Lower = price_Lower;
+        this.rate_Upper = rate_Upper;
+        this.rate_Lower = rate_Lower;
+        this.price_Upper = price_Upper;
+        this.price_Lower = price_Lower;
     }
     }
     
@@ -3306,44 +3349,44 @@
     public Boolean ayearcontract { get; set; }
     // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 end
     public lastMContract(String contractId, String contractNo, Date endDate, Integer count) {
-      this.endDate = endDate;
-      this.count = count;
-      this.contractId = contractId;
-      this.contractNo = contractNo;
+        this.endDate = endDate;
+        this.count = count;
+        this.contractId = contractId;
+        this.contractNo = contractNo;
     }
     
     // 鎺掑簭
     public Integer compareTo(Object compareTo) {
-      lastMContract compareToesd = (lastMContract)compareTo;
-      Integer returnValue = 0;
+        lastMContract compareToesd = (lastMContract)compareTo;
+        Integer returnValue = 0;
     
-      // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start
-      // 鍒ゆ柇鍦ㄦ暟閲�
-      if (count  > compareToesd.count) {
-        returnValue = -1;
-      } else if (count  < compareToesd.count) {
-        returnValue = 1;
-      } else {
-        if (endDate  > compareToesd.endDate ) {
-          returnValue = 1;
+        // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start
+        // 鍒ゆ柇鍦ㄦ暟閲�
+        if (count  > compareToesd.count) {
+            returnValue = -1;
+        } else if (count  < compareToesd.count) {
+            returnValue = 1;
         } else {
-          returnValue = -1;
+            if (endDate  > compareToesd.endDate ) {
+                returnValue = 1;
+            } else {
+                returnValue = -1;
+            }
         }
-      }
-      return returnValue;
+        return returnValue;
     }
     
     // 鍘熸柟妗�
     // if (endDate  > compareToesd.endDate ) {
-    //   returnValue = -1;
+    //  returnValue = -1;
     // } else if (endDate  < compareToesd.endDate ) {
-    //   returnValue = 1;
+    //  returnValue = 1;
     // }else{
     // if (count  > compareToesd.count ) {
-    //   returnValue = -1;
+    //  returnValue = -1;
     // } else if (count  < compareToesd.count ) {
-    //   returnValue = 1;
-    //   }
+    //  returnValue = 1;
+    //  }
     // }
     // return returnValue;
     // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 end
diff --git a/force-app/main/default/classes/SelectAssetEstimateVMControllerTest.cls b/force-app/main/default/classes/SelectAssetEstimateVMControllerTest.cls
index b1d76a6..5b6dad3 100644
--- a/force-app/main/default/classes/SelectAssetEstimateVMControllerTest.cls
+++ b/force-app/main/default/classes/SelectAssetEstimateVMControllerTest.cls
@@ -107,7 +107,53 @@
             insert entry;
             
             // 绱嶅叆姗熷櫒銈掍綔鎴愩仚銈�
-            Asset asset01 = createAsset('asset01', dep.Id, strategicDep[0].Id, hospital.Id, '00001', productA.Id,'涓绘満');
+            // Asset asset01 = createAsset('asset01', dep.Id, strategicDep[0].Id, hospital.Id, '00001', productA.Id,'涓绘満');
+            // Asset asset01 = intProCommonMethodController.buildAssetHost('asset01',dep.Id, hospital.Id, strategicDep[0].Id,'浣跨敤涓�');
+            Product2 pro = new Product2(
+                Name = 'proName',
+                // ProductCode='pro001',
+                Asset_Model_No__c = 'pro001',
+                SFDA_Status__c = '鏈夊姽',
+                Dealer_special_Object__c = true,
+                Packing_list_manual__c = 1,
+                Family='GI',
+                Fixture_Model_No__c='n01',
+                Serial_Lot_No__c='S/N tracing',
+                Fixture_Model_No_T__c = 'n01',
+                ProductCode_Ext__c='pc01',
+                Manual_Entry__c=false
+            );
+            insert pro;
+            Asset asset01 = new Asset(
+                Name = 'asset01',
+                Product2Id = pro.Id,
+                Hospital__c = hospital.Id,
+                Department_Class__c = strategicDep[0].Id,
+                AccountId = dep.Id,
+                Status = '浣跨敤涓�',
+                Asset_Owner__c = '鐥呴櫌璩囩敚',
+                IsCompetitorProduct = True,
+                AssetMark__c = '涓绘満',
+                RecordTypeId = System.Label.Asset_RecordType,
+                SerialNumber = 'asset1',
+                Quantity = 1,
+                Manage_type__c = '涓綋绠$悊',
+                Loaner_accsessary__c = false,
+                Out_of_wh__c = 0,
+                Salesdepartment__c = '1.鍗庡寳钀ヤ笟鏈儴',
+                Internal_asset_location__c = '鍖椾含 澶囧搧涓績',
+                Product_category__c = 'GI',
+                Equipment_Type__c = '浜у搧璇曠敤',
+                SalesProvince__c = '澶ц繛',
+                CompanyOfEquipment__c = '鍖椾含',
+                Internal_Asset_number__c = '0001',
+                Rental_Count__c = 0,
+                Asset_loaner_category__c = '鍥哄畾璧勪骇',
+                Consumable_Guaranteen_end__c = System.Today() + 1,
+                WH_location__c = '璐ф灦鍙�1'
+            );
+            insert asset01;
+
             Asset asset02 = createAsset('asset02', dep.Id, strategicDep[0].Id, hospital.Id, '00002', productA.Id,'涓绘満');
             Asset asset03 = createAsset('asset03', dep.Id, strategicDep[0].Id, hospital.Id, '00003', productA.Id,'鑰楁潗');
             Asset asset04 = createAsset('asset04', dep.Id, strategicDep[0].Id, hospital.Id, '00004', productA.Id,'鑰楁潗');
@@ -622,6 +668,12 @@
             //controller.ComputeLTYRepair();
             controller.cancel();
             controller.saveAndCancel();
+
+            controller.onChDealerUpdate();
+            controller.checkDealerId = mcae2.Id;
+            controller.onChDealerUpdate();
+            controller.checkDealerId = hospital.Id;
+            controller.onChDealerUpdate();
         }
     }
     
diff --git a/force-app/main/default/classes/StaticParameter.cls b/force-app/main/default/classes/StaticParameter.cls
index da9596f..86ef8a7 100644
--- a/force-app/main/default/classes/StaticParameter.cls
+++ b/force-app/main/default/classes/StaticParameter.cls
@@ -47,10 +47,24 @@
     public static Boolean EscapeVMCTrigger = false;
     // 璺宠繃鎷涙爣-璇环鍏宠仈trigger
     public static Boolean EscapeTOLinkTrigger = false;
+    
+    //wangweipeng     2021/09/01   鍦ㄩ�氳繃瑙﹀彂UpsertContactHandler鏇存柊contact琛ㄦ暟鎹椂锛岃烦杩囨洿鏂皍ser浠g爜    start
+    public static Boolean EscapeContactInsUpdUser = false;
+    //wangweipeng     2021/09/01        end
+    //EscapeAgencyOpportunityTrigger  thh 2021-09-16
+    public static Boolean EscapeAgencyOpportunityTrigger = false;
     // 鎵�鏈変汉鍙樻洿鐨勯�昏緫鍙湪batch澶勭悊鍜岀浉鍏虫�х‘璁ょ殑鏃跺�欒Е鍙� fxk 2021/9/28 Star
     public static Boolean EscapeOtherUpdateTenOwner = true;
-    // pk 璺宠繃ContactToUser 鍜� UserToContact 
+
     public static Boolean EscapeContactToUser = false;
+    
+    // 璺宠繃NFM701鎺ュ彛
+    public static Boolean EscapeNFM701Trigger = true;
+
+    // 璺宠繃NFM106鎺ュ彛
+    public static Boolean EscapeNFM106Trigger = false;
+
     public StaticParameter(){
     }
+
 }
\ No newline at end of file
diff --git a/force-app/main/default/pages/NewMCAgentPDF.page b/force-app/main/default/pages/NewMCAgentPDF.page
index 1dee69d..7f303e0 100644
--- a/force-app/main/default/pages/NewMCAgentPDF.page
+++ b/force-app/main/default/pages/NewMCAgentPDF.page
@@ -162,6 +162,11 @@
                 <c:PDFWbr targetStr="{!targetMC.TermFour_Once_Three}" />
                 <u>&nbsp;<c:PDFWbr targetStr="{!targetMC.Total_Contract_Amount_In_Words}" />&nbsp;</u>
                 <c:PDFWbr targetStr="{!targetMC.TermFour_Once_Four}" />
+                <!-- add    wangweipeng         2021/12/10        start   -->
+                <apex:outputPanel rendered="{!targetMC.MC.old_Is_RecognitionModel__c}">
+                    <c:PDFWbr targetStr="{!targetMC.TermFour_Once_Five}" />
+                </apex:outputPanel>
+                <!-- add    wangweipeng         2021/12/10        end   -->
             </td></tr>
         </apex:outputPanel>
 
@@ -260,10 +265,26 @@
         <tr><td height="15px"></td></tr>
         <tr><td><c:PDFWbr targetStr="{!targetMC.TermFive_Title}" /></td></tr>
         <tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-            <c:PDFWbr targetStr="{!targetMC.TermFive_Head}" />
+            <!-- update      wangweipeng            2021/12/10               start -->
+            <apex:outputPanel rendered="{!!targetMC.MC.old_Is_RecognitionModel__c}">
+                <c:PDFWbr targetStr="{!targetMC.TermFive_Head}" />
+            </apex:outputPanel>
+            <apex:outputPanel rendered="{!targetMC.MC.old_Is_RecognitionModel__c}">
+                <c:PDFWbr targetStr="{!targetMC.TermFive_Head2}" />
+            </apex:outputPanel>
+            <!-- update      wangweipeng            2021/12/10               end -->
         </td></tr>
         <tr><td><c:PDFWbr targetStr="{!targetMC.TermFive_One}" /></td></tr>
-        <tr><td><c:PDFWbr targetStr="{!targetMC.TermFive_One2}" /></td></tr>
+        <tr><td>
+            <!-- update      wangweipeng            2021/12/10               start -->
+            <apex:outputPanel rendered="{!!targetMC.MC.old_Is_RecognitionModel__c}">
+                <c:PDFWbr targetStr="{!targetMC.TermFive_One2}" />
+            </apex:outputPanel>
+            <apex:outputPanel rendered="{!targetMC.MC.old_Is_RecognitionModel__c}">
+                <c:PDFWbr targetStr="{!targetMC.TermFive_One3}" />
+            </apex:outputPanel>
+            <!-- update      wangweipeng            2021/12/10               end -->
+        </td></tr>
         <tr><td>
             <c:PDFWbr targetStr="{!targetMC.TermFive_Two}" />
             <u>&nbsp;<c:PDFWbr targetStr="{!targetMC.Mc.Small_Repair_Time__c}" />&nbsp;</u>
@@ -278,7 +299,16 @@
         <tr><td><c:PDFWbr targetStr="{!targetMC.TermFive_Five}" /></td></tr>
         <tr><td><c:PDFWbr targetStr="{!targetMC.TermFive_Five2}" /></td></tr>
         <tr><td><c:PDFWbr targetStr="{!targetMC.TermFive_Six}" /></td></tr>
-        <tr><td><c:PDFWbr targetStr="{!targetMC.TermFive_Seven}" /></td></tr>
+        <tr><td>
+            <!-- update      wangweipeng            2021/12/10               start -->
+            <apex:outputPanel rendered="{!!targetMC.MC.old_Is_RecognitionModel__c}">
+                <c:PDFWbr targetStr="{!targetMC.TermFive_Seven}" />
+            </apex:outputPanel>
+            <apex:outputPanel rendered="{!targetMC.MC.old_Is_RecognitionModel__c}">
+                <c:PDFWbr targetStr="{!targetMC.TermFive_Seven2}" />
+            </apex:outputPanel>
+            <!-- update      wangweipeng            2021/12/10               end -->
+        </td></tr>
         <tr><td><c:PDFWbr targetStr="{!targetMC.TermFive_Eight}" /></td></tr>
         <tr><td><c:PDFWbr targetStr="{!targetMC.TermFive_Nine}" /></td></tr>
         <tr><td>
@@ -390,40 +420,52 @@
         </apex:outputPanel> -->
         <!-- LJPH-BUKD5A 銆婂鎵樸�嬪悎鍚屾枃鏈殑淇敼  绮剧悽鎶�鏈� wql 2020/10/23  start -->
                     <!-- 鏍规嵁缁忛攢鍟嗗悕鏄惁鏈夊�煎垽鏂槸鍚︽墦鍗版柊/鍚堝悓鐗堟湰 -->
-        <apex:outputPanel rendered="{!IF(targetMC.MC.Dealer__c != '', 'true', 'false')}">
-            <!-- 鍗佷竴銆�  鑻ョ敳鏂规槸涔欐柟鐨勭壒绾︾粡閿�鍟� -->
-            <tr><td height="15px"></td></tr>
-            <tr><td>
-                <c:PDFWbr targetStr="{!targetMC.TermEleven_One}" />
-            </td></tr>
-            <tr><td><c:PDFWbr targetStr="{!targetMC.TermEleven_Two}" /></td></tr>
-            <tr><td><c:PDFWbr targetStr="{!targetMC.TermEleven_Three}" /></td></tr>
-            <tr><td><c:PDFWbr targetStr="{!targetMC.TermEleven_Four}" /></td></tr>
+        <!-- update      wangweipeng            2021/12/10               start -->
+        <apex:outputPanel rendered="{!!targetMC.MC.old_Is_RecognitionModel__c}">
+            <apex:outputPanel rendered="{!IF(targetMC.MC.Dealer__c != '', 'true', 'false')}">
+                <!-- 鍗佷竴銆�  鑻ョ敳鏂规槸涔欐柟鐨勭壒绾︾粡閿�鍟� -->
+                <tr><td height="15px"></td></tr>
+                <tr><td>
+                    <c:PDFWbr targetStr="{!targetMC.TermEleven_One}" />
+                </td></tr>
+                <tr><td><c:PDFWbr targetStr="{!targetMC.TermEleven_Two}" /></td></tr>
+                <tr><td><c:PDFWbr targetStr="{!targetMC.TermEleven_Three}" /></td></tr>
+                <tr><td><c:PDFWbr targetStr="{!targetMC.TermEleven_Four}" /></td></tr>
 
-            <!-- 涔濄�� 鏈悎鍚岀敳鏂规墽   浠� -->
-            <tr><td height="15px"></td></tr>
-            <tr><td>
-                <c:PDFWbr targetStr="{!targetMC.TermTen_One}" />
-                <u>&nbsp;<c:PDFWbr targetStr="{!targetMC.Mc.First_Party_Contract_Number__c}" />&nbsp;</u>
-                <c:PDFWbr targetStr="{!targetMC.TermTen_Two}" />
-            </td></tr>
-            <tr><td height="15px"></td></tr>
-        </apex:outputPanel>
-        <apex:outputPanel rendered="{!IF(targetMC.MC.Dealer__c != '', 'false', 'true')}">
-            <!-- 鍘熺増鏈� -->
-            <!-- 涔濄�� 鏈悎鍚岀敳鏂规墽   浠� -->
-            <tr><td height="15px"></td></tr>
-            <tr><td>
-                <c:PDFWbr targetStr="{!targetMC.TermNine_One}" />
-                <u>&nbsp;<c:PDFWbr targetStr="{!targetMC.Mc.First_Party_Contract_Number__c}" />&nbsp;</u>
-                <c:PDFWbr targetStr="{!targetMC.TermNine_Two}" />
-            </td></tr>
-            <tr><td height="15px"></td></tr>
-            <!-- 鍘熺増鏈�  -->
+                <!-- 涔濄�� 鏈悎鍚岀敳鏂规墽   浠� -->
+                <tr><td height="15px"></td></tr>
+                <tr><td>
+                    <c:PDFWbr targetStr="{!targetMC.TermTen_One}" />
+                    <u>&nbsp;<c:PDFWbr targetStr="{!targetMC.Mc.First_Party_Contract_Number__c}" />&nbsp;</u>
+                    <c:PDFWbr targetStr="{!targetMC.TermTen_Two}" />
+                </td></tr>
+                <tr><td height="15px"></td></tr>
+            </apex:outputPanel>
+            <apex:outputPanel rendered="{!targetMC.MC.old_Is_RecognitionModel__c}">
+                <!-- 鍘熺増鏈� -->
+                <!-- 涔濄�� 鏈悎鍚岀敳鏂规墽   浠� -->
+                <tr><td height="15px"></td></tr>
+                <tr><td>
+                    <c:PDFWbr targetStr="{!targetMC.TermNine_One}" />
+                    <u>&nbsp;<c:PDFWbr targetStr="{!targetMC.Mc.First_Party_Contract_Number__c}" />&nbsp;</u>
+                    <c:PDFWbr targetStr="{!targetMC.TermNine_Two}" />
+                </td></tr>
+                <tr><td height="15px"></td></tr>
+                <!-- 鍘熺増鏈�  -->
+            </apex:outputPanel>
         </apex:outputPanel>
         <!-- LJPH-BUKD5A 銆婂鎵樸�嬪悎鍚屾枃鏈殑淇敼  绮剧悽鎶�鏈� wql 2020/10/23  end -->
-        
 
+        <apex:outputPanel rendered="{!targetMC.MC.old_Is_RecognitionModel__c}">
+            <tr><td height="15px"></td></tr>
+            <tr><td>
+                <c:PDFWbr targetStr="{!targetMC.TermTen_One2}" />
+                <u>&nbsp;<c:PDFWbr targetStr="{!targetMC.Mc.First_Party_Contract_Number__c}" />&nbsp;</u>
+                <c:PDFWbr targetStr="{!targetMC.TermTen_Two2}" />
+            </td></tr>
+            <tr><td height="15px"></td></tr>
+        </apex:outputPanel>
+        <!-- update      wangweipeng            2021/12/10               end -->
     </table>
         <!-- 銉氥兗銈革紦 -->
         <table width="100%" cellspacing="1" cellpadding="1" style="font-size:13pt;">
diff --git a/force-app/main/default/pages/SelectAssetEstimateVM.page b/force-app/main/default/pages/SelectAssetEstimateVM.page
index 5dd3e7f..1dbdeeb 100644
--- a/force-app/main/default/pages/SelectAssetEstimateVM.page
+++ b/force-app/main/default/pages/SelectAssetEstimateVM.page
@@ -134,6 +134,7 @@
         var target = j$(escapeVfId('allPage:allForm:allBlock:contract:estimateTarget')).val();
         if (target != '鍖婚櫌') {
             j$(escapeVfId('allPage:allForm:allBlock:contract:dealer')).attr("disabled", true);
+            j$(escapeVfId('allPage:allForm:allBlock:contract:FirstParagraphEnd')).attr("disabled", true);
         }
     }
     if ('{!DecideBtnDisabled}' == 'false') {
@@ -266,8 +267,16 @@
 
 function checkAll(checker) {
     var cnt = j$(escapeVfId('allPage:allForm:allBlock:assetSection:productCnt')).val();
+
     for (var i = 0; i < cnt; i++) {
-        if (j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetRowCheckbox')).size() == 0) {
+        //2021-11-30 fy add LJPH-C8W8FV 缃《 start
+        //if (j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetRowCheckbox')).size() == 0) {
+        //    continue;
+        //}else{
+        //    document.getElementById('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetRowCheckbox').checked = checker.checked;
+        //}
+        //2021-11-30 fy add LJPH-C8W8FV 缃《 end
+	 if (j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetRowCheckbox')).size() == 0) {
             break;
         }
         document.getElementById('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetRowCheckbox').checked = checker.checked;
@@ -325,42 +334,8 @@
     refreshAsset(cnt);
 }
 
-function checkContractEstiStartDate(val, cnt) {
-    if (val == null || val == "") {
-        return;
-    }
-    for (var i = 0; i < cnt; i++) {
-        var instaldate = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':InstallDate')).text();
-        if (instaldate != null && instaldate != '') {
-            var listprice = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceHidden')).val();
-            var isnew = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetNewHidden')).val();
-            if (isnew == "true") {
-                listprice = listprice / {!isNewPriceAdj};
-            }
-            var startdate = new Date(val);
-            startdate.setMonth(startdate.getMonth() + isNewAddMonth);
-            instaldate = new Date(instaldate);
-            if (startdate < instaldate) {
-                listprice = listprice * {!isNewPriceAdj};
-                //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPrice')).text(toNumComma(listprice));
-                j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceHidden')).val(listprice);
-                j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPricePageHidden')).val(listprice);
-                j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetNew')).attr('checked',true);
-                j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetNewHidden')).val('true');
-            } else {
-                //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPrice')).text(toNumComma(listprice));
-                j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceHidden')).val(listprice);
-                j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPricePageHidden')).val(listprice);
-                j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetNew')).attr('checked',false);
-                j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetNewHidden')).val('false');
-            }
-        }
-    }
-    
-    refreshAsset(cnt);
-}
-
 function refreshAsset(cnt) {
+    // alert(cnt);
     // 鎻愪氦鍚庡氨椤甸潰涓嶈绠椾簡
     var isDisabled = {!PageDisabled};
     // 鍚堝悓鎬荤悊
@@ -458,7 +433,7 @@
                     }
                     //鏈�鍚庣粨鏉熸棩+1骞�
                     lastendDate.setMonth(lastendDate.getMonth() + 12);
-                    if (Date.parse(contractStartDate) > Date.parse(lastendDate)) {
+                    if (Date.parse(contractStartDate) > Date.parse(lastendDate) ) {
                         oyearCount ++;
                     }
                     // 鍙栬仈鍔ㄤ环鏍�
@@ -544,7 +519,7 @@
             } else {
                 strMoney = month * strMoney + month2 * strMoney;
             }
-            var b = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Contract_No')).value();
+            var b = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Contract_No')).value(); 
             var LastMContractRecord = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':LastMContractRecord')).value();
             if(b != ''){
                 conCCount ++;
@@ -769,13 +744,16 @@
 function resetDealer() {
     var target = j$(escapeVfId('allPage:allForm:allBlock:contract:estimateTarget')).val();
     var obj = document.getElementById('allPage:allForm:allBlock:contract:dealer');
+    var obj2 = document.getElementById('allPage:allForm:allBlock:contract:FirstParagraphEnd');
     var obj_lkwgt = document.getElementById('allPage:allForm:allBlock:contract:dealer_lkwgt');
     if (target == '鍖婚櫌') {
         obj.style.display = "none";
+        obj2.style.display = "none";
         obj_lkwgt.style.display = "none";
     } else {
         obj.style.display = "block";
         obj_lkwgt.style.display = "block";
+        obj2.style.display = "block";
     }
 }
 
@@ -1177,7 +1155,86 @@
         alert('鍚堝悓鏈熸渶闀垮彧鑳介�夋嫨60涓湀锛�');
         return 0;
     }
+
 }
+
+    //鑾峰彇缁忛攢鍟嗙殑鍏堟鏍囪瘑
+    function onChDealerUpdateJs(oBj){
+        //鑾峰彇 鎶ヤ环鎻愪氦瀵硅薄  鏄惁涓虹粡閿�鍟�
+        var estimateTarget = j$(escapeVfId('allPage:allForm:allBlock:contract:estimateTarget'))[0].value;
+        if(estimateTarget == '缁忛攢鍟�'){
+            //鍒ゆ柇缁忛攢鍟嗗悕鏄惁涓虹┖
+            var dealerValue = j$(escapeVfId('allPage:allForm:allBlock:contract:dealer')).val();
+            if(dealerValue != ''){
+                //鑾峰彇缁忛攢鍟嗗悕鐨刬d
+                var dealerId = j$(escapeVfId('allPage:allForm:allBlock:contract:dealer_lkid')).val();
+                //鐢变簬salesforce鐨勬煡鎵惧瓧娈垫槸鍙互杈撳叆鐨勶紝鎵�浠ュ垽鏂粬濡傛灉涓虹┖鎴栬�呬负 000000000000000 鐨勬椂鍊欙紝浼犵殑鍙傛暟灏变綅缁忛攢鍟嗕腑鏂囧悕锛屽叾浠栨儏鍐典紶id
+                if(dealerId != '' && dealerId != '000000000000000'){
+                    onChDealerUpdate(dealerId);
+                }else{
+                    onChDealerUpdate(dealerValue);
+                }
+            }else{
+                onChDealerUpdate('');
+                //j$(escapeVfId('allPage:allForm:allBlock:contract:FirstParagraphEnd'))[0].checked = false;
+            }
+        }
+    }
+    //濡傛灉閫夋嫨鐨勭粡閿�鍟嗕负鍏堟瀵硅薄锛岄偅涔堝仛涓�涓嬫彁绀�
+    function hintAccount(){
+        var xkChecked = j$(escapeVfId('allPage:allForm:allBlock:contract:FirstParagraphEnd'))[0].checked;
+        if(xkChecked){
+            alert('璇锋敞鎰忥紝褰撳墠缁忛攢鍟嗕负鍏堟瀵硅薄銆�');
+        }
+    }
+
+//LJPH-C9SCX7 銆愬鎵樸�戝悎鍚屾棤绌虹櫧鏈熺殑鎻愰啋  lt  20211221  start
+//鍚堝悓寮�濮嬫棩棰勫畾鏃ラ粯璁や负涓婃湡鍚堝悓1缁撴潫鏃ョ殑绗�2澶�
+// function DefaultStartDate(){
+//     //涓婃湡鍚堝悓1缁撴潫鏃�
+//     var LastContractEndDate;
+//     var LastContractEndDate2;  //鏃ユ湡鏍煎紡
+//     var cnt = j$(escapeVfId('allPage:allForm:allBlock:assetSection:productCnt')).val();
+//     for (var i = 0; i < cnt; i++){
+//         LastContractEndDate = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':End_Date')).value();
+//          //鎴栬�呮崲闅愯棌鏍囩Maintenance_Contract__r.Past_Contract_end_day__c
+//         LastContractEndDate2 = LastContractEndDate;
+//         if(LastContractEndDate != null && LastContractEndDate != ''){
+//             break;
+//         }
+//     }
+
+//     if(LastContractEndDate != null && LastContractEndDate != ''){
+//         //涓婃湡鍚堝悓1缁撴潫鏃ョ殑绗�2澶�
+//         LastContractEndDate += " 00:00:00";//璁剧疆涓哄綋澶╁噷鏅�12鐐�
+//         LastContractEndDate = Date.parse(new Date(LastContractEndDate))/1000;//杞崲涓烘椂闂存埑
+//         LastContractEndDate += (86400) * 1;//淇敼鍚庣殑鏃堕棿鎴�
+//         var newDate = new Date(parseInt(LastContractEndDate) * 1000);//杞崲涓烘椂闂�
+//         var LastContractEndDate1 = newDate.getFullYear() + '/' + (newDate.getMonth() + 1) + '/' + newDate.getDate();;
+
+//         //鑾峰彇褰撳墠鏃ユ湡(currentdate)
+//         var date1 = new Date();
+//         var seperator = "/";
+//         var year = date1.getFullYear();
+//         var month = date1.getMonth() + 1;
+//         var day = date1.getDate();
+//         if (month >= 1 && month <= 9) {
+//             month = "0" + month;
+//         }
+//         if (day >= 0 && day <= 9) {
+//             day = "0" + day;
+//         }
+//         var currentdate = year + seperator + month + seperator + day;
+
+//         //涓婃湡鍚堝悓灏氭湭缁撴潫 , 寮�濮嬮瀹氭棩
+//         if(currentdate < LastContractEndDate2){
+//             document.getElementById("allPage:allForm:allBlock:contract:startdate").value = LastContractEndDate1;
+//         }
+//     }
+    
+// }
+//LJPH-C9SCX7 銆愬鎵樸�戝悎鍚屾棤绌虹櫧鏈熺殑鎻愰啋  lt  20211221  end
+
 </script>
 <apex:form id="allForm">
     <apex:inputHidden id="alertStringValue" value="{!alertString}" />
@@ -1197,6 +1254,10 @@
     <apex:actionFunction name="decide" action="{!decide}" rerender="allForm" oncomplete="unblockUI();"/>
     <apex:actionFunction name="decideCancle" action="{!decideCancle}" rerender="allForm" oncomplete="unblockUI();"/>
     <apex:inputHidden id="oldDecideContractDate" value="{!OldContractStartDate}" />
+    <!-- 缁忛攢鍟嗗彂鐢熷彉鍖栫殑change鏃堕棿 -->
+    <apex:actionFunction name="onChDealerUpdate" action="{!onChDealerUpdate}" rerender="contract" onComplete="hintAccount();">
+        <apex:param name="checkDealerId" assignTo="{!checkDealerId}" value="" />
+    </apex:actionFunction>
     <input type="hidden" id="oldContractDate" value="{!estimate.Contract_Start_Date__c}" />
 <script type="text/javascript">
 //j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('false');
@@ -1311,10 +1372,10 @@
                     </td>
                     <td> </td>
                 </tr>
-
             </table>
             </apex:outputPanel>
         <apex:outputPanel >
+            
         <table align="center" width="100%"  style="border-collapse:separate; border-spacing:0px 10px" >
             <tr>    
                 <td width="50%" align="right"> <label class="labelCol vfLabelColTextWrap " style="margin-left:22%">鍚堝悓璇环缂栫爜</label> </td>
@@ -1350,9 +1411,15 @@
   
                 <td  width="50%" align="right">  
                     <label class="labelCol vfLabelColTextWrap " style="margin-left:30%"> 缁忛攢鍟嗗悕</label></td>
-                <td width="50%" align="left"> <apex:inputField value="{!estimate.Dealer__c}" id="dealer" /> </td>
+            <!-- update     wangweipeng             2021/12/04         start -->
+                <td width="50%" align="left"> <apex:inputField value="{!estimate.Dealer__c}" id="dealer" onchange="onChDealerUpdateJs(this);return false;" style="float: left;"/> </td>
             </tr>
-            
+            <tr>
+                <td  width="50%" align="right">  
+                    <label class="labelCol vfLabelColTextWrap " style="margin-left:30%"> 鍏堟鏍囪瘑锛堢粡閿�鍟嗭級</label></td>
+                <td width="50%" align="left" > <apex:inputCheckbox value="{!estimate.Is_RecognitionModel__c}" id="FirstParagraphEnd" onClick="return false;" /> </td>
+            </tr>
+            <!-- update     wangweipeng             2021/12/04         end -->
         </table>
         <script type="text/javascript">
             j$(escapeVfId('allPage:allForm:allBlock:contract:estimateTarget')).children('option[value=]').remove();
@@ -1513,38 +1580,6 @@
                                     <!-- 20200103 Gzw 璁$畻瀹為檯鎶ヤ环閲戦 end -->
 
                                 </td>
-                                <!-- 瀹炵哗鑱斿姩浠锋牸璁$畻 end -->
-                                
-                                <!-- 闅愯棌鍚堝悓鏈堟暟
-                                <td class="dataCell" width="90px" style="text-align:right" >
-                                    <apex:outputField value="{!ar.rec.CurrentContract_F__r.Contract_Range__c}" rendered="{!Not(ar.IsManual)}" id="lastContRange" />
-                                </td>-->
-                                
-                                <!-- <td class="dataCell" width="70px">
-                                    <apex:outputField value="{!ar.rec.Asset_Owner__c}" rendered="{!Not(ar.IsManual)}" />
-                                </td>
-                                <td class="dataCell" width="90px" style="text-align:right" >
-                                    <apex:outputField value="{!ar.rec.Accumulation_Repair_Amount__c}" rendered="{!Not(ar.IsManual)}" />
-                                </td> -->
-                                <!--<td class="dataCell" width="90px" style="text-align:right" >-->
-                                    <!-- 闅愯棌鏈嶅姟鍚堝悓浠锋牸
-                                    <apex:outputText value="{!ar.mcae.Estimate_List_Price__c}" id="assetListPrice" style="padding-right:3px;" />
-                                    <apex:outputPanel layout="none" rendered="{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.createable}" >
-                                        <apex:inputHidden value="{!ar.mcae.Estimate_List_Price__c}" id="assetListPriceHidden"/>
-                                        <apex:inputHidden value="{!ar.mcae.Estimate_List_Price_Page__c}" id="assetListPricePageHidden" />
-                                    </apex:outputPanel>
-                                    
-                                    <apex:outputPanel layout="none" rendered="{!Not($ObjectType.Maintenance_Contract_Asset_Estimate__c.createable)}" >
-                                        <input type="hidden" value="{!ar.mcae.Estimate_List_Price__c}" id="allPage:allForm:allBlock:assetSection:assetTable:{!Text(cnt-1)}:assetListPriceHidden"/>
-                                    </apex:outputPanel>-->
-                                <!--</td>-->
-                                <!--<td>
-                                    <apex:outputText value="{!ar.mcae.Maintenance_Price_YearTXT__c}" id="assetListPriceTXT" />
-                                    <apex:inputHidden value="{!ar.mcae.Maintenance_Price_YearTXT__c}" id="assetListPriceTXTHidden" />
-                                </td>-->
-
-
-
                                 <td class="dataCell" width="70px" style="text-align:right" >
                                     <apex:inputField value="{!ar.mcae.Repair_Price__c}" id="repairPrice" style="ime-mode: disabled; width:95%; text-align:right;" onchange="refreshAsset({!productCount});"/>
                                 </td>
@@ -1552,6 +1587,13 @@
                                     <apex:inputField value="{!ar.mcae.Comment__c}" id="comment" style="width:95%;"/>
                                 </td>
                             </tr>
+
+                            <!-- LJPH-C9SCX7 銆愬鎵樸�戝悎鍚屾棤绌虹櫧鏈熺殑鎻愰啋  lt  20211221  start  -->
+                            <!-- <script>
+                                DefaultStartDate();
+                            </script> -->
+                            <!-- LJPH-C9SCX7 銆愬鎵樸�戝悎鍚屾棤绌虹櫧鏈熺殑鎻愰啋  lt  20211221  end  -->
+
                             <apex:variable value="{!cnt + 1}" var="cnt" />
                         </apex:repeat>
 
diff --git a/force-app/main/default/triggers/AccountTrigger.trigger b/force-app/main/default/triggers/AccountTrigger.trigger
index 7982443..08737e2 100644
--- a/force-app/main/default/triggers/AccountTrigger.trigger
+++ b/force-app/main/default/triggers/AccountTrigger.trigger
@@ -2,10 +2,7 @@
  * 瀹㈡埛鍚屾 鍦⊿P銆丟I涓绘媴褰撳彉鍖栨椂鏇存柊璇环鏉冮檺
  */
 trigger AccountTrigger on Account (after insert, after update, before delete, before insert, before update, after delete ) {
-    if (StaticParameter.EscapeAccountTrigger) {
-System.debug('Escape銆丒scapeAccountTrigger:::::' + StaticParameter.EscapeAccountTrigger);
-        return;
-    }
+    
     if ((Trigger.isAfter && Trigger.isInsert) || (Trigger.isAfter && Trigger.isUpdate) || (Trigger.isBefore && Trigger.isDelete)) {
         // 鍚屾鍒� Account2__c
         AccountTrigger.syncAccount2(Trigger.new, Trigger.newMap, Trigger.old, Trigger.oldMap);
@@ -130,5 +127,94 @@
             }
         }
         //HWAG-B4PCZ5 2018-09-19 end 
+        if (StaticParameter.EscapeAccountTrigger) {
+            System.debug('Escape銆丒scapeAccountTrigger:::::' + StaticParameter.EscapeAccountTrigger);   
+            return;
+        }
+        //NFM112 2021/11/10 start
+        List<String> IdList = new List<String>();
+        for(Account account : Trigger.new){
+           Account old = Trigger.oldMap.get(account.Id);
+           if(old.FirstParagraph__c != account.FirstParagraph__c  || old.MonthlyPayment__c != account.MonthlyPayment__c){
+                IdList.add(account.Id);
+            }
+        }
+        if(IdList.size()>0){
+            for(String Id : IdList){
+                BatchIF_Log__c iflog = new BatchIF_Log__c();
+                iflog.Type__c = 'NFM112';
+                iflog.Log__c  = 'callout start\n';
+                insert iflog;
+                //iflog = [Select Id, Name from BatchIF_Log__c where Id = :iflog.Id];
+                //System.debug(Logginglevel.DEBUG, 'NFM112_' + iflog.Name + ' start');                  
+                NFM112Controller.executeNotFuture(iflog.Id, Id);
+            }
+        }
+        //NFM112 2021/11/10 end
     }
+ //add            wangweipeng              2022/02/10                            start
+    //缁忛攢鍟嗙殑鎬ц川鍙戠敓鍙樺寲锛岄偅涔堥渶瑕佸彂閭欢锛屽叾涓竴涓敹浠朵汉涓哄ぇ鍖哄姪鐞�
+    //澶у尯鍔╃悊锛氭牴鎹缁忛攢鍟嗘墍鍦ㄧ殑閭d釜澶у尯锛屾潵鍒ゆ柇鍒板簳鍙戠粰璋侊紝姣忎釜澶у尯鍔╃悊閮芥湁涓�涓汉锛岀洰鍓嶆槸瀛樺埌鑷畾涔夋簮鏁版嵁閲岄潰浜�
+    if(Trigger.isBefore){
+        //鐢ㄤ簬瀛樻斁姝ょ粡閿�鍟嗘槸閭d釜澶у尯
+        Set<String> setStaff = new Set<String>();
+        if(Trigger.isUpdate){
+            for (Account acc : Trigger.new) {
+                //鍒ゆ柇褰撳墠淇敼鐨勫鎴锋槸鍚︿负缁忛攢鍟�
+                if(acc.RecordTypeId == '01210000000Qem1'){
+                    //濡傛灉鏄慨鏀圭粡閿�鍟嗭紝閭d箞鍒ゆ柇姝ょ粡閿�鍟嗙殑鍏堟鏍囪瘑鏄惁鍙戠敓鍙樺寲锛屽鏋滃彂閫佸彉鍖栵紝閭d箞灏辨洿鏂颁竴涓嬪ぇ鍖�
+                    if(acc.FirstParagraphEnd__c != Trigger.oldMap.get(acc.Id).FirstParagraphEnd__c){
+                        setStaff.add(acc.Salesdepartment_HP__c);                    
+                    }
+                }
+            }
+        }else if(Trigger.isInsert){
+            for (Account acc : Trigger.new) {
+                //鍒ゆ柇褰撳墠鏂板鐨勫鎴锋槸鍚︿负缁忛攢鍟�
+                if(acc.RecordTypeId == '01210000000Qem1'){
+                    setStaff.add(acc.Salesdepartment_HP__c);
+                }
+            }
+        }
+        if(setStaff.size() > 0){
+            //鑾峰彇瀵瑰簲鐨勮嚜瀹氫箟鍏冩暟鎹�
+            List<FSE_Regional_Assistant_Account__mdt> usrList = [select id,MasterLabel,DeveloperName,UserName__c,UserId__c from FSE_Regional_Assistant_Account__mdt where MasterLabel in :setStaff];
+            if(usrList != null && usrList.size() > 0){
+                //鑾峰彇澶у尯瀵瑰簲鐨勫姪鐞嗕汉鐨刬d
+                if(Trigger.isUpdate){
+                    for (Account acc : Trigger.new) {
+                        for(FSE_Regional_Assistant_Account__mdt fraam : usrList){
+                            if(acc.FirstParagraphEnd__c != Trigger.oldMap.get(acc.Id).FirstParagraphEnd__c){
+                                if(fraam.MasterLabel == acc.Salesdepartment_HP__c){
+                                    acc.FSE_Regional_Assistant_Account__c = fraam.UserId__c;
+                                }
+                            }
+                        }
+                    }
+                }else if(Trigger.isInsert){
+                    for (Account acc : Trigger.new) {
+                       for(FSE_Regional_Assistant_Account__mdt fraam : usrList){
+                            if(fraam.MasterLabel == acc.Salesdepartment_HP__c){
+                                acc.FSE_Regional_Assistant_Account__c = fraam.UserId__c;
+                            }
+                        } 
+                    }
+                }
+            }
+        }
+    }
+    //add            wangweipeng              2022/02/10                            end
+    
+    // if(Trigger.isUpdate){
+    //     List<String> IdList = new List<String>();
+    //     for(Account account : Trigger.new){
+    //        Account old = Trigger.oldMap.get(account.Id);
+    //        if(old.FirstParagraph__c != account.FirstParagraph__c  || old.MonthlyPayment__c != account.MonthlyPayment__c){
+    //                 IdList.add(account.Id);
+    //         }
+    //     }
+    //     if(IdList.size()>0){
+    //         UpdateContractAimAmountHandler.sendToSAP(IdList);
+    //     }
+    // }
 }
\ No newline at end of file
diff --git a/force-app/main/default/triggers/MaintenanceContractTrigger.trigger b/force-app/main/default/triggers/MaintenanceContractTrigger.trigger
index 49c6813..25f563a 100644
--- a/force-app/main/default/triggers/MaintenanceContractTrigger.trigger
+++ b/force-app/main/default/triggers/MaintenanceContractTrigger.trigger
@@ -20,5 +20,66 @@
             // 娲诲嫊_銈点儞銈炽兂銈掑墛闄�
             ControllerUtil.delEvent3ForTrigger(mcIds);
         }
+        
+        //add                    wangweipeng         2021/11/29              start
+        //鍒ゆ柇璁ゆ鏄惁瀹屾垚
+        if(Trigger.isUpdate){
+            for (Maintenance_Contract__c nmc : Trigger.new) {
+                //鍒ゆ柇 涓婁紶璁ゆ鍚堝悓鏃堕棿 鏄惁涓虹┖锛屽鏋滀笉涓虹┖锛岄偅涔堣瘉鏄庢鍚堝悓闇�瑕佽娆撅紝骞朵笖璁ゆ閲戦闇�瑕佸拰 绗竴娆¤鍒掍粯娆鹃噾棰� 鍋氬姣�
+                if(nmc.upload_to_RM_time__c != null){
+                    if(nmc.All_Amount__c != Trigger.oldMap.get(nmc.Id).All_Amount__c || nmc.Payment_Plan_Sum_First__c != Trigger.oldMap.get(nmc.Id).Payment_Plan_Sum_First__c){
+                        if(nmc.Payment_Plan_Sum_First__c != null || nmc.Payment_Plan_Sum_First__c > 0.0 ){
+                            nmc.Is_Recognition_Model_True__c = nmc.All_Amount__c >= nmc.Payment_Plan_Sum_First__c ? true : false;
+                        }else{
+                            if(nmc.All_Amount__c > 0.0 && nmc.All_Amount__c != null){
+                                nmc.Is_Recognition_Model_True__c = true;
+                            }else{
+                                nmc.Is_Recognition_Model_True__c = false;
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        //FSE鎵�鍦ㄥぇ鍖哄姪鐞� 璧嬪��  鏍规嵁涓绘媴褰撲汉 鐨勬湰閮�
+        //鍗庡寳锛氭椽璐虹敺  涓滃寳锛氬垬鑾硅幑  瑗垮寳锛氱鐞洩  瑗垮崡锛氫綍瀛︾惣  鍗庝笢锛氶檲鏄庤禑  鍗庡崡锛氶椈闈�
+        Set<String> setStaff = new Set<String>();
+        if(Trigger.isUpdate){
+            for (Maintenance_Contract__c nmc : Trigger.new) {
+                if(nmc.Service_Contract_Staff__c != Trigger.oldMap.get(nmc.Id).Service_Contract_Staff__c || String.isBlank(nmc.FSE_Regional_Assistant__c)){
+                    setStaff.add(nmc.Service_Contract_Staff_Salesdepartment__c);//涓绘媴褰撴湰閮紙澶у尯锛�
+                }
+            }
+        }else if(Trigger.isInsert){
+            for (Maintenance_Contract__c nmc : Trigger.new) {
+                if(String.isNotBlank(nmc.Service_Contract_Staff__c)){
+                    setStaff.add(nmc.Service_Contract_Staff_Salesdepartment__c);//涓绘媴褰撴湰閮紙澶у尯锛�
+                }
+            }
+        }
+        if(setStaff.size() > 0){
+            //鑾峰彇瀵瑰簲鐨勮嚜瀹氫箟鍏冩暟鎹�
+            List<FSE_Regional_Assistant__mdt> usrList = [select id,MasterLabel,DeveloperName,UserName__c,UserId__c from FSE_Regional_Assistant__mdt where MasterLabel in :setStaff];
+            if(usrList != null && usrList.size() > 0){
+                for (Maintenance_Contract__c nmc : Trigger.new) {
+                    //濡傛灉鏄洿鏂帮紝閭d箞鍒ゆ柇涓绘媴褰撲汉鏄惁鏈夊彉鍖栨垨FSE澶у尯鍔╃悊鏄惁涓虹┖锛屽鏋滄弧瓒冲叾涓竴鏉★紝閭d箞鏇存柊澶у尯鍔╃悊
+                    if(Trigger.isUpdate){
+                       if(!(nmc.Service_Contract_Staff__c != Trigger.oldMap.get(nmc.Id).Service_Contract_Staff__c 
+                        || String.isBlank(nmc.FSE_Regional_Assistant__c)))
+                       {
+                            continue;
+                       }
+                    }
+                    if(String.isNotBlank(nmc.Service_Contract_Staff__c)){
+                        for(FSE_Regional_Assistant__mdt fram : usrList){
+                            if(String.isNotBlank(fram.MasterLabel) && nmc.Service_Contract_Staff_Salesdepartment__c == fram.MasterLabel){
+                                nmc.FSE_Regional_Assistant__c = fram.UserId__c;
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        //add                    wangweipeng         2021/11/29              end
     }
 }
\ No newline at end of file
diff --git a/force-app/main/default/triggers/PaymentMaintenanceContractTrigger.trigger b/force-app/main/default/triggers/PaymentMaintenanceContractTrigger.trigger
new file mode 100644
index 0000000..b20020b
--- /dev/null
+++ b/force-app/main/default/triggers/PaymentMaintenanceContractTrigger.trigger
@@ -0,0 +1,4 @@
+trigger PaymentMaintenanceContractTrigger on Payment_Maintenance_Contract__c (before insert, after insert, before update, after update, after delete, before delete) {
+	PaymentMaintenanceContractTriggerHandler pmct = new PaymentMaintenanceContractTriggerHandler();
+	pmct.run();
+}
\ No newline at end of file
diff --git a/force-app/main/default/triggers/Repair.trigger b/force-app/main/default/triggers/Repair.trigger
index 303efaa..cc50c6d 100644
--- a/force-app/main/default/triggers/Repair.trigger
+++ b/force-app/main/default/triggers/Repair.trigger
@@ -18,14 +18,20 @@
     //wangweipeng  20210727   end
 
     if ((Trigger.isAfter && Trigger.isInsert) || (Trigger.isAfter && Trigger.isUpdate) || (Trigger.isAfter && Trigger.isDelete)) {
-        NFM103Controller.NFM103Trigger(Trigger.new, Trigger.newMap, Trigger.old, Trigger.oldMap);
-        NFM603Controller.NFM603Trigger(Trigger.new, Trigger.newMap, Trigger.old, Trigger.oldMap);
-        RepairTrigger.UpdateAssert(Trigger.new, Trigger.newMap, Trigger.old, Trigger.oldMap);
+        // if(!(System.isFuture()||System.isBatch())){// Add By Lijun 20220303 to avoid mutiple execute
+            NFM103Controller.NFM103Trigger(Trigger.new, Trigger.newMap, Trigger.old, Trigger.oldMap);
+            NFM603Controller.NFM603Trigger(Trigger.new, Trigger.newMap, Trigger.old, Trigger.oldMap);
+            RepairTrigger.UpdateAssert(Trigger.new, Trigger.newMap, Trigger.old, Trigger.oldMap);
+        // }
     }
     // ----------------------------------------------------------------------
     // 銇撱亾銈堛倞銆佷慨鐞嗐伄銈点兗銉撱偣銈炽兂銉堛儵銈儓闋呯洰銈掕嚜鍕曠殑銇洿鏂般仚銈嬨儹銈搞儍銈�
     // ----------------------------------------------------------------------
     if ( Trigger.isBefore && (Trigger.isInsert || Trigger.isUpdate)) {
+         //鍏堟鍚庝慨-淇悊澧炲姞鍏堟鏍囪瘑 thh 20220322 start
+         RepairTrigger.AdvancePaymentFlagUpsert(Trigger.new, Trigger.newMap, Trigger.old, Trigger.oldMap);
+         //鍏堟鍚庝慨-淇悊澧炲姞鍏堟鏍囪瘑 thh 20220322 end
+
         // 绱嶅叆姗熷櫒ID銈掍竴鎰忋伀鏍肩磵銇欍倠 Set銇с仚銆�
         Set<ID> assetIds = new Set<Id>();
 
@@ -66,7 +72,7 @@
             boolean defaultFlag = true;
             //add     wangweipeng               2021/12/09          end
             // 鑽夋涓慨鐞嗐仩銇戞洿鏂�
-            // GZW 鐗规畩澶勭悊 璺宠繃缁翠慨涓績鑷姩璧嬪�硷紝浠ユ墜閫変负鍑� start
+             // GZW 鐗规畩澶勭悊 璺宠繃缁翠慨涓績鑷姩璧嬪�硷紝浠ユ墜閫変负鍑� start
             // 鍒ゆ柇鏉′欢杩藉姞   && repair.Exc_work_location__c == false
             if(repair.Exc_work_location__c){
                 defaultFlag = false;
@@ -76,7 +82,7 @@
             if ((repair.Status__c == '鑽夋涓�' || String.isBlank(repair.Status__c)) == false) {
                 // if (Trigger.isUpdate && repair.SAP_Transfer_time__c == null) {
                 if (Trigger.isUpdate && repair.SAP_Transfer_time__c == null && repair.Exc_work_location__c == false) {
-                
+
                     repair = RepairTrigger.updateWorkLocationSelect(repair, null);
                     defaultFlag = false;
                 }
@@ -275,7 +281,6 @@
     // ----------------------------------------------------------------------
     // 銇撱亾銇俱仹銆併偟銉笺儞銈广偝銉炽儓銉┿偗銉堥爡鐩倰鑷嫊鐨勩伀鏇存柊銇欍倠銉偢銉冦偗
     // ----------------------------------------------------------------------
-
 
 
     // ----------------------------------------------------------------------

--
Gitblit v1.9.1