高章伟
2022-02-24 2aa8da8af66aa8ae00f25831aed6bb0364176e7b
force-app/main/default/classes/SelectAssetEstimateVMTcmController.cls
@@ -25,9 +25,9 @@
public Asset ass { get; set; }
// 2021、8、26 合同报价页面的优化,无保有设备点检对象选择框变黑 fxk end
// 病院配下の納入機器の情報を格納する。
private List<Asset> assetRecords;                                                       // TODO 系列病院の場合、この配列は固定できないです。
   private Transient List<Asset> assetRecords;                                               // TODO 系列病院の場合、この配列は固定できないです。
public List<AssetInfo> checkedAssets { get; set; }
private List<AssetInfo> unCheckedAssets = new List<AssetInfo>();
   private Transient List<AssetInfo> unCheckedAssets = new List<AssetInfo>();
//public List<List<AssetInfo>> checkedAssetsView { get; set; }
public List<List<AssetInfo> > unCheckedAssetsView { get; set; }
@@ -230,10 +230,11 @@
         sqlTail += assetSerialNumberList[i] + '\')';
      }
   }
      //tcm 添加 Management_Code__c  20211201 start
   String soql = 'SELECT Id, Name, Asset_situation__c, SerialNumber, Department_Name__c, Installation_Site__c, '
                 + 'Posting_Date__c,Management_Code__c,IF_Warranty__c,Reson_Can_not_Warranty__c, InstallDate,isNewDate_use__c, '
                 + 'Asset_Owner__c, Accumulation_Repair_Amount__c, Maintenance_Price_Month__c, Final_Examination_Date__c, '
                 + 'CurrentContract_F__c,CurrentContract_F__r.Maintenance_Contract_No_F__c,CurrentContract_F__r.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, '
                 + 'CurrentContract_F__r.First_Estimate_Date__c,CurrentContract_F__r.Estimate_Contract_endDate__c,'
                 + 'CurrentContract_F__r.Contract_Consumption_rate__c,CurrentContract_F__r.First_contract_usage_Rate__c,CurrentContract_F__r.Contract_Range__c,'
@@ -553,9 +554,6 @@
   //HWAG-B399Q8 2018/08/20  添加一额外字段 IS_Clone_After_Decide__c start
   this.estimate = [SELECT Id, Name, Maintenance_Contract__c, Estimation_Decision__c, CreatedDate, Service_Contract_Staff__c,
                    JingliApprovalManager__c, BuchangApprovalManager__c, ZongjianApprovalManager__c, Finally_Approved_Staff__c,
                    //LJPH-C95AQ2 ly 20211207 Start
                     JingliApprovalManager__r.Name, BuchangApprovalManager__r.Name,
                     //LJPH-C95AQ2 ly 20211207 End
                    Contract_Esti_Start_Date__c, Contract_Esti_End_Date__c, Contract_Range__c, Contract_Start_Date__c, Contract_End_Date__c,
                    Maintenance_Contract_Status__c, Discount_reason__c, Improve_ConsumptionRate_Idea__c, Process_Status__c,
                    Estimate_Trial_Money__c, Maintenance_Price__c, Department__c, PrintDate__c, Quote_Date__c, Submit_quotation_day__c,
@@ -693,9 +691,10 @@
   //HWAG-B399Q8 2018/08/20  检验是否显示'请提交待审批' end
   // 納入機器の情報を取得
   if (!String.isBlank(this.targetHospitalId) && (this.targetHospitalId.length() == 15 || this.targetHospitalId.length() == 18)) {
         //tcm 添加 Management_Code__c  20211201 start
      assetRecords = [SELECT Id, Name, Asset_situation__c, SerialNumber, Department_Name__c, Installation_Site__c, Posting_Date__c, Management_Code__c, IF_Warranty__c, Reson_Can_not_Warranty__c,
                      InstallDate, isNewDate_use__c, Asset_Owner__c, Accumulation_Repair_Amount__c, Maintenance_Price_Month__c, Final_Examination_Date__c, CurrentContract_End_Date__c, EquipmentGuaranteeFlg__c,
                      CurrentContract_F__c, CurrentContract_F__r.Maintenance_Contract_No_F__c, CurrentContract_F__r.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__c, CurrentContract_F__r.Maintenance_Contract_No_F__c,CurrentContract_F__r.Management_Code__c, CurrentContract_F__r.RecordType_DeveloperName__c, CurrentContract_F__r.Estimate_Num__c, CurrentContract_F__r.Contract_End_Date__c, CurrentContract_F__r.Estimate_Contract_endDate__c,
                      CurrentContract_F_asset__c, CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c, CurrentContract_F_asset__r.endDateGurantee_Text__c, CurrentContract_F__r.Gurantee_Estimate_startDate__c,
                      CurrentContract_F__r.First_Estimate_Date__c,
                      CurrentContract_F__r.Contract_Consumption_rate__c, CurrentContract_F__r.First_contract_usage_Rate__c,
@@ -838,6 +837,9 @@
                                                          // Gzw 20200807 五个去年合同相关,所以报价产品,获取上期合同 start
                                                          Last_MContract__c
                                                          // Gzw 20200807 五个去年合同相关,所以报价产品,获取上期合同 eng
                                                // LJPH-C9GD34 gzw fix start
                                                ,Estimate_List_Price_Page__c
                                                // LJPH-C9GD34 gzw fix end
                                                          FROM Maintenance_Contract_Asset_Estimate__c
                                                          WHERE Maintenance_Contract_Estimate__c = :this.targetEstimateId
                                                                                                   ORDER BY
@@ -1004,12 +1006,12 @@
         }
      }
      notInId += '\')';
      //tcm 添加 Management_Code__c  20211201 start
      String sqlStr = 'SELECT Id, Name, Asset_situation__c, SerialNumber, Department_Name__c, Installation_Site__c, '
                      + 'Posting_Date__c,Management_Code__c,IF_Warranty__c,Reson_Can_not_Warranty__c, InstallDate,isNewDate_use__c, '
                      + 'Asset_Owner__c, Accumulation_Repair_Amount__c, Maintenance_Price_Month__c, Final_Examination_Date__c, '
                      + 'CurrentContract_End_Date__c, Extend_Gurantee_DateTo__c,EquipmentGuaranteeFlg__c, '
                      + 'CurrentContract_F__c,CurrentContract_F__r.Maintenance_Contract_No_F__c,CurrentContract_F__r.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, '
                      + '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,'
@@ -1047,11 +1049,12 @@
      List<Asset> temAsset = new List<Asset> ();
      //HWAG-BDJ43R ---XHL---20190729---
      String sqlStr = '';
         //tcm 添加 Management_Code__c  20211201 start
      sqlStr  = 'SELECT Id, Name, Asset_situation__c, SerialNumber, Department_Name__c, Installation_Site__c,';
      sqlStr += 'Posting_Date__c,Management_Code__c,IF_Warranty__c,Reson_Can_not_Warranty__c,InstallDate,isNewDate_use__c,';
      sqlStr += 'Asset_Owner__c, Accumulation_Repair_Amount__c, Maintenance_Price_Month__c, Final_Examination_Date__c,';
      sqlStr += 'CurrentContract_End_Date__c,Extend_Gurantee_DateTo__c,EquipmentGuaranteeFlg__c,';
      sqlStr += 'CurrentContract_F__c,CurrentContract_F__r.Maintenance_Contract_No_F__c,CurrentContract_F__r.RecordType_DeveloperName__c,CurrentContract_F__r.Estimate_Num__c,CurrentContract_F__r.Contract_End_Date__c,';
         sqlStr += 'CurrentContract_F__c,CurrentContract_F__r.Maintenance_Contract_No_F__c,CurrentContract_F__r.Management_Code__c,CurrentContract_F__r.RecordType_DeveloperName__c,CurrentContract_F__r.Estimate_Num__c,CurrentContract_F__r.Contract_End_Date__c,';
      sqlStr += 'CurrentContract_F_asset__c,CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c,CurrentContract_F_asset__r.endDateGurantee_Text__c,CurrentContract_F__r.Gurantee_Estimate_startDate__c,';
      sqlStr += 'CurrentContract_F__r.First_Estimate_Date__c,CurrentContract_F__r.Estimate_Contract_endDate__c,';
      sqlStr += 'CurrentContract_F__r.Contract_Consumption_rate__c,CurrentContract_F__r.First_contract_usage_Rate__c,';
@@ -1935,7 +1938,7 @@
   this.printTripartite = false;
   this.printAgent = false;
   this.estimate.PrintDate__c = Date.today();
   //SelectAssetEstimateVMController.ComputeLTYRepair(targetEstimateId);
      //SelectAssetEstimateVMTcmController.ComputeLTYRepair(targetEstimateId);
   if (this.estimate.Quote_Date__c == null) {
      this.estimate.Quote_Date__c = Date.today();
   }
@@ -2541,6 +2544,9 @@
                                                               Last_MContract__c
                                                               // Gzw 20200807 五个去年合同相关,所以报价产品,获取上期合同 eng
                                                               , Last_MContract__r.RecordType_DeveloperName__c
                                                     // LJPH-C9GD34 gzw fix start
                                                     ,Estimate_List_Price_Page__c
                                                     // LJPH-C9GD34 gzw fix end
                                                               from Maintenance_Contract_Asset_Estimate__c
                                                               where Maintenance_Contract_Estimate__c = :this.estimate.Id and Asset__c <> null]) {
@@ -2575,7 +2581,9 @@
      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;
      this.contract.Service_contract_target_number__c = this.estimate.Service_contract_target_number__c;
         // 点检总次数自动赋值 gzw fix 20211122 start
         // this.contract.Service_contract_target_number__c = this.estimate.Service_contract_target_number__c;
         // 点检总次数自动赋值 gzw fix 20211122 end
      this.contract.Contract_department_manual__c = this.estimate.Department__c;
      // 追加上期合同信息 start
@@ -2614,10 +2622,6 @@
         this.contract.Contract_End_Date__c = this.estimate.Contract_End_Date__c;
         this.contract.JingliApprovalManager__c = this.estimate.JingliApprovalManager__c;
         this.contract.BuchangApprovalManager__c = this.estimate.BuchangApprovalManager__c;
         //LJPH-C95AQ2 ly 20211207 Start
         this.contract.JingliApprovalManager_Txt__c = this.estimate.JingliApprovalManager__r.Name;
         this.contract.BuchangApprovalManager_Txt__c = this.estimate.BuchangApprovalManager__r.Name;
         //LJPH-C95AQ2 ly 20211207 End
         this.contract.ZongjianApprovalManager__c = this.estimate.ZongjianApprovalManager__c;
         this.contract.Finally_Approved_Staff__c = this.estimate.Finally_Approved_Staff__c;
         this.contract.TKZongjianApprovalManager__c = this.estimate.TKZongjianApprovalManager__c;
@@ -2635,10 +2639,6 @@
         this.contract.Contract_End_Date__c = this.estimate.Contract_End_Date__c;
         this.contract.JingliApprovalManager__c = this.estimate.JingliApprovalManager__c;
         this.contract.BuchangApprovalManager__c = this.estimate.BuchangApprovalManager__c;
         //LJPH-C95AQ2 ly 20211207 Start
         this.contract.JingliApprovalManager_Txt__c = this.estimate.JingliApprovalManager__r.Name;
         this.contract.BuchangApprovalManager_Txt__c = this.estimate.BuchangApprovalManager__r.Name;
         //LJPH-C95AQ2 ly 20211207 End
         this.contract.ZongjianApprovalManager__c = this.estimate.ZongjianApprovalManager__c;
         this.contract.Finally_Approved_Staff__c = this.estimate.Finally_Approved_Staff__c;
         this.contract.TKZongjianApprovalManager__c = this.estimate.TKZongjianApprovalManager__c;
@@ -2993,21 +2993,21 @@
public class AssetInfo {
// 新合同备品确保提供 当前标记
public Boolean etGFlg {get; set;}
public Integer lineNo {get; private set;}
   public Transient Integer lineNo {get; private 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 Decimal orgPrice {get; private set;}
public Decimal orgPrice12 {get; private set;}
   public Transient Decimal orgPrice {get; private set;}
   public Transient Decimal orgPrice12 {get; private set;}
// add by fxk 2021/9/9 控制点检对象是否可选 Star
public Boolean CheckRows {get; private set;}
// add by fxk 2021/9/9 控制点检对象是否可选 End
//add by rentx 2020-11-12 LJPH-BV93RZ start
public String proName;
public String proSerialNumber;
public String proSerialName;
   public Transient String proName;
   public Transient String proSerialNumber;
   public Transient String proSerialName;
//add by rentx 2020-11-12 LJPH-BV93RZ end
//add by mzy 2020-11-12 LJPH-BX9CVX start
//public Date NoPartRiskDate;
@@ -3068,7 +3068,9 @@
      LastMContract_Price__c = mcae.LastMContract_Price__c,
      Adjustment_Lower_price__c = mcae.Adjustment_Lower_price__c,
      Asset_Consumption_rate__c = mcae.Asset_Consumption_rate__c
         // LJPH-C9GD34 gzw fix start
         ,Estimate_List_Price_Page__c = mcae.Estimate_List_Price_Page__c
         // LJPH-C9GD34 gzw fix end
      );
   this.isManual = false;
   this.rec_checkBox_c = true;
@@ -3112,6 +3114,9 @@
      Asset_Consumption_rate__c = mcae.Asset_Consumption_rate__c,
      Contract_Esti_Start_Date__c = mcae.Maintenance_Contract_Estimate__r.Contract_Esti_Start_Date__c
                                    // Contract_Esti_Start_Date__c=mcae.Contract_Esti_Start_Date__c
         // LJPH-C9GD34 gzw fix start
         ,Estimate_List_Price_Page__c = mcae.Estimate_List_Price_Page__c
         // LJPH-C9GD34 gzw fix end
      );
   this.isManual = true;
   this.rec_checkBox_c = false;
@@ -3174,14 +3179,14 @@
   return rs;
}
// 2021-09-10 tcm 排序逻辑调整 start 传入日期参数,lastMContractMap1
public static List<lastMContract> getlastMContract(List<AssetInfo> checkedAssets, Date startDate) {
   Map<String, lastMContract> lastMContractMap = new Map<String, lastMContract>();
   Map<String, lastMContract> lastMContractMap1 = new Map<String, lastMContract>();
   for (AssetInfo ai : checkedAssets) {
      lastMContract lM = new lastMContract(ai.rec.CurrentContract_F__c, ai.rec.CurrentContract_F__r.Maintenance_Contract_No_F__c, ai.rec.CurrentContract_F__r.Contract_End_Date__c, 1);
         lastMContract lM = new lastMContract(ai.rec.CurrentContract_F__c, ai.rec.CurrentContract_F__r.Management_Code__c, ai.rec.CurrentContract_F__r.Contract_End_Date__c, 1);
         // 2021-09-10 tcm 排序逻辑调整 start
      // 计算空白期
      if (startDate != null && lM.endDate != null) {
         if (startDate.daysbetween(lM.endDate) > -366 && startDate.daysbetween(lM.endDate) < 366) {