diff --git a/epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/ComplementLogOperationDTO.java b/epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/ComplementLogOperationDTO.java new file mode 100644 index 0000000000..ff363c2ad6 --- /dev/null +++ b/epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/ComplementLogOperationDTO.java @@ -0,0 +1,21 @@ +package com.epmet.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2022/10/20 14:21 + * @DESC + */ +@Data +public class ComplementLogOperationDTO implements Serializable { + + private static final long serialVersionUID = 7563210356670229204L; + + private String staffId; + + private String orgId; + private String orgIdPath; +} diff --git a/epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/form/LogOperationListFormDTO.java b/epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/form/LogOperationListFormDTO.java index 3fe203b482..a4fc503431 100644 --- a/epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/form/LogOperationListFormDTO.java +++ b/epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/form/LogOperationListFormDTO.java @@ -10,4 +10,24 @@ public class LogOperationListFormDTO { private Integer pageNo = 1; private Integer pageSize = 10; + /** + * 姓名 + */ + private String operatorName; + /** + * 手机号 + */ + private String operatorMobile; + /** + * yyyyMMdd + */ + private String startTime; + /** + * yyyyMMdd + */ + private String endTime; + /** + * 默认传data_tm + */ + private String category; } diff --git a/epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/region/LogOperationResultDTO.java b/epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/region/LogOperationResultDTO.java index b08c9fc295..b794dcbd26 100644 --- a/epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/region/LogOperationResultDTO.java +++ b/epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/region/LogOperationResultDTO.java @@ -1,7 +1,10 @@ package com.epmet.dto.region; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; +import java.util.Date; + /** * */ @@ -45,4 +48,6 @@ public class LogOperationResultDTO { */ private Long operatingTime; + @JsonFormat(pattern="yyyy-MM-dd HH:mm") + private Date operateTime; } diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/controller/LogOperationController.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/controller/LogOperationController.java index 089ad29639..419ff38b21 100644 --- a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/controller/LogOperationController.java +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/controller/LogOperationController.java @@ -1,7 +1,10 @@ package com.epmet.controller; +import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.annotation.RequirePermission; import com.epmet.commons.tools.enums.RequirePermissionEnum; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.user.LoginUserUtil; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; @@ -45,4 +48,26 @@ public class LogOperationController { return new Result>().ok(resultList); } + /** + * 数字社区-操作记录 + * @param formDTO + * @return + */ + @PostMapping("page") + public Result> page(@RequestBody LogOperationListFormDTO formDTO, @LoginUser TokenDto tokenDto){ + return new Result>().ok(logOperationService.page(loginUserUtil.getLoginUserCustomerId(), + formDTO.getStartTime(), + formDTO.getEndTime(), + formDTO.getOperatorName(), + formDTO.getOperatorMobile(), + formDTO.getPageNo(), + formDTO.getPageSize(), + formDTO.getCategory(),tokenDto)); + } + + @PostMapping("complementLogOperation") + public Result complementLogOperation(){ + logOperationService.complementLogOperation(); + return new Result(); + } } diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/dao/LogOperationDao.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/dao/LogOperationDao.java index a63a5aa8e4..be1858c9e2 100644 --- a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/dao/LogOperationDao.java +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/dao/LogOperationDao.java @@ -18,8 +18,14 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.ComplementLogOperationDTO; +import com.epmet.dto.region.LogOperationResultDTO; import com.epmet.entity.LogOperationEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; /** * 操作日指标 @@ -29,5 +35,17 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface LogOperationDao extends BaseDao { - + + List pageList(@Param("customerId") String customerId, + @Param("startTime")String startTime, + @Param("endTime")String endTime, + @Param("operatorName")String operatorName, + @Param("operatorMobile")String operatorMobile, + @Param("category")String category, + @Param("agencyId")String agencyId); + + List> getStaffId(); + + void updateBatchLog(@Param("list") List list); + } \ No newline at end of file diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/entity/LogOperationEntity.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/entity/LogOperationEntity.java index 537d1fc9b2..e576d3823a 100644 --- a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/entity/LogOperationEntity.java +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/entity/LogOperationEntity.java @@ -79,6 +79,8 @@ public class LogOperationEntity extends BaseEpmetEntity { * 操作人手机号 */ private String operatorMobile; + private String orgId; + private String orgIdPath; /** * 操作时间,该时间不是插入数据的时间,而是操作发生的真实时间 diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/RocketMQConsumerRegister.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/RocketMQConsumerRegister.java index 93a2f8e5f0..7f15960037 100644 --- a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/RocketMQConsumerRegister.java +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/RocketMQConsumerRegister.java @@ -5,6 +5,7 @@ import com.epmet.commons.rocketmq.constants.TopicConstants; import com.epmet.commons.rocketmq.register.MQAbstractRegister; import com.epmet.commons.rocketmq.register.MQConsumerProperties; import com.epmet.mq.listener.listener.AuthOperationLogListener; +import com.epmet.mq.listener.listener.CheckAndExportOperationLogListener; import com.epmet.mq.listener.listener.PointOperationLogListener; import com.epmet.mq.listener.listener.ProjectOperationLogListener; import org.apache.rocketmq.common.protocol.heartbeat.MessageModel; @@ -19,6 +20,7 @@ public class RocketMQConsumerRegister extends MQAbstractRegister { register(consumerProperties, ConsomerGroupConstants.AUTH_OPERATION_LOG_GROUP, MessageModel.CLUSTERING, TopicConstants.AUTH, "*", new AuthOperationLogListener()); register(consumerProperties, ConsomerGroupConstants.PROJECT_OPERATION_LOG_GROUP, MessageModel.CLUSTERING, TopicConstants.PROJECT_CHANGED, "*", new ProjectOperationLogListener()); register(consumerProperties, ConsomerGroupConstants.POINT_OPERATION_LOG_GROUP, MessageModel.CLUSTERING, TopicConstants.POINT, "*", new PointOperationLogListener()); + register(consumerProperties, ConsomerGroupConstants.CHECK_OR_EXPORT_GROUP, MessageModel.CLUSTERING, TopicConstants.CHECK_OR_EXPORT, "*", new CheckAndExportOperationLogListener()); // ...其他监听器类似 } diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/CheckAndExportOperationLogListener.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/CheckAndExportOperationLogListener.java new file mode 100644 index 0000000000..977117ac84 --- /dev/null +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/CheckAndExportOperationLogListener.java @@ -0,0 +1,122 @@ +package com.epmet.mq.listener.listener; + +import com.alibaba.fastjson.JSON; +import com.epmet.auth.constants.AuthOperationEnum; +import com.epmet.commons.rocketmq.constants.MQUserPropertys; +import com.epmet.commons.rocketmq.messages.CheckMQMsg; +import com.epmet.commons.rocketmq.messages.LoginMQMsg; +import com.epmet.commons.tools.distributedlock.DistributedLock; +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.redis.RedisKeys; +import com.epmet.commons.tools.redis.RedisUtils; +import com.epmet.commons.tools.utils.SpringContextUtils; +import com.epmet.entity.LogOperationEntity; +import com.epmet.mq.listener.bean.log.LogOperationHelper; +import com.epmet.mq.listener.bean.log.OperatorInfo; +import com.epmet.service.LogOperationService; +import org.apache.commons.lang3.StringUtils; +import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext; +import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus; +import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently; +import org.apache.rocketmq.common.message.MessageExt; +import org.redisson.api.RLock; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.List; +import java.util.concurrent.TimeUnit; + +/** + * @author zxc + * @Description 查询明文或者导出操作日志监听器 + */ +public class CheckAndExportOperationLogListener implements MessageListenerConcurrently { + + private Logger logger = LoggerFactory.getLogger(getClass()); + + private RedisUtils redisUtils; + + @Override + public ConsumeConcurrentlyStatus consumeMessage(List msgs, ConsumeConcurrentlyContext context) { + + if (redisUtils == null) { + redisUtils = SpringContextUtils.getBean(RedisUtils.class); + } + + try { + msgs.forEach(msg -> consumeMessage(msg)); + } catch (Exception e) { + logger.error(ExceptionUtils.getErrorStackTrace(e)); + return ConsumeConcurrentlyStatus.RECONSUME_LATER; + } + return ConsumeConcurrentlyStatus.CONSUME_SUCCESS; + } + + private void consumeMessage(MessageExt messageExt) { + String tags = messageExt.getTags(); + String msg = new String(messageExt.getBody()); + String pendingMsgLabel = messageExt.getUserProperty(MQUserPropertys.BLOCKED_MSG_LABEL); + logger.info("查询明文或者导出操作日志监听器-收到消息内容:{}", msg); + CheckMQMsg msgObj = JSON.parseObject(msg, CheckMQMsg.class); + + //获取操作人信息 + OperatorInfo operatorInfo = LogOperationHelper.getInstance().getOperatorInfo(msgObj.getUserId()); + LogOperationEntity logEntity = new LogOperationEntity(); + logEntity.setCategory("data_tm"); + logEntity.setType(msgObj.getType()); + logEntity.setTypeDisplay(msgObj.getTypeDisplay()); + logEntity.setIp(msgObj.getIp()); + logEntity.setFromApp(msgObj.getFromApp()); + logEntity.setFromClient(msgObj.getFromClient()); + logEntity.setTargetId(""); + logEntity.setCustomerId(operatorInfo.getCustomerId()); + logEntity.setOperatorId(msgObj.getUserId()); + logEntity.setOperatorName(operatorInfo.getName()); + logEntity.setOperatorMobile(operatorInfo.getMobile()); + logEntity.setOperatingTime(msgObj.getOperateTime()); + logEntity.setContent(msgObj.getContent()); + logEntity.setOrgId(msgObj.getOrgId()); + logEntity.setOrgIdPath(msgObj.getOrgIdPath()); + + DistributedLock distributedLock = null; + RLock lock = null; + try { + distributedLock = SpringContextUtils.getBean(DistributedLock.class); + lock = distributedLock.getLock(String.format("lock:auth_operation_log:%s:%s", logEntity.getType(), logEntity.getOperatorId()), + 30L, 30L, TimeUnit.SECONDS); + SpringContextUtils.getBean(LogOperationService.class).log(logEntity); + } catch (RenException e) { + // 如果是我们手动抛出的异常,说明在业务可控范围内。目前不需要MQ重试 + logger.error("【RocketMQ】添加操作日志失败:".concat(ExceptionUtils.getErrorStackTrace(e))); + } catch (Exception e) { + // 不是我们自己抛出的异常,可以让MQ重试 + logger.error("【RocketMQ】添加操作日志失败:".concat(ExceptionUtils.getErrorStackTrace(e))); + throw e; + } finally { + distributedLock.unLock(lock); + } + + if (StringUtils.isNotBlank(pendingMsgLabel)) { + try { + removePendingMqMsgCache(pendingMsgLabel); + } catch (Exception e) { + logger.error("【查询明文或者导出操作日志监听器】-删除mq阻塞消息缓存失败:{}", ExceptionUtils.getErrorStackTrace(e)); + } + } + } + + /** + * @description + * + * @param pendingMsgLabel + * @return + * @author wxz + * @date 2021.10.14 16:32:32 + */ + private void removePendingMqMsgCache(String pendingMsgLabel) { + String key = RedisKeys.blockedMqMsgKey(pendingMsgLabel); + redisUtils.delete(key); + //logger.info("【登录操作事件监听器】删除pendingMsgLabel成功:{}", pendingMsgLabel); + } +} diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/LogOperationService.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/LogOperationService.java index 67b3736395..ce56a25a6e 100644 --- a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/LogOperationService.java +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/LogOperationService.java @@ -1,5 +1,7 @@ package com.epmet.service; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.dto.region.LogOperationResultDTO; import com.epmet.entity.LogOperationEntity; @@ -25,4 +27,23 @@ public interface LogOperationService { * @date 2021.06.07 21:56 */ List listOperationLogs(String condition, String customerId, Integer pageNo, Integer pageSize); + + /** + * 数字社区-操作记录 + * @param loginUserCustomerId + * @param startTime + * @param endTime + * @param operatorName + * @param operatorMobile + * @return + */ + PageData page(String loginUserCustomerId, + String startTime, + String endTime, + String operatorName, + String operatorMobile, + Integer pageNo, Integer pageSize, String category, TokenDto tokenDto); + + void complementLogOperation(); + } diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/LogOperationServiceImpl.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/LogOperationServiceImpl.java index 1cbf7e32d2..fae8de2b7c 100644 --- a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/LogOperationServiceImpl.java +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/LogOperationServiceImpl.java @@ -4,20 +4,30 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.feign.ResultDataResolver; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.redis.common.CustomerStaffRedis; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.dao.LogOperationDao; +import com.epmet.dto.ComplementLogOperationDTO; import com.epmet.dto.CustomerStaffDTO; import com.epmet.dto.form.CustomerStaffFormDTO; import com.epmet.dto.region.LogOperationResultDTO; import com.epmet.entity.LogOperationEntity; import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.service.LogOperationService; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import java.util.*; @@ -174,7 +184,72 @@ public class LogOperationServiceImpl implements LogOperationService, ResultDataR ldto.setCustomerId(l.getCustomerId()); ldto.setOperatorMobile(staffMap.get(l.getOperatorId()).getMobile()); ldto.setOperatorName(staffMap.get(l.getOperatorId()).getRealName()); + ldto.setOperateTime(l.getOperatingTime()); return ldto; }).collect(Collectors.toList()); } + + /** + * 数字社区-操作记录 + * + * @param customerId + * @param startTime + * @param endTime + * @param operatorName + * @param operatorMobile + * @return + */ + @Override + public PageData page(String customerId, String startTime, String endTime, String operatorName, String operatorMobile, + Integer pageNo, Integer pageSize, String category, TokenDto tokenDto) { + CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId()); + if (null == staffInfo){ + throw new EpmetException("未查询工作人员信息:"+tokenDto.getUserId()); + } + // 列表/导出查询 + PageHelper.startPage(pageNo, pageSize); + List list = logOperationDao.pageList(customerId, startTime, endTime, operatorName, operatorMobile,category,staffInfo.getAgencyId()); + PageInfo pageInfo = new PageInfo<>(list); + return new PageData<>(list, pageInfo.getTotal()); + } + + /** + * Desc: 补全 log_operation 表的 org_id 和 org_id_path + * @param + * @author zxc + * @date 2022/10/20 13:50 + */ + @Override + public void complementLogOperation() { + Integer no = NumConstant.ONE; + Integer size; + do { + PageInfo> pageInfo = PageHelper.startPage(no, NumConstant.ONE_HUNDRED).doSelectPageInfo(() -> logOperationDao.getStaffId()); + size = pageInfo.getList().size(); + if (!CollectionUtils.isEmpty(pageInfo.getList())){ + List needUpdate = new ArrayList<>(); + for (Map m : pageInfo.getList()) { + CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(m.get("CUSTOMER_ID"), m.get("OPERATOR_ID")); + if (null == staffInfo){ + logger.warn("未查询到工作人员信息"+m.get("OPERATOR_ID")); + continue; + } + ComplementLogOperationDTO dto = new ComplementLogOperationDTO(); + dto.setStaffId(staffInfo.getStaffId()); + dto.setOrgId(staffInfo.getAgencyId()); + dto.setOrgIdPath(StringUtils.isBlank(staffInfo.getAgencyPIds()) ? staffInfo.getAgencyId() : staffInfo.getAgencyPIds().concat(":").concat(staffInfo.getAgencyId())); + needUpdate.add(dto); + } + if (!CollectionUtils.isEmpty(needUpdate)){ + updateLog(needUpdate); + } + } + no++; + }while (size == NumConstant.ONE_HUNDRED); + } + + @Transactional(rollbackFor = Exception.class) + public void updateLog(List list){ + logOperationDao.updateBatchLog(list); + } } diff --git a/epmet-admin/epmet-admin-server/src/main/resources/db/migration/V0.0.25__alter_log_operation2.sql b/epmet-admin/epmet-admin-server/src/main/resources/db/migration/V0.0.25__alter_log_operation2.sql new file mode 100644 index 0000000000..aa1c5f98a3 --- /dev/null +++ b/epmet-admin/epmet-admin-server/src/main/resources/db/migration/V0.0.25__alter_log_operation2.sql @@ -0,0 +1,3 @@ + +alter table log_operation add COLUMN ORG_ID VARCHAR(32) comment '组织ID' AFTER ID; +alter table log_operation add COLUMN ORG_ID_PATH VARCHAR(255) comment '组织ID全路径,包括组织ID' AFTER ORG_ID; \ No newline at end of file diff --git a/epmet-admin/epmet-admin-server/src/main/resources/mapper/LogOperationDao.xml b/epmet-admin/epmet-admin-server/src/main/resources/mapper/LogOperationDao.xml index 5f34d339ad..749e9b4288 100644 --- a/epmet-admin/epmet-admin-server/src/main/resources/mapper/LogOperationDao.xml +++ b/epmet-admin/epmet-admin-server/src/main/resources/mapper/LogOperationDao.xml @@ -26,5 +26,67 @@ + + update log_operation + + + + when OPERATOR_ID = #{item.staffId} then #{item.orgId} + + + + + when OPERATOR_ID = #{item.staffId} then #{item.orgIdPath} + + + UPDATED_TIME = NOW() + + where 1=1 + + OPERATOR_ID = #{item.staffId} + + + + \ No newline at end of file diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/IcLoginServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/IcLoginServiceImpl.java index ea0ae6d5fb..16d7e2ba5e 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/IcLoginServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/IcLoginServiceImpl.java @@ -5,11 +5,14 @@ import com.epmet.auth.constants.AuthOperationConstants; import com.epmet.commons.rocketmq.messages.LoginMQMsg; import com.epmet.commons.tools.constant.AppClientConstant; import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.feign.ResultDataResolver; import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisUtils; +import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.security.dto.IcTokenDto; import com.epmet.commons.tools.utils.CpUserDetailRedis; import com.epmet.commons.tools.utils.IpUtils; @@ -23,6 +26,7 @@ import com.epmet.jwt.JwtTokenProperties; import com.epmet.jwt.JwtTokenUtils; import com.epmet.service.IcLoginService; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.context.request.RequestContextHolder; @@ -115,14 +119,12 @@ public class IcLoginServiceImpl implements IcLoginService, ResultDataResolver { */ private void sendLoginEvent(String userId, String fromApp, String fromClient) { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); - LoginMQMsg loginMQMsg = new LoginMQMsg(); loginMQMsg.setUserId(userId); loginMQMsg.setLoginTime(new Date()); loginMQMsg.setIp(IpUtils.getIpAddr(request)); loginMQMsg.setFromApp(fromApp); loginMQMsg.setFromClient(fromClient); - SystemMsgFormDTO form = new SystemMsgFormDTO(); form.setMessageType(AuthOperationConstants.LOGIN); form.setContent(loginMQMsg); diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java index e1ab790e0f..9850feb4b3 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java @@ -12,6 +12,7 @@ import com.epmet.commons.rocketmq.messages.LoginMQMsg; import com.epmet.commons.tools.constant.AppClientConstant; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.constant.StrConstant; +import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.enums.EnvEnum; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; @@ -19,6 +20,7 @@ import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.feign.ResultDataResolver; import com.epmet.commons.tools.redis.common.CustomerDingDingRedis; +import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.redis.common.bean.DingMiniInfoCache; import com.epmet.commons.tools.security.dto.GovTokenDto; import com.epmet.commons.tools.security.dto.TokenDto; @@ -830,7 +832,6 @@ public class ThirdLoginServiceImpl implements ThirdLoginService, ResultDataResol loginMQMsg.setIp(IpUtils.getIpAddr(request)); loginMQMsg.setFromApp(fromApp); loginMQMsg.setFromClient(fromClient); - SystemMsgFormDTO form = new SystemMsgFormDTO(); form.setMessageType(AuthOperationConstants.LOGIN); form.setContent(loginMQMsg); diff --git a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/ConsomerGroupConstants.java b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/ConsomerGroupConstants.java index 6bc618a01b..c4f43a03b2 100644 --- a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/ConsomerGroupConstants.java +++ b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/ConsomerGroupConstants.java @@ -108,4 +108,9 @@ public interface ConsomerGroupConstants { * 党建积分操作消费组 */ String PARTY_BUILDING_GROUP = "party_building_group"; + + /** + * 查看或者导出 日志记录 消费组 + */ + String CHECK_OR_EXPORT_GROUP = "check_or_export_group"; } diff --git a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/TopicConstants.java b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/TopicConstants.java index 23bfd628a4..2624971db2 100644 --- a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/TopicConstants.java +++ b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/TopicConstants.java @@ -91,4 +91,9 @@ public interface TopicConstants { String IC_MESSAGE = "ic_message"; String PARTY_BUILDING = "party_building"; + + /** + * 查看或者导出 日志记录 + */ + String CHECK_OR_EXPORT = "check_or_export"; } diff --git a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/CheckMQMsg.java b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/CheckMQMsg.java new file mode 100644 index 0000000000..30b1595e20 --- /dev/null +++ b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/CheckMQMsg.java @@ -0,0 +1,33 @@ +package com.epmet.commons.rocketmq.messages; + +import lombok.Data; + +import java.util.Date; + +@Data +public class CheckMQMsg { + + /** + * 谁登录 + */ + private String userId; + + private String content; + + private String typeDisplay; + private String type; + + /** + * 操作时间 + */ + private Date operateTime; + + private String ip; + + private String fromApp; + + private String fromClient; + private String orgId; + private String orgIdPath; + +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/StrConstant.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/StrConstant.java index b89a521218..1dd825b18e 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/StrConstant.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/StrConstant.java @@ -13,6 +13,8 @@ import org.springframework.http.MediaType; public interface StrConstant { String UTF_8 = CharEncoding.UTF_8; + String HTTP_STATUS_OK = "200"; + String HTTP_RESP_CODE = "code"; String ISO_8859_1 = CharEncoding.ISO_8859_1; diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/CommonUserFeignClient.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/CommonUserFeignClient.java index 0f8f937a8a..8e67c1939b 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/CommonUserFeignClient.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/CommonUserFeignClient.java @@ -2,6 +2,7 @@ package com.epmet.commons.tools.feign; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.feign.fallback.CommonUserFeignClientFallBackFactory; +import com.epmet.commons.tools.redis.common.bean.IcResiUserInfoCache; import com.epmet.commons.tools.redis.common.bean.ResiUserInfoCache; import com.epmet.commons.tools.utils.Result; import org.springframework.cloud.openfeign.FeignClient; @@ -17,4 +18,7 @@ import org.springframework.web.bind.annotation.PostMapping; public interface CommonUserFeignClient { @PostMapping("/epmetuser/userbaseinfo/getUserInfo/{userId}") Result getUserInfo(@PathVariable("userId") String userId); + + @PostMapping("/epmetuser/icresiuser/getIcResiUserInfo/{userId}") + Result getIcResiUserInfo(@PathVariable("userId") String userId); } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonUserFeignClientFallback.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonUserFeignClientFallback.java index 8cd5660484..77f212943c 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonUserFeignClientFallback.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonUserFeignClientFallback.java @@ -2,6 +2,7 @@ package com.epmet.commons.tools.feign.fallback; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.feign.CommonUserFeignClient; +import com.epmet.commons.tools.redis.common.bean.IcResiUserInfoCache; import com.epmet.commons.tools.redis.common.bean.ResiUserInfoCache; import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.Result; @@ -20,4 +21,9 @@ public class CommonUserFeignClientFallback implements CommonUserFeignClient { public Result getUserInfo(String userId) { return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getUserInfo", userId); } + + @Override + public Result getIcResiUserInfo(String userId) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getIcResiUserInfo", userId); + } } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java index c09f13f2f4..49ab921e0f 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java @@ -393,6 +393,10 @@ public class RedisKeys { return rootPrefix.concat("resi:user:").concat(userId); } + public static String getIcResiUserKey(String userId) { + return rootPrefix.concat("resi:icResiUser:").concat(userId); + } + /** * @param userId * @return epmet:badge:user:[customerId]:[userId] diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/CustomerResiUserRedis.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/CustomerResiUserRedis.java index 5b34fcdee7..2efa0bdbf1 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/CustomerResiUserRedis.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/CustomerResiUserRedis.java @@ -1,10 +1,12 @@ package com.epmet.commons.tools.redis.common; import cn.hutool.core.bean.BeanUtil; +import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.feign.CommonUserFeignClient; import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisUtils; +import com.epmet.commons.tools.redis.common.bean.IcResiUserInfoCache; import com.epmet.commons.tools.redis.common.bean.ResiUserInfoCache; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; @@ -70,6 +72,31 @@ public class CustomerResiUserRedis { return resultData; } + public static IcResiUserInfoCache getIcResiUserInfo(String icResiUserId){ + if (StringUtils.isBlank(icResiUserId)){ + log.warn("getIcResiUserInfo param is blank,userId:{}",icResiUserId); + return null; + } + String key = RedisKeys.getIcResiUserKey(icResiUserId); + Map map = customerResiUserRedis.redisUtils.hGetAll(key); + if (!CollectionUtils.isEmpty(map)) { + return ConvertUtils.mapToEntity(map, IcResiUserInfoCache.class); + } + Result result = customerResiUserRedis.commonUserFeignClient.getIcResiUserInfo(icResiUserId); + if (result == null || !result.success()) { + throw new EpmetException("获取居民信息失败"); + } + IcResiUserInfoCache data = result.getData(); + if (null == data) { + log.warn("居民信息为空,userId:{}", icResiUserId); + return null; + } + + Map cacheMap = BeanUtil.beanToMap(data, false, true); + customerResiUserRedis.redisUtils.hMSet(key, cacheMap); + return data; + } + @Nullable private static ResiUserInfoCache reloadStaffCache(String userId, String key) { Result result = customerResiUserRedis.commonUserFeignClient.getUserInfo(userId); @@ -87,4 +114,15 @@ public class CustomerResiUserRedis { return resultData; } + /** + * Desc: 删除Ic居民缓存 + * @param icResiUserId + * @author zxc + * @date 2022/10/20 15:57 + */ + public static Boolean delIcResiUserInfo(String icResiUserId){ + String key = RedisKeys.getIcResiUserKey(icResiUserId); + return customerResiUserRedis.redisUtils.delete(key); + } + } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/IcResiUserInfoCache.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/IcResiUserInfoCache.java new file mode 100644 index 0000000000..6749272790 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/IcResiUserInfoCache.java @@ -0,0 +1,539 @@ +package com.epmet.commons.tools.redis.common.bean; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * @Author zxc + * @DateTime 2022/10/17 15:40 + * @DESC + */ +@Data +public class IcResiUserInfoCache implements Serializable { + + private static final long serialVersionUID = -3644143706074015380L; + + + /** + * 主键 + */ + private String id; + + /** + * 客户Id customer.id + */ + private String customerId; + + /** + * + */ + private String agencyId; + + /** + * + */ + private String pids; + + /** + * 网格ID + */ + private String gridId; + + /** + * 所属小区ID + */ + private String villageId; + + /** + * 所属楼宇Id + */ + private String buildId; + + /** + * 单元id + */ + private String unitId; + + /** + * 所属家庭Id + */ + private String homeId; + + /** + * 是否本地户籍 + */ + private String isBdhj; + + /** + * 姓名 + */ + private String name; + + /** + * 手机号 + */ + private String mobile; + + /** + * 性别 + */ + private String gender; + + /** + * 身份证号 + */ + private String idCard; + + /** + * 出生日期 + */ + private String birthday; + + /** + * 备注 + */ + private String remarks; + + /** + * 联系人 + */ + private String contacts; + + /** + * 联系人电话 + */ + private String contactsMobile; + + /** + * 九小场所url + */ + private String ninePlace; + + /** + * 是否党员 + */ + private String isParty; + + /** + * 是否低保户 + */ + private String isDbh; + + /** + * 是否保障房 + */ + private String isEnsureHouse; + + /** + * 是否失业 + */ + private String isUnemployed; + + /** + * 是否育龄妇女 + */ + private String isYlfn; + + /** + * 是否退役军人 + */ + private String isVeterans; + + /** + * 是否统战人员 + */ + private String isUnitedFront; + + /** + * 是否信访人员 + */ + private String isXfry; + + /** + * 是否志愿者 + */ + private String isVolunteer; + + /** + * 是否老年人 + */ + private String isOldPeople; + + /** + * 是否空巢 + */ + private String isKc; + + /** + * 是否失独 + */ + private String isSd; + + /** + * 是否失能 + */ + private String isSn; + + /** + * 是否失智 + */ + private String isSz; + + /** + * 是否残疾 + */ + private String isCj; + + /** + * 是否大病 + */ + private String isDb; + + /** + * 是否慢病 + */ + private String isMb; + + /** + * 是否特殊人群 + */ + private String isSpecial; + + /** + * 是否租户【是:1 否:0】 + */ + private String isTenant; + + /** + * 是否是流动人口【是:1 否:0】 + */ + private String isFloating; + + /** + * 是否新阶层人士【是:1 否:0】 + */ + private String isXjc; + + /** + * 文化程度【字典表】 + */ + private String culture; + + /** + * 文化程度备注 + */ + private String cultureRemakes; + + /** + * 特长【字典表】 + */ + private String specialSkill; + + /** + * 兴趣爱好 + */ + private String hobby; + + /** + * 兴趣爱好备注 + */ + private String hobbyRemakes; + + /** + * 宗教信仰 + */ + private String faith; + + /** + * 宗教信仰备注 + */ + private String faithRemakes; + + /** + * 残疾类别【字典表】 + */ + private String cjlb; + + /** + * 残疾登记(状况)【字典表】 + */ + private String cjzk; + + /** + * 残疾证号 + */ + private String cjzh; + + /** + * 残疾说明 + */ + private String cjsm; + + /** + * 有无监护人【yes no】 + */ + private String ynJdr; + + /** + * 有无技能特长【yes no】 + */ + private String ynJntc; + + /** + * 有无劳动能力 + */ + private String ynLdnl; + + /** + * 有无非义务教育阶段助学【yes no】 + */ + private String ynFywjyjdzx; + + /** + * 所患大病 + */ + private String shdb; + + /** + * 患大病时间 + */ + private String dbsj; + + /** + * 所患慢性病 + */ + private String shmxb; + + /** + * 患慢性病时间 + */ + private String mxbsj; + + /** + * 是否参保 + */ + private String isCb; + + /** + * 自付金额 + */ + private String zfje; + + /** + * 救助金额 + */ + private String jzje; + + /** + * 救助时间[yyyy-MM-dd] + */ + private String jzsj; + + /** + * 享受救助明细序号 + */ + private String jzmxxh; + + /** + * 健康信息备注 + */ + private String healthRemakes; + + /** + * 工作单位 + */ + private String gzdw; + + /** + * 职业 + */ + private String zy; + + /** + * 离退休时间 + */ + private String ltxsj; + + /** + * 工作信息备注 + */ + private String workRemake; + + /** + * 退休金额 + */ + private String txje; + + /** + * 月收入 + */ + private String ysr; + + /** + * 是否经济低保 + */ + private String isJjdb; + + /** + * 籍贯 + */ + private String jg; + + /** + * 户籍所在地 + */ + private String hjszd; + + /** + * 现居住地 + */ + private String xjzd; + + /** + * 人户情况 + */ + private String rhzk; + + /** + * 居住信息备注 + */ + private String jzxxRemakes; + + /** + * 民族【字典表】 + */ + private String mz; + + /** + * 与户主关系【字典表】 + */ + private String yhzgx; + + /** + * 居住情况【字典表】 + */ + private String jzqk; + + /** + * 婚姻状况【字典表】 + */ + private String hyzk; + + /** + * 配偶情况【字典表】 + */ + private String poqk; + + /** + * 有无赡养人 + */ + private String ynSyr; + + /** + * 与赡养人关系【字典表】 + */ + private String ysyrgx; + + /** + * 赡养人电话 + */ + private String syrMobile; + + /** + * 家庭信息备注 + */ + private String jtxxRemakes; + + /** + * 用户状态【0:正常;1:迁出;2:注销】 + */ + private String status; + + /** + * 用户详细状态:01:新增、02:导入、03:迁入、04:新生、11:迁出、21死亡 + */ + private String subStatus; + + + /** + * 删除标识 0.未删除 1.已删除 + */ + private Integer delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + + /** + * 预留字段1 + */ + private String field1; + + /** + * 预留字段2 + */ + private String field2; + + /** + * 预留字段3 + */ + private String field3; + + /** + * 预留字段4 + */ + private String field4; + + /** + * 预留字段5 + */ + private String field5; + + /** + * 预留字段6 + */ + private String field6; + + /** + * 预留字段7 + */ + private String field7; + + /** + * 预留字段8 + */ + private String field8; + + /** + * 预留字段9 + */ + private String field9; + + /** + * 预留字段10 + */ + private String field10; +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/YtHsResUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/YtHsResUtils.java index cb28cf5419..9010c9b84a 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/YtHsResUtils.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/YtHsResUtils.java @@ -2,14 +2,18 @@ package com.epmet.commons.tools.utils; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.dto.result.YtDataSyncResDTO; import com.epmet.commons.tools.dto.result.YtHscyResDTO; import com.epmet.commons.tools.dto.result.YtHsjcResDTO; +import com.google.common.util.concurrent.RateLimiter; import lombok.extern.slf4j.Slf4j; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.TimeUnit; /** * @Description @@ -19,14 +23,15 @@ import java.util.Map; @Slf4j public class YtHsResUtils { private static String SERVER_URL = "http://10.2.2.60:8191/sjzt/server/"; - private static final String APP_KEY_VALUE = "DR4jF5Be7sCsqDmCamq2tmYCl"; private static final String APP_KEY = "appkey"; private static final String CARD_NO = "card_no"; - private static final String USER_NAME = "name"; private static final String ROW_NUM = "ROWNUM"; private static final String PAGE_SIZE = "PAGESIZE"; - private static final String START = "ROWNUM"; - private static final String LIMIT = "PAGESIZE"; + /** + * rate is "2 permits per second" + */ + private static final Map rateLimiterMap = new ConcurrentHashMap<>(); + /** * desc:核酸采样查询 @@ -35,28 +40,42 @@ public class YtHsResUtils { */ public static YtHscyResDTO hscy(String cardNo, Integer rowNum, Integer pageSize) { try { + tryAcquire("hscy"); + Map param = new HashMap<>(); - param.put(APP_KEY, APP_KEY_VALUE); + param.put(APP_KEY, "tz45j4kuWcnnjoJOVSlzGWJgI"); param.put(CARD_NO, cardNo); param.put(ROW_NUM, rowNum); param.put(PAGE_SIZE, pageSize); log.info("hscy api param:{}", param); - //todo 核酸检测 mock数据 放开她 - //Result result = HttpClientManager.getInstance().sendGet(SERVER_URL+"hscyxxcx", param); - String mockData = "{\"id\":\"1570924677539635484\",\"name\":\"杨XX\",\"card_type\":\"1\",\"card_no\":\"370283199912010302\",\"create_by\":\"370613594\",\"create_time\":\"2022-09-17 07:15:22\",\"sys_org_code\":\"370613\",\"sample_tube\":\"GCJ-0825-0441\",\"package_id\":\"bcj00208083952\",\"city\":\"烟台市\",\"uuid\":\"6225684525062602095\",\"county\":\"莱山区\",\"depart_ids\":\"未填写\",\"depart_name\":null,\"realname\":\"采样点327\",\"upload_time\":\"2022-09-17 07:56:45\",\"sd_id\":null,\"sd_batch\":null,\"sd_operation\":null,\"sd_time\":null,\"inserttime\":\"2022-09-17 09:36:20\"}"; - Result result = new Result().ok(mockData); + + Result result = HttpClientManager.getInstance().sendGet(SERVER_URL + "hscyxxcx", param); +// String mockData = "{\"code\":\"200\",\"msg\":\"请求成功\",\"data\":[{\"id\":\"1570924677539635484\",\"name\":\"杨XX\",\"card_type\":\"1\",\"card_no\":\"370283199912010302\",\"create_by\":\"370613594\",\"create_time\":\"2022-09-24 06:48:28\",\"sys_org_code\":\"370613\",\"sample_tube\":\"GCJ-0825-0441\",\"package_id\":\"bcj00208083952\",\"city\":\"烟台市\",\"uuid\":\"6225684525062602095\",\"county\":\"莱山区\",\"depart_ids\":\"未填写\",\"depart_name\":null,\"realname\":\"采样点327\",\"upload_time\":\"2022-09-17 07:56:45\",\"sd_id\":null,\"sd_batch\":null,\"sd_operation\":null,\"sd_time\":null,\"inserttime\":\"2022-09-17 09:36:20\"}]}"; +// Result result = new Result().ok(mockData); log.info("hscy api result:{}", JSON.toJSONString(result)); if (result.success()) { - return JSON.parseObject(result.getData(), YtHscyResDTO.class); + String data = result.getData(); + JSONObject jsonObject = JSON.parseObject(data); + if (jsonObject != null && StrConstant.HTTP_STATUS_OK.equals(jsonObject.getString(StrConstant.HTTP_RESP_CODE))) { + return JSON.parseObject(result.getData(), YtHscyResDTO.class); + } else { + log.warn("hscy 调用蓝图接口败"); + } } } catch (Exception e) { - log.error(String.format("烟台核酸检测结果查询异常cardNo:%s,异常信息:%s", cardNo, e.getMessage())); + log.error(String.format("烟台核酸检测结果查询异常cardNo:%s", cardNo), e); } YtHscyResDTO resultResult = new YtHscyResDTO(); resultResult.setData(new ArrayList<>()); return resultResult; } + private static void tryAcquire(String hscy) { + RateLimiter rateLimiter = rateLimiterMap.getOrDefault(hscy, RateLimiter.create(2.0)); + rateLimiterMap.putIfAbsent(hscy,rateLimiter); + rateLimiter.tryAcquire(1, TimeUnit.SECONDS); + } + /** * desc:核酸结果查询 * @@ -64,24 +83,30 @@ public class YtHsResUtils { */ public static YtHsjcResDTO hsjc(String cardNo, Integer rowNum, Integer pageSize) { try { - //String param = String.format("&card_no=%s&ROWNUM=%s&PAGESIZE=%s", cardNo, rowNum, pageSize); - //String apiUrl = url.concat(param); + tryAcquire("hsjc"); + Map param = new HashMap<>(); - param.put(APP_KEY, APP_KEY_VALUE); + param.put(APP_KEY, "DR4jF5Be7sCsqDmCamq2tmYCl"); param.put(CARD_NO, cardNo); param.put(ROW_NUM, rowNum); param.put(PAGE_SIZE, pageSize); log.info("hsjc api param:{}", param); - //todo 核酸检测 mock数据 放开她 - //Result result = HttpClientManager.getInstance().sendGet(SERVER_URL+"hsjcxx", param); - String mockData = "{\"code\":\"200\",\"msg\":\"请求成功\",\"data\":[{\"id\":\"6a31eb2d38c011eda054fa163ebc7ff4\",\"name\":\"数据同步测试用户\",\"card_no\":\"370283199912010302\",\"telephone\":\"13697890860\",\"address\":\"保利香榭里公馆18-1-302\",\"test_time\":\"2022-09-20 12:52:28\",\"depart_name\":\"天仁医学检验实验室有限公司\",\"county\":\"莱山区\",\"upload_time\":\"2022-09-20 21:23:10\",\"sample_result_pcr\":\"2\",\"sample_time\":\"2022-09-20 06:48:28\",\"sampling_org_pcr\":\"采样点327\"}],\"total\":1}"; - Result result = new Result().ok(mockData); + Result result = HttpClientManager.getInstance().sendGet(SERVER_URL + "hsjcxx", param); +// String mockData = "{\"code\":\"200\",\"msg\":\"请求成功\",\"data\":[{\"id\":\"6a31eb2d38c011eda054fa163ebc7ff4\",\"name\":\"数据同步测试用户\",\"card_no\":\"370283199912010302\",\"telephone\":\"13697890860\",\"address\":\"保利香榭里公馆18-1-302\",\"test_time\":\"2022-09-24 12:52:28\",\"depart_name\":\"天仁医学检验实验室有限公司\",\"county\":\"莱山区\",\"upload_time\":\"2022-09-20 21:23:10\",\"sample_result_pcr\":\"2\",\"sample_time\":\"2022-09-24 06:48:28\",\"sampling_org_pcr\":\"采样点327\"}],\"total\":1}"; +// Result result = new Result().ok(mockData); log.info("hsjc api result:{}", JSON.toJSONString(result)); if (result.success()) { - return JSON.parseObject(result.getData(), YtHsjcResDTO.class); + String data = result.getData(); + JSONObject jsonObject = JSON.parseObject(data); + if (jsonObject != null && StrConstant.HTTP_STATUS_OK.equals(jsonObject.getString(StrConstant.HTTP_RESP_CODE))) { + return JSON.parseObject(result.getData(), YtHsjcResDTO.class); + } else { + log.warn("hsjc 调用蓝图接口败"); + } + } } catch (Exception e) { - log.error(String.format("烟台核酸检测结果查询异常cardNo:%s,异常信息:%s", cardNo, e.getMessage())); + log.error(String.format("烟台核酸检测结果查询异常cardNo:%s", cardNo), e); } YtHsjcResDTO resultResult = new YtHsjcResDTO(); resultResult.setData(new ArrayList<>()); @@ -95,13 +120,14 @@ public class YtHsResUtils { */ public static YtDataSyncResDTO siWang(String cardNo, String userName) { try { + tryAcquire("siWang"); // 1)appkey秘钥 // 2)name姓名 必填 // 3)idcard身份证号 必填 // 4)start开始默认0 // 5)limit每页记录数 Map param = new HashMap<>(); - param.put(APP_KEY, APP_KEY_VALUE); + param.put(APP_KEY, "IGE8TMM6f4t1Sef7FfstOLHAL"); param.put("id_card", cardNo); param.put("name", userName); param.put("start", 0); @@ -109,24 +135,26 @@ public class YtHsResUtils { log.info("siWang api param:{}", param); - //todo 放开他 - //Result result = HttpClientManager.getInstance().sendGet(SERVER_URL+"mzt_hhrysj1", param); - String mockData = "{\"code\":\"200\",\"msg\":\"请求成功\",\"data\":\"{\\\"code\\\":200,\\\"data\\\":\\\"{\\\\\\\"data\\\\\\\":[{\\\\\\\"AGE\\\\\\\":\\\\\\\"82\\\\\\\",\\\\\\\"BIRTHDAY\\\\\\\":\\\\\\\"1933-02-23\\\\\\\",\\\\\\\"CARD_TYPE\\\\\\\":\\\\\\\"1\\\\\\\",\\\\\\\"CREATE_ORGAN_NAME\\\\\\\":\\\\\\\"莱州市殡仪馆\\\\\\\",\\\\\\\"CREMATION_TIME\\\\\\\":\\\\\\\"2016-01-03 13:01\\\\\\\",\\\\\\\"DEAD_ID\\\\\\\":\\\\\\\"8abc809851ffaf1501520600555c2849\\\\\\\",\\\\\\\"DEATH_DATE\\\\\\\":\\\\\\\"2016-01-02\\\\\\\",\\\\\\\"FAMILY_ADD\\\\\\\":\\\\\\\"山东省莱州市光州西路420号\\\\\\\",\\\\\\\"FOLK\\\\\\\":\\\\\\\"01\\\\\\\",\\\\\\\"ID_CARD\\\\\\\":\\\\\\\"370625193302231929\\\\\\\",\\\\\\\"NAME\\\\\\\":\\\\\\\"陈秀芬\\\\\\\",\\\\\\\"NATION\\\\\\\":\\\\\\\"156\\\\\\\",\\\\\\\"POPULACE\\\\\\\":\\\\\\\"3381C300B4B9439FE05319003C0A0897\\\\\\\",\\\\\\\"POPULACE_NAME\\\\\\\":\\\\\\\"烟台市莱州市文昌路街道\\\\\\\",\\\\\\\"RECORD_ID\\\\\\\":\\\\\\\"8abc809851ffaf1501520600694e2877\\\\\\\",\\\\\\\"RN\\\\\\\":\\\\\\\"1\\\\\\\",\\\\\\\"SEX\\\\\\\":\\\\\\\"2\\\\\\\"}],\\\\\\\"fields\\\\\\\":[\\\\\\\"RN\\\\\\\",\\\\\\\"RECORD_ID\\\\\\\",\\\\\\\"DEAD_ID\\\\\\\",\\\\\\\"NAME\\\\\\\",\\\\\\\"SEX\\\\\\\",\\\\\\\"CARD_TYPE\\\\\\\",\\\\\\\"ID_CARD\\\\\\\",\\\\\\\"BIRTHDAY\\\\\\\",\\\\\\\"AGE\\\\\\\",\\\\\\\"NATION\\\\\\\",\\\\\\\"FOLK\\\\\\\",\\\\\\\"IF_LOCAL\\\\\\\",\\\\\\\"POPULACE\\\\\\\",\\\\\\\"FAMILY_ADD\\\\\\\",\\\\\\\"WORK_NAME\\\\\\\",\\\\\\\"DEATH_DATE\\\\\\\",\\\\\\\"CREMATION_TIME\\\\\\\",\\\\\\\"CREATE_ORGAN_NAME\\\\\\\",\\\\\\\"POPULACE_NAME\\\\\\\"],\\\\\\\"total\\\\\\\":\\\\\\\"1\\\\\\\"}\\\",\\\"message\\\":\\\"\\\"}\",\"total\":0}"; - Result result = new Result().ok(mockData); + Result result = HttpClientManager.getInstance().sendGet(SERVER_URL + "mzt_hhrysj1", param); +// String mockData = "{\"code\":\"200\",\"msg\":\"请求成功\",\"data\":\"{\\\"code\\\":200,\\\"data\\\":\\\"{\\\\\\\"data\\\\\\\":[{\\\\\\\"AGE\\\\\\\":\\\\\\\"82\\\\\\\",\\\\\\\"BIRTHDAY\\\\\\\":\\\\\\\"1933-02-23\\\\\\\",\\\\\\\"CARD_TYPE\\\\\\\":\\\\\\\"1\\\\\\\",\\\\\\\"CREATE_ORGAN_NAME\\\\\\\":\\\\\\\"莱州市殡仪馆\\\\\\\",\\\\\\\"CREMATION_TIME\\\\\\\":\\\\\\\"2016-01-03 13:01\\\\\\\",\\\\\\\"DEAD_ID\\\\\\\":\\\\\\\"8abc809851ffaf1501520600555c2849\\\\\\\",\\\\\\\"DEATH_DATE\\\\\\\":\\\\\\\"2016-01-02\\\\\\\",\\\\\\\"FAMILY_ADD\\\\\\\":\\\\\\\"山东省莱州市光州西路420号\\\\\\\",\\\\\\\"FOLK\\\\\\\":\\\\\\\"01\\\\\\\",\\\\\\\"ID_CARD\\\\\\\":\\\\\\\"370625193302231929\\\\\\\",\\\\\\\"NAME\\\\\\\":\\\\\\\"陈秀芬\\\\\\\",\\\\\\\"NATION\\\\\\\":\\\\\\\"156\\\\\\\",\\\\\\\"POPULACE\\\\\\\":\\\\\\\"3381C300B4B9439FE05319003C0A0897\\\\\\\",\\\\\\\"POPULACE_NAME\\\\\\\":\\\\\\\"烟台市莱州市文昌路街道\\\\\\\",\\\\\\\"RECORD_ID\\\\\\\":\\\\\\\"8abc809851ffaf1501520600694e2877\\\\\\\",\\\\\\\"RN\\\\\\\":\\\\\\\"1\\\\\\\",\\\\\\\"SEX\\\\\\\":\\\\\\\"2\\\\\\\"}],\\\\\\\"fields\\\\\\\":[\\\\\\\"RN\\\\\\\",\\\\\\\"RECORD_ID\\\\\\\",\\\\\\\"DEAD_ID\\\\\\\",\\\\\\\"NAME\\\\\\\",\\\\\\\"SEX\\\\\\\",\\\\\\\"CARD_TYPE\\\\\\\",\\\\\\\"ID_CARD\\\\\\\",\\\\\\\"BIRTHDAY\\\\\\\",\\\\\\\"AGE\\\\\\\",\\\\\\\"NATION\\\\\\\",\\\\\\\"FOLK\\\\\\\",\\\\\\\"IF_LOCAL\\\\\\\",\\\\\\\"POPULACE\\\\\\\",\\\\\\\"FAMILY_ADD\\\\\\\",\\\\\\\"WORK_NAME\\\\\\\",\\\\\\\"DEATH_DATE\\\\\\\",\\\\\\\"CREMATION_TIME\\\\\\\",\\\\\\\"CREATE_ORGAN_NAME\\\\\\\",\\\\\\\"POPULACE_NAME\\\\\\\"],\\\\\\\"total\\\\\\\":\\\\\\\"1\\\\\\\"}\\\",\\\"message\\\":\\\"\\\"}\",\"total\":0}"; +// Result result = new Result().ok(mockData); log.info("siWang api result:{}", JSON.toJSONString(result)); + if (!result.success()) { + return new YtDataSyncResDTO(); + } String data = result.getData(); JSONObject jsonObject = JSON.parseObject(data); //他们的结果是成功的 - if (jsonObject != null && "200".equals(jsonObject.getString("code"))) { + if (jsonObject != null && StrConstant.HTTP_STATUS_OK.equals(jsonObject.getString(StrConstant.HTTP_RESP_CODE))) { //第一层 JSONObject firstData = JSON.parseObject(jsonObject.getString("data")); //第二层 data - if (firstData != null && "200".equals(firstData.getString("code"))) { + if (firstData != null && StrConstant.HTTP_STATUS_OK.equals(firstData.getString(StrConstant.HTTP_RESP_CODE))) { //第一层 JSONObject secondData = JSON.parseObject(firstData.getString("data")); Object thirdData = ""; - if (secondData != null && secondData.getJSONArray("data") != null) { + if (secondData != null && secondData.getJSONArray("data") != null && secondData.getJSONArray("data").size() >0 ) { //第二层 data thirdData = secondData.getJSONArray("data").get(0); } @@ -138,7 +166,7 @@ public class YtHsResUtils { log.warn("siWang 调用蓝图接口败"); } } catch (Exception e) { - log.error(String.format("烟台siWang结果查询异常cardNo:%s,异常信息:%s", cardNo, e.getMessage())); + log.error(String.format("烟台siWang结果查询异常cardNo:%s", cardNo), e); } return new YtDataSyncResDTO(); } @@ -150,6 +178,7 @@ public class YtHsResUtils { * @remark:默认失败 因为一旦成功没有数据 会影响残疾人的数据 接口失败数据不做任何处理 */ public static YtDataSyncResDTO canji(String idCard, String userName) { + tryAcquire("canji"); YtDataSyncResDTO failResult = new YtDataSyncResDTO(); failResult.setCode(500); @@ -159,46 +188,27 @@ public class YtHsResUtils { // 2)name姓名 // 3)citizenId身份证号 Map param = new HashMap<>(); - param.put(APP_KEY, APP_KEY_VALUE); + param.put(APP_KEY, "EWGsaK0aM21wkDjCIWbahGVk2"); param.put("citizenId", idCard); param.put("name", userName); log.info("canji api param:{}", param); - //todo 上线放开她 - //Result result = HttpClientManager.getInstance().sendGet(SERVER_URL+"sdcl_xxzx_czcjr1", param); - String mockData = "{\"code\":\"200\",\"msg\":\"请求成功\",\"data\":\"{\\\"code\\\":200,\\\"data\\\":\\\"{\\\\\\\"result\\\\\\\":true,\\\\\\\"errorcode\\\\\\\":0,\\\\\\\"msg\\\\\\\":\\\\\\\"获取成功\\\\\\\",\\\\\\\"data\\\\\\\":{\\\\\\\"isNewRecord\\\\\\\":true,\\\\\\\"delFlag\\\\\\\":\\\\\\\"0\\\\\\\",\\\\\\\"pageNo\\\\\\\":0,\\\\\\\"pageSize\\\\\\\":0,\\\\\\\"name\\\\\\\":\\\\\\\"数据同步测试用户\\\\\\\",\\\\\\\"genderName\\\\\\\":\\\\\\\"男\\\\\\\",\\\\\\\"citizenId\\\\\\\":\\\\\\\"370682198002072719\\\\\\\",\\\\\\\"cardNum\\\\\\\":\\\\\\\"370283199912010302\\\\\\\",\\\\\\\"idtKindName\\\\\\\":\\\\\\\"精神\\\\\\\",\\\\\\\"idtLevelName\\\\\\\":\\\\\\\"二级\\\\\\\",\\\\\\\"eduLevelName\\\\\\\":\\\\\\\"小学\\\\\\\",\\\\\\\"marriagerName\\\\\\\":\\\\\\\"未婚\\\\\\\",\\\\\\\"guardian\\\\\\\":\\\\\\\"盖希仁\\\\\\\",\\\\\\\"guardianPhone\\\\\\\":\\\\\\\"13854516627\\\\\\\",\\\\\\\"guardianRName\\\\\\\":\\\\\\\"兄/弟/姐/妹\\\\\\\",\\\\\\\"raceName\\\\\\\":\\\\\\\"汉族\\\\\\\",\\\\\\\"certDate\\\\\\\":1620779842000,\\\\\\\"residentAdd\\\\\\\":\\\\\\\"姜疃镇凤头村248号附1号\\\\\\\",\\\\\\\"nowAdd\\\\\\\":\\\\\\\"山东省烟台市莱阳市姜疃镇凤头村委会\\\\\\\",\\\\\\\"phoneNo\\\\\\\":\\\\\\\"13854516627\\\\\\\"}}\\\",\\\"message\\\":\\\"\\\"}\",\"total\":0}"; - Result result = new Result().ok(mockData); + Result result = HttpClientManager.getInstance().sendGet(SERVER_URL + "sdcl_xxzx_czcjr1", param); +// String mockData = "{\"code\":\"200\",\"msg\":\"请求成功\",\"data\":\"{\\\"code\\\":200,\\\"data\\\":\\\"{\\\\\\\"result\\\\\\\":true,\\\\\\\"errorcode\\\\\\\":0,\\\\\\\"msg\\\\\\\":\\\\\\\"获取成功\\\\\\\",\\\\\\\"data\\\\\\\":{\\\\\\\"isNewRecord\\\\\\\":true,\\\\\\\"delFlag\\\\\\\":\\\\\\\"0\\\\\\\",\\\\\\\"pageNo\\\\\\\":0,\\\\\\\"pageSize\\\\\\\":0,\\\\\\\"name\\\\\\\":\\\\\\\"数据同步测试用户\\\\\\\",\\\\\\\"genderName\\\\\\\":\\\\\\\"男\\\\\\\",\\\\\\\"citizenId\\\\\\\":\\\\\\\"370682198002072719\\\\\\\",\\\\\\\"cardNum\\\\\\\":\\\\\\\"370283199912010302\\\\\\\",\\\\\\\"idtKindName\\\\\\\":\\\\\\\"精神\\\\\\\",\\\\\\\"idtLevelName\\\\\\\":\\\\\\\"二级\\\\\\\",\\\\\\\"eduLevelName\\\\\\\":\\\\\\\"小学\\\\\\\",\\\\\\\"marriagerName\\\\\\\":\\\\\\\"未婚\\\\\\\",\\\\\\\"guardian\\\\\\\":\\\\\\\"盖希仁\\\\\\\",\\\\\\\"guardianPhone\\\\\\\":\\\\\\\"13854516627\\\\\\\",\\\\\\\"guardianRName\\\\\\\":\\\\\\\"兄/弟/姐/妹\\\\\\\",\\\\\\\"raceName\\\\\\\":\\\\\\\"汉族\\\\\\\",\\\\\\\"certDate\\\\\\\":1620779842000,\\\\\\\"residentAdd\\\\\\\":\\\\\\\"姜疃镇凤头村248号附1号\\\\\\\",\\\\\\\"nowAdd\\\\\\\":\\\\\\\"山东省烟台市莱阳市姜疃镇凤头村委会\\\\\\\",\\\\\\\"phoneNo\\\\\\\":\\\\\\\"13854516627\\\\\\\"}}\\\",\\\"message\\\":\\\"\\\"}\",\"total\":0}"; +// Result result = new Result().ok(mockData); log.info("canji api result:{}", JSON.toJSONString(result)); + if (result.success()) { - /*返回示例 - { - "code":"200", - "msg":"请求成功", - "data":"{ - \"code\":200, - \"data\":{ - \\\"result\\\":true, - \\\"errorcode\\\":0, - \\\"msg\\\":\\\"获取成功\\\", - \\\"data\\\":{ - \\\"isNewRecord\\\":\\\"true\\\", - } - } - \"message\":\"\" - }", - "total":0 - } - */ String data = result.getData(); JSONObject jsonObject = JSON.parseObject(data); //他们的结果是成功的 - if (jsonObject != null && "200".equals(jsonObject.getString("code"))) { + if (jsonObject != null && StrConstant.HTTP_STATUS_OK.equals(jsonObject.getString(StrConstant.HTTP_RESP_CODE))) { //第一层data JSONObject realObject = JSON.parseObject(jsonObject.getString("data")); - if (realObject != null && "200".equals(realObject.getString("code"))) { + if (realObject != null && StrConstant.HTTP_STATUS_OK.equals(realObject.getString(StrConstant.HTTP_RESP_CODE))) { //第二层 data String thirdData = realObject.getString("data"); return JSON.parseObject(thirdData, YtDataSyncResDTO.class); @@ -211,15 +221,15 @@ public class YtHsResUtils { } } catch (Exception e) { - log.error(String.format("烟台canji结果查询异常cardNo:%s,异常信息:%s", idCard, e.getMessage())); + log.error(String.format("烟台canji结果查询异常cardNo:%s,异常信息:%s", idCard), e); } return failResult; } public static void main(String[] args) { - YtDataSyncResDTO canji = canji("123", "123"); - System.out.println("残疾结果:" + JSON.toJSON(canji)); + //YtDataSyncResDTO canji = canji("123", "123"); + //System.out.println("残疾结果:" + JSON.toJSON(canji)); YtDataSyncResDTO siwang = siWang("1213", "!23"); diff --git a/epmet-module/data-aggregator/data-aggregator-server/pom.xml b/epmet-module/data-aggregator/data-aggregator-server/pom.xml index 27873367ec..30999f1c99 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/pom.xml +++ b/epmet-module/data-aggregator/data-aggregator-server/pom.xml @@ -126,6 +126,18 @@ 2.0.0 compile + + com.epmet + epmet-commons-rocketmq + 2.0.0 + compile + + + com.epmet + epmet-message-client + 2.0.0 + compile + diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/EpmetUserController.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/EpmetUserController.java index 9b9c7a0ef1..24d9c5a738 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/EpmetUserController.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/EpmetUserController.java @@ -14,6 +14,8 @@ import com.epmet.dataaggre.dto.govorg.result.GridMemberDataAnalysisResultDTO; import com.epmet.dataaggre.excel.StaffPatrollExcel; import com.epmet.dataaggre.service.datastats.DataStatsService; import com.epmet.dataaggre.service.epmetuser.EpmetUserService; +import com.epmet.dto.form.DetailByTypeFormDTO; +import com.epmet.dto.result.DetailByTypeResultDTO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -285,4 +287,16 @@ public class EpmetUserController { return new Result>().ok(epmetUserService.gridMemberPatrolList(formDTO)); } + /** + * Desc: 数据明文查询 + * @param formDTO + * @author zxc + * @date 2022/10/17 13:45 + */ + @PostMapping("detailByType") + public Result detailByType(@RequestBody DetailByTypeFormDTO formDTO, @LoginUser TokenDto tokenDto){ + ValidatorUtils.validateEntity(formDTO, DetailByTypeFormDTO.DetailByTypeForm.class); + return new Result().ok(epmetUserService.detailByType(formDTO,tokenDto)); + } + } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/IcResiUserDao.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/IcResiUserDao.java index 3b3a66dd50..e666aab317 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/IcResiUserDao.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/IcResiUserDao.java @@ -30,6 +30,7 @@ import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.List; +import java.util.Map; /** * 用户基础信息 @@ -138,4 +139,14 @@ public interface IcResiUserDao extends BaseDao { @Param("agencyId")String agencyId, @Param("staffOrgIds")String staffOrgIds, @Param("search")String search); + + Map getTripReportRecordInfo(@Param("id")String id); + + Map getVaccineRecordInfo(@Param("id")String id); + + Map getSpecialAttentionInfo(@Param("id")String id); + + Map getNoNatCompareInfo(@Param("id")String id); + + Map getNatInfo(@Param("id")String id); } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/EpmetUserService.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/EpmetUserService.java index 901087a7ba..6ff3e02f90 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/EpmetUserService.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/EpmetUserService.java @@ -1,6 +1,7 @@ package com.epmet.dataaggre.service.epmetuser; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.dataaggre.dto.datastats.form.NowStatsDataFormDTO; import com.epmet.dataaggre.dto.datastats.result.NowStatsDataResultDTO; import com.epmet.dataaggre.dto.epmetuser.form.*; @@ -20,6 +21,8 @@ import com.epmet.dataaggre.entity.epmetuser.IcPointVaccinesInoculationEntity; import com.epmet.dataaggre.entity.epmetuser.IcResiUserEntity; import com.epmet.dto.IcResiUserDTO; import com.epmet.dto.UserBaseInfoDTO; +import com.epmet.dto.form.DetailByTypeFormDTO; +import com.epmet.dto.result.DetailByTypeResultDTO; import java.util.List; import java.util.Map; @@ -250,4 +253,14 @@ public interface EpmetUserService { List listVaccinePoints(String customerId, String agencyId, String staffOrgIds, String search); List listNucleicPoints(String customerId, String agencyId,String staffOrgIds, String search); + + + /** + * Desc: 数据明文查询 + * @param formDTO + * @author zxc + * @date 2022/10/17 13:45 + */ + DetailByTypeResultDTO detailByType(DetailByTypeFormDTO formDTO, TokenDto tokenDto); + } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java index f93c66675b..79f949b525 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java @@ -2,16 +2,26 @@ package com.epmet.dataaggre.service.epmetuser.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.epmet.commons.dynamic.datasource.annotation.DataSource; +import com.epmet.commons.rocketmq.constants.TopicConstants; +import com.epmet.commons.rocketmq.messages.CheckMQMsg; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.dto.form.IdAndNameDTO; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.enums.OrgTypeEnum; +import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.redis.common.CustomerIcHouseRedis; +import com.epmet.commons.tools.redis.common.CustomerResiUserRedis; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; +import com.epmet.commons.tools.redis.common.bean.HouseInfoCache; +import com.epmet.commons.tools.redis.common.bean.IcResiUserInfoCache; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.commons.tools.utils.IpUtils; import com.epmet.constant.BadgeConstant; +import com.epmet.constant.NeighborhoodConstant; import com.epmet.constant.OrgInfoConstant; import com.epmet.dataaggre.constant.DataSourceConstant; import com.epmet.dataaggre.dao.epmetuser.*; @@ -42,7 +52,11 @@ import com.epmet.dataaggre.service.govproject.GovProjectService; import com.epmet.dataaggre.service.opercustomize.CustomerFootBarService; import com.epmet.dto.IcResiUserDTO; import com.epmet.dto.UserBaseInfoDTO; +import com.epmet.dto.form.DetailByTypeFormDTO; +import com.epmet.dto.form.SystemMsgFormDTO; +import com.epmet.dto.result.DetailByTypeResultDTO; import com.epmet.dto.result.StaffRoleResultDTO; +import com.epmet.feign.EpmetMessageOpenFeignClient; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import lombok.extern.slf4j.Slf4j; @@ -51,8 +65,11 @@ import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; import java.text.NumberFormat; import java.util.*; import java.util.stream.Collectors; @@ -98,6 +115,8 @@ public class EpmetUserServiceImpl implements EpmetUserService { private IcPointVaccinesInoculationDao pointVaccinesInoculationDao; @Resource private IcPointNucleicMonitoringDao pointNucleicMonitoringDao; + @Autowired + private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; /** * @Description 根据UserIds查询 @@ -971,4 +990,113 @@ public class EpmetUserServiceImpl implements EpmetUserService { query.like(StringUtils.isNotBlank(search), IcPointNucleicMonitoringEntity::getName, search); return pointNucleicMonitoringDao.selectList(query); } + + @Override + public DetailByTypeResultDTO detailByType(DetailByTypeFormDTO formDTO, TokenDto tokenDto) { + DetailByTypeResultDTO result = new DetailByTypeResultDTO(); + String customerId = tokenDto.getCustomerId(); + String userId = tokenDto.getUserId(); + CheckMQMsg msg = new CheckMQMsg(); + if (formDTO.getType().equals(NeighborhoodConstant.CHECK_HOUSE)){ + HouseInfoCache houseInfo = CustomerIcHouseRedis.getHouseInfo(customerId, formDTO.getId()); + if (null == houseInfo){ + throw new EpmetException("查询房屋信息失败:"+formDTO.getId()); + } + result.setMobile(houseInfo.getOwnerPhone()); + result.setIdCard(houseInfo.getOwnerIdCard()); + msg.setContent("查看"+houseInfo.getAllName()+"房屋的敏感信息"); + }else if (formDTO.getType().equals(NeighborhoodConstant.CHECK_IC_RESI_USER)){ + IcResiUserInfoCache icResiUserInfo = CustomerResiUserRedis.getIcResiUserInfo(formDTO.getId()); + if (null == icResiUserInfo){ + throw new EpmetException("查询icResiUser失败:"+formDTO.getId()); + } + result.setIdCard(icResiUserInfo.getIdCard()); + result.setMobile(icResiUserInfo.getMobile()); + msg.setContent("查看"+icResiUserInfo.getName()+"的敏感信息"); + }else if (formDTO.getType().equals(NeighborhoodConstant.JMFYXX)){ + IcResiUserInfoCache icResiUserInfo = CustomerResiUserRedis.getIcResiUserInfo(formDTO.getId()); + if (null == icResiUserInfo){ + throw new EpmetException("查询icResiUser失败:"+formDTO.getId()); + } + result.setIdCard(icResiUserInfo.getIdCard()); + result.setMobile(icResiUserInfo.getMobile()); + msg.setContent("查看"+icResiUserInfo.getName()+"的敏感信息(居民防疫信息)"); + }else if (formDTO.getType().equals(NeighborhoodConstant.ROUTE_FOLLOW)){ + Map info = icResiUserDao.getTripReportRecordInfo(formDTO.getId()); + if (null == info){ + throw new EpmetException("未查询到行程随访信息:"+formDTO.getId()); + } + result.setIdCard(info.get(NeighborhoodConstant.ID_CARD)); + result.setMobile(info.get(NeighborhoodConstant.MOBILE)); + msg.setContent("查看"+info.get(NeighborhoodConstant.NAME)+"的敏感信息(行程随访)"); + }else if (formDTO.getType().equals(NeighborhoodConstant.VACCINATION_RECORD)){ + Map info = icResiUserDao.getVaccineRecordInfo(formDTO.getId()); + if (null == info){ + throw new EpmetException("未查询到疫苗接种信息:"+formDTO.getId()); + } + result.setIdCard(info.get(NeighborhoodConstant.ID_CARD)); + result.setMobile(info.get(NeighborhoodConstant.MOBILE)); + msg.setContent("查看"+info.get(NeighborhoodConstant.NAME)+"的敏感信息(疫苗接种记录)"); + }else if (formDTO.getType().equals(NeighborhoodConstant.VACCINE_SPECIAL_ATTENTION) + || formDTO.getType().equals(NeighborhoodConstant.FOCUS_GROUP_SPECIAL_ATTENTION_QUARANTINE) + || formDTO.getType().equals(NeighborhoodConstant.FOCUS_GROUP_SPECIAL_ATTENTION_HISTORY)){ + Map info = icResiUserDao.getSpecialAttentionInfo(formDTO.getId()); + if (null == info){ + throw new EpmetException("未查询到特别关注名单信息:"+formDTO.getId()); + } + result.setIdCard(info.get(NeighborhoodConstant.ID_CARD)); + result.setMobile(info.get(NeighborhoodConstant.MOBILE)); + String cMsg = ""; + switch (formDTO.getType()){ + case NeighborhoodConstant.VACCINE_SPECIAL_ATTENTION: + cMsg = "疫苗接种关注名单"; + break; + case NeighborhoodConstant.FOCUS_GROUP_SPECIAL_ATTENTION_QUARANTINE: + cMsg = "重点人群关注名单(防疫隔离)"; + break; + case NeighborhoodConstant.FOCUS_GROUP_SPECIAL_ATTENTION_HISTORY: + cMsg = "重点人群关注名单(历史记录)"; + break; + default: + } + msg.setContent("查看"+info.get(NeighborhoodConstant.NAME)+"的敏感信息("+cMsg+")"); + + }else if (formDTO.getType().equals(NeighborhoodConstant.NO_NAT_COMPARE)){ + Map info = icResiUserDao.getNoNatCompareInfo(formDTO.getId()); + if (null == info){ + throw new EpmetException("未查询到未做核酸比对信息:"+formDTO.getId()); + } + result.setIdCard(info.get(NeighborhoodConstant.ID_CARD)); + result.setMobile(info.get(NeighborhoodConstant.MOBILE)); + msg.setContent("查看"+info.get(NeighborhoodConstant.NAME)+"的敏感信息(未做核酸比对)"); + }else if (formDTO.getType().equals(NeighborhoodConstant.NAT_RECORD)){ + Map info = icResiUserDao.getNatInfo(formDTO.getId()); + if (null == info){ + throw new EpmetException("未查询到核酸检测信息:"+formDTO.getId()); + } + result.setIdCard(info.get(NeighborhoodConstant.ID_CARD)); + result.setMobile(info.get(NeighborhoodConstant.MOBILE)); + msg.setContent("查看"+info.get(NeighborhoodConstant.NAME)+"的敏感信息(核酸检测信息)"); + } + // 发送mq消息 + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + msg.setOperateTime(new Date()); + msg.setType(formDTO.getType()); + msg.setTypeDisplay(msg.getContent()); + msg.setUserId(userId); + CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(customerId, userId); + if(null == staffInfo){ + throw new EpmetException("未查询到工作人员信息:"+userId); + } + msg.setOrgId(staffInfo.getAgencyId()); + msg.setOrgIdPath(StringUtils.isBlank(staffInfo.getAgencyPIds()) ? staffInfo.getAgencyId() : staffInfo.getAgencyPIds().concat(":").concat(staffInfo.getAgencyId())); + msg.setFromApp(tokenDto.getApp()); + msg.setIp(IpUtils.getIpAddr(request)); + msg.setFromClient(tokenDto.getClient()); + SystemMsgFormDTO form = new SystemMsgFormDTO(); + form.setMessageType(TopicConstants.CHECK_OR_EXPORT); + form.setContent(msg); + epmetMessageOpenFeignClient.sendSystemMsgByMQ(form); + return result; + } } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/IcResiUserDao.xml b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/IcResiUserDao.xml index d89996a58a..d80dceb72d 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/IcResiUserDao.xml +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/IcResiUserDao.xml @@ -283,4 +283,47 @@ having volunteerCategory is null or volunteerCategory = '' + + + + + + + + diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/SystemMessageType.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/SystemMessageType.java index 9920eb019a..e0d8c80b35 100644 --- a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/SystemMessageType.java +++ b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/SystemMessageType.java @@ -175,6 +175,12 @@ public interface SystemMessageType { */ String PARTY_MEETING_MESSAGE = "party_meeting_message"; + + /** + * 查看或者导出 日志记录 + */ + String CHECK_OR_EXPORT = "check_or_export"; + String ZBWYH = "参加支部委员会"; String ZBDYDH = "参加支部党员大会"; String DXZH = "参加党小组会"; diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/SystemMessageServiceImpl.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/SystemMessageServiceImpl.java index 3eea1f03d8..ad742b155b 100644 --- a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/SystemMessageServiceImpl.java +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/SystemMessageServiceImpl.java @@ -248,6 +248,9 @@ public class SystemMessageServiceImpl implements SystemMessageService { case SystemMessageType.WMFWHD: topic=TopicConstants.PARTY_BUILDING; break; + case SystemMessageType.CHECK_OR_EXPORT: + topic = TopicConstants.CHECK_OR_EXPORT; + break; default: logger.error("getTopicByMsgType msgType:{} is not support for any topic", msgType); } diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/PointRuleServiceImpl.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/PointRuleServiceImpl.java index 251046a50f..f8210046bd 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/PointRuleServiceImpl.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/PointRuleServiceImpl.java @@ -26,11 +26,14 @@ import com.epmet.commons.rocketmq.messages.PointRuleChangedMQMsg; import com.epmet.commons.tools.constant.Constant; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; +import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.enums.CommonOperateTypeEnum; import com.epmet.commons.tools.enums.EventEnum; import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.user.LoginUserUtil; import com.epmet.commons.tools.utils.ConvertUtils; diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/constant/NeighborhoodConstant.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/constant/NeighborhoodConstant.java index 49a21f262e..261b951496 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/constant/NeighborhoodConstant.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/constant/NeighborhoodConstant.java @@ -6,10 +6,61 @@ package com.epmet.constant; */ public interface NeighborhoodConstant { + String MOBILE = "MOBILE"; + String ID_CARD = "ID_CARD"; + String NAME = "NAME"; + String GRID = "grid"; String NEIGHBOR_HOOD= "neighbourHood"; String BUILDING = "building"; String HOUSE = "house"; + String CHECK_HOUSE = "checkHouse"; + + /** + * ic居民 + */ + String IC_RESI_USER = "icResiUser"; + String CHECK_IC_RESI_USER = "checkIcResiUser"; + + /** + * 居民防疫信息 + */ + String JMFYXX = "JMFYXX"; + + /** + * 行程随访 + */ + String ROUTE_FOLLOW = "routeFollow"; + + /** + * 疫苗接种记录 + */ + String VACCINATION_RECORD = "vaccinationRecord"; + + /** + * 疫苗接种关注名单 + */ + String VACCINE_SPECIAL_ATTENTION = "vaccineSpecialAttention"; + + /** + * 未做核酸比对 + */ + String NO_NAT_COMPARE = "noNatCompare"; + + /** + * 核酸检测记录 + */ + String NAT_RECORD = "natRecord"; + + /** + * 重点人群关注名单【防疫隔离】 + */ + String FOCUS_GROUP_SPECIAL_ATTENTION_QUARANTINE = "focusGroupSpecialAttentionQuarantine"; + + /** + * 重点人群关注名单【历史记录】 + */ + String FOCUS_GROUP_SPECIAL_ATTENTION_HISTORY = "focusGroupSpecialAttentionHistory"; } diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/IcHouseDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/IcHouseDTO.java index e026d7cbdc..cdbf65c799 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/IcHouseDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/IcHouseDTO.java @@ -161,4 +161,13 @@ public class IcHouseDTO implements Serializable { * 房屋可编辑编码 */ private String coding; + + /** + * 加密后的联系方式 + */ + private String showOwnerPhone; + /** + * 加密后的房主身份证 + */ + private String showOwnerIdCard; } diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DetailByTypeFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DetailByTypeFormDTO.java new file mode 100644 index 0000000000..45fc98f517 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DetailByTypeFormDTO.java @@ -0,0 +1,25 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2022/10/17 13:42 + * @DESC + */ +@Data +public class DetailByTypeFormDTO implements Serializable { + + private static final long serialVersionUID = 8190270734257503603L; + + public interface DetailByTypeForm{} + + @NotBlank(message = "type不能为空",groups = DetailByTypeForm.class) + private String type; + + @NotBlank(message = "id不能为空",groups = DetailByTypeForm.class) + private String id; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DetailByTypeResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DetailByTypeResultDTO.java new file mode 100644 index 0000000000..3992215890 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DetailByTypeResultDTO.java @@ -0,0 +1,20 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2022/10/17 13:41 + * @DESC + */ +@Data +public class DetailByTypeResultDTO implements Serializable { + + private static final long serialVersionUID = -8067849365791132347L; + + private String idCard; + + private String mobile; +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java index 35b3bc0e6f..0e2f57f7d9 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java @@ -25,6 +25,8 @@ import com.alibaba.excel.write.metadata.style.WriteCellStyle; import com.alibaba.excel.write.style.HorizontalCellStyleStrategy; import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; import com.alibaba.fastjson.JSON; +import com.epmet.commons.rocketmq.constants.TopicConstants; +import com.epmet.commons.rocketmq.messages.CheckMQMsg; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.annotation.MaskResponse; import com.epmet.commons.tools.annotation.ReportRequest; @@ -40,10 +42,7 @@ import com.epmet.commons.tools.feign.ResultDataResolver; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.redis.common.bean.HouseInfoCache; import com.epmet.commons.tools.security.dto.TokenDto; -import com.epmet.commons.tools.utils.ConvertUtils; -import com.epmet.commons.tools.utils.ExcelUtils; -import com.epmet.commons.tools.utils.HouseQRcodeUtils; -import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.utils.*; import com.epmet.commons.tools.utils.poi.excel.handler.ExcelFillRowMergeStrategy; import com.epmet.commons.tools.utils.poi.excel.handler.FreezeAndFilter; import com.epmet.commons.tools.validator.ValidatorUtils; @@ -54,6 +53,7 @@ import com.epmet.dto.result.*; import com.epmet.entity.CustomerOrgParameterEntity; import com.epmet.feign.EpmetAdminOpenFeignClient; import com.epmet.feign.EpmetCommonServiceOpenFeignClient; +import com.epmet.feign.EpmetMessageOpenFeignClient; import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.service.HouseService; import com.epmet.util.ExcelPoiUtils; @@ -66,18 +66,18 @@ import org.apache.poi.ss.usermodel.VerticalAlignment; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.multipart.MultipartFile; import javax.imageio.ImageIO; import javax.imageio.stream.ImageOutputStream; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.awt.image.BufferedImage; import java.io.*; import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Set; +import java.util.*; import java.util.concurrent.TimeUnit; @@ -105,6 +105,8 @@ public class HouseController implements ResultDataResolver { @Autowired private IcHouseDao icHouseDao; + @Autowired + private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; @ReportRequest @PostMapping("houselist") @@ -265,7 +267,7 @@ public class HouseController implements ResultDataResolver { * @throws Exception */ @RequestMapping("exporthouseinfo") - public void exporthouseinfo(@RequestBody IcHouseListFormDTO formDTO, HttpServletResponse response) throws Exception { + public void exporthouseinfo(@RequestBody IcHouseListFormDTO formDTO, HttpServletResponse response,@LoginUser TokenDto tokenDto) throws Exception { ValidatorUtils.validateEntity(formDTO); if (StringUtils.isNotBlank(formDTO.getId())){ formDTO.setSelectType("id"); @@ -274,7 +276,21 @@ public class HouseController implements ResultDataResolver { } formDTO.setIsPage(false); houseService.exportBuildinginfo(formDTO, response); - + // 新增操作日志 + CheckMQMsg msg = new CheckMQMsg(); + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + msg.setOperateTime(new Date()); + msg.setContent("导出房屋数据"); + msg.setType("exportHouse"); + msg.setTypeDisplay("导出房屋数据"); + msg.setUserId(tokenDto.getUserId()); + msg.setFromApp(tokenDto.getApp()); + msg.setIp(IpUtils.getIpAddr(request)); + msg.setFromClient(tokenDto.getClient()); + SystemMsgFormDTO form = new SystemMsgFormDTO(); + form.setMessageType(TopicConstants.CHECK_OR_EXPORT); + form.setContent(msg); + epmetMessageOpenFeignClient.sendSystemMsgByMQ(form); } @PostMapping("queryListHouseInfo") @@ -452,6 +468,22 @@ public class HouseController implements ResultDataResolver { //获取导出配置 haveSearchCache.invalidateAll(); + + // 发送操作日志 + CheckMQMsg msg = new CheckMQMsg(); + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + msg.setOperateTime(new Date()); + msg.setContent("导出一户一档数据"); + msg.setType("exportYHYD"); + msg.setTypeDisplay("导出一户一档数据"); + msg.setUserId(tokenDto.getUserId()); + msg.setFromApp(tokenDto.getApp()); + msg.setIp(IpUtils.getIpAddr(request)); + msg.setFromClient(tokenDto.getClient()); + SystemMsgFormDTO form = new SystemMsgFormDTO(); + form.setMessageType(TopicConstants.CHECK_OR_EXPORT); + form.setContent(msg); + epmetMessageOpenFeignClient.sendSystemMsgByMQ(form); } catch (EpmetException e) { response.reset(); response.setCharacterEncoding("UTF-8"); diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcHouseController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcHouseController.java index 6d828df25a..e7b5ac7e56 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcHouseController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcHouseController.java @@ -18,20 +18,17 @@ package com.epmet.controller; import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.annotation.MaskResponse; import com.epmet.commons.tools.dto.form.PageFormDTO; import com.epmet.commons.tools.dto.result.OptionResultDTO; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.IcHouseDTO; -import com.epmet.dto.IcVaccinePrarmeterDTO; import com.epmet.dto.form.CheckHouseInfoFormDTO; +import com.epmet.dto.form.DetailByTypeFormDTO; import com.epmet.dto.form.HouseFormDTO; -import com.epmet.dto.form.VaccinePrarmeterListFormDTO; -import com.epmet.dto.result.HouseAgencyInfoResultDTO; -import com.epmet.dto.result.HouseInfoDTO; -import com.epmet.dto.result.HouseListResultDTO; -import com.epmet.dto.result.HousesNameResultDTO; +import com.epmet.dto.result.*; import com.epmet.service.IcHouseService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -53,6 +50,7 @@ public class IcHouseController { @Autowired private IcHouseService icHouseService; + @MaskResponse(fieldNames = { "showOwnerPhone", "showOwnerIdCard" }, fieldsMaskType = { MaskResponse.MASK_TYPE_MOBILE, MaskResponse.MASK_TYPE_ID_CARD }) @GetMapping("{id}") public Result get(@PathVariable("id") String id) { IcHouseDTO data = icHouseService.get(id); @@ -154,6 +152,6 @@ public class IcHouseController { ValidatorUtils.validateEntity(formDTO, PageFormDTO.AddUserInternalGroup.class); formDTO.setCustomerId(tokenDto.getCustomerId()); return icHouseService.checkHomeInfo(formDTO); - } + } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcHouseService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcHouseService.java index 77a5bdd4ad..0855d78104 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcHouseService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcHouseService.java @@ -7,11 +7,9 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.dto.IcHouseDTO; import com.epmet.dto.ImportGeneralDTO; import com.epmet.dto.form.CheckHouseInfoFormDTO; +import com.epmet.dto.form.DetailByTypeFormDTO; import com.epmet.dto.form.HouseFormDTO; -import com.epmet.dto.result.HouseAgencyInfoResultDTO; -import com.epmet.dto.result.HouseInfoDTO; -import com.epmet.dto.result.HouseListResultDTO; -import com.epmet.dto.result.HousesNameResultDTO; +import com.epmet.dto.result.*; import com.epmet.entity.IcHouseEntity; import java.util.List; @@ -139,4 +137,6 @@ public interface IcHouseService extends BaseService { * @return */ Result checkHomeInfo(CheckHouseInfoFormDTO formDTO); + + } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcHouseServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcHouseServiceImpl.java index 0f69fc8816..943d6f9eee 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcHouseServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcHouseServiceImpl.java @@ -3,6 +3,8 @@ package com.epmet.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.rocketmq.constants.TopicConstants; +import com.epmet.commons.rocketmq.messages.CheckMQMsg; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.dto.result.OptionResultDTO; @@ -10,10 +12,14 @@ import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.redis.common.CustomerIcHouseRedis; +import com.epmet.commons.tools.redis.common.CustomerResiUserRedis; import com.epmet.commons.tools.redis.common.bean.HouseInfoCache; +import com.epmet.commons.tools.redis.common.bean.IcResiUserInfoCache; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.IpUtils; import com.epmet.commons.tools.utils.Result; +import com.epmet.constant.NeighborhoodConstant; import com.epmet.dao.IcBuildingDao; import com.epmet.dao.IcBuildingUnitDao; import com.epmet.dao.IcHouseDao; @@ -23,7 +29,9 @@ import com.epmet.dto.IcResiCategoryStatsConfigDTO; import com.epmet.dto.IcResiUserDTO; import com.epmet.dto.ImportGeneralDTO; import com.epmet.dto.form.CheckHouseInfoFormDTO; +import com.epmet.dto.form.DetailByTypeFormDTO; import com.epmet.dto.form.HouseFormDTO; +import com.epmet.dto.form.SystemMsgFormDTO; import com.epmet.dto.result.*; import com.epmet.entity.IcBuildingEntity; import com.epmet.entity.IcBuildingUnitEntity; @@ -32,6 +40,7 @@ import com.epmet.entity.IcNeighborHoodEntity; import com.epmet.enums.HousePurposeEnums; import com.epmet.enums.HouseRentFlagEnums; import com.epmet.enums.HouseTypeEnums; +import com.epmet.feign.EpmetMessageOpenFeignClient; import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.feign.OperCustomizeOpenFeignClient; import com.epmet.redis.IcHouseRedis; @@ -39,10 +48,14 @@ import com.epmet.service.IcHouseService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; import java.util.*; import java.util.concurrent.atomic.AtomicInteger; @@ -69,7 +82,8 @@ public class IcHouseServiceImpl extends BaseServiceImpl().ok(icEpidemicSpecialAttentionService.pie(tokenDto)); } + /** + * 批量删除 ic_epidemic_special_attention + * @param ids + * @return + */ + @PostMapping("delete") + public Result delete(@RequestBody List ids){ + if(CollectionUtils.isNotEmpty(ids)){ + icEpidemicSpecialAttentionService.delete(ids); + } + return new Result(); + } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java index c70bf78c83..701968bcf0 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java @@ -22,6 +22,8 @@ import com.alibaba.excel.ExcelWriter; import com.alibaba.excel.write.metadata.WriteSheet; import com.alibaba.excel.write.metadata.fill.FillWrapper; import com.alibaba.fastjson.JSON; +import com.epmet.commons.rocketmq.constants.TopicConstants; +import com.epmet.commons.rocketmq.messages.CheckMQMsg; import com.epmet.commons.rocketmq.messages.IcResiUserAddMQMsg; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.annotation.MaskResponse; @@ -46,6 +48,7 @@ import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; +import com.epmet.commons.tools.redis.common.bean.IcResiUserInfoCache; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.user.LoginUserUtil; import com.epmet.commons.tools.utils.*; @@ -84,6 +87,8 @@ import org.jetbrains.annotations.NotNull; import org.redisson.api.RLock; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.multipart.MultipartFile; import javax.servlet.ServletOutputStream; @@ -557,6 +562,20 @@ public class IcResiUserController implements ResultDataResolver { } else { icResiUserExportService.exportIcResiUser(tokenDto, pageFormDTO, response,false); } + CheckMQMsg msg = new CheckMQMsg(); + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + msg.setOperateTime(new Date()); + msg.setContent("导出居民数据"); + msg.setType("exportIcResiUser"); + msg.setTypeDisplay("导出居民数据"); + msg.setUserId(tokenDto.getUserId()); + msg.setFromApp(tokenDto.getApp()); + msg.setIp(IpUtils.getIpAddr(request)); + msg.setFromClient(tokenDto.getClient()); + SystemMsgFormDTO form = new SystemMsgFormDTO(); + form.setMessageType(TopicConstants.CHECK_OR_EXPORT); + form.setContent(msg); + epmetMessageOpenFeignClient.sendSystemMsgByMQ(form); } catch (EpmetException e) { response.reset(); response.setCharacterEncoding("UTF-8"); @@ -1436,4 +1455,9 @@ public class IcResiUserController implements ResultDataResolver { return new Result(); } + @PostMapping("getIcResiUserInfo/{userId}") + public Result getIcResiUserInfo(@PathVariable("userId") String userId){ + return new Result().ok(icResiUserService.getIcResiUserInfo(userId)); + } + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcNatDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcNatDao.java index b2419b09f5..f21ec91eb3 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcNatDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcNatDao.java @@ -64,4 +64,6 @@ public interface IcNatDao extends BaseDao { List getExistNatInfo(@Param("list") List entities); + void updateBatchNat(@Param("list")List entities); + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/data/IcNatImportExcelData.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/data/IcNatImportExcelData.java index ae0cb210d7..b54c571f8f 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/data/IcNatImportExcelData.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/data/IcNatImportExcelData.java @@ -24,9 +24,9 @@ public class IcNatImportExcelData { @Length(max = 15, message = "手机号长度不正确,应小于15位") private String mobile; - @NotBlank(message = "身份证号为必填项") - @ExcelProperty("身份证号") - @Length(max = 18, message = "身份证号长度不正确,应小于18位") + @NotBlank(message = "证件号为必填项") + @ExcelProperty("证件号") + @Length(max = 18, message = "证件号长度不正确,应小于18位") private String idCard; // @NotNull(message = "检测时间为必填项") diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/IcNatExcelImportListener.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/IcNatExcelImportListener.java index 59f5eaab7b..c600349029 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/IcNatExcelImportListener.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/IcNatExcelImportListener.java @@ -68,7 +68,7 @@ public class IcNatExcelImportListener implements ReadListener ids); /** * Desc: 【疫苗接种关注名单,疫苗接种关注名单】列表 diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcNatService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcNatService.java index ea75c911e4..430a66424a 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcNatService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcNatService.java @@ -92,4 +92,6 @@ public interface IcNatService extends BaseService { * @return */ Integer updateIsResiFlag(String customerId, String icResiUserId); + + void updateBatchNat(List entities); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java index 87dcd4cba3..e3e0f75e1f 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java @@ -20,6 +20,7 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.dto.result.OptionDataResultDTO; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.redis.common.bean.IcResiUserInfoCache; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.IcResiUserDTO; @@ -518,4 +519,6 @@ public interface IcResiUserService extends BaseService { * @Date 2022/9/8 15:45 */ void updateYlfn(); + + IcResiUserInfoCache getIcResiUserInfo(String userId); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/DataSyncConfigServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/DataSyncConfigServiceImpl.java index 2517791025..bb72f987a6 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/DataSyncConfigServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/DataSyncConfigServiceImpl.java @@ -14,7 +14,6 @@ import com.epmet.commons.tools.enums.GenderEnum; import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.redis.common.CustomerOrgRedis; -import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; import com.epmet.commons.tools.redis.common.bean.GridInfoCache; import com.epmet.commons.tools.security.dto.TokenDto; @@ -44,6 +43,8 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.*; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; import java.util.stream.Collectors; /** @@ -68,6 +69,8 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl newConfigList = new ArrayList<>(); allConfigList.forEach(c -> { if (c.getDataCode().equals(formDTO.getDataCode())){ - disAllData(c,formDTO); - return; + //串行执行 + //disAllData(c,formDTO); + + //并行执行 + newConfigList.add(c); } }); + //死亡 残疾等接口 并行执行 + dataSyncYanTaiParallel(newConfigList,formDTO); }else { - for (DataSyncConfigDTO config : allConfigList) { - //没有配置 数据拉取范围 继续下次循环 - if (CollectionUtils.isEmpty(config.getScopeList())) { + //死亡 残疾等接口 并行执行 + dataSyncYanTaiParallel(allConfigList,formDTO); + //串行执行 +// for (DataSyncConfigDTO config : allConfigList) { +// //没有配置 数据拉取范围 继续下次循环 +// if (CollectionUtils.isEmpty(config.getScopeList())) { +// continue; +// } +// disAllData(config,formDTO); +// } + } + } + + private void dataSyncYanTaiParallel(List configList, DataSyncTaskParam formDTO) { + if (CollectionUtils.isEmpty(configList)) { + log.warn("dataSyncYanTaiParallel configList is null"); + return; + } + long count = configList.stream().filter(o -> CollectionUtils.isNotEmpty(o.getScopeList())).count(); + if (count < 1) { + log.warn("dataSyncYanTaiParallel scopeList is null"); + return; + } + //没传具体参数 则 按照 + int pageNo = NumConstant.ONE; + int pageSize = NumConstant.ONE_THOUSAND; + + List dbResiList = null; + CountDownLatch countDownLatch = new CountDownLatch((int) count); + + do { + for (DataSyncConfigDTO config : configList) {//设置查询数据范围 + formDTO.setOrgList(config.getScopeList()); + DataSyncEnum anEnum = DataSyncEnum.getEnum(config.getDataCode()); + + //查询正常状态的居民 并回显 残疾状态 + formDTO.setCategoryColumn("IS_CJ"); + dbResiList = getNatUserInfoFromDb(formDTO, pageNo, pageSize); + if (CollectionUtils.isEmpty(dbResiList)) { continue; } - disAllData(config,formDTO); + List finalDbResiList = dbResiList; + switch (anEnum) { + case HE_SUAN: + executorService.submit(() -> { + try { + //查询正常状态的居民 + hsjc(finalDbResiList, config.getCustomerId(), formDTO.getIsSync()); + log.info("======核酸检测信息拉取结束======"); + } catch (Exception e) { + log.error("hsjc thread execute exception", e); + } finally { + countDownLatch.countDown(); + } + }); + + break; + case CAN_JI: + executorService.submit(() -> { + try { + //查询正常状态的居民 + canJi(finalDbResiList); + log.info("======canJi信息拉取结束======"); + } catch (Exception e) { + log.error("hsjc thread execute exception", e); + } finally { + countDownLatch.countDown(); + } + }); + + break; + case SI_WANG: + try { + //查询正常状态的居民 + siWang(finalDbResiList); + log.info("======siWang信息拉取结束======"); + } catch (Exception e) { + log.error("hsjc thread execute exception", e); + } finally { + countDownLatch.countDown(); + } + break; + default: + log.warn("没有要处理的数据"); + } + try { + //等这一批居民 各个方法都执行完后 再继续下一批 + countDownLatch.await(); + } catch (InterruptedException e) { + log.error("dataSyncYanTaiParallel现成被中断"); + } } - } + + pageNo++; + } while (dbResiList != null && dbResiList.size() == pageSize); + } private void disAllData(DataSyncConfigDTO config,DataSyncTaskParam formDTO){ //没传具体参数 则 按照 int pageNo = NumConstant.ONE; - int pageSize = 1;//todo fangkaita NumConstant.ONE_THOUSAND; - //ToDo 去掉 - formDTO.setIdCards(Collections.singletonList("370283199912010302")); + int pageSize = NumConstant.ONE_THOUSAND; + List dbResiList = null; //设置查询数据范围 formDTO.setOrgList(config.getScopeList()); @@ -241,7 +336,7 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl dbResiList) { @@ -255,6 +350,9 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl queryWrapper = new LambdaQueryWrapper<>(); @@ -312,7 +410,6 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl pageInfo = PageHelper.startPage(pageNo, pageSize, false) .doSelectPageInfo(() -> baseDao.getIdCardsByScope(formDTO)); - List dbResiList; - dbResiList = pageInfo.getList(); - /* //如果传了身份证号 则按照身份证号查询 并同步记录, userId如果为空则是 手动录入的 此人没有录入居民库 但是也可以同步 - if (CollectionUtils.isNotEmpty(formDTO.getIdCards()) && DataSyncEnum.HE_SUAN.getCode().equals(anEnum.getCode())) { - List collect = formDTO.getIdCards().stream().map(id -> { - NatUserInfoResultDTO e = new NatUserInfoResultDTO(); - e.setIdCard(id); - e.setUserId(""); - return e; - }).collect(Collectors.toList()); - - for (NatUserInfoResultDTO c : collect) { - dbResiList.stream().filter(u -> u.getIdCard().equals(c.getIdCard())).forEach(u -> c.setUserId(u.getUserId())); - } - dbResiList = collect; - }*/ - return dbResiList; + return pageInfo.getList(); } private void canJi(List resiList) { @@ -454,100 +535,64 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl idCards, String customerId, String isSync) { try { - List entities = new ArrayList<>(); idCards.forEach(idCard -> { -// YtHscyResDTO sampleResult = YtHsResUtils.hscy(idCard.getIdCard(), NumConstant.ONE, NumConstant.ONE); - YtHsjcResDTO natInfoResult = YtHsResUtils.hsjc(idCard.getIdCard(), NumConstant.ONE, NumConstant.ONE); - /*Boolean aBoolean = CollectionUtils.isEmpty(sampleResult.getData()) && CollectionUtils.isNotEmpty(natInfoResult.getData()); - Boolean bBoolean = CollectionUtils.isNotEmpty(sampleResult.getData()) && CollectionUtils.isNotEmpty(natInfoResult.getData());*/ - /** - * 1.采样结果 和 检测结果 都不为空,以检测结果为准 - * 2.采样结果为空,检测结果不为空 - */ -// if (aBoolean || bBoolean) { - if (CollectionUtils.isNotEmpty(natInfoResult.getData())) { - natInfoResult.getData().forEach(natInfo -> { + YtHscyResDTO sampleResult = YtHsResUtils.hscy(idCard.getIdCard(), NumConstant.ONE, NumConstant.ONE); + if (CollectionUtils.isNotEmpty(sampleResult.getData())){ + List entities = new ArrayList<>(); + sampleResult.getData().forEach(sampleInfo -> { IcNatEntity e = new IcNatEntity(); e.setCustomerId(customerId); e.setIsResiUser(StringUtils.isBlank(idCard.getUserId()) ? NumConstant.ZERO_STR : NumConstant.ONE_STR); e.setUserId(idCard.getUserId()); + e.setMobile(""); e.setUserType(isSync.equals(NumConstant.ONE_STR) ? "manualSync" : "sync"); - e.setName(StringUtils.isNotBlank(natInfo.getName()) ? natInfo.getName() : ""); - e.setMobile(StringUtils.isNotBlank(natInfo.getTelephone()) ? natInfo.getTelephone() : ""); - e.setIdCard(StringUtils.isNotBlank(natInfo.getCard_no()) ? natInfo.getCard_no() : ""); - e.setNatTime(DateUtils.parseDate(natInfo.getTest_time(), DateUtils.DATE_TIME_PATTERN)); - e.setSampleTime(DateUtils.parseDate(natInfo.getSample_time(), DateUtils.DATE_TIME_PATTERN)); - String resultPcr = natInfo.getSample_result_pcr(); - //检测结果 转换 我们 0:阴性 1:阳性, 他们 :1:阳性,2:阴性 - e.setNatResult(NumConstant.ZERO_STR); - if (NumConstant.ONE_STR.equals(resultPcr)) { - e.setNatResult(NumConstant.ONE_STR); - } - e.setNatAddress(natInfo.getSampling_org_pcr()); + e.setName(StringUtils.isNotBlank(sampleInfo.getName()) ? sampleInfo.getName() : ""); + e.setIdCard(StringUtils.isNotBlank(sampleInfo.getCard_no()) ? sampleInfo.getCard_no() : ""); + e.setSampleTime(DateUtils.parseDate(sampleInfo.getCreate_time(), DateUtils.DATE_TIME_PATTERN)); e.setAgencyId(idCard.getAgencyId()); e.setPids(idCard.getPids()); e.setAttachmentType(""); e.setAttachmentUrl(""); entities.add(e); }); + if (CollectionUtils.isNotEmpty(entities)){ + List existSampleInfo = icNatDao.getExistNatInfo(entities); + sampleAndNat(existSampleInfo,entities,NumConstant.ONE_STR,customerId,isSync); + } } - /*if (CollectionUtils.isNotEmpty(sampleResult.getData()) && CollectionUtils.isEmpty(natInfoResult.getData())){ - sampleResult.getData().forEach(sampleInfo -> { + YtHsjcResDTO natInfoResult = YtHsResUtils.hsjc(idCard.getIdCard(), NumConstant.ONE, NumConstant.ONE); + if (CollectionUtils.isNotEmpty(natInfoResult.getData())) { + List entities = new ArrayList<>(); + natInfoResult.getData().forEach(natInfo -> { IcNatEntity e = new IcNatEntity(); e.setCustomerId(customerId); e.setIsResiUser(StringUtils.isBlank(idCard.getUserId()) ? NumConstant.ZERO_STR : NumConstant.ONE_STR); e.setUserId(idCard.getUserId()); e.setUserType(isSync.equals(NumConstant.ONE_STR) ? "manualSync" : "sync"); - e.setName(StringUtils.isNotBlank(sampleInfo.getName()) ? sampleInfo.getName() : ""); - e.setMobile(StringUtils.isNotBlank(sampleInfo.get()) ? sampleInfo.getTelephone() : ""); - e.setIdCard(StringUtils.isNotBlank(sampleInfo.getCard_no()) ? sampleInfo.getCard_no() : ""); - e.setNatTime(DateUtils.parseDate(sampleInfo.getTest_time(), DateUtils.DATE_TIME_PATTERN)); - e.setSampleTime(DateUtils.parseDate(sampleInfo.getSample_time(), DateUtils.DATE_TIME_PATTERN)); - String resultPcr = sampleInfo.getSample_result_pcr(); + e.setName(StringUtils.isNotBlank(natInfo.getName()) ? natInfo.getName() : ""); + e.setMobile(StringUtils.isNotBlank(natInfo.getTelephone()) ? natInfo.getTelephone() : ""); + e.setIdCard(StringUtils.isNotBlank(natInfo.getCard_no()) ? natInfo.getCard_no() : ""); + e.setNatTime(DateUtils.parseDate(natInfo.getTest_time(), DateUtils.DATE_TIME_PATTERN)); + e.setSampleTime(DateUtils.parseDate(natInfo.getSample_time(), DateUtils.DATE_TIME_PATTERN)); + String resultPcr = natInfo.getSample_result_pcr(); //检测结果 转换 我们 0:阴性 1:阳性, 他们 :1:阳性,2:阴性 e.setNatResult(NumConstant.ZERO_STR); - if (NumConstant.ONE_STR.equals(resultPcr)){ + if (NumConstant.ONE_STR.equals(resultPcr)) { e.setNatResult(NumConstant.ONE_STR); } - e.setNatAddress(sampleInfo.getSampling_org_pcr()); + e.setNatAddress(natInfo.getSampling_org_pcr()); e.setAgencyId(idCard.getAgencyId()); e.setPids(idCard.getPids()); e.setAttachmentType(""); e.setAttachmentUrl(""); entities.add(e); }); - } - });*/ - if (CollectionUtils.isNotEmpty(entities)) { - List existNatInfos = icNatDao.getExistNatInfo(entities); - entities.forEach(e -> existNatInfos.stream().filter(i -> i.getUserId().equals(e.getUserId()) && i.getIdCard().equals(e.getIdCard())).forEach(i -> e.setExistStatus(true))); - Map> groupByStatus = entities.stream().collect(Collectors.groupingBy(IcNatEntity::getExistStatus)); - if (CollectionUtils.isNotEmpty(groupByStatus.get(false))) { - for (List icNatEntities : ListUtils.partition(groupByStatus.get(false), NumConstant.FIVE_HUNDRED)) { - icNatService.insertBatch(icNatEntities); - //组织关系表 - List relationEntities = new ArrayList<>(); - icNatEntities.forEach(ne -> { - // 不是居民的先不加关系表吧 - if (ne.getIsResiUser().equals(NumConstant.ONE_STR)) { - IcNatRelationEntity e = new IcNatRelationEntity(); - e.setCustomerId(customerId); - e.setAgencyId(ne.getAgencyId()); - e.setPids(ne.getPids()); - e.setIcNatId(ne.getId()); - e.setUserType("sync"); - relationEntities.add(e); - } - }); - if (CollectionUtils.isNotEmpty(relationEntities)) { - icNatRelationService.insertBatch(relationEntities); - } - } + if (CollectionUtils.isNotEmpty(entities)) { + List existNatInfos = icNatDao.getExistNatInfo(entities); + sampleAndNat(existNatInfos,entities,NumConstant.TWO_STR,customerId,isSync); } - } }); } catch (Exception e) { @@ -556,6 +601,61 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl existInfo, List entities, String type, String customerId, String isSync){ + /** + * 采样结果不为空 + * 数据库采样时间+idCard+userId 存在的 不做操作 + * 数据库采样时间+idCard+userId 不存在的 新增 + * + * 检测结果不为空 + * 数据库采样时间+idCard+userId 存在的 做更新 + * 数据库采样时间+idCard+userId 不存在的 新增 + */ + entities.forEach(e -> existInfo.stream().filter(i -> i.getUserId().equals(e.getUserId()) && i.getIdCard().equals(e.getIdCard())).forEach(i -> { + e.setExistStatus(true); + e.setId(i.getId()); + })); + Map> groupByStatus = entities.stream().collect(Collectors.groupingBy(IcNatEntity::getExistStatus)); + if (CollectionUtils.isNotEmpty(groupByStatus.get(false))) { + for (List icNatEntities : ListUtils.partition(groupByStatus.get(false), NumConstant.FIVE_HUNDRED)) { + // 主表新增 + icNatService.insertBatch(icNatEntities); + // 组织关系表 + List relationEntities = new ArrayList<>(); + icNatEntities.forEach(ne -> { + if (ne.getIsResiUser().equals(NumConstant.ONE_STR)) { + IcNatRelationEntity e = new IcNatRelationEntity(); + e.setCustomerId(customerId); + e.setAgencyId(ne.getAgencyId()); + e.setPids(ne.getPids()); + e.setIcNatId(ne.getId()); + e.setUserType(isSync.equals(NumConstant.ONE_STR) ? "manualSync" : "sync"); + relationEntities.add(e); + } + }); + if (CollectionUtils.isNotEmpty(relationEntities)) { + icNatRelationService.insertBatch(relationEntities); + } + } + } + if (NumConstant.TWO_STR.equals(type)){ + if (CollectionUtils.isNotEmpty(groupByStatus.get(true))){ + for (List icNatEntities : ListUtils.partition(groupByStatus.get(true), NumConstant.ONE_HUNDRED)) { + icNatService.updateBatchNat(icNatEntities); + } + } + } + } + private class JudgeDealStatus { private boolean isNext; private DataSyncRecordDisabilityDTO dbDisablityEntity; diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/DataSyncRecordDisabilityServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/DataSyncRecordDisabilityServiceImpl.java index 3b564f19e7..4ee1cdb64e 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/DataSyncRecordDisabilityServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/DataSyncRecordDisabilityServiceImpl.java @@ -11,6 +11,7 @@ import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; +import com.epmet.commons.tools.enums.GenderEnum; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.page.PageData; @@ -97,7 +98,10 @@ public class DataSyncRecordDisabilityServiceImpl extends BaseServiceImpl all = Arrays.asList(ids); + // 根据IDs查询烟台拉取的残疾信息 List entities = baseDao.selectBatchIds(all); IcFormOptionsQueryFormDTO formDTO = new IcFormOptionsQueryFormDTO(); formDTO.setCustomerId(customerId); @@ -266,7 +274,8 @@ public class DataSyncRecordDisabilityServiceImpl extends BaseServiceImpl StringUtils.isBlank(e.getCjzk()) || StringUtils.isBlank(e.getCjlb())).forEach(e -> e.setUpdateStatus(true)); + // cjzk,cjlb为空的,处理结果赋值 处理失败 +// entities.stream().filter(e -> StringUtils.isBlank(e.getCjzk()) || StringUtils.isBlank(e.getCjlb())).forEach(e -> e.setUpdateStatus(true)); // 变更记录 List collect = entities.stream().map(m -> { CategoryStatusAndIdDTO dto = new CategoryStatusAndIdDTO(); diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcEpidemicSpecialAttentionServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcEpidemicSpecialAttentionServiceImpl.java index 65070ee096..ab52942896 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcEpidemicSpecialAttentionServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcEpidemicSpecialAttentionServiceImpl.java @@ -131,9 +131,9 @@ public class IcEpidemicSpecialAttentionServiceImpl extends BaseServiceImpl ids) { // 逻辑删除(@TableLogic 注解) - baseDao.deleteBatchIds(Arrays.asList(ids)); + baseDao.deleteBatchIds(ids); } /** diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNatServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNatServiceImpl.java index 3a9282b9bb..fcc03adf39 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNatServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNatServiceImpl.java @@ -464,6 +464,14 @@ public class IcNatServiceImpl extends BaseServiceImpl imp return baseDao.updateIsResiFlag(customerId,icResiUserId); } + @Override + @Transactional(rollbackFor = Exception.class) + public void updateBatchNat(List entities) { + if (CollectionUtils.isNotEmpty(entities)){ + baseDao.updateBatchNat(entities); + } + } + /** * 批量持久化 * @param entities diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserExportServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserExportServiceImpl.java index b0b9a12f77..ec754bb2b8 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserExportServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserExportServiceImpl.java @@ -7,6 +7,8 @@ import com.alibaba.excel.write.metadata.style.WriteCellStyle; import com.alibaba.excel.write.style.HorizontalCellStyleStrategy; import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; import com.alibaba.fastjson.JSON; +import com.epmet.commons.rocketmq.constants.TopicConstants; +import com.epmet.commons.rocketmq.messages.CheckMQMsg; import com.epmet.commons.tools.constant.Constant; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.NumConstant; @@ -20,22 +22,17 @@ import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.security.dto.TokenDto; -import com.epmet.commons.tools.utils.ExcelUtils; -import com.epmet.commons.tools.utils.Md5Util; -import com.epmet.commons.tools.utils.Result; -import com.epmet.commons.tools.utils.SpringContextUtils; +import com.epmet.commons.tools.utils.*; import com.epmet.commons.tools.utils.poi.excel.handler.ExcelFillCellMergeStrategy; import com.epmet.commons.tools.utils.poi.excel.handler.FreezeAndFilter; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.constant.IcResiUserConstant; -import com.epmet.dto.form.ExportResiUserFormDTO; -import com.epmet.dto.form.IcExportTemplateQueryFormDTO; -import com.epmet.dto.form.IcResiUserPageFormDTO; -import com.epmet.dto.form.ResiUserQueryValueDTO; +import com.epmet.dto.form.*; import com.epmet.dto.result.FormItemResult; import com.epmet.dto.result.IcCustomExportResultDTO; import com.epmet.dto.result.OptionDTO; import com.epmet.excel.support.ExportResiUserItemDTO; +import com.epmet.feign.EpmetMessageOpenFeignClient; import com.epmet.feign.OperCustomizeOpenFeignClient; import com.epmet.service.IcResiUserExportService; import com.epmet.service.IcResiUserImportService; @@ -53,7 +50,10 @@ import org.apache.poi.ss.usermodel.VerticalAlignment; import org.jetbrains.annotations.Nullable; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.*; @@ -76,6 +76,8 @@ public class IcResiUserExportServiceImpl implements IcResiUserExportService { private IcResiUserService icResiUserService; @Autowired private IcResiUserImportService icResiUserImportService; + @Autowired + private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; /** * key:itemId,value: key:columnName,中文 diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java index ec9bf3043c..bae8e89c0b 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java @@ -44,10 +44,7 @@ import com.epmet.commons.tools.redis.common.CustomerIcHouseRedis; import com.epmet.commons.tools.redis.common.CustomerOrgRedis; import com.epmet.commons.tools.redis.common.CustomerResiUserRedis; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; -import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; -import com.epmet.commons.tools.redis.common.bean.GridInfoCache; -import com.epmet.commons.tools.redis.common.bean.HouseInfoCache; -import com.epmet.commons.tools.redis.common.bean.ResiUserInfoCache; +import com.epmet.commons.tools.redis.common.bean.*; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.*; import com.epmet.constant.IcPlatformConstant; @@ -697,6 +694,7 @@ public class IcResiUserServiceImpl extends BaseServiceImpl - when id = #{item.id} then '处理成功' + when id = #{item.id} then '' @@ -132,6 +132,12 @@ when d.deal_status = 2 then '处理失败' else '处理失败' end) as dealStatusName, d.now_add as address, + ( + case when d.GENDER='1' then '男' + when d.GENDER='2' then '女' + else '未知' + end + )as genderCn, d.* FROM data_sync_record_disability d WHERE DEL_FLAG = 0 diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcNatCompareRecordDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcNatCompareRecordDao.xml index 2a33a5680b..0e3fcaa606 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/IcNatCompareRecordDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcNatCompareRecordDao.xml @@ -7,6 +7,7 @@ SELECT + ID, USER_ID, ID_CARD FROM ic_nat WHERE del_flag = '0' AND USER_ID = #{l.userId} AND ID_CARD = #{l.idCard} - AND UNIX_TIMESTAMP(NAT_TIME) = UNIX_TIMESTAMP(#{l.natTime}) + AND UNIX_TIMESTAMP(SAMPLE_TIME) = UNIX_TIMESTAMP(#{l.sampleTime}) @@ -189,4 +190,36 @@ m.ID_CARD = t.ID_CARD AND m.DEL_FLAG = '0' + + UPDATE ic_nat + + + + when ID = #{l.id} then #{l.natTime} + + + + + when ID = #{l.id} then #{l.natAddress} + + + + + when ID = #{l.id} then #{l.natResult} + + + + + when ID = #{l.id} then #{l.mobile} + + + UPDATED_TIME = NOW() + + WHERE DEL_FLAG = '0' + AND ID IN( + + #{l.id} + ) + + diff --git a/epmet-user/epmet-user-server/src/test/java/com/epmet/dao/IcNatDaoTest.java b/epmet-user/epmet-user-server/src/test/java/com/epmet/dao/IcNatDaoTest.java new file mode 100644 index 0000000000..d650f19cb3 --- /dev/null +++ b/epmet-user/epmet-user-server/src/test/java/com/epmet/dao/IcNatDaoTest.java @@ -0,0 +1,30 @@ +package com.epmet.dao; + +import com.epmet.entity.IcNatEntity; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import java.util.ArrayList; +import java.util.List; +@SpringBootTest +@RunWith(SpringRunner.class) +public class IcNatDaoTest { + @Autowired + private IcNatDao icNatDao; + + @Test + public void updateBatchNat() { + List entities = new ArrayList<>(); + for (int i = 0; i < 2; i++) { + IcNatEntity en = new IcNatEntity(); + en.setNatResult("222222"+i); + en.setUserId(""+i); + en.setIdCard("card"+i); + entities.add(en); + } + icNatDao.updateBatchNat(entities); + } +}