From e14d6d0619330cad423f06493e3aa2371faa2a8f Mon Sep 17 00:00:00 2001
From: 19626 <1962676589@qq.com>
Date: 星期六, 09 九月 2023 14:02:23 +0800
Subject: [PATCH] Sit期间修改

---
 force-app/main/default/classes/ReportController.cls |  320 +++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 237 insertions(+), 83 deletions(-)

diff --git a/force-app/main/default/classes/ReportController.cls b/force-app/main/default/classes/ReportController.cls
index 76a56d9..8535a6b 100644
--- a/force-app/main/default/classes/ReportController.cls
+++ b/force-app/main/default/classes/ReportController.cls
@@ -70,7 +70,7 @@
             res.profileId = UserInfo.getProfileId();
             res.userId = UserInfo.getUserId();
             res.luShengId = getUserIdByName(LightingButtonConstant.LU_SHENG_NAME);
-            res.huDiAnId = getUserIdByName(LightingButtonConstant.HU_DI_AN_NAME);
+            // res.huDiAnId = getUserIdByName(LightingButtonConstant.HU_DI_AN_NAME);
             res.systemProfileId = getProfileIdByName(LightingButtonConstant.SYSTEM_PROFILE_NAME);
             System.debug(LoggingLevel.INFO, '*** res: ' + res);
         } catch (Exception e) {
@@ -261,6 +261,25 @@
         }
         return res;
     }
+    @AuraEnabled
+    public static InitData initForNewOnLineSurveyButton(String recordId){
+        InitData res = new InitData();
+        try {
+            Report__c re = [
+                select
+                Date__c,
+                Practitioner1__c,
+                OwnerId
+                from Report__c where Id =: recordId
+            ];
+            res.ownerId = re.OwnerId;
+            res.datec = re.Date__c;
+            res.practitioner1 = re.Practitioner1__c;
+        } catch (Exception e) {
+            throw new AuraHandledException(e.getMessage());
+        }
+        return res;
+    }
 
     //缁欐彁浜ょ浉搴旂殑js鎻愪緵鍒濆鍖栨暟鎹�
     @AuraEnabled
@@ -274,10 +293,18 @@
             update rac;
             return null;
         } catch (Exception e) {
-            String eMessage = e.getMessage();
-            Integer left = eMessage.indexOf(',') + 1;
-            Integer right = eMessage.length();
-            return eMessage.substring(left,right);
+            if (e.getMessage().contains(',')) {
+                System.debug(LoggingLevel.INFO, '*** e: ' + e);
+                String exc = '' + e.getMessage();
+                Integer left = exc.indexOf(':') + 1;
+                Integer right = exc.lastIndexOf(':');
+                String str = exc.substring(left,right);
+                left = str.indexOf(',') +  1;
+                String newStr = str.substring(left);
+                return newStr;
+            }else {
+                return e.getMessage();   
+            }
         }
     }
     //OPDtoSIS鎿嶄綔鏇存柊鐩稿簲鏁版嵁
@@ -290,10 +317,18 @@
             update rac;
             return null;
         } catch (Exception e) {
-            String eMessage = e.getMessage();
-            Integer left = eMessage.indexOf(',') + 1;
-            Integer right = eMessage.length();
-            return eMessage.substring(left,right);
+            if (e.getMessage().contains(',')) {
+                System.debug(LoggingLevel.INFO, '*** e: ' + e);
+                String exc = '' + e.getMessage();
+                Integer left = exc.indexOf(':') + 1;
+                Integer right = exc.lastIndexOf(':');
+                String str = exc.substring(left,right);
+                left = str.indexOf(',') +  1;
+                String newStr = str.substring(left);
+                return newStr;
+            }else {
+                return e.getMessage();   
+            }
         }
     }
 
@@ -309,10 +344,18 @@
             update rac;
             return null;
         } catch (Exception e) {
-            String eMessage = e.getMessage();
-            Integer left = eMessage.indexOf(',') + 1;
-            Integer right = eMessage.length();
-            return eMessage.substring(left,right);
+            if (e.getMessage().contains(',')) {
+                System.debug(LoggingLevel.INFO, '*** e: ' + e);
+                String exc = '' + e.getMessage();
+                Integer left = exc.indexOf(':') + 1;
+                Integer right = exc.lastIndexOf(':');
+                String str = exc.substring(left,right);
+                left = str.indexOf(',') +  1;
+                String newStr = str.substring(left);
+                return newStr;
+            }else {
+                return e.getMessage();   
+            }
         }
     }
     //瀹屾瘯鎿嶄綔鏇存柊鐩稿簲鏁版嵁
@@ -326,10 +369,18 @@
             update rac;
             return null;
         } catch (Exception e) {
-            String eMessage = e.getMessage();
-            Integer left = eMessage.indexOf(',') + 1;
-            Integer right = eMessage.length();
-            return eMessage.substring(left,right);
+            if (e.getMessage().contains(',')) {
+                System.debug(LoggingLevel.INFO, '*** e: ' + e);
+                String exc = '' + e.getMessage();
+                Integer left = exc.indexOf(':') + 1;
+                Integer right = exc.lastIndexOf(':');
+                String str = exc.substring(left,right);
+                left = str.indexOf(',') +  1;
+                String newStr = str.substring(left);
+                return newStr;
+            }else {
+                return e.getMessage();   
+            }
         }
     }
     //OCSM瑕佹姤鍛婃搷浣滄洿鏂扮浉搴旀暟鎹�
@@ -342,10 +393,18 @@
             update rac;
             return null;
         } catch (Exception e) {
-            String eMessage = e.getMessage();
-            Integer left = eMessage.indexOf(',') + 1;
-            Integer right = eMessage.length();
-            return eMessage.substring(left,right);
+            if (e.getMessage().contains(',')) {
+                System.debug(LoggingLevel.INFO, '*** e: ' + e);
+                String exc = '' + e.getMessage();
+                Integer left = exc.indexOf(':') + 1;
+                Integer right = exc.lastIndexOf(':');
+                String str = exc.substring(left,right);
+                left = str.indexOf(',') +  1;
+                String newStr = str.substring(left);
+                return newStr;
+            }else {
+                return e.getMessage();   
+            }
         }
     }
 
@@ -359,10 +418,18 @@
             update rac;
             return null;
         } catch (Exception e) {
-            String eMessage = e.getMessage();
-            Integer left = eMessage.indexOf(',') + 1;
-            Integer right = eMessage.length();
-            return eMessage.substring(left,right);
+            if (e.getMessage().contains(',')) {
+                System.debug(LoggingLevel.INFO, '*** e: ' + e);
+                String exc = '' + e.getMessage();
+                Integer left = exc.indexOf(':') + 1;
+                Integer right = exc.lastIndexOf(':');
+                String str = exc.substring(left,right);
+                left = str.indexOf(',') +  1;
+                String newStr = str.substring(left);
+                return newStr;
+            }else {
+                return e.getMessage();   
+            }
         }
     }
     //DispatchOCSMQARA鎿嶄綔鏇存柊鐩稿簲鏁版嵁
@@ -375,10 +442,18 @@
             update rac;
             return null;
         } catch (Exception e) {
-            String eMessage = e.getMessage();
-            Integer left = eMessage.indexOf(',');
-            Integer right = eMessage.length();
-            return eMessage.substring(left,right);
+            if (e.getMessage().contains(',')) {
+                System.debug(LoggingLevel.INFO, '*** e: ' + e);
+                String exc = '' + e.getMessage();
+                Integer left = exc.indexOf(':') + 1;
+                Integer right = exc.lastIndexOf(':');
+                String str = exc.substring(left,right);
+                left = str.indexOf(',') +  1;
+                String newStr = str.substring(left);
+                return newStr;
+            }else {
+                return e.getMessage();   
+            }
         }
     }
     //OCSM涓嶈鎶ュ憡鎿嶄綔鏇存柊鐩稿簲鏁版嵁
@@ -391,10 +466,18 @@
             update rac;
             return null;
         } catch (Exception e) {
-            String eMessage = e.getMessage();
-            Integer left = eMessage.indexOf(',');
-            Integer right = eMessage.length();
-            return eMessage.substring(left,right); 
+            if (e.getMessage().contains(',')) {
+                System.debug(LoggingLevel.INFO, '*** e: ' + e);
+                String exc = '' + e.getMessage();
+                Integer left = exc.indexOf(':') + 1;
+                Integer right = exc.lastIndexOf(':');
+                String str = exc.substring(left,right);
+                left = str.indexOf(',') +  1;
+                String newStr = str.substring(left);
+                return newStr;
+            }else {
+                return e.getMessage();   
+            }
         }
     }
 
@@ -408,10 +491,18 @@
             update rac;
             return null;
         } catch (Exception e) {
-            String eMessage = e.getMessage();
-            Integer left = eMessage.indexOf(',');
-            Integer right = eMessage.length();
-            return eMessage.substring(left,right);
+            if (e.getMessage().contains(',')) {
+                System.debug(LoggingLevel.INFO, '*** e: ' + e);
+                String exc = '' + e.getMessage();
+                Integer left = exc.indexOf(':') + 1;
+                Integer right = exc.lastIndexOf(':');
+                String str = exc.substring(left,right);
+                left = str.indexOf(',') +  1;
+                String newStr = str.substring(left);
+                return newStr;
+            }else {
+                return e.getMessage();   
+            }
         }
     }
     
@@ -445,10 +536,18 @@
             update rac;
             return null;
         } catch (Exception e) {
-            String eMessage = e.getMessage();
-            Integer left = eMessage.indexOf(',');
-            Integer right = eMessage.length();
-            return eMessage.substring(left,right);
+            if (e.getMessage().contains(',')) {
+                System.debug(LoggingLevel.INFO, '*** e: ' + e);
+                String exc = '' + e.getMessage();
+                Integer left = exc.indexOf(':') + 1;
+                Integer right = exc.lastIndexOf(':');
+                String str = exc.substring(left,right);
+                left = str.indexOf(',') +  1;
+                String newStr = str.substring(left);
+                return newStr;
+            }else {
+                return e.getMessage();   
+            }
         }
     }
 
@@ -462,14 +561,18 @@
             update rac;
             return null;
         } catch (Exception e) {
-            System.debug(LoggingLevel.INFO, '*** e: ' + e);
-            String exc = '' + e.getMessage();
-            Integer left = exc.indexOf(':') + 1;
-            Integer right = exc.lastIndexOf(':');
-            String str = exc.substring(left,right);
-            left = str.indexOf(',') +  1;
-            String newStr = str.substring(left);
-            return newStr;
+            if (e.getMessage().contains(',')) {
+                System.debug(LoggingLevel.INFO, '*** e: ' + e);
+                String exc = '' + e.getMessage();
+                Integer left = exc.indexOf(':') + 1;
+                Integer right = exc.lastIndexOf(':');
+                String str = exc.substring(left,right);
+                left = str.indexOf(',') +  1;
+                String newStr = str.substring(left);
+                return newStr;
+            }else {
+                return e.getMessage();   
+            } 
         }
     }
 
@@ -486,10 +589,18 @@
             update rac;
             return null;
         } catch (Exception e) {
-            String eMessage = e.getMessage();
-            Integer left = eMessage.indexOf(',');
-            Integer right = eMessage.length();
-            return eMessage.substring(left,right);
+            if (e.getMessage().contains(',')) {
+                System.debug(LoggingLevel.INFO, '*** e: ' + e);
+                String exc = '' + e.getMessage();
+                Integer left = exc.indexOf(':') + 1;
+                Integer right = exc.lastIndexOf(':');
+                String str = exc.substring(left,right);
+                left = str.indexOf(',') +  1;
+                String newStr = str.substring(left);
+                return newStr;
+            }else {
+                return e.getMessage();   
+            }
         }
     }
     //VOC鍥炵瓟鏇存柊鐩稿簲鏁版嵁
@@ -498,24 +609,39 @@
         try {
             Report__c rac = [select Status__c,JingliApprovalManager__r.Id,BuchangApprovalManager__r.Id,SalesManager__r.Id,BuchangApprovalManagerSales__r.Id,ZongjianApprovalManager__c,Submit_time__c,Submit_report_day__c,Owner.Id from Report__c where Id = :recordId];
             // share
-            rac.Id = recordId;
             User[] records = [SELECT  Job_Category__c FROM User WHERE Id = :createdById];
             List<String> userAccess = new List<String>();
             if (records[0].Job_Category__c == LightingButtonConstant.TYPE_OF_SALES_SERVICES) {
-            userAccess.add(rac.JingliApprovalManager__c + LightingButtonConstant.USER_ACCESS_READ);
-            userAccess.add(rac.BuchangApprovalManager__c + LightingButtonConstant.USER_ACCESS_READ);
-            rac.VOC_CreatedBy_jingli__c = rac.JingliApprovalManager__c;
-            rac.VOC_CreatedBy_buzhang__c = rac.BuchangApprovalManager__c;
-            } else {
-            userAccess.add(rac.SalesManager__c + LightingButtonConstant.USER_ACCESS_READ);
-            userAccess.add(rac.BuchangApprovalManagerSales__c + LightingButtonConstant.USER_ACCESS_READ);
-            rac.VOC_CreatedBy_jingli__c = rac.SalesManager__c;
-            rac.VOC_CreatedBy_buzhang__c = rac.BuchangApprovalManagerSales__c;
+            if(rac.JingliApprovalManager__c != null){
+                userAccess.add(rac.JingliApprovalManager__c + LightingButtonConstant.USER_ACCESS_READ);
+                rac.VOC_CreatedBy_jingli__c = rac.JingliApprovalManager__c;
             }
-            userAccess.add(rac.ZongjianApprovalManager__c + LightingButtonConstant.USER_ACCESS_READ);
+            if(rac.BuchangApprovalManager__c != null){
+                userAccess.add(rac.BuchangApprovalManager__c + LightingButtonConstant.USER_ACCESS_READ);
+                rac.VOC_CreatedBy_buzhang__c = rac.BuchangApprovalManager__c;
+            }
+            
+            
+            } else {
+                if(rac.SalesManager__c != null){
+                    userAccess.add(rac.SalesManager__c + LightingButtonConstant.USER_ACCESS_READ);
+                    rac.VOC_CreatedBy_jingli__c = rac.SalesManager__c;
+                }
+                if(rac.BuchangApprovalManagerSales__c != null){
+                    userAccess.add(rac.BuchangApprovalManagerSales__c + LightingButtonConstant.USER_ACCESS_READ);
+                    rac.VOC_CreatedBy_buzhang__c = rac.BuchangApprovalManagerSales__c;
+                }
+           
+            
+            
+            
+            }
+            if(rac.ZongjianApprovalManager__c != null){
+                userAccess.add(rac.ZongjianApprovalManager__c + LightingButtonConstant.USER_ACCESS_READ);
+            }
             String rtn = ControllerUtil.setSObjectShare(LightingButtonConstant.SOBJECT_NAME_OF_REPORT_SHARE,LightingButtonConstant.SOBJECT_NAME_OF_VOC_SHARE,recordId,userAccess,rac.Owner.Id);
             if (rtn != LightingButtonConstant.OK) {
-            return null;
+            return rtn;
             }
             rac.Status__c = LightingButtonConstant.STATUS_VOC_WRITE_OVER;
             rac.Submit_time__c = Date.today();
@@ -523,10 +649,18 @@
             update rac;
             return null;
         } catch (Exception e) {
-            String eMessage = e.getMessage();
-            Integer left = eMessage.indexOf(',');
-            Integer right = eMessage.length();
-            return eMessage.substring(left, right);
+            if (e.getMessage().contains(',')) {
+                System.debug(LoggingLevel.INFO, '*** e: ' + e);
+                String exc = '' + e.getMessage();
+                Integer left = exc.indexOf(':') + 1;
+                Integer right = exc.lastIndexOf(':');
+                String str = exc.substring(left,right);
+                left = str.indexOf(',') +  1;
+                String newStr = str.substring(left);
+                return newStr;
+            }else {
+                return e.getMessage();   
+            }
         }
     }
     //VOC鍒ゅ畾鏇存柊鐩稿簲鏁版嵁
@@ -538,26 +672,34 @@
                 // VOC瀵惧繙鑰呫伄绲岀悊閮ㄩ暦绶忕洠銈掕ō瀹�
                 User[] records = [SELECT Id, Job_Category__c, JingliApprovalManager__c, SalesManager__c, BuchangApprovalManager__c, BuchangApprovalManagerSales__c, ZongjianApprovalManager__c FROM User WHERE Id = :personId];
                 if (records[0].job_Category__c == LightingButtonConstant.TYPE_OF_SALES_SERVICES) {
-                    rac.VOC_jingli__c = records[0].JingliApprovalManager__c == null ? '' : records[0].JingliApprovalManager__c;
-                    rac.VOC_buzhang__c = records[0].BuchangApprovalManager__c == null ? '' : records[0].BuchangApprovalManager__c;
+                    rac.VOC_jingli__c = records[0].JingliApprovalManager__c == null ? null : records[0].JingliApprovalManager__c;
+                    rac.VOC_buzhang__c = records[0].BuchangApprovalManager__c == null ? null : records[0].BuchangApprovalManager__c;
                 } else {
-                    rac.VOC_jingli__c = records[0].SalesManager__c == null ? '' : records[0].SalesManager__c;
-                    rac.VOC_buzhang__c = records[0].BuchangApprovalManagerSales__c == null ? '' : records[0].BuchangApprovalManagerSales__c;
+                    rac.VOC_jingli__c = records[0].SalesManager__c == null ? null : records[0].SalesManager__c;
+                    rac.VOC_buzhang__c = records[0].BuchangApprovalManagerSales__c == null ? null : records[0].BuchangApprovalManagerSales__c;
                 }
-                rac.VOC_zongjian__c = records[0].ZongjianApprovalManager__c == null ? '' : records[0].ZongjianApprovalManager__c;
+                rac.VOC_zongjian__c = records[0].ZongjianApprovalManager__c == null ? null : records[0].ZongjianApprovalManager__c;
                 rac.Status__c = LightingButtonConstant.STATUS_VOC_CHECK_OVER;
                 rac.VOC_Finish__c = false;
                 Date serverTimestamp = Date.today();
                 rac.VOC_share_date__c = serverTimestamp;
                 // share
                 List<String> userAccess = new List<String>();
-                userAccess.add(rac.Responsible_Person__c + LightingButtonConstant.USER_ACCESS_EDIT);
-                userAccess.add(rac.VOC_jingli__c + LightingButtonConstant.USER_ACCESS_READ);
-                userAccess.add(rac.VOC_buzhang__c + LightingButtonConstant.USER_ACCESS_READ);
-                userAccess.add(rac.VOC_zongjian__c + LightingButtonConstant.USER_ACCESS_READ);
+                if(rac.Responsible_Person__c != null){
+                    userAccess.add(rac.Responsible_Person__c + LightingButtonConstant.USER_ACCESS_EDIT);
+                }
+                if(rac.VOC_jingli__c != null){
+                    userAccess.add(rac.VOC_jingli__c + LightingButtonConstant.USER_ACCESS_READ);
+                }
+                if(rac.VOC_buzhang__c != null){
+                    userAccess.add(rac.VOC_buzhang__c + LightingButtonConstant.USER_ACCESS_READ);
+                }
+                if(rac.VOC_zongjian__c != null){
+                    userAccess.add(rac.VOC_zongjian__c + LightingButtonConstant.USER_ACCESS_READ);
+                }
                 String rtn = ControllerUtil.setSObjectShare(LightingButtonConstant.SOBJECT_NAME_OF_REPORT_SHARE,LightingButtonConstant.SOBJECT_NAME_OF_VOC_SHARE,recordId,userAccess,rac.Owner.Id);
                 if (rtn != LightingButtonConstant.OK) {
-                    return null;
+                    return rtn;
                 }
                 update rac;
                 } else {
@@ -581,10 +723,18 @@
             update report;
             return null;
         } catch (Exception e) {
-            String eMessage = e.getMessage();
-            Integer left = eMessage.indexOf(',');
-            Integer right = eMessage.length();
-            return eMessage.substring(left,right);
+            if (e.getMessage().contains(',')) {
+                System.debug(LoggingLevel.INFO, '*** e: ' + e);
+                String exc = '' + e.getMessage();
+                Integer left = exc.indexOf(':') + 1;
+                Integer right = exc.lastIndexOf(':');
+                String str = exc.substring(left,right);
+                left = str.indexOf(',') +  1;
+                String newStr = str.substring(left);
+                return newStr;
+            }else {
+                return e.getMessage();   
+            }
         }
     }
     @AuraEnabled
@@ -682,5 +832,9 @@
         public String demoPurpose2;
         @AuraEnabled
         public String opdPlan;
+        @AuraEnabled
+        public Date datec;
+        @AuraEnabled
+        public String practitioner1;
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1