涂煌豪
2022-03-22 8e39e511f1a272ee05b53ff68a985464a8c7ccf9
force-app/main/default/triggers/Repair.trigger
@@ -25,7 +25,11 @@
    // ----------------------------------------------------------------------
    // ここより、修理のサービスコントラクト項目を自動的に更新するロジック
    // ----------------------------------------------------------------------
    if ( Trigger.isBefore && (Trigger.isInsert || Trigger.isUpdate)) {
    if (Trigger.isBefore && (Trigger.isInsert || Trigger.isUpdate)) {
        //先款后修-修理增加先款标识 thh 20220322 start
        RepairTrigger.AdvancePaymentFlagUpsert(Trigger.new, Trigger.newMap, Trigger.old, Trigger.oldMap);
        //先款后修-修理增加先款标识 thh 20220322 end
        // 納入機器IDを一意に格納する Setです。
        Set<ID> assetIds = new Set<Id>();
@@ -66,8 +70,17 @@
            boolean defaultFlag = true;
            //add     wangweipeng               2021/12/09          end
            // 草案中修理だけ更新
            // GZW 特殊处理 跳过维修中心自动赋值,以手选为准 start
            // 判断条件追加   && repair.Exc_work_location__c == false
            if(repair.Exc_work_location__c){
                defaultFlag = false;
            }
            // GZW 特殊处理 跳过维修中心自动赋值,以手选为准 start
            if ((repair.Status__c == '草案中' || String.isBlank(repair.Status__c)) == false) {
                if (Trigger.isUpdate && repair.SAP_Transfer_time__c == null) {
                // if (Trigger.isUpdate && repair.SAP_Transfer_time__c == null) {
                if (Trigger.isUpdate && repair.SAP_Transfer_time__c == null && repair.Exc_work_location__c == false) {
                    repair = RepairTrigger.updateWorkLocationSelect(repair, null);
                    defaultFlag = false;
                }
@@ -79,7 +92,8 @@
            Boolean needsetnull = true;
            System.debug( '-----:自动带出维修合同11111' + middleTableList);
            if (middleTableList == null) {
            // if (middleTableList == null) {
            if (middleTableList == null  && repair.Exc_work_location__c == false) {
                if ((repair.NewProductGuarante_Txt__c == '2: 多年保修'
                        || repair.NewProductGuarante_Txt__c == '2: 服务多年保修'
                        || repair.NewProductGuarante_Txt__c == '8: 市场多年保修')
@@ -114,7 +128,8 @@
                            repair.repairPlace__c = middleTable.Maintenance_Contract__r.SalesOfficeCode_selection__c;
                            //新增逻辑 HWAG-BKP5FB 精琢科技 2020/03/19 Start
                            //wangweipeng   发生数据到SAP以后,修理的维修中心不能做修改
                            if(repair.SAP_Transfer_time__c == null){
                            // if(repair.SAP_Transfer_time__c == null){
                            if(repair.SAP_Transfer_time__c == null  && repair.Exc_work_location__c == false){
                                repair = RepairTrigger.updateWorkLocationSelect(repair, middleTable);    
                                defaultFlag = false;
                            }
@@ -159,7 +174,8 @@
            // Boolean needsetnull = true;
            System.debug( '-----:自动带出虚拟维修合同');
            System.debug( '-----:自动带出虚拟维修合同' + middleTableVMList);
            if (middleTableVMList == null) {
            // if (middleTableVMList == null) {
            if (middleTableVMList == null  && repair.Exc_work_location__c == false) {
                if ((repair.NewProductGuarante_Txt__c == '2: 多年保修'
                        || repair.NewProductGuarante_Txt__c == '2: 服务多年保修'
                        || repair.NewProductGuarante_Txt__c == '8: 市场多年保修')
@@ -180,7 +196,8 @@
                        repair.VM_Maintenance_Contract__c = middleTable.Maintenance_Contract__c;
                        needsetnull = false;
                        //新增逻辑 SLIU-BMMDWK 精琢科技 2020/03/17 Start
                        if (repair.VM_Maintenance_Contract__c != null) {
                        // if (repair.VM_Maintenance_Contract__c != null) {
                        if (repair.VM_Maintenance_Contract__c != null  && repair.Exc_work_location__c == false) {
                            repair = RepairTrigger.updateWorkLocationSelect(repair, middleTable);
                            defaultFlag = false;
                        }
@@ -257,13 +274,12 @@
                //迁移进程生成器中repair Alltime功能       End
                /****************************************************************************************************/
            }
        }
        }
    }
    // ----------------------------------------------------------------------
    // ここまで、サービスコントラクト項目を自動的に更新するロジック
    // ----------------------------------------------------------------------
    // ----------------------------------------------------------------------
    // これより、On-Callの「On-Call跟进结果」を更新するロジック