19626
2023-09-09 e14d6d0619330cad423f06493e3aa2371faa2a8f
force-app/main/default/classes/lexSolutionProjectRequirementsController.cls
@@ -1,27 +1,70 @@
public with sharing class lexSolutionProjectRequirementsController {
    @AuraEnabled
    public static InitData initSubmitSolutionForApprovalButton(String recordId){
    public static Map<String,Object> initSubmitSolutionForApprovalButton(String recordId){
        InitData res = new InitData();
        Map<String,Object> maps = new Map<String,Object>();
        try {
            SolutionProjectRequirements__c so = [
                select
                Status__c,
                Submit_Date_YouWant__c,
                CreatedDate,
                Department_Class__r.Id,
                Department_Class__c,
                Product_Leader__c
                from SolutionProjectRequirements__c where Id =: recordId
            ];
            res.status = so.Status__c;
            res.submitDateYouWant = so.Submit_Date_YouWant__c;
            res.createdDate = so.CreatedDate;
            res.departmentClassId = so.Department_Class__r.Id;
            res.departmentClassId = so.Department_Class__c;
            res.productLeader = so.Product_Leader__c;
            res.userId = UserInfo.getUserId();
            res.userName = UserInfo.getUserName();
            maps.put('res', res);
        } catch (Exception e) {
            String message = e.getMessage();
            maps.put('error', message);
            return maps;
        }
        return maps;
    }
    @AuraEnabled
    public static InitData initForApplyAgainButton(String recordId){
        InitData res = new InitData();
        try {
            SolutionProjectRequirements__c so = [
                select
                Department_Class__c,
                Hospital__c
                from SolutionProjectRequirements__c where Id =: recordId
            ];
            res.hospital = so.Hospital__c;
            res.departmentClass = so.Department_Class__c;
        } catch (Exception e) {
            throw new AuraHandledException(e.getMessage());
        }
        return res;
    }
    @AuraEnabled
    public static InitData initForClosingCaseFlowButton(String recordId){
        InitData res = new InitData();
        try {
            SolutionProjectRequirements__c so = [
                select
                Status__c
                from SolutionProjectRequirements__c where Id =: recordId
            ];
            res.status = so.Status__c;
            res.profileId = UserInfo.getProfileId();
            res.m2ProfileId = [select Id from Profile where Name =: lexLightingButtonConstant.M2_PROFILE_NAME].Id;
        } catch (Exception e) {
            throw new AuraHandledException(e.getMessage());
        }
        return res;
    }
    @AuraEnabled
    public static string updateSubmitSolutionForApprovalButton(String recordId){
@@ -33,7 +76,33 @@
            update so;
            return '';
        } catch (Exception e) {
            return e.getMessage();
            if (e.getMessage().contains(':')) {
                String eMessage = e.getMessage();
                Integer left = eMessage.indexOf(',') + 1;
                Integer right = eMessage.lastIndexOf('。') + 1;
                return eMessage.substring(left,right);
            }else {
                return e.getMessage();
            }
        }
    }
    @AuraEnabled
    public static string updateForClosingCaseFlowButton(String recordId){
        SolutionProjectRequirements__c so = new SolutionProjectRequirements__c();
        try {
            so.Id = recordId;
            so.Status__c = '07结案';
            update so;
            return '';
        } catch (Exception e) {
            if (e.getMessage().contains(',')) {
                String eMessage = e.getMessage();
                Integer left = eMessage.indexOf(',');
                Integer right = eMessage.length();
                return eMessage.substring(left + 1,right);
            }else {
                return e.getMessage();
            }
        }
    }
@@ -53,6 +122,35 @@
        }
        return accList;
    }
    @AuraEnabled
    public static List<Solution_Programme__c> queryForSolutionProgramme(String recordId){
        List<Solution_Programme__c> so = new List<Solution_Programme__c>();
        try {
            so = [
                select id,
                Scheme_Type__c,
                ApprovalClosingProgramme__c
                from Solution_Programme__c where SolutionProjectRequirements__c =: recordId and Scheme_Type__c = '结案'
            ];
        } catch (Exception e) {
            throw new AuraHandledException(e.getMessage());
        }
        return so;
    }
    @AuraEnabled
    public static List<solutionClosingAttachment__c> queryForAttachments1(String solprogrammeId){
        List<solutionClosingAttachment__c> so = new List<solutionClosingAttachment__c>();
        try {
            so = [
                select id,name from solutionClosingAttachment__c where Solution_Programme__c =: solprogrammeId
            ];
        } catch (Exception e) {
            throw new AuraHandledException(e.getMessage());
        }
        return so;
    }
    class InitData{
        @AuraEnabled
        public String status;
@@ -68,5 +166,15 @@
        public String userName;
        @AuraEnabled
        public String productLeader;
        @AuraEnabled
        public String profileId;
        @AuraEnabled
        public String m2ProfileId;
        @AuraEnabled
        public String oldProjectNo;
        @AuraEnabled
        public String departmentClass;
        @AuraEnabled
        public String hospital;
    }
}