From 07390e2fcb4adf27c928335bf27ae7939c5a80ad Mon Sep 17 00:00:00 2001
From: buli <137736985@qq.com>
Date: 星期二, 23 五月 2023 11:28:12 +0800
Subject: [PATCH] bakcup20230523

---
 force-app/main/default/classes/SelectSubstituteControllerLWT.cls |   59 ++++++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 42 insertions(+), 17 deletions(-)

diff --git a/force-app/main/default/classes/SelectSubstituteControllerLWT.cls b/force-app/main/default/classes/SelectSubstituteControllerLWT.cls
index d8c26a6..9b281a8 100644
--- a/force-app/main/default/classes/SelectSubstituteControllerLWT.cls
+++ b/force-app/main/default/classes/SelectSubstituteControllerLWT.cls
@@ -572,19 +572,13 @@
     }
     
     @AuraEnabled
-    public static String postponeCheck(String endDate, Integer d) {
-        Date before5day = getWD_addday(date.parse(endDate), d);
-        if (Date.today() > before5day) {
-            return System.Label.EquipmentRentalPostponeOverDeadline;
-        }
-        return 'OK';
-    }
-
-    public static Date getWD_addday(Date d, Integer i) {
+    public static String postponeCheck(String endDate, Integer i) {
+        Date d=Date.valueOf(endDate);
+        // return 'OK1';S
+        Date selectDate;
         if (d == Date.valueOf('4000-12-31')) {
-            return d;
-        }
-        if (i >= 0) {
+            selectDate=d;
+        } else if (i >= 0) {
             List<OlympusCalendar__c> workday = [
                     select Id, Date__c, IsWorkDay__c 
                       from OlympusCalendar__c 
@@ -592,8 +586,11 @@
                        and IsWorkDay__c = 1
                      order by Date__c
                      limit :(i+1)];
-            Date selectDate = workday[i].Date__c;
-            return selectDate;
+            selectDate = workday[i].Date__c;
+            return 'OK1';
+            // if (Date.today() > selectDate) {
+            //     return System.Label.EquipmentRentalPostponeOverDeadline;
+            // }
         } else {
             i = Math.abs(i);
             List<OlympusCalendar__c> workday = [
@@ -603,11 +600,39 @@
                        and IsWorkDay__c = 1
                      order by Date__c desc
                      limit :(i+1)];
-            Date selectDate = workday[i].Date__c;
-            return selectDate;
+            selectDate = workday[i].Date__c;
         }
+
+        if (Date.today() > selectDate) {
+            return System.Label.EquipmentRentalPostponeOverDeadline;
+        }
+        return 'OK';
+
+        // Date before5day = getWD_addday(date.parse(endDate), d);
+        // return 'OK2';
+        // if (Date.today() > before5day) {
+        //     return System.Label.EquipmentRentalPostponeOverDeadline;
+        // }
+        // return 'OK';
     }
-    
+
+    // public static Date getWD_addday(Date d, Integer i) {
+        
+    // }
+
+    @AuraEnabled
+    public static String submitApprovalRequest(String recordId) {
+        try{
+           Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
+           req.setObjectId(recordId);
+           Approval.ProcessResult result = Approval.process(req);
+           if(result.getErrors()!=null&&result.getErrors().size()>0)return result.getErrors().get(0).getMessage();
+        }catch(Exception e){
+            System.debug(' submitApprovalRequest  error: '+e.getMessage());
+            return e.getMessage();
+        }
+        return null;
+    }
 
     public class UpdateResult {
         @AuraEnabled public String recordId {get;set;}

--
Gitblit v1.9.1