高章伟
2023-03-03 d8dc84a3d56df839895f1c417a4d9cbee763d262
force-app/main/default/classes/HospitalApprovalResponseController.cls
@@ -29,7 +29,13 @@
    // 画面初始化
    public void init() {
        hasError = true;
        List<Account> raList = [select Id, Name, Is_Active__c, Response__c, ResponseNew__c, OwnerId, Owner.Name, Owner.Email, Response_Cc_User1__c, Response_Cc_User2__c, Response_Cc_User3__c, Response_Cc_User4__c, Response_Cc_User5__c from Account where id = : accid ];
        List<Account> raList = [select Id, Name, Is_Active__c, Response__c, ResponseNew__c, OwnerId,
                                       Owner.Name, Owner.Email, Response_Cc_User1__c,
                                       Response_Cc_User2__c, Response_Cc_User3__c, Response_Cc_User4__c,
                                       Response_Cc_User5__c
                                       , Response_Cc_User6__c   //20221212 lt 医院审批优化
                                from Account
                                where id = : accid ];
        
        if (raList.size() > 0) {
            ra = raList[0];
@@ -41,10 +47,14 @@
        cc.Response_Cc_User4__c = null;
        cc.Response_Cc_User5__c = null;
        List<User> toSysUser = [select Id, Name, Email from User where Id = : System.Label.LeaderID_Zhu];
        if (toSysUser.size() > 0) {
            systemUser = toSysUser[0];
        }
        //20221212 lt 医院审批优化 start
        cc.Response_Cc_User6__c = null;
        // List<User> toSysUser = [select Id, Name, Email from User where Id = : System.Label.LeaderID_Zhu];
        // if (toSysUser.size() > 0) {
        //     systemUser = toSysUser[0];
        // }
        //20221212 lt 医院审批优化 end
        // 邮件默认cc
        if (type == 'response2system') {
@@ -89,14 +99,39 @@
        Map<Id, User> userMap = new Map<Id, User>([
            select Id, Name, Email from User where Id in :ccList
        ]);
        //20221212 lt 医院审批优化 start
        List<Id> toList = new List<Id>();
        if (String.isBlank(cc.Response_Cc_User6__c) == false) {
            toList.add(cc.Response_Cc_User6__c);
        }
        Map<Id, User> touserMap = new Map<Id, User>([
            select Id, Name, Email from User where Id in :toList
        ]);
        //20221212 lt 医院审批优化 end
        // 收信者
        String toName = '';
        List<String> toMailList = new List<String>();
        if (type == 'response2system') {
            toName = systemUser.Name;
            toMailList.add(systemUser.Email);
            //20221212 lt 医院审批优化 start
            // toName = systemUser.Name;
            // toMailList.add(systemUser.Email);
            if (touserMap.size() > 0) {
                for (Id id : touserMap.keySet()) {
                    toName += touserMap.get(id).Name + ', ';
                    toMailList.add(touserMap.get(id).Email);
                }
            }
            if (toName != '') {
                toName = toName.left(toName.length() - 2);
            }else if(String.isBlank(toName) == true){
                cc.Response_Cc_User6__c.addError('to审批人必填。');
                return null;
            }
            //20221212 lt 医院审批优化 end
        } else if (type == 'response2user') {
            toName = ra.Owner.Name + '(审批提交人)';
            toName = ra.Owner.Name ;  //+ '(审批提交人)'  lt del
            toMailList.add(ra.Owner.Email);
        }
        // 抄送者
@@ -106,21 +141,21 @@
        //WLIG-BS2CJW  ---20200807---update By rentongxiao ---Start
        //获取 郭 和 油 的信息
        String ydIdsStr = System.Label.LeaderId_YD;
        List<String> ydIds = ydIdsStr.split(',');
        // String ydIdsStr = System.Label.LeaderId_YD;
        // List<String> ydIds = ydIdsStr.split(',');
        List<User> yds = [select Id, Name, Email from User where Id in : ydIds];
        // List<User> yds = [select Id, Name, Email from User where Id in : ydIds];
        if(type == 'response2user'){
            ccName += systemUser.Name + ', ';
            ccMailList.add(systemUser.Email);
            if (yds.size() > 0) {
                for(User u : yds){
                    ccName += u.Name +', ';
                    ccMailList.add(u.Email);
                }
            }
        }
        // if(type == 'response2user'){
        //     ccName += systemUser.Name + ', ';
        //     ccMailList.add(systemUser.Email);
        //     if (yds.size() > 0) {
        //         for(User u : yds){
        //             ccName += u.Name +', ';
        //             ccMailList.add(u.Email);
        //         }
        //     }
        // }
        //WLIG-BS2CJW ---20200807---update By rentongxiao---End