From e3c02c03dd2de442bbced87236f60a13a1cd154e Mon Sep 17 00:00:00 2001
From: 高章伟 <gaozhangwei@prec-tech.com>
Date: 星期四, 02 三月 2023 17:51:57 +0800
Subject: [PATCH] gzw 正式环境最新代码更新

---
 force-app/main/default/classes/CancelPostponePlanHandler.cls |   59 +++++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 41 insertions(+), 18 deletions(-)

diff --git a/force-app/main/default/classes/CancelPostponePlanHandler.cls b/force-app/main/default/classes/CancelPostponePlanHandler.cls
index c24309d..ee65c7c 100644
--- a/force-app/main/default/classes/CancelPostponePlanHandler.cls
+++ b/force-app/main/default/classes/CancelPostponePlanHandler.cls
@@ -112,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           
@@ -155,25 +172,31 @@
                 }
             } 
             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

--
Gitblit v1.9.1