| | |
| | | // } 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; |
| | |
| | | // 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 |
| | |
| | | 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]; |
| | |
| | | } |
| | | } |
| | | if (cancelIdSet1.size() > 0) { |
| | | List<Approval.ProcessWorkitemRequest> requests = new List<Approval.ProcessWorkitemRequest> (); |
| | | Map<ID,ProcessInstance> piMap = New Map<ID,ProcessInstance>([Select Id from ProcessInstance where TargetObjectId IN :cancelIdSet1]); |
| | | system.debug('==cancelIdSet1=='+cancelIdSet1); |
| | | for(ProcessInstanceWorkItem wi : [Select Id from ProcessInstanceWorkItem where ProcessInstanceId IN :piMap.keySet()]){ |
| | | Approval.ProcessWorkitemRequest req2 = new Approval.ProcessWorkitemRequest(); |
| | | req2.setAction('Removed'); |
| | | req2.setWorkitemId(wi.Id); |
| | | requests.add(req2); |
| | | List<Approval.ProcessWorkitemRequest> requests = new List<Approval.ProcessWorkitemRequest> (); |
| | | Map<ID,ProcessInstance> piMap = New Map<ID,ProcessInstance>([Select Id from ProcessInstance where TargetObjectId IN :cancelIdSet1]); |
| | | system.debug('==cancelIdSet1=='+cancelIdSet1); |
| | | for(ProcessInstanceWorkItem wi : [Select Id from ProcessInstanceWorkItem where ProcessInstanceId IN :piMap.keySet()]){ |
| | | Approval.ProcessWorkitemRequest req2 = new Approval.ProcessWorkitemRequest(); |
| | | req2.setAction('Removed'); |
| | | req2.setWorkitemId(wi.Id); |
| | | requests.add(req2); |
| | | } |
| | | system.debug('==requests.size()=='+requests.size()); |
| | | if (requests.size() > 0) { |
| | | Approval.ProcessResult[] processResults = null; |
| | | processResults = Approval.process(requests, true); |
| | | system.debug('==调回审批得结果=='+processResults); |
| | | } |
| | | } |
| | | system.debug('==requests.size()=='+requests.size()); |
| | | if (requests.size() > 0) { |
| | | Approval.ProcessResult[] processResults = null; |
| | | processResults = Approval.process(requests, true); |
| | | system.debug('==调回审批得结果=='+processResults); |
| | | if(Rentals.size()>0){ |
| | | update Rentals; |
| | | } |
| | | } |
| | | 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 |