msg, ConsumeConcurrentlyContext consumeConcurrentlyContext)-> RocketUtil.execute(msg, consumeConcurrentlyContext, userInfoService, CONFIG_NAME);
+ }
+
+}
diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/entity/MQMessage.java b/src/main/java/weaver/xuanran/wang/shyl/mq/entity/MQMessage.java
new file mode 100644
index 0000000..1c005ab
--- /dev/null
+++ b/src/main/java/weaver/xuanran/wang/shyl/mq/entity/MQMessage.java
@@ -0,0 +1,44 @@
+package weaver.xuanran.wang.shyl.mq.entity;
+
+import lombok.Data;
+
+/**
+ * mq消息实体类
+ *
+ * @Author xuanran.wang
+ * @Date 2022/12/30 13:09
+ */
+@Data
+public class MQMessage {
+ /**
+ * 消息ID
+ **/
+ private String id;
+ /**
+ * 消息队列名
+ *
+ * AUTH_CONSOLE_USERINFO_TOPIC: 用户队列;
+ * AUTH_CONSOLE_ORG_TOPIC: 机构队列;
+ * AUTH_CONSOLE_USERINFO_PASSWORD_TOPIC: 密码修改队列
+ *
+ **/
+ private String topic;
+ /**
+ * 消息内容操作类型
+ *
+ * CREATE_ACTION:新增;
+ * UPDATE_ACTION: 修改;
+ * DELETE_ACTION: 删除;
+ * PASSWORD_ACTION: 修改密码
+ *
+ **/
+ private String actionType;
+ /**
+ * 消息发送时间
+ **/
+ private String sendTime;
+ /**
+ * 消息业务内容,json 格式,分业务(用户、机构、密码修改)
+ **/
+ private String content;
+}
diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/entity/ModifyPassWord.java b/src/main/java/weaver/xuanran/wang/shyl/mq/entity/ModifyPassWord.java
new file mode 100644
index 0000000..6ba71b3
--- /dev/null
+++ b/src/main/java/weaver/xuanran/wang/shyl/mq/entity/ModifyPassWord.java
@@ -0,0 +1,43 @@
+package weaver.xuanran.wang.shyl.mq.entity;
+
+/**
+ * 密码修改
+ *
+ * @Author xuanran.wang
+ * @Date 2022/12/30 13:59
+ */
+public class ModifyPassWord {
+ /**
+ * 主键
+ **/
+ private String id;
+ /**
+ * 用户ID
+ **/
+ private String uid;
+ /**
+ * 用户账号
+ **/
+ private String username;
+ /**
+ * 用户名称
+ **/
+ private String displayName;
+ /**
+ * 旧密码
+ **/
+ private String oldPassword;
+ /**
+ * 新密码
+ **/
+ private String password;
+ /**
+ * 确认密码
+ **/
+ private String confirmPassword;
+ /**
+ * 盐值
+ **/
+ private String decipherable;
+
+}
diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/entity/Org.java b/src/main/java/weaver/xuanran/wang/shyl/mq/entity/Org.java
new file mode 100644
index 0000000..10c9ad8
--- /dev/null
+++ b/src/main/java/weaver/xuanran/wang/shyl/mq/entity/Org.java
@@ -0,0 +1,38 @@
+
+package weaver.xuanran.wang.shyl.mq.entity;
+
+import lombok.Data;
+
+/**
+ * 机构实体
+ *
+ * @Author xuanran.wang
+ * @Date 2022/12/30 13:56
+ */
+@Data
+public class Org {
+ /**
+ * 机构ID
+ **/
+ private String id;
+ /**
+ * 机构编号
+ **/
+ private String orgCode;
+ /**
+ * 机构名称
+ **/
+ private String orgName;
+ /**
+ * 机构父级ID
+ **/
+ private String parentId;
+ /**
+ * 机构排序号
+ **/
+ private String sortIndex;
+ /**
+ * 机构状态
+ **/
+ private String status;
+}
diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/entity/UserInfo.java b/src/main/java/weaver/xuanran/wang/shyl/mq/entity/UserInfo.java
new file mode 100644
index 0000000..2849a15
--- /dev/null
+++ b/src/main/java/weaver/xuanran/wang/shyl/mq/entity/UserInfo.java
@@ -0,0 +1,61 @@
+package weaver.xuanran.wang.shyl.mq.entity;
+
+import lombok.Data;
+
+/**
+ * 用户实体
+ *
+ * @Author xuanran.wang
+ * @Date 2022/12/30 13:52
+ */
+@Data
+public class UserInfo {
+ /**
+ * 用户ID
+ **/
+ private String id;
+ /**
+ * 用户账号
+ **/
+ private String userName;
+ /**
+ * 用户名称
+ **/
+ private String displayName;
+ /**
+ * 用户性别
+ **/
+ private String gender;
+ /**
+ * 用户生日
+ **/
+ private String birthDate;
+ /**
+ * 用户证件类型
+ **/
+ private String idType;
+ /**
+ * 用户证件号
+ **/
+ private String idCardNo;
+ /**
+ * 用户邮箱
+ **/
+ private String email;
+ /**
+ * 用户手机号
+ **/
+ private String mobile;
+ /**
+ * 用户机构ID
+ **/
+ private String departmentId;
+ /**
+ * 用户机构名称
+ **/
+ private String department;
+ /**
+ * 用户状态
+ **/
+ private String status;
+}
diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/mapper/ConsumerMapper.java b/src/main/java/weaver/xuanran/wang/shyl/mq/mapper/ConsumerMapper.java
new file mode 100644
index 0000000..d9757b1
--- /dev/null
+++ b/src/main/java/weaver/xuanran/wang/shyl/mq/mapper/ConsumerMapper.java
@@ -0,0 +1,35 @@
+package weaver.xuanran.wang.shyl.mq.mapper;
+
+import aiyh.utils.annotation.recordset.ParamMapper;
+import aiyh.utils.annotation.recordset.Update;
+
+/**
+ * 消费者mapper
+ *
+ * @Author xuanran.wang
+ * @Date 2022/12/30 14:19
+ */
+public interface ConsumerMapper {
+
+ /**
+ * 通过outKey更新人员状态为离职
+ * @author xuanran.wang
+ * @dateTime 2022/12/30 14:33
+ * @param outKey 外部系统id
+ * @return 更新成功/失败
+ **/
+ @Update("update hrmresource set status = 5 where outkey = #{outKey}")
+ boolean updateUserStatusByOutKey(@ParamMapper("outKey") String outKey);
+
+ /**
+ * 通过outKey删除部门信息
+ * @author xuanran.wang
+ * @dateTime 2022/12/30 14:33
+ * @param outKey 外部系统id
+ * @return 删除是否成功
+ **/
+ @Update("delete hrmdepartment where outkey = #{outKey}")
+ boolean deleteDepartmentByOutKey(@ParamMapper("outKey") String outKey);
+
+
+}
diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/service/CusInfoActionService.java b/src/main/java/weaver/xuanran/wang/shyl/mq/service/CusInfoActionService.java
new file mode 100644
index 0000000..da25254
--- /dev/null
+++ b/src/main/java/weaver/xuanran/wang/shyl/mq/service/CusInfoActionService.java
@@ -0,0 +1,20 @@
+package weaver.xuanran.wang.shyl.mq.service;
+
+import aiyh.utils.Util;
+import weaver.xuanran.wang.shyl.mq.mapper.ConsumerMapper;
+import weaver.xuanran.wang.shyl.mq.service.interfaces.CreateAction;
+import weaver.xuanran.wang.shyl.mq.service.interfaces.DeleteAction;
+import weaver.xuanran.wang.shyl.mq.service.interfaces.UpdateAction;
+
+/**
+ * 抽象类
+ *
+ * @Author xuanran.wang
+ * @Date 2022/12/30 13:04
+ */
+public abstract class CusInfoActionService implements CreateAction, DeleteAction, UpdateAction {
+ /**
+ * consumer-mapper
+ **/
+ protected final ConsumerMapper consumerMapper = Util.getMapper(ConsumerMapper.class);
+}
diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/service/impl/OrgServiceImpl.java b/src/main/java/weaver/xuanran/wang/shyl/mq/service/impl/OrgServiceImpl.java
new file mode 100644
index 0000000..86212be
--- /dev/null
+++ b/src/main/java/weaver/xuanran/wang/shyl/mq/service/impl/OrgServiceImpl.java
@@ -0,0 +1,28 @@
+package weaver.xuanran.wang.shyl.mq.service.impl;
+
+import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
+import weaver.xuanran.wang.shyl.mq.entity.MQMessage;
+import weaver.xuanran.wang.shyl.mq.service.CusInfoActionService;
+
+/**
+ *
+ *
+ * @Author xuanran.wang
+ * @Date 2022/12/30 15:05
+ */
+public class OrgServiceImpl extends CusInfoActionService {
+ @Override
+ public ConsumeConcurrentlyStatus cusCreateAction(MQMessage message) {
+ return null;
+ }
+
+ @Override
+ public ConsumeConcurrentlyStatus cusDeleteAction(MQMessage message) {
+ return null;
+ }
+
+ @Override
+ public ConsumeConcurrentlyStatus cusUpdateAction(MQMessage message) {
+ return null;
+ }
+}
diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/service/impl/UserServiceImpl.java b/src/main/java/weaver/xuanran/wang/shyl/mq/service/impl/UserServiceImpl.java
new file mode 100644
index 0000000..8beaee6
--- /dev/null
+++ b/src/main/java/weaver/xuanran/wang/shyl/mq/service/impl/UserServiceImpl.java
@@ -0,0 +1,49 @@
+package weaver.xuanran.wang.shyl.mq.service.impl;
+
+import aiyh.utils.Util;
+import aiyh.utils.excention.CustomerException;
+import com.alibaba.fastjson.JSONObject;
+import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
+import weaver.xuanran.wang.shyl.mq.entity.MQMessage;
+import weaver.xuanran.wang.shyl.mq.entity.UserInfo;
+import weaver.xuanran.wang.shyl.mq.mapper.ConsumerMapper;
+import weaver.xuanran.wang.shyl.mq.service.CusInfoActionService;
+
+/**
+ * 用户业务方法
+ *
+ * @Author xuanran.wang
+ * @Date 2022/12/30 13:04
+ */
+public class UserServiceImpl extends CusInfoActionService {
+
+ @Override
+ public ConsumeConcurrentlyStatus cusCreateAction(MQMessage message) {
+ String content = message.getContent();
+ UserInfo userInfo = JSONObject.parseObject(content, UserInfo.class);
+ return null;
+ }
+
+ @Override
+ public ConsumeConcurrentlyStatus cusDeleteAction(MQMessage message) {
+ try {
+ String content = message.getContent();
+ UserInfo userInfo = JSONObject.parseObject(content, UserInfo.class);
+ String id = userInfo.getId();
+ boolean success = consumerMapper.updateUserStatusByOutKey(id);
+ if(!success){
+ throw new CustomerException(Util.logStr("update user status error!"));
+ }
+ return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
+ }catch (Exception e){
+ throw new CustomerException(Util.logStr("cusDeleteAction execute error : [{}]!", e.getMessage()));
+ }
+ }
+
+ @Override
+ public ConsumeConcurrentlyStatus cusUpdateAction(MQMessage message) {
+ String content = message.getContent();
+ UserInfo userInfo = JSONObject.parseObject(content, UserInfo.class);
+ return null;
+ }
+}
diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/service/interfaces/CreateAction.java b/src/main/java/weaver/xuanran/wang/shyl/mq/service/interfaces/CreateAction.java
new file mode 100644
index 0000000..018e37a
--- /dev/null
+++ b/src/main/java/weaver/xuanran/wang/shyl/mq/service/interfaces/CreateAction.java
@@ -0,0 +1,14 @@
+package weaver.xuanran.wang.shyl.mq.service.interfaces;
+
+import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
+import weaver.xuanran.wang.shyl.mq.entity.MQMessage;
+
+/**
+ * 新增接口
+ *
+ * @Author xuanran.wang
+ * @Date 2022/12/30 13:00
+ */
+public interface CreateAction {
+ ConsumeConcurrentlyStatus cusCreateAction(MQMessage message);
+}
diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/service/interfaces/DeleteAction.java b/src/main/java/weaver/xuanran/wang/shyl/mq/service/interfaces/DeleteAction.java
new file mode 100644
index 0000000..ff2bc9e
--- /dev/null
+++ b/src/main/java/weaver/xuanran/wang/shyl/mq/service/interfaces/DeleteAction.java
@@ -0,0 +1,14 @@
+package weaver.xuanran.wang.shyl.mq.service.interfaces;
+
+import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
+import weaver.xuanran.wang.shyl.mq.entity.MQMessage;
+
+/**
+ * 删除接口
+ *
+ * @Author xuanran.wang
+ * @Date 2022/12/30 13:02
+ */
+public interface DeleteAction {
+ ConsumeConcurrentlyStatus cusDeleteAction(MQMessage message);
+}
diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/service/interfaces/PassWordAction.java b/src/main/java/weaver/xuanran/wang/shyl/mq/service/interfaces/PassWordAction.java
new file mode 100644
index 0000000..956e1cb
--- /dev/null
+++ b/src/main/java/weaver/xuanran/wang/shyl/mq/service/interfaces/PassWordAction.java
@@ -0,0 +1,14 @@
+package weaver.xuanran.wang.shyl.mq.service.interfaces;
+
+import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
+import weaver.xuanran.wang.shyl.mq.entity.MQMessage;
+
+/**
+ * 密码修改接口
+ *
+ * @Author xuanran.wang
+ * @Date 2022/12/30 13:03
+ */
+public interface PassWordAction {
+ ConsumeConcurrentlyStatus cusPassWordAction(MQMessage message);
+}
diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/service/interfaces/UpdateAction.java b/src/main/java/weaver/xuanran/wang/shyl/mq/service/interfaces/UpdateAction.java
new file mode 100644
index 0000000..0ad59b4
--- /dev/null
+++ b/src/main/java/weaver/xuanran/wang/shyl/mq/service/interfaces/UpdateAction.java
@@ -0,0 +1,14 @@
+package weaver.xuanran.wang.shyl.mq.service.interfaces;
+
+import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
+import weaver.xuanran.wang.shyl.mq.entity.MQMessage;
+
+/**
+ * 更新接口
+ *
+ * @Author xuanran.wang
+ * @Date 2022/12/30 13:01
+ */
+public interface UpdateAction {
+ ConsumeConcurrentlyStatus cusUpdateAction(MQMessage message);
+}
diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/util/RocketUtil.java b/src/main/java/weaver/xuanran/wang/shyl/mq/util/RocketUtil.java
new file mode 100644
index 0000000..a3af6cc
--- /dev/null
+++ b/src/main/java/weaver/xuanran/wang/shyl/mq/util/RocketUtil.java
@@ -0,0 +1,104 @@
+package weaver.xuanran.wang.shyl.mq.util;
+
+import aiyh.utils.Util;
+import aiyh.utils.excention.CustomerException;
+import com.alibaba.fastjson.JSONObject;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections.MapUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.log4j.Logger;
+import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
+import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
+import org.apache.rocketmq.common.message.MessageExt;
+import weaver.xuanran.wang.shyl.mq.constant.RocketMQConstant;
+import weaver.xuanran.wang.shyl.mq.RocketMQFactory;
+import weaver.xuanran.wang.shyl.mq.entity.MQMessage;
+import weaver.xuanran.wang.shyl.mq.service.CusInfoActionService;
+
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * rocketMQ集成工具类
+ *
+ * @Author xuanran.wang
+ * @Date 2022/12/29 21:03
+ */
+public class RocketUtil {
+ private static final Logger log = Util.getLogger();
+
+ /**
+ * 初始化配置文件对象
+ * @author xuanran.wang
+ * @dateTime 2022/12/29 12:53
+ **/
+ public static Map initMQConfigMap(String configName){
+ Map config = Util.getProperties2Map(configName);
+ if(MapUtils.isEmpty(config)){
+ throw new CustomerException(Util.logStr("please check /filesystem/prop/prop2map {}.properties file is exist!", configName));
+ }
+ for (Map.Entry entry : config.entrySet()) {
+ String key = Util.null2DefaultStr(entry.getKey(),"");
+ String value = Util.null2DefaultStr(entry.getValue(),"");
+ if(StringUtils.isBlank(key) || StringUtils.isBlank(value)){
+ throw new CustomerException(Util.logStr("the config file key is empty or key = {} value is empty!", key));
+ }
+ }
+ log.info(Util.logStr("ConfigName : {} , MQConfig : {} ",configName, JSONObject.toJSONString(config)));
+ return config;
+ }
+
+ /**
+ * 执行自定义业务方法
+ * @author xuanran.wang
+ * @dateTime 2022/12/30 13:34
+ * @param msg mq消息
+ * @param consumeConcurrentlyContext 消费者
+ * @param cusInfoActionService 传具体的业务方法
+ * @param configName 配置名称
+ * @return mq消费状态
+ **/
+ public static ConsumeConcurrentlyStatus execute(List msg, ConsumeConcurrentlyContext consumeConcurrentlyContext,
+ CusInfoActionService cusInfoActionService, String configName){
+ Map configMap = RocketMQFactory.CONFIG_MAPS.get(configName);
+ log.info(Util.logStr("{} service config is {}", configName, JSONObject.toJSONString(configMap)));
+ int maxReconsumeTimes = Util.getIntValue(Util.null2String(configMap.get("MaxReconsumeTimes")),RocketMQConstant.DEFAULT_MAX_RECONSUME_TIMES);
+ try {
+ if (CollectionUtils.isNotEmpty(msg)) {
+ MessageExt messageExt = msg.get(0);
+ String msgBody = "";
+ MQMessage mqMessage = null;
+ try {
+ msgBody = new String(messageExt.getBody(), StandardCharsets.UTF_8);
+ mqMessage = JSONObject.parseObject(msgBody, MQMessage.class);
+ }catch (Exception e){
+ throw new CustomerException(Util.logStr("parse msgBody to Message error current msgBody is {}, the error is {}", msg, e.getMessage()));
+ }
+ String actionType = mqMessage.getActionType();
+ switch (actionType){
+ case RocketMQConstant.CREATE_ACTION:{
+ return cusInfoActionService.cusCreateAction(mqMessage);
+ }
+ case RocketMQConstant.UPDATE_ACTION:{
+ return cusInfoActionService.cusUpdateAction(mqMessage);
+ }
+ case RocketMQConstant.DELETE_ACTION:{
+ return cusInfoActionService.cusDeleteAction(mqMessage);
+ }
+ default: throw new CustomerException(Util.logStr("current actionType : [{}] is not supported!", actionType));
+ }
+ }else {
+ log.error("the msgList is empty!");
+ }
+ } catch (Exception e) {
+ // 如果重试达到最大还是异常那么先返回成功 oa将错误日志记录到日志中
+ if (msg.get(0).getReconsumeTimes() == maxReconsumeTimes) {
+ return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
+ } else {
+ return ConsumeConcurrentlyStatus.RECONSUME_LATER;
+ }
+ }
+ return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
+ }
+}
diff --git a/src/test/java/xuanran/wang/ambofo/checkuser/CheckUserTest.java b/src/test/java/xuanran/wang/ambofo/checkuser/CheckUserTest.java
index ebc2770..a7fe51f 100644
--- a/src/test/java/xuanran/wang/ambofo/checkuser/CheckUserTest.java
+++ b/src/test/java/xuanran/wang/ambofo/checkuser/CheckUserTest.java
@@ -4,6 +4,7 @@ import aiyh.utils.Util;
import basetest.BaseTest;
import com.api.xuanran.wang.ambofo.checkuser.service.CheckUserService;
import org.junit.Test;
+import weaver.interfaces.encode.AuthorizationBasic4OAuth2;
/**
* 安波福校验用户测试类
@@ -24,4 +25,12 @@ public class CheckUserTest extends BaseTest {
log.error(Util.getErrString(e));
}
}
+
+ @Test
+ public void testPA(){
+ String clientId = "ai-689bbdb3c4834b15af692540c62dc126";
+ String clientSecret = "7o88qSgOx0SOCQxR9xFGUm0n";
+ AuthorizationBasic4OAuth2 auth2 = new AuthorizationBasic4OAuth2();
+ log.info(auth2.encode(clientId + ":" + clientSecret));
+ }
}
diff --git a/src/test/java/xuanran/wang/epdi/datapush/RequestDataPush.java b/src/test/java/xuanran/wang/epdi/datapush/RequestDataPush.java
new file mode 100644
index 0000000..dafea68
--- /dev/null
+++ b/src/test/java/xuanran/wang/epdi/datapush/RequestDataPush.java
@@ -0,0 +1,31 @@
+package xuanran.wang.epdi.datapush;
+
+import basetest.BaseTest;
+import com.alibaba.fastjson.JSONObject;
+import org.junit.Test;
+import weaver.xuanran.wang.epdi.datapush.eneity.MainRequestConfig;
+import weaver.xuanran.wang.epdi.datapush.service.RequestPushService;
+
+import java.util.Map;
+
+/**
+ * 上海电力研究院测试类
+ *
+ * @Author xuanran.wang
+ * @Date 2022/12/26 10:14
+ */
+public class RequestDataPush extends BaseTest {
+
+ private final RequestPushService requestDataPush = new RequestPushService();
+
+ @Test
+ public void testCreatesJson(){
+ String requestId = "798800";
+ String tableName = "";
+ String uniqueCode = "token";
+ MainRequestConfig config = requestDataPush.getRequestPushConfigByUniqueCode(uniqueCode);
+ Map requestParam = requestDataPush.getRequestParam(config, requestId);
+ log.info("请求参数: " + JSONObject.toJSONString(requestParam));
+
+ }
+}