diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/RocketMQFactory.java b/src/main/java/weaver/xuanran/wang/shyl/mq/RocketMQFactory.java
index efeb869..1153f0f 100644
--- a/src/main/java/weaver/xuanran/wang/shyl/mq/RocketMQFactory.java
+++ b/src/main/java/weaver/xuanran/wang/shyl/mq/RocketMQFactory.java
@@ -27,6 +27,7 @@ public class RocketMQFactory {
configMap = RocketUtil.initMQConfigMap(configName);
CONFIG_MAPS.put(configName, configMap);
}
+ // 最大重试次数
int maxReconsumeTimes = Util.getIntValue(Util.null2String(configMap.get("MaxReconsumeTimes")), RocketMQConstant.DEFAULT_MAX_RECONSUME_TIMES);
// 声明一个消费者consumer,需要传入一个组 weaver-consumer
DefaultMQPushConsumer consumer = new DefaultMQPushConsumer(Util.null2String(configMap.get("ConsumerGroup")));
diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/constant/RocketMQConstant.java b/src/main/java/weaver/xuanran/wang/shyl/mq/constant/RocketMQConstant.java
index 806fd5e..d015a63 100644
--- a/src/main/java/weaver/xuanran/wang/shyl/mq/constant/RocketMQConstant.java
+++ b/src/main/java/weaver/xuanran/wang/shyl/mq/constant/RocketMQConstant.java
@@ -1,5 +1,8 @@
package weaver.xuanran.wang.shyl.mq.constant;
+import java.util.HashMap;
+import java.util.Map;
+
/**
*
RocketMQ常量
*
@@ -12,4 +15,20 @@ public class RocketMQConstant {
public static final String DELETE_ACTION = "DELETE_ACTION";
public static final String PASSWORD_ACTION = "PASSWORD_ACTION";
public static final int DEFAULT_MAX_RECONSUME_TIMES = 5;
+ public static final String SEX_GIRL = "1";
+ public static final String SEX_BOY = "2";
+ public static final String STATUS_ENABLE = "1";
+ public static final String STATUS_NO_ENABLE = "4";
+ public static final String ID_TYPE_UNKNOWN = "0";
+ public static final String ID_TYPE_ID_CARD = "1";
+ public static final String ID_TYPE_PASSPORT = "3";
+ public static final String ID_TYPE_STU_CARD = "4";
+ public static final String ID_TYPE_SOLDIER_CARD = "5";
+ public static final String DEFAULT_PASSWORD = "1";
+
+ public static Map SEX_MAPPING = new HashMap<>();
+
+ static {
+ SEX_MAPPING.put(SEX_BOY, "0");
+ }
}
diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/consumer/OrgConsumer.java b/src/main/java/weaver/xuanran/wang/shyl/mq/consumer/OrgConsumer.java
index 0f2d536..2633780 100644
--- a/src/main/java/weaver/xuanran/wang/shyl/mq/consumer/OrgConsumer.java
+++ b/src/main/java/weaver/xuanran/wang/shyl/mq/consumer/OrgConsumer.java
@@ -9,6 +9,7 @@ import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
import org.apache.rocketmq.common.message.MessageExt;
import weaver.xuanran.wang.shyl.mq.RocketMQFactory;
import weaver.xuanran.wang.shyl.mq.RocketMQListener;
+import weaver.xuanran.wang.shyl.mq.service.impl.OrgServiceImpl;
import weaver.xuanran.wang.shyl.mq.util.RocketUtil;
import java.util.List;
@@ -24,6 +25,7 @@ public class OrgConsumer extends RocketMQListener {
private static final Logger log = Util.getLogger();
private static final String CONFIG_NAME = "OrgConsumer";
+ private final OrgServiceImpl orgService = new OrgServiceImpl();
public OrgConsumer(){
super(CONFIG_NAME);
@@ -31,11 +33,7 @@ public class OrgConsumer extends RocketMQListener {
@Override
public MessageListenerConcurrently service() {
- return (List list, ConsumeConcurrentlyContext consumeConcurrentlyContext)->{
- Map map = RocketMQFactory.CONFIG_MAPS.get(CONFIG_NAME);
- log.info(Util.logStr("{} service config is {}", CONFIG_NAME, JSONObject.toJSONString(map)));
- return ConsumeConcurrentlyStatus.RECONSUME_LATER;
- };
+ return (List msg, ConsumeConcurrentlyContext consumeConcurrentlyContext) -> RocketUtil.execute(msg, consumeConcurrentlyContext, orgService, CONFIG_NAME);
}
}
diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/consumer/PassWordConsumer.java b/src/main/java/weaver/xuanran/wang/shyl/mq/consumer/PassWordConsumer.java
index 38d28e9..e45de99 100644
--- a/src/main/java/weaver/xuanran/wang/shyl/mq/consumer/PassWordConsumer.java
+++ b/src/main/java/weaver/xuanran/wang/shyl/mq/consumer/PassWordConsumer.java
@@ -9,6 +9,8 @@ import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
import org.apache.rocketmq.common.message.MessageExt;
import weaver.xuanran.wang.shyl.mq.RocketMQFactory;
import weaver.xuanran.wang.shyl.mq.RocketMQListener;
+import weaver.xuanran.wang.shyl.mq.service.impl.PassWordServiceImpl;
+import weaver.xuanran.wang.shyl.mq.util.RocketUtil;
import java.util.List;
import java.util.Map;
@@ -28,13 +30,11 @@ public class PassWordConsumer extends RocketMQListener {
super(CONFIG_NAME);
}
+ private final PassWordServiceImpl passWordService = new PassWordServiceImpl();
+
@Override
public MessageListenerConcurrently service() {
- return (List list, ConsumeConcurrentlyContext consumeConcurrentlyContext)->{
- Map map = RocketMQFactory.CONFIG_MAPS.get(CONFIG_NAME);
- log.info(Util.logStr("{} service config is {}", CONFIG_NAME, JSONObject.toJSONString(map)));
- return ConsumeConcurrentlyStatus.RECONSUME_LATER;
- };
+ return (List msg, ConsumeConcurrentlyContext consumeConcurrentlyContext) -> RocketUtil.execute(msg, consumeConcurrentlyContext, passWordService, CONFIG_NAME);
}
}
diff --git a/src/main/java/weaver/xuanran/wang/shyl/mq/consumer/UserInfoConsumer.java b/src/main/java/weaver/xuanran/wang/shyl/mq/consumer/UserInfoConsumer.java
index 62909ef..708c069 100644
--- a/src/main/java/weaver/xuanran/wang/shyl/mq/consumer/UserInfoConsumer.java
+++ b/src/main/java/weaver/xuanran/wang/shyl/mq/consumer/UserInfoConsumer.java
@@ -29,7 +29,7 @@ public class UserInfoConsumer extends RocketMQListener {
@Override
public MessageListenerConcurrently service() {
- return (List msg, ConsumeConcurrentlyContext consumeConcurrentlyContext)-> RocketUtil.execute(msg, consumeConcurrentlyContext, userInfoService, CONFIG_NAME);
+ return (List msg, ConsumeConcurrentlyContext consumeConcurrentlyContext) -> RocketUtil.execute(msg, consumeConcurrentlyContext, userInfoService, CONFIG_NAME);
}
}
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
index 6ba71b3..f147608 100644
--- a/src/main/java/weaver/xuanran/wang/shyl/mq/entity/ModifyPassWord.java
+++ b/src/main/java/weaver/xuanran/wang/shyl/mq/entity/ModifyPassWord.java
@@ -1,11 +1,14 @@
package weaver.xuanran.wang.shyl.mq.entity;
+import lombok.Data;
+
/**
* 密码修改
*
* @Author xuanran.wang
* @Date 2022/12/30 13:59
*/
+@Data
public class ModifyPassWord {
/**
* 主键
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
index d9757b1..e3f87d7 100644
--- a/src/main/java/weaver/xuanran/wang/shyl/mq/mapper/ConsumerMapper.java
+++ b/src/main/java/weaver/xuanran/wang/shyl/mq/mapper/ConsumerMapper.java
@@ -3,6 +3,8 @@ package weaver.xuanran.wang.shyl.mq.mapper;
import aiyh.utils.annotation.recordset.ParamMapper;
import aiyh.utils.annotation.recordset.Update;
+import java.util.Map;
+
/**
* 消费者mapper
*
@@ -15,7 +17,6 @@ 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}")
@@ -31,5 +32,44 @@ public interface ConsumerMapper {
@Update("delete hrmdepartment where outkey = #{outKey}")
boolean deleteDepartmentByOutKey(@ParamMapper("outKey") String outKey);
+ /**
+ * 通过outKey获取部门数据信息
+ * @author xuanran.wang
+ * @dateTime 2022/12/30 14:33
+ * @param outKey 外部系统id
+ * @return map key : id, val : 分部id
+ **/
+ @Update("select id departmentId, subcompanyid1 subCompanyId from hrmdepartment where outkey = #{outKey}")
+ Map getDepInfoByOutKey(@ParamMapper("outKey") String outKey);
+ /**
+ * 通过outKey获取人力资源id
+ * @author xuanran.wang
+ * @dateTime 2022/12/30 14:33
+ * @param outKey 外部系统id
+ * @return id
+ **/
+ @Update("select id from hrmresource where outkey = #{outKey}")
+ String getHrmIdByOutKey(@ParamMapper("outKey") String outKey);
+
+ /**
+ * 通过outKey获取oa部门id
+ * @author xuanran.wang
+ * @dateTime 2022/12/30 14:33
+ * @param outKey 外部系统id
+ * @return id
+ **/
+ @Update("select id from hrmdepartment where outkey = #{outKey}")
+ String getDepIdByOutKey(@ParamMapper("outKey") String outKey);
+
+ /**
+ * 通过outKey获取oa部门id
+ * @author xuanran.wang
+ * @dateTime 2022/12/30 14:33
+ * @param id 外部系统id
+ * @return true/false
+ **/
+ @Update("update hrmresource set password = #{password} where id = #{id}")
+ boolean updatePasswordById(@ParamMapper("id") String id,
+ @ParamMapper("password") String password);
}
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
index da25254..d9727a5 100644
--- a/src/main/java/weaver/xuanran/wang/shyl/mq/service/CusInfoActionService.java
+++ b/src/main/java/weaver/xuanran/wang/shyl/mq/service/CusInfoActionService.java
@@ -1,9 +1,12 @@
package weaver.xuanran.wang.shyl.mq.service;
import aiyh.utils.Util;
+import org.apache.log4j.Logger;
+import weaver.conn.RecordSet;
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.PassWordAction;
import weaver.xuanran.wang.shyl.mq.service.interfaces.UpdateAction;
/**
@@ -12,9 +15,27 @@ 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 {
+public abstract class CusInfoActionService implements CreateAction, DeleteAction, UpdateAction, PassWordAction {
+ protected final RecordSet recordSet = new RecordSet();
+
+ protected final Logger logger = Util.getLogger();
+
/**
* consumer-mapper
**/
protected final ConsumerMapper consumerMapper = Util.getMapper(ConsumerMapper.class);
+
+ /**
+ * 获取下一个人员id
+ * @author xuanran.wang
+ * @dateTime 2023/01/03 10:50
+ * @return next id
+ **/
+ protected synchronized String getNextHrmId(){
+ recordSet.executeProc("HrmResourceMaxId_Get", "");
+ recordSet.next();
+ //新增的部门id
+ return Util.null2String(recordSet.getInt(1));
+ }
+
}
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
index 86212be..5a715b1 100644
--- 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
@@ -1,9 +1,22 @@
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.commons.lang3.StringUtils;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
+import weaver.conn.RecordSet;
+import weaver.general.TimeUtil;
+import weaver.hrm.company.DepartmentComInfo;
+import weaver.interfaces.hrm.HrmServiceManager;
+import weaver.matrix.MatrixUtil;
import weaver.xuanran.wang.shyl.mq.entity.MQMessage;
+import weaver.xuanran.wang.shyl.mq.entity.Org;
import weaver.xuanran.wang.shyl.mq.service.CusInfoActionService;
+import java.util.ArrayList;
+import java.util.List;
+
/**
*
*
@@ -11,18 +24,151 @@ import weaver.xuanran.wang.shyl.mq.service.CusInfoActionService;
* @Date 2022/12/30 15:05
*/
public class OrgServiceImpl extends CusInfoActionService {
+ /**
+ * 部门创建
+ * @author xuanran.wang
+ * @dateTime 2023/1/3 14:05
+ * @param message mq消息
+ * @return 成功/重试
+ **/
@Override
public ConsumeConcurrentlyStatus cusCreateAction(MQMessage message) {
- return null;
+ try {
+ String content = message.getContent();
+ Org org = JSONObject.parseObject(content, Org.class);
+ char separator = weaver.general.Util.getSeparator();
+ // 分部id
+ String subId = "";
+ RecordSet insertRs = new RecordSet();
+ if(StringUtils.isBlank(subId)){
+ throw new CustomerException("SubCompany can not be empey!");
+ }
+ //使用存储过程新增分部
+ String para = org.getOrgName() + separator + org.getOrgName() + separator +
+ "" + separator + "" + separator + subId + separator + org.getSortIndex() + separator + "";
+ insertRs.executeProc("HrmDepartment_Insert", para);
+ if (insertRs.next()) {
+ int depId = insertRs.getInt(1);
+ updateDepartmentInfo(String.valueOf(depId), subId, org);
+ }
+ return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
+ }catch (Exception e){
+ throw new CustomerException(Util.logStr("orgCreateAction error : {}", e.getMessage()));
+ }
}
+ /**
+ * 部门删除
+ * @author xuanran.wang
+ * @dateTime 2023/1/3 13:59
+ * @param message mq消息
+ * @return 成功/重试
+ **/
@Override
public ConsumeConcurrentlyStatus cusDeleteAction(MQMessage message) {
- return null;
+ try {
+ String content = message.getContent();
+ Org org = JSONObject.parseObject(content, Org.class);
+ String id = org.getId();
+ if(StringUtils.isBlank(id)){
+ throw new CustomerException("userInfo id can not be empty!");
+ }
+ boolean success = consumerMapper.deleteDepartmentByOutKey(id);
+ if (!success) {
+ throw new CustomerException(Util.logStr("update user status error!"));
+ }
+ return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
+ }catch (Exception e){
+ throw new CustomerException(Util.logStr("orgDeleteAction execute error : [{}]!", e.getMessage()));
+ }
}
@Override
public ConsumeConcurrentlyStatus cusUpdateAction(MQMessage message) {
+ try {
+ String content = message.getContent();
+ Org org = JSONObject.parseObject(content, Org.class);
+ String outKey = org.getId();
+ // 分部待明确
+ String subId = "";
+ String depId = consumerMapper.getDepIdByOutKey(outKey);
+ if(StringUtils.isBlank(depId)){
+ throw new CustomerException(Util.logStr("The department information data obtained by foreign key is empty!"));
+ }
+ updateDepartmentInfo(depId, subId, org);
+ return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
+ }catch (Exception e){
+ throw new CustomerException(Util.logStr("orgUpdateAction error : {}", e.getMessage()));
+ }
+ }
+
+ public void updateDepartmentInfo(String depId, String subId, Org org){
+ String insertSQL = "update hrmdepartment set created = ?, creater = ?, modified = ?, modifier = ?," +
+ " departmentcode = ?, tlevel = ?, showorder = ?, canceled = ?,departmentmark = ?, " +
+ " departmentname = ?, supdepid = ?, subcompanyid1 = ?, outkey = ? where id = ?";
+ RecordSet updateRs = new RecordSet();
+ List