高章伟
2023-03-03 d8dc84a3d56df839895f1c417a4d9cbee763d262
force-app/main/default/classes/SelectAssetEstimateController.cls
@@ -545,9 +545,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,
@@ -861,11 +858,7 @@
    // 取得分页数据
    private void setPageRecord() {
        checkIdList = new List<String> ();
        for (AssetInfo ass : this.checkedAssets) {
            if (!ass.isManual) {
                checkIdList.add(ass.rec.Id);
            }
        }
        if ((currPage * selctRecordNum) <= 2000) {
            String notInId = '(\'';
@@ -1950,6 +1943,7 @@
            this.estimate.Contract_Range__c.addError('必须输入合同月数!');
            return null;
        }
        NextMaintenanceContract();
        //add by rentx 2020-11-13 LJPH-BV93RZ end
        // add 维修合同报价,保存时,把记录类型赋值一下 2021.6.8 fxk start
        Id Maintenance_Contract = Schema.SObjectType.Maintenance_Contract_Estimate__c.getRecordTypeInfosByDeveloperName().get('Maintenance_Quote').getRecordTypeId();
@@ -2125,7 +2119,8 @@
     * 決定メソッド
     */
    public PageReference decide() {
        System.debug('decide start');
        System.debug('decide start');
        NextMaintenanceContract();
        inDicideFlag = true;
        // TODO check decide 资格
        Savepoint sp = Database.setSavepoint();
@@ -2138,6 +2133,49 @@
        }
        return null;
    }
    //  public PageReference dosomething() {
    //     System.debug('dosomething start');
    //     NextMaintenanceContract();
    //     return null;
    // }
    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');
    }
    public PageReference decideCancle() {
@@ -2467,10 +2505,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;
@@ -2485,10 +2519,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;
@@ -2569,6 +2599,7 @@
            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;
@@ -3037,6 +3068,40 @@
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        SelectAssetEstimateController saec = new SelectAssetEstimateController();
        saec.targetEstimateId = strId;
        saec.isPageAction = true;