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 927fa19198..d28b19396d 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 @@ -30,12 +30,17 @@ public interface TopicConstants { String POINT = "point"; /** - * 组织信息变更 + * 组织信息 */ String ORG = "org"; /** - * 工作人员信息变更 + * 工作人员 */ String STAFF = "staff"; + + /** + * 巡查 + */ + String PATROL = "patrol"; } diff --git a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/StaffPatrolMQMsg.java b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/StaffPatrolMQMsg.java new file mode 100644 index 0000000000..f8221d7c76 --- /dev/null +++ b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/StaffPatrolMQMsg.java @@ -0,0 +1,28 @@ +package com.epmet.commons.rocketmq.messages; + +import lombok.Data; + +/** + * 用户巡查消息体 + * @author liujianjun + */ +@Data +public class StaffPatrolMQMsg { + /** + * 客户Id + */ + private String customerId; + + /** + * 巡查记录id + */ + private String patrolId; + + /** + * 操作类型 + * SystemMessageType.USER_PATROL_START + * SystemMessageTypSTOP + */ + private String actionType; + +} 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 e1c59f003e..9e502bd6ca 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 @@ -65,4 +65,14 @@ public interface SystemMessageType { */ String STAFF_CHANGE = "staff_change"; + /** + * 用户开始巡查 + */ + String USER_PATROL_START = "user_patrol_start"; + + /** + * 用户结束巡查 + */ + String USER_PATROL_STOP = "user_patrol_stop"; + } diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/send/SendMqMsgUtil.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/send/SendMqMsgUtil.java index 4c7241decd..32674d49f6 100644 --- a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/send/SendMqMsgUtil.java +++ b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/send/SendMqMsgUtil.java @@ -1,9 +1,10 @@ package com.epmet.send; import com.alibaba.fastjson.JSON; +import com.epmet.commons.rocketmq.messages.GroupAchievementMQMsg; import com.epmet.commons.rocketmq.messages.PointRuleChangedMQMsg; import com.epmet.commons.rocketmq.messages.ProjectChangedMQMsg; -import com.epmet.commons.rocketmq.messages.GroupAchievementMQMsg; +import com.epmet.commons.rocketmq.messages.StaffPatrolMQMsg; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.utils.Result; import com.epmet.constant.SystemMessageType; @@ -128,4 +129,33 @@ public class SendMqMsgUtil { } + /** + * @Description 发送巡查相关消息 + * @return + * @author wxz + * @date 2021.06.21 12:46 + */ + public boolean sendPatrolMqMsg(StaffPatrolMQMsg msg) { + try { + SystemMsgFormDTO msgForm = new SystemMsgFormDTO(); + msgForm.setMessageType(msg.getActionType()); + msgForm.setContent(msg); + Result sendMsgResult = null; + log.info("sendPatrolMqMsg param:{}",msgForm); + int retryTime = 0; + do { + sendMsgResult = epmetMessageOpenFeignClient.sendSystemMsgByMQ(msgForm); + } while ((sendMsgResult == null || !sendMsgResult.success()) && retryTime++ < NumConstant.TWO); + + if (sendMsgResult != null && sendMsgResult.success()) { + return true; + } + log.error("发送(巡查相关)系统消息到message服务失败:{},msg:{}", JSON.toJSONString(sendMsgResult), JSON.toJSONString(msgForm)); + } catch (Exception e) { + log.error("sendMqMsg exception", e); + } + return false; + + } + } 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 f7aacf297c..c85480be6d 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 @@ -2,7 +2,6 @@ package com.epmet.service.impl; import com.alibaba.fastjson.JSON; import com.epmet.auth.constants.AuthOperationConstants; -import com.epmet.auth.constants.AuthOperationEnum; import com.epmet.commons.rocketmq.constants.TopicConstants; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.ExceptionUtils; @@ -91,6 +90,10 @@ public class SystemMessageServiceImpl implements SystemMessageService { case SystemMessageType.STAFF_CHANGE: topic = TopicConstants.STAFF; break; + case SystemMessageType.USER_PATROL_START: + case SystemMessageType.USER_PATROL_STOP: + topic = TopicConstants.PATROL; + break; } return topic; } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffPatrolRecordServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffPatrolRecordServiceImpl.java index 12255c1153..b46f4a6eae 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffPatrolRecordServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffPatrolRecordServiceImpl.java @@ -3,15 +3,16 @@ package com.epmet.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.rocketmq.messages.StaffPatrolMQMsg; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; -import com.epmet.commons.tools.exception.ErrorCode; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.constant.PatrolConstant; +import com.epmet.constant.SystemMessageType; import com.epmet.dao.CustomerStaffDao; import com.epmet.dao.StaffPatrolDetailDao; import com.epmet.dao.StaffPatrolRecordDao; @@ -23,9 +24,10 @@ import com.epmet.dto.result.*; import com.epmet.entity.StaffPatrolDetailEntity; import com.epmet.entity.StaffPatrolRecordEntity; import com.epmet.entity.StatsStaffPatrolRecordDailyEntity; -import com.epmet.feign.GovOrgFeignClient; +import com.epmet.feign.EpmetMessageOpenFeignClient; import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.feign.GovProjectOpenFeignClient; +import com.epmet.send.SendMqMsgUtil; import com.epmet.service.StaffPatrolDetailService; import com.epmet.service.StaffPatrolRecordService; import com.epmet.util.DimIdGenerator; @@ -40,7 +42,6 @@ import javax.annotation.Resource; import java.util.ArrayList; import java.util.Date; import java.util.List; -import java.util.Objects; import java.util.stream.Collectors; /** @@ -55,25 +56,20 @@ public class StaffPatrolRecordServiceImpl extends BaseServiceImplsendPatrolMsg(e, SystemMessageType.USER_PATROL_STOP)); + } /**