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 |  597 +++++++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 456 insertions(+), 141 deletions(-)

diff --git a/force-app/main/default/classes/ReportController.cls b/force-app/main/default/classes/ReportController.cls
index de418fe..8535a6b 100644
--- a/force-app/main/default/classes/ReportController.cls
+++ b/force-app/main/default/classes/ReportController.cls
@@ -1,4 +1,46 @@
+/* 
+鐢ㄤ簬缁檒wc鐨刯s鍒濆鍖栨暟鎹拰瀵硅褰曡繘琛宒ml鎿嶄綔锛屾controller灞炰簬鎶ュ憡涔�
+*/
 public with sharing class ReportController {
+
+    @AuraEnabled
+    public static InitData initForOPDReportConsumButton(String recordId){
+        InitData res = new initData();
+        try {
+            Consum_Apply__c con = [select RA_Status__c,Product_category__c,Id,Hospital__c,Strategic_dept__c,Account__c from Consum_Apply__c where Id =: recordId];
+            res.raStatus = con.RA_Status__c;
+            res.productCategory = con.Product_category__c;
+            res.consumApplyId = con.Id;
+            res.hospital = con.Hospital__c;
+            res.strategicDept = con.Strategic_dept__c;
+            res.account = con.Account__c;
+            res.recordTypeId1 = Schema.SObjectType.Report__c.getRecordTypeInfosByName().get(lexLightingButtonConstant.RECORD_TYPE_NAME_BY_SIS_ENG).getRecordTypeId();
+            res.recordTypeId = Schema.SObjectType.Report__c.getRecordTypeInfosByName().get(lexLightingButtonConstant.RECORD_TYPE_NAME_BY_SIS_ET).getRecordTypeId();
+        } catch (Exception e) {
+            throw new AuraHandledException(e.getMessage());
+        }
+        return res;
+    }
+    @AuraEnabled
+    public static InitData initForOPDReportButton(String recordId){
+        InitData res = new initData();
+        try {
+            Rental_Apply__c rent = [select RA_Status__c,Asset_return_day2__c,Hospital__c,Strategic_dept__c,Account__c,OPDPlan__c,Follow_UP_Opp__c,demo_purpose2__c from Rental_Apply__c where Id =: recordId];
+            res.raStatus = rent.RA_Status__c;
+            res.assetReturnDay2 = rent.Asset_return_day2__c;
+            res.hospitalId = rent.Hospital__c;
+            res.strategicDeptId = rent.Strategic_dept__c;
+            res.accountId = rent.Account__c;
+            res.demoPurpose2 = rent.demo_purpose2__c;
+            res.followUPOpp = rent.Follow_UP_Opp__c;
+            res.opdPlan = rent.OPDPlan__c;
+            res.recordTypeId = Schema.SObjectType.Report__c.getRecordTypeInfosByName().get(lexLightingButtonConstant.RECORD_TYPE_NAME_BY_OPD).getRecordTypeId();
+        } catch (Exception e) {
+            throw new AuraHandledException(e.getMessage());
+        }
+        return res;
+    }
+    //缁橵OC瀹屾瘯鐩稿簲鐨刯s鎻愪緵鍒濆鍖栨暟鎹�
     @AuraEnabled
     public static InitData initForVOCFinishButton (String recordId) {
         InitData res = new initData();
@@ -6,12 +48,17 @@
             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);
         } 
         return res;
     }
+    //缁橵OC鍒ゅ畾鐩稿簲鐨刯s鎻愪緵鍒濆鍖栨暟鎹�
     @AuraEnabled
     public static InitData initForVOCCheckButton (String recordId) {
         InitData res = new initData();
@@ -21,13 +68,17 @@
             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);
         } 
         return res;
     }
-
+    //缁橵OC鎻愬嚭鐩稿簲鐨刯s鎻愪緵鍒濆鍖栨暟鎹�
     @AuraEnabled
     public static Initdata initForVOCSubmitButton(String recordId){
         InitData res = new InitData();
@@ -44,7 +95,7 @@
     }
 
 
-
+    //缁橵OC鍥炵瓟鐩稿簲鐨刯s鎻愪緵鍒濆鍖栨暟鎹�
     @AuraEnabled
     public static Initdata initForVOCAnswerButton(String recordId){
         InitData res = new InitData();
@@ -57,15 +108,15 @@
         }
         return res;
     }
-
+    //缁橵OC缁撴灉纭鐩稿簲鐨刯s鎻愪緵鍒濆鍖栨暟鎹�
     @AuraEnabled
     public static InitData initForVOCConfirmButton (String recordId) {
         InitData res = new initData();
         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);
@@ -73,7 +124,7 @@
         return res;
     }
 
-
+    //缁欏彇娑堢浉搴旂殑js鎻愪緵鍒濆鍖栨暟鎹�
     @AuraEnabled
     public static InitData initForCancelButton(String recordId){
         InitData res = new InitData();
@@ -86,22 +137,21 @@
         return res;
     }
 
-
+    //缁橭CSM涓嶈鎶ュ憡鐩稿簲鐨刯s鎻愪緵鍒濆鍖栨暟鎹�
     @AuraEnabled
     public static InitData initForOCSMNoToReportButton(String recordId){
         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);
         }
         return res;
     }
-
-
+    //缁橲IStoOPD鐩稿簲鐨刯s鎻愪緵鍒濆鍖栨暟鎹�
     @AuraEnabled
     public static InitData initForSIStoOPDButton(String recordId){
         InitData res = new InitData();
@@ -116,13 +166,13 @@
         return res;
     }
 
-
+    //缁橭CSM瑕佹姤鍛婄浉搴旂殑js鎻愪緵鍒濆鍖栨暟鎹�
     @AuraEnabled
     public static InitData initForOCSMToReportButton(String recordId){
         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);
@@ -130,7 +180,7 @@
         return res;
     }
 
-
+    //缁欏畬姣曠浉搴旂殑js鎻愪緵鍒濆鍖栨暟鎹�
     @AuraEnabled
     public static InitData initForCompleteButton(String recordId){
         InitData res = new InitData();
@@ -143,19 +193,19 @@
         }
         return res;
     }
-
+    //缁橧ntake universal code缂栬緫鐩稿簲鐨刯s鎻愪緵鍒濆鍖栨暟鎹�
     @AuraEnabled
     public static InitData initForASRCEditorButton(String recordId){
         InitData res = new InitData();
-        String recordTypeId = 'ASRCDecision';
+        String developerName = LightingButtonConstant.DEVELOPER_NAME_ASRC_DECISION;
         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];
+            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);
@@ -164,19 +214,19 @@
     }
 
 
-
+    //缁橣inal universal code缂栬緫鐩稿簲鐨刯s鎻愪緵鍒濆鍖栨暟鎹�
     @AuraEnabled
     public static InitData initForASACEditorButton(String recordId){
         InitData res = new InitData();
-        String recordTypeId = 'ASACDecision';
+        String recordTypeId = LightingButtonConstant.DEVELOPER_NAME_ASAC_DECISION;
         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);
@@ -185,7 +235,7 @@
     }
 
 
-
+    //缁橭PDtoSIS鐩稿簲鐨刯s鎻愪緵鍒濆鍖栨暟鎹�
     @AuraEnabled
     public static InitData initForOPDtoSISButton(String recordId){
         InitData res = new InitData();
@@ -200,7 +250,7 @@
         return res;
     }
 
-
+    //缁欐彁浜�(瀵规墜娲诲姩鎶ュ憡)鐩稿簲鐨刯s鎻愪緵鍒濆鍖栨暟鎹�
     @AuraEnabled
     public static InitData initForSubmitCompetitorReportButton(String recordId){
         InitData res = null;
@@ -211,135 +261,262 @@
         }
         return res;
     }
-
-
     @AuraEnabled
-    public static void updateForSubmitButton(String reocrdId){
+    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
+    public static String updateForSubmitButton(String recordId){
         try {
             Report__c rac = new Report__c();
-            rac.Id = reocrdId;
-            rac.Status__c = '鎻愪氦';
+            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());
+            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鎿嶄綔鏇存柊鐩稿簲鏁版嵁
     @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 = '01210000000RLTi';
+            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);
+            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
-    public static void updateForCancelSubmitReportButton(String recordId){
+    public static String updateForCancelSubmitReportButton(String recordId){
         try {
             Report__c rac = new Report__c();
             rac.Id = recordId;
-            rac.Status__c = '鑽夋涓�';
+            rac.Status__c = LightingButtonConstant.STATUS_DRAFT;
             rac.Submit_report_day__c = null;
             rac.Submit_time__c = null;
             update rac;
+            return null;
         } catch (Exception e) {
-            throw new AuraHandledException(e.getMessage());
+            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
-    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 = '瀹屾瘯';
-            rac.RecordTypeId = '01210000000Qeky';
+            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());
+            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瑕佹姤鍛婃搷浣滄洿鏂扮浉搴旀暟鎹�
     @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 = '寰呮姤鍛�';
+            rac.OCSMAdministrativeReportStatus__c = LightingButtonConstant.STATUS_TO_BE_REPORTED;
             update rac;
+            return null;
         } catch (Exception e) {
-            System.debug(LoggingLevel.INFO, '*** e: ' + e);
+            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();   
+            }
         }
     }
 
-
+    //SIStoOPD鎿嶄綔鏇存柊鐩稿簲鏁版嵁
     @AuraEnabled
-    public static void updateForSIStoOPDButton(String recordId){
+    public static String updateForSIStoOPDButton(String recordId){
         Report__c rac = new Report__c();
         try {
             rac.Id = recordId;
-            rac.RecordTypeId = '01210000000Qekj';
+            rac.recordTypeId = Schema.SObjectType.Report__c.getRecordTypeInfosByName().get(LightingButtonConstant.RECORD_TYPE_NAME_BY_FOLLOW_THE_STAGE).getRecordTypeId();
             update rac;
+            return null;
         } catch (Exception e) {
-            throw new AuraHandledException(e.getMessage());
+            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鎿嶄綔鏇存柊鐩稿簲鏁版嵁
     @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);
+            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涓嶈鎶ュ憡鎿嶄綔鏇存柊鐩稿簲鏁版嵁
     @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  = '鏃犻渶鎶ュ憡';
+            rac.OCSMAdministrativeReportStatus__c  = LightingButtonConstant.STATUS_TO_NOT_REPORT;
             update rac;
+            return null;
         } catch (Exception e) {
-            System.debug(LoggingLevel.INFO, '*** e: ' + e);
+            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
-    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 = '鍙栨秷';
+            rac.Status__c = LightingButtonConstant.STATUS_CANCEL;
             update rac;
+            return null;
         } catch (Exception e) {
-            System.debug(LoggingLevel.INFO, '*** e: ' + e);
+            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缁撴灉纭鏇存柊鐩稿簲鏁版嵁
     @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 == '鏄�') {
-                rac.Status__c = '缁撴灉纭瀹屾瘯';
-                } else if (Satisfy == '鍚�') {
+            if (satisfy == LightingButtonConstant.CN_YES) {
+                rac.Status__c = LightingButtonConstant.STATUS_VOC_CONFIRMED;
+                } else if (satisfy == LightingButtonConstant.CN_NO) {
                 // 瀵惧繙绲愭灉锛堜竴鍥炵洰锛夈伀鍊ゃ仾銇戙倢銇般�佷竴鍥炵洰銇�屽惁銆嶃仺瑕嬨仾銇�
-                if (Satisfy1 != '鍚�') {
+                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;
@@ -349,115 +526,184 @@
                 rac.VOC_Unsatisfy_Reason1__c = records[0].VOC_Unsatisfy_Reason__c;
                 rac.VOC_follow_up_result1__c = records[0].VOC_follow_up_result__c;
                 rac.VOC_solution_category1__c = records[0].VOC_solution_category__c;
-                rac.Status__c = '鑽夋涓�';
+                rac.Status__c = LightingButtonConstant.STATUS_DRAFT;
                 }
                 // 瀵惧繙绲愭灉锛堜竴鍥炵洰锛夈伀鍊ゃ亗銈屻伆銆佷簩鍥炵洰銇�屽惁銆嶃仺瑕嬨仾銇�
                 else {
-                rac.Status__c = '缁撴灉纭瀹屾瘯';
+                rac.Status__c = LightingButtonConstant.STATUS_VOC_CONFIRMED;
                 }
                 }
             update rac;
+            return null;
         } catch (Exception e) {
-            System.debug(LoggingLevel.INFO, '*** e: ' + e);
+            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鍥炵瓟鏇存柊鐩稿簲鏁版嵁
     @AuraEnabled
     public static String updateForVOCAnswerButton(String recordId){
         try {
             Report__c rac = [select Status__c from Report__c where Id = :recordId];
-            rac.Status__c = '鍥炵瓟瀹屾瘯';
+            rac.Status__c = LightingButtonConstant.STATUS_VOC_END_OF_ANSWER;
             update rac;
             return null;
         } catch (Exception e) {
-            System.debug(LoggingLevel.INFO, '*** e: ' + e);
-            String exc = '' + e.getMessage();
-            
-            return exc;
+            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
-    public static void updateForSubmitCompetitorReportButton(String recordId){
+    public static String updateForSubmitCompetitorReportButton(String recordId){
         try {
             Report__c rac = new Report__c();
             rac.Id = recordId;
-            rac.Status__c = '鐢宠珛涓�';
+            rac.Status__c = LightingButtonConstant.STATUS_VOC_APPLYING;
             rac.Submit_time__c = Datetime.now();
             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);
+            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鍥炵瓟鏇存柊鐩稿簲鏁版嵁
     @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
-            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 == '閿�鍞湇鍔�') {
-            userAccess.add(rac.JingliApprovalManager__c + '_Read');
-            userAccess.add(rac.BuchangApprovalManager__c + '_Read');
-            rac.VOC_CreatedBy_jingli__c = rac.JingliApprovalManager__c;
-            rac.VOC_CreatedBy_buzhang__c = rac.BuchangApprovalManager__c;
+            if (records[0].Job_Category__c == LightingButtonConstant.TYPE_OF_SALES_SERVICES) {
+            if(rac.JingliApprovalManager__c != null){
+                userAccess.add(rac.JingliApprovalManager__c + LightingButtonConstant.USER_ACCESS_READ);
+                rac.VOC_CreatedBy_jingli__c = rac.JingliApprovalManager__c;
+            }
+            if(rac.BuchangApprovalManager__c != null){
+                userAccess.add(rac.BuchangApprovalManager__c + LightingButtonConstant.USER_ACCESS_READ);
+                rac.VOC_CreatedBy_buzhang__c = rac.BuchangApprovalManager__c;
+            }
+            
+            
             } else {
-            userAccess.add(rac.SalesManager__c + '_Read');
-            userAccess.add(rac.BuchangApprovalManagerSales__c + '_Read');
-            rac.VOC_CreatedBy_jingli__c = rac.SalesManager__c;
-            rac.VOC_CreatedBy_buzhang__c = rac.BuchangApprovalManagerSales__c;
+                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;
+                }
+           
+            
+            
+            
             }
-            userAccess.add(rac.ZongjianApprovalManager__c + '_Read');
-            String rtn = ControllerUtil.setSObjectShare('Report__Share','VOCShare__c',recordId,userAccess,rac.Owner.Id);
-            if (rtn != 'OK') {
-            return;
+            if(rac.ZongjianApprovalManager__c != null){
+                userAccess.add(rac.ZongjianApprovalManager__c + LightingButtonConstant.USER_ACCESS_READ);
             }
-            rac.Status__c = '濉啓瀹屾瘯';
+            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 rtn;
+            }
+            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);
-            
+            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鍒ゅ畾鏇存柊鐩稿簲鏁版嵁
     @AuraEnabled
     public static String updateForVOCCheckButton (String recordId,String isVOC,String personId) {          
         try {
             Report__c rac = [select Owner.Id,VOC_jingli__r.Id,VOC_buzhang__r.Id,VOC_zongjian__r.Id,VOC_Finish__c,VOC_share_date__c,Responsible_Person__r.Id from Report__c where Id = :recordId];
-            if (isVOC == 'VOC') {
+            if (isVOC == LightingButtonConstant.VOC_NAME) {
                 // 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 == '閿�鍞湇鍔�') {
-                    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;
+                if (records[0].job_Category__c == LightingButtonConstant.TYPE_OF_SALES_SERVICES) {
+                    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.Status__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 + '_Edit');
-                userAccess.add(rac.VOC_jingli__c + '_Read');
-                userAccess.add(rac.VOC_buzhang__c + '_Read');
-                userAccess.add(rac.VOC_zongjian__c + '_Read');
-                String rtn = ControllerUtil.setSObjectShare('Report__Share','VOCShare__c',recordId,userAccess,rac.Owner.Id);
-                if (rtn != 'OK') {
-                    return null;
+                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 rtn;
                 }
                 update rac;
                 } else {
-                    rac.Status__c = '瀹屾瘯';
+                    rac.Status__c = LightingButtonConstant.STATUS_VOC_FINISH;
                     rac.VOC_Finish__c = true;
                     update rac;
                 }
@@ -468,15 +714,48 @@
             return exc;
         }
     }
+    //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 = '瀹屾瘯';
+            report.Status__c = LightingButtonConstant.STATUS_VOC_FINISH;
             update report;
+            return null;
         } catch (Exception e) {
-            System.debug(LoggingLevel.INFO, '*** e: ' + e);
+            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
+    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
@@ -490,36 +769,72 @@
         @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;
+        @AuraEnabled
+        public String raStatus;
+        @AuraEnabled
+        public String productCategory;
+        @AuraEnabled
+        public String hospitalId;
+        @AuraEnabled
+        public String hospital;
+        @AuraEnabled
+        public String strategicDeptId;
+        @AuraEnabled
+        public String strategicDept;
+        @AuraEnabled
+        public String accountId;
+        @AuraEnabled
+        public String account;
+        @AuraEnabled
+        public String rentalApplyId;
+        @AuraEnabled
+        public String consumApplyId;
+        @AuraEnabled
+        public String recordTypeId;
+        @AuraEnabled
+        public String recordTypeId1;
+        @AuraEnabled
+        public Date assetReturnDay2;
+        @AuraEnabled
+        public String followUPOpp;
+        @AuraEnabled
+        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