高章伟
2023-03-02 e3c02c03dd2de442bbced87236f60a13a1cd154e
force-app/main/default/classes/NFM106Controller.cls
@@ -24,7 +24,18 @@
        public String QuotationAmount;
        public String ContractPeriod;
        public PaymentInformation_element[] PaymentInformation;
        //URF限次合同2期 LY 20220811 start
        public SeriesInformation_element[] SeriesInformation;
        //URF限次合同2期 LY 20220811 end
    }
    //URF限次合同2期 LY 20220811 start
    public class SeriesInformation_element {
        public String SeriesNo;
        public String RepairTime;
        public String SeriesAmount;
    }
    //URF限次合同2期 LY 20220811 end
    public class RepairContractLogin_element {
        public NFMUtil.Monitoring Monitoring;
        public GeneralData_element[] GeneralData;
@@ -66,24 +77,58 @@
                }
            }
        }
        //Repair测试类跳过 thh 20220401 start
        if(StaticParameter.EscapeNFM106Trigger){
            return;
        }
        //Repair测试类跳过 thh 20220401 end
        if (Trigger.isBefore) {
            if (Trigger.isUpdate) {
                for(Maintenance_Contract__c mc : newList) {
                    // 虚拟维修合同跳过
                    if (mc.RecordType_DeveloperName__c == 'VM_Contract')continue ;
                    if (NFM106Controller.NFM106_Ids.contains(mc.Id) == false && mc.Status__c == '契約') {
                        if (oldMap.get(mc.Id).Status__c != mc.Status__c
                                || oldMap.get(mc.Id).Contract_Conclusion_Date__c != mc.Contract_Conclusion_Date__c
                        ) {
                            if (String.isBlank(mc.Maintenance_Contract_No__c)) {
                                mc.addError('状态变为合同时,必须输入「' + Schema.SObjectType.Maintenance_Contract__c.fields.Maintenance_Contract_No__c.label + '」');
                                continue;
                            }
                            mcIds.put(mc.Id, mc.Id);
                            mcNoList.add(mc.Maintenance_Contract_No__c);
                            NFM106Controller.debug_msg += 'NFM106_callout_update_' + mc.Name;
                    //update     wangweipeng                               2021/11/16   start
                    //新增先款后修功能,如果经销商是先款对象,需要先认款合同上传然后再上传SAP
                    //判断是否需要走认款的接口
                    boolean flag = false;
                    if(mc.old_Is_RecognitionModel__c){
                        //判断当前合同是否已经认款完成
                        if(!mc.Is_Recognition_Model_True__c){
                            flag = true;
                        }
                    }
                    //为true时,证明此合同必须先上传认款合同,然后再能走上传SAP接口
                    if(flag){
                        //如果是否认款合同字段为true,并且认款合同状态变为 认款中,那么就走认款接口
                        if(mc.upload_to_RM_time__c != null && (oldMap.get(mc.Id).upload_to_RM_time__c != mc.upload_to_RM_time__c)){
                            //走认款接口,状态不变
                            if(NFM106Controller.NFM106_Ids.contains(mc.Id) == false && mc.Status__c == '引合中'){
                                if (String.isBlank(mc.Maintenance_Contract_No__c)) {
                                    mc.addError('状态变为合同时,必须输入「' + Schema.SObjectType.Maintenance_Contract__c.fields.Maintenance_Contract_No__c.label + '」');
                                    continue;
                                }
                                mcIds.put(mc.Id, mc.Id);
                                mcNoList.add(mc.Maintenance_Contract_No__c);
                                NFM106Controller.debug_msg += 'NFM106_callout_update_' + mc.Name;
                            }
                        }
                    } else {//正常上传SAP接口
                        if (NFM106Controller.NFM106_Ids.contains(mc.Id) == false && mc.Status__c == '契約') {
                            if (oldMap.get(mc.Id).Status__c != mc.Status__c
                                    || oldMap.get(mc.Id).Contract_Conclusion_Date__c != mc.Contract_Conclusion_Date__c
                            ) {
                                if (String.isBlank(mc.Maintenance_Contract_No__c)) {
                                    mc.addError('状态变为合同时,必须输入「' + Schema.SObjectType.Maintenance_Contract__c.fields.Maintenance_Contract_No__c.label + '」');
                                    continue;
                                }
                                mcIds.put(mc.Id, mc.Id);
                                mcNoList.add(mc.Maintenance_Contract_No__c);
                                NFM106Controller.debug_msg += 'NFM106_callout_update_' + mc.Name;
                            }
                        }
                    }
                    //update     wangweipeng                          2021/11/16   end
                }
            }
        }
@@ -177,6 +222,14 @@
                    // LJPH-BS89NQ start
                    upload_to_sap_time__c
                     // LJPH-BS89NQ end
                    //URF限次合同2期 LY 20220811 start
                    ,Estimation_Id__r.Total_Number_Asset_P__c
                    ,Estimation_Id__r.URF_P_RepairTime__c
                    ,Estimation_Id__r.Estimate_List_Price_Sum_P__c
                    ,Estimation_Id__r.Total_Number_Asset_V__c
                    ,Estimation_Id__r.URF_V_RepairTime__c
                    ,Estimation_Id__r.Estimate_List_Price_Sum_V__c
                    //URF限次合同2期 LY 20220811 end
               from Maintenance_Contract__c where Id IN :mcIds];          // 削除データを検索しないはず、All ROWS いらないはず
            System.debug(Logginglevel.DEBUG, 'NFM106_ recptList.size()=' + mcList.size());
@@ -255,6 +308,23 @@
                }
                // HWAG-BE88UG 【委托】SFDC-SAP搭现有接口添加合同“付款计划”信息 by vivek end
                //URF限次合同2期 LY 20220811 start
                element.SeriesInformation = new List<SeriesInformation_element>();
                if(mc.Estimation_Id__r.Total_Number_Asset_P__c != null && mc.Estimation_Id__r.Total_Number_Asset_P__c != 0){
                    SeriesInformation_element seriesInformationP = new SeriesInformation_element();
                    element.SeriesInformation.add(seriesInformationP);
                    seriesInformationP.SeriesNo = 'P';
                    seriesInformationP.RepairTime = mc.Estimation_Id__r.URF_P_RepairTime__c.toPlainString();
                    seriesInformationP.SeriesAmount = mc.Estimation_Id__r.Estimate_List_Price_Sum_P__c.toPlainString();
                }
                if(mc.Estimation_Id__r.Total_Number_Asset_V__c != null && mc.Estimation_Id__r.Total_Number_Asset_V__c != 0){
                    SeriesInformation_element seriesInformationP = new SeriesInformation_element();
                    element.SeriesInformation.add(seriesInformationP);
                    seriesInformationP.SeriesNo = 'V';
                    seriesInformationP.RepairTime = mc.Estimation_Id__r.URF_V_RepairTime__c.toPlainString();
                    seriesInformationP.SeriesAmount = mc.Estimation_Id__r.Estimate_List_Price_Sum_V__c.toPlainString();
                }
                //URF限次合同2期 LY 20220811 end
                logstr += '[' + element.ContractNo + ']EndUserNoorAgentNo[' + element.EndUserNoorAgentNo + '] ';
            }
@@ -362,7 +432,8 @@
            // CHAN-BSV3GZ start
            // 原代码
            // rowData.retry_cnt__c=0;
            if (status == 'OK') {
            system.debug('status15122021'+status);
            if (status == 'ok') {
                rowData.retry_cnt__c = 0;
            } else {
                if (rowData.retry_cnt__c == null) rowData.retry_cnt__c = 0;