From 083202a12647b4f1f8545b8e7bc423bc035786a2 Mon Sep 17 00:00:00 2001
From: 黄千龙 <huangqianlong@prec-tech.com>
Date: 星期二, 28 三月 2023 10:19:06 +0800
Subject: [PATCH] 上限合同VM

---
 force-app/main/default/classes/SelectAssetEstimateVMController.cls |  227 ++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 153 insertions(+), 74 deletions(-)

diff --git a/force-app/main/default/classes/SelectAssetEstimateVMController.cls b/force-app/main/default/classes/SelectAssetEstimateVMController.cls
index bff4d41..a471cb2 100644
--- a/force-app/main/default/classes/SelectAssetEstimateVMController.cls
+++ b/force-app/main/default/classes/SelectAssetEstimateVMController.cls
@@ -18,6 +18,11 @@
     public Boolean printAgent { get; private set; }
     public boolean inDicideFlag {get; set;}                         //浣滀负琛ュ厖锛屽搴旀姤浠峰喅瀹氫箣鍚庯紝鍗存湭鑳借鍚堝悓璧锋鏃ユ湡浼犻�掔粰鍚堝悓鐨勯棶棰�
     public String isPaymentSet {get; set;}
+    // 鎶ヤ环瑙勫垯鏀瑰杽 20230309 start 
+    // public Boolean Is_Blank_period {get; set;}
+    // public String Cost_rate_ForecastF{get;set;}
+    // public String PastContractendday{get;set;}
+    // 鎶ヤ环瑙勫垯鏀瑰杽 20230309 end 
     //public String PaymentSet {get;set;}
     // 寮曟暟銇偟銉笺儞銈瑰绱勩伄鎯呭牨銈掓牸绱嶃仚銈嬨��
     public Maintenance_Contract__c contract { get; private set; }
@@ -132,7 +137,7 @@
     public Decimal Denominator {get; set; }
     public Decimal Accrued {get; set; }
     public String ProductModel{get;set;}
-    // public String Category{get;set;}
+    public String Category{get;set;}
     public Decimal Consumption_rate_Gurante{get;set;}
 
 
@@ -392,9 +397,9 @@
                       //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,CurrentContract_F_asset__r.Maintenance_Price_Year__c,'
-                      +'CurrentContract_F_asset__r.IS_VMContract_Asset__c,'
-                      +'CurrentContract_F__r.endDateGurantee__c,'
+                      // +'CurrentContract_F_asset__r.Asset_Consumption_Rate__c,Product2.Category4__c,Product2.Asset_Model_No__c,CurrentContract_F_asset__r.Maintenance_Price_Year__c,'
+                      // +'CurrentContract_F_asset__r.IS_VMContract_Asset__c,'
+                      // +'CurrentContract_F__r.endDateGurantee__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 + '\' ';
@@ -827,7 +832,10 @@
                          , 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 //杩囧幓鍚堝悓缁撴潫鏃�
+                         // 鎶ヤ环瑙勫垯鏀瑰杽20230314 start
+                        // , Maintenance_Contract__r.Past_Contract_end_day__c //杩囧幓鍚堝悓缁撴潫鏃�
+                        // ,renewTen_OFF__c
+                         // 鎶ヤ环瑙勫垯鏀瑰杽20230314 end
                         //LJPH-C9SCX7 銆愬鎵樸�戝悎鍚屾棤绌虹櫧鏈熺殑鎻愰啋  lt  20211221  end
                         // URF闄愭鍚堝悓2鏈� LY 20220811 start
                         ,URF_P_MaxRepairCount__c,URF_V_MaxRepairCount__c
@@ -1030,14 +1038,18 @@
                             , URF_Maintenance_Contract__r.Management_Code__c
                             , URF_Maintenance_Contract__r.Contract_End_Date__c
                             //URF闄愭鍚堝悓2鏈� LY 20220811 end
-
+                            // 鎶ヤ环瑙勫垯鏀瑰杽 20230315 start
+                            // ,IS_StandardPricing__c
+                            // 鎶ヤ环瑙勫垯鏀瑰杽 20230315 end
                             //澶氬勾淇濊澶囩画绛捐绠楅�昏緫璋冩暣 2023/1/17 start
-                            ,CurrentContract_F_asset__r.Asset_Consumption_Rate__c
-                            ,CurrentContract_F_asset__r.Maintenance_Price_Year__c
-                            ,CurrentContract_F_asset__r.IS_VMContract_Asset__c
-                            ,Product2.Asset_Model_No__c
-                            ,Product2.Category4__c
-                            ,CurrentContract_F__r.endDateGurantee__c
+                            // ,CurrentContract_F_asset__r.Asset_Consumption_Rate__c
+                            // ,CurrentContract_F_asset__r.Maintenance_Price_Year__c
+                            // ,CurrentContract_F_asset__r.IS_VMContract_Asset__c
+                            // ,Product2.Asset_Model_No__c
+                            // ,Product2.Category4__c
+                            // ,CurrentContract_F__r.endDateGurantee__c
+                            //娣诲姞鏄惁鏈嶅姟澶氬勾淇濅慨锛屽骞翠繚缁翠慨鏈熻嚦
+                            // ,IS_Extend_Gurantee__c,Extend_Gurantee_DateTo__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
@@ -1063,7 +1075,17 @@
             }else{
                 this.isLimitPrice = false;
             }
-        // 涓婇檺鍚堝悓 hql 20230216 start
+        // 涓婇檺鍚堝悓 hql 20230216 end
+        // 鎶ヤ环瑙勫垯鏀瑰杽 20230309 start 
+            // Maintenance_Contract__c mc1 = [SELECT id,Is_Blank_period__c,Cost_rate_ForecastF__c FROM Maintenance_Contract__c  WHERE Id =: this.targetMaintenanceContractId];
+            // Boolean IsBlankperiod = mc1.Is_Blank_period__c;
+            // this.Cost_rate_ForecastF = mc1.Cost_rate_ForecastF__c;
+            // if(IsBlankperiod){
+            //     this.Is_Blank_period = true;
+            // }else{
+            //     this.Is_Blank_period = false;
+            // }
+        // 鎶ヤ环瑙勫垯鏀瑰杽 20230309 end 
         // 閬告姙娓堛伩銇磵鍏ユ鍣ㄦ儏鍫便倰鍙栧緱
         Map<Id, Integer> selectedAssetIds = new Map<Id, Integer>();
         List<Maintenance_Contract_Asset_Estimate__c> selectedMcaes = new List<Maintenance_Contract_Asset_Estimate__c>();
@@ -1077,12 +1099,12 @@
                 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.CurrentContract_F_asset__r.IS_VMContract_Asset__c,
-                Asset__r.CurrentContract_F_asset__r.Maintenance_Price_Year__c,
-                Asset__r.Product2.Asset_Model_No__c,
-                Asset__r.Product2.Category4__c,
-                Asset__r.CurrentContract_F__r.endDateGurantee__c,
+                // Asset__r.CurrentContract_F_asset__r.Asset_Consumption_Rate__c,
+                // Asset__r.CurrentContract_F_asset__r.IS_VMContract_Asset__c,
+                // Asset__r.CurrentContract_F_asset__r.Maintenance_Price_Year__c,
+                // Asset__r.Product2.Asset_Model_No__c,
+                // Asset__r.Product2.Category4__c,
+                // Asset__r.CurrentContract_F__r.endDateGurantee__c,
                 //澶氬勾淇濊澶囩画绛捐绠楅�昏緫璋冩暣 2022/1/18 end
                 Asset__r.CurrentContract_F__r.First_Estimate_Date__c,
                 Asset__r.CurrentContract_F__r.Contract_Consumption_rate__c,
@@ -1202,7 +1224,7 @@
                                                                 Asset__r.EquipmentGuaranteeFlg__c,
                                                                 //2021-11-30 fy add LJPH-C8W8FV 缃《 start
                                                                 Asset__r.OwnershipMachine_No__c,
-                                                                Product_Manual__r.Category4__c,
+                                                                // Product_Manual__r.Category4__c,
                                                                 //2021-11-30 fy add LJPH-C8W8FV 缃《 end
                                                                 Asset_Consumption_rate__c,
                                                                 Asset__r.CurrentContract_F__c,
@@ -1252,7 +1274,7 @@
                                                                 Adjustment_Lower_price__c,
                                                                 Adjustment_Upper_price__c,
                                                                 // 鏈嶅姟鍚堝悓鎶ヤ环瑙勫垯鏀瑰杽 20230227 start
-                                                                IS_StandardPricing__c,
+                                                                // IS_StandardPricing__c,
                                                                 // 鏈嶅姟鍚堝悓鎶ヤ环瑙勫垯鏀瑰杽 20230227 end
                                                                 Last_inspection_day__c,
                                                                 Check_Result__c,
@@ -1262,6 +1284,9 @@
                                                                 Repair_Price_Auto__c,
                                                                 Third_Party_Return__c,
                                                                  //   (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� end 
+                                                                // 鎶ヤ环瑙勫垯鏀瑰杽 20230308 start
+                                                                 // Blank_period__c,
+                                                                // 鎶ヤ环瑙勫垯鏀瑰杽 20230308 end
                                                                 Comment__c,
                                                                 Asset__r.Posting_Date__c,
                                                                 EquipmentGuaranteeFlgTxt__c,
@@ -1272,12 +1297,12 @@
                                                                 // 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
-                                                                ,Asset__r.CurrentContract_F_asset__r.Maintenance_Price_Year__c
-                                                                ,Asset__r.CurrentContract_F_asset__r.IS_VMContract_Asset__c
-                                                                ,Asset__r.CurrentContract_F__r.endDateGurantee__c
+                                                                // ,Asset__r.Product2.Asset_Model_No__c
+                                                                // ,Asset__r.Product2.Category4__c
+                                                                // ,Asset__r.CurrentContract_F_asset__r.Asset_Consumption_Rate__c
+                                                                // ,Asset__r.CurrentContract_F_asset__r.Maintenance_Price_Year__c
+                                                                // ,Asset__r.CurrentContract_F_asset__r.IS_VMContract_Asset__c
+                                                                // ,Asset__r.CurrentContract_F__r.endDateGurantee__c
                                                                 //甯傚満澶氬勾淇濅慨浠锋牸寮�鍙� 2023/01/28 end
 
                                                                 ,Estimate_List_Price_Page__c
@@ -1328,6 +1353,7 @@
         // Map<String,repair__c> assNewRepMap  = new Map<String,repair__c>();
         // assNewRepMap = getNewrep(this.assetRecords);
         datatemp = getChartData();
+        // System.debug(LoggingLevel.INFO, '*** this.assetRecords: ' + this.assetRecords);
         for (Asset ast : this.assetRecords) {
             Boolean isNew = false;
             Decimal listPrice = ast.Maintenance_Price_Month__c;
@@ -1384,7 +1410,9 @@
                 //
                 //
                 //
+                // ast.CurrentContract_End_Date__c = ast.CurrentContract_F_asset__r.IS_VMContract_Asset__c ? ast.Extend_Gurantee_DateTo__c : ast.CurrentContract_End_Date__c;
                 checkedAssets.add(new AssetInfo(checkedAssets.size(), ast, isNew, listPrice, selectedLocal,estimate));
+
             } else {
                 //update by rentongxiao 2020-09-23 start
                 if (ast.AssetMark__c == '涓绘満') {
@@ -1405,6 +1433,8 @@
                }
              */
         }
+
+            // System.debug(LoggingLevel.INFO, '*** checkedAssets: ' + checkedAssets);
         totalPage = (totalRecords / selctRecordNum) + (Math.mod(totalRecords, selctRecordNum) > 0 ? 1 : 0);
     
         system.debug('椤哄簭妫�娴�' + checkedAssets);
@@ -1431,7 +1461,7 @@
         //2021-11-30 fy add LJPH-C8W8FV 缃《 start
         List<AssetInfo> topAsset =new List<AssetInfo>();
         List<AssetInfo> otherAsset =new List<AssetInfo>();
-        
+        // System.debug(LoggingLevel.INFO, '*** 椤哄簭: ' + checkedAssets);
         for(AssetInfo ched : checkedAssets){
             system.debug('椤哄簭妫�娴�2' + ched.ProductModelNoc);
             system.debug('椤哄簭妫�娴�3' + ched.AssetModelNoc);
@@ -1456,6 +1486,7 @@
         }
         checkedAssets=NumberSort;
         //2021-11-30 fy add LJPH-C8W8FV 缃《 end
+    // System.debug(LoggingLevel.INFO, '*** checkedAssetsEND: ' + checkedAssets);
     }
     
     //
@@ -1504,12 +1535,12 @@
                             + '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,'
-                            + 'CurrentContract_F_asset__r.Maintenance_Price_Year__c,'
-                            + 'CurrentContract_F_asset__r.IS_VMContract_Asset__c,'
-                            + 'Product2.Asset_Model_No__c,'
-                            + 'Product2.Category4__c,'
-                            + 'CurrentContract_F__r.endDateGurantee__c,'
+                            // + 'CurrentContract_F_asset__r.Asset_Consumption_Rate__c,'
+                            // + 'CurrentContract_F_asset__r.Maintenance_Price_Year__c,'
+                            // + 'CurrentContract_F_asset__r.IS_VMContract_Asset__c,'
+                            // + 'Product2.Asset_Model_No__c,'
+                            // + 'Product2.Category4__c,'
+                            // + 'CurrentContract_F__r.endDateGurantee__c,'
                             //甯傚満澶氬勾淇濅环鏍煎紑鍙� end 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;
@@ -1569,7 +1600,7 @@
             //URF闄愭鍚堝悓2鏈� LY 20220811 end
             
             //甯傚満澶氬勾淇濅环鏍煎紑鍙� start DC 2023/01/17 璁惧娑堣垂鐜�
-            sqlStr += 'CurrentContract_F_asset__r.Asset_Consumption_Rate__c,CurrentContract_F_asset__r.IS_VMContract_Asset__c,CurrentContract_F_asset__r.Maintenance_Price_Year__c,Product2.Asset_Model_No__c,Product2.Category4__c,CurrentContract_F__r.endDateGurantee__c,';
+            // sqlStr += 'CurrentContract_F_asset__r.Asset_Consumption_Rate__c,CurrentContract_F_asset__r.IS_VMContract_Asset__c,CurrentContract_F_asset__r.Maintenance_Price_Year__c,Product2.Asset_Model_No__c,Product2.Category4__c,CurrentContract_F__r.endDateGurantee__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 + '\'';
@@ -1777,6 +1808,9 @@
             and Agreed_Date__c != null
             and Agreed_Date__c > :LastYearDate
             and Agreed_Date__c <= :today
+            // DB202302544421 LHJ add 
+            and Status2__c !='00.鍒犻櫎' 
+            and Status2__c !='00.鍙栨秷'
             group by Delivered_Product__c
         ];
         List<AggregateResult> SecRepairList = [
@@ -1801,6 +1835,9 @@
             and Agreed_Date__c != null
             and Agreed_Date__c <= :LastYearDate
             and Agreed_Date__c > :LastSecondYearDate
+            // DB202302544421 LHJ add 
+            and Status2__c !='00.鍒犻櫎' 
+            and Status2__c !='00.鍙栨秷'
             group by Delivered_Product__c
         ];
         // 杩囧幓3骞撮棿淇悊瀹炵哗
@@ -1826,6 +1863,9 @@
             and Agreed_Date__c != null
             and Agreed_Date__c <= :LastSecondYearDate
             and Agreed_Date__c > :LastThirdYearDate
+            // DB202302544421 LHJ add 
+            and Status2__c !='00.鍒犻櫎' 
+            and Status2__c !='00.鍙栨秷'
             group by Delivered_Product__c
         ];
         // 杩囧幓3骞翠慨鐞嗗疄缁�
@@ -1851,6 +1891,9 @@
             and Agreed_Date__c != null
             and Agreed_Date__c <= :today
             and Agreed_Date__c > :LastThirdYearDate
+            // DB202302544421 LHJ add 
+            and Status2__c !='00.鍒犻櫎' 
+            and Status2__c !='00.鍙栨秷'
             group by Delivered_Product__c
         ];
     
@@ -1992,6 +2035,9 @@
             and Agreed_Date__c != null
             and Agreed_Date__c > :LastYearDate
             and Agreed_Date__c <= :today
+            // DB202302544421 LHJ add 
+            and Status2__c !='00.鍒犻櫎' 
+            and Status2__c !='00.鍙栨秷'
             group by Delivered_Product__c
         ];
         List<AggregateResult> SecRepairList = [
@@ -2016,6 +2062,9 @@
             and Agreed_Date__c != null
             and Agreed_Date__c <= :LastYearDate
             and Agreed_Date__c > :LastSecondYearDate
+            // DB202302544421 LHJ add 
+            and Status2__c !='00.鍒犻櫎' 
+            and Status2__c !='00.鍙栨秷'
             group by Delivered_Product__c
         ];
         // 杩囧幓3骞撮棿淇悊瀹炵哗
@@ -2041,6 +2090,9 @@
             and Agreed_Date__c != null
             and Agreed_Date__c <= :LastSecondYearDate
             and Agreed_Date__c > :LastThirdYearDate
+            // DB202302544421 LHJ add 
+            and Status2__c !='00.鍒犻櫎' 
+            and Status2__c !='00.鍙栨秷'
             group by Delivered_Product__c
         ];
         // 杩囧幓3骞翠慨鐞嗗疄缁�
@@ -2066,6 +2118,9 @@
             and Agreed_Date__c != null
             and Agreed_Date__c <= :today
             and Agreed_Date__c > :LastThirdYearDate
+            // DB202302544421 LHJ add 
+            and Status2__c !='00.鍒犻櫎' 
+            and Status2__c !='00.鍙栨秷'
             group by Delivered_Product__c
         ];
         // 杩囧幓1骞撮棿
@@ -3523,6 +3578,9 @@
                 if (newValue.size() > 0) insert newValue;
             }
             // 鈶� start
+            // 鎶ヤ环瑙勫垯鏀瑰杽 20230309 start 
+            // this.contract.Is_Blank_period__c = this.Is_Blank_period;
+            // 鎶ヤ环瑙勫垯鏀瑰杽 20230309 end 
             this.contract.Estimation_Id__c = this.targetEstimateId;     
             this.contract.Contract_Esti_Start_Date__c = this.estimate.Contract_Esti_Start_Date__c;
             this.contract.Contract_Range__c = this.estimate.Contract_Range__c;
@@ -3898,23 +3956,23 @@
                 //2.涓�骞翠互涓婄殑鍚堝悓锛屽湪缁撴潫鍓�6涓湀寮�濮嬪彲浠ュ紑鏀剧画绛炬姤浠枫��
                 //3.绠$悊鍛樿烦杩囷紝
                 //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') {
+                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;
-                //     // 鍙紑濮嬫姤浠风殑鏈堟暟闄愬埗
-                //     if (input.rec.CurrentContract_F__r.Contract_Range__c >= 12 && monthCon > 6) {
-                //         input.rec.Name.addError(input.rec.Name + '(' + input.rec.SerialNumber + ') -- 鍚堝悓缁撴潫鍓�6涓湀寮�濮嬪彲浠ュ埗浣滄姤浠枫��');
-                //         rtn = false;
-                //     }
-                //     //ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '---' + monthCon  + ' +++ ' + Math.floor(input.rec.CurrentContract_F__r.Contract_Range__c/2)));
-                //     //rtn = false;
-                //     if (input.rec.CurrentContract_F__r.Contract_Range__c < 12 && monthCon > Math.floor(input.rec.CurrentContract_F__r.Contract_Range__c / 2)) {
-                //         input.rec.Name.addError(input.rec.Name + '(' + input.rec.SerialNumber + ') -- 缁忓巻鏈堟暟杩囧崐鏂瑰彲鍒朵綔鎶ヤ环');
-                //         rtn = false;
-                //     }
-                // }
+                    Integer noOfDays = today.daysBetween(input.rec.CurrentContract_F__r.Contract_End_Date__c);
+                    Decimal monthCon = (Decimal)noOfDays / 365 * 12;
+                    // 鍙紑濮嬫姤浠风殑鏈堟暟闄愬埗
+                    if (input.rec.CurrentContract_F__r.Contract_Range__c >= 12 && monthCon > 6) {
+                        input.rec.Name.addError(input.rec.Name + '(' + input.rec.SerialNumber + ') -- 鍚堝悓缁撴潫鍓�6涓湀寮�濮嬪彲浠ュ埗浣滄姤浠枫��');
+                        rtn = false;
+                    }
+                    //ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '---' + monthCon  + ' +++ ' + Math.floor(input.rec.CurrentContract_F__r.Contract_Range__c/2)));
+                    //rtn = false;
+                    if (input.rec.CurrentContract_F__r.Contract_Range__c < 12 && monthCon > Math.floor(input.rec.CurrentContract_F__r.Contract_Range__c / 2)) {
+                        input.rec.Name.addError(input.rec.Name + '(' + input.rec.SerialNumber + ') -- 缁忓巻鏈堟暟杩囧崐鏂瑰彲鍒朵綔鎶ヤ环');
+                        rtn = false;
+                    }
+                }
         // 澶氬勾淇濆垽鏂�
         if ( String.isNotBlank(input.rec.CurrentContract_F__c) && input.rec.CurrentContract_F__r.RecordType_DeveloperName__c == 'VM_Contract') {
             //if (UserInfo.getProfileId() != System.Label.ProfileId_SystemAdmin && String.isNotBlank(input.rec.CurrentContract_F__c) && input.rec.CurrentContract_F__r.RecordType_DeveloperName__c == 'VM_Contract') {
@@ -3926,14 +3984,14 @@
 
             //甯傚満澶氬勾淇濅慨浠锋牸寮�鍙� DC 2023/02/02 Start  缁撴潫鏃ョ┖鐧芥湡澶т簬6涓湀 鎶ラ敊鎻愮ず
 
-            Date endDate6Month = input.rec.CurrentContract_F_asset__r.endDateGurantee_Text__c.addMonths(6);
-            Date cotractEndDay = input.rec.CurrentContract_F__r.endDateGurantee__c;
+            // Date endDate6Month = input.rec.CurrentContract_F_asset__r.endDateGurantee_Text__c.addMonths(6);
+            // Date cotractEndDay = input.rec.CurrentContract_F__r.endDateGurantee__c;
 
 
-            if(today>endDate6Month && cotractEndDay <today){
-                input.rec.Name.addError(input.rec.Name + '(' + input.rec.SerialNumber + ') -- 寤鸿绌虹櫧鏈熸帶鍒跺湪1涓湀浠ュ唴锛屽涓嶅緱宸辩┖鐧芥湡鍦�6涓湀浠ヤ笂锛岃鍏堣仈缁滄湇鍔$鐞嗛儴璇勪及銆�');
+            // if(today>endDate6Month && cotractEndDay <today){
+            //     input.rec.Name.addError(input.rec.Name + '(' + input.rec.SerialNumber + ') -- 甯傚満澶氬勾淇濈粨鏉熷凡瓒呰繃6涓湀锛岀敱浜庣┖鐧芥湡杩囬暱锛岃鍏堣仈绯绘湇鍔$鐞嗛儴璇勪及銆�');
 
-            }
+            // }
 
             //甯傚満澶氬勾淇濅慨浠锋牸寮�鍙� DC 2023/02/02 end
 
@@ -3943,18 +4001,18 @@
             // 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 + ') -- 娌℃湁缁鎶ヤ环鏉冮檺锛屾垨鑰呰繕娌″埌缁鏃堕棿銆�');
-            //     }
-            //     System.debug(LoggingLevel.INFO, '*** this.contract.Open_RenewalQuotation__c: ' + this.contract.Open_RenewalQuotation__c);
-            //     System.debug(LoggingLevel.INFO, '*** : input.rec.CurrentContract_F__r.VM_Contract_Check__c' + input.rec.CurrentContract_F__r.VM_Contract_Check__c);
-            //     System.debug(LoggingLevel.INFO, '*** monthCon: ' + monthCon);
-            //     //input.rec.Name.addError(input.rec.Name + '(' + input.rec.SerialNumber + ') -- 娌℃湁缁鎶ヤ环鏉冮檺锛屾垨鑰呰繕娌″埌缁鏃堕棿銆�');
-            //     rtn = false;
-            // }
+            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 + ') -- 娌℃湁缁鎶ヤ环鏉冮檺锛屾垨鑰呰繕娌″埌缁鏃堕棿銆�');
+                }
+                // System.debug(LoggingLevel.INFO, '*** this.contract.Open_RenewalQuotation__c: ' + this.contract.Open_RenewalQuotation__c);
+                // System.debug(LoggingLevel.INFO, '*** : input.rec.CurrentContract_F__r.VM_Contract_Check__c' + input.rec.CurrentContract_F__r.VM_Contract_Check__c);
+                // System.debug(LoggingLevel.INFO, '*** monthCon: ' + monthCon);
+                //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;
@@ -4111,7 +4169,7 @@
     public class AssetInfo {
     // 鏂板悎鍚屽鍝佺‘淇濇彁渚� 褰撳墠鏍囪
     public Boolean etGFlg {get; set;}
-    public String ISStandardPricing{get; set;}
+    // public String ISStandardPricing{get; set;}
     public Integer lineNo {get; private set;}
     public Decimal Repair_Price_Auto {get; set;}
     public String Agreed_Date{get; set;}
@@ -4122,6 +4180,7 @@
     public Maintenance_Contract_Estimate__c estimate {get; set;}
     public Transient Decimal orgPrice {get; private set;}
     public Transient Decimal orgPrice12 {get; private set;}
+    // public String Blank_period {get;  set;}
     // add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� Star
     public Boolean CheckRows {get; private set;}
     // add by fxk 2021/9/9 鎺у埗鐐规瀵硅薄鏄惁鍙�� End
@@ -4143,7 +4202,7 @@
     public String MDMModelNoc;
     //2021-11-30 fy add LJPH-C8W8FV 缃《 end
     //甯傚満澶氬勾淇� 浠锋牸寮�鍙� start 2023/01/17
-    public String Category;
+    // public String Category;
     //甯傚満澶氬勾淇� 浠锋牸寮�鍙� end 2023/01/17
     public Id getRecId() {
         Id rtn = null;
@@ -4178,9 +4237,16 @@
     public AssetInfo(Integer lineNo, Asset record, Boolean isNew, Decimal listPrice, Maintenance_Contract_Asset_Estimate__c mcae,Maintenance_Contract_Estimate__c estimate) {
         this.lineNo = lineNo;
         this.rec = record;
-        this.ISStandardPricing = mcae.IS_StandardPricing__c;
+        // this.rec.CurrentContract_End_Date__c = record.CurrentContract_End_Date__c;
+        // this.rec.CurrentContract_End_Date__c = record.IS_Extend_Gurantee__c ? record.Extend_Gurantee_DateTo__c : record.CurrentContract_End_Date__c;
+        // this.ISStandardPricing = record.IS_StandardPricing__c;
         this.estimate = new Maintenance_Contract_Estimate__c();
         this.estimate.IS_Reduced_price_approval__c = estimate.IS_Reduced_price_approval__c;
+         // 鎶ヤ环瑙勫垯鏀瑰杽 20230308 start
+        // this.estimate.Contract_Esti_Start_Date__c = estimate.Contract_Esti_Start_Date__c;
+        // this.estimate.renewTen_OFF__c = estimate.renewTen_OFF__c;
+         // 鎶ヤ环瑙勫垯鏀瑰杽 20230308 end
+
         //   (2022骞�12鏈堜笂绾�)鏁呴殰鍝佸姞璐� start
         // if (record.Asset_situation__c == '淇悊涓�' && record.Return_Without_Repair__r.Agreed_Date__c!=null) {
         //     this.Agreed_Date = '涓嶄负绌�';
@@ -4209,6 +4275,9 @@
             Check_Result__c = mcae.Check_Result__c,
             Repair_Price__c = mcae.Repair_Price__c,
             Repair_Price_pass__c = mcae.Repair_Price_pass__c,
+            // 鎶ヤ环瑙勫垯鏀瑰杽 20230308 start
+            // Blank_period__c = mcae.Blank_period__c,           
+            // 鎶ヤ环瑙勫垯鏀瑰杽 20230308 end
             Comment__c = mcae.Comment__c,
             EquipmentGuaranteeFlgTxt__c = mcae.EquipmentGuaranteeFlgTxt__c,
             Estimate_Cost__c = mcae.Estimate_Cost__c,
@@ -4232,6 +4301,17 @@
                 this.mcae.Repair_Price_pass__c = this.mcae.Repair_Price__c;
             }
         }
+         // 鎶ヤ环瑙勫垯鏀瑰杽 20230308 start
+            // if (this.estimate.Contract_Esti_Start_Date__c!=null  && this.rec.CurrentContract_End_Date__c != null) {
+            //        this.mcae.Blank_period__c = String.valueof(this.rec.CurrentContract_End_Date__c.daysbetween(this.estimate.Contract_Esti_Start_Date__c));
+            // } 
+            // if (this.estimate.Contract_Esti_Start_Date__c==null && this.rec.CurrentContract_End_Date__c != null) {
+            //        this.mcae.Blank_period__c = String.valueof(this.rec.CurrentContract_End_Date__c.daysbetween(system.today()));   
+            // }
+            // if (this.mcae.Blank_period__c!=null&&integer.valueOf(this.mcae.Blank_period__c)<15 ) {
+            //         this.mcae.Blank_period__c = '鏃犵紳缁';
+            // }      
+        // 鎶ヤ环瑙勫垯鏀瑰杽 20230308 end
         this.isManual = false;
         this.rec_checkBox_c = true;
         this.orgPrice = record.Maintenance_Price_Month__c;
@@ -4249,7 +4329,7 @@
         //add by rentx 2020-11-12 LJPH-BV93RZ end
 
         //甯傚満澶氬勾淇� 浠锋牸寮�鍙� start 2023/01/17
-        this.Category = mcae.Product_Manual__r.Category4__c;
+        // this.Category = mcae.Product_Manual__r.Category4__c;
         //甯傚満澶氬勾淇� 浠锋牸寮�鍙� end 2023/01/17
 
         //add by mzy 2021-02-07 start
@@ -4262,7 +4342,6 @@
     public AssetInfo(Integer lineNo, Maintenance_Contract_Asset_Estimate__c mcae) {
         this.lineNo = lineNo;
         this.rec = null;
-        this.ISStandardPricing = mcae.IS_StandardPricing__c;
         this.mcae = new Maintenance_Contract_Asset_Estimate__c(
             //                id = mcae.Id,             // 鏈綋銇亜銈夈仾銇勩伄锛� 銈汇儍銉堛仐銇熴倝銆佹柊瑕忔ī闄愩亴銇亸銇с倐銆佹洿鏂般仹銇嶃伨銇欍�傚緦钘ゃ仌銈撱伀纰鸿獚銇椼仧銆併仾銇忋仹銈傘亜銇勩仹銇欍��
             isNew__c = mcae.IsNew__c,
@@ -4308,7 +4387,7 @@
         //2021-11-30 fy add LJPH-C8W8FV 缃《 end
 
         //甯傚満澶氬勾淇� 浠锋牸寮�鍙� start 2023/01/17
-        this.Category = mcae.Product_Manual__r.Category4__c;
+        // this.Category = mcae.Product_Manual__r.Category4__c;
         //甯傚満澶氬勾淇� 浠锋牸寮�鍙� end 2023/01/17
     }
     

--
Gitblit v1.9.1