高章伟
2023-03-03 d8dc84a3d56df839895f1c417a4d9cbee763d262
force-app/main/default/classes/CancelPostponePlanHandler.cls
@@ -67,7 +67,9 @@
            // } else if (oldMap.get(cpp.Id).get('Status__c') != cpp.Status__c && cpp.Status__c == '延期成功') {
            } else if (Trigger.isInsert && cpp.Status__c == '延期成功' ||
                    Trigger.isUpdate && oldMap.get(cpp.Id).get('Status__c') != cpp.Status__c && cpp.Status__c == '延期成功') {
                opdplan.Id =  cpp.CancelOPDPlan__c;
                // SWAG-BXDC25 mzy 审批后,更新【OPD计划实施日期temp】  Start
                //opdplan.OPDPlan_ImplementDate__c = cpp.NextPlanDate__c;
                opdplan.OPDPlan_ImplementDate_temp__c = cpp.NextPlanDate__c;
@@ -110,7 +112,24 @@
        // SWAG-BUF6J5 20201111  you start
        if (cancelIdSet.size() > 0) {//查询opd计划下得所有备品借出申请  更新 状态
            List<Rental_Apply__c> Rentals = new List<Rental_Apply__c>();
            List<Rental_Apply__c> RentalList = [select id,Cancel_Reason__c , Loaner_cancel_request__c,OPDPlan__c from Rental_Apply__c where OPDPlan__c in: cancelIdSet and Status__c <> '取消'];
            // 20230222 ljh DB202301265636 start
            // 20230202 ljh DB202301265636 start
            // List<Rental_Apply__c> RentalList = [select id,Cancel_Reason__c , Loaner_cancel_request__c,OPDPlan__c from Rental_Apply__c where OPDPlan__c in: cancelIdSet and Status__c <> '取消'];
            List<Rental_Apply__c> RentalList = [select id,Cancel_Reason__c , Loaner_cancel_request__c,OPDPlan__c from Rental_Apply__c where OPDPlan__c in: cancelIdSet and Status__c <> '取消' AND Shipment_request_Cnt__c = 0];
            // 20230202 ljh DB202301265636 end
            // 学会取消批准的时候 发邮件 不上线了
            // List<Rental_Apply__c> RentalList = new List<Rental_Apply__c>();
            // List<Rental_Apply__c> RentalCancleAlertList = new List<Rental_Apply__c>();
            // List<Rental_Apply__c> RentalListTemp = [select id,Cancel_Reason__c , Loaner_cancel_request__c,OPDPlan__c,Shipment_request_Cnt__c from Rental_Apply__c where OPDPlan__c in: cancelIdSet and Status__c <> '取消'];
            // for(Rental_Apply__c ra:RentalListTemp){
            //     if(ra.Shipment_request_Cnt__c == 0){
            //         RentalList.add(ra);
            //     }else{
            //         ra.CancelDay__c = Date.today();
            //         RentalCancleAlertList.add(ra);
            //     }
            // }
            // 20230222 ljh DB202301265636 end
            Set<String> cancelIdSet1 = new Set<String>(); //手动调回审批
            SS_Batch_Column_Mapping__c mpdMapping = SS_Batch_Column_Mapping__c.getValues('Rental_Apply_OPD_Cancle');
            //2021/02/07 liying SWAG-BXVDPJ start           
@@ -137,13 +156,8 @@
                  for (Rental_Apply__c rtl : RentalList) {
                      if(rtl.OPDPlan__c == cpp.CancelOPDPlan__c && cpp.if_HaveRental_Apply__c == false){
                          cancelIdSet1.add(rtl.id);
                          System.debug('理由汇总的Map:'+opdMap);
                          System.debug('理由:'+(cpp.cancelReasonCombobox__c));
                          System.debug('理由是否相等:'+(opdMap.containsKey(cpp.cancelReasonCombobox__c)));
                          // 2021/02/07 liying SWAG-BXVDPJ start
                          if(opdMap.containsKey(cpp.cancelReasonCombobox__c)){
                             System.debug('取消理由:'+(opdMap.get(cpp.cancelReasonCombobox__c).split(';')[1]) +'   \r\n '+'备品取消理由:'+opdMap.get(cpp.cancelReasonCombobox__c).split(';')[0]);
                             rtl.Cancel_Reason__c = opdMap.get(cpp.cancelReasonCombobox__c).split(';')[1];
                             rtl.Loaner_cancel_reason__c = opdMap.get(cpp.cancelReasonCombobox__c).split(';')[0];   
                             rtl.Loaner_cancel_request__c = opdMap.get(cpp.cancelReasonCombobox__c).split(';')[0];  
@@ -177,6 +191,12 @@
             if(Rentals.size()>0){
                   update Rentals;
                } 
            // 20230222 ljh DB202301265636 start
            // 学会取消批准的时候 发邮件 不上线了
            // if(RentalCancleAlertList.size() > 0 ){
            //     update RentalCancleAlertList;
            // }
            // 20230222 ljh DB202301265636 end
        }
        // SWAG-BUF6J5 20201111  you end
        //2021-08-11  mzy   SWAG-C5RAZV  事件——计划 延期 调查  start