From 928399eceec50e3d37ea08669a12789a9410a9d2 Mon Sep 17 00:00:00 2001
From: 沙世明 <shashiming@prec-tech.com>
Date: 星期二, 22 十一月 2022 16:51:16 +0800
Subject: [PATCH] 111

---
 force-app/main/default/classes/rollupToRepairBatch.cls |   30 ++++++++++++++++++++++++------
 1 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/force-app/main/default/classes/rollupToRepairBatch.cls b/force-app/main/default/classes/rollupToRepairBatch.cls
index 94a09eb..5cfceb4 100644
--- a/force-app/main/default/classes/rollupToRepairBatch.cls
+++ b/force-app/main/default/classes/rollupToRepairBatch.cls
@@ -26,7 +26,10 @@
 
 
     global Database.QueryLocator start(Database.BatchableContext bc) {
-
+        // 20221110 ljh 浼樺寲 start
+        Date st = Date.today().addMonths(-36);
+        Datetime startDatetime = Datetime.newInstance(st.year(), st.month(), st.day(), 8, 0, 0);
+        // 20221110 ljh 浼樺寲 end
         if (repairId != null && repairId.size() > 0) {
             return Database.getQueryLocator(
                        [select Id,
@@ -46,6 +49,18 @@
                         from repair__c
                        ]);
         } else {
+            // 20221110 ljh 浼樺寲 start
+            // return Database.getQueryLocator(
+            //            [select Id ,
+            //             if_Rental_Apply__c ,
+            //             Offer_Rental_New__c,
+            //             Request_approval_day__c,
+            //             Bollow_Date__c
+            //             from repair__c
+            //             where Repair_Completed_Date__c = null Or
+            //                     Repair_Completed_Date__c >= :
+            //                     Date.today().addMonths(-12)
+            //            ]);
             return Database.getQueryLocator(
                        [select Id ,
                         if_Rental_Apply__c ,
@@ -53,10 +68,15 @@
                         Request_approval_day__c,
                         Bollow_Date__c
                         from repair__c
-                        where Repair_Completed_Date__c = null Or
-                                Repair_Completed_Date__c >= :
-                                Date.today().addMonths(-12)
+                        where Status1__c  != '0.鍙栨秷' 
+                        and Status1__c   != '0.鍒犻櫎' 
+                        and Status1__c != '5.瀹屾瘯'
+                        and (
+                        (Repair_Completed_Date__c = null and CreatedDate > :startDatetime)
+                         Or Repair_Completed_Date__c >= :Date.today().addMonths(-12)
+                        )
                        ]);
+            // 20221110 ljh 浼樺寲 end
         }
     }
 
@@ -91,7 +111,6 @@
         if (raList != null && raList.size() > 0) {
             for (Rental_Apply__c ra : raList) {
                 if (updateRepairMap.containsKey(ra.Repair__c)) {
-                    System.debug('zheli01'+ra.Request_approval_day__c+'~'+ra.Cancel_Reason__c);
                     Repair__c rep = updateRepairMap.get(ra.Repair__c);
                     if (ra.Request_approval_day__c != null &&
                             (
@@ -117,7 +136,6 @@
 
                         
                     }
-                    updateRepairMap.put(ra.Repair__c,rep);
                 }
             }
         }

--
Gitblit v1.9.1