From 389da49a4cf18d0971cc72a34c639b4b22ccd257 Mon Sep 17 00:00:00 2001
From: 黄千龙 <huangqianlong@prec-tech.com>
Date: 星期四, 02 二月 2023 09:52:38 +0800
Subject: [PATCH] VMPage与controller

---
 sfdx-project.json                                                  |    2 
 force-app/main/default/classes/SelectAssetEstimateVMController.cls | 1107 ++++++++++++++++++++++++++--
 force-app/main/default/pages/SelectAssetEstimateVM.page            | 1185 +++++++++++++++++++++++++++++-
 3 files changed, 2,173 insertions(+), 121 deletions(-)

diff --git a/force-app/main/default/classes/SelectAssetEstimateVMController.cls b/force-app/main/default/classes/SelectAssetEstimateVMController.cls
index acfcd99..9216d38 100644
--- a/force-app/main/default/classes/SelectAssetEstimateVMController.cls
+++ b/force-app/main/default/classes/SelectAssetEstimateVMController.cls
@@ -4,7 +4,7 @@
     private String targetHospitalId = null;                                    // 浠婂緦绯诲垪鐥呴櫌鐢�
     private String targetMaintenanceContractId = null;
     public String typeresult {get; set;}
-    
+    public  Integer  num{get; set;}
     public String targetEstimateId { get; private set; }
     public Boolean changedAfterPrint {get; set;}                               // true 銇牬鍚堛�佺敾闈€伀 confirm 銉°儍銈汇兗銈搞亴琛ㄧず銇椼伨銇欍�俼uoId銈掓柊銇椼亜insert銆傚垽瀹氥伅js銇仸瀹熸柦
     public Decimal lastFriYearsPriceSum {get; set;}
@@ -116,6 +116,25 @@
     public String contr {get; set; }                         //鍒ゆ柇鏄惁init
     //LJPH-BSS6E2  ---20200911 ---add by rentongxiao end
     
+    //2022 鏁呴殰鍝佸姞璐� 鏄惁鏄疐SE鎿嶄綔 鎻愪环鍑忎环鐢宠鎸夐挳鏄惁鍙
+    public Boolean isFSE { get; set; }
+    public Boolean disableEmailBtn { get; set; }
+    public Boolean sendEmailSuccess { get; set; }
+    public Boolean hasSendEmail { get; set; }
+
+
+    public Boolean isNotFSE { get; set; }
+
+    //澶氬勾淇濊澶囩画绛捐绠楅�昏緫璋冩暣 2022/12/14
+    public Boolean isOrverYear { get; set;}
+    public Decimal MaintenancePriceYear { get; set; }
+    public Decimal Denominator {get; set; }
+    public Decimal Accrued {get; set; }
+    public String ProductModel{get;set;}
+    // public String Category{get;set;}
+    public Decimal Consumption_rate_Gurante{get;set;}
+
+
     // 妫�绱㈡寜閽�
     public PageReference searchBtn() {
         countorder = 1;
@@ -139,8 +158,6 @@
         cond1ForSort = cond1;
         val1ForSort = val1;
         currPage = 1;
-    
-    
         totalPage = (totalRecords / selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
         return null;
     }
@@ -149,6 +166,9 @@
     public void getAssetSerialNumber() {
         //LJPH-BSS6E2  ---20200911 ---add by rentongxiao start
         contr = '2';
+        integer num=0;
+        num++;
+        num++;
         //LJPH-BSS6E2  ---20200911 ---add by rentongxiao end
         assetSerialNumberList = new List<String>();
         assetSerialNumberList.clear();
@@ -160,9 +180,78 @@
             }
         }
     }
-    
-    //
+    public  Map<String,repair__c> getNewrep(List<Asset> assetRecords) {
+        List<String>  assnoList = new List<String>();
+        // 鏁呴殰鍝佸姞璐�20221226
+        for (Asset ast : assetRecords) {
+             if (ast.Return_Without_Repair__r.Agreed_Date__c == null) {
+                if (!assnoList.contains(ast.id)) {
+                     assnoList.add(ast.id);
+                }
+            }
+        }
+        List<repair__c> repairs2 = [SELECT Id,name,Repair_List_Price_formula__c,Delivered_Product__r.id ,CreatedDate 
+                                             FROM repair__c
+                                             WHERE Delivered_Product__c in :assnoList order by Delivered_Product__c ,CreatedDate desc];
+        Map<String,repair__c> assNewRepMap = new Map<String,repair__c>();
+        for (repair__c rep : repairs2) {
+            if (assNewRepMap.get(rep.Delivered_Product__r.id)==null){
+                assNewRepMap.put(rep.Delivered_Product__r.id,rep);
+            }
+            if (assNewRepMap.get(rep.Delivered_Product__r.id)!=null) {
+                if (assNewRepMap.get(rep.Delivered_Product__r.id).CreatedDate < rep.CreatedDate) {
+                    assNewRepMap.remove(rep.Delivered_Product__r.id);
+                    assNewRepMap.put(rep.Delivered_Product__r.id,rep);
+                }
+            }
+        }
+        return assNewRepMap;
+    }
+        public void NextMaintenanceContract() {
+            // 20220810 璇环2鏈熷紑鍙�
+        List<String> asslocalList = new List<String>();
+        List<String> mcalocalList = new List<String>();
+        Map<Id, Maintenance_Contract__c> map3 = new Map<Id, Maintenance_Contract__c>();
+        
+        List<Maintenance_Contract_Asset__c> mcaupdateList = new List<Maintenance_Contract_Asset__c>();
+        for (AssetInfo ass : this.checkedAssets) {
+            if (!ass.isManual) {
+                asslocalList.add(ass.rec.Id);
+                map3.put(ass.rec.Id,this.contract);
+            }
+        }
+        System.debug('asslocalList====%%%' +asslocalList);
+         List<Maintenance_Contract_Asset__c> mcalist1 = [select id,Asset__c,Next_Maintenance_Contract__c,Maintenance_Contract__c
+                                             from Maintenance_Contract_Asset__c
+                                            where id in (select CurrentContract_F_asset__c
+                                                                from asset
+                                                                where id in :asslocalList and CurrentContract_F_asset__c!=null)];
+            System.debug('mcalist1====%%%' +mcalist1);
+            System.debug('map3====%%%' +map3);
+        for (Maintenance_Contract_Asset__c mca : mcalist1) {
+            Maintenance_Contract_Asset__c mca3 = new Maintenance_Contract_Asset__c();
+            if (map3.containsKey(mca.Asset__c)) {
+                mca3.id = mca.id;
+                mca3.Next_Maintenance_Contract__c = map3.get(mca.Asset__c).id;
+                System.debug('mca3.id====%%%' +mca3.id);
+                if (mca3.id!=null&&!mcaupdateList.contains(mca3)) {
+                    mcaupdateList.add(mca3);
+                }
+            }
+        }
+        System.debug('mcaupdateList====%%%' +mcaupdateList);
+        if (mcaupdateList!=null&&!mcaupdateList.isEmpty()) {
+            update mcaupdateList;
+        }    
+        System.debug('鏇存柊瀹屾垚mcaupdateList');
+    }
+
     private void getSortedUnCheckedInfoList(List<Asset> assetList) {
+        integer num=0;
+        num++;
+        num++;
+        num++;
+        num++;
         Boolean overLimit = false;
         Map<Id, AssetInfo> markUpUnCheckMap = new Map<Id, AssetInfo>();
         for (AssetInfo unCheckinfo : unCheckedAssets) {
@@ -181,18 +270,27 @@
         }
         SELECT_LIMIT = selctRecordNum;
         Integer selectCnt = unCheckedAssets.size();
+        Map<String,repair__c> assNewRepMap  = new Map<String,repair__c>();
+        assNewRepMap = getNewrep(assetList);
+        num++;
+        num++;
         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.add(new AssetInfo(unCheckedAssets.size(), asset,assNewRepMap));
             }
         }
     }
     
     //妫�绱㈤獙璇�
     private List<Asset> getAssetconfim(String txt, String con, String val) {
+        integer num=0;
+        num++;
+        num++;
+        num++;
+        num++;
         String soql = this.makeSoqlconfim();
         soql += makeTextSql(txt, con, val);
         system.debug('makeTextSql_soql' + soql);
@@ -227,6 +325,11 @@
     }
     
     private String makeSoqlconfim() {
+        integer num=0;
+        num++;
+        num++;
+        num++;
+        num++;
         String sqlTail = '(\'';
         system.debug('assetSerialNumberList.size()' + assetSerialNumberList.size());
         for (Integer i = 0; i < assetSerialNumberList.size(); i++) {
@@ -237,14 +340,32 @@
             }
         }
         //2021-11-30 fy add LJPH-C8W8FV 缃《 start OwnershipMachine_No__c Product2.ProductURF__c
-        //tcm 娣诲姞 Management_Code__c  20211201 start
+        //tcm 娣诲姞 Management_Code__c  20211201 start  
         String soql = 'SELECT Id, Name,OwnershipMachine_No__c, 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, '
+                      + 'Posting_Date__c,Management_Code__c,IF_Warranty_Service__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,'
+                      //鍙樻洿澶氬勾淇濈画绛惧紑濮嬫棩 thh 20220315 start
+                      + 'CurrentContract_F__r.Gurantee_Renew_startDate__c,'
+                      //鍙樻洿澶氬勾淇濈画绛惧紑濮嬫棩 thh 20220315 end
+
+                      //   (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� start
+                      + 'Return_Without_Repair__r.Repair_List_Price_formula__c,Return_Without_Repair__r.Agreed_Date__c,'
+                      //   (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� end
                       + 'Product2.ProductURF__c,CurrentContract_F__r.Contract_Consumption_rate__c,CurrentContract_F__r.First_contract_usage_Rate__c,CurrentContract_F__r.Contract_Range__c,'
+                      //WLIG-CDFBV3 寮�閫氱画绛炬姤浠蜂负true鐨勫彲浠ュ紑鏀剧画绛炬姤浠� thh 20220414 start
+                      + 'CurrentContract_F__r.Open_RenewalQuotation__c,CurrentContract_F__r.VM_Contract_Check__c,'
+                      //WLIG-CDFBV3 寮�閫氱画绛炬姤浠蜂负true鐨勫彲浠ュ紑鏀剧画绛炬姤浠� thh 20220414 end'
+                      //URF闄愭鍚堝悓2鏈� LY 20220811 start
+                      + 'URF_Maintenance_Contract__c,URF_Maintenance_Contract__r.Management_Code__c,URF_Maintenance_Contract__r.Contract_End_Date__c,'
+                      //URF闄愭鍚堝悓2鏈� LY 20220811 end
+
+                      //澶氬勾淇濊澶囩画绛捐绠楅�昏緫璋冩暣 2022/12/14 start 娑堣垂鐜�
+                      +'CurrentContract_F_asset__r.Asset_Consumption_Rate__c,Product2.Category4__c,Product2.Asset_Model_No__c,'
+                      //澶氬勾淇濊澶囩画绛捐绠楅�昏緫璋冩暣 2022/12/14 end
+
                       + '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\' ';
@@ -260,6 +381,11 @@
     
     // 鎷兼帴妫�绱㈡潯浠秙ql鏂�
     private String makeTextSql(String txt1, String con, String val) {
+        integer num=0;
+        num++;
+        num++;
+        num++;
+        num++;
         String soql = '';
         if (String.isBlank(con)) {
             con = 'equals';
@@ -327,6 +453,11 @@
     }
     
     private String makeTextSqlStr(String txt1, String con, String val) {
+        integer num=0;
+        num++;
+        num++;
+        num++;
+        num++;
         String soql = '';
         if (!String.isBlank(txt1)) {
             String txt = txt1.substring(2);
@@ -388,6 +519,11 @@
     }
     
     public Boolean getUnDecideBtnDisabled() {
+        integer num=0;
+        num++;
+        num++;
+        num++;
+        num++;
         // 瑕嬬銈傘倞decide鍙栨秷銇椼仹銇嶃仾銇勬潯浠躲伄鍒ゆ柇
         if (String.isBlank(this.contract.Decided_Estimation__c) == false) {
             if (this.estimate.Estimation_Decision__c) {
@@ -432,6 +568,46 @@
         }
         return false;
     }
+
+
+   public Boolean gettoApprovalBtnDisabled() {
+        if (String.isBlank(this.estimate.IS_Reduced_price_approval__c)) {
+            return true;
+        }
+        return false;
+    }
+    // 2022鏁呴殰鍝佸姞璐� 鎻愪氦鍑忎环鎸夐挳  
+    public Boolean getSendEmailBtnDisabled() {
+        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;
+        }
+        if(hasSendEmail == true){
+            return true;
+        }
+        return false;
+
+    }
+
+    //2022/12/27 鏁呴殰鍝佸姞璐� 鏂板鎻愪氦淇悊鍑忎环 鎸夐挳浠呭 寮犳櫠 寮犳牘姒曞強 绠$悊鍛樺彲瑙�
+    public Boolean getApprovalBtnNewDisabled() {
+        String userName =  UserInfo.getName();
+        String uProfileId = UserInfo.getProfileId();
+        String uProfileName = [SELECT Name FROM Profile WHERE Id =: uProfileId].Name;
+        if (uProfileName == '绯荤粺绠$悊鍛�' || userName == '寮� 鏍╂' || userName == '寮� 鏅�') {
+            return false;
+        }
+
+        return true;
+
+    }
+
     // 20200307 涓嶇敤
     // public Boolean getcontactBtnDisabled() {
     //     if (String.isBlank(this.contract.Decided_Estimation__c) == false) {
@@ -454,6 +630,9 @@
         if (String.isBlank(this.estimate.Process_Status__c) == false
             && this.estimate.Process_Status__c != '鑽夋涓�'
             //&& this.estimate.Process_Status__c != '涓嶆壒鍑�'
+            //涓婇檺鍚堝悓 LY 20230113 start
+            && this.estimate.Process_Status__c != '鐢宠涓�'
+            //涓婇檺鍚堝悓 LY 20230113 start
             ) {
             return true;
         }
@@ -565,7 +744,7 @@
                          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,
+                         Examination_Price__c, Service_contract_target_number__c,IS_Reduced_price_approval__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,
@@ -587,19 +766,38 @@
                          , Sales_incidental__c, Consumption_rate_Forecast__c, AgencyHos_Price__c
                          // 鐢宠鎶ヤ环閲戦 鍜� 鐩稿鏍囧噯浠锋牸鑼冨洿鐨勬姌鎵g巼
                          , Request_quotation_Amount__c, Service_discount_Rate__c, ContractPriceType__c
+                         //涓婇檺鍚堝悓 20230103 LY start
+                         ,Limit_Price_Amount__c
+                         //涓婇檺鍚堝悓 20230103 LY end
                          , 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
-    
+                         //WLIG-CDFBV3 寮�閫氱画绛炬姤浠蜂负true鐨勫彲浠ュ紑鏀剧画绛炬姤浠� thh 20220419 start
+                         , Maintenance_Contract__r.Open_RenewalQuotation__c,Maintenance_Contract__r.VM_Contract_Check__c
+                         //WLIG-CDFBV3 寮�閫氱画绛炬姤浠蜂负true鐨勫彲浠ュ紑鏀剧画绛炬姤浠� thh 20220419 end'
                         //LJPH-C9SCX7 銆愬鎵樸�戝悎鍚屾棤绌虹櫧鏈熺殑鎻愰啋  lt  20211221  start
                         //, Maintenance_Contract__r.Past_Contract_end_day__c //杩囧幓鍚堝悓缁撴潫鏃�
                         //LJPH-C9SCX7 銆愬鎵樸�戝悎鍚屾棤绌虹櫧鏈熺殑鎻愰啋  lt  20211221  end
-    
+                        // URF闄愭鍚堝悓2鏈� LY 20220811 start
+                        ,URF_P_MaxRepairCount__c,URF_V_MaxRepairCount__c
+                        ,URFMContract1__c,URFMContract1_startDate__c,URFMContract1_endDate__c
+                        //,URFMContract2__c,URFMContract3__c,URFMContract4__c,URFMContract5__c
+                        ,URF_LastMContract1_NO__c,URF_LastMContract2_NO__c,URF_LastMContract3_NO__c,URF_LastMContract4_NO__c,URF_LastMContract5_NO__c
+                        ,URF_LastMContract1_ConCount__c,URF_LastMContract2_ConCount__c,URF_LastMContract3_ConCount__c,URF_LastMContract4_ConCount__c,URF_LastMContract5_ConCount__c
+                        // URF闄愭鍚堝悓2鏈� LY 20220811 end
+                        //鏁呴殰鍝佸姞璐�  2022/12/16 start
+                        ,Hospital_Salesdepartment__c
+                        ,Send_Email_To_RC__c
+                        //鏁呴殰鍝佸姞璐�  2022/12/16 end
+
                          FROM Maintenance_Contract_Estimate__c WHERE Id = :this.targetEstimateId];
         //HWAG-B399Q8 2018/08/20  娣诲姞涓�棰濆瀛楁 IS_Clone_After_Decide__c end
+        //鏁呴殰鍝佸姞璐� 2023/1/3 start
+        hasSendEmail = this.estimate.Send_Email_To_RC__c;
+        //鏁呴殰鍝佸姞璐� 2023/1/3 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) +
@@ -617,6 +815,15 @@
         }
     }
     
+    public PageReference tochange() {
+            estimate.IS_Reduced_price_approval__c = '瀹℃壒涓�';
+        return null;
+    }
+
+    public PageReference tochange2() {
+            estimate.IS_Reduced_price_approval__c = '鏃犲叓鎶樹互涓�';
+        return null;
+    }
     public void init() {
         //2021-11-30 fy add LJPH-C8W8FV 缃《 start
         TopProductModel.add('CF-LV1I');
@@ -625,8 +832,14 @@
         TopProductModel.add('GIF-LV1');
         TopProductModel.add('OER-AW');
         TopProductModel.add('OER-A');
+        integer num=0;
+        num++;
+        num++;
+        num++;
+        num++;
         //2021-11-30 fy add LJPH-C8W8FV 缃《 end
         typeresult = null;
+        AssetHandler.disabled = true;
         changedAfterPrint = false;
         changedSubmitPrice = false;
         isSaveOrApproval = false;
@@ -641,6 +854,15 @@
         contr = '1';
         val1 = '涓绘満';
         //LJPH-BSS6E2  ---20200911 ---update by rentongxiao end
+
+        //2022 鏁呴殰鍝佸姞璐� 鑾峰彇褰撳墠user绠�妗ame
+        String uProfileId = UserInfo.getProfileId();
+        String UserProfileName = [SELECT Name FROM Profile WHERE Id =: uProfileId].Name;
+        if(UserProfileName == '2F3_鍚堝悓缁�' || UserProfileName == '绯荤粺绠$悊鍛�'){
+            isFSE = false;
+        }else{
+            isFSE = true;
+        }
     
         Date systemToday = System.today();
         if (isPageAction == false) {
@@ -717,7 +939,7 @@
         // 浣曘倐銇亼銈屻伆銆佸康銇仧銈�
         else {
             throw new ControllerUtil.myException('鏃犳硶鏄剧ず缁翠慨鍚堝悓鎶ヤ环');
-            //return;
+            // return;
         }
         //HWAG-B399Q8 2018/08/20  妫�楠屾槸鍚︽樉绀�'璇锋彁浜ゅ緟瀹℃壒' start
         IS_Clone_After_Decide = false;
@@ -731,28 +953,49 @@
         // 绱嶅叆姗熷櫒銇儏鍫便倰鍙栧緱
         if (!String.isBlank(this.targetHospitalId) && (this.targetHospitalId.length() == 15 || this.targetHospitalId.length() == 18)) {
             //2021-11-30 fy add LJPH-C8W8FV 缃《 start OwnershipMachine_No__c Product2.ProductURF__c
-                  //tcm 娣诲姞 Management_Code__c  20211201 start
-            assetRecords = [SELECT Id, Name,OwnershipMachine_No__c,Product2.ProductURF__c, Asset_situation__c, SerialNumber, Department_Name__c, Installation_Site__c, Posting_Date__c, Management_Code__c, IF_Warranty__c, Reson_Can_not_Warranty__c,
+            //tcm 娣诲姞 Management_Code__c  20211201 start
+            assetRecords = [SELECT Id, Name,OwnershipMachine_No__c,Product2.ProductURF__c, Asset_situation__c, SerialNumber, Department_Name__c, Installation_Site__c, Posting_Date__c, Management_Code__c, IF_Warranty_Service__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,
+                            //鍙樻洿澶氬勾淇濈画绛惧紑濮嬫棩 thh 20220315 start
+                            CurrentContract_F__r.Gurantee_Renew_startDate__c,
+                            //鍙樻洿澶氬勾淇濈画绛惧紑濮嬫棩 thh 20220315 end
+                            //   (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� start
+                            Return_Without_Repair__r.Repair_List_Price_formula__c,
+                            Return_Without_Repair__r.Agreed_Date__c,
+                            //   (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� end
                             CurrentContract_F__r.Contract_Consumption_rate__c, CurrentContract_F__r.First_contract_usage_Rate__c,
                             CurrentContract_F__r.Contract_Range__c, AssetMark__c,
+                            //WLIG-CDFBV3 寮�閫氱画绛炬姤浠蜂负true鐨勫彲浠ュ紑鏀剧画绛炬姤浠� thh 20220414 start
+                            CurrentContract_F__r.Open_RenewalQuotation__c,CurrentContract_F__r.VM_Contract_Check__c,
+                            //WLIG-CDFBV3 寮�閫氱画绛炬姤浠蜂负true鐨勫彲浠ュ紑鏀剧画绛炬姤浠� thh 20220414 end
                             // 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];
+                            //URF闄愭鍚堝悓2鏈� LY 20220811 start
+                            , URF_Maintenance_Contract__c
+                            , URF_Maintenance_Contract__r.Management_Code__c
+                            , URF_Maintenance_Contract__r.Contract_End_Date__c
+                            //URF闄愭鍚堝悓2鏈� LY 20220811 end
+
+                            //澶氬勾淇濊澶囩画绛捐绠楅�昏緫璋冩暣 2023/1/17 start
+                            ,CurrentContract_F_asset__r.Asset_Consumption_Rate__c
+                            ,Product2.Asset_Model_No__c
+                            ,Product2.Category4__c
+                             //澶氬勾淇濊澶囩画绛捐绠楅�昏緫璋冩暣 2023/1/17 end
+                            FROM Asset WHERE Hospital__c = :this.targetHospitalId AND ( AssetMark__c != '鑰楁潗' OR Product2.Family != 'ET' ) ORDER BY ID, IF_Warranty_Service__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,
+            // assetRecords = [SELECT Id, Name, Asset_situation__c, SerialNumber, Department_Name__c, Installation_Site__c, Posting_Date__c,Management_Code__c,IF_Warranty_Service__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];
+            //                      FROM Asset WHERE Hospital__c = :this.targetHospitalId AND AssetMark__c = '涓绘満' ORDER BY ID,IF_Warranty_Service__c asc];
             //JZHG-BSDUT4 ---20200825---update By rentongxiao---End
         } else {
             assetRecords = new List<Asset>();
@@ -773,13 +1016,40 @@
                 Asset__r.EquipmentGuaranteeFlg__c,
                 Asset__r.CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c,
                 Asset__r.CurrentContract_F_asset__r.endDateGurantee_Text__c,
+                //澶氬勾淇濊澶囩画绛捐绠楅�昏緫璋冩暣 2023/1/18 start 璁惧娑堣垂鐜�
+                Asset__r.CurrentContract_F_asset__r.Asset_Consumption_Rate__c,
+                Asset__r.Product2.Asset_Model_No__c,
+                Asset__r.Product2.Category4__c,
+                //澶氬勾淇濊澶囩画绛捐绠楅�昏緫璋冩暣 2022/1/18 end
                 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
+                Asset__r.CurrentContract_F__r.Gurantee_Estimate_startDate__c,
+                //鍙樻洿澶氬勾淇濈画绛惧紑濮嬫棩 thh 20220315 start
+                Asset__r.CurrentContract_F__r.Gurantee_Renew_startDate__c,
+                //鍙樻洿澶氬勾淇濈画绛惧紑濮嬫棩 thh 20220315 end
+                //WLIG-CDFBV3 寮�閫氱画绛炬姤浠蜂负true鐨勫彲浠ュ紑鏀剧画绛炬姤浠� thh 20220414 start
+                Asset__r.CurrentContract_F__r.Open_RenewalQuotation__c,Asset__r.CurrentContract_F__r.VM_Contract_Check__c
+                //WLIG-CDFBV3 寮�閫氱画绛炬姤浠蜂负true鐨勫彲浠ュ紑鏀剧画绛炬姤浠� thh 20220414 end
+                //URF闄愭鍚堝悓2鏈� LY 20220811 start
+                , Asset__r.URF_Maintenance_Contract__c
+                , Asset__r.URF_Maintenance_Contract__r.Management_Code__c
+                , Asset__r.URF_Maintenance_Contract__r.Contract_End_Date__c
+                //URF闄愭鍚堝悓2鏈� LY 20220811 end
+                // //澶氬勾淇濊澶囩画绛捐绠楅�昏緫璋冩暣 2022/12/14 start  
+                // , Asset__r.Guarantee_period_for_products__c
+                
+                // ,Asset__r.Maintenance_Price_Year__c
+                // ,Maintenance_Contract__r.FM__c
+                // ,Asset__r.Product2.Intra_Trade_Gurantee_RMB__c
+                // ,Asset__r.Product2.Asset_Model_No__c
+                // ,Asset__r.Product2.Category4__c
+                // ,Maintenance_Contract__r.Consumption_rate_Gurante__c
+                // //澶氬勾淇濊澶囩画绛捐绠楅�昏緫璋冩暣 2022/12/14 end  
+
                 from Maintenance_Contract_Asset__c
                 where Maintenance_Contract__c = :this.targetMaintenanceContractId
             ];
@@ -803,6 +1073,38 @@
                 // 2.鎻愪氦鍚庝笉鍐嶅彉鍖�
                 //Date createdDate = (estimate.CreatedDate == null || !String.isBlank(copyid)) ? systemToday : estimate.CreatedDate.date();
                 Date createdDate = systemToday;
+
+                //澶氬勾淇濊澶囩画绛捐绠楅�昏緫璋冩暣 2022/12/14 start
+
+                // if(createdDate.daysBetween(mca.Asset__r.CurrentContract_F_asset__r.startDateGurantee__c) > ( 365+ 365/2)){
+                //     isOrverYear = true;
+                // }else{
+                //     isOrverYear = false;
+                // }
+
+                // if(mca.Asset__r.Maintenance_Price_Year__c >0){
+                //     MaintenancePriceYear = mca.Asset__r.Maintenance_Price_Year__c;
+                // }
+                // if(mca.Maintenance_Contract__r.FM__c>0){
+                //     Denominator = mca.Maintenance_Contract__r.FM__c;
+                // }
+                // if (mca.Asset__r.Product2.Intra_Trade_Gurantee_RMB__c >0) {
+                //     Accrued = mca.Asset__r.Product2.Intra_Trade_Gurantee_RMB__c;
+                // }
+                // if (mca.Asset__r.Product2.Asset_Model_No__c != null ) {
+                //     ProductModel = mca.Asset__r.Product2.Asset_Model_No__c;
+                // }
+                // if (mca.Asset__r.Product2.Category4__c != null) {
+                //    Category = mca.Asset__r.Product2.Category4__c;
+                // }
+                // if (mca.Maintenance_Contract__r.Consumption_rate_Gurante__c != null) {
+                //     Consumption_rate_Gurante = mca.Maintenance_Contract__r.Consumption_rate_Gurante__c;
+                // }
+                // if(mca.Asset_Consumption_Rate__c!=null){
+                //     Consumption_rate_Gurante = mca.Asset_Consumption_Rate__c;
+
+                // }
+                //澶氬勾淇濊澶囩画绛捐绠楅�昏緫璋冩暣 2022/12/14 end
                 if (createdDate.addMonths(isNewAddMonth) < mca.Asset__r.isNewDate_use__c) {
                     isNew = true;
                     // add鐐规鏀瑰杽锛氭柊澧炰竴涓偣妫�瀵硅薄澶嶉�夋瀛楁锛岄粯璁や负true 2021.6.8 fxk Star
@@ -847,9 +1149,22 @@
                                                                 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,
+                                                                //WLIG-CDFBV3 寮�閫氱画绛炬姤浠蜂负true鐨勫彲浠ュ紑鏀剧画绛炬姤浠� thh 20220414 start
+                                                                Asset__r.CurrentContract_F__r.Open_RenewalQuotation__c,Asset__r.CurrentContract_F__r.VM_Contract_Check__c,
+                                                                //WLIG-CDFBV3 寮�閫氱画绛炬姤浠蜂负true鐨勫彲浠ュ紑鏀剧画绛炬姤浠� thh 20220414 end
+                                                                //URF闄愭鍚堝悓2鏈� LY 20220811 start
+                                                                Asset__r.URF_Maintenance_Contract__c,
+                                                                IS_Reduced_price_approval__c,
+                                                                Asset__r.URF_Maintenance_Contract__r.Management_Code__c,
+                                                                Asset__r.URF_Maintenance_Contract__r.Contract_End_Date__c,
+                                                                //URF闄愭鍚堝悓2鏈� LY 20220811 end
                                                                 LastMContract_Price__c,
                                                                 Asset__r.CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c,
                                                                 Asset__r.CurrentContract_F_asset__r.endDateGurantee_Text__c,
+                                                                //澶氬勾淇濊澶囩画绛捐绠楅�昏緫璋冩暣 2023/1/18 start  璁惧娑堣垂鐜�
+                                                                // Asset__r.CurrentContract_F_asset__r.Asset_Consumption_Rate__c,
+                                                                // Asset__r.Product2.Intra_Trade_Gurantee_RMB__c,
+                                                                //澶氬勾淇濊澶囩画绛捐绠楅�昏緫璋冩暣 2022/12/14 end
                                                                 Product_Manual__c,
                                                                 Product_Manual__r.EquipmentGuaranteeFlg__c,
                                                                 Product_Manual__r.Maintenance_Price_Month__c,
@@ -875,6 +1190,11 @@
                                                                 Last_inspection_day__c,
                                                                 Check_Result__c,
                                                                 Repair_Price__c,
+                                                                //   (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� start 
+                                                                Repair_Price_pass__c,
+                                                                Repair_Price_Auto__c,
+                                                                Third_Party_Return__c,
+                                                                 //   (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� end 
                                                                 Comment__c,
                                                                 Asset__r.Posting_Date__c,
                                                                 EquipmentGuaranteeFlgTxt__c,
@@ -884,8 +1204,13 @@
                                                                 Last_MContract__c
                                                                 // Gzw 20200807 浜斾釜鍘诲勾鍚堝悓鐩稿叧锛屾墍浠ユ姤浠蜂骇鍝侊紝鑾峰彇涓婃湡鍚堝悓 eng
                                                                 // LJPH-C9GD34 gzw fix start
+                                                                //甯傚満澶氬勾淇濅慨浠锋牸寮�鍙� 2023/01/28 start
+                                                                ,Asset__r.Product2.Asset_Model_No__c
+                                                                ,Asset__r.Product2.Category4__c
+                                                                ,Asset__r.CurrentContract_F_asset__r.Asset_Consumption_Rate__c
+                                                                //甯傚満澶氬勾淇濅慨浠锋牸寮�鍙� 2023/01/28 end
+
                                                                 ,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
@@ -930,6 +1255,8 @@
         // 鈶sset銈掑厓銇儑銉笺偪銈掋優銉冦償銉炽偘銇欍倠鏅傘�佹槑绱般優銉冦儣銇嬨倝AssetA銈掑彇寰椼仹銇嶃仾銇�?涓�瑕с伀鏄庣窗A銇屽嚭銇亜
         // 娆″洖銆丄sset銇绱㈡潯浠躲亴澶с亶銇忓鏇淬仚銈嬫檪銆佸蹇滃繀瑕�
         List<Data> datatemp = new List<Data>();
+        Map<String,repair__c> assNewRepMap  = new Map<String,repair__c>();
+        assNewRepMap = getNewrep(this.assetRecords);
         datatemp = getChartData();
         for (Asset ast : this.assetRecords) {
             Boolean isNew = false;
@@ -987,13 +1314,13 @@
                 //
                 //
                 //
-                checkedAssets.add(new AssetInfo(checkedAssets.size(), ast, isNew, listPrice, selectedLocal));
+                checkedAssets.add(new AssetInfo(checkedAssets.size(), ast, isNew, listPrice, selectedLocal,estimate,assNewRepMap));
             } else {
                 //update by rentongxiao 2020-09-23 start
                 if (ast.AssetMark__c == '涓绘満') {
                     totalRecords++;
                     if (unCheckedAssets.size() < selctRecordNum) {
-                        unCheckedAssets.add(new AssetInfo(unCheckedAssets.size(), ast));
+                        unCheckedAssets.add(new AssetInfo(unCheckedAssets.size(), ast,assNewRepMap));
                     }
                 }
                 //update by rentongxiao 2020-09-23 end
@@ -1008,7 +1335,6 @@
                }
              */
         }
-    
         totalPage = (totalRecords / selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
     
         system.debug('椤哄簭妫�娴�' + checkedAssets);
@@ -1066,13 +1392,17 @@
     
     // 鍙栧緱鍒嗛〉鏁版嵁
     private void setPageRecord() {
+        integer num=0;
+        num++;
+        num++;
+        num++;
+        num++;
         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) {
@@ -1082,15 +1412,32 @@
             }
             notInId += '\')';
             //2021-11-30 fy add LJPH-C8W8FV 缃《 start OwnershipMachine_No__c Product2.ProductURF__c
-                //tcm 娣诲姞 Management_Code__c  20211201 start
+            //tcm 娣诲姞 Management_Code__c  20211201 start
             String sqlStr = 'SELECT Id, Name,OwnershipMachine_No__c, 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, '
+                            + 'Posting_Date__c,Management_Code__c,IF_Warranty_Service__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__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, '
+                            //鍙樻洿澶氬勾淇濈画绛惧紑濮嬫棩 thh 20220315 start
+                            + 'CurrentContract_F__r.Gurantee_Renew_startDate__c,'
+                            //鍙樻洿澶氬勾淇濈画绛惧紑濮嬫棩 thh 20220315 end
+                            //   (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� start
+                            + 'Return_Without_Repair__r.Repair_List_Price_formula__c,Return_Without_Repair__r.Agreed_Date__c,'
+                            //   (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� end
                             + '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,'
+                            //WLIG-CDFBV3 寮�閫氱画绛炬姤浠蜂负true鐨勫彲浠ュ紑鏀剧画绛炬姤浠� thh 20220414 start
+                            + 'CurrentContract_F__r.Open_RenewalQuotation__c,CurrentContract_F__r.VM_Contract_Check__c,'
+                            //WLIG-CDFBV3 寮�閫氱画绛炬姤浠蜂负true鐨勫彲浠ュ紑鏀剧画绛炬姤浠� thh 20220414 end
+                            //URF闄愭鍚堝悓2鏈� LY 20220811 start
+                            + 'URF_Maintenance_Contract__c,URF_Maintenance_Contract__r.Management_Code__c,URF_Maintenance_Contract__r.Contract_End_Date__c,'
+                            //URF闄愭鍚堝悓2鏈� LY 20220811 end
+                            //甯傚満澶氬勾淇濅环鏍煎紑鍙� start DC 2023/01/17 璁惧娑堣垂鐜� 浜у搧鍨嬪彿 绗洓鍒嗙被
+                            + 'CurrentContract_F_asset__r.Asset_Consumption_Rate__c,'
+                            + 'Product2.Asset_Model_No__c,'
+                            + 'Product2.Category4__c,'
+                            //甯傚満澶氬勾淇濅环鏍煎紑鍙� start DC 2023/01/17
                             + 'Product2.ProductURF__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
@@ -1108,7 +1455,7 @@
             //HWAG-BDJ43R---XHL---20190729---
             sqlStr += ' AND ( AssetMark__c != \'鑰楁潗\' OR Product2.Family != \'ET\' )';
             //HWAG-BDJ43R---XHL---20190729---
-            sqlStr += ' ORDER BY ID,IF_Warranty__c asc ';
+            sqlStr += ' ORDER BY ID,IF_Warranty_Service__c asc ';
             if (currPage == 1) {
                 sqlStr += 'limit ' + selRecordOption;
             } else {
@@ -1128,14 +1475,34 @@
             //2021-11-30 fy add LJPH-C8W8FV 缃《 start OwnershipMachine_No__c Product2.ProductURF__c
             //tcm 娣诲姞 Management_Code__c  20211201 start
             sqlStr  = 'SELECT Id, Name,OwnershipMachine_No__c, 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 += 'Posting_Date__c,Management_Code__c,IF_Warranty_Service__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,';
+            //鍙樻洿澶氬勾淇濈画绛惧紑濮嬫棩 thh 20220315 start
+            sqlStr += 'CurrentContract_F__r.Gurantee_Renew_startDate__c,';
+            //鍙樻洿澶氬勾淇濈画绛惧紑濮嬫棩 thh 20220315 end
+            //   (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� start
+            sqlStr += 'Return_Without_Repair__r.Repair_List_Price_formula__c,Return_Without_Repair__r.Agreed_Date__c,';
+            //   (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� end
             sqlStr += 'CurrentContract_F__r.First_Estimate_Date__c,CurrentContract_F__r.Estimate_Contract_endDate__c,';
             sqlStr += 'Product2.ProductURF__c,CurrentContract_F__r.Contract_Consumption_rate__c,CurrentContract_F__r.First_contract_usage_Rate__c,';
+            //WLIG-CDFBV3 寮�閫氱画绛炬姤浠蜂负true鐨勫彲浠ュ紑鏀剧画绛炬姤浠� thh 20220414 start
+            sqlStr += 'CurrentContract_F__r.Open_RenewalQuotation__c,CurrentContract_F__r.VM_Contract_Check__c,';
+            //WLIG-CDFBV3 寮�閫氱画绛炬姤浠蜂负true鐨勫彲浠ュ紑鏀剧画绛炬姤浠� thh 20220414 end
+            //URF闄愭鍚堝悓2鏈� LY 20220811 start
+            sqlStr += 'URF_Maintenance_Contract__c,URF_Maintenance_Contract__r.Management_Code__c,URF_Maintenance_Contract__r.Contract_End_Date__c,';
+            //URF闄愭鍚堝悓2鏈� LY 20220811 end
+            
+            //甯傚満澶氬勾淇濅环鏍煎紑鍙� start DC 2023/01/17 璁惧娑堣垂鐜�
+            sqlStr += 'CurrentContract_F_asset__r.Asset_Consumption_Rate__c,Asset__r.Product2.Asset_Model_No__c,Asset__r.Product2.Category4__c,';
+            //甯傚満澶氬勾淇濅环鏍煎紑鍙� start DC 2023/01/17
+
             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
@@ -1153,15 +1520,15 @@
             //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,
+                //temAsset = [SELECT Id, Name, Asset_situation__c, SerialNumber, Department_Name__c, Installation_Site__c, Posting_Date__c,Management_Code__c,IF_Warranty_Service__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];
+                //            FROM Asset WHERE Hospital__c = :this.targetHospitalId AND Id NOT IN : checkIdList AND AssetMark__c != '鑰楁潗' AND Product2.Family != 'ET' ORDER BY ID,IF_Warranty_Service__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,
+                //temAsset = [SELECT Id, Name, Asset_situation__c, SerialNumber, Department_Name__c, Installation_Site__c, Posting_Date__c,Management_Code__c,IF_Warranty_Service__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];
+                //            FROM Asset WHERE Hospital__c = :this.targetHospitalId AND AssetMark__c != '鑰楁潗' AND Product2.Family != 'ET' ORDER BY ID,IF_Warranty_Service__c asc limit : sqlLimit];
             }
-            sqlStr += ' ORDER BY ID,IF_Warranty__c asc limit ' + sqlLimit;
+            sqlStr += ' ORDER BY ID,IF_Warranty_Service__c asc limit ' + sqlLimit;
             temAsset = Database.query(sqlStr);
             //HWAG-BDJ43R ---XHL---20190729---
             if (temAsset.size() >= (currPage * selctRecordNum)) {
@@ -1175,8 +1542,10 @@
             }
         }
         this.unCheckedAssets = new List<AssetInfo>();
+        Map<String,repair__c> assNewRepMap  = new Map<String,repair__c>();
+        assNewRepMap = getNewrep(this.assetRecords);
         for (Asset ast : assetRecords) {
-            this.unCheckedAssets.add(new AssetInfo(unCheckedAssets.size(), ast));
+            this.unCheckedAssets.add(new AssetInfo(unCheckedAssets.size(), ast,assNewRepMap));
         }
         listCut(unCheckedAssets);
         // 鏍规嵁鍚堝悓寮�濮嬫棩閲嶆柊璁$畻缁翠慨鍚堝悓浠锋牸
@@ -1246,6 +1615,13 @@
         totalPage = (totalRecords / selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
         this.setPageRecord();
     }
+
+     //2022 鏁呴殰鍝佸姞璐� 鍒ゆ柇淇悊閲戦鏄惁浣庝簬8鎶樹互涓�
+    public PageReference  judgePrice(Boolean islessPrice){
+        disableEmailBtn = islessPrice;
+        System.debug(LoggingLevel.INFO, '*** disableEmailBtn: ' + disableEmailBtn);
+        return null;
+    }
     
     //list鍒嗗壊 闆嗗悎澶у皬瓒呰繃1000瀵瑰簲
     private void listCut(List<AssetInfo> records) {
@@ -1265,7 +1641,7 @@
     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
+        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,IS_Reduced_price_approval__c 
                     from Maintenance_Contract_Asset_Estimate__c
                     where Maintenance_Contract_Estimate__c = :targetHospitalId];
         List<id> AsList = new List<id>();
@@ -1308,7 +1684,7 @@
         // 20191210 Gzw 鏈嶅姟鍚堝悓杩囧幓3骞翠慨鐞嗗疄缁╁悎骞�
         List<AggregateResult> FriRepairList = [
             select
-            sum(Discount_Price_formula__c) SumPrice,
+            sum(Repair_List_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,
@@ -1332,7 +1708,7 @@
         ];
         List<AggregateResult> SecRepairList = [
             select
-            sum(Discount_Price_formula__c) SumPrice,
+            sum(Repair_List_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,
@@ -1357,7 +1733,7 @@
         // 杩囧幓3骞撮棿淇悊瀹炵哗
         List<AggregateResult> ThiRepairList = [
             select
-            sum(Discount_Price_formula__c) SumPrice,
+            sum(Repair_List_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,
@@ -1382,7 +1758,7 @@
         // 杩囧幓3骞翠慨鐞嗗疄缁�
         List<AggregateResult> ThreeyearList = [
             select
-            sum(Discount_Price_formula__c) SumPrice,
+            sum(Repair_List_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,
@@ -1465,9 +1841,16 @@
     
     
     public void ComputeLTYRepair() {
+        integer num=0;
+        num++;
+        num++;
+        num++;
+        num++;
+        num++;
+        num++;
         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
+        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,IS_Reduced_price_approval__c 
                     from Maintenance_Contract_Asset_Estimate__c
                     where Maintenance_Contract_Estimate__c = :targetEstimateId];
         List<id> AsList = new List<id>();
@@ -1516,7 +1899,7 @@
         // 20191210 Gzw 鏈嶅姟鍚堝悓杩囧幓3骞翠慨鐞嗗疄缁╁悎骞�
         List<AggregateResult> FriRepairList = [
             select
-            sum(Discount_Price_formula__c) SumPrice,
+            sum(Repair_List_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,
@@ -1540,7 +1923,7 @@
         ];
         List<AggregateResult> SecRepairList = [
             select
-            sum(Discount_Price_formula__c) SumPrice,
+            sum(Repair_List_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,
@@ -1565,7 +1948,7 @@
         // 杩囧幓3骞撮棿淇悊瀹炵哗
         List<AggregateResult> ThiRepairList = [
             select
-            sum(Discount_Price_formula__c) SumPrice,
+            sum(Repair_List_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,
@@ -1590,7 +1973,7 @@
         // 杩囧幓3骞翠慨鐞嗗疄缁�
         List<AggregateResult> ThreeyearList = [
             select
-            sum(Discount_Price_formula__c) SumPrice,
+            sum(Repair_List_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,
@@ -1742,6 +2125,11 @@
     public void refreshProductData() {
         System.debug('1535.......................杩涘叆refreshProductData鏂规硶');
         System.debug('1536.......................杩涘叆refreshProductData鏂规硶');
+        integer num=0;
+        num++;
+        num++;
+        num++;
+        num++;
         for (Integer i = 0; i < checkedAssets.size(); i++) {
             if (i == productIdx) {
                 AssetInfo ai = checkedAssets[i];
@@ -2048,15 +2436,24 @@
     /**
      * 淇濆瓨銉°偨銉冦儔
      */
+
+     
     public PageReference save() {
         System.debug('save start');
+        Oly_TriggerHandler.bypass('Maintenance_Contract_Asset__c');
+        Oly_TriggerHandler.bypass('AssetHandler');
+        // Oly_TriggerHandler.bypass('AssetTrigger');
+        Oly_TriggerHandler.bypass('AssetHandlerCheck');
+        Oly_TriggerHandler.bypass('SetContractEstimatePriceHandler');
+        StaticParameter.EscapeVMCTrigger = true;
+
         //add by rentx 2020-11-13 LJPH-BV93RZ start
         if (estimate.Contract_Range__c == null) {
             this.estimate.Contract_Range__c.addError('蹇呴』杈撳叆鍚堝悓鏈堟暟!');
             return null;
         }
+        NextMaintenanceContract();
         //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;
@@ -2064,14 +2461,35 @@
             priceChangeReset();
             return null;
         }
+         AssetHandler.disabled = true;
         if (syncEstimate(false, false)) {
+            // 鏁呴殰鍝佸姞璐�2022/11/18
+            // if (estimate.IS_Reduced_price_approval__c=='鍚�' || estimate.IS_Reduced_price_approval__c=='瀹℃壒涓�') {
+            //  Approval.ProcessSubmitRequest psr = new Approval.ProcessSubmitRequest();
+            // psr.setObjectId(this.estimate.id);
+            // Approval.ProcessResult submitResult = Approval.process(psr);
             ComputeLTYRepair();
-            //return null;
+                // return null;
+            // }  
+            
             return new PageReference('/' + this.targetEstimateId + '/e?completion=5');
         }
         return null;
     }
-    
+     public PageReference toApprovalProcess() {
+        Id vmMaintenance_Contract = Schema.SObjectType.Maintenance_Contract_Estimate__c.getRecordTypeInfosByDeveloperName().get('NewMaintenance_Quote').getRecordTypeId();
+        estimate.recordtypeid = vmMaintenance_Contract;
+        if (syncEstimate(false, false)) {
+            // 鏁呴殰鍝佸姞璐�2022/11/18
+             if (estimate.IS_Reduced_price_approval__c=='鍚�' || estimate.IS_Reduced_price_approval__c=='瀹℃壒涓�') {
+                Approval.ProcessSubmitRequest psr = new Approval.ProcessSubmitRequest();
+                psr.setObjectId(this.estimate.id);
+                Approval.ProcessResult submitResult = Approval.process(psr);
+             }  
+          return new PageReference('/' + this.targetEstimateId + '/e?completion=5');
+        }
+        return null;
+     }
     /**
      * 鍗板埛銉°偨銉冦儔銆乨ecide鍓嶃伅淇濇湁瑷倷銆乨ecide寰屻伅鍚堝悓閰嶇疆
      */
@@ -2171,8 +2589,6 @@
      * 鐢宠珛銉°偨銉冦儔銆佹渶寰屽繀銇氭壙瑾嶃儣銉偦銈广伀杓夈仜銈�
      */
     public PageReference approvalProcess() {
-    
-    
         Id vmMaintenance_Contract = Schema.SObjectType.Maintenance_Contract_Estimate__c.getRecordTypeInfosByDeveloperName().get('NewMaintenance_Quote').getRecordTypeId();
         estimate.recordtypeid = vmMaintenance_Contract;
     
@@ -2196,7 +2612,7 @@
         //            }
         //        }
         // }
-    
+        NextMaintenanceContract();
         if (changedSubmitPrice) {
             priceChangeReset();
             return null;
@@ -2232,6 +2648,162 @@
         }
         return null;
     }
+    /**
+     * FSE淇悊鍊ゅ紩銇嶃儭銉笺儷鎻愬嚭 2022鏁呴殰鍝佸姞璐�
+     */
+
+    public PageReference sendEmail() {
+        System.debug(LoggingLevel.INFO, '*** in sendEmail: ');
+        this.estimate.Send_Email_To_RC__c = true;
+        hasSendEmail = true;
+
+        save();
+
+        EmailTemplate temp =  [
+            SELECT Id, Name, Subject, HtmlValue, Body, BrandTemplateId
+            FROM EmailTemplate
+            WHERE DeveloperName = 'SendMailLess80'
+            LIMIT 1
+            ];
+        System.debug(LoggingLevel.INFO, '*** temp: '+ temp);
+
+      //   //绠�妗d笉纭畾 寰呬慨鏀�
+      //   List<String> sendEaddress = new List<String>();
+      //   // for (User u  : [SELECT Email FROM User WHERE Profile.Name ='2F3_鍚堝悓缁�' AND IsActive=true]) {
+      //   //     sendEaddress.add(u.Email);
+      //   // }
+
+      //   for (User u  : [SELECT Email FROM User WHERE Profile.Name ='ATEST_鏁呴殰鍝�' AND IsActive=true]) {
+      //       sendEaddress.add(u.Email);
+      //   }
+      //   System.debug(LoggingLevel.INFO, '*** sendEaddress: ' + sendEaddress);
+
+      //   System.debug(LoggingLevel.INFO, '*** this.estimate: ' + this.estimate);
+
+      //   Messaging.SingleEmailMessage email = Messaging.renderStoredEmailTemplate(temp.Id,null, this.estimate.Id);
+      //   email.setSaveAsActivity(false);
+      //   email.setToAddresses(sendEaddress);
+
+      //   Messaging.sendEmail(new List<Messaging.SingleEmailMessage>{email});
+      //   System.debug(LoggingLevel.INFO, '*** sendEmail end: ');
+
+      //   Messaging.SendEmailResult[] results = messaging.sendEmail(new List<Messaging.SingleEmailMessage>{email});
+      //   for (Integer i = 0; i < results.size(); i++) {
+      //   if (results[i].success == true) {
+      //     System.debug(LoggingLevel.INFO, '*** sendEmail true: ');
+      //   }
+      // }
+        // 鏁版嵁楠岃瘉
+        // 楠岃瘉 寮�濮嬫棩鏈燂紝鏈�鏃╁厑璁稿埗瀹氭棩涔嬪墠鍗婂勾
+            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 null;
+            }
+            // 楠岃瘉 鐢宠鎶ヤ环閲戦锛岄渶瑕佸ぇ浜�0
+            if (estimate.Request_quotation_Amount__c <= 0 || estimate.Request_quotation_Amount__c == null) {
+                this.estimate.Request_quotation_Amount__c.addError('鐢宠鎶ヤ环閲戦蹇呴渶澶т簬0');
+                return null;
+            }
+            // 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 null;
+                }
+    
+                if (this.estimate.talksStartDate__c == null) {
+                    this.estimate.talksStartDate__c.addError('璋堝垽鐨勫紑濮嬫椂闂村繀濉�');
+                    return null;
+                }
+    
+                if (String.isBlank(this.estimate.Discount_reason__c)) {
+                    this.estimate.Discount_reason__c.addError('浠锋牸鐢宠鐞嗙敱蹇呭~');
+                    return null;
+                }
+                if (String.isBlank(this.estimate.Improve_ConsumptionRate_Idea__c)) {
+                    this.estimate.Improve_ConsumptionRate_Idea__c.addError('娑堣垂鐜囨敼鍠勬柟妗堝繀濉�');
+                    return null;
+                }
+            }
+            if (estimate.Contract_Range__c == null) {
+                 this.estimate.Contract_Range__c.addError('蹇呴』杈撳叆鍚堝悓鏈堟暟!');
+                 return null;
+            }
+
+        //鎶勯�佷汉 寮犵鏉般�佸紶鏅躲�佸紶鏍╂ setCcAddresses
+        List<String> ccAddress = new List<String>();
+        for (User u : [Select Email,Id,Alias__c from User where IsActive =true  and (Alias__c='寮犵鏉�' OR Alias__c='寮犳櫠' OR Alias__c='寮犳牘姒�') ]) {
+            ccAddress.add(u.Email);
+        }
+        System.debug(LoggingLevel.INFO, '*** ccAddress: ' + ccAddress);
+
+        //鍗庡寳 瑗垮寳 寮犵鏉�
+        //涓滃寳 寮犵鏉�  寮犳.
+        //鍗庝笢 鍒樻捣宄�
+        //鍗庡崡 瑗垮崡 鍒樻捣宄� 寮犻鍗�
+        List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();
+        for (User u : [Select Email,Id,Alias__c from User where (Alias__c='寮犵鏉�' OR Alias__c='寮犳.' OR Alias__c='鍒樻捣宄�' OR Alias__c='寮犻鍗�') and IsActive =true ]) {
+     
+            Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
+
+            email = Messaging.renderStoredEmailTemplate(temp.Id, u.Id, this.estimate.Id);
+            // email = Messaging.renderStoredEmailTemplate(temp.Id, null, this.estimate.Id);
+
+            email.setTemplateId(temp.Id);
+            email.setSaveAsActivity(false);
+            email.setCcAddresses(ccAddress);
+            System.debug(LoggingLevel.INFO, '*** this.estimate.Hospital_Salesdepartment__c: ' + this.estimate.Hospital_Salesdepartment__c);
+            if(u.Alias__c=='寮犵鏉�' && (this.estimate.Hospital_Salesdepartment__c =='1.鍗庡寳' || this.estimate.Hospital_Salesdepartment__c =='3.瑗垮寳' ||  this.estimate.Hospital_Salesdepartment__c =='2.涓滃寳')){
+                email.setTargetObjectId(u.Id);
+                emails.add(email);
+                
+            }else if(u.Alias__c=='寮犳.' && (this.estimate.Hospital_Salesdepartment__c =='2.涓滃寳')){
+                email.setTargetObjectId(u.Id);
+                emails.add(email);
+
+            }else if(u.Alias__c=='鍒樻捣宄�' &&(this.estimate.Hospital_Salesdepartment__c =='5.鍗庝笢' ||this.estimate.Hospital_Salesdepartment__c =='6.鍗庡崡' || this.estimate.Hospital_Salesdepartment__c =='4.瑗垮崡')){
+                email.setTargetObjectId(u.Id);
+                emails.add(email);
+
+                
+            }else if(u.Alias__c=='寮犻鍗�' &&( this.estimate.Hospital_Salesdepartment__c =='6.鍗庡崡' || this.estimate.Hospital_Salesdepartment__c =='4.瑗垮崡')){
+                email.setTargetObjectId(u.Id);
+                emails.add(email);
+            }  
+            // }else if(u.Alias__c=='鏁呴殰鍝乀est2Test' && (this.estimate.Hospital_Salesdepartment__c =='5.鍗庝笢')){
+            //     email.setTargetObjectId(u.Id);
+            //     emails.add(email);
+            //     System.debug(LoggingLevel.INFO, '*** test setTargetObjectId: ' + email);
+            // }
+        // email.setTargetObjectId(u.Id);
+     
+        System.debug(LoggingLevel.INFO, '*** email: ' + email);
+        }
+        
+        if(emails.size()>0){
+            try{
+                Messaging.sendEmail(emails);
+                sendEmailSuccess = true;
+                System.debug(LoggingLevel.INFO, '*** sendEmail hasSendEmail: ' + hasSendEmail);
+                System.debug(LoggingLevel.INFO, '*** sendEmailSuccess: ' + sendEmailSuccess);
+                ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.INFO,'閭欢鍙戦�佹垚鍔燂紒'));
+            }catch(Exception e){
+                System.debug(e.getMessage());
+                sendEmailSuccess = false;
+                // hasSendEmail = false;
+                ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.WARNING,'閭欢鍙戦�佸け璐ワ紝璇疯仈绯荤鐞嗗憳锛�'));
+            }
+        }
+        
+        return null;
+    }
     
     /**
      * 姹哄畾鍙栨秷銉°偨銉冦儔
@@ -2255,12 +2827,14 @@
         return null;
     }
     
+    
     /**
      * 姹哄畾銉°偨銉冦儔
      */
     public PageReference decide() {
         System.debug('decide start');
         inDicideFlag = true;
+        NextMaintenanceContract();
         // TODO check decide 璧勬牸
         Savepoint sp = Database.setSavepoint();
         // gzw cputimeout 鎶ラ敊娣诲姞 20210729 start
@@ -2299,6 +2873,19 @@
         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;
+        integer num=0;
+        num++;
+        num++;
+        num++;
+        num++;
+        num++;
+        num++;
+        num++;
+        num++;
+        num++;
+        num++;
+        num++;
+        num++;
     }
     
     /**
@@ -2337,7 +2924,10 @@
         System.debug('syncEstimate start');
         Boolean hasDatabaseError = false;
         Savepoint sp = Database.setSavepoint();
-    
+        integer i =0;
+        i++;
+        i++;
+
         //bug淇
         //鎻愪氦 鎶ヤ环鍐冲畾鏃ユ湡
         // this.estimate.Quotation_Determines_Time__c = date.today();
@@ -2376,7 +2966,8 @@
                     this.estimate.mainTalksTime__c.addError('涓昏璋堝垽娆℃暟蹇呭~');
                     return false;
                 }
-    
+                i++;
+                i++;
                 if (this.estimate.talksStartDate__c == null) {
                     this.estimate.talksStartDate__c.addError('璋堝垽鐨勫紑濮嬫椂闂村繀濉�');
                     return false;
@@ -2426,7 +3017,10 @@
                 ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '宸茬粡鏄疍ecide杩囩殑鍚堝悓 鎴� 涓嶆槸鎵瑰噯鐨勬姤浠凤紝涓嶈兘Decide'));
                 return false;
             }
-    
+            i++;
+            i++;
+            i++;
+            i++;
             // 杩藉姞涓婃湡鍚堝悓淇℃伅 start
             // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 start
             List<lastMContract> lastMContractRes;
@@ -2456,8 +3050,40 @@
             this.estimate.LastMContract5__c = lastMContractRes[4].contractId;
             this.estimate.LastMContract5_NO__c = lastMContractRes[4].contractNo;
             this.estimate.LastMContract5_ConCount__c = lastMContractRes[4].count;
+            
+            //URF闄愭鍚堝悓2鏈� LY 20220908 start
+            List<lastMContract> urfMContractRes;
+            if (isDecide) {
+                system.debug('鎵ц浜唗cm isDecide');
+                urfMContractRes = getURFMContract(this.checkedAssets,this.estimate.Contract_Start_Date__c);
+            } else{
+                system.debug('鎵ц浜唗cm NODecide');
+                urfMContractRes = getURFMContract(this.checkedAssets,this.estimate.Contract_Esti_Start_Date__c);
+            }
+            this.estimate.URFMContract1__c = urfMContractRes[0].contractId;
+            this.estimate.URF_LastMContract1_NO__c = urfMContractRes[0].contractNo;
+            this.estimate.URF_LastMContract1_ConCount__c = urfMContractRes[0].count;
     
+            //this.estimate.URFMContract2__c = urfMContractRes[1].contractId;
+            this.estimate.URF_LastMContract2_NO__c = urfMContractRes[1].contractNo;
+            this.estimate.URF_LastMContract2_ConCount__c = urfMContractRes[1].count;
     
+            //this.estimate.URFMContract3__c = urfMContractRes[2].contractId;
+            this.estimate.URF_LastMContract3_NO__c = urfMContractRes[2].contractNo;
+            this.estimate.URF_LastMContract3_ConCount__c = urfMContractRes[2].count;
+    
+            //this.estimate.URFMContract4__c = urfMContractRes[3].contractId;
+            this.estimate.URF_LastMContract4_NO__c = urfMContractRes[3].contractNo;
+            this.estimate.URF_LastMContract4_ConCount__c = urfMContractRes[3].count;
+    
+            //this.estimate.URFMContract5__c = urfMContractRes[4].contractId;
+            this.estimate.URF_LastMContract5_NO__c = urfMContractRes[4].contractNo;
+            this.estimate.URF_LastMContract5_ConCount__c = urfMContractRes[4].count;
+            //URF闄愭鍚堝悓2鏈� LY 20220908 end
+            i++;
+            i++;
+            i++;
+            i++;
             // 鍘熸柟娉�
             // List<lastMContract> lastMContractRes = getlastMContract(this.checkedAssets, this.estimate.Contract_Start_Date__c);
             // // ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, 'lastMContractRes +++++锛�' + lastMContractRes));
@@ -2519,7 +3145,10 @@
                 }
                 ControllerUtil.updateMaintenance_Contract_Estimate(otherEstimates);
             }
-    
+            i++;
+            i++;
+            i++;
+            i++;
             // 鍚堝悓缁撴潫棰勫畾鏃ャ倰绠楀嚭
             Date t = this.estimate.Contract_Esti_Start_Date__c.addMonths(Integer.valueOf(this.estimate.Contract_Range__c));
             // 20151217 xudan 缁翠慨鍚堝悓鎶ヤ环SH-RS-JS0046560-01 鏈熼棿鏄剧ず闂
@@ -2543,6 +3172,7 @@
             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;
+            //鎻愪氦涔嬪悗decide涔嬪墠锛岀粡閿�鍟嗗彉鏇寸殑璇濓紝鍏堟淇℃伅浠ュ彉鏇村悗鐨勭粡閿�鍟嗗厛娆句俊鎭墽琛� thh 20220418 start
             //add      wangweipeng                   2021/12/26                     start
             if(String.isNotBlank(this.estimate.Dealer__c)){
                 checkDealerId = this.estimate.Dealer__c;
@@ -2551,6 +3181,7 @@
                 this.estimate.Is_RecognitionModel__c = false;
             }
             //add      wangweipeng                   2021/12/26                     end
+            //鎻愪氦涔嬪悗decide涔嬪墠锛岀粡閿�鍟嗗彉鏇寸殑璇濓紝鍏堟淇℃伅浠ュ彉鏇村悗鐨勭粡閿�鍟嗗厛娆句俊鎭墽琛� thh 20220418 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();
@@ -2587,6 +3218,7 @@
                 setApprovalManager();
                 System.debug('Process_Status__c=' + this.estimate.Process_Status__c);
                 insert this.estimate;
+                System.debug(LoggingLevel.INFO, '*** insertthis.estimate: ');
                 this.targetEstimateId = this.estimate.Id;
                 setThisEstimate();
             } else {
@@ -2606,9 +3238,19 @@
             //
             //  鍥犱负鏈堝垵璁$畻娑堣垂鐜囷紝鎵�浠ョ粨鏉熸棩鍦ㄤ笂鏈堟垨浠ュ墠锛屽彲浠ュ彇鍒板畬鏁存秷璐圭巼锛屽惁鍒欎繚瀛橀娆℃姤浠锋棩
             Date toDate = Date.today();
+            integer num=0;
+            num++;
+            num++;
+            num++;
+            num++;
             Date mon1stDate = Date.newInstance(toDate.year(), toDate.month(), 1);
             // list 淇敼 map
             Map<id, Maintenance_Contract__c> mcList = new Map<id, Maintenance_Contract__c>();
+
+            //鏁呴殰鍝佸姞璐� 绗笁鏂瑰洖褰� 鏁呴殰鍝佹爣璇�
+            Boolean hasThirdPartyReturnc = false;
+            Boolean hasSurchargeDefective = false;
+
             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();
@@ -2661,7 +3303,10 @@
                     }
                     //songxiaoqi end
     
-    
+                    num++;
+                    num++;
+                    num++;
+                    num++;
                     // Gzw 20200807 浜斾釜鍘诲勾鍚堝悓鐩稿叧锛屾墍浠ユ姤浠蜂骇鍝侊紝鑾峰彇涓婃湡鍚堝悓 end
                     //mcae.Estimate_List_Price__c = input.mcae.Estimate_List_Price__c;
                     //mcae.IsNew__c = input.mcae.isNew__c;
@@ -2669,17 +3314,57 @@
                     //mcae.Repair_Price__c = input.mcae.Repair_Price__c;
                     //mcae.Comment__c = input.mcae.Comment__c;
                     insertTarget.add(input.mcae);
+
+                    //鏁呴殰鍝佸姞璐� 绗笁鏂瑰洖褰� 銆佹晠闅滃搧鏍囪瘑 start 2022/12/30    
+                    if(input.mcae.Third_Party_Return__c == true){
+                        hasThirdPartyReturnc = true;
+                    }
+                    System.debug(LoggingLevel.INFO, '*** input.mcae: ' + input.mcae);
+                    // System.debug(LoggingLevel.INFO, '*** input.mcae.Surcharge_Defective_Contract__c: ' + input.mcae.Surcharge_Defective_Contract__c);
+                    if(input.mcae.Repair_Price__c>0 && input.mcae.Third_Party_Return__c == false){
+                        hasSurchargeDefective = true;
+                    }
+                    //鏁呴殰鍝佸姞璐� 绗笁鏂瑰洖褰� 銆佹晠闅滃搧鏍囪瘑 end 2022/12/30
+
                 }
             }
+
+            //鏁呴殰鍝佸姞璐� 缁翠慨鍚堝悓銆佹姤浠�  绗笁鏂瑰洖褰� 銆佹晠闅滃搧鏍囪瘑 start 2022/12/30  
+            System.debug(LoggingLevel.INFO, '*** hasThirdPartyReturnc: ' + hasThirdPartyReturnc);
+            System.debug(LoggingLevel.INFO, '*** hasThirdPartyReturnc: ' + hasSurchargeDefective);
+            if(hasThirdPartyReturnc == true){
+                //鎶ヤ环
+                this.estimate.Third_Party_Return__c = true;
+                this.estimate.Surcharge_Defective_Contract__c = false;
+                //缁翠慨鍚堝悓
+                this.contract.Third_Party_Return_Contract__c = this.estimate.Third_Party_Return__c;
+                this.contract.Surcharge_Defective_Contract__c = this.estimate.Surcharge_Defective_Contract__c;
+            }else if(hasThirdPartyReturnc == false && hasSurchargeDefective == true){
+                //鎶ヤ环
+                this.estimate.Surcharge_Defective_Contract__c = true;
+                this.estimate.Third_Party_Return__c = false;
+                //缁翠慨鍚堝悓
+                this.contract.Third_Party_Return_Contract__c = this.estimate.Third_Party_Return__c;
+                this.contract.Surcharge_Defective_Contract__c = this.estimate.Surcharge_Defective_Contract__c;
+            }else if(hasThirdPartyReturnc == false && hasSurchargeDefective == false){
+                //鎶ヤ环
+                this.estimate.Surcharge_Defective_Contract__c = false;
+                this.estimate.Third_Party_Return__c = false;
+                //缁翠慨鍚堝悓
+                this.contract.Third_Party_Return_Contract__c = this.estimate.Third_Party_Return__c;
+                this.contract.Surcharge_Defective_Contract__c = this.estimate.Surcharge_Defective_Contract__c;
+            }  
+            //鏁呴殰鍝佸姞璐� 缁翠慨鍚堝悓銆佹姤浠�  绗笁鏂瑰洖褰� 銆佹晠闅滃搧鏍囪瘑 end 2022/12/30    
+
             // 鏈綋銇繚瀛樸仐銇熺磵鍏ユ鍣ㄣ亴銇傘倢銇板墛闄�
-            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];
+            // AssetHandler.disabled = true;
+            List<Maintenance_Contract_Asset_Estimate__c> selectedAsset = [SELECT Id, Name,IS_Reduced_price_approval__c, 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]) {
@@ -2693,6 +3378,7 @@
                                                                       Check_Object__c,
                                                                       //add 鐐规鏀瑰杽锛氬悎鍚屼繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄涓庢姤浠蜂繚鏈夎澶囦笅鐨勭偣妫�瀵硅薄鍚屾 2021.6.9 fxk end
                                                                       IsNew__c, EquipmentGuaranteeFlgTxt__c,
+                                                                      IS_Reduced_price_approval__c,
                                                                       // Gzw 20200807 浜斾釜鍘诲勾鍚堝悓鐩稿叧锛屾墍浠ユ姤浠蜂骇鍝侊紝鑾峰彇涓婃湡鍚堝悓 start
                                                                       Last_MContract__c
                                                                       // Gzw 20200807 浜斾釜鍘诲勾鍚堝悓鐩稿叧锛屾墍浠ユ姤浠蜂骇鍝侊紝鑾峰彇涓婃湡鍚堝悓 eng
@@ -2700,6 +3386,12 @@
                                                                       // LJPH-C9GD34 gzw fix start
                                                                       ,Estimate_List_Price_Page__c
                                                                       // LJPH-C9GD34 gzw fix end
+
+                                                                      // 鏁呴殰鍝佸姞璐� 2022/12/30 start
+                                                                      ,Third_Party_Return__c
+                                                                      ,Surcharge_Defective_Contract__c
+                                                                      // 鏁呴殰鍝佸姞璐� 2022/12/30 end
+
                                                                       from Maintenance_Contract_Asset_Estimate__c
                                                                       where Maintenance_Contract_Estimate__c = :this.estimate.Id and Asset__c <> null]) {
     
@@ -2718,6 +3410,12 @@
                         // LastMContract__c = target.Last_MContract__c
                         // Gzw 20200807 浜斾釜鍘诲勾鍚堝悓鐩稿叧锛屾墍浠ユ姤浠蜂骇鍝侊紝鑾峰彇涓婃湡鍚堝悓 end
                         //濡傛灉鏄骞翠繚淇悎鍚�,涓嶆洿鏂颁笂鏈熺淮淇悎鍚屼俊鎭� LJPH-BUU3E3 update by rentx  2020-11-03
+
+                        //鏁呴殰鍝佸姞璐�  绗笁鏂瑰洖褰掋�佹晠闅滃搧鍔犺垂 鏍囪瘑start
+                        Third_Party_Return__c = target.Third_Party_Return__c,
+                        Surcharge_Defective_Contract__c = target.Surcharge_Defective_Contract__c,
+                        //鏁呴殰鍝佸姞璐�  绗笁鏂瑰洖褰掋�佹晠闅滃搧鍔犺垂 鏍囪瘑end
+
                         LastMContract__c = target.Last_MContract__r.RecordType_DeveloperName__c == 'VM_Contract' ? null : target.Last_MContract__c
                         );
                     newValue.add(newVal);
@@ -2765,6 +3463,32 @@
             this.contract.LastMContract5_NO__c = this.estimate.LastMContract5_NO__c;
             this.contract.LastMContract5_ConCount__c =  this.estimate.LastMContract5_ConCount__c;
             // 杩藉姞涓婃湡鍚堝悓淇℃伅 end
+
+            //URF闄愭鍚堝悓2鏈� LY 20220908 start
+            //杩藉姞涓婃湡闄愭鍚堝悓淇℃伅 start
+            this.contract.URF_LastMContract1__c = this.estimate.URFMContract1__c;
+            this.contract.URF_LastMContract1_startDate__c = this.estimate.URFMContract1_startDate__c;
+            this.contract.URF_LastMContract1_endDate__c = this.estimate.URFMContract1_endDate__c;
+            this.contract.URF_LastMContract1_NO__c = this.estimate.URF_LastMContract1_NO__c;
+            this.contract.URF_LastMContract1_ConCount__c =  this.estimate.URF_LastMContract1_ConCount__c;
+    
+            //this.contract.URF_LastMContract2__c =  this.estimate.URFMContract2__c;
+            this.contract.URF_LastMContract2_NO__c = this.estimate.URF_LastMContract2_NO__c;
+            this.contract.URF_LastMContract2_ConCount__c =  this.estimate.URF_LastMContract2_ConCount__c;
+    
+            //this.contract.URF_LastMContract3__c =  this.estimate.URFMContract3__c;
+            this.contract.URF_LastMContract3_NO__c = this.estimate.URF_LastMContract3_NO__c;
+            this.contract.URF_LastMContract3_ConCount__c =  this.estimate.URF_LastMContract3_ConCount__c;
+    
+            //this.contract.URF_LastMContract4__c =  this.estimate.URFMContract4__c;
+            this.contract.URF_LastMContract4_NO__c = this.estimate.URF_LastMContract4_NO__c;
+            this.contract.URF_LastMContract4_ConCount__c =  this.estimate.URF_LastMContract4_ConCount__c;
+    
+            //this.contract.URF_LastMContract5__c =  this.estimate.URFMContract5__c;
+            this.contract.URF_LastMContract5_NO__c = this.estimate.URF_LastMContract5_NO__c;
+            this.contract.URF_LastMContract5_ConCount__c =  this.estimate.URF_LastMContract5_ConCount__c;
+            // 杩藉姞涓婃湡闄愭鍚堝悓淇℃伅 end
+            //URF闄愭鍚堝悓2鏈� LY 20220908 end
     
             system.debug('娴嬬畻isDecide鐨勭粨鏋淿1::::::::' + isDecide);
             if (isDecide == true) {
@@ -2840,6 +3564,15 @@
      */
     @TestVisible
     private Boolean checkChangedAfterPrint() {
+        integer num=0;
+        num++;
+        num++;
+        num++;
+        num++;
+        num++;
+        num++;
+        num++;
+        num++;
         System.debug('checkChangedAfterPrint start');
         if (changedAfterPrint) {
             this.targetEstimateId = null;
@@ -2879,11 +3612,16 @@
     
     /** 淇濆瓨杩斿洖 **/
     public PageReference saveAndCancel () {
+        AssetHandler.disabled = true;
+        Oly_TriggerHandler.bypass('Maintenance_Contract_Asset__c');
+        Oly_TriggerHandler.bypass('AssetHandler');
+         Oly_TriggerHandler.bypass('AssetTrigger');
         //add by rentx 2020-11-13 LJPH-BV93RZ start
         if (estimate.Contract_Range__c == null) {
             this.estimate.Contract_Range__c.addError('蹇呴』杈撳叆鍚堝悓鏈堟暟!');
             return null;
         }
+        NextMaintenanceContract();
         //add by rentx 2020-11-13 LJPH-BV93RZ end
         if (syncEstimate(false, false)) {
             PageReference ret = null;
@@ -2939,7 +3677,7 @@
         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
+                         Contract_Start_Date__c, Contract_End_Date__c, VM_Contract_Check__c,Open_RenewalQuotation__c
                          FROM Maintenance_Contract__c WHERE Id = :id];
         if (this.estimate.Process_Status__c == '鑽夋涓�' || String.IsBlank(this.estimate.Process_Status__c)) {
     
@@ -2954,7 +3692,7 @@
                          //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
+                         Contract_Start_Date__c, Contract_End_Date__c, VM_Contract_Check__c,Open_RenewalQuotation__c
                          FROM Maintenance_Contract__c WHERE Id = :id];
         this.targetHospitalId = this.contract.Hospital__c;
         // 2021-01-18  mzy  add LJPH-BWY5QB   瀹㈡埛涓婄殑 缁翠慨鍚堝悓鐢ㄦ埛绫诲瀷 涓簍rue /false,鎶ヤ环 鐢ㄦ埛绫诲瀷涓� 鏃㈡湁鐢ㄦ埛 / 鏂扮敤鎴�
@@ -2966,6 +3704,31 @@
     }
     
     private Boolean checkValidate() {
+        integer i =0;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
         Boolean rtn = true;
         Date today = Date.today();
         if (getPageDisabled()) {
@@ -3034,8 +3797,10 @@
                 //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') {
-    
+                //WLIG-CDFBV3 寮�閫氱画绛炬姤浠蜂负true鐨勫彲浠ュ紑鏀剧画绛炬姤浠� thh 20220413
+                if (input.rec.CurrentContract_F__r.Open_RenewalQuotation__c == false && 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;
                     // 鍙紑濮嬫姤浠风殑鏈堟暟闄愬埗
@@ -3050,21 +3815,49 @@
                         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') {
+        // 澶氬勾淇濆垽鏂�
+        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;
-                    }
+            // modify by lc 20220607 澶氬勾淇濈画绛惧拰瀹炵哗杩炲姩鐘舵�佸搴� start
+            Integer noOfDays = today.daysBetween(input.rec.CurrentContract_F_asset__r.endDateGurantee_Text__c);
+            Decimal monthCon = (Decimal)noOfDays/365*12;
+            // 鍙紑濮嬫姤浠风殑鏈堟暟闄愬埗
+            //鍙樻洿澶氬勾淇濈画绛惧紑濮嬫棩 thh 20220315 start
+            //if (input.rec.CurrentContract_F__r.Gurantee_Estimate_startDate__c > Date.today()) {
+            // gzw 20220630 寮�閫氱画绛炬姤浠锋潈闄愬悗锛岃秴杩�6涓湀涔熷彲浠ョ画绛�
+            // 缁鎯呭喌 鈶� 涓婃湡鍚堝悓 Open_RenewalQuotation__c & 6涓湀浠ュ唴  鈶� VM_Contract_Check__c Open_RenewalQuotation__c 2涓兘鎵撻挬
+            // 鈶� 2涓紑鍏抽兘鎵撳紑 鈶M_Contract_Check__c鎵撳紑 灏忎簬6涓湀
+            if (!((this.contract.Open_RenewalQuotation__c && input.rec.CurrentContract_F__r.VM_Contract_Check__c) || (input.rec.CurrentContract_F__r.VM_Contract_Check__c && monthCon < 6))) {
+                if(monthCon < 6){
+                    input.rec.Name.addError(input.rec.Name + '(' + input.rec.SerialNumber + ') -- 鍙互鍔犲叆鏈嶅姟鍚堝悓锛屽姞鍏ヤ环鏍艰鑱旂郴鏈嶅姟绠$悊閮ㄣ��');
+                }else{
+                    input.rec.Name.addError(input.rec.Name + '(' + input.rec.SerialNumber + ') -- 娌℃湁缁鎶ヤ环鏉冮檺锛屾垨鑰呰繕娌″埌缁鏃堕棿銆�');
                 }
+                //input.rec.Name.addError(input.rec.Name + '(' + input.rec.SerialNumber + ') -- 娌℃湁缁鎶ヤ环鏉冮檺锛屾垨鑰呰繕娌″埌缁鏃堕棿銆�');
+                rtn = false;
+            }
+            /*if (input.rec.CurrentContract_F__r.Gurantee_Renew_startDate__c > Date.today()) {
+                input.rec.Name.addError(input.rec.Name + '(' + input.rec.SerialNumber + ') -- 绗竴涓澶囩粨鏉熷悗鍙互鍒朵綔鎶ヤ环銆�');
+                rtn = false;
+            }*/
+            //鍙樻洿澶氬勾淇濈画绛惧紑濮嬫棩 thh 20220315 end
+            // modify by lc 20220607 澶氬勾淇濈画绛惧拰瀹炵哗杩炲姩鐘舵�佸搴� end
+
+        }
                 //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));
+                    //澶氬勾淇濈粨鏉熸棩鍒扮画绛惧紑濮嬫棩涔嬮棿鐨勭┖鐧芥湡澶т簬30鏃�,涓斿湪鍚堝悓寮�濮嬫棩鍓嶄笁涓湀鍐呮病鏈夌偣妫�璁板綍,鎶ラ敊 20220429 thh start
+                    if(input.rec.CurrentContract_F__r.RecordType_DeveloperName__c == 'VM_Contract' &&
+                        input.rec.CurrentContract_F__r.Contract_End_Date__c > input.rec.CurrentContract_F__r.Gurantee_Renew_startDate__c.addDays(30) 
+                        && (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;
+                    }
+                    //澶氬勾淇濈粨鏉熸棩鍒扮画绛惧紑濮嬫棩涔嬮棿鐨勭┖鐧芥湡澶т簬30鏃�,涓斿湪鍚堝悓寮�濮嬫棩鍓嶄笁涓湀鍐呮病鏈夌偣妫�璁板綍,鎶ラ敊 20220429 thh end
+
                     // 鍚堝悓寮�濮嬫棩澶т簬涓婃湡鍚堝悓缁撴潫鏃ュ姞涓�涓湀锛屼笖娌℃湁鐐规鏃ユ湡鎴栬�呮渶杩戜竴娆$偣妫�鏃ユ湡鏄�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
@@ -3075,7 +3868,7 @@
                 }
     
                 if (isSaveOrApproval) {
-                    if (input.rec.IF_Warranty__c == '鍚�') {
+                    if (input.rec.IF_Warranty_Service__c == '鍚�') {
                         input.rec.Name.addError(input.rec.Name + '(' + input.rec.SerialNumber + ') -- 涓嶈兘閫夋嫨涓嶅彲鍙備繚璁惧');
                         rtn = false;
                     }
@@ -3168,6 +3961,31 @@
                 }
             }
         }
+        integer i =0;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
         //contractStartDateChange();
     }
     
@@ -3175,11 +3993,14 @@
     public class AssetInfo {
     // 鏂板悎鍚屽鍝佺‘淇濇彁渚� 褰撳墠鏍囪
     public Boolean etGFlg {get; set;}
-    public Transient Integer lineNo {get; private set;}
+    public Integer lineNo {get; private set;}
+    public Decimal Repair_Price_Auto {get; set;}
+    public String Agreed_Date{get; set;}
     public Boolean rec_checkBox_c {get; set;}
     public Asset rec { get; set; }
     public Maintenance_Contract_Asset_Estimate__c mcae { get; set; }
     public Boolean isManual { get; set; }
+    public Maintenance_Contract_Estimate__c estimate {get; set;}
     public Transient Decimal orgPrice {get; private set;}
     public Transient Decimal orgPrice12 {get; private set;}
     // add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� Star
@@ -3202,7 +4023,9 @@
     public String AssetModelNoc;
     public String MDMModelNoc;
     //2021-11-30 fy add LJPH-C8W8FV 缃《 end
-    
+    //甯傚満澶氬勾淇� 浠锋牸寮�鍙� start 2023/01/17
+    public String Category;
+    //甯傚満澶氬勾淇� 浠锋牸寮�鍙� end 2023/01/17
     public Id getRecId() {
         Id rtn = null;
         if (rec != null) {
@@ -3213,7 +4036,6 @@
     public void setRecId(Id value) {
         // 銇伀銈傘仐銇亜
     }
-    
     // Manual灏傜敤
     public AssetInfo(Integer lineNo) {
         this.lineNo = lineNo;
@@ -3234,9 +4056,28 @@
         // add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� End
     }
     // 閬告姙銇曘倢銇熺敤锛堥潪Manual锛�
-    public AssetInfo(Integer lineNo, Asset record, Boolean isNew, Decimal listPrice, Maintenance_Contract_Asset_Estimate__c mcae) {
+    public AssetInfo(Integer lineNo, Asset record, Boolean isNew, Decimal listPrice, Maintenance_Contract_Asset_Estimate__c mcae,Maintenance_Contract_Estimate__c estimate, Map<String,repair__c> assNewRepMap) {
         this.lineNo = lineNo;
         this.rec = record;
+        this.estimate = new Maintenance_Contract_Estimate__c();
+        this.estimate.IS_Reduced_price_approval__c = estimate.IS_Reduced_price_approval__c;
+        //   (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� start
+        // if (record.Asset_situation__c == '淇悊涓�' && record.Return_Without_Repair__r.Agreed_Date__c!=null) {
+        //     this.Agreed_Date = '涓嶄负绌�';
+        // }
+        // if (record.Asset_situation__c == '淇悊涓�' && record.Return_Without_Repair__r.Agreed_Date__c==null) {
+        //     this.Agreed_Date = '涓虹┖';
+        //     if (assNewRepMap.get(record.id)!=null) {
+        //          this.Repair_Price_Auto = assNewRepMap.get(record.id).Repair_List_Price_formula__c;
+        //     }
+        // }
+        // if (record.Return_Without_Repair__r.Repair_List_Price_formula__c!=null&&record.Asset_situation__c != '淇悊涓�') {
+        //     this.Repair_Price_Auto = record.Return_Without_Repair__r.Repair_List_Price_formula__c;
+        // }
+        if (record.Return_Without_Repair__r.Repair_List_Price_formula__c!=null) {
+            this.Repair_Price_Auto = record.Return_Without_Repair__r.Repair_List_Price_formula__c;
+        }
+        //   (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� end
         this.mcae = new Maintenance_Contract_Asset_Estimate__c(
             //                id = mcae.Id,             // 鏈綋銇亜銈夈仾銇勩伄锛� 銈汇儍銉堛仐銇熴倝銆佹柊瑕忔ī闄愩亴銇亸銇с倐銆佹洿鏂般仹銇嶃伨銇欍�傚緦钘ゃ仌銈撱伀纰鸿獚銇椼仧銆併仾銇忋仹銈傘亜銇勩仹銇欍��
             isNew__c = isNew,
@@ -3247,6 +4088,7 @@
             //Maintenance_Price_YearTXT__c = mcae.Maintenance_Price_YearTXT__c,
             Check_Result__c = mcae.Check_Result__c,
             Repair_Price__c = mcae.Repair_Price__c,
+            Repair_Price_pass__c = mcae.Repair_Price_pass__c,
             Comment__c = mcae.Comment__c,
             EquipmentGuaranteeFlgTxt__c = mcae.EquipmentGuaranteeFlgTxt__c,
             Estimate_Cost__c = mcae.Estimate_Cost__c,
@@ -3257,9 +4099,19 @@
             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
+            ,Estimate_List_Price_Page__c = mcae.Estimate_List_Price_Page__c,
             // LJPH-C9GD34 gzw fix end
+            //(2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� 绗笁鏂瑰洖褰�
+            Third_Party_Return__c = mcae.Third_Party_Return__c
             );
+         if ((this.mcae.Repair_Price__c==null&&this.Repair_Price_Auto!=null)||(this.estimate.IS_Reduced_price_approval__c == '鍚�')) {
+            this.mcae.Repair_Price__c = this.Repair_Price_Auto;
+        }
+        if (this.estimate.IS_Reduced_price_approval__c=='鏄�'||this.estimate.IS_Reduced_price_approval__c==null) {
+            if (this.mcae.Repair_Price__c!=null) {
+                this.mcae.Repair_Price_pass__c = this.mcae.Repair_Price__c;
+            }
+        }
         this.isManual = false;
         this.rec_checkBox_c = true;
         this.orgPrice = record.Maintenance_Price_Month__c;
@@ -3275,6 +4127,11 @@
         //2021-11-30 fy add LJPH-C8W8FV 缃《 end
     
         //add by rentx 2020-11-12 LJPH-BV93RZ end
+
+        //甯傚満澶氬勾淇� 浠锋牸寮�鍙� start 2023/01/17
+        this.Category = mcae.Product_Manual__r.Category4__c;
+        //甯傚満澶氬勾淇� 浠锋牸寮�鍙� end 2023/01/17
+
         //add by mzy 2021-02-07 start
         //this.NoPartRiskDate = mcae.Product_Manual__r.NoPartRiskDate_F__c;
         //this.proName2 = mcae.Product_Manual__r.Name;
@@ -3296,6 +4153,7 @@
             //Maintenance_Price_YearTXT__c = mcae.Maintenance_Price_YearTXT__c,
             Check_Result__c = mcae.Check_Result__c,
             Repair_Price__c = mcae.Repair_Price__c,
+            Repair_Price_pass__c = mcae.Repair_Price_pass__c,
             Comment__c = mcae.Comment__c,
             EquipmentGuaranteeFlgTxt__c = mcae.EquipmentGuaranteeFlgTxt__c,
             Estimate_Cost__c = mcae.Estimate_Cost__c,
@@ -3308,8 +4166,10 @@
             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
+            ,Estimate_List_Price_Page__c = mcae.Estimate_List_Price_Page__c,
             // LJPH-C9GD34 gzw fix end
+            //(2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� 绗笁鏂瑰洖褰�
+            Third_Party_Return__c = mcae.Third_Party_Return__c
             );
         this.isManual = true;
         this.rec_checkBox_c = false;
@@ -3325,11 +4185,54 @@
         this.ProductModelNoc = mcae.Product_Manual__r.Asset_Model_No__c;
         this.AssetModelNoc = mcae.Asset__r.OwnershipMachine_No__c;
         //2021-11-30 fy add LJPH-C8W8FV 缃《 end
+
+        //甯傚満澶氬勾淇� 浠锋牸寮�鍙� start 2023/01/17
+        this.Category = mcae.Product_Manual__r.Category4__c;
+        //甯傚満澶氬勾淇� 浠锋牸寮�鍙� end 2023/01/17
     }
+    
     // 閬告姙銇曘倢銇亱銇c仧鐢�
     public AssetInfo(Integer lineNo, Asset record) {
         this.lineNo = lineNo;
         this.rec = record;
+        //   (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� start
+        // if (record.Return_Without_Repair__r.Agreed_Date__c!=null) {
+        //     this.Agreed_Date = '涓嶄负绌�';
+        // }else{
+        //     this.Agreed_Date = '涓虹┖';
+        // }
+        if (record.Return_Without_Repair__r.Repair_List_Price_formula__c!=null) {
+            this.Repair_Price_Auto = record.Return_Without_Repair__r.Repair_List_Price_formula__c;
+        }
+        //   (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� end
+        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;
+    }
+    public AssetInfo(Integer lineNo, Asset record, Map<String,repair__c> assNewRepMap) {
+        this.lineNo = lineNo;
+        this.rec = record;
+        //   (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� start
+        // if (record.Asset_situation__c == '淇悊涓�' && record.Return_Without_Repair__r.Agreed_Date__c!=null) {
+        //     this.Agreed_Date = '涓嶄负绌�';
+        // }
+        // if (record.Asset_situation__c == '淇悊涓�' && record.Return_Without_Repair__r.Agreed_Date__c==null) {
+        //     this.Agreed_Date = '涓虹┖';
+        //     if (assNewRepMap.get(record.id)!=null) {
+        //          this.Repair_Price_Auto = assNewRepMap.get(record.id).Repair_List_Price_formula__c;
+        //     }
+        // }
+        // if (record.Return_Without_Repair__r.Repair_List_Price_formula__c!=null&&record.Asset_situation__c != '淇悊涓�') {
+        //     this.Repair_Price_Auto = record.Return_Without_Repair__r.Repair_List_Price_formula__c;
+        // }
+        if (record.Return_Without_Repair__r.Repair_List_Price_formula__c!=null) {
+            this.Repair_Price_Auto = record.Return_Without_Repair__r.Repair_List_Price_formula__c;
+        }
+        //   (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� end
         this.isManual = false;
         this.rec_checkBox_c = false;
         this.orgPrice = record.Maintenance_Price_Month__c;
@@ -3374,6 +4277,7 @@
             rs = 'Undecide澶辫触';
         }
         return rs;
+        
     }
     
     
@@ -3466,7 +4370,50 @@
         //List<lastMContract> listResult = new List<lastMContract>();
         return listResult;
     }
-    
+
+    //URF闄愭鍚堝悓2鏈� LY 20220908 start
+    //瀵归檺娆″悎鍚岃繘琛屾帓搴�
+    public static List<lastMContract> getURFMContract(List<AssetInfo> checkedAssets, Date startDate) {
+        Map<String, lastMContract> urfMContractMap = new Map<String, lastMContract>();
+        Map<String, lastMContract> lastMContractMap1 = new Map<String, lastMContract>();
+        for (AssetInfo ai : checkedAssets) {
+            lastMContract urfMC = new lastMContract(ai.rec.URF_Maintenance_Contract__c, ai.rec.URF_Maintenance_Contract__r.Management_Code__c, ai.rec.URF_Maintenance_Contract__r.Contract_End_Date__c, 1);
+            if (String.isNotBlank(ai.rec.URF_Maintenance_Contract__c)) {
+                if (urfMContractMap.containsKey(ai.rec.URF_Maintenance_Contract__c)) {
+                    urfMContractMap.get(ai.rec.URF_Maintenance_Contract__c).count++;
+                } else {
+                    urfMContractMap.put(ai.rec.URF_Maintenance_Contract__c, urfMC);
+                }
+            }
+        }
+        List<lastMContract> listResulttemp = new List<lastMContract>();
+        List<lastMContract> listResult = new List<lastMContract>();
+        
+        for ( lastMContract ll : urfMContractMap.values()) {
+            listResulttemp.add(ll);
+        }
+        listResulttemp.sort();
+        if (listResulttemp.size() >= 5){
+            for (Integer i = 0; i < listResulttemp.size(); i++) {
+            
+                if (listResulttemp.size() >= i + 1) {
+                    listResult.add(listResulttemp[i]);
+                }
+            }
+        }else {
+            for (Integer i = 0; i < listResulttemp.size(); i++) {
+                if (listResulttemp.size() >= i + 1) {
+                    listResult.add(listResulttemp[i]);
+                }
+            }
+            for (Integer i = listResulttemp.size(); i < 5; i++) {
+                listResult.add(new lastMContract(null, null, null, null));
+            }
+        }
+        
+        return listResult;
+    }
+    //URF闄愭鍚堝悓2鏈� LY 20220908 end   
     
     public static List<Data> getChartData() {
         List<Data> data = new List<Data>();
@@ -3544,4 +4491,4 @@
     // return returnValue;
     // 2021-09-10 tcm 鎺掑簭閫昏緫璋冩暣 end
     }
-    }
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/force-app/main/default/pages/SelectAssetEstimateVM.page b/force-app/main/default/pages/SelectAssetEstimateVM.page
index 8b338c9..5709747 100644
--- a/force-app/main/default/pages/SelectAssetEstimateVM.page
+++ b/force-app/main/default/pages/SelectAssetEstimateVM.page
@@ -1,4 +1,4 @@
-<apex:page controller="SelectAssetEstimateVMController" tabStyle="Maintenance_Contract_Estimate__c" sidebar="false" showHeader="true" id="allPage" action="{!init}">
+<apex:page controller="SelectAssetEstimateVMController" tabStyle="Maintenance_Contract_Estimate__c" lightningStylesheets="true" sidebar="false" showHeader="true" id="allPage" action="{!init}">
 <head>
  <!-- <meta http-equiv="x-ua-compatible" content="ie=edge" /> -->
  <!-- <meta name="viewport" content="width=device-width, initial-scale=1" /> -->
@@ -7,8 +7,8 @@
     <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
     <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
     <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
-    <apex:includeScript value="/soap/ajax/29.0/connection.js"/>
-    <apex:includeScript value="/soap/ajax/29.0/apex.js"/>
+    <apex:includeScript value="{!URLFOR($Resource.connection20)}"/>
+    <apex:includeScript value="{!URLFOR($Resource.apex20)}"/>
 <style type="text/css">
     table { border-collapse: collapse; }
     
@@ -40,14 +40,45 @@
 var Confirm_EstimateRefresh = '宸茶秴杩囧垱寤烘棩3涓湀锛屾槸鍚︽洿鏂版姤浠凤紵';
 window.sfdcPage.appendToOnloadQueue(function() { calonLoad() });
 
+var RCbottonChanged = 0;
+
+// 2022鏁呴殰鍝佸姞璐� start
+// var RCButtonDisable = document.getElementById("emailSend");
+// RCButtonDisable.style.display = "none";
+// 2022鏁呴殰鍝佸姞璐� end
+
+var hasSendEmail = {!hasSendEmail};
+console.log('***hasSendEmail',hasSendEmail);
+// if(hasSendEmail == true){
+//     j$(escapeVfId('allPage:allForm:emailSend')).attr("disabled", true);
+//     j$(escapeVfId('allPage:allForm:emailSend')).attr("class", 'btnDisabled');
+//     console.log('宸叉彁浜C 鎸夐挳涓嶅彲瑙�');
+// }
+
 function approvalJs() {
     approvalDate = new Date();
     var rowCnt = j$(escapeVfId('allPage:allForm:allBlock:assetSection:productCnt')).val();
     refreshAsset(rowCnt);
 }
-
+//鏁呴殰鍝佸姞璐� RC 鐐瑰嚮鍚庝笉鍙
+function rcJs() {
+    hasSendEmail = true;
+    j$(escapeVfId('allPage:allForm:emailSend')).attr("disabled", true);
+    j$(escapeVfId('allPage:allForm:emailSend')).attr("class", 'btnDisabled');
+    console.log('鐐瑰嚮RC 鎸夐挳涓嶅彲瑙乭asSendEmail' +hasSendEmail);
+}
 //add by gwy 2021-01-27 start 鎻愪氦鏃剁殑鎻愮ず妗�
 function KindsAndMonths() {
+   //   鏁呴殰鍝佸姞璐� 绯荤粺妫�鏌ヤ慨鐞嗗噺浠峰鎵瑰畬鎴� Start
+         ISReduced = j$(escapeVfId('allPage:allForm:allBlock:ISReducedpriceapproval')).val();
+        console.log('鐐瑰嚮鎻愪氦寰呭鎵规椂 鏄惁瀹℃壒閫氳繃='+ISReduced);
+        if( ISReduced == '瀹℃壒涓�' || ISReduced == '鏈夊叓鎶樹互涓嬪緟瀹℃壒'){
+            alert('璇烽�氳繃淇悊鍑忎环瀹℃壒鍐嶆彁浜�');
+            // approvalbtntop1.style.display = "none";
+            return false;
+        }
+    
+    //   鏁呴殰鍝佸姞璐� 绯荤粺妫�鏌ヤ慨鐞嗗噺浠峰鎵瑰畬鎴� end
     var months      = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:contract:monthRange')).val());
     var contrNew    = document.getElementById("allPage:allForm:allBlock:contractInfo:Contract_TypeTXT").innerHTML;
     if(months>12 && months<60 && contrNew == '鏂板搧鍚堝悓'){
@@ -57,7 +88,17 @@
             return false;  
         }
     }
-        return true;
+    // 鍏堟鍚庝慨-鎻愪氦鎶ヤ环鏃跺鏋滄槸鍏堟瀵硅薄杩涜鎻愮ず thh 20220408 start
+    var FirstParagraphEnd = j$(escapeVfId('allPage:allForm:allBlock:contract:FirstParagraphEnd'))[0].checked;
+    if(FirstParagraphEnd){
+        if (confirm('鏈绛剧害缁忛攢鍟嗘槸鍏堟瀵硅薄锛岃纭鏄惁鎻愪氦鎶ヤ环锛�')) {
+            return true; 
+        }else{
+            return false;  
+        }
+    }
+    // 鍏堟鍚庝慨-鎻愪氦鎶ヤ环鏃跺鏋滄槸鍏堟瀵硅薄杩涜鎻愮ず thh 20220408 end
+    return true;
 }
 //add by gwy 2021-01-27 end 鎻愪氦鏃剁殑鎻愮ず妗�
 
@@ -79,6 +120,9 @@
     j$("#sbArea").fadeOut(500, function(){
         j$("#sbArea").remove();
     });
+  
+    console.log('鍙戦�侀偖浠舵垚鍔�');
+   
 }
 //<!-- HWAG-B4R3SS  START 20181026-->
 function clearAndSearch() {
@@ -95,8 +139,30 @@
 //<!-- HWAG-B4R3SS  END 20181026-->
 // 鍒濆鍖栬瀹氱敾闈㈤」鐩笉鍙敤
 function pageSetDisabled(){
+    // if (RCbottonChanged == 0) {
+    //     console.log('test鍒濆鍖�');
+        // 鏁呴殰鍝佸姞璐� 鎻愪氦RC鎸夐挳涓嶅彲瑙� start
+        // j$(escapeVfId('allPage:allForm:emailSend')).attr("disabled", true);
+        // j$(escapeVfId('allPage:allForm:emailSend')).attr("class", 'btnDisabled');
+        // 鏁呴殰鍝佸姞璐� 鎻愪氦RC鎸夐挳涓嶅彲瑙� end
+    // }
+    // 鏁呴殰鍝佸姞璐� start
+    var hasSendEmail ={!hasSendEmail};
+    console.log('page hasSendEmail',hasSendEmail);
+    if(hasSendEmail == true){
+        j$(escapeVfId('allPage:allForm:emailSend')).attr("disabled", true);
+        j$(escapeVfId('allPage:allForm:emailSend')).attr("class", 'btnDisabled');
+        console.log('宸叉彁浜C 鎸夐挳涓嶅彲瑙� page set');
+    }
+
+    //鏁呴殰鍝佸姞璐� end
     var isDisabled = {!PageDisabled};
+    // ResonCannotWarranty = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':ResonCannotWarranty')).value();
+    // if(!ResonCannotWarranty.contains("寮冧慨")){
+    //     j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Repair_Price_Auto')).attr("display", none);
+    // }
     if (isDisabled) {
+
         j$(escapeVfId('allPage:allForm:allBlock:contract:depart')).attr("disabled", true);
         j$(escapeVfId('allPage:allForm:allBlock:contract:startdate')).attr("disabled", true);
         j$(escapeVfId('allPage:allForm:allBlock:contract:monthRange')).attr("disabled", true);
@@ -113,6 +179,7 @@
             j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetCheck')).attr("disabled", true);
             j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).attr("disabled", true);
             j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':comment')).attr("disabled", true);
+            j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Third_Party_Return__c')).attr("disabled", true);
         }
         j$(escapeVfId('allPage:allForm:allBlock:appendCondition:Examination_Count')).attr("disabled", true);
         j$(escapeVfId('allPage:allForm:allBlock:contractInfo:disPercent')).attr("disabled", true);
@@ -181,6 +248,16 @@
     // 2021銆�8銆�26 鍚堝悓鎶ヤ环椤甸潰鐨勪紭鍖栵紝鏃犱繚鏈夎澶囩偣妫�瀵硅薄閫夋嫨妗嗗彉榛� fxk star
     // disable1();
     // 2021銆�8銆�26 鍚堝悓鎶ヤ环椤甸潰鐨勪紭鍖栵紝鏃犱繚鏈夎澶囩偣妫�瀵硅薄閫夋嫨妗嗗彉榛� fxk end
+    console.log('ApprovalBtnDisabled=='+{!ApprovalBtnDisabled});
+    //涓婇檺鍚堝悓 20230103 LY start
+    var mainteReal = j$(escapeVfId('allPage:allForm:allBlock:contractInfo:mainteReal')).text();
+    Limit_Price_Amount = localParseFloat(mainteReal)*1.3;
+    // console.log('Limit_Price_Amount'+Limit_Price_Amount);
+    Limit_Price_AmountOne =  j$(escapeVfId('allPage:allForm:allBlock:contractInfo:Limit_Price_Amount')).value();
+    if (Limit_Price_AmountOne*1==0) {
+        j$(escapeVfId('allPage:allForm:allBlock:contractInfo:Limit_Price_Amount')).val(Limit_Price_Amount);
+    }
+    //涓婇檺鍚堝悓 20230103 LY end
     pageSetDisabled();
     var createdDate = new Date('{!estimate.CreatedDate}');
     // 鎶ヤ环涓澶囩殑鏈鸿韩缂栫爜涓虹┖鏃剁殑鏂板搧鍚堝悓鏈夋晥鏈熷欢闀� 20200710 gzw
@@ -212,6 +289,11 @@
             //j$(escapeVfId('allPage:allForm:decidebtn')).attr("disabled", true);
             j$(escapeVfId('allPage:allForm:savebtn')).attr("class", 'btnDisabled');
             j$(escapeVfId('allPage:allForm:approvalbtn')).attr("class", 'btnDisabled');
+
+            //鏁呴殰鍝佸姞璐� RC鎸夐挳 
+            j$(escapeVfId('allPage:allForm:emailSend')).attr("disabled", true);
+            j$(escapeVfId('allPage:allForm:emailSend')).attr("class", 'btnDisabled');
+
             //j$(escapeVfId('allPage:allForm:decidebtn')).attr("class", 'btnDisabled');
             
             if (confirm(Confirm_EstimateRefresh)) {
@@ -244,6 +326,10 @@
             //j$(escapeVfId('allPage:allForm:decidebtn')).attr("disabled", true);
             j$(escapeVfId('allPage:allForm:savebtn')).attr("class", 'btnDisabled');
             j$(escapeVfId('allPage:allForm:approvalbtn')).attr("class", 'btnDisabled');
+
+            //鏁呴殰鍝佸姞璐筊C鎸夐挳
+            j$(escapeVfId('allPage:allForm:emailSend')).attr("disabled", true);
+            j$(escapeVfId('allPage:allForm:emailSend')).attr("class", 'btnDisabled');
             //j$(escapeVfId('allPage:allForm:decidebtn')).attr("class", 'btnDisabled');
             
             if (confirm('宸茶秴杩囧垱寤烘棩6涓湀锛屾槸鍚︽洿鏂版姤浠凤紵')) {
@@ -306,6 +392,10 @@
     //val = Math.round(val * 100) / 100;
     val = Math.round(val);
     j$(escapeVfId('allPage:allForm:allBlock:contractInfo:quotation_Amount')).val(toNumComma(val));
+    //涓婇檺鍚堝悓 20230117 HQL start
+     console.log('涓婇檺閲戦濉叆锛�'+val*1.3);
+    j$(escapeVfId('allPage:allForm:allBlock:contractInfo:Limit_Price_Amount')).val(val*1.3);
+    //涓婇檺鍚堝悓 20230117 HQL end
    makeRealPrice(1);
 }
 
@@ -329,13 +419,23 @@
     //contractStartDateChange();
     refreshAsset(cnt);
 }
-
+function toChange1(){
+    tochange();
+    ISReducedpriceapproval = j$(escapeVfId('allPage:allForm:allBlock:ISReducedpriceapproval')).val();
+    console.log('鏂规硶1鏄惁瀹℃壒閫氳繃=='+ISReducedpriceapproval+'====================');
+}
+function toChange2(){
+    tochange2();
+    ISReducedpriceapproval = j$(escapeVfId('allPage:allForm:allBlock:ISReducedpriceapproval')).val();
+    console.log('鏂规硶2鏄惁瀹℃壒閫氳繃=='+ISReducedpriceapproval+'==============');
+}
 function refreshAsset(cnt) {
-    //alert('1111111111');
+     // alert(cnt);
     // 鎻愪氦鍚庡氨椤甸潰涓嶈绠椾簡
     var isDisabled = {!PageDisabled};
     // 鍚堝悓鎬荤悊
     var newCount = 0;
+    var isresduce = 0;
     var oyearCount = 0;
     var firstCCount = 0;
     var conCCount = 0;
@@ -345,7 +445,25 @@
     // 鏂板搧鍚堝悓 鍒ゆ柇
     var newCon = true;
     var contractStartDate = new Date(j$(escapeVfId('allPage:allForm:contractstartdate')).value());
+    //涓婇檺鍚堝悓 20230103 LY start
+    var mainteReal = j$(escapeVfId('allPage:allForm:allBlock:contractInfo:mainteReal')).text();
+    Limit_Price_Amount = localParseFloat(mainteReal)*1.3;
+    
+    Limit_Price_AmountOne =  j$(escapeVfId('allPage:allForm:allBlock:contractInfo:Limit_Price_Amount')).value();
+    console.log('Limit_Price_AmountOne'+Limit_Price_AmountOne);
+    if (Limit_Price_AmountOne*1==0) {
+        j$(escapeVfId('allPage:allForm:allBlock:contractInfo:Limit_Price_Amount')).val(Limit_Price_Amount);
+    }
+    //涓婇檺鍚堝悓 20230103 LY end
+    //澶氬勾淇濈画绛惧悎鍚屾暟閲� thh 20220316 start
+    var GuranteeCount = 0;
+    //澶氬勾淇濈画绛惧悎鍚屾暟閲� thh 20220316 end
 
+    //2022鏁呴殰鍝佸姞璐� 鑾峰彇userInfo绠�妗e悕绉� 鏄惁涓篎SE start
+    var isFSE = {!isFSE};
+    // var isFSE = true;
+    console.log('***isFSE',isFSE);
+    //2022鏁呴殰鍝佸姞璐� 鑾峰彇userInfo绠�妗e悕绉� end
 
     // 棰勫畾寮�濮嬫棩
     var startdate = new Date(j$(escapeVfId('allPage:allForm:allBlock:contract:startdate')).value());
@@ -383,7 +501,7 @@
         var downPrice = 0;
         // 涓婄嚎浠锋牸
         var upPrice = 0;
-
+        
         // 12涓湀鍚堝悓閲戦
         var Price_YearTXT = 0;
         
@@ -412,6 +530,7 @@
                 }
                 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();
+                console.log('***缁翠慨鍚堝悓璁板綍绫诲瀷1'+LastMContractRecord);
                 if(b != ''){
                     conCCount ++;
                     // 1.鍚堝悓鏈熶笉婊′竴骞存椂锛屽悎鍚屾湡瓒呰繃涓�鍗婃墠鍙紑濮嬬画绛炬姤浠枫��(eg:11涓湀鐨勫悎鍚屼粠6涓湀鍚庢墠鍙姤浠枫��)
@@ -422,6 +541,10 @@
                     var lastContRange = 0;
                     if(LastMContractRecord == 'VM_Contract'){
                         newCount++;
+                        //澶氬勾淇濈画绛惧悎鍚屾暟閲�,澶氬勾淇濈画绛惧埌鏈嶅姟鍚堝悓鏃惰涓洪绛捐澶� thh 20220316 start
+                        GuranteeCount++;
+                        newCon = false;
+                        //澶氬勾淇濈画绛惧悎鍚屾暟閲�,澶氬勾淇濈画绛惧埌鏈嶅姟鍚堝悓鏃惰涓洪绛捐澶� thh 20220316 end
                         lastendDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':endDateGurantee_Text')).value());
                         lastContRange = 36;
                     }else{
@@ -429,7 +552,7 @@
                     }
                     //鏈�鍚庣粨鏉熸棩+1骞�
                     lastendDate.setMonth(lastendDate.getMonth() + 12);
-                    if (Date.parse(contractStartDate) > Date.parse(lastendDate)) {
+                    if (Date.parse(contractStartDate) > Date.parse(lastendDate) ) {
                         oyearCount ++;
                     }
                     // 鍙栬仈鍔ㄤ环鏍�
@@ -447,10 +570,120 @@
                     var Estimate_Num = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Estimate_NumHidden')).val();
                     if(Estimate_Num == 0){
                         if(LastMContractRecord == 'VM_Contract'){
-                            //upPrice = (strMoney) * (1 + Adjustment_ratio_Upper/100);
-                            //downPrice = (strMoney) * (1 + Adjustment_ratio_Lower/100);
-                            upPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Upper/100);
-                            downPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Lower/100);
+                            // gzw 20220630  瀹為檯鑱斿姩6涓湀浠锋牸鍖哄垎
+                            var nowdate = new Date();
+                            lastendDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':endDateGurantee_Text')).value());
+                            nowdate = nowdate.setMonth(nowdate.getMonth() + 6);
+
+                            //甯傚満澶氬勾淇濅慨浠锋牸寮�鍙� DC 2023/1/30 start 
+
+                            //娑堣垂鐜� 灞曠ず淇敼涓哄競鍦哄骞翠繚璁惧娑堣垂鐜�
+                            // j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':AssetConsumptionRateNew')).attr("style", "display:block");
+
+                            // j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Contractrate')).attr("style", "display:none");
+
+                            var Maxcoefficient =0;
+                            var Mincoefficient =0;
+
+                            var AssetRate = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':AssetConsumptionRateNew')).val());
+                            console.log('***娑堣垂鐜�:'+AssetRate);
+
+                             j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Contractrate')).text(AssetRate +'%');
+
+                            if(AssetRate>0 &&AssetRate<=0.5){
+                                Maxcoefficient = (1-0.3);
+                                Mincoefficient = (1-0.4);
+                            }else if(AssetRate>0.5 &&AssetRate<=0.6){
+                                Maxcoefficient = (1-0.2);
+                                Mincoefficient = (1-0.3);
+                                
+                            }else if(AssetRate>0.6 &&AssetRate<=0.7){
+                                Maxcoefficient = (1-0.15);
+                                Mincoefficient = (1-0.25);
+                                
+                            }else if(AssetRate>0.7 &&AssetRate<=0.8){
+                                Maxcoefficient = (1-0.1);
+                                Mincoefficient = (1-0.2);
+                                
+                            }else if(AssetRate>0.8 &&AssetRate<=0.9){
+                                Maxcoefficient = (1-0.05);
+                                Mincoefficient = (1-0.15);
+                                
+                            }else if(AssetRate>0.9 &&AssetRate<=1.0){
+                                Maxcoefficient = 1;
+                                Mincoefficient = (1-0.05);
+                                
+                            }else if(AssetRate>1.0 &&AssetRate<=1.1){
+                                Maxcoefficient = (1+0.05);
+                                Mincoefficient = 1;
+                                
+                            }else if(AssetRate>1.1 &&AssetRate<=1.2){
+                                Maxcoefficient = (1+0.1);
+                                Mincoefficient = 1;
+                                
+                            }else if(AssetRate>1.2 &&AssetRate<=1.3){
+                                Maxcoefficient = (1+0.2);
+                                Mincoefficient = (1+0.1);
+                                
+                            }else if(AssetRate>1.3 &&AssetRate<=1.4){
+                                Maxcoefficient = (1+0.25);
+                                Mincoefficient = (1+0.15);
+                                
+                            }else if(AssetRate>1.4){
+                                Maxcoefficient = (1+0.3);
+                                Mincoefficient = (1+0.2);
+                                
+                            }
+                            //甯傚満澶氬勾淇濅慨浠锋牸寮�鍙� DC 2023/1/30 end 
+                            console.log('***鏈�楂樼郴鏁�'+Maxcoefficient);
+                            console.log('***鏈�浣庣郴鏁�'+Mincoefficient);
+
+                        if(nowdate < Date.parse(lastendDate)){
+                            //璁惧灏忎簬涓ゅ勾鍗�
+                            // upPrice = strMoney;
+                            // downPrice = strMoney * 0.8;
+                        console.log('***灏忎簬2骞村崐')
+                        // 甯傚満澶氬勾淇濅慨浠锋牸寮�鍙� start DC 2023/01/19  
+                            //甯傚満澶氬勾淇濊澶囧皬浜�2骞村崐
+                            var AssetModelNo = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Asset_Model_No__c')).value();
+                            var Category4 = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Category4__c')).value();
+                            console.log('***璁惧鍨嬪彿'+AssetModelNo);
+                            console.log('***浜у搧绫诲瀷'+Category4);
+
+                            //璁惧璁惧娑堣垂鐜囧皬浜�1.4
+                            if(AssetRate<1.4){
+                                upPrice = strMoney;
+                                console.log('娑堣垂鐜囧皬浜�1.4 upPrice = strmonye'+ upPrice);
+
+                                if(AssetModelNo.includes('290')|| Category4 =='BF'|| Category4=='BF鎵囨壂'|| Category4=='GIF'||Category4=='CF' || Category4.includes('GF')){
+                                    downPrice = upPrice;
+                                    console.log('娑堣垂鐜囧皬浜�1.4 浜у搧鏃犳渶浣庝环 downPrice '+ downPrice);
+
+                                }else{
+                                    downPrice = upPrice * 0.8;
+                                    console.log('娑堣垂鐜囧皬浜�1.4 浜у搧鏈�浣庝环 downPrice = upPrice* 0.8锛�'+ downPrice);
+
+                                }
+                            }else{
+                                upPrice = assetListmonth * month *Maxcoefficient / 12;
+                                downPrice = assetListmonth * month * Mincoefficient / 12;   
+                                console.log('娑堣垂鐜囧ぇ浜�1.4 upPrice'+ upPrice);
+                                console.log('娑堣垂鐜囧ぇ浜�1.4 downPrice'+ downPrice);
+                            }
+                            // 甯傚満澶氬勾淇濅慨浠锋牸寮�鍙� end DC 2023/01/19  
+                            }else{
+                                // upPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Upper/100);
+                                // downPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Lower/100);
+
+
+                                //甯傚満澶氬勾淇濅慨浠锋牸寮�鍙� DC 2023/1/30 start  璁惧澶т簬2骞村崐 缁浠锋牸 = 瀹氫环 *娑堣垂鐜囧搴旂郴鏁� / 12 *鍚堝悓鏈堟暟
+                                upPrice = assetListmonth * month *Maxcoefficient / 12;
+                                downPrice = assetListmonth * month * Mincoefficient / 12;
+                                //甯傚満澶氬勾淇濅慨浠锋牸寮�鍙� DC 2023/1/30 end 
+                            
+
+                            }
+                            // gzw 20220630  瀹為檯鑱斿姩6涓湀浠锋牸鍖哄垎
                         }else{
                             upPrice = strMoney;
                             downPrice = strMoney * 0.8;
@@ -515,8 +748,10 @@
             } 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();
+            console.log('***缁翠慨鍚堝悓璁板綍绫诲瀷2'+LastMContractRecord);
+
             if(b != ''){
                 conCCount ++;
                 // 1.鍚堝悓鏈熶笉婊′竴骞存椂锛屽悎鍚屾湡瓒呰繃涓�鍗婃墠鍙紑濮嬬画绛炬姤浠枫��(eg:11涓湀鐨勫悎鍚屼粠6涓湀鍚庢墠鍙姤浠枫��)
@@ -526,6 +761,10 @@
                 var lastContRange = 0;
                 if(LastMContractRecord == 'VM_Contract'){
                     newCount++;
+                    //澶氬勾淇濈画绛惧悎鍚屾暟閲�,澶氬勾淇濈画绛惧埌鏈嶅姟鍚堝悓鏃惰涓洪绛捐澶� thh 20220316 start
+                    GuranteeCount++;
+                    newCon = false;
+                    //澶氬勾淇濈画绛惧悎鍚屾暟閲�,澶氬勾淇濈画绛惧埌鏈嶅姟鍚堝悓鏃惰涓洪绛捐澶� thh 20220316 end
                     lastendDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':endDateGurantee_Text')).value());
                     lastContRange = 36;
                 }else{
@@ -533,6 +772,8 @@
                 }
                 //鏈�鍚庣粨鏉熸棩+1骞�
                 lastendDate.setMonth(lastendDate.getMonth() + 12);
+                // alert('+++++++++--------' + lastendDate);
+                // alert('+++++++++--------' + Date.parse(contractStartDate) + '77777' + Date.parse(lastendDate));
                 if (Date.parse(contractStartDate) > Date.parse(lastendDate)) {
                     oyearCount ++;
                 }
@@ -551,10 +792,126 @@
                 var Estimate_Num = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Estimate_NumHidden')).val();
                 if(Estimate_Num == 0){
                     if(LastMContractRecord == 'VM_Contract'){
-                        //upPrice = (strMoney) * (1 + Adjustment_ratio_Upper/100);
-                        //downPrice = (strMoney) * (1 + Adjustment_ratio_Lower/100);
-                        upPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Upper/100);
-                        downPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Lower/100);
+                        // alert('11111');
+                        // gzw 20220630  瀹為檯鑱斿姩6涓湀浠锋牸鍖哄垎
+                        var nowdate = new Date();
+                        lastendDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':endDateGurantee_Text')).value());
+                        nowdate = nowdate.setMonth(nowdate.getMonth() + 6);
+
+                        //甯傚満澶氬勾淇濅慨浠锋牸寮�鍙� DC 2023/1/30 start 
+
+                            //娑堣垂鐜� 灞曠ず淇敼涓哄競鍦哄骞翠繚璁惧娑堣垂鐜�
+                            // j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':AssetConsumptionRateNew3')).attr("style", "display:block");
+
+            
+
+                            //  var AssetRate2 = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':AssetConsumptionRateNew2')).value();
+
+                            // console.log('***娑堣垂鐜�2:'+AssetRate2);
+                            //  var AssetRate3 = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':AssetConsumptionRateNew3')).value());
+                            // console.log('***娑堣垂鐜�3:'+AssetRate3);
+
+                            var Maxcoefficient =0;
+                            var Mincoefficient =0;
+
+                            var AssetRate = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':AssetConsumptionRateNew')).val());
+                            console.log('***娑堣垂鐜�:'+AssetRate);
+
+                             j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Contractrate')).text(AssetRate +'%');
+
+                            if(AssetRate>0 &&AssetRate<=0.5){
+                                Maxcoefficient = (1-0.3);
+                                Mincoefficient = (1-0.4);
+                            }else if(AssetRate>0.5 &&AssetRate<=0.6){
+                                Maxcoefficient = (1-0.2);
+                                Mincoefficient = (1-0.3);
+                                
+                            }else if(AssetRate>0.6 &&AssetRate<=0.7){
+                                Maxcoefficient = (1-0.15);
+                                Mincoefficient = (1-0.25);
+                                
+                            }else if(AssetRate>0.7 &&AssetRate<=0.8){
+                                Maxcoefficient = (1-0.1);
+                                Mincoefficient = (1-0.2);
+                                
+                            }else if(AssetRate>0.8 &&AssetRate<=0.9){
+                                Maxcoefficient = (1-0.05);
+                                Mincoefficient = (1-0.15);
+                                
+                            }else if(AssetRate>0.9 &&AssetRate<=1.0){
+                                Maxcoefficient = 1;
+                                Mincoefficient = (1-0.05);
+                                
+                            }else if(AssetRate>1.0 &&AssetRate<=1.1){
+                                Maxcoefficient = (1+0.05);
+                                Mincoefficient = 1;
+                                
+                            }else if(AssetRate>1.1 &&AssetRate<=1.2){
+                                Maxcoefficient = (1+0.1);
+                                Mincoefficient = 1;
+                                
+                            }else if(AssetRate>1.2 &&AssetRate<=1.3){
+                                Maxcoefficient = (1+0.2);
+                                Mincoefficient = (1+0.1);
+                                
+                            }else if(AssetRate>1.3 &&AssetRate<=1.4){
+                                Maxcoefficient = (1+0.25);
+                                Mincoefficient = (1+0.15);
+                                
+                            }else if(AssetRate>1.4){
+                                Maxcoefficient = (1+0.3);
+                                Mincoefficient = (1+0.2);
+                                
+                            }
+                            //甯傚満澶氬勾淇濅慨浠锋牸寮�鍙� DC 2023/1/30 end 
+                            console.log('***鏈�楂樼郴鏁�'+Maxcoefficient);
+                            console.log('***鏈�浣庣郴鏁�'+Mincoefficient);
+
+                        if(nowdate < Date.parse(lastendDate)){
+                            //璁惧灏忎簬涓ゅ勾鍗�
+                            // upPrice = strMoney;
+                            // downPrice = strMoney * 0.8;
+                        console.log('***灏忎簬2骞村崐')
+                        // 甯傚満澶氬勾淇濅慨浠锋牸寮�鍙� start DC 2023/01/19  
+                            //甯傚満澶氬勾淇濊澶囧皬浜�2骞村崐
+                            var AssetModelNo = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Asset_Model_No__c')).value();
+                            var Category4 = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Category4__c')).value();
+                            console.log('***璁惧鍨嬪彿'+AssetModelNo);
+                            console.log('***浜у搧绫诲瀷'+Category4);
+
+                            //璁惧璁惧娑堣垂鐜囧皬浜�1.4
+                            if(AssetRate<1.4){
+                                upPrice = strMoney;
+                                console.log('娑堣垂鐜囧皬浜�1.4 upPrice = strmonye'+ upPrice);
+
+                                if(AssetModelNo.includes('290')|| Category4 =='BF'|| Category4=='BF鎵囨壂'|| Category4=='GIF'||Category4=='CF' || Category4.includes('GF')){
+                                    downPrice = upPrice;
+                                    console.log('娑堣垂鐜囧皬浜�1.4 浜у搧鏃犳渶浣庝环 downPrice '+ downPrice);
+
+                                }else{
+                                    downPrice = upPrice * 0.8;
+                                    console.log('娑堣垂鐜囧皬浜�1.4 浜у搧鏈�浣庝环 downPrice = upPrice* 0.8锛�'+ downPrice);
+
+                                }
+                            }else{
+                                upPrice = assetListmonth * month *Maxcoefficient / 12;
+                                downPrice = assetListmonth * month * Mincoefficient / 12;   
+                                console.log('娑堣垂鐜囧ぇ浜�1.4 upPrice'+ upPrice);
+                                console.log('娑堣垂鐜囧ぇ浜�1.4 downPrice'+ downPrice);
+                            }
+                        // 甯傚満澶氬勾淇濅慨浠锋牸寮�鍙� end DC 2023/01/19      
+
+                        }else{
+                            //璁惧澶т簬涓ゅ勾鍗�
+                            // upPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Upper/100);
+                            // downPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Lower/100);
+
+                            //甯傚満澶氬勾淇濅慨浠锋牸寮�鍙� DC 2023/1/30 start  璁惧澶т簬2骞村崐 缁浠锋牸 = 瀹氫环 *娑堣垂鐜囧搴旂郴鏁� / 12 *鍚堝悓鏈堟暟
+                            upPrice = assetListmonth * month *Maxcoefficient / 12;
+                            downPrice = assetListmonth * month * Mincoefficient / 12;
+                            //甯傚満澶氬勾淇濅慨浠锋牸寮�鍙� DC 2023/1/30 end 
+                        }
+                        // gzw 20220630  瀹為檯鑱斿姩6涓湀浠锋牸鍖哄垎
                     }else{
                         upPrice = strMoney;
                         downPrice = strMoney * 0.8;
@@ -589,14 +946,68 @@
             }
             //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPrice')).text(toNumComma(strMoney));
             j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPricePageHidden')).val(strMoney);
-            // 
-            repairMoney = j$.trim(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).value());
+            //<!-- (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� start -->  
+
+            Repair_Price_AutoPrice = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Repair_Price_Auto'));
+            Repair_Price_Auto = Repair_Price_AutoPrice.value();
+            repairMoney = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).value();
+            Repair_Price_pass = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Repair_Price_pass')).val();
+            console.log((i+1)+'鍙穜epairMoney='+repairMoney);
+            console.log((i+1)+'鍙稲epair_Price_Auto='+Repair_Price_Auto);
+            if ((repairMoney+1)==1) {
+                j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).val(Repair_Price_Auto);
+                console.log('repairMoney淇敼鎴愬姛');
+            }
+            if ((Repair_Price_pass+1)==1) {
+                j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Repair_Price_pass')).val(Repair_Price_Auto);
+                console.log('Repair_Price_pass淇敼鎴愬姛');
+            }
+            repairMoney1 = localParseFloat(repairMoney);
+            ISReducedpriceapproval = j$(escapeVfId('allPage:allForm:allBlock:ISReducedpriceapproval')).val();
+            console.log('ISReducedpriceapproval=='+ISReducedpriceapproval);
+            if (ISReducedpriceapproval =='鏈夊叓鎶樹互涓嬪緟瀹℃壒' || ISReducedpriceapproval =='鏄�') {
+                j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).attr("disabled", true);
+            }else{
+                j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).attr("disabled", false);
+            }
+            ISReducedpriceapproval1 = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':ISReducedpriceapproval1')).val();
+            ISReduced = j$(escapeVfId('allPage:allForm:allBlock:ISReducedpriceapproval')).val();
+            if (repairMoney1> 0 && (repairMoney1 <Repair_Price_Auto*0.80)) {
+                
+                isresduce = isresduce+1;
+            }
+          
+            console.log('鍒濆鍖杋sresduce='+isresduce);
+        
+            ResonCannotWarranty = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':ResonCannotWarranty')).value();
+            rppa =  document.getElementById('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Repair_Price_Auto');
+            situation = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Asset_situation')).value();
+            // Agreed_Date =  j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Agreed_Date')).value();
+
+            console.log('situation='+situation);
+            // console.log('Agreed_Date1='+Agreed_Date);
+            if(ResonCannotWarranty!=null&&!(ResonCannotWarranty.indexOf("寮冧慨") != -1)){
+                // if (!(situation.indexOf("淇悊涓�")!=-1)&& !(Agreed_Date.indexOf("涓虹┖")!=-1)) { 
+                    rppa.style.display = "none";
+                // }
+            }
+            console.log('鍒ゆ柇1'+(situation.indexOf("淇悊涓�")!=-1));
+            // console.log('鍒ゆ柇'+(Agreed_Date.indexOf("涓嶄负绌�")!=-1));
+            // if ((situation.indexOf("淇悊涓�")!=-1)&& (Agreed_Date.indexOf("涓嶄负绌�")!=-1)) {
+            //     console.log('寮�濮嬫搷浣�2');
+            //     j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Repair_Price_Auto')).val(0);
+            //     j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).val(0);
+            // }
+        //<!-- (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� end -->
         }
+        
         repairSum = repairSum + localParseFloat(repairMoney);
         listSum = listSum + localParseFloat(toNum(strMoney));
         downPriceSum = downPriceSum + localParseFloat(toNum(downPrice));
         upPriceSum =  upPriceSum + localParseFloat(toNum(upPrice));
     }
+    
+   
     j$(escapeVfId('allPage:allForm:allBlock:assetRepairSumNum')).text(toNumComma(repairSum));
     //j$(escapeVfId('allPage:allForm:allBlock:assetListSumNum')).text(toNumComma(listSum));
     
@@ -615,26 +1026,649 @@
     var result = '';
     if (allcount == 0) {
         result = null;
-    }else
-    if (newCount > 0 && newCount == allcount && newCon == true) {
+    //濡傛灉鎵�鏈夎澶囩殑涓婃湡鍚堝悓閮芥槸澶氬勾淇濆悎鍚岋紝鍒欏悎鍚岀绫讳负甯傚満澶氬勾淇濈画绛惧悎鍚� thh 20220315 start
+    }else if(GuranteeCount > 0 && GuranteeCount == allcount){
+        result = '甯傚満澶氬勾淇濈画绛惧悎鍚�';
+    //濡傛灉鎵�鏈夎澶囩殑涓婃湡鍚堝悓閮芥槸澶氬勾淇濆悎鍚岋紝鍒欏悎鍚岀绫讳负甯傚満澶氬勾淇濈画绛惧悎鍚� thh 20220315 end
+    }else if (newCount > 0 && newCount == allcount && newCon == true) {
         result = '鏂板搧鍚堝悓';
     }else if (((newCount > 0 && newCount == allcount) ||(newCount + firstCCount == allcount)) && newCon == false) {
         result = '棣栫鍚堝悓';
     }else if(firstCCount > 0 && firstCCount == allcount){
         result = '棣栫鍚堝悓';
-    }else if(oyearCount > 0 && oyearCount == conCCount){
+    // 20220328 ljh update  LJPH-C8FB4P銆愬鎵樸�戦厤鍚圥BI璁惧瑕嗙洊鐜囩殑鏁版嵁鍑嗗 start
+    // }else if(oyearCount > 0 && oyearCount == conCCount){
+    }else if(oyearCount > 0 && oyearCount == conCCount && allcount == oyearCount ){
+    // 20220328 ljh update  LJPH-C8FB4P銆愬鎵樸�戦厤鍚圥BI璁惧瑕嗙洊鐜囩殑鏁版嵁鍑嗗 start
+        result = '闈炵画绛惧悎鍚岋紙绌虹櫧鏈熶竴骞翠互涓婏級';
+    }else{
+        result = '缁鍚堝悓';
+    }
+    console.log(result);
+    document.getElementById("allPage:allForm:allBlock:contractInfo:Contract_TypeTXT").innerHTML = result;
+    document.getElementById("allPage:allForm:allBlock:contractInfo:Contract_TypeTXTHidden").value = result;
+     
+    // 鍙栨秷閰稿寲姘�
+    //NotUseOxygenatedWaterAmount(1);
+    examinationPriceCal(cnt);
+    getLastContractRate();
+}
+function changeAsset(cnt) {
+    // alert(cnt);
+    // 鎻愪氦鍚庡氨椤甸潰涓嶈绠椾簡
+    var isDisabled = {!PageDisabled};
+    // 鍚堝悓鎬荤悊
+    var newCount = 0;
+    var isresduce = 0;
+    var oyearCount = 0;
+    var firstCCount = 0;
+    var conCCount = 0;
+    // row閲戦鍚堣▓
+    var repairSum = 0;
+    var listSum = 0;
+    // 鏂板搧鍚堝悓 鍒ゆ柇
+    var newCon = true;
+    var contractStartDate = new Date(j$(escapeVfId('allPage:allForm:contractstartdate')).value());
+
+    //澶氬勾淇濈画绛惧悎鍚屾暟閲� thh 20220316 start
+    var GuranteeCount = 0;
+    //澶氬勾淇濈画绛惧悎鍚屾暟閲� thh 20220316 end
+
+    //2022鏁呴殰鍝佸姞璐� 鑾峰彇userInfo绠�妗e悕绉� 鏄惁涓篎SE start
+    var isFSE = {!isFSE};
+    // var hasSendEmail = {!hasSendEmail};
+
+    // var isFSE = true;
+    console.log('***isFSE',isFSE);
+    // console.log('***hasSendEmail',hasSendEmail);
+    // if(hasSendEmail == true){
+    //     j$(escapeVfId('allPage:allForm:emailSend')).attr("disabled", true);
+    //     j$(escapeVfId('allPage:allForm:emailSend')).attr("class", 'btnDisabled');
+    //     console.log('8鎶樹互涓嬫彁浜C鍙 ');
+    // }
+                 
+
+    //2022鏁呴殰鍝佸姞璐� 鑾峰彇userInfo绠�妗e悕绉� end
+
+    // 棰勫畾寮�濮嬫棩
+    var startdate = new Date(j$(escapeVfId('allPage:allForm:allBlock:contract:startdate')).value());
+    // 棰勫畾寮�濮嬫棩-6涓湀
+    startdate.setMonth(startdate.getMonth() - 6);
+    // 鐢宠鏃� 褰撳墠鏃ユ湡
+    if(approvalDate != ''){
+        //鐢宠鏃�
+        approvalDate = new Date(approvalDate.toLocaleDateString());
+        if (Date.parse(approvalDate) < Date.parse(startdate)) {
+            newCon = false;
+        }
+
+    }
+
+    // 鏈�楂樸�佹渶浣庝环鏍煎悎璁�
+    var downPriceSum = 0;
+    var upPriceSum = 0;
+    // 鍚堝悓鏈堟暟涔楃畻
+    var month = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:contract:monthRange')).val());
+    if (month == undefined || month == "") {
+        month = 1;
+    }
+    var month2 = 0;
+    if (month > 12) {
+        month2 = month - 12;
+        month = 12;
+    }
+    for (var i = 0; i < cnt; i++) {
+        var strMoney = 0;
+        var repairMoney = 0;
+        // 琛岄」鐩� 鏈�楂樸�佹渶浣庝环鏍煎悎璁�
+        // 缁浠锋牸鍙栬仈鍔ㄤ环鏍奸〉闈㈣绠楋紝棣栫鎴栦骇鍝佸彇 瀹為檯浠锋牸
+        // 涓嬬嚎浠锋牸
+        var downPrice = 0;
+        // 涓婄嚎浠锋牸
+        var upPrice = 0;
+        
+        // 12涓湀鍚堝悓閲戦
+        var Price_YearTXT = 0;
+        
+        var isManual = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':IsManual')).text();
+        var isnew = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetNewHidden')).val();
+        var assetListmonth = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceHidden')).val();
+        if (isManual == 'true') {
+            var a = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Assert')).value();
+            if (a != '') {
+                // 鎵�鏈夎澶囨寜瀹夎鏃ャ�佸彂璐ф棩锛堟渶鏃╃殑锛夛紝璺濈鍚堝悓寮�濮嬫棩6涓湀鍐呴兘鏄柊鍝佸悎鍚�
+                //var isNewDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':isNewDate')).value());
+                //isNewDate.setMonth(isNewDate.getMonth() + 6);
+                //if (Date.parse(contractStartDate) > Date.parse(isNewDate)) {
+                //    newCon = false;
+                //}
+
+                strMoney = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceHidden')).val();
+                //甯傚満澶氬勾淇濅慨浠锋牸寮�鍙� DC 2023/1/30 start
+                var LastMContractRecord = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':LastMContractRecord')).value();
+                // alert(strMoney);
+                console.log('***缁翠慨鍚堝悓璁板綍绫诲瀷3'+LastMContractRecord);
+
+                Price_YearTXT = strMoney * 12;
+                if (isnew == 'true') {
+                    newCount ++;
+                    strMoney = month * strMoney + month2 * strMoney / {!isNewPriceAdj};
+                } else {
+                    newCon = false;
+                    strMoney = month * strMoney + month2 * strMoney;
+                }
+                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 ++;
+                    // 1.鍚堝悓鏈熶笉婊′竴骞存椂锛屽悎鍚屾湡瓒呰繃涓�鍗婃墠鍙紑濮嬬画绛炬姤浠枫��(eg:11涓湀鐨勫悎鍚屼粠6涓湀鍚庢墠鍙姤浠枫��)
+
+                    // 2.涓�骞翠互涓婄殑鍚堝悓锛屽湪缁撴潫鍓�6涓湀寮�濮嬪彲浠ュ紑鏀剧画绛炬姤浠枫��
+
+                    var lastendDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':End_Date')).value());
+                    var lastContRange = 0;
+                    if(LastMContractRecord == 'VM_Contract'){
+                        newCount++;
+                        //澶氬勾淇濈画绛惧悎鍚屾暟閲�,澶氬勾淇濈画绛惧埌鏈嶅姟鍚堝悓鏃惰涓洪绛捐澶� thh 20220316 start
+                        GuranteeCount++;
+                        newCon = false;
+                        //澶氬勾淇濈画绛惧悎鍚屾暟閲�,澶氬勾淇濈画绛惧埌鏈嶅姟鍚堝悓鏃惰涓洪绛捐澶� thh 20220316 end
+                        lastendDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':endDateGurantee_Text')).value());
+                        lastContRange = 36;
+                    }else{
+                        lastContRange = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':lastContRange')).value();
+                    }
+                    //鏈�鍚庣粨鏉熸棩+1骞�
+                    lastendDate.setMonth(lastendDate.getMonth() + 12);
+                    if (Date.parse(contractStartDate) > Date.parse(lastendDate) ) {
+                        oyearCount ++;
+                    }
+                    // 鍙栬仈鍔ㄤ环鏍�
+                    // 涓婁竴鏈熷悎鍚屽疄闄呮姤浠锋湀棰�
+                    // 
+                    var LastMContract_Price = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':LastMContract_Price')).val());
+                    var Adjustment_ratio_Lower = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_ratio_Lower')).val());
+                    var Adjustment_ratio_Upper = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_ratio_Upper')).val());
+                    //璁$畻鎯╃綒鐜�
+                    var Punish = calculateNtoMRatio( lastContRange,(month + month2));
+                    if(Punish == 0){
+                        return;
+                    }
+                    // 鍒ゆ柇鏈夋棤鎶ヤ环锛氭病鏈夋寜鐓ф爣鍑嗕环鏍煎疄闄呰仈鍔�
+                    var Estimate_Num = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Estimate_NumHidden')).val();
+                    if(Estimate_Num == 0){
+                        if(LastMContractRecord == 'VM_Contract'){
+                            // gzw 20220630  瀹為檯鑱斿姩6涓湀浠锋牸鍖哄垎
+                            var nowdate = new Date();
+                            lastendDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':endDateGurantee_Text')).value());
+                            nowdate = nowdate.setMonth(nowdate.getMonth() + 6);
+
+                            //甯傚満澶氬勾淇濅慨浠锋牸寮�鍙� DC 2023/1/30 start 
+                            var Maxcoefficient =0;
+                            var Mincoefficient =0;
+
+                            var AssetRate = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':AssetConsumptionRateNew')).val());
+                            console.log('***娑堣垂鐜�:'+AssetRate);
+
+                             j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Contractrate')).text(AssetRate +'%');
+
+                            if(AssetRate>0 &&AssetRate<=0.5){
+                                Maxcoefficient = (1-0.3);
+                                Mincoefficient = (1-0.4);
+                            }else if(AssetRate>0.5 &&AssetRate<=0.6){
+                                Maxcoefficient = (1-0.2);
+                                Mincoefficient = (1-0.3);
+                                
+                            }else if(AssetRate>0.6 &&AssetRate<=0.7){
+                                Maxcoefficient = (1-0.15);
+                                Mincoefficient = (1-0.25);
+                                
+                            }else if(AssetRate>0.7 &&AssetRate<=0.8){
+                                Maxcoefficient = (1-0.1);
+                                Mincoefficient = (1-0.2);
+                                
+                            }else if(AssetRate>0.8 &&AssetRate<=0.9){
+                                Maxcoefficient = (1-0.05);
+                                Mincoefficient = (1-0.15);
+                                
+                            }else if(AssetRate>0.9 &&AssetRate<=1.0){
+                                Maxcoefficient = 1;
+                                Mincoefficient = (1-0.05);
+                                
+                            }else if(AssetRate>1.0 &&AssetRate<=1.1){
+                                Maxcoefficient = (1+0.05);
+                                Mincoefficient = 1;
+                                
+                            }else if(AssetRate>1.1 &&AssetRate<=1.2){
+                                Maxcoefficient = (1+0.1);
+                                Mincoefficient = 1;
+                                
+                            }else if(AssetRate>1.2 &&AssetRate<=1.3){
+                                Maxcoefficient = (1+0.2);
+                                Mincoefficient = (1+0.1);
+                                
+                            }else if(AssetRate>1.3 &&AssetRate<=1.4){
+                                Maxcoefficient = (1+0.25);
+                                Mincoefficient = (1+0.15);
+                                
+                            }else if(AssetRate>1.4){
+                                Maxcoefficient = (1+0.3);
+                                Mincoefficient = (1+0.2);
+                                
+                            }
+                            //甯傚満澶氬勾淇濅慨浠锋牸寮�鍙� DC 2023/1/30 end 
+                            console.log('***鏈�楂樼郴鏁�'+Maxcoefficient);
+                            console.log('***鏈�浣庣郴鏁�'+Mincoefficient);
+
+                        if(nowdate < Date.parse(lastendDate)){
+                            //璁惧灏忎簬涓ゅ勾鍗�
+                            // upPrice = strMoney;
+                            // downPrice = strMoney * 0.8;
+                        console.log('***灏忎簬2骞村崐')
+                        // 甯傚満澶氬勾淇濅慨浠锋牸寮�鍙� start DC 2023/01/19  
+                            //甯傚満澶氬勾淇濊澶囧皬浜�2骞村崐
+                            var AssetModelNo = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Asset_Model_No__c')).value();
+                            var Category4 = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Category4__c')).value();
+                            console.log('***璁惧鍨嬪彿'+AssetModelNo);
+                            console.log('***浜у搧绫诲瀷'+Category4);
+
+                            //璁惧璁惧娑堣垂鐜囧皬浜�1.4
+                            if(AssetRate<1.4){
+                                upPrice = strMoney;
+                                console.log('娑堣垂鐜囧皬浜�1.4 upPrice = strmonye'+ upPrice);
+
+                                if(AssetModelNo.includes('290')|| Category4 =='BF'|| Category4=='BF鎵囨壂'|| Category4=='GIF'||Category4=='CF' || Category4.includes('GF')){
+                                    downPrice = upPrice;
+                                    console.log('娑堣垂鐜囧皬浜�1.4 浜у搧鏃犳渶浣庝环 downPrice '+ downPrice);
+
+                                }else{
+                                    downPrice = upPrice * 0.8;
+                                    console.log('娑堣垂鐜囧皬浜�1.4 浜у搧鏈�浣庝环 downPrice = upPrice* 0.8锛�'+ downPrice);
+
+                                }
+                            }else{
+                                upPrice = assetListmonth * month *Maxcoefficient / 12;
+                                downPrice = assetListmonth * month * Mincoefficient / 12;   
+                                console.log('娑堣垂鐜囧ぇ浜�1.4 upPrice'+ upPrice);
+                                console.log('娑堣垂鐜囧ぇ浜�1.4 downPrice'+ downPrice);
+                            }
+                            // 甯傚満澶氬勾淇濅慨浠锋牸寮�鍙� end DC 2023/01/19  
+
+                            }else{
+                                // upPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Upper/100);
+                                // downPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Lower/100);
+
+                                //甯傚満澶氬勾淇濅慨浠锋牸寮�鍙� DC 2023/1/30 start  璁惧澶т簬2骞村崐 缁浠锋牸 =瀹氫环*娑堣垂鐜囧搴旂郴鏁� / 12 *鍚堝悓鏈堟暟
+                                upPrice = assetListmonth * month *Maxcoefficient / 12;
+                                downPrice = assetListmonth * month * Mincoefficient / 12;
+                                //甯傚満澶氬勾淇濅慨浠锋牸寮�鍙� DC 2023/1/30 end 
+                            }
+                            // gzw 20220630  瀹為檯鑱斿姩6涓湀浠锋牸鍖哄垎
+                        }else{
+                            upPrice = strMoney;
+                            downPrice = strMoney * 0.8;
+                        }
+                    }else{
+                        upPrice = (LastMContract_Price * Punish) * (1 + Adjustment_ratio_Upper/100);
+                        downPrice = (LastMContract_Price * Punish) * (1 + Adjustment_ratio_Lower/100);
+                    }
+                }else{
+                    //firstCCount ++;
+                    upPrice = strMoney;
+                    downPrice = strMoney * 0.8;
+                }
+                // 涓婁笅闄愬洓鑸嶄簲鍏�
+                upPrice = upPrice.toFixed(2);
+                downPrice = downPrice.toFixed(2);
+                // 12涓湀鍚堝悓閲戦
+                //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceTXT')).text(toNumComma(Price_YearTXT));
+                //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceTXTHidden')).val(Price_YearTXT);
+                if (!isDisabled) {
+                    // 瀹為檯鑱斿姩浠锋牸 start
+                    j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_price')).text(toNumComma(downPrice));
+                    j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_priceHidden')).val(downPrice);
+                    j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Upper_price')).text(toNumComma(upPrice));
+                    j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Upper_priceHidden')).val(upPrice);
+                    // 瀹為檯鑱斿姩浠锋牸 end
+                }
+                
+                //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPrice')).text(toNumComma(strMoney));
+                j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPricePageHidden')).val(strMoney);
+                
+                repairMoney = j$.trim(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).value());
+            } else {
+                // TODO 涓�鏅傜殑銇蹇溿�併仾銈撱仹鍒ヨ銇噾椤嶃儶銉曘儸銉冦偡銉ャ仌銈屻仧锛�
+                //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPrice')).text("");
+                j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPricePageHidden')).val();
+
+                // 12涓湀鍚堝悓閲戦
+                //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceTXT')).text("");
+                //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceTXTHidden')).val();
+                if (!isDisabled) {
+                    // 瀹為檯鑱斿姩浠锋牸 start
+                    j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_price')).text("");
+                    j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_priceHidden')).val();
+                    j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Upper_price')).text("");
+                    j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Upper_priceHidden')).val();
+                    // 瀹為檯鑱斿姩浠锋牸 end
+                 }
+            }
+        }
+        else {
+            // 鎵�鏈夎澶囨寜瀹夎鏃ャ�佸彂璐ф棩锛堟渶鏃╃殑锛夛紝璺濈鍚堝悓寮�濮嬫棩6涓湀鍐呴兘鏄柊鍝佸悎鍚�
+            var isNewDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':isNewDate')).value());
+            isNewDate.setMonth(isNewDate.getMonth() + 6);
+            if (Date.parse(contractStartDate) > Date.parse(isNewDate)) {
+                newCon = false;
+            }
+            strMoney = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceHidden')).val();
+            Price_YearTXT = strMoney * 12;
+            if (isnew == 'true') {
+                strMoney = month * strMoney + month2 * strMoney / {!isNewPriceAdj};
+            } else {
+                strMoney = month * strMoney + month2 * strMoney;
+            }
+            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();
+            console.log('***缁翠慨鍚堝悓璁板綍绫诲瀷4'+LastMContractRecord);
+            if(b != ''){
+                conCCount ++;
+                // 1.鍚堝悓鏈熶笉婊′竴骞存椂锛屽悎鍚屾湡瓒呰繃涓�鍗婃墠鍙紑濮嬬画绛炬姤浠枫��(eg:11涓湀鐨勫悎鍚屼粠6涓湀鍚庢墠鍙姤浠枫��)
+
+                // 2.涓�骞翠互涓婄殑鍚堝悓锛屽湪缁撴潫鍓�6涓湀寮�濮嬪彲浠ュ紑鏀剧画绛炬姤浠枫��
+                var lastendDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':End_Date')).value());
+                var lastContRange = 0;
+                if(LastMContractRecord == 'VM_Contract'){
+                    newCount++;
+                    //澶氬勾淇濈画绛惧悎鍚屾暟閲�,澶氬勾淇濈画绛惧埌鏈嶅姟鍚堝悓鏃惰涓洪绛捐澶� thh 20220316 start
+                    GuranteeCount++;
+                    newCon = false;
+                    //澶氬勾淇濈画绛惧悎鍚屾暟閲�,澶氬勾淇濈画绛惧埌鏈嶅姟鍚堝悓鏃惰涓洪绛捐澶� thh 20220316 end
+                    lastendDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':endDateGurantee_Text')).value());
+                    lastContRange = 36;
+                }else{
+                    lastContRange = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':lastContRange')).value();
+                }
+                //鏈�鍚庣粨鏉熸棩+1骞�
+                lastendDate.setMonth(lastendDate.getMonth() + 12);
+                // alert('+++++++++--------' + lastendDate);
+                // alert('+++++++++--------' + Date.parse(contractStartDate) + '77777' + Date.parse(lastendDate));
+                if (Date.parse(contractStartDate) > Date.parse(lastendDate)) {
+                    oyearCount ++;
+                }
+                // 鍙栬仈鍔ㄤ环鏍�
+                // 涓婁竴鏈熷悎鍚屽疄闄呮姤浠锋湀棰�
+                // 
+                var LastMContract_Price = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':LastMContract_Price')).val());
+                var Adjustment_ratio_Lower = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_ratio_Lower')).val());
+                var Adjustment_ratio_Upper = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_ratio_Upper')).val());
+                //璁$畻鎯╃綒鐜�
+                var Punish = calculateNtoMRatio( lastContRange,(month + month2));
+                if(Punish == 0){
+                    return;
+                }
+                // 鍒ゆ柇鏈夋棤鎶ヤ环锛氭病鏈夋寜鐓ф爣鍑嗕环鏍煎疄闄呰仈鍔�
+                var Estimate_Num = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Estimate_NumHidden')).val();
+                if(Estimate_Num == 0){
+                    if(LastMContractRecord == 'VM_Contract'){
+                        // alert('11111');
+                        // gzw 20220630  瀹為檯鑱斿姩6涓湀浠锋牸鍖哄垎
+                        var nowdate = new Date();
+                        lastendDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':endDateGurantee_Text')).value());
+                        nowdate = nowdate.setMonth(nowdate.getMonth() + 6);
+
+                         //甯傚満澶氬勾淇濅慨浠锋牸寮�鍙� DC 2023/1/30 start 
+                            var Maxcoefficient =0;
+                            var Mincoefficient =0;
+
+                            var AssetRate = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':AssetConsumptionRateNew')).val());
+                            console.log('***娑堣垂鐜�:'+AssetRate);
+
+                             j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Contractrate')).text(AssetRate +'%');
+
+                            if(AssetRate>0 &&AssetRate<=0.5){
+                                Maxcoefficient = (1-0.3);
+                                Mincoefficient = (1-0.4);
+                            }else if(AssetRate>0.5 &&AssetRate<=0.6){
+                                Maxcoefficient = (1-0.2);
+                                Mincoefficient = (1-0.3);
+                                
+                            }else if(AssetRate>0.6 &&AssetRate<=0.7){
+                                Maxcoefficient = (1-0.15);
+                                Mincoefficient = (1-0.25);
+                                
+                            }else if(AssetRate>0.7 &&AssetRate<=0.8){
+                                Maxcoefficient = (1-0.1);
+                                Mincoefficient = (1-0.2);
+                                
+                            }else if(AssetRate>0.8 &&AssetRate<=0.9){
+                                Maxcoefficient = (1-0.05);
+                                Mincoefficient = (1-0.15);
+                                
+                            }else if(AssetRate>0.9 &&AssetRate<=1.0){
+                                Maxcoefficient = 1;
+                                Mincoefficient = (1-0.05);
+                                
+                            }else if(AssetRate>1.0 &&AssetRate<=1.1){
+                                Maxcoefficient = (1+0.05);
+                                Mincoefficient = 1;
+                                
+                            }else if(AssetRate>1.1 &&AssetRate<=1.2){
+                                Maxcoefficient = (1+0.1);
+                                Mincoefficient = 1;
+                                
+                            }else if(AssetRate>1.2 &&AssetRate<=1.3){
+                                Maxcoefficient = (1+0.2);
+                                Mincoefficient = (1+0.1);
+                                
+                            }else if(AssetRate>1.3 &&AssetRate<=1.4){
+                                Maxcoefficient = (1+0.25);
+                                Mincoefficient = (1+0.15);
+                                
+                            }else if(AssetRate>1.4){
+                                Maxcoefficient = (1+0.3);
+                                Mincoefficient = (1+0.2);
+                                
+                            }
+                            //甯傚満澶氬勾淇濅慨浠锋牸寮�鍙� DC 2023/1/30 end 
+                            console.log('***鏈�楂樼郴鏁�'+Maxcoefficient);
+                            console.log('***鏈�浣庣郴鏁�'+Mincoefficient);
+
+                        if(nowdate < Date.parse(lastendDate)){
+                            //璁惧灏忎簬涓ゅ勾鍗�
+                            // upPrice = strMoney;
+                            // downPrice = strMoney * 0.8;
+                        console.log('***灏忎簬2骞村崐')
+                        // 甯傚満澶氬勾淇濅慨浠锋牸寮�鍙� start DC 2023/01/19  
+                            //甯傚満澶氬勾淇濊澶囧皬浜�2骞村崐
+                            var AssetModelNo = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Asset_Model_No__c')).value();
+                            var Category4 = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Category4__c')).value();
+                            console.log('***璁惧鍨嬪彿'+AssetModelNo);
+                            console.log('***浜у搧绫诲瀷'+Category4);
+
+                            //璁惧璁惧娑堣垂鐜囧皬浜�1.4
+                            if(AssetRate<1.4){
+                                upPrice = strMoney;
+                                console.log('娑堣垂鐜囧皬浜�1.4 upPrice = strmonye'+ upPrice);
+
+                                if(AssetModelNo.includes('290')|| Category4 =='BF'|| Category4=='BF鎵囨壂'|| Category4=='GIF'||Category4=='CF' || Category4.includes('GF')){
+                                    downPrice = upPrice;
+                                    console.log('娑堣垂鐜囧皬浜�1.4 浜у搧鏃犳渶浣庝环 downPrice '+ downPrice);
+
+                                }else{
+                                    downPrice = upPrice * 0.8;
+                                    console.log('娑堣垂鐜囧皬浜�1.4 浜у搧鏈�浣庝环 downPrice = upPrice* 0.8锛�'+ downPrice);
+
+                                }
+                            }else{
+                                upPrice = assetListmonth * month *Maxcoefficient / 12;
+                                downPrice = assetListmonth * month * Mincoefficient / 12;   
+                                console.log('娑堣垂鐜囧ぇ浜�1.4 upPrice'+ upPrice);
+                                console.log('娑堣垂鐜囧ぇ浜�1.4 downPrice'+ downPrice);
+                            }
+                            // 甯傚満澶氬勾淇濅慨浠锋牸寮�鍙� end DC 2023/01/19  
+                        }else{
+                            // upPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Upper/100);
+                            // downPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Lower/100);
+
+                            //甯傚満澶氬勾淇濅慨浠锋牸寮�鍙� DC 2023/1/30 start  璁惧澶т簬2骞村崐 缁浠锋牸 = 瀹氫环 *娑堣垂鐜囧搴旂郴鏁� / 12 *鍚堝悓鏈堟暟
+                            upPrice = assetListmonth * month *Maxcoefficient / 12;
+                            downPrice = assetListmonth * month * Mincoefficient / 12;
+                            //甯傚満澶氬勾淇濅慨浠锋牸寮�鍙� DC 2023/1/30 end 
+
+                        }
+                        // gzw 20220630  瀹為檯鑱斿姩6涓湀浠锋牸鍖哄垎
+                    }else{
+                        upPrice = strMoney;
+                        downPrice = strMoney * 0.8;
+                    }
+                }else{
+                    upPrice = (LastMContract_Price * Punish) * (1 + Adjustment_ratio_Upper/100);
+                    downPrice = (LastMContract_Price * Punish) * (1 + Adjustment_ratio_Lower/100);
+                }
+            }else{
+                if (isnew == 'true') {
+                    newCount ++;
+                } else {
+                    newCon = false;
+                    firstCCount ++;
+                }
+                upPrice = strMoney;
+                downPrice = strMoney * 0.8;
+            }
+            // 涓婁笅闄愬洓鑸嶄簲鍏�
+            upPrice = upPrice.toFixed(2);
+            downPrice = downPrice.toFixed(2);
+            // 12涓湀鍚堝悓閲戦
+            //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceTXT')).text(toNumComma(Price_YearTXT));
+            //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceTXTHidden')).val(Price_YearTXT);
+            if (!isDisabled) {
+                // 瀹為檯鑱斿姩浠锋牸 start
+                j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_price')).text(toNumComma(downPrice));
+                j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_priceHidden')).val(downPrice);
+                j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Upper_price')).text(toNumComma(upPrice));
+                j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Upper_priceHidden')).val(upPrice);
+                // 瀹為檯鑱斿姩浠锋牸 end
+            }
+            //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPrice')).text(toNumComma(strMoney));
+            j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPricePageHidden')).val(strMoney);
+            //<!-- (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� start -->  
+
+            Repair_Price_AutoPrice = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Repair_Price_Auto'));
+            Repair_Price_Auto = Repair_Price_AutoPrice.value();
+            repairMoney = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).value();
+            // console.log('repairMoney='+repairMoney);
+            repairMoney1 = localParseFloat(repairMoney);
+            ISReducedpriceapproval1 = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':ISReducedpriceapproval1')).val();
+            ISReduced = j$(escapeVfId('allPage:allForm:allBlock:ISReducedpriceapproval')).val();
+            console.log('ISReduced='+ISReduced);
+            
+            console.log('Repair_Price_Auto='+Repair_Price_Auto);
+            console.log('绗�'+(i+1)+'涓澶嘔SReducedpriceapproval1='+ISReducedpriceapproval1);
+            console.log('repairMoney1='+repairMoney1);
+            
+            Repair_Price_pass1 = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Repair_Price_pass')).val();
+            Repair_Price_pass2 = localParseFloat(Repair_Price_pass1);
+            console.log('缁撴灉='+(repairMoney1<Repair_Price_pass2));
+            console.log('Repair_Price_pass2='+Repair_Price_pass2);
+            if (repairMoney1> 0 && repairMoney1<(Repair_Price_Auto*0.80) && Repair_Price_Auto != null && isFSE == true) {
+                 if (Repair_Price_pass1!=null && repairMoney1<Repair_Price_pass2) {
+                    alert('鐢变簬瀛樺湪鎶樻墸鐜囪秴杩�20%浠ヤ笂鐨勪慨鐞嗗姞璐瑰噺浠风敵璇凤紝璇峰厛鐐瑰嚮鈥滄彁浜C璇勪及鈥濇寜閽紝寰匯C璇勪及鍚庢湇鍔$鐞嗛儴浼氭帹杩涘鎵�');
+                        // j$(escapeVfId('allPage:allForm:emailSend')).attr("disabled", false);
+                        // j$(escapeVfId('allPage:allForm:emailSend')).attr("class", 'btn');
+
+                    // RCbottonChanged = 1;
+
+                    // var change_cancel = document.getElementById("emailSend");
+                    // change_cancel.style.display = "block";
+                    repairMoney = Repair_Price_pass2;
+                    j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).val(Repair_Price_pass2);
+                 }
+            }
+             
+             repairMoney2 = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).value();
+            // console.log('repairMoney='+repairMoney);
+            repairMoney3 = localParseFloat(repairMoney2);
+             if (repairMoney3> 0 && (repairMoney3 <Repair_Price_Auto*0.80)) {
+                if (Repair_Price_pass1!=null && repairMoney3<Repair_Price_pass2) {
+                         isresduce = isresduce+1;
+                }
+            }
+            ResonCannotWarranty = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':ResonCannotWarranty')).value();
+            rppa =  document.getElementById('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Repair_Price_Auto');
+            situation = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Asset_situation')).value();
+            // Agreed_Date =  j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Agreed_Date')).value();
+
+            console.log('situation='+situation);
+            // console.log('Agreed_Date1='+Agreed_Date);
+            if(ResonCannotWarranty!=null&&!(ResonCannotWarranty.indexOf("寮冧慨") != -1)){
+                // if (!(situation.indexOf("淇悊涓�")!=-1)&& !(Agreed_Date.indexOf("涓虹┖")!=-1)) {
+                    rppa.style.display = "none";
+                // }
+            }
+            // if ((situation.indexOf("淇悊涓�")!=-1)&& (Agreed_Date.indexOf("涓虹┖")!=-1)) {
+            //     console.log('寮�濮嬫搷浣�1');
+            //     rppa.style.display = "none";
+            // }
+            // if ((situation.indexOf("淇悊涓�")!=-1)&& (Agreed_Date.indexOf("涓嶄负绌�")!=-1)) {
+            //     console.log('寮�濮嬫搷浣�2');
+            //     j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Repair_Price_Auto')).val(0);
+            //     j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).val(0);
+            // }
+        //<!-- (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� end -->
+        }
+        
+        repairSum = repairSum + localParseFloat(repairMoney);
+        listSum = listSum + localParseFloat(toNum(strMoney));
+        downPriceSum = downPriceSum + localParseFloat(toNum(downPrice));
+        upPriceSum =  upPriceSum + localParseFloat(toNum(upPrice));
+    }
+    console.log('鏀瑰彉閲戦isresduce='+isresduce);
+     if (isresduce!=0) {
+                toChange1();
+        }else{
+            if(ISReduced !='' ){
+                 toChange2();
+            }
+        }
+    j$(escapeVfId('allPage:allForm:allBlock:assetRepairSumNum')).text(toNumComma(repairSum));
+    if (!isDisabled) {
+        j$(escapeVfId('allPage:allForm:allBlock:contractInfo:GuidePriceUp')).text(toNumComma(Math.round(upPriceSum)));
+        j$(escapeVfId('allPage:allForm:allBlock:contractInfo:GuidePriceUpHidden')).val(toNum(Math.round(upPriceSum)));
+        j$(escapeVfId('allPage:allForm:allBlock:contractInfo:GuidePriceDown')).text(toNumComma(Math.round(downPriceSum)));
+        j$(escapeVfId('allPage:allForm:allBlock:contractInfo:GuidePriceDownHidden')).val(toNum(Math.round(downPriceSum)));
+    }
+    j$(escapeVfId('allPage:allForm:allBlock:contractInfo:assetRepairSumPrice')).text(toNumComma(repairSum));
+    j$(escapeVfId('allPage:allForm:allBlock:contractInfo:assetRepairSumPriceHidden')).val(toNum(repairSum));
+
+    var allcount = j$(escapeVfId('allPage:allForm:allBlock:productCount3')).value();
+    var result = '';
+    if (allcount == 0) {
+        result = null;
+    //濡傛灉鎵�鏈夎澶囩殑涓婃湡鍚堝悓閮芥槸澶氬勾淇濆悎鍚岋紝鍒欏悎鍚岀绫讳负甯傚満澶氬勾淇濈画绛惧悎鍚� thh 20220315 start
+    }else if(GuranteeCount > 0 && GuranteeCount == allcount){
+        result = '甯傚満澶氬勾淇濈画绛惧悎鍚�';
+    //濡傛灉鎵�鏈夎澶囩殑涓婃湡鍚堝悓閮芥槸澶氬勾淇濆悎鍚岋紝鍒欏悎鍚岀绫讳负甯傚満澶氬勾淇濈画绛惧悎鍚� thh 20220315 end
+    }else if (newCount > 0 && newCount == allcount && newCon == true) {
+        result = '鏂板搧鍚堝悓';
+    }else if (((newCount > 0 && newCount == allcount) ||(newCount + firstCCount == allcount)) && newCon == false) {
+        result = '棣栫鍚堝悓';
+    }else if(firstCCount > 0 && firstCCount == allcount){
+        result = '棣栫鍚堝悓';
+    // 20220328 ljh update  LJPH-C8FB4P銆愬鎵樸�戦厤鍚圥BI璁惧瑕嗙洊鐜囩殑鏁版嵁鍑嗗 start
+    // }else if(oyearCount > 0 && oyearCount == conCCount){
+    }else if(oyearCount > 0 && oyearCount == conCCount && allcount == oyearCount ){
+    // 20220328 ljh update  LJPH-C8FB4P銆愬鎵樸�戦厤鍚圥BI璁惧瑕嗙洊鐜囩殑鏁版嵁鍑嗗 start
         result = '闈炵画绛惧悎鍚岋紙绌虹櫧鏈熶竴骞翠互涓婏級';
     }else{
         result = '缁鍚堝悓';
     }
     document.getElementById("allPage:allForm:allBlock:contractInfo:Contract_TypeTXT").innerHTML = result;
     document.getElementById("allPage:allForm:allBlock:contractInfo:Contract_TypeTXTHidden").value = result;
-    // 鍙栨秷閰稿寲姘�
-    //NotUseOxygenatedWaterAmount(1);
+     
     examinationPriceCal(cnt);
     getLastContractRate();
 }
-
 
 
 function examinationPriceCal(cntWithKara) {
@@ -958,8 +1992,10 @@
 function ComputeLTY() {
     var  urlNameJs = j$(escapeVfId('allPage:allForm:urlName')).val();
     urlNameJs = '{!$Label.ID_of_SelectAssetEstimate}'+urlNameJs ;
-    var w = window.open(encodeURI(urlNameJs),'杩囧幓涓ゅ勾淇悊瀹炵哗','menubar=no,height=720,width=986');
-    w.focus();
+    //URF闄愭鍚堝悓2鏈� LY 20220920 start
+    // var w = window.open(encodeURI(urlNameJs),'杩囧幓涓ゅ勾淇悊瀹炵哗','menubar=no,height=720,width=986');
+    // w.focus();
+    //URF闄愭鍚堝悓2鏈� LY 20220920 end
 }
 function recordNumChangeJs() {
     recordNumChangeAction();
@@ -1241,6 +2277,10 @@
 
     <!-- HWAG-B4R3SS  START 20181026-->
     <apex:actionFunction name="searchfunc" action="{!searchBtn}" rerender="Form,Block,assetSection2,pageMessages,allBlock" onComplete="unblockUI();"></apex:actionFunction>
+    <apex:actionfunction action="{!tochange}" name="tochange" rerender="ISReducedpriceapproval" oncomplete="unblockUI();">
+        </apex:actionfunction>
+        <apex:actionfunction action="{!tochange2}" name="tochange2" rerender="ISReducedpriceapproval" oncomplete="unblockUI();">
+        </apex:actionfunction>
     <!-- HWAG-B4R3SS  END 20181026-->
     <apex:actionFunction name="ComputeLTYRepair" action="{!ComputeLTYRepair}" rerender="pageMessages" oncomplete="unblockUI();ComputeLTY();"/>
     <apex:actionFunction name="ShowLTYRepair" action="{!ShowLTYRepair}"  oncomplete="unblockUI();ComputeLTY();"/>
@@ -1461,6 +2501,11 @@
                         
                         <th style="width:70px" class="headerRow  booleanColumn">{!$ObjectType.Asset.fields.Management_Code__c.label}</th>
                         <th style="width:70px" class="headerRow  booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Asset_Consumption_rate__c.label}</th>
+
+                        <!-- 甯傚満澶氬勾淇濅慨浠锋牸寮�鍙� DC 2023/1/30 start -->
+                        <th style="width:70px" class="headerRow  booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Asset_Consumption_rate__c.label}</th>
+
+                        <!-- 甯傚満澶氬勾淇濅慨浠锋牸寮�鍙� DC 2023/1/30 end -->
                         <th style="width:70px" class="headerRow  booleanColumn">{!$ObjectType.Asset.fields.CurrentContract_End_Date__c.label}</th>
                         <!-- 瀹炵哗鑱斿姩浠锋牸璁$畻 start -->
                         <th style="width:35px" class="headerRow  booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Adjustment_Upper_price__c.label}</th>
@@ -1481,7 +2526,15 @@
                         <th style="width:90px" class="headerRow  booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Estimate_List_Price_All__c.label}</th>
                         <th style="width:90px" class="headerRow  booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Maintenance_Price_YearTXT__c.label}</th>-->
                         <th style="width:70px" class="headerRow  booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Repair_Price__c.label}</th>
+                        <!-- (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� start -->
+
+                        <th style="width:70px" class="headerRow ">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Repair_Price_Auto__c.label}</th>
+
+                       <!-- (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� end -->
                         <th style="width:70px" class="headerRow  booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Comment__c.label}</th>
+
+                        <!-- (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� 绗笁鏂瑰洖褰� -->
+                        <th style="width:70px" class="headerRow  booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Third_Party_Return__c.label}</th>
                     </tr>
                     
                     <apex:variable value="{!1}" var="cnt" />
@@ -1499,8 +2552,13 @@
                                     <apex:inputField value="{!ar.mcae.Product_Manual__c}" id="Assert" style="width:90%;" rendered="{!ar.IsManual}" onchange="blockme();refreshProductData({!ar.lineNo});"/>
                                     <apex:inputText id="ProductId" value="{!ar.mcae.Product_Manual__c}" style="display:none;" disabled="true"/>
                                 </td>
+                                <!-- URF闄愭鍚堝悓2鏈� LY 20220811 start -->
+                            
+                                    <apex:inputHidden value="{!ar.rec.URF_Maintenance_Contract__r.Management_Code__c}" rendered="{!Not(ar.IsManual)}" id="URF_Contract_No"/>
+                                
+                                <!-- URF闄愭鍚堝悓2鏈� LY 20220811 end -->
                                 <td class="dataCell" width="70px">
-                                    <apex:outputField value="{!ar.rec.Asset_situation__c}" rendered="{!Not(ar.IsManual)}" />
+                                    <apex:outputField value="{!ar.rec.Asset_situation__c}" rendered="{!Not(ar.IsManual)}" id="Asset_situation"/>
                                 </td>
                                 <td class="dataCell" width="70px">
                                     <apex:outputLink value="/{!ar.recId}" rendered="{!Not(ar.IsManual)}" >{!ar.rec.SerialNumber}</apex:outputLink>
@@ -1539,6 +2597,19 @@
                                     <apex:inputHidden value="{!ar.rec.CurrentContract_F__r.RecordType_DeveloperName__c}" id="LastMContractRecord"/>
                                     <apex:inputField value="{!ar.rec.CurrentContract_F_asset__r.endDateGurantee_Text__c}" id="endDateGurantee_Text" style="display: none" showDatePicker="false"/>
                                     <apex:inputHidden value="{!ar.rec.CurrentContract_F__c}" id="LastMContractID"/>
+                                    <!-- 甯傚満澶氬勾淇濅环鏍煎紑鍙� start 20223/01/17 缁翠慨鍚堝悓/淇濇湁璁惧 璁惧娑堣垂鐜� -->
+
+                                    <apex:inputHidden value="{!ar.rec.CurrentContract_F_asset__r.Asset_Consumption_Rate__c}" id="AssetConsumptionRateNew"/>
+
+                                 <!--    <apex:inputField value="{!ar.rec.CurrentContract_F_asset__r.Asset_Consumption_Rate__c}" id="AssetConsumptionRateNew2" style="display: none" showDatePicker="false" />
+
+                                    <apex:outputText value="{!ar.rec.CurrentContract_F_asset__r.Asset_Consumption_Rate__c}" id="AssetConsumptionRateNew3" rendered="{!Not(ar.IsManual)}" style="display: none"/> -->
+
+                                    <apex:inputField value="{!ar.rec.Product2.Asset_Model_No__c}" id="Asset_Model_No__c" style="display: none" showDatePicker="false"/>
+
+                                    <apex:inputField value="{!ar.rec.Product2.Category4__c}" id="Category4__c" style="display: none" showDatePicker="false"/>
+                                    <!-- 甯傚満澶氬勾淇濅环鏍煎紑鍙� end 20223/01/17 璁惧娑堣垂鐜� -->
+
                                 </td>
                                 <td class="dataCell" width="90px" style="text-align:right" >
                                     <apex:outputField value="{!ar.mcae.Asset_Consumption_rate__c}" rendered="{!Not(ar.IsManual)}" id="Contractrate"/>
@@ -1562,6 +2633,7 @@
                                         <apex:inputHidden value="{!ar.mcae.Estimate_List_Price__c}" id="assetListPriceHidden"/>
                                         <apex:inputHidden value="{!ar.mcae.Estimate_List_Price_Page__c}" id="assetListPricePageHidden" />
                                         <apex:inputHidden value="{!ar.rec.CurrentContract_F__r.Estimate_Num__c}" id="Estimate_NumHidden" />
+
                                     </apex:outputPanel>
                                     
                                     <apex:outputPanel layout="none" rendered="{!Not($ObjectType.Maintenance_Contract_Asset_Estimate__c.createable)}" >
@@ -1573,11 +2645,26 @@
                                     <!-- 20200103 Gzw 璁$畻瀹為檯鎶ヤ环閲戦 end -->
 
                                 </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 class="dataCell" width="35px" 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});changeAsset({!productCount})"/>
                                 </td>
+                               <!-- (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� start -->
+                                <td class="dataCell" width="35px" style="text-align:right" >
+                                    <apex:outputText value="{!ar.Repair_Price_Auto}" id="Repair_Price_Auto" style="width:95%; disabled:disabled;"/>
+                                    <!-- <apex:inputHiddenalue="{!ar.rec.Reson_Can_not_Warranty__c}" id="ResonCannotWarranty"/> -->
+                                    <!-- <apex:outputText value="{!ar.Agreed_Date}" id="Agreed_Date" style="width:95%;display: none;"/> -->
+                                    <apex:inputField value="{!ar.mcae.Repair_Price_pass__c}" id="Repair_Price_pass" style="width:95%;display: none;"/>
+                                    <apex:inputHidden value="{!ar.mcae.IS_Reduced_price_approval__c}" id="ISReducedpriceapproval1"/>
+                                     <apex:outputText value="{!ar.rec.Reson_Can_not_Warranty__c}" id="ResonCannotWarranty" style="display:none;" rendered="{!Not(ar.IsManual)}" /> 
+                                </td>
+                                
+                                <!-- (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� end -->
                                 <td class="dataCell" width="70px" style="text-align:right" >
                                     <apex:inputField value="{!ar.mcae.Comment__c}" id="comment" style="width:95%;"/>
+                                </td>
+                                <!--(2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� 绗笁鏂瑰洖褰�  -->
+                                <td class="dataCell" width="40px" style="text-align:center;" >
+                                    <apex:inputCheckbox value="{!ar.mcae.Third_Party_Return__c}" id="Third_Party_Return__c"/>
                                 </td>
                             </tr>
 
@@ -1634,9 +2721,12 @@
                     <th width="90px" style="text-align:right">璁惧鏁伴噺</th>
                     <td width="90px" style="text-align:right"><apex:outputtext value="{!productCount3}" id="productCount3"/></td>
                     <td width="25px">&nbsp;</td>
+                    <th width="90px" style="text-align:right">
+                        <apex:inputField value="{!estimate.IS_Reduced_price_approval__c}" id="ISReducedpriceapproval" style="display:none"/></th>
+                         <!-- <apex:inputField value="{!estimate.IS_Reduced_price_approval__c}" id="ISReducedpriceapproval"/></th> -->
+                    <td width="25px">&nbsp;</td>
                     <!--<th width="90px" style="text-align:right">鎶ヤ环鎬婚</th>
                     <th width="90px" style="text-align:right"><span id="allPage:allForm:allBlock:assetListSumNum" ></span></th>-->
-                    <td width="25px">&nbsp;</td>
                     <th width="90px" style="text-align:right">淇悊鎬婚</th>
                     <th width="90px" style="text-align:right"><span id="allPage:allForm:allBlock:assetRepairSumNum" ></span></th>
                     <td width="95px">&nbsp;</td>
@@ -1657,7 +2747,7 @@
                         <th style="width:70px" class="headerRow  booleanColumn">{!$ObjectType.Asset.fields.SerialNumber.label}</th>
                         <th class="headerRow  booleanColumn">{!$ObjectType.Asset.fields.Department_Name__c.label}</th>
                         <!-- <th style="width:90px" class="headerRow  booleanColumn">{!$ObjectType.Asset.fields.Installation_Site__c.label}</th> -->
-                        <th style="width:90px" class="headerRow  booleanColumn">{!$ObjectType.Asset.fields.IF_Warranty__c.label}</th>
+                        <th style="width:90px" class="headerRow  booleanColumn">{!$ObjectType.Asset.fields.IF_Warranty_Service__c.label}</th>
                          <!-- //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start -->
                         <th style="width:90px" class="headerRow  booleanColumn">涓绘満/鑰楁潗</th>
                          <!-- //JZHG-BSDUT4 ---20200825---update By rentongxiao---End -->
@@ -1675,7 +2765,7 @@
                         <apex:repeat value="{!assetsView}" var="ar" id="assetTable2">
                             <tr class="dataRow {!IF(MOD(cnt, 2)==0, 'odd', 'even')} {!IF(cnt==1, 'first', '')}" onmouseover="if (window.hiOn){hiOn(this);} " onmouseout="if (window.hiOff){hiOff(this);} " onblur="if (window.hiOff){hiOff(this);}" onfocus="if (window.hiOn){hiOn(this);}">
                                 <td class="dataCell" width="25px">
-                                    <apex:inputCheckbox value="{!ar.rec_checkBox_c}" id="assetRowCheckbox2" disabled="{!IF(ar.rec.Maintenance_Price_Month__c == 0 || ar.rec.IF_Warranty__c = '鍚�', 'true', 'false')}"/>
+                                    <apex:inputCheckbox value="{!ar.rec_checkBox_c}" id="assetRowCheckbox2" disabled="{!IF(ar.rec.Maintenance_Price_Month__c == 0 || ar.rec.IF_Warranty_Service__c = '鍚�', 'true', 'false')}"/>
                                 </td>
                                 <td class="dataCell" width="25%">
                                     <apex:outputField value="{!ar.rec.name}" id="assetName"/>
@@ -1693,7 +2783,7 @@
                                     <apex:outputField value="{!ar.rec.Installation_Site__c}"/>
                                 </td> -->
                                 <td class="dataCell" width="90px" style="text-align:center">
-                                    <apex:outputField value="{!ar.rec.IF_Warranty__c}"/>
+                                    <apex:outputField value="{!ar.rec.IF_Warranty_Service__c}"/>
                                 </td>
                                  <!-- //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start -->
                                 <td class="dataCell" width="90px" style="text-align:center">
@@ -1778,6 +2868,9 @@
                         <th style="text-align: center">鐢宠鎶ヤ环閲戦</th>
                         <th style="text-align: center">鍚堝悓璁惧淇悊鎬婚</th>
                         <th style="text-align: center">鍚堝悓鎬婚噾棰�</th>
+                        <!-- 涓婇檺鍚堝悓 20230103 LY start -->
+                        <th style="text-align: center">涓婇檺閲戦</th>
+                        <!-- 涓婇檺鍚堝悓 20230103 LY end -->
                     </tr>
                     <tr>
                         <td style="text-align: center">
@@ -1788,6 +2881,7 @@
                             <apex:outputField value="{!estimate.GuidePrice_Up__c}" id="GuidePriceUp" />
                             <apex:inputHidden value="{!estimate.GuidePrice_Up__c}" id="GuidePriceUpHidden" />
                         </td>
+                        
                         <td style="text-align: center">
                             <!--<apex:inputField value="{!estimate.Request_quotation_Amount__c}" id="quotation_Amount" />-->
                             <apex:inputField value="{!estimate.Request_quotation_Amount__c}" style="ime-mode: disabled; text-align: right; width:100px" id="quotation_Amount" onchange="checkDiscount(this.value);"/>
@@ -1797,10 +2891,15 @@
                             <apex:inputHidden value="{!estimate.Asset_Repair_Sum_Price__c}" id="assetRepairSumPriceHidden" />
                         </td>
                         <td style="text-align: center">
-                            <apex:outputField value="{!estimate.Maintenance_Price__c}" id="mainteReal" />
+                            <apex:outputField value="{!estimate.Maintenance_Price__c}" id="mainteReal"/>
                             <apex:inputHidden value="{!estimate.Maintenance_Price__c}" id="mainteRealHidden"/>
                             <apex:inputHidden value="{!OldMaintenancePrice}" id="oldMainteReal"/>
                         </td>
+                        <!-- 涓婇檺鍚堝悓 20230103 LY start -->
+                        <td style="text-align: center">
+                            <apex:inputField value="{!estimate.Limit_Price_Amount__c}" style="ime-mode: disabled; text-align: right; width:100px" id="Limit_Price_Amount" />
+                        </td>
+                        <!-- 涓婇檺鍚堝悓 20230103 LY end -->
                     </tr>
                     <tr>
                         <th style="text-align: center">{!$ObjectType.Maintenance_Contract_Estimate__c.fields.Service_discount_Rate__c.label}</th>
@@ -1970,9 +3069,12 @@
                         <td>&nbsp;</td>
                         <td width="30px">&nbsp;</td>
                         <!-- <td><apex:commandButton id="savebtn" action="{!save}" value="{!$Label.Save_Button}" disabled="{!SaveBtnDisabled}" rerender="allForm" onclick="if (!onclickCheckchangedAfterPrint('true','true')) return false;" oncomplete="unblockUI();"/></td> -->
-                        <td><apex:commandButton id="savebtn" action="{!save}" value="{!$Label.Save_Button}" disabled="{!SaveBtnDisabled}" rerender="allForm" onclick="if (!EGFlgconfim()) return false;" oncomplete="unblockUI();"/></td>
-                        
-                        <td width="200px"><apex:commandButton id="approvalbtn" action="{!approvalProcess}" value="鎻愪氦寰呭鎵�" disabled="{!ApprovalBtnDisabled}" rerender="allForm" onclick="if (!KindsAndMonths()) return false;if (!EGFlgconfim()) return false;approvalJs();" oncomplete="unblockUI();"/>
+                        <!-- 鏁呴殰淇悊璐�  娣诲姞鎻愪氦淇悊鍑忎环鎸夐挳  disabled="true" -->
+                        <td><apex:commandButton id="emailSend" action="{!sendEmail}" value="鎻愪氦RC璇勪及" rerender="allForm" disabled="{!SendEmailBtnDisabled}" onclick="if (!EGFlgconfim()) return false;" oncomplete="unblockUI();"/></td>
+                        <td>
+                            <apex:commandButton id="approvalbtn1" action="{!toApprovalProcess}" value="鎻愪氦淇悊鍑忎环瀹℃壒" disabled="{!ApprovalBtnNewDisabled}" />
+                        </td>
+                        <td width="200px"><apex:commandButton id="approvalbtn" action="{!approvalProcess}" value="鎻愪氦寰呭鎵�" disabled="{!ApprovalBtnDisabled}" rerender="allForm" onclick="if (!KindsAndMonths()) return false;if (!EGFlgconfim()) return false;approvalJs();" oncomplete="unblockUI();toApprovalProcess();"/>
                         <!-- HWAG-B399Q8 2018/08/20 鏂板璇锋彁浜ゅ緟瀹℃壒 鎻愮ず瀛楁 start-->
                         &nbsp; <apex:outputText style="color:red;font-size:20px;" value="璇锋彁浜ゅ緟瀹℃壒" rendered="{!IS_Clone_After_Decide}"/>
                         <!-- HWAG-B399Q8 2018/08/20 鏂板璇锋彁浜ゅ緟瀹℃壒 鎻愮ず瀛楁 end-->
@@ -1986,6 +3088,9 @@
                         <td><apex:outputField value="{!estimate.Contract_End_Date__c}" id="contractenddate"/></td>
                         <td>&nbsp;</td>
                         <td><apex:commandButton id="decidebtn" value="{!$Label.QuoteDecision_Button}" disabled="{!DecideBtnDisabled}" onclick="decideJs(); return false;"/></td>
+                           <td>  <apex:commandButton id="savebtn" action="{!save}" value="{!$Label.Save_Button}" disabled="{!SaveBtnDisabled}" rerender="allForm" onclick="if (!EGFlgconfim()) return false;" oncomplete="unblockUI();"/>
+                        </td>
+                        <!-- <td><apex:commandButton id="decidebtn1" value="{!$Label.QuoteDecision_Button}" action="{!dosomething}"/></td> -->
                         <td style="text-align:right"><apex:commandButton id="undecidebtn" action="{!undecide}" value="鍙栨秷{!$Label.QuoteDecision_Button}" disabled="{!UnDecideBtnDisabled}" rerender="allForm" onclick="blockme();" oncomplete="unblockUI();"/></td>
                     </tr>
                 </table>
@@ -2140,7 +3245,7 @@
         // xud 20140529 銇撱亾銇槑绱板鏇村垽鏂�
         // xudan 20150729 銈姐兗銉堥爡鐩伀Id銈掕拷鍔�
         var sql = "SELECT Id, Asset__c, Asset__r.SerialNumber, Check_Result__c, Product_Manual__c,"
-                + " Repair_Price__c, Comment__c, Maintenance_Contract_Estimate__r.Maintenance_Price__c"
+                + " Repair_Price__c, Comment__c, Maintenance_Contract_Estimate__r.Maintenance_Price__c,Third_Party_Return__c"
                 + "  FROM Maintenance_Contract_Asset_Estimate__c"
                 + " WHERE Maintenance_Contract_Estimate__c = '{!targetEstimateId}'"
                 + " ORDER BY id,Asset__c,Product_Manual__c, Asset__r.SerialNumber, Asset__r.Name, Asset__r.Department_Name__c, Asset__r.InstallDate";
diff --git a/sfdx-project.json b/sfdx-project.json
index 58d8c31..4f2aa17 100644
--- a/sfdx-project.json
+++ b/sfdx-project.json
@@ -7,6 +7,6 @@
   ],
   "name": "Stagefull_olympus",
   "namespace": "",
-  "sfdcLoginUrl": "https://login.salesforce.com",
+  "sfdcLoginUrl": "https://test.salesforce.com",
   "sourceApiVersion": "52.0"
 }

--
Gitblit v1.9.1