鲜丰门店下培训人员拉取
This commit is contained in:
@@ -31,6 +31,7 @@ public enum RocketMqGroupEnum {
|
|||||||
* 事件消息监听
|
* 事件消息监听
|
||||||
*/
|
*/
|
||||||
FEI_SHU_EVENT_LISTENER("fei_shu_event_listener", new ArrayList<>(Arrays.asList(RocketMqTagEnum.USER_EVENT, RocketMqTagEnum.AUTH_SCOPE_CHANGE, RocketMqTagEnum.DEPT_EVENT))),
|
FEI_SHU_EVENT_LISTENER("fei_shu_event_listener", new ArrayList<>(Arrays.asList(RocketMqTagEnum.USER_EVENT, RocketMqTagEnum.AUTH_SCOPE_CHANGE, RocketMqTagEnum.DEPT_EVENT))),
|
||||||
|
SYNC_TRAINING_PERSON("sync_training_person", new ArrayList<>(Arrays.asList(RocketMqTagEnum.SYNC_TRAINING_PERSON))),
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ public enum RocketMqTagEnum {
|
|||||||
USER_EVENT("user_event","钉钉通讯录变更事件"),
|
USER_EVENT("user_event","钉钉通讯录变更事件"),
|
||||||
DEPT_EVENT("dept_event","部门事件"),
|
DEPT_EVENT("dept_event","部门事件"),
|
||||||
STORE_DING_QUEUE("store_ding_queue", "微应用钉钉消息发送"),
|
STORE_DING_QUEUE("store_ding_queue", "微应用钉钉消息发送"),
|
||||||
|
SYNC_TRAINING_PERSON("sync_training_person", "建店完成后拉取培训人员"),
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import com.github.pagehelper.PageHelper;
|
|||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@@ -161,4 +162,11 @@ public class ShopInfoDAO {
|
|||||||
public Long getRegionIdByid(Long shopId){
|
public Long getRegionIdByid(Long shopId){
|
||||||
return shopInfoMapper.getRegionIdByid(shopId);
|
return shopInfoMapper.getRegionIdByid(shopId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ShopInfoDO selectByStoreNum(String storeNum){
|
||||||
|
if (StringUtils.isBlank(storeNum)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return shopInfoMapper.selectByStoreNum(storeNum);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package com.cool.store.dto.ehr;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 鲜丰门店下培训人员拉取
|
||||||
|
* @author chenyupeng
|
||||||
|
* @since 2021/8/17
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class SyncXfsgTrainingPersonInfoDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 企业id
|
||||||
|
*/
|
||||||
|
private String enterpriseId;
|
||||||
|
/**
|
||||||
|
* 工号
|
||||||
|
*/
|
||||||
|
private String jobnumber;
|
||||||
|
/**
|
||||||
|
* 身份证号码
|
||||||
|
*/
|
||||||
|
private String idCard;
|
||||||
|
/**
|
||||||
|
* 门店编号
|
||||||
|
*/
|
||||||
|
private String storeNum;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@ import com.aliyun.openservices.ons.api.bean.Subscription;
|
|||||||
import com.cool.store.constants.CommonConstants;
|
import com.cool.store.constants.CommonConstants;
|
||||||
import com.cool.store.enums.RocketMqGroupEnum;
|
import com.cool.store.enums.RocketMqGroupEnum;
|
||||||
import com.cool.store.mq.RocketMqConfig;
|
import com.cool.store.mq.RocketMqConfig;
|
||||||
|
import com.cool.store.mq.consumer.listener.XfsgTrainingPersonSyncListener;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
@@ -29,6 +30,8 @@ public class ConsumerClient {
|
|||||||
private RocketMqConfig rocketMqConfig;
|
private RocketMqConfig rocketMqConfig;
|
||||||
// @Resource
|
// @Resource
|
||||||
// private FeiShuEventListener feiShuEventListener;
|
// private FeiShuEventListener feiShuEventListener;
|
||||||
|
@Resource
|
||||||
|
private XfsgTrainingPersonSyncListener xfsgTrainingPersonSyncListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取通用配置
|
* 获取通用配置
|
||||||
@@ -81,4 +84,20 @@ public class ConsumerClient {
|
|||||||
// return consumerBean;
|
// return consumerBean;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 鲜丰门店下培训人员拉取
|
||||||
|
*/
|
||||||
|
@Bean(initMethod = "start", destroyMethod = "shutdown")
|
||||||
|
public ConsumerBean xfsgTrainingPersonSyncQueueBean() {
|
||||||
|
RocketMqGroupEnum groupEnum = RocketMqGroupEnum.SYNC_TRAINING_PERSON;
|
||||||
|
ConsumerBean consumerBean = new ConsumerBean();
|
||||||
|
//配置文件
|
||||||
|
Properties properties = getCommonProperties(groupEnum);
|
||||||
|
consumerBean.setProperties(properties);
|
||||||
|
Map<Subscription, MessageListener> commonSubscriptionTable = getCommonSubscriptionTable(groupEnum, xfsgTrainingPersonSyncListener);
|
||||||
|
//订阅多个topic如上面设置
|
||||||
|
consumerBean.setSubscriptionTable(commonSubscriptionTable);
|
||||||
|
return consumerBean;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,152 @@
|
|||||||
|
package com.cool.store.mq.consumer.listener;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.aliyun.openservices.ons.api.Action;
|
||||||
|
import com.aliyun.openservices.ons.api.ConsumeContext;
|
||||||
|
import com.aliyun.openservices.ons.api.Message;
|
||||||
|
import com.aliyun.openservices.ons.api.MessageListener;
|
||||||
|
import com.cool.store.constants.CommonConstants;
|
||||||
|
import com.cool.store.dao.ShopInfoDAO;
|
||||||
|
import com.cool.store.dao.TempUserDetailDAO;
|
||||||
|
import com.cool.store.dto.ehr.StaffBaseInfoDTO;
|
||||||
|
import com.cool.store.dto.ehr.SyncXfsgTrainingPersonInfoDTO;
|
||||||
|
import com.cool.store.entity.ShopInfoDO;
|
||||||
|
import com.cool.store.entity.TempUserDetailDO;
|
||||||
|
import com.cool.store.enums.UserRoleEnum;
|
||||||
|
import com.cool.store.service.XfsgEhrService;
|
||||||
|
import com.cool.store.utils.RedisUtilPool;
|
||||||
|
import com.cool.store.utils.poi.DateUtils;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 鲜丰门店下培训人员拉取
|
||||||
|
* @author wxp
|
||||||
|
* @since 2024/4/29
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class XfsgTrainingPersonSyncListener implements MessageListener {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
public XfsgEhrService xfsgEhrService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ShopInfoDAO shopInfoDAO;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private TempUserDetailDAO tempUserDetailDAO;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public RedisUtilPool redisUtilPool;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Action consume(Message message, ConsumeContext context) {
|
||||||
|
String text = new String(message.getBody());
|
||||||
|
if(StringUtils.isBlank(text)){
|
||||||
|
log.info("消息体为空,tag:{},messageId:{}",message.getTag(),message.getMsgID());
|
||||||
|
return Action.CommitMessage;
|
||||||
|
}
|
||||||
|
String lockKey = "XfsgTrainingPersonSyncListener:" + message.getMsgID();
|
||||||
|
boolean lock = redisUtilPool.setNxExpire(lockKey, message.getMsgID(), CommonConstants.NORMAL_LOCK_TIMES);
|
||||||
|
if(lock){
|
||||||
|
try {
|
||||||
|
syncXfsgTrainingPerson(text);
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("XfsgTrainingPersonSyncListener consume error",e);
|
||||||
|
return Action.ReconsumeLater;
|
||||||
|
}finally {
|
||||||
|
redisUtilPool.delKey(lockKey);
|
||||||
|
}
|
||||||
|
log.info("消费成功,tag:{},messageId:{},reqBody={}",message.getTag(),message.getMsgID(),text);
|
||||||
|
return Action.CommitMessage;
|
||||||
|
}
|
||||||
|
return Action.ReconsumeLater;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void syncXfsgTrainingPerson(String text) {
|
||||||
|
log.info("syncXfsgTrainingPerson, reqBody={}", text);
|
||||||
|
SyncXfsgTrainingPersonInfoDTO request = JSONObject.parseObject(text, SyncXfsgTrainingPersonInfoDTO.class);
|
||||||
|
if(StringUtils.isAnyBlank(request.getStoreNum(), request.getJobnumber(), request.getIdCard())){
|
||||||
|
log.info("syncXfsgTrainingPerson参数缺失={}", text);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 系统建店完成一定有门店编码???
|
||||||
|
ShopInfoDO shopInfoDO = shopInfoDAO.selectByStoreNum(request.getStoreNum());
|
||||||
|
if(shopInfoDO == null){
|
||||||
|
log.info("门店编码对应的店铺信息不存在storeNum:{}", request.getStoreNum());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TempUserDetailDO checkTempUserDetailDO = tempUserDetailDAO.selectByIdCard(request.getIdCard());
|
||||||
|
// 系统已建店,并且身份证号信息不存在
|
||||||
|
if(checkTempUserDetailDO != null){
|
||||||
|
log.info("培训人员身份证信息已存在idCard:{}", checkTempUserDetailDO.getIdCard());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
StaffBaseInfoDTO staffBaseInfoDTO = xfsgEhrService.getUserInfoByCode(request.getJobnumber());
|
||||||
|
log.info("培训人员主数据信息:staffBaseInfoDTO:{}", JSONObject.toJSONString(staffBaseInfoDTO));
|
||||||
|
if(staffBaseInfoDTO != null){
|
||||||
|
TempUserDetailDO tempUserDetailDO = new TempUserDetailDO();
|
||||||
|
tempUserDetailDO.setLineId(shopInfoDO.getLineId());
|
||||||
|
tempUserDetailDO.setShopId(shopInfoDO.getId());
|
||||||
|
tempUserDetailDO.setRegionId(shopInfoDO.getRegionId());
|
||||||
|
tempUserDetailDO.setMobile(staffBaseInfoDTO.getPhone());
|
||||||
|
tempUserDetailDO.setUsername(staffBaseInfoDTO.getName());
|
||||||
|
tempUserDetailDO.setSex(staffBaseInfoDTO.getSex());
|
||||||
|
if(StringUtils.isNotBlank(staffBaseInfoDTO.getAge())){
|
||||||
|
tempUserDetailDO.setAge(Integer.valueOf(staffBaseInfoDTO.getAge()));
|
||||||
|
}
|
||||||
|
tempUserDetailDO.setIdCard(staffBaseInfoDTO.getIdCard());
|
||||||
|
tempUserDetailDO.setStatus(1);
|
||||||
|
tempUserDetailDO.setEducational(fillEducational(staffBaseInfoDTO.getHighestDegree()));
|
||||||
|
tempUserDetailDO.setRoleId(fillRoleId(staffBaseInfoDTO.getJobName()));
|
||||||
|
tempUserDetailDO.setIdCardNegativeUrl(staffBaseInfoDTO.getEmblemPhoto());
|
||||||
|
tempUserDetailDO.setIdCardPositiveUrl(staffBaseInfoDTO.getIdNumPhoto());
|
||||||
|
tempUserDetailDO.setHealthCertificateUrl(staffBaseInfoDTO.getHealthCertificate());
|
||||||
|
tempUserDetailDO.setRegisterTime(new Date());
|
||||||
|
if(StringUtils.isNotBlank(staffBaseInfoDTO.getEntryDate())){
|
||||||
|
tempUserDetailDO.setRegisterTime(DateUtils.parseDate(staffBaseInfoDTO.getEntryDate()));
|
||||||
|
}
|
||||||
|
tempUserDetailDO.setSubmitTime(new Date());
|
||||||
|
tempUserDetailDO.setSource("sync");
|
||||||
|
tempUserDetailDAO.insertSelective(tempUserDetailDO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 学历 0-小学 1-初中 2-高中 3-中专 4-大专 5-本科 6-硕士 7-硕士以上
|
||||||
|
private Integer fillEducational(String highestDegree) {
|
||||||
|
if("小学".equals(highestDegree)){
|
||||||
|
return 0;
|
||||||
|
}else if("初中".equals(highestDegree)){
|
||||||
|
return 1;
|
||||||
|
}else if("高中".equals(highestDegree)){
|
||||||
|
return 2;
|
||||||
|
}else if("中专".equals(highestDegree)){
|
||||||
|
return 3;
|
||||||
|
}else if("大专".equals(highestDegree)){
|
||||||
|
return 4;
|
||||||
|
}else if("本科".equals(highestDegree)){
|
||||||
|
return 5;
|
||||||
|
}else if("硕士".equals(highestDegree)){
|
||||||
|
return 6;
|
||||||
|
}else if("硕士以上".equals(highestDegree)){
|
||||||
|
return 7;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Long fillRoleId(String jobName) {
|
||||||
|
if(UserRoleEnum.XFSG_CLERK.getDesc().equals(jobName)){
|
||||||
|
return UserRoleEnum.XFSG_CLERK.getCode();
|
||||||
|
}else if(UserRoleEnum.XFSG_SHOPOWNER.getDesc().equals(jobName)){
|
||||||
|
return UserRoleEnum.XFSG_SHOPOWNER.getCode();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user