# E10密码修改MQ广播推送对接文档

**Source:** <https://www.e-cology.com.cn/sp/doc/docShare/1001451382772293842?tenantKey=t7akvdnf84>

**Share ID:** 1001451382772293842

**Document ID:** 2001636856203577895

**前言：E10密码变更支持MQ广播发送，有需求对接的可以做监听**

**版本支持： 支持20240402基线版本后（包含20240402基线）**

**通过ESB配置监听MQ实现（ESB相关配置方法可咨询陈正）**

 

**一、监听MQ**

监听topic

topicname : passport_pwd_change

消息体内容：

    JSONObject object = new JSONObject();
    // user_info相关信息
    buildUserInfo(dto.getUserId(), object);
    object.put("jobNum", jobNum); // 员工工号（对应employee表jobnum字段）
    object.put("password", newPwd); // 明文密码
    object.put("passwordEncode", encodePassword); // 密文密码
    // 注意原密码仅在 用户前台操作会输入原密码的场景下 MQ才会进行发送否则不会存在原密码
    object.put("oldPassword", dto.getOldPassword());// 明文原密码
    object.put("oldPasswordEncode", oldEncodePassword);// 密文原密码
    object.put("employeeId", employeeId); // 员工id
    object.put("userId", userId);// 用户账号id
    object.put("tenantKey", tenantKey);// 组织代码（租户key）

    public void buildUserInfo(Long userId, JSONObject returnObj) {
        UserInfo info = userInfoService.findById(userId);
        if (StringUtils.isNotBlank(info.getAccount())) {
            returnObj.put("account", info.getAccount());
        }
        if (StringUtils.isNotBlank(info.getEmail())) {
            returnObj.put("email", info.getEmail());
        }
        if (StringUtils.isNotBlank(info.getMobile())) {
            returnObj.put("mobile", info.getMobile());
        }
    }

 

 

 

具体发送代码：（更新20250901基线配合ESB调整传递对象从String调整为Jsonobject）

```
public void mqSend(BasicCommonPasswordDto dto) {
    String topicName = "passport_pwd_change";
    // 修改密码为用户级别则针对用户下所有employee进行广播
    Long userId = dto.getUserId();
    String newPwd = dto.getPassword();
    String oriPwd = null;

    // 通过user_id查询人员并进行广播
    HrmOrgEmpCondition con = new HrmOrgEmpCondition();
    con.setUserIds(Collections.singletonList(userId)).setAccounttype(0).setTypeList(Arrays.asList("inside", "external"))
            .setUserStatusList(Collections.singletonList(UserStatus.normal));
    List<HrmEmployee> hrmEmployees = hrmCommonEmployeeService.queryEmpsByCondidtion(con, HrmConditionResultType.BEAN.name());
    for (HrmEmployee hrmEmployee : hrmEmployees) {
        String tenantKey = hrmEmployee.getTenantKey();
        Long employeeId = hrmEmployee.getId();
        String jobNum = hrmEmployee.getJobNum();
        try {
            logger.info("commonPassportPasswordChangeMq param tenantKey userId employeeId newPwd oriPwd {} {} {} {} {}", tenantKey, userId, employeeId, newPwd, oriPwd);
            String encodePassword = encryptPassword(dto.getPassword(), dto);
            logger.info("commonPassportPasswordChangeMq encodePassword {}", encodePassword);
            //AsyncBean<String> asyncBean = new AsyncBean<>();
            AsyncBean<JSONObject> asyncBean = new AsyncBean<>();
            asyncBean.setTenantKey(tenantKey);
            asyncBean.setTopic(topicName);
            JSONObject object = new JSONObject();
            // user_info相关信息
            buildUserInfo(dto.getUserId(), object);
            object.put("jobNum", jobNum);
            object.put("password", newPwd);
            object.put("passwordEncode", encodePassword);
       // 原密码相关
        if(StringUtils.isNotBlank(dto.getOldPassword())){
          String oldEncodePassword = encryptPassword(dto.getOldPassword(), dto);
          object.put("oldPassword", dto.getOldPassword());
          object.put("oldPasswordEncode", oldEncodePassword);
        }
            object.put("employeeId", employeeId);
            object.put("userId", userId);
            object.put("tenantKey", tenantKey);
            //asyncBean.setMessage(object.toJSONString());
            asyncBean.setMessage(object);
            try {
                asyncUtilInter.createExchange(topicName);
            } catch (Exception e) {
                logger.error("commonPassportPasswordChangeMq.createExchange申明交换机失败", e);
            }
            logger.info("commonPassportPasswordChangeMq broadCast mq employeeId {} {}", employeeId, asyncBean.getMessage());
            asyncClient.broadCast(asyncBean);
        } catch (Exception e) {
            logger.error("commonPassportPasswordChangeMq mq broadCast error", e);
        }
    }
}
```

 

**二、二开代码相关**

**需要重点关注：如果是客户环境对传输密码加密方式有要求需要做二开修改加密方式（默认安全组统一加密机）**

**现在二开组不推荐拦截方法的方式二开了 除非客户强烈要求 ，已不在建议二开加密方式了，以下文档可以考虑忽略**

 

 

原加密代码：

    // 这里的加密传输一般会做二开，不同客户传输加密要求不同
        public String encryptPassword(String password, BasicCommonPasswordDto dto) throws Exception {
            // 默认安全组通用加密方式
            SymmetricEncryptionAlgorithm encryptionAlgorithm = new SymmetricEncryptionAlgorithm();
    //        encryptionAlgorithm.setTenantKey(StringUtils.isEmpty(dto.getTenantKey()) ? BasicConstant.DEFAULT_KEY : dto.getTenantKey());
        return encryptionAlgorithm.encrypt(password);
        }

 

新版本安全组加上了租户KEY设置

    // 这里的加密传输一般会做二开，不同客户传输加密要求不同
    public String encryptPassword(String password, BasicCommonPasswordDto dto) throws Exception {
        // 默认安全组通用加密方式
        SymmetricEncryptionAlgorithm encryptionAlgorithm = new SymmetricEncryptionAlgorithm();
       // BasicConstant.DEFAULT_KEY = "all_teams";
        encryptionAlgorithm.setTenantKey(StringUtils.isEmpty(dto.getTenantKey()) ? BasicConstant.DEFAULT_KEY : dto.getTenantKey());
        return encryptionAlgorithm.encrypt(password);
    }

 

二开拦截此方法做加密处理，二开代码可参考如下（具体开发者自行调整）**现在二开组不推荐拦截方法的方式二开了 除非客户强烈要求 ，已不在建议二开加密方式了**：

**二开项目完成后jar包部署后需要重启对应服务：**

**组合部署：重启e10-common 或者 e10-base(具体以环境部署的服务名称为准)**

**单体：重启E10服务**

 

    package com.weaver.seconddev;

    import com.alibaba.nacos.common.codec.Base64;
    import com.weaver.loom.api.annotation.*;
    import com.weaver.loom.api.inter.Holder;
    import lombok.extern.slf4j.Slf4j;
    import org.springframework.stereotype.Component;

    import javax.crypto.Cipher;
    import javax.crypto.spec.SecretKeySpec;

    @Slf4j
    @Hook(value = "com.weaver.passport.mq.PassportPasswordChangeMq")
    @Component
    public class CommonPasswordMqInterrupt {
        
        public static String encrypt(String content) throws Exception {
        // todo 按照客户要求进行加密       
         return "xxxxx";
        }

        @Skip
        @After(method = "encryptPassword(String,BasicCommonPasswordDto)")
        public void handleEncryptPassword(@Returned Holder<String> resultHolder,
                                  Holder<String> passwordHolder,
                                  Holder<BasicCommonPasswordDto> basicCommonPasswordDtoHolder,
                                  @Proxy Object instance) {
            String password = passwordHolder.get();
            try {
                String encryptPassword = encrypt(password);
                resultHolder.set(encryptPassword);
            } catch (Exception e) {
                log.error("handleEncryptPassword encrypt error", e);
            }
        }

    }

 

三、MQ发送开关项控制

**注意：需要用主管理组织的管理员账号登录才能看到系统级设置菜单**

**保存后 等两分钟生效（等待缓存刷新）**

![](https://www.e-cology.com.cn/papi/file/preview?type=redirect&imgFormat=image&fileId=1001451056287309825&customParam=%7B%22authType%22%3A1%2C%22tenantKey%22%3A%22t7akvdnf84%22%2C%22shareOutId%22%3A%221001451382772293842%22%2C%22pwd%22%3A%22%22%2C%22telephone%22%3A%22%22%2C%22email%22%3A%22%22%2C%22docId%22%3A%222001636856203577895%22%2C%22externalId%22%3A%22null%22%7D)

 

 

 

四：动作流相关配置

 

入口 后台管理-\>平台引擎-\>ESB中心-》动作流

 

![](https://www.e-cology.com.cn/papi/file/preview?type=redirect&imgFormat=image&fileId=1064146192786186255&customParam=%7B%22authType%22%3A1%2C%22tenantKey%22%3A%22t7akvdnf84%22%2C%22shareOutId%22%3A%221001451382772293842%22%2C%22pwd%22%3A%22%22%2C%22telephone%22%3A%22%22%2C%22email%22%3A%22%22%2C%22docId%22%3A%222001636856203577895%22%2C%22externalId%22%3A%22null%22%7D)

 

点击新建

![](https://www.e-cology.com.cn/papi/file/preview?type=redirect&imgFormat=image&fileId=1064146407626145834&customParam=%7B%22authType%22%3A1%2C%22tenantKey%22%3A%22t7akvdnf84%22%2C%22shareOutId%22%3A%221001451382772293842%22%2C%22pwd%22%3A%22%22%2C%22telephone%22%3A%22%22%2C%22email%22%3A%22%22%2C%22docId%22%3A%222001636856203577895%22%2C%22externalId%22%3A%22null%22%7D)

选择自定义触发-\>内置mq监听触发组件

 

![](https://www.e-cology.com.cn/papi/file/preview?type=redirect&imgFormat=image&fileId=1064146489281536006&customParam=%7B%22authType%22%3A1%2C%22tenantKey%22%3A%22t7akvdnf84%22%2C%22shareOutId%22%3A%221001451382772293842%22%2C%22pwd%22%3A%22%22%2C%22telephone%22%3A%22%22%2C%22email%22%3A%22%22%2C%22docId%22%3A%222001636856203577895%22%2C%22externalId%22%3A%22null%22%7D)

![](https://www.e-cology.com.cn/papi/file/preview?type=redirect&imgFormat=image&fileId=1064146587888943150&customParam=%7B%22authType%22%3A1%2C%22tenantKey%22%3A%22t7akvdnf84%22%2C%22shareOutId%22%3A%221001451382772293842%22%2C%22pwd%22%3A%22%22%2C%22telephone%22%3A%22%22%2C%22email%22%3A%22%22%2C%22docId%22%3A%222001636856203577895%22%2C%22externalId%22%3A%22null%22%7D)

 

 

配置队列名称和接收参数

 

![](https://www.e-cology.com.cn/papi/file/preview?type=redirect&imgFormat=image&fileId=1064146764134277159&customParam=%7B%22authType%22%3A1%2C%22tenantKey%22%3A%22t7akvdnf84%22%2C%22shareOutId%22%3A%221001451382772293842%22%2C%22pwd%22%3A%22%22%2C%22telephone%22%3A%22%22%2C%22email%22%3A%22%22%2C%22docId%22%3A%222001636856203577895%22%2C%22externalId%22%3A%22null%22%7D)

 

参数按需选择添加

![](https://www.e-cology.com.cn/papi/file/preview?type=redirect&imgFormat=image&fileId=1064147713271037993&customParam=%7B%22authType%22%3A1%2C%22tenantKey%22%3A%22t7akvdnf84%22%2C%22shareOutId%22%3A%221001451382772293842%22%2C%22pwd%22%3A%22%22%2C%22telephone%22%3A%22%22%2C%22email%22%3A%22%22%2C%22docId%22%3A%222001636856203577895%22%2C%22externalId%22%3A%22null%22%7D)

 

 

后续添加对接第三方相关的动作流执行组件如http组件等

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 
