李彤
2022-04-02 1949e7ccb3bfab67ad2b16d7e0172851c3f823bb
force-app/main/default/classes/SelectAssetEstimateVMController.cls
@@ -72,7 +72,9 @@
    public List<String> assetSerialNumberList = new List<String>();
    // 新规 或者 copy
    private Boolean newIns = false;
    //add   wangweipeng     2021/12/06     start
    public String checkDealerId{get;set;}
    //add   wangweipeng     2021/12/06     end
    
    static {
      textOpts = new List<SelectOption>();
@@ -538,6 +540,7 @@
      currPage = 1;
      selRecordOption = '20';
      totalRecords = 0;
        checkDealerId = '';
    }
    /**
     * Visaulforceから呼ばれるコンストラクタ
@@ -566,7 +569,7 @@
               Maintenance_Contract__r.Payment_Plan_Sum_Fifth__c,
               Maintenance_Contract__r.Payment_Plan_Sum_Sixth__c,
               Discount_Price__c, Discount_Percentage__c, IsSyncing__c,
               NotUse_Oxygenated_Water__c, Estimate_Target__c, Dealer__c,
                         NotUse_Oxygenated_Water__c, Estimate_Target__c, Dealer__c,Dealer__r.FirstParagraphEnd__c,Is_RecognitionModel__c,
               Append_Condition_Price__c, Asset_Sum_Price__c, Asset_Repair_Sum_Price__c,
               Print_Contract__c, Print_RepairPrice__c, Print_DiscountPercentage__c, Print_Agent__c, Change_Dealer_Approval__c,
               Print_DiscountPrice__c, Print_ListPrice__c, Print_MaintePrice__c, Print_SumPrice__c, Print_Tripartite__c, TKZongjianApprovalManager__c
@@ -586,6 +589,7 @@
               //跳过点检标记 2021/07/28 gzw start
               , Skip_DJ__c
               //跳过点检标记 2021/07/28 gzw start
               FROM Maintenance_Contract_Estimate__c WHERE Id = :this.targetEstimateId];
      //HWAG-B399Q8 2018/08/20  添加一额外字段 IS_Clone_After_Decide__c end
      decimal PriceSum =  (this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_First__c == null ? 0 : this.estimate.Maintenance_Contract__r.Payment_Plan_Sum_First__c) +
@@ -1007,6 +1011,7 @@
          }
        }
        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, '
@@ -1050,6 +1055,7 @@
        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,';
@@ -1076,7 +1082,6 @@
        //JZHG-BSDUT4 ---20200904---update By rentongxiao---end
        //HWAG-B4R3SS  END 20181026
        if (checkIdList.size() > 0) {
          sqlStr += '  AND Id NOT IN ' + checkIdList;
          //temAsset = [SELECT Id, Name, Asset_situation__c, SerialNumber, Department_Name__c, Installation_Site__c, Posting_Date__c,Management_Code__c,IF_Warranty__c,Reson_Can_not_Warranty__c,
          //            InstallDate, Asset_Owner__c, Accumulation_Repair_Amount__c, Maintenance_Price_Month__c, Final_Examination_Date__c,CurrentContract_End_Date__c,Extend_Gurantee_DateTo__c
@@ -2400,6 +2405,15 @@
        t = this.estimate.Contract_Start_Date__c.addMonths(Integer.valueOf(this.estimate.Contract_Range__c));
        t = t.addDays(-1);
        this.estimate.Contract_End_Date__c = t;
            //add      wangweipeng                   2021/12/26                     start
            if(String.isNotBlank(this.estimate.Dealer__c)){
                checkDealerId = this.estimate.Dealer__c;
                onChDealerUpdate();
            }else{
                this.estimate.Is_RecognitionModel__c = false;
            }
            //add      wangweipeng                   2021/12/26                     end
            System.debug('---------345----'+this.estimate.Dealer__c+'-------'+this.estimate.Dealer__r.FirstParagraphEnd__c);
        // 位置调整 在1951 line
        // Date createdDate = this.estimate.CreatedDate == null ? System.today() : this.estimate.CreatedDate.date();
        // 3ヶ月超過している場合には、Decideできない
@@ -2579,6 +2593,7 @@
        this.contract.Contract_Esti_End_Date__c = this.estimate.Contract_Esti_End_Date__c;
        this.contract.Estimate_Target__c = this.estimate.Estimate_Target__c;
        this.contract.Dealer__c = this.estimate.Dealer__c;
            this.contract.old_Is_RecognitionModel__c = this.estimate.Is_RecognitionModel__c;
        this.contract.NotUse_Oxygenated_Water__c = this.estimate.NotUse_Oxygenated_Water__c;
        this.contract.Estimate_Trial_Money__c = this.estimate.Estimate_Trial_Money__c;
        this.contract.Contract_Amount__c = this.estimate.Maintenance_Price__c;
@@ -2753,6 +2768,34 @@
      return ret;
    }
    
    //add     wangweipeng                     2021/12/26                 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;
    }
    //add     wangweipeng                     2021/12/26                 end
    // 2021-02-07  gzw add  LJPH-BWY5QB start
    private void setEndUserType(String id) {
      this.contract = [SELECT Id, Name, Status__c, Decided_Estimation__c, Service_Contract_Staff__c,