From f6a201e215d929bda9815e1689907d166a603519 Mon Sep 17 00:00:00 2001
From: 19626 <1962676589@qq.com>
Date: 星期一, 15 五月 2023 15:08:27 +0800
Subject: [PATCH] 5月15日陈京武按钮开发

---
 force-app/main/default/classes/ReportController.cls |  197 +++++++++++++++++++++++++++++++++++--------------
 1 files changed, 140 insertions(+), 57 deletions(-)

diff --git a/force-app/main/default/classes/ReportController.cls b/force-app/main/default/classes/ReportController.cls
index aea48b6..9afd242 100644
--- a/force-app/main/default/classes/ReportController.cls
+++ b/force-app/main/default/classes/ReportController.cls
@@ -10,6 +10,10 @@
             Report__c report = [select Status__c from Report__c where Id = :recordId];
             res.status = report.Status__c;
             res.profileId = UserInfo.getProfileId();
+            res.userId = UserInfo.getUserId();
+            res.luShengId = getUserIdByName(LightingButtonConstant.LU_SHENG_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) {
             System.debug(LoggingLevel.INFO, '*** e: ' + e);
@@ -26,6 +30,10 @@
             res.isVOC = report.IsVOC__c;
             res.personId = report.Responsible_Person__r.Id;
             res.profileId = UserInfo.getProfileId();
+            res.userId = UserInfo.getUserId();
+            res.luShengId = getUserIdByName(LightingButtonConstant.LU_SHENG_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) {
             System.debug(LoggingLevel.INFO, '*** e: ' + e);
@@ -69,8 +77,8 @@
         try {
             Report__c report = [select Status__c,VOC_Satisfy__c,VOC_Satisfy1__c from Report__c where Id = :recordId];
             res.status = report.Status__c;
-            res.Satisfy = report.VOC_Satisfy__c;
-            res.Satisfy1 = report.VOC_Satisfy1__c;
+            res.satisfy = report.VOC_Satisfy__c;
+            res.satisfy1 = report.VOC_Satisfy1__c;
             System.debug(LoggingLevel.INFO, '*** res: ' + res);
         } catch (Exception e) {
             System.debug(LoggingLevel.INFO, '*** e: ' + e);
@@ -97,8 +105,8 @@
         InitData res = new InitData();
         try {
             Report__c report = [select OCSMAdministrativeReportNumber__c,OCSMAdministrativeReportDate__c,Aware_date__c from Report__c where Id = :recordId];
-            res.OCSMAdministrativeReportDate = report.OCSMAdministrativeReportDate__c;
-            res.OCSMAdministrativeReportNumber = report.OCSMAdministrativeReportNumber__c;
+            res.theOCSMAdministrativeReportDate = report.OCSMAdministrativeReportDate__c;
+            res.theOCSMAdministrativeReportNumber = report.OCSMAdministrativeReportNumber__c;
             res.awareDate = report.Aware_date__c;
         } catch (Exception e) {
             System.debug(LoggingLevel.INFO, '*** e: ' + e);
@@ -126,7 +134,7 @@
         InitData res = new InitData();
         try {
             Report__c report = [select OCSMAdministrativeReportStatus__c,AwareDate__C from Report__c where Id = :recordId];
-            res.OCSMAdministrativeReportStatus = report.OCSMAdministrativeReportStatus__c;
+            res.theOCSMAdministrativeReportStatus = report.OCSMAdministrativeReportStatus__c;
             res.awareDate = report.AwareDate__C;
         } catch (Exception e) {
             System.debug(LoggingLevel.INFO, '*** e: ' + e);
@@ -155,11 +163,11 @@
         try {
             PAE_DecisionRecord__c[] report = [SELECT LastModifiedDate, Id, Name, LastModifiedById,RecordType.DeveloperName FROM PAE_DecisionRecord__c where PAE_Report__c =  :recordId  And RecordType.DeveloperName = :developerName Order by LastModifiedDate desc];
             if (report != null && !report.isEmpty()) {
-                res.LastModifiedDate = report[0].LastModifiedDate;
-                res.Id = report[0].Id;
-                res.Name = report[0].Name;
-                res.LastModifiedById = report[0].LastModifiedById;
-                res.DeveloperName = report[0].RecordType.DeveloperName;
+                res.lastModifiedDate = report[0].LastModifiedDate;
+                res.id = report[0].Id;
+                res.name = report[0].Name;
+                res.lastModifiedById = report[0].LastModifiedById;
+                res.developerName = report[0].RecordType.DeveloperName;
             }
         } catch (Exception e) {
             System.debug(LoggingLevel.INFO, '*** e: ' + e);
@@ -176,11 +184,11 @@
         try {
             PAE_DecisionRecord__c[] report = [SELECT LastModifiedDate, Id, Name, LastModifiedById,RecordType.DeveloperName FROM PAE_DecisionRecord__c where PAE_Report__c =  :recordId  And RecordType.DeveloperName = :recordTypeId Order by LastModifiedDate desc];
             if (report != null && !report.isEmpty()) {
-                res.LastModifiedDate = report[0].LastModifiedDate;
-                res.Id = report[0].Id;
-                res.Name = report[0].Name;
-                res.LastModifiedById = report[0].LastModifiedById;
-                res.DeveloperName = report[0].RecordType.DeveloperName;
+                res.lastModifiedDate = report[0].LastModifiedDate;
+                res.id = report[0].Id;
+                res.name = report[0].Name;
+                res.lastModifiedById = report[0].LastModifiedById;
+                res.developerName = report[0].RecordType.DeveloperName;
             }
         } catch (Exception e) {
             System.debug(LoggingLevel.INFO, '*** e: ' + e);
@@ -218,34 +226,42 @@
 
     //缁欐彁浜ょ浉搴旂殑js鎻愪緵鍒濆鍖栨暟鎹�
     @AuraEnabled
-    public static void updateForSubmitButton(String reocrdId){
+    public static String updateForSubmitButton(String recordId){
         try {
             Report__c rac = new Report__c();
-            rac.Id = reocrdId;
+            rac.Id = recordId;
             rac.Status__c = LightingButtonConstant.RECORD_TYPE_NAME_BY_SUBMIT;
             rac.Submit_time__c = Datetime.now();
             rac.Submit_report_day__c = Date.today();
             update rac;
+            return null;
         } catch (Exception e) {
-            throw new AuraHandledException(e.getMessage());
+            String eMessage = e.getMessage();
+            Integer left = eMessage.indexOf(',') + 1;
+            Integer right = eMessage.length();
+            return eMessage.substring(left,right);
         }
     }
     //OPDtoSIS鎿嶄綔鏇存柊鐩稿簲鏁版嵁
     @AuraEnabled
-    public static void updateForOPDtoSISButton(String recordId){
+    public static String updateForOPDtoSISButton(String recordId){
         try {
             Report__c rac = new Report__c();
             rac.Id = recordId;
             rac.RecordTypeId = Schema.SObjectType.Report__c.getRecordTypeInfosByName().get(LightingButtonConstant.RECORD_TYPE_NAME_BY_OPD).getRecordTypeId();
             update rac;
+            return null;
         } catch (Exception e) {
-            System.debug(LoggingLevel.INFO, '*** e: ' + e);
+            String eMessage = e.getMessage();
+            Integer left = eMessage.indexOf(',') + 1;
+            Integer right = eMessage.length();
+            return eMessage.substring(left,right);
         }
     }
 
     //鍙栨秷鎻愪氦鎿嶄綔鏇存柊鐩稿簲鏁版嵁
     @AuraEnabled
-    public static void updateForCancelSubmitReportButton(String recordId){
+    public static String updateForCancelSubmitReportButton(String recordId){
         try {
             Report__c rac = new Report__c();
             rac.Id = recordId;
@@ -253,33 +269,45 @@
             rac.Submit_report_day__c = null;
             rac.Submit_time__c = null;
             update rac;
+            return null;
         } catch (Exception e) {
-            throw new AuraHandledException(e.getMessage());
+            String eMessage = e.getMessage();
+            Integer left = eMessage.indexOf(',') + 1;
+            Integer right = eMessage.length();
+            return eMessage.substring(left,right);
         }
     }
     //瀹屾瘯鎿嶄綔鏇存柊鐩稿簲鏁版嵁
     @AuraEnabled
-    public static void updateForCompleteButton(String recordId){
+    public static String updateForCompleteButton(String recordId){
         Report__c rac = new Report__c();
         try {
             rac.Id = recordId;
             rac.Status__c = LightingButtonConstant.STATUS_COMPLETE;
             rac.RecordTypeId = Schema.SObjectType.Report__c.getRecordTypeInfosByName().get(LightingButtonConstant.VOC_NAME).getRecordTypeId();
             update rac;
+            return null;
         } catch (Exception e) {
-            throw new AuraHandledException(e.getMessage());
+            String eMessage = e.getMessage();
+            Integer left = eMessage.indexOf(',') + 1;
+            Integer right = eMessage.length();
+            return eMessage.substring(left,right);
         }
     }
     //OCSM瑕佹姤鍛婃搷浣滄洿鏂扮浉搴旀暟鎹�
     @AuraEnabled
-    public static void updateForOCSMToReportButton(String recordId){
+    public static String updateForOCSMToReportButton(String recordId){
         try {
             Report__c rac = new Report__c();
             rac.Id = recordId;
             rac.OCSMAdministrativeReportStatus__c = LightingButtonConstant.STATUS_TO_BE_REPORTED;
             update rac;
+            return null;
         } catch (Exception e) {
-            System.debug(LoggingLevel.INFO, '*** e: ' + e);
+            String eMessage = e.getMessage();
+            Integer left = eMessage.indexOf(',') + 1;
+            Integer right = eMessage.length();
+            return eMessage.substring(left,right);
         }
     }
 
@@ -293,58 +321,73 @@
             update rac;
             return null;
         } catch (Exception e) {
-            return e.getMessage();
+            String eMessage = e.getMessage();
+            Integer left = eMessage.indexOf(',') + 1;
+            Integer right = eMessage.length();
+            return eMessage.substring(left,right);
         }
     }
     //DispatchOCSMQARA鎿嶄綔鏇存柊鐩稿簲鏁版嵁
     @AuraEnabled
-    public static void updateForDispatchOCSMQARAButton(String recordId){
+    public static String updateForDispatchOCSMQARAButton(String recordId){
         try {
             Report__c rac = new Report__c();
             rac.Id = recordId;
             rac.Dispatch_OCSM_QARA__c = true;
             update rac;
+            return null;
         } catch (Exception e) {
-            System.debug(LoggingLevel.INFO, '*** e: ' + e);
+            String eMessage = e.getMessage();
+            Integer left = eMessage.indexOf(',');
+            Integer right = eMessage.length();
+            return eMessage.substring(left,right);
         }
     }
     //OCSM涓嶈鎶ュ憡鎿嶄綔鏇存柊鐩稿簲鏁版嵁
     @AuraEnabled
-    public static void updateForOCSMNoToReportButton(String recordId){
+    public static String updateForOCSMNoToReportButton(String recordId){
         try {
             Report__c rac = new Report__c();
             rac.Id = recordId;
             rac.OCSMAdministrativeReportStatus__c  = LightingButtonConstant.STATUS_TO_NOT_REPORT;
             update rac;
+            return null;
         } catch (Exception e) {
-            System.debug(LoggingLevel.INFO, '*** e: ' + e);
+            String eMessage = e.getMessage();
+            Integer left = eMessage.indexOf(',');
+            Integer right = eMessage.length();
+            return eMessage.substring(left,right); 
         }
     }
 
     //鍙栨秷鎿嶄綔鏇存柊鐩稿簲鏁版嵁
     @AuraEnabled
-    public static void updateForCancelButton(String recordId){
+    public static String updateForCancelButton(String recordId){
         try {
             Report__c rac = new Report__c();
             rac.Id = recordId;
             rac.Status__c = LightingButtonConstant.STATUS_CANCEL;
             update rac;
+            return null;
         } catch (Exception e) {
-            System.debug(LoggingLevel.INFO, '*** e: ' + e);
+            String eMessage = e.getMessage();
+            Integer left = eMessage.indexOf(',');
+            Integer right = eMessage.length();
+            return eMessage.substring(left,right);
         }
     }
     
     //VOC缁撴灉纭鏇存柊鐩稿簲鏁版嵁
     @AuraEnabled
-    public static void updateForVOCConfirmButton(String recordId,String Satisfy,String Satisfy1){
+    public static String updateForVOCConfirmButton(String recordId,String satisfy,String satisfy1){
         try {
             Report__c rac = new Report__c();
             rac.Id = recordId;
-            if (Satisfy == LightingButtonConstant.CN_YES) {
+            if (satisfy == LightingButtonConstant.CN_YES) {
                 rac.Status__c = LightingButtonConstant.STATUS_VOC_CONFIRMED;
-                } else if (Satisfy == LightingButtonConstant.CN_NO) {
+                } else if (satisfy == LightingButtonConstant.CN_NO) {
                 // 瀵惧繙绲愭灉锛堜竴鍥炵洰锛夈伀鍊ゃ仾銇戙倢銇般�佷竴鍥炵洰銇�屽惁銆嶃仺瑕嬨仾銇�
-                if (Satisfy1 != LightingButtonConstant.CN_NO) {
+                if (satisfy1 != LightingButtonConstant.CN_NO) {
                 Report__c[] records = [SELECT Id, VOC_Satisfy__c, VOC_Unsatisfy_Reason__c, VOC_follow_up_result__c, VOC_solution_category__c FROM Report__c WHERE Id = :recordId];
                 rac.VOC_Satisfy__c = null;
                 rac.VOC_Unsatisfy_Reason__c = null;
@@ -362,8 +405,12 @@
                 }
                 }
             update rac;
+            return null;
         } catch (Exception e) {
-            System.debug(LoggingLevel.INFO, '*** e: ' + e);
+            String eMessage = e.getMessage();
+            Integer left = eMessage.indexOf(',');
+            Integer right = eMessage.length();
+            return eMessage.substring(left,right);
         }
     }
     //VOC鍥炵瓟鏇存柊鐩稿簲鏁版嵁
@@ -388,7 +435,7 @@
 
     //鎻愪氦绔炰簤瀵规墜鎶ュ憡鏇存柊鐩稿簲鏁版嵁
     @AuraEnabled
-    public static void updateForSubmitCompetitorReportButton(String recordId){
+    public static String updateForSubmitCompetitorReportButton(String recordId){
         try {
             Report__c rac = new Report__c();
             rac.Id = recordId;
@@ -397,13 +444,17 @@
             rac.Submit_report_day__c = Date.today();
             rac.Date__c = Date.today();
             update rac;
+            return null;
         } catch (Exception e) {
-            System.debug(LoggingLevel.INFO, '*** e: ' + e);
+            String eMessage = e.getMessage();
+            Integer left = eMessage.indexOf(',');
+            Integer right = eMessage.length();
+            return eMessage.substring(left,right);
         }
     }
     //VOC鍥炵瓟鏇存柊鐩稿簲鏁版嵁
     @AuraEnabled
-    public static void updateForVOCSubmitButton(String recordId ,String createdById){
+    public static String updateForVOCSubmitButton(String recordId ,String createdById){
         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
@@ -424,15 +475,18 @@
             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;
+            return null;
             }
             rac.Status__c = LightingButtonConstant.STATUS_VOC_WRITE_OVER;
             rac.Submit_time__c = Date.today();
             rac.Submit_report_day__c = Date.today();
             update rac;
+            return null;
         } catch (Exception e) {
-            System.debug(LoggingLevel.INFO, '*** e: ' + e);
-            
+            String eMessage = e.getMessage();
+            Integer left = eMessage.indexOf(',');
+            Integer right = eMessage.length();
+            return eMessage.substring(left, right);
         }
     }
     //VOC鍒ゅ畾鏇存柊鐩稿簲鏁版嵁
@@ -480,14 +534,38 @@
     }
     //VOC瀹屾瘯鎿嶄綔鏇存柊鐩稿簲鏁版嵁
     @AuraEnabled
-    public static void updateForVOCFinishButton (String recordId) {
+    public static String updateForVOCFinishButton (String recordId) {
         try {
             Report__c report = [select Id,Status__C from Report__c where Id = :recordId];
             report.Status__c = LightingButtonConstant.STATUS_VOC_FINISH;
             update report;
+            return null;
         } catch (Exception e) {
-            System.debug(LoggingLevel.INFO, '*** e: ' + e);
+            String eMessage = e.getMessage();
+            Integer left = eMessage.indexOf(',');
+            Integer right = eMessage.length();
+            return eMessage.substring(left,right);
         }
+    }
+    @AuraEnabled
+    public static string getUserIdByName(String name){
+        User user = null;
+        try {
+            user = [select Id from User where Name =:name]; 
+        } catch (Exception e) {
+            throw new AuraHandledException(e.getMessage());
+        }
+        return user.Id;
+    }
+    @AuraEnabled
+    public static string getProfileIdByName(String name){
+        Profile profile = null;
+        try {
+            profile = [select Id from Profile where Name =:name];
+        } catch (Exception e) {
+            throw new AuraHandledException(e.getMessage());
+        }
+        return profile.Id;
     }
     public class InitData{
         @AuraEnabled
@@ -501,32 +579,37 @@
         @AuraEnabled
         public String ownerId;
         @AuraEnabled
-        public String Satisfy;
+        public String satisfy;
         @AuraEnabled
-        public String Satisfy1;
+        public String satisfy1;
         @AuraEnabled
         public String profileId;
         @AuraEnabled
-        public String OCSMAdministrativeReportNumber;
+        public String theOCSMAdministrativeReportNumber;
         @AuraEnabled
-        public Date OCSMAdministrativeReportDate;
+        public Date theOCSMAdministrativeReportDate;
         @AuraEnabled
         public Date awareDate;
         @AuraEnabled
-        public String OCSMAdministrativeReportStatus;
+        public String theOCSMAdministrativeReportStatus;
         @AuraEnabled
-        public Datetime LastModifiedDate;
+        public Datetime lastModifiedDate;
         @AuraEnabled
-        public String Id;
+        public String id;
         @AuraEnabled
-        public String Name;
+        public String name;
         @AuraEnabled
-        public String LastModifiedById;
+        public String lastModifiedById;
         @AuraEnabled
-        public String DeveloperName;
+        public String developerName;
         @AuraEnabled
         public String userId;
-
+        @AuraEnabled
+        public String luShengId;
+        @AuraEnabled
+        public String huDiAnId;
+        @AuraEnabled
+        public String systemProfileId;
         
 
 

--
Gitblit v1.9.1