diff --git a/epmet-commons/epmet-commons-rocketmq/pom.xml b/epmet-commons/epmet-commons-rocketmq/pom.xml new file mode 100644 index 0000000000..41ee2e97e1 --- /dev/null +++ b/epmet-commons/epmet-commons-rocketmq/pom.xml @@ -0,0 +1,21 @@ + + + + epmet-commons + com.epmet + 2.0.0 + + 4.0.0 + + epmet-commons-rocketmq + + + + org.apache.rocketmq + rocketmq-spring-boot-starter + 2.1.1 + + + \ No newline at end of file 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 new file mode 100644 index 0000000000..0bcf7d4aa6 --- /dev/null +++ b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/ConsomerGroupConstants.java @@ -0,0 +1,21 @@ +package com.epmet.commons.rocketmq.constants; + +/** + * 消费者组常量 + */ +public interface ConsomerGroupConstants { + + /** + * 初始化客户角色消费者组 + */ + String INIT_CUSTOMER_ROLES_GROUP = "init_customer_roles_group"; + /** + * 初始化客户自定义消费者组 + */ + String INIT_CUSTOMER_CUSTOMIZE_GROUP = "init_customer_customize_group"; + /** + * 初始化客户组织机构信息分组 + */ + String INIT_CUSTOMER_ORG_GROUP = "init_customer_org_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 new file mode 100644 index 0000000000..d95a829b8f --- /dev/null +++ b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/TopicConstants.java @@ -0,0 +1,5 @@ +package com.epmet.commons.rocketmq.constants; + +public interface TopicConstants { + String INIT_CUSTOMER = "init_customer_topic"; +} diff --git a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/InitCustomerMQMsg.java b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/InitCustomerMQMsg.java new file mode 100644 index 0000000000..104d77581c --- /dev/null +++ b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/InitCustomerMQMsg.java @@ -0,0 +1,148 @@ +package com.epmet.commons.rocketmq.messages; + +public class InitCustomerMQMsg { + + private String customerId; + + private InitCustomerAgency agency; + + private InitCustomerStaff staff; + + public static class InitCustomerStaff { + private String agencyId; + private Integer gender; + private String mobile; + private String name; + private String workType; + + public String getAgencyId() { + return agencyId; + } + + public void setAgencyId(String agencyId) { + this.agencyId = agencyId; + } + + public Integer getGender() { + return gender; + } + + public void setGender(Integer gender) { + this.gender = gender; + } + + public String getMobile() { + return mobile; + } + + public void setMobile(String mobile) { + this.mobile = mobile; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getWorkType() { + return workType; + } + + public void setWorkType(String workType) { + this.workType = workType; + } + } + + public static class InitCustomerAgency { + private String agencyId; + private String organizationName; + private String level; + private String areaCode; + private String province; + private String city; + private String district; + + public String getAgencyId() { + return agencyId; + } + + public void setAgencyId(String agencyId) { + this.agencyId = agencyId; + } + + public String getOrganizationName() { + return organizationName; + } + + public void setOrganizationName(String organizationName) { + this.organizationName = organizationName; + } + + public String getLevel() { + return level; + } + + public void setLevel(String level) { + this.level = level; + } + + public String getAreaCode() { + return areaCode; + } + + public void setAreaCode(String areaCode) { + this.areaCode = areaCode; + } + + public String getProvince() { + return province; + } + + public void setProvince(String province) { + this.province = province; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getDistrict() { + return district; + } + + public void setDistrict(String district) { + this.district = district; + } + } + + public String getCustomerId() { + return customerId; + } + + public void setCustomerId(String customerId) { + this.customerId = customerId; + } + + public InitCustomerAgency getAgency() { + return agency; + } + + public void setAgency(InitCustomerAgency agency) { + this.agency = agency; + } + + public InitCustomerStaff getStaff() { + return staff; + } + + public void setStaff(InitCustomerStaff staff) { + this.staff = staff; + } +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java index 4d3c107de3..e3a02b4696 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java @@ -20,6 +20,7 @@ public enum EpmetErrorCode { ERR10006(10006, "登录超时,请重新登录"), ERR10007(10007, "当前帐号已在别处登录"), ERR10019(10019, "验证码不正确"), + SYSTEM_MQ_MSG_SEND_FAIL(10020, "MQ消息发送失败"), ERR401(401, "未授权"), INTERNAL_VALIDATE_ERROR(7000, "内部数据校验异常"), SERVER_ERROR(8000, "服务器开小差了..."), diff --git a/epmet-commons/pom.xml b/epmet-commons/pom.xml index d4b8e270b4..0bf8dd9c9f 100644 --- a/epmet-commons/pom.xml +++ b/epmet-commons/pom.xml @@ -23,6 +23,7 @@ epmet-commons-tools-wx-mp epmet-commons-service-call epmet-commons-extapp-auth + epmet-commons-rocketmq diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/SystemMessageSendApproach.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/SystemMessageSendApproach.java new file mode 100644 index 0000000000..7406175d87 --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/SystemMessageSendApproach.java @@ -0,0 +1,7 @@ +package com.epmet.constant; + +public interface SystemMessageSendApproach { + + String MQ = "mq"; + +} 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 new file mode 100644 index 0000000000..382b96e275 --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/SystemMessageType.java @@ -0,0 +1,13 @@ +package com.epmet.constant; + +/** + * 系统消息类型 + */ +public interface SystemMessageType { + + /** + * 初始化客户 + */ + String INIT_CUSTOMER = "init_customer"; + +} diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/SystemMsgFormDTO.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/SystemMsgFormDTO.java new file mode 100644 index 0000000000..c0fc9308b8 --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/SystemMsgFormDTO.java @@ -0,0 +1,15 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotNull; + +@Data +public class SystemMsgFormDTO { + + @NotNull(message = "消息类型不能为空") + private String messageType; + + @NotNull(message = "消息内容不能为空") + private Object content; +} diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/EpmetMessageOpenFeignClient.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/EpmetMessageOpenFeignClient.java index 1035ab1552..3a72c53a54 100644 --- a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/EpmetMessageOpenFeignClient.java +++ b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/EpmetMessageOpenFeignClient.java @@ -4,6 +4,7 @@ import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.SysSmsDTO; import com.epmet.dto.form.SendVerificationCodeFormDTO; +import com.epmet.dto.form.SystemMsgFormDTO; import com.epmet.dto.form.UserMessageFormDTO; import com.epmet.dto.form.WxSubscribeMessageFormDTO; import com.epmet.dto.result.SendVerificationCodeResultDTO; @@ -77,4 +78,13 @@ public interface EpmetMessageOpenFeignClient { **/ @PostMapping(value = "message/wxmpmessage/sendwxsubscribemessage", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE) Result sendWxSubscribeMessage(List msgList); + + /** + * @Description 通过mq发送系统消息 + * @return + * @author wxz + * @date 2021.01.06 15:16 + */ + @PostMapping("/message/system/send-by-mq") + Result sendSystemMsgByMQ(@RequestBody SystemMsgFormDTO form); } diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/fallback/EpmetMessageOpenFeignClientFallback.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/fallback/EpmetMessageOpenFeignClientFallback.java index 889569147f..915c16ff61 100644 --- a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/fallback/EpmetMessageOpenFeignClientFallback.java +++ b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/fallback/EpmetMessageOpenFeignClientFallback.java @@ -5,6 +5,7 @@ import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.SysSmsDTO; import com.epmet.dto.form.SendVerificationCodeFormDTO; +import com.epmet.dto.form.SystemMsgFormDTO; import com.epmet.dto.form.UserMessageFormDTO; import com.epmet.dto.form.WxSubscribeMessageFormDTO; import com.epmet.dto.result.SendVerificationCodeResultDTO; @@ -51,4 +52,9 @@ public class EpmetMessageOpenFeignClientFallback implements EpmetMessageOpenFeig public Result sendWxSubscribeMessage(List msgList) { return ModuleUtils.feignConError(ServiceConstant.EPMET_MESSAGE_SERVER, "sendWxSubscribeMessage", msgList); } + + @Override + public Result sendSystemMsgByMQ(SystemMsgFormDTO form) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_MESSAGE_SERVER, "sendSystemMsgByMQ", form); + } } diff --git a/epmet-module/epmet-message/epmet-message-server/pom.xml b/epmet-module/epmet-message/epmet-message-server/pom.xml index 6a10b4724d..43c2cd1311 100644 --- a/epmet-module/epmet-message/epmet-message-server/pom.xml +++ b/epmet-module/epmet-message/epmet-message-server/pom.xml @@ -112,6 +112,13 @@ 2.0.0 compile + + + + com.epmet + epmet-commons-rocketmq + 2.0.0 + diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/SystemMessageController.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/SystemMessageController.java new file mode 100644 index 0000000000..7a31e91785 --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/SystemMessageController.java @@ -0,0 +1,27 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.dto.form.SystemMsgFormDTO; +import com.epmet.service.SystemMessageService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("system") +public class SystemMessageController { + + @Autowired + private SystemMessageService systemMessageService; + + @PostMapping("send-by-mq") + public Result sendSystemMsgByMQ(@RequestBody SystemMsgFormDTO form) { + ValidatorUtils.validateEntity(form); + systemMessageService.sendMQMessage(form.getMessageType(), form.getContent()); + return new Result(); + } + +} diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/SystemMessageDao.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/SystemMessageDao.java new file mode 100644 index 0000000000..7770c58547 --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/SystemMessageDao.java @@ -0,0 +1,33 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.SystemMessageEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 系统消息表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-01-06 + */ +@Mapper +public interface SystemMessageDao extends BaseDao { + +} \ No newline at end of file diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/SystemMessageEntity.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/SystemMessageEntity.java new file mode 100644 index 0000000000..effdb2d59b --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/SystemMessageEntity.java @@ -0,0 +1,57 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.omg.CORBA.StringHolder; + +import java.util.Date; + +/** + * 系统消息表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-01-06 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("system_message") +public class SystemMessageEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 消息类型 + */ + private String msgType; + + /** + * 发送途径 + */ + private String sendApproach; + + /** + * 消息内容 + */ + private String content; + +} diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/SystemMessageService.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/SystemMessageService.java new file mode 100644 index 0000000000..2985b550c9 --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/SystemMessageService.java @@ -0,0 +1,7 @@ +package com.epmet.service; + +public interface SystemMessageService { + + void sendMQMessage(String messageType, Object content); + +} 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 new file mode 100644 index 0000000000..64a067af56 --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/SystemMessageServiceImpl.java @@ -0,0 +1,70 @@ +package com.epmet.service.impl; + +import com.alibaba.fastjson.JSON; +import com.epmet.commons.rocketmq.constants.TopicConstants; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.constant.SystemMessageSendApproach; +import com.epmet.constant.SystemMessageType; +import com.epmet.dao.SystemMessageDao; +import com.epmet.entity.SystemMessageEntity; +import com.epmet.service.SystemMessageService; +import org.apache.rocketmq.common.message.Message; +import org.apache.rocketmq.remoting.common.RemotingHelper; +import org.apache.rocketmq.spring.core.RocketMQTemplate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +public class SystemMessageServiceImpl implements SystemMessageService { + + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Autowired + private SystemMessageDao systemMessageDao; + + @Autowired + private RocketMQTemplate rocketMQTemplate; + + @Transactional(rollbackFor = Exception.class) + @Override + public void sendMQMessage(String messageType, Object content) { + String contentStr = JSON.toJSONString(content); + //存储消息到表 + SystemMessageEntity systemMessageEntity = new SystemMessageEntity(); + systemMessageEntity.setMsgType(messageType); + systemMessageEntity.setSendApproach(SystemMessageSendApproach.MQ); + systemMessageEntity.setContent(contentStr); + systemMessageDao.insert(systemMessageEntity); + + //发送mq消息 + try { + Message meMessage = new Message(getTopicByMsgType(messageType), contentStr.getBytes(RemotingHelper.DEFAULT_CHARSET)); + rocketMQTemplate.getProducer().send(meMessage); + } catch (Exception e) { + String errorStackTrace = ExceptionUtils.getErrorStackTrace(e); + logger.error("发送系统消息失败,堆栈信息:{}", errorStackTrace); + throw new RenException(EpmetErrorCode.SYSTEM_MQ_MSG_SEND_FAIL.getCode()); + } + } + + /** + * @Description 根据消息类型获取topic + * @return + * @author wxz + * @date 2021.01.06 13:42 + */ + private String getTopicByMsgType(String msgType) { + String topic = null; + switch (msgType) { + case SystemMessageType.INIT_CUSTOMER: + topic = TopicConstants.INIT_CUSTOMER; + break; + } + return topic; + } +} diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/resources/bootstrap.yml b/epmet-module/epmet-message/epmet-message-server/src/main/resources/bootstrap.yml index dcdcaab913..bf7f1e23fe 100644 --- a/epmet-module/epmet-message/epmet-message-server/src/main/resources/bootstrap.yml +++ b/epmet-module/epmet-message/epmet-message-server/src/main/resources/bootstrap.yml @@ -131,4 +131,9 @@ thread: dingTalk: robot: webHook: @dingTalk.robot.webHook@ - secret: @dingTalk.robot.secret@ \ No newline at end of file + secret: @dingTalk.robot.secret@ + +rocketmq: + name-server: 192.168.1.130:9876;192.168.1.132:9876 + producer: + group: epmet_message \ No newline at end of file diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/SystemMessageDao.xml b/epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/SystemMessageDao.xml new file mode 100644 index 0000000000..a5ce6d9da5 --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/SystemMessageDao.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/pom.xml b/epmet-module/gov-org/gov-org-server/pom.xml index aa5fe041a6..9c69a57101 100644 --- a/epmet-module/gov-org/gov-org-server/pom.xml +++ b/epmet-module/gov-org/gov-org-server/pom.xml @@ -95,6 +95,12 @@ 2.0.0 compile + + + com.epmet + epmet-commons-rocketmq + 2.0.0 + diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/mq/listener/InitCustomerOrgListener.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/mq/listener/InitCustomerOrgListener.java new file mode 100644 index 0000000000..47e04307ec --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/mq/listener/InitCustomerOrgListener.java @@ -0,0 +1,76 @@ +package com.epmet.mq.listener; + +import com.alibaba.fastjson.JSON; +import com.epmet.commons.rocketmq.constants.ConsomerGroupConstants; +import com.epmet.commons.rocketmq.constants.TopicConstants; +import com.epmet.commons.rocketmq.messages.InitCustomerMQMsg; +import com.epmet.constant.UserWorkType; +import com.epmet.dto.CustomerAgencyDTO; +import com.epmet.dto.form.AddAgencyAndStaffFormDTO; +import com.epmet.dto.form.AdminStaffFromDTO; +import com.epmet.service.AgencyService; +import org.apache.rocketmq.common.message.MessageExt; +import org.apache.rocketmq.spring.annotation.MessageModel; +import org.apache.rocketmq.spring.annotation.RocketMQMessageListener; +import org.apache.rocketmq.spring.core.RocketMQListener; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 监听初始化客户动作,为客户初始化角色列表 + */ +@RocketMQMessageListener(topic = TopicConstants.INIT_CUSTOMER, + consumerGroup = ConsomerGroupConstants.INIT_CUSTOMER_ORG_GROUP, + messageModel = MessageModel.CLUSTERING, + selectorExpression = "*") +@Component +public class InitCustomerOrgListener implements RocketMQListener { + + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Autowired + private AgencyService agencyService; + + @Override + public void onMessage(MessageExt messageExt) { + String msg = new String(messageExt.getBody()); + logger.info("初始化客户-初始化组织信息-收到消息内容:{}", msg); + InitCustomerMQMsg msgObj = JSON.parseObject(msg, InitCustomerMQMsg.class); + agencyService.saveRootAgency(constructRootAndAgencyDTO(msgObj)); + } + + /** + * @Description 构造dto + * @return + * @author wxz + * @date 2021.01.06 15:03 + */ + private AddAgencyAndStaffFormDTO constructRootAndAgencyDTO(InitCustomerMQMsg msgObj) { + AddAgencyAndStaffFormDTO agencyAndStaff = new AddAgencyAndStaffFormDTO(); + //客户组织信息 + CustomerAgencyDTO agencyDTO = new CustomerAgencyDTO(); + agencyDTO.setId(msgObj.getAgency().getAgencyId()); + agencyDTO.setCustomerId(msgObj.getCustomerId()); + agencyDTO.setOrganizationName(msgObj.getAgency().getOrganizationName()); + agencyDTO.setLevel(msgObj.getAgency().getLevel()); + agencyDTO.setAreaCode(msgObj.getAgency().getAreaCode()); + agencyDTO.setProvince(msgObj.getAgency().getProvince()); + agencyDTO.setCity(msgObj.getAgency().getCity()); + agencyDTO.setDistrict(msgObj.getAgency().getDistrict()); + agencyAndStaff.setAgencyDTO(agencyDTO); + + //客户管理员信息 + AdminStaffFromDTO staffSubmitFrom = new AdminStaffFromDTO(); + staffSubmitFrom.setCustomerId(msgObj.getCustomerId()); + staffSubmitFrom.setAgencyId(msgObj.getStaff().getAgencyId()); + staffSubmitFrom.setGender(msgObj.getStaff().getGender()); + staffSubmitFrom.setMobile(msgObj.getStaff().getMobile()); + staffSubmitFrom.setName(msgObj.getStaff().getName()); + staffSubmitFrom.setWorkType(UserWorkType.FULL_TIME); + agencyAndStaff.setStaffDTO(staffSubmitFrom); + + return agencyAndStaff; + } +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/bootstrap.yml b/epmet-module/gov-org/gov-org-server/src/main/resources/bootstrap.yml index 8651e49ce2..c7410e4c71 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/bootstrap.yml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/bootstrap.yml @@ -135,4 +135,7 @@ pagehelper: dingTalk: robot: webHook: @dingTalk.robot.webHook@ - secret: @dingTalk.robot.secret@ \ No newline at end of file + secret: @dingTalk.robot.secret@ + +rocketmq: + name-server: 192.168.1.130:9876;192.168.1.132:9876 \ No newline at end of file diff --git a/epmet-module/oper-crm/oper-crm-server/pom.xml b/epmet-module/oper-crm/oper-crm-server/pom.xml index 1ee199269a..610cdd9734 100644 --- a/epmet-module/oper-crm/oper-crm-server/pom.xml +++ b/epmet-module/oper-crm/oper-crm-server/pom.xml @@ -87,6 +87,18 @@ 2.0.0 compile + + + com.epmet + epmet-message-client + 2.0.0 + + + + com.epmet + epmet-commons-rocketmq + 2.0.0 + diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java index 9857f910c5..9080d1573f 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java @@ -22,6 +22,7 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.rocketmq.messages.InitCustomerMQMsg; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; @@ -32,6 +33,7 @@ import com.epmet.commons.tools.utils.HttpClientManager; import com.epmet.commons.tools.utils.Result; import com.epmet.constant.ModuleConstant; import com.epmet.constant.RoleKeyConstants; +import com.epmet.constant.SystemMessageType; import com.epmet.constant.UserWorkType; import com.epmet.dao.CustomerDao; import com.epmet.dto.*; @@ -80,6 +82,8 @@ public class CustomerServiceImpl extends BaseServiceImpl page(Map params) { @@ -468,48 +472,62 @@ public class CustomerServiceImpl extends BaseServiceImpl getAllList() { List list = baseDao.getAllList(); diff --git a/epmet-module/oper-customize/oper-customize-server/pom.xml b/epmet-module/oper-customize/oper-customize-server/pom.xml index a36f6d46d1..636e2cc3b3 100644 --- a/epmet-module/oper-customize/oper-customize-server/pom.xml +++ b/epmet-module/oper-customize/oper-customize-server/pom.xml @@ -70,6 +70,13 @@ 2.0.0 compile + + + + com.epmet + epmet-commons-rocketmq + 2.0.0 + diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/mq/listener/InitCustomerCustomizeListener.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/mq/listener/InitCustomerCustomizeListener.java new file mode 100644 index 0000000000..c4239a7a47 --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/mq/listener/InitCustomerCustomizeListener.java @@ -0,0 +1,43 @@ +package com.epmet.mq.listener; + +import com.alibaba.fastjson.JSON; +import com.epmet.commons.rocketmq.constants.ConsomerGroupConstants; +import com.epmet.commons.rocketmq.constants.TopicConstants; +import com.epmet.commons.rocketmq.messages.InitCustomerMQMsg; +import com.epmet.dto.CustomerHomeDTO; +import com.epmet.service.CustomerHomeService; +import org.apache.rocketmq.common.message.MessageExt; +import org.apache.rocketmq.spring.annotation.MessageModel; +import org.apache.rocketmq.spring.annotation.RocketMQMessageListener; +import org.apache.rocketmq.spring.core.RocketMQListener; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 监听初始化客户动作,为客户初始化角色列表 + */ +@RocketMQMessageListener(topic = TopicConstants.INIT_CUSTOMER, + consumerGroup = ConsomerGroupConstants.INIT_CUSTOMER_CUSTOMIZE_GROUP, + messageModel = MessageModel.CLUSTERING, + selectorExpression = "*") +@Component +public class InitCustomerCustomizeListener implements RocketMQListener { + + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Autowired + private CustomerHomeService customerHomeService; + + @Override + public void onMessage(MessageExt messageExt) { + String msg = new String(messageExt.getBody()); + logger.info("初始化客户-初始化客户自定义信息-收到消息内容:{}", msg); + InitCustomerMQMsg msgObj = JSON.parseObject(msg, InitCustomerMQMsg.class); + + CustomerHomeDTO customerHomeDTO = new CustomerHomeDTO(); + customerHomeDTO.setCustomerId(msgObj.getCustomerId()); + customerHomeService.init(customerHomeDTO); + } +} \ No newline at end of file diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/resources/bootstrap.yml b/epmet-module/oper-customize/oper-customize-server/src/main/resources/bootstrap.yml index b6cb0ffbb8..093896fc57 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/resources/bootstrap.yml +++ b/epmet-module/oper-customize/oper-customize-server/src/main/resources/bootstrap.yml @@ -122,4 +122,7 @@ pagehelper: dingTalk: robot: webHook: @dingTalk.robot.webHook@ - secret: @dingTalk.robot.secret@ \ No newline at end of file + secret: @dingTalk.robot.secret@ + +rocketmq: + name-server: 192.168.1.130:9876;192.168.1.132:9876 \ No newline at end of file diff --git a/epmet-user/epmet-user-server/pom.xml b/epmet-user/epmet-user-server/pom.xml index d3d04f835d..5da0332708 100644 --- a/epmet-user/epmet-user-server/pom.xml +++ b/epmet-user/epmet-user-server/pom.xml @@ -100,6 +100,12 @@ 2.0.0 compile + + + com.epmet + epmet-commons-rocketmq + 2.0.0 + diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/mq/listener/InitCustomerRolesListener.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/mq/listener/InitCustomerRolesListener.java new file mode 100644 index 0000000000..34dd589b80 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/mq/listener/InitCustomerRolesListener.java @@ -0,0 +1,39 @@ +package com.epmet.mq.listener; + +import com.alibaba.fastjson.JSON; +import com.epmet.commons.rocketmq.constants.ConsomerGroupConstants; +import com.epmet.commons.rocketmq.constants.TopicConstants; +import com.epmet.commons.rocketmq.messages.InitCustomerMQMsg; +import com.epmet.service.GovStaffRoleService; +import org.apache.rocketmq.common.message.MessageExt; +import org.apache.rocketmq.spring.annotation.MessageModel; +import org.apache.rocketmq.spring.annotation.RocketMQMessageListener; +import org.apache.rocketmq.spring.core.RocketMQListener; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 监听初始化客户动作,为客户初始化角色列表 + */ +@RocketMQMessageListener(topic = TopicConstants.INIT_CUSTOMER, + consumerGroup = ConsomerGroupConstants.INIT_CUSTOMER_ROLES_GROUP, + messageModel = MessageModel.CLUSTERING, + selectorExpression = "*") +@Component +public class InitCustomerRolesListener implements RocketMQListener { + + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Autowired + private GovStaffRoleService govStaffRoleService; + + @Override + public void onMessage(MessageExt messageExt) { + String msg = new String(messageExt.getBody()); + logger.info("初始化客户-初始化角色列表-收到消息内容:{}", msg); + InitCustomerMQMsg msgObj = JSON.parseObject(msg, InitCustomerMQMsg.class); + govStaffRoleService.initGovStaffRolesForCustomer(msgObj.getCustomerId()); + } +} diff --git a/epmet-user/epmet-user-server/src/main/resources/bootstrap.yml b/epmet-user/epmet-user-server/src/main/resources/bootstrap.yml index 380e974475..663515b101 100644 --- a/epmet-user/epmet-user-server/src/main/resources/bootstrap.yml +++ b/epmet-user/epmet-user-server/src/main/resources/bootstrap.yml @@ -144,4 +144,7 @@ openapi: dingTalk: robot: webHook: @dingTalk.robot.webHook@ - secret: @dingTalk.robot.secret@ \ No newline at end of file + secret: @dingTalk.robot.secret@ + +rocketmq: + name-server: 192.168.1.130:9876;192.168.1.132:9876 \ No newline at end of file