diff --git a/epmet-admin/epmet-admin-server/pom.xml b/epmet-admin/epmet-admin-server/pom.xml index c9903ba390..1bd83b7e49 100644 --- a/epmet-admin/epmet-admin-server/pom.xml +++ b/epmet-admin/epmet-admin-server/pom.xml @@ -136,6 +136,7 @@ false + true 192.168.1.140:9876;192.168.1.141:9876 epmet_message @@ -172,6 +173,7 @@ false + false 192.168.1.140:9876;192.168.1.141:9876 epmet_message @@ -205,6 +207,7 @@ true + true 192.168.10.161:9876 epmet_message @@ -238,6 +241,7 @@ true + true 192.168.11.187:9876;192.168.11.184:9876 epmet_message diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/RocketMQConsumerRegister.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/RocketMQConsumerRegister.java index 1399fe6a13..8c07d1279d 100644 --- a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/RocketMQConsumerRegister.java +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/RocketMQConsumerRegister.java @@ -2,6 +2,8 @@ package com.epmet.mq.listener; 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.commons.tools.enums.EnvEnum; import com.epmet.mq.listener.listener.AuthOperationLogListener; import com.epmet.mq.listener.listener.PointOperationLogListener; @@ -16,55 +18,15 @@ import org.springframework.stereotype.Component; import javax.annotation.PostConstruct; @Component -public class RocketMQConsumerRegister { - @Value("${spring.profiles.active}") - private String env; - @Value("${rocketmq.name-server}") - private String nameServer; +public class RocketMQConsumerRegister extends MQAbstractRegister { - /** - * @return - * @Description 注册监听器 - * @author wxz - * @date 2021.03.03 16:09 - */ - @PostConstruct - public void registerAllListeners() { - try { - if (!EnvEnum.LOCAL.getCode().equals(env)) { - register(nameServer, ConsomerGroupConstants.AUTH_OPERATION_LOG_GROUP, MessageModel.CLUSTERING, TopicConstants.AUTH, "*", new AuthOperationLogListener()); - register(nameServer, ConsomerGroupConstants.PROJECT_OPERATION_LOG_GROUP, MessageModel.CLUSTERING, TopicConstants.PROJECT_CHANGED, "*", new ProjectOperationLogListener()); - register(nameServer, ConsomerGroupConstants.POINT_OPERATION_LOG_GROUP, MessageModel.CLUSTERING, TopicConstants.POINT, "*", new PointOperationLogListener()); - } - } catch (MQClientException e) { - e.printStackTrace(); - } - } - - public void register(String nameServer, String group, MessageModel messageModel, String topic, String subException, MessageListenerConcurrently listener) throws MQClientException { - // 实例化消费者 - DefaultMQPushConsumer consumer = new DefaultMQPushConsumer(group); - - // 设置NameServer的地址 - consumer.setNamesrvAddr(nameServer); - consumer.setMessageModel(messageModel); - consumer.setInstanceName(buildInstanceName()); - // 订阅一个或者多个Topic,以及Tag来过滤需要消费的消息 - consumer.subscribe(topic, subException); - // 注册回调实现类来处理从broker拉取回来的消息 - consumer.registerMessageListener(listener); - // 启动消费者实例 - consumer.start(); - } - - private String buildInstanceName() { - String instanceName = ""; - for (int i = 0; i < 4; i++) { - int t = (int) (Math.random() * 10); - instanceName = instanceName.concat(t + ""); - } + @Override + public void registerAllListeners(String env, MQConsumerProperties consumerProperties) { + // 客户初始化监听器注册 + register(consumerProperties, ConsomerGroupConstants.AUTH_OPERATION_LOG_GROUP, MessageModel.CLUSTERING, TopicConstants.AUTH, "*", new AuthOperationLogListener()); + register(consumerProperties, ConsomerGroupConstants.PROJECT_OPERATION_LOG_GROUP, MessageModel.CLUSTERING, TopicConstants.PROJECT_CHANGED, "*", new ProjectOperationLogListener()); + register(consumerProperties, ConsomerGroupConstants.POINT_OPERATION_LOG_GROUP, MessageModel.CLUSTERING, TopicConstants.POINT, "*", new PointOperationLogListener()); - return instanceName; + // ...其他监听器类似 } - -} +} \ No newline at end of file diff --git a/epmet-admin/epmet-admin-server/src/main/resources/bootstrap.yml b/epmet-admin/epmet-admin-server/src/main/resources/bootstrap.yml index 0d9082cec3..74c6bc2567 100644 --- a/epmet-admin/epmet-admin-server/src/main/resources/bootstrap.yml +++ b/epmet-admin/epmet-admin-server/src/main/resources/bootstrap.yml @@ -136,4 +136,5 @@ shutdown: waitTimeSecs: 30 # 优雅停机等待时间,超过30秒,发出告警 rocketmq: + enable: @rocketmq.enable@ name-server: @rocketmq.nameserver@ \ No newline at end of file diff --git a/epmet-commons/epmet-commons-rocketmq/pom.xml b/epmet-commons/epmet-commons-rocketmq/pom.xml index 346f055ccc..75b7a9d1a5 100644 --- a/epmet-commons/epmet-commons-rocketmq/pom.xml +++ b/epmet-commons/epmet-commons-rocketmq/pom.xml @@ -26,5 +26,10 @@ org.projectlombok lombok + + com.epmet + epmet-commons-tools + 2.0.0 + diff --git a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/register/ConsumerConfigProperties.java b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/register/ConsumerConfigProperties.java deleted file mode 100644 index 71a8fea41c..0000000000 --- a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/register/ConsumerConfigProperties.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.epmet.commons.rocketmq.register; - -import lombok.Data; -import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently; - -import java.io.Serializable; - -/** - * desc:mq 消费配置类 - * - * @author: LiuJanJun - * @date: 2021/4/30 2:39 下午 - * @version: 1.0 - */ -@Data -public class ConsumerConfigProperties implements Serializable { - - private static final long serialVersionUID = 2069676324708473773L; - /** - * 消费者组 - */ - private String consumerGroup; - /** - * 主题 - */ - private String topic; - /** - * 标签 - */ - private String tag = "*"; - /** - * 最小消费的线程数 - */ - private int consumeThreadMin = 2; - /** - * 最大消费的线程数 - */ - private int consumeThreadMax = 4; - /** - * 消费监听器 - */ - private MessageListenerConcurrently consumerListener; -} diff --git a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/register/MQAbstractRegister.java b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/register/MQAbstractRegister.java new file mode 100644 index 0000000000..b1ca887c59 --- /dev/null +++ b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/register/MQAbstractRegister.java @@ -0,0 +1,77 @@ +package com.epmet.commons.rocketmq.register; + +import com.epmet.commons.tools.exception.ExceptionUtils; +import lombok.extern.slf4j.Slf4j; +import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer; +import org.apache.rocketmq.client.consumer.listener.MessageListener; +import org.apache.rocketmq.client.exception.MQClientException; +import org.apache.rocketmq.common.protocol.heartbeat.MessageModel; + +/** + * @author wxz + * @Description 父类抽象注册器 + * @date 2021.07.14 15:38:21 + */ +@Slf4j +public abstract class MQAbstractRegister { + + /** + * @Description 注册所有监听器,由子类实现,做具体监听器的注册 + * @return + * @author wxz + * @date 2021.07.14 15:48 + */ + public abstract void registerAllListeners(String env, MQConsumerProperties consumerProperties); + + /** + * @Description 真正执行注册的方法,供子类直接调用,子类也可以覆盖该方法 + * @return + * @author wxz + * @date 2021.07.14 15:56 + */ + public void register(MQConsumerProperties consumerProperties, String group, MessageModel messageModel, String topic, String subExpression, MessageListener listener) { + try { + String nameServer = consumerProperties.getNameServer(); + Integer consumeThreadMin = consumerProperties.getConsumeThreadMin(); + Integer consumeThreadMax = consumerProperties.getConsumeThreadMax(); + String instanceName = buildInstanceName(); + // 实例化消费者 + DefaultMQPushConsumer consumer = new DefaultMQPushConsumer(group); + + // 设置NameServer的地址 + consumer.setNamesrvAddr(nameServer); + consumer.setMessageModel(messageModel); + consumer.setInstanceName(instanceName); + // 订阅一个或者多个Topic,以及Tag来过滤需要消费的消息 + consumer.subscribe(topic, subExpression); + // 注册回调实现类来处理从broker拉取回来的消息 + consumer.registerMessageListener(listener); + if (consumeThreadMin != null) { + consumer.setConsumeThreadMin(consumeThreadMin); + } + if (consumeThreadMax != null) { + consumer.setConsumeThreadMax(consumeThreadMax); + } + // 启动消费者实例 + consumer.start(); + log.info(String.format("监听器注册完成,消费者组:%s,Topic:%s,Tag:%s,实例名称:%s", group, topic, subExpression, instanceName)); + } catch (Exception e) { + log.error(String.format("监听器注册失败,消费者组:%s,Topic:%s,Tag:%s。详细信息:%s", group, topic, subExpression, ExceptionUtils.getErrorStackTrace(e))); + } + } + + /** + * @Description 构造实例名称 + * @return + * @author wxz + * @date 2021.07.14 15:56 + */ + private String buildInstanceName() { + String instanceName = ""; + for (int i = 0; i < 4; i++) { + int t = (int) (Math.random() * 10); + instanceName = instanceName.concat(t + ""); + } + return instanceName; + } +} diff --git a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/register/MQConsumerProperties.java b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/register/MQConsumerProperties.java new file mode 100644 index 0000000000..76af70e0e2 --- /dev/null +++ b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/register/MQConsumerProperties.java @@ -0,0 +1,29 @@ +package com.epmet.commons.rocketmq.register; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * @Description 注册属性 + * @author wxz + * @date 2021.07.14 15:33:16 +*/ +@Data +@ConfigurationProperties(prefix = "rocketmq") +public class MQConsumerProperties { + + /** + * nameServer + */ + private String nameServer; + + /** + * 最小消费线程数 + */ + private Integer consumeThreadMin; + /** + * 最大消费线程数 + */ + private Integer consumeThreadMax; + +} diff --git a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/register/MQConsumerRegister.java b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/register/MQConsumerRegister.java deleted file mode 100644 index 3387b55931..0000000000 --- a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/register/MQConsumerRegister.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.epmet.commons.rocketmq.register; - -import lombok.extern.slf4j.Slf4j; -import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer; -import org.apache.rocketmq.client.exception.MQClientException; -import org.apache.rocketmq.common.protocol.heartbeat.MessageModel; -import org.springframework.beans.factory.annotation.Value; - -import javax.annotation.PostConstruct; - -/** - * desc:注册mq监听器 - * - * @author liujianjun - */ -@Slf4j -public abstract class MQConsumerRegister { - @Value("${spring.profiles.active}") - private String env; - @Value("${rocketmq.name-server}") - private String namesrvAddr; - - public abstract ConsumerConfigProperties getConsumerProperty(); - - - /** - * @return - * @Description 注册监听器 - * @author wxz - * @date 2021.03.03 16:09 - */ - @PostConstruct - public void registerMQListener() { - ConsumerConfigProperties consumerProperty = getConsumerProperty(); - log.info("registerAllListeners consumers:{} success", consumerProperty); - //本地环境不注册 - //if (!"local".equals(env)) { - try { - // 实例化消费者 - DefaultMQPushConsumer consumer = new DefaultMQPushConsumer(consumerProperty.getConsumerGroup()); - - // 设置NameServer的地址 - consumer.setNamesrvAddr(namesrvAddr); - consumer.setMessageModel(MessageModel.CLUSTERING); - consumer.setInstanceName(buildInstanceName()); - // 订阅一个或者多个Topic,以及Tag来过滤需要消费的消息 - consumer.subscribe(consumer.getConsumerGroup(), consumerProperty.getTag()); - // 注册回调实现类来处理从broker拉取回来的消息 - consumer.registerMessageListener(consumerProperty.getConsumerListener()); - consumer.setConsumeThreadMin(consumerProperty.getConsumeThreadMin()); - consumer.setConsumeThreadMax(consumerProperty.getConsumeThreadMax()); - // 启动消费者实例 - consumer.start(); - } catch (MQClientException e) { - log.info("registerMQListener exception", e); - } - - //} - - } - - /** - * desc: 因为docker-compose部署有问题 所有自己命名 - * - * @param - * @return java.lang.String - * @author LiuJanJun - * @date 2021/4/30 5:00 下午 - */ - private String buildInstanceName() { - String instanceName = ""; - for (int i = 0; i < 4; i++) { - int t = (int) (Math.random() * 10); - instanceName = instanceName.concat(t + ""); - } - - return instanceName; - } -} diff --git a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/register/MQRegisterConfiguration.java b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/register/MQRegisterConfiguration.java new file mode 100644 index 0000000000..77e3d178f7 --- /dev/null +++ b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/register/MQRegisterConfiguration.java @@ -0,0 +1,35 @@ +package com.epmet.commons.rocketmq.register; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +import javax.annotation.PostConstruct; + +/** + * @author wxz + * @Description MQ注册配置类 + * @date 2021.07.14 15:36:24 + */ +@Configuration +@ConditionalOnProperty(prefix = "rocketmq", name = "enable", havingValue = "true", matchIfMissing = false) +@EnableConfigurationProperties(MQConsumerProperties.class) +@Slf4j +public class MQRegisterConfiguration { + + @Value("${spring.profiles.active}") + private String env; + @Autowired + private MQConsumerProperties consumerProperties; + @Autowired + private MQAbstractRegister mqRegister; + + @PostConstruct + public void register() { + mqRegister.registerAllListeners(env, consumerProperties); + log.info("监听器注册动作执行完毕"); + } +} 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 360cb3c71a..93d81104d5 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 @@ -5,6 +5,7 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.dto.StatsFormDTO; import com.epmet.dto.extract.form.*; import com.epmet.dto.group.form.GroupStatsFormDTO; +import com.epmet.dto.group.form.GroupTotalFormDTO; import com.epmet.dto.screen.form.InitCustomerIndexForm; import com.epmet.dto.stats.form.CustomerIdAndDateIdFormDTO; import com.epmet.feign.impl.DataStatisticalOpenFeignClientFallBack; @@ -266,4 +267,11 @@ public interface DataStatisticalOpenFeignClient { */ @PostMapping("/data/stats/bizData/stats/daily") Result exeStatsDaily(@RequestBody BizDataFormDTO formDTO); + + /** + * @dscription 小组总数日统计和热议话题日统计任务 + * @author sun + */ + @PostMapping("/data/stats/statsgroup/groupandhottopic") + Result groupAndHotTopicTask(@RequestBody GroupTotalFormDTO 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 e15214e9d7..7bf37b9ce7 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 @@ -6,6 +6,7 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.dto.StatsFormDTO; import com.epmet.dto.extract.form.*; import com.epmet.dto.group.form.GroupStatsFormDTO; +import com.epmet.dto.group.form.GroupTotalFormDTO; import com.epmet.dto.screen.form.InitCustomerIndexForm; import com.epmet.dto.stats.form.CustomerIdAndDateIdFormDTO; import com.epmet.feign.DataStatisticalOpenFeignClient; @@ -259,4 +260,9 @@ public class DataStatisticalOpenFeignClientFallBack implements DataStatisticalOp public Result exeStatsDaily(BizDataFormDTO formDTO) { return ModuleUtils.feignConError(ServiceConstant.DATA_STATISTICAL_SERVER, "exeStatsDaily", formDTO); } + + @Override + public Result groupAndHotTopicTask(GroupTotalFormDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.DATA_STATISTICAL_SERVER, "groupAndHotTopic", formDTO); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/pom.xml b/epmet-module/data-statistical/data-statistical-server/pom.xml index d1b4c185c8..97f6c5eb85 100644 --- a/epmet-module/data-statistical/data-statistical-server/pom.xml +++ b/epmet-module/data-statistical/data-statistical-server/pom.xml @@ -256,6 +256,7 @@ SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd + true 192.168.1.140:9876;192.168.1.141:9876 @@ -375,6 +376,7 @@ SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd + local 192.168.1.140:9876;192.168.1.141:9876 @@ -493,6 +495,7 @@ SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd + true 192.168.10.161:9876 @@ -609,6 +612,7 @@ SEC95f4f40b533ad379ea6a6d1af6dd37029383cfe1b7cd96dfac2678be2c1c3ed1 + true 192.168.11.187:9876;192.168.11.184:9876 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsGroupController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsGroupController.java index 9896ae6290..baa6fb21d2 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsGroupController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsGroupController.java @@ -1,10 +1,15 @@ package com.epmet.controller; +import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.StatsFormDTO; import com.epmet.dto.group.form.GroupStatsFormDTO; import com.epmet.dto.group.form.GroupTotalFormDTO; +import com.epmet.dto.stats.topic.form.TopicStatusFormDTO; import com.epmet.service.StatsGroupService; +import com.epmet.service.StatsTopicService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -18,9 +23,11 @@ import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("statsgroup") public class StatsGroupController { - + Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private StatsGroupService statsGroupService; + @Autowired + private StatsTopicService statsTopicService; /** * 网格数、小组数、网格下所有组内人数(不去重) @@ -81,5 +88,39 @@ public class StatsGroupController { return new Result(); } + /** + * @dscription 小组总数日统计和热议话题日统计任务 + * @author sun + */ + @PostMapping("/groupandhottopic") + public Result groupAndHotTopic(GroupTotalFormDTO formDTO) { + try { + statsGroupService.gridGroupTotal(formDTO); + logger.info("小组总数-网格日统计任务成功"); + } catch (Exception e) { + logger.error("小组总数-网格日统计任务:", e); + } + try { + statsGroupService.agencyGroupTotal(formDTO); + logger.info("小组总数-机关日统计任务成功"); + } catch (Exception e) { + logger.error("小组总数-机关日统计任务失败:", e); + } + TopicStatusFormDTO topic = ConvertUtils.sourceToTarget(formDTO, TopicStatusFormDTO.class); + try { + statsTopicService.gridTopicStatus(topic); + logger.info("热议中话题-网格日统计任务成功"); + } catch (Exception e) { + logger.error("热议中话题-网格日统计任务失败:", e); + } + try { + statsTopicService.agencyTopicStatus(topic); + logger.info("热议中话题-机关日统计任务成功"); + } catch (Exception e) { + logger.error("热议中话题-机关日统计任务失败:", e); + } + return new Result(); + } + } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/issue/StatsIssueDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/issue/StatsIssueDao.java index 875efb82e1..ac3043d843 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/issue/StatsIssueDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/issue/StatsIssueDao.java @@ -26,7 +26,8 @@ public interface StatsIssueDao extends BaseDao { * @author zhaoqifeng * @date 2020/6/17 14:13 */ - List selectAgencyIssueTotal(@Param("customerId") String customerId, @Param("date") String date); + List selectAgencyIssueTotal(@Param("customerId") String customerId, @Param("date") String date, + @Param("gridList") List gridList); /** * 获取当前日期组织下议题增量 @@ -37,7 +38,8 @@ public interface StatsIssueDao extends BaseDao { * @author zhaoqifeng * @date 2020/6/18 9:55 */ - List selectAgencyIssueInc(@Param("customerId") String customerId, @Param("date") String date); + List selectAgencyIssueInc(@Param("customerId") String customerId, @Param("date") String date, + @Param("gridList") List gridList); /** * 已关闭议题统计 @@ -48,7 +50,8 @@ public interface StatsIssueDao extends BaseDao { * @author zhaoqifeng * @date 2020/6/18 14:41 */ - List selectAgencyClosedIssueTotal(@Param("customerId") String customerId, @Param("date") String date); + List selectAgencyClosedIssueTotal(@Param("customerId") String customerId, @Param("date") String date, + @Param("gridList") List gridList); /** * 已关闭议题增量 @@ -59,7 +62,8 @@ public interface StatsIssueDao extends BaseDao { * @author zhaoqifeng * @date 2020/6/18 14:41 */ - List selectAgencyClosedIssueInc(@Param("customerId") String customerId, @Param("date") String date); + List selectAgencyClosedIssueInc(@Param("customerId") String customerId, @Param("date") String date, + @Param("gridList") List gridList); /** * @param issueEntity @@ -181,4 +185,14 @@ public interface StatsIssueDao extends BaseDao { List selectIssueVoteStatis(@Param("customerId") String customerId, @Param("dateId") String dateId); List selectCategory(@Param("customerId") String customerId, @Param("ids") Set set); + + + List getIssueTotalList(@Param("customerId") String customerId, @Param("date") String date); + + /** + * @Author sun + * @Description 查询议题库已删除网格下可能存在的项目Id集合 + **/ + List selectProjectByGrids(@Param("gridIds") List gridIds); + } 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 93b72c077a..a2123a127f 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 @@ -87,4 +87,12 @@ public interface CustomerGridDao extends BaseDao { * @return java.util.List */ List getCustomerStaffGridList(@Param("customerId") String customerId); + + List getDelGridList(@Param("customerId") String customerId); + + /** + * @Author sun + * @Description 查询客户已删除网格列表 + **/ + List selectDelGridList(@Param("customerId") String customerId); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/mq/RocketMQConsumerRegister.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/mq/RocketMQConsumerRegister.java index c383ae1b41..33ee4218e3 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/mq/RocketMQConsumerRegister.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/mq/RocketMQConsumerRegister.java @@ -2,6 +2,8 @@ package com.epmet.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.commons.tools.constant.NumConstant; import com.epmet.commons.tools.enums.EnvEnum; import lombok.extern.slf4j.Slf4j; @@ -14,57 +16,13 @@ import org.springframework.stereotype.Component; import javax.annotation.PostConstruct; -@Slf4j @Component -public class RocketMQConsumerRegister { - @Value("${spring.profiles.active}") - private String env; - @Value("${rocketmq.name-server}") - private String nameServer; +public class RocketMQConsumerRegister extends MQAbstractRegister { - /** - * @return - * @Description 注册监听器 - * @author wxz - * @date 2021.03.03 16:09 - */ - @PostConstruct - public void registerAllListeners() { - try { - if (!EnvEnum.LOCAL.getCode().equals(env)) { - register(ConsomerGroupConstants.PROJECT_CHANGED_COMPONENTS_GROUP, MessageModel.CLUSTERING, TopicConstants.PROJECT_CHANGED, "*", new ProjectChangedCustomListener()); - } - } catch (MQClientException e) { - log.error("registerAllListeners exception", e); - } + @Override + public void registerAllListeners(String env, MQConsumerProperties consumerProperties) { + // 客户初始化监听器注册 + register(consumerProperties, ConsomerGroupConstants.PROJECT_CHANGED_COMPONENTS_GROUP, MessageModel.CLUSTERING, TopicConstants.PROJECT_CHANGED, "*", new ProjectChangedCustomListener()); + // ...其他监听器类似 } - - public void register(String group, MessageModel messageModel, String topic, String subException, MessageListenerConcurrently listener) throws MQClientException { - // 实例化消费者 - DefaultMQPushConsumer consumer = new DefaultMQPushConsumer(group); - - // 设置NameServer的地址 - consumer.setNamesrvAddr(nameServer); - consumer.setMessageModel(messageModel); - consumer.setInstanceName(buildInstanceName()); - // 订阅一个或者多个Topic,以及Tag来过滤需要消费的消息 - consumer.subscribe(topic, subException); - // 注册回调实现类来处理从broker拉取回来的消息 - consumer.registerMessageListener(listener); - //一次批量拉去10条消息 - consumer.setConsumeMessageBatchMaxSize(NumConstant.TEN); - // 启动消费者实例 - consumer.start(); - } - - private String buildInstanceName() { - String instanceName = ""; - for (int i = 0; i < 4; i++) { - int t = (int) (Math.random() * 10); - instanceName = instanceName.concat(t + ""); - } - - return instanceName; - } - -} +} \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/Issue/IssueService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/Issue/IssueService.java index b920c0e29a..4096fcb500 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/Issue/IssueService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/Issue/IssueService.java @@ -28,7 +28,7 @@ public interface IssueService { * @param date * @return java.util.List */ - List getAgencyIssueTotal(String customerId, String date); + List getAgencyIssueTotal(String customerId, String date, List gridList); /** * 获取当前日期组织下议题增量 @@ -38,7 +38,7 @@ public interface IssueService { * @param date * @return java.util.List */ - List getAgencyIssueInc(String customerId, String date); + List getAgencyIssueInc(String customerId, String date, List gridList); /** * 获取截止当前日期组织下已关闭议题统计 @@ -48,7 +48,7 @@ public interface IssueService { * @param date * @return java.util.List */ - List getAgencyClosedIssueTotal(String customerId, String date); + List getAgencyClosedIssueTotal(String customerId, String date, List gridList); /** * 获取当前日期组织下已关闭议题增量 @@ -58,7 +58,7 @@ public interface IssueService { * @param date * @return java.util.List */ - List getAgencyClosedIssueInc(String customerId, String date); + List getAgencyClosedIssueInc(String customerId, String date, List gridList); /** * @param issueEntity @@ -183,4 +183,31 @@ public interface IssueService { * @date 2021.03.09 00:23 */ Map getIntegratedProjectCategory(Map> param,String customerId); + + /** + * 获取议题总数 + * @author zhaoqifeng + * @date 2021/7/20 16:20 + * @param customerId + * @param date + * @return java.util.List + */ + List getIssueTotalList(String customerId, String date); + + + /** + * 获取议题增量 + * @author zhaoqifeng + * @date 2021/7/20 16:20 + * @param customerId + * @param date + * @return java.util.List + */ + List getIssueIncrList(String customerId, String date); + + /** + * @Author sun + * @Description 查询议题库已删除网格下可能存在的项目Id集合 + **/ + List getProjectByGrids(List gridIds); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/Issue/impl/IssueServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/Issue/impl/IssueServiceImpl.java index 44578a426a..fd5702c71b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/Issue/impl/IssueServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/Issue/impl/IssueServiceImpl.java @@ -34,23 +34,23 @@ public class IssueServiceImpl implements IssueService { private StatsIssueDao statsIssueDao; @Override - public List getAgencyIssueTotal(String customerId, String date) { - return statsIssueDao.selectAgencyIssueTotal(customerId, date); + public List getAgencyIssueTotal(String customerId, String date, List gridList) { + return statsIssueDao.selectAgencyIssueTotal(customerId, date, gridList); } @Override - public List getAgencyIssueInc(String customerId, String date) { - return statsIssueDao.selectAgencyIssueInc(customerId, date); + public List getAgencyIssueInc(String customerId, String date, List gridList) { + return statsIssueDao.selectAgencyIssueInc(customerId, date, gridList); } @Override - public List getAgencyClosedIssueTotal(String customerId, String date) { - return statsIssueDao.selectAgencyClosedIssueTotal(customerId, date); + public List getAgencyClosedIssueTotal(String customerId, String date, List gridList) { + return statsIssueDao.selectAgencyClosedIssueTotal(customerId, date, gridList); } @Override - public List getAgencyClosedIssueInc(String customerId, String date) { - return statsIssueDao.selectAgencyClosedIssueInc(customerId, date); + public List getAgencyClosedIssueInc(String customerId, String date, List gridList) { + return statsIssueDao.selectAgencyClosedIssueInc(customerId, date, gridList); } /** @@ -169,4 +169,42 @@ public class IssueServiceImpl implements IssueService { return map; } + + /** + * 获取议题总数 + * + * @param customerId + * @param date + * @return java.util.List + * @author zhaoqifeng + * @date 2021/7/20 16:20 + */ + @Override + public List getIssueTotalList(String customerId, String date) { + return null; + } + + /** + * 获取议题增量 + * + * @param customerId + * @param date + * @return java.util.List + * @author zhaoqifeng + * @date 2021/7/20 16:20 + */ + @Override + public List getIssueIncrList(String customerId, String date) { + return null; + } + + /** + * @Author sun + * @Description 查询议题库已删除网格下可能存在的项目Id集合 + **/ + @Override + public List getProjectByGrids(List gridIds) { + return statsIssueDao.selectProjectByGrids(gridIds); + } + } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginExtractServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginExtractServiceImpl.java index 7f20601afa..649391be59 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginExtractServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginExtractServiceImpl.java @@ -237,7 +237,7 @@ public class FactOriginExtractServiceImpl implements FactOriginExtractService { } }); - //网格、组织小组总数日统计 + /* //网格、组织小组总数日统计 threadPool.submit(() -> { GroupTotalFormDTO formDTO = new GroupTotalFormDTO(); formDTO.setCustomerId(param.getCustomerId()); @@ -295,7 +295,7 @@ public class FactOriginExtractServiceImpl implements FactOriginExtractService { log.error("热议中话题-机关日统计计算错误,参数:" + JSON.toJSONString(formDTO), e); } } - }); + });*/ submitProjectRelationData(param, finalDaysBetween); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsIssueServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsIssueServiceImpl.java index 7c0a98776f..c359035647 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsIssueServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsIssueServiceImpl.java @@ -17,6 +17,7 @@ import com.epmet.dto.stats.FactIssueGridMonthlyDTO; import com.epmet.entity.stats.*; import com.epmet.service.Issue.IssueService; import com.epmet.service.StatsIssueService; +import com.epmet.service.org.CustomerGridService; import com.epmet.service.project.ProjectService; import com.epmet.service.stats.*; import com.epmet.util.DimIdGenerator; @@ -57,6 +58,8 @@ public class StatsIssueServiceImpl implements StatsIssueService { private FactIssueGridDailyService factIssueGridDailyService; @Autowired private FactIssueGridMonthlyService factIssueGridMonthlyService; + @Autowired + private CustomerGridService customerGridService; @Override public void agencyGridIssueStats(StatsFormDTO formDTO) { @@ -119,16 +122,17 @@ public class StatsIssueServiceImpl implements StatsIssueService { DimIdGenerator.DimIdBean dimId = DimIdGenerator.getDimIdBean(date); //清空数据 factIssueAgencyDailyService.deleteByCustomerId(customerId, dimId.getDateId()); + List gridList = customerGridService.getDelGridList(customerId); //获取当前客户下所有机关 List agencyList = dimAgencyService.getDimAgencyList(dimAgencyDTO); //获取机关下议题各种状态的数目统计 - List issueAgencyTotalList = issueService.getAgencyIssueTotal(customerId, dateString); + List issueAgencyTotalList = issueService.getAgencyIssueTotal(customerId, dateString, gridList); //获取机关下议题各种状态的数目增量 - List issueAgencyIncList = issueService.getAgencyIssueInc(customerId, dateString); + List issueAgencyIncList = issueService.getAgencyIssueInc(customerId, dateString, gridList); //获取机关下已关闭议题统计 - List issueAgencyClosedTotalList = issueService.getAgencyClosedIssueTotal(customerId, dateString); + List issueAgencyClosedTotalList = issueService.getAgencyClosedIssueTotal(customerId, dateString, gridList); //获取机关下已关闭议题增量 - List issueAgencyClosedIncList = issueService.getAgencyClosedIssueInc(customerId, dateString); + List issueAgencyClosedIncList = issueService.getAgencyClosedIssueInc(customerId, dateString, gridList); //已结案项目统计 List projectAgencyClosedTotalList = projectService.getAgencyClosedProjectTotal(customerId, dateString); //已结案项目增量 @@ -180,14 +184,15 @@ public class StatsIssueServiceImpl implements StatsIssueService { dimAgencyDTO.setCustomerId(customerId); //获取日期相关维度 DimIdGenerator.DimIdBean dimId = DimIdGenerator.getDimIdBean(date); + List gridList = customerGridService.getDelGridList(customerId); //清空数据 factIssueAgencyMonthlyService.deleteByCustomerId(customerId, dimId.getMonthId()); //获取当前客户下所有机关 List agencyList = dimAgencyService.getDimAgencyList(dimAgencyDTO); //获取机关下议题各种状态的数目统计 - List issueAgencyTotalList = issueService.getAgencyIssueTotal(customerId, dateString); + List issueAgencyTotalList = issueService.getAgencyIssueTotal(customerId, dateString, gridList); //获取机关下已关闭议题统计 - List issueAgencyClosedTotalList = issueService.getAgencyClosedIssueTotal(customerId, dateString); + List issueAgencyClosedTotalList = issueService.getAgencyClosedIssueTotal(customerId, dateString, gridList); //已结案项目统计 List projectAgencyClosedTotalList = projectService.getAgencyClosedProjectTotal(customerId, dateString); //统计机关下议题各个指标月度增量 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsProjectServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsProjectServiceImpl.java index af00a87d3b..ca28b9fd3e 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsProjectServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsProjectServiceImpl.java @@ -12,6 +12,7 @@ import com.epmet.entity.project.ProjectProcessEntity; import com.epmet.entity.stats.*; import com.epmet.service.Issue.IssueService; import com.epmet.service.StatsProjectService; +import com.epmet.service.org.CustomerGridService; import com.epmet.service.project.ProjectProcessService; import com.epmet.service.project.ProjectService; import com.epmet.service.stats.*; @@ -29,6 +30,7 @@ import java.text.NumberFormat; import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; /** * 数据统计-项目(独立于任何具体数据源外层的service) @@ -59,6 +61,8 @@ public class StatsProjectServiceImpl implements StatsProjectService { private FactGridProjectDailyService factGridProjectDailyService; @Autowired private FactGridProjectMonthlyService factGridProjectMonthlyService; + @Autowired + private CustomerGridService customerGridService; /** * @Author sun @@ -123,6 +127,31 @@ public class StatsProjectServiceImpl implements StatsProjectService { log.info("StatsProjectServiceImpl.customerAgencyStats-根据客户Id查询项目进展表业务数据,对应客户Id:" + customerId); List processList = projectProcessService.getProcessList(projectEntity); + //20210721 sun 业务逻辑调整,网格删除,组织没有删除情况,相应的组织层级数据统计应舍弃以删除网格数据 start + //处理逻辑:查询已删除网格下项目Id,将已查询的项目、节点数据中的脏数据剔除【项目库有张表有网格Id,可以查出每个项目所属网格,但是关联该表后sql查询效率极低固舍弃此方案】 + //4-1.查询客户下已删除网格列表下存在的项目Id集合 + List list = customerGridService.getdelGridProjectIdList(customerId); + if (list.size() > NumConstant.ZERO) { + Map map = list.stream().collect(Collectors.toMap(String::toString, v -> v, (c1, c2) -> c1)); + //4-2.遍历删除项目主表查询的无效数据 + Iterator proiter = projectList.iterator(); + while (proiter.hasNext()) { + ProjectEntity next = proiter.next(); + if (map.containsKey(next.getId())) { + proiter.remove(); + } + } + //4-3.遍历删除项目节点表查询的无效数据 + Iterator iterator = processList.iterator(); + while (iterator.hasNext()) { + ProjectProcessEntity next = iterator.next(); + if (map.containsKey(next.getProjectId())) { + iterator.remove(); + } + } + } + //20210721 sun end + //5:机关层级日月统计 if (null != dimAgencyList && dimAgencyList.size() > NumConstant.ZERO) { //5.1:执行机关日数据统计 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 392b90bc89..2da4de7518 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 @@ -61,4 +61,20 @@ public interface CustomerGridService extends BaseService { * @return java.util.List */ List getCustomerStaffGridList(String customerId); + + /** + * 获取已删除的grid + * @author zhaoqifeng + * @date 2021/7/20 16:33 + * @param customerId + * @return java.util.List + */ + List getDelGridList(String customerId); + + /** + * @Author sun + * @Description 查询客户下已删除网格列表下存在的项目Id集合 + **/ + List getdelGridProjectIdList(String customerId); + } 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 680c9892bb..0d1ccf9b0d 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 @@ -2,6 +2,7 @@ package com.epmet.service.org.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.constant.DataSourceConstant; import com.epmet.dao.org.CustomerGridDao; import com.epmet.dto.group.AgencyDTO; @@ -10,10 +11,12 @@ import com.epmet.dto.group.result.GridIdListByCustomerResultDTO; import com.epmet.dto.org.CustomerStaffGridDTO; import com.epmet.dto.org.GridInfoDTO; import com.epmet.entity.org.CustomerGridEntity; +import com.epmet.service.Issue.IssueService; import com.epmet.service.org.CustomerGridService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -23,6 +26,8 @@ public class CustomerGridServiceImpl extends BaseServiceImpl listGridsByCreateTime(Date start, Date end) { @@ -79,4 +84,35 @@ public class CustomerGridServiceImpl extends BaseServiceImpl getCustomerStaffGridList(String customerId) { return customerGridDao.getCustomerStaffGridList(customerId); } + + /** + * 获取已删除的grid + * + * @param customerId + * @return java.util.List + * @author zhaoqifeng + * @date 2021/7/20 16:33 + */ + @Override + public List getDelGridList(String customerId) { + return null; + } + + /** + * @Author sun + * @Description 查询客户下已删除网格列表下存在的项目Id集合 + **/ + @Override + public List getdelGridProjectIdList(String customerId) { + List resultList = new ArrayList<>(); + //1.查询客户已删除网格列表 + List gridIds = customerGridDao.selectDelGridList(customerId); + if (gridIds.size() < NumConstant.ONE) { + return resultList; + } + //2.查询议题库已删除网格下可能存在的项目Id集合 + resultList = issueService.getProjectByGrids(gridIds); + return resultList; + } + } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml index c0479d72a3..7723414608 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml @@ -207,4 +207,5 @@ shutdown: waitTimeSecs: 30 # 优雅停机等待时间,超过30秒,发出告警 rocketmq: + enable: @rocketmq.enable@ name-server: @rocketmq.nameserver@ diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/issue/StatsIssueDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/issue/StatsIssueDao.xml index 59219341a1..3ee79011e8 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/issue/StatsIssueDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/issue/StatsIssueDao.xml @@ -13,6 +13,11 @@ DEL_FLAG = '0' AND CUSTOMER_ID = #{customerId} AND DATE(UPDATED_TIME) #{date} + + + AND GRID_ID != #{gridId} + + GROUP BY ORG_ID, ISSUE_STATUS @@ -34,6 +39,11 @@ i.DEL_FLAG = '0' AND i.CUSTOMER_ID = #{customerId} AND DATE(ip.CREATED_TIME) = #{date} + + + AND i.GRID_ID != #{gridId} + + GROUP BY i.ORG_ID, ip.ISSUE_STATUS @@ -55,6 +65,11 @@ AND ISSUE_STATUS = 'closed' AND CUSTOMER_ID = #{customerId} AND DATE(UPDATED_TIME) #{date} + + + AND GRID_ID != #{gridId} + + GROUP BY ORG_ID, RESOLVE_TYPE @@ -72,6 +87,11 @@ AND ISSUE_STATUS = 'closed' AND CUSTOMER_ID = #{customerId} AND DATE(UPDATED_TIME) = #{date} + + + AND GRID_ID != #{gridId} + + GROUP BY ORG_ID, RESOLVE_TYPE @@ -301,4 +321,31 @@ order by a.category_type,a.sort + + + + \ No newline at end of file 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 ed9d05b49a..d84d884cb3 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 @@ -106,4 +106,24 @@ csg.DEL_FLAG = '0' AND csg.CUSTOMER_ID = #{customerId} + + + + \ No newline at end of file diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/StatsGroupService.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/StatsGroupService.java index 84013b997d..94a2595331 100644 --- a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/StatsGroupService.java +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/StatsGroupService.java @@ -1,6 +1,7 @@ package com.epmet.service; import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.group.form.GroupTotalFormDTO; /** * @Author zxc @@ -29,4 +30,9 @@ public interface StatsGroupService { */ Result groupAgencyMonthly(String date); + /** + * @dscription 小组总数日统计和热议话题日统计任务 + * @author sun + */ + Result groupAndHotTopicTask(GroupTotalFormDTO formDTO); } diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/StatsGroupServiceImpl.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/StatsGroupServiceImpl.java index 669a97a60c..290c04733e 100644 --- a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/StatsGroupServiceImpl.java +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/StatsGroupServiceImpl.java @@ -2,6 +2,7 @@ package com.epmet.service.impl; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.group.form.GroupStatsFormDTO; +import com.epmet.dto.group.form.GroupTotalFormDTO; import com.epmet.service.StatsGroupService; import com.epmet.feign.DataStatisticalOpenFeignClient; import org.springframework.beans.factory.annotation.Autowired; @@ -37,4 +38,13 @@ public class StatsGroupServiceImpl implements StatsGroupService { formDTO.setDate(date); return statsPublicityFeignClient.groupAgencyMonthly(formDTO); } + + /** + * @dscription 小组总数日统计和热议话题日统计任务 + * @author sun + */ + @Override + public Result groupAndHotTopicTask(GroupTotalFormDTO formDTO) { + return statsPublicityFeignClient.groupAndHotTopicTask(formDTO); + } } diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/GroupAndHotTopicTask.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/GroupAndHotTopicTask.java new file mode 100644 index 0000000000..cfba46d52f --- /dev/null +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/GroupAndHotTopicTask.java @@ -0,0 +1,40 @@ +package com.epmet.task; + +import com.alibaba.fastjson.JSON; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.extract.form.ExtractOriginFormDTO; +import com.epmet.dto.group.form.GroupTotalFormDTO; +import com.epmet.service.DimInitService; +import com.epmet.service.StatsGroupService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * @dscription 小组总数日统计和热议话题日统计任务【因任务中用到了其他日统计表数据,需要在那些日统计任务之后单独执行】 + * 每天凌晨三点执行【0 0 3 * * ?】 + * @author sun + */ +@Slf4j +@Component("groupAndHotTopicTask") +public class GroupAndHotTopicTask implements ITask { + + @Autowired + private StatsGroupService statsGroupService; + + @Override + public void run(String params) { + log.debug("groupAndHotTopicTask定时任务正在执行,参数为:{}", params); + GroupTotalFormDTO formDTO = new GroupTotalFormDTO(); + if (StringUtils.isNotBlank(params)) { + formDTO = JSON.parseObject(params, GroupTotalFormDTO.class); + } + Result result = statsGroupService.groupAndHotTopicTask(formDTO); + if (result.success()){ + log.debug("groupAndHotTopicTask定时任务正在执行定时任务执行成功"); + }else { + log.debug("groupAndHotTopicTask定时任务正在执行定时任务执行失败:" + result.getMsg()); + } + } +} diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java index 09727f5e56..425b3f8cfc 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java @@ -439,6 +439,7 @@ public class AccessServiceImpl implements AccessService { @Override public Set listOperationPermissions(String staffId, String currAgencyId) { + Set filtedOps = new HashSet<>(); LoginUserDetailsResultDTO userDetails = getLoginUserDetails(loginUserUtil.getLoginUserApp(), loginUserUtil.getLoginUserClient(), loginUserUtil.getLoginUserId()); if (userDetails == null) { @@ -476,7 +477,9 @@ public class AccessServiceImpl implements AccessService { CustomerAgencyDTO currAgencyDto = currAgencyRst.getData(); if (currAgencyDto == null || currAgencyDto.getId() == null) { - throw new RenException(EpmetErrorCode.REQUIRE_PERMISSION.getCode(), "操作权限不足,当前组织信息不存在"); + logger.warn(String.format("根据组织ID:{}未找到组织信息,返回空权限列表", currAgencyId)); + return filtedOps; + //throw new RenException(EpmetErrorCode.REQUIRE_PERMISSION.getCode(), "操作权限不足,当前组织信息不存在"); } // 获取机关单位中的角色 @@ -489,8 +492,6 @@ public class AccessServiceImpl implements AccessService { String currOrgIdPath = getOrgIdPath(currAgencyDto); String currOrgRelation = getCurrOrgRelation(belongOrgIdPath, currOrgIdPath); - Set filtedOps = new HashSet<>(); - if (!CollectionUtils.isEmpty(roleList)) { roleList.forEach(role -> { List opeAndScopeDTO = listAllRoleOperationScopesByRoleId(role.getId()); diff --git a/epmet-module/gov-issue/gov-issue-server/pom.xml b/epmet-module/gov-issue/gov-issue-server/pom.xml index b266f10c0c..04eb309484 100644 --- a/epmet-module/gov-issue/gov-issue-server/pom.xml +++ b/epmet-module/gov-issue/gov-issue-server/pom.xml @@ -175,6 +175,7 @@ SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd + true 192.168.1.140:9876;192.168.1.141:9876 @@ -215,6 +216,7 @@ SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd + false 192.168.1.140:9876;192.168.1.141:9876 @@ -254,6 +256,7 @@ https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4 SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd + true 192.168.10.161:9876 @@ -294,6 +297,7 @@ + true 192.168.11.187:9876;192.168.11.184:9876 diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/mq/RocketMQConsumerRegister.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/mq/RocketMQConsumerRegister.java index 1674e82553..ff16d20238 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/mq/RocketMQConsumerRegister.java +++ b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/mq/RocketMQConsumerRegister.java @@ -2,6 +2,8 @@ package com.epmet.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.mq.listener.IssueProjectCategoryTagInitListener; import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer; import org.apache.rocketmq.client.consumer.listener.MessageListener; @@ -13,50 +15,13 @@ import org.springframework.stereotype.Component; import javax.annotation.PostConstruct; @Component -public class RocketMQConsumerRegister { +public class RocketMQConsumerRegister extends MQAbstractRegister { - @Value("${rocketmq.name-server}") - private String nameServer; + @Override + public void registerAllListeners(String env, MQConsumerProperties consumerProperties) { + // 客户初始化监听器注册 + register(consumerProperties, ConsomerGroupConstants.ISSUE_PROJECT_CATEGORY_TAG, MessageModel.CLUSTERING, TopicConstants.INIT_CUSTOMER, "*", new IssueProjectCategoryTagInitListener()); - /** - * @return - * @Description 注册监听器 - * @author wxz - * @date 2021.03.03 16:09 - */ - @PostConstruct - public void registerAllListeners() { - try { - register(nameServer, ConsomerGroupConstants.ISSUE_PROJECT_CATEGORY_TAG, MessageModel.CLUSTERING, TopicConstants.INIT_CUSTOMER, "*", new IssueProjectCategoryTagInitListener()); - } catch (MQClientException e) { - e.printStackTrace(); - } + // ...其他监听器类似 } - - public void register(String nameServer, String group, MessageModel messageModel, String topic, String subException, MessageListener listener) throws MQClientException { - // 实例化消费者 - DefaultMQPushConsumer consumer = new DefaultMQPushConsumer(group); - - // 设置NameServer的地址 - consumer.setNamesrvAddr(nameServer); - consumer.setMessageModel(messageModel); - consumer.setInstanceName(buildInstanceName()); - // 订阅一个或者多个Topic,以及Tag来过滤需要消费的消息 - consumer.subscribe(topic, subException); - // 注册回调实现类来处理从broker拉取回来的消息 - consumer.registerMessageListener(listener); - // 启动消费者实例 - consumer.start(); - } - - private String buildInstanceName() { - String instanceName = ""; - for (int i = 0; i < 4; i++) { - int t = (int) (Math.random() * 10); - instanceName = instanceName.concat(t + ""); - } - - return instanceName; - } - -} +} \ No newline at end of file diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/resources/bootstrap.yml b/epmet-module/gov-issue/gov-issue-server/src/main/resources/bootstrap.yml index 9e787eb546..09823befef 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/resources/bootstrap.yml +++ b/epmet-module/gov-issue/gov-issue-server/src/main/resources/bootstrap.yml @@ -129,4 +129,5 @@ shutdown: waitTimeSecs: 30 # 优雅停机等待时间,超过30秒,发出告警 rocketmq: + enable: @rocketmq.enable@ name-server: @rocketmq.nameserver@ diff --git a/epmet-module/gov-org/gov-org-server/pom.xml b/epmet-module/gov-org/gov-org-server/pom.xml index 9c353b0f90..180922a33d 100644 --- a/epmet-module/gov-org/gov-org-server/pom.xml +++ b/epmet-module/gov-org/gov-org-server/pom.xml @@ -170,6 +170,7 @@ + true 192.168.1.140:9876;192.168.1.141:9876 epmet_message @@ -212,6 +213,7 @@ + false 192.168.1.140:9876;192.168.1.141:9876 epmet_message @@ -255,6 +257,7 @@ + true 192.168.10.161:9876 epmet_message @@ -295,6 +298,7 @@ + true 192.168.11.187:9876;192.168.11.184:9876 epmet_message diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/mq/RocketMQConsumerRegister.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/mq/RocketMQConsumerRegister.java index bfe0f9f00f..ea2474714b 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/mq/RocketMQConsumerRegister.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/mq/RocketMQConsumerRegister.java @@ -2,65 +2,36 @@ package com.epmet.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.commons.tools.enums.EnvEnum; import com.epmet.mq.listener.InitCustomerOrgRolesListener; -import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer; -import org.apache.rocketmq.client.consumer.listener.MessageListener; -import org.apache.rocketmq.client.exception.MQClientException; import org.apache.rocketmq.common.protocol.heartbeat.MessageModel; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; -import javax.annotation.PostConstruct; - +/** + * @Description 如果rocketmq.enable=true,这里必须实现,且 实例化 + * @author wxz + * @date 2021.07.14 17:13:41 +*/ @Component -public class RocketMQConsumerRegister { - @Value("${spring.profiles.active}") - private String env; - @Value("${rocketmq.name-server}") - private String nameServer; - - /** - * @return - * @Description 注册监听器 - * @author wxz - * @date 2021.03.03 16:09 - */ - @PostConstruct - public void registerAllListeners() { - try { - if (!EnvEnum.LOCAL.getCode().equals(env)) { - register(nameServer, ConsomerGroupConstants.INIT_CUSTOMER_ORG_ROLES_GROUP, MessageModel.CLUSTERING, TopicConstants.INIT_CUSTOMER, "*", new InitCustomerOrgRolesListener()); - } - } catch (MQClientException e) { - e.printStackTrace(); - } - } - - public void register(String nameServer, String group, MessageModel messageModel, String topic, String subException, MessageListener listener) throws MQClientException { - // 实例化消费者 - DefaultMQPushConsumer consumer = new DefaultMQPushConsumer(group); - - // 设置NameServer的地址 - consumer.setNamesrvAddr(nameServer); - consumer.setMessageModel(messageModel); - consumer.setInstanceName(buildInstanceName()); - // 订阅一个或者多个Topic,以及Tag来过滤需要消费的消息 - consumer.subscribe(topic, subException); - // 注册回调实现类来处理从broker拉取回来的消息 - consumer.registerMessageListener(listener); - // 启动消费者实例 - consumer.start(); +public class RocketMQConsumerRegister extends MQAbstractRegister { + + @Override + public void registerAllListeners(String env, MQConsumerProperties consumerProperties) { + //判断逻辑,放到了了Pom.xml中,local不开启即可 + //if (!EnvEnum.LOCAL.getCode().equals(env)) { + //... + //} + + // 客户初始化监听器注册 + register(consumerProperties, + ConsomerGroupConstants.INIT_CUSTOMER_ORG_ROLES_GROUP, + MessageModel.CLUSTERING, + TopicConstants.INIT_CUSTOMER, + "*", + new InitCustomerOrgRolesListener()); + + // ...其他监听器类似 } - - private String buildInstanceName() { - String instanceName = ""; - for (int i = 0; i < 4; i++) { - int t = (int) (Math.random() * 10); - instanceName = instanceName.concat(t + ""); - } - - return instanceName; - } - } 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 010e2044a3..7224ea757a 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 @@ -28,7 +28,6 @@ import java.util.concurrent.TimeUnit; * @return * @date 2021.03.03 16:10 */ -//@Component public class InitCustomerOrgRolesListener implements MessageListenerConcurrently { private Logger logger = LoggerFactory.getLogger(getClass()); diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/bootstrap.yml b/epmet-module/gov-org/gov-org-server/src/main/resources/bootstrap.yml index 8baed16dd6..324ed0a5ca 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/bootstrap.yml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/bootstrap.yml @@ -145,4 +145,8 @@ shutdown: waitTimeSecs: 30 # 优雅停机等待时间,超过30秒,发出告警 rocketmq: + # 是否开启mq + enable: @rocketmq.enable@ name-server: @rocketmq.nameserver@ +# consume-thread-min: 2 +# consume-thread-max: 2 diff --git a/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/LatestListFormDTO.java b/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/LatestListFormDTO.java index ca84aee3b0..c7f174086d 100644 --- a/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/LatestListFormDTO.java +++ b/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/LatestListFormDTO.java @@ -37,5 +37,7 @@ public class LatestListFormDTO implements Serializable { */ private Integer pageSize = 3; + private Integer num = 0; + } diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java index 953104da7b..d721ccad51 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java +++ b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java @@ -1014,7 +1014,8 @@ public class ProjectServiceImpl extends BaseServiceImpl getClosedProjectList(LatestListFormDTO formDTO) { - + int pageIndex = (formDTO.getPageNo() - NumConstant.ONE) * formDTO.getPageSize(); + formDTO.setNum(pageIndex); return baseDao.selectClosedProjectList(formDTO); } diff --git a/epmet-module/gov-project/gov-project-server/src/main/resources/mapper/ProjectDao.xml b/epmet-module/gov-project/gov-project-server/src/main/resources/mapper/ProjectDao.xml index 11eeea95b4..265ef3bcc6 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/resources/mapper/ProjectDao.xml +++ b/epmet-module/gov-project/gov-project-server/src/main/resources/mapper/ProjectDao.xml @@ -155,19 +155,24 @@