diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/AuthOperationLogListener.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/AuthOperationLogListener.java index 4f9e361fc5..6f8afd1418 100644 --- a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/AuthOperationLogListener.java +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/AuthOperationLogListener.java @@ -2,22 +2,19 @@ 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.LoginMQMsg; -import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.distributedlock.DistributedLock; -import com.epmet.commons.tools.exception.EpmetErrorCode; 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.utils.IpUtils; -import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.redis.RedisKeys; +import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.commons.tools.utils.SpringContextUtils; -import com.epmet.dto.CustomerStaffDTO; import com.epmet.entity.LogOperationEntity; -import com.epmet.feign.EpmetUserOpenFeignClient; 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; @@ -40,8 +37,15 @@ public class AuthOperationLogListener 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) { @@ -54,6 +58,7 @@ public class AuthOperationLogListener implements MessageListenerConcurrently { 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); LoginMQMsg msgObj = JSON.parseObject(msg, LoginMQMsg.class); @@ -91,5 +96,27 @@ public class AuthOperationLogListener implements MessageListenerConcurrently { } 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/mq/listener/listener/PointOperationLogListener.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/PointOperationLogListener.java index f953c35edc..aa4f50a768 100644 --- a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/PointOperationLogListener.java +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/PointOperationLogListener.java @@ -1,10 +1,13 @@ package com.epmet.mq.listener.listener; import com.alibaba.fastjson.JSON; +import com.epmet.commons.rocketmq.constants.MQUserPropertys; import com.epmet.commons.rocketmq.messages.PointRuleChangedMQMsg; 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.enums.SystemMessageTypeEnum; @@ -34,8 +37,15 @@ public class PointOperationLogListener 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) { @@ -48,6 +58,7 @@ public class PointOperationLogListener implements MessageListenerConcurrently { private void consumeMessage(MessageExt messageExt) { String opeType = messageExt.getTags(); String msg = new String(messageExt.getBody()); + String pendingMsgLabel = messageExt.getUserProperty(MQUserPropertys.BLOCKED_MSG_LABEL); logger.info("积分操作日志监听器-收到消息内容:{}", msg); PointRuleChangedMQMsg msgObj = JSON.parseObject(msg, PointRuleChangedMQMsg.class); @@ -87,5 +98,27 @@ public class PointOperationLogListener implements MessageListenerConcurrently { } 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/mq/listener/listener/ProjectOperationLogListener.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/ProjectOperationLogListener.java index 13384ea62e..a47d55c2de 100644 --- a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/ProjectOperationLogListener.java +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/ProjectOperationLogListener.java @@ -1,11 +1,14 @@ package com.epmet.mq.listener.listener; import com.alibaba.fastjson.JSON; +import com.epmet.commons.rocketmq.constants.MQUserPropertys; import com.epmet.commons.rocketmq.messages.LoginMQMsg; import com.epmet.commons.rocketmq.messages.ProjectChangedMQMsg; 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; @@ -34,8 +37,15 @@ public class ProjectOperationLogListener 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) { @@ -48,6 +58,7 @@ public class ProjectOperationLogListener implements MessageListenerConcurrently 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); ProjectChangedMQMsg msgObj = JSON.parseObject(msg, ProjectChangedMQMsg.class); @@ -87,6 +98,14 @@ public class ProjectOperationLogListener implements MessageListenerConcurrently } finally { distributedLock.unLock(lock); } + + if (StringUtils.isNotBlank(pendingMsgLabel)) { + try { + removePendingMqMsgCache(pendingMsgLabel); + } catch (Exception e) { + logger.error("【项目操作事件监听器】-删除mq阻塞消息缓存失败:{}", ExceptionUtils.getErrorStackTrace(e)); + } + } } private String getOperationTypeDisplay(String type) { @@ -107,4 +126,18 @@ public class ProjectOperationLogListener implements MessageListenerConcurrently return null; } } + + /** + * @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-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 890d19acf1..a1c61abf6b 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 @@ -45,4 +45,19 @@ public interface ConsomerGroupConstants { */ String POINT_OPERATION_LOG_GROUP = "point_operation_log_group"; + /** + * 开放的对接数据(中间库) 组织变更事件监听器分组 + */ + String OPEN_DATA_ORG_CHANGE_EVENT_LISTENER_GROUP = "open_data_org_change_event_listener_group"; + + /** + * 开放的对接数据(中间库) 工作人员变更事件监听器分组 + */ + String OPEN_DATA_STAFF_CHANGE_EVENT_LISTENER_GROUP = "open_data_staff_change_event_listener_group"; + + /** + * 开放的对接数据(中间库) 巡查记录变更事件监听器分组 + */ + String OPEN_DATA_PATROL_CHANGE_EVENT_LISTENER_GROUP = "open_data_patrol_change_event_listener_group"; + } diff --git a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/MQUserPropertys.java b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/MQUserPropertys.java new file mode 100644 index 0000000000..c1a53a29ba --- /dev/null +++ b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/MQUserPropertys.java @@ -0,0 +1,13 @@ +package com.epmet.commons.rocketmq.constants; + +/** + * @Description MQ用户自定义属性 + * @author wxz + * @date 2021.10.14 15:47:03 +*/ +public interface MQUserPropertys { + + //阻塞消息label + String BLOCKED_MSG_LABEL = "blockedMsgLabel"; + +} 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 8fe36aa53a..4dfeaa3500 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 @@ -13,6 +13,7 @@ public interface TopicConstants { * 项目变动 */ String PROJECT_CHANGED = "project_changed"; + /** * 小组成就 */ @@ -27,4 +28,19 @@ 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/OrgOrStaffMQMsg.java b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/OrgOrStaffMQMsg.java new file mode 100644 index 0000000000..650b9e9f90 --- /dev/null +++ b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/OrgOrStaffMQMsg.java @@ -0,0 +1,27 @@ +package com.epmet.commons.rocketmq.messages; + +import lombok.AllArgsConstructor; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * 组织、网格、人员中间库数据上报MQ + * @author sun + */ +@Data +public class OrgOrStaffMQMsg implements Serializable { + + //客户Id + private String customerId; + //组织、网格、人员Id + private String orgId; + //数据类型【组织:agency 网格:grid 人员:staff】 + private String orgType; + //操作类型【组织新增:agency_create 组织变更:agency_change 网格新增:grid_create 网格变更:grid_change 人员新增:staff_create 人员变更:staff_change】 + private String type; + + +} 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..d8d68cac56 --- /dev/null +++ b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/StaffPatrolMQMsg.java @@ -0,0 +1,21 @@ +package com.epmet.commons.rocketmq.messages; + +import lombok.Data; + +/** + * 用户巡查消息体 + * @author liujianjun + */ +@Data +public class StaffPatrolMQMsg { + /** + * 客户Id + */ + private String customerId; + + /** + * 巡查记录id + */ + private String patrolId; + +} 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 c601d2fd71..fd4a97d11e 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 @@ -44,6 +44,11 @@ public interface StrConstant { */ String COLON = ":"; + /** + * 英文分号 + */ + String SEMICOLON = ";"; + /** * 中文顿号 */ diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/PageFormDTO.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/PageFormDTO.java index 134124f512..4820f4d50b 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/PageFormDTO.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/PageFormDTO.java @@ -20,8 +20,17 @@ public class PageFormDTO { } @NotNull(message = "页码不能为空", groups = AddUserInternalGroup.class) - private Integer pageNo; + private Integer pageNo = 1; @NotNull(message = "每页数量不能为空", groups = AddUserInternalGroup.class) - private Integer pageSize; + private Integer pageSize = 20; + + /** + * 偏移量 从多少条开始 + */ + private Integer offset; + + public Integer getOffset() { + return (pageNo-1)*pageSize; + } } 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 6fe4130225..388927ce5a 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 @@ -547,4 +547,16 @@ public class RedisKeys { public static String getQuestionnaireAccessKey(String userId, String qKey) { return rootPrefix.concat("questionnaire:accesskey:").concat(userId).concat(":").concat(qKey); } + + /** + * @description 检查message MQ阻塞消息 + * + * @param blockedMsgLabel 滞留消息的label + * @return + * @author wxz + * @date 2021.10.14 14:33:53 + */ + public static String blockedMqMsgKey(String blockedMsgLabel) { + return rootPrefix.concat("message:mq:blocked:").concat(blockedMsgLabel); + } } diff --git a/epmet-gateway/pom.xml b/epmet-gateway/pom.xml index e09410668d..3d668a8b6f 100644 --- a/epmet-gateway/pom.xml +++ b/epmet-gateway/pom.xml @@ -223,6 +223,9 @@ lb://data-aggregator-server + + lb://open-data-worker-server + lb://epmet-openapi-adv-server @@ -361,6 +364,10 @@ lb://data-aggregator-server + + + http://127.0.0.1:8117 + lb://epmet-openapi-adv-server @@ -469,6 +476,8 @@ lb://data-aggregator-server lb://tduck-api + + lb://open-data-worker-server lb://epmet-openapi-adv-server @@ -570,6 +579,8 @@ lb://epmet-ext-server lb://data-aggregator-server + + lb://open-data-worker-server lb://epmet-openapi-adv-server diff --git a/epmet-gateway/src/main/resources/bootstrap.yml b/epmet-gateway/src/main/resources/bootstrap.yml index c0308758b9..69423d078f 100644 --- a/epmet-gateway/src/main/resources/bootstrap.yml +++ b/epmet-gateway/src/main/resources/bootstrap.yml @@ -350,6 +350,16 @@ spring: filters: - StripPrefix=1 - CpAuth=true + #政府工作端议题管理 + - id: open-data-worker-server + uri: @gateway.routes.gov-issue-server.uri@ + order: 38 + predicates: + - Path=${server.servlet.context-path}/opendata/** + filters: + - StripPrefix=1 + - CpAuth=true + nacos: discovery: server-addr: @nacos.server-addr@ diff --git a/epmet-module/data-statistical/data-statistical-client/pom.xml b/epmet-module/data-statistical/data-statistical-client/pom.xml index 1e128a8adf..34fae622ba 100644 --- a/epmet-module/data-statistical/data-statistical-client/pom.xml +++ b/epmet-module/data-statistical/data-statistical-client/pom.xml @@ -17,6 +17,18 @@ epmet-commons-tools 2.0.0 + + com.epmet + open-data-worker-client + 2.0.0 + compile + + + com.epmet + open-data-worker-client + 2.0.0 + compile + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/basereport/form/EventInfoFormDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/basereport/form/EventInfoFormDTO.java new file mode 100644 index 0000000000..dbbbe4bbf0 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/basereport/form/EventInfoFormDTO.java @@ -0,0 +1,21 @@ +package com.epmet.dto.basereport.form; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Description + * @Author zhaoqifeng + * @Date 2021/10/15 10:55 + */ +@Data +public class EventInfoFormDTO implements Serializable { + private static final long serialVersionUID = 8479649048108914555L; + private String customerId; + private String projectId; + /** + * 操作类型【新增:add 修改删除:edit】 + */ + private String type; +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/basereport/result/EventInfoResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/basereport/result/EventInfoResultDTO.java new file mode 100644 index 0000000000..faff5af737 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/basereport/result/EventInfoResultDTO.java @@ -0,0 +1,143 @@ +package com.epmet.dto.basereport.result; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * @Description + * @Author zhaoqifeng + * @Date 2021/10/15 10:57 + */ +@Data +public class EventInfoResultDTO implements Serializable { + private static final long serialVersionUID = -6483163020737762044L; + /** + * 客户Id + */ + private String customerId; + + /** + * 网格编码 + */ + private String orgCode; + + /** + * 网格名称 + */ + private String orgName; + + /** + * 事件名称 + */ + private String eventName; + + /** + * 事件类别 + */ + private String eventCategory; + + /** + * 上报时间 YYYY-MM-DD HH:MM:SS + */ + private Date reportTime; + + /** + * 发生时间 格式为“YYYY-MM-DD” + */ + private Date happenDate; + + /** + * 发生地点 + */ + private String happenPlace; + + /** + * 事件简述 + */ + private String eventDescription; + + /** + * 办结方式 01自办;02上报 源于居民端的最终结案的项目为02;工作端立项的项目最终结案的01 + */ + private String waysOfResolving; + + /** + * 是否办结 Y:是、N:否 + */ + private String successfulOrNo; + + /** + * 办结层级01省、自治区、直辖市02地、市、州、盟03县、市、区、旗04乡镇、街道05片区06村、社区07网格 + */ + private String completeLevel; + + /** + * 基础信息主键 + */ + private String baseInfoId; + + /** + * 办结时间 + */ + private Date completeTime; + + /** + * 经度 + */ + private BigDecimal lng; + + /** + * 纬度 + */ + private BigDecimal lat; + + /** + * 主要当事人姓名 + */ + private String name; + + /** + * 涉及人数 + */ + private Integer numberInvolved; + + /** + * 涉及单位 + */ + private String relatedUnits; + + /** + * 重点场所类别 01九小场所, 02公共场所 + */ + private String keyAreaType; + + /** + * 宗教活动规模 01 0-50人,02 51-200人,03 201人以上 + + */ + private String religionScale; + + /** + * 宗教类别 01道教 02佛教 03基督教 04伊斯兰教 05其他 + + */ + private String religionType; + + /** + * 重点场所是否变动 Y:是、N:否 + */ + private String isKeyareaState; + + /** + * 重点人员是否在当地 Y:是、N:否 + */ + private String isKeypeopleLocate; + + /** + * 重点人员现状 + */ + private String keypeopleStatus; +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/org/result/CustomerAgencyDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/org/result/CustomerAgencyDTO.java new file mode 100644 index 0000000000..c78138e9bf --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/org/result/CustomerAgencyDTO.java @@ -0,0 +1,145 @@ +/** + * 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.dto.org.result; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * 机关单位信息表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-20 + */ +@Data +public class CustomerAgencyDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * ID + */ + private String id; + + /** + * 客户ID + */ + private String customerId; + + /** + * 上级组织机构ID + */ + private String pid; + + /** + * 所有上级组织机构ID(以英文:隔开) + */ + private String pids; + + /** + * 所有上级名称,以-连接 + */ + private String allParentName; + + /** + * 组织名称 + */ + private String organizationName; + + /** + * 机关级别(社区级:community, +乡(镇、街道)级:street, +区县级: district, +市级: city +省级:province) 机关级别(社区级:community,乡(镇、街道)级:street,区县级: district,市级: city省级:province) + */ + private String level; + + /** + * 地区编码 + */ + private String areaCode; + + /** + * 删除标识 + */ + private String delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + + /** + * 总人数 + */ + private Integer totalUser; + + /** + * 省 + */ + private String province; + + /** + * 市 + */ + private String city; + + /** + * 区县 + */ + private String district; + + /** + * 当前组织的上级行政地区编码add0204;举例平阴县对应的是济南市3701 + */ + private String parentAreaCode; + + /** + * 街道 + */ + private String street; + + /** + * 社区 + */ + private String community; +} \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/org/result/CustomerGridDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/org/result/CustomerGridDTO.java new file mode 100644 index 0000000000..bcff1ea7b0 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/org/result/CustomerGridDTO.java @@ -0,0 +1,129 @@ +/** + * 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.dto.org.result; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * 客户网格表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-16 + */ +@Data +public class CustomerGridDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * ID 唯一标识 + */ + private String id; + + /** + * 客户ID + */ + private String customerId; + + /** + * 网格名称 + */ + private String gridName; + + /** 组织-网格 */ + private String gridNamePath; + + /** + * 中心位置经度 + */ + private String longitude; + + /** + * 中心位置纬度 + */ + private String latitude; + + /** + * 所属地区码(所属组织地区码) + */ + private String areaCode; + + /** + * 删除标识:0.未删除 1.已删除 + */ + private Integer delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + + /** + * 管辖区域 + */ + private String manageDistrict; + + /** + * 当前网格总人数 + */ + private Integer totalUser; + + /** + * 所属组织机构ID(customer_organization.id) + */ + private String pid; + + /** + * 所有上级组织ID + */ + private String pids; + + /** + * 所属组织机构名 + */ + private String agencyName; + + /** + * 所有上级组织名 + */ + private String allParentName; +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/org/result/GridBaseInfoDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/org/result/GridBaseInfoDTO.java new file mode 100644 index 0000000000..5da47611a5 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/org/result/GridBaseInfoDTO.java @@ -0,0 +1,103 @@ +/** + * 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.dto.org.result; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * 网格员基础信息表 + */ +@Data +public class GridBaseInfoDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 网格Id + */ + private String gridId; + /** + * 工作人员Id + */ + private String staffId; + /** + * 客户Id + */ + private String customerId; + + /** + * 网格编码 + */ + private String code; + + /** + * 网格名称 + */ + private String gridName; + + /** + * 网格员姓名 + */ + private String GRID_LEVEL; + + /** + * 专属网格类型[01:党政机关; 02:医院; 03:学校; 04:企业; 05:园区; 06:商圈; 07:市场; 08:景区; + */ + private String GRID_TYPE; + + /** + * 网格内人口规模[01:500人以下(含500人); 02:500-1000人(含1000人); 03:1000-1500人(含1500人); 04:1500人以上] + */ + private String POPULATION_SIZE; + + /** + * 是否成立网格党支部或网格党小组[Y:是、N:否] + */ + private String IS_PARTY_BRANCH; + + /** + * 网格党组织类型[01:网格党支部; 02:网格党小组] + */ + private String PARTY_BRANCH_TYPE; + + /** + * 中心点(质心)经度 + */ + private String LNG; + + /** + * 中心点(质心)纬度 + */ + private String LAT; + + /** + * 网格颜色 + */ + private Date GRID_COLOR; + + /** + * 空间范围 + */ + private String SHAPE; + + +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/ScreenCustomerGridDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/ScreenCustomerGridDTO.java index 2a707f9540..2dcdc32028 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/ScreenCustomerGridDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/ScreenCustomerGridDTO.java @@ -43,7 +43,7 @@ public class ScreenCustomerGridDTO implements Serializable { * 客户id */ private String customerId; - + private String code; /** * 网格id */ diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/ScreenProjectDataDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/ScreenProjectDataDTO.java index 9c6bb27cea..180ac24fe5 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/ScreenProjectDataDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/ScreenProjectDataDTO.java @@ -170,7 +170,7 @@ public class ScreenProjectDataDTO implements Serializable { /** * 结案日期 */ - private String closeCaseTime; + private Date closeCaseTime; /** * 数据更新至: yyyy|yyyMM|yyyyMMdd @@ -196,4 +196,5 @@ public class ScreenProjectDataDTO implements Serializable { * fact_origin_project_main_daily.grid_id对应的网格名称 */ private String tempGridName; + } diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/form/ScreenProjectDataInfoFormDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/form/ScreenProjectDataInfoFormDTO.java index 9202158945..66e3943591 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/form/ScreenProjectDataInfoFormDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/form/ScreenProjectDataInfoFormDTO.java @@ -115,7 +115,8 @@ public class ScreenProjectDataInfoFormDTO implements Serializable { /** * 结案日期 */ - private String closeCaseTime; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") + private Date closeCaseTime; /** * 所有上级ID,用英文逗号分开 diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/param/MidPatrolFormDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/param/MidPatrolFormDTO.java new file mode 100644 index 0000000000..b0810e54cc --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/param/MidPatrolFormDTO.java @@ -0,0 +1,29 @@ +package com.epmet.dto.user.param; + +import com.epmet.commons.tools.dto.form.PageFormDTO; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * desc:查询巡查 参数 + * + * @author zhaoqifeng + * @dscription + * @date 2021/6/7 16:23 + */ +@NoArgsConstructor +@Data +public class MidPatrolFormDTO extends PageFormDTO implements Serializable { + private static final long serialVersionUID = 4411051728689886810L; + /** + * 客户Id + */ + private String customerId; + /** + * 巡查记录id 没有则查询全部 + */ + private String patrolId; + +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/GridUserInfoDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/GridUserInfoDTO.java new file mode 100644 index 0000000000..2fde3c3566 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/GridUserInfoDTO.java @@ -0,0 +1,182 @@ +/** + * 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.dto.user.result; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * 网格员基础信息表 + */ +@Data +public class GridUserInfoDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 网格Id + */ + private String gridId; + /** + * 工作人员Id + */ + private String staffId; + /** + * 客户Id + */ + private String customerId; + + /** + * 网格编码 + */ + private String code; + + /** + * 网格名称 + */ + private String gridName; + + /** + * 网格员姓名 + */ + private String nickName; + + /** + * 专属网格类型[01:党政机关; 02:医院; 03:学校; 04:企业; 05:园区; 06:商圈; 07:市场; 08:景区; + */ + private String cardNum; + + /** + * 网格员类型[01:专职网格员; 02:兼职网格员; 03:网格长; 04:综治机构人员; 05:职能部门人员] + */ + private String userType; + + /** + * 手机号码 + */ + private String phonenumber; + + /** + * 性别[1:男性; 2:女性; 9:未说明的性别] + */ + private String sex; + + /** + * 民族[字典表主键] + */ + private String nation; + + /** + * 政治面貌[字典表主键] + */ + private String paerty; + + /** + * 出生日期[YYYY-MM-DD] + */ + private Date birthday; + + /** + * 学历[字典表主键] + */ + private String education; + + /** + * 入职时间 + */ + private Date entryDate; + + /** + * 是否离职 + */ + private String isLeave; + + /** + * 离职时间 + */ + private Date leaveDate; + + /** + * 网格员年收入 + */ + private String income; + + /** + * 是否社区(村)两委委员[Y:是、N:否] + */ + private String isCommittee; + + /** + * 是否社区工作者[Y:是、N:否] + */ + private String isCommunityWorkers; + + /** + * 是否社会工作者[Y:是、N:否] + */ + private String isSocialWorker; + + /** + * 是否村(居)民小组长[Y:是、N:否 + */ + private String isVillageLeader; + + /** + * 是否警务助理[Y:是、N:否] + */ + private String isPoliceAssistant; + + /** + * 是否人民调解员[Y:是、N:否] + */ + private String isMediator; + + /** + * 删除标识 0.未删除 1.已删除 + */ + private Integer delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/MidPatrolDetailResult.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/MidPatrolDetailResult.java new file mode 100644 index 0000000000..434d2c8740 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/MidPatrolDetailResult.java @@ -0,0 +1,56 @@ +/** + * 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.dto.user.result; + +import lombok.Data; + +import java.io.Serializable; + + +/** + * 工作人员巡查明细记录 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-06-07 + */ +@Data +public class MidPatrolDetailResult implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 客户Id + */ + private String customerId; + + /** + * 维度 + */ + private String latitude; + + /** + * 经度 + */ + private String longitude; + +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/MidPatrolRecordResult.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/MidPatrolRecordResult.java new file mode 100644 index 0000000000..12c18962d1 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/MidPatrolRecordResult.java @@ -0,0 +1,137 @@ +/** + * 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.dto.user.result; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * 工作人员巡查主记录 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-06-07 + */ +@Data +public class MidPatrolRecordResult implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 客户Id + */ + private String customerId; + + /** + * 网格id + */ + private String grid; + + /** + * 网格所有上级id + */ + private String gridPids; + + /** + * 工作人员用户id + */ + private String staffId; + + /** + * 工作人员所属组织id=网格所属的组织id + */ + private String agencyId; + + /** + * 巡查开始时间 + */ + private Date patrolStartTime; + + /** + * 巡查结束时间,前端传入 + */ + private Date patrolEndTime; + + /** + * 实际结束时间=操作结束巡查的时间 + */ + private Date actrualEndTime; + + /** + * 本次巡查总耗时,单位秒;结束巡查时写入 + */ + private Integer totalTime; + + /** + * 正在巡查中:patrolling;结束:end + */ + private String status; + + /** + * 删除标识 0.未删除 1.已删除 + */ + private Integer delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + + /** + * 维度 + */ + private String latitude; + + /** + * 精度 + */ + private String longitude; + + /** + * 经纬度组合成的路线 经度,维度; + */ + private String route; + +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/DataStatisticalOpenFeignClient.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/DataStatisticalOpenFeignClient.java index 93d81104d5..50b339b697 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/DataStatisticalOpenFeignClient.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/DataStatisticalOpenFeignClient.java @@ -3,17 +3,31 @@ package com.epmet.feign; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.StatsFormDTO; -import com.epmet.dto.extract.form.*; +import com.epmet.dto.basereport.form.EventInfoFormDTO; +import com.epmet.dto.extract.form.BizDataFormDTO; +import com.epmet.dto.extract.form.ExtractIndexFormDTO; +import com.epmet.dto.extract.form.ExtractOriginFormDTO; +import com.epmet.dto.extract.form.ExtractScreenFormDTO; import com.epmet.dto.group.form.GroupStatsFormDTO; import com.epmet.dto.group.form.GroupTotalFormDTO; +import com.epmet.dto.org.result.CustomerAgencyDTO; +import com.epmet.dto.org.result.CustomerGridDTO; import com.epmet.dto.screen.form.InitCustomerIndexForm; import com.epmet.dto.stats.form.CustomerIdAndDateIdFormDTO; -import com.epmet.feign.impl.DataStatisticalOpenFeignClientFallBack; +import com.epmet.dto.user.param.MidPatrolFormDTO; +import com.epmet.dto.user.result.GridUserInfoDTO; +import com.epmet.dto.user.result.MidPatrolDetailResult; +import com.epmet.dto.user.result.MidPatrolRecordResult; import com.epmet.feign.impl.DataStatisticalOpenFeignClientFallBackFactory; +import com.epmet.opendata.dto.BaseDisputeProcessDTO; +import com.epmet.opendata.dto.form.GridBaseInfoFormDTO; +import com.epmet.opendata.dto.form.StaffBaseInfoFormDTO; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; +import java.util.List; + /** * desc: 数据统计 对外feign client * @@ -274,4 +288,57 @@ public interface DataStatisticalOpenFeignClient { */ @PostMapping("/data/stats/statsgroup/groupandhottopic") Result groupAndHotTopicTask(@RequestBody GroupTotalFormDTO formDTO); + + /** + * @dscription 批量查询客户组织基础信息 + * @author sun + */ + @PostMapping("/data/stats/datareporting/agencybaseinfo") + Result> getAgencyBaseInfo(@RequestBody GridBaseInfoFormDTO formDTO); + + /** + * @dscription 批量查询客户网格基础信息 + * @author sun + */ + @PostMapping("/data/stats/datareporting/gridbaseinfo") + Result> getGridBaseInfo(@RequestBody GridBaseInfoFormDTO formDTO); + + /** + * @dscription 批量查询客户网格员基础信息 + * @author sun + */ + @PostMapping("/data/stats/datareporting/staffbaseinfo") + Result> getStaffBaseInfo(@RequestBody StaffBaseInfoFormDTO formDTO); + + /** + * 根据巡查记录id 获取巡查主记录信息 + * + * @param midPatrolFormDTO + * @return + * @author yinzuomei + * @date 2021/9/10 8:56 上午 + */ + @PostMapping(value = "/data/stats/datareporting/getPatrolRecordList") + Result> getPatrolRecordList(@RequestBody MidPatrolFormDTO midPatrolFormDTO); + + /** + * 根据巡查记录id 获取巡查轨迹(明细)信息 + * + * @param midPatrolFormDTO + * @return + * @author yinzuomei + * @date 2021/9/10 8:56 上午 + */ + @PostMapping(value = "/data/stats/datareporting/getPatrolDetailList") + Result> getPatrolDetailList(@RequestBody MidPatrolFormDTO midPatrolFormDTO); + + /** + * 事件上报 + * @Param formDTO + * @Return {@link Result>} + * @Author zhaoqifeng + * @Date 2021/10/15 16:50 + */ + @PostMapping("/data/stats/datareporting/eventinfo") + Result> getEventInfo(@RequestBody EventInfoFormDTO formDTO); } diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBack.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBack.java index 7bf37b9ce7..b36b9e9434 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBack.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBack.java @@ -4,13 +4,27 @@ import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.StatsFormDTO; -import com.epmet.dto.extract.form.*; +import com.epmet.dto.basereport.form.EventInfoFormDTO; +import com.epmet.dto.extract.form.BizDataFormDTO; +import com.epmet.dto.extract.form.ExtractIndexFormDTO; +import com.epmet.dto.extract.form.ExtractOriginFormDTO; +import com.epmet.dto.extract.form.ExtractScreenFormDTO; import com.epmet.dto.group.form.GroupStatsFormDTO; import com.epmet.dto.group.form.GroupTotalFormDTO; +import com.epmet.dto.org.result.CustomerAgencyDTO; +import com.epmet.dto.org.result.CustomerGridDTO; import com.epmet.dto.screen.form.InitCustomerIndexForm; import com.epmet.dto.stats.form.CustomerIdAndDateIdFormDTO; +import com.epmet.dto.user.param.MidPatrolFormDTO; +import com.epmet.dto.user.result.GridUserInfoDTO; +import com.epmet.dto.user.result.MidPatrolDetailResult; +import com.epmet.dto.user.result.MidPatrolRecordResult; import com.epmet.feign.DataStatisticalOpenFeignClient; -import org.springframework.stereotype.Component; +import com.epmet.opendata.dto.BaseDisputeProcessDTO; +import com.epmet.opendata.dto.form.GridBaseInfoFormDTO; +import com.epmet.opendata.dto.form.StaffBaseInfoFormDTO; + +import java.util.List; /** * desc: @@ -265,4 +279,59 @@ public class DataStatisticalOpenFeignClientFallBack implements DataStatisticalOp public Result groupAndHotTopicTask(GroupTotalFormDTO formDTO) { return ModuleUtils.feignConError(ServiceConstant.DATA_STATISTICAL_SERVER, "groupAndHotTopic", formDTO); } + + @Override + public Result> getAgencyBaseInfo(GridBaseInfoFormDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.DATA_STATISTICAL_SERVER, "getAgencyBaseInfo", formDTO); + } + + @Override + public Result> getGridBaseInfo(GridBaseInfoFormDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.DATA_STATISTICAL_SERVER, "getGridBaseInfo", formDTO); + } + + @Override + public Result> getStaffBaseInfo(StaffBaseInfoFormDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.DATA_STATISTICAL_SERVER, "getStaffBaseInfo", formDTO); + } + + /** + * 根据巡查记录id 获取巡查主记录信息 + * + * @param midPatrolFormDTO + * @return + * @author yinzuomei + * @date 2021/9/10 8:56 上午 + */ + @Override + public Result> getPatrolRecordList(MidPatrolFormDTO midPatrolFormDTO) { + return ModuleUtils.feignConError(ServiceConstant.DATA_STATISTICAL_SERVER, "getPatrolRecordList", midPatrolFormDTO); + } + + /** + * 根据巡查记录id 获取巡查轨迹(明细)信息 + * + * @param midPatrolFormDTO + * @return + * @author yinzuomei + * @date 2021/9/10 8:56 上午 + */ + @Override + public Result> getPatrolDetailList(MidPatrolFormDTO midPatrolFormDTO) { + return ModuleUtils.feignConError(ServiceConstant.DATA_STATISTICAL_SERVER, "getPatrolDetailList", midPatrolFormDTO); + } + + /** + * 事件上报 + * + * @param formDTO + * @Param formDTO + * @Return {@link Result>} + * @Author zhaoqifeng + * @Date 2021/10/15 16:50 + */ + @Override + public Result> getEventInfo(EventInfoFormDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.DATA_STATISTICAL_SERVER, "getEventInfo", formDTO); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/pom.xml b/epmet-module/data-statistical/data-statistical-server/pom.xml index 714dfa2c01..4e19d8988d 100644 --- a/epmet-module/data-statistical/data-statistical-server/pom.xml +++ b/epmet-module/data-statistical/data-statistical-server/pom.xml @@ -116,6 +116,12 @@ 2.0.0 compile + + com.epmet + open-data-worker-client + 2.0.0 + compile + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DataReportingController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DataReportingController.java new file mode 100644 index 0000000000..d9de9bc1e1 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DataReportingController.java @@ -0,0 +1,105 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.dto.basereport.form.EventInfoFormDTO; +import com.epmet.dto.org.result.CustomerAgencyDTO; +import com.epmet.dto.org.result.CustomerGridDTO; +import com.epmet.dto.user.param.MidPatrolFormDTO; +import com.epmet.dto.user.result.GridUserInfoDTO; +import com.epmet.dto.user.result.MidPatrolDetailResult; +import com.epmet.dto.user.result.MidPatrolRecordResult; +import com.epmet.opendata.dto.BaseDisputeProcessDTO; +import com.epmet.opendata.dto.form.GridBaseInfoFormDTO; +import com.epmet.opendata.dto.form.StaffBaseInfoFormDTO; +import com.epmet.service.DataReportingService; +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; + +import java.util.List; + +/** + * @dscription 省网格化平台数据上报--数据查询 + * @author sun + */ +@RequestMapping("datareporting") +@RestController +public class DataReportingController { + @Autowired + private DataReportingService dataReportingService; + + /** + * @Author sun + * @Description 批量查询客户组织基础信息 + **/ + @PostMapping("agencybaseinfo") + public Result> getAgencyBaseInfo(@RequestBody(required = false) GridBaseInfoFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, GridBaseInfoFormDTO.Grid.class); + return new Result>().ok(dataReportingService.getAgencyBaseInfo(formDTO)); + } + + /** + * @Author sun + * @Description 批量查询客户网格基础信息 + **/ + @PostMapping("gridbaseinfo") + public Result> getGridBaseInfo(@RequestBody(required = false) GridBaseInfoFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, GridBaseInfoFormDTO.Grid.class); + return new Result>().ok(dataReportingService.getGridBaseInfo(formDTO)); + } + + /** + * @Author sun + * @Description 批量查询客户网格员基础信息 + **/ + @PostMapping("staffbaseinfo") + public Result> getStaffBaseInfo(@RequestBody(required = false) StaffBaseInfoFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, StaffBaseInfoFormDTO.Staff.class); + return new Result>().ok(dataReportingService.getStaffBaseInfo(formDTO)); + } + + + /** + * desc: 条件获取巡查主表信息 + * + * @param formDTO + * @return com.epmet.commons.tools.utils.Result> + * @author LiuJanJun + * @date 2021/10/15 12:01 下午 + */ + @PostMapping("getPatrolRecordList") + public Result> getPatrolRecordList(@RequestBody(required = false) MidPatrolFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, StaffBaseInfoFormDTO.Staff.class); + return new Result>().ok(dataReportingService.getPatrolRecordList(formDTO)); + } + + /** + * desc: 条件获取巡查明细信息 + * + * @param formDTO + * @return com.epmet.commons.tools.utils.Result> + * @author LiuJanJun + * @date 2021/10/15 12:01 下午 + */ + @PostMapping("getPatrolDetailList") + public Result> getPatrolDetailList(@RequestBody(required = false) MidPatrolFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, StaffBaseInfoFormDTO.Staff.class); + return new Result>().ok(dataReportingService.getPatrolDetailList(formDTO)); + } + + /** + * @Description 事件上报 + * @Param formDTO + * @Return {@link Result>} + * @Author zhaoqifeng + * @Date 2021/10/15 14:09 + */ + @PostMapping("eventinfo") + public Result> getEventInfo(@RequestBody(required = false) EventInfoFormDTO formDTO) { + return new Result>().ok(dataReportingService.getEventInfo(formDTO)); + } + +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerGridDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerGridDao.java index a2123a127f..84743c5a76 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerGridDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerGridDao.java @@ -23,7 +23,11 @@ import com.epmet.dto.group.result.AgencyGridTotalCountResultDTO; import com.epmet.dto.group.result.GridIdListByCustomerResultDTO; import com.epmet.dto.org.CustomerStaffGridDTO; import com.epmet.dto.org.GridInfoDTO; +import com.epmet.dto.org.result.CustomerGridDTO; +import com.epmet.dto.user.result.GridUserInfoDTO; import com.epmet.entity.org.CustomerGridEntity; +import com.epmet.opendata.dto.form.GridBaseInfoFormDTO; +import com.epmet.opendata.dto.form.StaffBaseInfoFormDTO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -95,4 +99,16 @@ public interface CustomerGridDao extends BaseDao { * @Description 查询客户已删除网格列表 **/ List selectDelGridList(@Param("customerId") String customerId); + + /** + * @Author sun + * @Description 批量查询客户网格基础信息 + **/ + List getGridBaseInfo(GridBaseInfoFormDTO formDTO); + + /** + * @Author sun + * @Description 查询工作人员所属网格信息 + **/ + List getStaffGrid(StaffBaseInfoFormDTO formDTO); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/StatsCustomerAgencyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/StatsCustomerAgencyDao.java index 5745ff7cca..d091e81711 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/StatsCustomerAgencyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/StatsCustomerAgencyDao.java @@ -2,9 +2,11 @@ package com.epmet.dao.org; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.AgencySubTreeDto; +import com.epmet.dto.org.result.CustomerAgencyDTO; import com.epmet.dto.org.result.CustomerAreaCodeResultDTO; import com.epmet.dto.org.result.OrgStaffDTO; import com.epmet.entity.org.CustomerAgencyEntity; +import com.epmet.opendata.dto.form.GridBaseInfoFormDTO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -71,4 +73,10 @@ public interface StatsCustomerAgencyDao extends BaseDao { CustomerAgencyEntity selectByDeptId(String deptId); CustomerAgencyEntity selecByAreaCode(@Param("customerId")String customerId, @Param("areaCode")String areaCode); + + /** + * @Author sun + * @Description 批量查询客户组织基础信息 + **/ + List getAgencyBaseInfo(GridBaseInfoFormDTO formDTO); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/UserDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/UserDao.java index 8e03a5abc2..fabf82d123 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/UserDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/UserDao.java @@ -5,8 +5,10 @@ import com.epmet.dto.extract.form.StaffPatrolStatsFormDTO; import com.epmet.dto.extract.result.UserPartyResultDTO; import com.epmet.dto.screen.ScreenProjectDataDTO; import com.epmet.dto.stats.form.GmUploadEventFormDTO; +import com.epmet.dto.user.param.MidPatrolFormDTO; import com.epmet.dto.user.result.*; import com.epmet.entity.evaluationindex.screen.ScreenPartyUserRankDataEntity; +import com.epmet.opendata.dto.form.StaffBaseInfoFormDTO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -252,5 +254,15 @@ public interface UserDao { * @author sun */ int saveOrUpGmUploadEvent(@Param("list") List list); + + /** + * @Author sun + * @Description 批量查询客户网格员基础信息 + **/ + List getStaffBaseInfo(StaffBaseInfoFormDTO formDTO); + + List getPatrolRecordList(MidPatrolFormDTO formDTO); + + List getPatrolDetailList(MidPatrolFormDTO formDTO); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenCustomerAgencyEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenCustomerAgencyEntity.java index ba06221d17..6bf9ea9e6f 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenCustomerAgencyEntity.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenCustomerAgencyEntity.java @@ -92,7 +92,7 @@ public class ScreenCustomerAgencyEntity extends BaseEpmetEntity { * 行政地区编码 */ private String areaCode; - + private String code; private String sourceType; /** diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenCustomerGridEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenCustomerGridEntity.java index 4a0d8e53c8..9de3701b58 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenCustomerGridEntity.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenCustomerGridEntity.java @@ -39,6 +39,7 @@ public class ScreenCustomerGridEntity extends BaseEpmetEntity { * 客户id */ private String customerId; + private String code; /** * 网格id diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenProjectDataEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenProjectDataEntity.java index ac4775c311..b53feaf6f6 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenProjectDataEntity.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenProjectDataEntity.java @@ -143,7 +143,7 @@ public class ScreenProjectDataEntity extends BaseEpmetEntity { /** * 结案日期 */ - private String closeCaseTime; + private Date closeCaseTime; /** * 数据更新至: yyyy|yyyMM|yyyyMMdd @@ -159,4 +159,5 @@ public class ScreenProjectDataEntity extends BaseEpmetEntity { * 满意度得分 */ private BigDecimal satisfactionScore; + } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/mq/ProjectChangedCustomListener.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/mq/ProjectChangedCustomListener.java index f62cfe09f8..1792654765 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/mq/ProjectChangedCustomListener.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/mq/ProjectChangedCustomListener.java @@ -1,8 +1,10 @@ package com.epmet.mq; import com.alibaba.fastjson.JSON; +import com.epmet.commons.rocketmq.constants.MQUserPropertys; import com.epmet.commons.rocketmq.messages.ProjectChangedMQMsg; 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; @@ -45,12 +47,18 @@ public class ProjectChangedCustomListener implements MessageListenerConcurrently @Override public ConsumeConcurrentlyStatus consumeMessage(List msgs, ConsumeConcurrentlyContext context) { + long start = System.currentTimeMillis(); try { - List msgStrs = msgs.stream().map(messageExt -> new String(messageExt.getBody())).distinct().collect(Collectors.toList()); - for (String msgStr : msgStrs) { - consumeMessage(msgStr); + //List msgStrs = msgs.stream().map(messageExt -> new String(messageExt.getBody())).distinct().collect(Collectors.toList()); + //for (String msgStr : msgStrs) { + // consumeMessage(msgStr); + //} + + for (MessageExt msgExt : msgs) { + consumeMessage(msgExt); } + } catch (Exception e) { //失败不重发 logger.error("consumeMessage fail,msg:{}",e.getMessage()); @@ -60,7 +68,10 @@ public class ProjectChangedCustomListener implements MessageListenerConcurrently return ConsumeConcurrentlyStatus.CONSUME_SUCCESS; } - private void consumeMessage(String msg) { + private void consumeMessage(MessageExt msgExt) { + String msg = new String(msgExt.getBody()); + String pendingMsgLabel = msgExt.getUserProperty(MQUserPropertys.BLOCKED_MSG_LABEL); + logger.info("receive customerId:{}", JSON.toJSONString(msg)); ProjectChangedMQMsg msgObj = JSON.parseObject(msg, ProjectChangedMQMsg.class); if (msgObj == null){ @@ -87,6 +98,14 @@ public class ProjectChangedCustomListener implements MessageListenerConcurrently } else { log.info("该客户的项目变动消息刚刚消费,请等待30秒,customer id:{}", msgObj.getCustomerId()); } + + if (org.apache.commons.lang.StringUtils.isNotBlank(pendingMsgLabel)) { + try { + removePendingMqMsgCache(pendingMsgLabel); + } catch (Exception e) { + logger.error("【项目变动事件监听器】-删除mq滞留消息缓存失败:{}", ExceptionUtils.getErrorStackTrace(e)); + } + } } public void consumeMessage(ProjectChangedMQMsg msgObj) { @@ -151,6 +170,20 @@ public class ProjectChangedCustomListener implements MessageListenerConcurrently } + /** + * @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("【项目变动事件监听器】删除mq阻塞消息缓存成功,penddingMsgLabel:{}", pendingMsgLabel); + } + /*@Override public ConsumerConfigProperties getConsumerProperty() { ConsumerConfigProperties configProperties = new ConsumerConfigProperties(); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/DataReportingService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/DataReportingService.java new file mode 100644 index 0000000000..bbaf18aa3c --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/DataReportingService.java @@ -0,0 +1,73 @@ +package com.epmet.service; + +import com.epmet.dto.basereport.form.EventInfoFormDTO; +import com.epmet.dto.basereport.result.EventInfoResultDTO; +import com.epmet.dto.org.result.CustomerAgencyDTO; +import com.epmet.dto.org.result.CustomerGridDTO; +import com.epmet.dto.user.param.MidPatrolFormDTO; +import com.epmet.dto.user.result.GridUserInfoDTO; +import com.epmet.dto.user.result.MidPatrolDetailResult; +import com.epmet.dto.user.result.MidPatrolRecordResult; +import com.epmet.opendata.dto.BaseDisputeProcessDTO; +import com.epmet.opendata.dto.form.GridBaseInfoFormDTO; +import com.epmet.opendata.dto.form.StaffBaseInfoFormDTO; + +import java.util.List; + +/** + * @dscription 省网格化平台数据上报--数据查询 + * @author sun + */ +public interface DataReportingService { + /** + * @Author sun + * @Description 批量查询客户组织基础信息 + * + * @return*/ + List getAgencyBaseInfo(GridBaseInfoFormDTO formDTO); + + /** + * @Author sun + * @Description 批量查询客户网格基础信息 + * + * @return*/ + List getGridBaseInfo(GridBaseInfoFormDTO formDTO); + + /** + * @Author sun + * @Description 批量查询客户网格员基础信息 + * + * @return*/ + List getStaffBaseInfo(StaffBaseInfoFormDTO formDTO); + + /** + * desc: 获取巡查记录列表 + * + * @param formDTO + * @return java.util.List + * @author LiuJanJun + * @date 2021/10/15 1:21 下午 + */ + List getPatrolRecordList(MidPatrolFormDTO formDTO); + + /** + * desc: 获取巡查明细列表 + * + * @param formDTO + * @return java.util.List + * @author LiuJanJun + * @date 2021/10/15 1:22 下午 + */ + List getPatrolDetailList(MidPatrolFormDTO formDTO); + + + /** + * 事件上报 + * @Param formDTO + * @Return {@link List} + * @Author zhaoqifeng + * @Date 2021/10/15 14:10 + */ + List getEventInfo(EventInfoFormDTO formDTO); + +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerAgencyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerAgencyService.java index 5ded177ae0..fcb81fc243 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerAgencyService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerAgencyService.java @@ -17,6 +17,7 @@ package com.epmet.service.evaluationindex.screen; +import com.epmet.commons.mybatis.service.BaseService; import com.epmet.dto.CustomerAgencyDTO; import com.epmet.dto.extract.form.PartyBaseInfoFormDTO; import com.epmet.dto.extract.form.ScreenPartyBranchDataFormDTO; @@ -35,7 +36,7 @@ import java.util.Map; * @author generator generator@elink-cn.com * @since v1.0.0 2020-09-22 */ -public interface ScreenCustomerAgencyService{ +public interface ScreenCustomerAgencyService extends BaseService { /** * @Description 根据agencyId,查询所有子级agencyId,【当机关的级别为 community时,所有子级为gridId】 @@ -137,5 +138,21 @@ public interface ScreenCustomerAgencyService{ * @author sun */ List getByCustomerId(String customerId); + /** + * @Description 根据ID获取组织 + * @Param agencyId + * @Return {@link ScreenCustomerAgencyEntity} + * @Author zhaoqifeng + * @Date 2021/10/15 15:44 + */ + ScreenCustomerAgencyEntity getAgencyById(String agencyId); + /** + * @Description 获取组织列表 + * @Param customerId + * @Return {@link Map< String, ScreenCustomerAgencyEntity>} + * @Author zhaoqifeng + * @Date 2021/10/15 15:44 + */ + Map getAgencyList(String customerId); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerGridService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerGridService.java index 1fb59aa3b5..bf701b81d3 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerGridService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerGridService.java @@ -28,6 +28,7 @@ import com.epmet.entity.evaluationindex.screen.ScreenCustomerGridEntity; import com.epmet.entity.org.CustomerGridEntity; import java.util.List; +import java.util.Map; /** * 网格(党支部)信息 @@ -111,4 +112,21 @@ public interface ScreenCustomerGridService extends BaseService selectGridInfoList(String customerId, String pids); List selectEntityByAgencyId(String customerId, String parentAgencyId); + + /** + * @Description 根据ID获取网格 + * @Param gridId + * @Return {@link ScreenCustomerGridDTO} + * @Author zhaoqifeng + * @Date 2021/10/15 15:50 + */ + ScreenCustomerGridDTO getGridById(String gridId); + /** + * @Description 获取网格列表 + * @Param customerId + * @Return {@link Map} + * @Author zhaoqifeng + * @Date 2021/10/15 15:50 + */ + Map getGridList(String customerId); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenProjectDataService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenProjectDataService.java index 7b82707c91..2cf68852db 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenProjectDataService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenProjectDataService.java @@ -127,4 +127,15 @@ public interface ScreenProjectDataService extends BaseService meta,List orient); int updateProjectSatisfactionScore(String projectId, BigDecimal calProjectSatisfactionScore); + + /** + * 获取项目 + * @Param customerId + * @Param projectId + * @Return {@link List} + * @Author zhaoqifeng + * @Date 2021/10/15 14:22 + */ + List getProjectList(String customerId, String projectId); + } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerAgencyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerAgencyServiceImpl.java index 16ba642e62..972d8ef961 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerAgencyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerAgencyServiceImpl.java @@ -17,7 +17,9 @@ package com.epmet.service.evaluationindex.screen.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.epmet.commons.dynamic.datasource.annotation.DataSource; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.utils.DateUtils; import com.epmet.constant.DataSourceConstant; @@ -36,13 +38,14 @@ import com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity; import com.epmet.entity.org.CustomerAgencyEntity; import com.epmet.service.evaluationindex.screen.ScreenCustomerAgencyService; 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.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; -import org.springframework.util.StringUtils; import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; /** @@ -54,7 +57,7 @@ import java.util.stream.Collectors; @Service @Slf4j @DataSource(DataSourceConstant.EVALUATION_INDEX) -public class ScreenCustomerAgencyServiceImpl implements ScreenCustomerAgencyService { +public class ScreenCustomerAgencyServiceImpl extends BaseServiceImpl implements ScreenCustomerAgencyService { @Autowired private ScreenCustomerAgencyDao screenCustomerAgencyDao; @@ -304,4 +307,30 @@ public class ScreenCustomerAgencyServiceImpl implements ScreenCustomerAgencyServ return screenCustomerAgencyDao.selectByCustomerId(customerId); } + @Override + public ScreenCustomerAgencyEntity getAgencyById(String agencyId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(ScreenCustomerAgencyEntity::getAgencyId, agencyId); + return baseDao.selectOne(wrapper); + } + + /** + * @param customerId + * @Description 获取组织列表 + * @Param customerId + * @Return {@link Map< String, ScreenCustomerAgencyEntity>} + * @Author zhaoqifeng + * @Date 2021/10/15 15:44 + */ + @Override + public Map getAgencyList(String customerId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(customerId), ScreenCustomerAgencyEntity::getAgencyId, customerId); + List list = baseDao.selectList(wrapper); + if (CollectionUtils.isEmpty(list)) { + return Collections.emptyMap(); + } + return list.stream().collect(Collectors.toMap(ScreenCustomerAgencyEntity::getAgencyId, Function.identity())); + } + } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerGridServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerGridServiceImpl.java index 1ae24e2d25..c87c58f7fd 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerGridServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerGridServiceImpl.java @@ -22,6 +22,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.DateUtils; import com.epmet.constant.DataSourceConstant; import com.epmet.constant.OrgSourceTypeConstant; @@ -34,15 +35,15 @@ import com.epmet.dto.screen.ScreenProjectGridDailyDTO; import com.epmet.entity.evaluationindex.screen.ScreenCustomerGridEntity; import com.epmet.entity.org.CustomerGridEntity; import com.epmet.service.evaluationindex.screen.ScreenCustomerGridService; +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.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; /** * 网格(党支部)信息 @@ -215,4 +216,36 @@ public class ScreenCustomerGridServiceImpl extends BaseServiceImpl selectEntityByAgencyId(String customerId, String parentAgencyId) { return baseDao.selectEntityByAgencyId(customerId,parentAgencyId); } + + /** + * @param gridId + * @Description 根据ID获取网格 + * @Param gridId + * @Return {@link ScreenCustomerGridDTO} + * @Author zhaoqifeng + * @Date 2021/10/15 15:50 + */ + @Override + public ScreenCustomerGridDTO getGridById(String gridId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(ScreenCustomerGridEntity::getGridId, gridId); + ScreenCustomerGridEntity entity = baseDao.selectOne(wrapper); + return ConvertUtils.sourceToTarget(entity, ScreenCustomerGridDTO.class); + } + + /** + * @param customerId + * @Description 获取网格列表 + * @Param customerId + * @Return {@link Map } + * @Author zhaoqifeng + * @Date 2021/10/15 15:50 + */ + @Override + public Map getGridList(String customerId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(customerId), ScreenCustomerGridEntity::getGridId, customerId); + List list = baseDao.selectList(wrapper); + return ConvertUtils.sourceToTarget(list, ScreenCustomerGridDTO.class).stream().collect(Collectors.toMap(ScreenCustomerGridDTO::getGridId, Function.identity())); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectDataServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectDataServiceImpl.java index 5e14db736e..10678a2fbc 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectDataServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectDataServiceImpl.java @@ -17,6 +17,7 @@ package com.epmet.service.evaluationindex.screen.impl; +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.epmet.commons.dynamic.datasource.annotation.DataSource; @@ -26,7 +27,8 @@ import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.constant.DataSourceConstant; -import com.epmet.dao.evaluationindex.screen.*; +import com.epmet.dao.evaluationindex.screen.ScreenProjectDataDao; +import com.epmet.dao.evaluationindex.screen.ScreenProjectImgDataDao; import com.epmet.dto.screen.ScreenProjectDataDTO; import com.epmet.dto.screen.form.ScreenProjectDataInfoFormDTO; import com.epmet.dto.screencoll.ScreenCollFormDTO; @@ -42,7 +44,6 @@ import org.springframework.util.CollectionUtils; import javax.annotation.Resource; import java.math.BigDecimal; -import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Date; @@ -134,22 +135,18 @@ public class ScreenProjectDataServiceImpl extends BaseServiceImpl} + * @Author zhaoqifeng + * @Date 2021/10/15 14:22 + */ + @Override + public List getProjectList(String customerId, String projectId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(customerId), ScreenProjectDataEntity::getCustomerId, customerId); + wrapper.eq(StringUtils.isNotBlank(projectId), ScreenProjectDataEntity::getProjectId, projectId); + wrapper.ne(ScreenProjectDataEntity::getCategoryCode, null); + wrapper.ne(ScreenProjectDataEntity::getCategoryCode, ""); + List list = baseDao.selectList(wrapper); + return ConvertUtils.sourceToTarget(list, ScreenProjectDataDTO.class); + } + } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/DataReportingServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/DataReportingServiceImpl.java new file mode 100644 index 0000000000..26b125af39 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/DataReportingServiceImpl.java @@ -0,0 +1,235 @@ +package com.epmet.service.impl; + +import com.epmet.commons.tools.constant.StrConstant; +import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.constant.OrgTypeConstant; +import com.epmet.constant.ProjectConstant; +import com.epmet.dto.basereport.form.EventInfoFormDTO; +import com.epmet.dto.org.result.CustomerAgencyDTO; +import com.epmet.dto.org.result.CustomerGridDTO; +import com.epmet.dto.screen.ScreenCustomerGridDTO; +import com.epmet.dto.screen.ScreenProjectDataDTO; +import com.epmet.dto.user.param.MidPatrolFormDTO; +import com.epmet.dto.user.result.CustomerStaffDTO; +import com.epmet.dto.user.result.GridUserInfoDTO; +import com.epmet.dto.user.result.MidPatrolDetailResult; +import com.epmet.dto.user.result.MidPatrolRecordResult; +import com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity; +import com.epmet.entity.stats.CustomerProjectCategoryDictEntity; +import com.epmet.opendata.dto.BaseDisputeProcessDTO; +import com.epmet.opendata.dto.form.GridBaseInfoFormDTO; +import com.epmet.opendata.dto.form.StaffBaseInfoFormDTO; +import com.epmet.service.DataReportingService; +import com.epmet.service.evaluationindex.screen.ScreenCustomerAgencyService; +import com.epmet.service.evaluationindex.screen.ScreenCustomerGridService; +import com.epmet.service.evaluationindex.screen.ScreenProjectDataService; +import com.epmet.service.org.CustomerAgencyService; +import com.epmet.service.org.CustomerGridService; +import com.epmet.service.stats.CustomerProjectCategoryDictService; +import com.epmet.service.user.StatsStaffPatrolService; +import com.epmet.service.user.UserService; +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 javax.annotation.Resource; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @dscription 省网格化平台数据上报--数据查询 + * @author sun + */ +@Slf4j +@Service +public class DataReportingServiceImpl implements DataReportingService { + @Autowired + private CustomerAgencyService customerAgencyService; + @Autowired + private CustomerGridService customerGridService; + @Autowired + private UserService userService; + @Resource + private ScreenProjectDataService screenProjectDataService; + @Resource + private ScreenCustomerAgencyService screenCustomerAgencyService; + @Resource + private ScreenCustomerGridService screenCustomerGridService; + @Autowired + private StatsStaffPatrolService statsStaffPatrolService; + @Resource + private CustomerProjectCategoryDictService customerProjectCategoryDictService; + + /** + * @Author sun + * @Description 批量查询客户组织基础信息 + **/ + @Override + public List getAgencyBaseInfo(GridBaseInfoFormDTO formDTO) { + //批量查询客户组织信息 + List resultList = customerAgencyService.getAgencyBaseInfo(formDTO); + return resultList; + } + + /** + * @Author sun + * @Description 批量查询客户网格基础信息 + **/ + @Override + public List getGridBaseInfo(GridBaseInfoFormDTO formDTO) { + //批量查询客户网格信息 + List resultList = customerGridService.getGridBaseInfo(formDTO); + return resultList; + } + + /** + * @Author sun + * @Description 批量查询客户网格员基础信息 + **/ + @Override + public List getStaffBaseInfo(StaffBaseInfoFormDTO formDTO) { + //1.查询工作人员所属网格信息 + List resultList = customerGridService.getStaffGrid(formDTO); + + //2.查询工作人员基础信息 + List staffDTOList = userService.getStaffBaseInfo(formDTO); + if (CollectionUtils.isEmpty(staffDTOList)) { + return new ArrayList<>(); + } + Map staffMap = new HashMap<>(); + staffDTOList.forEach(staff -> staffMap.put(staff.getUserId(), staff)); + + //3.封装数据 + resultList.forEach(st -> { + if (staffMap.containsKey(st.getStaffId())) { + CustomerStaffDTO dto = staffMap.get(st.getStaffId()); + st.setNickName(dto.getRealName()); + st.setCardNum("01"); + st.setUserType(dto.getWorkType().equals("fulltime") ? "01" : "02"); + st.setPhonenumber(dto.getMobile()); + st.setSex(0 == dto.getGender() ? "9" : dto.getGender().toString()); + st.setNation("01"); + st.setPaerty("13"); + st.setBirthday(new Date()); + st.setEducation("20"); + st.setEntryDate(new Date()); + st.setIsLeave("N"); + //st.setLeaveDate(); + st.setIncome("05"); + st.setIsCommittee("Y"); + st.setIsCommunityWorkers("Y"); + st.setIsSocialWorker("Y"); + st.setIsVillageLeader("Y"); + st.setIsPoliceAssistant("N"); + st.setIsMediator("Y"); + st.setDelFlag(dto.getDelFlag()); + st.setCreatedBy(dto.getCreatedBy()); + st.setCreatedTime(dto.getCreatedTime()); + st.setUpdatedBy(dto.getUpdatedBy()); + st.setUpdatedTime(dto.getUpdatedTime()); + } + }); + + return resultList; + } + + /** + * 事件上报 + * + * @param formDTO + * @Param formDTO + * @Return {@link List} + * @Author zhaoqifeng + * @Date 2021/10/15 14:10 + */ + @Override + public List getEventInfo(EventInfoFormDTO formDTO) { + List list; + //根据入参,获取项目 + List projectList = screenProjectDataService.getProjectList(formDTO.getCustomerId(), formDTO.getProjectId()); + //项目列表为空,返回空数组 + if(CollectionUtils.isEmpty(projectList)) { + return Collections.emptyList(); + } + //项目ID不为空时,因为只有一条,可以直接处理 + if (StringUtils.isNotEmpty(formDTO.getProjectId())) { + list = projectList.stream().map(project -> { + BaseDisputeProcessDTO dto = getBaseDisputeProcessDTO(project); + if (OrgTypeConstant.AGENCY.equals(project.getOrgType())) { + ScreenCustomerAgencyEntity agency = screenCustomerAgencyService.getAgencyById(project.getOrgId()); + dto.setOrgCode(agency.getCode()); + dto.setOrgName(agency.getAgencyName()); + } else { + ScreenCustomerGridDTO grid = screenCustomerGridService.getGridById(project.getOrgId()); + dto.setOrgCode(grid.getCode()); + dto.setOrgName(grid.getGridName()); + } + return dto; + }).collect(Collectors.toList()); + } else { + //项目ID不为空时,提前取出客户下的组织和网格 + Map agencyMap = screenCustomerAgencyService.getAgencyList(formDTO.getCustomerId()); + Map gridMap = screenCustomerGridService.getGridList(formDTO.getCustomerId()); + list = projectList.stream().map(project -> { + BaseDisputeProcessDTO dto = getBaseDisputeProcessDTO(project); + if (OrgTypeConstant.AGENCY.equals(project.getOrgType())) { + ScreenCustomerAgencyEntity agency = agencyMap.get(project.getOrgId()); + dto.setOrgCode(agency.getCode()); + dto.setOrgName(agency.getAgencyName()); + } else { + ScreenCustomerGridDTO grid = gridMap.get(project.getOrgId()); + dto.setOrgCode(grid.getCode()); + dto.setOrgName(grid.getGridName()); + } + return dto; + }).collect(Collectors.toList()); + } + return list.stream().filter(item -> StringUtils.isNotBlank(item.getEventCategory())).collect(Collectors.toList()); + } + + private BaseDisputeProcessDTO getBaseDisputeProcessDTO(ScreenProjectDataDTO project) { + BaseDisputeProcessDTO dto = new BaseDisputeProcessDTO(); + dto.setId(project.getProjectId()); + dto.setCustomerId(project.getCustomerId()); + dto.setEventName(project.getProjectTitle()); + String categoryCode = project.getCategoryCode().split(StrConstant.COMMA)[0]; + //如果是孔村、榆山、锦水的项目需要关联分类字典表 + if("2fe0065f70ca0e23ce4c26fca5f1d933".equals(project.getCustomerId()) || + "44876154d10d7cb7affd92000f84f833".equals(project.getCustomerId()) || + "46c55cb862d6d5e6d05d2ab61a1cc07e".equals(project.getCustomerId())) { + CustomerProjectCategoryDictEntity categoryEntity = customerProjectCategoryDictService.getByCategoryCode(project.getCustomerId(), categoryCode); + if (null != categoryEntity) { + categoryCode = categoryEntity.getEpmetCategoryCode(); + } else { + categoryCode = null; + } + } + dto.setReportTime(project.getProjectCreateTime()); + dto.setHappenDate(DateUtils.parseDate(DateUtils.format(project.getProjectCreateTime()), DateUtils.DATE_PATTERN)); + dto.setEventDescription(project.getProjectContent()); + //TODO 办结方式 + dto.setWaysOfResolving("01"); + dto.setSuccessfulOrNo(ProjectConstant.CLOSED_CASE.equals(project.getProjectStatusCode())?"Y":"N"); + //TODO 办结层级 + dto.setCompleteLevel("01"); + dto.setCompleteTime(project.getCloseCaseTime()); + dto.setLat(project.getLatitude()); + dto.setLng(project.getLongitude()); + return dto; + } + + + + @Override + public List getPatrolRecordList(MidPatrolFormDTO formDTO) { + return userService.getPatrolRecordList(formDTO); + } + + @Override + public List getPatrolDetailList(MidPatrolFormDTO formDTO) { + return userService.getPatrolDetailList(formDTO); + } + +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerAgencyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerAgencyService.java index 60991b69bf..490e598aff 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerAgencyService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerAgencyService.java @@ -1,8 +1,10 @@ package com.epmet.service.org; +import com.epmet.dto.org.result.CustomerAgencyDTO; import com.epmet.dto.org.result.CustomerAreaCodeResultDTO; import com.epmet.dto.org.result.OrgStaffDTO; import com.epmet.entity.org.CustomerAgencyEntity; +import com.epmet.opendata.dto.form.GridBaseInfoFormDTO; import java.util.Date; import java.util.List; @@ -58,4 +60,9 @@ public interface CustomerAgencyService { */ void sysAgencyInfo(String fromCustomerId, String toCustomerId); + /** + * @Author sun + * @Description 批量查询客户组织基础信息 + **/ + List getAgencyBaseInfo(GridBaseInfoFormDTO formDTO); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerGridService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerGridService.java index 2da4de7518..a0d6fb449d 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerGridService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerGridService.java @@ -6,7 +6,11 @@ import com.epmet.dto.group.result.AgencyGridTotalCountResultDTO; import com.epmet.dto.group.result.GridIdListByCustomerResultDTO; import com.epmet.dto.org.CustomerStaffGridDTO; import com.epmet.dto.org.GridInfoDTO; +import com.epmet.dto.org.result.CustomerGridDTO; +import com.epmet.dto.user.result.GridUserInfoDTO; import com.epmet.entity.org.CustomerGridEntity; +import com.epmet.opendata.dto.form.GridBaseInfoFormDTO; +import com.epmet.opendata.dto.form.StaffBaseInfoFormDTO; import java.util.Date; import java.util.List; @@ -77,4 +81,15 @@ public interface CustomerGridService extends BaseService { **/ List getdelGridProjectIdList(String customerId); + /** + * @Author sun + * @Description 批量查询客户网格基础信息 + **/ + List getGridBaseInfo(GridBaseInfoFormDTO formDTO); + + /** + * @Author sun + * @Description 查询工作人员所属网格信息 + **/ + List getStaffGrid(StaffBaseInfoFormDTO formDTO); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerAgencyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerAgencyServiceImpl.java index 66ea3b4b37..86ef831a2f 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerAgencyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerAgencyServiceImpl.java @@ -5,12 +5,14 @@ import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.constant.DataSourceConstant; import com.epmet.dao.org.StatsCustomerAgencyDao; +import com.epmet.dto.org.result.CustomerAgencyDTO; import com.epmet.dto.org.result.CustomerAreaCodeResultDTO; import com.epmet.dto.org.result.OrgStaffDTO; import com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity; import com.epmet.entity.evaluationindex.screen.ScreenCustomerGridEntity; import com.epmet.entity.org.CustomerAgencyEntity; import com.epmet.entity.org.CustomerGridEntity; +import com.epmet.opendata.dto.form.GridBaseInfoFormDTO; import com.epmet.service.evaluationindex.screen.ScreenCustomerAgencyService; import com.epmet.service.evaluationindex.screen.ScreenCustomerGridService; import com.epmet.service.org.CustomerAgencyService; @@ -271,4 +273,14 @@ public class CustomerAgencyServiceImpl implements CustomerAgencyService { } } } + + /** + * @Author sun + * @Description 批量查询客户组织基础信息 + **/ + @Override + public List getAgencyBaseInfo(GridBaseInfoFormDTO formDTO) { + return customerAgencyDao.getAgencyBaseInfo(formDTO); + } + } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerGridServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerGridServiceImpl.java index 4d4ab8bee0..3a74f81639 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerGridServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerGridServiceImpl.java @@ -10,7 +10,11 @@ import com.epmet.dto.group.result.AgencyGridTotalCountResultDTO; import com.epmet.dto.group.result.GridIdListByCustomerResultDTO; import com.epmet.dto.org.CustomerStaffGridDTO; import com.epmet.dto.org.GridInfoDTO; +import com.epmet.dto.org.result.CustomerGridDTO; +import com.epmet.dto.user.result.GridUserInfoDTO; import com.epmet.entity.org.CustomerGridEntity; +import com.epmet.opendata.dto.form.GridBaseInfoFormDTO; +import com.epmet.opendata.dto.form.StaffBaseInfoFormDTO; import com.epmet.service.Issue.IssueService; import com.epmet.service.org.CustomerGridService; import org.springframework.beans.factory.annotation.Autowired; @@ -115,4 +119,22 @@ public class CustomerGridServiceImpl extends BaseServiceImpl getGridBaseInfo(GridBaseInfoFormDTO formDTO) { + return customerGridDao.getGridBaseInfo(formDTO); + } + + /** + * @Author sun + * @Description 查询工作人员所属网格信息 + **/ + @Override + public List getStaffGrid(StaffBaseInfoFormDTO formDTO) { + return customerGridDao.getStaffGrid(formDTO); + } + } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/impl/ProjectProcessServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/impl/ProjectProcessServiceImpl.java index d16db0530e..a71c61bfbd 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/impl/ProjectProcessServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/impl/ProjectProcessServiceImpl.java @@ -20,7 +20,6 @@ package com.epmet.service.project.impl; import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.NumConstant; -import com.epmet.commons.tools.utils.DateUtils; import com.epmet.constant.DataSourceConstant; import com.epmet.dao.project.ProjectProcessDao; import com.epmet.dto.ProjectProcessDTO; @@ -40,7 +39,9 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; -import java.util.*; +import java.util.Collections; +import java.util.List; +import java.util.Map; import java.util.stream.Collectors; /** @@ -144,7 +145,7 @@ public class ProjectProcessServiceImpl extends BaseServiceImpl closedInfo.stream().filter(closedCase -> StringUtils.equals(closedCase.getProjectId(),target.getProjectId())).map( merge -> { target.setProjectStatusCode("closed_case"); - target.setCloseCaseTime(DateUtils.format(merge.getCreatedTime(),DateUtils.DATE_TIME_PATTERN)); + target.setCloseCaseTime(merge.getCreatedTime()); return target; } )).collect(Collectors.toList()); @@ -166,7 +167,7 @@ public class ProjectProcessServiceImpl extends BaseServiceImpl closedInfo.stream().filter(closedCase -> StringUtils.equals(closedCase.getProjectId(),target.getProjectId())).map( merge -> { //target.setProjectStatusCode("closed_case"); - target.setCloseCaseTime(DateUtils.format(merge.getCreatedTime(),DateUtils.DATE_TIME_PATTERN)); + target.setCloseCaseTime(merge.getCreatedTime()); return target; } )).collect(Collectors.toList()); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/CustomerProjectCategoryDictService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/CustomerProjectCategoryDictService.java index ef8440c594..cc8633b08f 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/CustomerProjectCategoryDictService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/CustomerProjectCategoryDictService.java @@ -55,4 +55,14 @@ public interface CustomerProjectCategoryDictService extends BaseService formDTO); + + /** + * @Description 获取分类信息 + * @Param customerId + * @Param categoryCode + * @Return {@link CustomerProjectCategoryDictEntity} + * @Author zhaoqifeng + * @Date 2021/10/15 16:33 + */ + CustomerProjectCategoryDictEntity getByCategoryCode(String customerId, String categoryCode); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/CustomerProjectCategoryDictServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/CustomerProjectCategoryDictServiceImpl.java index 97a8a560f5..d7c81c93ad 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/CustomerProjectCategoryDictServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/CustomerProjectCategoryDictServiceImpl.java @@ -17,6 +17,7 @@ package com.epmet.service.stats.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.NumConstant; @@ -116,4 +117,22 @@ public class CustomerProjectCategoryDictServiceImpl extends BaseServiceImpl wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(CustomerProjectCategoryDictEntity::getCategoryCode, categoryCode); + wrapper.eq(CustomerProjectCategoryDictEntity::getCustomerId, customerId); + return baseDao.selectOne(wrapper); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/UserService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/UserService.java index f45809be94..cf98bb6c18 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/UserService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/UserService.java @@ -7,11 +7,10 @@ import com.epmet.dto.org.result.OrgStaffDTO; import com.epmet.dto.screen.ScreenProjectDataDTO; import com.epmet.dto.stats.form.GmUploadEventFormDTO; import com.epmet.dto.stats.user.result.UserStatisticalData; -import com.epmet.dto.user.result.StaffRoleInfoDTO; -import com.epmet.dto.user.result.CustomerStaffDTO; -import com.epmet.dto.user.result.StaffPatrolRecordResult; -import com.epmet.dto.user.result.StatsStaffPatrolRecordDailyDTO; +import com.epmet.dto.user.param.MidPatrolFormDTO; +import com.epmet.dto.user.result.*; import com.epmet.entity.evaluationindex.screen.ScreenPartyUserRankDataEntity; +import com.epmet.opendata.dto.form.StaffBaseInfoFormDTO; import com.epmet.util.DimIdGenerator; import java.util.Date; @@ -137,4 +136,14 @@ public interface UserService { * @author sun */ void saveOrUpGmUploadEvent(List list); + + /** + * @Author sun + * @Description 批量查询客户网格员基础信息 + **/ + List getStaffBaseInfo(StaffBaseInfoFormDTO formDTO); + + List getPatrolRecordList(MidPatrolFormDTO formDTO); + + List getPatrolDetailList(MidPatrolFormDTO formDTO); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java index 95c7c333ff..f6dc980302 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java @@ -17,8 +17,10 @@ import com.epmet.dto.screen.ScreenProjectDataDTO; import com.epmet.dto.stats.form.GmUploadEventFormDTO; import com.epmet.dto.stats.user.*; import com.epmet.dto.stats.user.result.UserStatisticalData; +import com.epmet.dto.user.param.MidPatrolFormDTO; import com.epmet.dto.user.result.*; import com.epmet.entity.evaluationindex.screen.ScreenPartyUserRankDataEntity; +import com.epmet.opendata.dto.form.StaffBaseInfoFormDTO; import com.epmet.service.user.UserService; import com.epmet.util.DimIdGenerator; import com.epmet.util.ModuleConstant; @@ -1088,4 +1090,23 @@ public class UserServiceImpl implements UserService { userDao.saveOrUpGmUploadEvent(list); } + /** + * @Author sun + * @Description 批量查询客户网格员基础信息 + **/ + @Override + public List getStaffBaseInfo(StaffBaseInfoFormDTO formDTO) { + return userDao.getStaffBaseInfo(formDTO); + } + + @Override + public List getPatrolRecordList(MidPatrolFormDTO formDTO) { + return userDao.getPatrolRecordList(formDTO); + } + + @Override + public List getPatrolDetailList(MidPatrolFormDTO formDTO) { + return userDao.getPatrolDetailList(formDTO); + } + } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml index d84d884cb3..5d637d31de 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml @@ -126,4 +126,41 @@ AND customer_id = #{customerId} + + + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/StatsCustomerAgencyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/StatsCustomerAgencyDao.xml index f7fe07a1a8..e1e4d79131 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/StatsCustomerAgencyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/StatsCustomerAgencyDao.xml @@ -203,4 +203,22 @@ AND ca.CUSTOMER_ID = #{customerId} AND ca.AREA_CODE = #{areaCode} + + + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml index f6ddac0fef..4715f23c2a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml @@ -991,4 +991,66 @@ updated_time = NOW() + + + + diff --git a/epmet-module/epmet-job/epmet-job-server/pom.xml b/epmet-module/epmet-job/epmet-job-server/pom.xml index e29f5759e5..769cfab32a 100644 --- a/epmet-module/epmet-job/epmet-job-server/pom.xml +++ b/epmet-module/epmet-job/epmet-job-server/pom.xml @@ -38,6 +38,11 @@ epmet-third-client 2.0.0 + + com.epmet + epmet-message-client + 2.0.0 + org.springframework.boot spring-boot-starter-web diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/SystemMessageScannerService.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/SystemMessageScannerService.java new file mode 100644 index 0000000000..3316aef52a --- /dev/null +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/SystemMessageScannerService.java @@ -0,0 +1,23 @@ +package com.epmet.service; + +public interface SystemMessageScannerService { + /** + * @description 扫描未成功发送到MQ的消息 + * + * @param + * @return + * @author wxz + * @date 2021.10.16 23:24:05 + */ + void scanPenddingSystemMQMessage(); + + /** + * @description 扫描发送成功但是未正常处理的MQ的消息 + * + * @param + * @return + * @author wxz + * @date 2021.10.16 23:24:27 + */ + void scanBlockedSystemMQMessage(); +} diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/SystemMessageScannerServiceImpl.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/SystemMessageScannerServiceImpl.java new file mode 100644 index 0000000000..f47ba3ec39 --- /dev/null +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/SystemMessageScannerServiceImpl.java @@ -0,0 +1,22 @@ +package com.epmet.service; + +import com.epmet.feign.EpmetMessageOpenFeignClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class SystemMessageScannerServiceImpl implements SystemMessageScannerService { + + @Autowired + private EpmetMessageOpenFeignClient messageOpenFeignClient; + + @Override + public void scanPenddingSystemMQMessage() { + messageOpenFeignClient.penddingMqMsgScan(); + } + + @Override + public void scanBlockedSystemMQMessage() { + messageOpenFeignClient.blockedMqMsgScan(); + } +} diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/BlockedMQSystemMessageScanner.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/BlockedMQSystemMessageScanner.java new file mode 100644 index 0000000000..6840b15eaa --- /dev/null +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/BlockedMQSystemMessageScanner.java @@ -0,0 +1,25 @@ +package com.epmet.task; + +import com.epmet.service.SystemMessageScannerService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component("blockedMQSystemMessageScanner") +@Slf4j +public class BlockedMQSystemMessageScanner implements ITask { + + @Autowired + private SystemMessageScannerService systemMessageScannerService; + + @Override + public void run(String params) { + try { + //log.info("【blockedMQSystemMessageScanner】开始执行scanBlockedSystemMQMessage任务"); + systemMessageScannerService.scanBlockedSystemMQMessage(); + log.info("【blockedMQSystemMessageScanner】执行scanBlockedSystemMQMessage任务完成"); + } catch (Exception e) { + log.error("【blockedMQSystemMessageScanner】执行scanBlockedSystemMQMessage任务失败"); + } + } +} diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/PenddingMQSystemMessageScanner.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/PenddingMQSystemMessageScanner.java new file mode 100644 index 0000000000..f4b24f2cb6 --- /dev/null +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/PenddingMQSystemMessageScanner.java @@ -0,0 +1,25 @@ +package com.epmet.task; + +import com.epmet.service.SystemMessageScannerService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component("penddingMQSystemMessageScanner") +@Slf4j +public class PenddingMQSystemMessageScanner implements ITask { + + @Autowired + private SystemMessageScannerService systemMessageScannerService; + + @Override + public void run(String params) { + try { + //log.info("【blockedMQSystemMessageScanner】开始执行scanBlockedSystemMQMessage任务"); + systemMessageScannerService.scanPenddingSystemMQMessage(); + log.info("【blockedMQSystemMessageScanner】执行scanPenddingSystemMQMessage任务完成"); + } catch (Exception e) { + log.error("【blockedMQSystemMessageScanner】执行scanPenddingSystemMQMessage任务失败"); + } + } +} 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 626b081436..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 @@ -25,4 +25,54 @@ public interface SystemMessageType { */ String POINT_RULE_CHANGED = "point_rule_changed"; + /** + * 网格新增 + */ + String GRID_CREATE = "grid_create"; + + /** + * 网格信息变更 + */ + String GRID_CHANGE = "grid_change"; + + /** + * agency机构新增 + */ + String AGENCY_CREATE = "agency_create"; + + /** + * agency机构信息变更 + */ + String AGENCY_CHANGE = "agency_change"; + + /** + * 部门新增 + */ + String DEPARTMENT_CREATE = "department_create"; + + /** + * 部门信息变更 + */ + String DEPARTMENT_CHANGE = "department_change"; + + /** + * 工作人员新增 + */ + String STAFF_CREATE = "staff_create"; + + /** + * 工作人员变更 + */ + 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/dto/form/SystemMsgFormDTO.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/SystemMsgFormDTO.java index c0fc9308b8..c0fb1400e9 100644 --- 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 @@ -7,9 +7,18 @@ import javax.validation.constraints.NotNull; @Data public class SystemMsgFormDTO { - @NotNull(message = "消息类型不能为空") + // 发送mq消息分组 + public interface SendMsgByMQ {} + + // 应答mq消息 + public interface AckMsgByMQ {} + + @NotNull(message = "消息类型不能为空", groups = { SendMsgByMQ.class }) private String messageType; - @NotNull(message = "消息内容不能为空") + @NotNull(message = "消息内容不能为空", groups = { SendMsgByMQ.class }) private Object content; + + @NotNull(message = "pendingMsgLabel不能为空", groups = { AckMsgByMQ.class }) + private String pendingMsgLabel; } 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 f375d75aaf..b3681a0b33 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 @@ -27,7 +27,7 @@ import java.util.List; * @author yinzuomei@elink-cn.com * @date 2020/6/4 13:47 */ -//@FeignClient(name = ServiceConstant.EPMET_MESSAGE_SERVER, fallback = EpmetMessageOpenFeignClientFallback.class,url = "http://127.0.0.1:8085") +//@FeignClient(name = ServiceConstant.EPMET_MESSAGE_SERVER, fallbackFactory = EpmetMessageOpenFeignClientFallbackFactory.class, url = "http://127.0.0.1:8085") @FeignClient(name = ServiceConstant.EPMET_MESSAGE_SERVER, fallbackFactory = EpmetMessageOpenFeignClientFallbackFactory.class) public interface EpmetMessageOpenFeignClient { /** @@ -107,4 +107,26 @@ public interface EpmetMessageOpenFeignClient { */ @PostMapping("/message/system/send-by-mq") Result sendSystemMsgByMQ(@RequestBody SystemMsgFormDTO form); + + /** + * @description 检查MQ阻塞消息(MQ收到消息,但是往监听者发送消息或者监听者处理逻辑问题导致无法消费消息) + * + * @param + * @return + * @author wxz + * @date 2021.10.16 22:07:38 + */ + @PostMapping("/message/system/blocked-mq-msg-scan") + Result blockedMqMsgScan(); + + /** + * @description 检查MQ滞留消息(往MQ发送消息失败,MQ未收到消息) + * + * @param + * @return + * @author wxz + * @date 2021.10.16 22:08:32 + */ + @PostMapping("/message/system/pendding-mq-msg-scan") + Result penddingMqMsgScan(); } 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 069d76c795..d9a044d73d 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 @@ -69,4 +69,14 @@ public class EpmetMessageOpenFeignClientFallback implements EpmetMessageOpenFeig public Result sendSystemMsgByMQ(SystemMsgFormDTO form) { return ModuleUtils.feignConError(ServiceConstant.EPMET_MESSAGE_SERVER, "sendSystemMsgByMQ", form); } + + @Override + public Result blockedMqMsgScan() { + return ModuleUtils.feignConError(ServiceConstant.EPMET_MESSAGE_SERVER, "blockedMqMsgScan"); + } + + @Override + public Result penddingMqMsgScan() { + return ModuleUtils.feignConError(ServiceConstant.EPMET_MESSAGE_SERVER, "penddingMqMsgScan"); + } } 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..551bb9d4ec 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,7 @@ package com.epmet.send; import com.alibaba.fastjson.JSON; -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.*; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.utils.Result; import com.epmet.constant.SystemMessageType; @@ -128,4 +126,60 @@ public class SendMqMsgUtil { } + /** + * @Description 发送巡查相关消息 + * @return + * @author wxz + * @date 2021.06.21 12:46 + */ + public boolean sendPatrolMqMsg(StaffPatrolMQMsg msg,String messageType) { + try { + SystemMsgFormDTO msgForm = new SystemMsgFormDTO(); + msgForm.setMessageType(messageType); + 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; + + } + + /** + * @Description 组织、网格、人员中间库信息同步Mq + * @author sun + */ + public boolean sendOrgStaffMqMsg(OrgOrStaffMQMsg msg) { + try { + SystemMsgFormDTO msgForm = new SystemMsgFormDTO(); + msgForm.setMessageType(msg.getType()); + msgForm.setContent(msg); + Result sendMsgResult; + log.info("sendOrgStaffMqMsg 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("sendOrgStaffMqMsg exception", e); + } + return false; + + } + } 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 index 7a31e91785..8c1ea726cd 100644 --- 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 @@ -17,10 +17,46 @@ public class SystemMessageController { @Autowired private SystemMessageService systemMessageService; + /** + * @description 发送mq消息 + * + * @param form + * @return + * @author wxz + * @date 2021.10.14 16:07:07 + */ @PostMapping("send-by-mq") public Result sendSystemMsgByMQ(@RequestBody SystemMsgFormDTO form) { - ValidatorUtils.validateEntity(form); - systemMessageService.sendMQMessage(form.getMessageType(), form.getContent()); + ValidatorUtils.validateEntity(form, SystemMsgFormDTO.SendMsgByMQ.class); + systemMessageService.persistAndSendMQMessage(form.getMessageType(), form.getContent()); + return new Result(); + } + + /** + * @description 检查MQ阻塞消息(MQ收到消息,但是往监听者发送消息或者监听者处理逻辑问题导致无法消费消息) + * + * @param + * @return + * @author wxz + * @date 2021.10.16 22:07:38 + */ + @PostMapping("blocked-mq-msg-scan") + public Result blockedMqMsgScan() { + systemMessageService.blockedMqMsgScan(); + return new Result(); + } + + /** + * @description 检查MQ滞留消息(往MQ发送消息失败,MQ未收到消息) + * + * @param + * @return + * @author wxz + * @date 2021.10.16 22:08:32 + */ + @PostMapping("pendding-mq-msg-scan") + public Result penddingMqMsgScan() { + systemMessageService.penddingMqMsgScan(); return new Result(); } diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/SystemMessagePenddingDao.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/SystemMessagePenddingDao.java new file mode 100644 index 0000000000..57ba0d3afb --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/SystemMessagePenddingDao.java @@ -0,0 +1,35 @@ +/** + * 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.SystemMessagePenddingEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * 系统消息表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-16 + */ +@Mapper +public interface SystemMessagePenddingDao extends BaseDao { + + void physicalDeleteById(@Param("penddingId") String penddingId); +} \ No newline at end of file diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/SystemMessagePenddingEntity.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/SystemMessagePenddingEntity.java new file mode 100644 index 0000000000..87a7956504 --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/SystemMessagePenddingEntity.java @@ -0,0 +1,61 @@ +/** + * 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 java.util.Date; + +/** + * 系统消息表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-16 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("system_message_pendding") +public class SystemMessagePenddingEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 消息类型。init_customer:客户初始化,login登录,logout退出 + */ + private String msgType; + + /** + * 消息主表id + */ + private String msgId; + + /** + * 消息发送途径 + */ + 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 index 2985b550c9..64e34527d1 100644 --- 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 @@ -2,6 +2,34 @@ package com.epmet.service; public interface SystemMessageService { - void sendMQMessage(String messageType, Object content); + /** + * @description 持久化和发送mq消息 + * + * @param messageType + * @param content + * @return + * @author wxz + * @date 2021.10.14 15:07:02 + */ + void persistAndSendMQMessage(String messageType, Object content); + /** + * @description 扫描阻塞的消息 + * + * @param + * @return + * @author wxz + * @date 2021.10.15 10:13:37 + */ + void blockedMqMsgScan(); + + /** + * @description 扫描待办的消息(因为发送到MQ失败而堆积) + * + * @param + * @return + * @author wxz + * @date 2021.10.16 12:11:39 + */ + void penddingMqMsgScan(); } 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 9c56520419..dfd6737b57 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,16 +2,23 @@ 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.MQUserPropertys; 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.commons.tools.redis.RedisKeys; +import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.constant.SystemMessageSendApproach; import com.epmet.constant.SystemMessageType; import com.epmet.dao.SystemMessageDao; +import com.epmet.dao.SystemMessagePenddingDao; import com.epmet.entity.SystemMessageEntity; +import com.epmet.entity.SystemMessagePenddingEntity; import com.epmet.service.SystemMessageService; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; import org.apache.rocketmq.common.message.Message; import org.apache.rocketmq.remoting.common.RemotingHelper; import org.apache.rocketmq.spring.core.RocketMQTemplate; @@ -21,37 +28,118 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.time.LocalDateTime; +import java.util.List; +import java.util.Set; +import java.util.UUID; + @Service public class SystemMessageServiceImpl implements SystemMessageService { private Logger logger = LoggerFactory.getLogger(getClass()); + // 消息堆积时间阈值,单位s + private static final long PENDDING_MQ_MSG_EXEC_THRESHOLD_DELTA_L1 = 1 * 60; + private static final long PENDDING_MQ_MSG_EXEC_THRESHOLD_DELTA_L2 = 2 * 60; + private static final long PENDDING_MQ_MSG_EXEC_THRESHOLD_DELTA_L3 = 5 * 60; + private static final long PENDDING_MQ_MSG_EXEC_THRESHOLD_DELTA_L4 = 10 * 60; + private static final long PENDDING_MQ_MSG_EXEC_THRESHOLD_DELTA_L5 = 30 * 60; + private static final long PENDDING_MQ_MSG_EXEC_THRESHOLD_DELTA_L6 = 60 * 60; + + // 堆积消息告警间隔时长,单位s + public static final long PENDDING_MQ_MSG_ALERT_SECONDS_DELTA = 60 * 60; + + // 各个级别上次告警时间 + private LocalDateTime l1LastAlertTime; + private LocalDateTime l6LastAlertTime; + @Autowired private SystemMessageDao systemMessageDao; + @Autowired + private SystemMessagePenddingDao systemMessagePenddingDao; + @Autowired private RocketMQTemplate rocketMQTemplate; - @Transactional(rollbackFor = Exception.class) + @Autowired + private RedisUtils redisUtils; + @Override - public void sendMQMessage(String messageType, Object content) { + public void persistAndSendMQMessage(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消息 + logger.info("【发送MQ系统消息】-落盘并发送-messageType:{}, contentStr:{}", messageType, contentStr); + // 1.消息落盘 + String penddingMsgId = persistMessage(messageType, contentStr); + + // 2.发送消息 + sendMQMessage(messageType, contentStr, penddingMsgId); + } + + /** + * @description 消息落盘,有事务 + * + * @param messageType + * @param contentStr + * @return + * @author wxz + * @date 2021.10.16 11:04:53 + */ + @Transactional(rollbackFor = Exception.class) + public String persistMessage(String messageType, String contentStr) { + + SystemMessageEntity message = new SystemMessageEntity(); + message.setMsgType(messageType); + message.setSendApproach(SystemMessageSendApproach.MQ); + message.setContent(contentStr); + systemMessageDao.insert(message); + + SystemMessagePenddingEntity pendding = new SystemMessagePenddingEntity(); + pendding.setMsgType(messageType); + pendding.setSendApproach(SystemMessageSendApproach.MQ); + pendding.setContent(contentStr); + pendding.setMsgId(message.getId()); + systemMessagePenddingDao.insert(pendding); + + logger.info("【发送MQ系统消息】-落盘完成"); + + return pendding.getId(); + } + + private void sendMQMessage(String messageType, String contentStr, String penddingId) { + String topic = getTopicByMsgType(messageType); + + // 缓存下来,供滞留消息扫描。TTL -1,永不过期 + String pendingMsgLabel = null; + String pendingMsgKey = null; try { - Message meMessage = new Message(getTopicByMsgType(messageType), messageType, contentStr.getBytes(RemotingHelper.DEFAULT_CHARSET)); + MessageCacheBean mcb = new MessageCacheBean(LocalDateTime.now(), messageType, topic, contentStr); + pendingMsgLabel = UUID.randomUUID().toString().replace("-", ""); + pendingMsgKey = RedisKeys.blockedMqMsgKey(pendingMsgLabel); + redisUtils.set(pendingMsgKey, mcb, -1); + //logger.info("【发送MQ系统消息】-存入redis堆积列表成功-{}-{}-{}", topic, messageType, pendingMsgLabel); + } catch (Exception e) { + logger.error("【发送MQ系统消息】将系统MQ消息存储到Redis堆积列表失败,业务继续执行,{}", ExceptionUtils.getThrowableErrorStackTrace(e)); + } + + // 3.发送mq消息 + try { + Message meMessage = new Message(topic, messageType, contentStr.getBytes(RemotingHelper.DEFAULT_CHARSET)); + meMessage.putUserProperty(MQUserPropertys.BLOCKED_MSG_LABEL, pendingMsgLabel); rocketMQTemplate.getProducer().send(meMessage); + logger.info("【发送MQ系统消息】-发送到MQ成功"); } catch (Exception e) { String errorStackTrace = ExceptionUtils.getErrorStackTrace(e); - logger.error("发送系统消息失败,堆栈信息:{}", errorStackTrace); + logger.error("【发送MQ系统消息】发送系统MQ消息失败,堆栈信息:{}", errorStackTrace); + + // 清理阻塞中的消息缓存 + redisUtils.delete(pendingMsgKey); + throw new RenException(EpmetErrorCode.SYSTEM_MQ_MSG_SEND_FAIL.getCode()); } + + // 删除消息堆积 + systemMessagePenddingDao.physicalDeleteById(penddingId); } /** @@ -79,7 +167,100 @@ public class SystemMessageServiceImpl implements SystemMessageService { case SystemMessageType.POINT_RULE_CHANGED: topic = TopicConstants.POINT; break; + case SystemMessageType.GRID_CREATE: + case SystemMessageType.GRID_CHANGE: + case SystemMessageType.AGENCY_CREATE: + case SystemMessageType.AGENCY_CHANGE: + case SystemMessageType.DEPARTMENT_CREATE: + case SystemMessageType.DEPARTMENT_CHANGE: + topic = TopicConstants.ORG; + break; + case SystemMessageType.STAFF_CREATE: + case SystemMessageType.STAFF_CHANGE: + topic = TopicConstants.STAFF; + break; + case SystemMessageType.USER_PATROL_START: + case SystemMessageType.USER_PATROL_STOP: + topic = TopicConstants.PATROL; + break; } return topic; } + + @Override + public void blockedMqMsgScan() { + String scanKey = RedisKeys.blockedMqMsgKey("*"); + Set keys = redisUtils.keys(scanKey); + //System.out.println(keys); + for (String key : keys) { + MessageCacheBean mcb = (MessageCacheBean) redisUtils.get(key); + + LocalDateTime createTime = mcb.getCreateTime(); + LocalDateTime now = LocalDateTime.now(); + //long deltaSeconds = ChronoUnit.SECONDS.between(createTime, now); + + // 此处暂时使用粗粒度的Topic判断,耕细粒度的应该使用SystemMessageType + switch (mcb.getTopic()) { + case TopicConstants.AUTH: + case TopicConstants.GROUP_ACHIEVEMENT: + case TopicConstants.INIT_CUSTOMER: + case TopicConstants.ORG: + case TopicConstants.PATROL: + case TopicConstants.POINT: + case TopicConstants.STAFF: + + // 耗时较短。一个小时最多发送一次告警 + if (l1LastAlertTime == null || ( + createTime.plusSeconds(PENDDING_MQ_MSG_EXEC_THRESHOLD_DELTA_L1).isBefore(now) + && l1LastAlertTime.plusSeconds(PENDDING_MQ_MSG_ALERT_SECONDS_DELTA).isBefore(now)) + ) { + + logger.error("【MQ阻塞消息扫描】Topic:{},messageType:{},redisKey:{},等{}个消息发生阻塞", mcb.topic, mcb.messageType, key, keys.size()); + l1LastAlertTime = now; + + } + break; + + case TopicConstants.PROJECT_CHANGED: + // 耗时较长,一个小时最多发送一次告警 + if (l1LastAlertTime == null || ( + createTime.plusSeconds(PENDDING_MQ_MSG_EXEC_THRESHOLD_DELTA_L6).isBefore(now) + && l6LastAlertTime.plusSeconds(PENDDING_MQ_MSG_ALERT_SECONDS_DELTA).isBefore(now)) + ) { + logger.error("【MQ阻塞消息扫描】Topic:{},messageType:{},redisKey:{},等{}个消息发生阻塞", mcb.topic, mcb.messageType, key, keys.size()); + l1LastAlertTime = now; + } + break; + } + } + } + + @Override + public void penddingMqMsgScan() { + Integer count = systemMessagePenddingDao.selectCount(null); + if (count == 0) { + return; + } + + // 扫描并且重新投递 + List penddingMsgs = systemMessagePenddingDao.selectList(null); + for (SystemMessagePenddingEntity penddingMsg : penddingMsgs) { + try { + sendMQMessage(penddingMsg.getMsgType(), penddingMsg.getContent(), penddingMsg.getId()); + } catch (Exception e) { + // 投递失败不应影响后续消息的投递 + logger.error("【重新投递MQ消息】失败, msgType:{}, penddingMsgId:{}, 错误:{}", penddingMsg.getMsgType(), penddingMsg.getId() , ExceptionUtils.getErrorStackTrace(e)); + } + } + } + + @Data + @NoArgsConstructor + @AllArgsConstructor + static class MessageCacheBean { + private LocalDateTime createTime; + private String messageType; + private String topic; + private Object content; + } } diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/resources/db/migration/V0.3.18__create_sys_msg_pendding.sql b/epmet-module/epmet-message/epmet-message-server/src/main/resources/db/migration/V0.3.18__create_sys_msg_pendding.sql new file mode 100644 index 0000000000..78a45a9865 --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-server/src/main/resources/db/migration/V0.3.18__create_sys_msg_pendding.sql @@ -0,0 +1,14 @@ +CREATE TABLE `system_message_pendding` ( + `ID` varchar(64) NOT NULL COMMENT '主键', + `MSG_ID` varchar(64) NOT NULL COMMENT '消息主表id', + `MSG_TYPE` varchar(32) NOT NULL COMMENT '消息类型。init_customer:客户初始化,login登录,logout退出', + `SEND_APPROACH` varchar(32) NOT NULL COMMENT '消息发送途径', + `CONTENT` varchar(1024) NOT NULL COMMENT '消息内容', + `REVISION` int(11) DEFAULT NULL COMMENT '乐观锁', + `CREATED_BY` varchar(32) NOT NULL COMMENT '创建人(发布消息的人)', + `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', + `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', + `DEL_FLAG` varchar(1) NOT NULL COMMENT '删除标记 0:未删除,1:已删除', + PRIMARY KEY (`ID`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='系统消息滞留表' \ No newline at end of file diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/SystemMessagePenddingDao.xml b/epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/SystemMessagePenddingDao.xml new file mode 100644 index 0000000000..4a5ab00608 --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/SystemMessagePenddingDao.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + delete from system_message_pendding where ID = #{penddingId} + + + + \ No newline at end of file diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/mq/listener/IssueProjectCategoryTagInitListener.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/mq/listener/IssueProjectCategoryTagInitListener.java index 19ca52066c..a9eb9c436f 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/mq/listener/IssueProjectCategoryTagInitListener.java +++ b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/mq/listener/IssueProjectCategoryTagInitListener.java @@ -1,12 +1,17 @@ package com.epmet.mq.listener; import com.alibaba.fastjson.JSON; +import com.epmet.commons.rocketmq.constants.MQUserPropertys; import com.epmet.commons.rocketmq.messages.InitCustomerMQMsg; 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.dto.form.CategoryTagInitFormDTO; import com.epmet.service.IssueProjectCategoryDictService; +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; @@ -32,8 +37,15 @@ public class IssueProjectCategoryTagInitListener implements MessageListenerConcu @Autowired private DistributedLock distributedLock; + 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) { @@ -45,6 +57,7 @@ public class IssueProjectCategoryTagInitListener implements MessageListenerConcu public void consumeMessage(MessageExt messageExt) { String msg = new String(messageExt.getBody()); + String pendingMsgLabel = messageExt.getUserProperty(MQUserPropertys.BLOCKED_MSG_LABEL); logger.info("初始化客户-初始化议题、项目的分类、标签数据-收到消息内容:{}", msg); InitCustomerMQMsg msgObj = JSON.parseObject(msg, InitCustomerMQMsg.class); @@ -66,5 +79,27 @@ public class IssueProjectCategoryTagInitListener implements MessageListenerConcu } 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("【议题/项目分类标签初始化事件监听器】删除mq阻塞消息缓存成功,penddingMsgLabel:{}", pendingMsgLabel); } } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DeleteGridFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DeleteGridFormDTO.java index ed266210ba..5bd8641413 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DeleteGridFormDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DeleteGridFormDTO.java @@ -27,4 +27,9 @@ public class DeleteGridFormDTO implements Serializable { * userId */ private String userId; + + /** + * 客户Id + */ + private String customerId; } diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditGridFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditGridFormDTO.java index 0ad04c404d..ff48cd1972 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditGridFormDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditGridFormDTO.java @@ -40,4 +40,7 @@ public class EditGridFormDTO implements Serializable { */ private String manageDistrict; + //客户Id + private String customerId; + } diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/RemoveAgencyFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/RemoveAgencyFormDTO.java index 5caaec7ea5..27bee4e64d 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/RemoveAgencyFormDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/RemoveAgencyFormDTO.java @@ -38,5 +38,9 @@ public class RemoveAgencyFormDTO implements Serializable { */ @NotBlank(message = "机关组织ID不能为空") private String agencyId; + /** + * 客户Id + */ + private String customerId; } \ 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 2bc10abf21..13561a58a3 100644 --- a/epmet-module/gov-org/gov-org-server/pom.xml +++ b/epmet-module/gov-org/gov-org-server/pom.xml @@ -107,6 +107,12 @@ 2.0.0 compile + + com.epmet + epmet-message-client + 2.0.0 + compile + diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java index a3695f6362..112d6b8e35 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java @@ -141,6 +141,7 @@ public class AgencyController { @RequirePermission(requirePermission = RequirePermissionEnum.ORG_SUBAGENCY_DELETE) public Result removeAgency(@LoginUser TokenDto tokenDTO, @RequestBody RemoveAgencyFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO); + formDTO.setCustomerId(tokenDTO.getCustomerId()); return agencyService.removeAgency(formDTO); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/GridController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/GridController.java index ce24000220..f9cc5c1b54 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/GridController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/GridController.java @@ -58,6 +58,7 @@ public class GridController { @RequirePermission(requirePermission = RequirePermissionEnum.ORG_GRID_UPDATE) public Result editGrid(@LoginUser TokenDto tokenDto, @RequestBody EditGridFormDTO editGridFormDTO){ ValidatorUtils.validateEntity(editGridFormDTO, EditGridFormDTO.EditGrid.class); + editGridFormDTO.setCustomerId(tokenDto.getCustomerId()); return customerGridService.editGrid(tokenDto,editGridFormDTO); } @@ -68,6 +69,7 @@ public class GridController { @PostMapping("deletegrid") @RequirePermission(requirePermission = RequirePermissionEnum.ORG_GRID_DELETE) public Result deleteGrid(@LoginUser TokenDto tokenDto, @RequestBody DeleteGridFormDTO deleteGridFormDTO){ + deleteGridFormDTO.setCustomerId(tokenDto.getCustomerId()); return customerGridService.deleteGrid(tokenDto,deleteGridFormDTO); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/mq/listener/InitCustomerOrgRolesListener.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/mq/listener/InitCustomerOrgRolesListener.java index 7224ea757a..11bcc80e38 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/mq/listener/InitCustomerOrgRolesListener.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/mq/listener/InitCustomerOrgRolesListener.java @@ -1,16 +1,20 @@ package com.epmet.mq.listener; import com.alibaba.fastjson.JSON; +import com.epmet.commons.rocketmq.constants.MQUserPropertys; import com.epmet.commons.rocketmq.messages.InitCustomerMQMsg; 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.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.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; @@ -32,8 +36,15 @@ public class InitCustomerOrgRolesListener 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) { @@ -45,6 +56,7 @@ public class InitCustomerOrgRolesListener implements MessageListenerConcurrently private void consumeMessage(MessageExt messageExt) { String msg = new String(messageExt.getBody()); + String pendingMsgLabel = messageExt.getUserProperty(MQUserPropertys.BLOCKED_MSG_LABEL); logger.info("初始化客户-初始化组织信息-收到消息内容:{}", msg); InitCustomerMQMsg msgObj = JSON.parseObject(msg, InitCustomerMQMsg.class); @@ -65,6 +77,14 @@ public class InitCustomerOrgRolesListener implements MessageListenerConcurrently } finally { distributedLock.unLock(lock); } + + if (StringUtils.isNotBlank(pendingMsgLabel)) { + try { + removePendingMqMsgCache(pendingMsgLabel); + } catch (Exception e) { + logger.error("【客户初始化事件监听器】-orgRole-删除mq阻塞消息缓存失败:{}", ExceptionUtils.getErrorStackTrace(e)); + } + } } /** @@ -100,6 +120,20 @@ public class InitCustomerOrgRolesListener implements MessageListenerConcurrently return agencyAndStaff; } + /** + * @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("【客户初始化事件监听器】删除mq阻塞消息缓存成功,penddingMsgLabel:{}", pendingMsgLabel); + } + /* @Override public ConsumerConfigProperties getConsumerProperty() { ConsumerConfigProperties configProperties = new ConsumerConfigProperties(); diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java index b60e0ff31c..aa070f2d90 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java @@ -18,6 +18,7 @@ package com.epmet.service.impl; import com.alibaba.fastjson.JSON; +import com.epmet.commons.rocketmq.messages.OrgOrStaffMQMsg; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; @@ -35,8 +36,10 @@ import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.entity.CustomerAgencyEntity; import com.epmet.feign.EpmetCommonServiceOpenFeignClient; +import com.epmet.feign.EpmetMessageOpenFeignClient; import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.redis.CustomerAgencyRedis; +import com.epmet.send.SendMqMsgUtil; import com.epmet.service.AgencyService; import com.epmet.service.CustomerAgencyService; import com.epmet.service.CustomerOrgParameterService; @@ -80,6 +83,8 @@ public class AgencyServiceImpl implements AgencyService { private CustomerOrgParameterService customerOrgParameterService; @Autowired private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient; + @Autowired + private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; /** @@ -176,6 +181,16 @@ public class AgencyServiceImpl implements AgencyService { //5.redis缓存 customerAgencyRedis.delete(formDTO.getAgencyId()); + + //2021-10-18 推送mq,数据同步到中介库 start【中介库只放了组织的名称、级别,所以涉及批量修改pname的操作不涉及同步中间库】 + OrgOrStaffMQMsg mq = new OrgOrStaffMQMsg(); + mq.setCustomerId(originalEntity.getCustomerId()); + mq.setOrgId(formDTO.getAgencyId()); + mq.setOrgType("agency"); + mq.setType("agency_change"); + SendMqMsgUtil.build().openFeignClient(epmetMessageOpenFeignClient).sendOrgStaffMqMsg(mq); + //2021-10-18 end + return result; } @@ -215,6 +230,16 @@ public class AgencyServiceImpl implements AgencyService { log.error(CustomerAgencyConstant.DEL_EXCEPTION); throw new RenException(CustomerAgencyConstant.DEL_EXCEPTION); } + + //2021-10-18 推送mq,数据同步到中介库 start + OrgOrStaffMQMsg mq = new OrgOrStaffMQMsg(); + mq.setCustomerId(formDTO.getCustomerId()); + mq.setOrgId(formDTO.getAgencyId()); + mq.setOrgType("agency"); + mq.setType("agency_change"); + SendMqMsgUtil.build().openFeignClient(epmetMessageOpenFeignClient).sendOrgStaffMqMsg(mq); + //2021-10-18 end + return result; } @@ -370,6 +395,16 @@ public class AgencyServiceImpl implements AgencyService { entity.setTotalUser(0); entity.setCustomerId(form.getCustomerId()); customerAgencyDao.insert(entity); + + //2021-10-18 推送mq,数据同步到中介库 start + OrgOrStaffMQMsg mq = new OrgOrStaffMQMsg(); + mq.setCustomerId(form.getCustomerId()); + mq.setOrgId(entity.getId()); + mq.setOrgType("agency"); + mq.setType("agency_create"); + SendMqMsgUtil.build().openFeignClient(epmetMessageOpenFeignClient).sendOrgStaffMqMsg(mq); + //2021-10-18 end + return entity.getId(); } @@ -430,6 +465,15 @@ public class AgencyServiceImpl implements AgencyService { throw new RenException(EpmetErrorCode.OPER_ADD_CUSTOMER_MANAGER_ERROR.getCode(), staffResult.getMsg()); } + //2021-10-18 推送mq,数据同步到中介库 start + OrgOrStaffMQMsg mq = new OrgOrStaffMQMsg(); + mq.setCustomerId(agencyDTO.getCustomerId()); + mq.setOrgId(entity.getId()); + mq.setOrgType("agency"); + mq.setType("agency_create"); + SendMqMsgUtil.build().openFeignClient(epmetMessageOpenFeignClient).sendOrgStaffMqMsg(mq); + //2021-10-18 end + } /** @@ -474,6 +518,15 @@ public class AgencyServiceImpl implements AgencyService { //3:返回新组织Id resultDTO.setAgencyId(insertEntity.getId()); resultDTO.setAreaCode(insertEntity.getAreaCode()); + + //2021-10-18 推送mq,数据同步到中介库 start + OrgOrStaffMQMsg mq = new OrgOrStaffMQMsg(); + mq.setCustomerId(parent.getCustomerId()); + mq.setOrgId(insertEntity.getId()); + mq.setOrgType("agency"); + mq.setType("agency_create"); + SendMqMsgUtil.build().openFeignClient(epmetMessageOpenFeignClient).sendOrgStaffMqMsg(mq); + //2021-10-18 end return resultDTO; } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java index 58faa734ac..d5497b8a08 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java @@ -21,6 +21,7 @@ import cn.hutool.core.bean.BeanUtil; 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.OrgOrStaffMQMsg; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; @@ -41,8 +42,10 @@ import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.entity.CustomerAgencyEntity; import com.epmet.entity.CustomerGridEntity; +import com.epmet.feign.EpmetMessageOpenFeignClient; import com.epmet.feign.EpmetUserFeignClient; import com.epmet.feign.OperCrmOpenFeignClient; +import com.epmet.send.SendMqMsgUtil; import com.epmet.service.CustomerAgencyService; import com.epmet.service.CustomerGridService; import com.epmet.util.ModuleConstant; @@ -79,9 +82,10 @@ public class CustomerGridServiceImpl extends BaseServiceImpl page(Map params) { @@ -270,6 +274,16 @@ public class CustomerGridServiceImpl extends BaseServiceImpl().ok(resultDTO); } @@ -291,6 +305,16 @@ public class CustomerGridServiceImpl extends BaseServiceImpl + + + open-data-worker + com.epmet + 2.0.0 + + 4.0.0 + + open-data-worker-client + + + + com.epmet + epmet-commons-tools + 2.0.0 + + + diff --git a/epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/BaseDisputeProcessDTO.java b/epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/BaseDisputeProcessDTO.java new file mode 100644 index 0000000000..38ab49fc12 --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/BaseDisputeProcessDTO.java @@ -0,0 +1,207 @@ +/** + * 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.opendata.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * 事件信息表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-15 + */ +@Data +public class BaseDisputeProcessDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 客户Id + */ + private String customerId; + + /** + * 网格编码 + */ + private String orgCode; + + /** + * 网格名称 + */ + private String orgName; + + /** + * 事件名称 + */ + private String eventName; + + /** + * 事件类别 + */ + private String eventCategory; + + /** + * 上报时间 YYYY-MM-DD HH:MM:SS + */ + private Date reportTime; + + /** + * 发生时间 格式为“YYYY-MM-DD” + */ + private Date happenDate; + + /** + * 发生地点 + */ + private String happenPlace; + + /** + * 事件简述 + */ + private String eventDescription; + + /** + * 办结方式 01自办;02上报 源于居民端的最终结案的项目为02;工作端立项的项目最终结案的01 + */ + private String waysOfResolving; + + /** + * 是否办结 Y:是、N:否 + */ + private String successfulOrNo; + + /** + * 办结层级 +01省、自治区、直辖市 +02地、市、州、盟 +03县、市、区、旗 +04乡镇、街道 +05片区 +06村、社区 +07网格 + + */ + private String completeLevel; + + /** + * 基础信息主键 + */ + private String baseInfoId; + + /** + * 办结时间 + */ + private Date completeTime; + + /** + * 经度 + */ + private BigDecimal lng; + + /** + * 纬度 + */ + private BigDecimal lat; + + /** + * 主要当事人姓名 + */ + private String name; + + /** + * 涉及人数 + */ + private Integer numberInvolved; + + /** + * 涉及单位 + */ + private String relatedUnits; + + /** + * 重点场所类别 01九小场所, 02公共场所 + */ + private String keyAreaType; + + /** + * 宗教活动规模 01 0-50人,02 51-200人,03 201人以上 + + */ + private String religionScale; + + /** + * 宗教类别 01道教 02佛教 03基督教 04伊斯兰教 05其他 + + */ + private String religionType; + + /** + * 重点场所是否变动 Y:是、N:否 + */ + private String isKeyareaState; + + /** + * 重点人员是否在当地 Y:是、N:否 + */ + private String isKeypeopleLocate; + + /** + * 重点人员现状 + */ + private String keypeopleStatus; + + /** + * 删除标识 0.未删除 1.已删除 + */ + private Long delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/BaseGridInfoDTO.java b/epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/BaseGridInfoDTO.java new file mode 100644 index 0000000000..2b105cfe85 --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/BaseGridInfoDTO.java @@ -0,0 +1,136 @@ +/** + * 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.opendata.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 网格基础信息表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-15 + */ +@Data +public class BaseGridInfoDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 客户Id + */ + private String customerId; + + /** + * 组织/网格Id + */ + private String orgId; + + /** + * 网格编码 + */ + private String code; + + /** + * 网格名称 + */ + private String gridName; + + /** + * 网格层级[07:网格] + */ + private String gridLevel; + + /** + * 专属网格类型[01:党政机关; 02:医院; 03:学校; 04:企业; 05:园区; 06:商圈; 07:市场; 08:景区; + */ + private String gridType; + + /** + * 网格内人口规模[01:500人以下(含500人); 02:500-1000人(含1000人); 03:1000-1500人(含1500人); 04:1500人以上] + */ + private String populationSize; + + /** + * 是否成立网格党支部或网格党小组[Y:是、N:否] + */ + private String isPartyBranch; + + /** + * 网格党组织类型[01:网格党支部; 02:网格党小组] + */ + private String partyBranchType; + + /** + * 中心点(质心)经度 + */ + private String lng; + + /** + * 中心点(质心)纬度 + */ + private String lat; + + /** + * 网格颜色 + */ + private String gridColor; + + /** + * 空间范围 + */ + private String shape; + + /** + * 删除标识 0.未删除 1.已删除 + */ + private Long delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/BaseGridUserDTO.java b/epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/BaseGridUserDTO.java new file mode 100644 index 0000000000..fb5218cdf8 --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/BaseGridUserDTO.java @@ -0,0 +1,191 @@ +/** + * 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.opendata.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 网格员基础信息表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-15 + */ +@Data +public class BaseGridUserDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 客户Id + */ + private String customerId; + + /** + * 网格Id + */ + private String gridId; + + /** + * 人员Id + */ + private String staffId; + + /** + * 网格编码 + */ + private String code; + + /** + * 网格名称 + */ + private String gridName; + + /** + * 网格员姓名 + */ + private String nickName; + + /** + * 专属网格类型[01:党政机关; 02:医院; 03:学校; 04:企业; 05:园区; 06:商圈; 07:市场; 08:景区; + */ + private String cardNum; + + /** + * 网格员类型[01:专职网格员; 02:兼职网格员; 03:网格长; 04:综治机构人员; 05:职能部门人员] + */ + private String userType; + + /** + * 手机号码 + */ + private String phonenumber; + + /** + * 性别[1:男性; 2:女性; 9:未说明的性别] + */ + private String sex; + + /** + * 民族[字典表主键] + */ + private String nation; + + /** + * 政治面貌[字典表主键] + */ + private String paerty; + + /** + * 出生日期[YYYY-MM-DD] + */ + private Date birthday; + + /** + * 学历[字典表主键] + */ + private String education; + + /** + * 入职时间 + */ + private Date entryDate; + + /** + * 是否离职 + */ + private String isLeave; + + /** + * 离职时间 + */ + private Date leaveDate; + + /** + * 网格员年收入 + */ + private String income; + + /** + * 是否社区(村)两委委员[Y:是、N:否] + */ + private String isCommittee; + + /** + * 是否社区工作者[Y:是、N:否] + */ + private String isCommunityWorkers; + + /** + * 是否社会工作者[Y:是、N:否] + */ + private String isSocialWorker; + + /** + * 是否村(居)民小组长[Y:是、N:否 + */ + private String isVillageLeader; + + /** + * 是否警务助理[Y:是、N:否] + */ + private String isPoliceAssistant; + + /** + * 是否人民调解员[Y:是、N:否] + */ + private String isMediator; + + /** + * 删除标识 0.未删除 1.已删除 + */ + private Long delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/form/GridBaseInfoFormDTO.java b/epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/form/GridBaseInfoFormDTO.java new file mode 100644 index 0000000000..c1952d1bcf --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/form/GridBaseInfoFormDTO.java @@ -0,0 +1,34 @@ +package com.epmet.opendata.dto.form; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.List; + +/** + * @dscription 插叙客户网格基础信息--接口入参 + * @author sun + */ +@Data +public class GridBaseInfoFormDTO implements Serializable { + + private static final long serialVersionUID = -3634745091993094743L; + /** + * 客户Id + */ + @NotBlank(message = "事件标识不能为空", groups = {Grid.class}) + private String customerId = ""; + /** + * 网格Id + */ + private List orgIdList; + /** + * 操作类型【新增:add 修改删除:edit】 + */ + private String type; + + public interface Grid extends CustomerClientShowGroup {} + +} diff --git a/epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/form/StaffBaseInfoFormDTO.java b/epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/form/StaffBaseInfoFormDTO.java new file mode 100644 index 0000000000..d486c7f67a --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/form/StaffBaseInfoFormDTO.java @@ -0,0 +1,33 @@ +package com.epmet.opendata.dto.form; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.List; + +/** + * @dscription 插叙客户网格人员基础信息--接口入参 + * @author sun + */ +@Data +public class StaffBaseInfoFormDTO implements Serializable { + + private static final long serialVersionUID = -3634745091993094743L; + /** + * 客户Id + */ + @NotBlank(message = "事件标识不能为空", groups = {Staff.class}) + private String customerId = ""; + /** + * 人员Id + */ + private List staffIdList; + /** + * 操作类型【新增:add 修改删除:edit】 + */ + private String type; + public interface Staff extends CustomerClientShowGroup {} + +} diff --git a/epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/form/UpsertPatrolRecordForm.java b/epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/form/UpsertPatrolRecordForm.java new file mode 100644 index 0000000000..d80157031e --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/form/UpsertPatrolRecordForm.java @@ -0,0 +1,33 @@ +package com.epmet.opendata.dto.form; + +import com.epmet.commons.tools.dto.form.PageFormDTO; +import lombok.Data; + +import javax.validation.constraints.NotEmpty; + +/** + * 插入或更新巡查记录主表 + * @author liujianjun + */ +@Data +public class UpsertPatrolRecordForm extends PageFormDTO { + /** + * 客户Id + */ + @NotEmpty(message = "customerId不能为空") + private String customerId; + + /** + * 巡查记录id + */ + private String patrolId; + + /** + * 操作类型 + * SystemMessageType.USER_PATROL_START + * SystemMessageTypSTOP + */ + @NotEmpty(message = "actionType不能为空") + private String actionType; + +} diff --git a/epmet-module/open-data-worker/open-data-worker-server/Dockerfile b/epmet-module/open-data-worker/open-data-worker-server/Dockerfile new file mode 100644 index 0000000000..bdbf6243c4 --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/Dockerfile @@ -0,0 +1,11 @@ +FROM java:8 + +RUN export LANG="zh_CN.UTF-8" +RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime +RUN echo 'Asia/Shanghai' > /etc/timezone + +COPY ./target/*.jar ./open-data-worker.jar + +EXPOSE 8107 + +ENTRYPOINT ["sh", "-c", "exec $RUN_INSTRUCT"] \ No newline at end of file diff --git a/epmet-module/open-data-worker/open-data-worker-server/deploy/docker-compose-dev.yml b/epmet-module/open-data-worker/open-data-worker-server/deploy/docker-compose-dev.yml new file mode 100644 index 0000000000..5df8669717 --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/deploy/docker-compose-dev.yml @@ -0,0 +1,18 @@ +version: "3.7" +services: + gov-voice-server: + container_name: open-data-worker-server-dev + image: 192.168.1.140:5000/epmet-cloud-dev/open-data-worker-server:version_placeholder + ports: + - "8107:8107" + network_mode: host # 使用现有网络 + volumes: + - "/opt/epmet-cloud-logs/dev:/logs" + environment: + RUN_INSTRUCT: "java -Xms32m -Xmx200m -jar ./open-data-worker.jar" + restart: "unless-stopped" + deploy: + resources: + limits: + cpus: '0.1' + memory: 250M \ No newline at end of file diff --git a/epmet-module/open-data-worker/open-data-worker-server/deploy/docker-compose-prod.yml b/epmet-module/open-data-worker/open-data-worker-server/deploy/docker-compose-prod.yml new file mode 100644 index 0000000000..feedbad307 --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/deploy/docker-compose-prod.yml @@ -0,0 +1,18 @@ +version: "3.7" +services: + gov-voice-server: + container_name: open-data-worker-server-prod + image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-master/open-data-worker-server:0.3.69 + ports: + - "8107:8107" + network_mode: host # 使用现有网络 + volumes: + - "/opt/epmet-cloud-logs/prod:/logs" + environment: + RUN_INSTRUCT: "java -Xms256m -Xmx512m -jar ./open-data-worker.jar" + restart: "unless-stopped" + deploy: + resources: + limits: + cpus: '0.1' + memory: 600M \ No newline at end of file diff --git a/epmet-module/open-data-worker/open-data-worker-server/deploy/docker-compose-test.yml b/epmet-module/open-data-worker/open-data-worker-server/deploy/docker-compose-test.yml new file mode 100644 index 0000000000..faa41dfeed --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/deploy/docker-compose-test.yml @@ -0,0 +1,18 @@ +version: "3.7" +services: + gov-voice-server: + container_name: open-data-worker-server-test + image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-release/open-data-worker-server:version_placeholder + ports: + - "8107:8107" + network_mode: host # 使用现有网络 + volumes: + - "/opt/epmet-cloud-logs/test:/logs" + environment: + RUN_INSTRUCT: "java -Xms32m -Xmx300m -jar ./open-data-worker.jar" + restart: "unless-stopped" + deploy: + resources: + limits: + cpus: '0.1' + memory: 350M \ No newline at end of file diff --git a/epmet-module/open-data-worker/open-data-worker-server/pom.xml b/epmet-module/open-data-worker/open-data-worker-server/pom.xml new file mode 100644 index 0000000000..6a40fad5b3 --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/pom.xml @@ -0,0 +1,282 @@ + + + + open-data-worker + com.epmet + 2.0.0 + + 4.0.0 + + open-data-worker-server + + + + com.epmet + epmet-commons-tools + 2.0.0 + + + com.epmet + epmet-commons-mybatis + 2.0.0 + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework + spring-context-support + + + org.springframework.boot + spring-boot-starter-actuator + + + de.codecentric + spring-boot-admin-starter-client + ${spring.boot.admin.version} + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + io.github.openfeign + feign-httpclient + 10.3.0 + + + + + com.epmet + epmet-commons-rocketmq + 2.0.0 + + + + com.epmet + epmet-message-client + 2.0.0 + + + com.epmet + open-data-worker-client + 2.0.0 + compile + + + com.epmet + epmet-user-client + 2.0.0 + compile + + + com.epmet + data-statistical-client + 2.0.0 + compile + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + ${project.basedir}/src/main/java + + + true + ${basedir}/src/main/resources + + + + + + + dev + + 8117 + dev + + + + + + epmet_open_data_user + EpmEt-db-UsEr + + 0 + 192.168.1.140 + 6379 + 123456 + + true + 192.168.1.140:8848 + 1fecc730-5e6e-464c-aae9-7567944e7936 + + + false + + + true + + + false + + + https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4 + SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd + + + true + 192.168.1.140:9876;192.168.1.141:9876 + + + + local + + true + + + 8117 + local + + + + + + epmet_open_data_user + EpmEt-db-UsEr + + 0 + 192.168.1.140 + 6379 + 123456 + + false + 192.168.1.140:8848 + 1fecc730-5e6e-464c-aae9-7567944e7936 + + + false + + + false + + + false + + + https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4 + SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd + + + false + 192.168.1.140:9876;192.168.1.141:9876 + + + + test + + + 8117 + test + + + + + + epmet + elink@833066 + + 0 + r-m5eoz5b6tkx09y6bpz.redis.rds.aliyuncs.com + 6379 + EpmEtrEdIs!q@w + + true + 192.168.10.150:8848 + 67e3c350-533e-4d7c-9f8f-faf1b4aa82ae + + + false + + + true + + + true + + + https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4 + SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd + + + true + 192.168.10.161:9876 + + + + prod + + 8117 + prod + + + + + + epmet_open_data_user + EpmEt-db-UsEr + + 0 + r-m5ez3n1j0qc3ykq2ut.redis.rds.aliyuncs.com + 6379 + EpmEtclOUdrEdIs!Q2w + + true + 192.168.11.180:8848 + bd205d23-e696-47be-b995-916313f86e99 + + + false + + + true + + + true + + + https://oapi.dingtalk.com/robot/send?access_token=a5f66c3374b1642fe2142dbf56d5997e280172d4e8f2b546c9423a68c82ece6c + SEC95f4f40b533ad379ea6a6d1af6dd37029383cfe1b7cd96dfac2678be2c1c3ed1 + + + true + 192.168.11.187:9876;192.168.11.184:9876 + + + + + diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/OpenDataApplication.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/OpenDataApplication.java new file mode 100644 index 0000000000..532877cf4b --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/OpenDataApplication.java @@ -0,0 +1,26 @@ +package com.epmet; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.context.annotation.ComponentScan; + +/** + * @Description OpenData服务启动类 + * 注意:此处要使用@ComponentScan的原因是,启动类处于包com.epmet.opendata下,想用com.epmet.commons包下的一些Spring对象,需要 + * 手动指定扫描包,否则无法扫描 + * @author wxz + * @date 2021.10.13 15:16:05 +*/ +@SpringBootApplication +@EnableDiscoveryClient +@EnableFeignClients +@ServletComponentScan +//@ComponentScan(value = { "com.epmet" }) +public class OpenDataApplication { + public static void main(String[] args) { + SpringApplication.run(OpenDataApplication.class, args); + } +} diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/aspect/RequestLogAspect.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/aspect/RequestLogAspect.java new file mode 100644 index 0000000000..506c00da2d --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/aspect/RequestLogAspect.java @@ -0,0 +1,40 @@ +package com.epmet.opendata.aspect; + +import com.epmet.commons.tools.aspect.BaseRequestLogAspect; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; + +/** + * 日志/异常处理切面实现,调用父类方法完成日志记录和异常处理。 + */ +@Aspect +@Component +@Order(0) +public class RequestLogAspect extends BaseRequestLogAspect { + + @Override + @Around(value = "execution(* com.epmet.opendata.controller.*Controller*.*(..)) ") + public Object proceed(ProceedingJoinPoint point) throws Throwable { + return super.proceed(point, getRequest()); + } + + /** + * 获取Request对象 + * + * @return + */ + private HttpServletRequest getRequest() { + RequestAttributes ra = RequestContextHolder.getRequestAttributes(); + ServletRequestAttributes sra = (ServletRequestAttributes) ra; + return sra.getRequest(); + } + +} diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/config/ModuleConfigImpl.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/config/ModuleConfigImpl.java new file mode 100644 index 0000000000..802c020918 --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/config/ModuleConfigImpl.java @@ -0,0 +1,26 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.epmet.opendata.config; + +import com.epmet.commons.tools.config.ModuleConfig; +import org.springframework.stereotype.Service; + +/** + * 模块配置信息 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@Service +public class ModuleConfigImpl implements ModuleConfig { + @Override + public String getName() { + return "govvoice"; + } +} diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/config/NacosServiceListListenerRegisterer.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/config/NacosServiceListListenerRegisterer.java new file mode 100644 index 0000000000..a25220cbfb --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/config/NacosServiceListListenerRegisterer.java @@ -0,0 +1,161 @@ +package com.epmet.opendata.config; + +import com.alibaba.cloud.nacos.NacosDiscoveryProperties; +import com.alibaba.nacos.api.exception.NacosException; +import com.alibaba.nacos.api.naming.NamingService; +import com.alibaba.nacos.api.naming.listener.Event; +import com.alibaba.nacos.api.naming.listener.EventListener; +import com.alibaba.nacos.api.naming.listener.NamingEvent; +import com.alibaba.nacos.api.naming.pojo.ListView; +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.netflix.loadbalancer.DynamicServerListLoadBalancer; +import com.netflix.loadbalancer.ILoadBalancer; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.cloud.netflix.ribbon.SpringClientFactory; +import org.springframework.context.annotation.Configuration; + +import javax.annotation.PostConstruct; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.*; + +/** + * @author wxz + * @Description Nacos服务列表刷新监听注册器 + * @date 2021.09.22 14:33:11 + */ +@Slf4j +@Configuration +@ConditionalOnProperty(prefix = "spring.cloud.nacos.discovery.serviceListChangedListening", name = "enable", havingValue = "true", matchIfMissing = false) +public class NacosServiceListListenerRegisterer { + + public static final String REFRESH_SERVER_LIST_METHOD_NAME = "restOfInit"; + // 服务列表拉取间隔:10s + public static final long SERVICE_LIST_PULLING_DELAY_SECONDS = 10; + + private NamingService namingService; + + private ScheduledExecutorService executor; + + @Autowired + private NacosDiscoveryProperties discoveryProperties; + + @Autowired + private SpringClientFactory springClientFactory; + + // 监听中的服务列表 + private List observingServers = new ArrayList<>(33); + + @PostConstruct + public void init() { + namingService = discoveryProperties.namingServiceInstance(); + // 启动监听 + executor = new ScheduledThreadPoolExecutor(2, new ThreadFactory() { + @Override + public Thread newThread(Runnable r) { + Thread thread = new Thread(r); + thread.setDaemon(true); + thread.setName("NacosServiceListWatchingRegisterer"); + return thread; + } + }); + + // 立即启动,并15s刷新一次服务列表,用于新服务列表的发现 + ScheduledFuture future = executor.scheduleAtFixedRate(new EpmetNacosServiceListListener(), 0, SERVICE_LIST_PULLING_DELAY_SECONDS, TimeUnit.SECONDS); + } + + public class EpmetNacosServiceListListener implements Runnable { + + @Override + public void run() { + doRefreshServerList(); + } + + /** + * @param + * @return + * @description 执行刷新 + * @author wxz + * @date 2021.09.22 16:04:49 + */ + private synchronized void doRefreshServerList() { + ListView serviceListView = null; + try { + serviceListView = namingService.getServicesOfServer(1, 100); + //启动监听 + if (serviceListView == null || serviceListView.getCount() == 0) { + log.info("【Nacos服务列表定时刷新】当前无任何可添加监听的服务"); + return; + } + List serviceList = serviceListView.getData(); + log.info("【Nacos服务列表定时刷新】Nacos服务端服务列表: {}", serviceList); + + for (String service : serviceList) { + try { + + // 如果该服务已经在监听列表中存在了,则不再注册监听。注:不能取消空服务的监听,因为空服务随时可能恢复运行,需要实时监听。 + if (observingServers.contains(service)) { + continue; + } + + namingService.subscribe(service, new EventListener() { + @Override + public void onEvent(Event event) { + if (event instanceof NamingEvent) { + NamingEvent namingEvent = (NamingEvent) event; + log.info("【Nacos服务列表刷新监听】收到事件:{}:[{}]", namingEvent.getServiceName(), namingEvent.getInstances()); + doRefreshServerList(service); + } + } + }); + + // 将该服务加入到监听列表中 + observingServers.add(service); + } catch (NacosException e) { + String errorStackTrace = ExceptionUtils.getErrorStackTrace(e); + log.error("【Nacos服务列表定时刷新】订阅ApplicationContext的刷新事件失败,错误信息:{}", errorStackTrace); + } + } + + } catch (NacosException e) { + String errorStackTrace = ExceptionUtils.getErrorStackTrace(e); + log.error("【Nacos服务列表定时刷新】链接Nacos服务端失败,错误信息:{}", errorStackTrace); + } + } + + /** + * @param serviceName + * @return + * @description 刷新ServerList + * @author wxz + * @date 2021.09.22 09:29:16 + */ + private void doRefreshServerList(String serviceName) { + // 刷新方式1:反射调用DynamicServerListLoadBalancer中的restOfInit()方法。该方法原来只执行一次,此处不推荐用 + //ILoadBalancer loadBalancer = springClientFactory.getLoadBalancer(serviceName); + //if (loadBalancer instanceof ZoneAwareLoadBalancer) { + // ZoneAwareLoadBalancer zaLoadBalancer = (ZoneAwareLoadBalancer) loadBalancer; + // IClientConfig clientConfig = springClientFactory.getClientConfig(serviceName); + // try { + // Method restOfInitMethod = zaLoadBalancer.getClass().getSuperclass().getDeclaredMethod(REFRESH_SERVER_LIST_METHOD_NAME, IClientConfig.class); + // restOfInitMethod.setAccessible(true); + // restOfInitMethod.invoke(zaLoadBalancer, clientConfig); + // } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + // String errorStackTrace = ExceptionUtils.getErrorStackTrace(e); + // log.error("【LoadBalancer刷新服务列表】失败:{}", errorStackTrace); + // } + //} + + // 刷新方式2:DynamicServerListLoadBalancer#updateListOfServers()该方法为ribbon定时刷新服务列表的时候真正调用的方法,但是加了@VisibleForTesting + // 暂且 1 try + ILoadBalancer loadBalancer = springClientFactory.getLoadBalancer(serviceName); + if (loadBalancer instanceof DynamicServerListLoadBalancer) { + DynamicServerListLoadBalancer dslb = (DynamicServerListLoadBalancer) loadBalancer; + dslb.updateListOfServers(); + } + } + } + +} diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/BaseDisputeProcessController.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/BaseDisputeProcessController.java new file mode 100644 index 0000000000..038756ea9c --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/BaseDisputeProcessController.java @@ -0,0 +1,56 @@ +/** + * 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.opendata.controller; + +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.basereport.form.EventInfoFormDTO; +import com.epmet.opendata.service.BaseDisputeProcessService; +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; + + +/** + * 事件信息表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-15 + */ +@RestController +@RequestMapping("basedisputeprocess") +public class BaseDisputeProcessController { + + @Autowired + private BaseDisputeProcessService baseDisputeProcessService; + + /** + * 获取上报事件 + * @Param formDTO + * @Return {@link Result} + * @Author zhaoqifeng + * @Date 2021/10/15 16:59 + */ + @PostMapping("eventinfo") + public Result getEventinfo(@RequestBody(required = false) EventInfoFormDTO formDTO) { + baseDisputeProcessService.getEventinfo(formDTO); + return new Result(); + } + +} \ No newline at end of file diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/BaseGridInfoController.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/BaseGridInfoController.java new file mode 100644 index 0000000000..531ecc8cde --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/BaseGridInfoController.java @@ -0,0 +1,67 @@ +/** + * 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.opendata.controller; + +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.opendata.dto.form.GridBaseInfoFormDTO; +import com.epmet.opendata.service.BaseGridInfoService; +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; + + +/** + * 网格基础信息表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-15 + */ +@RestController +@RequestMapping("basegridinfo") +public class BaseGridInfoController { + + @Autowired + private BaseGridInfoService baseGridInfoService; + + + /** + * @Author sun + * @Description 组织基础信息中介库同步 + **/ + @PostMapping("agencybaseinfo") + public Result getAgencyBaseInfo(@RequestBody(required = false) GridBaseInfoFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, GridBaseInfoFormDTO.Grid.class); + baseGridInfoService.getAgencyBaseInfo(formDTO); + return new Result(); + } + + /** + * @Author sun + * @Description 网格基础信息中介库同步 + **/ + @PostMapping("gridbaseinfo") + public Result getGridBaseInfo(@RequestBody(required = false) GridBaseInfoFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, GridBaseInfoFormDTO.Grid.class); + baseGridInfoService.getGridBaseInfo(formDTO); + return new Result(); + } + +} \ No newline at end of file diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/BaseGridUserController.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/BaseGridUserController.java new file mode 100644 index 0000000000..dcf3146724 --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/BaseGridUserController.java @@ -0,0 +1,59 @@ +/** + * 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.opendata.controller; + +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.dto.user.result.GridUserInfoDTO; +import com.epmet.opendata.dto.form.StaffBaseInfoFormDTO; +import com.epmet.opendata.service.BaseGridUserService; +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; + +import java.util.List; + + +/** + * 网格员基础信息表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-15 + */ +@RestController +@RequestMapping("basegriduser") +public class BaseGridUserController { + + @Autowired + private BaseGridUserService baseGridUserService; + + /** + * @Author sun + * @Description 网格员信息中间库同步 + **/ + @PostMapping("staffbaseinfo") + public Result getStaffBaseInfo(@RequestBody(required = false) StaffBaseInfoFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, StaffBaseInfoFormDTO.Staff.class); + baseGridUserService.getStaffBaseInfo(formDTO); + return new Result(); + } + + +} \ No newline at end of file diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/InitDataController.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/InitDataController.java new file mode 100644 index 0000000000..38fe35fd15 --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/InitDataController.java @@ -0,0 +1,52 @@ +/** + * 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.opendata.controller; + +import com.epmet.commons.tools.utils.Result; +import com.epmet.constant.SystemMessageType; +import com.epmet.opendata.dto.form.UpsertPatrolRecordForm; +import com.epmet.opendata.service.UserPatrolRecordService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + + +/** + * 中间库数据初始化controller + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-14 + */ +@RestController +@RequestMapping("init") +public class InitDataController { + + @Autowired + private UserPatrolRecordService userPatrolRecordService; + + /** + * @Author sun + * @Description 网格员信息中间库同步 + **/ + @PostMapping("patrol/{customerId}") + public Result reloadPatrolData(@PathVariable String customerId) { + return new Result().ok(userPatrolRecordService.reloadPatrolData(customerId)); + } +} diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/UserPatrolRecordController.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/UserPatrolRecordController.java new file mode 100644 index 0000000000..fb2334e8df --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/UserPatrolRecordController.java @@ -0,0 +1,54 @@ +/** + * 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.opendata.controller; + +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.opendata.dto.form.UpsertPatrolRecordForm; +import com.epmet.opendata.service.UserPatrolRecordService; +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; + + +/** + * 用户巡查主记录 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-14 + */ +@RestController +@RequestMapping("userpatrolrecord") +public class UserPatrolRecordController { + + @Autowired + private UserPatrolRecordService userPatrolRecordService; + + /** + * @Author sun + * @Description 网格员信息中间库同步 + **/ + @PostMapping("patrol") + public Result getStaffBaseInfo(@RequestBody(required = false) UpsertPatrolRecordForm formDTO) { + ValidatorUtils.validateEntity(formDTO); + userPatrolRecordService.insertPatrolRecord(formDTO); + return new Result(); + } +} diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/BaseDisputeProcessDao.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/BaseDisputeProcessDao.java new file mode 100644 index 0000000000..c7b8df45d9 --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/BaseDisputeProcessDao.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.opendata.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.opendata.entity.BaseDisputeProcessEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 事件信息表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-15 + */ +@Mapper +public interface BaseDisputeProcessDao extends BaseDao { + +} \ No newline at end of file diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/BaseGridInfoDao.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/BaseGridInfoDao.java new file mode 100644 index 0000000000..40c5649d1b --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/BaseGridInfoDao.java @@ -0,0 +1,41 @@ +/** + * 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.opendata.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.opendata.entity.BaseGridInfoEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 网格基础信息表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-15 + */ +@Mapper +public interface BaseGridInfoDao extends BaseDao { + + /** + * @Author sun + * @Description 网格基础信息批量更新部分字段 + **/ + void updateBatch(@Param("list") List entityList); +} \ No newline at end of file diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/BaseGridUserDao.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/BaseGridUserDao.java new file mode 100644 index 0000000000..c53eb48e1f --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/BaseGridUserDao.java @@ -0,0 +1,41 @@ +/** + * 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.opendata.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.opendata.entity.BaseGridUserEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 网格员基础信息表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-15 + */ +@Mapper +public interface BaseGridUserDao extends BaseDao { + + /** + * @Author sun + * @Description 网格员基础信息批量更新部分字段 + **/ + void updateBatch(@Param("list") List entityList); +} \ No newline at end of file diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/UserPatrolDetailDao.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/UserPatrolDetailDao.java new file mode 100644 index 0000000000..57fb4edc6d --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/UserPatrolDetailDao.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.opendata.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.opendata.entity.UserPatrolDetailEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 工作人员巡查记录明细 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-14 + */ +@Mapper +public interface UserPatrolDetailDao extends BaseDao { + +} diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/UserPatrolRecordDao.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/UserPatrolRecordDao.java new file mode 100644 index 0000000000..7c40b093a3 --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/UserPatrolRecordDao.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.opendata.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.opendata.entity.UserPatrolRecordEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 用户巡查主记录 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-14 + */ +@Mapper +public interface UserPatrolRecordDao extends BaseDao { + +} diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/entity/BaseDisputeProcessEntity.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/entity/BaseDisputeProcessEntity.java new file mode 100644 index 0000000000..c7266558ed --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/entity/BaseDisputeProcessEntity.java @@ -0,0 +1,177 @@ +/** + * 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.opendata.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 事件信息表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-15 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("base_dispute_process") +public class BaseDisputeProcessEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户Id + */ + private String customerId; + + /** + * 网格编码 + */ + private String orgCode; + + /** + * 网格名称 + */ + private String orgName; + + /** + * 事件名称 + */ + private String eventName; + + /** + * 事件类别 + */ + private String eventCategory; + + /** + * 上报时间 YYYY-MM-DD HH:MM:SS + */ + private Date reportTime; + + /** + * 发生时间 格式为“YYYY-MM-DD” + */ + private Date happenDate; + + /** + * 发生地点 + */ + private String happenPlace; + + /** + * 事件简述 + */ + private String eventDescription; + + /** + * 办结方式 01自办;02上报 源于居民端的最终结案的项目为02;工作端立项的项目最终结案的01 + */ + private String waysOfResolving; + + /** + * 是否办结 Y:是、N:否 + */ + private String successfulOrNo; + + /** + * 办结层级 +01省、自治区、直辖市 +02地、市、州、盟 +03县、市、区、旗 +04乡镇、街道 +05片区 +06村、社区 +07网格 + + */ + private String completeLevel; + + /** + * 基础信息主键 + */ + private String baseInfoId; + + /** + * 办结时间 + */ + private Date completeTime; + + /** + * 经度 + */ + private BigDecimal lng; + + /** + * 纬度 + */ + private BigDecimal lat; + + /** + * 主要当事人姓名 + */ + private String name; + + /** + * 涉及人数 + */ + private Integer numberInvolved; + + /** + * 涉及单位 + */ + private String relatedUnits; + + /** + * 重点场所类别 01九小场所, 02公共场所 + */ + private String keyAreaType; + + /** + * 宗教活动规模 01 0-50人,02 51-200人,03 201人以上 + + */ + private String religionScale; + + /** + * 宗教类别 01道教 02佛教 03基督教 04伊斯兰教 05其他 + + */ + private String religionType; + + /** + * 重点场所是否变动 Y:是、N:否 + */ + private String isKeyareaState; + + /** + * 重点人员是否在当地 Y:是、N:否 + */ + private String isKeypeopleLocate; + + /** + * 重点人员现状 + */ + private String keypeopleStatus; + +} diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/entity/BaseGridInfoEntity.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/entity/BaseGridInfoEntity.java new file mode 100644 index 0000000000..f74e8b2205 --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/entity/BaseGridInfoEntity.java @@ -0,0 +1,106 @@ +/** + * 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.opendata.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 网格基础信息表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-15 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("base_grid_info") +public class BaseGridInfoEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户Id + */ + private String customerId; + + /** + * 组织/网格Id + */ + private String orgId; + + /** + * 网格编码 + */ + private String code; + + /** + * 网格名称 + */ + private String gridName; + + /** + * 网格层级[07:网格] + */ + private String gridLevel; + + /** + * 专属网格类型[01:党政机关; 02:医院; 03:学校; 04:企业; 05:园区; 06:商圈; 07:市场; 08:景区; + */ + private String gridType; + + /** + * 网格内人口规模[01:500人以下(含500人); 02:500-1000人(含1000人); 03:1000-1500人(含1500人); 04:1500人以上] + */ + private String populationSize; + + /** + * 是否成立网格党支部或网格党小组[Y:是、N:否] + */ + private String isPartyBranch; + + /** + * 网格党组织类型[01:网格党支部; 02:网格党小组] + */ + private String partyBranchType; + + /** + * 中心点(质心)经度 + */ + private String lng; + + /** + * 中心点(质心)纬度 + */ + private String lat; + + /** + * 网格颜色 + */ + private String gridColor; + + /** + * 空间范围 + */ + private String shape; + +} diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/entity/BaseGridUserEntity.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/entity/BaseGridUserEntity.java new file mode 100644 index 0000000000..5d0b2f1de6 --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/entity/BaseGridUserEntity.java @@ -0,0 +1,161 @@ +/** + * 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.opendata.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 网格员基础信息表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-15 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("base_grid_user") +public class BaseGridUserEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户Id + */ + private String customerId; + + /** + * 网格Id + */ + private String gridId; + + /** + * 人员Id + */ + private String staffId; + + /** + * 网格编码 + */ + private String code; + + /** + * 网格名称 + */ + private String gridName; + + /** + * 网格员姓名 + */ + private String nickName; + + /** + * 专属网格类型[01:党政机关; 02:医院; 03:学校; 04:企业; 05:园区; 06:商圈; 07:市场; 08:景区; + */ + private String cardNum; + + /** + * 网格员类型[01:专职网格员; 02:兼职网格员; 03:网格长; 04:综治机构人员; 05:职能部门人员] + */ + private String userType; + + /** + * 手机号码 + */ + private String phonenumber; + + /** + * 性别[1:男性; 2:女性; 9:未说明的性别] + */ + private String sex; + + /** + * 民族[字典表主键] + */ + private String nation; + + /** + * 政治面貌[字典表主键] + */ + private String paerty; + + /** + * 出生日期[YYYY-MM-DD] + */ + private Date birthday; + + /** + * 学历[字典表主键] + */ + private String education; + + /** + * 入职时间 + */ + private Date entryDate; + + /** + * 是否离职 + */ + private String isLeave; + + /** + * 离职时间 + */ + private Date leaveDate; + + /** + * 网格员年收入 + */ + private String income; + + /** + * 是否社区(村)两委委员[Y:是、N:否] + */ + private String isCommittee; + + /** + * 是否社区工作者[Y:是、N:否] + */ + private String isCommunityWorkers; + + /** + * 是否社会工作者[Y:是、N:否] + */ + private String isSocialWorker; + + /** + * 是否村(居)民小组长[Y:是、N:否 + */ + private String isVillageLeader; + + /** + * 是否警务助理[Y:是、N:否] + */ + private String isPoliceAssistant; + + /** + * 是否人民调解员[Y:是、N:否] + */ + private String isMediator; + +} diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/entity/UserPatrolDetailEntity.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/entity/UserPatrolDetailEntity.java new file mode 100644 index 0000000000..470c316e53 --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/entity/UserPatrolDetailEntity.java @@ -0,0 +1,61 @@ +/** + * 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.opendata.entity; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 工作人员巡查记录明细 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-14 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("user_patrol_detail") +public class UserPatrolDetailEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户Id + */ + private String customerId; + + /** + * staff_patrol_record.ID + */ + private String staffPatrolRecId; + + /** + * 路线 + */ + private String route; + + /** + * 是否已删除(0-未删除,1-已删除) + */ + @TableField(fill = FieldFill.INSERT) + private String delFlag; + +} diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/entity/UserPatrolRecordEntity.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/entity/UserPatrolRecordEntity.java new file mode 100644 index 0000000000..e068a9d80a --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/entity/UserPatrolRecordEntity.java @@ -0,0 +1,113 @@ +/** + * 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.opendata.entity; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 用户巡查主记录 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-14 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("user_patrol_record") +public class UserPatrolRecordEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户Id + */ + private String customerId; + + /** + * 网格id + */ + private String grid; + + /** + * 网格所有上级id + */ + private String gridPids; + + /** + * 用户id + */ + private String staffId; + + /** + * 工作人员所属组织id=网格所属的组织id + */ + private String agencyId; + + /** + * 巡查开始时间 + */ + private Date patrolStartTime; + + /** + * 巡查结束时间 + */ + private Date patrolEndTime; + + /** + * 实际结束时间 + */ + private Date actrualEndTime; + + /** + * 巡查开始地点 + */ + private String startLocation; + + /** + * 巡查结束地点 + */ + private String endLocation; + + /** + * 本次巡查总耗时,单位秒 + */ + private Integer totalTime; + + /** + * 巡查距离,单位米 + */ + private Integer distance; + + /** + * 正在巡查中:patrolling;结束:end + */ + private String status; + + /** + * 是否已删除(0-未删除,1-已删除) + */ + @TableField(fill = FieldFill.INSERT) + private String delFlag; + +} diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/healthcheck/HealthCheckController.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/healthcheck/HealthCheckController.java new file mode 100644 index 0000000000..0a6b1d6264 --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/healthcheck/HealthCheckController.java @@ -0,0 +1,21 @@ +package com.epmet.opendata.healthcheck; + +import com.epmet.commons.tools.utils.Result; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("healthcheck") +public class HealthCheckController { + + /** + * http健康检查 + * @return + */ + @PostMapping("http") + public Result httpHealthCheck() { + return new Result(); + } + +} diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/RocketMQConsumerRegister.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/RocketMQConsumerRegister.java new file mode 100644 index 0000000000..2ffed8c3dd --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/RocketMQConsumerRegister.java @@ -0,0 +1,54 @@ +package com.epmet.opendata.mq; + +import com.epmet.commons.rocketmq.constants.ConsomerGroupConstants; +import com.epmet.commons.rocketmq.constants.TopicConstants; +import com.epmet.commons.rocketmq.register.MQAbstractRegister; +import com.epmet.commons.rocketmq.register.MQConsumerProperties; +import com.epmet.opendata.mq.listener.OpenDataOrgChangeEventListener; +import com.epmet.opendata.mq.listener.OpenDataPatrolChangeEventListener; +import com.epmet.opendata.mq.listener.OpenDataProjectChangeEventListener; +import com.epmet.opendata.mq.listener.OpenDataStaffChangeEventListener; +import org.apache.rocketmq.common.protocol.heartbeat.MessageModel; +import org.springframework.stereotype.Component; + +/** + * @Description 如果rocketmq.enable=true,这里必须实现,且 实例化 + * @author wxz + * @date 2021.07.14 17:13:41 +*/ +@Component +public class RocketMQConsumerRegister extends MQAbstractRegister { + + @Override + public void registerAllListeners(String env, MQConsumerProperties consumerProperties) { + // 客户初始化监听器注册 + register(consumerProperties, + ConsomerGroupConstants.OPEN_DATA_ORG_CHANGE_EVENT_LISTENER_GROUP, + MessageModel.CLUSTERING, + TopicConstants.ORG, + "*", + new OpenDataOrgChangeEventListener()); + + register(consumerProperties, + ConsomerGroupConstants.OPEN_DATA_STAFF_CHANGE_EVENT_LISTENER_GROUP, + MessageModel.CLUSTERING, + TopicConstants.STAFF, + "*", + new OpenDataStaffChangeEventListener()); + + register(consumerProperties, + ConsomerGroupConstants.OPEN_DATA_PATROL_CHANGE_EVENT_LISTENER_GROUP, + MessageModel.CLUSTERING, + TopicConstants.PATROL, + "*", + new OpenDataPatrolChangeEventListener()); + register(consumerProperties, + ConsomerGroupConstants.PROJECT_CHANGED_COMPONENTS_GROUP, + MessageModel.CLUSTERING, + TopicConstants.PROJECT_CHANGED, + "*", + new OpenDataProjectChangeEventListener()); + + // ...其他监听器类似 + } +} diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataOrgChangeEventListener.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataOrgChangeEventListener.java new file mode 100644 index 0000000000..04e95a893b --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataOrgChangeEventListener.java @@ -0,0 +1,115 @@ +package com.epmet.opendata.mq.listener; + +import com.alibaba.fastjson.JSON; +import com.epmet.commons.rocketmq.constants.MQUserPropertys; +import com.epmet.commons.rocketmq.messages.OrgOrStaffMQMsg; +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.opendata.dto.form.GridBaseInfoFormDTO; +import com.epmet.opendata.service.BaseGridInfoService; +import org.apache.commons.lang.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.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; + +/** + * @Description 系统对接中间库,组织信息变更监听器 + * @author wxz + * @date 2021.10.13 15:21:48 +*/ +public class OpenDataOrgChangeEventListener 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) { + // msg即为消息体 + // tags为SystemMessageType.java中的项,为具体的操作,此处拿到tags,判断是创建还是变更,来做响应的后续操作即可 + String msg = new String(messageExt.getBody()); + String topic = messageExt.getTopic(); + String tags = messageExt.getTags(); + String pendingMsgLabel = messageExt.getUserProperty(MQUserPropertys.BLOCKED_MSG_LABEL); + + logger.info("【开放数据事件监听器】-组织信息变更-收到消息内容:{},操作:{}", msg, tags); + OrgOrStaffMQMsg obj = JSON.parseObject(msg, OrgOrStaffMQMsg.class); + + DistributedLock distributedLock = null; + RLock lock = null; + try { + distributedLock = SpringContextUtils.getBean(DistributedLock.class); + lock = distributedLock.getLock(String.format("lock:open_data_org:%s", obj.getOrgId()), + 30L, 30L, TimeUnit.SECONDS); + + GridBaseInfoFormDTO dto = new GridBaseInfoFormDTO(); + dto.setCustomerId(obj.getCustomerId()); + dto.setType(obj.getType()); + List orgIdList = new ArrayList<>(); + orgIdList.add(obj.getOrgId()); + if ("agency".equals(obj.getOrgType())) { + SpringContextUtils.getBean(BaseGridInfoService.class).getAgencyBaseInfo(dto); + } else { + SpringContextUtils.getBean(BaseGridInfoService.class).getGridBaseInfo(dto); + } + } catch (RenException e) { + // 如果是我们手动抛出的异常,说明在业务可控范围内。目前不需要MQ重试 + logger.error("【开放数据事件监听器】-组织信息变更-同步信息到中间库失败:".concat(ExceptionUtils.getErrorStackTrace(e))); + } catch (Exception e) { + // 不是我们自己抛出的异常,可以让MQ重试 + logger.error("【开放数据事件监听器】-组织信息变更-同步信息到中间库失败:".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("【开放数据事件监听器】删除mq阻塞消息缓存成功,blockedMsgLabel:{}", pendingMsgLabel); + } +} diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataPatrolChangeEventListener.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataPatrolChangeEventListener.java new file mode 100644 index 0000000000..6207c6fa74 --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataPatrolChangeEventListener.java @@ -0,0 +1,125 @@ +package com.epmet.opendata.mq.listener; + +import com.alibaba.fastjson.JSON; +import com.epmet.commons.rocketmq.constants.MQUserPropertys; +import com.epmet.commons.rocketmq.messages.StaffPatrolMQMsg; +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.constant.SystemMessageType; +import com.epmet.opendata.dto.form.UpsertPatrolRecordForm; +import com.epmet.opendata.service.UserPatrolRecordService; +import lombok.extern.slf4j.Slf4j; +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 wxz + * @Description 系统对接中间库,巡查信息变更监听器 + * @date 2021.10.13 15:21:48 + */ +@Slf4j +public class OpenDataPatrolChangeEventListener 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) { + // msg即为消息体 + // tags为SystemMessageType.java中的项,为具体的操作,此处拿到tags,判断是创建还是变更,来做响应的后续操作即可 + String msg = new String(messageExt.getBody()); + String topic = messageExt.getTopic(); + String tags = messageExt.getTags(); + String pendingMsgLabel = messageExt.getUserProperty(MQUserPropertys.BLOCKED_MSG_LABEL); + + logger.info("【开放数据事件监听器】-巡查记录信息变更-收到消息内容:{}, 操作:{}", msg, tags); + StaffPatrolMQMsg msgObj = JSON.parseObject(msg, StaffPatrolMQMsg.class); + if (msgObj == null) { + log.warn("consumeMessage msg body is blank"); + return; + } + DistributedLock distributedLock = null; + RLock lock = null; + try { + distributedLock = SpringContextUtils.getBean(DistributedLock.class); + lock = distributedLock.getLock(String.format("lock:open_data_patrol:%s", msgObj.getPatrolId()), + 30L, 30L, TimeUnit.SECONDS); + UpsertPatrolRecordForm patrolRecordForm = new UpsertPatrolRecordForm(); + patrolRecordForm.setCustomerId(msgObj.getCustomerId()); + patrolRecordForm.setPatrolId(msgObj.getPatrolId()); + patrolRecordForm.setActionType(tags); + Boolean aBoolean = false; + switch (tags) { + case SystemMessageType.USER_PATROL_START: + aBoolean = SpringContextUtils.getBean(UserPatrolRecordService.class).insertPatrolRecord(patrolRecordForm); + break; + case SystemMessageType.USER_PATROL_STOP: + aBoolean = SpringContextUtils.getBean(UserPatrolRecordService.class).updatePatrolRecord(patrolRecordForm); + break; + default: + log.error("错误的消息类型:{}", tags); + + } + + } catch (RenException e) { + // 如果是我们手动抛出的异常,说明在业务可控范围内。目前不需要MQ重试 + logger.error("【开放数据事件监听器】-巡查记录信息变更-失败:".concat(ExceptionUtils.getErrorStackTrace(e))); + } catch (Exception e) { + // 不是我们自己抛出的异常,可以让MQ重试 + logger.error("【开放数据事件监听器】-巡查记录信息变更-失败:".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)); + } + } + } + + /** + * @param pendingMsgLabel + * @return + * @description + * @author wxz + * @date 2021.10.14 16:32:32 + */ + private void removePendingMqMsgCache(String pendingMsgLabel) { + String key = RedisKeys.blockedMqMsgKey(pendingMsgLabel); + redisUtils.delete(key); + //logger.info("【开放数据事件监听器】删除mq阻塞消息缓存成功,blockedMsgLabel:{}", pendingMsgLabel); + } +} diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataProjectChangeEventListener.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataProjectChangeEventListener.java new file mode 100644 index 0000000000..e82e2cd8c9 --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataProjectChangeEventListener.java @@ -0,0 +1,108 @@ +package com.epmet.opendata.mq.listener; + +import com.alibaba.fastjson.JSON; +import com.epmet.commons.rocketmq.constants.MQUserPropertys; +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.dto.basereport.form.EventInfoFormDTO; +import com.epmet.feign.EpmetMessageOpenFeignClient; +import com.epmet.opendata.service.BaseDisputeProcessService; +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 wxz + * @Description 系统对接中间库,项目信息变更监听器 + * @date 2021.10.13 15:21:48 + */ +public class OpenDataProjectChangeEventListener implements MessageListenerConcurrently { + + private Logger logger = LoggerFactory.getLogger(getClass()); + + private EpmetMessageOpenFeignClient messageOpenFeignClient; + + 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) { + // msg即为消息体 + // tags为SystemMessageType.java中的项,为具体的操作,此处拿到tags,判断是创建还是变更,来做响应的后续操作即可 + String msg = new String(messageExt.getBody()); + String topic = messageExt.getTopic(); + String tags = messageExt.getTags(); + String pendingMsgLabel = messageExt.getUserProperty(MQUserPropertys.BLOCKED_MSG_LABEL); + + //messageExt.propert + + logger.info("【开放数据事件监听器】-项目信息变更-收到消息内容:{}, 操作:{}, pendingMsgLabel:{}", msg, tags, pendingMsgLabel); + EventInfoFormDTO obj = JSON.parseObject(msg, EventInfoFormDTO.class); + + DistributedLock distributedLock = null; + RLock lock = null; + try { + distributedLock = SpringContextUtils.getBean(DistributedLock.class); + lock = distributedLock.getLock(String.format("lock:open_data_project:%s", obj.getProjectId()), + 30L, 30L, TimeUnit.SECONDS); + SpringContextUtils.getBean(BaseDisputeProcessService.class).getEventinfo(obj); + } catch (RenException e) { + // 如果是我们手动抛出的异常,说明在业务可控范围内。目前不需要MQ重试 + logger.error("【开放数据事件监听器】-项目信息变更-上报项目信息失败:".concat(ExceptionUtils.getErrorStackTrace(e))); + } catch (Exception e) { + // 不是我们自己抛出的异常,可以让MQ重试 + logger.error("【开放数据事件监听器】-项目信息变更-上报项目信息失败:".concat(ExceptionUtils.getErrorStackTrace(e))); + throw e; + } finally { + distributedLock.unLock(lock); + } + + if (StringUtils.isNotBlank(pendingMsgLabel)) { + try { + removePendingMqMsgCache(pendingMsgLabel); + } catch (Exception e) { + logger.error("【开放数据事件监听器】-project-删除mq滞留消息缓存失败:{}", ExceptionUtils.getErrorStackTrace(e)); + } + } + } + + /** + * @description + * + * @param pendingMsgLabel + * @return + * @description 应答mq消息 + * @author wxz + * @date 2021.10.14 16:32:32 + */ + private void removePendingMqMsgCache(String pendingMsgLabel) { + String key = RedisKeys.blockedMqMsgKey(pendingMsgLabel); + redisUtils.delete(key); + } +} diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataStaffChangeEventListener.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataStaffChangeEventListener.java new file mode 100644 index 0000000000..48d0ece671 --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataStaffChangeEventListener.java @@ -0,0 +1,116 @@ +package com.epmet.opendata.mq.listener; + +import com.epmet.commons.rocketmq.constants.MQUserPropertys; +import com.alibaba.fastjson.JSON; +import com.epmet.commons.rocketmq.messages.OrgOrStaffMQMsg; +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.feign.EpmetMessageOpenFeignClient; +import com.epmet.opendata.dto.form.StaffBaseInfoFormDTO; +import com.epmet.opendata.service.BaseGridUserService; +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.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; + +/** + * @author wxz + * @Description 系统对接中间库,工作人员信息变更监听器 + * @date 2021.10.13 15:21:48 + */ +public class OpenDataStaffChangeEventListener implements MessageListenerConcurrently { + + private Logger logger = LoggerFactory.getLogger(getClass()); + + private EpmetMessageOpenFeignClient messageOpenFeignClient; + + 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) { + // msg即为消息体 + // tags为SystemMessageType.java中的项,为具体的操作,此处拿到tags,判断是创建还是变更,来做响应的后续操作即可 + String msg = new String(messageExt.getBody()); + String topic = messageExt.getTopic(); + String tags = messageExt.getTags(); + String pendingMsgLabel = messageExt.getUserProperty(MQUserPropertys.BLOCKED_MSG_LABEL); + + //messageExt.propert + + logger.info("【开放数据事件监听器】-工作人员信息变更-收到消息内容:{}, 操作:{}, blockedMsgLabel:{}", msg, tags, pendingMsgLabel); + OrgOrStaffMQMsg obj = JSON.parseObject(msg, OrgOrStaffMQMsg.class); + + DistributedLock distributedLock = null; + RLock lock = null; + try { + distributedLock = SpringContextUtils.getBean(DistributedLock.class); + lock = distributedLock.getLock(String.format("lock:open_data_staff:%s", obj.getOrgId()), + 30L, 30L, TimeUnit.SECONDS); + + StaffBaseInfoFormDTO dto = new StaffBaseInfoFormDTO(); + dto.setCustomerId(obj.getCustomerId()); + dto.setType(obj.getType()); + List staffIdList = new ArrayList<>(); + staffIdList.add(obj.getOrgId()); + SpringContextUtils.getBean(BaseGridUserService.class).getStaffBaseInfo(dto); + } catch (RenException e) { + // 如果是我们手动抛出的异常,说明在业务可控范围内。目前不需要MQ重试 + logger.error("【开放数据事件监听器】-工作人员信息变更-初始化客户组织失败:".concat(ExceptionUtils.getErrorStackTrace(e))); + } catch (Exception e) { + // 不是我们自己抛出的异常,可以让MQ重试 + logger.error("【开放数据事件监听器】-工作人员信息变更-初始化客户组织失败:".concat(ExceptionUtils.getErrorStackTrace(e))); + throw e; + } finally { + distributedLock.unLock(lock); + } + + if (StringUtils.isNotBlank(pendingMsgLabel)) { + try { + removePendingMqMsgCache(pendingMsgLabel); + } catch (Exception e) { + logger.error("【开放数据事件监听器】-staff-删除mq阻塞消息缓存失败:{}", ExceptionUtils.getErrorStackTrace(e)); + } + } + } + + /** + * @description + * + * @param pendingMsgLabel + * @return + * @description 应答mq消息 + * @author wxz + * @date 2021.10.14 16:32:32 + */ + private void removePendingMqMsgCache(String pendingMsgLabel) { + String key = RedisKeys.blockedMqMsgKey(pendingMsgLabel); + redisUtils.delete(key); + } +} diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/BaseDisputeProcessService.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/BaseDisputeProcessService.java new file mode 100644 index 0000000000..20d2516dab --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/BaseDisputeProcessService.java @@ -0,0 +1,40 @@ +/** + * 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.opendata.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.dto.basereport.form.EventInfoFormDTO; +import com.epmet.opendata.entity.BaseDisputeProcessEntity; + +/** + * 事件信息表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-15 + */ +public interface BaseDisputeProcessService extends BaseService { + + /** + * 获取上报事件 + * @Param formDTO + * @Return + * @Author zhaoqifeng + * @Date 2021/10/15 16:59 + */ + void getEventinfo(EventInfoFormDTO formDTO); +} \ No newline at end of file diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/BaseGridInfoService.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/BaseGridInfoService.java new file mode 100644 index 0000000000..f0fe03c28a --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/BaseGridInfoService.java @@ -0,0 +1,44 @@ +/** + * 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.opendata.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.opendata.dto.form.GridBaseInfoFormDTO; +import com.epmet.opendata.entity.BaseGridInfoEntity; + +/** + * 网格基础信息表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-15 + */ +public interface BaseGridInfoService extends BaseService { + + /** + * @Author sun + * @Description 组织基础信息中介库同步 + **/ + void getAgencyBaseInfo(GridBaseInfoFormDTO formDTO); + + /** + * @Author sun + * @Description 网格基础信息中介库同步 + **/ + void getGridBaseInfo(GridBaseInfoFormDTO formDTO); + +} \ No newline at end of file diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/BaseGridUserService.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/BaseGridUserService.java new file mode 100644 index 0000000000..2cdda5d9c5 --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/BaseGridUserService.java @@ -0,0 +1,38 @@ +/** + * 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.opendata.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.opendata.dto.form.StaffBaseInfoFormDTO; +import com.epmet.opendata.entity.BaseGridUserEntity; + +/** + * 网格员基础信息表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-15 + */ +public interface BaseGridUserService extends BaseService { + + /** + * @Author sun + * @Description 网格员信息中间库同步 + **/ + void getStaffBaseInfo(StaffBaseInfoFormDTO formDTO); + +} \ No newline at end of file diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/UserPatrolDetailService.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/UserPatrolDetailService.java new file mode 100644 index 0000000000..13cde46235 --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/UserPatrolDetailService.java @@ -0,0 +1,35 @@ +/** + * 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.opendata.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.opendata.entity.UserPatrolDetailEntity; + +/** + * 工作人员巡查记录明细 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-14 + */ +public interface UserPatrolDetailService extends BaseService { + + + int deleteByPatrolId(String patrolId); + + int deleteByCustomerId(String customerId); +} diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/UserPatrolRecordService.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/UserPatrolRecordService.java new file mode 100644 index 0000000000..e6896f32b8 --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/UserPatrolRecordService.java @@ -0,0 +1,53 @@ +/** + * 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.opendata.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.opendata.dto.form.UpsertPatrolRecordForm; +import com.epmet.opendata.entity.UserPatrolRecordEntity; + +/** + * 用户巡查主记录 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-14 + */ +public interface UserPatrolRecordService extends BaseService { + + /** + * desc:根据条件插入巡查记录 + * @param patrolRecordForm + * @return + */ + Boolean insertPatrolRecord(UpsertPatrolRecordForm patrolRecordForm); + + /** + * desc:根据条件更新巡查记录及轨迹 + * @param patrolRecordForm + * @return + */ + Boolean updatePatrolRecord(UpsertPatrolRecordForm patrolRecordForm); + + /** + * desc:重新加载数据 + * @param customerId + * @return + */ + Boolean reloadPatrolData(String customerId); + +} diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BaseDisputeProcessServiceImpl.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BaseDisputeProcessServiceImpl.java new file mode 100644 index 0000000000..0a0d18a9f0 --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BaseDisputeProcessServiceImpl.java @@ -0,0 +1,74 @@ +/** + * 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.opendata.service.impl; + +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.basereport.form.EventInfoFormDTO; +import com.epmet.feign.DataStatisticalOpenFeignClient; +import com.epmet.opendata.dao.BaseDisputeProcessDao; +import com.epmet.opendata.dto.BaseDisputeProcessDTO; +import com.epmet.opendata.entity.BaseDisputeProcessEntity; +import com.epmet.opendata.service.BaseDisputeProcessService; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 事件信息表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-15 + */ +@Service +public class BaseDisputeProcessServiceImpl extends BaseServiceImpl implements BaseDisputeProcessService { + @Resource + private DataStatisticalOpenFeignClient dataStatisticalOpenFeignClient; + + /** + * 获取上报事件 + * + * @param formDTO + * @Param formDTO + * @Return + * @Author zhaoqifeng + * @Date 2021/10/15 16:59 + */ + @Override + public void getEventinfo(EventInfoFormDTO formDTO) { + Result> result = dataStatisticalOpenFeignClient.getEventInfo(formDTO); + if (!result.success()) { + throw new RenException(result.getInternalMsg()); + } + List list = result.getData(); + if (CollectionUtils.isNotEmpty(list)) { + List entityList = ConvertUtils.sourceToTarget(list, BaseDisputeProcessEntity.class); + if("add".equals(formDTO.getType())){ + insertBatch(entityList); + }else { + updateBatchById(entityList); + } + } + + } + +} \ No newline at end of file diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BaseGridInfoServiceImpl.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BaseGridInfoServiceImpl.java new file mode 100644 index 0000000000..1d4f4a1e17 --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BaseGridInfoServiceImpl.java @@ -0,0 +1,123 @@ +/** + * 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.opendata.service.impl; + +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.org.result.CustomerAgencyDTO; +import com.epmet.dto.org.result.CustomerGridDTO; +import com.epmet.feign.DataStatisticalOpenFeignClient; +import com.epmet.opendata.dao.BaseGridInfoDao; +import com.epmet.opendata.dto.form.GridBaseInfoFormDTO; +import com.epmet.opendata.entity.BaseGridInfoEntity; +import com.epmet.opendata.service.BaseGridInfoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.List; + +/** + * 网格基础信息表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-15 + */ +@Service +public class BaseGridInfoServiceImpl extends BaseServiceImpl implements BaseGridInfoService { + @Autowired + private DataStatisticalOpenFeignClient dataStatisticalOpenFeignClient; + + /** + * @Author sun + * @Description 组织基础信息中介库同步 + **/ + @Override + @Transactional(rollbackFor = Exception.class) + public void getAgencyBaseInfo(GridBaseInfoFormDTO formDTO) { + //1.查询网格基础信息 + Result> result = dataStatisticalOpenFeignClient.getAgencyBaseInfo(formDTO); + if (!result.success()) { + throw new RenException(result.getInternalMsg()); + } + //2.中间库新增/修改数据 + List entityList = new ArrayList<>(); + result.getData().forEach(ag->{ + BaseGridInfoEntity entity = new BaseGridInfoEntity(); + entity.setCustomerId(ag.getCustomerId()); + entity.setOrgId(ag.getId()); + entity.setCode(""); + entity.setGridName(ag.getOrganizationName()); + String level = "06"; + if("province".equals(ag.getLevel())){ level = "01"; } + else if("city".equals(ag.getLevel())){ level = "02"; } + else if("district".equals(ag.getLevel())){ level = "03"; } + else if("street".equals(ag.getLevel())){ level = "04"; } + entity.setGridLevel(level); + entity.setGridType("01"); + entity.setDelFlag(ag.getDelFlag().toString()); + entity.setUpdatedBy(ag.getUpdatedBy()); + entity.setUpdatedTime(ag.getUpdatedTime()); + entityList.add(entity); + }); + if("add".equals(formDTO.getType())){ + insertBatch(entityList); + }else { + baseDao.updateBatch(entityList); + } + + } + + /** + * @Author sun + * @Description 网格基础信息中介库同步 + **/ + @Override + @Transactional(rollbackFor = Exception.class) + public void getGridBaseInfo(GridBaseInfoFormDTO formDTO) { + //1.查询网格基础信息 + Result> result = dataStatisticalOpenFeignClient.getGridBaseInfo(formDTO); + if (!result.success()) { + throw new RenException(result.getInternalMsg()); + } + //2.中间库新增/修改数据 + List entityList = new ArrayList<>(); + result.getData().forEach(ag->{ + BaseGridInfoEntity entity = new BaseGridInfoEntity(); + entity.setCustomerId(ag.getCustomerId()); + entity.setOrgId(ag.getId()); + entity.setCode(""); + entity.setGridName(ag.getGridName()); + entity.setGridLevel("07"); + entity.setGridType("01"); + entity.setDelFlag(ag.getDelFlag().toString()); + entity.setUpdatedBy(ag.getUpdatedBy()); + entity.setUpdatedTime(ag.getUpdatedTime()); + entityList.add(entity); + }); + if("add".equals(formDTO.getType())){ + insertBatch(entityList); + }else { + baseDao.updateBatch(entityList); + } + + } + +} \ No newline at end of file diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BaseGridUserServiceImpl.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BaseGridUserServiceImpl.java new file mode 100644 index 0000000000..c323a8e2c4 --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BaseGridUserServiceImpl.java @@ -0,0 +1,73 @@ +/** + * 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.opendata.service.impl; + +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.org.result.CustomerAgencyDTO; +import com.epmet.dto.user.result.CustomerStaffDTO; +import com.epmet.dto.user.result.GridUserInfoDTO; +import com.epmet.feign.DataStatisticalOpenFeignClient; +import com.epmet.opendata.dao.BaseGridUserDao; +import com.epmet.opendata.dto.form.StaffBaseInfoFormDTO; +import com.epmet.opendata.entity.BaseGridInfoEntity; +import com.epmet.opendata.entity.BaseGridUserEntity; +import com.epmet.opendata.service.BaseGridUserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.List; + +/** + * 网格员基础信息表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-15 + */ +@Service +public class BaseGridUserServiceImpl extends BaseServiceImpl implements BaseGridUserService { + @Autowired + private DataStatisticalOpenFeignClient dataStatisticalOpenFeignClient; + + /** + * @Author sun + * @Description 网格员信息中间库同步 + **/ + @Override + @Transactional(rollbackFor = Exception.class) + public void getStaffBaseInfo(StaffBaseInfoFormDTO formDTO) { + //1.查询网格基础信息 + Result> result = dataStatisticalOpenFeignClient.getStaffBaseInfo(formDTO); + if (!result.success()) { + throw new RenException(result.getInternalMsg()); + } + //2.中间库新增/修改数据 + List entityList = ConvertUtils.sourceToTarget(result.getData(), BaseGridUserEntity.class); + if("add".equals(formDTO.getType())){ + insertBatch(entityList); + }else { + baseDao.updateBatch(entityList); + } + + } + +} \ No newline at end of file diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/UserPatrolDetailServiceImpl.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/UserPatrolDetailServiceImpl.java new file mode 100644 index 0000000000..a8e9b220bc --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/UserPatrolDetailServiceImpl.java @@ -0,0 +1,50 @@ +/** + * 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.opendata.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.opendata.dao.UserPatrolDetailDao; +import com.epmet.opendata.entity.UserPatrolDetailEntity; +import com.epmet.opendata.service.UserPatrolDetailService; +import org.springframework.stereotype.Service; + +/** + * 工作人员巡查记录明细 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-14 + */ +@Service +public class UserPatrolDetailServiceImpl extends BaseServiceImpl implements UserPatrolDetailService { + + + @Override + public int deleteByPatrolId(String patrolId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(UserPatrolDetailEntity::getStaffPatrolRecId, patrolId); + return baseDao.delete(wrapper); + } + + @Override + public int deleteByCustomerId(String customerId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(UserPatrolDetailEntity::getCustomerId, customerId); + return baseDao.delete(wrapper); + } +} diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/UserPatrolRecordServiceImpl.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/UserPatrolRecordServiceImpl.java new file mode 100644 index 0000000000..0a5312e602 --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/UserPatrolRecordServiceImpl.java @@ -0,0 +1,235 @@ +/** + * 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.opendata.service.impl; + +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.dto.user.param.MidPatrolFormDTO; +import com.epmet.dto.user.result.MidPatrolRecordResult; +import com.epmet.feign.DataStatisticalOpenFeignClient; +import com.epmet.opendata.dao.UserPatrolRecordDao; +import com.epmet.opendata.dto.form.UpsertPatrolRecordForm; +import com.epmet.opendata.entity.UserPatrolDetailEntity; +import com.epmet.opendata.entity.UserPatrolRecordEntity; +import com.epmet.opendata.service.UserPatrolDetailService; +import com.epmet.opendata.service.UserPatrolRecordService; +import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.NotNull; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import java.util.ArrayList; +import java.util.List; + + +/** + * 用户巡查主记录 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-14 + */ +@Slf4j +@Service +public class UserPatrolRecordServiceImpl extends BaseServiceImpl implements UserPatrolRecordService { + + @Autowired + private DataStatisticalOpenFeignClient dataStatisticalOpenFeignClient; + @Autowired + private UserPatrolDetailService userPatrolDetailService; + + @Override + public Boolean insertPatrolRecord(UpsertPatrolRecordForm patrolRecordForm) { + log.info("upsertPatrolRecord param:{}", JSON.toJSONString(patrolRecordForm)); + ValidatorUtils.validateEntity(patrolRecordForm); + MidPatrolFormDTO midPatrolFormDTO = buildParam(patrolRecordForm); + Result> record = dataStatisticalOpenFeignClient.getPatrolRecordList(midPatrolFormDTO); + if (record == null || !record.success()) { + log.error("获取巡查记录失败,param:{}", JSON.toJSONString(midPatrolFormDTO)); + return false; + } + List data = record.getData(); + if (CollectionUtils.isEmpty(data)) { + //数据已被删除了 + //暂时设置error 用于排错 + log.error("获取巡查记录返回为空,param:{}", JSON.toJSONString(midPatrolFormDTO)); + int effectRow = baseDao.deleteById(patrolRecordForm.getPatrolId()); + log.warn("del effectRow:{}", effectRow); + return true; + } + List insertList = new ArrayList<>(); + data.forEach(o-> insertList.add(buildEntity(o))); + //insert + if (CollectionUtils.isEmpty(insertList)){ + log.error("构建要插入的数据为空,param:{}", JSON.toJSONString(midPatrolFormDTO)); + return false; + } + this.insertBatch(insertList, NumConstant.ONE_HUNDRED); + return true; + } + + @Override + public Boolean updatePatrolRecord(UpsertPatrolRecordForm patrolRecordForm) { + log.info("updatePatrolRecord param:{}", JSON.toJSONString(patrolRecordForm)); + ValidatorUtils.validateEntity(patrolRecordForm); + MidPatrolFormDTO midPatrolFormDTO = buildParam(patrolRecordForm); + Result> record = dataStatisticalOpenFeignClient.getPatrolRecordList(midPatrolFormDTO); + if (record == null || !record.success()) { + log.error("获取巡查记录失败,param:{}", JSON.toJSONString(midPatrolFormDTO)); + return false; + } + List data = record.getData(); + if (CollectionUtils.isEmpty(data)) { + //数据已被删除了 + //暂时设置error 用于排错 + log.error("获取巡查记录返回为空,param:{}", JSON.toJSONString(midPatrolFormDTO)); + int effectRow = baseDao.deleteById(patrolRecordForm.getPatrolId()); + log.warn("del effectRow:{}", effectRow); + return true; + } + data.forEach(o->{ + UserPatrolRecordEntity recordEntity = buildEntity(o); + //update + int effectRow = baseDao.updateById(recordEntity); + if (effectRow == NumConstant.ZERO) { + baseDao.insert(recordEntity); + } + UserPatrolDetailEntity detailEntity = buildDetailEntity(o); + //先删除再新增 + userPatrolDetailService.deleteByPatrolId(recordEntity.getId()); + boolean insert = userPatrolDetailService.insert(detailEntity); + }); + + return true; + } + + @Override + public Boolean reloadPatrolData(String customerId) { + int pageNo = 1; + int pageSize = 1000; + List resultList = null; + do { + MidPatrolFormDTO param = new MidPatrolFormDTO(); + param.setCustomerId(customerId); + param.setPageNo(pageNo++); + param.setPageSize(pageSize); + Result> record = dataStatisticalOpenFeignClient.getPatrolRecordList(param); + if (record == null || !record.success()) { + log.error("获取巡查记录失败,param:{}", JSON.toJSONString(param)); + return false; + } + resultList = record.getData(); + if (CollectionUtils.isEmpty(resultList)){ + log.warn("不存在巡查记录,param:{}", JSON.toJSONString(param)); + return false; + } + insertRecordBatch(resultList,true); + + + + }while (!CollectionUtils.isEmpty(resultList) && resultList.size()> pageSize ); + + return null; + } + private Boolean insertRecordBatch(List list,boolean isReload){ + List insertList = new ArrayList<>(); + list.forEach(o-> insertList.add(buildEntity(o))); + //insert + if (CollectionUtils.isEmpty(insertList)){ + log.error("构建要插入的数据为空,param:{}", JSON.toJSONString(list)); + return false; + } + if (isReload){ + int i = userPatrolDetailService.deleteByCustomerId(list.get(0).getCustomerId()); + log.info("insertRecordBatch del patrol effectRow:{}",i); + } + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(UserPatrolRecordEntity::getCustomerId, list.get(0).getCustomerId()); + int delete = baseDao.delete(wrapper); + log.info("insertRecordBatch del patrol effectRow:{}",delete); + this.insertBatch(insertList, NumConstant.ONE_HUNDRED); + List insertDetailList = new ArrayList<>(); + list.forEach(o-> { + insertDetailList.add(buildDetailEntity(o)); + if (!isReload){ + //先删除再新增 + userPatrolDetailService.deleteByPatrolId(o.getId()); + } + }); + if (CollectionUtils.isEmpty(insertList)){ + log.warn("构建要插入的数据为空,param:{}", JSON.toJSONString(list)); + } + userPatrolDetailService.insertBatch(insertDetailList, NumConstant.ONE_HUNDRED); + return true; + } + + @NotNull + private UserPatrolDetailEntity buildDetailEntity(MidPatrolRecordResult recordResult) { + UserPatrolDetailEntity detailEntity = new UserPatrolDetailEntity(); + detailEntity.setCustomerId(recordResult.getCustomerId()); + detailEntity.setStaffPatrolRecId(recordResult.getId()); + detailEntity.setRoute(recordResult.getRoute()); + detailEntity.setId(recordResult.getId()); + detailEntity.setRevision(recordResult.getRevision()); + detailEntity.setCreatedBy(recordResult.getCreatedBy()); + detailEntity.setCreatedTime(recordResult.getCreatedTime()); + detailEntity.setUpdatedBy(recordResult.getUpdatedBy()); + detailEntity.setUpdatedTime(recordResult.getUpdatedTime()); + detailEntity.setDelFlag(String.valueOf(recordResult.getDelFlag())); + return detailEntity; + } + + private UserPatrolRecordEntity buildEntity(MidPatrolRecordResult recordResult) { + UserPatrolRecordEntity entity = new UserPatrolRecordEntity(); + entity.setCustomerId(recordResult.getCustomerId()); + entity.setGrid(recordResult.getGrid()); + entity.setGridPids(recordResult.getGridPids()); + entity.setStaffId(recordResult.getStaffId()); + entity.setAgencyId(recordResult.getAgencyId()); + entity.setPatrolStartTime(recordResult.getPatrolStartTime()); + entity.setPatrolEndTime(recordResult.getPatrolEndTime()); + entity.setActrualEndTime(recordResult.getActrualEndTime()); + entity.setStartLocation(""); + entity.setEndLocation(""); + entity.setTotalTime(recordResult.getTotalTime()); + entity.setDistance(0); + entity.setStatus(recordResult.getStatus()); + entity.setId(recordResult.getId()); + entity.setRevision(recordResult.getRevision()); + entity.setCreatedBy(recordResult.getCreatedBy()); + entity.setCreatedTime(recordResult.getCreatedTime()); + entity.setUpdatedBy(recordResult.getUpdatedBy()); + entity.setUpdatedTime(recordResult.getUpdatedTime()); + entity.setDelFlag(String.valueOf(recordResult.getDelFlag())); + return entity; + } + + @NotNull + private MidPatrolFormDTO buildParam(UpsertPatrolRecordForm patrolRecordForm) { + MidPatrolFormDTO midPatrolFormDTO = new MidPatrolFormDTO(); + midPatrolFormDTO.setCustomerId(patrolRecordForm.getCustomerId()); + midPatrolFormDTO.setPatrolId(patrolRecordForm.getPatrolId()); + midPatrolFormDTO.setPageNo(patrolRecordForm.getPageNo()); + midPatrolFormDTO.setPageSize(patrolRecordForm.getPageSize()); + return midPatrolFormDTO; + } +} diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/bootstrap.yml b/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/bootstrap.yml new file mode 100644 index 0000000000..49db95eb6d --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/bootstrap.yml @@ -0,0 +1,138 @@ +server: + port: @server.port@ + version: @version@ + servlet: + context-path: /opendata + +spring: + main: + allow-bean-definition-overriding: true + application: + name: open-data-worker-server + #环境 dev|test|prod + profiles: + active: @spring.profiles.active@ + jackson: + time-zone: GMT+8 + date-format: yyyy-MM-dd HH:mm:ss + redis: + database: @spring.redis.index@ + host: @spring.redis.host@ + port: @spring.redis.port@ + password: @spring.redis.password@ + timeout: 30s + datasource: + druid: + #MySQL + driver-class-name: com.mysql.cj.jdbc.Driver + url: @spring.datasource.druid.url@ + username: @spring.datasource.druid.username@ + password: @spring.datasource.druid.password@ + cloud: + nacos: + discovery: + server-addr: @nacos.server-addr@ + #nacos的命名空间ID,默认是public + namespace: @nacos.discovery.namespace@ + #不把自己注册到注册中心的地址 + register-enabled: @nacos.register-enabled@ + ip: @nacos.ip@ + serviceListChangedListening: + enable: @nacos.service-list-changed-listening.enable@ + config: + enabled: @nacos.config-enabled@ + server-addr: @nacos.server-addr@ + namespace: @nacos.config.namespace@ + group: @nacos.config.group@ + file-extension: yaml + #指定共享配置,且支持动态刷新 +# ext-config: +# - data-id: datasource.yaml +# group: ${spring.cloud.nacos.config.group} +# refresh: true +# - data-id: common.yaml +# group: ${spring.cloud.nacos.config.group} +# refresh: true + + # 数据迁移工具flyway + flyway: + enabled: @spring.flyway.enabled@ + locations: classpath:db/migration + url: @spring.datasource.druid.url@ + user: @spring.datasource.druid.username@ + password: @spring.datasource.druid.password@ + baseline-on-migrate: true + baseline-version: 0 + + +management: + endpoints: + web: + exposure: + include: "*" + endpoint: + health: + show-details: ALWAYS + +mybatis-plus: + mapper-locations: classpath:/mapper/**/*.xml + #实体扫描,多个package用逗号或者分号分隔 + typeAliasesPackage: com.epmet.entity + global-config: + #数据库相关配置 + db-config: + #主键类型 AUTO:"数据库ID自增", INPUT:"用户输入ID", ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID"; + id-type: ID_WORKER + #字段策略 IGNORED:"忽略判断",NOT_NULL:"非 NULL 判断"),NOT_EMPTY:"非空判断" + field-strategy: NOT_NULL + #驼峰下划线转换 + column-underline: true + banner: false + #原生配置 + configuration: + map-underscore-to-camel-case: true + cache-enabled: false + call-setters-on-nulls: true + jdbc-type-for-null: 'null' + +feign: + hystrix: + enabled: true + client: + config: + default: + loggerLevel: BASIC + okhttp: + enabled: true + +hystrix: + command: + default: + execution: + isolation: + thread: + timeoutInMilliseconds: 60000 #缺省为1000 + +ribbon: + ReadTimeout: 300000 + ConnectTimeout: 300000 + +#pageHelper分页插件 +pagehelper: + helper-dialect: mysql + reasonable: false #分页合理化配置,例如输入页码为-1,则自动转化为最小页码1 + +#feign 日志需要该配置 +logging: + level: + com.epmet: debug + +dingTalk: + robot: + webHook: @dingTalk.robot.webHook@ + secret: @dingTalk.robot.secret@ + +rocketmq: + # 是否开启mq + enable: @rocketmq.enable@ + name-server: @rocketmq.nameserver@ \ No newline at end of file diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/init_db.sql b/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/init_db.sql new file mode 100644 index 0000000000..ac7d9c109c --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/init_db.sql @@ -0,0 +1,14 @@ +create database epmet_open_data default character set utf8mb4 collate utf8mb4_general_ci; + +-- 开发环境的脚本 +CREATE USER epmet_open_data_user@'%' IDENTIFIED BY 'EpmEt-db-UsEr'; +GRANT ALL ON `epmet_open_data`.* TO 'epmet_open_data_user'@'%'; +flush privileges; + + + +-- 测试环境的脚本 + + + +-- 生产环境的数据 \ No newline at end of file diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/logback-spring.xml b/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/logback-spring.xml new file mode 100644 index 0000000000..bcbff37445 --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/logback-spring.xml @@ -0,0 +1,176 @@ + + + + + + + + + + + + + ${appname} + + + + + + + + + debug + + + ${CONSOLE_LOG_PATTERN} + + UTF-8 + + + + + + + + ${log.path}/debug.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + + ${log.path}/debug-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + debug + ACCEPT + DENY + + + + + + + ${log.path}/info.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + + ${log.path}/info-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + info + ACCEPT + DENY + + + + + + + ${log.path}/warn.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + ${log.path}/warn-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + warn + ACCEPT + DENY + + + + + + + ${log.path}/error.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + ${log.path}/error-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + ERROR + ACCEPT + DENY + ${webHook} + ${secret} + ${appname} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/BaseDisputeProcessDao.xml b/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/BaseDisputeProcessDao.xml new file mode 100644 index 0000000000..6fbc4d42a5 --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/BaseDisputeProcessDao.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/BaseGridInfoDao.xml b/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/BaseGridInfoDao.xml new file mode 100644 index 0000000000..4d823eac28 --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/BaseGridInfoDao.xml @@ -0,0 +1,50 @@ + + + + + + + UPDATE base_grid_info + + + + + + when org_id = #{item.orgId} then #{item.gridName} + + + + + + + + when org_id = #{item.orgId} then #{item.delFlag} + + + + + + + + when org_id = #{item.orgId} then #{item.updatedBy} + + + + + + + + when org_id = #{item.orgId} then #{item.updatedTime} + + + + + + WHERE + 1=1 + + org_id = #{item.orgId} + + + + \ No newline at end of file diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/BaseGridUserDao.xml b/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/BaseGridUserDao.xml new file mode 100644 index 0000000000..f5a47aea3a --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/BaseGridUserDao.xml @@ -0,0 +1,58 @@ + + + + + + + UPDATE base_grid_user + + + + + + when (grid_id = #{item.gridId} AND staff_id = #{item.staffId} ) then #{item.gridName} + + + + + + + + when (grid_id = #{item.gridId} AND staff_id = #{item.staffId} ) then #{item.nickName} + + + + + + + + when (grid_id = #{item.gridId} AND staff_id = #{item.staffId} ) then #{item.delFlag} + + + + + + + + when (grid_id = #{item.gridId} AND staff_id = #{item.staffId} ) then #{item.updatedBy} + + + + + + + + when (grid_id = #{item.gridId} AND staff_id = #{item.staffId} ) then #{item.updatedTime} + + + + + + WHERE + 1=1 + + (grid_id = #{item.gridId} AND staff_id = #{item.staffId} ) + + + + \ No newline at end of file diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/UserPatrolDetailDao.xml b/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/UserPatrolDetailDao.xml new file mode 100644 index 0000000000..bd61a74027 --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/UserPatrolDetailDao.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/UserPatrolRecordDao.xml b/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/UserPatrolRecordDao.xml new file mode 100644 index 0000000000..750e9f177b --- /dev/null +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/UserPatrolRecordDao.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/epmet-module/open-data-worker/pom.xml b/epmet-module/open-data-worker/pom.xml new file mode 100644 index 0000000000..97fe762b08 --- /dev/null +++ b/epmet-module/open-data-worker/pom.xml @@ -0,0 +1,18 @@ + + + + epmet-module + com.epmet + 2.0.0 + + 4.0.0 + + open-data-worker + pom + + open-data-worker-client + open-data-worker-server + + \ No newline at end of file diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/mq/listener/InitCustomerComponentsListener.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/mq/listener/InitCustomerComponentsListener.java index d21ea39357..5980ad0a2a 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/mq/listener/InitCustomerComponentsListener.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/mq/listener/InitCustomerComponentsListener.java @@ -1,13 +1,17 @@ package com.epmet.mq.listener; import com.alibaba.fastjson.JSON; +import com.epmet.commons.rocketmq.constants.MQUserPropertys; import com.epmet.commons.rocketmq.messages.InitCustomerMQMsg; 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.dto.CustomerHomeDTO; import com.epmet.service.CustomerHomeService; +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; @@ -15,7 +19,6 @@ import org.apache.rocketmq.common.message.MessageExt; import org.redisson.api.RLock; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; import java.util.List; import java.util.concurrent.TimeUnit; @@ -28,8 +31,15 @@ public class InitCustomerComponentsListener implements MessageListenerConcurrent 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) { @@ -41,6 +51,7 @@ public class InitCustomerComponentsListener implements MessageListenerConcurrent private void consumeMessage(MessageExt messageExt) { String msg = new String(messageExt.getBody()); + String pendingMsgLabel = messageExt.getUserProperty(MQUserPropertys.BLOCKED_MSG_LABEL); logger.info("初始化客户-初始化客户自定义信息-收到消息内容:{}", msg); InitCustomerMQMsg msgObj = JSON.parseObject(msg, InitCustomerMQMsg.class); @@ -66,6 +77,28 @@ public class InitCustomerComponentsListener implements MessageListenerConcurrent } 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("【开放数据事件监听器】删除mq滞留消息缓存成功,blockedMsgLabel:{}", pendingMsgLabel); } /* @Override diff --git a/epmet-module/pom.xml b/epmet-module/pom.xml index 56b1452eec..8b9efdfdb8 100644 --- a/epmet-module/pom.xml +++ b/epmet-module/pom.xml @@ -44,6 +44,7 @@ epmet-point epmet-ext data-aggregator - + open-data-worker + diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/mq/GroupAchievementCustomListener.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/mq/GroupAchievementCustomListener.java index 33c0ff7c63..6644a29dc3 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/mq/GroupAchievementCustomListener.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/mq/GroupAchievementCustomListener.java @@ -1,9 +1,13 @@ package com.epmet.mq; import com.alibaba.fastjson.JSON; +import com.epmet.commons.rocketmq.constants.MQUserPropertys; import com.epmet.commons.rocketmq.messages.GroupAchievementMQMsg; 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.modules.group.service.StatsAchievementService; import lombok.extern.slf4j.Slf4j; @@ -31,8 +35,15 @@ public class GroupAchievementCustomListener implements MessageListenerConcurren 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); + } + long start = System.currentTimeMillis(); try { msgs.forEach(this::consumeMessage); @@ -48,6 +59,7 @@ public class GroupAchievementCustomListener implements MessageListenerConcurren private void consumeMessage(MessageExt messageExt) { logger.info("receive msg:{}", JSON.toJSONString(messageExt)); String msg = new String(messageExt.getBody()); + String pendingMsgLabel = messageExt.getUserProperty(MQUserPropertys.BLOCKED_MSG_LABEL); GroupAchievementMQMsg msgObj = JSON.parseObject(msg, GroupAchievementMQMsg.class); if (msgObj == null){ @@ -87,9 +99,29 @@ public class GroupAchievementCustomListener implements MessageListenerConcurren 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("【小组成就事件监听器】删除mq滞留消息缓存成功,penddingMsgLabel:{}", pendingMsgLabel); + } /*@Override public ConsumerConfigProperties getConsumerProperty() { diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java index 989b86924d..6e0c14c1e4 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java @@ -22,6 +22,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.entity.DataScope; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.rocketmq.messages.OrgOrStaffMQMsg; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.ServiceConstant; @@ -49,8 +50,10 @@ import com.epmet.entity.GovStaffRoleEntity; import com.epmet.entity.StaffRoleEntity; import com.epmet.entity.UserEntity; import com.epmet.feign.AuthFeignClient; +import com.epmet.feign.EpmetMessageOpenFeignClient; import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.feign.OperCrmOpenFeignClient; +import com.epmet.send.SendMqMsgUtil; import com.epmet.service.CustomerStaffService; import com.epmet.service.GovStaffRoleService; import com.epmet.service.StaffRoleService; @@ -99,6 +102,8 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl page(Map params) { @@ -342,6 +347,16 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl().ok(ConvertUtils.sourceToTarget(staffEntity, CustomerStaffDTO.class)); } @@ -415,6 +430,16 @@ public class CustomerStaffServiceImpl extends BaseServiceImplsendPatrolMsg(e, SystemMessageType.USER_PATROL_STOP)); + } /**