111
沙世明
2022-11-22 928399eceec50e3d37ea08669a12789a9410a9d2
force-app/main/default/classes/SelectAssetEstimateURFController.cls
@@ -76,7 +76,7 @@
    // 新规 或者 copy
    private Boolean newIns = false;
    //URF限次合同2期 LY 20220811 start
    //public  Integer uRFPMaxRepairCount = 3;
    public String checkDealerId{get;set;}
    //URF限次合同2期 LY 20220811 end
    
    
@@ -252,6 +252,7 @@
                      //XLIU-CE7AVC【委托】URF限次修理合同的最高价格修改 thh 20220509 end
                      //URF限次合同2期 LY 20220811 start
                      + 'Product2.ProductURF__r.Maintenance_Price_Year_URF_3__c, Product2.ProductURF__r.Maintenance_Price_Year_URF_Max_3__c, Product2.ProductURF__r.UFR_Maintenance_Price_Month_3__c,'
                      + 'URF_Maintenance_Contract__c,URF_Maintenance_Contract__r.Management_Code__c,URF_Maintenance_Contract__r.Contract_End_Date__c,'
                      //URF限次合同2期 LY 20220811 end
                      + 'CurrentContract_End_Date__c, Extend_Gurantee_DateTo__c,EquipmentGuaranteeFlg__c,AssetMark__c FROM Asset WHERE Product2.ProductURF__c != null AND Hospital__c = \'' + this.targetHospitalId + '\' ';
        //HWAG-BDJ43R ---XHL---20190729---
@@ -552,6 +553,932 @@
        currPage = 1;
        selRecordOption = '20';
        totalRecords = 0;
        //URF限次合同2期 LY 20220920 start
        checkDealerId = '';
        //URF限次合同2期 LY 20220920 end
        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 ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
        i ++;
    }
    /**
     * Visaulforceから呼ばれるコンストラクタ
@@ -598,7 +1525,12 @@
                         , 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
                        // URF限次合同2期 LY 20220811 start
                        ,Is_RecognitionModel__c
                        ,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
                         FROM Maintenance_Contract_Estimate__c WHERE Id = :this.targetEstimateId];
        //HWAG-B399Q8 2018/08/20  添加一额外字段 IS_Clone_After_Decide__c end
@@ -698,9 +1630,6 @@
            this.estimate.Contract_Start_Date__c = systemToday;
            this.setContractInfo(this.targetMaintenanceContractId);
            this.newIns = true;
            //URF限次合同2期 LY 20220811 start
           //this.estimate.URF_P_MaxRepairCount__c = uRFPMaxRepairCount;// URF-P最大大修次数
           //URF限次合同2期 LY 20220811 end
        }
        // 何もなければ、念のため
        else {
@@ -738,6 +1667,9 @@
                            , Product2.ProductURF__r.Maintenance_Price_Year_URF_3__c
                            , Product2.ProductURF__r.Maintenance_Price_Year_URF_Max_3__c
                            , Product2.ProductURF__r.UFR_Maintenance_Price_Month_3__c
                            , URF_Maintenance_Contract__c
                            , URF_Maintenance_Contract__r.Management_Code__c
                            , URF_Maintenance_Contract__r.Contract_End_Date__c
                            //URF限次合同2期 LY 20220811 end
                            FROM Asset WHERE Hospital__c = :this.targetHospitalId AND ( AssetMark__c != '耗材' OR Product2.Family != 'ET' ) ORDER BY ID, IF_Warranty__c asc];
            //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start
@@ -790,6 +1722,9 @@
                , Asset__r.Product2.ProductURF__r.Maintenance_Price_Year_URF_3__c
                , Asset__r.Product2.ProductURF__r.Maintenance_Price_Year_URF_Max_3__c
                , Asset__r.Product2.ProductURF__r.UFR_Maintenance_Price_Month_3__c
                , 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
                from Maintenance_Contract_Asset__c
                where Maintenance_Contract__c = :this.targetMaintenanceContractId AND Asset__r.Product2.ProductURF__c != null
@@ -827,7 +1762,10 @@
                    // add点检改善:新增一个点检对象复选框字段,默认为true 2021.6.8 fxk End
                    // 20210315 gzw 追加限次产品信息 start
                    // listPrice = mca.Asset__r.Maintenance_Price_Month__c * isNewPriceAdj;
                    listPrice = mca.Asset__r.Product2.ProductURF__r.UFR_Maintenance_Price_Month__c  * isNewPriceAdj;
                    // listPrice = mca.Asset__r.Product2.ProductURF__r.UFR_Maintenance_Price_Month__c  * isNewPriceAdj;
                    listPrice = mca.Asset__r.Product2.ProductURF__r.UFR_Maintenance_Price_Month_3__c  * isNewPriceAdj;
                    // 20210315 gzw 追加限次产品信息 end
    
                }
@@ -908,6 +1846,9 @@
                                                                Asset__r.Product2.ProductURF__r.Maintenance_Price_Year_URF_3__c,
                                                                Asset__r.Product2.ProductURF__r.Maintenance_Price_Year_URF_Max_3__c,
                                                                Asset__r.Product2.ProductURF__r.UFR_Maintenance_Price_Month_3__c,
                                                                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
                                                                URF_Series__c,
                                                                Series_RepairCount__c,
@@ -961,7 +1902,13 @@
                                //mcae.Estimate_List_Price__c = mcae.Asset__r.Product2.ProductURF__r.UFR_Maintenance_Price_Month__c * isNewPriceAdj;
                                // mcae.Estimate_List_Price__c = mcae.Asset__r.Maintenance_Price_Month__c * isNewPriceAdj;
                                //URF限次合同2期 LY 20220811 start
                                mcae.Estimate_List_Price__c = mcae.Asset__r.Product2.ProductURF__r.UFR_Maintenance_Price_Month_3__c * isNewPriceAdj;
                                // if (Integer.valueOf(this.estimate.URF_V_MaxRepairCount__c)==2){
                                //    mcae.Estimate_List_Price__c = mcae.Asset__r.Product2.ProductURF__r.UFR_Maintenance_Price_Month__c * isNewPriceAdj;
                                // }else{
                                   mcae.Estimate_List_Price__c = mcae.Asset__r.Product2.ProductURF__r.UFR_Maintenance_Price_Month_3__c * isNewPriceAdj;
                                // }
                                //URF限次合同2期 LY 20220811 end
                            }
                        } else {
@@ -970,7 +1917,12 @@
                                //mcae.Estimate_List_Price__c = mcae.Asset__r.Product2.ProductURF__r.UFR_Maintenance_Price_Month__c;
                                // mcae.Estimate_List_Price__c = mcae.Asset__r.Maintenance_Price_Month__c;
                                //URF限次合同2期 LY 20220811 start
                                mcae.Estimate_List_Price__c = mcae.Asset__r.Product2.ProductURF__r.UFR_Maintenance_Price_Month_3__c;
                                // if (Integer.valueOf(this.estimate.URF_V_MaxRepairCount__c)==2){
                                //    mcae.Estimate_List_Price__c = mcae.Asset__r.Product2.ProductURF__r.UFR_Maintenance_Price_Month__c;
                                // }else{
                                   mcae.Estimate_List_Price__c = mcae.Asset__r.Product2.ProductURF__r.UFR_Maintenance_Price_Month_3__c;
                                // }
                                //URF限次合同2期 LY 20220811 end
                            }
    
@@ -980,7 +1932,12 @@
                        if (String.isNotBlank(mcae.Product_Manual__r.ProductURF__c)) {
                           //URF限次合同2期 LY 20220811 start
                            //mcae.Estimate_List_Price__c = mcae.Product_Manual__r.ProductURF__r.UFR_Maintenance_Price_Month__c * isNewPriceAdj;
                           mcae.Estimate_List_Price__c = mcae.Product_Manual__r.ProductURF__r.UFR_Maintenance_Price_Month_3__c * isNewPriceAdj;
                           // if (Integer.valueOf(this.estimate.URF_V_MaxRepairCount__c)==2){
                           //    mcae.Estimate_List_Price__c = mcae.Product_Manual__r.ProductURF__r.UFR_Maintenance_Price_Month__c * isNewPriceAdj;
                           // }else{
                              mcae.Estimate_List_Price__c = mcae.Product_Manual__r.ProductURF__r.UFR_Maintenance_Price_Month_3__c * isNewPriceAdj;
                           // }
                           //URF限次合同2期 LY 20220811 end
                        }
                    }
@@ -1030,7 +1987,13 @@
            // Decimal listPrice = ast.Maintenance_Price_Month__c;
            //Decimal listPrice = ast.Product2.ProductURF__r.UFR_Maintenance_Price_Month__c;
            //URF限次合同2期 LY 20220811 start
            Decimal listPrice = ast.Product2.ProductURF__r.UFR_Maintenance_Price_Month_3__c;
            // Decimal listPrice =0;
            // if (Integer.valueOf(this.estimate.URF_V_MaxRepairCount__c)==2){
            //    listPrice = ast.Product2.ProductURF__r.UFR_Maintenance_Price_Month__c;
            // }else{
               Decimal listPrice = ast.Product2.ProductURF__r.UFR_Maintenance_Price_Month_3__c;
            // }
            //URF限次合同2期 LY 20220811 end
            if (selectedAssetIds.containsKey(ast.Id)) {
                Maintenance_Contract_Asset_Estimate__c selectedLocal = selectedMcaes.get(selectedAssetIds.get(ast.Id));
@@ -1202,6 +2165,7 @@
                            //XLIU-CE7AVC【委托】URF限次修理合同的最高价格修改 thh 20220509 end
                            //URF限次合同2期 LY 20220811 start
                            + 'Product2.ProductURF__r.Maintenance_Price_Year_URF_3__c, Product2.ProductURF__r.Maintenance_Price_Year_URF_Max_3__c, Product2.ProductURF__r.UFR_Maintenance_Price_Month_3__c,'
                            + 'URF_Maintenance_Contract__c,URF_Maintenance_Contract__r.Management_Code__c,URF_Maintenance_Contract__r.Contract_End_Date__c,'
                            //URF限次合同2期 LY 20220811 end
                            + 'CurrentContract_F__r.Contract_Range__c,AssetMark__c FROM Asset WHERE Product2.ProductURF__c != null AND Hospital__c = \'' + this.targetHospitalId + '\' '
                            + 'AND Id NOT IN ' + notInId;
@@ -1250,6 +2214,7 @@
            sqlStr += 'Product2.ProductURF__c,Product2.ProductURF__r.URFLimitSerial__c,Product2.ProductURF__r.UFR_MaxRepairCount__c,Product2.ProductURF__r.UFR_Maintenance_Price_Month__c,';
            //URF限次合同2期 LY 20220811 start
            sqlStr += 'Product2.ProductURF__r.UFR_Maintenance_Price_Month_3__c,';
            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
            sqlStr += ' CurrentContract_F__r.Contract_Range__c,AssetMark__c FROM Asset WHERE Product2.ProductURF__c != null AND Hospital__c = \'' + this.targetHospitalId + '\'';
            //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start
@@ -1899,7 +2864,12 @@
                    }
                    //URF限次合同2期 LY 20220811 start
                    //ai.mcae.Estimate_List_Price__c = prd[0].ProductURF__r.UFR_Maintenance_Price_Month__c * isNewPriceAdj;
                    ai.mcae.Estimate_List_Price__c = prd[0].ProductURF__r.UFR_Maintenance_Price_Month_3__c * isNewPriceAdj;
                    // if (Integer.valueOf(this.estimate.URF_V_MaxRepairCount__c)==2){
                    //    ai.mcae.Estimate_List_Price__c = prd[0].ProductURF__r.UFR_Maintenance_Price_Month__c * isNewPriceAdj;
                    // }else{
                       ai.mcae.Estimate_List_Price__c = prd[0].ProductURF__r.UFR_Maintenance_Price_Month_3__c * isNewPriceAdj;
                    // }
                    //URF限次合同2期 LY 20220811 end
                    //ai.mcae.Maintenance_Price_YearTXT__c = ai.mcae.Estimate_List_Price__c * 12;
                    ai.orgPrice = prd[0].ProductURF__r.UFR_Maintenance_Price_Month__c;
@@ -1975,11 +2945,19 @@
            // Decimal listPrice = ass.rec.Maintenance_Price_Month__c;
            //URF限次合同2期 LY 20220811 start
            //Decimal listPrice = ass.rec.Product2.ProductURF__r.UFR_Maintenance_Price_Month__c;
            Decimal listPrice = ass.rec.Product2.ProductURF__r.UFR_Maintenance_Price_Month_3__c;
            // Decimal listPrice =0;
            // if (Integer.valueOf(this.estimate.URF_V_MaxRepairCount__c)==2){
            //    listPrice = ass.rec.Product2.ProductURF__r.UFR_Maintenance_Price_Month__c;
            // }else{
               Decimal listPrice = ass.rec.Product2.ProductURF__r.UFR_Maintenance_Price_Month_3__c;
            // }
            //URF限次合同2期 LY 20220811 end
            //XLIU-CE7AVC【委托】URF限次修理合同的最高价格修改 thh 20220510 start
            Decimal MaxPrice = ass.rec.Product2.ProductURF__r.Maintenance_Price_Year_URF_Max__c;
            Decimal MinPrice = ass.rec.Product2.ProductURF__r.Maintenance_Price_Year_URF__c;
            // Decimal MaxPrice = ass.rec.Product2.ProductURF__r.Maintenance_Price_Year_URF_Max__c;
            // Decimal MinPrice = ass.rec.Product2.ProductURF__r.Maintenance_Price_Year_URF__c;
            Decimal MaxPrice = ass.rec.Product2.ProductURF__r.Maintenance_Price_Year_URF_Max_3__c;
            Decimal MinPrice = ass.rec.Product2.ProductURF__r.Maintenance_Price_Year_URF_3__c;
            //XLIU-CE7AVC【委托】URF限次修理合同的最高价格修改 thh 20220510 end
            if (ass.rec_checkBox_c) {
                //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO , 'unCheckedAssets ' ));
@@ -2604,6 +3582,16 @@
            }
            // 2021-09-10 tcm 排序逻辑调整 end
    
          // URF限次合同2期 LY 20220908 排序逻辑调整 start
            List<lastMContract> urfMContractRes;
            if (isDecide) {
                system.debug('执行了tcm isDecide');
                urfMContractRes = getURFMContract(this.checkedAssets,this.estimate.Contract_Start_Date__c);
            } else{
                system.debug('执行了tcm NODecide');
                urfMContractRes = getURFMContract(this.checkedAssets,this.estimate.Contract_Esti_Start_Date__c);
            }
            // URF限次合同2期 LY 20220908 排序逻辑调整 end
            
            //XLIU-CE7AVC【委托】URF限次修理合同的最高价格修改 thh 20220509 start
            Integer Contract_year = 0;
@@ -2647,7 +3635,28 @@
    
            // 追加上期合同信息 end
    
          //URF限次合同2期 LY 20220908 start
          //追加限次合同信息
          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
    
            // 同期処理
            // ①维修合同に既存の保有设备を削除
@@ -2714,6 +3723,16 @@
            // if (true) {
            //     return false;
            // }
            //URF限次合同2期 LY 20220920 start
            //提交之后decide之前,经销商变更的话,先款信息以变更后的经销商先款信息执行 thh 20220418 start
            if(String.isNotBlank(this.estimate.Dealer__c)){
                checkDealerId = this.estimate.Dealer__c;
                onChDealerUpdate();
            }else{
                this.estimate.Is_RecognitionModel__c = false;
            }
            //提交之后decide之前,经销商变更的话,先款信息以变更后的经销商先款信息执行 thh 20220418 end
            //URF限次合同2期 LY 20220920 end
            if (String.isBlank(this.targetEstimateId)) {
                newIns = true;
                this.estimate.Process_Status__c = '草案中';
@@ -2912,6 +3931,9 @@
            this.contract.Contract_Esti_End_Date__c = this.estimate.Contract_Esti_End_Date__c;
            this.contract.Estimate_Target__c = this.estimate.Estimate_Target__c;
            this.contract.Dealer__c = this.estimate.Dealer__c;
            //URF限次合同2期 LY 20220920 start
            this.contract.old_Is_RecognitionModel__c = this.estimate.Is_RecognitionModel__c;
            //URF限次合同2期 LY 20220920 end
            this.contract.NotUse_Oxygenated_Water__c = this.estimate.NotUse_Oxygenated_Water__c;
            this.contract.Estimate_Trial_Money__c = this.estimate.Estimate_Trial_Money__c;
            this.contract.Contract_Amount__c = this.estimate.Maintenance_Price__c;
@@ -2944,6 +3966,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) {
@@ -3065,7 +4113,11 @@
        
        //URF限次合同2期 LY 20220811 start
        if (!String.isNotBlank(estimate.URF_V_MaxRepairCount__c)) {
            this.estimate.Contract_Range__c.addError('请选择URF-V最大大修次数!');
            this.estimate.URF_V_MaxRepairCount__c.addError('请选择URF-V最大大修次数!');
            return null;
        }
        if (!String.isNotBlank(estimate.URF_P_MaxRepairCount__c)) {
            this.estimate.URF_V_MaxRepairCount__c.addError('请选择URF-V最大大修次数!');
            return null;
        }
        //URF限次合同2期 LY 20220811 end
@@ -3089,6 +4141,32 @@
        }
        return ret;
    }
    //URF限次合同2期 LY 20220920 start
    //获取当前选中的经销商是否为先款标识
    public PageReference onChDealerUpdate(){
        //checkDealerId  此变量可能会存 经销商id或经销商中文名
        if(String.isNotBlank(checkDealerId)){
            try {
                List<Account> accListC = [select id,name,FirstParagraphEnd__c from Account where id = :checkDealerId OR name = :checkDealerId];
                if(accListC != null && accListC.size() == 1){
                    if(accListC[0].FirstParagraphEnd__c){
                        this.estimate.Is_RecognitionModel__c = true;
                    }else{
                        this.estimate.Is_RecognitionModel__c = false;
                    }
                }else{
                    this.estimate.Is_RecognitionModel__c = false;
                }
            } catch (Exception e) {
                //return 'McaeList Update Failed : '+e;
            }
        }else{
            this.estimate.Is_RecognitionModel__c = false;
        }
        System.debug('----------------23--'+this.estimate.Is_RecognitionModel__c);
        return null;
    }
    //URF限次合同2期 LY 20220920 end
    
    // 2021-02-07  gzw add  LJPH-BWY5QB start
    private void setEndUserType(String id) {
@@ -3623,6 +4701,49 @@
        //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() {