diff --git a/epmet-admin/epmet-admin-server/pom.xml b/epmet-admin/epmet-admin-server/pom.xml index 1e797e0078..5f9e8ab342 100644 --- a/epmet-admin/epmet-admin-server/pom.xml +++ b/epmet-admin/epmet-admin-server/pom.xml @@ -141,6 +141,15 @@ true 192.168.1.140:9876;192.168.1.141:9876 epmet_message + + + true + 5 + 8 + 20 + 60 + epmet-admin + callerRunsPolicy @@ -181,6 +190,15 @@ false 192.168.1.140:9876;192.168.1.141:9876 epmet_message + + + true + 5 + 8 + 20 + 60 + epmet-admin + callerRunsPolicy @@ -217,6 +235,15 @@ true 192.168.10.161:9876 epmet_message + + + true + 5 + 8 + 20 + 60 + epmet-admin + callerRunsPolicy @@ -254,6 +281,15 @@ true 192.168.11.187:9876;192.168.11.184:9876 epmet_message + + + true + 5 + 8 + 20 + 60 + epmet-admin + callerRunsPolicy 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 fc45940737..80503e260f 100644 --- a/epmet-admin/epmet-admin-server/src/main/resources/bootstrap.yml +++ b/epmet-admin/epmet-admin-server/src/main/resources/bootstrap.yml @@ -139,4 +139,15 @@ shutdown: rocketmq: enable: @rocketmq.enable@ - name-server: @rocketmq.nameserver@ \ No newline at end of file + name-server: @rocketmq.nameserver@ + +thread: + # 线程池配置 + threadPool: + enableCustomize: @thread.threadPool.enable-customize@ + corePoolSize: @thread.threadPool.core-pool-size@ + maxPoolSize: @thread.threadPool.max-pool-size@ + queueCapacity: @thread.threadPool.queue-capacity@ + keepAliveSeconds: @thread.threadPool.keep-alive-seconds@ + threadNamePrefix: @thread.threadPool.thread-name-prefix@ + rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@ \ No newline at end of file diff --git a/epmet-admin/epmet-admin-server/src/main/resources/db/migration/V0.0.11__del_social_org.sql b/epmet-admin/epmet-admin-server/src/main/resources/db/migration/V0.0.11__del_social_org.sql new file mode 100644 index 0000000000..ae315be35c --- /dev/null +++ b/epmet-admin/epmet-admin-server/src/main/resources/db/migration/V0.0.11__del_social_org.sql @@ -0,0 +1,7 @@ +UPDATE sys_dict_data +SET DEL_FLAG = '1', +UPDATED_BY = 'yinzuomei', +UPDATED_TIME = NOW(), +remark = '2022.02.21删除社会组织功能,改用联建单位两新组织' +WHERE + dict_value = 'social_org'; \ No newline at end of file diff --git a/epmet-admin/epmet-admin-server/src/main/resources/mapper/SysDictDataDao.xml b/epmet-admin/epmet-admin-server/src/main/resources/mapper/SysDictDataDao.xml index ff1273d4ae..d7ea8fa27b 100644 --- a/epmet-admin/epmet-admin-server/src/main/resources/mapper/SysDictDataDao.xml +++ b/epmet-admin/epmet-admin-server/src/main/resources/mapper/SysDictDataDao.xml @@ -14,8 +14,8 @@ FROM sys_dict_data a INNER JOIN sys_dict_type b ON a.dict_type_id = b.id - WHERE - b.dict_type = #{dictType} + WHERE a.del_flag='0' + and b.dict_type = #{dictType} ORDER BY a.sort ASC @@ -27,8 +27,8 @@ FROM sys_dict_data a INNER JOIN sys_dict_type b ON a.dict_type_id = b.id - WHERE - b.dict_type = #{dictType} + WHERE a.del_flag='0' + and b.dict_type = #{dictType} ORDER BY a.sort asc diff --git a/epmet-auth/pom.xml b/epmet-auth/pom.xml index 41b8b92296..b4c31f05cc 100644 --- a/epmet-auth/pom.xml +++ b/epmet-auth/pom.xml @@ -216,6 +216,15 @@ UUCnxLyXiB4eBF4p https://epmet-cloud.elinkservice.cn + + + true + 5 + 8 + 20 + 60 + epmet-auth + callerRunsPolicy @@ -273,6 +282,15 @@ UUCnxLyXiB4eBF4p https://epmet-cloud.elinkservice.cn + + + true + 5 + 8 + 20 + 60 + epmet-auth + callerRunsPolicy @@ -325,6 +343,15 @@ UUCnxLyXiB4eBF4p https://epmet-cloud.elinkservice.cn + + + true + 5 + 8 + 20 + 60 + epmet-auth + callerRunsPolicy @@ -382,6 +409,15 @@ UUCnxLyXiB4eBF4p https://epmet-cloud.elinkservice.cn + + + true + 5 + 8 + 20 + 60 + epmet-auth + callerRunsPolicy diff --git a/epmet-auth/src/main/java/com/epmet/StringRandomUtils.java b/epmet-auth/src/main/java/com/epmet/StringRandomUtils.java new file mode 100644 index 0000000000..fbac601c41 --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/StringRandomUtils.java @@ -0,0 +1,32 @@ +package com.epmet; + +import com.epmet.commons.tools.constant.StrConstant; + +/** + * desc:随机生成字母 + * + * @author: LiuJanJun + * @date: 2022/3/1 5:16 下午 + * @version: 1.0 + */ +public class StringRandomUtils { + + public static String getRandomStr(int length){ + String result = StrConstant.EPMETY_STR; + //小写字母范围: 97~122 + for (int i = 0; i < length; i++) { + int randomNumber = 97 + (int) (Math.random()* (122+1-97)); + result += (char)randomNumber; + } + return result; + } + + public static void main(String[] args) { + StringRandomUtils test = new StringRandomUtils(); + //测试 + for (int i = 0; i < 1000000; i++) { + System.out.println(getRandomStr(5)); + } + } + +} diff --git a/epmet-auth/src/main/java/com/epmet/controller/LoginController.java b/epmet-auth/src/main/java/com/epmet/controller/LoginController.java index c9df95100b..c1fdb8a045 100644 --- a/epmet-auth/src/main/java/com/epmet/controller/LoginController.java +++ b/epmet-auth/src/main/java/com/epmet/controller/LoginController.java @@ -68,30 +68,6 @@ public class LoginController { } } - /** - * @description 基层治理平台登录验证码 - * - * @param response - * @return - * @author wxz - * @date 2021.10.25 14:19:40 - */ - @GetMapping("ic-login-captcha") - public void icLoginCaptcha(HttpServletResponse response, String uuid) throws IOException { - try { - //生成图片验证码 - BufferedImage image = captchaService.createIcLoginCaptcha(uuid); - response.reset(); - response.setHeader("Cache-Control", "no-store, no-cache"); - response.setContentType("image/jpeg"); - ServletOutputStream out = response.getOutputStream(); - ImageIO.write(image, "jpg", out); - out.close(); - } catch (IOException e) { - log.error("获取登陆验证码异常", e); - } - } - /** * @param formDTO * @return com.epmet.commons.tools.utils.Result diff --git a/epmet-auth/src/main/java/com/epmet/service/CaptchaService.java b/epmet-auth/src/main/java/com/epmet/service/CaptchaService.java index 812a586dcb..d6f8573e65 100644 --- a/epmet-auth/src/main/java/com/epmet/service/CaptchaService.java +++ b/epmet-auth/src/main/java/com/epmet/service/CaptchaService.java @@ -23,16 +23,6 @@ public interface CaptchaService { */ BufferedImage create(String uuid); - /** - * @description 基层治理平台登录验证码 - * - * @param - * @return - * @author wxz - * @date 2021.10.25 14:15:30 - */ - BufferedImage createIcLoginCaptcha(String uuid); - /** * 验证码效验 * @param uuid uuid diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/CaptchaServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/CaptchaServiceImpl.java index 115009f9e9..fbdf85b00b 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/CaptchaServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/CaptchaServiceImpl.java @@ -8,16 +8,17 @@ package com.epmet.service.impl; -import com.google.code.kaptcha.Producer; +import com.epmet.StringRandomUtils; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.redis.CaptchaRedis; import com.epmet.service.CaptchaService; +import com.google.code.kaptcha.Producer; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.awt.image.BufferedImage; -import java.util.UUID; /** * 验证码 @@ -35,8 +36,8 @@ public class CaptchaServiceImpl implements CaptchaService { @Override public BufferedImage create(String uuid) { - //生成验证码 - String captcha = producer.createText(); + //生成验证码 //producer.createText(); + String captcha = StringRandomUtils.getRandomStr(NumConstant.FIVE); //logger.info("uuid:"+uuid+",生成的验证码:"+captcha); //保存验证码 captchaRedis.set(uuid, captcha); @@ -44,17 +45,6 @@ public class CaptchaServiceImpl implements CaptchaService { return producer.createImage(captcha); } - @Override - public BufferedImage createIcLoginCaptcha(String uuid) { - //生成验证码 - String captchaText = producer.createText(); - //logger.info("uuid:"+uuid+",生成的验证码:"+captcha); - //保存验证码 - captchaRedis.setIcLoginCaptcha(uuid, captchaText); - - return producer.createImage(captchaText); - } - @Override public boolean validate(String uuid, String code) { String captcha = captchaRedis.get(uuid); diff --git a/epmet-auth/src/main/resources/bootstrap.yml b/epmet-auth/src/main/resources/bootstrap.yml index bf965caff7..8cdc2c21db 100644 --- a/epmet-auth/src/main/resources/bootstrap.yml +++ b/epmet-auth/src/main/resources/bootstrap.yml @@ -159,3 +159,15 @@ epmet: # third服务的相关配置 third: urlPrefix: @epmet.third.urlprefix@ + + +thread: + # 线程池配置 + threadPool: + enableCustomize: @thread.threadPool.enable-customize@ + corePoolSize: @thread.threadPool.core-pool-size@ + maxPoolSize: @thread.threadPool.max-pool-size@ + queueCapacity: @thread.threadPool.queue-capacity@ + keepAliveSeconds: @thread.threadPool.keep-alive-seconds@ + threadNamePrefix: @thread.threadPool.thread-name-prefix@ + rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@ \ No newline at end of file diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/config/AsyncConfig.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/config/AsyncConfig.java new file mode 100644 index 0000000000..2778f3c9ef --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/config/AsyncConfig.java @@ -0,0 +1,93 @@ +package com.epmet.commons.tools.config; + +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; + +import java.util.concurrent.Executor; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.RejectedExecutionHandler; +import java.util.concurrent.ThreadPoolExecutor; + +/** + * 线程池配置类 + * thread: + * # 线程池配置 + * threadPool: + * enableCustomize: true [true会使用自定义线程池,false则使用springboot自动配置的线程池。推荐使用自定义线程池] + * 可以只配置此参数,其他参会会使用默认值,但还是建议把参数配置全。 + * corePoolSize: 2 + * maxPoolSize: 4 + * queueCapacity: 2 + * keepAliveSeconds: 60 + * threadNamePrefix: [线程池名字] + * rejectedExecutionHandler: [拒绝策略] + * + * 顺序:核心线程->放入队列->未达到maxPoolSize则继续增加线程直到达到maxPoolSize->拒绝策略 + * 开启自定义线程池:thread.threadPool.enableCustomize=true,不配置或者配置为false,自定义线程池都不会开启 + * rejectedExecutionHandler拒绝策略:abortPolicy/discardPolicy/discardOldestPolicy/callerRunsPolicy(默认) + */ +@EnableConfigurationProperties(EpmetThreadPoolProperties.class) +@Configuration +@ConditionalOnProperty(prefix = "thread.threadPool", name = "enableCustomize", havingValue = "true", matchIfMissing = false) +public class AsyncConfig { + + /** + * 默认值 + */ + private int corePoolSize = 5; + private int maxPoolSize = 8; + private int queueCapacity = 20; + private String threadNamePrefix = "epmet-default-"; + private int keepAliveSeconds = 60; + private String rejectedExecutionHandler = "callerRunsPolicy"; + + public AsyncConfig(EpmetThreadPoolProperties properties) { + if (properties.getCorePoolSize() != null) corePoolSize = properties.getCorePoolSize(); + if (properties.getMaxPoolSize() != null) maxPoolSize = properties.getMaxPoolSize(); + if (properties.getQueueCapacity() != null) queueCapacity = properties.getQueueCapacity(); + if (properties.getThreadNamePrefix() != null) threadNamePrefix = properties.getThreadNamePrefix(); + if (properties.getKeepAliveSeconds() != null) keepAliveSeconds = properties.getKeepAliveSeconds(); + if (properties.getRejectedExecutionHandler() != null) rejectedExecutionHandler = properties.getRejectedExecutionHandler(); + } + + @Bean + public Executor executor() { + ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); + executor.setCorePoolSize(corePoolSize); + executor.setMaxPoolSize(maxPoolSize); + executor.setQueueCapacity(queueCapacity); + executor.setThreadNamePrefix(threadNamePrefix); + executor.setRejectedExecutionHandler(getRejectedExecutionHandler(rejectedExecutionHandler)); //对拒绝task的处理策略 + executor.setKeepAliveSeconds(keepAliveSeconds); + executor.initialize(); + return executor; + } + + @Bean + public ExecutorService executorService() { + ThreadPoolTaskExecutor executor = (ThreadPoolTaskExecutor) executor(); + return executor.getThreadPoolExecutor(); + } + + /** + * 获取拒绝策略handler + * @param policy + * @return + */ + private RejectedExecutionHandler getRejectedExecutionHandler(String policy) { + switch (policy) { + case "abortPolicy": + return new ThreadPoolExecutor.AbortPolicy(); + case "discardPolicy": + return new ThreadPoolExecutor.DiscardPolicy(); + case "discardOldestPolicy": + return new ThreadPoolExecutor.DiscardOldestPolicy(); + default: + // 默认情况下,使用主线程执行 + return new ThreadPoolExecutor.CallerRunsPolicy(); + } + } +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/config/EpmetThreadPoolProperties.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/config/EpmetThreadPoolProperties.java new file mode 100644 index 0000000000..1984a01dec --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/config/EpmetThreadPoolProperties.java @@ -0,0 +1,47 @@ +package com.epmet.commons.tools.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * 线程池配置参数 + * thread-pool会自动对应到threadPool + */ +@ConfigurationProperties(prefix = "thread.thread-pool") +@Data +public class EpmetThreadPoolProperties { + + /** + * 是否允许自定义线程池 + */ + private Boolean enableCustomize; + /** + * 核心线程数 + */ + private Integer corePoolSize; + + /** + * 最大线程数 + */ + private Integer maxPoolSize; + + /** + * 队列容量 + */ + private Integer queueCapacity; + + /** + * 线程名前缀 + */ + private String threadNamePrefix; + + /** + * 线程存活时长 + */ + private Integer keepAliveSeconds; + + /** + * 拒绝策略 + */ + private String rejectedExecutionHandler; +} \ No newline at end of file diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/config/ThreadDispatcherConfig.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/config/ThreadDispatcherConfig.java new file mode 100644 index 0000000000..1b2d32c2cc --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/config/ThreadDispatcherConfig.java @@ -0,0 +1,39 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + *

+ * https://www.renren.io + *

+ * 版权所有,侵权必究! + */ + +package com.epmet.commons.tools.config; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.filter.RequestContextFilter; +import org.springframework.web.servlet.DispatcherServlet; + +import javax.annotation.PostConstruct; + + +/** + * DESC:设置线程继承属性为true,便于子线程获取到父线程的request,两个都设置为了保险 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@Configuration +public class ThreadDispatcherConfig { + + @Autowired + RequestContextFilter requestContextFilter; + @Autowired + DispatcherServlet dispatcherServlet; + + @PostConstruct + public void init() { + // 设置线程继承属性为true,便于子线程获取到父线程的request,两个都设置为了保险。 + requestContextFilter.setThreadContextInheritable(true); + dispatcherServlet.setThreadContextInheritable(true); + } +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/Constant.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/Constant.java index 400e3893e4..77875d5415 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/Constant.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/Constant.java @@ -171,4 +171,7 @@ public interface Constant { * 被禁用标识 * */ String DISABLE = "disable"; + + String OPITON_SOURCE_REMOTE = "remote"; + String OPITON_SOURCE_LOCAL = "local"; } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/DingDingRobotConstant.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/DingDingRobotConstant.java new file mode 100644 index 0000000000..08c5708cf6 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/DingDingRobotConstant.java @@ -0,0 +1,15 @@ +package com.epmet.commons.tools.constant; + +public interface DingDingRobotConstant { + /** + * 尹作梅测试用 + */ + String YZM_TEST_URL="https://oapi.dingtalk.com/robot/send?access_token=249c5f49006cf14b37f9c3bc502ede34c16926a5ac5a0deeb9c9b4be735c0daf"; + String YZM_TEST_SECRET="SECa03f447d67c62d924b5ae52dd9a7ddd9147d32c1d43f8cb43449f505444bdc6b"; + + /** + * EPMET V3 产品研发群 + */ + String V3_ROBOT_URL="https://oapi.dingtalk.com/robot/send?access_token=75e9ab857536f3018baa09009646876edbd263d07521a1a22eedfc3852623614"; + String V3_ROBOT_SECRET="SECdc8d3fb6780faa919f38fd43783f76d111255036c3b5bdcbc086dff023ee84d5"; +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/SpecialCustomerOrgConstant.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/SpecialCustomerOrgConstant.java new file mode 100644 index 0000000000..e65434f0bd --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/SpecialCustomerOrgConstant.java @@ -0,0 +1,36 @@ +package com.epmet.commons.tools.constant; + + +/** + * 需要特殊处理的客户id + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +public interface SpecialCustomerOrgConstant { + /** + * 榆山街道组织id + */ + String YUSHAN_AGENCY_ID_PROD="1258587398679126017"; + + /** + * 南宁社区-开发测试用的 + */ + String test="6e511da6816e53af4cda952365a26eb9"; + + /** + * 榆山生产客户id + */ + String YUSHAN_PROD_CUSTOMER_ID = "46c55cb862d6d5e6d05d2ab61a1cc07e"; + + /** + * 榆山测试客户id + */ + String YUSHAN_TEST_CUSTOMER_ID = "a4bbf298d8e427844038cee466f022ef"; + + /** + * 生产平阴客户id + */ + String PING_YIN_CUSTOMER_ID="6f203e30de1a65aab7e69c058826cd80"; + +} 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 67f467f63c..62d9fef763 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 @@ -107,4 +107,7 @@ public interface StrConstant { * 积分规则修改的头 */ String POINT_CHANGE_HEAD = "修改了%s规则,"; + + String YES = "是"; + String NO = "否"; } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/DingTextBriefNessFormDTO.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/DingTextBriefNessFormDTO.java new file mode 100644 index 0000000000..f6e324497e --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/DingTextBriefNessFormDTO.java @@ -0,0 +1,27 @@ +package com.epmet.commons.tools.dto.form; + +import com.dingtalk.api.request.OapiRobotSendRequest; +import lombok.Data; + +/** + * 钉钉机器人发送文本通知,@手机号,简参 + */ +@Data +public class DingTextBriefNessFormDTO { + + /* { + "msgtype":"text", + "text":{ + "content":"我就是我, @15764229697 是不同的烟火" + }, + "at":{ + "atMobiles": [ + "15764229697" + ], + "isAtAll":false + } + }*/ + private String msgtype; + private OapiRobotSendRequest.Text text; + private OapiRobotSendRequest.At at; +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/UpdateUserPointsFormDTO.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/UpdateUserPointsFormDTO.java new file mode 100644 index 0000000000..1eb3092d07 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/UpdateUserPointsFormDTO.java @@ -0,0 +1,29 @@ +package com.epmet.commons.tools.dto.form; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class UpdateUserPointsFormDTO implements Serializable { + + /** + * 行为类型: + * 双十信息更新-double_info_update + * 网格巡查-grid_patrol + * 网格上报事件-grid_report_event + * 网格工作上传-grid_work_upload + */ + private String behaviorType; + + /** + * 手机号 + */ + private String mobile; + + /** + * 工作端用户id + */ + private String staffId; + private String customerId; +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/BehaviorTypeYuShanEnum.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/BehaviorTypeYuShanEnum.java new file mode 100644 index 0000000000..8c5b1caf5b --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/BehaviorTypeYuShanEnum.java @@ -0,0 +1,43 @@ +package com.epmet.commons.tools.enums; + + +/** + * 更新用户积分(双实信息更新 网格巡查) + * 行为类型枚举类 + */ +public enum BehaviorTypeYuShanEnum { + + DOUBLE_INFO_UPDATE("double_info_update", "双十信息更新"), + GRID_PATROL("grid_patrol", "网格巡查"), + GRID_REPORT_EVENT("grid_report_event", "网格上报事件"), + GRID_WORK_UPLOAD("grid_work_upload", "网格工作上传"), + ; + + private String code; + private String name; + + + BehaviorTypeYuShanEnum(String code, String name) { + this.code = code; + this.name = name; + } + + public static BehaviorTypeYuShanEnum getEnum(String code) { + BehaviorTypeYuShanEnum[] values = BehaviorTypeYuShanEnum.values(); + for (BehaviorTypeYuShanEnum value : values) { + if (value.getCode().equals(code)) { + return value; + } + } + return null; + } + + + public String getCode() { + return code; + } + + public String getName() { + return name; + } +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/ExternalApiEnum.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/ExternalApiEnum.java new file mode 100644 index 0000000000..ed916dd6df --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/ExternalApiEnum.java @@ -0,0 +1,35 @@ +package com.epmet.commons.tools.enums; + +/** + * 外部api + */ +public enum ExternalApiEnum { + + /** + * 榆山-测试服务器地址 + */ + UPDATE_USER_POINTS("/api/points/behavior/updateUserPoints","更新用户积分(双实信息更新 网格巡查)","http://yapi.elinkservice.cn/project/57/interface/api/7466"); + + private String apiPath; + private String desc; + private String descUrl; + + + ExternalApiEnum(String apiPath, String desc,String descUrl) { + this.apiPath = apiPath; + this.desc = desc; + this.descUrl=descUrl; + } + + public String getApiPath() { + return apiPath; + } + + public String getDesc() { + return desc; + } + + public String getDescUrl() { + return descUrl; + } +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/ExternalServerEnum.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/ExternalServerEnum.java new file mode 100644 index 0000000000..119a222e27 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/ExternalServerEnum.java @@ -0,0 +1,55 @@ +package com.epmet.commons.tools.enums; + +import com.epmet.commons.tools.constant.StrConstant; + + +/** + * 外部客户的服务器地址 + */ +public enum ExternalServerEnum { + DEV_TEST("45687aa479955f9d06204d415238f7cc", "https://epdc-api-test.elinkservice.cn/epdc-api"), + /** + * 榆山-测试服务器地址 + */ + YUSHAN_TEST("a4bbf298d8e427844038cee466f022ef", "https://epdc-api-test.elinkservice.cn/epdc-api"), + /** + * 榆山-生产服务器地址 + */ + YUSHAN_PROD("46c55cb862d6d5e6d05d2ab61a1cc07e", "https://epdc-yushan.elinkservice.cn/epdc-api"); + + + private String customerId; + private String url; + + + ExternalServerEnum(String customerId, String url) { + this.customerId = customerId; + this.url = url; + } + + public static String getUrl(String customerId) { + ExternalServerEnum[] array = values(); + for (ExternalServerEnum enumValue : array) { + if (enumValue.getCustomerId().equals(customerId)) { + return enumValue.getUrl(); + } + } + return StrConstant.EPMETY_STR; + } + + public String getCustomerId() { + return customerId; + } + + public void setCustomerId(String customerId) { + this.customerId = customerId; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/ResultDataResolver.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/ResultDataResolver.java index 1bfa31e96b..8a9bc6ad80 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/ResultDataResolver.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/ResultDataResolver.java @@ -1,9 +1,12 @@ package com.epmet.commons.tools.feign; import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.utils.Result; import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Feign请求结果解析器 @@ -12,30 +15,30 @@ public interface ResultDataResolver { /** * @Description 获取Result种的data,如果失败(返回result为null或者result.success为false),那么返回null - * @return + * @return data数据 * @author wxz * @date 2021.06.07 22:45 */ - //default R tryGetResultData(Result result, String targetServiceName) { - // Logger logger = LoggerFactory.getLogger(ResultDataResolver.class); - // if (result == null) { - // logger.error("调用{}服务发生错误,返回Result为null", targetServiceName); - // return null; - // } - // if (!result.success()) { - // logger.error("调用{}服务发生错误,错误信息:{}", targetServiceName, result.getInternalMsg()); - // return null; - // } - // return result.getData(); - //} + default R getResultDataOrReturnNull(Result result, String targetServiceName) { + Logger logger = LoggerFactory.getLogger(ResultDataResolver.class); + if (result == null) { + logger.error("调用{}服务发生错误,返回Result为null", targetServiceName); + return null; + } + if (!result.success()) { + logger.error("调用{}服务发生错误,内部信息:{},错误信息:{}", targetServiceName, result.getInternalMsg(), result.getMsg()); + return null; + } + return result.getData(); + } /** - * @Description - * @return + * @Description 解析Result中的结果,如果请求上游服务返回的结果不成功,则抛出异常 + * @return data数据 * @param targetServiceName 目标service名称 - * @param errorCode 错误码,可以为空,为空则使用上游服务抛出的错误码 - * @param errorInternalMsg 内部错误信息,可以为空,为空则使用上游服务抛出的异常信息 - * @param showMsg 展示给前端程序的错误信息,可以为空。为空则根据errorCode给定错误msg信息 + * @param errorCode 错误码,可以为空,为空则使用8000 + * @param errorInternalMsg 内部错误信息,可以为空,为空则internalMsg="" + * @param showMsg 展示给前端程序的错误信息,可以为空。为空则showMsg="" * @author wxz * @date 2021.06.07 22:45 */ @@ -43,11 +46,25 @@ public interface ResultDataResolver { if (result == null) { throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), "调用{}服务发生错误,返回Result为null", targetServiceName); } - if (!result.success()) { + + // 考虑到:上游服务抛出的异常代码和错误消息并不一定适用于当前服务,并且上有服务的错误消息弹出之后可能给用户造成困扰, + // 因此,当前服务抛出异常的时候,不再继承上游服务返回的错误码和错误消息 + /*if (!result.success()) { Integer finalErrorCode = errorCode == null ? result.getCode() : errorCode; String finalErrorInternalMsg = StringUtils.isBlank(errorInternalMsg) ? result.getInternalMsg() : errorInternalMsg; throw new RenException(finalErrorCode, finalErrorInternalMsg, showMsg, RenException.MessageMode.CODE_INTERNAL_EXTERNAL); + }*/ + + if (!result.success()) { + + // 如果不通过参数指定code,则默认使用8000服务器开小差 + Integer finalErrorCode = errorCode == null ? EpmetErrorCode.SERVER_ERROR.getCode() : errorCode; + String finalErrorInternalMsg = StringUtils.isBlank(errorInternalMsg) ? "" : errorInternalMsg; + String finalShowMsg = StringUtils.isBlank(showMsg) ? "" : showMsg; + + throw new EpmetException(finalErrorCode, finalErrorInternalMsg, finalShowMsg); } + return result.getData(); } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java index d0ba1f61de..9f6be36819 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java @@ -66,6 +66,7 @@ public class LogMsgSendFilter extends LevelFilter { } if (StringUtils.isNotBlank(activeEnv)) { + stringBuilder.append("告警环境:").append(activeEnv); stringBuilder.append("\n"); } @@ -112,7 +113,6 @@ public class LogMsgSendFilter extends LevelFilter { if (!flag) { logger.warn("msgSender.sendMsg fail,param:{}", stringBuilder.toString()); } - stringBuilder.append("告警环境:").append(activeEnv); } catch (Exception e) { logger.warn("decide exception", e); } 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 53c50c5c2e..0798627046 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 @@ -673,4 +673,67 @@ public class RedisKeys { public static String icResiImportResiCategoryKey(String importTag, String type, String resiId) { return icResiImportTypeKey(importTag, type).concat(":").concat(resiId); } + + /** + * @Description 临时房屋缓存key + * @param customerId + * @param userId + * @author zxc + * @date 2022/2/14 9:38 上午 + */ + public static String getTemporaryHouseInfoCacheKey(String customerId,String userId){ + return rootPrefix.concat("temporary:").concat("temporaryHouse:").concat(customerId).concat(":").concat(userId); + } + + /** + * @Description 临时网格缓存key + * @param customerId + * @param userId + * @author zxc + * @date 2022/2/14 9:38 上午 + */ + public static String getTemporaryGridInfoCacheKey(String customerId,String userId){ + return rootPrefix.concat("temporary:").concat("temporaryGrid:").concat(customerId).concat(":").concat(userId); + } + + /** + * @Description 临时小区缓存key + * @param customerId + * @param userId + * @author zxc + * @date 2022/2/14 9:39 上午 + */ + public static String getTemporaryNeighborHoodInfoCacheKey(String customerId,String userId){ + return rootPrefix.concat("temporary:").concat("temporaryNeighborHood:").concat(customerId).concat(":").concat(userId); + } + + /** + * @Description 临时楼栋缓存key + * @param customerId + * @param userId + * @author zxc + * @date 2022/2/14 9:39 上午 + */ + public static String getTemporaryBuildingInfoCacheKey(String customerId,String userId){ + return rootPrefix.concat("temporary:").concat("temporaryBuilding:").concat(customerId).concat(":").concat(userId); + } + + /** + * @Description 临时楼栋单元缓存key + * @param customerId + * @param userId + * @author zxc + * @date 2022/2/14 1:54 下午 + */ + public static String getTemporaryBuildingUnitInfoCacheKey(String customerId,String userId){ + return rootPrefix.concat("temporary:").concat("temporaryBuildingUnit:").concat(customerId).concat(":").concat(userId); + } + + public static String getTemporaryImportResultCacheKey(String customerId,String userId){ + return rootPrefix.concat("temporary:").concat("temporaryResult:").concat(customerId).concat(":").concat(userId); + } + + public static String getCustomerMenuList(String customerId, Integer type) { + return rootPrefix.concat("oper:access:nav:customerId:").concat(customerId).concat(":type:")+type; + } } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java index 048745cfb6..ce4b79cb1e 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java @@ -305,6 +305,7 @@ public class HttpClientManager { */ public Result sendAlarmMsg(String content) { Long timestamp = System.currentTimeMillis(); + //生产环境报警群:重要消息通知 String url = "https://oapi.dingtalk.com/robot/send?access_token=c40055ed85e45fdaafea00f3218928794262ff15163e09ad5c89764433b69806"; String secret = "SEC220eafdcb39ab5dd6cffa9f11b0e5de7178ddac9812d40fdceb6b1dda2963186"; diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/YuShanSysApiService.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/YuShanSysApiService.java new file mode 100644 index 0000000000..1a714fdffd --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/YuShanSysApiService.java @@ -0,0 +1,82 @@ +package com.epmet.commons.tools.utils; + + +import com.alibaba.fastjson.JSON; +import com.epmet.commons.tools.constant.SpecialCustomerOrgConstant; +import com.epmet.commons.tools.dto.form.UpdateUserPointsFormDTO; +import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; +import com.epmet.commons.tools.enums.EnvEnum; +import com.epmet.commons.tools.enums.ExternalApiEnum; +import com.epmet.commons.tools.enums.ExternalServerEnum; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.redis.common.CustomerStaffRedis; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import java.util.List; + +/** + * e事通调用榆山api + * + * @author yinzuomei + * @date 2022-02-16 + **/ +@Service +@Slf4j +public class YuShanSysApiService { + + + /** + * 更新用户积分(双实信息更新 网格巡查) + * + * @return + */ + @Async + public void updateUserPoints(String customerId, List paramList) { + if (StringUtils.isBlank(customerId) || CollectionUtils.isEmpty(paramList)) { + throw new RenException("参数错误"); + } + if (!SpecialCustomerOrgConstant.PING_YIN_CUSTOMER_ID.equals(customerId)) { + return; + } + String serverUrl = null; + EnvEnum currentEnv = EnvEnum.getCurrentEnv(); + if (EnvEnum.PROD.getCode().equals(currentEnv.getCode())) { + serverUrl = ExternalServerEnum.getUrl(SpecialCustomerOrgConstant.YUSHAN_PROD_CUSTOMER_ID); + } else if (EnvEnum.TEST.getCode().equals(currentEnv.getCode()) || EnvEnum.LOCAL.getCode().equals(currentEnv.getCode())) { + serverUrl = ExternalServerEnum.getUrl(SpecialCustomerOrgConstant.YUSHAN_TEST_CUSTOMER_ID); + } + if (StringUtils.isBlank(serverUrl)) { + log.warn(String.format("当前客户:%s,未配置服务器地址", customerId)); + return; + } + String apiPath = serverUrl.concat(ExternalApiEnum.UPDATE_USER_POINTS.getApiPath()); + log.info(String.format("updateUserPoints 接口路径:%s", apiPath)); + for (UpdateUserPointsFormDTO formDTO : paramList) { + try { + CustomerStaffInfoCacheResult staff = CustomerStaffRedis.getStaffInfo(customerId, formDTO.getStaffId()); + //只有榆山街道的工作人员才调用 + if (null != staff && (staff.getAgencyId().equals(SpecialCustomerOrgConstant.YUSHAN_AGENCY_ID_PROD) || staff.getAgencyPIds().contains(SpecialCustomerOrgConstant.YUSHAN_AGENCY_ID_PROD))) { + formDTO.setMobile(staff.getMobile()); + //测试用手机号 + // formDTO.setMobile("13205302682"); + Result res = HttpClientManager.getInstance().sendPostByJSON(apiPath, JSON.toJSONString(formDTO)); + Result result = JSON.parseObject(res.getData(), Result.class); + log.info(String.format("updateUserPoints 入参:%s;返参:%s", JSON.toJSONString(formDTO),JSON.toJSONString(result))); + if (!result.success()) { + log.warn("updateUserPoints failed:{}", JSON.toJSONString(result)); + } + } + } catch (Exception e) { + log.warn("updateUserPoints exception 入参:{}", JSON.toJSONString(formDTO)); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), e.getMessage()); + } + } + } + + +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/validator/group/QueryGroup.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/validator/group/QueryGroup.java new file mode 100644 index 0000000000..df4536366b --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/validator/group/QueryGroup.java @@ -0,0 +1,19 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.epmet.commons.tools.validator.group; + +/** + * 查询 Group + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +public interface QueryGroup { + +} diff --git a/epmet-gateway/src/main/java/com/epmet/GatewayApplication.java b/epmet-gateway/src/main/java/com/epmet/GatewayApplication.java index a1630c821e..064b59610e 100644 --- a/epmet-gateway/src/main/java/com/epmet/GatewayApplication.java +++ b/epmet-gateway/src/main/java/com/epmet/GatewayApplication.java @@ -10,6 +10,7 @@ package com.epmet; import com.epmet.commons.tools.aspect.ServletExceptionHandler; import com.epmet.commons.tools.config.RedissonConfig; +import com.epmet.commons.tools.config.ThreadDispatcherConfig; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; @@ -27,7 +28,7 @@ import org.springframework.context.annotation.FilterType; @EnableDiscoveryClient @EnableFeignClients //@ServletComponentScan -@ComponentScan(basePackages = {"com.epmet.*"}, excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {RedissonConfig.class, ServletExceptionHandler.class})) +@ComponentScan(basePackages = {"com.epmet.*"}, excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {RedissonConfig.class, ThreadDispatcherConfig.class, ServletExceptionHandler.class})) public class GatewayApplication { public static void main(String[] args) { diff --git a/epmet-gateway/src/main/resources/bootstrap.yml b/epmet-gateway/src/main/resources/bootstrap.yml index c8c245b15a..598f8d7518 100644 --- a/epmet-gateway/src/main/resources/bootstrap.yml +++ b/epmet-gateway/src/main/resources/bootstrap.yml @@ -234,6 +234,7 @@ spring: - Path=${server.servlet.context-path}/commonservice/** filters: - StripPrefix=1 + - CpAuth=true #党建园地 - id: resi-home-server uri: @gateway.routes.resi-home-server.uri@ diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/result/CustomerDataManageResultDTO.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/result/CustomerDataManageResultDTO.java index e736309945..f293af93d0 100644 --- a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/result/CustomerDataManageResultDTO.java +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/result/CustomerDataManageResultDTO.java @@ -44,6 +44,10 @@ public class CustomerDataManageResultDTO { private Integer patrolCount = 0; //巡查时长 private String patrolDuration; + /** + * 例行工作次数 + */ + private Integer patrolRoutineWorkTimes = 0; //未转换前的巡查时长 private Integer patrolDurationInteger = 0; //数据对应dateId diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/feign/DataAggregatorOpenFeignClient.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/feign/DataAggregatorOpenFeignClient.java new file mode 100644 index 0000000000..a164b0c020 --- /dev/null +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/feign/DataAggregatorOpenFeignClient.java @@ -0,0 +1,24 @@ +package com.epmet.dataaggre.feign; + + +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dataaggre.dto.govorg.form.GridLivelyFormDTO; +import com.epmet.dataaggre.feign.impl.DataAggregatorOpenFeignClientFallbackFactory; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +@FeignClient(name = ServiceConstant.DATA_AGGREGATOR_SERVER, fallbackFactory = DataAggregatorOpenFeignClientFallbackFactory.class) +// @FeignClient(name = ServiceConstant.DATA_AGGREGATOR_SERVER, fallbackFactory= DataAggregatorOpenFeignClientFallbackFactory.class,url = "localhost:8114") +public interface DataAggregatorOpenFeignClient { + + /** + * 定时任务导出网格活跃统计表 + * @param form + * @return + */ + @PostMapping(value = "data/aggregator/org/export-send-msg") + Result exportGridLiveRes(@RequestBody GridLivelyFormDTO form); + +} diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/feign/impl/DataAggregatorOpenFeignClientFallback.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/feign/impl/DataAggregatorOpenFeignClientFallback.java new file mode 100644 index 0000000000..ea2bfebddf --- /dev/null +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/feign/impl/DataAggregatorOpenFeignClientFallback.java @@ -0,0 +1,19 @@ +package com.epmet.dataaggre.feign.impl; + +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.utils.ModuleUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dataaggre.dto.govorg.form.GridLivelyFormDTO; +import com.epmet.dataaggre.feign.DataAggregatorOpenFeignClient; + +public class DataAggregatorOpenFeignClientFallback implements DataAggregatorOpenFeignClient { + /** + * 定时任务导出网格活跃统计表 + * @param form + * @return + */ + @Override + public Result exportGridLiveRes(GridLivelyFormDTO form) { + return ModuleUtils.feignConError(ServiceConstant.DATA_AGGREGATOR_SERVER, "pcworkRecordListExportSendMsg",form); + } +} diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/feign/impl/DataAggregatorOpenFeignClientFallbackFactory.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/feign/impl/DataAggregatorOpenFeignClientFallbackFactory.java new file mode 100644 index 0000000000..ffb9a28654 --- /dev/null +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/feign/impl/DataAggregatorOpenFeignClientFallbackFactory.java @@ -0,0 +1,17 @@ +package com.epmet.dataaggre.feign.impl; + +import com.epmet.dataaggre.feign.DataAggregatorOpenFeignClient; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +@Slf4j +@Component +public class DataAggregatorOpenFeignClientFallbackFactory implements FallbackFactory { + private DataAggregatorOpenFeignClientFallback fallback = new DataAggregatorOpenFeignClientFallback(); + + @Override + public DataAggregatorOpenFeignClient create(Throwable throwable) { + return null; + } +} \ No newline at end of file diff --git a/epmet-module/data-aggregator/data-aggregator-server/pom.xml b/epmet-module/data-aggregator/data-aggregator-server/pom.xml index a222f7963f..a3a4717b98 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/pom.xml +++ b/epmet-module/data-aggregator/data-aggregator-server/pom.xml @@ -110,6 +110,12 @@ --> + + com.epmet + epmet-oss-client + 2.0.0 + compile + @@ -259,6 +265,15 @@ https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4 SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd + + + true + 5 + 8 + 20 + 60 + data-aggregator + callerRunsPolicy @@ -375,6 +390,15 @@ https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4 SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd + + + true + 5 + 8 + 20 + 60 + data-aggregator + callerRunsPolicy @@ -491,6 +515,15 @@ https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4 SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd + + + true + 5 + 8 + 20 + 60 + data-aggregator + callerRunsPolicy @@ -608,6 +641,15 @@ https://oapi.dingtalk.com/robot/send?access_token=a5f66c3374b1642fe2142dbf56d5997e280172d4e8f2b546c9423a68c82ece6c SEC95f4f40b533ad379ea6a6d1af6dd37029383cfe1b7cd96dfac2678be2c1c3ed1 + + + true + 5 + 8 + 20 + 60 + data-aggregator + callerRunsPolicy diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/GovOrgController.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/GovOrgController.java index a0f7bafdbb..c1b2b0e98a 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/GovOrgController.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/GovOrgController.java @@ -27,7 +27,6 @@ import com.epmet.dataaggre.entity.govorg.CustomerAgencyEntity; import com.epmet.dataaggre.enums.GridMemberDataAnalysisEnums; import com.epmet.dataaggre.service.AggreGridService; import com.epmet.dataaggre.service.govorg.GovOrgService; -import com.epmet.dto.form.patrol.PcworkRecordListFormDTO; import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; @@ -402,4 +401,15 @@ public class GovOrgController { govOrgService.grdiLivelyExport(response, formDTO); } + /** + * 定时任务调用本方法,查询网格活跃度统计结果,生成excel,上传oss.发送钉钉excel. + * @param formDTO + * @return + */ + @PostMapping("export-send-msg") + public Result pcworkRecordListExportSendMsg(@RequestBody GridLivelyFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, GridLivelyFormDTO.Grid.class); + govOrgService.pcworkRecordListExportSendMsg(formDTO); + return new Result(); + } } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/StatsStaffPatrolRecordDailyDao.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/StatsStaffPatrolRecordDailyDao.java index 49c101c018..e1fe7554ec 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/StatsStaffPatrolRecordDailyDao.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/StatsStaffPatrolRecordDailyDao.java @@ -40,6 +40,7 @@ public interface StatsStaffPatrolRecordDailyDao extends BaseDao userIds, @Param("startDateId") String startDateID, @Param("endDateID") String endDateID); + + /** + * desc: 获取例行工作次数 + * @param patrolForm + * @return + */ + List getRoutineWorkCount(CustomerDataManageFormDTO patrolForm); } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/CustomerDataManageExcel.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/CustomerDataManageExcel.java index 821a11426f..65f55557fe 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/CustomerDataManageExcel.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/CustomerDataManageExcel.java @@ -47,6 +47,9 @@ public class CustomerDataManageExcel { @Excel(name = "巡查时长") private String patrolDuration; + @Excel(name = "例行工作次数") + private Integer patrolRoutineWorkTimes; + /** * 未转换前的巡查时长 */ diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/GridLivelyExcel.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/GridLivelyExcel.java index 655675326f..331511dbe6 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/GridLivelyExcel.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/GridLivelyExcel.java @@ -29,40 +29,57 @@ import lombok.Data; */ @Data public class GridLivelyExcel { - @ExcelProperty("组织ID") @ExcelIgnore private String agencyId; //组织名称 + @Excel(name = "组织名称",width = 15) @ExcelProperty("组织名称") @ColumnWidth(15) private String agencyName; + //组织下所有网格总数 + @Excel(name = "网格总数",width = 15) @ExcelProperty("网格总数") @ColumnWidth(15) private Integer gridSumNum; + //活跃网格数 + @Excel(name = "活跃网格数",width = 15) @ExcelProperty("活跃网格数") @ColumnWidth(15) private Integer gridLivelyNum; + + //活跃网格数占比 + @Excel(name = "活跃网格数占比",width = 15) @ExcelProperty("活跃网格数占比") @ColumnWidth(15) private String gridLivelyRatio; + //正常运行网格数 + @Excel(name = "正常运行网格数",width = 15) @ExcelProperty("正常运行网格数") @ColumnWidth(15) private Integer gridOrdinaryNum; + + //正常运行网格数占比 + @Excel(name = "正常运行网格数占比",width = 15) @ExcelProperty("正常运行网格数占比") @ColumnWidth(15) private String gridOrdinaryRatio; + //僵尸网格数 + @Excel(name = "僵尸网格数",width = 15) @ExcelProperty("僵尸网格数") @ColumnWidth(15) private Integer gridLazyNum; + + //僵尸网格数占比 + @Excel(name = "僵尸网格数占比",width = 15) @ExcelProperty("僵尸网格数占比") @ColumnWidth(15) private String gridLazyRatio; diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java index 84dec4c630..527b6a484b 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java @@ -1,60 +1,61 @@ package com.epmet.dataaggre.service.datastats.impl; import com.alibaba.fastjson.JSON; -import com.epmet.commons.dynamic.datasource.annotation.DataSource; -import com.epmet.commons.tools.constant.NumConstant; -import com.epmet.commons.tools.enums.OrgLevelEnum; -import com.epmet.commons.tools.exception.RenException; -import com.epmet.commons.tools.feign.ResultDataResolver; -import com.epmet.commons.tools.utils.ConvertUtils; -import com.epmet.commons.tools.utils.DateUtils; -import com.epmet.commons.tools.utils.ExcelUtils; -import com.epmet.dataaggre.constant.DataSourceConstant; -import com.epmet.dataaggre.constant.OrgConstant; -import com.epmet.dataaggre.dao.datastats.DataStatsDao; -import com.epmet.dataaggre.dao.datastats.FactGridMemberStatisticsDailyDao; -import com.epmet.dataaggre.dto.datastats.FactGroupActDailyDTO; -import com.epmet.dataaggre.dto.datastats.form.*; -import com.epmet.dataaggre.dto.datastats.result.*; + import com.epmet.commons.dynamic.datasource.annotation.DataSource; + import com.epmet.commons.tools.constant.NumConstant; + import com.epmet.commons.tools.enums.OrgLevelEnum; + import com.epmet.commons.tools.enums.OrgTypeEnum; + import com.epmet.commons.tools.exception.RenException; + import com.epmet.commons.tools.feign.ResultDataResolver; + import com.epmet.commons.tools.utils.ConvertUtils; + import com.epmet.commons.tools.utils.DateUtils; + import com.epmet.commons.tools.utils.ExcelUtils; + import com.epmet.dataaggre.constant.DataSourceConstant; + import com.epmet.dataaggre.constant.OrgConstant; + import com.epmet.dataaggre.dao.datastats.DataStatsDao; + import com.epmet.dataaggre.dao.datastats.FactGridMemberStatisticsDailyDao; + import com.epmet.dataaggre.dto.datastats.FactGroupActDailyDTO; + import com.epmet.dataaggre.dto.datastats.form.*; + import com.epmet.dataaggre.dto.datastats.result.*; import com.epmet.dataaggre.dto.epmetuser.FactIcuserCategoryAnalysisDailyDTO; import com.epmet.dataaggre.dto.epmetuser.form.GridMemberPatrolListFormDTO; -import com.epmet.dataaggre.dto.epmetuser.result.GridMemberPatrolListResultDTO; -import com.epmet.dataaggre.dto.epmetuser.result.PatrolDailySumResult; -import com.epmet.dataaggre.dto.evaluationindex.ScreenAgencyOrGridListDTO; -import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerAgencyDTO; -import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerGridDTO; -import com.epmet.dataaggre.dto.evaluationindex.ScreenGovernRankDataDailyDTO; + import com.epmet.dataaggre.dto.epmetuser.result.GridMemberPatrolListResultDTO; + import com.epmet.dataaggre.dto.epmetuser.result.PatrolDailySumResult; + import com.epmet.dataaggre.dto.evaluationindex.ScreenAgencyOrGridListDTO; + import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerAgencyDTO; + import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerGridDTO; + import com.epmet.dataaggre.dto.evaluationindex.ScreenGovernRankDataDailyDTO; import com.epmet.dataaggre.dto.govorg.form.GridLivelyFormDTO; import com.epmet.dataaggre.dto.govorg.result.GridDateIdResultDTO; import com.epmet.dataaggre.dto.govorg.result.GridMemberDataAnalysisResultDTO; -import com.epmet.dataaggre.dto.govproject.form.ProjectTotalFormDTO; -import com.epmet.dataaggre.dto.resigroup.ActCategoryDictDTO; -import com.epmet.dataaggre.dto.resigroup.result.GroupActRankDetailDTO; -import com.epmet.dataaggre.entity.datastats.DimAgencyEntity; -import com.epmet.dataaggre.entity.datastats.FactAgencyGovernDailyEntity; -import com.epmet.dataaggre.excel.CustomerDataManageExcel; -import com.epmet.dataaggre.service.datastats.DataStatsService; -import com.epmet.dataaggre.service.epmetuser.StatsStaffPatrolRecordDailyService; -import com.epmet.dataaggre.service.evaluationindex.EvaluationIndexService; -import com.epmet.dataaggre.service.govorg.GovOrgService; -import com.epmet.dataaggre.service.opercrm.CustomerRelation; -import com.github.pagehelper.PageHelper; -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.servlet.http.HttpServletResponse; -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.text.NumberFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.*; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicReference; -import java.util.stream.Collectors; + import com.epmet.dataaggre.dto.govproject.form.ProjectTotalFormDTO; + import com.epmet.dataaggre.dto.resigroup.ActCategoryDictDTO; + import com.epmet.dataaggre.dto.resigroup.result.GroupActRankDetailDTO; + import com.epmet.dataaggre.entity.datastats.DimAgencyEntity; + import com.epmet.dataaggre.entity.datastats.FactAgencyGovernDailyEntity; + import com.epmet.dataaggre.excel.CustomerDataManageExcel; + import com.epmet.dataaggre.service.datastats.DataStatsService; + import com.epmet.dataaggre.service.epmetuser.StatsStaffPatrolRecordDailyService; + import com.epmet.dataaggre.service.evaluationindex.EvaluationIndexService; + import com.epmet.dataaggre.service.govorg.GovOrgService; + import com.epmet.dataaggre.service.opercrm.CustomerRelation; + import com.github.pagehelper.PageHelper; + 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.servlet.http.HttpServletResponse; + import java.math.BigDecimal; + import java.math.RoundingMode; + import java.text.NumberFormat; + import java.text.ParseException; + import java.text.SimpleDateFormat; + import java.util.*; + import java.util.concurrent.atomic.AtomicInteger; + import java.util.concurrent.atomic.AtomicReference; + import java.util.stream.Collectors; /** * @Author sun @@ -98,15 +99,15 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve formDTO.setDateId(format.format(yesterday)); } - //0.根据组织Id查询是否存在子客户,存在的按areaCode查询当前客户之外的客户组织列表 + //NumConstant.ZERO.根据组织Id查询是否存在子客户,存在的按areaCode查询当前客户之外的客户组织列表 agencyList = indexService.getAgencyIdsByAgencyId(formDTO.getAgencyId()); agencyList.add(formDTO.getAgencyId()); //1.查询组织下注册用户最新日统计数据【只查询注册用户的统计数据,不涉及参与用户的】 List userList = dataStatsDao.getAgnecyRegUser(agencyList, formDTO.getDateId()); - int userTotal = 0; - int resiTotal = 0; - int partyMemberTotal = 0; + int userTotal = NumConstant.ZERO; + int resiTotal = NumConstant.ZERO; + int partyMemberTotal = NumConstant.ZERO; for (AgencyBasicDataResultDTO u : userList){ userTotal+=u.getUserTotal(); resiTotal+=u.getResiTotal(); @@ -114,15 +115,15 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve } resultDTO.setUserTotal(userTotal); resultDTO.setResiTotal(resiTotal); - resultDTO.setResiRatio(resultDTO.getResiTotal() == 0 || resultDTO.getUserTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getResiTotal() / (float) resultDTO.getUserTotal()))); + resultDTO.setResiRatio(resultDTO.getResiTotal() == NumConstant.ZERO || resultDTO.getUserTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getResiTotal() / (float) resultDTO.getUserTotal()))); resultDTO.setPartyMemberTotal(partyMemberTotal); - resultDTO.setPartyMemberRatio(resultDTO.getPartyMemberTotal() == 0 || resultDTO.getUserTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getPartyMemberTotal() / (float) resultDTO.getUserTotal()))); + resultDTO.setPartyMemberRatio(resultDTO.getPartyMemberTotal() == NumConstant.ZERO || resultDTO.getUserTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getPartyMemberTotal() / (float) resultDTO.getUserTotal()))); //2.查询组织下最新群组日统计数据 List groupList = dataStatsDao.getAgnecyGroup(agencyList, formDTO.getDateId()); - int groupTotal = 0; - int ordinaryTotal = 0; - int branchTotal = 0; + int groupTotal = NumConstant.ZERO; + int ordinaryTotal = NumConstant.ZERO; + int branchTotal = NumConstant.ZERO; for (AgencyBasicDataResultDTO g : groupList){ groupTotal+=g.getGroupTotal(); ordinaryTotal+=g.getOrdinaryTotal(); @@ -130,9 +131,9 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve } resultDTO.setGroupTotal(groupTotal); resultDTO.setOrdinaryTotal(ordinaryTotal); - resultDTO.setOrdinaryRatio(resultDTO.getOrdinaryTotal() == 0 || resultDTO.getGroupTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getOrdinaryTotal() / (float) resultDTO.getGroupTotal()))); + resultDTO.setOrdinaryRatio(resultDTO.getOrdinaryTotal() == NumConstant.ZERO || resultDTO.getGroupTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getOrdinaryTotal() / (float) resultDTO.getGroupTotal()))); resultDTO.setBranchTotal(branchTotal); - resultDTO.setBranchRatio(resultDTO.getBranchTotal() == 0 || resultDTO.getGroupTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getBranchTotal() / (float) resultDTO.getGroupTotal()))); + resultDTO.setBranchRatio(resultDTO.getBranchTotal() == NumConstant.ZERO || resultDTO.getGroupTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getBranchTotal() / (float) resultDTO.getGroupTotal()))); //3.查询组织下最新话题日统计数据 //状态话题-机关日统计数据表最新日期三种状态数据 @@ -148,21 +149,21 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve //转议题 int shiftIssueTotal = topicSHiftIssue.stream().mapToInt(AgencyBasicDataResultDTO.Topic::getShiftedIssueTotal).sum(); resultDTO.setShiftIssueTotal(shiftIssueTotal); - resultDTO.setShiftIssueRatio(resultDTO.getShiftIssueTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftIssueTotal() / (float) resultDTO.getTopicTotal()))); + resultDTO.setShiftIssueRatio(resultDTO.getShiftIssueTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftIssueTotal() / (float) resultDTO.getTopicTotal()))); //热议中 int discussingTotal = hotdiscuss.stream().mapToInt(AgencyBasicDataResultDTO.Topic::getTopicCount).sum(); resultDTO.setDiscussingTotal(discussingTotal); - resultDTO.setDiscussingRatio(resultDTO.getDiscussingTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getDiscussingTotal() / (float) resultDTO.getTopicTotal()))); + resultDTO.setDiscussingRatio(resultDTO.getDiscussingTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getDiscussingTotal() / (float) resultDTO.getTopicTotal()))); //已处理 resultDTO.setClosedTopicTotal(closedTotal); - resultDTO.setClosedTopicRatio(resultDTO.getClosedTopicTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedTopicTotal() / (float) resultDTO.getTopicTotal()))); + resultDTO.setClosedTopicRatio(resultDTO.getClosedTopicTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedTopicTotal() / (float) resultDTO.getTopicTotal()))); - //4.查询组织下最新议题日统计数据 + //NumConstant.FOUR.查询组织下最新议题日统计数据 List issueList = dataStatsDao.getAgencyIssue(agencyList, formDTO.getDateId()); - int issueTotal = 0; - int votingTotal = 0; - int closedIssueTotal = 0; - int shiftProjectTotal = 0; + int issueTotal = NumConstant.ZERO; + int votingTotal = NumConstant.ZERO; + int closedIssueTotal = NumConstant.ZERO; + int shiftProjectTotal = NumConstant.ZERO; for (AgencyBasicDataResultDTO i : issueList){ issueTotal+=i.getIssueTotal(); votingTotal+=i.getVotingTotal(); @@ -171,17 +172,17 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve } resultDTO.setIssueTotal(issueTotal); resultDTO.setVotingTotal(votingTotal); - resultDTO.setVotingRatio(resultDTO.getVotingTotal() == 0 || resultDTO.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getVotingTotal() / (float) resultDTO.getIssueTotal()))); + resultDTO.setVotingRatio(resultDTO.getVotingTotal() == NumConstant.ZERO || resultDTO.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getVotingTotal() / (float) resultDTO.getIssueTotal()))); resultDTO.setClosedIssueTotal(closedIssueTotal); - resultDTO.setClosedIssueRatio(resultDTO.getClosedIssueTotal() == 0 || resultDTO.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedIssueTotal() / (float) resultDTO.getIssueTotal()))); + resultDTO.setClosedIssueRatio(resultDTO.getClosedIssueTotal() == NumConstant.ZERO || resultDTO.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedIssueTotal() / (float) resultDTO.getIssueTotal()))); resultDTO.setShiftProjectTotal(shiftProjectTotal); - resultDTO.setShiftProjectRatio(resultDTO.getShiftProjectTotal() == 0 || resultDTO.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftProjectTotal() / (float) resultDTO.getIssueTotal()))); + resultDTO.setShiftProjectRatio(resultDTO.getShiftProjectTotal() == NumConstant.ZERO || resultDTO.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftProjectTotal() / (float) resultDTO.getIssueTotal()))); //5.查询组织下最新项目日统计数据 List projectList = dataStatsDao.getAgencyProject(agencyList, formDTO.getDateId()); - int projectTotal = 0; - int pendingTotal = 0; - int closedProjectTotal = 0; + int projectTotal = NumConstant.ZERO; + int pendingTotal = NumConstant.ZERO; + int closedProjectTotal = NumConstant.ZERO; for (AgencyBasicDataResultDTO p : projectList){ projectTotal+=p.getProjectTotal(); pendingTotal+=p.getPendingTotal(); @@ -189,9 +190,9 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve } resultDTO.setProjectTotal(projectTotal); resultDTO.setPendingTotal(pendingTotal); - resultDTO.setPendingRatio(resultDTO.getPendingTotal() == 0 || resultDTO.getProjectTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getPendingTotal() / (float) resultDTO.getProjectTotal()))); + resultDTO.setPendingRatio(resultDTO.getPendingTotal() == NumConstant.ZERO || resultDTO.getProjectTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getPendingTotal() / (float) resultDTO.getProjectTotal()))); resultDTO.setClosedProjectTotal(closedProjectTotal); - resultDTO.setClosedProjectRatio(resultDTO.getClosedProjectTotal() == 0 || resultDTO.getProjectTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedProjectTotal() / (float) resultDTO.getProjectTotal()))); + resultDTO.setClosedProjectRatio(resultDTO.getClosedProjectTotal() == NumConstant.ZERO || resultDTO.getProjectTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedProjectTotal() / (float) resultDTO.getProjectTotal()))); return resultDTO; } @@ -220,21 +221,21 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve gridIds.add(formDTO.getGridId()); List userList = dataStatsDao.getSubGridUser(gridIds, formDTO.getDateId()); if (userList.size() > NumConstant.ZERO) { - resultDTO.setUserTotal(userList.get(0).getUserTotal()); - resultDTO.setResiTotal(userList.get(0).getResiTotal()); - resultDTO.setResiRatio(resultDTO.getResiTotal() == 0 || resultDTO.getUserTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getResiTotal() / (float) resultDTO.getUserTotal()))); - resultDTO.setPartyMemberTotal(userList.get(0).getPartyMemberTotal()); - resultDTO.setPartyMemberRatio(resultDTO.getPartyMemberTotal() == 0 || resultDTO.getUserTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getPartyMemberTotal() / (float) resultDTO.getUserTotal()))); + resultDTO.setUserTotal(userList.get(NumConstant.ZERO).getUserTotal()); + resultDTO.setResiTotal(userList.get(NumConstant.ZERO).getResiTotal()); + resultDTO.setResiRatio(resultDTO.getResiTotal() == NumConstant.ZERO || resultDTO.getUserTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getResiTotal() / (float) resultDTO.getUserTotal()))); + resultDTO.setPartyMemberTotal(userList.get(NumConstant.ZERO).getPartyMemberTotal()); + resultDTO.setPartyMemberRatio(resultDTO.getPartyMemberTotal() == NumConstant.ZERO || resultDTO.getUserTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getPartyMemberTotal() / (float) resultDTO.getUserTotal()))); } //2.查询网格下最新群组日统计数据 List groupList = dataStatsDao.getSubGridGroup(gridIds, formDTO.getDateId()); if (groupList.size() > NumConstant.ZERO) { - resultDTO.setGroupTotal(groupList.get(0).getGroupTotal()); - resultDTO.setOrdinaryTotal(groupList.get(0).getOrdinaryTotal()); - resultDTO.setOrdinaryRatio(resultDTO.getOrdinaryTotal() == 0 || resultDTO.getGroupTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getOrdinaryTotal() / (float) resultDTO.getGroupTotal()))); - resultDTO.setBranchTotal(groupList.get(0).getBranchTotal()); - resultDTO.setBranchRatio(resultDTO.getBranchTotal() == 0 || resultDTO.getGroupTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getBranchTotal() / (float) resultDTO.getGroupTotal()))); + resultDTO.setGroupTotal(groupList.get(NumConstant.ZERO).getGroupTotal()); + resultDTO.setOrdinaryTotal(groupList.get(NumConstant.ZERO).getOrdinaryTotal()); + resultDTO.setOrdinaryRatio(resultDTO.getOrdinaryTotal() == NumConstant.ZERO || resultDTO.getGroupTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getOrdinaryTotal() / (float) resultDTO.getGroupTotal()))); + resultDTO.setBranchTotal(groupList.get(NumConstant.ZERO).getBranchTotal()); + resultDTO.setBranchRatio(resultDTO.getBranchTotal() == NumConstant.ZERO || resultDTO.getGroupTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getBranchTotal() / (float) resultDTO.getGroupTotal()))); } //3.查询网格下最新话题日统计数据 @@ -245,7 +246,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve List topicShiftIssueList = dataStatsDao.getSubGridTopicShiftIssue(gridIds, formDTO.getDateId()); //热议中话题-网格日统计数据 List hotdiscussList = dataStatsDao.getSubGridTopicHotDiscuss(gridIds, formDTO.getDateId()); - AtomicReference closedTotal = new AtomicReference<>(0); + AtomicReference closedTotal = new AtomicReference<>(NumConstant.ZERO); if (topicList.size() > NumConstant.ZERO) { resultDTO.setTopicTotal(topicList.stream().collect(Collectors.summingInt(SubGridFormDTO.Topic::getTopicCount))); topicList.forEach(t -> { @@ -256,38 +257,38 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve } //转议题 if (topicShiftIssueList.size() > NumConstant.ZERO) { - resultDTO.setShiftIssueTotal(topicShiftIssueList.get(0).getShiftedIssueTotal()); - resultDTO.setShiftIssueRatio(resultDTO.getShiftIssueTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftIssueTotal() / (float) resultDTO.getTopicTotal()))); + resultDTO.setShiftIssueTotal(topicShiftIssueList.get(NumConstant.ZERO).getShiftedIssueTotal()); + resultDTO.setShiftIssueRatio(resultDTO.getShiftIssueTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftIssueTotal() / (float) resultDTO.getTopicTotal()))); } //热议中 if (hotdiscussList.size() > NumConstant.ZERO) { - resultDTO.setDiscussingTotal(hotdiscussList.get(0).getTopicCount()); - resultDTO.setDiscussingRatio(resultDTO.getDiscussingTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getDiscussingTotal() / (float) resultDTO.getTopicTotal()))); + resultDTO.setDiscussingTotal(hotdiscussList.get(NumConstant.ZERO).getTopicCount()); + resultDTO.setDiscussingRatio(resultDTO.getDiscussingTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getDiscussingTotal() / (float) resultDTO.getTopicTotal()))); } //已处理 resultDTO.setClosedTopicTotal(closedTotal.get()); - resultDTO.setClosedTopicRatio(resultDTO.getClosedTopicTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedTopicTotal() / (float) resultDTO.getTopicTotal()))); + resultDTO.setClosedTopicRatio(resultDTO.getClosedTopicTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedTopicTotal() / (float) resultDTO.getTopicTotal()))); - //4.查询网格下最新议题日统计数据 + //NumConstant.FOUR.查询网格下最新议题日统计数据 List issueList = dataStatsDao.getSubGridIssue(gridIds, formDTO.getDateId()); if (issueList.size() > NumConstant.ZERO) { - resultDTO.setIssueTotal(issueList.get(0).getIssueTotal()); - resultDTO.setVotingTotal(issueList.get(0).getVotingTotal()); - resultDTO.setVotingRatio(resultDTO.getVotingTotal() == 0 || resultDTO.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getVotingTotal() / (float) resultDTO.getIssueTotal()))); - resultDTO.setClosedIssueTotal(issueList.get(0).getClosedIssueTotal()); - resultDTO.setClosedIssueRatio(resultDTO.getClosedIssueTotal() == 0 || resultDTO.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedIssueTotal() / (float) resultDTO.getIssueTotal()))); - resultDTO.setShiftProjectTotal(issueList.get(0).getShiftProjectTotal()); - resultDTO.setShiftProjectRatio(resultDTO.getShiftProjectTotal() == 0 || resultDTO.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftProjectTotal() / (float) resultDTO.getIssueTotal()))); + resultDTO.setIssueTotal(issueList.get(NumConstant.ZERO).getIssueTotal()); + resultDTO.setVotingTotal(issueList.get(NumConstant.ZERO).getVotingTotal()); + resultDTO.setVotingRatio(resultDTO.getVotingTotal() == NumConstant.ZERO || resultDTO.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getVotingTotal() / (float) resultDTO.getIssueTotal()))); + resultDTO.setClosedIssueTotal(issueList.get(NumConstant.ZERO).getClosedIssueTotal()); + resultDTO.setClosedIssueRatio(resultDTO.getClosedIssueTotal() == NumConstant.ZERO || resultDTO.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedIssueTotal() / (float) resultDTO.getIssueTotal()))); + resultDTO.setShiftProjectTotal(issueList.get(NumConstant.ZERO).getShiftProjectTotal()); + resultDTO.setShiftProjectRatio(resultDTO.getShiftProjectTotal() == NumConstant.ZERO || resultDTO.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftProjectTotal() / (float) resultDTO.getIssueTotal()))); } //5.查询网格下最新项目日统计数据 List projectList = dataStatsDao.getSubGridProject(gridIds, formDTO.getDateId()); if (projectList.size() > NumConstant.ZERO) { - resultDTO.setProjectTotal(projectList.get(0).getProjectTotal()); - resultDTO.setPendingTotal(projectList.get(0).getPendingTotal()); - resultDTO.setPendingRatio(resultDTO.getPendingTotal() == 0 || resultDTO.getProjectTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getPendingTotal() / (float) resultDTO.getProjectTotal()))); - resultDTO.setClosedProjectTotal(projectList.get(0).getClosedProjectTotal()); - resultDTO.setClosedProjectRatio(resultDTO.getClosedProjectTotal() == 0 || resultDTO.getProjectTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedProjectTotal() / (float) resultDTO.getProjectTotal()))); + resultDTO.setProjectTotal(projectList.get(NumConstant.ZERO).getProjectTotal()); + resultDTO.setPendingTotal(projectList.get(NumConstant.ZERO).getPendingTotal()); + resultDTO.setPendingRatio(resultDTO.getPendingTotal() == NumConstant.ZERO || resultDTO.getProjectTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getPendingTotal() / (float) resultDTO.getProjectTotal()))); + resultDTO.setClosedProjectTotal(projectList.get(NumConstant.ZERO).getClosedProjectTotal()); + resultDTO.setClosedProjectRatio(resultDTO.getClosedProjectTotal() == NumConstant.ZERO || resultDTO.getProjectTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedProjectTotal() / (float) resultDTO.getProjectTotal()))); } return resultDTO; @@ -339,12 +340,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve dto.setResiTotal(u.getResiTotal()); } } - dto.setPartyMemberRatio(dto.getPartyMemberTotal() == 0 || dto.getUserTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getPartyMemberTotal() / (float) dto.getUserTotal()))); - dto.setResiRatio(dto.getResiTotal() == 0 || dto.getUserTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getResiTotal() / (float) dto.getUserTotal()))); + dto.setPartyMemberRatio(dto.getPartyMemberTotal() == NumConstant.ZERO || dto.getUserTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getPartyMemberTotal() / (float) dto.getUserTotal()))); + dto.setResiRatio(dto.getResiTotal() == NumConstant.ZERO || dto.getUserTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getResiTotal() / (float) dto.getUserTotal()))); resultList.add(dto); } - //4.按要求排序并返回 + //NumConstant.FOUR.按要求排序并返回 Collections.sort(resultList, new Comparator() { @Override public int compare(SubAgencyUserResultDTO o1, SubAgencyUserResultDTO o2) { @@ -408,12 +409,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve dto.setResiTotal(re.getResiTotal()); } } - dto.setPartyMemberRatio(dto.getPartyMemberTotal() == 0 || dto.getUserTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getPartyMemberTotal() / (float) dto.getUserTotal()))); - dto.setResiRatio(dto.getResiTotal() == 0 || dto.getUserTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getResiTotal() / (float) dto.getUserTotal()))); + dto.setPartyMemberRatio(dto.getPartyMemberTotal() == NumConstant.ZERO || dto.getUserTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getPartyMemberTotal() / (float) dto.getUserTotal()))); + dto.setResiRatio(dto.getResiTotal() == NumConstant.ZERO || dto.getUserTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getResiTotal() / (float) dto.getUserTotal()))); resultList.add(dto); } - //4.按要求排序并返回 + //NumConstant.FOUR.按要求排序并返回 Collections.sort(resultList, new Comparator() { @Override public int compare(SubGridUserResultDTO o1, SubGridUserResultDTO o2) { @@ -477,12 +478,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve dto.setBranchTotal(u.getBranchTotal()); } } - dto.setOrdinaryRatio(dto.getOrdinaryTotal() == 0 || dto.getGroupTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getOrdinaryTotal() / (float) dto.getGroupTotal()))); - dto.setBranchRatio(dto.getBranchTotal() == 0 || dto.getGroupTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getBranchTotal() / (float) dto.getGroupTotal()))); + dto.setOrdinaryRatio(dto.getOrdinaryTotal() == NumConstant.ZERO || dto.getGroupTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getOrdinaryTotal() / (float) dto.getGroupTotal()))); + dto.setBranchRatio(dto.getBranchTotal() == NumConstant.ZERO || dto.getGroupTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getBranchTotal() / (float) dto.getGroupTotal()))); resultList.add(dto); } - //4.按要求排序并返回 + //NumConstant.FOUR.按要求排序并返回 Collections.sort(resultList, new Comparator() { @Override public int compare(SubAgencyGroupResultDTO o1, SubAgencyGroupResultDTO o2) { @@ -543,12 +544,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve dto.setBranchTotal(re.getBranchTotal()); } } - dto.setOrdinaryRatio(dto.getOrdinaryTotal() == 0 || dto.getGroupTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getOrdinaryTotal() / (float) dto.getGroupTotal()))); - dto.setBranchRatio(dto.getBranchTotal() == 0 || dto.getGroupTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getBranchTotal() / (float) dto.getGroupTotal()))); + dto.setOrdinaryRatio(dto.getOrdinaryTotal() == NumConstant.ZERO || dto.getGroupTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getOrdinaryTotal() / (float) dto.getGroupTotal()))); + dto.setBranchRatio(dto.getBranchTotal() == NumConstant.ZERO || dto.getGroupTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getBranchTotal() / (float) dto.getGroupTotal()))); resultList.add(dto); } - //4.按要求排序并返回 + //NumConstant.FOUR.按要求排序并返回 Collections.sort(resultList, new Comparator() { @Override public int compare(SubGridGroupResultDTO o1, SubGridGroupResultDTO o2) { @@ -604,10 +605,10 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve List hotdiscuss = dataStatsDao.getSubAgencyTopicHotDiscuss(agencyIds, formDTO.getDateId()); subAgencyList.forEach(sub -> { SubAgencyTopicResultDTO resultDTO = new SubAgencyTopicResultDTO(); - AtomicInteger topicTotal = new AtomicInteger(0); - AtomicInteger closedTotal = new AtomicInteger(0); - AtomicInteger shiftIssueTotal = new AtomicInteger(0); - AtomicInteger hotdiscussTotal = new AtomicInteger(0); + AtomicInteger topicTotal = new AtomicInteger(NumConstant.ZERO); + AtomicInteger closedTotal = new AtomicInteger(NumConstant.ZERO); + AtomicInteger shiftIssueTotal = new AtomicInteger(NumConstant.ZERO); + AtomicInteger hotdiscussTotal = new AtomicInteger(NumConstant.ZERO); topic.forEach(t -> { if (t.getAgencyId().equals(sub.getAgencyId())) { topicTotal.addAndGet(t.getTopicCount()); @@ -633,28 +634,25 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve resultDTO.setAreaCode(null == sub.getAreaCode() ? "" : sub.getAreaCode()); resultDTO.setTopicTotal(topicTotal.get()); resultDTO.setDiscussingTotal(hotdiscussTotal.get()); - resultDTO.setDiscussingRatio(resultDTO.getDiscussingTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getDiscussingTotal() / (float) resultDTO.getTopicTotal()))); + resultDTO.setDiscussingRatio(resultDTO.getDiscussingTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getDiscussingTotal() / (float) resultDTO.getTopicTotal()))); resultDTO.setClosedTopicTotal(closedTotal.get()); - resultDTO.setClosedTopicRatio(resultDTO.getClosedTopicTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedTopicTotal() / (float) resultDTO.getTopicTotal()))); + resultDTO.setClosedTopicRatio(resultDTO.getClosedTopicTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedTopicTotal() / (float) resultDTO.getTopicTotal()))); resultDTO.setShiftIssueTotal(shiftIssueTotal.get()); - resultDTO.setShiftIssueRatio(resultDTO.getShiftIssueTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftIssueTotal() / (float) resultDTO.getTopicTotal()))); + resultDTO.setShiftIssueRatio(resultDTO.getShiftIssueTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftIssueTotal() / (float) resultDTO.getTopicTotal()))); resultList.add(resultDTO); }); //3.按要求排序并返回 - Collections.sort(resultList, new Comparator() { - @Override - public int compare(SubAgencyTopicResultDTO o1, SubAgencyTopicResultDTO o2) { - if ("discussing".equals(formDTO.getType())) { - return o2.getDiscussingTotal().compareTo(o1.getDiscussingTotal()); - } else if ("closed".equals(formDTO.getType())) { - return o2.getClosedTopicTotal().compareTo(o1.getClosedTopicTotal()); - } else if ("shiftIssue".equals(formDTO.getType())) { - return o2.getShiftIssueTotal().compareTo(o1.getShiftIssueTotal()); - } else { - return o2.getTopicTotal().compareTo(o1.getTopicTotal()); - } + resultList.sort((o1, o2) -> { + if ("discussing".equals(formDTO.getType())) { + return o2.getDiscussingTotal().compareTo(o1.getDiscussingTotal()); + } else if ("closed".equals(formDTO.getType())) { + return o2.getClosedTopicTotal().compareTo(o1.getClosedTopicTotal()); + } else if ("shiftIssue".equals(formDTO.getType())) { + return o2.getShiftIssueTotal().compareTo(o1.getShiftIssueTotal()); + } else { + return o2.getTopicTotal().compareTo(o1.getTopicTotal()); } }); @@ -700,10 +698,10 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve List hotdiscuss = dataStatsDao.getSubGridTopicHotDiscuss(gridIds, formDTO.getDateId()); gridList.forEach(gr -> { SubGridTopicResultDTO resultDTO = new SubGridTopicResultDTO(); - AtomicInteger topicTotal = new AtomicInteger(0); - AtomicInteger closedTotal = new AtomicInteger(0); - AtomicInteger shiftIssueTotal = new AtomicInteger(0); - AtomicInteger hotdiscussTotal = new AtomicInteger(0); + AtomicInteger topicTotal = new AtomicInteger(NumConstant.ZERO); + AtomicInteger closedTotal = new AtomicInteger(NumConstant.ZERO); + AtomicInteger shiftIssueTotal = new AtomicInteger(NumConstant.ZERO); + AtomicInteger hotdiscussTotal = new AtomicInteger(NumConstant.ZERO); topic.forEach(t -> { if (t.getGridId().equals(gr.getGridId())) { topicTotal.addAndGet(t.getTopicCount()); @@ -727,11 +725,11 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve resultDTO.setGridName(gr.getGridName()); resultDTO.setTopicTotal(topicTotal.get()); resultDTO.setDiscussingTotal(hotdiscussTotal.get()); - resultDTO.setDiscussingRatio(resultDTO.getDiscussingTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getDiscussingTotal() / (float) resultDTO.getTopicTotal()))); + resultDTO.setDiscussingRatio(resultDTO.getDiscussingTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getDiscussingTotal() / (float) resultDTO.getTopicTotal()))); resultDTO.setClosedTopicTotal(closedTotal.get()); - resultDTO.setClosedTopicRatio(resultDTO.getClosedTopicTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedTopicTotal() / (float) resultDTO.getTopicTotal()))); + resultDTO.setClosedTopicRatio(resultDTO.getClosedTopicTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedTopicTotal() / (float) resultDTO.getTopicTotal()))); resultDTO.setShiftIssueTotal(shiftIssueTotal.get()); - resultDTO.setShiftIssueRatio(resultDTO.getShiftIssueTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftIssueTotal() / (float) resultDTO.getTopicTotal()))); + resultDTO.setShiftIssueRatio(resultDTO.getShiftIssueTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftIssueTotal() / (float) resultDTO.getTopicTotal()))); resultList.add(resultDTO); }); @@ -802,13 +800,13 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve dto.setShiftProjectTotal(u.getShiftProjectTotal()); } } - dto.setVotingRatio(dto.getVotingTotal() == 0 || dto.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getVotingTotal() / (float) dto.getIssueTotal()))); - dto.setClosedIssueRatio(dto.getClosedIssueTotal() == 0 || dto.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getClosedIssueTotal() / (float) dto.getIssueTotal()))); - dto.setShiftProjectRatio(dto.getShiftProjectTotal() == 0 || dto.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getShiftProjectTotal() / (float) dto.getIssueTotal()))); + dto.setVotingRatio(dto.getVotingTotal() == NumConstant.ZERO || dto.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getVotingTotal() / (float) dto.getIssueTotal()))); + dto.setClosedIssueRatio(dto.getClosedIssueTotal() == NumConstant.ZERO || dto.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getClosedIssueTotal() / (float) dto.getIssueTotal()))); + dto.setShiftProjectRatio(dto.getShiftProjectTotal() == NumConstant.ZERO || dto.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getShiftProjectTotal() / (float) dto.getIssueTotal()))); resultList.add(dto); } - //4.按要求排序并返回 + //NumConstant.FOUR.按要求排序并返回 Collections.sort(resultList, new Comparator() { @Override public int compare(SubAgencyIssueResultDTO o1, SubAgencyIssueResultDTO o2) { @@ -872,13 +870,13 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve dto.setShiftProjectTotal(re.getShiftProjectTotal()); } } - dto.setVotingRatio(dto.getVotingTotal() == 0 || dto.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getVotingTotal() / (float) dto.getIssueTotal()))); - dto.setClosedIssueRatio(dto.getClosedIssueTotal() == 0 || dto.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getClosedIssueTotal() / (float) dto.getIssueTotal()))); - dto.setShiftProjectRatio(dto.getShiftProjectTotal() == 0 || dto.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getShiftProjectTotal() / (float) dto.getIssueTotal()))); + dto.setVotingRatio(dto.getVotingTotal() == NumConstant.ZERO || dto.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getVotingTotal() / (float) dto.getIssueTotal()))); + dto.setClosedIssueRatio(dto.getClosedIssueTotal() == NumConstant.ZERO || dto.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getClosedIssueTotal() / (float) dto.getIssueTotal()))); + dto.setShiftProjectRatio(dto.getShiftProjectTotal() == NumConstant.ZERO || dto.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getShiftProjectTotal() / (float) dto.getIssueTotal()))); resultList.add(dto); } - //4.按要求排序并返回 + //NumConstant.FOUR.按要求排序并返回 Collections.sort(resultList, new Comparator() { @Override public int compare(SubGridIssueResultDTO o1, SubGridIssueResultDTO o2) { @@ -943,12 +941,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve dto.setClosedProjectTotal(u.getClosedProjectTotal()); } } - dto.setPendingRatio(dto.getPendingTotal() == 0 || dto.getProjectTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getPendingTotal() / (float) dto.getProjectTotal()))); - dto.setClosedProjectRatio(dto.getClosedProjectTotal() == 0 || dto.getProjectTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getClosedProjectTotal() / (float) dto.getProjectTotal()))); + dto.setPendingRatio(dto.getPendingTotal() == NumConstant.ZERO || dto.getProjectTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getPendingTotal() / (float) dto.getProjectTotal()))); + dto.setClosedProjectRatio(dto.getClosedProjectTotal() == NumConstant.ZERO || dto.getProjectTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getClosedProjectTotal() / (float) dto.getProjectTotal()))); resultList.add(dto); } - //4.按要求排序并返回 + //NumConstant.FOUR.按要求排序并返回 Collections.sort(resultList, new Comparator() { @Override public int compare(SubAgencyProjectResultDTO o1, SubAgencyProjectResultDTO o2) { @@ -1009,12 +1007,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve dto.setClosedProjectTotal(re.getClosedProjectTotal()); } } - dto.setPendingRatio(dto.getPendingTotal() == 0 || dto.getProjectTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getPendingTotal() / (float) dto.getProjectTotal()))); - dto.setClosedProjectRatio(dto.getClosedProjectTotal() == 0 || dto.getProjectTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getClosedProjectTotal() / (float) dto.getProjectTotal()))); + dto.setPendingRatio(dto.getPendingTotal() == NumConstant.ZERO || dto.getProjectTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getPendingTotal() / (float) dto.getProjectTotal()))); + dto.setClosedProjectRatio(dto.getClosedProjectTotal() == NumConstant.ZERO || dto.getProjectTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getClosedProjectTotal() / (float) dto.getProjectTotal()))); resultList.add(dto); } - //4.按要求排序并返回 + //NumConstant.FOUR.按要求排序并返回 Collections.sort(resultList, new Comparator() { @Override public int compare(SubGridProjectResultDTO o1, SubGridProjectResultDTO o2) { @@ -1278,7 +1276,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve resultList.add(dto); } - //4.按要求排序并返回 + //NumConstant.FOUR.按要求排序并返回 Collections.sort(resultList, new Comparator() { @Override public int compare(AgencyGovrnResultDTO o1, AgencyGovrnResultDTO o2) { @@ -1380,7 +1378,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve resultList.add(dto); } - //4.按要求排序并返回 + //NumConstant.FOUR.按要求排序并返回 Collections.sort(resultList, new Comparator() { @Override public int compare(GridGovrnResultDTO o1, GridGovrnResultDTO o2) { @@ -1388,7 +1386,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve return o2.getGroupSelfGovernRatio().compareTo(o1.getGroupSelfGovernRatio()); } else if ("grid".equals(formDTO.getType())) { return o2.getGridSelfGovernRatio().compareTo(o1.getGridSelfGovernRatio()); - } else if ("community".equals(formDTO.getType())) { + } else if (OrgLevelEnum.COMMUNITY.getCode().equals(formDTO.getType())) { return o2.getCommunityResolvedRatio().compareTo(o1.getCommunityResolvedRatio()); } else if ("department".equals(formDTO.getType())) { return o2.getDistrictDeptResolvedRatio().compareTo(o1.getDistrictDeptResolvedRatio()); @@ -1471,18 +1469,18 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve formDTO.setDateId(format.format(yesterday)); } BaseStatsDataResultDTO result = new BaseStatsDataResultDTO(); - result.setTopicTotal(0); - result.setTopicIncr(0); + result.setTopicTotal(NumConstant.ZERO); + result.setTopicIncr(NumConstant.ZERO); - result.setIssueTotal(0); - result.setIssueIncr(0); - result.setProjectTotal(0); - result.setProjectIncr(0); - result.setClosedProjectTotal(0); - result.setClosedProjectIncr(0); + result.setIssueTotal(NumConstant.ZERO); + result.setIssueIncr(NumConstant.ZERO); + result.setProjectTotal(NumConstant.ZERO); + result.setProjectIncr(NumConstant.ZERO); + result.setClosedProjectTotal(NumConstant.ZERO); + result.setClosedProjectIncr(NumConstant.ZERO); - //0.根据组织Id查询是否存在子客户,存在的按areaCode查询当前客户之外的客户组织列表 + //NumConstant.ZERO.根据组织Id查询是否存在子客户,存在的按areaCode查询当前客户之外的客户组织列表 List agencyList = indexService.getAgencyIdsByAgencyId(formDTO.getAgencyId()); agencyList.add(formDTO.getAgencyId()); TotalAndIncrResultDTO sum = dataStatsDao.getAgencySumTopic(agencyList, formDTO.getDateId()); @@ -1546,7 +1544,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve List result = new ArrayList<>(); //如果是社区 则下级是网格 查询网格的数据 if (OrgLevelEnum.COMMUNITY.getCode().equals(formDTO.getAgencyLevel())){ - //0.根据组织Id查询是否存在子客户,存在的按areaCode查询当前客户之外的客户组织列表 + //NumConstant.ZERO.根据组织Id查询是否存在子客户,存在的按areaCode查询当前客户之外的客户组织列表 List subAgencyList = indexService.getSubGridList(formDTO.getAgencyId()); if (subAgencyList.size() < NumConstant.ONE) { return null; @@ -1585,7 +1583,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve result.add(resultDTO); }); }else { - //0.根据组织Id查询是否存在子客户,存在的按areaCode查询当前客户之外的客户组织列表 + //NumConstant.ZERO.根据组织Id查询是否存在子客户,存在的按areaCode查询当前客户之外的客户组织列表 List subAgencyList = indexService.getSubAgencyListByAgency(formDTO.getAgencyId()); if (subAgencyList.size() < NumConstant.ONE) { return null; @@ -1636,9 +1634,9 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve resultDTO.setRoutineWorkCount(patrolRecordDTO.getRoutineWorkCount()); resultDTO.setPatrolTotal(patrolRecordDTO.getPatrolTotal()); Integer totalTime = patrolRecordDTO.getTotalTime(); - if (totalTime != null || totalTime > 0){ + if (totalTime != null || totalTime > NumConstant.ZERO){ int minutes = totalTime / 60; - if (minutes >0){ + if (minutes >NumConstant.ZERO){ String totalTimeDesc = minutes / 60 + "小时"+ minutes % 60 + "分"; resultDTO.setPatrolTotalTime(totalTimeDesc); } @@ -1649,12 +1647,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve private Integer getTotal(Map startMap, Map endMap,String agencyId){ Integer total1 = startMap.getOrDefault(agencyId,NumConstant.ZERO); Integer total2 = endMap.getOrDefault(agencyId,NumConstant.ZERO); - return Math.max(total2-total1,0); + return Math.max(total2-total1,NumConstant.ZERO); } private String getPercentage(Integer countInt, Integer totalInt) { if (NumConstant.ZERO == totalInt) { - return "0%"; + return "NumConstant.ZERO%"; } BigDecimal count = new BigDecimal(countInt); BigDecimal total = new BigDecimal(totalInt); @@ -1681,7 +1679,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve //根据组织级别判断查询直属下级组织或网格数据 //2.直属网格 - if ("community".equals(formDTO.getAgencyLevel())) { + if (OrgLevelEnum.COMMUNITY.getCode().equals(formDTO.getAgencyLevel())) { //2-1.查询组织直属网格列表【网格维度】 List gridList = indexService.getSubGridList(formDTO.getAgencyId()); if (gridList.size() < NumConstant.ONE) { @@ -1729,8 +1727,8 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve }); } - //4.按用户数降序排序并返回 - Collections.sort(resultList, (o1, o2) -> { + //NumConstant.FOUR.按用户数降序排序并返回 + resultList.sort((o1, o2) -> { //降序 return o2.getUserTotal().compareTo(o1.getUserTotal()); }); @@ -1757,7 +1755,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve //根据组织级别判断查询直属下级组织或网格数据 //2.直属网格 - if ("community".equals(formDTO.getAgencyLevel())) { + if (OrgLevelEnum.COMMUNITY.getCode().equals(formDTO.getAgencyLevel())) { //2-1.查询组织直属网格列表【网格维度】 List gridList = indexService.getSubGridList(formDTO.getAgencyId()); if (gridList.size() < NumConstant.ONE) { @@ -1798,7 +1796,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve List hotdiscuss = dataStatsDao.getSubAgencyTopicHotDiscuss(agencyIds, formDTO.getDateId()); //3-3.查询直属下级组织小组日统计数据 List list = dataStatsDao.getSubAgencyGroup(agencyIds, formDTO.getDateId()); - //3-4.封装数据 + //3-NumConstant.FOUR.封装数据 subAgencyList.forEach(sub -> { SubTopicAndGroupResultDTO resultDTO = new SubTopicAndGroupResultDTO(); resultDTO.setOrgId(sub.getAgencyId()); @@ -1817,12 +1815,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve }); } - //4.按用户数降序排序并返回 - Collections.sort(resultList, (o1, o2) -> { + //NumConstant.FOUR.按用户数降序排序并返回 + resultList.sort((o1, o2) -> { //降序 return o2.getTopicTotal().compareTo(o1.getTopicTotal()); }); - AtomicInteger i = new AtomicInteger(1); + AtomicInteger i = new AtomicInteger(NumConstant.ONE); resultList.forEach(e->e.setSort(i.getAndIncrement())); return resultList; } @@ -1876,24 +1874,27 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve */ @Override public void CustomerDataManage(CustomerDataManageFormDTO formDTO, HttpServletResponse response) throws Exception { + String openTime = formDTO.getStartTime(); List result = operateExport(formDTO).getList(); if (!CollectionUtils.isEmpty(result)){ CustomerDataManageResultDTO.CustomerDataManage c = new CustomerDataManageResultDTO.CustomerDataManage(); c.setOrgName("合计"); - c.setUserCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getUserCount))); - c.setResidentCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getResidentCount))); - c.setPartyMemberCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getPartyMemberCount))); - c.setGroupCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getGroupCount))); - c.setTopicCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getTopicCount))); - c.setIssueCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getIssueCount))); - c.setProjectCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getProjectCount))); - c.setClosedProjectCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getClosedProjectCount))); - c.setPatrolPeopleCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getPatrolPeopleCount))); - c.setPatrolCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getPatrolCount))); - c.setPatrolDurationInteger(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getPatrolDurationInteger))); + c.setUserCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getUserCount).sum()); + c.setResidentCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getResidentCount).sum()); + c.setPartyMemberCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getPartyMemberCount).sum()); + c.setGroupCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getGroupCount).sum()); + c.setTopicCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getTopicCount).sum()); + c.setIssueCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getIssueCount).sum()); + c.setProjectCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getProjectCount).sum()); + c.setClosedProjectCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getClosedProjectCount).sum()); + c.setPatrolPeopleCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getPatrolPeopleCount).sum()); + c.setPatrolRoutineWorkTimes(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getPatrolRoutineWorkTimes).sum()); + c.setPatrolCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getPatrolCount).sum()); + c.setPatrolDurationInteger(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getPatrolDurationInteger).sum()); c.setPatrolDuration(getHm(c.getPatrolDurationInteger())); result.add(c); } + formDTO.setStartTime(openTime); String fileName = excelName(formDTO); ExcelUtils.exportExcelToTargetDisposeAll(response,fileName,result, CustomerDataManageExcel.class); } @@ -1908,7 +1909,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve String result = "0分钟"; if (seconds >= NumConstant.SIXTY) { Integer hours = seconds / 3600; - Integer minutes = seconds % 3600 / 60; + Integer minutes = seconds % 3600 / NumConstant.SIXTY; result = (hours < NumConstant.ONE ? "" : hours + "小时") + (minutes < NumConstant.ONE ? "" : minutes + "分钟"); }else if (seconds < NumConstant.SIXTY && seconds > NumConstant.ZERO){ result = "1分钟"; @@ -1928,20 +1929,20 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve s.append(agencyName); if (StringUtils.isNotBlank(formDTO.getStartTime())){ String startTime = formDTO.getStartTime(); - String sYear = startTime.substring(0, 4); - String sMonth = startTime.substring(4, 6); - String sDay = startTime.substring(6, 8); + String sYear = startTime.substring(NumConstant.ZERO, NumConstant.FOUR); + String sMonth = startTime.substring(NumConstant.FOUR, NumConstant.SIX); + String sDay = startTime.substring(NumConstant.SIX, NumConstant.EIGHT); String endTime = formDTO.getEndTime(); - String eYear = endTime.substring(0, 4); - String eMonth = endTime.substring(4, 6); - String eDay = endTime.substring(6, 8); + String eYear = endTime.substring(NumConstant.ZERO, NumConstant.FOUR); + String eMonth = endTime.substring(NumConstant.FOUR, NumConstant.SIX); + String eDay = endTime.substring(NumConstant.SIX, NumConstant.EIGHT); s.append(sYear).append("年").append(sMonth).append("月").append(sDay).append("日-") .append(eYear).append("年").append(eMonth).append("月").append(eDay).append("日区间新增值"); }else { String endTime = formDTO.getEndTime(); - String eYear = endTime.substring(0, 4); - String eMonth = endTime.substring(4, 6); - String eDay = endTime.substring(6, 8); + String eYear = endTime.substring(NumConstant.ZERO, NumConstant.FOUR); + String eMonth = endTime.substring(NumConstant.FOUR, NumConstant.SIX); + String eDay = endTime.substring(NumConstant.SIX, NumConstant.EIGHT); s.append(eYear).append("年").append(eMonth).append("月").append(eDay).append("日截止累计值"); } return s.toString(); @@ -1976,7 +1977,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve } //组织或网格Id集合 List idList = agencyGrid.getAgencyGridList().stream().map(ScreenAgencyOrGridListDTO.AgencyGrid::getOrgId).collect(Collectors.toList()); - formDTO.setDataType(!"community".equals(agencyGrid.getLevel()) ? "agency" : "grid"); + formDTO.setDataType(!OrgLevelEnum.COMMUNITY.getCode().equals(agencyGrid.getLevel()) ? OrgTypeEnum.AGENCY.getCode() : OrgTypeEnum.GRID.getCode()); formDTO.setIdList(idList); resultDTO.setTotal(idList.size()); @@ -1984,25 +1985,27 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve formDTO.setSourceType("end"); List userEnd = dataStatsDao.regUserList(formDTO); HashMap uEndMap = new HashMap<>(); - userEnd.stream().forEach(u->uEndMap.put(u.getOrgId(),u)); + userEnd.forEach(u->uEndMap.put(u.getOrgId(),u)); List groupEnd = dataStatsDao.groupList(formDTO); HashMap gEndMap = new HashMap<>(); - groupEnd.stream().forEach(u->gEndMap.put(u.getOrgId(),u)); + groupEnd.forEach(u->gEndMap.put(u.getOrgId(),u)); List topicEnd = dataStatsDao.topicList(formDTO); HashMap tEndMap = new HashMap<>(); - topicEnd.stream().forEach(u->tEndMap.put(u.getOrgId(),u)); + topicEnd.forEach(u->tEndMap.put(u.getOrgId(),u)); List issueEnd = dataStatsDao.issueList(formDTO); HashMap iEndMap = new HashMap<>(); - issueEnd.stream().forEach(u->iEndMap.put(u.getOrgId(),u)); + issueEnd.forEach(u->iEndMap.put(u.getOrgId(),u)); List projectEnd = dataStatsDao.projectList(formDTO); HashMap pEndMap = new HashMap<>(); - projectEnd.stream().forEach(u->pEndMap.put(u.getOrgId(),u)); + projectEnd.forEach(u->pEndMap.put(u.getOrgId(),u)); //巡查数据不区分区间差值,只计算累计值,人员做去重处理且是有巡查记录的人员 == CustomerDataManageFormDTO patrolForm = ConvertUtils.sourceToTarget(formDTO,CustomerDataManageFormDTO.class); patrolForm.setStartTime(startTimeForm); List patrolEnd = statsStaffPatrolRecordDailyService.patrolList(patrolForm); - //4.判断是否需要查询起始日期用户、群组、话题、议题、项目、巡查数据 + //获取例行工作次数 + List workCountList = statsStaffPatrolRecordDailyService.getPatrolRecordCount(patrolForm); + //NumConstant.FOUR.判断是否需要查询起始日期用户、群组、话题、议题、项目、巡查数据 HashMap uStartMap = new HashMap<>(); HashMap gStartMap = new HashMap<>(); HashMap tStartMap = new HashMap<>(); @@ -2011,87 +2014,101 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve if ("Interval".equals(formDTO.getType())) { formDTO.setSourceType("start"); List userStart = dataStatsDao.regUserList(formDTO); - userStart.stream().forEach(u->uStartMap.put(u.getOrgId(),u)); + userStart.forEach(u->uStartMap.put(u.getOrgId(),u)); List groupStart = dataStatsDao.groupList(formDTO); - groupStart.stream().forEach(u->gStartMap.put(u.getOrgId(),u)); + groupStart.forEach(u->gStartMap.put(u.getOrgId(),u)); List topicStart = dataStatsDao.topicList(formDTO); - topicStart.stream().forEach(u->tStartMap.put(u.getOrgId(),u)); + topicStart.forEach(u->tStartMap.put(u.getOrgId(),u)); List issueStart = dataStatsDao.issueList(formDTO); - issueStart.stream().forEach(u->iStartMap.put(u.getOrgId(),u)); + issueStart.forEach(u->iStartMap.put(u.getOrgId(),u)); List projectStart = dataStatsDao.projectList(formDTO); - projectStart.stream().forEach(u->pStartMap.put(u.getOrgId(),u)); + projectStart.forEach(u->pStartMap.put(u.getOrgId(),u)); } //5.封装数据 - agencyGrid.getAgencyGridList().forEach(org -> { + for (ScreenAgencyOrGridListDTO.AgencyGrid org : agencyGrid.getAgencyGridList()) { CustomerDataManageResultDTO.CustomerDataManage dto = new CustomerDataManageResultDTO.CustomerDataManage(); dto.setOrgId(org.getOrgId()); dto.setOrgName(org.getOrgName()); - int user = 0; - int resi = 0; - int part = 0; - if(uEndMap.containsKey(org.getOrgId())){ + int user = NumConstant.ZERO; + int resi = NumConstant.ZERO; + int part = NumConstant.ZERO; + if (uEndMap.containsKey(org.getOrgId())) { user = uEndMap.get(org.getOrgId()).getUserCount(); resi = uEndMap.get(org.getOrgId()).getResidentCount(); part = uEndMap.get(org.getOrgId()).getPartyMemberCount(); - if ("Interval".equals(formDTO.getType())&&uStartMap.containsKey(org.getOrgId())) { + if ("Interval".equals(formDTO.getType()) && uStartMap.containsKey(org.getOrgId())) { user = user - uStartMap.get(org.getOrgId()).getUserCount(); resi = resi - uStartMap.get(org.getOrgId()).getResidentCount(); part = part - uStartMap.get(org.getOrgId()).getPartyMemberCount(); } } - int group = 0; - if(gEndMap.containsKey(org.getOrgId())){ + int group = NumConstant.ZERO; + if (gEndMap.containsKey(org.getOrgId())) { group = gEndMap.get(org.getOrgId()).getGroupCount(); - if ("Interval".equals(formDTO.getType())&&gStartMap.containsKey(org.getOrgId())) { + if ("Interval".equals(formDTO.getType()) && gStartMap.containsKey(org.getOrgId())) { group = group - gStartMap.get(org.getOrgId()).getGroupCount(); } } - int topic = 0; - if(tEndMap.containsKey(org.getOrgId())){ + int topic = NumConstant.ZERO; + if (tEndMap.containsKey(org.getOrgId())) { topic = tEndMap.get(org.getOrgId()).getTopicCount(); - if ("Interval".equals(formDTO.getType())&&tStartMap.containsKey(org.getOrgId())) { + if ("Interval".equals(formDTO.getType()) && tStartMap.containsKey(org.getOrgId())) { topic = topic - tStartMap.get(org.getOrgId()).getTopicCount(); } } - int issue = 0; - if(iEndMap.containsKey(org.getOrgId())){ + int issue = NumConstant.ZERO; + if (iEndMap.containsKey(org.getOrgId())) { issue = iEndMap.get(org.getOrgId()).getIssueCount(); - if ("Interval".equals(formDTO.getType())&&iStartMap.containsKey(org.getOrgId())) { + if ("Interval".equals(formDTO.getType()) && iStartMap.containsKey(org.getOrgId())) { issue = issue - iStartMap.get(org.getOrgId()).getIssueCount(); } } - int project = 0; - int closed = 0; - if(pEndMap.containsKey(org.getOrgId())){ + int project = NumConstant.ZERO; + int closed = NumConstant.ZERO; + if (pEndMap.containsKey(org.getOrgId())) { project = pEndMap.get(org.getOrgId()).getProjectCount(); closed = pEndMap.get(org.getOrgId()).getClosedProjectCount(); - if ("Interval".equals(formDTO.getType())&&pStartMap.containsKey(org.getOrgId())) { + if ("Interval".equals(formDTO.getType()) && pStartMap.containsKey(org.getOrgId())) { project = project - pStartMap.get(org.getOrgId()).getProjectCount(); closed = closed - pStartMap.get(org.getOrgId()).getClosedProjectCount(); } } - int patro = 0; - int patroCount = 0; + int patro = NumConstant.ZERO; + int patroCount = NumConstant.ZERO; String patrolDuration = ""; - int patrolDurationInteger = 0; + int patrolDurationInteger = NumConstant.ZERO; HashSet set = new HashSet(); for (CustomerDataManageResultDTO.CustomerDataManage u : patrolEnd) { - if ("community".equals(agencyGrid.getLevel()) && org.getOrgId().equals(u.getOrgId())) { + if (OrgLevelEnum.COMMUNITY.getCode().equals(agencyGrid.getLevel()) && org.getOrgId().equals(u.getOrgId())) { patroCount += u.getPatrolCount(); patrolDurationInteger += u.getPatrolDurationInteger(); set.add(u.getStaffId()); } - if (!"community".equals(agencyGrid.getLevel()) && u.getOrgId().contains(org.getOrgId())) { + if (!OrgLevelEnum.COMMUNITY.getCode().equals(agencyGrid.getLevel()) && u.getOrgId().contains(org.getOrgId())) { patroCount += u.getPatrolCount(); patrolDurationInteger += u.getPatrolDurationInteger(); set.add(u.getStaffId()); } } + //例行工作次数累加 + int patrolRoutineWorkTimes = NumConstant.ZERO; + if (CollectionUtils.isNotEmpty(workCountList) && workCountList.get(NumConstant.ZERO) != null) { + for (CustomerDataManageResultDTO.CustomerDataManage work : workCountList) { + if (OrgLevelEnum.COMMUNITY.getCode().equals(agencyGrid.getLevel()) && org.getOrgId().equals(work.getOrgId())) { + patrolRoutineWorkTimes += work.getPatrolRoutineWorkTimes(); + set.add(work.getStaffId()); + } else if (!OrgLevelEnum.COMMUNITY.getCode().equals(agencyGrid.getLevel()) && work.getOrgId().contains(org.getOrgId())) { + patrolRoutineWorkTimes += work.getPatrolRoutineWorkTimes(); + set.add(work.getStaffId()); + } + } + } + patro = set.size(); Integer minutes = patrolDurationInteger / 60; - patrolDuration = (minutes / 60 > 0 ? minutes / 60 + "小时" : "") + (minutes % 60 > 0 ? minutes % 60 + "分钟" : "0分钟"); + patrolDuration = (minutes / 60 > NumConstant.ZERO ? minutes / 60 + "小时" : "") + (minutes % 60 > NumConstant.ZERO ? minutes % 60 + "分钟" : "0分钟"); dto.setUserCount(user); dto.setResidentCount(resi); @@ -2106,10 +2123,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve dto.setPatrolDuration(patrolDuration); dto.setPatrolDurationInteger(patrolDurationInteger); + dto.setPatrolRoutineWorkTimes(patrolRoutineWorkTimes); + dataManageList.add(dto); - }); + } - //6.默认按用户总数降序 + //NumConstant.SIX.默认按用户总数降序 Collections.sort(dataManageList, new Comparator() { @Override public int compare(CustomerDataManageResultDTO.CustomerDataManage o1, CustomerDataManageResultDTO.CustomerDataManage o2) { diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/StatsStaffPatrolRecordDailyService.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/StatsStaffPatrolRecordDailyService.java index 4bd0b91d93..6b20674c30 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/StatsStaffPatrolRecordDailyService.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/StatsStaffPatrolRecordDailyService.java @@ -35,12 +35,13 @@ import java.util.List; public interface StatsStaffPatrolRecordDailyService extends BaseService { /** - * desc:获取组织或网格的 时间段内的总次数等 + * desc:获取组织或网格的 时间段内的总次数等 + * * @param orgIdList - * @param startDateId - * @param endDateId - * @return - */ + * @param startDateId + * @param endDateId + * @return + */ List getPatrolSumList(List orgIdList, String startDateId, String endDateId); /** @@ -51,11 +52,20 @@ public interface StatsStaffPatrolRecordDailyService extends BaseService listStaffPatrolRecordDailyAnalysis(String gridPids, String gridId, List userIds, String startDateID, String endDateID); + + /** + * desc:获取巡查日统计的相关次数 + * + * @param patrolForm + * @return + */ + List getPatrolRecordCount(CustomerDataManageFormDTO patrolForm); } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/StatsStaffPatrolRecordDailyServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/StatsStaffPatrolRecordDailyServiceImpl.java index 610bdcd81c..d885b50130 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/StatsStaffPatrolRecordDailyServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/StatsStaffPatrolRecordDailyServiceImpl.java @@ -52,4 +52,9 @@ public class StatsStaffPatrolRecordDailyServiceImpl extends BaseServiceImpl listStaffPatrolRecordDailyAnalysis(String gridPids, String gridId, List userIds, String startDateID, String endDateID) { return baseDao.listStaffPatrolRecordDailyAnalysis(gridPids, gridId, userIds, startDateID, endDateID); } + + @Override + public List getPatrolRecordCount(CustomerDataManageFormDTO patrolForm) { + return baseDao.getRoutineWorkCount(patrolForm); + } } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/GovOrgService.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/GovOrgService.java index d81af9c6f7..51d938bb2e 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/GovOrgService.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/GovOrgService.java @@ -182,4 +182,10 @@ public interface GovOrgService { * @Description 查询组织的直属下级组织下网格活跃度统计--文件导出 **/ void grdiLivelyExport(HttpServletResponse response, GridLivelyFormDTO formDTO); + + /** + * @Author sun + * @Description 查询组织的直属下级组织下网格活跃度统计--文件导出 + **/ + void pcworkRecordListExportSendMsg(GridLivelyFormDTO formDTO); } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java index 4fc3cb4f81..7acb871048 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java @@ -1,18 +1,27 @@ package com.epmet.dataaggre.service.govorg.impl; +import cn.afterturn.easypoi.excel.ExcelExportUtil; +import cn.afterturn.easypoi.excel.entity.ExportParams; import com.alibaba.excel.EasyExcel; import com.alibaba.excel.ExcelWriter; import com.alibaba.excel.write.metadata.WriteSheet; import com.alibaba.fastjson.JSON; +import com.dingtalk.api.request.OapiRobotSendRequest; import com.epmet.commons.dynamic.datasource.annotation.DataSource; +import com.epmet.commons.tools.constant.DingDingRobotConstant; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.constant.StrConstant; +import com.epmet.commons.tools.dto.form.DingTextBriefNessFormDTO; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; 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.common.CustomerStaffRedis; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ExcelUtils; +import com.epmet.commons.tools.utils.HttpClientManager; +import com.epmet.commons.tools.utils.Result; import com.epmet.dataaggre.constant.DataSourceConstant; import com.epmet.dataaggre.dao.govorg.*; import com.epmet.dataaggre.dto.epmetuser.result.ListStaffResultDTO; @@ -28,13 +37,23 @@ import com.epmet.dataaggre.service.datastats.DataStatsService; import com.epmet.dataaggre.service.epmetuser.EpmetUserService; import com.epmet.dataaggre.service.govorg.GovOrgService; import com.epmet.dataaggre.service.opercrm.CustomerRelation; +import com.epmet.dto.result.UploadImgResultDTO; +import com.epmet.feign.OssFeignClient; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.FileItemFactory; +import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.lang3.StringUtils; +import org.apache.http.entity.ContentType; +import org.apache.poi.ss.usermodel.Workbook; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.web.multipart.commons.CommonsMultipartFile; import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.OutputStream; import java.text.NumberFormat; import java.text.SimpleDateFormat; import java.util.*; @@ -67,6 +86,8 @@ public class GovOrgServiceImpl implements GovOrgService { private EpmetUserService epmetUserService; @Autowired private DataStatsService dataStatsService; + @Autowired + private OssFeignClient ossFeignClient; /** * @param staffId @@ -690,4 +711,80 @@ public class GovOrgServiceImpl implements GovOrgService { return name.toString(); } + /** + * @Author sun + * @Description 查询组织的直属下级组织下网格活跃度统计--文件导出 + **/ + @Override + public void pcworkRecordListExportSendMsg(GridLivelyFormDTO formDTO) { + List data = ConvertUtils.sourceToTarget(grdiLively(formDTO), GridLivelyExcel.class); + if(CollectionUtils.isEmpty(data)){ + log.warn(String.format("网格员活跃度统计数据查询为空,入参【%s】", JSON.toJSONString(formDTO))); + return; + } + ExportParams exportParams = new ExportParams(); + String sheetName = excelSheetName(formDTO); + exportParams.setSheetName(sheetName); + Workbook workbook = ExcelExportUtil.exportExcel(exportParams, + GridLivelyExcel.class, data); + + // 文件名 + String resultDescFileName = sheetName.concat(".xls"); + + FileItemFactory factory = new DiskFileItemFactory(16, null); + FileItem fileItem = factory.createItem("file", ContentType.APPLICATION_OCTET_STREAM.toString(), true, resultDescFileName); + OutputStream os = null; + Result uploadResult = null; + try { + os = fileItem.getOutputStream(); + workbook.write(os); + uploadResult = ossFeignClient.uploadImportTaskDescFile(new CommonsMultipartFile(fileItem)); + } catch (Exception e) { + String errormsg = ExceptionUtils.getErrorStackTrace(e); + log.warn("【网格活跃度统计】上传错误描述文件异常:{}", errormsg); + } finally { + try { + os.close(); + } catch (IOException e) { + String errormsg = ExceptionUtils.getErrorStackTrace(e); + log.warn("【网格活跃度统计】上传错误描述文件关闭输出流:{}", errormsg); + } + try { + fileItem.delete(); + } catch (Exception e) { + String errormsg = ExceptionUtils.getErrorStackTrace(e); + log.warn("【网格活跃度统计】上传错误描述文件删除临时文件:{}", errormsg); + } + } + log.warn(String.format("网格员活跃度统计数据查询为空,返参【%s】", JSON.toJSONString(uploadResult))); + if (uploadResult == null || !uploadResult.success()) { + log.warn("【网格活跃度统计】调用OSS上传结果描述文件失败"); + } else { + //EPMETV3群机器人 + String secret = DingDingRobotConstant.V3_ROBOT_SECRET; + String url = DingDingRobotConstant.V3_ROBOT_URL; + // String secret = DingDingRobotConstant.YZM_TEST_SECRET; + // String url = DingDingRobotConstant.YZM_TEST_URL; + + DingTextBriefNessFormDTO dingTalkTextMsg=new DingTextBriefNessFormDTO(); + dingTalkTextMsg.setMsgtype("text"); + + //小雷哥手机号:18660295251, + OapiRobotSendRequest.At at = new OapiRobotSendRequest.At(); + at.setAtMobiles(Arrays.asList("18660295251")); + at.setIsAtAll(false); + dingTalkTextMsg.setAt(at); + + //文本方式发送 + OapiRobotSendRequest.Text text = new OapiRobotSendRequest.Text(); + text.setContent("网格活跃度统计: \n" + + "起止时间: " + formDTO.getStartTime().concat(StrConstant.UNDER_LINE).concat(formDTO.getEndTime()) + "\n" + + "文件下载地址: " + uploadResult.getData().getUrl() + "\n"+ + "请查收@18660295251"); + dingTalkTextMsg.setText(text); + HttpClientManager.getInstance().sendDingMsg(JSON.toJSONString(dingTalkTextMsg), url, secret); + } + } + + } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/bootstrap.yml b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/bootstrap.yml index 934dcae2c5..9df581e38f 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/bootstrap.yml +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/bootstrap.yml @@ -191,3 +191,14 @@ dingTalk: logging: level: com.epmet.dataaggre: debug + +thread: + # 线程池配置 + threadPool: + enableCustomize: @thread.threadPool.enable-customize@ + corePoolSize: @thread.threadPool.core-pool-size@ + maxPoolSize: @thread.threadPool.max-pool-size@ + queueCapacity: @thread.threadPool.queue-capacity@ + keepAliveSeconds: @thread.threadPool.keep-alive-seconds@ + threadNamePrefix: @thread.threadPool.thread-name-prefix@ + rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@ diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/datastats/DatsStatsDao.xml b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/datastats/DatsStatsDao.xml index be3c501bf3..26f74c4124 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/datastats/DatsStatsDao.xml +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/datastats/DatsStatsDao.xml @@ -331,17 +331,19 @@ @@ -349,17 +351,19 @@ @@ -1004,7 +1008,8 @@ FROM ( SELECT DISTINCT - date_id dateId, project_total projectCount, closed_total closedProjectCount + + date_id dateId, SUM(project_total) projectCount, SUM(closed_total) closedProjectCount , agency_id orgId @@ -1028,6 +1033,7 @@ AND date_id #{endTime} + GROUP BY date_id, agency_id ORDER BY date_id ASC @@ -1035,6 +1041,7 @@ AND date_id =]]> #{startTime} AND date_id #{endTime} + GROUP BY date_id, agency_id ORDER BY date_id DESC diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/StatsStaffPatrolRecordDailyDao.xml b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/StatsStaffPatrolRecordDailyDao.xml index 86aae4d681..273b7e215b 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/StatsStaffPatrolRecordDailyDao.xml +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/StatsStaffPatrolRecordDailyDao.xml @@ -86,5 +86,42 @@ sprd.STAFF_ID, sprd.GRID_ID + diff --git a/epmet-module/data-report/data-report-server/pom.xml b/epmet-module/data-report/data-report-server/pom.xml index cc8fb18e5a..bc3fe1b533 100644 --- a/epmet-module/data-report/data-report-server/pom.xml +++ b/epmet-module/data-report/data-report-server/pom.xml @@ -192,6 +192,15 @@ https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4 SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd + + + true + 5 + 8 + 20 + 60 + data-report + callerRunsPolicy @@ -246,6 +255,15 @@ https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4 SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd + + + true + 5 + 8 + 20 + 60 + data-report + callerRunsPolicy @@ -300,6 +318,15 @@ https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4 SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd + + + true + 5 + 8 + 20 + 60 + data-report + callerRunsPolicy @@ -354,6 +381,15 @@ https://oapi.dingtalk.com/robot/send?access_token=a5f66c3374b1642fe2142dbf56d5997e280172d4e8f2b546c9423a68c82ece6c SEC95f4f40b533ad379ea6a6d1af6dd37029383cfe1b7cd96dfac2678be2c1c3ed1 + + + true + 5 + 8 + 20 + 60 + data-report + callerRunsPolicy diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/ScreenProjectController.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/ScreenProjectController.java index 5b9e5c314d..28cf89d084 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/ScreenProjectController.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/ScreenProjectController.java @@ -204,6 +204,7 @@ public class ScreenProjectController { //tokenDto.setUserId("36bc0fb38565ecdebf8ab9b476b44548"); //tokenDto.setCustomerId("45687aa479955f9d06204d415238f7cc"); ValidatorUtils.validateEntity(formDTO, ProjectCategoryFormDTO.CategoryProjectExportForm.class); + String openTime = formDTO.getStartTime(); List data = screenProjectService.selectProjectCategory(formDTO, tokenDto); String templatePath = "excel/project_category_temp.xlsx"; @@ -216,7 +217,7 @@ public class ScreenProjectController { Map mapData = new HashMap<>(); mapData.put("list",resultDTOList); mapData.put("orgName", formDTO.getOrgName()); - mapData.put("exportDate",getExportDateStr(formDTO.getStartTime(),formDTO.getEndTime())); + mapData.put("exportDate", getExportDateStr(openTime, formDTO.getEndTime())); Workbook workbook = ExcelExportUtil.exportExcel(new TemplateExportParams(templatePath), mapData); response.setHeader("content-Type", "application/vnd.ms-excel"); response.addHeader("Content-Disposition", "attachment;fileName=" + URLEncoder.encode("项目分类统计.xls", "UTF-8")); diff --git a/epmet-module/data-report/data-report-server/src/main/resources/bootstrap.yml b/epmet-module/data-report/data-report-server/src/main/resources/bootstrap.yml index 2ee366e369..8f7e9c61c4 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/bootstrap.yml +++ b/epmet-module/data-report/data-report-server/src/main/resources/bootstrap.yml @@ -158,3 +158,14 @@ shutdown: graceful: enable: true #是否开启优雅停机 waitTimeSecs: 30 # 优雅停机等待时间,超过30秒,发出告警 + +thread: + # 线程池配置 + threadPool: + enableCustomize: @thread.threadPool.enable-customize@ + corePoolSize: @thread.threadPool.core-pool-size@ + maxPoolSize: @thread.threadPool.max-pool-size@ + queueCapacity: @thread.threadPool.queue-capacity@ + keepAliveSeconds: @thread.threadPool.keep-alive-seconds@ + threadNamePrefix: @thread.threadPool.thread-name-prefix@ + rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@ diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/UserGroupIdDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/UserGroupIdDTO.java new file mode 100644 index 0000000000..854a000fde --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/UserGroupIdDTO.java @@ -0,0 +1,13 @@ +package com.epmet.dto.extract; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + + +@Data +public class UserGroupIdDTO implements Serializable { + private String userId; + private List groupIdList; +} diff --git a/epmet-module/data-statistical/data-statistical-server/pom.xml b/epmet-module/data-statistical/data-statistical-server/pom.xml index b4096512ac..3a6562bbcb 100644 --- a/epmet-module/data-statistical/data-statistical-server/pom.xml +++ b/epmet-module/data-statistical/data-statistical-server/pom.xml @@ -286,11 +286,14 @@ false - - 5 - 8 - 10 - 30 + + true + 5 + 8 + 20 + 60 + data-statistical + callerRunsPolicy https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4 @@ -415,11 +418,14 @@ false - - 5 - 8 - 10 - 30 + + true + 5 + 8 + 20 + 60 + data-statistical + callerRunsPolicy https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4 @@ -543,11 +549,15 @@ false - - 5 - 8 - 10 - 30 + + true + 5 + 8 + 20 + 60 + data-statistical + callerRunsPolicy + https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4 SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd @@ -667,11 +677,14 @@ false - - 5 - 8 - 10 - 30 + + true + 5 + 8 + 20 + 60 + data-statistical + callerRunsPolicy https://oapi.dingtalk.com/robot/send?access_token=a5f66c3374b1642fe2142dbf56d5997e280172d4e8f2b546c9423a68c82ece6c diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/config/AsyncConfig.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/config/AsyncConfig.java deleted file mode 100644 index ba50e40a30..0000000000 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/config/AsyncConfig.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.epmet.config; - -import com.epmet.properties.ThreadProperties; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.scheduling.annotation.EnableAsync; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; - -import java.util.concurrent.Executor; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.ThreadPoolExecutor; - -/** - * 线程池配置类 - */ -@Configuration -@EnableConfigurationProperties(ThreadProperties.class) -@EnableAsync -public class AsyncConfig { - - @Autowired - private ThreadProperties threadProperties; - - @Bean - public Executor executor() { - ThreadProperties.ThreadPoolProperties threadPoolProps = threadProperties.getThreadPool(); - - ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); - executor.setCorePoolSize(threadPoolProps.getCorePoolSize()); - executor.setMaxPoolSize(threadPoolProps.getMaxPoolSize()); - executor.setQueueCapacity(threadPoolProps.getQueueCapacity()); - executor.setThreadNamePrefix("data-stats-"); - // rejection-policy:当pool已经达到max size的时候,如何处理新任务 - // CALLER_RUNS:不在新线程中执行任务,而是由调用者所在的线程来执行 - executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); //对拒绝task的处理策略 - executor.setKeepAliveSeconds(threadPoolProps.getKeepAlive()); - executor.initialize(); - return executor; - } - - @Bean - public ExecutorService executorService() { - ThreadPoolTaskExecutor executor = (ThreadPoolTaskExecutor) executor(); - return executor.getThreadPoolExecutor(); - } - -} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java index 97453a2f06..84cb0c6964 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java @@ -621,20 +621,23 @@ public class DemoController { private CalCpcIndexService calCpcIndexService; @PostMapping("calCpcPartyAbility") - public Result calCpcPartyAbility(@RequestParam("customerId") String customerId, @RequestParam("monthId")String monthId) { + public Result calCpcPartyAbility(@RequestParam("customerId") String customerId, @RequestParam("monthId") String monthId) { + long startCpc = System.currentTimeMillis(); if (StringUtils.isNotBlank(customerId) && StringUtils.isNotBlank(monthId)) { - calCpcIndexService.calCpcPartyAbility(customerId,monthId); - }else{ + calCpcIndexService.calCpcPartyAbilityV2(customerId, monthId); + // calCpcIndexService.calCpcPartyAbility(customerId, monthId); + } else { QueryWrapper customerEntityQueryWrapper = new QueryWrapper<>(); - List customerEntityList=dimCustomerDao.selectList(customerEntityQueryWrapper); + List customerEntityList = dimCustomerDao.selectList(customerEntityQueryWrapper); QueryWrapper wrapper = new QueryWrapper<>(); - List dimMonthEntityList= dimMonthDao.selectList(wrapper); - for(DimCustomerEntity customerEntity:customerEntityList){ - for(DimMonthEntity monthEntity:dimMonthEntityList) { - calCpcIndexService.calCpcPartyAbility(customerEntity.getId(),monthEntity.getId()); + List dimMonthEntityList = dimMonthDao.selectList(wrapper); + for (DimCustomerEntity customerEntity : customerEntityList) { + for (DimMonthEntity monthEntity : dimMonthEntityList) { + calCpcIndexService.calCpcPartyAbilityV2(customerEntity.getId(), monthEntity.getId()); } } } + log.error("手动调用党员相关-党建能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startCpc, customerId); return new Result(); } @@ -1113,14 +1116,22 @@ public class DemoController { if (StringUtils.isNotBlank(startDate) && StringUtils.isNotBlank(endDate)){ List daysBetween = DateUtils.getDaysBetween(startDate, endDate); daysBetween.forEach(d -> { - screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectGridData(customerId,d); - screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectOrgData(customerId,d); + executorService.submit(() -> { + screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectGridData(customerId,d); + }); + executorService.submit(() -> { + screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectOrgData(customerId,d); + }); result.add(d); redisUtils.hSet(RedisKeys.getBackDoorbizExcuteResult("gridandorgdailynew"),customerId,result,3*24*60*60L); }); }else { - screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectGridData(customerId,dateId); - screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectOrgData(customerId,dateId); + executorService.submit(() -> { + screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectGridData(customerId,dateId); + }); + executorService.submit(() -> { + screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectOrgData(customerId,dateId); + }); result.add(dateId); redisUtils.hSet(RedisKeys.getBackDoorbizExcuteResult("gridandorgdailynew"),customerId,result,3*24*60*60L); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenExtractDailyController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenExtractDailyController.java index 07919aa425..756ecc2d8a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenExtractDailyController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenExtractDailyController.java @@ -5,7 +5,6 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.dto.extract.form.ExtractOriginFormDTO; import com.epmet.dto.extract.form.ExtractScreenFormDTO; import com.epmet.service.evaluationindex.extract.toscreen.ScreenExtractService; -import com.google.common.util.concurrent.ThreadFactoryBuilder; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; @@ -13,7 +12,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import java.util.concurrent.*; +import java.util.concurrent.ExecutorService; /** * @Author zxc @@ -23,13 +22,10 @@ import java.util.concurrent.*; @RestController @RequestMapping("screenextract") public class ScreenExtractDailyController { - ThreadFactory namedThreadFactory = new ThreadFactoryBuilder() - .setNameFormat("ScreenExtractDailyController-pool-%d").build(); - ExecutorService threadPool = new ThreadPoolExecutor(1, 1, - 10L, TimeUnit.MINUTES, - new LinkedBlockingQueue<>(500), namedThreadFactory, new ThreadPoolExecutor.CallerRunsPolicy()); @Autowired private ScreenExtractService screenExtractService; + @Autowired + private ExecutorService executorService; /** * @param extractOriginFormDTO @@ -39,7 +35,7 @@ public class ScreenExtractDailyController { */ @PostMapping("extractdailyall") public Result screenExtractDaily(@RequestBody ExtractOriginFormDTO extractOriginFormDTO) { - threadPool.submit(() -> { + executorService.submit(() -> { log.info("screenExtractDaily start,param:{}", JSON.toJSONString(extractOriginFormDTO)); try { screenExtractService.extractDailyAll(extractOriginFormDTO); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/external/IndexCalculateController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/external/IndexCalculateController.java index 29267ca44e..15f6cb77c8 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/external/IndexCalculateController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/external/IndexCalculateController.java @@ -1,5 +1,6 @@ package com.epmet.controller.external; +import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.enums.EnvEnum; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.redis.RedisKeys; @@ -16,7 +17,6 @@ import com.epmet.model.CalculateFlagModel; import com.epmet.service.evaluationindex.indexcal.CpcIndexCalculateService; import com.epmet.service.evaluationindex.indexcal.IndexCalculateService; import com.epmet.util.DimIdGenerator; -import com.google.common.util.concurrent.ThreadFactoryBuilder; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -27,7 +27,8 @@ import java.util.Date; import java.util.HashMap; import java.util.Map; import java.util.Set; -import java.util.concurrent.*; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; /** * 指标计算controller @@ -39,13 +40,6 @@ import java.util.concurrent.*; @RestController @RequestMapping("indexcalculate") public class IndexCalculateController { - ThreadFactory namedThreadFactory = new ThreadFactoryBuilder() - .setNameFormat("indexcalculate-pool-%d").build(); - ExecutorService singleThreadPool = new ThreadPoolExecutor(1, 1, - 0L, TimeUnit.MILLISECONDS, - new LinkedBlockingQueue(1024), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy()); - - @Autowired private IndexCalculateService indexCalculateService; @@ -54,6 +48,9 @@ public class IndexCalculateController { @Autowired private RedisUtils redisUtils; + @Autowired + private ExecutorService executorService; + // 计算同步锁 private Object statsCalLock = new Object(); @@ -68,7 +65,7 @@ public class IndexCalculateController { CalculateFlagModel flag = (CalculateFlagModel) redisUtils.get(RedisKeys.getCustomerStatsCalFlag(customerId)); flag.setStatus(CalculateStatus.PENDDING); redisUtils.set(RedisKeys.getCustomerStatsCalFlag(customerId), flag); - log.info("客户【%s】正在执行计算,实例发生重启,修改计算状态为:calculation->pendding", customerId); + log.error("客户【%s】正在执行计算,实例发生重启,修改计算状态为:calculation->pendding", customerId); }); } @@ -97,7 +94,7 @@ public class IndexCalculateController { } /** - * 按照客户计算所有指标(按照月份) + * 这个是外部客户主动调用的方法入口 按照客户计算所有指标(按照月份) * * @param formDTO * @return com.epmet.commons.tools.utils.Result @@ -112,6 +109,35 @@ public class IndexCalculateController { return new Result().ok(true); } + @PostMapping("calSingle") + public Result calculateSingle(@RequestBody CalculateCommonFormDTO formDTO) { + long start = System.currentTimeMillis(); + try { + ValidatorUtils.validateEntity(formDTO); + Boolean aBoolean = indexCalculateService.indexCalculate(formDTO); + HttpClientManager.getInstance().sendAlarmMsg(EnvEnum.getCurrentEnv().getName() + "客户Id:" + formDTO.getCustomerId() + ";monthId:" + formDTO.getMonthId() + ",calculateAll全部指标计算完成,是否成功:" + aBoolean + ",总耗时:" + (System.currentTimeMillis() - start) / 1000 + "秒"); + if (aBoolean) { + return new Result().ok(true); + } + } catch (Exception e) { + return new Result().error(e.getMessage()); + } + return new Result().error("指标计算失败"); + } + + /** + * desc:异步 连续计算[指定或所有内部客户][多个月份]的指标得分入口 适用于公式调整后或之前计算错误 统一计算 + * @param formDTO + * @return + * @remark:不要轻易调用 因为异步 怕有冲突 + */ + @PostMapping("warn/moreStats") + public Result indexStatistics(@RequestBody IndexStatisticsFormDTO formDTO){ + log.error("moreStats 不要轻易调用 因为异步 怕有冲突,参数:{}", JSON.toJSONString(formDTO)); + indexCalculateService.indexStatistics(formDTO); + return new Result(); + } + /** * 指标计算 * @@ -142,7 +168,7 @@ public class IndexCalculateController { * @return */ private void submitCalculate(CalculateCommonFormDTO formDTO) { - Future future = singleThreadPool.submit(() -> { + Future future = executorService.submit(() -> { try { long start = System.currentTimeMillis(); Boolean aBoolean = indexCalculateService.indexCalculate(formDTO); @@ -202,21 +228,6 @@ public class IndexCalculateController { return new Result(); } - @PostMapping("reAll") - public Result calculateAll(@RequestBody CalculateCommonFormDTO formDTO) { - long start = System.currentTimeMillis(); - try { - Boolean aBoolean = indexCalculateService.indexCalculate(formDTO); - HttpClientManager.getInstance().sendAlarmMsg(EnvEnum.getCurrentEnv().getName() + "客户Id:" + formDTO.getCustomerId() + ";monthId:" + formDTO.getMonthId() + ",calculateAll全部指标计算完成,是否成功:" + aBoolean + ",总耗时:" + (System.currentTimeMillis() - start) / 1000 + "秒"); - if (aBoolean) { - return new Result().ok(true); - } - } catch (Exception e) { - return new Result().error(e.getMessage()); - } - return new Result().error("指标计算失败"); - } - /** * desc:计算党员指标分数 * @@ -343,12 +354,6 @@ public class IndexCalculateController { return new Result(); }*/ - @PostMapping("indexstatistics") - public Result indexStatistics(@RequestBody IndexStatisticsFormDTO formDTO){ - indexCalculateService.indexStatistics(formDTO); - return new Result(); - } - /** * @return com.epmet.commons.tools.utils.Result * @param formDTO diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginGroupMainDailyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginGroupMainDailyDao.java index 1533d70143..c4f3f8f231 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginGroupMainDailyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginGroupMainDailyDao.java @@ -19,6 +19,7 @@ package com.epmet.dao.evaluationindex.extract; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.extract.FactOriginGroupMainDailyDTO; +import com.epmet.dto.extract.UserGroupIdDTO; import com.epmet.dto.extract.form.GridHeartedFormDTO; import com.epmet.dto.extract.form.ScreenPartyLinkMassesDataFormDTO; import com.epmet.dto.extract.result.GridGroupUserCountResultDTO; @@ -225,4 +226,6 @@ public interface FactOriginGroupMainDailyDao extends BaseDao */ List selectPartyMemberGroupStaticByGrid(@Param("customerId") String customerId, @Param("dateId") String dateId); + + List selectGroupAndLeader(String customerId); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginIssueLogDailyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginIssueLogDailyDao.java index 5e9177adf7..aa77da7fc6 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginIssueLogDailyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginIssueLogDailyDao.java @@ -170,4 +170,12 @@ public interface FactOriginIssueLogDailyDao extends BaseDao */ List getClosedIssueIncr(@Param("customerId") String customerId, @Param("dateId") String dateId); + + /** + * 查询出本月内做过议题表决的用户id + * @param customerId + * @param monthId + * @return + */ + List queryVoteUserIds(@Param("customerId")String customerId, @Param("monthId")String monthId); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginTopicLogDailyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginTopicLogDailyDao.java index ef3ab5e833..0e8b939582 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginTopicLogDailyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginTopicLogDailyDao.java @@ -103,4 +103,12 @@ public interface FactOriginTopicLogDailyDao extends BaseDao selectPartyActiveTopic(@Param("customerId")String customerId,@Param("monthId") String monthId,@Param("isParty") Integer isParty); + + /** + * 查询出本月内,评论过话题的用户id + * @param customerId + * @param monthId + * @return + */ + List queryCommentTopicUserIds(@Param("customerId") String customerId, @Param("monthId")String monthId); } \ No newline at end of file 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 fc651f6c37..c4f683ca2b 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 @@ -25,6 +25,7 @@ import com.epmet.dto.org.CustomerStaffGridDTO; import com.epmet.dto.org.GridInfoDTO; import com.epmet.dto.org.form.GridBaseInfoFormDTO; import com.epmet.dto.org.result.CustomerGridDTO; +import com.epmet.dto.stats.DimGridDTO; import com.epmet.dto.user.form.StaffBaseInfoFormDTO; import com.epmet.dto.user.result.GridUserInfoDTO; import com.epmet.entity.org.CustomerGridEntity; @@ -118,4 +119,10 @@ public interface CustomerGridDao extends BaseDao { * @Description 查询工作人员所属网格信息 **/ List getStaffGrid(StaffBaseInfoFormDTO formDTO); + + /** + * @Author sun + * @Description 查询客户下有效网格列表 + **/ + List gridListByCustomerId(@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/dao/user/StatsStaffPatrolRecordDailyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/StatsStaffPatrolRecordDailyDao.java index 42233f31d6..7c37db8f28 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/StatsStaffPatrolRecordDailyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/StatsStaffPatrolRecordDailyDao.java @@ -43,7 +43,7 @@ public interface StatsStaffPatrolRecordDailyDao extends BaseDao insertList); + Integer insertBatchOrUpdate(@Param("list") List insertList); /** * desc: 删除内部数据 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 a09e63861c..a096dc3307 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 @@ -4,12 +4,14 @@ import com.alibaba.fastjson.JSON; import com.epmet.commons.rocketmq.constants.MQUserPropertys; import com.epmet.commons.rocketmq.messages.DisputeProcessMQMsg; import com.epmet.commons.rocketmq.messages.ProjectChangedMQMsg; +import com.epmet.commons.tools.constant.NumConstant; 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.PingYinConstant; import com.epmet.constant.SystemMessageType; import com.epmet.dto.extract.form.ExtractOriginFormDTO; import com.epmet.service.evaluationindex.extract.todata.FactOriginExtractService; @@ -66,7 +68,7 @@ public class ProjectChangedCustomListener implements MessageListenerConcurrently } catch (Exception e) { //失败不重发 logger.error("consumeMessage fail,msg:{}",e.getMessage()); - return ConsumeConcurrentlyStatus.CONSUME_SUCCESS; + return ConsumeConcurrentlyStatus.RECONSUME_LATER; } log.info("consumeMessage success, cost:{} ms",System.currentTimeMillis() - start); return ConsumeConcurrentlyStatus.CONSUME_SUCCESS; @@ -94,7 +96,7 @@ public class ProjectChangedCustomListener implements MessageListenerConcurrently } log.info("消费了项目变动消息,customer id:{}", msgObj.getCustomerId()); - if (org.apache.commons.lang.StringUtils.isNotBlank(pendingMsgLabel)) { + if (StringUtils.isNotBlank(pendingMsgLabel)) { try { removePendingMqMsgCache(pendingMsgLabel); } catch (Exception e) { @@ -109,19 +111,21 @@ public class ProjectChangedCustomListener implements MessageListenerConcurrently try { String customerId = msgObj.getCustomerId(); distributedLock = SpringContextUtils.getBean(DistributedLock.class); - lock = distributedLock.getLock(String.format("lock:project_changed:%s", customerId) - ,30L, 30L, TimeUnit.SECONDS); + lock = distributedLock.getLock(String.format("lock:project_changed:%s:%s", customerId, msgObj.getProjectId()) + ,60L, 60L, TimeUnit.SECONDS); if (StringUtils.isBlank(customerId)){ logger.error("consumer project_changed fail,msg:{}",customerId); return; } - //消息被消费太快 业务数据还没有完成 歇一会先 + //睡一秒 要不然那边执行不完 try { - Thread.sleep(60L); + Thread.sleep(NumConstant.ONE_THOUSAND); } catch (InterruptedException e) { - logger.error("consumeMessage sleep exception",e); + log.error("consumeMessage exception",e); } + + ExtractOriginFormDTO extractOriginFormDTO = new ExtractOriginFormDTO(); extractOriginFormDTO.setCustomerId(customerId); @@ -146,21 +150,8 @@ public class ProjectChangedCustomListener implements MessageListenerConcurrently } logger.info("consumer projectChanged msg success,{}",aBoolean); - //发送项目数据上报的mq消息 - if ("6f203e30de1a65aab7e69c058826cd80".equals(customerId)) { - if ("issue_shift_project".equals(msgObj.getOperation()) || "created".equals(msgObj.getOperation()) || "close".equals(msgObj.getOperation())) { - String type; - if ("issue_shift_project".equals(msgObj.getOperation()) || "created".equals(msgObj.getOperation())) { - type = SystemMessageType.PROJECT_ADD; - } else { - type = SystemMessageType.PROJECT_EDIT; - } - List projectList = new ArrayList<>(); - projectList.add(msgObj.getProjectId()); - DisputeProcessMQMsg msg = new DisputeProcessMQMsg(customerId, projectList, type); - SpringContextUtils.getBean(ScreenProjectDataService.class).sendProjectChangeMq(msg); - } - } + sendProject2OpenData(msgObj, customerId); + } catch (RenException e) { // 如果是我们手动抛出的异常,说明在业务可控范围内。目前不需要MQ重试 logger.error("【RocketMQ】消费项目变动消息失败:",e); @@ -175,6 +166,29 @@ public class ProjectChangedCustomListener implements MessageListenerConcurrently } } + /** + * desc:发型项目数据到 opendata + * @param msgObj + * @param customerId + */ + private void sendProject2OpenData(ProjectChangedMQMsg msgObj, String customerId) { + //发送项目数据上报的mq消息 + if (PingYinConstant.PROD_PING_YIN_CUSTOMER_ID.equals(customerId)) { + if ("issue_shift_project".equals(msgObj.getOperation()) || "created".equals(msgObj.getOperation()) || "close".equals(msgObj.getOperation())) { + String type; + if ("issue_shift_project".equals(msgObj.getOperation()) || "created".equals(msgObj.getOperation())) { + type = SystemMessageType.PROJECT_ADD; + } else { + type = SystemMessageType.PROJECT_EDIT; + } + List projectList = new ArrayList<>(); + projectList.add(msgObj.getProjectId()); + DisputeProcessMQMsg msg = new DisputeProcessMQMsg(customerId, projectList, type); + SpringContextUtils.getBean(ScreenProjectDataService.class).sendProjectChangeMq(msg); + } + } + } + @PreDestroy public void saveCalStatus() { //todo diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/biz/impl/BizDataStatsServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/biz/impl/BizDataStatsServiceImpl.java index 15d3ba8b06..25dd3d764b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/biz/impl/BizDataStatsServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/biz/impl/BizDataStatsServiceImpl.java @@ -21,7 +21,6 @@ import com.epmet.service.stats.DimCustomerService; import com.epmet.service.user.StatsStaffPatrolService; import com.epmet.service.user.UserService; import com.epmet.util.DimIdGenerator; -import com.google.common.util.concurrent.ThreadFactoryBuilder; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -34,7 +33,6 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; -import java.util.concurrent.*; import java.util.stream.Collectors; /** @@ -47,11 +45,6 @@ import java.util.stream.Collectors; @Slf4j @Service public class BizDataStatsServiceImpl implements BizDataStatsService { - ThreadFactory namedThreadFactory = new ThreadFactoryBuilder() - .setNameFormat("bizDataStats-pool-%d").build(); - ExecutorService threadPool = new ThreadPoolExecutor(3, 6, - 10L, TimeUnit.MINUTES, - new LinkedBlockingQueue<>(500), namedThreadFactory, new ThreadPoolExecutor.CallerRunsPolicy()); @Autowired private CustomerStaffService customerStaffService; @Autowired @@ -130,6 +123,7 @@ public class BizDataStatsServiceImpl implements BizDataStatsService { List insertList = buildInitPatrolStatsData(formDTO, allGridMembers); Map yesterdayStatsMap = insertList.stream().collect(Collectors.toMap(o -> o.getGridId() + o.getStaffId(), o -> o, (o1, o2) -> o1)); + log.debug("reloadStaffPatrolStatsData 所有网格员数据{}",JSON.toJSONString(yesterdayStatsMap)); //获取昨日的巡查记录 List yesterdayPatrolList = userService.selectStaffPatrolListByDateId(formDTO.getCustomerId(), formDTO.getDateId()); @@ -138,7 +132,7 @@ public class BizDataStatsServiceImpl implements BizDataStatsService { //获取昨日的例行工作数据 List yesterdayWorkList = userService.selectRoutineWorkListByDateId(formDTO.getCustomerId(), formDTO.getDateId()); - + log.debug("reloadStaffPatrolStatsData 例行工作数据数据{}",JSON.toJSONString(yesterdayWorkList)); //遍历网格员 设置其 巡查次数 巡查时常 上报项目数 yesterdayPatrolList.forEach(patrolRecord -> { String key = patrolRecord.getGrid().concat(patrolRecord.getStaffId()); @@ -172,7 +166,7 @@ public class BizDataStatsServiceImpl implements BizDataStatsService { String unqPatrolKey = getUnqPatrolKey(patrol.getGrid(), patrol.getStaffId()); StatsStaffPatrolRecordDailyDTO recordDailyDTO = yesterdayStatsMap.get(unqPatrolKey); if (recordDailyDTO == null) { - log.error("have project data but have any patrolRecordDaily,gridId:{},staffId:{}", patrol.getGrid(), patrol.getStaffId()); + log.error("reloadStaffPatrolStatsData have project data but have any patrolRecordDaily,gridId:{},staffId:{}", patrol.getGrid(), patrol.getStaffId()); return; } @@ -181,17 +175,17 @@ public class BizDataStatsServiceImpl implements BizDataStatsService { }); }); yesterdayWorkList.forEach(work->{ - String key = work.getGridId().concat(work.getUserId()); + String key = getUnqPatrolKey(work.getGridId(),work.getUserId()); StatsStaffPatrolRecordDailyDTO patrolRecordDailyDTO = yesterdayStatsMap.get(key); if (patrolRecordDailyDTO == null){ + log.warn("reloadStaffPatrolStatsData getRoutineWorkCount key{} not exist in gridMembers",key); return; } patrolRecordDailyDTO.setRoutineWorkCount(patrolRecordDailyDTO.getRoutineWorkCount() + NumConstant.ONE); - }); - Integer effectRow = statsStaffPatrolService.delAndInsertBatch(formDTO, insertList); - log.debug("initStaffPatrolStats insert rows:{}", effectRow); + Integer effectRow = statsStaffPatrolService.insertBatchOrUpdate(formDTO, insertList); + log.info("initStaffPatrolStats insert rows:{}", effectRow); } /** @@ -218,7 +212,7 @@ public class BizDataStatsServiceImpl implements BizDataStatsService { private void initStaffPatrolTodayData(StaffPatrolStatsFormDTO formDTO, List allGridMembers) { log.info("initStaffPatrolTodayData param:{}", JSON.toJSONString(formDTO)); List insertList = buildInitPatrolStatsData(formDTO, allGridMembers); - Integer effectRow = statsStaffPatrolService.delAndInsertBatch(formDTO, insertList); + Integer effectRow = statsStaffPatrolService.insertBatchOrUpdate(formDTO, insertList); log.debug("initStaffPatrolStats insert rows:{}", effectRow); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/CalCpcIndexService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/CalCpcIndexService.java index cb9552dd4d..48cf376478 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/CalCpcIndexService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/CalCpcIndexService.java @@ -1,7 +1,5 @@ package com.epmet.service.evaluationindex.extract.dataToIndex; -import java.util.Map; - /** * 党员相关 * @@ -18,4 +16,7 @@ public interface CalCpcIndexService { * @Date 2020/9/17 14:08 **/ void calCpcPartyAbility(String customerId, String monthId); + + + void calCpcPartyAbilityV2(String customerId, String monthId); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/CalCpcIndexServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/CalCpcIndexServiceImpl.java index 353c3ad882..90f39088ea 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/CalCpcIndexServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/CalCpcIndexServiceImpl.java @@ -1,7 +1,10 @@ package com.epmet.service.evaluationindex.extract.dataToIndex.impl; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.dto.extract.UserGroupIdDTO; import com.epmet.dto.indexcollect.result.CpcIndexCommonDTO; import com.epmet.entity.evaluationindex.indexcoll.FactIndexPartyAblityCpcMonthlyEntity; import com.epmet.service.evaluationindex.extract.dataToIndex.CalCpcIndexService; @@ -9,8 +12,10 @@ import com.epmet.service.evaluationindex.extract.todata.*; import com.epmet.service.evaluationindex.indexcoll.FactIndexPartyAblityCpcMonthlyService; import com.epmet.service.group.GroupDataService; import com.epmet.service.stats.DimCustomerPartymemberService; +import com.google.common.collect.Lists; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -20,6 +25,8 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.CompletableFuture; +import java.util.stream.Collectors; /** * 党员相关 @@ -134,6 +141,237 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService { factIndexPartyAblityCpcMonthlyService.delAndSavePartyAblityCpcMonthly(customerId,monthId,indexPartyAblityCpcList); } + @Override + public void calCpcPartyAbilityV2(String customerId, String monthId) { + //1、构造初始值 当前客户下所有的党员 + List indexPartyAblityCpcList = dimCustomerPartymemberService.selectPartyMemberList(customerId); + if (CollectionUtils.isEmpty(indexPartyAblityCpcList)) { + log.info("dim_customer_partymember do not any records customerId=" + customerId); + return; + } + + //可以先查询出每个党员的 自建群 + Map> userCreatedGroups = queryUserCreatedGroups(customerId, indexPartyAblityCpcList); + + CompletableFuture> createTopicCountFuture = CompletableFuture.supplyAsync(() -> { + return calCreateTopicCount(customerId, monthId); + }); + + CompletableFuture> joinTopicCountFuture = CompletableFuture.supplyAsync(() -> { + return calJoinTopicCount(customerId, monthId); + }); + + CompletableFuture> shiftIssueCountFuture = CompletableFuture.supplyAsync(() -> { + return calShiftIssueCount(customerId, monthId); + }); + + CompletableFuture> shiftProjectCountFuture = CompletableFuture.supplyAsync(() -> { + return calShiftProjectCount(customerId, monthId); + }); + + CompletableFuture> joinThreeMeetsCountFuture = CompletableFuture.supplyAsync(() -> { + return calJoinThreeMeetsCount(customerId, monthId); + }); + + + CompletableFuture> groupUserCountFuture = CompletableFuture.supplyAsync(() -> { + return calgroupUserCount(customerId, monthId, indexPartyAblityCpcList, userCreatedGroups); + }); + + + CompletableFuture> groupActiveUserCountFuture = CompletableFuture.supplyAsync(() -> { + return calGroupActiveUserCount(customerId, monthId, indexPartyAblityCpcList, userCreatedGroups); + }); + + + CompletableFuture> groupTopicCountFuture = CompletableFuture.supplyAsync(() -> { + return calGroupTopicCount(customerId, monthId); + }); + + + CompletableFuture> topicToIssueRatioFuture = CompletableFuture.supplyAsync(() -> { + return caltopicToIssueRatio(customerId, monthId, indexPartyAblityCpcList, userCreatedGroups); + }); + + Map createTopicCountMap = new HashMap<>(); + Map joinTopicCountMap = new HashMap<>(); + Map shiftIssueCountMap = new HashMap<>(); + Map shiftProjectCountMap = new HashMap<>(); + Map joinThreeMeetsCountMap = new HashMap<>(); + Map groupUserCountMap = new HashMap<>(); + Map groupActiveUserCountMap = new HashMap<>(); + Map groupTopicCountMap = new HashMap<>(); + Map topicToIssueRatioMap = new HashMap<>(); + try { + //1、党员提出话题数 + createTopicCountMap = createTopicCountFuture.get(); + } catch (Exception e) { + log.error("党员相关-党建能力原始指标值【党员提出话题数】计算异常:{}", ExceptionUtils.getErrorStackTrace(e)); + } + + try{ + //2、党员参与话题数(支持、反对、评论、浏览)---目前只统计 党员评论话题次数之和 + joinTopicCountMap = joinTopicCountFuture.get(); + } catch (Exception e) { + log.error("党员相关-党建能力原始指标值【党员参与话题数】计算异常:{}", ExceptionUtils.getErrorStackTrace(e)); + } + try{ + //3、党员提出的话题转议题数 + shiftIssueCountMap = shiftIssueCountFuture.get(); + + } catch (Exception e) { + log.error("党员相关-党建能力原始指标值【党员提出的话题转议题数】计算异常:{}", ExceptionUtils.getErrorStackTrace(e)); + } + try{ + //4、党员提出的议题转项目数 + shiftProjectCountMap = shiftProjectCountFuture.get(); + } catch (Exception e) { + log.error("党员相关-党建能力原始指标值【党员提出的议题转项目数】计算异常:{}", ExceptionUtils.getErrorStackTrace(e)); + } + try{ + //5、参加“三会一课”次数 默认0 :当前用户在本月内活动签到次数 限制活动分类编码100001 三会一课 + joinThreeMeetsCountMap = joinThreeMeetsCountFuture.get(); + } catch (Exception e) { + log.error("党员相关-党建能力原始指标值【参加“三会一课”次数】计算异常:{}", ExceptionUtils.getErrorStackTrace(e)); + } + try{ + //6、党员自建群群众人数 :和评价周期无关 + groupUserCountMap = groupUserCountFuture.get(); + } catch (Exception e) { + log.error("党员相关-党建能力原始指标值【党员自建群群众人数】计算异常:{}", ExceptionUtils.getErrorStackTrace(e)); + } + try{ + //7、党员自建群活跃群众人数 + groupActiveUserCountMap = groupActiveUserCountFuture.get(); + } catch (Exception e) { + log.error("党员相关-党建能力原始指标值【党员自建群活跃群众人数】计算异常:{}", ExceptionUtils.getErrorStackTrace(e)); + } + try{ + //8、党员自建群活跃度——话题数:从话题表中统计党员自建群i的话题总数;对所有自建群话题数累加。 + groupTopicCountMap = groupTopicCountFuture.get(); + } catch (Exception e) { + log.error("党员相关-党建能力原始指标值【党员自建群活跃度】计算异常:{}", ExceptionUtils.getErrorStackTrace(e)); + } + + try{ + //9、自建群活跃度——议题转项目率 + topicToIssueRatioMap = topicToIssueRatioFuture.get(); + } catch (Exception e) { + log.error("党员相关-党建能力原始指标值【自建群活跃度】计算异常:{}", ExceptionUtils.getErrorStackTrace(e)); + } + + List list = new ArrayList<>(); + List> partionList = Lists.partition(indexPartyAblityCpcList, 500); + List>> entityFutures = new ArrayList<>(); + //2、计算实际值,更新 + for (List partList : partionList) { + String quarterId = DateUtils.getQuarterId(monthId); + String yearId = DateUtils.getYearId(monthId); + Map finalCreateTopicCountMap = createTopicCountMap; + Map finalJoinTopicCountMap = joinTopicCountMap; + Map finalShiftIssueCountMap = shiftIssueCountMap; + Map finalShiftProjectCountMap = shiftProjectCountMap; + Map finalJoinThreeMeetsCountMap = joinThreeMeetsCountMap; + Map finalGroupUserCountMap = groupUserCountMap; + Map finalGroupActiveUserCountMap = groupActiveUserCountMap; + Map finalGroupTopicCountMap = groupTopicCountMap; + Map finalTopicToIssueRatioMap = topicToIssueRatioMap; + //目前平阴2100多个党员,200个一组,开一个线程 + CompletableFuture> future = CompletableFuture.supplyAsync(() -> { + return constructEntity(monthId, + quarterId, + yearId, + partList, + finalCreateTopicCountMap, + finalJoinTopicCountMap, + finalShiftIssueCountMap, + finalShiftProjectCountMap, + finalJoinThreeMeetsCountMap, + finalGroupUserCountMap, + finalGroupActiveUserCountMap, + finalGroupTopicCountMap, + finalTopicToIssueRatioMap); + }); + + entityFutures.add(future); + } + + for (CompletableFuture> entityFuture : entityFutures) { + try { + List partList = entityFuture.get(); + list.addAll(partList); + } catch (InterruptedException e) { + log.error("党员相关-党建能力原始指标构造异常:{}", ExceptionUtils.getErrorStackTrace(e)); + } catch (Exception e) { + log.error("党员相关-党建能力原始指标构造异常:{}", ExceptionUtils.getErrorStackTrace(e)); + } + } + //3、删除之前统计过的、批插入批量插入 + factIndexPartyAblityCpcMonthlyService.delAndSavePartyAblityCpcMonthly(customerId, monthId, list); + } + + + private List constructEntity(String monthId, + String quarterId, + String yearId, + List partList, + Map createTopicCountMap, + Map joinTopicCountMap, + Map shiftIssueCountMap, + Map shiftProjectCountMap, + Map joinThreeMeetsCountMap, + Map groupUserCountMap, + Map groupActiveUserCountMap, + Map groupTopicCountMap, + Map topicToIssueRatioMap) { + List resultList = new ArrayList<>(); + for (FactIndexPartyAblityCpcMonthlyEntity temp : partList) { + FactIndexPartyAblityCpcMonthlyEntity indexPartyAblityCpcEntity = ConvertUtils.sourceToTarget(temp, FactIndexPartyAblityCpcMonthlyEntity.class); + indexPartyAblityCpcEntity.setMonthId(monthId); + indexPartyAblityCpcEntity.setQuarterId(quarterId); + indexPartyAblityCpcEntity.setYearId(yearId); + //1、党员提出话题数 + if (MapUtils.isNotEmpty(createTopicCountMap) && createTopicCountMap.containsKey(indexPartyAblityCpcEntity.getUserId())) { + indexPartyAblityCpcEntity.setCreateTopicCount(createTopicCountMap.get(indexPartyAblityCpcEntity.getUserId())); + } + //2、党员参与话题数(支持、反对、评论、浏览)---目前只统计 党员评论话题次数之和 + if (MapUtils.isNotEmpty(joinTopicCountMap) && joinTopicCountMap.containsKey(indexPartyAblityCpcEntity.getUserId())) { + indexPartyAblityCpcEntity.setJoinTopicCount(joinTopicCountMap.get(indexPartyAblityCpcEntity.getUserId())); + } + //3、党员提出的话题转议题数 + if (MapUtils.isNotEmpty(shiftIssueCountMap) && shiftIssueCountMap.containsKey(indexPartyAblityCpcEntity.getUserId())) { + indexPartyAblityCpcEntity.setShiftIssueCount(shiftIssueCountMap.get(indexPartyAblityCpcEntity.getUserId())); + } + //4、党员提出的议题转项目数 + if (MapUtils.isNotEmpty(shiftProjectCountMap) && shiftProjectCountMap.containsKey(indexPartyAblityCpcEntity.getUserId())) { + indexPartyAblityCpcEntity.setShiftProjectCount(shiftProjectCountMap.get(indexPartyAblityCpcEntity.getUserId())); + } + //5、参加“三会一课”次数 目前没有此业务,默认0 : 当前用户在本月内活动签到次数 限制活动分类编码100001 三会一课 + if (MapUtils.isNotEmpty(joinThreeMeetsCountMap) && joinThreeMeetsCountMap.containsKey(indexPartyAblityCpcEntity.getUserId())) { + indexPartyAblityCpcEntity.setJoinThreeMeetsCount(joinThreeMeetsCountMap.get(indexPartyAblityCpcEntity.getUserId())); + } + //6、党员自建群群众人数 + if (MapUtils.isNotEmpty(groupUserCountMap) && groupUserCountMap.containsKey(indexPartyAblityCpcEntity.getUserId())) { + indexPartyAblityCpcEntity.setGroupUserCount(groupUserCountMap.get(indexPartyAblityCpcEntity.getUserId())); + } + //7、党员自建群活跃群众人数 + if (MapUtils.isNotEmpty(groupActiveUserCountMap) && groupActiveUserCountMap.containsKey(indexPartyAblityCpcEntity.getUserId())) { + indexPartyAblityCpcEntity.setGroupActiveUserCount(groupActiveUserCountMap.get(indexPartyAblityCpcEntity.getUserId())); + } + //8、党员自建群活跃度——话题数 + if (MapUtils.isNotEmpty(groupTopicCountMap) && groupTopicCountMap.containsKey(indexPartyAblityCpcEntity.getUserId())) { + indexPartyAblityCpcEntity.setGroupTopicCount(groupTopicCountMap.get(indexPartyAblityCpcEntity.getUserId())); + } + //9、自建群活跃度——议题转项目率 + if (MapUtils.isNotEmpty(topicToIssueRatioMap) && topicToIssueRatioMap.containsKey(indexPartyAblityCpcEntity.getUserId())) { + indexPartyAblityCpcEntity.setTopicToIssueRatio(topicToIssueRatioMap.get(indexPartyAblityCpcEntity.getUserId())); + } + resultList.add(indexPartyAblityCpcEntity); + } + return resultList; + } + + /** * @param customerId * @param partyMemberList @@ -144,7 +382,7 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService { **/ private Map> queryUserCreatedGroups(String customerId, List partyMemberList) { Map> map = new HashMap<>(); - for (FactIndexPartyAblityCpcMonthlyEntity partyMember : partyMemberList) { + /*for (FactIndexPartyAblityCpcMonthlyEntity partyMember : partyMemberList) { //查询当前党员建了多少个组 List groupIdList=factOriginGroupMainDailyService.selectGroupIds(customerId,partyMember.getUserId()); if (CollectionUtils.isEmpty(groupIdList)) { @@ -153,6 +391,17 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService { } else { map.put(partyMember.getUserId(), groupIdList); } + }*/ + //查询出所有的小组,按照组长 + List list = factOriginGroupMainDailyService.selectGroupAndLeader(customerId); + Map> userGroupIdMap = list.stream().collect(Collectors.toMap(UserGroupIdDTO::getUserId, UserGroupIdDTO::getGroupIdList)); + for (FactIndexPartyAblityCpcMonthlyEntity partyMember : partyMemberList) { + if (MapUtils.isEmpty(userGroupIdMap) || !userGroupIdMap.containsKey(partyMember.getUserId())) { + map.put(partyMember.getUserId(), new ArrayList<>()); + continue; + } else { + map.put(partyMember.getUserId(), userGroupIdMap.get(partyMember.getUserId())); + } } return map; } @@ -166,11 +415,13 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService { * @Date 2020/9/18 10:59 **/ private Map calCreateTopicCount(String customerId, String monthId) { + long startCpc = System.currentTimeMillis(); List list = factOriginTopicMainDailyService.selectPartyCreateTopicCount(customerId, monthId); Map resultMap = new HashMap<>(); for (CpcIndexCommonDTO cpcIndexCommonDTO: list) { resultMap.put(cpcIndexCommonDTO.getUserId(), cpcIndexCommonDTO.getIndexValue()); } + log.warn("1、党员相关-党建能力【党员提出话题数】执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startCpc, customerId); return resultMap; } @@ -183,11 +434,13 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService { * @Date 2020/9/18 13:33 **/ private Map calJoinTopicCount(String customerId, String monthId) { + long startCpc = System.currentTimeMillis(); List list = factOriginTopicLogDailyService.selectJoinTopicCount(customerId, monthId); Map resultMap = new HashMap<>(); for (CpcIndexCommonDTO cpcIndexCommonDTO : list) { resultMap.put(cpcIndexCommonDTO.getUserId(), cpcIndexCommonDTO.getIndexValue()); } + log.warn("2、党员相关-党建能力【党员参与话题数】执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startCpc, customerId); return resultMap; } @@ -201,11 +454,13 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService { * @Date 2020/9/18 13:53 **/ private Map calShiftIssueCount(String customerId, String monthId) { + long startCpc = System.currentTimeMillis(); List list = issueExtractService.selectShiftIssueCount(customerId, monthId); Map resultMap = new HashMap<>(); for (CpcIndexCommonDTO cpcIndexCommonDTO : list) { resultMap.put(cpcIndexCommonDTO.getUserId(), cpcIndexCommonDTO.getIndexValue()); } + log.warn("3、党员相关-党建能力【党员提出的话题转议题数】执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startCpc, customerId); return resultMap; } @@ -218,12 +473,14 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService { * @Date 2020/9/18 14:10 **/ private Map calShiftProjectCount(String customerId, String monthId) { + long startCpc = System.currentTimeMillis(); //查询fact_origin_project_main_daily 表 中议题的议题的状态为 shift_ List list = factOriginProjectMainDailyService.selectShiftProjectCount(customerId, monthId); Map resultMap = new HashMap<>(); for (CpcIndexCommonDTO cpcIndexCommonDTO : list) { resultMap.put(cpcIndexCommonDTO.getUserId(), cpcIndexCommonDTO.getIndexValue()); } + log.warn("4、党员相关-党建能力【党员提出的议题转项目数】执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startCpc, customerId); return resultMap; } @@ -236,12 +493,14 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService { * @Date 2021/5/12 13:38 **/ private Map calJoinThreeMeetsCount(String customerId, String monthId) { + long startCpc = System.currentTimeMillis(); //查询小组活动签到表,计算用户在本月内签到的活动次数 List list=groupDataService.selectJoinThreeMeetsCount(customerId,monthId); Map resultMap = new HashMap<>(); for (CpcIndexCommonDTO cpcIndexCommonDTO : list) { resultMap.put(cpcIndexCommonDTO.getUserId(), cpcIndexCommonDTO.getIndexValue()); } + log.warn("5、党员相关-党建能力【参加“三会一课”次数】执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startCpc, customerId); return resultMap; } @@ -256,6 +515,7 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService { private Map calgroupUserCount(String customerId, String monthId, List partyMemberList, Map> userCreatedGroups) { + long startCpc = System.currentTimeMillis(); /*含义:评价周期内,党员自建群中群众成员数。 数据来源:用户社群关系表。 计算方法:对党员i的所有j个自建群,从用户社群关系表中统计属于每个自建群的群众用户总人数,并对j个群众用户总数进行不重复累加。 @@ -265,7 +525,7 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService { //查询当前党员建了多少个组 List groupIdList = userCreatedGroups.get(partyMember.getUserId()); if (CollectionUtils.isEmpty(groupIdList)) { - log.info("当前党员userId="+partyMember.getUserId()+"没有创建过小组, 【党员相关-党员自建群群众人数】赋值0"); + // log.info("当前党员userId="+partyMember.getUserId()+"没有创建过小组, 【党员相关-党员自建群群众人数】赋值0"); map.put(partyMember.getUserId(), NumConstant.ZERO); continue; } @@ -279,6 +539,7 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService { map.put(partyMember.getUserId(), memberIdList.size()); } } + log.warn("6、党员相关-党建能力【党员自建群群众人数】执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startCpc, customerId); return map; } @@ -294,6 +555,7 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService { private Map calGroupActiveUserCount(String customerId, String monthId, List partyMemberList, Map> userCreatedGroups) { + long startCpc = System.currentTimeMillis(); /*含义:评价周期内,党员自建群中活跃群众成员数。所谓活跃群成员,即评价周期内参与话题、事件评论、点赞、点踩总次数大于给定阈值的群众用户。 数据来源:话题用户阅读表、话题评论用户表态表、话题评论表、事件点赞点踩表、事件评论点赞点踩表、事件评论表、用户信息表。 计算方法: @@ -311,7 +573,7 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService { //1、查询当前党员建了多少个组 List groupIdList = userCreatedGroups.get(partyMember.getUserId()); if (CollectionUtils.isEmpty(groupIdList)) { - log.info("当前党员userId="+partyMember.getUserId()+"没有创建过小组, 【党员相关-党员自建群活跃群众人数】赋值0"); + // log.warn("当前党员userId="+partyMember.getUserId()+"没有创建过小组, 【党员相关-党员自建群活跃群众人数】赋值0"); map.put(partyMember.getUserId(), NumConstant.ZERO); continue; } @@ -321,23 +583,35 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService { map.put(partyMember.getUserId(), NumConstant.ZERO); continue; } + //可以先把本月内评论的用户+本月内表决过的用户 集合查询出来。避免循环查询 + List commentTopicUserIds=factOriginTopicLogDailyService.queryCommentTopicUserIds(customerId,monthId); + List voteUserIds=issueExtractService.queryVoteUserIds(customerId,monthId); //3、判断每个成员是否 “活跃” for (String memberId : memberIdList) { + //注释2022.03.02 //1、判断成员在本月内是否评论过 - Integer topicCommentCount = factOriginTopicLogDailyService.selectUserCommentCount(memberId, customerId, monthId); + /*Integer topicCommentCount = factOriginTopicLogDailyService.selectUserCommentCount(memberId, customerId, monthId); if (topicCommentCount > 0) { groupActiveUserCount++; continue; - } + }*/ //2、判断成员在本月内是否表决过(支持or反对)议题 - Integer voteCount = issueExtractService.selectCountUserVote(memberId, customerId, monthId); + /*Integer voteCount = issueExtractService.selectCountUserVote(memberId, customerId, monthId); if (voteCount > 0) { groupActiveUserCount++; + }*/ + if (CollectionUtils.isNotEmpty(commentTopicUserIds) && commentTopicUserIds.contains(memberId)) { + groupActiveUserCount++; + continue; + } + if (CollectionUtils.isNotEmpty(voteUserIds) && voteUserIds.contains(memberId)) { + groupActiveUserCount++; } } //赋值每个党员的 -- 党员自建群活跃群众人数 map.put(partyMember.getUserId(), groupActiveUserCount); } + log.warn("7、党员相关-党建能力【党员自建群活跃群众人数】执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startCpc, customerId); return map; } @@ -351,6 +625,7 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService { * @Date 2020/9/18 14:31 **/ private Map calGroupTopicCount(String customerId, String monthId) { + long startCpc = System.currentTimeMillis(); /*含义:评价周期内,党员自建群中话题发布数。 数据来源:话题表。 计算方法:从话题表中统计党员自建群i的话题总数;对所有自建群话题数累加。 @@ -360,6 +635,7 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService { for (CpcIndexCommonDTO dto : list) { resultMap.put(dto.getUserId(), dto.getIndexValue()); } + log.warn("8、党员相关-党建能力【党员自建群活跃度——话题数】执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startCpc, customerId); return resultMap; } @@ -374,6 +650,7 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService { String monthId, List partyMemberList, Map> userCreatedGroups) { + long startCpc = System.currentTimeMillis(); Map map = new HashMap<>(); for (FactIndexPartyAblityCpcMonthlyEntity partyMember : partyMemberList) { //如果党员自建群为空,直接赋值0 @@ -408,6 +685,7 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService { BigDecimal topicToIssueRatio = new BigDecimal(topicToIssueRatioStr).multiply(new BigDecimal(NumConstant.ONE_HUNDRED)); map.put(partyMember.getUserId(), topicToIssueRatio); } + log.warn("9、党员相关-党建能力【自建群活跃度——议题转项目率】执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startCpc, customerId); return map; } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexOriginExtractServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexOriginExtractServiceImpl.java index 783b11feeb..1548abed61 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexOriginExtractServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexOriginExtractServiceImpl.java @@ -4,11 +4,14 @@ import cn.hutool.core.collection.CollectionUtil; import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.constant.CustomerIdConstant; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.enums.EnvEnum; +import com.epmet.commons.tools.utils.HttpClientManager; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.extract.form.ExtractIndexFormDTO; +import com.epmet.dto.indexcal.CalculateCommonFormDTO; import com.epmet.service.evaluationindex.extract.dataToIndex.*; +import com.epmet.service.evaluationindex.indexcal.IndexCalculateService; import com.epmet.service.stats.DimCustomerService; -import com.google.common.util.concurrent.ThreadFactoryBuilder; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -18,7 +21,8 @@ import org.springframework.util.CollectionUtils; import java.time.LocalDate; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.*; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; /** * desc:指标原始数据抽取服务实现类 @@ -26,12 +30,8 @@ import java.util.concurrent.*; @Slf4j @Service public class IndexOriginExtractServiceImpl implements IndexOriginExtractService { - ThreadFactory namedThreadFactory = new ThreadFactoryBuilder() - .setNameFormat("indexOriginExtract-pool-%d").build(); - ExecutorService threadPool = new ThreadPoolExecutor(1, 1, - 10L, TimeUnit.MINUTES, - new LinkedBlockingQueue<>(500), namedThreadFactory, new ThreadPoolExecutor.CallerRunsPolicy()); - + @Autowired + private ExecutorService executorService; @Autowired private CalCpcIndexService calCpcIndexService; @Autowired @@ -45,7 +45,10 @@ public class IndexOriginExtractServiceImpl implements IndexOriginExtractService @Autowired private IndexCollDistrictService indexCollDistrictService; @Autowired - private IndexCollDistrictDepartmentService indexCollDistrictDepartmentService; + private IndexCollDistrictDepartmentService indexCollDistrictDepartmentService; + @Autowired + private IndexCalculateService indexCalculateService; + /** * desc:从统计库对象抽取指标数据 * @@ -56,7 +59,7 @@ public class IndexOriginExtractServiceImpl implements IndexOriginExtractService String monthId = formDTO.getMonthId(); String customerId = formDTO.getCustomerId(); if (StringUtils.isBlank(monthId)) { - monthId = LocalDate.now().minusMonths(NumConstant.ONE).toString().replace("-","").substring(NumConstant.ZERO,NumConstant.SIX); + monthId = LocalDate.now().minusMonths(NumConstant.ONE).toString().replace("-", "").substring(NumConstant.ZERO, NumConstant.SIX); } List customerIds = new ArrayList<>(); if (StringUtils.isNotBlank(customerId)) { @@ -67,7 +70,7 @@ public class IndexOriginExtractServiceImpl implements IndexOriginExtractService List customerIdList = null; do { customerIdList = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize); - if (!CollectionUtils.isEmpty(customerIdList)){ + if (!CollectionUtils.isEmpty(customerIdList)) { customerIds.addAll(customerIdList); } } while (!CollectionUtil.isEmpty(customerIdList) && customerIdList.size() == pageSize); @@ -91,88 +94,104 @@ public class IndexOriginExtractServiceImpl implements IndexOriginExtractService private void submitJob(ExtractIndexFormDTO param) { - CountDownLatch countDownLatch = new CountDownLatch(2); + CountDownLatch countDownLatch = new CountDownLatch(NumConstant.SIX); long start = System.currentTimeMillis(); final String customerId = param.getCustomerId(); final String monthId = param.getMonthId(); - threadPool.submit(() -> { + executorService.submit(() -> { try { long startCpc = System.currentTimeMillis(); - calCpcIndexService.calCpcPartyAbility(customerId, monthId); - log.error("党员相关-党建能力执行完毕======总耗时:{}ms,customerId:{}",System.currentTimeMillis()-startCpc, param.getCustomerId()); + // calCpcIndexService.calCpcPartyAbility(customerId, monthId); + calCpcIndexService.calCpcPartyAbilityV2(customerId, monthId); + log.info("党员相关-党建能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startCpc, param.getCustomerId()); } catch (Exception e) { log.error("抽取【党员相关数据】发生异常,参数:" + JSON.toJSONString(param), e); - }finally { + } finally { countDownLatch.countDown(); } }); - threadPool.submit(() -> { + executorService.submit(() -> { try { long startGridGovern = System.currentTimeMillis(); calGridIndexService.calGridIndexGovernAbility(customerId, monthId); - log.error("网格相关-治理能力执行完毕======总耗时:{}ms,customerId:{}",System.currentTimeMillis()-startGridGovern, param.getCustomerId()); + log.info("网格相关-治理能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startGridGovern, param.getCustomerId()); } catch (Exception e) { log.error("抽取【网格治理能力数据】发生异常,参数:" + JSON.toJSONString(param), e); } try { long startGridParty = System.currentTimeMillis(); calGridIndexService.calGridIndexPartyAbility(customerId, monthId); - log.error("网格相关-党建能力执行完毕======总耗时:{}ms,customerId:{}",System.currentTimeMillis()-startGridParty, param.getCustomerId()); + log.info("网格相关-党建能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startGridParty, param.getCustomerId()); } catch (Exception e) { log.error("抽取【网格党建能力数据】发生异常,参数:" + JSON.toJSONString(param), e); } try { long startGridService = System.currentTimeMillis(); calGridIndexService.calGridIndexServiceAbility(customerId, monthId); - log.error("网格相关-服务能力执行完毕======总耗时:{}ms,customerId:{}",System.currentTimeMillis()-startGridService, param.getCustomerId()); + log.info("网格相关-服务能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startGridService, param.getCustomerId()); } catch (Exception e) { log.error("抽取【网格服务能力数据】发生异常,参数:" + JSON.toJSONString(param), e); } - - try{ - //dimAgency + countDownLatch.countDown(); + }); + executorService.submit(() -> { + try { long startCommunity = System.currentTimeMillis(); indexCollCommunityService.saveCommunityAbility(customerId, monthId); - log.error("社区相关-三大能力执行完毕======总耗时:{}ms,customerId:{}",System.currentTimeMillis()-startCommunity, param.getCustomerId()); - }catch (Exception e){ + log.info("社区相关-三大能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startCommunity, param.getCustomerId()); + } catch (Exception e) { log.error("抽取【社区治理能力-社区党建能力-服务能力】发生异常,参数:" + JSON.toJSONString(param), e); } - try{ - //dimAgency + countDownLatch.countDown(); + }); + executorService.submit(() -> { + try { long startStreet = System.currentTimeMillis(); indexCollStreetService.saveStreetAbility(customerId, monthId); - log.error("街道相关-三大能力执行完毕======总耗时:{}ms,customerId:{}",System.currentTimeMillis()-startStreet, param.getCustomerId()); - }catch (Exception e){ + log.info("街道相关-三大能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startStreet, param.getCustomerId()); + } catch (Exception e) { log.error("抽取【街道治理能力-街道党建能力-服务能力】发生异常,参数:" + JSON.toJSONString(param), e); } - - - try{ - //dimAgency + countDownLatch.countDown(); + }); + executorService.submit(() -> { + try { long startDept = System.currentTimeMillis(); indexCollDistrictDepartmentService.saveDepartmentAbility(customerId, monthId); - log.error("区直部门相关-治理能力执行完毕======总耗时:{}ms,customerId:{}",System.currentTimeMillis()-startDept, param.getCustomerId()); - }catch (Exception e){ + log.info("区直部门相关-治理能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startDept, param.getCustomerId()); + } catch (Exception e) { log.error("抽取【区直部门治理能力】发生异常,参数:" + JSON.toJSONString(param), e); } - - - try{ - //dimAgency + countDownLatch.countDown(); + }); + executorService.submit(() -> { + try { long startDistrict = System.currentTimeMillis(); indexCollDistrictService.saveDistrictAbility(customerId, monthId); - log.error("全区相关-三大能力执行完毕======总耗时:{}ms,customerId:{}",System.currentTimeMillis()-startDistrict, param.getCustomerId()); - }catch (Exception e){ + log.info("全区相关-三大能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startDistrict, param.getCustomerId()); + } catch (Exception e) { log.error("抽取【全区治理能力-全区党建能力-服务能力】发生异常,参数:" + JSON.toJSONString(param), e); } countDownLatch.countDown(); }); - + log.info("indexOriginExtractAll======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - start, param.getCustomerId()); try { + //等前面都执行完 再执行计算指标得分 countDownLatch.await(); + executorService.submit(() -> { + long startT = System.currentTimeMillis(); + CalculateCommonFormDTO formDTO1 = new CalculateCommonFormDTO(); + try { + formDTO1.setMonthId(monthId); + formDTO1.setCustomerId(customerId); + Boolean aBoolean = indexCalculateService.indexCalculate(formDTO1); + HttpClientManager.getInstance().sendAlarmMsg(EnvEnum.getCurrentEnv().getName() + "客户Id:" + customerId + ";monthId:" + monthId + ",calculateAll全部指标计算完成,是否成功:" + aBoolean + ",总耗时:" + (System.currentTimeMillis() - startT) / 1000 + "秒"); + } catch (Exception e) { + log.error("extractMonthly 计算分数异常,参数:{}", JSON.toJSONString(formDTO1)); + } + }); } catch (InterruptedException e) { log.error("indexOriginExtractAll countDownLatch exception", e); } - log.error("indexOriginExtractAll执行完毕======总耗时:{}ms,customerId:{}",System.currentTimeMillis()-start, param.getCustomerId()); } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/FactOriginGroupMainDailyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/FactOriginGroupMainDailyService.java index 89beadf503..6b88a66d94 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/FactOriginGroupMainDailyService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/FactOriginGroupMainDailyService.java @@ -19,6 +19,7 @@ package com.epmet.service.evaluationindex.extract.todata; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.dto.extract.FactOriginGroupMainDailyDTO; +import com.epmet.dto.extract.UserGroupIdDTO; import com.epmet.dto.extract.form.ScreenPartyLinkMassesDataFormDTO; import com.epmet.dto.extract.result.GridGroupUserCountResultDTO; import com.epmet.dto.extract.result.OrgStatisticsResultDTO; @@ -125,4 +126,10 @@ public interface FactOriginGroupMainDailyService extends BaseService getPartyMemberGroupStatic(String customerId, String dateId, String type); + /** + * 查询出小组id ,组长userId + * @param customerId + * @return + */ + List selectGroupAndLeader(String customerId); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/FactOriginTopicLogDailyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/FactOriginTopicLogDailyService.java index 7c43394dea..6820edb992 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/FactOriginTopicLogDailyService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/FactOriginTopicLogDailyService.java @@ -79,4 +79,12 @@ public interface FactOriginTopicLogDailyService extends BaseService selectPartyActiveTopic(String customerId, String monthId,Integer isParty); + + /** + * 查询出本月内,评论过话题的用户id + * @param customerId + * @param monthId + * @return + */ + List queryCommentTopicUserIds(String customerId, String monthId); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/IssueExtractService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/IssueExtractService.java index 85caea8cc5..010791542e 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/IssueExtractService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/IssueExtractService.java @@ -107,4 +107,12 @@ public interface IssueExtractService { * @date 2020/9/21 9:37 上午 */ List selectPartyActiveIssueVote(String customerId, String monthId, Integer isParty); + + /** + * 查询出本月内做过议题表决的用户id + * @param customerId + * @param monthId + * @return + */ + List queryVoteUserIds(String customerId, String monthId); } 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 b650e906d3..6db437e591 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 @@ -7,13 +7,10 @@ import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.DateUtils; import com.epmet.dto.extract.form.ExtractOriginFormDTO; import com.epmet.dto.stats.form.CustomerIdAndDateIdFormDTO; -import com.epmet.service.StatsGroupService; -import com.epmet.service.StatsTopicService; import com.epmet.service.evaluationindex.extract.todata.*; import com.epmet.service.stats.DimCustomerPartymemberService; import com.epmet.service.stats.DimCustomerService; import com.epmet.util.DimIdGenerator; -import com.google.common.util.concurrent.ThreadFactoryBuilder; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -23,7 +20,9 @@ import org.springframework.util.CollectionUtils; import java.util.ArrayList; import java.util.Date; import java.util.List; -import java.util.concurrent.*; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; /** * desc:抽取业务数据 到 统计库 汇聚类 @@ -31,12 +30,6 @@ import java.util.concurrent.*; @Slf4j @Service public class FactOriginExtractServiceImpl implements FactOriginExtractService { - ThreadFactory namedThreadFactory = new ThreadFactoryBuilder() - .setNameFormat("factOriginExtract-pool-%d").build(); - ExecutorService threadPool = new ThreadPoolExecutor(3, 6, - 10L, TimeUnit.MINUTES, - new LinkedBlockingQueue<>(500), namedThreadFactory, new ThreadPoolExecutor.CallerRunsPolicy()); - @Autowired private IssueExtractService issueExtractService; @Autowired @@ -54,9 +47,7 @@ public class FactOriginExtractServiceImpl implements FactOriginExtractService { @Autowired private FactGroupActDailyService factGroupActDailyService; @Autowired - private StatsGroupService statsGroupService; - @Autowired - private StatsTopicService statsTopicService; + private ExecutorService executorService; @Override @@ -106,7 +97,7 @@ public class FactOriginExtractServiceImpl implements FactOriginExtractService { daysBetween = DateUtils.getDaysBetween(param.getStartDate(), param.getEndDate()); } List finalDaysBetween = daysBetween; - threadPool.submit(() -> { + executorService.submit(() -> { try { CustomerIdAndDateIdFormDTO formDTO = new CustomerIdAndDateIdFormDTO(); formDTO.setCustomerId(param.getCustomerId()); @@ -132,7 +123,7 @@ public class FactOriginExtractServiceImpl implements FactOriginExtractService { countDownLatch.countDown(); } }); - threadPool.submit(() -> { + executorService.submit(() -> { try { ExtractOriginFormDTO paramNew = ConvertUtils.sourceToTarget(param, ExtractOriginFormDTO.class); if (!isRange) { @@ -156,7 +147,7 @@ public class FactOriginExtractServiceImpl implements FactOriginExtractService { countDownLatch.countDown(); } }); - threadPool.submit(() -> { + executorService.submit(() -> { try { log.debug("extractAll start param:{}", JSON.toJSONString(param)); ExtractOriginFormDTO paramNew = ConvertUtils.sourceToTarget(param, ExtractOriginFormDTO.class); @@ -183,7 +174,7 @@ public class FactOriginExtractServiceImpl implements FactOriginExtractService { countDownLatch.countDown(); } }); - threadPool.submit(() -> { + executorService.submit(() -> { try { ExtractOriginFormDTO paramNew = ConvertUtils.sourceToTarget(param, ExtractOriginFormDTO.class); if (!isRange) { @@ -222,7 +213,7 @@ public class FactOriginExtractServiceImpl implements FactOriginExtractService { } }); //小组活动 - threadPool.submit(() -> { + executorService.submit(() -> { try { ExtractOriginFormDTO extractOriginFormDTO = ConvertUtils.sourceToTarget(param, ExtractOriginFormDTO.class); if (!isRange) { @@ -339,7 +330,7 @@ public class FactOriginExtractServiceImpl implements FactOriginExtractService { @Override public Future submitProjectRelationData(ExtractOriginFormDTO param, List finalDaysBetween) { - Future submit = threadPool.submit(() -> { + Future submit = executorService.submit(() -> { ExtractOriginFormDTO paramNew = ConvertUtils.sourceToTarget(param, ExtractOriginFormDTO.class); if (CollectionUtils.isEmpty(finalDaysBetween)) { try { diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginGroupMainDailyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginGroupMainDailyServiceImpl.java index 164b0b76dc..05c0720986 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginGroupMainDailyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginGroupMainDailyServiceImpl.java @@ -22,8 +22,8 @@ import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.constant.OrgTypeConstant; import com.epmet.dao.evaluationindex.extract.FactOriginGroupMainDailyDao; -import com.epmet.dao.evaluationindex.extract.FactOriginGroupMemberDailyDao; import com.epmet.dto.extract.FactOriginGroupMainDailyDTO; +import com.epmet.dto.extract.UserGroupIdDTO; import com.epmet.dto.extract.form.ScreenPartyLinkMassesDataFormDTO; import com.epmet.dto.extract.result.GridGroupUserCountResultDTO; import com.epmet.dto.extract.result.OrgStatisticsResultDTO; @@ -198,4 +198,15 @@ public class FactOriginGroupMainDailyServiceImpl extends BaseServiceImpl selectGroupAndLeader(String customerId) { + return baseDao.selectGroupAndLeader(customerId); + } + } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginTopicLogDailyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginTopicLogDailyServiceImpl.java index 70ecc1807f..46da054bd8 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginTopicLogDailyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginTopicLogDailyServiceImpl.java @@ -108,4 +108,16 @@ public class FactOriginTopicLogDailyServiceImpl extends BaseServiceImpl selectPartyActiveTopic(String customerId, String monthId, Integer isParty) { return baseDao.selectPartyActiveTopic(customerId, monthId, isParty); } + + /** + * 查询出本月内,评论过话题的用户id + * + * @param customerId + * @param monthId + * @return + */ + @Override + public List queryCommentTopicUserIds(String customerId, String monthId) { + return baseDao.queryCommentTopicUserIds(customerId,monthId); + } } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/IssueExtractServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/IssueExtractServiceImpl.java index 4cdd1368e6..d55cfdcc71 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/IssueExtractServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/IssueExtractServiceImpl.java @@ -374,4 +374,17 @@ public class IssueExtractServiceImpl implements IssueExtractService { public List selectPartyActiveIssueVote(String customerId, String monthId, Integer isParty) { return issueLogDailyDao.selectPartyActiveIssueVote(customerId, monthId, isParty); } + + /** + * 查询出本月内做过议题表决的用户id + * + * @param customerId + * @param monthId + * @return + */ + @Override + public List queryVoteUserIds(String customerId, String monthId) { + return issueLogDailyDao.queryVoteUserIds(customerId,monthId); + } + } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java index 6d4e5c029f..e3ed39133b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java @@ -7,22 +7,17 @@ import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.distributedlock.DistributedLock; import com.epmet.commons.tools.distributedlock.LockConstants; -import com.epmet.commons.tools.enums.EnvEnum; import com.epmet.commons.tools.utils.DateUtils; -import com.epmet.commons.tools.utils.HttpClientManager; import com.epmet.dto.extract.form.ExtractFactGridGovernDailyFromDTO; import com.epmet.dto.extract.form.ExtractOriginFormDTO; import com.epmet.dto.extract.form.ExtractScreenFormDTO; -import com.epmet.dto.indexcal.CalculateCommonFormDTO; import com.epmet.dto.screen.form.ScreenCentralZoneDataFormDTO; import com.epmet.service.evaluationindex.extract.todata.FactAgencyGovernDailyService; import com.epmet.service.evaluationindex.extract.todata.FactGridGovernDailyService; import com.epmet.service.evaluationindex.extract.todata.FactGridMemberStatisticsDailyService; import com.epmet.service.evaluationindex.extract.toscreen.*; -import com.epmet.service.evaluationindex.indexcal.IndexCalculateService; import com.epmet.service.evaluationindex.screen.*; import com.epmet.service.stats.DimCustomerService; -import com.google.common.util.concurrent.ThreadFactoryBuilder; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.redisson.api.RLock; @@ -33,7 +28,9 @@ import org.springframework.util.CollectionUtils; import java.time.LocalDate; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.*; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.TimeUnit; /** * @Author zxc @@ -42,12 +39,6 @@ import java.util.concurrent.*; @Service @Slf4j public class ScreenExtractServiceImpl implements ScreenExtractService { - ThreadFactory namedThreadFactory = new ThreadFactoryBuilder() - .setNameFormat("ScreenExtractServiceImpl-pool-%d").build(); - ExecutorService threadPool = new ThreadPoolExecutor(3, 6, - 10L, TimeUnit.MINUTES, - new LinkedBlockingQueue<>(500), namedThreadFactory, new ThreadPoolExecutor.CallerRunsPolicy()); - @Autowired private DimCustomerService dimCustomerService; @Autowired @@ -65,8 +56,6 @@ public class ScreenExtractServiceImpl implements ScreenExtractService { @Autowired private PublicPartiTotalDataExtractService publicPartiTotalDataExtractService; @Autowired - private IndexCalculateService indexCalculateService; - @Autowired private ScreenCentralZoneDataAbsorptionService screenCentralZoneDataAbsorptionService; @Autowired private ScreenGrassrootsGovernDataAbsorptionService screenGrassrootsGovernDataAbsorptionService; @@ -81,10 +70,6 @@ public class ScreenExtractServiceImpl implements ScreenExtractService { @Autowired private ScreenProjectSettleService screenProjectSettleService; @Autowired - private ScreenProjectCategoryGridDailyService projectCategoryGridDailyService; - @Autowired - private ScreenProjectCategoryOrgDailyService projectCategoryOrgDailyService; - @Autowired private FactGridGovernDailyService factGridGovernDailyService; @Autowired private FactAgencyGovernDailyService factAgencyGovernDailyService; @@ -94,6 +79,9 @@ public class ScreenExtractServiceImpl implements ScreenExtractService { private ScreenProjectCategoryGridAndOrgDailyService screenProjectCategoryGridAndOrgDailyService; @Autowired private DistributedLock distributedLock; + @Autowired + private ExecutorService executorService; + /** * @param extractOriginFormDTO @@ -183,7 +171,7 @@ public class ScreenExtractServiceImpl implements ScreenExtractService { lock = distributedLock.getLock(LockConstants.SCREEN_DAILY, NumConstant.SIX_HUNDRED_L, NumConstant.TEN_L, TimeUnit.SECONDS); //等待3个线程执行完毕后再 继续执行下一个客户的 避免死锁 final CountDownLatch latch = new CountDownLatch(NumConstant.FOUR); - threadPool.submit(() -> { + executorService.submit(() -> { //党员基本情况screen_cpc_base_data try { try { @@ -215,7 +203,7 @@ public class ScreenExtractServiceImpl implements ScreenExtractService { } }); - threadPool.submit(() -> { + executorService.submit(() -> { //公众参与排行(注册人数、参与人数、话题数、议题数、项目数)screen_public_party_total_data try { @@ -263,7 +251,7 @@ public class ScreenExtractServiceImpl implements ScreenExtractService { log.info("extractDaily 2 thread run end ========= dateId:{},customerId:{}", dateId, customerId); } }); - threadPool.submit(() -> { + executorService.submit(() -> { try { try { @@ -278,26 +266,12 @@ public class ScreenExtractServiceImpl implements ScreenExtractService { } catch (Exception e) { log.error("项目(事件)分析按组织_按天统计失败,customerId为:" + customerId + "dateId为:" + dateId, e); } - - //按天统计:网格内各个分类下的项目总数 - try { - screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectGridData(customerId, dateId); - } catch (Exception e) { - log.error("按天统计:网格内各个分类下的项目总数,customerId为:" + customerId + "dateId为:" + dateId, e); - } - - // 按天统计:组织内各个分类下的项目总数 - try { - screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectOrgData(customerId, dateId); - } catch (Exception e) { - log.error("按天统计:组织内各个分类下的项目总数,customerId为:" + customerId + "dateId为:" + dateId, e); - } } finally { latch.countDown(); log.info("extractDaily 3 thread run end ========= dateId:{},customerId:{}", dateId, customerId); } }); - threadPool.submit(() -> { + executorService.submit(() -> { //治理能力排行screen_govern_rank_data try { try { @@ -342,6 +316,20 @@ public class ScreenExtractServiceImpl implements ScreenExtractService { log.error("网格员数据统计fact_grid_member_statistics_daily抽取失败,customerId为:" + customerId + "dateId为:" + dateId, e); } extractPartData(customerId, dateId, null); + // 挪到这的原因是因为,要等 screen_project_data表跑完,下面两个方法抽取数据来源于screen_project_data和screen_project_category + //按天统计:网格内各个分类下的项目总数 + try { + screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectGridData(customerId, dateId); + } catch (Exception e) { + log.error("按天统计:网格内各个分类下的项目总数,customerId为:" + customerId + "dateId为:" + dateId, e); + } + + // 按天统计:组织内各个分类下的项目总数 + try { + screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectOrgData(customerId, dateId); + } catch (Exception e) { + log.error("按天统计:组织内各个分类下的项目总数,customerId为:" + customerId + "dateId为:" + dateId, e); + } } finally { latch.countDown(); log.info("extractDaily 4 thread run end ========= dateId:{},customerId:{}", dateId, customerId); @@ -447,16 +435,6 @@ public class ScreenExtractServiceImpl implements ScreenExtractService { } catch (Exception e) { log.error("党建引领抽取到大屏失败,参数为:" + JSON.toJSONString(formDTO), e); } - //已经挪到天抽取的抽取里了 - /* try { - //基层治理 - 热心市民 screen_party_user_rank_data - ScreenCentralZoneDataFormDTO param = new ScreenCentralZoneDataFormDTO(); - param.setCustomerId(customerId); - param.setDateId(monthId); - screenGrassrootsGovernDataAbsorptionService.userScoreDataHub(param); - } catch (Exception e) { - log.error("大屏热心市民/党员得分数据写入失败,参数为:{}" + JSON.toJSONString(formDTO), e); - }*/ try { // 项目(事件)数量分析按网格_按月统计 screenProjectQuantityGridMonthlyService.extractionProjectGridMonthly(customerId, monthId); @@ -474,20 +452,6 @@ public class ScreenExtractServiceImpl implements ScreenExtractService { log.info("===== extractMonthly method end not contains shi bei:{}======", customerId); return; } - //此方法保持在最后即可 计算指标分数 todo 优化 手动创建线程池 控制任务数量 - ExecutorService pool = Executors.newSingleThreadExecutor(); - pool.submit(() -> { - long start = System.currentTimeMillis(); - CalculateCommonFormDTO formDTO1 = new CalculateCommonFormDTO(); - try { - formDTO1.setMonthId(monthId); - formDTO1.setCustomerId(customerId); - Boolean aBoolean = indexCalculateService.indexCalculate(formDTO1); - HttpClientManager.getInstance().sendAlarmMsg(EnvEnum.getCurrentEnv().getName() + "客户Id:" + formDTO.getCustomerId() + ";monthId:" + formDTO1.getMonthId() + ",calculateAll全部指标计算完成,是否成功:" + aBoolean + ",总耗时:" + (System.currentTimeMillis() - start) / 1000 + "秒"); - } catch (Exception e) { - log.error("extractMonthly 计算分数异常,参数:{}", JSON.toJSONString(formDTO1)); - } - }); log.info("===== extractMonthly method end ======"); } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/IndexCalculateService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/IndexCalculateService.java index d5d41e48a3..cabc852377 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/IndexCalculateService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/IndexCalculateService.java @@ -19,6 +19,11 @@ public interface IndexCalculateService { */ Boolean indexCalculate(CalculateCommonFormDTO formDTO); + /** + * desc:异步 连续计算[指定或所有内部客户][多个月份]的指标得分入口 + * @param formDTO + * @return + */ Boolean indexStatistics(IndexStatisticsFormDTO formDTO); /** diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java index d1e449b4a0..b2d3c0b9d7 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java @@ -1,7 +1,9 @@ package com.epmet.service.evaluationindex.indexcal.impl; +import cn.hutool.core.collection.CollectionUtil; import com.alibaba.fastjson.JSON; import com.epmet.commons.dynamic.datasource.annotation.DataSource; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.enums.EnvEnum; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.utils.DateUtils; @@ -17,16 +19,16 @@ import com.epmet.redis.IndexCalRedis; import com.epmet.service.crm.CustomerRelationService; import com.epmet.service.evaluationindex.indexcal.*; import com.epmet.service.evaluationindex.indexcoll.FactIndexCollectService; +import com.epmet.service.stats.DimCustomerService; import com.epmet.util.DimIdGenerator; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; +import java.util.*; /** * @author liujianjun @@ -58,6 +60,8 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { private ScreenCustomerAgencyDao screenCustomerAgencyDao; @Autowired private CustomerRelationService customerRelationService; + @Autowired + private DimCustomerService dimCustomerService; @Override public Boolean indexCalculate(CalculateCommonFormDTO formDTO) { @@ -67,14 +71,15 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { formDTO.setMonthId(DimIdGenerator.getMonthDimId(DateUtils.addDateMonths(new Date(), -1))); } //按照客户分组 - List customerIds = new ArrayList<>(); + Set customerIds = new HashSet<>(); if (StringUtils.isBlank(formDTO.getCustomerId())) { + log.error("什么情况下走的这个方法,应该干掉他,因为...=====param:{}",JSON.toJSONString(formDTO)); Result> externalCustomerIdsResult = epmetCommonServiceOpenFeignClient.getExternalCustomerIds(); if (!externalCustomerIdsResult.success()) { log.error("indexCalculate epmetCommonServiceOpenFeignClient.getExternalCustomerIds return fail"); return false; } - customerIds = externalCustomerIdsResult.getData(); + customerIds.addAll(externalCustomerIdsResult.getData()); } else { customerIds.add(formDTO.getCustomerId()); } @@ -95,8 +100,7 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { } return flag; } catch (Exception e) { - e.printStackTrace(); - log.warn("indexCalculate exception:{}",e); + log.warn("indexCalculate late exception",e); log.error("indexCalculate exception,param:{}", JSON.toJSONString(formDTO)); } finally { //清除缓存 @@ -212,12 +216,15 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { public Boolean indexStatistics(IndexStatisticsFormDTO formDTO) { List customerIds = new ArrayList<>(); if (StringUtils.isEmpty(formDTO.getCustomerId())){ - Result> externalCustomerIds = epmetCommonServiceOpenFeignClient.getExternalCustomerIds(); - if (!externalCustomerIds.success()){ - log.error("indexCalculate epmetCommonServiceOpenFeignClient.getExternalCustomerIds return fail"); - return false; - } - customerIds = externalCustomerIds.getData(); + int pageNo = NumConstant.ONE; + int pageSize = NumConstant.ONE_HUNDRED; + List customerIdList = null; + do { + customerIdList = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize); + if (!CollectionUtils.isEmpty(customerIdList)){ + customerIds.addAll(customerIdList); + } + } while (!CollectionUtil.isEmpty(customerIdList) && customerIdList.size() == pageSize); }else { customerIds.add(formDTO.getCustomerId()); } 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 eb849391a9..852fb8c47d 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 @@ -1,17 +1,23 @@ package com.epmet.service.impl; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.constant.PingYinConstant; import com.epmet.constant.ProjectConstant; +import com.epmet.dto.ProjectDTO; import com.epmet.dto.StatsFormDTO; import com.epmet.dto.project.form.MonthProjectListFormDTO; import com.epmet.dto.stats.DimAgencyDTO; +import com.epmet.dto.stats.DimGridDTO; import com.epmet.entity.issue.IssueEntity; +import com.epmet.entity.org.CustomerAgencyEntity; import com.epmet.entity.project.ProjectEntity; 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.CustomerAgencyService; import com.epmet.service.org.CustomerGridService; import com.epmet.service.project.ProjectProcessService; import com.epmet.service.project.ProjectService; @@ -63,6 +69,8 @@ public class StatsProjectServiceImpl implements StatsProjectService { private FactGridProjectMonthlyService factGridProjectMonthlyService; @Autowired private CustomerGridService customerGridService; + @Autowired + private CustomerAgencyService customerAgencyService; /** * @Author sun @@ -108,10 +116,18 @@ public class StatsProjectServiceImpl implements StatsProjectService { DimIdGenerator.DimIdBean dimId = DimIdGenerator.getDimIdBean(date); //2:根据客户Id查询机关维度表数据 - DimAgencyDTO dimAgencyDTO = new DimAgencyDTO(); - dimAgencyDTO.setCustomerId(customerId); - List dimAgencyList = dimAgencyService.getDimAgencyList(dimAgencyDTO); - + //2022.3.3 平阴数据统计时只统计了五个街道的 其他三个街道是上报的,现在这三个街道在小程序也产生了项目(例行工作)数据, + //但是dim维度表不能有这三个街道的组织,因此改查业务库组织列表数据 start sun + List dimAgencyList = new ArrayList<>(); + if (customerId.equals(PingYinConstant.PROD_PING_YIN_CUSTOMER_ID)) { + List agencyList = customerAgencyService.queryAgencyListByCustomerId(customerId); + dimAgencyList = ConvertUtils.sourceToTarget(agencyList, DimAgencyDTO.class); + } else { + DimAgencyDTO dimAgencyDTO = new DimAgencyDTO(); + dimAgencyDTO.setCustomerId(customerId); + dimAgencyList = dimAgencyService.getDimAgencyList(dimAgencyDTO); + } + //2022.3.3 end sun /* //2022.1.12 客户数据量大 调整计算逻辑,一千条已查询,封装数据,将这部分业务数据查询拿到子方法分页查询处理 sun //3:根据客户Id查询项目业务表已结案数据(查询传入日期及之前的数据) @@ -650,7 +666,16 @@ public class StatsProjectServiceImpl implements StatsProjectService { DimIdGenerator.DimIdBean dimId = DimIdGenerator.getDimIdBean(date); //2:根据客户Id查询网格维度表数据 - List dimGridList = dimGridService.getGridListByCustomerId(customerId); + //2022.3.3 平阴数据统计时只统计了五个街道的 其他三个街道是上报的,现在这三个街道在小程序也产生了项目(例行工作)数据, + //但是dim维度表不能有这三个街道的组织,因此改查业务库网格列表数据 start sun + List dimGridList = new ArrayList<>(); + if (customerId.equals(PingYinConstant.PROD_PING_YIN_CUSTOMER_ID)) { + List gridList = customerGridService.gridListByCustomerId(customerId); + dimGridList = ConvertUtils.sourceToTarget(gridList, DimGridEntity.class); + } else { + dimGridList = dimGridService.getGridListByCustomerId(customerId); + } + //2022.3.3 end sun //3:根据客户Id查询项目业务表已结案数据(查询传入日期及之前的数据) ProjectEntity projectEntity = new ProjectEntity(); 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 5894fafa1b..0dd3fd62a9 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 @@ -8,9 +8,11 @@ import com.epmet.dto.org.CustomerStaffGridDTO; import com.epmet.dto.org.GridInfoDTO; import com.epmet.dto.org.form.GridBaseInfoFormDTO; import com.epmet.dto.org.result.CustomerGridDTO; +import com.epmet.dto.stats.DimGridDTO; import com.epmet.dto.user.form.StaffBaseInfoFormDTO; import com.epmet.dto.user.result.GridUserInfoDTO; import com.epmet.entity.org.CustomerGridEntity; +import com.epmet.entity.stats.DimGridEntity; import java.util.Date; import java.util.List; @@ -99,4 +101,10 @@ public interface CustomerGridService extends BaseService { * @Description 查询工作人员所属网格信息 **/ List getStaffGrid(StaffBaseInfoFormDTO formDTO); + + /** + * @Author sun + * @Description 查询客户下有效网格列表 + **/ + List gridListByCustomerId(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 c9ad658627..10bfbc4fd5 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 @@ -12,6 +12,7 @@ import com.epmet.dto.org.CustomerStaffGridDTO; import com.epmet.dto.org.GridInfoDTO; import com.epmet.dto.org.form.GridBaseInfoFormDTO; import com.epmet.dto.org.result.CustomerGridDTO; +import com.epmet.dto.stats.DimGridDTO; import com.epmet.dto.user.form.StaffBaseInfoFormDTO; import com.epmet.dto.user.result.GridUserInfoDTO; import com.epmet.entity.org.CustomerGridEntity; @@ -147,4 +148,13 @@ public class CustomerGridServiceImpl extends BaseServiceImpl gridListByCustomerId(String customerId) { + return customerGridDao.gridListByCustomerId(customerId); + } + } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/StatsStaffPatrolService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/StatsStaffPatrolService.java index 1f1f9cefff..7a50ff5546 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/StatsStaffPatrolService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/StatsStaffPatrolService.java @@ -10,7 +10,7 @@ import java.util.List; */ public interface StatsStaffPatrolService { - Integer delAndInsertBatch(StaffPatrolStatsFormDTO formDTO, List insertList); + Integer insertBatchOrUpdate(StaffPatrolStatsFormDTO formDTO, List insertList); List selectData(String customerId, String yesterdayStr); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/StatsStaffPatrolServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/StatsStaffPatrolServiceImpl.java index 97bc67ed86..32145d5c76 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/StatsStaffPatrolServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/StatsStaffPatrolServiceImpl.java @@ -1,6 +1,5 @@ package com.epmet.service.user.impl; -import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.tools.utils.ConvertUtils; @@ -33,10 +32,8 @@ public class StatsStaffPatrolServiceImpl implements StatsStaffPatrolService { @Transactional(rollbackFor = Exception.class) @Override - public Integer delAndInsertBatch(StaffPatrolStatsFormDTO formDTO, List insertList) { - int delete = statsStaffPatrolRecordDailyDao.deleteInternal(formDTO); - log.debug("delAndInsertBatch delete:{},param:{}", delete, JSON.toJSONString(formDTO)); - return statsStaffPatrolRecordDailyDao.insertBatch(insertList); + public Integer insertBatchOrUpdate(StaffPatrolStatsFormDTO formDTO, List insertList) { + return statsStaffPatrolRecordDailyDao.insertBatchOrUpdate(insertList); } @Override 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 c70278a240..8374e06c4f 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 @@ -197,10 +197,13 @@ dynamic: thread: # 线程池配置 threadPool: - corePoolSize: @thread.pool.core-pool-size@ - maxPoolSize: @thread.pool.max-pool-size@ - queueCapacity: @thread.pool.queue-capacity@ - keepAlive: @thread.pool.keep-alive@ + enableCustomize: @thread.threadPool.enable-customize@ + corePoolSize: @thread.threadPool.core-pool-size@ + maxPoolSize: @thread.threadPool.max-pool-size@ + queueCapacity: @thread.threadPool.queue-capacity@ + keepAliveSeconds: @thread.threadPool.keep-alive-seconds@ + threadNamePrefix: @thread.threadPool.thread-name-prefix@ + rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@ dingTalk: robot: diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/db/migration/V0.0.29__addindex_forcpcability.sql b/epmet-module/data-statistical/data-statistical-server/src/main/resources/db/migration/V0.0.29__addindex_forcpcability.sql new file mode 100644 index 0000000000..48f8576eb6 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/db/migration/V0.0.29__addindex_forcpcability.sql @@ -0,0 +1,5 @@ +-- stat库执行 +alter table fact_origin_topic_main_daily add index `IDX_TOPIC_MAIN_GROUP_ID` (`GROUP_ID`); +alter table fact_origin_project_main_daily add index `IDX_P_MAIN_TOPIC_ID` (`TOPIC_ID`); +alter table fact_origin_issue_main_daily add index `IDX_ISSUE_MAIN_TOPIC_ID` (`TOPIC_ID`); +alter table fact_origin_group_member_daily add index `IDX_GM_GROUP_ID` (`GROUP_ID`); \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginGroupMainDailyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginGroupMainDailyDao.xml index c8c672e57f..4b4e709722 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginGroupMainDailyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginGroupMainDailyDao.xml @@ -382,4 +382,22 @@ GRID_ID + + + + + + + + + + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginIssueLogDailyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginIssueLogDailyDao.xml index 995c6cebad..6c8aa06b96 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginIssueLogDailyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginIssueLogDailyDao.xml @@ -237,4 +237,26 @@ GRID_ID, OPERATION_USER_ID + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectOrgPeriodDailyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectOrgPeriodDailyDao.xml index 9515803a6b..c346dda21a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectOrgPeriodDailyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectOrgPeriodDailyDao.xml @@ -40,12 +40,12 @@ WHERE DEL_FLAG = '0' AND CUSTOMER_ID = #{customerId} - AND (DATE_FORMAT(INFORMED_DATE,"%Y%m%d") >= #{dateId} OR DATE_FORMAT(HANDLED_DATE,"%Y%m%d") >= #{dateId} OR DATE_FORMAT(PERIOD_TILL_REPLY_FIRSTLY,"%Y%m%d") >= #{dateId}) PROJECT_ID = #{item} + AND (DATE_FORMAT(INFORMED_DATE,"%Y%m%d") >= #{dateId} OR DATE_FORMAT(HANDLED_DATE,"%Y%m%d") >= #{dateId} OR DATE_FORMAT(PERIOD_TILL_REPLY_FIRSTLY,"%Y%m%d") >= #{dateId}) SELECT @@ -141,8 +141,8 @@ GROUP BY fp.ORG_ID - - + + - \ No newline at end of file + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginTopicLogDailyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginTopicLogDailyDao.xml index 1d7bc88cab..8e6f652f07 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginTopicLogDailyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginTopicLogDailyDao.xml @@ -143,4 +143,27 @@ AND CUSTOMER_ID = #{customerId} AND MONTH_ID = #{monthId} + + + \ 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 053c6004b0..adcaf8e50d 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 @@ -185,4 +185,17 @@ + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/StatsStaffPatrolRecordDailyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/StatsStaffPatrolRecordDailyDao.xml index 7e00ed10c8..ebf1914935 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/StatsStaffPatrolRecordDailyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/StatsStaffPatrolRecordDailyDao.xml @@ -2,7 +2,7 @@ - + insert into stats_staff_patrol_record_daily ( ID, @@ -63,6 +63,11 @@ ON DUPLICATE KEY UPDATE PATROL_TOTAL = values(PATROL_TOTAL), TOTAL_TIME = values(TOTAL_TIME), + LATEST_PATROL_STATUS = values(LATEST_PATROL_STATUS), + LATEST_PATROL_TIME = values(LATEST_PATROL_TIME), + REPORT_PROJECT_COUNT = values(REPORT_PROJECT_COUNT), + ROUTINE_WORK_COUNT = values(ROUTINE_WORK_COUNT), + UPDATED_TIME = now(), UPDATED_BY = VALUES(UPDATED_BY) diff --git a/epmet-module/epmet-activiti/epmet-activiti-server/pom.xml b/epmet-module/epmet-activiti/epmet-activiti-server/pom.xml index fa8fd80209..3788524034 100644 --- a/epmet-module/epmet-activiti/epmet-activiti-server/pom.xml +++ b/epmet-module/epmet-activiti/epmet-activiti-server/pom.xml @@ -185,6 +185,15 @@ true false + + + true + 5 + 8 + 20 + 60 + epmet-activiti + callerRunsPolicy @@ -219,6 +228,15 @@ false false + + + true + 5 + 8 + 20 + 60 + epmet-activiti + callerRunsPolicy @@ -250,6 +268,15 @@ true true + + + true + 5 + 8 + 20 + 60 + epmet-activiti + callerRunsPolicy @@ -281,6 +308,15 @@ true true + + + true + 5 + 8 + 20 + 60 + epmet-activiti + callerRunsPolicy diff --git a/epmet-module/epmet-activiti/epmet-activiti-server/src/main/resources/bootstrap.yml b/epmet-module/epmet-activiti/epmet-activiti-server/src/main/resources/bootstrap.yml index f31026085f..b39474ad3d 100644 --- a/epmet-module/epmet-activiti/epmet-activiti-server/src/main/resources/bootstrap.yml +++ b/epmet-module/epmet-activiti/epmet-activiti-server/src/main/resources/bootstrap.yml @@ -109,3 +109,14 @@ hystrix: ribbon: ReadTimeout: 300000 ConnectTimeout: 300000 + +thread: + # 线程池配置 + threadPool: + enableCustomize: @thread.threadPool.enable-customize@ + corePoolSize: @thread.threadPool.core-pool-size@ + maxPoolSize: @thread.threadPool.max-pool-size@ + queueCapacity: @thread.threadPool.queue-capacity@ + keepAliveSeconds: @thread.threadPool.keep-alive-seconds@ + threadNamePrefix: @thread.threadPool.thread-name-prefix@ + rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@ diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/constant/ImportTaskConstants.java b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/constants/ImportTaskConstants.java similarity index 54% rename from epmet-user/epmet-user-client/src/main/java/com/epmet/constant/ImportTaskConstants.java rename to epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/constants/ImportTaskConstants.java index 685e80a39a..6212a35cb6 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/constant/ImportTaskConstants.java +++ b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/constants/ImportTaskConstants.java @@ -1,13 +1,20 @@ -package com.epmet.constant; +package com.epmet.constants; /** * 导入任务的业务类型常量 */ public interface ImportTaskConstants { /** - * 居民 + * 业务类型:居民 */ String BIZ_TYPE_RESI = "resi"; + String BIZ_TYPE_NEIGHBOR_HOOD = "neighborHood"; + String BIZ_TYPE_BUILDING = "building"; + String BIZ_TYPE_HOUSE = "house"; + String BIZ_TYPE_PARTY_MEMBER = "party_member"; + String BIZ_TYPE_COMMUNITY_SELF_ORG = "community_self_org"; + String BIZ_TYPE_PARTY_UNIT = "party_unit"; + String BIZ_TYPE_PARTY_ACTIVITY = "party_activity"; /** * 处理状态:处理中 diff --git a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/ImportTaskCommonFormDTO.java b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/ImportTaskCommonFormDTO.java new file mode 100644 index 0000000000..9eea1fe6c2 --- /dev/null +++ b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/ImportTaskCommonFormDTO.java @@ -0,0 +1,55 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.dto.form.PageFormDTO; +import com.epmet.commons.tools.validator.group.QueryGroup; +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +@Data +public class ImportTaskCommonFormDTO extends PageFormDTO { + + public interface Create {} + public interface Finish {} + + /** + * 原始文件名 + */ + @NotBlank(message = "原始文件名必填", groups = { Create.class }) + private String originFileName; + + /** + * 操作者ID + */ + @NotBlank(message = "操作者ID必填", groups = { Create.class, Finish.class, QueryGroup.class}) + private String operatorId; + + /** + * 业务类型 + */ + @NotBlank(message = "业务类型必填", groups = { Create.class }) + private String bizType; + + /** + * 任务ID + */ + @NotBlank(message = "任务ID必填", groups = { Finish.class }) + private String taskId; + + /** + * 处理状态 + */ + @NotBlank(message = "处理状态必填", groups = { Finish.class }) + private String processStatus; + + /** + * 结果文件 url + */ + private String resultDescFilePath; + + /** + * 结果描述文本 + */ + private String resultDesc; + +} diff --git a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/ImportTaskCommonResultDTO.java b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/ImportTaskCommonResultDTO.java new file mode 100644 index 0000000000..9812f1abbc --- /dev/null +++ b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/ImportTaskCommonResultDTO.java @@ -0,0 +1,43 @@ +package com.epmet.dto.result; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.Date; + +@Data +@NoArgsConstructor +public class ImportTaskCommonResultDTO implements Serializable { + public ImportTaskCommonResultDTO(String taskId) { + this.taskId = taskId; + } + + private String taskId; + + /** + * 原始文件名 + */ + private String originFileName; + + /** + * 业务类型。resi:居民;楼栋:building;房屋:house。依次补充 + */ + private String bizType; + + /** + * 处理状态。processing:处理中;finished:完成;导入失败:finished_fail + */ + private String processStatus; + + /** + * 开始导入的时间 + */ + private Date startTime; + + /** + * 失败文件地址 + */ + private String resultDescFile; + +} diff --git a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/EpmetCommonServiceOpenFeignClient.java b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/EpmetCommonServiceOpenFeignClient.java index 1fe124a14f..9ddd2d710d 100644 --- a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/EpmetCommonServiceOpenFeignClient.java +++ b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/EpmetCommonServiceOpenFeignClient.java @@ -4,12 +4,12 @@ import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.form.*; import com.epmet.dto.result.*; -import com.epmet.feign.fallback.EpmetCommonServiceOpenFeignClientFallback; import com.epmet.feign.fallback.EpmetCommonServiceOpenFeignClientFallbackFactory; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; import java.util.List; import java.util.Map; @@ -124,4 +124,20 @@ public interface EpmetCommonServiceOpenFeignClient { **/ @PostMapping(value = "commonservice/areacode/addareacode", consumes = MediaType.APPLICATION_JSON_VALUE) Result addAreaCode(AddAreaCodeFormDTO formDTO); + + /** + * 创建导入任务 + * @param input + * @return + */ + @RequestMapping("/commonservice/import-task/create") + Result createImportTask(@RequestBody ImportTaskCommonFormDTO input); + + /** + * 结束导入任务 + * @param input + * @return + */ + @RequestMapping("/commonservice/import-task/finish") + Result finishImportTask(@RequestBody ImportTaskCommonFormDTO input); } diff --git a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallback.java b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallback.java index 4afee3fa08..c3c62d64da 100644 --- a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallback.java +++ b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallback.java @@ -111,4 +111,14 @@ public class EpmetCommonServiceOpenFeignClientFallback implements EpmetCommonSer public Result addAreaCode(AddAreaCodeFormDTO formDTO) { return ModuleUtils.feignConError(ServiceConstant.EPMET_COMMON_SERVICE, "addAreaCode", formDTO); } + + @Override + public Result createImportTask(ImportTaskCommonFormDTO input) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_COMMON_SERVICE, "createImportTask", input); + } + + @Override + public Result finishImportTask(ImportTaskCommonFormDTO input) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_COMMON_SERVICE, "finishImportTask", input); + } } diff --git a/epmet-module/epmet-common-service/common-service-server/pom.xml b/epmet-module/epmet-common-service/common-service-server/pom.xml index 38a3ccbbbd..852c9da379 100644 --- a/epmet-module/epmet-common-service/common-service-server/pom.xml +++ b/epmet-module/epmet-common-service/common-service-server/pom.xml @@ -139,6 +139,15 @@ SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd + + + true + 5 + 8 + 20 + 60 + common-service + callerRunsPolicy @@ -187,6 +196,15 @@ SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd + + + true + 5 + 8 + 20 + 60 + common-service + callerRunsPolicy @@ -233,6 +251,15 @@ SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd + + + true + 5 + 8 + 20 + 60 + common-service + callerRunsPolicy @@ -276,6 +303,15 @@ SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd + + + true + 5 + 8 + 20 + 60 + common-service + callerRunsPolicy diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ImportTaskController.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ImportTaskController.java new file mode 100644 index 0000000000..8af4083542 --- /dev/null +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ImportTaskController.java @@ -0,0 +1,82 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.QueryGroup; +import com.epmet.dto.form.ImportTaskCommonFormDTO; +import com.epmet.dto.result.ImportTaskCommonResultDTO; +import com.epmet.service.ImportTaskService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequestMapping("import-task") +public class ImportTaskController { + + @Autowired + private ImportTaskService importTaskService; + + /** + * desc:分页获取个人导入记录 + * @param tokenDto + * @return + */ + @RequestMapping("page") + public Result> list(@LoginUser TokenDto tokenDto, @RequestBody ImportTaskCommonFormDTO param) { + //tokenDto.setUserId("d8dfc6c1fa2538976059f3900036d419"); + param.setOperatorId(tokenDto.getUserId()); + ValidatorUtils.validateEntity(param, QueryGroup.class); + return new Result().ok(importTaskService.page(param)); + } + + /** + * 创建导入任务 + * @param input + * @return + */ + @RequestMapping("create") + public Result createTask(@RequestBody ImportTaskCommonFormDTO input) { + ValidatorUtils.validateEntity(input, ImportTaskCommonFormDTO.Create.class); + String operatorId = input.getOperatorId(); + String bizType = input.getBizType(); + String originFileName = input.getOriginFileName(); + + String taskId = importTaskService.createProcessTask(operatorId, bizType, originFileName); + ImportTaskCommonResultDTO ro = new ImportTaskCommonResultDTO(taskId); + return new Result().ok(ro); + } + + /** + * 结束任务 + * @param input + * @return + */ + @RequestMapping("finish") + public Result finishTask(@RequestBody ImportTaskCommonFormDTO input) { + ValidatorUtils.validateEntity(input, ImportTaskCommonFormDTO.Finish.class); + Boolean finished = importTaskService.finish(input.getTaskId(), input.getProcessStatus(), input.getOperatorId(), input.getResultDescFilePath(), input.getResultDesc()); + if (!finished) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), + "失败,请确认任务是否存在,以及是否已完成", + "失败,请确认任务是否存在,以及是否已完成"); + } + return new Result(); + } + + /** + * 检查是否有正在执行的任务。 + * @param bizType 业务类型,非必填,不传则任意一种导入正在执行都会返回true + * @return + */ + @GetMapping("processing-check") + public Result processingTaskCheck(@RequestParam(value = "biz_type", required = false) String bizType) { + Boolean r = importTaskService.processingTaskCheck(bizType); + return new Result().ok(r); + } + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/ImportTaskDao.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/ImportTaskDao.java similarity index 100% rename from epmet-user/epmet-user-server/src/main/java/com/epmet/dao/ImportTaskDao.java rename to epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/ImportTaskDao.java diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/ImportTaskEntity.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/ImportTaskEntity.java similarity index 88% rename from epmet-user/epmet-user-server/src/main/java/com/epmet/entity/ImportTaskEntity.java rename to epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/ImportTaskEntity.java index 742c6cc93e..0602a42963 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/ImportTaskEntity.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/ImportTaskEntity.java @@ -1,7 +1,6 @@ package com.epmet.entity; import com.baomidou.mybatisplus.annotation.TableName; - import com.epmet.commons.mybatis.entity.BaseEpmetEntity; import lombok.Data; import lombok.EqualsAndHashCode; @@ -21,6 +20,16 @@ public class ImportTaskEntity extends BaseEpmetEntity { private static final long serialVersionUID = 1L; + /** + * 客户ID + */ + private String customerId; + + /** + * 原始文件名 + */ + private String originFileName; + /** * 业务类型。resi:居民;楼栋:building;房屋:house。依次补充 */ diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ImportTaskService.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ImportTaskService.java new file mode 100644 index 0000000000..918643d8f2 --- /dev/null +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ImportTaskService.java @@ -0,0 +1,54 @@ +package com.epmet.service; + + +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.form.ImportTaskCommonFormDTO; +import com.epmet.dto.result.ImportTaskCommonResultDTO; + +/** + * + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-02-15 + */ +public interface ImportTaskService { + +// /** +// * 检查指定类型该用户是否存在处理中的导入任务 +// * @param operatorId 操作者ID +// * @param bizType 业务类型。resi:居民 +// * @return +// */ +// boolean existsProcessingTask(String operatorId, String bizType); + + /** + * 创建处理任务 + * @param operatorId + * @param bizType + * @param originFileName 原始文件名 + */ + String createProcessTask(String operatorId, String bizType, String originFileName); + + /** + * 结束导入 + * @param taskId 任务id + * @param processStatus 处理状态 + * @param resultDescFile 结果描述文件 + * @param resultDesc 结果描述文本 + */ + Boolean finish(String taskId, String processStatus, String operatorId, String resultDescFile, String resultDesc); + + /** + * desc:分页获取个人导入记录 + * @param param + * @return + */ + PageData page(ImportTaskCommonFormDTO param); + + /** + * 检查是否有正在执行的任务 + * @param bizType + * @return + */ + Boolean processingTaskCheck(String bizType); +} diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalAppServiceImpl.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalAppServiceImpl.java index 12f84f3456..b6dcf98dcf 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalAppServiceImpl.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalAppServiceImpl.java @@ -187,7 +187,6 @@ public class ExternalAppServiceImpl implements ExternalAppService { @Override public List getCustomerIds() { - return externalAppDao.getCustomerIds(); } @@ -224,4 +223,4 @@ public class ExternalAppServiceImpl implements ExternalAppService { return appIdInfoResultDTO; } -} \ No newline at end of file +} diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ImportTaskServiceImpl.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ImportTaskServiceImpl.java new file mode 100644 index 0000000000..cb28fecad8 --- /dev/null +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ImportTaskServiceImpl.java @@ -0,0 +1,123 @@ +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.commons.tools.security.user.LoginUserUtil; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.constants.ImportTaskConstants; +import com.epmet.dao.ImportTaskDao; +import com.epmet.dto.form.ImportTaskCommonFormDTO; +import com.epmet.dto.result.ImportTaskCommonResultDTO; +import com.epmet.entity.ImportTaskEntity; +import com.epmet.service.ImportTaskService; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-02-15 + */ +@Service +public class ImportTaskServiceImpl implements ImportTaskService { + + @Autowired + private ImportTaskDao importRecordDao; + + @Autowired + private LoginUserUtil loginUserUtil; + +// /** +// * 该用户,该业务类型,是否有正在处理的导入任务 +// * @param operatorId 操作者ID +// * @param bizType 业务类型。resi:居民 +// * @return +// */ +// @Override +// public boolean existsProcessingTask(String operatorId, String bizType) { +// LambdaQueryWrapper query = new LambdaQueryWrapper<>(); +// query.eq(ImportTaskEntity::getOperatorId, operatorId); +// query.eq(ImportTaskEntity::getBizType, bizType); +// query.eq(ImportTaskEntity::getProcessStatus, ImportTaskConstants.PROCESS_STATUS_PROCESSING); +// +// return importRecordDao.selectCount(query) > 0; +// } + + /** + * 检查是否有正在执行的任务 + * @param operatorId + * @param bizType + * @return + */ + public boolean existsProcessingTask(String operatorId, String bizType) { + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + query.eq(ImportTaskEntity::getOperatorId, operatorId); + query.eq(ImportTaskEntity::getBizType, bizType); + query.eq(ImportTaskEntity::getProcessStatus, ImportTaskConstants.PROCESS_STATUS_PROCESSING); + + return importRecordDao.selectCount(query) > 0; + } + + @Override + public String createProcessTask(String operatorId, String bizType, String originFileName) { + if (existsProcessingTask(operatorId, bizType)) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), + "存在进行中的导入", + "存在进行中的导入"); + } + + ImportTaskEntity importRecord = new ImportTaskEntity(); + importRecord.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_PROCESSING); + importRecord.setOperatorId(operatorId); + importRecord.setBizType(bizType); + importRecord.setCustomerId(loginUserUtil.getLoginUserCustomerId()); + importRecord.setStartTime(new Date()); + importRecord.setOriginFileName(originFileName); + + importRecordDao.insert(importRecord); + return importRecord.getId(); + } + + @Override + public Boolean finish(String taskId, String processStatus, String operatorId, String resultDescFile, String resultDesc) { + return importRecordDao.finish(taskId, processStatus, operatorId, resultDesc, resultDescFile) > 0; + } + + @Override + public PageData page(ImportTaskCommonFormDTO param) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(ImportTaskEntity::getOperatorId,param.getOperatorId()) + .orderByDesc(ImportTaskEntity::getStartTime); + Page page = PageHelper.startPage(param.getPageNo(), param.getPageSize(), param.isPage()).doSelectPage(() -> { + importRecordDao.selectList(queryWrapper); + }); + List list = new ArrayList<>(); + page.getResult().forEach(item->{ + ImportTaskCommonResultDTO record = ConvertUtils.sourceToTarget(item, ImportTaskCommonResultDTO.class); + record.setTaskId(item.getId()); + list.add(record); + }); + return new PageData<>(list,page.getTotal()); + } + + @Override + public Boolean processingTaskCheck(String bizType) { + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + if (StringUtils.isNotBlank(bizType)) { + query.eq(ImportTaskEntity::getBizType, bizType); + } + query.eq(ImportTaskEntity::getProcessStatus, ImportTaskConstants.PROCESS_STATUS_PROCESSING); + + return importRecordDao.selectCount(query) > 0; + } +} diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/resources/bootstrap.yml b/epmet-module/epmet-common-service/common-service-server/src/main/resources/bootstrap.yml index 3da9f56074..1900bf9009 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/resources/bootstrap.yml +++ b/epmet-module/epmet-common-service/common-service-server/src/main/resources/bootstrap.yml @@ -140,3 +140,14 @@ shutdown: graceful: enable: true #是否开启优雅停机 waitTimeSecs: 30 # 优雅停机等待时间,超过30秒,发出告警 + +thread: + # 线程池配置 + threadPool: + enableCustomize: @thread.threadPool.enable-customize@ + corePoolSize: @thread.threadPool.core-pool-size@ + maxPoolSize: @thread.threadPool.max-pool-size@ + queueCapacity: @thread.threadPool.queue-capacity@ + keepAliveSeconds: @thread.threadPool.keep-alive-seconds@ + threadNamePrefix: @thread.threadPool.thread-name-prefix@ + rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@ diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/resources/db/migration/V0.0.12__createImportTask.sql b/epmet-module/epmet-common-service/common-service-server/src/main/resources/db/migration/V0.0.12__createImportTask.sql new file mode 100644 index 0000000000..437af39520 --- /dev/null +++ b/epmet-module/epmet-common-service/common-service-server/src/main/resources/db/migration/V0.0.12__createImportTask.sql @@ -0,0 +1,19 @@ +CREATE TABLE `import_task` ( + `ID` varchar(64) NOT NULL COMMENT 'ID', + `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户ID', + `ORIGIN_FILE_NAME` varchar(128) NOT NULL COMMENT '原始文件名', + `BIZ_TYPE` varchar(32) NOT NULL COMMENT '业务类型。【resi:居民;neighborHood:小区;building:楼栋;house:房屋;party_member:党员;society_org:社会组织;community_self_org:社区自组织】依次补充', + `PROCESS_STATUS` varchar(32) NOT NULL COMMENT '处理状态。processing:处理中;finished_success:成功;finished_unsuccess:未完全成功', + `OPERATOR_ID` varchar(64) NOT NULL COMMENT '谁导入的', + `START_TIME` datetime NOT NULL COMMENT '开始导入的时间', + `RESULT_DESC_FILE` varchar(255) DEFAULT NULL COMMENT '导入失败结果描述文件', + `RESULT_DESC` varchar(255) DEFAULT NULL COMMENT '导入结果描述,可以输入任何描述信息', + `DEL_FLAG` tinyint(1) NOT NULL COMMENT '删除标识:0.未删除 1.已删除', + `REVISION` int(11) NOT NULL COMMENT '乐观锁', + `CREATED_BY` varchar(64) NOT NULL COMMENT '创建人', + `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(64) NOT NULL COMMENT '更新人', + `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 + diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/resources/db/migration/V0.0.13__ImportTaskCommentModify.sql b/epmet-module/epmet-common-service/common-service-server/src/main/resources/db/migration/V0.0.13__ImportTaskCommentModify.sql new file mode 100644 index 0000000000..de7c4f70a0 --- /dev/null +++ b/epmet-module/epmet-common-service/common-service-server/src/main/resources/db/migration/V0.0.13__ImportTaskCommentModify.sql @@ -0,0 +1 @@ +alter table import_task modify column PROCESS_STATUS varchar(32) comment '处理状态。processing:处理中;finished_success:成功;finished_fail:未完全成功' \ No newline at end of file diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalAppDao.xml b/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalAppDao.xml index fbc74db7ff..8f401cb0f5 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalAppDao.xml +++ b/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalAppDao.xml @@ -66,7 +66,7 @@ @@ -84,4 +84,4 @@ - \ No newline at end of file + diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/ImportTaskDao.xml b/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ImportTaskDao.xml similarity index 94% rename from epmet-user/epmet-user-server/src/main/resources/mapper/ImportTaskDao.xml rename to epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ImportTaskDao.xml index edc56fa5c7..fce694cb16 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/ImportTaskDao.xml +++ b/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ImportTaskDao.xml @@ -5,6 +5,7 @@ + diff --git a/epmet-module/epmet-ext/epmet-ext-server/pom.xml b/epmet-module/epmet-ext/epmet-ext-server/pom.xml index e0d4e979b0..c7c3165af0 100644 --- a/epmet-module/epmet-ext/epmet-ext-server/pom.xml +++ b/epmet-module/epmet-ext/epmet-ext-server/pom.xml @@ -226,6 +226,15 @@ SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd + + + true + 5 + 8 + 20 + 60 + epmet-ext + callerRunsPolicy @@ -267,6 +276,15 @@ SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd + + + true + 5 + 8 + 20 + 60 + epmet-ext + callerRunsPolicy @@ -308,6 +326,15 @@ SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd + + + true + 5 + 8 + 20 + 60 + epmet-ext + callerRunsPolicy @@ -350,6 +377,15 @@ SEC95f4f40b533ad379ea6a6d1af6dd37029383cfe1b7cd96dfac2678be2c1c3ed1 + + + true + 5 + 8 + 20 + 60 + epmet-ext + callerRunsPolicy diff --git a/epmet-module/epmet-ext/epmet-ext-server/src/main/resources/bootstrap.yml b/epmet-module/epmet-ext/epmet-ext-server/src/main/resources/bootstrap.yml index bf9a797c20..d4e3824a5d 100644 --- a/epmet-module/epmet-ext/epmet-ext-server/src/main/resources/bootstrap.yml +++ b/epmet-module/epmet-ext/epmet-ext-server/src/main/resources/bootstrap.yml @@ -117,3 +117,14 @@ shutdown: openApi: accessToken: expire: 7200 + +thread: + # 线程池配置 + threadPool: + enableCustomize: @thread.threadPool.enable-customize@ + corePoolSize: @thread.threadPool.core-pool-size@ + maxPoolSize: @thread.threadPool.max-pool-size@ + queueCapacity: @thread.threadPool.queue-capacity@ + keepAliveSeconds: @thread.threadPool.keep-alive-seconds@ + threadNamePrefix: @thread.threadPool.thread-name-prefix@ + rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@ diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/IcActivityServiceRelationDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/IcActivityServiceRelationDTO.java new file mode 100644 index 0000000000..c5f7f33641 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/IcActivityServiceRelationDTO.java @@ -0,0 +1,85 @@ +package com.epmet.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * 联建活动与服务事项关联表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-02-21 + */ +@Data +public class IcActivityServiceRelationDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 客户id + */ + private String customerId; + + /** + * 组织ID + */ + private String agencyId; + + /** + * 组织的所有上级 + */ + private String pids; + + /** + * 活动ID + */ + private String activityId; + + /** + * act_info表ID + */ + private String actId; + + /** + * 服务事项 + */ + private String serviceMatter; + + /** + * 删除标识 0未删除、1已删除 + */ + private String 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/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/IcActivityUnitRelationDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/IcActivityUnitRelationDTO.java new file mode 100644 index 0000000000..8af5942af0 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/IcActivityUnitRelationDTO.java @@ -0,0 +1,89 @@ +package com.epmet.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 联建活动与单位关联表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-02-21 + */ +@Data +public class IcActivityUnitRelationDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 客户id + */ + private String customerId; + + /** + * 组织ID + */ + private String agencyId; + + /** + * 组织的所有上级 + */ + private String pids; + + /** + * 活动ID + */ + private String activityId; + + /** + * act_info表ID + */ + private String actId; + + /** + * 单位ID + */ + private String unitId; + + /** + * 服务事项 + */ + private String serviceMatter; + + /** + * 删除标识 0未删除、1已删除 + */ + private String 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/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/IcPartyActivityDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/IcPartyActivityDTO.java index 81edd97c20..bcb04fb6ef 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/IcPartyActivityDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/IcPartyActivityDTO.java @@ -19,12 +19,15 @@ package com.epmet.dto; import com.epmet.commons.tools.validator.group.AddGroup; import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotEmpty; import java.io.Serializable; import java.util.Date; +import java.util.List; /** @@ -46,35 +49,44 @@ public class IcPartyActivityDTO implements Serializable { /** * 客户id */ + @JsonIgnore private String customerId; /** * 组织ID */ + @JsonIgnore private String agencyId; /** * 组织的所有上级 */ + @JsonIgnore private String pids; /** * act_info表ID */ + @JsonIgnore private String actId; + private String unitId; + private String unitName; /** * 单位ID */ - @NotBlank(message = "单位不能为空",groups = AddGroup.class) - private String unitId; - private String unitName; + @NotEmpty(message = "单位不能为空",groups = AddGroup.class) + private List unitIdList; + private List unitNameList; + + private String serviceMatter; + private String serviceMatterName; /** * 服务事项 */ - @NotBlank(message = "服务事项不能为空",groups = AddGroup.class) - private String serviceMatter; - private String serviceMatterName; + @NotEmpty(message = "服务事项不能为空",groups = AddGroup.class) + private List serviceMatterList; + private List serviceMatterNameList; /** * 活动标题 */ @@ -131,31 +143,37 @@ public class IcPartyActivityDTO implements Serializable { /** * 删除标识 0未删除、1已删除 */ + @JsonIgnore private String delFlag; /** * 乐观锁 */ + @JsonIgnore private Integer revision; /** * 创建人 */ + @JsonIgnore private String createdBy; /** * 创建时间 */ + @JsonIgnore private Date createdTime; /** * 更新人 */ + @JsonIgnore private String updatedBy; /** * 更新时间 */ + @JsonIgnore private Date updatedTime; } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/LatestActServiceRelationDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/LatestActServiceRelationDTO.java new file mode 100644 index 0000000000..b25b10f432 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/LatestActServiceRelationDTO.java @@ -0,0 +1,79 @@ +package com.epmet.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 联建活动与服务事项关联表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-02-21 + */ +@Data +public class LatestActServiceRelationDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 客户id + */ + private String customerId; + + /** + * 组织ID + */ + private String agencyId; + + /** + * 组织的所有上级 + */ + private String pids; + + /** + * latest_act_info表ID + */ + private String actId; + + /** + * 服务事项 + */ + private String serviceMatter; + + /** + * 删除标识 0未删除、1已删除 + */ + private String 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/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/LatestActUnitRelationDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/LatestActUnitRelationDTO.java new file mode 100644 index 0000000000..534053660d --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/LatestActUnitRelationDTO.java @@ -0,0 +1,84 @@ +package com.epmet.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 联建活动与单位关联表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-02-21 + */ +@Data +public class LatestActUnitRelationDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 客户id + */ + private String customerId; + + /** + * 组织ID + */ + private String agencyId; + + /** + * 组织的所有上级 + */ + private String pids; + + /** + * latest_act_info表ID + */ + private String actId; + + /** + * 单位ID + */ + private String unitId; + + /** + * 服务事项 + */ + private String serviceMatter; + + /** + * 删除标识 0未删除、1已删除 + */ + private String 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/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/DraftActInfoFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/DraftActInfoFormDTO.java index f00ebe792f..a88d1d393f 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/DraftActInfoFormDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/DraftActInfoFormDTO.java @@ -170,7 +170,7 @@ public class DraftActInfoFormDTO implements Serializable { * 联建单位 */ private String unitId; - + private List unitIdList; /** * 活动目标 */ @@ -180,5 +180,6 @@ public class DraftActInfoFormDTO implements Serializable { * 服务事项 */ private String serviceMatter; + private List serviceMatterList; } diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/PublishActInfoFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/PublishActInfoFormDTO.java index ef1f3c3e19..099fa38e60 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/PublishActInfoFormDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/PublishActInfoFormDTO.java @@ -5,10 +5,7 @@ import lombok.Data; import org.hibernate.validator.constraints.Length; import javax.validation.Valid; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; +import javax.validation.constraints.*; import java.io.Serializable; import java.math.BigDecimal; import java.util.List; @@ -200,9 +197,9 @@ public class PublishActInfoFormDTO implements Serializable { /** * 联建单位 */ - @NotBlank(message = "联建单位不能为空", groups = {AddPartyActivityGroup.class}) private String unitId; - + @NotEmpty(message = "联建单位不能为空", groups = {AddPartyActivityGroup.class}) + private List unitIdList; /** * 活动目标 */ @@ -212,6 +209,7 @@ public class PublishActInfoFormDTO implements Serializable { /** * 服务事项 */ - @NotBlank(message = "服务事项不能为空", groups = {AddPartyActivityGroup.class}) private String serviceMatter; + @NotEmpty(message = "服务事项不能为空", groups = {AddPartyActivityGroup.class}) + private List serviceMatterList; } diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/RePublishFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/RePublishFormDTO.java index b093e9dcba..587a60a0ff 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/RePublishFormDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/RePublishFormDTO.java @@ -5,10 +5,7 @@ import lombok.Data; import org.hibernate.validator.constraints.Length; import javax.validation.Valid; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; +import javax.validation.constraints.*; import java.io.Serializable; import java.math.BigDecimal; import java.util.List; @@ -206,8 +203,9 @@ public class RePublishFormDTO implements Serializable { /** * 联建单位 */ - @NotBlank(message = "联建单位不能为空", groups = {AddPartyActivityGroup.class}) private String unitId; + @NotEmpty(message = "联建单位不能为空", groups = {PublishActInfoFormDTO.AddPartyActivityGroup.class}) + private List unitIdList; /** * 活动目标 @@ -218,6 +216,7 @@ public class RePublishFormDTO implements Serializable { /** * 服务事项 */ - @NotBlank(message = "服务事项不能为空", groups = {AddPartyActivityGroup.class}) private String serviceMatter; + @NotEmpty(message = "服务事项不能为空", groups = {PublishActInfoFormDTO.AddPartyActivityGroup.class}) + private List serviceMatterList; } diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/resi/ResiActDetailResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/resi/ResiActDetailResultDTO.java index a232ebdf33..aa33f41e69 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/resi/ResiActDetailResultDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/resi/ResiActDetailResultDTO.java @@ -186,6 +186,8 @@ public class ResiActDetailResultDTO implements Serializable { */ private String unitId; private String unitName; + private List unitIdList; + private List unitNameList; /** * 活动目标 */ @@ -196,4 +198,6 @@ public class ResiActDetailResultDTO implements Serializable { */ private String serviceMatter; private String serviceMatterName; + private List serviceMatterList; + private List serviceMatterNameList; } diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/ActPreviewResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/ActPreviewResultDTO.java index 5e3df9d139..caeed480d5 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/ActPreviewResultDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/ActPreviewResultDTO.java @@ -1,6 +1,7 @@ package com.epmet.dto.result.work; import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Data; import java.io.Serializable; @@ -74,7 +75,12 @@ public class ActPreviewResultDTO implements Serializable { * 主办方名称 */ private String sponsorName; - + @JsonIgnore + private String sponsorType; + @JsonIgnore + private String sponsorId; + @JsonIgnore + private String pid; /** * 联系人 */ @@ -100,6 +106,8 @@ public class ActPreviewResultDTO implements Serializable { */ private String unitId; private String unitName; + private List unitIdList; + private List unitNameList; /** * 活动目标 */ @@ -110,4 +118,6 @@ public class ActPreviewResultDTO implements Serializable { */ private String serviceMatter; private String serviceMatterName; + private List serviceMatterList; + private List serviceMatterNameList; } diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/CanceledActDetailResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/CanceledActDetailResultDTO.java index 3da7fade52..764d3ffabf 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/CanceledActDetailResultDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/CanceledActDetailResultDTO.java @@ -158,6 +158,8 @@ public class CanceledActDetailResultDTO implements Serializable { */ private String unitId; private String unitName; + private List unitIdList; + private List unitNameList; /** * 活动目标 */ @@ -168,4 +170,6 @@ public class CanceledActDetailResultDTO implements Serializable { */ private String serviceMatter; private String serviceMatterName; + private List serviceMatterList; + private List serviceMatterNameList; } diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/FinishedActDetailResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/FinishedActDetailResultDTO.java index 3e4bfbdc9a..5bf9c4bfb1 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/FinishedActDetailResultDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/FinishedActDetailResultDTO.java @@ -147,6 +147,8 @@ public class FinishedActDetailResultDTO implements Serializable { */ private String unitId; private String unitName; + private List unitIdList; + private List unitNameList; /** * 活动目标 */ @@ -157,4 +159,6 @@ public class FinishedActDetailResultDTO implements Serializable { */ private String serviceMatter; private String serviceMatterName; + private List serviceMatterList; + private List serviceMatterNameList; } diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/InProgressActDetailResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/InProgressActDetailResultDTO.java index 8dc4ad2fb2..03fdbf576b 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/InProgressActDetailResultDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/InProgressActDetailResultDTO.java @@ -142,6 +142,8 @@ public class InProgressActDetailResultDTO implements Serializable { */ private String unitId; private String unitName; + private List unitIdList; + private List unitNameList; /** * 活动目标 */ @@ -152,4 +154,6 @@ public class InProgressActDetailResultDTO implements Serializable { */ private String serviceMatter; private String serviceMatterName; + private List serviceMatterList; + private List serviceMatterNameList; } diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/LatestDraftActInfoResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/LatestDraftActInfoResultDTO.java index c4a250df92..70b4c5754f 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/LatestDraftActInfoResultDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/LatestDraftActInfoResultDTO.java @@ -176,7 +176,7 @@ public class LatestDraftActInfoResultDTO implements Serializable { * 联建单位 */ private String unitId; - + private List unitIdList; /** * 活动目标 */ @@ -186,4 +186,5 @@ public class LatestDraftActInfoResultDTO implements Serializable { * 服务事项 */ private String serviceMatter; + private List serviceMatterList; } diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/ReEditActInfoResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/ReEditActInfoResultDTO.java index a360fd53c3..367ab0ec1d 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/ReEditActInfoResultDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/ReEditActInfoResultDTO.java @@ -159,6 +159,8 @@ public class ReEditActInfoResultDTO implements Serializable { */ private String unitId; private String unitName; + private List unitIdList; + private List unitNameList; /** * 活动目标 */ @@ -169,4 +171,6 @@ public class ReEditActInfoResultDTO implements Serializable { */ private String serviceMatter; private String serviceMatterName; + private List serviceMatterList; + private List serviceMatterNameList; } diff --git a/epmet-module/epmet-heart/epmet-heart-server/pom.xml b/epmet-module/epmet-heart/epmet-heart-server/pom.xml index 1309074311..59e233e9e5 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/pom.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/pom.xml @@ -94,6 +94,18 @@ epmet-commons-rocketmq 2.0.0 + + com.epmet + common-service-client + 2.0.0 + compile + + + com.epmet + epmet-oss-client + 2.0.0 + compile + @@ -162,6 +174,15 @@ true 192.168.1.140:9876;192.168.1.141:9876 + + + true + 5 + 8 + 20 + 60 + epmet-heart + callerRunsPolicy @@ -209,6 +230,15 @@ false 192.168.1.140:9876;192.168.1.141:9876 + + + true + 5 + 8 + 20 + 60 + epmet-heart + callerRunsPolicy @@ -256,6 +286,15 @@ true 192.168.10.161:9876 + + + true + 5 + 8 + 20 + 60 + epmet-heart + callerRunsPolicy @@ -303,6 +342,15 @@ true 192.168.11.187:9876;192.168.11.184:9876 + + + true + 5 + 8 + 20 + 60 + epmet-heart + callerRunsPolicy diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcCommunitySelfOrganizationController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcCommunitySelfOrganizationController.java index 5dc6a27d04..bbea13e834 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcCommunitySelfOrganizationController.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcCommunitySelfOrganizationController.java @@ -17,10 +17,6 @@ package com.epmet.controller; -import cn.afterturn.easypoi.excel.ExcelExportUtil; -import cn.afterturn.easypoi.excel.entity.ExportParams; -import cn.afterturn.easypoi.excel.entity.enmus.ExcelType; -import cn.hutool.poi.excel.ExcelUtil; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.aop.NoRepeatSubmit; import com.epmet.commons.tools.exception.RenException; @@ -34,18 +30,22 @@ import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.constants.ImportTaskConstants; import com.epmet.dto.IcCommunitySelfOrganizationDTO; import com.epmet.dto.form.*; import com.epmet.dto.form.demand.ServiceQueryFormDTO; import com.epmet.dto.result.CommunitySelfOrganizationListResultDTO; +import com.epmet.dto.result.ImportTaskCommonResultDTO; import com.epmet.dto.result.demand.OptionDTO; import com.epmet.excel.ExportCommunitySelfOrganizationExcel; import com.epmet.excel.IcCommunitySelfOrganizationExcel; import com.epmet.excel.ImportCommunitySelfOrganizationSon; +import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.service.IcCommunitySelfOrganizationService; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.io.FilenameUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -66,6 +66,8 @@ public class IcCommunitySelfOrganizationController { @Autowired private IcCommunitySelfOrganizationService icCommunitySelfOrganizationService; + @Autowired + private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient; @GetMapping("page") public Result> page(@RequestParam Map params){ @@ -138,6 +140,8 @@ public class IcCommunitySelfOrganizationController { * @date 2021/11/25 9:03 上午 */ @PostMapping("importcommunityselforganization") + //service方法是异步的,需要事务注解加在被调用方 否则事务不起作用 + @Transactional(rollbackFor = Exception.class) public Result importCommunitySelfOrganization(@LoginUser TokenDto tokenDto, HttpServletResponse response, @RequestPart("file") MultipartFile file) throws Exception { if (file.isEmpty()) { throw new RenException("请上传文件"); @@ -148,7 +152,18 @@ public class IcCommunitySelfOrganizationController { if (!"xls".equals(extension) && !"xlsx".equals(extension)) { throw new RenException("文件类型不匹配"); } - icCommunitySelfOrganizationService.importCommunitySelfOrganization(tokenDto, response, file); + //1.查询当前工作人员是否有再导入的党员先锋数据,有则不允许导入,没有则进行新的导入 + ImportTaskCommonFormDTO importTaskForm = new ImportTaskCommonFormDTO(); + importTaskForm.setOriginFileName(file.getOriginalFilename()); + importTaskForm.setOperatorId(tokenDto.getUserId()); + importTaskForm.setBizType(ImportTaskConstants.BIZ_TYPE_COMMUNITY_SELF_ORG); + Result result = commonServiceOpenFeignClient.createImportTask(importTaskForm); + if (!result.success()) { + throw new RenException(result.getInternalMsg()); + } + //2.执行导入程序 + icCommunitySelfOrganizationService.importCommunitySelfOrganization(tokenDto, response, file, result.getData().getTaskId()); + return new Result(); } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcPartyActivityController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcPartyActivityController.java index 5071fd8710..75de3a06d6 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcPartyActivityController.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcPartyActivityController.java @@ -19,6 +19,8 @@ package com.epmet.controller; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.aop.NoRepeatSubmit; +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.DateUtils; @@ -27,20 +29,28 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.constants.ImportTaskConstants; import com.epmet.dto.IcPartyActivityDTO; +import com.epmet.dto.form.ImportTaskCommonFormDTO; import com.epmet.dto.form.PartyActivityFormDTO; +import com.epmet.dto.result.ImportTaskCommonResultDTO; import com.epmet.dto.result.demand.OptionDTO; import com.epmet.excel.IcPartyActivityExcel; +import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.service.IcPartyActivityService; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.io.FilenameUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; +import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.CompletableFuture; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; @@ -51,12 +61,15 @@ import java.util.stream.Collectors; * @author generator generator@elink-cn.com * @since v1.0.0 2021-11-19 */ +@Slf4j @RestController @RequestMapping("icpartyactivity") public class IcPartyActivityController { @Autowired private IcPartyActivityService icPartyActivityService; + @Resource + private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient; @PostMapping("search") public Result> page(@RequestBody PartyActivityFormDTO formDTO){ @@ -116,7 +129,58 @@ public class IcPartyActivityController { */ @PostMapping("import") public Result importData(@LoginUser TokenDto tokenDto, HttpServletResponse response, @RequestPart("file") MultipartFile file) throws IOException { - return icPartyActivityService.importData(tokenDto, response, file); + if (file.isEmpty()) { + throw new RenException("请上传文件"); + } + + String originalFilename = file.getOriginalFilename(); + // 校验文件类型 + String extension = FilenameUtils.getExtension(originalFilename); + if (!"xls".equals(extension) && !"xlsx".equals(extension)) { + throw new RenException("文件类型不匹配"); + } + + //1.查询当前工作人员是否有再导入的党员先锋数据,有则不允许导入,没有则进行新的导入 + ImportTaskCommonFormDTO importTaskForm = new ImportTaskCommonFormDTO(); + importTaskForm.setOriginFileName(file.getOriginalFilename()); + importTaskForm.setOperatorId(tokenDto.getUserId()); + importTaskForm.setBizType(ImportTaskConstants.BIZ_TYPE_PARTY_UNIT); + Result result = commonServiceOpenFeignClient.createImportTask(importTaskForm); + if (!result.success()) { + throw new RenException(result.getInternalMsg()); + } + + // 异步执行导入 + CompletableFuture.runAsync(() -> { + try { + Thread.sleep(1000L); + } catch (InterruptedException e) { + e.printStackTrace(); + } + submitResiImportTask(tokenDto, response, file, result.getData().getTaskId()); + }); + return new Result(); + } + + private void submitResiImportTask(TokenDto tokenDto, HttpServletResponse response, MultipartFile file, String importTaskId) { + + try { + icPartyActivityService.importData(tokenDto, response, file, importTaskId); + } catch (Throwable e) { + String errorMsg = ExceptionUtils.getThrowableErrorStackTrace(e); + log.error("【导入联建活动信息失败】导入失败:{}", errorMsg); + + ImportTaskCommonFormDTO importTaskForm = new ImportTaskCommonFormDTO(); + importTaskForm.setOperatorId(tokenDto.getUserId()); + importTaskForm.setBizType(ImportTaskConstants.BIZ_TYPE_PARTY_ACTIVITY); + importTaskForm.setTaskId(importTaskId); + importTaskForm.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL); + importTaskForm.setResultDesc("联建活动信息导入失败,请查看系统日志"); + Result result = commonServiceOpenFeignClient.finishImportTask(importTaskForm); + if (!result.success()) { + throw new RenException(result.getInternalMsg()); + } + } } /** diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcPartyUnitController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcPartyUnitController.java index 5aaf4863fb..817e1657a9 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcPartyUnitController.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcPartyUnitController.java @@ -21,6 +21,8 @@ import com.epmet.commons.rocketmq.messages.ServerSatisfactionCalFormDTO; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.aop.NoRepeatSubmit; import com.epmet.commons.tools.dto.result.OptionDataResultDTO; +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ExcelUtils; @@ -29,23 +31,33 @@ import com.epmet.commons.tools.validator.AssertUtils; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.constants.ImportTaskConstants; import com.epmet.dto.IcPartyUnitDTO; +import com.epmet.dto.form.ImportTaskCommonFormDTO; import com.epmet.dto.form.PartyActivityFormDTO; import com.epmet.dto.form.PartyUnitFormDTO; import com.epmet.dto.form.demand.ServiceQueryFormDTO; +import com.epmet.dto.result.ImportTaskCommonResultDTO; import com.epmet.dto.result.PartyUnitDistributionResultDTO; import com.epmet.dto.result.demand.OptionDTO; import com.epmet.excel.IcPartyUnitExcel; +import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.service.IcPartyUnitService; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.io.FilenameUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import java.nio.file.Path; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.CompletableFuture; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; @@ -56,12 +68,21 @@ import java.util.stream.Collectors; * @author generator generator@elink-cn.com * @since v1.0.0 2021-11-19 */ +@Slf4j @RestController @RequestMapping("icpartyunit") public class IcPartyUnitController { @Autowired private IcPartyUnitService icPartyUnitService; + @Resource + private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient; + + /** + * 联建单位上传临时目录 + */ + private Path IC_PARTY_UNIT_UPLOAD_DIR; + @PostMapping("list") public Result> search(@LoginUser TokenDto tokenDto, @RequestBody PartyUnitFormDTO formDTO){ @@ -151,8 +172,39 @@ public class IcPartyUnitController { * @Date 2021/11/30 14:42 */ @PostMapping("import") - public Result importData(@LoginUser TokenDto tokenDto, HttpServletResponse response, @RequestPart("file") MultipartFile file) throws IOException { - return icPartyUnitService.importData(tokenDto, response, file); + public Result importData(@LoginUser TokenDto tokenDto, HttpServletRequest multipartRequest, HttpServletResponse response, @RequestPart("file") MultipartFile file) throws IOException { + + if (file.isEmpty()) { + throw new RenException("请上传文件"); + } + + String originalFilename = file.getOriginalFilename(); + // 校验文件类型 + String extension = FilenameUtils.getExtension(originalFilename); + if (!"xls".equals(extension) && !"xlsx".equals(extension)) { + throw new RenException("文件类型不匹配"); + } + + //1.查询当前工作人员是否有再导入的党员先锋数据,有则不允许导入,没有则进行新的导入 + ImportTaskCommonFormDTO importTaskForm = new ImportTaskCommonFormDTO(); + importTaskForm.setOriginFileName(file.getOriginalFilename()); + importTaskForm.setOperatorId(tokenDto.getUserId()); + importTaskForm.setBizType(ImportTaskConstants.BIZ_TYPE_PARTY_UNIT); + Result result = commonServiceOpenFeignClient.createImportTask(importTaskForm); + if (!result.success()) { + throw new RenException(result.getInternalMsg()); + } + + // 异步执行导入 + CompletableFuture.runAsync(() -> { + try { + Thread.sleep(1000L); + } catch (InterruptedException e) { + e.printStackTrace(); + } + submitResiImportTask(tokenDto, response, file, result.getData().getTaskId()); + }); + return new Result(); } /** @@ -194,4 +246,25 @@ public class IcPartyUnitController { icPartyUnitService.calPartyUnitSatisfation(formDTO); return new Result(); } + + private void submitResiImportTask(TokenDto tokenDto, HttpServletResponse response, MultipartFile file, String importTaskId) { + + try { + icPartyUnitService.importData(tokenDto, response, file, importTaskId); + } catch (Throwable e) { + String errorMsg = ExceptionUtils.getThrowableErrorStackTrace(e); + log.error("【导入联建单位信息失败】导入失败:{}", errorMsg); + + ImportTaskCommonFormDTO importTaskForm = new ImportTaskCommonFormDTO(); + importTaskForm.setOperatorId(tokenDto.getUserId()); + importTaskForm.setBizType(ImportTaskConstants.BIZ_TYPE_PARTY_UNIT); + importTaskForm.setTaskId(importTaskId); + importTaskForm.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL); + importTaskForm.setResultDesc("联建单位信息导入失败,请查看系统日志"); + Result result = commonServiceOpenFeignClient.finishImportTask(importTaskForm); + if (!result.success()) { + throw new RenException(result.getInternalMsg()); + } + } + } } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcSocietyOrgController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcSocietyOrgController.java index 786fc77928..2b07959e33 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcSocietyOrgController.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcSocietyOrgController.java @@ -20,6 +20,7 @@ package com.epmet.controller; import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ExcelPoiUtils; import com.epmet.commons.tools.utils.ExcelUtils; @@ -27,10 +28,8 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.form.AddSocietyOrgFormDTO; import com.epmet.dto.form.EditSocietyOrgFormDTO; -import com.epmet.dto.form.GetListPlaceOrgFormDTO; import com.epmet.dto.form.GetListSocietyOrgFormDTO; import com.epmet.dto.form.demand.ServiceQueryFormDTO; -import com.epmet.dto.result.GetListPlaceOrgResultDTO; import com.epmet.dto.result.GetListSocietyOrgResultDTO; import com.epmet.dto.result.demand.OptionDTO; import com.epmet.excel.IcSocietyOrgExcel; @@ -164,9 +163,9 @@ public class IcSocietyOrgController { Collections.sort(resultList); String subList = resultList.stream().map(String::valueOf).collect(Collectors.joining("、")); log.warn(str + "第" + subList + "行未成功!"); - return new Result().error(9999, str + "第" + subList + "行未成功!"); + return new Result().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), str + "第" + subList + "行未成功!"); } return new Result().ok(str); } -} \ No newline at end of file +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcActivityServiceRelationDao.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcActivityServiceRelationDao.java new file mode 100644 index 0000000000..46cfe4eb3e --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcActivityServiceRelationDao.java @@ -0,0 +1,25 @@ +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.IcActivityServiceRelationEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * 联建活动与服务事项关联表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-02-21 + */ +@Mapper +public interface IcActivityServiceRelationDao extends BaseDao { + /** + * 删除活动所属服务 + * + * @Param activityId + * @Return + * @Author zhaoqifeng + * @Date 2022/2/21 16:19 + */ + void deleteByActivity(@Param("activityId") String activityId); +} \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcActivityUnitRelationDao.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcActivityUnitRelationDao.java new file mode 100644 index 0000000000..be27ce119b --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcActivityUnitRelationDao.java @@ -0,0 +1,25 @@ +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.IcActivityUnitRelationEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * 联建活动与单位关联表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-02-21 + */ +@Mapper +public interface IcActivityUnitRelationDao extends BaseDao { + /** + * 删除活动所属单位 + * + * @Param activityId + * @Return + * @Author zhaoqifeng + * @Date 2022/2/21 16:19 + */ + void deleteByActivity(@Param("activityId") String activityId); +} \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcCommunitySelfOrganizationDao.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcCommunitySelfOrganizationDao.java index efc9881b2a..e8fc375773 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcCommunitySelfOrganizationDao.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcCommunitySelfOrganizationDao.java @@ -18,6 +18,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.IcCommunitySelfOrganizationDTO; import com.epmet.dto.form.CommunitySelfOrganizationListFormDTO; import com.epmet.dto.result.CommunitySelfOrganizationListDTO; import com.epmet.dto.result.demand.OptionDTO; @@ -63,5 +64,5 @@ public interface IcCommunitySelfOrganizationDao extends BaseDao selectOrgByOrgName(@Param("names")List names, @Param("customerId") String customerId); - + List selectOrgByCustomerId(@Param("customerId") String customerId); } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcPartyActivityDao.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcPartyActivityDao.java index bb7e41c2ed..c8fba2ffed 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcPartyActivityDao.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcPartyActivityDao.java @@ -23,6 +23,8 @@ import com.epmet.dto.result.ActivityStatisticsDTO; import com.epmet.entity.IcPartyActivityEntity; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + /** * 联建活动 * @@ -40,5 +42,16 @@ public interface IcPartyActivityDao extends BaseDao { * @Date 2021/12/9 16:06 */ ActivityStatisticsDTO getStatistics(PartyActivityFormDTO formDTO); - + + /** + * 活动列表查询 + * @Param formDTO + * @Return {@link java.util.List} + * @Author zhaoqifeng + * @Date 2022/2/21 14:50 + */ + List selectActivityList(PartyActivityFormDTO formDTO); + + + List getActivityList(PartyActivityFormDTO formDTO); } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/LatestActServiceRelationDao.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/LatestActServiceRelationDao.java new file mode 100644 index 0000000000..6a46bf5031 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/LatestActServiceRelationDao.java @@ -0,0 +1,25 @@ +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.LatestActServiceRelationEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * 联建活动与服务事项关联表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-02-21 + */ +@Mapper +public interface LatestActServiceRelationDao extends BaseDao { + /** + * 删除活动所属服务 + * + * @Param activityId + * @Return + * @Author zhaoqifeng + * @Date 2022/2/21 16:19 + */ + void deleteByActivity(@Param("activityId") String activityId); +} \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/LatestActUnitRelationDao.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/LatestActUnitRelationDao.java new file mode 100644 index 0000000000..19e8d48e57 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/LatestActUnitRelationDao.java @@ -0,0 +1,25 @@ +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.LatestActUnitRelationEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * 联建活动与单位关联表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-02-21 + */ +@Mapper +public interface LatestActUnitRelationDao extends BaseDao { + /** + * 删除活动所属服务 + * + * @Param activityId + * @Return + * @Author zhaoqifeng + * @Date 2022/2/21 16:19 + */ + void deleteByActivity(@Param("activityId") String activityId); +} \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcActivityServiceRelationEntity.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcActivityServiceRelationEntity.java new file mode 100644 index 0000000000..31790b660f --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcActivityServiceRelationEntity.java @@ -0,0 +1,56 @@ +package com.epmet.entity; + +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 2022-02-21 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("ic_activity_service_relation") +public class IcActivityServiceRelationEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户id + */ + private String customerId; + + /** + * 组织ID + */ + private String agencyId; + + /** + * 组织的所有上级 + */ + private String pids; + + /** + * 活动ID + */ + private String activityId; + + /** + * act_info表ID + */ + private String actId; + + /** + * 服务事项 + */ + private String serviceMatter; + + /** + * 排序 + */ + private Integer sort; + +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcActivityUnitRelationEntity.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcActivityUnitRelationEntity.java new file mode 100644 index 0000000000..d7983ff41c --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcActivityUnitRelationEntity.java @@ -0,0 +1,56 @@ +package com.epmet.entity; + +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 2022-02-21 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("ic_activity_unit_relation") +public class IcActivityUnitRelationEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户id + */ + private String customerId; + + /** + * 组织ID + */ + private String agencyId; + + /** + * 组织的所有上级 + */ + private String pids; + + /** + * 活动ID + */ + private String activityId; + + /** + * act_info表ID + */ + private String actId; + + /** + * 单位ID + */ + private String unitId; + + /** + * 排序 + */ + private Integer sort; + +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/LatestActServiceRelationEntity.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/LatestActServiceRelationEntity.java new file mode 100644 index 0000000000..20e20de39b --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/LatestActServiceRelationEntity.java @@ -0,0 +1,41 @@ +package com.epmet.entity; + +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 2022-02-21 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("latest_act_service_relation") +public class LatestActServiceRelationEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户id + */ + private String customerId; + + /** + * latest_act_info表ID + */ + private String actId; + + /** + * 服务事项 + */ + private String serviceMatter; + + /** + * 排序 + */ + private Integer sort; + +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/LatestActUnitRelationEntity.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/LatestActUnitRelationEntity.java new file mode 100644 index 0000000000..d386197d79 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/LatestActUnitRelationEntity.java @@ -0,0 +1,41 @@ +package com.epmet.entity; + +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 2022-02-21 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("latest_act_unit_relation") +public class LatestActUnitRelationEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户id + */ + private String customerId; + + /** + * latest_act_info表ID + */ + private String actId; + + /** + * 单位ID + */ + private String unitId; + + /** + * 排序 + */ + private Integer sort; + +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/CommunitySelfOrgImportExcel.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/CommunitySelfOrgImportExcel.java new file mode 100644 index 0000000000..a55b7c9b69 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/CommunitySelfOrgImportExcel.java @@ -0,0 +1,37 @@ +/** + * 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.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +/** + * 社会自组织导入错误数据存放文件 + * @author sun + */ +@Data +public class CommunitySelfOrgImportExcel { + + /*@Excel(name = "组织名称", width = 40) + private String agencyName;*/ + @Excel(name = "社会自组织名称", width = 40) + private String societyName; + @Excel(name = "错误信息", width = 50) + private String errorInfo; + +} \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/IcPartyActivityImportFailedExcel.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/IcPartyActivityImportFailedExcel.java new file mode 100644 index 0000000000..7ee7a96358 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/IcPartyActivityImportFailedExcel.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.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import com.epmet.commons.tools.utils.ExcelVerifyInfo; +import lombok.Data; + +/** + * 联建活动 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-11-19 + */ +@Data +public class IcPartyActivityImportFailedExcel extends ExcelVerifyInfo { + + @Excel(name = "活动标题", width = 40) + private String title; + + @Excel(name = "错误信息", width = 50) + private String errorInfo; +} \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/IcPartyUnitImportFailedExcel.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/IcPartyUnitImportFailedExcel.java new file mode 100644 index 0000000000..2cd7e44e2a --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/IcPartyUnitImportFailedExcel.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.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import com.epmet.commons.tools.utils.ExcelVerifyInfo; +import lombok.Data; + +/** + * 联建单位 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-11-19 + */ +@Data +public class IcPartyUnitImportFailedExcel extends ExcelVerifyInfo { + + @Excel(name = "单位名称", width = 40) + private String unitName; + + @Excel(name = "错误信息", width = 50) + private String errorInfo; +} \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/ImportCommunitySelfOrganization.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/ImportCommunitySelfOrganization.java index 2a9995be2a..a6c6102431 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/ImportCommunitySelfOrganization.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/ImportCommunitySelfOrganization.java @@ -5,6 +5,7 @@ import cn.afterturn.easypoi.excel.annotation.ExcelCollection; import com.epmet.commons.tools.utils.ExcelVerifyInfo; import lombok.Data; +import javax.validation.constraints.NotBlank; import java.util.Date; import java.util.List; @@ -17,22 +18,27 @@ import java.util.List; public class ImportCommunitySelfOrganization extends ExcelVerifyInfo { @Excel(name = "组织名称", needMerge = true) + @NotBlank(message = "不能为空") private String organizationName; @Excel(name = "组织人数", needMerge = true) + //@NotNull(message = "不能为空") private Integer organizationPersonCount; @Excel(name = "服务事项", needMerge = true) + @NotBlank(message = "不能为空") private String serviceItem; @Excel(name = "负责人", needMerge = true) + @NotBlank(message = "不能为空") private String principalName; @Excel(name = "联系电话", needMerge = true) + @NotBlank(message = "不能为空") private String principalPhone; @Excel(name = "创建时间", needMerge = true) - private Date organizationCreatedTime; + private String organizationCreatedTime; @ExcelCollection(name = "组织成员") private List persons; diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcActivityServiceRelationService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcActivityServiceRelationService.java new file mode 100644 index 0000000000..ae402d24a0 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcActivityServiceRelationService.java @@ -0,0 +1,44 @@ +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.entity.IcActivityServiceRelationEntity; + +import java.util.List; + +/** + * 联建活动与服务事项关联表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-02-21 + */ +public interface IcActivityServiceRelationService extends BaseService { + /** + * 获取活动所属服务事项 + * + * @Param activityId 活动ID + * @Return {@link List } + * @Author zhaoqifeng + * @Date 2022/2/21 14:36 + */ + List getServiceList(String activityId); + + /** + * 物理删除活动所属服务事项 + * + * @Param activityId + * @Return + * @Author zhaoqifeng + * @Date 2022/2/21 16:10 + */ + void deleteByActivity(String activityId); + + /** + * 逻辑删除活动所属服务事项 + * + * @Param activityId + * @Return + * @Author zhaoqifeng + * @Date 2022/2/21 16:10 + */ + void delete(String activityId); +} \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcActivityUnitRelationService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcActivityUnitRelationService.java new file mode 100644 index 0000000000..3d109db98b --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcActivityUnitRelationService.java @@ -0,0 +1,44 @@ +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.entity.IcActivityUnitRelationEntity; + +import java.util.List; + +/** + * 联建活动与单位关联表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-02-21 + */ +public interface IcActivityUnitRelationService extends BaseService { + /** + * 获取活动所属党建单位 + * + * @Param activityId 活动ID + * @Return {@link List} + * @Author zhaoqifeng + * @Date 2022/2/21 14:36 + */ + List getUnitList(String activityId); + + /** + * 物理删除删除活动所属单位 + * + * @Param activityId + * @Return + * @Author zhaoqifeng + * @Date 2022/2/21 16:10 + */ + void deleteByActivity(String activityId); + + /** + * 逻辑删除删除活动所属单位 + * + * @Param activityId + * @Return + * @Author zhaoqifeng + * @Date 2022/2/21 16:10 + */ + void delete(String activityId); +} \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcCommunitySelfOrganizationService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcCommunitySelfOrganizationService.java index 9f8c8f4682..ab97e36e84 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcCommunitySelfOrganizationService.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcCommunitySelfOrganizationService.java @@ -157,7 +157,7 @@ public interface IcCommunitySelfOrganizationService extends BaseService queryListById(List communityOrgIds); } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcPartyActivityService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcPartyActivityService.java index c36db9b2d6..6fe8225b11 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcPartyActivityService.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcPartyActivityService.java @@ -20,7 +20,6 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; -import com.epmet.commons.tools.utils.Result; import com.epmet.dto.IcPartyActivityDTO; import com.epmet.dto.form.PartyActivityFormDTO; import com.epmet.dto.result.demand.OptionDTO; @@ -98,7 +97,7 @@ public interface IcPartyActivityService extends BaseService { * @Author zhaoqifeng * @Date 2021/11/29 11:01 */ - Result importData(TokenDto tokenDto, HttpServletResponse response, MultipartFile file) throws IOException; + void importData(TokenDto tokenDto, HttpServletResponse response, MultipartFile file, String taskId) throws IOException; /** * @Description 按类型统计单位数量 diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/LatestActServiceRelationService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/LatestActServiceRelationService.java new file mode 100644 index 0000000000..6cc376aab0 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/LatestActServiceRelationService.java @@ -0,0 +1,44 @@ +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.entity.LatestActServiceRelationEntity; + +import java.util.List; + +/** + * 联建活动与服务事项关联表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-02-21 + */ +public interface LatestActServiceRelationService extends BaseService { + /** + * 获取活动所属服务事项列表 + * + * @Param actId + * @Return {@link List < String>} + * @Author zhaoqifeng + * @Date 2022/2/22 14:53 + */ + List getServiceMatterList(String actId); + + /** + * 物理删除活动所属服务事项 + * + * @Param actId + * @Return + * @Author zhaoqifeng + * @Date 2022/2/22 14:54 + */ + void deleteByAct(String actId); + + /** + * 逻辑删除活动所属服务事项 + * + * @Param actId + * @Return + * @Author zhaoqifeng + * @Date 2022/2/22 14:54 + */ + void delete(String actId); +} \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/LatestActUnitRelationService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/LatestActUnitRelationService.java new file mode 100644 index 0000000000..da31dc42ba --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/LatestActUnitRelationService.java @@ -0,0 +1,45 @@ +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.entity.LatestActUnitRelationEntity; + +import java.util.List; + +/** + * 联建活动与单位关联表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-02-21 + */ +public interface LatestActUnitRelationService extends BaseService { + /** + * 获取活动所属联建单位列表 + * + * @Param actId + * @Return {@link List< String>} + * @Author zhaoqifeng + * @Date 2022/2/22 14:53 + */ + List getUnitList(String actId); + + /** + * 物理删除活动所属单位列表 + * + * @Param actId + * @Return + * @Author zhaoqifeng + * @Date 2022/2/22 14:54 + */ + void deleteByAct(String actId); + + /** + * 逻辑删除活动所属单位列表 + * + * @Param actId + * @Return + * @Author zhaoqifeng + * @Date 2022/2/22 14:54 + */ + void delete(String actId); + +} \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActInfoServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActInfoServiceImpl.java index e595bdd0c6..407cb74dac 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActInfoServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActInfoServiceImpl.java @@ -22,7 +22,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.NumConstant; -import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; @@ -34,6 +33,7 @@ import com.epmet.dao.ActInfoDao; import com.epmet.dao.ActUserRelationDao; import com.epmet.dao.HeartUserInfoDao; import com.epmet.dto.ActInfoDTO; +import com.epmet.dto.IcPartyActivityDTO; import com.epmet.dto.IcPartyUnitDTO; import com.epmet.dto.form.resi.*; import com.epmet.dto.result.demand.OptionDTO; @@ -42,7 +42,6 @@ import com.epmet.entity.ActInfoEntity; import com.epmet.entity.ActUserRelationEntity; import com.epmet.service.*; import com.epmet.utils.CaculateDistance; -import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -77,6 +76,12 @@ public class ActInfoServiceImpl extends BaseServiceImpl page(Map params) { @@ -255,16 +260,26 @@ public class ActInfoServiceImpl extends BaseServiceImpl serviceItemList=icServiceItemDictService.queryDictList(tokenDto.getCustomerId()); - Map categoryMap=serviceItemList.stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel)); - detailResultDTO.setServiceMatterName(MapUtils.isNotEmpty(categoryMap) && categoryMap.containsKey(detailResultDTO.getServiceMatter()) ? categoryMap.get(detailResultDTO.getServiceMatter()) : StrConstant.EPMETY_STR); - } - if (StringUtils.isNotBlank(detailResultDTO.getUnitId())) { - //获取单位名称 - IcPartyUnitDTO unitDTO = icPartyUnitService.get(detailResultDTO.getUnitId()); - detailResultDTO.setUnitName(null != unitDTO ? unitDTO.getUnitName() : StrConstant.EPMETY_STR); + if (ActConstant.PARTY.equals(detailResultDTO.getActType())) { + IcPartyActivityDTO dto = icPartyActivityService.getActivityByActId(formDto.getActId()); + if (null != dto) { + //获取服务事项 + List serviceItemList = icServiceItemDictService.queryDictList(tokenDto.getCustomerId()); + Map categoryMap = serviceItemList.stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel)); + List services = icActivityServiceRelationService.getServiceList(dto.getId()); + List serviceNames = services.stream().map(categoryMap::get).collect(Collectors.toList()); + detailResultDTO.setServiceMatterList(services); + detailResultDTO.setServiceMatterNameList(serviceNames); + + //获取联建单位 + IcPartyUnitDTO unitDTO = new IcPartyUnitDTO(); + unitDTO.setAgencyId(dto.getAgencyId()); + Map option = icPartyUnitService.option(unitDTO).stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel)); + List unitIds = icActivityUnitRelationService.getUnitList(dto.getId()); + List unitNames = unitIds.stream().map(option::get).collect(Collectors.toList()); + detailResultDTO.setUnitIdList(unitIds); + detailResultDTO.setUnitNameList(unitNames); + } } return new Result().ok(detailResultDTO); } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcActivityServiceRelationServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcActivityServiceRelationServiceImpl.java new file mode 100644 index 0000000000..b85129f293 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcActivityServiceRelationServiceImpl.java @@ -0,0 +1,78 @@ +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.dao.IcActivityServiceRelationDao; +import com.epmet.entity.IcActivityServiceRelationEntity; +import com.epmet.service.IcActivityServiceRelationService; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 联建活动与服务事项关联表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-02-21 + */ +@Service +public class IcActivityServiceRelationServiceImpl extends BaseServiceImpl implements IcActivityServiceRelationService { + + + /** + * 获取活动所属服务事项 + * + * @param activityId + * @Param activityId 活动ID + * @Return {@link List } + * @Author zhaoqifeng + * @Date 2022/2/21 14:36 + */ + @Override + public List getServiceList(String activityId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(IcActivityServiceRelationEntity::getActivityId, activityId); + wrapper.orderByAsc(IcActivityServiceRelationEntity::getSort); + List list = baseDao.selectList(wrapper); + if (CollectionUtils.isEmpty(list)) { + return Collections.emptyList(); + } + return list.stream().map(IcActivityServiceRelationEntity::getServiceMatter).collect(Collectors.toList()); + } + + /** + * 删除活动所属服务事项 + * + * @param activityId + * @Param activityId + * @Return + * @Author zhaoqifeng + * @Date 2022/2/21 16:10 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteByActivity(String activityId) { + baseDao.deleteByActivity(activityId); + } + + /** + * 逻辑删除活动所属服务事项 + * + * @param activityId + * @Param activityId + * @Return + * @Author zhaoqifeng + * @Date 2022/2/21 16:10 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String activityId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(IcActivityServiceRelationEntity::getActivityId, activityId); + baseDao.delete(wrapper); + } +} \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcActivityUnitRelationServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcActivityUnitRelationServiceImpl.java new file mode 100644 index 0000000000..d7bedf1d0b --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcActivityUnitRelationServiceImpl.java @@ -0,0 +1,77 @@ +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.dao.IcActivityUnitRelationDao; +import com.epmet.entity.IcActivityUnitRelationEntity; +import com.epmet.service.IcActivityUnitRelationService; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 联建活动与单位关联表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-02-21 + */ +@Service +public class IcActivityUnitRelationServiceImpl extends BaseServiceImpl implements IcActivityUnitRelationService { + + /** + * 获取活动所属党建单位 + * + * @param activityId + * @Param activityId 活动ID + * @Return {@link List } + * @Author zhaoqifeng + * @Date 2022/2/21 14:36 + */ + @Override + public List getUnitList(String activityId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(IcActivityUnitRelationEntity::getActivityId, activityId); + wrapper.orderByAsc(IcActivityUnitRelationEntity::getSort); + List list = baseDao.selectList(wrapper); + if (CollectionUtils.isEmpty(list)) { + return Collections.emptyList(); + } + return list.stream().map(IcActivityUnitRelationEntity::getUnitId).collect(Collectors.toList()); + } + + /** + * 删除活动所属单位 + * + * @param activityId + * @Param activityId + * @Return + * @Author zhaoqifeng + * @Date 2022/2/21 16:10 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteByActivity(String activityId) { + baseDao.deleteByActivity(activityId); + } + + /** + * 逻辑删除删除活动所属单位 + * + * @param activityId + * @Param activityId + * @Return + * @Author zhaoqifeng + * @Date 2022/2/21 16:10 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String activityId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(IcActivityUnitRelationEntity::getActivityId, activityId); + baseDao.delete(wrapper); + } +} \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java index 5176518aa2..7dd0c6343e 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java @@ -1,5 +1,7 @@ package com.epmet.service.impl; +import cn.afterturn.easypoi.excel.ExcelExportUtil; +import cn.afterturn.easypoi.excel.entity.ExportParams; import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -12,6 +14,7 @@ import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.redis.common.CustomerOrgRedis; @@ -21,37 +24,53 @@ import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.ExcelPoiUtils; +import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.PhoneValidatorUtils; import com.epmet.constant.IcCommunitySelfOrganizationConstant; import com.epmet.constant.UserDemandConstant; +import com.epmet.constants.ImportTaskConstants; import com.epmet.dao.IcCommunitySelfOrganizationDao; import com.epmet.dto.IcCommunitySelfOrganizationDTO; -import com.epmet.dto.form.AddCommunitySelfOrganizationFormDTO; -import com.epmet.dto.form.CommunitySelfOrganizationListFormDTO; -import com.epmet.dto.form.DelCommunitySelfOrganizationFormDTO; -import com.epmet.dto.form.EditCommunitySelfOrganizationFormDTO; +import com.epmet.dto.form.*; import com.epmet.dto.form.demand.ServiceQueryFormDTO; import com.epmet.dto.result.CommunitySelfOrganizationListDTO; import com.epmet.dto.result.CommunitySelfOrganizationListResultDTO; +import com.epmet.dto.result.UploadImgResultDTO; import com.epmet.dto.result.demand.OptionDTO; import com.epmet.entity.IcCommunitySelfOrganizationEntity; import com.epmet.entity.IcCommunitySelfOrganizationPersonnelEntity; +import com.epmet.excel.CommunitySelfOrgImportExcel; import com.epmet.excel.ImportCommunitySelfOrganization; +import com.epmet.feign.EpmetCommonServiceOpenFeignClient; +import com.epmet.feign.OssFeignClient; import com.epmet.service.IcCommunitySelfOrganizationPersonnelService; import com.epmet.service.IcCommunitySelfOrganizationService; import com.epmet.service.IcUserDemandRecService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.FileItemFactory; +import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.lang3.StringUtils; +import org.apache.http.entity.ContentType; +import org.apache.poi.ss.usermodel.Workbook; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Async; +import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.commons.CommonsMultipartFile; import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import java.io.OutputStream; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.*; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; @@ -64,12 +83,18 @@ import static com.epmet.commons.tools.utils.DateUtils.DATE_PATTERN; * @since v1.0.0 2021-11-18 */ @Service +@Slf4j +@EnableAsync public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl implements IcCommunitySelfOrganizationService { @Autowired private IcCommunitySelfOrganizationPersonnelService personnelService; @Autowired private IcUserDemandRecService icUserDemandRecService; + @Autowired + private OssFeignClient ossFeignClient; + @Autowired + private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient; @Override public PageData page(Map params) { @@ -362,9 +387,9 @@ public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl testExcelImportResult = ExcelPoiUtils.importExcelMore(file, 0, 2, ImportCommunitySelfOrganization.class); List list = testExcelImportResult.getList(); @@ -410,7 +435,7 @@ public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl { @@ -446,6 +471,212 @@ public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl fileList = new ArrayList<>(); + CommunitySelfOrgImportExcel excel = null; + //1.读取Excel数据 + ExcelImportResult testExcelImportResult = ExcelPoiUtils.importExcelMore(file, 0, 2, ImportCommunitySelfOrganization.class); + //2.存在错误行数据时存入错误数据集合中 + for (ImportCommunitySelfOrganization entity : testExcelImportResult.getFailList()) { + //打印失败的行 和失败的信息 + log.warn("第{}行,{}", entity.getRowNum(), entity.getErrorMsg()); + excel = new CommunitySelfOrgImportExcel(); + //excel.setAgencyName(entity.getOrganizationName()); + excel.setSocietyName(entity.getOrganizationName()); + excel.setErrorInfo(entity.getErrorMsg()); + fileList.add(excel); + } + //正确行数据集合 + List list = testExcelImportResult.getList(); + if (CollectionUtils.isNotEmpty(list)){ + //3.分别判断导入数据是否是当前组织下数据、社会自组织名称是否已存在、手机号是否规范 + //3-1.查询当前组织下已从存在的社会自组织名称 + CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId()); + //查询当前组织下的社会自组织数据 + List communitySeltOrgList = baseDao.selectOrgByCustomerId(tokenDto.getCustomerId()); + //组织信息 + AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(staffInfoCache.getAgencyId()); + //3-2.检验数据,把不允许导入的数据剔除 + Iterator iterator = list.iterator(); + while (iterator.hasNext()) { + AtomicBoolean bl = new AtomicBoolean(false); + StringBuffer errMsg = new StringBuffer(""); + ImportCommunitySelfOrganization obj = iterator.next(); + //社会自组织名称重复 + communitySeltOrgList.forEach(org -> { + if (obj.getOrganizationName().equals(org.getOrganizationName())) { + log.warn(String.format("当前客户下的社会自组织名称已存在,社会自组织名称->%s,行号->%s", obj.getOrganizationName(), obj.getRowNum())); + errMsg.append("客户下社会自组织名称已存在;"); + bl.set(true); + } + }); + //手机号不合规 + boolean m = PhoneValidatorUtils.isMobile(obj.getPrincipalPhone()); + boolean t = PhoneValidatorUtils.isTel(obj.getPrincipalPhone()); + if (!m && !t){ + errMsg.append("手机号码不合法;"); + bl.set(true); + log.warn("手机号码不合法,自组织名称{}", obj.getOrganizationName()); + } + if(bl.get()){ + excel = new CommunitySelfOrgImportExcel(); + //excel.setAgencyName(obj.getOrganizationName()); + excel.setSocietyName(obj.getOrganizationName()); + excel.setErrorInfo(errMsg.toString()); + fileList.add(excel); + iterator.remove(); + } + } + + list.forEach(l -> { + IcCommunitySelfOrganizationEntity e = ConvertUtils.sourceToTarget(l, IcCommunitySelfOrganizationEntity.class); + e.setCustomerId(tokenDto.getCustomerId()); + e.setOrgId(agencyInfo.getId()); + e.setOrgType(IcCommunitySelfOrganizationConstant.ORG_TYPE_AGENCY); + e.setPid(agencyInfo.getPid()); + e.setPids(agencyInfo.getPids()); + e.setOrganizationCreatedTime(DateUtils.parse(l.getOrganizationCreatedTime(), DATE_PATTERN)); + + List persons = new ArrayList<>(); + AtomicReference bl = new AtomicReference<>(false); + StringBuffer msg = new StringBuffer(""); + if (CollectionUtils.isNotEmpty(l.getPersons())){ + l.getPersons().forEach(p -> { + boolean m = PhoneValidatorUtils.isMobile(p.getPersonPhone()); + boolean t = PhoneValidatorUtils.isTel(p.getPersonPhone()); + if (!m && !t){ + bl.set(true); + msg.append("自组织下成员手机号错误;"); + log.warn("自组织下成员手机号错误,自组织名称{}", l.getOrganizationName()); + return; + //throw new EpmetException(EpmetErrorCode.CHECK_PHONE_ERROR.getCode()); + } + }); + persons = ConvertUtils.sourceToTarget(l.getPersons(), IcCommunitySelfOrganizationPersonnelEntity.class); + Map> groupByPhone = persons.stream().collect(Collectors.groupingBy(IcCommunitySelfOrganizationPersonnelEntity::getPersonPhone)); + List phones = new ArrayList<>(); + groupByPhone.forEach((k,v) -> { + if (v.size() > NumConstant.ONE){ + phones.add(k); + } + }); + if (CollectionUtils.isNotEmpty(phones)){ + bl.set(true); + msg.append("自组织下成员手机号重复;"); + log.warn("自组织下成员手机号重复,自组织名称{}", l.getOrganizationName()); + /*StringBuffer sb = new StringBuffer(); + phones.forEach(p -> { + sb.append(p).append(","); + }); + String copywriter = sb.toString().substring(NumConstant.ZERO, sb.length() - NumConstant.ONE); + EpmetErrorCode.EXISTS_SAME_PHONE_ERROR.setMsg(String.format(EpmetErrorCode.EXISTS_SAME_PHONE_ERROR.getMsg(),copywriter)); + throw new RenException(EpmetErrorCode.EXISTS_SAME_PHONE_ERROR.getCode());*/ + } + } + if(bl.get()){ + CommunitySelfOrgImportExcel ex = new CommunitySelfOrgImportExcel(); + //ex.setAgencyName(l.getOrganizationName()); + ex.setSocietyName(l.getOrganizationName()); + ex.setErrorInfo(msg.toString()); + fileList.add(ex); + return; + } + baseDao.insert(e); + if(CollectionUtils.isNotEmpty(persons)){ + persons.forEach(p -> { + p.setCustomerId(tokenDto.getCustomerId()); + p.setOrgId(e.getId()); + }); + personnelService.insertBatch(persons); + } + + }); + } + //4.错误数据生成文件,修改导入任务状态 + String url = erroeImport(fileList); + upImportTask(url, taskId, tokenDto.getUserId(), true); + } catch (Exception e) { + String errorMsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【社会自组织信息导入】程序错误:{}", errorMsg); + upImportTask(null, taskId, tokenDto.getUserId(), false); + } + } + /** + * @Author sun + * @Description 社会自组织导入,错误数据生成导入失败文件存到阿里云,修改导入任务为已结束 + **/ + private String erroeImport(List fileList) throws IOException { + String url = ""; + //1.有错误数据则生成错误数据存放文件传到阿里云服务 + if (!org.springframework.util.CollectionUtils.isEmpty(fileList)) { + Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("导入失败的数据列表", "导入失败的数据列表"), + CommunitySelfOrgImportExcel.class, fileList); + + // 文件名 + String resultDescFileName = UUID.randomUUID().toString().concat(".xlsx"); + FileItemFactory factory = new DiskFileItemFactory(16, null); + FileItem fileItem = factory.createItem("file", ContentType.APPLICATION_OCTET_STREAM.toString(), true, resultDescFileName); + OutputStream os = fileItem.getOutputStream(); + Result uploadResult = null; + try { + workbook.write(os); + uploadResult = ossFeignClient.uploadImportTaskDescFile(new CommonsMultipartFile(fileItem)); + } catch (Exception e) { + String errormsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【社会自组织信息导入】上传错误描述文件:{}", errormsg); + } finally { + try { + os.close(); + } catch (IOException e) { + String errormsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【社会自组织信息导入】上传错误描述文件关闭输出流:{}", errormsg); + } + try { + fileItem.delete(); + } catch (Exception e) { + String errormsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【社会自组织信息导入】上传错误描述文件删除临时文件:{}", errormsg); + } + } + + if (uploadResult == null || !uploadResult.success()) { + log.error("【社会自组织信息导入】调用OSS上传结果描述文件失败"); + } + url = uploadResult.getData().getUrl(); + } + return url; + } + /** + * @Author sun + * @Description 社会自组织导入修改导入任务状态 + **/ + private void upImportTask(String url, String importTaskId, String staffId, Boolean status) { + //2.更新导入任务数据 + ImportTaskCommonFormDTO importTaskForm = new ImportTaskCommonFormDTO(); + importTaskForm.setOperatorId(staffId); + importTaskForm.setBizType(ImportTaskConstants.BIZ_TYPE_PARTY_MEMBER); + importTaskForm.setTaskId(importTaskId); + importTaskForm.setResultDescFilePath(url); + if (status && StringUtils.isBlank(url)) { + importTaskForm.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_SUCCESS); + } else { + importTaskForm.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL); + importTaskForm.setResultDesc("社会自组织导入存在程序错误"); + } + Result result = commonServiceOpenFeignClient.finishImportTask(importTaskForm); + if (!result.success()) { + throw new RenException(result.getInternalMsg()); + } + } @Override public List queryListById(List communityOrgIds) { diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyActivityServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyActivityServiceImpl.java index cdfa84d5e2..b72739dbbc 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyActivityServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyActivityServiceImpl.java @@ -17,13 +17,16 @@ package com.epmet.service.impl; +import cn.afterturn.easypoi.excel.ExcelExportUtil; +import cn.afterturn.easypoi.excel.entity.ExportParams; import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; -import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.security.dto.TokenDto; @@ -31,30 +34,44 @@ import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.ExcelPoiUtils; import com.epmet.commons.tools.utils.Result; +import com.epmet.constants.ImportTaskConstants; import com.epmet.dao.IcPartyActivityDao; import com.epmet.dto.IcPartyActivityDTO; import com.epmet.dto.IcPartyUnitDTO; +import com.epmet.dto.form.ImportTaskCommonFormDTO; import com.epmet.dto.form.PartyActivityFormDTO; import com.epmet.dto.result.ActivityStatisticsDTO; +import com.epmet.dto.result.UploadImgResultDTO; import com.epmet.dto.result.demand.OptionDTO; +import com.epmet.entity.IcActivityServiceRelationEntity; +import com.epmet.entity.IcActivityUnitRelationEntity; import com.epmet.entity.IcPartyActivityEntity; import com.epmet.excel.IcPartyActivityImportExcel; -import com.epmet.service.IcPartyActivityService; -import com.epmet.service.IcPartyUnitService; -import com.epmet.service.IcServiceItemDictService; +import com.epmet.excel.IcPartyActivityImportFailedExcel; +import com.epmet.feign.EpmetCommonServiceOpenFeignClient; +import com.epmet.feign.OssFeignClient; +import com.epmet.service.*; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.FileItemFactory; +import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.lang3.StringUtils; +import org.apache.http.entity.ContentType; +import org.apache.poi.ss.usermodel.Workbook; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.commons.CommonsMultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import java.io.OutputStream; import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; /** @@ -71,6 +88,14 @@ public class IcPartyActivityServiceImpl extends BaseServiceImpl wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(IcPartyActivityEntity::getAgencyId, formDTO.getAgencyId()); - wrapper.eq(StringUtils.isNotBlank(formDTO.getUnitId()), IcPartyActivityEntity::getUnitId, formDTO.getUnitId()); - wrapper.eq(StringUtils.isNotBlank(formDTO.getServiceMatter()), IcPartyActivityEntity::getServiceMatter, formDTO.getServiceMatter()); - wrapper.like(StringUtils.isNotBlank(formDTO.getTitle()), IcPartyActivityEntity::getTitle, formDTO.getTitle()); - wrapper.between(IcPartyActivityEntity::getActivityTime, formDTO.getStartTime(), formDTO.getEndTime()); - wrapper.orderByDesc(IcPartyActivityEntity::getUpdatedTime); - List list = baseDao.selectList(wrapper); + List list = baseDao.selectActivityList(formDTO); PageInfo pageInfo = new PageInfo<>(list); List dtoList = ConvertUtils.sourceToTarget(list, IcPartyActivityDTO.class); - IcPartyUnitDTO unitDTO = new IcPartyUnitDTO(); - unitDTO.setAgencyId(formDTO.getAgencyId()); if (CollectionUtils.isNotEmpty(dtoList)) { + //获取组织下联建单位 + IcPartyUnitDTO unitDTO = new IcPartyUnitDTO(); + unitDTO.setAgencyId(formDTO.getAgencyId()); Map option = icPartyUnitService.option(unitDTO).stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel)); dtoList.forEach(dto -> { - dto.setUnitName(option.get(dto.getUnitId())); + //联建单位ID与单位名匹配 + List unitIds = Arrays.asList(dto.getUnitId().split(StrConstant.COMMA)); + List unitNames = unitIds.stream().map(option::get).collect(Collectors.toList()); + dto.setUnitName(StringUtils.join(unitNames, StrConstant.COMMA)); }); } @@ -117,54 +139,49 @@ public class IcPartyActivityServiceImpl extends BaseServiceImpl wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(IcPartyActivityEntity::getAgencyId, formDTO.getAgencyId()); - wrapper.eq(StringUtils.isNotBlank(formDTO.getUnitId()), IcPartyActivityEntity::getUnitId, formDTO.getUnitId()); - wrapper.eq(StringUtils.isNotBlank(formDTO.getServiceMatter()), IcPartyActivityEntity::getServiceMatter, formDTO.getServiceMatter()); - wrapper.like(StringUtils.isNotBlank(formDTO.getTitle()), IcPartyActivityEntity::getTitle, formDTO.getTitle()); - wrapper.between(IcPartyActivityEntity::getActivityTime, formDTO.getStartTime(), formDTO.getEndTime()); - wrapper.orderByDesc(IcPartyActivityEntity::getUpdatedTime); - List list = baseDao.selectList(wrapper); + List list = baseDao.selectActivityList(formDTO); List dtoList = ConvertUtils.sourceToTarget(list, IcPartyActivityDTO.class); - IcPartyUnitDTO unitDTO = new IcPartyUnitDTO(); - unitDTO.setAgencyId(formDTO.getAgencyId()); if (CollectionUtils.isNotEmpty(dtoList)) { + IcPartyUnitDTO unitDTO = new IcPartyUnitDTO(); + unitDTO.setAgencyId(formDTO.getAgencyId()); Map option = icPartyUnitService.option(unitDTO).stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel)); dtoList.forEach(dto -> { - dto.setUnitName(option.get(dto.getUnitId())); + List unitIds = Arrays.asList(dto.getUnitId().split(StrConstant.COMMA)); + List unitNames = unitIds.stream().map(option::get).collect(Collectors.toList()); + dto.setUnitName(StringUtils.join(unitNames, StrConstant.COMMA)); }); } return dtoList; } - private QueryWrapper getWrapper(Map params){ - String id = (String)params.get(FieldConstant.ID_HUMP); - - QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); - - return wrapper; - } - @Override public IcPartyActivityDTO get(String id) { IcPartyActivityEntity entity = baseDao.selectById(id); if (null == entity) { return null; } - //获取服务事项名称 + IcPartyActivityDTO dto = ConvertUtils.sourceToTarget(entity, IcPartyActivityDTO.class); + + //获取服务事项 List serviceItemList=icServiceItemDictService.queryDictList(entity.getCustomerId()); Map categoryMap=serviceItemList.stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel)); + List services = icActivityServiceRelationService.getServiceList(id); + List serviceNames = services.stream().map(categoryMap::get).collect(Collectors.toList()); + dto.setServiceMatterList(services); + dto.setServiceMatterNameList(serviceNames); + + //获取单位 + //获取组织下联建单位 + IcPartyUnitDTO unitDTO = new IcPartyUnitDTO(); + unitDTO.setAgencyId(entity.getAgencyId()); + Map option = icPartyUnitService.option(unitDTO).stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel)); + List unitIds = icActivityUnitRelationService.getUnitList(id); + List unitNames = unitIds.stream().map(option::get).collect(Collectors.toList()); + dto.setUnitIdList(unitIds); + dto.setUnitNameList(unitNames); - IcPartyActivityDTO dto = ConvertUtils.sourceToTarget(entity, IcPartyActivityDTO.class); - dto.setServiceMatterName(categoryMap.get(dto.getServiceMatter())); - //获取单位名称 - IcPartyUnitDTO unitDTO = icPartyUnitService.get(dto.getUnitId()); - if (null != unitDTO) { - dto.setUnitName(unitDTO.getUnitName()); - } return dto; } @@ -181,6 +198,35 @@ public class IcPartyActivityServiceImpl extends BaseServiceImpl unitRelationList = dto.getUnitIdList().stream().map(unitId -> { + IcActivityUnitRelationEntity relation = new IcActivityUnitRelationEntity(); + relation.setCustomerId(entity.getCustomerId()); + relation.setAgencyId(entity.getAgencyId()); + relation.setPids(entity.getPids()); + relation.setActivityId(entity.getId()); + relation.setUnitId(unitId); + relation.setSort(i.getAndIncrement()); + return relation; + }).collect(Collectors.toList()); + icActivityUnitRelationService.insertBatch(unitRelationList); + + //保存活动与服务关系 + icActivityServiceRelationService.deleteByActivity(entity.getId()); + AtomicInteger j = new AtomicInteger(NumConstant.ONE); + List serviceRelationList = dto.getServiceMatterList().stream().map(service -> { + IcActivityServiceRelationEntity relation = new IcActivityServiceRelationEntity(); + relation.setCustomerId(entity.getCustomerId()); + relation.setAgencyId(entity.getAgencyId()); + relation.setPids(entity.getPids()); + relation.setActivityId(entity.getId()); + relation.setServiceMatter(service); + relation.setSort(j.getAndIncrement()); + return relation; + }).collect(Collectors.toList()); + icActivityServiceRelationService.insertBatch(serviceRelationList); } @Override @@ -188,6 +234,8 @@ public class IcPartyActivityServiceImpl extends BaseServiceImpl fileList = new ArrayList<>(); ExcelImportResult importResult = ExcelPoiUtils.importExcelMore(file, 0, 1, IcPartyActivityImportExcel.class); List failList = importResult.getFailList(); //存放错误数据行号 - List numList = new ArrayList<>(); if (!org.springframework.util.CollectionUtils.isEmpty(failList)) { for (IcPartyActivityImportExcel entity : failList) { //打印失败的行 和失败的信息 log.warn("第{}行,{}", entity.getRowNum(), entity.getErrorMsg()); - numList.add(entity.getRowNum()); + IcPartyActivityImportFailedExcel failed = ConvertUtils.sourceToTarget(entity, IcPartyActivityImportFailedExcel.class); + failed.setErrorInfo(entity.getErrorMsg()); + fileList.add(failed); } } List result = importResult.getList(); @@ -233,72 +283,201 @@ public class IcPartyActivityServiceImpl extends BaseServiceImpl%s", obj.getRowNum())); iterator.remove(); - } else if (null == option.get(obj.getUnitName())){ - numList.add(obj.getRowNum()); - log.warn(String.format("单位名称不存在,行号->%s", obj.getRowNum())); - iterator.remove(); + } else { + List unitList = Arrays.asList(obj.getUnitName().split(StrConstant.COMMA)); + unitList.forEach(unit -> { + if (null == option.get(unit)) { + IcPartyActivityImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyActivityImportFailedExcel.class); + failed.setErrorInfo("单位名称不存在"); + fileList.add(failed); + log.warn(String.format("单位名称不存在,行号->%s", obj.getRowNum())); + iterator.remove(); + } + }); } //服务事项校验 if (StringUtils.isBlank(obj.getServiceMatter())) { - numList.add(obj.getRowNum()); + IcPartyActivityImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyActivityImportFailedExcel.class); + failed.setErrorInfo("服务事项为空"); + fileList.add(failed); log.warn(String.format("服务事项为空,行号->%s", obj.getRowNum())); iterator.remove(); - } else if (null == categoryMap.get(obj.getServiceMatter())){ - numList.add(obj.getRowNum()); - log.warn(String.format("服务事项不存在,行号->%s", obj.getRowNum())); - iterator.remove(); + } else { + List serviceList = Arrays.asList(obj.getServiceMatter().split(StrConstant.SEMICOLON)); + serviceList.forEach(service -> { + if (null == categoryMap.get(service)) { + IcPartyActivityImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyActivityImportFailedExcel.class); + failed.setErrorInfo("服务事项不存在"); + fileList.add(failed); + log.warn(String.format("服务事项不存在,行号->%s", obj.getRowNum())); + iterator.remove(); + } + }); + } //活动标题 活动目标 活动内容 活动时间 活动地址 活动地址经度 活动地址纬度 活动结果 - if(StringUtils.isBlank(obj.getTitle()) || StringUtils.isBlank(obj.getTarget()) || - StringUtils.isBlank(obj.getContent()) || - StringUtils.isBlank(obj.getActivityTime()) || - StringUtils.isBlank(obj.getAddress()) || - StringUtils.isBlank(obj.getLatitude()) || - StringUtils.isBlank(obj.getLongitude()) || - StringUtils.isBlank(obj.getResult())) { - numList.add(obj.getRowNum()); - log.warn(String.format("活动标题、活动目标、活动内容、活动时间、活动地址、活动地址经度、活动地址纬度、活动结果为空,行号->%s", obj.getRowNum())); + if(StringUtils.isBlank(obj.getTitle())) { + IcPartyActivityImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyActivityImportFailedExcel.class); + failed.setErrorInfo("活动标题为空"); + fileList.add(failed); + log.warn(String.format("活动标题为空,行号->%s", obj.getRowNum())); iterator.remove(); + } else if(StringUtils.isBlank(obj.getTarget())) { + IcPartyActivityImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyActivityImportFailedExcel.class); + failed.setErrorInfo("活动目标为空"); + fileList.add(failed); + log.warn(String.format("活动目标为空,行号->%s", obj.getRowNum())); + } else if(StringUtils.isBlank(obj.getContent())) { + IcPartyActivityImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyActivityImportFailedExcel.class); + failed.setErrorInfo("活动内容为空"); + fileList.add(failed); + log.warn(String.format("活动内容为空,行号->%s", obj.getRowNum())); + } else if(StringUtils.isBlank(obj.getActivityTime())) { + IcPartyActivityImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyActivityImportFailedExcel.class); + failed.setErrorInfo("活动时间为空"); + fileList.add(failed); + log.warn(String.format("活动时间为空,行号->%s", obj.getRowNum())); + } else if(StringUtils.isBlank(obj.getAddress())) { + IcPartyActivityImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyActivityImportFailedExcel.class); + failed.setErrorInfo("活动地址为空"); + fileList.add(failed); + log.warn(String.format("活动地址为空,行号->%s", obj.getRowNum())); + } else if(StringUtils.isBlank(obj.getLatitude())) { + IcPartyActivityImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyActivityImportFailedExcel.class); + failed.setErrorInfo("活动地址纬度为空"); + fileList.add(failed); + log.warn(String.format("活动地址纬度为空,行号->%s", obj.getRowNum())); + } else if(StringUtils.isBlank(obj.getLongitude())) { + IcPartyActivityImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyActivityImportFailedExcel.class); + failed.setErrorInfo("活动地址经度为空"); + fileList.add(failed); + log.warn(String.format("活动地址经度为空,行号->%s", obj.getRowNum())); + } else if(StringUtils.isBlank(obj.getResult())) { + IcPartyActivityImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyActivityImportFailedExcel.class); + failed.setErrorInfo("活动结果为空"); + fileList.add(failed); + log.warn(String.format("活动结果为空,行号->%s", obj.getRowNum())); } } - if (CollectionUtils.isEmpty(result)) { - Collections.sort(numList); + if (CollectionUtils.isNotEmpty(result)) { + result.forEach(item -> { + IcPartyActivityEntity entity = new IcPartyActivityEntity(); + entity.setCustomerId(tokenDto.getCustomerId()); + entity.setAgencyId(staffInfoCache.getAgencyId()); + entity.setPids(staffInfoCache.getAgencyPIds()); + entity.setTitle(item.getTitle()); + entity.setTarget(item.getTarget()); + entity.setContent(item.getContent()); + entity.setPeopleCount(item.getPeopleCount()); + entity.setActivityTime(DateUtils.parse(item.getActivityTime(), DateUtils.DATE_TIME_PATTERN)); + entity.setAddress(item.getAddress()); + entity.setLatitude(item.getLatitude()); + entity.setLongitude(item.getLongitude()); + entity.setResult(item.getResult()); + insert(entity); + + //保存活动与单位关系 + icActivityUnitRelationService.deleteByActivity(entity.getId()); + AtomicInteger i = new AtomicInteger(NumConstant.ONE); + List unitRelationList = Arrays.stream(item.getUnitName().split(StrConstant.COMMA)).map(unit -> { + IcActivityUnitRelationEntity relation = new IcActivityUnitRelationEntity(); + relation.setCustomerId(entity.getCustomerId()); + relation.setAgencyId(entity.getAgencyId()); + relation.setPids(entity.getPids()); + relation.setActivityId(entity.getId()); + relation.setUnitId(option.get(unit)); + relation.setSort(i.getAndIncrement()); + return relation; + }).collect(Collectors.toList()); + icActivityUnitRelationService.insertBatch(unitRelationList); + + //保存活动与服务关系 + icActivityServiceRelationService.deleteByActivity(entity.getId()); + AtomicInteger j = new AtomicInteger(NumConstant.ONE); + List serviceRelationList = Arrays.stream(item.getServiceMatter().split(StrConstant.SEMICOLON)).map(service -> { + IcActivityServiceRelationEntity relation = new IcActivityServiceRelationEntity(); + relation.setCustomerId(entity.getCustomerId()); + relation.setAgencyId(entity.getAgencyId()); + relation.setPids(entity.getPids()); + relation.setActivityId(entity.getId()); + relation.setServiceMatter(categoryMap.get(service)); + relation.setSort(j.getAndIncrement()); + return relation; + }).collect(Collectors.toList()); + icActivityServiceRelationService.insertBatch(serviceRelationList); + }); + } + String str = String.format("共%s条,成功导入%s条。", fileList.size() + result.size(), fileList.size() + result.size() - fileList.size()); + + if (fileList.size() > NumConstant.ZERO) { + List numList = fileList.stream().map(IcPartyActivityImportFailedExcel::getRowNum).sorted().collect(Collectors.toList()); String subList = numList.stream().map(String::valueOf).collect(Collectors.joining("、")); - return new Result().error(9999, "第" + subList + "行未成功!"); + log.warn(str + "第" + subList + "行未成功!"); } - List list = result.stream().map(item -> { - IcPartyActivityEntity entity = new IcPartyActivityEntity(); - entity.setCustomerId(tokenDto.getCustomerId()); - entity.setAgencyId(staffInfoCache.getAgencyId()); - entity.setPids(staffInfoCache.getAgencyPIds()); - entity.setTitle(item.getTitle()); - entity.setTarget(item.getTarget()); - entity.setContent(item.getContent()); - entity.setUnitId(option.get(item.getUnitName())); - entity.setServiceMatter(categoryMap.get(item.getServiceMatter())); - entity.setPeopleCount(item.getPeopleCount()); - entity.setActivityTime(DateUtils.parse(item.getActivityTime(), DateUtils.DATE_TIME_PATTERN)); - entity.setAddress(item.getAddress()); - entity.setLatitude(item.getLatitude()); - entity.setLongitude(item.getLongitude()); - entity.setResult(item.getResult()); - return entity; - }).collect(Collectors.toList()); + //错误数据生成文件,修改导入任务状态 + erroeImport(fileList, taskId, tokenDto.getUserId()); + } - insertBatch(list); + private void erroeImport(List fileList, String importTaskId, String staffId) throws IOException { + String url = ""; + //1.有错误数据则生成错误数据存放文件传到阿里云服务 + if (CollectionUtils.isNotEmpty(fileList)) { + Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("导入失败的数据列表", "导入失败的数据列表"), + IcPartyActivityImportFailedExcel.class, fileList); + // 文件名 + String resultDescFileName = UUID.randomUUID().toString().concat(".xlsx"); + FileItemFactory factory = new DiskFileItemFactory(16, null); + FileItem fileItem = factory.createItem("file", ContentType.APPLICATION_OCTET_STREAM.toString(), true, resultDescFileName); + OutputStream os = fileItem.getOutputStream(); + Result uploadResult = null; + try { + workbook.write(os); + uploadResult = ossFeignClient.uploadImportTaskDescFile(new CommonsMultipartFile(fileItem)); + } catch (Exception e) { + String errormsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【联建活动信息导入】上传错误描述文件:{}", errormsg); + } finally { + try { + os.close(); + } catch (IOException e) { + String errormsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【联建活动信息导入】上传错误描述文件关闭输出流:{}", errormsg); + } + try { + fileItem.delete(); + } catch (Exception e) { + String errormsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【联建活动信息导入】上传错误描述文件删除临时文件:{}", errormsg); + } + } - String str = String.format("共%s条,成功导入%s条。", numList.size() + result.size(), numList.size() + result.size() - numList.size()); - if (numList.size() > NumConstant.ZERO) { - Collections.sort(numList); - String subList = numList.stream().map(String::valueOf).collect(Collectors.joining("、")); - log.warn(str + "第" + subList + "行未成功!"); - return new Result().error(9999, str + "第" + subList + "行未成功!"); + if (uploadResult == null || !uploadResult.success()) { + log.error("【联建活动信息导入】调用OSS上传结果描述文件失败"); + } else { + url = uploadResult.getData().getUrl(); + } + } + //2.更新导入任务数据 + ImportTaskCommonFormDTO importTaskForm = new ImportTaskCommonFormDTO(); + importTaskForm.setOperatorId(staffId); + importTaskForm.setBizType(ImportTaskConstants.BIZ_TYPE_PARTY_ACTIVITY); + importTaskForm.setTaskId(importTaskId); + importTaskForm.setResultDescFilePath(url); + importTaskForm.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_SUCCESS); + if (CollectionUtils.isNotEmpty(fileList)) { + importTaskForm.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL); + importTaskForm.setResultDesc("联建活动导入存在错误数据"); + } + Result result = commonServiceOpenFeignClient.finishImportTask(importTaskForm); + if (!result.success()) { + throw new RenException(result.getInternalMsg()); } - return new Result().ok(str); } /** @@ -346,14 +525,7 @@ public class IcPartyActivityServiceImpl extends BaseServiceImpl wrapper = new LambdaQueryWrapper<>(); - wrapper.and(wp -> wp.eq(IcPartyActivityEntity::getAgencyId, formDTO.getAgencyId()).or(). - like(IcPartyActivityEntity::getPids, formDTO.getAgencyId())); - wrapper.eq(StringUtils.isNotBlank(formDTO.getServiceMatter()), IcPartyActivityEntity::getServiceMatter, formDTO.getServiceMatter()); - wrapper.ge(null != formDTO.getStartTime(),IcPartyActivityEntity::getActivityTime, formDTO.getStartTime()); - wrapper.le(null != formDTO.getEndTime(), IcPartyActivityEntity::getActivityTime, formDTO.getEndTime()); - wrapper.orderByDesc(IcPartyActivityEntity::getActivityTime); - List list = baseDao.selectList(wrapper); + List list = baseDao.getActivityList(formDTO); List dtoList = ConvertUtils.sourceToTarget(list, IcPartyActivityDTO.class); IcPartyUnitDTO unitDTO = new IcPartyUnitDTO(); @@ -366,8 +538,15 @@ public class IcPartyActivityServiceImpl extends BaseServiceImpl categoryMap=serviceItemList.stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel)); //数据组装 dtoList.forEach(dto -> { - dto.setServiceMatterName(categoryMap.get(dto.getServiceMatter())); - dto.setUnitName(option.get(dto.getUnitId())); + //联建单位ID与单位名匹配 + List unitIds = Arrays.asList(dto.getUnitId().split(StrConstant.COMMA)); + List unitNames = unitIds.stream().map(option::get).collect(Collectors.toList()); + dto.setUnitName(StringUtils.join(unitNames, StrConstant.COMMA)); + + //服务事项与服务事项名匹配 + List services = Arrays.asList(dto.getServiceMatter().split(StrConstant.COMMA)); + List serviceNames = services.stream().map(categoryMap::get).collect(Collectors.toList()); + dto.setServiceMatterName(StringUtils.join(serviceNames, StrConstant.SEMICOLON)); }); } PageInfo pageInfo = new PageInfo<>(dtoList); @@ -422,4 +601,4 @@ public class IcPartyActivityServiceImpl extends BaseServiceImpl search(PartyUnitFormDTO formDTO) { @@ -303,16 +324,19 @@ public class IcPartyUnitServiceImpl extends BaseServiceImpl fileList = new ArrayList<>(); + ExcelImportResult importResult = ExcelPoiUtils.importExcelMore(file, 0, 1, IcPartyUnitImportExcel.class); List failList = importResult.getFailList(); //存放错误数据行号 - List numList = new ArrayList<>(); if (!org.springframework.util.CollectionUtils.isEmpty(failList)) { for (IcPartyUnitImportExcel entity : failList) { //打印失败的行 和失败的信息 log.warn("第{}行,{}", entity.getRowNum(), entity.getErrorMsg()); - numList.add(entity.getRowNum()); + IcPartyUnitImportFailedExcel failed = ConvertUtils.sourceToTarget(entity, IcPartyUnitImportFailedExcel.class); + failed.setErrorInfo(entity.getErrorMsg()); + fileList.add(failed); } } List result = importResult.getList(); @@ -329,7 +353,9 @@ public class IcPartyUnitServiceImpl extends BaseServiceImpl%s", obj.getRowNum())); iterator.remove(); } else { @@ -338,14 +364,18 @@ public class IcPartyUnitServiceImpl extends BaseServiceImpl list = baseDao.selectList(wrapper); if (CollectionUtils.isNotEmpty(list)) { - numList.add(obj.getRowNum()); + IcPartyUnitImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyUnitImportFailedExcel.class); + failed.setErrorInfo("单位名称已存在"); + fileList.add(failed); log.warn(String.format("单位名称已存在,行号->%s", obj.getRowNum())); iterator.remove(); } } //分类校验 if (StringUtils.isBlank(obj.getType()) || null == PartyUnitTypeEnum.getCode(obj.getType())) { - numList.add(obj.getRowNum()); + IcPartyUnitImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyUnitImportFailedExcel.class); + failed.setErrorInfo("分类名不存在"); + fileList.add(failed); log.warn(String.format("分类名不存在,行号->%s", obj.getRowNum())); iterator.remove(); } @@ -354,62 +384,139 @@ public class IcPartyUnitServiceImpl extends BaseServiceImpl matters = Arrays.asList(obj.getServiceMatter().split(StrConstant.COLON)); matters.forEach(item -> { if (null == categoryMap.get(item)) { - numList.add(obj.getRowNum()); + IcPartyUnitImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyUnitImportFailedExcel.class); + failed.setErrorInfo("服务事项不存在"); + fileList.add(failed); log.warn(String.format("服务事项不存在,行号->%s", obj.getRowNum())); iterator.remove(); } }); } //联系人 联系电话 在职党员 地址 中心位置经度 中心位置纬度 校验 - if (StringUtils.isBlank(obj.getContact()) || StringUtils.isBlank(obj.getContactMobile()) || - StringUtils.isBlank(obj.getContact()) || - null == obj.getMemberCount() || - StringUtils.isBlank(obj.getLatitude()) || - StringUtils.isBlank(obj.getLongitude())) { - numList.add(obj.getRowNum()); - log.warn(String.format("联系人、联系电话、在职党员、地址、中心位置经度、中心位置纬度为空,行号->%s", obj.getRowNum())); + if (StringUtils.isBlank(obj.getContact())) { + IcPartyUnitImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyUnitImportFailedExcel.class); + failed.setErrorInfo("联系人为空"); + fileList.add(failed); + log.warn(String.format("联系人为空,行号->%s", obj.getRowNum())); iterator.remove(); + } else if (StringUtils.isBlank(obj.getContactMobile())) { + IcPartyUnitImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyUnitImportFailedExcel.class); + failed.setErrorInfo("联系电话为空"); + fileList.add(failed); + log.warn(String.format("联系电话为空,行号->%s", obj.getRowNum())); + } else if (StringUtils.isBlank(obj.getAddress())) { + IcPartyUnitImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyUnitImportFailedExcel.class); + failed.setErrorInfo("地址为空"); + fileList.add(failed); + log.warn(String.format("地址为空,行号->%s", obj.getRowNum())); + } else if (null == obj.getMemberCount()) { + IcPartyUnitImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyUnitImportFailedExcel.class); + failed.setErrorInfo("在职党员为空"); + fileList.add(failed); + log.warn(String.format("在职党员为空,行号->%s", obj.getRowNum())); + } else if (StringUtils.isBlank(obj.getLatitude())) { + IcPartyUnitImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyUnitImportFailedExcel.class); + failed.setErrorInfo("中心位置纬度为空"); + fileList.add(failed); + log.warn(String.format("中心位置纬度为空,行号->%s", obj.getRowNum())); + } else if (StringUtils.isBlank(obj.getLongitude())) { + IcPartyUnitImportFailedExcel failed = ConvertUtils.sourceToTarget(obj, IcPartyUnitImportFailedExcel.class); + failed.setErrorInfo("中心位置经度为空"); + fileList.add(failed); + log.warn(String.format("中心位置经度为空,行号->%s", obj.getRowNum())); } } - if (CollectionUtils.isEmpty(result)) { - Collections.sort(numList); - String subList = numList.stream().map(String::valueOf).collect(Collectors.joining("、")); - return new Result().error(9999, "第" + subList + "行未成功!"); - } - - List list = result.stream().map(item -> { - IcPartyUnitEntity entity = new IcPartyUnitEntity(); - entity.setCustomerId(tokenDto.getCustomerId()); - entity.setAgencyId(staffInfoCache.getAgencyId()); - entity.setPids(staffInfoCache.getAgencyPIds()); - entity.setUnitName(item.getUnitName()); - entity.setType(PartyUnitTypeEnum.getCode(item.getType())); - if (StringUtils.isNotBlank(item.getServiceMatter())) { - entity.setServiceMatter(getServiceMatter(categoryMap, item.getServiceMatter())); - } - entity.setContact(item.getContact()); - entity.setContactMobile(item.getContactMobile()); - entity.setAddress(item.getAddress()); - entity.setLatitude(item.getLatitude()); - entity.setLongitude(item.getLongitude()); - entity.setMemberCount(item.getMemberCount()); - entity.setRemark(item.getRemark()); - return entity; - }).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(result)) { + List list = result.stream().map(item -> { + IcPartyUnitEntity entity = new IcPartyUnitEntity(); + entity.setCustomerId(tokenDto.getCustomerId()); + entity.setAgencyId(staffInfoCache.getAgencyId()); + entity.setPids(staffInfoCache.getAgencyPIds()); + entity.setUnitName(item.getUnitName()); + entity.setType(PartyUnitTypeEnum.getCode(item.getType())); + if (StringUtils.isNotBlank(item.getServiceMatter())) { + entity.setServiceMatter(getServiceMatter(categoryMap, item.getServiceMatter())); + } + entity.setContact(item.getContact()); + entity.setContactMobile(item.getContactMobile()); + entity.setAddress(item.getAddress()); + entity.setLatitude(item.getLatitude()); + entity.setLongitude(item.getLongitude()); + entity.setMemberCount(item.getMemberCount()); + entity.setRemark(item.getRemark()); + return entity; + }).collect(Collectors.toList()); - insertBatch(list); + insertBatch(list); + } - String str = String.format("共%s条,成功导入%s条。", numList.size() + result.size(), numList.size() + result.size() - numList.size()); - if (numList.size() > NumConstant.ZERO) { - Collections.sort(numList); + String str = String.format("共%s条,成功导入%s条。", fileList.size() + result.size(), fileList.size() + result.size() - fileList.size()); + if (fileList.size() > NumConstant.ZERO) { + List numList = fileList.stream().map(IcPartyUnitImportFailedExcel::getRowNum).sorted().collect(Collectors.toList()); String subList = numList.stream().map(String::valueOf).collect(Collectors.joining("、")); log.warn(str + "第" + subList + "行未成功!"); - return new Result().error(9999, str + "第" + subList + "行未成功!"); } - return new Result().ok(str); + + //错误数据生成文件,修改导入任务状态 + erroeImport(fileList, taskId, tokenDto.getUserId()); } + private void erroeImport(List fileList, String importTaskId, String staffId) throws IOException { + String url = ""; + //1.有错误数据则生成错误数据存放文件传到阿里云服务 + if (CollectionUtils.isNotEmpty(fileList)) { + Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("导入失败的数据列表", "导入失败的数据列表"), + IcPartyUnitImportFailedExcel.class, fileList); + // 文件名 + String resultDescFileName = UUID.randomUUID().toString().concat(".xlsx"); + FileItemFactory factory = new DiskFileItemFactory(16, null); + FileItem fileItem = factory.createItem("file", ContentType.APPLICATION_OCTET_STREAM.toString(), true, resultDescFileName); + OutputStream os = fileItem.getOutputStream(); + Result uploadResult = null; + try { + workbook.write(os); + uploadResult = ossFeignClient.uploadImportTaskDescFile(new CommonsMultipartFile(fileItem)); + } catch (Exception e) { + String errormsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【联建单位信息导入】上传错误描述文件:{}", errormsg); + } finally { + try { + os.close(); + } catch (IOException e) { + String errormsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【联建单位信息导入】上传错误描述文件关闭输出流:{}", errormsg); + } + try { + fileItem.delete(); + } catch (Exception e) { + String errormsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【联建单位信息导入】上传错误描述文件删除临时文件:{}", errormsg); + } + } + + if (uploadResult == null || !uploadResult.success()) { + log.error("【联建单位信息导入】调用OSS上传结果描述文件失败"); + } else { + url = uploadResult.getData().getUrl(); + } + } + //2.更新导入任务数据 + ImportTaskCommonFormDTO importTaskForm = new ImportTaskCommonFormDTO(); + importTaskForm.setOperatorId(staffId); + importTaskForm.setBizType(ImportTaskConstants.BIZ_TYPE_PARTY_UNIT); + importTaskForm.setTaskId(importTaskId); + importTaskForm.setResultDescFilePath(url); + importTaskForm.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_SUCCESS); + if (CollectionUtils.isNotEmpty(fileList)) { + importTaskForm.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL); + importTaskForm.setResultDesc("联建单位导入存在错误数据"); + } + Result result = commonServiceOpenFeignClient.finishImportTask(importTaskForm); + if (!result.success()) { + throw new RenException(result.getInternalMsg()); + } + } /** * @param formDTO * @Description 按类型统计单位数量 @@ -493,4 +600,4 @@ public class IcPartyUnitServiceImpl extends BaseServiceImpl page(Map params) { @@ -158,6 +165,8 @@ public class LatestActInfoServiceImpl extends BaseServiceImpl implements LatestActServiceRelationService { + + + /** + * 获取活动所属服务事项列表 + * + * @param actId + * @Param actId + * @Return {@link List < String>} + * @Author zhaoqifeng + * @Date 2022/2/22 14:53 + */ + @Override + public List getServiceMatterList(String actId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(LatestActServiceRelationEntity::getActId, actId); + wrapper.orderByAsc(LatestActServiceRelationEntity::getSort); + List list = baseDao.selectList(wrapper); + if (CollectionUtils.isEmpty(list)) { + return Collections.emptyList(); + } + return list.stream().map(LatestActServiceRelationEntity::getServiceMatter).collect(Collectors.toList()); + } + + /** + * 删除活动所属服务事项 + * + * @param actId + * @Param actId + * @Return + * @Author zhaoqifeng + * @Date 2022/2/22 14:54 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteByAct(String actId) { + baseDao.deleteByActivity(actId); + } + + /** + * 逻辑删除活动所属服务事项 + * + * @param actId + * @Param actId + * @Return + * @Author zhaoqifeng + * @Date 2022/2/22 14:54 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String actId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(LatestActServiceRelationEntity::getActId, actId); + baseDao.delete(wrapper); + } +} \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/LatestActUnitRelationServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/LatestActUnitRelationServiceImpl.java new file mode 100644 index 0000000000..ceaa0ff9a6 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/LatestActUnitRelationServiceImpl.java @@ -0,0 +1,78 @@ +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.dao.LatestActUnitRelationDao; +import com.epmet.entity.LatestActUnitRelationEntity; +import com.epmet.service.LatestActUnitRelationService; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 联建活动与单位关联表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-02-21 + */ +@Service +public class LatestActUnitRelationServiceImpl extends BaseServiceImpl implements LatestActUnitRelationService { + + + /** + * 获取活动所属联建单位列表 + * + * @param actId + * @Param actId + * @Return {@link List < String>} + * @Author zhaoqifeng + * @Date 2022/2/22 14:53 + */ + @Override + public List getUnitList(String actId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(LatestActUnitRelationEntity::getActId, actId); + wrapper.orderByAsc(LatestActUnitRelationEntity::getSort); + List list = baseDao.selectList(wrapper); + if (CollectionUtils.isEmpty(list)) { + return Collections.emptyList(); + } + return list.stream().map(LatestActUnitRelationEntity::getUnitId).collect(Collectors.toList()); + } + + /** + * 删除活动所属单位列表 + * + * @param actId + * @Param actId + * @Return + * @Author zhaoqifeng + * @Date 2022/2/22 14:54 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteByAct(String actId) { + baseDao.deleteByActivity(actId); + } + + /** + * 逻辑删除活动所属单位列表 + * + * @param actId + * @Param actId + * @Return + * @Author zhaoqifeng + * @Date 2022/2/22 14:54 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String actId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(LatestActUnitRelationEntity::getActId, actId); + baseDao.delete(wrapper); + } +} \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActDraftServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActDraftServiceImpl.java index 5572a48f48..1273ffa577 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActDraftServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActDraftServiceImpl.java @@ -1,8 +1,10 @@ package com.epmet.service.impl; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.security.user.LoginUserUtil; import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.constant.ActConstant; import com.epmet.dto.IcPartyUnitDTO; import com.epmet.dto.LatestActContentDTO; import com.epmet.dto.LatestActInfoDTO; @@ -11,6 +13,8 @@ import com.epmet.dto.form.work.DraftActContentFormDTO; import com.epmet.dto.form.work.DraftActInfoFormDTO; import com.epmet.dto.result.demand.OptionDTO; import com.epmet.dto.result.work.*; +import com.epmet.entity.LatestActServiceRelationEntity; +import com.epmet.entity.LatestActUnitRelationEntity; import com.epmet.service.*; import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; @@ -24,6 +28,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; /** @@ -45,7 +50,10 @@ public class WorkActDraftServiceImpl implements WorkActDraftService { private IcServiceItemDictService icServiceItemDictService; @Resource private IcPartyUnitService icPartyUnitService; - + @Resource + private LatestActServiceRelationService latestActServiceRelationService; + @Resource + private LatestActUnitRelationService latestActUnitRelationService; /** * @return com.epmet.dto.form.work.PublishActInitResultDTO @@ -86,6 +94,10 @@ public class WorkActDraftServiceImpl implements WorkActDraftService { if(null!=latestAct){ List actContentList=latestActContentService.selectActContentList(latestAct.getActDraftId()); latestAct.setActContent(actContentList); + List unitList = latestActUnitRelationService.getUnitList(latestAct.getActDraftId()); + latestAct.setUnitIdList(unitList); + List serviceList = latestActServiceRelationService.getServiceMatterList(latestAct.getActDraftId()); + latestAct.setServiceMatterList(serviceList); } return latestAct; }else{ @@ -116,6 +128,32 @@ public class WorkActDraftServiceImpl implements WorkActDraftService { } SaveActDraftResultDTO resultDTO=new SaveActDraftResultDTO(); resultDTO.setActDraftId(actDraftId); + + //保存活动与服务关系 + latestActServiceRelationService.deleteByAct(actDraftId); + AtomicInteger i = new AtomicInteger(NumConstant.ONE); + List serviceList = formDTO.getServiceMatterList().stream().map(service -> { + LatestActServiceRelationEntity entity = new LatestActServiceRelationEntity(); + entity.setCustomerId(formDTO.getCustomerId()); + entity.setActId(actDraftId); + entity.setServiceMatter(service); + entity.setSort(i.getAndIncrement()); + return entity; + }).collect(Collectors.toList()); + latestActServiceRelationService.insertBatch(serviceList); + + //保存活动与单位关系 + latestActUnitRelationService.deleteByAct(actDraftId); + AtomicInteger j = new AtomicInteger(NumConstant.ONE); + List unitList = formDTO.getUnitIdList().stream().map(unitId -> { + LatestActUnitRelationEntity entity = new LatestActUnitRelationEntity(); + entity.setCustomerId(formDTO.getCustomerId()); + entity.setActId(actDraftId); + entity.setUnitId(unitId); + entity.setSort(j.getAndIncrement()); + return entity; + }).collect(Collectors.toList()); + latestActUnitRelationService.insertBatch(unitList); return resultDTO; } @@ -146,6 +184,24 @@ public class WorkActDraftServiceImpl implements WorkActDraftService { IcPartyUnitDTO unitDTO = icPartyUnitService.get(actPreviewResultDTO.getUnitId()); actPreviewResultDTO.setUnitName(unitDTO.getUnitName()); } + if (ActConstant.PARTY.equals(actPreviewResultDTO.getActType())) { + //获取服务事项 + List serviceItemList = icServiceItemDictService.queryDictList(formDTO.getCustomerId()); + Map categoryMap = serviceItemList.stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel)); + List services = latestActServiceRelationService.getServiceMatterList(formDTO.getActDraftId()); + List serviceNames = services.stream().map(categoryMap::get).collect(Collectors.toList()); + actPreviewResultDTO.setServiceMatterList(services); + actPreviewResultDTO.setServiceMatterNameList(serviceNames); + + //获取联建单位 + IcPartyUnitDTO unitDTO = new IcPartyUnitDTO(); + unitDTO.setAgencyId(ActConstant.SPONSOR_AGENCY.equals(actPreviewResultDTO.getSponsorType())?actPreviewResultDTO.getSponsorId():actPreviewResultDTO.getPid()); + Map option = icPartyUnitService.option(unitDTO).stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel)); + List unitIds = latestActUnitRelationService.getUnitList(formDTO.getActDraftId()); + List unitNames = unitIds.stream().map(option::get).collect(Collectors.toList()); + actPreviewResultDTO.setUnitIdList(unitIds); + actPreviewResultDTO.setUnitNameList(unitNames); + } } return actPreviewResultDTO; } @@ -280,9 +336,7 @@ public class WorkActDraftServiceImpl implements WorkActDraftService { latestActInfoDTO.setAuditSwitch(formDTO.getAuditSwitch()); latestActInfoDTO.setActType(formDTO.getActType()); - latestActInfoDTO.setUnitId(formDTO.getUnitId()); latestActInfoDTO.setTarget(formDTO.getTarget()); - latestActInfoDTO.setServiceMatter(formDTO.getServiceMatter()); return latestActInfoDTO; } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActServiceImpl.java index 7b076059b9..7ab8dc2e52 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActServiceImpl.java @@ -33,7 +33,6 @@ import com.epmet.entity.*; import com.epmet.feign.EpmetMessageOpenFeignClient; import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.service.*; -import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -44,6 +43,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; @@ -102,6 +102,10 @@ public class WorkActServiceImpl implements WorkActService { private IcPartyUnitService icPartyUnitService; @Resource private IcServiceItemDictService icServiceItemDictService; + @Resource + private IcActivityUnitRelationService icActivityUnitRelationService; + @Resource + private IcActivityServiceRelationService icActivityServiceRelationService; /** @@ -232,6 +236,36 @@ public class WorkActServiceImpl implements WorkActService { if (ActConstant.PARTY.equals(formDTO.getActType())) { IcPartyActivityEntity activity = getPartyActivityEntity(formDTO, actInfoEntity); icPartyActivityService.insert(activity); + + //保存活动与单位关系 + icActivityUnitRelationService.deleteByActivity(activity.getId()); + AtomicInteger i = new AtomicInteger(NumConstant.ONE); + List unitRelationList = formDTO.getUnitIdList().stream().map(unitId -> { + IcActivityUnitRelationEntity relation = new IcActivityUnitRelationEntity(); + relation.setCustomerId(activity.getCustomerId()); + relation.setAgencyId(activity.getAgencyId()); + relation.setPids(activity.getPids()); + relation.setActivityId(activity.getId()); + relation.setUnitId(unitId); + relation.setSort(i.getAndIncrement()); + return relation; + }).collect(Collectors.toList()); + icActivityUnitRelationService.insertBatch(unitRelationList); + + //保存活动与服务关系 + icActivityServiceRelationService.deleteByActivity(activity.getId()); + AtomicInteger j = new AtomicInteger(NumConstant.ONE); + List serviceRelationList = formDTO.getServiceMatterList().stream().map(service -> { + IcActivityServiceRelationEntity relation = new IcActivityServiceRelationEntity(); + relation.setCustomerId(activity.getCustomerId()); + relation.setAgencyId(activity.getAgencyId()); + relation.setPids(activity.getPids()); + relation.setActivityId(activity.getId()); + relation.setServiceMatter(service); + relation.setSort(j.getAndIncrement()); + return relation; + }).collect(Collectors.toList()); + icActivityServiceRelationService.insertBatch(serviceRelationList); } return publishActResultDTO; @@ -779,17 +813,26 @@ public class WorkActServiceImpl implements WorkActService { canceledActDetailResultDTO.setIsMyPublish(false); } - if (StringUtils.isNotBlank(canceledActDetailResultDTO.getServiceMatter())) { - //获取服务事项 - List serviceItemList = icServiceItemDictService.queryDictList(customerId); - Map categoryMap = serviceItemList.stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel)); - canceledActDetailResultDTO.setServiceMatterName(MapUtils.isNotEmpty(categoryMap) && categoryMap.containsKey(canceledActDetailResultDTO.getServiceMatter()) ? - categoryMap.get(canceledActDetailResultDTO.getServiceMatter()) : StrConstant.EPMETY_STR); - } - if (StringUtils.isNotBlank(canceledActDetailResultDTO.getUnitId())) { - //获取单位名称 - IcPartyUnitDTO unitDTO = icPartyUnitService.get(canceledActDetailResultDTO.getUnitId()); - canceledActDetailResultDTO.setUnitName(unitDTO.getUnitName()); + if (ActConstant.PARTY.equals(canceledActDetailResultDTO.getActType())) { + IcPartyActivityDTO dto = icPartyActivityService.getActivityByActId(actId); + if (null != dto) { + //获取服务事项 + List serviceItemList = icServiceItemDictService.queryDictList(customerId); + Map categoryMap = serviceItemList.stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel)); + List services = icActivityServiceRelationService.getServiceList(dto.getId()); + List serviceNames = services.stream().map(categoryMap::get).collect(Collectors.toList()); + canceledActDetailResultDTO.setServiceMatterList(services); + canceledActDetailResultDTO.setServiceMatterNameList(serviceNames); + + //获取联建单位 + IcPartyUnitDTO unitDTO = new IcPartyUnitDTO(); + unitDTO.setAgencyId(dto.getAgencyId()); + Map option = icPartyUnitService.option(unitDTO).stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel)); + List unitIds = icActivityUnitRelationService.getUnitList(dto.getId()); + List unitNames = unitIds.stream().map(option::get).collect(Collectors.toList()); + canceledActDetailResultDTO.setUnitIdList(unitIds); + canceledActDetailResultDTO.setUnitNameList(unitNames); + } } } return canceledActDetailResultDTO; @@ -835,17 +878,26 @@ public class WorkActServiceImpl implements WorkActService { }else{ resultDTO.setIsMyPublish(false); } - - if (StringUtils.isNotBlank(resultDTO.getServiceMatter())) { - //获取服务事项 - List serviceItemList = icServiceItemDictService.queryDictList(formDTO.getCustomerId()); - Map categoryMap = serviceItemList.stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel)); - resultDTO.setServiceMatterName(MapUtils.isNotEmpty(categoryMap) && categoryMap.containsKey(resultDTO.getServiceMatter()) ? categoryMap.get(resultDTO.getServiceMatter()) : StrConstant.EPMETY_STR); - } - if (StringUtils.isNotBlank(resultDTO.getUnitId())) { - //获取单位名称 - IcPartyUnitDTO unitDTO = icPartyUnitService.get(resultDTO.getUnitId()); - resultDTO.setUnitName(unitDTO.getUnitName()); + if (ActConstant.PARTY.equals(resultDTO.getActType())) { + IcPartyActivityDTO dto = icPartyActivityService.getActivityByActId(formDTO.getActId()); + if (null != dto) { + //获取服务事项 + List serviceItemList = icServiceItemDictService.queryDictList(formDTO.getCustomerId()); + Map categoryMap = serviceItemList.stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel)); + List services = icActivityServiceRelationService.getServiceList(dto.getId()); + List serviceNames = services.stream().map(categoryMap::get).collect(Collectors.toList()); + resultDTO.setServiceMatterList(services); + resultDTO.setServiceMatterNameList(serviceNames); + + //获取联建单位 + IcPartyUnitDTO unitDTO = new IcPartyUnitDTO(); + unitDTO.setAgencyId(dto.getAgencyId()); + Map option = icPartyUnitService.option(unitDTO).stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel)); + List unitIds = icActivityUnitRelationService.getUnitList(dto.getId()); + List unitNames = unitIds.stream().map(option::get).collect(Collectors.toList()); + resultDTO.setUnitIdList(unitIds); + resultDTO.setUnitNameList(unitNames); + } } } return resultDTO; @@ -915,16 +967,26 @@ public class WorkActServiceImpl implements WorkActService { }else{ resultDTO.setIsMyPublish(false); } - if (StringUtils.isNotBlank(resultDTO.getServiceMatter())) { - //获取服务事项 - List serviceItemList=icServiceItemDictService.queryDictList(customerId); - Map categoryMap=serviceItemList.stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel)); - resultDTO.setServiceMatterName(MapUtils.isNotEmpty(categoryMap) && categoryMap.containsKey(resultDTO.getServiceMatter()) ? categoryMap.get(resultDTO.getServiceMatter()) : StrConstant.EPMETY_STR); - } - if (StringUtils.isNotBlank(resultDTO.getUnitId())) { - //获取单位名称 - IcPartyUnitDTO unitDTO = icPartyUnitService.get(resultDTO.getUnitId()); - resultDTO.setUnitName(unitDTO.getUnitName()); + if (ActConstant.PARTY.equals(resultDTO.getActType())) { + IcPartyActivityDTO dto = icPartyActivityService.getActivityByActId(actId); + if (null != dto) { + //获取服务事项 + List serviceItemList = icServiceItemDictService.queryDictList(customerId); + Map categoryMap = serviceItemList.stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel)); + List services = icActivityServiceRelationService.getServiceList(dto.getId()); + List serviceNames = services.stream().map(categoryMap::get).collect(Collectors.toList()); + resultDTO.setServiceMatterList(services); + resultDTO.setServiceMatterNameList(serviceNames); + + //获取联建单位 + IcPartyUnitDTO unitDTO = new IcPartyUnitDTO(); + unitDTO.setAgencyId(dto.getAgencyId()); + Map option = icPartyUnitService.option(unitDTO).stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel)); + List unitIds = icActivityUnitRelationService.getUnitList(dto.getId()); + List unitNames = unitIds.stream().map(option::get).collect(Collectors.toList()); + resultDTO.setUnitIdList(unitIds); + resultDTO.setUnitNameList(unitNames); + } } } return resultDTO; @@ -1309,16 +1371,26 @@ public class WorkActServiceImpl implements WorkActService { List actContent=actContentDao.selectByActId(actId); resultDTO.setActContent(actContent); - if (StringUtils.isNotBlank(resultDTO.getServiceMatter())) { - //获取服务事项 - List serviceItemList=icServiceItemDictService.queryDictList(customerId); - Map categoryMap=serviceItemList.stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel)); - resultDTO.setServiceMatterName(MapUtils.isNotEmpty(categoryMap) && categoryMap.containsKey(resultDTO.getServiceMatter()) ? categoryMap.get(resultDTO.getServiceMatter()) : StrConstant.EPMETY_STR); - } - if (StringUtils.isNotBlank(resultDTO.getUnitId())) { - //获取单位名称 - IcPartyUnitDTO unitDTO = icPartyUnitService.get(resultDTO.getUnitId()); - resultDTO.setUnitName(unitDTO.getUnitName()); + if (ActConstant.PARTY.equals(resultDTO.getActType())) { + IcPartyActivityDTO dto = icPartyActivityService.getActivityByActId(actId); + if (null != dto) { + //获取服务事项 + List serviceItemList = icServiceItemDictService.queryDictList(customerId); + Map categoryMap = serviceItemList.stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel)); + List services = icActivityServiceRelationService.getServiceList(dto.getId()); + List serviceNames = services.stream().map(categoryMap::get).collect(Collectors.toList()); + resultDTO.setServiceMatterList(services); + resultDTO.setServiceMatterNameList(serviceNames); + + //获取联建单位 + IcPartyUnitDTO unitDTO = new IcPartyUnitDTO(); + unitDTO.setAgencyId(dto.getAgencyId()); + Map option = icPartyUnitService.option(unitDTO).stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel)); + List unitIds = icActivityUnitRelationService.getUnitList(dto.getId()); + List unitNames = unitIds.stream().map(option::get).collect(Collectors.toList()); + resultDTO.setUnitIdList(unitIds); + resultDTO.setUnitNameList(unitNames); + } } return resultDTO; @@ -1438,6 +1510,36 @@ public class WorkActServiceImpl implements WorkActService { IcPartyActivityEntity activity = getPartyActivityEntity(ConvertUtils.sourceToTarget(rePublishFormDTO, PublishActInfoFormDTO.class), newActInfoEntity); activity.setId(activityDTO.getId()); icPartyActivityService.updateById(activity); + + //保存活动与单位关系 + icActivityUnitRelationService.deleteByActivity(activity.getId()); + AtomicInteger i = new AtomicInteger(NumConstant.ONE); + List unitRelationList = rePublishFormDTO.getUnitIdList().stream().map(unitId -> { + IcActivityUnitRelationEntity relation = new IcActivityUnitRelationEntity(); + relation.setCustomerId(activityDTO.getCustomerId()); + relation.setAgencyId(activityDTO.getAgencyId()); + relation.setPids(activityDTO.getPids()); + relation.setActivityId(activityDTO.getId()); + relation.setUnitId(unitId); + relation.setSort(i.getAndIncrement()); + return relation; + }).collect(Collectors.toList()); + icActivityUnitRelationService.insertBatch(unitRelationList); + + //保存活动与服务关系 + icActivityServiceRelationService.deleteByActivity(activity.getId()); + AtomicInteger j = new AtomicInteger(NumConstant.ONE); + List serviceRelationList = rePublishFormDTO.getServiceMatterList().stream().map(service -> { + IcActivityServiceRelationEntity relation = new IcActivityServiceRelationEntity(); + relation.setCustomerId(activityDTO.getCustomerId()); + relation.setAgencyId(activityDTO.getAgencyId()); + relation.setPids(activityDTO.getPids()); + relation.setActivityId(activityDTO.getId()); + relation.setServiceMatter(service); + relation.setSort(j.getAndIncrement()); + return relation; + }).collect(Collectors.toList()); + icActivityServiceRelationService.insertBatch(serviceRelationList); } } @@ -1462,8 +1564,6 @@ public class WorkActServiceImpl implements WorkActService { logger.warn("根据agencyId查询组织信息失败,agencyId={}",formDTO.getSponsorId()); } entity.setActId(actInfoEntity.getId()); - entity.setUnitId(actInfoEntity.getUnitId()); - entity.setServiceMatter(actInfoEntity.getServiceMatter()); entity.setTitle(actInfoEntity.getTitle()); entity.setTarget(actInfoEntity.getTarget()); entity.setContent(getContent(formDTO.getActContent())); diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/bootstrap.yml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/bootstrap.yml index aa43055c8e..31db2a802b 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/bootstrap.yml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/bootstrap.yml @@ -150,3 +150,14 @@ shutdown: graceful: enable: true #是否开启优雅停机 waitTimeSecs: 30 # 优雅停机等待时间,超过30秒,发出告警 + +thread: + # 线程池配置 + threadPool: + enableCustomize: @thread.threadPool.enable-customize@ + corePoolSize: @thread.threadPool.core-pool-size@ + maxPoolSize: @thread.threadPool.max-pool-size@ + queueCapacity: @thread.threadPool.queue-capacity@ + keepAliveSeconds: @thread.threadPool.keep-alive-seconds@ + threadNamePrefix: @thread.threadPool.thread-name-prefix@ + rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@ diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/db/migration/V0.0.11__ic_party_change.sql b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/db/migration/V0.0.11__ic_party_change.sql new file mode 100644 index 0000000000..ad3305d8f3 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/db/migration/V0.0.11__ic_party_change.sql @@ -0,0 +1,68 @@ +CREATE TABLE `ic_activity_service_relation` ( + `ID` varchar(64) NOT NULL COMMENT '主键', + `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户id', + `AGENCY_ID` varchar(64) NOT NULL COMMENT '组织ID', + `PIDS` varchar(255) DEFAULT NULL COMMENT '组织的所有上级', + `ACTIVITY_ID` varchar(32) NOT NULL COMMENT '活动ID', + `ACT_ID` varchar(64) DEFAULT NULL COMMENT 'act_info表ID', + `SERVICE_MATTER` varchar(32) NOT NULL DEFAULT '1' COMMENT '服务事项', + `SORT` int(4) DEFAULT NULL COMMENT '排序', + `DEL_FLAG` varchar(1) NOT NULL DEFAULT '0' COMMENT '删除标识 0未删除、1已删除', + `REVISION` int(11) NOT NULL DEFAULT '0' 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 '更新时间', + PRIMARY KEY (`ID`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='联建活动与服务事项关联表'; +CREATE TABLE `ic_activity_unit_relation` ( + `ID` varchar(64) NOT NULL COMMENT '主键', + `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户id', + `AGENCY_ID` varchar(64) NOT NULL COMMENT '组织ID', + `PIDS` varchar(255) DEFAULT NULL COMMENT '组织的所有上级', + `ACTIVITY_ID` varchar(32) NOT NULL COMMENT '活动ID', + `ACT_ID` varchar(64) DEFAULT NULL COMMENT 'act_info表ID', + `UNIT_ID` varchar(32) NOT NULL COMMENT '单位ID', + `SORT` int(4) DEFAULT '1' COMMENT '排序', + `DEL_FLAG` varchar(1) NOT NULL DEFAULT '0' COMMENT '删除标识 0未删除、1已删除', + `REVISION` int(11) NOT NULL DEFAULT '0' 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 '更新时间', + PRIMARY KEY (`ID`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='联建活动与单位关联表'; +CREATE TABLE `latest_act_service_relation` ( + `ID` varchar(64) NOT NULL COMMENT '主键', + `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户id', + `ACT_ID` varchar(64) DEFAULT NULL COMMENT 'latest_act_info表ID', + `SERVICE_MATTER` varchar(32) NOT NULL COMMENT '服务事项', + `SORT` int(4) DEFAULT '1' COMMENT '排序', + `DEL_FLAG` varchar(1) NOT NULL DEFAULT '0' COMMENT '删除标识 0未删除、1已删除', + `REVISION` int(11) NOT NULL DEFAULT '0' 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 '更新时间', + PRIMARY KEY (`ID`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='联建活动与服务事项关联表'; +CREATE TABLE `latest_act_unit_relation` ( + `ID` varchar(64) NOT NULL DEFAULT '1' COMMENT '主键', + `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户id', + `ACT_ID` varchar(64) DEFAULT NULL COMMENT 'latest_act_info表ID', + `UNIT_ID` varchar(32) NOT NULL COMMENT '单位ID', + `SORT` int(4) DEFAULT NULL COMMENT '排序', + `DEL_FLAG` varchar(1) NOT NULL DEFAULT '0' COMMENT '删除标识 0未删除、1已删除', + `REVISION` int(11) NOT NULL DEFAULT '0' 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 '更新时间', + PRIMARY KEY (`ID`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='联建活动与单位关联表'; + +ALTER TABLE `epmet_heart`.`ic_party_activity` + MODIFY COLUMN `UNIT_ID` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '单位ID' AFTER `ACT_ID`, + MODIFY COLUMN `SERVICE_MATTER` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '服务事项' AFTER `UNIT_ID`; + +UPDATE act_info SET ACT_TYPE = 'heart' WHERE ACT_TYPE IS NULL; \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/db/migration/V0.0.12__insert_ic_party_relation.sql b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/db/migration/V0.0.12__insert_ic_party_relation.sql new file mode 100644 index 0000000000..41aaf825dd --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/db/migration/V0.0.12__insert_ic_party_relation.sql @@ -0,0 +1,40 @@ +INSERT INTO ic_activity_unit_relation +SELECT + UUID() AS ID, + CUSTOMER_ID, + AGENCY_ID, + PIDS, + ID AS ACTIVITY_ID, + ACT_ID, + UNIT_ID, + 1 AS SORT, + DEL_FLAG, + REVISION, + CREATED_BY, + NOW(), + UPDATED_BY, + NOW() +FROM + ic_party_activity +WHERE UNIT_ID IS NOT NULL AND UNIT_ID != ''; +UPDATE ic_activity_unit_relation SET ID = REPLACE (ID, '-', ''); +INSERT INTO ic_activity_service_relation +SELECT + UUID() AS ID, + CUSTOMER_ID, + AGENCY_ID, + PIDS, + ID AS ACTIVITY_ID, + ACT_ID, + SERVICE_MATTER, + 1 AS SORT, + DEL_FLAG, + REVISION, + CREATED_BY, + NOW(), + UPDATED_BY, + NOW() +FROM + ic_party_activity +WHERE SERVICE_MATTER IS NOT NULL AND UNIT_ID != ''; +UPDATE ic_activity_service_relation SET ID = REPLACE (ID, '-', ''); \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcActivityServiceRelationDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcActivityServiceRelationDao.xml new file mode 100644 index 0000000000..dabb923f67 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcActivityServiceRelationDao.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + DELETE FROM ic_activity_service_relation WHERE ACTIVITY_ID = #{activityId} + + + + \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcActivityUnitRelationDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcActivityUnitRelationDao.xml new file mode 100644 index 0000000000..f8947c98e4 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcActivityUnitRelationDao.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + DELETE FROM ic_activity_unit_relation WHERE ACTIVITY_ID = #{activityId} + + + + \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcCommunitySelfOrganizationDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcCommunitySelfOrganizationDao.xml index fc1a118ced..d2575e0af0 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcCommunitySelfOrganizationDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcCommunitySelfOrganizationDao.xml @@ -97,4 +97,18 @@ #{n} + + + \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcPartyActivityDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcPartyActivityDao.xml index ede5b4c0e1..429461fbfb 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcPartyActivityDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcPartyActivityDao.xml @@ -28,14 +28,16 @@ + + + \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/LatestActInfoDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/LatestActInfoDao.xml index 67f4cb64a7..1bcd53d153 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/LatestActInfoDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/LatestActInfoDao.xml @@ -114,6 +114,9 @@ lai.SPONSOR_NAME AS sponsorName, lai.SPONSOR_CONTACTS AS sponsorContacts, lai.SPONSOR_TEL AS sponsorTel, + lai.SPONSOR_TYPE, + lai.SPONSOR_ID, + lai.PID, lai.ACT_TYPE, lai.UNIT_ID, lai.SERVICE_MATTER, diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/LatestActServiceRelationDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/LatestActServiceRelationDao.xml new file mode 100644 index 0000000000..abc0deda55 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/LatestActServiceRelationDao.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + DELETE FROM latest_act_service_relation WHERE ACT_ID = #{activityId} + + + \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/LatestActUnitRelationDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/LatestActUnitRelationDao.xml new file mode 100644 index 0000000000..e679b5dc53 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/LatestActUnitRelationDao.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + DELETE FROM latest_act_unit_relation WHERE ACT_ID = #{activityId} + + + \ No newline at end of file diff --git a/epmet-module/epmet-job/epmet-job-server/pom.xml b/epmet-module/epmet-job/epmet-job-server/pom.xml index db2669bc48..4b6620ada0 100644 --- a/epmet-module/epmet-job/epmet-job-server/pom.xml +++ b/epmet-module/epmet-job/epmet-job-server/pom.xml @@ -102,6 +102,12 @@ 2.0.0 compile + + com.epmet + data-aggregator-client + 2.0.0 + compile + diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/controller/DemoController.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/controller/DemoController.java index 6bb9718720..b0f2b3a32f 100644 --- a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/controller/DemoController.java +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/controller/DemoController.java @@ -8,12 +8,16 @@ package com.epmet.controller; +import com.alibaba.fastjson.JSON; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.dataaggre.dto.govorg.form.GridLivelyFormDTO; +import com.epmet.dataaggre.feign.DataAggregatorOpenFeignClient; import com.epmet.feign.DataStatisticalOpenFeignClient; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; /** * 定时任务 @@ -27,6 +31,8 @@ public class DemoController { @Autowired private DataStatisticalOpenFeignClient client; + @Autowired + private DataAggregatorOpenFeignClient dataAggregatorFeignClient; @GetMapping("testAlarm") public void testAlarm() { @@ -35,4 +41,18 @@ public class DemoController { //} client.agencyGridIssueStats(null); } + + + @PostMapping("exportGridLiveRes") + public Result exportGridLiveRes(@RequestParam("params") String params) { + if(StringUtils.isBlank(params)){ + return new Result(); + } + GridLivelyFormDTO formDTO = new GridLivelyFormDTO(); + if (StringUtils.isNotBlank(params)) { + formDTO = JSON.parseObject(params, GridLivelyFormDTO.class); + } + ValidatorUtils.validateEntity(formDTO,GridLivelyFormDTO.Grid.class); + return dataAggregatorFeignClient.exportGridLiveRes(formDTO); + } } diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/ExportGridLiveResTask.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/ExportGridLiveResTask.java new file mode 100644 index 0000000000..a3a4aae9bb --- /dev/null +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/ExportGridLiveResTask.java @@ -0,0 +1,68 @@ +package com.epmet.task; + +import com.alibaba.fastjson.JSON; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.dataaggre.dto.govorg.form.GridLivelyFormDTO; +import com.epmet.dataaggre.feign.DataAggregatorOpenFeignClient; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; + + +/** + * 每个星期一的凌晨5点执行,查询网格活跃度统计导出excel,上传oss, 发送钉钉@小雷哥 + */ +@Slf4j +@Component("exportGridLiveResTask") +public class ExportGridLiveResTask implements ITask { + + @Autowired + private DataAggregatorOpenFeignClient dataAggregatorFeignClient; + + @Override + public void run(String params) { + if(StringUtils.isBlank(params)){ + return; + } + GridLivelyFormDTO formDTO = new GridLivelyFormDTO(); + if (StringUtils.isNotBlank(params)) { + formDTO = JSON.parseObject(params, GridLivelyFormDTO.class); + } + //默认获取当前日期的上一个自然周 + if (StringUtils.isBlank(formDTO.getStartTime()) || StringUtils.isBlank(formDTO.getEndTime())) { + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.DATE, -1); + //上周日的日期 + Date yesterday = calendar.getTime(); + DateFormat format = new SimpleDateFormat("yyyyMMdd"); + Calendar c = new GregorianCalendar(); + //这里设置一周开始时间是星期一 + c.setFirstDayOfWeek(Calendar.MONDAY); + c.setTime(yesterday); + c.set(Calendar.DAY_OF_WEEK, c.getFirstDayOfWeek()); + //获取当前自然周的起始时间 + String beginTime = format.format(c.getTime()); + c.set(Calendar.DAY_OF_WEEK, c.getFirstDayOfWeek() + 6); + //当前自然周的截止时间 + String endTime = format.format(c.getTime()); + formDTO.setStartTime(beginTime); + formDTO.setEndTime(endTime); + } + ValidatorUtils.validateEntity(formDTO,GridLivelyFormDTO.Grid.class); + Result result = dataAggregatorFeignClient.exportGridLiveRes(formDTO); + if(!result.success()){ + log.error(String.format("exportGridLiveResTask网格活跃度统计导出失败,入参:%s",params)); + } + } + + + +} \ No newline at end of file diff --git a/epmet-module/epmet-message/epmet-message-server/pom.xml b/epmet-module/epmet-message/epmet-message-server/pom.xml index fe91db7f6b..2bef421caa 100644 --- a/epmet-module/epmet-message/epmet-message-server/pom.xml +++ b/epmet-module/epmet-message/epmet-message-server/pom.xml @@ -188,10 +188,13 @@ false - 5 - 8 - 10 - 30 + true + 5 + 8 + 20 + 60 + epmet-message + callerRunsPolicy @@ -238,11 +241,15 @@ false - - 5 - 8 - 10 - 30 + + true + 5 + 8 + 20 + 60 + epmet-message + callerRunsPolicy + https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4 @@ -288,11 +295,15 @@ true - - 5 - 8 - 10 - 30 + + true + 5 + 8 + 20 + 60 + epmet-message + callerRunsPolicy + https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4 @@ -336,11 +347,15 @@ true - - 5 - 8 - 10 - 30 + + true + 5 + 8 + 20 + 60 + epmet-message + callerRunsPolicy + https://oapi.dingtalk.com/robot/send?access_token=a5f66c3374b1642fe2142dbf56d5997e280172d4e8f2b546c9423a68c82ece6c diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/MessageApplication.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/MessageApplication.java index c32da6dd8a..9affe3659b 100644 --- a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/MessageApplication.java +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/MessageApplication.java @@ -13,6 +13,7 @@ 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.scheduling.annotation.EnableAsync; /** * 消息模块 @@ -24,6 +25,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @EnableDiscoveryClient @EnableFeignClients @ServletComponentScan +@EnableAsync public class MessageApplication { public static void main(String[] args) { diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/config/AsyncConfig.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/config/AsyncConfig.java deleted file mode 100644 index 95c0b0c55a..0000000000 --- a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/config/AsyncConfig.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.epmet.config; - -import com.epmet.properties.ThreadProperties; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.scheduling.annotation.EnableAsync; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; - -import java.util.concurrent.Executor; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.ThreadPoolExecutor; - -/** - * 线程池配置类 - */ -@Configuration -@EnableConfigurationProperties(ThreadProperties.class) -@EnableAsync -public class AsyncConfig { - - @Autowired - private ThreadProperties threadProperties; - - @Bean - public Executor executor() { - ThreadProperties.ThreadPoolProperties threadPoolProps = threadProperties.getThreadPool(); - - ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); - executor.setCorePoolSize(threadPoolProps.getCorePoolSize()); - executor.setMaxPoolSize(threadPoolProps.getMaxPoolSize()); - executor.setQueueCapacity(threadPoolProps.getQueueCapacity()); - executor.setThreadNamePrefix("epmet-message-"); - // rejection-policy:当pool已经达到max size的时候,如何处理新任务 - // CALLER_RUNS:不在新线程中执行任务,而是由调用者所在的线程来执行 - executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); //对拒绝task的处理策略 - executor.setKeepAliveSeconds(threadPoolProps.getKeepAlive()); - executor.initialize(); - return executor; - } - - @Bean - public ExecutorService executorService() { - ThreadPoolTaskExecutor executor = (ThreadPoolTaskExecutor) executor(); - return executor.getThreadPoolExecutor(); - } - -} diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/resources/bootstrap.yml b/epmet-module/epmet-message/epmet-message-server/src/main/resources/bootstrap.yml index f4f88d87ca..84dd154e10 100644 --- a/epmet-module/epmet-message/epmet-message-server/src/main/resources/bootstrap.yml +++ b/epmet-module/epmet-message/epmet-message-server/src/main/resources/bootstrap.yml @@ -126,10 +126,13 @@ pagehelper: thread: # 线程池配置 threadPool: - corePoolSize: @thread.pool.core-pool-size@ - maxPoolSize: @thread.pool.max-pool-size@ - queueCapacity: @thread.pool.queue-capacity@ - keepAlive: @thread.pool.keep-alive@ + enableCustomize: @thread.threadPool.enable-customize@ + corePoolSize: @thread.threadPool.core-pool-size@ + maxPoolSize: @thread.threadPool.max-pool-size@ + queueCapacity: @thread.threadPool.queue-capacity@ + keepAliveSeconds: @thread.threadPool.keep-alive-seconds@ + threadNamePrefix: @thread.threadPool.thread-name-prefix@ + rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@ dingTalk: robot: @@ -146,3 +149,4 @@ rocketmq: name-server: @rocketmq.nameserver@ producer: group: @rocketmq.producer.group@ + diff --git a/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/OssFeignClient.java b/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/OssFeignClient.java index 60697791d7..f1144b878d 100644 --- a/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/OssFeignClient.java +++ b/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/OssFeignClient.java @@ -14,7 +14,11 @@ import com.epmet.dto.result.UploadImgResultDTO; import com.epmet.feign.fallback.OssFeignClientFallbackFactory; import feign.codec.Encoder; import feign.form.spring.SpringFormEncoder; +import org.springframework.beans.factory.ObjectFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.http.HttpMessageConverters; import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.cloud.openfeign.support.SpringEncoder; import org.springframework.context.annotation.Bean; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.GetMapping; @@ -64,12 +68,24 @@ public interface OssFeignClient { @GetMapping(value = "oss/file/getOssFileUrl") Result getOssFileUrl(@RequestParam String filePath, @RequestParam String privacy); + /** + * 上传任务描述文件 + * 不限制大小 + * @param file + * @return + */ + @PostMapping(value = "oss/file/importTaskDescFile/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + Result uploadImportTaskDescFile(@RequestPart("file") MultipartFile file); //@Configuration class MultipartSupportConfig { + + @Autowired + private ObjectFactory messageConverters; + @Bean public Encoder feignFormEncoder() { - return new SpringFormEncoder(); + return new SpringFormEncoder(new SpringEncoder(messageConverters)); } } diff --git a/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/fallback/OssFeignClientFallback.java b/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/fallback/OssFeignClientFallback.java index dc43ed7467..805c2fc492 100644 --- a/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/fallback/OssFeignClientFallback.java +++ b/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/fallback/OssFeignClientFallback.java @@ -50,4 +50,9 @@ public class OssFeignClientFallback implements OssFeignClient { return ModuleUtils.feignConError(ServiceConstant.EPMET_OSS_SERVER, "download", filePath,privacy); } + @Override + public Result uploadImportTaskDescFile(MultipartFile file) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_OSS_SERVER, "uploadImportTaskDescFile", "MultipartFile"); + } + } diff --git a/epmet-module/epmet-oss/epmet-oss-server/pom.xml b/epmet-module/epmet-oss/epmet-oss-server/pom.xml index e27a7d8103..e1aa4893b4 100644 --- a/epmet-module/epmet-oss/epmet-oss-server/pom.xml +++ b/epmet-module/epmet-oss/epmet-oss-server/pom.xml @@ -146,6 +146,15 @@ false + + true + 5 + 8 + 20 + 60 + epmet-oss + callerRunsPolicy + https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4 @@ -185,6 +194,15 @@ false + + true + 5 + 8 + 20 + 60 + epmet-oss + callerRunsPolicy + false @@ -225,6 +243,15 @@ true + + true + 5 + 8 + 20 + 60 + epmet-oss + callerRunsPolicy + true @@ -262,6 +289,15 @@ true + + true + 5 + 8 + 20 + 60 + epmet-oss + callerRunsPolicy + true diff --git a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java index ac84d4d820..1b79042fbc 100644 --- a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java +++ b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java @@ -437,4 +437,15 @@ public class OssController { return new Result().ok(ossService.getOssFileUrl(filePath,privacy)); } + /** + * 上传任务描述文件 + * 不限制大小 + * @param file + * @return + */ + @PostMapping("/importTaskDescFile/upload") + public Result uploadImportTaskDescFile(@RequestPart("file") MultipartFile file) { + return ossService.uploadImg(file, null); + } + } diff --git a/epmet-module/epmet-oss/epmet-oss-server/src/main/resources/bootstrap.yml b/epmet-module/epmet-oss/epmet-oss-server/src/main/resources/bootstrap.yml index 1b939a5edd..334e1e5629 100644 --- a/epmet-module/epmet-oss/epmet-oss-server/src/main/resources/bootstrap.yml +++ b/epmet-module/epmet-oss/epmet-oss-server/src/main/resources/bootstrap.yml @@ -143,3 +143,14 @@ shutdown: graceful: enable: true #是否开启优雅停机 waitTimeSecs: 30 # 优雅停机等待时间,超过30秒,发出告警 + +thread: + # 线程池配置 + threadPool: + enableCustomize: @thread.threadPool.enable-customize@ + corePoolSize: @thread.threadPool.core-pool-size@ + maxPoolSize: @thread.threadPool.max-pool-size@ + queueCapacity: @thread.threadPool.queue-capacity@ + keepAliveSeconds: @thread.threadPool.keep-alive-seconds@ + threadNamePrefix: @thread.threadPool.thread-name-prefix@ + rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@ diff --git a/epmet-module/epmet-point/epmet-point-server/pom.xml b/epmet-module/epmet-point/epmet-point-server/pom.xml index 8aea483cfd..2dcda97101 100644 --- a/epmet-module/epmet-point/epmet-point-server/pom.xml +++ b/epmet-module/epmet-point/epmet-point-server/pom.xml @@ -159,11 +159,15 @@ false - - 5 - 8 - 10 - 30 + + true + 5 + 8 + 20 + 60 + epmet-point + callerRunsPolicy + https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4 SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd @@ -206,11 +210,15 @@ false - - 5 - 8 - 10 - 30 + + true + 5 + 8 + 20 + 60 + epmet-point + callerRunsPolicy + https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4 SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd @@ -253,11 +261,15 @@ true - - 5 - 8 - 10 - 30 + + true + 5 + 8 + 20 + 60 + epmet-point + callerRunsPolicy + https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4 SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd @@ -300,11 +312,15 @@ true - - 5 - 8 - 10 - 30 + + true + 5 + 8 + 20 + 60 + epmet-point + callerRunsPolicy + https://oapi.dingtalk.com/robot/send?access_token=a5f66c3374b1642fe2142dbf56d5997e280172d4e8f2b546c9423a68c82ece6c SEC95f4f40b533ad379ea6a6d1af6dd37029383cfe1b7cd96dfac2678be2c1c3ed1 diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/EpmetPointApplication.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/EpmetPointApplication.java index e2925628ba..79d5713a34 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/EpmetPointApplication.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/EpmetPointApplication.java @@ -5,6 +5,7 @@ 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.scheduling.annotation.EnableAsync; /** * 模块 @@ -16,6 +17,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @EnableDiscoveryClient @EnableFeignClients @ServletComponentScan +@EnableAsync public class EpmetPointApplication { public static void main(String[] args) { SpringApplication.run(EpmetPointApplication.class, args); diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/config/AsyncConfig.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/config/AsyncConfig.java deleted file mode 100644 index 2573cbd4ab..0000000000 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/config/AsyncConfig.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.epmet.config; - -import com.epmet.properties.ThreadProperties; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.scheduling.annotation.EnableAsync; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; - -import java.util.concurrent.Executor; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.ThreadPoolExecutor; - -/** - * 线程池配置类 - */ -@Configuration -@EnableConfigurationProperties(ThreadProperties.class) -@EnableAsync -public class AsyncConfig { - - @Autowired - private ThreadProperties threadProperties; - - @Bean - public Executor executor() { - ThreadProperties.ThreadPoolProperties threadPoolProps = threadProperties.getThreadPool(); - - ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); - executor.setCorePoolSize(threadPoolProps.getCorePoolSize()); - executor.setMaxPoolSize(threadPoolProps.getMaxPoolSize()); - executor.setQueueCapacity(threadPoolProps.getQueueCapacity()); - executor.setThreadNamePrefix("epmet-point-"); - // rejection-policy:当pool已经达到max size的时候,如何处理新任务 - // CALLER_RUNS:不在新线程中执行任务,而是由调用者所在的线程来执行 - executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); //对拒绝task的处理策略 - executor.setKeepAliveSeconds(threadPoolProps.getKeepAlive()); - executor.initialize(); - return executor; - } - - @Bean - public ExecutorService executorService() { - ThreadPoolTaskExecutor executor = (ThreadPoolTaskExecutor) executor(); - return executor.getThreadPoolExecutor(); - } - -} diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/resources/bootstrap.yml b/epmet-module/epmet-point/epmet-point-server/src/main/resources/bootstrap.yml index 4d5434a25f..b3fa3f8fe9 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/resources/bootstrap.yml +++ b/epmet-module/epmet-point/epmet-point-server/src/main/resources/bootstrap.yml @@ -126,10 +126,13 @@ pagehelper: thread: # 线程池配置 threadPool: - corePoolSize: @thread.pool.core-pool-size@ - maxPoolSize: @thread.pool.max-pool-size@ - queueCapacity: @thread.pool.queue-capacity@ - keepAlive: @thread.pool.keep-alive@ + enableCustomize: @thread.threadPool.enable-customize@ + corePoolSize: @thread.threadPool.core-pool-size@ + maxPoolSize: @thread.threadPool.max-pool-size@ + queueCapacity: @thread.threadPool.queue-capacity@ + keepAliveSeconds: @thread.threadPool.keep-alive-seconds@ + threadNamePrefix: @thread.threadPool.thread-name-prefix@ + rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@ dingTalk: robot: diff --git a/epmet-module/epmet-third/epmet-third-server/pom.xml b/epmet-module/epmet-third/epmet-third-server/pom.xml index 0b24d1acb0..a319b011d2 100644 --- a/epmet-module/epmet-third/epmet-third-server/pom.xml +++ b/epmet-module/epmet-third/epmet-third-server/pom.xml @@ -212,6 +212,15 @@ true + + true + 5 + 8 + 20 + 60 + epmet-third + callerRunsPolicy + false @@ -263,6 +272,15 @@ false + + true + 5 + 8 + 20 + 60 + epmet-third + callerRunsPolicy + false @@ -313,6 +331,15 @@ true + + true + 5 + 8 + 20 + 60 + epmet-third + callerRunsPolicy + true @@ -364,6 +391,15 @@ true + + true + 5 + 8 + 20 + 60 + epmet-third + callerRunsPolicy + true diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/bootstrap.yml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/bootstrap.yml index 1ad3de55ca..67b1a2740e 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/bootstrap.yml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/bootstrap.yml @@ -160,4 +160,15 @@ rocketmq: enable: @rocketmq.block-chain.enable@ name-server: @rocketmq.block-chain.name-server@ access-key: @rocketmq.block-chain.access-key@ - secret-key: @rocketmq.block-chain.secret-key@ \ No newline at end of file + secret-key: @rocketmq.block-chain.secret-key@ + +thread: + # 线程池配置 + threadPool: + enableCustomize: @thread.threadPool.enable-customize@ + corePoolSize: @thread.threadPool.core-pool-size@ + maxPoolSize: @thread.threadPool.max-pool-size@ + queueCapacity: @thread.threadPool.queue-capacity@ + keepAliveSeconds: @thread.threadPool.keep-alive-seconds@ + threadNamePrefix: @thread.threadPool.thread-name-prefix@ + rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@ \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/pom.xml b/epmet-module/gov-access/gov-access-server/pom.xml index b30b339746..054f185568 100644 --- a/epmet-module/gov-access/gov-access-server/pom.xml +++ b/epmet-module/gov-access/gov-access-server/pom.xml @@ -127,6 +127,15 @@ true + + true + 5 + 8 + 20 + 60 + gov-access + callerRunsPolicy + false @@ -166,6 +175,15 @@ false + + true + 5 + 8 + 20 + 60 + gov-access + callerRunsPolicy + false @@ -205,6 +223,15 @@ true + + true + 5 + 8 + 20 + 60 + gov-access + callerRunsPolicy + true @@ -241,6 +268,15 @@ true + + true + 5 + 8 + 20 + 60 + gov-access + callerRunsPolicy + true diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovCustomerMenuRedis.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovCustomerMenuRedis.java index 2333a6bd48..3cc19b8ae2 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovCustomerMenuRedis.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovCustomerMenuRedis.java @@ -17,31 +17,72 @@ package com.epmet.redis; +import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisUtils; +import com.epmet.dto.GovMenuDTO; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.util.List; + /** * 客户菜单配置表 * * @author generator generator@elink-cn.com * @since v1.0.0 2021-03-16 */ +@Slf4j @Component public class GovCustomerMenuRedis { @Autowired private RedisUtils redisUtils; - - public void delete(Object[] ids) { - + /** + * desc:保存客户菜单缓存 + * @param customerId + * @param type + * @see com.epmet.enums.MenuTypeEnum + */ + public void setCustomerMenuList(String customerId, Integer type, List govMenuDTOS) { + if (checkParam(customerId, type)) { + String key = RedisKeys.getCustomerMenuList(customerId, type); + redisUtils.set(key, govMenuDTOS, RedisUtils.DEFAULT_EXPIRE); + } + } + /** + * desc:获取客户菜单缓存 + * @param customerId + * @param type + * @see com.epmet.enums.MenuTypeEnum + */ + public List getCustomerMenuList(String customerId, Integer type) { + if (checkParam(customerId, type)) { + String key = RedisKeys.getCustomerMenuList(customerId, type); + return (List) redisUtils.get(key); + } + return null; } - public void set(){ + /** + * desc:删除客户菜单缓存 + * @param customerId + * @param type + * @see com.epmet.enums.MenuTypeEnum + */ + public void delCustomerMenu(String customerId, Integer type) { + if (checkParam(customerId, type)) { + String key = RedisKeys.getCustomerMenuList(customerId, type); + redisUtils.delete(key); + } } - public String get(String id){ - return null; + private boolean checkParam(String customerId, Integer type) { + if (StringUtils.isBlank(customerId) || type == null){ + log.warn("checkParam fail, param is null"); + return false; + } + return true; } - -} \ No newline at end of file +} diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovMenuRedis.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovMenuRedis.java index 361d6c3014..b96405de2e 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovMenuRedis.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovMenuRedis.java @@ -70,5 +70,4 @@ public class GovMenuRedis { String key = RedisKeys.getUserPermissionsKey(userId, app, client); return (Set)redisUtils.get(key); } - -} \ No newline at end of file +} diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovCustomerMenuServiceImpl.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovCustomerMenuServiceImpl.java index 8d7ef26acc..95e4f2f8d2 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovCustomerMenuServiceImpl.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovCustomerMenuServiceImpl.java @@ -20,14 +20,15 @@ package com.epmet.service.impl; 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.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; -import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.dao.GovCustomerMenuDao; import com.epmet.dto.GovCustomerMenuDTO; import com.epmet.dto.form.MenuConfigFormDTO; import com.epmet.entity.GovCustomerMenuEntity; +import com.epmet.enums.MenuTypeEnum; import com.epmet.redis.GovCustomerMenuRedis; import com.epmet.service.GovCustomerMenuService; import org.apache.commons.lang3.StringUtils; @@ -105,6 +106,7 @@ public class GovCustomerMenuServiceImpl extends BaseServiceImpl govCustomerMenuRedis.delCustomerMenu(customerId, MenuTypeEnum.MENU.value())); } @Override diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovMenuServiceImpl.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovMenuServiceImpl.java index 4e4c142b55..eb9467e926 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovMenuServiceImpl.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovMenuServiceImpl.java @@ -33,7 +33,7 @@ import com.epmet.dao.GovMenuDao; import com.epmet.dto.GovMenuDTO; import com.epmet.entity.GovMenuEntity; import com.epmet.enums.MenuTypeEnum; -import com.epmet.feign.EpmetUserFeignClient; +import com.epmet.redis.GovCustomerMenuRedis; import com.epmet.redis.GovMenuRedis; import com.epmet.service.*; import org.apache.commons.lang3.StringUtils; @@ -42,6 +42,7 @@ import org.slf4j.LoggerFactory; 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.*; @@ -57,7 +58,7 @@ public class GovMenuServiceImpl extends BaseServiceImpl getCustomerMenuList(String customerId, Integer type) { + List govMenuDTOS = govCustomerMenuRedis.getCustomerMenuList(customerId,type); + if (!CollectionUtils.isEmpty(govMenuDTOS)){ + return govMenuDTOS; + } List menuList = baseDao.getCustomerMenuList(customerId, type, HttpContextUtils.getLanguage()); List dtoList = ConvertUtils.sourceToTarget(menuList, GovMenuDTO.class); - return TreeUtils.buildTree(dtoList); + govMenuDTOS = TreeUtils.buildTree(dtoList); + govCustomerMenuRedis.setCustomerMenuList(customerId,type,govMenuDTOS); + return govMenuDTOS; } @Override diff --git a/epmet-module/gov-access/gov-access-server/src/main/resources/bootstrap.yml b/epmet-module/gov-access/gov-access-server/src/main/resources/bootstrap.yml index 0531e3885e..94f07d888b 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/resources/bootstrap.yml +++ b/epmet-module/gov-access/gov-access-server/src/main/resources/bootstrap.yml @@ -130,4 +130,15 @@ logging: dingTalk: robot: webHook: @dingTalk.robot.webHook@ - secret: @dingTalk.robot.secret@ \ No newline at end of file + secret: @dingTalk.robot.secret@ + +thread: + # 线程池配置 + threadPool: + enableCustomize: @thread.threadPool.enable-customize@ + corePoolSize: @thread.threadPool.core-pool-size@ + maxPoolSize: @thread.threadPool.max-pool-size@ + queueCapacity: @thread.threadPool.queue-capacity@ + keepAliveSeconds: @thread.threadPool.keep-alive-seconds@ + threadNamePrefix: @thread.threadPool.thread-name-prefix@ + rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@ \ No newline at end of file diff --git a/epmet-module/gov-grid/gov-grid-server/pom.xml b/epmet-module/gov-grid/gov-grid-server/pom.xml index 3e4eac304b..5a7686b00c 100644 --- a/epmet-module/gov-grid/gov-grid-server/pom.xml +++ b/epmet-module/gov-grid/gov-grid-server/pom.xml @@ -119,6 +119,15 @@ true + + true + 5 + 8 + 20 + 60 + gov-grid + callerRunsPolicy + false @@ -153,6 +162,15 @@ false + + true + 5 + 8 + 20 + 60 + gov-grid + callerRunsPolicy + false @@ -187,6 +205,15 @@ true + + true + 5 + 8 + 20 + 60 + gov-grid + callerRunsPolicy + true @@ -221,6 +248,15 @@ true + + true + 5 + 8 + 20 + 60 + gov-grid + callerRunsPolicy + true diff --git a/epmet-module/gov-grid/gov-grid-server/src/main/resources/bootstrap.yml b/epmet-module/gov-grid/gov-grid-server/src/main/resources/bootstrap.yml index d9f0085bd7..f9d8a3caa6 100644 --- a/epmet-module/gov-grid/gov-grid-server/src/main/resources/bootstrap.yml +++ b/epmet-module/gov-grid/gov-grid-server/src/main/resources/bootstrap.yml @@ -89,3 +89,14 @@ shutdown: graceful: enable: true #是否开启优雅停机 waitTimeSecs: 30 # 优雅停机等待时间,超过30秒,发出告警 + +thread: + # 线程池配置 + threadPool: + enableCustomize: @thread.threadPool.enable-customize@ + corePoolSize: @thread.threadPool.core-pool-size@ + maxPoolSize: @thread.threadPool.max-pool-size@ + queueCapacity: @thread.threadPool.queue-capacity@ + keepAliveSeconds: @thread.threadPool.keep-alive-seconds@ + threadNamePrefix: @thread.threadPool.thread-name-prefix@ + rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@ diff --git a/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/form/ShiftProjectFormDTO.java b/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/form/ShiftProjectFormDTO.java index b44cdb4acd..adb4ed7409 100644 --- a/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/form/ShiftProjectFormDTO.java +++ b/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/form/ShiftProjectFormDTO.java @@ -52,6 +52,10 @@ public class ShiftProjectFormDTO implements Serializable { * 议题标签 */ private List tagList; + /** + * token中客户Id + */ + private String customerId; } diff --git a/epmet-module/gov-issue/gov-issue-server/pom.xml b/epmet-module/gov-issue/gov-issue-server/pom.xml index 5e9a3f5657..eaf1d6d50b 100644 --- a/epmet-module/gov-issue/gov-issue-server/pom.xml +++ b/epmet-module/gov-issue/gov-issue-server/pom.xml @@ -169,6 +169,15 @@ true + + true + 5 + 8 + 20 + 60 + gov-issue + callerRunsPolicy + false https://epmet-dev.elinkservice.cn/api/epmetscan/api @@ -212,6 +221,15 @@ false + + true + 5 + 8 + 20 + 60 + gov-issue + callerRunsPolicy + false https://epmet-dev.elinkservice.cn/api/epmetscan/api @@ -255,6 +273,15 @@ true + + true + 5 + 8 + 20 + 60 + gov-issue + callerRunsPolicy + true https://epmet-dev.elinkservice.cn/api/epmetscan/api @@ -294,6 +321,15 @@ true + + true + 5 + 8 + 20 + 60 + gov-issue + callerRunsPolicy + true https://epmet-open.elinkservice.cn/api/epmetscan/api diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueManageController.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueManageController.java index b11a2e960b..a77e531b26 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueManageController.java +++ b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueManageController.java @@ -181,9 +181,9 @@ public class IssueManageController { @PostMapping("shiftproject-v2") public Result shiftProjectV2(@LoginUser TokenDto tokenDTO, @RequestBody ShiftProjectFormDTO formDTO) { formDTO.setStaffId(tokenDTO.getUserId()); + formDTO.setCustomerId(tokenDTO.getCustomerId()); ValidatorUtils.validateEntity(formDTO); - issueService.shiftProjectV2(formDTO); - return new Result(); + return issueService.shiftProjectV2(formDTO); } /** diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/IssueService.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/IssueService.java index 4eca209b95..01e16471da 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/IssueService.java +++ b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/IssueService.java @@ -3,6 +3,7 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.Result; import com.epmet.dto.IssueDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.*; @@ -219,7 +220,7 @@ public interface IssueService extends BaseService { * @param formDTO * @return void */ - void shiftProjectV2(ShiftProjectFormDTO formDTO); + Result shiftProjectV2(ShiftProjectFormDTO formDTO); /** * @Description 已关闭列表 政府端 diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java index a8c3188586..70e8528491 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java +++ b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java @@ -9,7 +9,9 @@ import com.epmet.commons.rocketmq.messages.GroupAchievementMQMsg; import com.epmet.commons.tools.constant.AppClientConstant; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.distributedlock.DistributedLock; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; +import com.epmet.commons.tools.enums.AchievementTypeEnum; import com.epmet.commons.tools.enums.EventEnum; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; @@ -41,7 +43,6 @@ import com.epmet.entity.IssueEntity; import com.epmet.entity.IssueProcessEntity; import com.epmet.entity.IssueProjectRelationEntity; import com.epmet.feign.*; -import com.epmet.commons.tools.enums.AchievementTypeEnum; import com.epmet.redis.GovIssueRedis; import com.epmet.redis.IssueVoteDetailRedis; import com.epmet.resi.group.dto.group.form.AllIssueFormDTO; @@ -62,6 +63,7 @@ import com.epmet.utils.ModuleConstants; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import org.apache.commons.collections4.CollectionUtils; +import org.redisson.api.RLock; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -136,6 +138,8 @@ public class IssueServiceImpl extends BaseServiceImpl imp private GovProjectOpenFeignClient govProjectOpenFeignClient; @Autowired private IssueVoteDetailService issueVoteDetailService; + @Autowired + private DistributedLock distributedLock; @Value("${openapi.scan.server.url}") @@ -957,127 +961,138 @@ public class IssueServiceImpl extends BaseServiceImpl imp * @date 2020/12/9 10:01 */ @Override - public void shiftProjectV2(ShiftProjectFormDTO formDTO) { - //1:查询议题数据 - IssueEntity entity = baseDao.selectById(formDTO.getIssueId()); - if (null == entity) { - throw new RenException(IssueConstant.SELECT_EXCEPTION); - } - if (IssueConstant.ISSUE_SHIFT_PROJECT.equals(entity.getIssueStatus())) { - throw new RenException(IssueConstant.ISSUE_SHIFT_PROJECT_EXCEPTION); - } - if (!IssueConstant.ISSUE_VOTING.equals(entity.getIssueStatus())) { - throw new RenException(IssueConstant.ISSUE_VOTING_EXCEPTION); - } - formDTO.setIssueDTO(ConvertUtils.sourceToTarget(entity, IssueDTO.class)); + public Result shiftProjectV2(ShiftProjectFormDTO formDTO) { + RLock lock = null; + try { + //获取锁,判断当前议题是否已处理 + lock = distributedLock.tryLock(formDTO.getCustomerId() + formDTO.getIssueId()); + //1:查询议题数据 + IssueEntity entity = baseDao.selectById(formDTO.getIssueId()); + if (null == entity) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),IssueConstant.SELECT_EXCEPTION,IssueConstant.SELECT_EXCEPTION); + } + if (IssueConstant.ISSUE_SHIFT_PROJECT.equals(entity.getIssueStatus())) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),IssueConstant.ISSUE_SHIFT_PROJECT_EXCEPTION,IssueConstant.ISSUE_SHIFT_PROJECT_EXCEPTION); + } + if (!IssueConstant.ISSUE_VOTING.equals(entity.getIssueStatus())) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),IssueConstant.ISSUE_VOTING_EXCEPTION,IssueConstant.ISSUE_VOTING_EXCEPTION); + } + formDTO.setIssueDTO(ConvertUtils.sourceToTarget(entity, IssueDTO.class)); - //获取议题分类 - List categoryList = issueCategoryService.getCategoryByIssue(formDTO.getIssueId()); - if (CollectionUtils.isEmpty(categoryList)) { - throw new RenException(EpmetErrorCode.CATEGORY_IS_NULL.getCode()); - } + //获取议题分类 + List categoryList = issueCategoryService.getCategoryByIssue(formDTO.getIssueId()); + if (CollectionUtils.isEmpty(categoryList)) { + throw new EpmetException(EpmetErrorCode.CATEGORY_IS_NULL.getCode(),EpmetErrorCode.CATEGORY_IS_NULL.getMsg(),EpmetErrorCode.CATEGORY_IS_NULL.getMsg()); + } - //公开回复内容审核 - if (StringUtils.isNotBlank(formDTO.getPublicReply())) { - TextScanParamDTO textScanParamDTO = new TextScanParamDTO(); - TextTaskDTO taskDTO = new TextTaskDTO(); - taskDTO.setDataId(UUID.randomUUID().toString().replace("-", "")); - taskDTO.setContent(formDTO.getPublicReply()); - textScanParamDTO.getTasks().add(taskDTO); - Result textSyncScanResult = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScanParamDTO); - if (!textSyncScanResult.success()) { - throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); - } else { - if (!textSyncScanResult.getData().isAllPass()) { - throw new RenException(EpmetErrorCode.TEXT_SCAN_FAILED.getCode()); + //公开回复内容审核 + if (StringUtils.isNotBlank(formDTO.getPublicReply())) { + TextScanParamDTO textScanParamDTO = new TextScanParamDTO(); + TextTaskDTO taskDTO = new TextTaskDTO(); + taskDTO.setDataId(UUID.randomUUID().toString().replace("-", "")); + taskDTO.setContent(formDTO.getPublicReply()); + textScanParamDTO.getTasks().add(taskDTO); + Result textSyncScanResult = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScanParamDTO); + if (!textSyncScanResult.success()) { + throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(),EpmetErrorCode.SERVER_ERROR.getMsg(),EpmetErrorCode.SERVER_ERROR.getMsg()); + } else { + if (!textSyncScanResult.getData().isAllPass()) { + throw new EpmetException(EpmetErrorCode.TEXT_SCAN_FAILED.getCode(),EpmetErrorCode.TEXT_SCAN_FAILED.getMsg(),EpmetErrorCode.TEXT_SCAN_FAILED.getMsg()); + } } } - } - - //因需要保证议题表中的转项目时间与创建项目时间一致 因此先新增项目数据再更新议题数据 - - //2:调用resi-group查询话题创建人数据(目前议题来源只有来自话题),为了到项目服务初始数据以及发送消息使用 - Result resultTopicDTO = resiGroupFeignClient.getTopicById(entity.getSourceId()); - if (!resultTopicDTO.success() || null == resultTopicDTO.getData()) { - throw new RenException(IssueConstant.SELECT_TOPIC_EXCEPTION); - } - ResiTopicDTO topicDTO = resultTopicDTO.getData(); - formDTO.setTopicDTO(topicDTO); - //3:调用gov-project服务,新增项目各业务表初始数据 - formDTO.setCategoryList(categoryList); - List tagList = issueTagsService.getTagsByIssue(formDTO.getIssueId()); - formDTO.setTagList(tagList); - Result resultDTO = govProjectFeignClient.issueShiftProject(formDTO); - if (!resultDTO.success() || null == resultDTO.getData()) { - logger.error(resultDTO.getInternalMsg()); - throw new RenException(IssueConstant.GOV_PRJECT_EXCEPTION); - } - IssueProjectResultDTO issueProjectResultDTO = resultDTO.getData(); - //更新项目对标签的引用次数 - if (CollectionUtils.isNotEmpty(tagList)) { - tagList.forEach(item -> { - IssueProjectTagDictDTO tag = issueProjectTagDictService.get(item.getTagId()); - tag.setProjectUseCount(tag.getProjectUseCount() + NumConstant.ONE); - issueProjectTagDictService.update(tag); - }); - } + //因需要保证议题表中的转项目时间与创建项目时间一致 因此先新增项目数据再更新议题数据 - //4:更新议题相关业务表数据 - //4.1:更新议题表数据 - entity.setIssueStatus(IssueConstant.ISSUE_SHIFT_PROJECT); - entity.setShiftedTime(issueProjectResultDTO.getShiftedTime()); - baseDao.updateById(entity); + //2:调用resi-group查询话题创建人数据(目前议题来源只有来自话题),为了到项目服务初始数据以及发送消息使用 + Result resultTopicDTO = resiGroupFeignClient.getTopicById(entity.getSourceId()); + if (!resultTopicDTO.success() || null == resultTopicDTO.getData()) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),IssueConstant.SELECT_TOPIC_EXCEPTION,IssueConstant.SELECT_TOPIC_EXCEPTION); + } + ResiTopicDTO topicDTO = resultTopicDTO.getData(); + formDTO.setTopicDTO(topicDTO); + + //3:调用gov-project服务,新增项目各业务表初始数据 + formDTO.setCategoryList(categoryList); + List tagList = issueTagsService.getTagsByIssue(formDTO.getIssueId()); + formDTO.setTagList(tagList); + Result resultDTO = govProjectFeignClient.issueShiftProject(formDTO); + if (!resultDTO.success() || null == resultDTO.getData()) { + logger.error(resultDTO.getInternalMsg()); + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),IssueConstant.GOV_PRJECT_EXCEPTION,IssueConstant.GOV_PRJECT_EXCEPTION); + } + IssueProjectResultDTO issueProjectResultDTO = resultDTO.getData(); + //更新项目对标签的引用次数 + if (CollectionUtils.isNotEmpty(tagList)) { + tagList.forEach(item -> { + IssueProjectTagDictDTO tag = issueProjectTagDictService.get(item.getTagId()); + tag.setProjectUseCount(tag.getProjectUseCount() + NumConstant.ONE); + issueProjectTagDictService.update(tag); + }); + } - //4.2:议题处理进展表新增数据 - IssueProcessEntity processEntity = new IssueProcessEntity(); - processEntity.setIssueId(entity.getId()); - processEntity.setIssueStatus(IssueConstant.ISSUE_SHIFT_PROJECT); - processEntity.setOrgType(IssueConstant.ISSUE_GRID); - processEntity.setOrgId(entity.getGridId()); - processEntity.setOrgName(issueProjectResultDTO.getOrgName()); - issueProcessDao.insert(processEntity); + //4:更新议题相关业务表数据 + //4.1:更新议题表数据 + entity.setIssueStatus(IssueConstant.ISSUE_SHIFT_PROJECT); + entity.setShiftedTime(issueProjectResultDTO.getShiftedTime()); + baseDao.updateById(entity); + + //4.2:议题处理进展表新增数据 + IssueProcessEntity processEntity = new IssueProcessEntity(); + processEntity.setIssueId(entity.getId()); + processEntity.setIssueStatus(IssueConstant.ISSUE_SHIFT_PROJECT); + processEntity.setOrgType(IssueConstant.ISSUE_GRID); + processEntity.setOrgId(entity.getGridId()); + processEntity.setOrgName(issueProjectResultDTO.getOrgName()); + issueProcessDao.insert(processEntity); + + //4.3:议题项目关系表新增数据 + IssueProjectRelationEntity relationEntity = new IssueProjectRelationEntity(); + relationEntity.setIssueId(entity.getId()); + relationEntity.setProjectId(issueProjectResultDTO.getProjectId()); + issueProjectRelationDao.insert(relationEntity); + + //5:调用epmet-message服务,给居民端话题创建人、议题发起人以及政府端工作人员发送消息 + if (!shiftProjectMessage(issueProjectResultDTO, formDTO, entity).success()) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),IssueConstant.SAVE_MSG_EXCEPTION,IssueConstant.SAVE_MSG_EXCEPTION); + } + //5-1:2020.10.26 添加给居民端话题创建人、议题发起人以及政府端工作人员推送微信订阅消息功能 sun + if (!wxmpShiftProjectMessage(issueProjectResultDTO, formDTO, entity).success()) { + logger.error("议题转项目,推送微信订阅消息失败!"); + } - //4.3:议题项目关系表新增数据 - IssueProjectRelationEntity relationEntity = new IssueProjectRelationEntity(); - relationEntity.setIssueId(entity.getId()); - relationEntity.setProjectId(issueProjectResultDTO.getProjectId()); - issueProjectRelationDao.insert(relationEntity); + //6:缓存中网格下表决中的议题总数减1 + govIssueRedis.subtractWorkGrassrootsIssueRedDotValue(entity.getGridId()); + try{ + issueVoteStatisticalService.syncVotingCacheToDbByParams(formDTO.getIssueId(),entity.getGridId(),null); + }catch(RenException e){ + logger.error(e.getInternalMsg()); + } - //5:调用epmet-message服务,给居民端话题创建人、议题发起人以及政府端工作人员发送消息 - if (!shiftProjectMessage(issueProjectResultDTO, formDTO, entity).success()) { - throw new RenException(IssueConstant.SAVE_MSG_EXCEPTION); - } - //5-1:2020.10.26 添加给居民端话题创建人、议题发起人以及政府端工作人员推送微信订阅消息功能 sun - if (!wxmpShiftProjectMessage(issueProjectResultDTO, formDTO, entity).success()) { - logger.error("议题转项目,推送微信订阅消息失败!"); - } - //6:缓存中网格下表决中的议题总数减1 - govIssueRedis.subtractWorkGrassrootsIssueRedDotValue(entity.getGridId()); - try{ - issueVoteStatisticalService.syncVotingCacheToDbByParams(formDTO.getIssueId(),entity.getGridId(),null); - }catch(RenException e){ - logger.error(e.getInternalMsg()); - } + //7:发送话题转议题积分事件 + TopicEventFormDTO eventParam = new TopicEventFormDTO(); + eventParam.setTopicId(entity.getSourceId()); + eventParam.setEvent(EventEnum.TOPIC_SHIFTED_TO_PROJECT); + if(!resiGroupOpenFeignClient.sendEvent(eventParam).success()){ + logger.warn("com.epmet.service.impl.IssueServiceImpl.shiftProjectV2,话题被转为项目积分事件发送失败,参数:{}", JSON.toJSONString(formDTO)); + } + // 8.数据库更新表决统计 + SelectIssueVotingDetailFormDTO dto = new SelectIssueVotingDetailFormDTO(); + dto.setGridId(entity.getGridId()); + dto.setIssueId(formDTO.getIssueId()); + issueVoteDetailService.updateVote(dto); - //7:发送话题转议题积分事件 - TopicEventFormDTO eventParam = new TopicEventFormDTO(); - eventParam.setTopicId(entity.getSourceId()); - eventParam.setEvent(EventEnum.TOPIC_SHIFTED_TO_PROJECT); - if(!resiGroupOpenFeignClient.sendEvent(eventParam).success()){ - logger.warn("com.epmet.service.impl.IssueServiceImpl.shiftProjectV2,话题被转为项目积分事件发送失败,参数:{}", JSON.toJSONString(formDTO)); + //8.记录日志 + //SendMqMsgUtil.build().openFeignClient(messageOpenFeignClient).sendProjectChangedMqMsg(); + return new Result(); + } catch (Exception e) { + return new Result().error(e.getMessage()); + } finally { + distributedLock.unLock(lock); } - // 8.数据库更新表决统计 - SelectIssueVotingDetailFormDTO dto = new SelectIssueVotingDetailFormDTO(); - dto.setGridId(entity.getGridId()); - dto.setIssueId(formDTO.getIssueId()); - issueVoteDetailService.updateVote(dto); - - //8.记录日志 - //SendMqMsgUtil.build().openFeignClient(messageOpenFeignClient).sendProjectChangedMqMsg(); } /** 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 93a00cd354..af7dee2c58 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 @@ -142,3 +142,14 @@ shutdown: rocketmq: enable: @rocketmq.enable@ name-server: @rocketmq.nameserver@ + +thread: + # 线程池配置 + threadPool: + enableCustomize: @thread.threadPool.enable-customize@ + corePoolSize: @thread.threadPool.core-pool-size@ + maxPoolSize: @thread.threadPool.max-pool-size@ + queueCapacity: @thread.threadPool.queue-capacity@ + keepAliveSeconds: @thread.threadPool.keep-alive-seconds@ + threadNamePrefix: @thread.threadPool.thread-name-prefix@ + rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@ diff --git a/epmet-module/gov-mine/gov-mine-server/pom.xml b/epmet-module/gov-mine/gov-mine-server/pom.xml index c643659b07..22c67633ee 100644 --- a/epmet-module/gov-mine/gov-mine-server/pom.xml +++ b/epmet-module/gov-mine/gov-mine-server/pom.xml @@ -139,6 +139,15 @@ true + + true + 5 + 8 + 20 + 60 + gov-mine + callerRunsPolicy + https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4 @@ -172,6 +181,15 @@ false + + true + 5 + 8 + 20 + 60 + gov-mine + callerRunsPolicy + https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4 @@ -205,6 +223,15 @@ true + + true + 5 + 8 + 20 + 60 + gov-mine + callerRunsPolicy + https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4 @@ -235,6 +262,15 @@ true + + true + 5 + 8 + 20 + 60 + gov-mine + callerRunsPolicy + https://oapi.dingtalk.com/robot/send?access_token=a5f66c3374b1642fe2142dbf56d5997e280172d4e8f2b546c9423a68c82ece6c diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/resources/bootstrap.yml b/epmet-module/gov-mine/gov-mine-server/src/main/resources/bootstrap.yml index 97052173b9..88eabe8772 100644 --- a/epmet-module/gov-mine/gov-mine-server/src/main/resources/bootstrap.yml +++ b/epmet-module/gov-mine/gov-mine-server/src/main/resources/bootstrap.yml @@ -108,3 +108,14 @@ shutdown: graceful: enable: true #是否开启优雅停机 waitTimeSecs: 30 # 优雅停机等待时间,超过30秒,发出告警 + +thread: + # 线程池配置 + threadPool: + enableCustomize: @thread.threadPool.enable-customize@ + corePoolSize: @thread.threadPool.core-pool-size@ + maxPoolSize: @thread.threadPool.max-pool-size@ + queueCapacity: @thread.threadPool.queue-capacity@ + keepAliveSeconds: @thread.threadPool.keep-alive-seconds@ + threadNamePrefix: @thread.threadPool.thread-name-prefix@ + rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@ diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/CustomerGridDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/CustomerGridDTO.java index a3600b2e0e..7acfd64627 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/CustomerGridDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/CustomerGridDTO.java @@ -62,6 +62,11 @@ public class CustomerGridDTO implements Serializable { */ private String latitude; + /** + * 中心点位位置 + */ + private String centerAddress; + /** * 所属地区码(所属组织地区码) */ diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/ImportGeneralDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/ImportGeneralDTO.java new file mode 100644 index 0000000000..9039cda6ef --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/ImportGeneralDTO.java @@ -0,0 +1,150 @@ +package com.epmet.dto; + +import com.epmet.commons.tools.constant.NumConstant; +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2022/2/13 4:32 下午 + * @DESC + */ +@Data +public class ImportGeneralDTO implements Serializable { + + private static final long serialVersionUID = -345610717773879687L; + + /** + * 组织名、ID + */ + private String agencyName; + private String agencyId; + + /** + * agencyId的pid + */ + private String pid; + private String pids; + + /** + * 网格名、ID + */ + private String gridName; + private String gridId; + + /** + * 小区名、ID + */ + private String neighborHoodName; + private String neighborHoodId; + + /** + * 所属楼栋、ID + */ + private String buildingName; + private String buildingId; + + /** + * 房屋类型 + */ + private String type; + + /** + * 单元数 + */ + private Integer totalUnitNum = NumConstant.ONE; + + /** + * 层数 + */ + private Integer totalFloorNum; + + /** + * 户数 + */ + private Integer totalHouseNum; + + /** + * 单元号、ID + */ + private Integer buildingUnit; + private String buildingUnitId; + + /** + * 门牌号 + */ + private String doorName; + + /** + * 房屋类型 + */ + private String houseType; + + /** + * 房屋用途 + */ + private String purpose; + + /** + * 是否出租 + */ + private String rentFlagString; + private Integer rentFlag; + + /** + * 姓名 + */ + private String ownerName; + + /** + * 电话 + */ + private String ownerPhone; + + /** + * 身份证 + */ + private String ownerIdCard; + + /** + * 行号 + */ + private Integer num; + + /** + * 关联物业 + */ + private String propertyName; + + /** + * 详细地址 + */ + private String address; + + /** + * 备注 + */ + private String remark; + + /** + * 房屋ID + */ + private String houseId; + + private String houseName; + + private String customerId; + + private Boolean existStatus = false; + + /** + * 楼栋重复状态 + */ + private Boolean buildingExistStatus = false; + + /** + * 小区重复状态 + */ + private Boolean neighborHoodExistStatus = false; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/NeighborHoodAndManagementDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/NeighborHoodAndManagementDTO.java new file mode 100644 index 0000000000..babc828970 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/NeighborHoodAndManagementDTO.java @@ -0,0 +1,42 @@ +package com.epmet.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2022/2/13 8:51 上午 + * @DESC + */ +@Data +public class NeighborHoodAndManagementDTO implements Serializable { + + private static final long serialVersionUID = -7500263771019585308L; + + private String gridId; + + /** + * 小区ID + */ + private String id; + + private String gridName; + + /** + * 小区名字 + */ + private String neighborHoodName; + private String neighborHoodId; + + /** + * 物业ID + */ + private String propertyId; + + /** + * 物业名字 + */ + private String propertyName; + +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyFormDTO.java index 7a5e6b5537..575a498d57 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyFormDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyFormDTO.java @@ -85,4 +85,22 @@ public class AddAgencyFormDTO implements Serializable { @Length(max=30,message = "区县级机关名称不能超过30个字") private String district; + //02.21新增需求:小程序工作端添加组织增加中心点位置入口,点击进入地图选择点位,可以搜索,中心点为必填 + //该接口为通用接口,后端暂时先不限制必填。由前端控制 + /** + * 中心位置经度 + */ + // @NotBlank(message = "请选择网格中心点位", groups = AddGridFormDTO.AddGrid.class) + private String longitude; + + /** + * 中心位置纬度 + */ + // @NotBlank(message = "请选择网格中心点位", groups = AddGridFormDTO.AddGrid.class) + private String latitude; + + /** + * 中心点位位置 + */ + private String centerAddress; } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyV2FormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyV2FormDTO.java index 50ee7a010c..0cbb5c1ab5 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyV2FormDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyV2FormDTO.java @@ -99,4 +99,23 @@ public class AddAgencyV2FormDTO implements Serializable { * 联系电话 */ private String mobile; + + //02.21新增需求:小程序工作端添加组织增加中心点位置入口,点击进入地图选择点位,可以搜索,中心点为必填 + //该接口为通用接口,后端暂时先不限制必填。由前端控制 + /** + * 中心位置经度 + */ + // @NotBlank(message = "请选择网格中心点位", groups = AddGridFormDTO.AddGrid.class) + private String longitude; + + /** + * 中心位置纬度 + */ + // @NotBlank(message = "请选择网格中心点位", groups = AddGridFormDTO.AddGrid.class) + private String latitude; + + /** + * 中心点位位置 + */ + private String centerAddress; } diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddGridFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddGridFormDTO.java index 965f8b5fc6..9eab6ce157 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddGridFormDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddGridFormDTO.java @@ -51,4 +51,22 @@ public class AddGridFormDTO implements Serializable { */ private String mobile; + //02.21新增需求:小程序工作端添加组织增加中心点位置入口,点击进入地图选择点位,可以搜索,中心点为必填 + //该接口为通用接口,后端暂时先不限制必填。由前端控制 + /** + * 中心位置经度 + */ + // @NotBlank(message = "请选择网格中心点位", groups = AddGridFormDTO.AddGrid.class) + private String longitude; + + /** + * 中心位置纬度 + */ + // @NotBlank(message = "请选择网格中心点位", groups = AddGridFormDTO.AddGrid.class) + private String latitude; + + /** + * 中心点位位置 + */ + private String centerAddress; } diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditAgencyFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditAgencyFormDTO.java index 7b3ff97ed8..7473027fde 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditAgencyFormDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditAgencyFormDTO.java @@ -89,4 +89,23 @@ public class EditAgencyFormDTO implements Serializable { @NotBlank(message = "组织级别不能为空;社区级:community,乡(镇、街道)级:street,区县级: district,市级: city省级:province", groups = AddAgencyV2FormDTO.AddUserInternalGroup.class) private String level; + + //02.21新增需求:小程序工作端添加组织增加中心点位置入口,点击进入地图选择点位,可以搜索,中心点为必填 + //该接口为通用接口,后端暂时先不限制必填。由前端控制 + /** + * 中心位置经度 + */ + // @NotBlank(message = "请选择网格中心点位", groups = AddGridFormDTO.AddGrid.class) + private String longitude; + + /** + * 中心位置纬度 + */ + // @NotBlank(message = "请选择网格中心点位", groups = AddGridFormDTO.AddGrid.class) + private String latitude; + + /** + * 中心点位位置 + */ + private String centerAddress; } \ No newline at end of file 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 1c42608fd8..8774da4f99 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 @@ -59,4 +59,22 @@ public class EditGridFormDTO implements Serializable { */ private String mobile; + //02.21新增需求:小程序工作端添加组织增加中心点位置入口,点击进入地图选择点位,可以搜索,中心点为必填 + //该接口为通用接口,后端暂时先不限制必填。由前端控制 + /** + * 中心位置经度 + */ + // @NotBlank(message = "请选择网格中心点位", groups = AddGridFormDTO.AddGrid.class) + private String longitude; + + /** + * 中心位置纬度 + */ + // @NotBlank(message = "请选择网格中心点位", groups = AddGridFormDTO.AddGrid.class) + private String latitude; + + /** + * 中心点位位置 + */ + private String centerAddress; } diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/ImportInfoFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/ImportInfoFormDTO.java new file mode 100644 index 0000000000..ca83776f30 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/ImportInfoFormDTO.java @@ -0,0 +1,34 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2022/2/12 10:38 上午 + * @DESC + */ +@Data +public class ImportInfoFormDTO implements Serializable { + + private static final long serialVersionUID = -3978921489168201769L; + + public interface ImportInfoForm{} + + /** + * 选中的组织ID + */ + @NotBlank(message = "orgId不能为空",groups = ImportInfoForm.class) + private String orgId; + + /** + * 组织类型 agency:组织,grid:网格,neighborHood:小区,building:楼栋 + */ + @NotBlank(message = "orgType不能为空",groups = ImportInfoForm.class) + private String orgType; + + private String customerId; + private String userId; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencysResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencysResultDTO.java index cace2a4c84..99028d23bb 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencysResultDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencysResultDTO.java @@ -118,4 +118,19 @@ public class AgencysResultDTO implements Serializable { * 联系电话 */ private String mobile; + + /** + * 中心位置经度 + */ + private String longitude; + + /** + * 中心位置纬度 + */ + private String latitude; + + /** + * 中心点位位置 + */ + private String centerAddress; } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/GridDetailResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/GridDetailResultDTO.java index f9a2726a1a..cae98d8bc4 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/GridDetailResultDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/GridDetailResultDTO.java @@ -35,6 +35,11 @@ public class GridDetailResultDTO implements Serializable { */ private String latitude; + /** + * 中心点位位置 + */ + private String centerAddress; + /** * 所属地区码(所属组织地区码) */ diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/ImportResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/ImportResultDTO.java new file mode 100644 index 0000000000..ddaa2d5bff --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/ImportResultDTO.java @@ -0,0 +1,31 @@ +package com.epmet.dto.result; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @Author zxc + * @DateTime 2022/2/15 9:25 上午 + * @DESC + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class ImportResultDTO implements Serializable { + + private static final long serialVersionUID = -5817164530837181890L; + + /** + * 未导入的行号 + */ + private List nums; + + /** + * 总条数 + */ + private Integer num; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/InfoByNamesResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/InfoByNamesResultDTO.java new file mode 100644 index 0000000000..00e92b3ece --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/InfoByNamesResultDTO.java @@ -0,0 +1,31 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2022/2/12 2:15 下午 + * @DESC + */ +@Data +public class InfoByNamesResultDTO implements Serializable { + + private static final long serialVersionUID = 264490056071606346L; + + private String gridId; + private String agencyId; + + private String gridName; + private String agencyName; + + private String pid; + + private String pids; + + private String parentAgencyId; + + private String agencyPids; + +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/UpdateBuildingHouseNumResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/UpdateBuildingHouseNumResultDTO.java new file mode 100644 index 0000000000..0a3d25f464 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/UpdateBuildingHouseNumResultDTO.java @@ -0,0 +1,21 @@ +package com.epmet.dto.result; + +import com.epmet.commons.tools.constant.NumConstant; +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2022/3/3 5:24 下午 + * @DESC + */ +@Data +public class UpdateBuildingHouseNumResultDTO implements Serializable { + + private static final long serialVersionUID = 4350166505117596584L; + + private String id; + + private Integer num; +} diff --git a/epmet-module/gov-org/gov-org-server/pom.xml b/epmet-module/gov-org/gov-org-server/pom.xml index 0f5ba6290d..658bf81895 100644 --- a/epmet-module/gov-org/gov-org-server/pom.xml +++ b/epmet-module/gov-org/gov-org-server/pom.xml @@ -33,6 +33,11 @@ epmet-commons-dynamic-datasource 2.0.0 + + com.epmet + epmet-oss-client + 2.0.0 + org.springframework.boot spring-boot-starter-web @@ -125,6 +130,12 @@ 2.0.0 compile + + com.alibaba + easyexcel + 3.0.3 + compile + @@ -192,6 +203,15 @@ true + + true + 5 + 8 + 20 + 60 + gov-org + callerRunsPolicy + false @@ -237,6 +257,15 @@ false + + true + 5 + 8 + 20 + 60 + gov-org + callerRunsPolicy + false @@ -282,6 +311,14 @@ true + + true + 5 + 8 + 20 + 60 + gov-org + callerRunsPolicy true @@ -325,6 +362,15 @@ true + + true + 5 + 8 + 20 + 60 + gov-org + callerRunsPolicy + true diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/GovOrgApplication.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/GovOrgApplication.java index ff43e6542c..348a7b67b0 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/GovOrgApplication.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/GovOrgApplication.java @@ -13,6 +13,7 @@ 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.scheduling.annotation.EnableAsync; /** * @@ -24,6 +25,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @EnableDiscoveryClient @EnableFeignClients @ServletComponentScan +@EnableAsync public class GovOrgApplication { public static void main(String[] args) { diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/CustomerGridConstant.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/CustomerGridConstant.java index 4374038f6f..bfe1fbe93c 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/CustomerGridConstant.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/CustomerGridConstant.java @@ -16,4 +16,7 @@ public interface CustomerGridConstant { String DEPT = "dept"; String GRID = "grid"; + + String NEIGHBORHOOD = "neighborHood"; + String BUILDING = "building"; } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/ImportErrorMsgConstants.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/ImportErrorMsgConstants.java new file mode 100644 index 0000000000..6dce569719 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/ImportErrorMsgConstants.java @@ -0,0 +1,22 @@ +package com.epmet.constant; + +/** + * @Author zxc + * @DateTime 2022/2/21 4:25 下午 + * @DESC + */ +public interface ImportErrorMsgConstants { + + String EXIST_ERROR = "数据已存在"; + + String HOUSE_ERROR = "所属组织、所属网格、所属小区、所属楼栋、单元号、房屋类型、房屋用途、出租、房主姓名、房主电话、房主身份证的值未填写,或者所填写信息在系统中未找到"; + + String BUILDING_ERROR = "所属组织、所属网格、所属小区、楼栋类型、单元数的值未填写,或者所填写信息在系统中未找到"; + + String NEIGHBOR_HOOD_ERROR = "所属组织、所属网格、详细地址的值未填写,或者所填写信息在系统中未找到"; + + String HOUSE_ERROR_NAME = "导入失败的列表-房屋"; + String BUILDING_ERROR_NAME = "导入失败的列表-楼宇"; + String NEIGHBORHOOD_ERROR_NAME = "导入失败的列表-小区"; + +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java index adaa3ed3f1..349df657f4 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java @@ -24,19 +24,23 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.aop.NoRepeatSubmit; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.constant.ImportErrorMsgConstants; +import com.epmet.constants.ImportTaskConstants; import com.epmet.dao.IcBuildingUnitDao; import com.epmet.dto.BuildingTreeLevelDTO; -import com.epmet.dto.form.IcBulidingFormDTO; -import com.epmet.dto.form.IcBulidingUnitFormDTO; -import com.epmet.dto.form.ListIcNeighborHoodFormDTO; +import com.epmet.dto.form.*; import com.epmet.dto.result.BuildingResultDTO; import com.epmet.dto.result.BuildingResultPagedDTO; import com.epmet.dto.result.IcNeighborHoodResultDTO; +import com.epmet.dto.result.ImportTaskCommonResultDTO; import com.epmet.entity.IcBuildingUnitEntity; import com.epmet.excel.IcBuildingExcel; +import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.service.BuildingService; import com.epmet.service.IcBuildingService; import com.epmet.service.NeighborHoodService; @@ -64,17 +68,12 @@ import java.util.stream.Collectors; @RequestMapping("building") public class BuildingController { - - @Autowired - private NeighborHoodService neighborHoodService; - - @Autowired - private IcBuildingService icBuildingService; @Autowired private BuildingService buildingService; @Autowired private IcBuildingUnitDao icBuildingUnitDao; - + @Autowired + private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient; @PostMapping("buildinglist") @@ -194,11 +193,41 @@ public class BuildingController { Collections.sort(resultList); String subList = resultList.stream().map(String::valueOf).collect(Collectors.joining("、")); log.warn(str + "第" + subList + "行未成功!"); - return new Result().error(9999, str+"第"+subList+"行未成功!"); + return new Result().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), str+"第"+subList+"行未成功!"); } return new Result().ok(str); } + /** + * @Description 楼宇导入 + * @param tokenDTO + * @param file + * @param orgId + * @param orgType + * @author zxc + * @date 2022/2/13 10:18 上午 + */ + @PostMapping("buildingimport") + public Result buildingImportExcel(@LoginUser TokenDto tokenDTO, @RequestParam("file") MultipartFile file, + @RequestParam("orgId")String orgId, + @RequestParam("orgType")String orgType) throws IOException{ + ImportInfoFormDTO formDTO = new ImportInfoFormDTO(); + formDTO.setCustomerId(tokenDTO.getCustomerId()); + formDTO.setOrgType(orgType); + formDTO.setOrgId(orgId); + formDTO.setUserId(tokenDTO.getUserId()); + ImportTaskCommonFormDTO importFormDTO = new ImportTaskCommonFormDTO(); + importFormDTO.setBizType(ImportTaskConstants.BIZ_TYPE_BUILDING); + importFormDTO.setOperatorId(formDTO.getUserId()); + importFormDTO.setOriginFileName(file.getOriginalFilename()); + Result importTask = epmetCommonServiceOpenFeignClient.createImportTask(importFormDTO); + if (!importTask.success()){ + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"","存在进行中的导入"); + } + buildingService.buildingImportExcel(formDTO,file,importTask); + return new Result(); + } + /** * 查看楼宇单元列表 * @param tokenDTO diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java index cd54f15e64..ea54959b86 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java @@ -19,37 +19,53 @@ package com.epmet.controller; import cn.afterturn.easypoi.excel.entity.TemplateExportParams; import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.ExcelReader; +import com.alibaba.excel.read.metadata.ReadSheet; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.aop.NoRepeatSubmit; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.feign.ResultDataResolver; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; -import com.epmet.dto.form.IcHouseFormDTO; -import com.epmet.dto.form.IcNeighborHoodFormDTO; -import com.epmet.dto.form.ListIcNeighborHoodFormDTO; -import com.epmet.dto.form.LoginUserDetailsFormDTO; -import com.epmet.dto.result.HouseInfoDTO; -import com.epmet.dto.result.IcNeighborHoodResultDTO; -import com.epmet.dto.result.LoginUserDetailsResultDTO; +import com.epmet.constant.ImportErrorMsgConstants; +import com.epmet.constants.ImportTaskConstants; +import com.epmet.dao.IcBuildingDao; +import com.epmet.dto.form.*; +import com.epmet.dto.result.*; import com.epmet.excel.IcHouseExcel; +import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.feign.GovOrgOpenFeignClient; +import com.epmet.model.HouseInfoModel; +import com.epmet.model.ImportHouseInfoListener; +import com.epmet.redis.IcHouseRedis; import com.epmet.service.HouseService; +import com.epmet.service.IcHouseService; +import com.epmet.service.IcNeighborHoodService; import com.epmet.util.ExcelPoiUtils; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; +import org.apache.tomcat.util.http.MimeHeaders; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Async; import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.support.StandardMultipartHttpServletRequest; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.io.File; import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.Field; import java.util.*; +import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; @@ -69,6 +85,14 @@ public class HouseController implements ResultDataResolver { @Autowired private EpmetUserOpenFeignClient userOpenFeignClient; + @Autowired + private IcBuildingDao icBuildingDao; + @Autowired + private IcHouseRedis icHouseRedis; + @Autowired + private IcHouseService icHouseService; + @Autowired + private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient; @PostMapping("houselist") @@ -223,7 +247,7 @@ public class HouseController implements ResultDataResolver { Collections.sort(resultList); String subList = resultList.stream().map(String::valueOf).collect(Collectors.joining("、")); log.warn(str + "第" + subList + "行未成功!"); - return new Result().error(9999, str+"第"+subList+"行未成功!"); + return new Result().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), str+"第"+subList+"行未成功!"); } return new Result().ok(str); } @@ -232,4 +256,26 @@ public class HouseController implements ResultDataResolver { Result> queryListHouseInfo(@RequestBody Set houseIds, @RequestParam("customerId") String customerId){ return new Result>().ok(houseService.queryListHouseInfo(houseIds,customerId)); } + + @PostMapping("houseimport") + public Result houseImport(@LoginUser TokenDto tokenDTO, @RequestParam("file") MultipartFile file, + @RequestParam("orgId")String orgId, + @RequestParam("orgType")String orgType,HttpServletRequest multipartRequest){ + ImportInfoFormDTO formDTO = new ImportInfoFormDTO(); + formDTO.setCustomerId(tokenDTO.getCustomerId()); + formDTO.setOrgType(orgType); + formDTO.setOrgId(orgId); + formDTO.setUserId(tokenDTO.getUserId()); + ImportTaskCommonFormDTO importFormDTO = new ImportTaskCommonFormDTO(); + importFormDTO.setBizType(ImportTaskConstants.BIZ_TYPE_HOUSE); + importFormDTO.setOperatorId(formDTO.getUserId()); + importFormDTO.setOriginFileName(file.getOriginalFilename()); + Result importTask = epmetCommonServiceOpenFeignClient.createImportTask(importFormDTO); + if (!importTask.success()){ + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"","存在进行中的导入"); + } + houseService.dispose(file,formDTO,importTask); + return new Result<>(); + } + } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java index fcd64c4658..107b6c612e 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java @@ -17,8 +17,11 @@ package com.epmet.controller; +import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.dto.result.OptionResultDTO; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; @@ -27,11 +30,20 @@ import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.constant.ImportErrorMsgConstants; +import com.epmet.constants.ImportTaskConstants; import com.epmet.dto.IcNeighborHoodDTO; +import com.epmet.dto.form.ImportInfoFormDTO; +import com.epmet.dto.form.ImportTaskCommonFormDTO; +import com.epmet.dto.result.ImportTaskCommonResultDTO; +import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.service.IcNeighborHoodService; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; import java.util.List; import java.util.Map; @@ -44,10 +56,13 @@ import java.util.Map; */ @RestController @RequestMapping("icneighborhood") +@Slf4j public class IcNeighborHoodController { @Autowired private IcNeighborHoodService icNeighborHoodService; + @Autowired + private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient; @GetMapping("page") public Result> page(@RequestParam Map params){ @@ -85,6 +100,18 @@ public class IcNeighborHoodController { return new Result(); } + /** + * @Description 通过ID查询小区信息 + * @Param ids + * @Return {@link Result< List< IcNeighborHoodDTO>>} + * @Author zhaoqifeng + * @Date 2021/11/8 10:46 + */ + @PostMapping("getlistbyids") + public Result> getListByIds(@RequestBody List ids) { + return new Result>().ok(icNeighborHoodService.getListByIds(ids)); + } + /** * @Description 获取网格下小区列表 * @Param dto @@ -98,15 +125,32 @@ public class IcNeighborHoodController { } /** - * @Description 通过ID查询小区信息 - * @Param ids - * @Return {@link Result< List< IcNeighborHoodDTO>>} - * @Author zhaoqifeng - * @Date 2021/11/8 10:46 + * @Description 小区信息导入 + * @param tokenDTO + * @param file + * @author zxc + * @date 2022/2/12 10:47 上午 */ - @PostMapping("getlistbyids") - public Result> getListByIds(@RequestBody List ids) { - return new Result>().ok(icNeighborHoodService.getListByIds(ids)); + @PostMapping("neighborhoodimport") + public Result neighborhoodImport(@LoginUser TokenDto tokenDTO, @RequestParam("file") MultipartFile file, + @RequestParam("orgId")String orgId, + @RequestParam("orgType")String orgType) throws IOException { + ImportInfoFormDTO formDTO = new ImportInfoFormDTO(); + formDTO.setCustomerId(tokenDTO.getCustomerId()); + formDTO.setOrgType(orgType); + formDTO.setOrgId(orgId); + formDTO.setUserId(tokenDTO.getUserId()); + ImportTaskCommonFormDTO importFormDTO = new ImportTaskCommonFormDTO(); + importFormDTO.setBizType(ImportTaskConstants.BIZ_TYPE_NEIGHBOR_HOOD); + importFormDTO.setOperatorId(formDTO.getUserId()); + importFormDTO.setOriginFileName(file.getOriginalFilename()); + Result importTask = epmetCommonServiceOpenFeignClient.createImportTask(importFormDTO); + if (!importTask.success()){ + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"","存在进行中的导入"); + } + log.info("插入任务结果"+ JSON.toJSONString(importTask.getData())); + icNeighborHoodService.neighborhoodImport(formDTO,file,importTask); + return new Result(); } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/NeighborHoodController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/NeighborHoodController.java index 60c1651315..da7f783c1e 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/NeighborHoodController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/NeighborHoodController.java @@ -23,6 +23,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.aop.NoRepeatSubmit; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; @@ -223,7 +224,7 @@ public class NeighborHoodController { Collections.sort(resultList); String subList = resultList.stream().map(String::valueOf).collect(Collectors.joining("、")); log.warn(str + "第" + subList + "行未成功!"); - return new Result().error(9999, str + "第" + subList + "行未成功!"); + return new Result().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), str + "第" + subList + "行未成功!"); } return new Result().ok(str); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java index 7eef403d38..3dcedd5c73 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java @@ -365,4 +365,13 @@ public interface CustomerGridDao extends BaseDao { @Param("operateUserId") String operateUserId); List getStaffGridList(@Param("customerId") String customerId, @Param("orgId") String orgId, @Param("orgType") String orgType); + + /** + * @Description 根据网格名字查询网格信息 + * @param names + * @author zxc + * @date 2022/2/12 2:06 下午 + */ + List selectGridInfoByNames(@Param("names")List names,@Param("customerId")String customerId); + } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcBuildingDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcBuildingDao.java index 6d029cb291..87ee60fcd4 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcBuildingDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcBuildingDao.java @@ -19,8 +19,10 @@ package com.epmet.dao; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.ImportGeneralDTO; import com.epmet.dto.result.BaseInfoFamilyBuildingResultDTO; import com.epmet.dto.result.BuildingResultDTO; +import com.epmet.dto.result.UpdateBuildingHouseNumResultDTO; import com.epmet.entity.CustomerAgencyEntity; import com.epmet.entity.IcBuildingEntity; import com.epmet.entity.IcHouseEntity; @@ -73,4 +75,116 @@ public interface IcBuildingDao extends BaseDao { List buildingListByIds(@Param("buildingIdList") List buildingIdList); IPage buildingListByIds(IPage page,@Param("buildingIdList") List buildingIdList); + /** + * @Description 根据ID查询楼栋名 + * @param orgId + * @author zxc + * @date 2022/2/13 2:32 下午 + */ + String selectBuildingNameById(@Param("orgId")String orgId); + + /** + * @Description 根据ID查询小区名 + * @param orgId + * @author zxc + * @date 2022/2/13 4:21 下午 + */ + String selectNeighborHoodNameById(@Param("orgId")String orgId); + + /** + * @Description 根据ID查询网格名 + * @param orgId + * @author zxc + * @date 2022/2/13 4:26 下午 + */ + String selectGridNameById(@Param("orgId")String orgId); + + /** + * @Description 根据ID查询组织名 + * @param orgId + * @author zxc + * @date 2022/2/13 4:29 下午 + */ + String selectAgencyNameById(@Param("orgId")String orgId); + + /** + * @Description 查询组织下所有网格信息 + * @param orgId + * @author zxc + * @date 2022/2/14 9:48 上午 + */ + List selectAllGridByOrgId(@Param("orgId")String orgId); + + /** + * @Description 查询网格下所有的小区 + * @param orgId + * @author zxc + * @date 2022/2/14 10:21 上午 + */ + List selectAllNeighborHoodByGridIds(@Param("orgIds")List orgId); + + /** + * @Description 根据小区ID查询楼栋 + * @param neighborHoodId + * @author zxc + * @date 2022/2/14 1:25 下午 + */ + List selectAllBuildingByNeighborHoodId(@Param("orgId")String orgId); + + /** + * @Description 根据楼栋ID查询楼栋单元 + * @param building + * @author zxc + * @date 2022/2/14 1:58 下午 + */ + List selectAllBuildingUnitByBuildingId(@Param("orgId")String orgId); + + /** + * @Description 根据ID查询小区 + * @param id + * @author zxc + * @date 2022/2/14 3:16 下午 + */ + ImportGeneralDTO selectNeighborHoodById(@Param("id")String id); + + /** + * @Description 根据ID查询楼栋 + * @param id + * @author zxc + * @date 2022/2/14 4:26 下午 + */ + ImportGeneralDTO selectBuildingById(@Param("id")String id); + + /** + * @Description 查询已存在的房屋 + * @param ids + * @author zxc + * @date 2022/2/14 5:32 下午 + */ + List selectExistHouse(@Param("ids")List ids); + + /** + * Desc: 查询客户下户数为空的 + * @param customerId + * @author zxc + * @date 2022/3/3 5:20 下午 + */ + List selectHouseTotalIsNull(@Param("customerId")String customerId); + + /** + * Desc: 查询楼栋下的户数 + * @param ids + * @author zxc + * @date 2022/3/3 5:26 下午 + */ + List selectHouseNum(@Param("ids")List ids); + + /** + * Desc: 批量更新楼栋户数 + * @param nums + * @author zxc + * @date 2022/3/3 5:31 下午 + */ + void allUpdateHouseNum(@Param("nums") List nums); + } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcNeighborHoodDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcNeighborHoodDao.java index 6e5d0487eb..3203e96854 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcNeighborHoodDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcNeighborHoodDao.java @@ -51,4 +51,14 @@ public interface IcNeighborHoodDao extends BaseDao { Integer checkNameUq(@Param("customerId") String customerId, @Param("neighborHoodName")String neighborHoodName, @Param("neighborId")String neighborId); + + /** + * @Description 根据小区名查询存在小区 + * @param names + * @param customerId + * @author zxc + * @date 2022/2/12 2:59 下午 + */ + List selectNeighborhoodNameByNames(@Param("names")List names,@Param("customerId") String customerId); + } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcPropertyManagementDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcPropertyManagementDao.java index b79a5cc3e6..442f3d0514 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcPropertyManagementDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcPropertyManagementDao.java @@ -20,6 +20,10 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.entity.IcPropertyManagementEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; /** * 物业表 @@ -31,4 +35,20 @@ import org.apache.ibatis.annotations.Mapper; public interface IcPropertyManagementDao extends BaseDao { IcPropertyManagementEntity selectByName(String name); + + /** + * @Description 根据物业名查询已存在的物业名 + * @param names + * @author zxc + * @date 2022/2/13 9:21 上午 + */ + List selectExistNames(@Param("names")List names); + + /** + * @Description 根据名字查ID + * @param names + * @author zxc + * @date 2022/2/13 9:59 上午 + */ + List selectIdByName(@Param("names")List names); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerAgencyEntity.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerAgencyEntity.java index cde41fbecc..fda8070609 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerAgencyEntity.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerAgencyEntity.java @@ -124,6 +124,11 @@ public class CustomerAgencyEntity extends BaseEpmetEntity { */ private String latitude; + /** + * 中心点位位置 + */ + private String centerAddress; + /** * 组织编码 */ diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerGridEntity.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerGridEntity.java index 49fe1b4bdb..d6018c2a29 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerGridEntity.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerGridEntity.java @@ -55,6 +55,11 @@ public class CustomerGridEntity extends BaseEpmetEntity { */ private String latitude; + /** + * 中心点位位置 + */ + private String centerAddress; + /** * 所属地区码(所属组织地区码) */ diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/IcNeighborHoodEntity.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/IcNeighborHoodEntity.java index 62489898d2..9fb05feb87 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/IcNeighborHoodEntity.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/IcNeighborHoodEntity.java @@ -17,6 +17,7 @@ package com.epmet.entity; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import com.epmet.commons.mybatis.entity.BaseEpmetEntity; @@ -98,4 +99,9 @@ public class IcNeighborHoodEntity extends BaseEpmetEntity { */ private String location; + @TableField(exist = false) + private String gridName; + + @TableField(exist = false) + private String propertyName; } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/IcNeighborHoodExcel.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/IcNeighborHoodExcel.java index 72c57047e0..b996da1bf2 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/IcNeighborHoodExcel.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/IcNeighborHoodExcel.java @@ -21,6 +21,7 @@ import cn.afterturn.easypoi.excel.annotation.Excel; import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.util.ExcelVerifyInfo; +import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Data; import org.hibernate.validator.constraints.Length; @@ -121,4 +122,16 @@ public class IcNeighborHoodExcel extends ExcelVerifyInfo implements Serializable @Length(max=500,message = "不能超过500个字") private String remark; + @JsonIgnore + private Boolean status = false; + + @JsonIgnore + private Boolean existNameStatus = false; + + @JsonIgnore + private Boolean agencyNameStatus = false; + + @JsonIgnore + private Boolean reStatus = false; + } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/BuildingErrorInfoModel.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/BuildingErrorInfoModel.java new file mode 100644 index 0000000000..7477c1a109 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/BuildingErrorInfoModel.java @@ -0,0 +1,24 @@ +package com.epmet.model; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; + +/** + * @Author zxc + * @DateTime 2022/2/15 10:07 上午 + * @DESC + */ +@Data +public class BuildingErrorInfoModel { + + @Excel(name = "小区名称" , width = 20) + private String neighborHoodName; + + @Excel(name = "楼栋名称", width = 20) + private String buildingName; + + @Excel(name = "错误信息", width = 100) + private String errorMsg; + +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/BuildingInfoModel.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/BuildingInfoModel.java new file mode 100644 index 0000000000..e76c391324 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/BuildingInfoModel.java @@ -0,0 +1,38 @@ +package com.epmet.model; + +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; + +/** + * @Author zxc + * @DateTime 2022/2/15 10:07 上午 + * @DESC + */ +@Data +public class BuildingInfoModel { + + @ExcelProperty(value = "所属组织") + private String agencyName; + + @ExcelProperty(value = "所属网格") + private String gridName; + + @ExcelProperty(value = "小区名称") + private String neighborHoodName; + + @ExcelProperty(value = "楼栋名称") + private String buildingName; + + @ExcelProperty(value = "楼栋类型") + private String type; + + @ExcelProperty(value = "单元数") + private Integer totalUnitNum; + + @ExcelProperty(value = "层数") + private Integer totalFloorNum; + + @ExcelProperty(value = "户数") + private Integer totalHouseNum; + +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseErrorInfoModel.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseErrorInfoModel.java new file mode 100644 index 0000000000..5d2a444f90 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseErrorInfoModel.java @@ -0,0 +1,31 @@ +package com.epmet.model; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; +import org.hibernate.validator.constraints.Length; + +/** + * @Author zxc + * @DateTime 2022/2/13 1:26 下午 + * @DESC + */ +@Data +public class HouseErrorInfoModel { + + @Excel(name = "所属小区", width = 20) + private String neighborHoodName; + + @Excel(name = "所属楼栋", width = 20) + private String buildingName; + + @Excel(name = "单元号", width = 20) + private Integer buildingUnit; + + @Excel(name = "门牌号", width = 20) + private String doorName; + + @Excel(name = "错误信息", width = 200) + private String errorMsg; + +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseInfoModel.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseInfoModel.java new file mode 100644 index 0000000000..9330a1a2d0 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseInfoModel.java @@ -0,0 +1,52 @@ +package com.epmet.model; + +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; +import org.hibernate.validator.constraints.Length; + +/** + * @Author zxc + * @DateTime 2022/2/13 1:26 下午 + * @DESC + */ +@Data +public class HouseInfoModel { + + @ExcelProperty(value = "所属组织") + private String agencyName; + + @ExcelProperty(value = "所属网格") + private String gridName; + + @ExcelProperty(value = "所属小区") + @Length(max=50,message = "不能超过50个字") + private String neighborHoodName; + + @ExcelProperty(value = "所属楼栋") + private String buildingName; + + @ExcelProperty(value = "单元号") + private Integer buildingUnit; + + @ExcelProperty(value = "门牌号") + private String doorName; + + @ExcelProperty(value = "房屋类型") + private String houseType; + + @ExcelProperty(value = "房屋用途") + private String purpose; + + @ExcelProperty(value = "出租") + private String rentFlagString; + + @ExcelProperty(value = "房主姓名") + private String ownerName; + + @ExcelProperty(value = "房主电话") + private String ownerPhone; + + @ExcelProperty(value = "房主身份证") + private String ownerIdCard; + +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportBuildingInfoListener.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportBuildingInfoListener.java new file mode 100644 index 0000000000..6c1963888a --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportBuildingInfoListener.java @@ -0,0 +1,407 @@ +package com.epmet.model; + +import com.alibaba.excel.context.AnalysisContext; +import com.alibaba.excel.event.AnalysisEventListener; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.commons.tools.redis.common.CustomerOrgRedis; +import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; +import com.epmet.commons.tools.redis.common.bean.GridInfoCache; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.constant.CustomerGridConstant; +import com.epmet.constant.ImportErrorMsgConstants; +import com.epmet.constants.ImportTaskConstants; +import com.epmet.dao.IcBuildingDao; +import com.epmet.dto.ImportGeneralDTO; +import com.epmet.dto.form.ImportInfoFormDTO; +import com.epmet.dto.form.ImportTaskCommonFormDTO; +import com.epmet.dto.result.ImportResultDTO; +import com.epmet.enums.BuildingTypeEnums; +import com.epmet.feign.EpmetCommonServiceOpenFeignClient; +import com.epmet.redis.IcHouseRedis; +import com.epmet.service.IcNeighborHoodService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.util.CollectionUtils; + +import java.io.IOException; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @Author zxc + * @DateTime 2022/2/15 10:06 上午 + * @DESC + */ +public class ImportBuildingInfoListener extends AnalysisEventListener { + + List nums = new ArrayList<>(); + Integer num = NumConstant.ZERO; + List errorInfos = new ArrayList<>(); + BuildingInfoModel info = null; + String taskId = ""; + + List needDisposeList = new ArrayList<>(); + List needInsertList = new ArrayList<>(); + + String gridName = null; + String agencyName = null; + + Map gridInfos = null; + List gridInfoDTOs = null; + Map neighborHoodInfos = null; + List neighborHoodInfoDTOs = null; + ImportGeneralDTO neighborHoodGeneralDTO = null; + Map buildingInfos = null; + List buildingInfoDTOs = null; + ImportGeneralDTO buildingGeneralDTO = null; + + private ImportInfoFormDTO formDTO; + private IcHouseRedis icHouseRedis; + private IcBuildingDao icBuildingDao; + private IcNeighborHoodService neighborHoodService; + private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient; + + public ImportBuildingInfoListener(ImportInfoFormDTO formDTO, IcHouseRedis icHouseRedis,IcBuildingDao icBuildingDao,IcNeighborHoodService neighborHoodService,EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient,String tId){ + this.formDTO = formDTO; + this.icHouseRedis = icHouseRedis; + this.icBuildingDao = icBuildingDao; + this.neighborHoodService = neighborHoodService; + this.epmetCommonServiceOpenFeignClient = epmetCommonServiceOpenFeignClient; + this.taskId = tId; + } + + @Override + public void invoke(BuildingInfoModel data, AnalysisContext context) { + if (null == data){ + return; + } + info = data; + num = num + NumConstant.ONE; + ImportGeneralDTO dto = ConvertUtils.sourceToTarget(data, ImportGeneralDTO.class); + dto.setNum(num); + dto.setCustomerId(formDTO.getCustomerId()); + if(StringUtils.isBlank(data.getAgencyName())){ + nums.add(num); + disposeErrorMsg(info, "所属组织的值未填写"); + return; + } + if(StringUtils.isBlank(data.getGridName())){ + nums.add(num); + disposeErrorMsg(info, "所属网格的值未填写"); + return; + } + if(StringUtils.isBlank(data.getNeighborHoodName())){ + nums.add(num); + disposeErrorMsg(info,"小区名称的值未填写"); + return; + } + if(StringUtils.isBlank(data.getBuildingName())){ + nums.add(num); + disposeErrorMsg(info,"楼栋名称的值未填写"); + return; + } + if(StringUtils.isBlank(data.getType())){ + nums.add(num); + disposeErrorMsg(info,"楼栋类型的值未填写"); + return; + } + if(null == data.getTotalUnitNum()){ + nums.add(num); + disposeErrorMsg(info,"单元数的值未填写"); + return; + } + // 应产品要求添加 + if (StringUtils.isNotBlank(dto.getType()) && (!dto.getType().equals("商品房") && !dto.getType().equals("自建房")) && !dto.getType().equals("别墅")){ + nums.add(num); + disposeErrorMsg(info, ImportErrorMsgConstants.BUILDING_ERROR); + return; + } + dto.setType(BuildingTypeEnums.getKeyByValue(dto.getType())); + if (formDTO.getOrgType().equals(CustomerGridConstant.NEIGHBORHOOD)){ + disposeNeighborHoodBuilding(dto); + }else if (formDTO.getOrgType().equals(CustomerGridConstant.GRID)){ + disposeGridBuilding(dto); + }else if (formDTO.getOrgType().equals(CustomerGridConstant.AGENCY)){ + disposeAgencyBuilding(dto); + } + // 数据筛选完毕,当num每满100条,处理一次 + if (num%NumConstant.ONE_HUNDRED == NumConstant.ZERO){ + finalDispose(); + } + } + + public void finalDispose(){ + if (CollectionUtils.isEmpty(needDisposeList)){ + return; + } + Map groupByAllName = needDisposeList.stream().collect(Collectors.groupingBy( + n -> n.getAgencyName() + "_" + n.getGridName() + "_" + + n.getNeighborHoodName() + "_" + n.getBuildingName(), Collectors.counting())); + groupByAllName.forEach((k,v) -> { + if (Integer.valueOf(v.toString()).compareTo(1) > 0){ + for (ImportGeneralDTO r : needDisposeList) { + if (k.equals(r.getAgencyName() + "_" + r.getGridName() + "_" + + r.getNeighborHoodName() + "_" + r.getBuildingName())){ + // 集合里重复的 + nums.add(r.getNum()); + disposeErrorMsg(info,ImportErrorMsgConstants.EXIST_ERROR); + r.setExistStatus(true); + } + } + } + }); + Map> groupByStatus = needDisposeList.stream().collect(Collectors.groupingBy(ImportGeneralDTO::getExistStatus)); + List importGeneralDTOS = groupByStatus.get(false); + if (!CollectionUtils.isEmpty(importGeneralDTOS)){ + List importInfo = neighborHoodService.getImportInfo(formDTO, importGeneralDTOS); + Map> groupByBuildingExistStatus = importInfo.stream().collect(Collectors.groupingBy(ImportGeneralDTO::getBuildingExistStatus)); + List existList = groupByBuildingExistStatus.get(true); + if (!CollectionUtils.isEmpty(existList)){ + existList.forEach(e -> { + nums.add(e.getNum()); + disposeErrorMsg(info,ImportErrorMsgConstants.EXIST_ERROR); + }); + } + } + // 清除 + needDisposeList = new ArrayList<>(); + needInsertList = new ArrayList<>(); + gridName = null; + agencyName = null; + gridInfos = null; + gridInfoDTOs = null; + neighborHoodInfos = null; + neighborHoodInfoDTOs = null; + neighborHoodGeneralDTO = null; + buildingInfos = null; + buildingInfoDTOs = null; + buildingGeneralDTO = null; + } + + public void fillData(ImportGeneralDTO dto, String orgType){ + if (orgType.equals(CustomerGridConstant.GRID) || orgType.equals(CustomerGridConstant.AGENCY)){ + List gridIds = new ArrayList<>(); + if (orgType.equals(CustomerGridConstant.GRID)){ + gridIds = Arrays.asList(formDTO.getOrgId()); + }else if (orgType.equals(CustomerGridConstant.AGENCY)){ + gridIds = gridInfoDTOs.stream().map(m -> m.getGridId()).collect(Collectors.toList()); + } + neighborHoodInfos = null == neighborHoodInfos ? getNeighborHoodInfos(gridIds) : neighborHoodInfos; + Object cacheNeighBorHood = icHouseRedis.getTemporaryCacheNeighBorHood(formDTO.getCustomerId(), formDTO.getUserId(), formDTO.getOrgId() + "_" + dto.getNeighborHoodName()); + // 赋值小区ID + dto.setNeighborHoodId(null == cacheNeighBorHood ? "" : cacheNeighBorHood.toString()); + } + if (StringUtils.isNotBlank(dto.getNeighborHoodId())){ + //小区ID不为空赋值楼栋ID + buildingInfos = null == buildingInfos ? getBuildingInfos(dto.getAgencyId()) : buildingInfos; + Object cacheBuilding = icHouseRedis.getTemporaryCacheBuilding(formDTO.getCustomerId(), formDTO.getUserId(), dto.getNeighborHoodId() + "_" + dto.getBuildingName()); + dto.setBuildingId(null == cacheBuilding ? "" : cacheBuilding.toString()); + if (StringUtils.isNotBlank(dto.getBuildingId())){ + // 说明数据库已存在此楼栋,不需添加 + nums.add(num); + disposeErrorMsg(info,ImportErrorMsgConstants.EXIST_ERROR); + }else { + needDisposeList.add(dto); + } + }else { + needDisposeList.add(dto); + } + } + + /** + * @Description 左侧树点击小区时调用 + * @param dto + * @author zxc + * @date 2022/2/15 10:41 上午 + */ + public void disposeNeighborHoodBuilding(ImportGeneralDTO dto){ + neighborHoodGeneralDTO = null == neighborHoodGeneralDTO ? icBuildingDao.selectNeighborHoodById(formDTO.getOrgId()) : neighborHoodGeneralDTO; + //排除不是本小区的 + if (!dto.getNeighborHoodName().equals(neighborHoodGeneralDTO.getNeighborHoodName())){ + nums.add(num); + disposeErrorMsg(info,ImportErrorMsgConstants.BUILDING_ERROR); + }else { + GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(neighborHoodGeneralDTO.getGridId()); + if (null == gridInfo){ + nums.add(num); + disposeErrorMsg(info, ImportErrorMsgConstants.BUILDING_ERROR); + return; + } + // 1.排除网格名不一样但小区名一样 2.排除组织不一样,网格一样,小区一样 + if ((!gridInfo.getGridName().equals(dto.getGridName()) && neighborHoodGeneralDTO.getNeighborHoodName().equals(dto.getNeighborHoodName())) || + (!gridInfo.getAgencyName().equals(dto.getAgencyName()) && gridInfo.getGridName().equals(dto.getGridName()) && neighborHoodGeneralDTO.getNeighborHoodName().equals(dto.getNeighborHoodName()))){ + nums.add(num); + disposeErrorMsg(info,ImportErrorMsgConstants.BUILDING_ERROR); + return; + } + dto.setNeighborHoodId(formDTO.getOrgId()); + dto.setGridId(neighborHoodGeneralDTO.getGridId()); + dto.setAgencyId(neighborHoodGeneralDTO.getAgencyId()); + AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId()); + if (null == agencyInfo){ + nums.add(num); + disposeErrorMsg(info, ImportErrorMsgConstants.BUILDING_ERROR); + return; + } + dto.setPid(agencyInfo.getPid()); + dto.setPids(agencyInfo.getPids()); + // 填充各种ID + fillData(dto,CustomerGridConstant.NEIGHBORHOOD); + } + } + + /** + * @Description 左侧树点击网格时调用 + * @param dto + * @author zxc + * @date 2022/2/15 10:41 上午 + */ + public void disposeGridBuilding(ImportGeneralDTO dto){ + gridName = null == gridName ? icBuildingDao.selectGridNameById(formDTO.getOrgId()) : gridName; + GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(formDTO.getOrgId()); + if (null == gridInfo){ + nums.add(num); + disposeErrorMsg(info, ImportErrorMsgConstants.BUILDING_ERROR); + return; + } + //排除不是本网格的 gridName不一样排除,gridName一样但是agencyName不一样也得排除 + if (dto.getGridName().compareTo(gridName) != 0 || (!dto.getAgencyName().equals(gridInfo.getAgencyName()) && dto.getGridName().equals(gridName))){ + nums.add(num); + disposeErrorMsg(info,ImportErrorMsgConstants.BUILDING_ERROR); + }else { + // + dto.setGridId(formDTO.getOrgId()); + dto.setAgencyId(gridInfo.getPid()); + AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId()); + if (null == agencyInfo){ + nums.add(num); + disposeErrorMsg(info, ImportErrorMsgConstants.BUILDING_ERROR); + return; + } + dto.setPid(agencyInfo.getPid()); + dto.setPids(agencyInfo.getPids()); + // 填充各种ID + fillData(dto, CustomerGridConstant.GRID); + } + } + + /** + * @Description 左侧树点击组织时调用 + * @param dto + * @author zxc + * @date 2022/2/15 10:41 上午 + */ + public void disposeAgencyBuilding(ImportGeneralDTO dto){ + agencyName = null == agencyName ? icBuildingDao.selectAgencyNameById(formDTO.getOrgId()) : agencyName; + //排除不是本组织的 + if (!dto.getAgencyName().equals(agencyName)){ + nums.add(num); + disposeErrorMsg(info,ImportErrorMsgConstants.BUILDING_ERROR); + }else { + // 根据组织查询出所有网格,甩出不是本组织下的网格 + gridInfos = null == gridInfos ? getGridInfos(formDTO.getOrgId()) : gridInfos; + if (null == gridInfos){ + // 组织下确实不存在网格 + nums.add(num); + disposeErrorMsg(info,ImportErrorMsgConstants.BUILDING_ERROR); + return; + } + // 根据网格名对比,没有找到的就把行号加入到未执行成功队列中 + Object cacheGridName = icHouseRedis.getTemporaryCacheGrid(formDTO.getCustomerId(), formDTO.getUserId(), dto.getGridName()); + if (null == cacheGridName){ + nums.add(num); + disposeErrorMsg(info,ImportErrorMsgConstants.BUILDING_ERROR); + return; + } + dto.setGridId(cacheGridName.toString()); + dto.setAgencyId(formDTO.getOrgId()); + AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId()); + if (null == agencyInfo){ + nums.add(num); + disposeErrorMsg(info, ImportErrorMsgConstants.BUILDING_ERROR); + return; + } + dto.setPid(agencyInfo.getPid()); + dto.setPids(agencyInfo.getPids()); + // 填充各种ID + fillData(dto,CustomerGridConstant.AGENCY); + } + } + + /** + * @Description 获取网格信息 + * @param orgId + * @author zxc + * @date 2022/2/14 9:57 上午 + */ + public Map getGridInfos(String orgId){ + gridInfoDTOs = icBuildingDao.selectAllGridByOrgId(orgId); + gridInfos = gridInfoDTOs.stream().collect(Collectors.toMap(n -> n.getGridName(), n -> n.getGridId())); + icHouseRedis.setTemporaryCacheGrid(formDTO.getCustomerId(), gridInfos, formDTO.getUserId()); + return gridInfos; + } + + /** + * @Description 获取网格下的小区 + * @param gridIds + * @author zxc + * @date 2022/2/14 10:16 上午 + */ + public Map getNeighborHoodInfos(List gridIds){ + neighborHoodInfoDTOs = icBuildingDao.selectAllNeighborHoodByGridIds(gridIds); + neighborHoodInfos = neighborHoodInfoDTOs.stream().collect(Collectors.toMap(n -> n.getGridId() + "_" + n.getNeighborHoodName(), n -> n.getNeighborHoodId())); + icHouseRedis.setTemporaryCacheNeighBorHood(formDTO.getCustomerId(), neighborHoodInfos, formDTO.getUserId()); + return neighborHoodInfos; + } + + /** + * @Description 获取小区下的楼栋 + * @param orgId + * @author zxc + * @date 2022/2/14 1:32 下午 + */ + public Map getBuildingInfos(String orgId){ + buildingInfoDTOs = icBuildingDao.selectAllBuildingByNeighborHoodId(orgId); + buildingInfos = buildingInfoDTOs.stream().collect(Collectors.toMap(n -> n.getNeighborHoodId() + "_" + n.getBuildingName(), n -> n.getBuildingId())); + icHouseRedis.setTemporaryCacheBuilding(formDTO.getCustomerId(), buildingInfos, formDTO.getUserId()); + return buildingInfos; + } + + public void disposeErrorMsg(BuildingInfoModel data,String msg){ + BuildingErrorInfoModel err = ConvertUtils.sourceToTarget(data, BuildingErrorInfoModel.class); + err.setErrorMsg(msg); + errorInfos.add(err); + } + + @Override + public void doAfterAllAnalysed(AnalysisContext context) { + finalDispose(); + // 删除缓存 + icHouseRedis.delTemporaryCacheGrids(formDTO.getCustomerId(), formDTO.getUserId()); + icHouseRedis.delTemporaryCacheNeighBorHood(formDTO.getCustomerId(), formDTO.getUserId()); + icHouseRedis.delTemporaryCacheBuilding(formDTO.getCustomerId(), formDTO.getUserId()); + icHouseRedis.delTemporaryCacheBuildingUnit(formDTO.getCustomerId(), formDTO.getUserId()); + icHouseRedis.delTemporaryCacheHouses(formDTO.getCustomerId(), formDTO.getUserId()); + // 放结果 + icHouseRedis.setImportResultDTO(formDTO.getCustomerId(), formDTO.getUserId(), new ImportResultDTO(nums,num)); + ImportTaskCommonFormDTO input = new ImportTaskCommonFormDTO(); + input.setOperatorId(formDTO.getUserId()); + input.setTaskId(taskId); + if (CollectionUtils.isEmpty(nums)){ + input.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_SUCCESS); + epmetCommonServiceOpenFeignClient.finishImportTask(input); + }else { + input.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL); + if (!CollectionUtils.isEmpty(errorInfos)){ + try { + String s = neighborHoodService.orgGeneralImport(errorInfos, BuildingErrorInfoModel.class); + input.setResultDescFilePath(s); + } catch (IOException e) { + epmetCommonServiceOpenFeignClient.finishImportTask(input); + e.printStackTrace(); + } + } + epmetCommonServiceOpenFeignClient.finishImportTask(input); + } + } +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportHouseInfoListener.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportHouseInfoListener.java new file mode 100644 index 0000000000..60b609752c --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportHouseInfoListener.java @@ -0,0 +1,579 @@ +package com.epmet.model; + +import com.alibaba.excel.context.AnalysisContext; +import com.alibaba.excel.event.AnalysisEventListener; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.commons.tools.redis.common.CustomerOrgRedis; +import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; +import com.epmet.commons.tools.redis.common.bean.GridInfoCache; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.constant.CustomerGridConstant; +import com.epmet.constant.ImportErrorMsgConstants; +import com.epmet.constants.ImportTaskConstants; +import com.epmet.dao.IcBuildingDao; +import com.epmet.dto.ImportGeneralDTO; +import com.epmet.dto.form.ImportInfoFormDTO; +import com.epmet.dto.form.ImportTaskCommonFormDTO; +import com.epmet.dto.result.ImportResultDTO; +import com.epmet.dto.result.UpdateBuildingHouseNumResultDTO; +import com.epmet.entity.IcHouseEntity; +import com.epmet.enums.HousePurposeEnums; +import com.epmet.enums.HouseRentFlagEnums; +import com.epmet.enums.HouseTypeEnums; +import com.epmet.feign.EpmetCommonServiceOpenFeignClient; +import com.epmet.redis.IcHouseRedis; +import com.epmet.service.IcHouseService; +import com.epmet.service.IcNeighborHoodService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import java.io.IOException; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @Author zxc + * @DateTime 2022/2/13 1:25 下午 + * @DESC + */ +public class ImportHouseInfoListener extends AnalysisEventListener { + + List nums = new ArrayList<>(); + Integer num = NumConstant.ZERO; + List errorInfos = new ArrayList<>(); + HouseInfoModel info = null; + String taskId = ""; + + List needDisposeList = new ArrayList<>(); + List needInsertList = new ArrayList<>(); + + String gridName = null; + String agencyName = null; + + Map gridInfos = null; + List gridInfoDTOs = null; + Map neighborHoodInfos = null; + List neighborHoodInfoDTOs = null; + ImportGeneralDTO neighborHoodGeneralDTO = null; + Map buildingInfos = null; + List buildingInfoDTOs = null; + ImportGeneralDTO buildingGeneralDTO = null; + Map buildingUnitInfos = null; + List buildingUnitInfoDTOs = null; + + private ImportInfoFormDTO formDTO; + private IcBuildingDao icBuildingDao; + private IcHouseRedis icHouseRedis; + private IcNeighborHoodService neighborHoodService; + private IcHouseService icHouseService; + private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient; + + public ImportHouseInfoListener(ImportInfoFormDTO formDTO,IcBuildingDao icBuildingDao, IcHouseRedis icHouseRedis,IcNeighborHoodService neighborHoodService, IcHouseService icHouseService, EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient,String tId){ + this.formDTO = formDTO; + this.icBuildingDao = icBuildingDao; + this.icHouseRedis = icHouseRedis; + this.neighborHoodService = neighborHoodService; + this.icHouseService = icHouseService; + this.epmetCommonServiceOpenFeignClient = epmetCommonServiceOpenFeignClient; + this.taskId = tId; + } + + @Override + public void invoke(HouseInfoModel data, AnalysisContext context) { + if (null == data){ + return; + } + info = data; + num = num + NumConstant.ONE; + ImportGeneralDTO dto = ConvertUtils.sourceToTarget(data, ImportGeneralDTO.class); + dto.setNum(num); + dto.setCustomerId(formDTO.getCustomerId()); + if(StringUtils.isBlank(data.getAgencyName())){ + nums.add(num); + disposeErrorMsg(info, "所属组织的值未填写"); + return; + } + if(StringUtils.isBlank(data.getGridName())){ + nums.add(num); + disposeErrorMsg(info, "所属网格的值未填写"); + return; + } + if(StringUtils.isBlank(data.getNeighborHoodName())){ + nums.add(num); + disposeErrorMsg(info,"所属小区的值未填写"); + return; + } + if(StringUtils.isBlank(data.getBuildingName())){ + nums.add(num); + disposeErrorMsg(info,"所属楼栋的值未填写"); + return; + } + if(StringUtils.isBlank(data.getHouseType())){ + nums.add(num); + disposeErrorMsg(info, "房屋类型的值未填写"); + return; + } + if(StringUtils.isBlank(data.getPurpose())){ + nums.add(num); + disposeErrorMsg(info, "房屋用途的值未填写"); + return; + } + if(StringUtils.isBlank(data.getRentFlagString())){ + nums.add(num); + disposeErrorMsg(info, "是否出租的值未填写"); + return; + } + if(StringUtils.isBlank(data.getOwnerIdCard())){ + nums.add(num); + disposeErrorMsg(info, "房主身份证的值未填写"); + return; + } + if(StringUtils.isBlank(data.getOwnerName())){ + nums.add(num); + disposeErrorMsg(info, "房主姓名的值未填写"); + return; + } + if(StringUtils.isBlank(data.getOwnerPhone())){ + nums.add(num); + disposeErrorMsg(info, "房主电话的值未填写"); + return; + } + if(StringUtils.isBlank(data.getDoorName())){ + nums.add(num); + disposeErrorMsg(info, "门牌号的值未填写"); + return; + } + if(null == data.getBuildingUnit()){ + nums.add(num); + disposeErrorMsg(info, "单元号的值未填写"); + return; + } + // 应产品要求 + if (StringUtils.isNotBlank(dto.getHouseType()) ){ + if( !"楼房".equals(dto.getHouseType()) && !dto.getHouseType().equals("平房") && !dto.getHouseType().equals("别墅") ){ + nums.add(num); + disposeErrorMsg(info,ImportErrorMsgConstants.HOUSE_ERROR); + return; + } + } + dto.setHouseType(HouseTypeEnums.getKeyByValue(dto.getHouseType())); + + if (StringUtils.isNotBlank(dto.getPurpose()) && (!dto.getPurpose().equals("住宅") && + !dto.getPurpose().equals("商业") && + !dto.getPurpose().equals("办公") && + !dto.getPurpose().equals("工业") && + !dto.getPurpose().equals("仓储") && + !dto.getPurpose().equals("商住混用") && + !dto.getPurpose().equals("其他")) ){ + nums.add(num); + disposeErrorMsg(info, ImportErrorMsgConstants.HOUSE_ERROR); + return; + } + dto.setPurpose(HousePurposeEnums.getKeyByValue(dto.getPurpose())); + if (StringUtils.isNotBlank(dto.getRentFlagString()) && (!dto.getRentFlagString().equals("是") && !dto.getRentFlagString().equals("否"))){ + nums.add(num); + disposeErrorMsg(info,ImportErrorMsgConstants.HOUSE_ERROR); + return; + } + dto.setRentFlag(HouseRentFlagEnums.getCodeByName(dto.getRentFlagString())); + dto.setHouseName(dto.getBuildingName()+"-"+dto.getBuildingUnit()+"-"+dto.getDoorName()); + if (formDTO.getOrgType().equals(CustomerGridConstant.BUILDING)){ + disposeBuildingHouse(dto); + }else if (formDTO.getOrgType().equals(CustomerGridConstant.NEIGHBORHOOD)){ + disposeNeighborHoodHouse(dto); + }else if (formDTO.getOrgType().equals(CustomerGridConstant.GRID)){ + disposeGridHouse(dto); + }else if (formDTO.getOrgType().equals(CustomerGridConstant.AGENCY)){ + disposeAgencyHouse(dto); + } + // 数据筛选完毕,当num每满100条,处理一次 + if (num%NumConstant.ONE_HUNDRED == NumConstant.ZERO){ + finalDispose(); + } + } + + public void disposeErrorMsg(HouseInfoModel data,String msg){ + HouseErrorInfoModel err = ConvertUtils.sourceToTarget(data, HouseErrorInfoModel.class); + err.setErrorMsg(msg); + errorInfos.add(err); + } + + public void finalDispose(){ + if (!CollectionUtils.isEmpty(needDisposeList)){ + List importInfo = neighborHoodService.getImportInfo(formDTO, needDisposeList); + needInsertList.addAll(importInfo); + } + if (CollectionUtils.isEmpty(needInsertList)){ + return; + } + Map collect = needInsertList.stream().collect(Collectors.groupingBy(n -> n.getBuildingUnitId() + "_" + n.getDoorName(), Collectors.counting())); + collect.forEach((k,v) -> { + if (Integer.valueOf(v.toString()).compareTo(1) > 0){ + for (ImportGeneralDTO r : needInsertList) { + if (k.equals(r.getBuildingUnitId()+"_"+r.getDoorName())){ + // 集合里重复的 + nums.add(r.getNum()); + disposeErrorMsg(info,ImportErrorMsgConstants.EXIST_ERROR); + r.setExistStatus(true); + } + } + } + }); + // 根据单元ID_doorName查询已存在的 + List ids = needInsertList.stream().filter(n -> StringUtils.isNotBlank(n.getBuildingUnitId())).map(m -> m.getBuildingUnitId() + "_" + m.getDoorName()).distinct().collect(Collectors.toList()); + List existHouses = icBuildingDao.selectExistHouse(ids); + existHouses.forEach(e -> { + for (ImportGeneralDTO n : needInsertList) { + if ((n.getBuildingUnitId()+"_"+n.getDoorName()).equals(e)){ + // 库里存在的 + nums.add(n.getNum()); + disposeErrorMsg(info,ImportErrorMsgConstants.EXIST_ERROR); + n.setExistStatus(true); + } + } + }); + // 根据存在状态分组 + Map> groupByExistStatus = needInsertList.stream().collect(Collectors.groupingBy(ImportGeneralDTO::getExistStatus)); + List importGeneralDTOS = groupByExistStatus.get(false); + houseInsert(importGeneralDTOS); + // 清除 + needDisposeList = new ArrayList<>(); + needInsertList = new ArrayList<>(); + gridName = null; + agencyName = null; + gridInfos = null; + gridInfoDTOs = null; + neighborHoodInfos = null; + neighborHoodInfoDTOs = null; + neighborHoodGeneralDTO = null; + buildingInfos = null; + buildingInfoDTOs = null; + buildingGeneralDTO = null; + buildingUnitInfos = null; + buildingUnitInfoDTOs = null; + } + + /** + * @Description 左侧树点击楼栋时调用 + * @param dto + * @author zxc + * @date 2022/2/14 3:23 下午 + */ + public void disposeBuildingHouse(ImportGeneralDTO dto){ + buildingGeneralDTO = null == buildingGeneralDTO ? icBuildingDao.selectBuildingById(formDTO.getOrgId()) : buildingGeneralDTO; + // 排除不是本楼的 + if (!dto.getBuildingName().equals(buildingGeneralDTO.getBuildingName())){ + nums.add(num); + disposeErrorMsg(info,ImportErrorMsgConstants.HOUSE_ERROR); + }else { + GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(buildingGeneralDTO.getGridId()); + if (null == gridInfo){ + nums.add(num); + disposeErrorMsg(info, ImportErrorMsgConstants.HOUSE_ERROR); + return; + } + // 排除 1、小区名不一样&&楼栋名一样 2、网格名不一样&&小区名一样&&楼名一样 3、组织名不一样&&网格名一样&&小区名一样&&楼名一样 + if ((!buildingGeneralDTO.getNeighborHoodName().equals(dto.getNeighborHoodName()) && buildingGeneralDTO.getBuildingName().equals(dto.getBuildingName())) + || (!gridInfo.getGridName().equals(dto.getGridName())&&buildingGeneralDTO.getNeighborHoodName().equals(dto.getNeighborHoodName()) && buildingGeneralDTO.getBuildingName().equals(dto.getBuildingName())) + || (!gridInfo.getAgencyName().equals(dto.getAgencyName())&&gridInfo.getGridName().equals(dto.getGridName())&&buildingGeneralDTO.getNeighborHoodName().equals(dto.getNeighborHoodName()) && buildingGeneralDTO.getBuildingName().equals(dto.getBuildingName()))){ + nums.add(num); + disposeErrorMsg(info,ImportErrorMsgConstants.HOUSE_ERROR); + return; + } + dto.setBuildingId(formDTO.getOrgId()); + dto.setNeighborHoodId(buildingGeneralDTO.getNeighborHoodId()); + dto.setGridId(buildingGeneralDTO.getGridId()); + dto.setAgencyId(buildingGeneralDTO.getAgencyId()); + AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId()); + if (null == agencyInfo){ + nums.add(num); + disposeErrorMsg(info, ImportErrorMsgConstants.HOUSE_ERROR); + return; + } + dto.setPid(agencyInfo.getPid()); + dto.setPids(agencyInfo.getPids()); + dto.setType(buildingGeneralDTO.getType()); + dto.setTotalHouseNum(buildingGeneralDTO.getTotalHouseNum()); + dto.setTotalFloorNum(buildingGeneralDTO.getTotalFloorNum()); + dto.setTotalUnitNum(buildingGeneralDTO.getTotalUnitNum()); + // 补充单元ID + buildingUnitInfos = null == buildingUnitInfos ? getBuildingUnitInfos(dto.getAgencyId()) : buildingUnitInfos; + Object cacheBuildingUnit = icHouseRedis.getTemporaryCacheBuildingUnit(formDTO.getCustomerId(), formDTO.getUserId(), dto.getBuildingId() + "_" + dto.getBuildingUnit()); + dto.setBuildingUnitId(null == cacheBuildingUnit ? "" : cacheBuildingUnit.toString()); + if (StringUtils.isNotBlank(dto.getBuildingUnitId())){ + // 所有ID补充完毕,不需调用补用方法 + needInsertList.add(dto); + }else { + needDisposeList.add(dto); + } + } + } + + /** + * @Description 左侧树点击小区时调用 + * @param dto + * @author zxc + * @date 2022/2/14 3:23 下午 + */ + public void disposeNeighborHoodHouse(ImportGeneralDTO dto){ + neighborHoodGeneralDTO = null == neighborHoodGeneralDTO ? icBuildingDao.selectNeighborHoodById(formDTO.getOrgId()) : neighborHoodGeneralDTO; + //排除不是本小区的 + if (!dto.getNeighborHoodName().equals(neighborHoodGeneralDTO.getNeighborHoodName())){ + nums.add(num); + disposeErrorMsg(info,ImportErrorMsgConstants.HOUSE_ERROR); + }else { + GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(neighborHoodGeneralDTO.getGridId()); + if (null == gridInfo){ + nums.add(num); + disposeErrorMsg(info, ImportErrorMsgConstants.HOUSE_ERROR); + return; + } + // 1.排除网格名不一样但小区名一样 2.排除组织不一样,网格一样,小区一样 + if ((!gridInfo.getGridName().equals(dto.getGridName()) && neighborHoodGeneralDTO.getNeighborHoodName().equals(dto.getNeighborHoodName())) || + (!gridInfo.getAgencyName().equals(dto.getAgencyName()) && gridInfo.getGridName().equals(dto.getGridName()) && neighborHoodGeneralDTO.getNeighborHoodName().equals(dto.getNeighborHoodName()))){ + nums.add(num); + disposeErrorMsg(info,ImportErrorMsgConstants.HOUSE_ERROR); + return; + } + dto.setNeighborHoodId(formDTO.getOrgId()); + dto.setGridId(neighborHoodGeneralDTO.getGridId()); + dto.setAgencyId(neighborHoodGeneralDTO.getAgencyId()); + AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId()); + if (null == agencyInfo){ + nums.add(num); + disposeErrorMsg(info, ImportErrorMsgConstants.HOUSE_ERROR); + return; + } + dto.setPid(agencyInfo.getPid()); + dto.setPids(agencyInfo.getPids()); + // 填充各种ID + fillData(dto,CustomerGridConstant.NEIGHBORHOOD); + } + } + + /** + * @Description 左侧树点击网格时调用 + * @param dto + * @author zxc + * @date 2022/2/14 2:14 下午 + */ + public void disposeGridHouse(ImportGeneralDTO dto){ + gridName = null == gridName ? icBuildingDao.selectGridNameById(formDTO.getOrgId()) : gridName; + GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(formDTO.getOrgId()); + if (null == gridInfo){ + nums.add(num); + disposeErrorMsg(info, ImportErrorMsgConstants.HOUSE_ERROR); + return; + } + //排除不是本网格的 gridName不一样排除,gridName一样但是agencyName不一样也得排除 + if (dto.getGridName().compareTo(gridName) != 0 || (!dto.getAgencyName().equals(gridInfo.getAgencyName()) && dto.getGridName().equals(gridName))){ + nums.add(num); + disposeErrorMsg(info,ImportErrorMsgConstants.HOUSE_ERROR); + }else { + // + dto.setGridId(formDTO.getOrgId()); + dto.setAgencyId(gridInfo.getPid()); + AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId()); + if (null == agencyInfo){ + nums.add(num); + disposeErrorMsg(info, ImportErrorMsgConstants.HOUSE_ERROR); + return; + } + dto.setPid(agencyInfo.getPid()); + dto.setPids(agencyInfo.getPids()); + // 填充各种ID + fillData(dto, CustomerGridConstant.GRID); + } + } + + /** + * @Description 左侧树点击组织时调用 + * @param dto + * @author zxc + * @date 2022/2/14 1:35 下午 + */ + public void disposeAgencyHouse(ImportGeneralDTO dto){ + agencyName = null == agencyName ? icBuildingDao.selectAgencyNameById(formDTO.getOrgId()) : agencyName; + //排除不是本组织的 + if (!dto.getAgencyName().equals(agencyName)){ + nums.add(num); + disposeErrorMsg(info,ImportErrorMsgConstants.HOUSE_ERROR); + }else { + // 根据组织查询出所有网格,甩出不是本组织下的网格 + gridInfos = null == gridInfos ? getGridInfos(formDTO.getOrgId()) : gridInfos; + if (null == gridInfos){ + // 组织下确实不存在网格 + nums.add(num); + disposeErrorMsg(info,ImportErrorMsgConstants.HOUSE_ERROR); + return; + } + // 根据网格名对比,没有找到的就把行号加入到未执行成功队列中 + Object cacheGridName = icHouseRedis.getTemporaryCacheGrid(formDTO.getCustomerId(), formDTO.getUserId(), dto.getGridName()); + if (null == cacheGridName){ + nums.add(num); + disposeErrorMsg(info,ImportErrorMsgConstants.HOUSE_ERROR); + return; + } + dto.setGridId(cacheGridName.toString()); + dto.setAgencyId(formDTO.getOrgId()); + AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId()); + if (null == agencyInfo){ + nums.add(num); + disposeErrorMsg(info, ImportErrorMsgConstants.HOUSE_ERROR); + return; + } + dto.setPid(agencyInfo.getPid()); + dto.setPids(agencyInfo.getPids()); + // 填充各种ID + fillData(dto, CustomerGridConstant.AGENCY); + } + } + + public void fillData(ImportGeneralDTO dto, String orgType){ + if (orgType.equals(CustomerGridConstant.GRID) || orgType.equals(CustomerGridConstant.AGENCY)){ + List gridIds = new ArrayList<>(); + if (orgType.equals(CustomerGridConstant.GRID)){ + gridIds = Arrays.asList(formDTO.getOrgId()); + }else if (orgType.equals(CustomerGridConstant.AGENCY)){ + gridIds = gridInfoDTOs.stream().map(m -> m.getGridId()).collect(Collectors.toList()); + } + neighborHoodInfos = null == neighborHoodInfos ? getNeighborHoodInfos(gridIds) : neighborHoodInfos; + Object cacheNeighBorHood = icHouseRedis.getTemporaryCacheNeighBorHood(formDTO.getCustomerId(), formDTO.getUserId(), dto.getGridId() + "_" + dto.getNeighborHoodName()); + // 赋值小区ID + dto.setNeighborHoodId(null == cacheNeighBorHood ? "" : cacheNeighBorHood.toString()); + } + if (StringUtils.isNotBlank(dto.getNeighborHoodId())){ + //小区ID不为空赋值楼栋ID + buildingInfos = null == buildingInfos ? getBuildingInfos(dto.getNeighborHoodId()) : buildingInfos; + Object cacheBuilding = icHouseRedis.getTemporaryCacheBuilding(formDTO.getCustomerId(), formDTO.getUserId(), dto.getNeighborHoodId() + "_" + dto.getBuildingName()); + dto.setBuildingId(null == cacheBuilding ? "" : cacheBuilding.toString()); + if (StringUtils.isNotBlank(dto.getBuildingId())){ + // 楼栋ID不为空赋值单元ID + buildingUnitInfos = null == buildingUnitInfos ? getBuildingUnitInfos(dto.getAgencyId()) : buildingUnitInfos; + Object cacheBuildingUnit = icHouseRedis.getTemporaryCacheBuildingUnit(formDTO.getCustomerId(), formDTO.getUserId(), dto.getBuildingId() + "_" + dto.getBuildingUnit()); + dto.setBuildingUnitId(null == cacheBuildingUnit ? "" : cacheBuildingUnit.toString()); + if (StringUtils.isNotBlank(dto.getBuildingUnitId())){ + // 所有ID补充完毕,不需调用补用方法 + needInsertList.add(dto); + }else { + needDisposeList.add(dto); + } + }else { + needDisposeList.add(dto); + } + }else { + needDisposeList.add(dto); + } + } + + /** + * @Description 获取网格信息 + * @param orgId + * @author zxc + * @date 2022/2/14 9:57 上午 + */ + public Map getGridInfos(String orgId){ + gridInfoDTOs = icBuildingDao.selectAllGridByOrgId(orgId); + gridInfos = gridInfoDTOs.stream().collect(Collectors.toMap(n -> n.getGridName(), n -> n.getGridId())); + icHouseRedis.setTemporaryCacheGrid(formDTO.getCustomerId(), gridInfos, formDTO.getUserId()); + return gridInfos; + } + + /** + * @Description 获取网格下的小区 + * @param gridIds + * @author zxc + * @date 2022/2/14 10:16 上午 + */ + public Map getNeighborHoodInfos(List gridIds){ + neighborHoodInfoDTOs = icBuildingDao.selectAllNeighborHoodByGridIds(gridIds); + neighborHoodInfos = neighborHoodInfoDTOs.stream().collect(Collectors.toMap(n -> n.getGridId() + "_" + n.getNeighborHoodName(), n -> n.getNeighborHoodId())); + icHouseRedis.setTemporaryCacheNeighBorHood(formDTO.getCustomerId(), neighborHoodInfos, formDTO.getUserId()); + return neighborHoodInfos; + } + + /** + * @Description 获取小区下的楼栋 + * @param orgId + * @author zxc + * @date 2022/2/14 1:32 下午 + */ + public Map getBuildingInfos(String orgId){ + buildingInfoDTOs = icBuildingDao.selectAllBuildingByNeighborHoodId(orgId); + buildingInfos = buildingInfoDTOs.stream().collect(Collectors.toMap(n -> n.getNeighborHoodId() + "_" + n.getBuildingName(), n -> n.getBuildingId())); + icHouseRedis.setTemporaryCacheBuilding(formDTO.getCustomerId(), buildingInfos, formDTO.getUserId()); + return buildingInfos; + } + + /** + * @Description 获取组织下的单元 + * @param orgId + * @author zxc + * @date 2022/2/14 2:04 下午 + */ + public Map getBuildingUnitInfos(String orgId){ + buildingUnitInfoDTOs = icBuildingDao.selectAllBuildingUnitByBuildingId(orgId); + if (!CollectionUtils.isEmpty(buildingUnitInfoDTOs)){ + buildingUnitInfos = buildingUnitInfoDTOs.stream().collect(Collectors.toMap(n -> n.getBuildingId() + "_" + n.getBuildingUnit(), n -> n.getBuildingUnitId())); + icHouseRedis.setTemporaryCacheBuildingUnit(formDTO.getCustomerId(), buildingUnitInfos, formDTO.getUserId()); + } + return buildingInfos; + } + + @Override + public void doAfterAllAnalysed(AnalysisContext context) { + finalDispose(); + // 更新ic_building户数 + List list = icBuildingDao.selectHouseTotalIsNull(formDTO.getCustomerId()); + if (!CollectionUtils.isEmpty(list)){ + List houseNum = icBuildingDao.selectHouseNum(list); + if (!CollectionUtils.isEmpty(houseNum)){ + icBuildingDao.allUpdateHouseNum(houseNum); + } + } + // 删除缓存 + icHouseRedis.delTemporaryCacheGrids(formDTO.getCustomerId(), formDTO.getUserId()); + icHouseRedis.delTemporaryCacheNeighBorHood(formDTO.getCustomerId(), formDTO.getUserId()); + icHouseRedis.delTemporaryCacheBuilding(formDTO.getCustomerId(), formDTO.getUserId()); + icHouseRedis.delTemporaryCacheBuildingUnit(formDTO.getCustomerId(), formDTO.getUserId()); + icHouseRedis.delTemporaryCacheHouses(formDTO.getCustomerId(), formDTO.getUserId()); + // 放结果 + icHouseRedis.setImportResultDTO(formDTO.getCustomerId(), formDTO.getUserId(), new ImportResultDTO(nums,num)); + + ImportTaskCommonFormDTO input = new ImportTaskCommonFormDTO(); + input.setOperatorId(formDTO.getUserId()); + input.setTaskId(taskId); + if (CollectionUtils.isEmpty(nums)){ + input.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_SUCCESS); + epmetCommonServiceOpenFeignClient.finishImportTask(input); + }else { + input.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL); + if (!CollectionUtils.isEmpty(errorInfos)){ + try { + String s = neighborHoodService.orgGeneralImport(errorInfos, HouseErrorInfoModel.class); + input.setResultDescFilePath(s); + } catch (IOException e) { + epmetCommonServiceOpenFeignClient.finishImportTask(input); + e.printStackTrace(); + } + } + epmetCommonServiceOpenFeignClient.finishImportTask(input); + } + } + + /** + * @Description 房屋信息插入 + * @param houses + * @author zxc + * @date 2022/2/14 5:21 下午 + */ + @Transactional(rollbackFor = Exception.class) + public void houseInsert(List houses){ + if (!CollectionUtils.isEmpty(houses)){ + icHouseService.insertBatch(ConvertUtils.sourceToTarget(houses, IcHouseEntity.class)); + } + } + +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportNeighborHoodInfoListener.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportNeighborHoodInfoListener.java new file mode 100644 index 0000000000..791e3b6741 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportNeighborHoodInfoListener.java @@ -0,0 +1,374 @@ +package com.epmet.model; + +import com.alibaba.excel.context.AnalysisContext; +import com.alibaba.excel.event.AnalysisEventListener; +import com.alibaba.fastjson.JSON; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.redis.common.CustomerOrgRedis; +import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; +import com.epmet.commons.tools.redis.common.bean.GridInfoCache; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.constant.CustomerGridConstant; +import com.epmet.constant.ImportErrorMsgConstants; +import com.epmet.constants.ImportTaskConstants; +import com.epmet.dao.IcBuildingDao; +import com.epmet.dao.IcPropertyManagementDao; +import com.epmet.dto.ImportGeneralDTO; +import com.epmet.dto.NeighborHoodAndManagementDTO; +import com.epmet.dto.form.ImportInfoFormDTO; +import com.epmet.dto.form.ImportTaskCommonFormDTO; +import com.epmet.dto.result.ImportResultDTO; +import com.epmet.entity.IcNeighborHoodPropertyEntity; +import com.epmet.entity.IcPropertyManagementEntity; +import com.epmet.feign.EpmetCommonServiceOpenFeignClient; +import com.epmet.redis.IcHouseRedis; +import com.epmet.service.IcNeighborHoodService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.util.CollectionUtils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @Author zxc + * @DateTime 2022/2/15 2:16 下午 + * @DESC + */ +@Slf4j +public class ImportNeighborHoodInfoListener extends AnalysisEventListener { + + List nums = new ArrayList<>(); + Integer num = NumConstant.ZERO; + List errorInfos = new ArrayList<>(); + NeighborHoodInfoModel info = null; + String taskId = ""; + + List needDisposeList = new ArrayList<>(); + List needInsertList = new ArrayList<>(); + + String gridName = null; + String agencyName = null; + + Map gridInfos = null; + List gridInfoDTOs = null; + Map neighborHoodInfos = null; + List neighborHoodInfoDTOs = null; + ImportGeneralDTO neighborHoodGeneralDTO = null; + + private ImportInfoFormDTO formDTO; + private IcHouseRedis icHouseRedis; + private IcBuildingDao icBuildingDao; + private IcNeighborHoodService neighborHoodService; + private IcPropertyManagementDao propertyManagementDao; + private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient; + + public ImportNeighborHoodInfoListener(ImportInfoFormDTO formDTO, IcHouseRedis icHouseRedis,IcBuildingDao icBuildingDao,IcNeighborHoodService neighborHoodService, IcPropertyManagementDao propertyManagementDao,EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient,String tId){ + this.formDTO = formDTO; + this.icHouseRedis = icHouseRedis; + this.icBuildingDao = icBuildingDao; + this.neighborHoodService = neighborHoodService; + this.propertyManagementDao = propertyManagementDao; + this.epmetCommonServiceOpenFeignClient = epmetCommonServiceOpenFeignClient; + this.taskId = tId; + } + + + @Override + public void invoke(NeighborHoodInfoModel data, AnalysisContext context) { + log.info("invoke =========="); + if (null == data){ + return; + } + info = data; + num = num + NumConstant.ONE; + log.info("读数据"+num); + if (StringUtils.isBlank(data.getNeighborHoodName()) || + StringUtils.isBlank(data.getGridName()) || StringUtils.isBlank(data.getAgencyName()) || StringUtils.isBlank(data.getAddress())){ + nums.add(num); + disposeErrorMsg(info,ImportErrorMsgConstants.NEIGHBOR_HOOD_ERROR); + return; + } + if(StringUtils.isBlank(data.getAgencyName())){ + nums.add(num); + disposeErrorMsg(info, "所属组织的值未填写"); + return; + } + if(StringUtils.isBlank(data.getGridName())){ + nums.add(num); + disposeErrorMsg(info, "所属网格的值未填写"); + return; + } + if(StringUtils.isBlank(data.getNeighborHoodName())){ + nums.add(num); + disposeErrorMsg(info,"小区名称的值未填写"); + return; + } + if(StringUtils.isBlank(data.getNeighborHoodName())){ + nums.add(num); + disposeErrorMsg(info,"详细地址的值未填写"); + return; + } + ImportGeneralDTO dto = ConvertUtils.sourceToTarget(data, ImportGeneralDTO.class); + dto.setNum(num); + dto.setCustomerId(formDTO.getCustomerId()); + if (formDTO.getOrgType().equals(CustomerGridConstant.GRID)){ + disposeGridNeighborHood(dto); + }else if (formDTO.getOrgType().equals(CustomerGridConstant.AGENCY)){ + disposeAgencyNeighborHood(dto); + } + // 数据筛选完毕,当num每满100条,处理一次 + if (num%NumConstant.ONE_HUNDRED == NumConstant.ZERO){ + finalDispose(); + } + log.info("读数据"+num+"完毕"); + } + + public void finalDispose(){ + if (CollectionUtils.isEmpty(needDisposeList)){ + return; + } + Map groupByAllName = needDisposeList.stream().collect(Collectors.groupingBy( + n -> n.getAgencyName() + "_" + n.getGridName() + "_" + n.getNeighborHoodName(), Collectors.counting())); + groupByAllName.forEach((k,v) -> { + if (Integer.valueOf(v.toString()).compareTo(1) > 0){ + for (ImportGeneralDTO r : needDisposeList) { + if (k.equals(r.getAgencyName() + "_" + r.getGridName() + "_" + r.getNeighborHoodName())){ + // 集合里重复的 + nums.add(r.getNum()); + disposeErrorMsg(info, ImportErrorMsgConstants.EXIST_ERROR); + r.setExistStatus(true); + } + } + } + }); + Map> groupByStatus = needDisposeList.stream().collect(Collectors.groupingBy(ImportGeneralDTO::getExistStatus)); + List importGeneralDTOS = groupByStatus.get(false); + if (!CollectionUtils.isEmpty(importGeneralDTOS)){ + List importInfo = neighborHoodService.getImportInfo(formDTO, importGeneralDTOS); + Map> groupByBuildingExistStatus = importInfo.stream().collect(Collectors.groupingBy(ImportGeneralDTO::getNeighborHoodExistStatus)); + List existList = groupByBuildingExistStatus.get(true); + if (!CollectionUtils.isEmpty(existList)){ + existList.forEach(e -> { + nums.add(e.getNum()); + disposeErrorMsg(info,ImportErrorMsgConstants.EXIST_ERROR); + }); + } + List notExistList = groupByBuildingExistStatus.get(false); + if (!CollectionUtils.isEmpty(notExistList)){ + // 物业表插入 + List propertyNames = notExistList.stream().filter(n -> StringUtils.isNotBlank(n.getPropertyName())).map(m -> m.getPropertyName()).distinct().collect(Collectors.toList()); + List disposePropertyNames = notExistList.stream().filter(n -> StringUtils.isNotBlank(n.getPropertyName())).map(m -> m.getPropertyName()).distinct().collect(Collectors.toList()); + if (!CollectionUtils.isEmpty(propertyNames)){ + List existPropertyNames = propertyManagementDao.selectExistNames(propertyNames); + disposePropertyNames.removeAll(existPropertyNames); + List propertyManagementEntities = new ArrayList<>(); + if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(disposePropertyNames)){ + disposePropertyNames.forEach(name -> { + IcPropertyManagementEntity e = new IcPropertyManagementEntity(); + e.setName(name); + propertyManagementEntities.add(e); + }); + } + neighborHoodService.insertPropertyManagement(propertyManagementEntities); + + // 小区物业关系表插入 + List neighborHoodAndManagementDTOS = ConvertUtils.sourceToTarget(notExistList, NeighborHoodAndManagementDTO.class); + List propertyManagementInfos = propertyManagementDao.selectIdByName(propertyNames); + neighborHoodAndManagementDTOS.forEach(n -> propertyManagementInfos.stream().filter(p -> p.getName().equals(n.getPropertyName())) + .forEach(p -> { + n.setPropertyId(p.getId()); + n.setNeighborHoodId(n.getNeighborHoodId()); + })); + List icNeighborHoodPropertyEntities = ConvertUtils.sourceToTarget(neighborHoodAndManagementDTOS, IcNeighborHoodPropertyEntity.class); + neighborHoodService.neighborHoodPropertyInsert(icNeighborHoodPropertyEntities); + } + } + } + + // 清除 + needDisposeList = new ArrayList<>(); + needInsertList = new ArrayList<>(); + gridName = null; + agencyName = null; + gridInfos = null; + gridInfoDTOs = null; + neighborHoodInfos = null; + neighborHoodInfoDTOs = null; + neighborHoodGeneralDTO = null; + } + + /** + * @Description 左侧树点击网格时调用 + * @param dto + * @author zxc + * @date 2022/2/15 2:37 下午 + */ + public void disposeGridNeighborHood(ImportGeneralDTO dto){ + gridName = null == gridName ? icBuildingDao.selectGridNameById(formDTO.getOrgId()) : gridName; + GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(formDTO.getOrgId()); + if (null == gridInfo){ + nums.add(num); + disposeErrorMsg(info,ImportErrorMsgConstants.NEIGHBOR_HOOD_ERROR); + return; + } + //排除不是本网格的 gridName不一样排除,gridName一样但是agencyName不一样也得排除 + if (dto.getGridName().compareTo(gridName) != 0 || (!dto.getAgencyName().equals(gridInfo.getAgencyName()) && dto.getGridName().equals(gridName))){ + nums.add(num); + disposeErrorMsg(info,ImportErrorMsgConstants.NEIGHBOR_HOOD_ERROR); + }else { + // + dto.setGridId(formDTO.getOrgId()); + dto.setAgencyId(gridInfo.getPid()); + AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId()); + if (null == agencyInfo){ + nums.add(num); + disposeErrorMsg(info,ImportErrorMsgConstants.NEIGHBOR_HOOD_ERROR); + return; + } + dto.setPid(agencyInfo.getPid()); + dto.setPids(agencyInfo.getPids()); + fillData(dto,CustomerGridConstant.GRID); + } + } + + /** + * @Description 左侧树点击组织时调用 + * @param dto + * @author zxc + * @date 2022/2/15 2:37 下午 + */ + public void disposeAgencyNeighborHood(ImportGeneralDTO dto){ + agencyName = null == agencyName ? icBuildingDao.selectAgencyNameById(formDTO.getOrgId()) : agencyName; + //排除不是本组织的 + if (!dto.getAgencyName().equals(agencyName)){ + nums.add(num); + disposeErrorMsg(info,ImportErrorMsgConstants.NEIGHBOR_HOOD_ERROR); + }else { + // 根据组织查询出所有网格,甩出不是本组织下的网格 + gridInfos = null == gridInfos ? getGridInfos(formDTO.getOrgId()) : gridInfos; + if (null == gridInfos){ + // 组织下确实不存在网格 + nums.add(num); + disposeErrorMsg(info,ImportErrorMsgConstants.NEIGHBOR_HOOD_ERROR); + return; + } + // 根据网格名对比,没有找到的就把行号加入到未执行成功队列中 + Object cacheGridName = icHouseRedis.getTemporaryCacheGrid(formDTO.getCustomerId(), formDTO.getUserId(), dto.getGridName()); + if (null == cacheGridName){ + nums.add(num); + disposeErrorMsg(info,ImportErrorMsgConstants.NEIGHBOR_HOOD_ERROR); + return; + } + dto.setGridId(cacheGridName.toString()); + dto.setAgencyId(formDTO.getOrgId()); + AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId()); + if (null == agencyInfo){ + nums.add(num); + disposeErrorMsg(info,ImportErrorMsgConstants.NEIGHBOR_HOOD_ERROR); + return; + } + dto.setPid(agencyInfo.getPid()); + dto.setPids(agencyInfo.getPids()); + fillData(dto,CustomerGridConstant.AGENCY); + } + } + + public void fillData(ImportGeneralDTO dto,String orgType){ + List gridIds = new ArrayList<>(); + if (orgType.equals(CustomerGridConstant.GRID)){ + gridIds = Arrays.asList(formDTO.getOrgId()); + }else if (orgType.equals(CustomerGridConstant.AGENCY)){ + gridIds = gridInfoDTOs.stream().map(m -> m.getGridId()).collect(Collectors.toList()); + } + neighborHoodInfos = null == neighborHoodInfos ? getNeighborHoodInfos(gridIds) : neighborHoodInfos; + Object cacheNeighBorHood = icHouseRedis.getTemporaryCacheNeighBorHood(formDTO.getCustomerId(), formDTO.getUserId(), dto.getGridId() + "_" + dto.getNeighborHoodName()); + // 赋值小区ID + dto.setNeighborHoodId(null == cacheNeighBorHood ? "" : cacheNeighBorHood.toString()); + if (StringUtils.isNotBlank(dto.getNeighborHoodId())){ + // 小区已存在 + nums.add(dto.getNum()); + disposeErrorMsg(info,ImportErrorMsgConstants.EXIST_ERROR); + }else { + needDisposeList.add(dto); + } + } + + /** + * @Description 获取网格信息 + * @param orgId + * @author zxc + * @date 2022/2/14 9:57 上午 + */ + public Map getGridInfos(String orgId){ + gridInfoDTOs = icBuildingDao.selectAllGridByOrgId(orgId); + gridInfos = gridInfoDTOs.stream().collect(Collectors.toMap(n -> n.getGridName(), n -> n.getGridId())); + icHouseRedis.setTemporaryCacheGrid(formDTO.getCustomerId(), gridInfos, formDTO.getUserId()); + return gridInfos; + } + + /** + * @Description 获取网格下的小区 + * @param gridIds + * @author zxc + * @date 2022/2/14 10:16 上午 + */ + public Map getNeighborHoodInfos(List gridIds){ + neighborHoodInfoDTOs = icBuildingDao.selectAllNeighborHoodByGridIds(gridIds); + neighborHoodInfos = neighborHoodInfoDTOs.stream().collect(Collectors.toMap(n -> n.getGridId() + "_" + n.getNeighborHoodName(), n -> n.getNeighborHoodId())); + icHouseRedis.setTemporaryCacheNeighBorHood(formDTO.getCustomerId(), neighborHoodInfos, formDTO.getUserId()); + return neighborHoodInfos; + } + + public void disposeErrorMsg(NeighborHoodInfoModel data,String msg){ + NeighborHoodErrorInfoModel err = ConvertUtils.sourceToTarget(data, NeighborHoodErrorInfoModel.class); + err.setErrorMsg(msg); + errorInfos.add(err); + } + + @Override + public void doAfterAllAnalysed(AnalysisContext context) { + ImportTaskCommonFormDTO input = new ImportTaskCommonFormDTO(); + input.setOperatorId(formDTO.getUserId()); + input.setTaskId(taskId); + input.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL); + try { + finalDispose(); + // 删除缓存 + icHouseRedis.delTemporaryCacheGrids(formDTO.getCustomerId(), formDTO.getUserId()); + icHouseRedis.delTemporaryCacheNeighBorHood(formDTO.getCustomerId(), formDTO.getUserId()); + icHouseRedis.delTemporaryCacheBuilding(formDTO.getCustomerId(), formDTO.getUserId()); + icHouseRedis.delTemporaryCacheBuildingUnit(formDTO.getCustomerId(), formDTO.getUserId()); + icHouseRedis.delTemporaryCacheHouses(formDTO.getCustomerId(), formDTO.getUserId()); + // 放结果 + icHouseRedis.setImportResultDTO(formDTO.getCustomerId(), formDTO.getUserId(), new ImportResultDTO(nums,num)); + log.info("数据处理完毕,开始更新任务状态"); + + if (CollectionUtils.isEmpty(nums)){ + input.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_SUCCESS); + epmetCommonServiceOpenFeignClient.finishImportTask(input); + }else { + if (!CollectionUtils.isEmpty(errorInfos)){ + try { + String s = neighborHoodService.orgGeneralImport(errorInfos, NeighborHoodErrorInfoModel.class); + if (s == null){ + log.warn("doAfterAllAnalysed orgGeneralImport fail,return null,taskId:{}", taskId); + } + input.setResultDescFilePath(s); + } catch (Exception e) { + log.error("doAfterAllAnalysed orgGeneralImport exception", e); + } + } + log.info("任务状态更新完毕"); + } + } catch (Exception e) { + log.error("doAfterAllAnalysed exception", e); + } finally { + epmetCommonServiceOpenFeignClient.finishImportTask(input); + } + log.info("任务DTO"+JSON.toJSONString(input)); + } +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/NeighborHoodErrorInfoModel.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/NeighborHoodErrorInfoModel.java new file mode 100644 index 0000000000..2bdc863e00 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/NeighborHoodErrorInfoModel.java @@ -0,0 +1,21 @@ +package com.epmet.model; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; + +/** + * @Author zxc + * @DateTime 2022/2/15 2:15 下午 + * @DESC + */ +@Data +public class NeighborHoodErrorInfoModel { + + @Excel(name = "小区名称", width = 20) + private String neighborHoodName; + + @Excel(name = "错误信息", width = 100) + private String errorMsg; + +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/NeighborHoodInfoModel.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/NeighborHoodInfoModel.java new file mode 100644 index 0000000000..8dbdbafccd --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/NeighborHoodInfoModel.java @@ -0,0 +1,32 @@ +package com.epmet.model; + +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; + +/** + * @Author zxc + * @DateTime 2022/2/15 2:15 下午 + * @DESC + */ +@Data +public class NeighborHoodInfoModel { + + @ExcelProperty(value = "所属组织") + private String agencyName; + + @ExcelProperty(value = "所属网格") + private String gridName; + + @ExcelProperty(value = "小区名称") + private String neighborHoodName; + + @ExcelProperty(value = "关联物业") + private String propertyName; + + @ExcelProperty(value = "详细地址") + private String address; + + @ExcelProperty(value = "备注") + private String remark; + +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/redis/IcHouseRedis.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/redis/IcHouseRedis.java index 4f3ece54a8..2329e467d6 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/redis/IcHouseRedis.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/redis/IcHouseRedis.java @@ -23,7 +23,9 @@ import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.dao.IcHouseDao; import com.epmet.dto.result.HouseInfoDTO; +import com.epmet.dto.result.ImportResultDTO; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; @@ -43,6 +45,9 @@ public class IcHouseRedis { @Autowired private IcHouseDao icHouseDao; + @Autowired + private RedisTemplate redisTemplate; + public void delete(Object[] ids) { } @@ -79,4 +84,221 @@ public class IcHouseRedis { return houseInfo; } + /** + * @Description 存放房屋临时缓存 + * @param customerId + * @param map + * @param userId + * @author zxc + * @date 2022/2/14 9:04 上午 + */ + public void setTemporaryCacheHouse(String customerId, Map map,String userId){ + String key = RedisKeys.getTemporaryHouseInfoCacheKey(customerId,userId); + redisUtils.hMSet(key,map); + } + + /** + * @Description 获取房屋临时缓存 + * @param customerId + * @param userId + * @author zxc + * @date 2022/2/14 9:28 上午 + */ + public Object getTemporaryCacheHouse(String customerId,String userId,String buildingIdAndUnitIdAndHouseName){ + String key = RedisKeys.getTemporaryHouseInfoCacheKey(customerId,userId); + return redisUtils.hGet(key, buildingIdAndUnitIdAndHouseName); + } + + /** + * @Description 删除房屋临时缓存 + * @param customerId + * @param userId + * @author zxc + * @date 2022/2/14 9:29 上午 + */ + public void delTemporaryCacheHouses(String customerId,String userId){ + String key = RedisKeys.getTemporaryHouseInfoCacheKey(customerId,userId); + redisUtils.delete(key); + } + + /** + * @Description 保存网格临时缓存 + * @param customerId + * @param map + * @param userId + * @author zxc + * @date 2022/2/14 1:49 下午 + */ + public void setTemporaryCacheGrid(String customerId, Map map,String userId) { + String key = RedisKeys.getTemporaryGridInfoCacheKey(customerId, userId); + redisUtils.hMSet(key, map); + } + + /** + * @Description 获取网格临时缓存【单个】 + * @param customerId + * @param userId + * @param gridName + * @author zxc + * @date 2022/2/14 1:49 下午 + */ + public Object getTemporaryCacheGrid(String customerId,String userId,String gridName){ + String key = RedisKeys.getTemporaryGridInfoCacheKey(customerId,userId); + Object o = redisUtils.hGet(key, gridName); + return o; + } + + /** + * @Description 获取网格临时缓存【多个】 + * @param customerId + * @param userId + * @author zxc + * @date 2022/2/14 1:50 下午 + */ + public Map getTemporaryCacheGrids(String customerId,String userId){ + String key = RedisKeys.getTemporaryGridInfoCacheKey(customerId,userId); + return redisUtils.hGetAll(key); + } + + /** + * @Description 删除网格临时缓存 + * @param customerId + * @param userId + * @author zxc + * @date 2022/2/14 1:50 下午 + */ + public void delTemporaryCacheGrids(String customerId,String userId){ + String key = RedisKeys.getTemporaryGridInfoCacheKey(customerId,userId); + redisUtils.delete(key); + } + + /** + * @Description 保存临时小区缓存 + * @param customerId + * @param map + * @param userId + * @author zxc + * @date 2022/2/14 1:50 下午 + */ + public void setTemporaryCacheNeighBorHood(String customerId, Map map,String userId) { + String key = RedisKeys.getTemporaryNeighborHoodInfoCacheKey(customerId, userId); + redisUtils.hMSet(key, map); + } + + /** + * @Description 获取临时小区缓存【单个】 + * @param customerId + * @param userId + * @param gridIdAndNeighborHoodName + * @author zxc + * @date 2022/2/14 1:50 下午 + */ + public Object getTemporaryCacheNeighBorHood(String customerId,String userId,String gridIdAndNeighborHoodName){ + String key = RedisKeys.getTemporaryNeighborHoodInfoCacheKey(customerId,userId); + return redisUtils.hGet(key, gridIdAndNeighborHoodName); + } + + /** + * @Description 删除临时小区缓存 + * @param customerId + * @param userId + * @author zxc + * @date 2022/2/14 1:51 下午 + */ + public void delTemporaryCacheNeighBorHood(String customerId,String userId){ + String key = RedisKeys.getTemporaryNeighborHoodInfoCacheKey(customerId,userId); + redisUtils.delete(key); + } + + /** + * @Description 保存临时楼栋缓存 + * @param customerId + * @param map + * @param userId + * @author zxc + * @date 2022/2/14 1:51 下午 + */ + public void setTemporaryCacheBuilding(String customerId, Map map,String userId) { + String key = RedisKeys.getTemporaryBuildingInfoCacheKey(customerId, userId); + redisUtils.hMSet(key, map); + } + + /** + * @Description 获取临时楼栋缓存【单个】 + * @param customerId + * @param userId + * @param neighborHoodIdAndBuildingName + * @author zxc + * @date 2022/2/14 1:51 下午 + */ + public Object getTemporaryCacheBuilding(String customerId,String userId,String neighborHoodIdAndBuildingName){ + String key = RedisKeys.getTemporaryBuildingInfoCacheKey(customerId,userId); + return redisUtils.hGet(key, neighborHoodIdAndBuildingName); + } + + /** + * @Description 删除临时楼栋缓存 + * @param customerId + * @param userId + * @author zxc + * @date 2022/2/14 1:51 下午 + */ + public void delTemporaryCacheBuilding(String customerId,String userId){ + String key = RedisKeys.getTemporaryBuildingInfoCacheKey(customerId,userId); + redisUtils.delete(key); + } + + /** + * @Description 保存临时楼栋单元缓存 + * @param customerId + * @param map + * @param userId + * @author zxc + * @date 2022/2/14 1:51 下午 + */ + public void setTemporaryCacheBuildingUnit(String customerId, Map map,String userId) { + String key = RedisKeys.getTemporaryBuildingUnitInfoCacheKey(customerId, userId); + redisUtils.hMSet(key, map); + } + + /** + * @Description 获取临时楼栋单元缓存【单个】 + * @param customerId + * @param userId + * @param buildingIdAndUnitName + * @author zxc + * @date 2022/2/14 1:51 下午 + */ + public Object getTemporaryCacheBuildingUnit(String customerId,String userId,String buildingIdAndUnitName){ + String key = RedisKeys.getTemporaryBuildingUnitInfoCacheKey(customerId,userId); + return redisUtils.hGet(key, buildingIdAndUnitName); + } + + /** + * @Description 删除临时楼栋单元缓存 + * @param customerId + * @param userId + * @author zxc + * @date 2022/2/14 1:51 下午 + */ + public void delTemporaryCacheBuildingUnit(String customerId,String userId){ + String key = RedisKeys.getTemporaryBuildingUnitInfoCacheKey(customerId,userId); + redisUtils.delete(key); + } + + public void setImportResultDTO(String customerId, String userId, ImportResultDTO dto){ + String key = RedisKeys.getTemporaryImportResultCacheKey(customerId,userId); + Map result = BeanUtil.beanToMap(dto, false, true); + redisUtils.hMSet(key,result,RedisUtils.MINUTE_ONE_EXPIRE); + } + + public ImportResultDTO getImportResultDTO(String customerId, String userId){ + String key = RedisKeys.getTemporaryImportResultCacheKey(customerId,userId); + Map map = redisUtils.hGetAll(key); + if (CollectionUtils.isEmpty(map)){ + return null; + } + return ConvertUtils.mapToEntity(map,ImportResultDTO.class); + } + } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/BuildingService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/BuildingService.java index 81b70a4bd2..a5d84c4d7d 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/BuildingService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/BuildingService.java @@ -17,15 +17,20 @@ package com.epmet.service; +import com.epmet.commons.tools.utils.Result; import com.epmet.dto.BuildingTreeLevelDTO; import com.epmet.dto.form.IcBulidingFormDTO; +import com.epmet.dto.form.ImportInfoFormDTO; import com.epmet.dto.form.ListIcNeighborHoodFormDTO; import com.epmet.dto.result.BuildingResultDTO; import com.epmet.dto.result.BuildingResultPagedDTO; import com.epmet.dto.result.IcNeighborHoodResultDTO; +import com.epmet.dto.result.ImportTaskCommonResultDTO; import com.epmet.excel.IcBuildingExcel; +import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; +import java.io.IOException; import java.util.List; /** @@ -62,4 +67,14 @@ public interface BuildingService { List buildingListByIds(List buildingIdList); BuildingResultPagedDTO buildinglistbyidsPage(List buildingIdList, Integer pageNo, Integer pageSize); + + /** + * @Description 楼宇导入 + * @param formDTO + * @param file + * @author zxc + * @date 2022/2/13 10:18 上午 + */ + Result buildingImportExcel(ImportInfoFormDTO formDTO, MultipartFile file,Result importTask) throws IOException; + } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java index ad5d1d69cb..c7a065024e 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java @@ -17,11 +17,15 @@ package com.epmet.service; +import com.epmet.commons.tools.utils.Result; import com.epmet.dto.form.IcHouseFormDTO; +import com.epmet.dto.form.ImportInfoFormDTO; import com.epmet.dto.form.ListIcNeighborHoodFormDTO; import com.epmet.dto.result.HouseInfoDTO; import com.epmet.dto.result.IcNeighborHoodResultDTO; +import com.epmet.dto.result.ImportTaskCommonResultDTO; import com.epmet.excel.IcHouseExcel; +import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import java.util.List; @@ -62,4 +66,6 @@ public interface HouseService { void exportBuildinginfo(ListIcNeighborHoodFormDTO formDTO, HttpServletResponse response) throws Exception; List queryListHouseInfo(Set houseIds, String customerId); + + Result dispose(MultipartFile file, ImportInfoFormDTO formDTO, Result importTask); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcBuildingService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcBuildingService.java index 5b5ff7d05d..b7279e59ad 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcBuildingService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcBuildingService.java @@ -102,4 +102,15 @@ public interface IcBuildingService extends BaseService { * @Date 2021/10/26 14:43 */ List getBuildingOptions(String neighborHoodId); + + /** + * 根据楼栋名获取楼栋信息 + * + * @Param neighborHoodId + * @Param buildingName + * @Return {@link IcBuildingDTO} + * @Author zhaoqifeng + * @Date 2022/2/14 15:19 + */ + IcBuildingDTO getBuildingInfo(String neighborHoodId, String buildingName); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcBuildingUnitService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcBuildingUnitService.java index 40045f2b75..0d315539e6 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcBuildingUnitService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcBuildingUnitService.java @@ -102,4 +102,14 @@ public interface IcBuildingUnitService extends BaseService * @Date 2021/10/26 14:49 */ List getUnitOptions(String buildingId); + + /** + * 根据单元名获取单元信息 + * @Param buildingId + * @Param unitName + * @Return {@link IcBuildingUnitDTO} + * @Author zhaoqifeng + * @Date 2022/2/14 15:42 + */ + IcBuildingUnitDTO getUnitInfo(String buildingId, String unitName); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java index 3592d82175..1d6193834f 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java @@ -20,9 +20,18 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.dto.result.OptionResultDTO; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; import com.epmet.dto.IcNeighborHoodDTO; +import com.epmet.dto.ImportGeneralDTO; +import com.epmet.dto.form.ImportInfoFormDTO; +import com.epmet.dto.result.ImportTaskCommonResultDTO; import com.epmet.entity.IcNeighborHoodEntity; +import com.epmet.entity.IcNeighborHoodPropertyEntity; +import com.epmet.entity.IcPropertyManagementEntity; +import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; +import java.util.Collection; import java.util.List; import java.util.Map; @@ -112,4 +121,30 @@ public interface IcNeighborHoodService extends BaseService * @Date 2021/11/8 10:45 */ List getListByIds(List ids); + + /** + * @Description 小区信息导入 + * @param formDTO + * @param file + * @author zxc + * @date 2022/2/12 11:11 上午 + */ + Result neighborhoodImport(ImportInfoFormDTO formDTO, MultipartFile file,Result importTask) throws IOException; + + /** + * 获取导入小区,楼栋,单元ID + * + * @Param formDTO + * @Param list + * @Return {@link List< ImportGeneralDTO >} + * @Author zhaoqifeng + * @Date 2022/2/14 9:40 + */ + List getImportInfo(ImportInfoFormDTO formDTO, List list); + + void insertPropertyManagement(List propertyManagementEntities); + + void neighborHoodPropertyInsert(List entities); + + String orgGeneralImport(Collection errorRows, Class tClass) throws IOException; } \ No newline at end of file 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 535d411b79..c20fd83965 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 @@ -158,7 +158,13 @@ public class AgencyServiceImpl implements AgencyService { originalEntity.setCode(formDTO.getCode()); originalEntity.setContacts(formDTO.getContacts()); originalEntity.setMobile(formDTO.getMobile()); - + if(StringUtils.isNotBlank(formDTO.getLatitude())){ + originalEntity.setLatitude(formDTO.getLatitude()); + } + if(StringUtils.isNotBlank(formDTO.getLongitude())){ + originalEntity.setLongitude(formDTO.getLongitude()); + } + originalEntity.setCenterAddress(formDTO.getCenterAddress()); //当前客户开启了area_code_switch参数:open: 选择地区编码必填;closed: 无需选择地区编码 if (CustomerAgencyConstant.AREA_CODE_SWITCH_OPEN.equals(formDTO.getAreaCodeSwitch())) { CustomerAgencyEntity parent = customerAgencyDao.selectById(originalEntity.getPid()); diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java index cdf6227a8e..091ef5dd1e 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java @@ -1,6 +1,9 @@ package com.epmet.service.impl; import cn.afterturn.easypoi.excel.entity.TemplateExportParams; +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.ExcelReader; +import com.alibaba.excel.read.metadata.ReadSheet; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -10,21 +13,31 @@ import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.constant.ImportErrorMsgConstants; +import com.epmet.constants.ImportTaskConstants; import com.epmet.dao.*; import com.epmet.dto.BuildingTreeLevelDTO; import com.epmet.dto.CustomerStaffAgencyDTO; import com.epmet.dto.IcBuildingDTO; import com.epmet.dto.form.IcBulidingFormDTO; +import com.epmet.dto.form.ImportInfoFormDTO; +import com.epmet.dto.form.ImportTaskCommonFormDTO; import com.epmet.dto.form.ListIcNeighborHoodFormDTO; -import com.epmet.dto.result.BuildingResultDTO; -import com.epmet.dto.result.BuildingResultPagedDTO; -import com.epmet.dto.result.IcNeighborHoodResultDTO; +import com.epmet.dto.result.*; import com.epmet.entity.*; import com.epmet.enums.BuildingTypeEnums; import com.epmet.excel.IcBuildingExcel; +import com.epmet.feign.EpmetCommonServiceOpenFeignClient; +import com.epmet.model.BuildingInfoModel; +import com.epmet.model.HouseInfoModel; +import com.epmet.model.ImportBuildingInfoListener; +import com.epmet.redis.IcHouseRedis; +import com.epmet.service.*; import com.epmet.service.BuildingService; import com.epmet.service.IcBuildingService; import com.epmet.service.IcBuildingUnitService; @@ -33,12 +46,17 @@ import com.epmet.util.ExcelPoiUtils; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Async; +import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; +import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.InputStream; import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; @@ -71,6 +89,12 @@ public class BuildingServiceImpl implements BuildingService { private CustomerStaffAgencyDao customerStaffAgencyDao; @Resource private IcBuildingUnitDao icBuildingUnitDao; + @Autowired + private IcHouseRedis icHouseRedis; + @Autowired + private IcNeighborHoodService neighborHoodService; + @Autowired + private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient; @Override @Transactional(rollbackFor = Exception.class) @@ -174,7 +198,7 @@ public class BuildingServiceImpl implements BuildingService { buildingTreeLevelDTO.setId(item.getId()); buildingTreeLevelDTO.setPId(item.getGridId()); buildingTreeLevelDTO.setLabel(item.getNeighborHoodName()); - buildingTreeLevelDTO.setLevel("neighbourHood"); + buildingTreeLevelDTO.setLevel("neighborHood"); buildingTreeLevelDTO.setLongitude(item.getLongitude()); buildingTreeLevelDTO.setLatitude(item.getLatitude()); buildingTreeLevelDTO.setChildren(new ArrayList<>()); @@ -325,7 +349,7 @@ public class BuildingServiceImpl implements BuildingService { icBuildingUnitService.insertBatch(icBuildingUnitEntityList); /* if(!"".equals(str)){ - return new Result().error(9999, str.append("不存在").toString()); + return new Result().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), str.append("不存在").toString()); }*/ return numList; } @@ -366,6 +390,49 @@ public class BuildingServiceImpl implements BuildingService { return result; } + /** + * @Description 楼宇导入 + * 根据左侧树选中的层级,可导入对应数据: + * 1. 选中社区可导入该社区下所有小区信息、楼宇信息、房屋信息(没有匹配的小区、楼宇均新增,网格没有对应的不新增); + * 2. 选中网格可导入该网格下所有小区信息、楼宇信息、房屋信息(没有匹配的小区、楼宇均新增); + * 3. 选中小区可导入该小区下所有楼宇信息、房屋信息(没有匹配的楼宇均新增); + * 4. 选中楼宇可导入该楼宇下所有房屋信息。 + * @param formDTO + * @param file + * @author zxc + * @date 2022/2/13 10:15 上午 + */ + @Override + @Async + public Result buildingImportExcel(ImportInfoFormDTO formDTO, MultipartFile file,Result importTask) throws IOException { + ExcelReader excelReader = null; + try { + InputStream inputStream = null; + try { + inputStream = file.getInputStream(); + } catch (IOException e) { + return new Result().error("读取文件失败"); + } + excelReader = EasyExcel.read(inputStream).build(); + // 这里为了简单 所以注册了 同样的head 和Listener 自己使用功能必须不同的Listener + ReadSheet readSheet = EasyExcel.readSheet(0).head(BuildingInfoModel.class) + .registerReadListener(new ImportBuildingInfoListener(formDTO,icHouseRedis,icBuildingDao,neighborHoodService,epmetCommonServiceOpenFeignClient,importTask.getData().getTaskId())) + .build(); + excelReader.read(readSheet); + } catch (Exception e){ + ImportTaskCommonFormDTO input = new ImportTaskCommonFormDTO(); + input.setOperatorId(formDTO.getUserId()); + input.setTaskId(importTask.getData().getTaskId()); + input.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL); + epmetCommonServiceOpenFeignClient.finishImportTask(input); + } finally { + if (excelReader != null) { + excelReader.finish(); + } + } + return new Result<>(); + } + private List searchAllBuilding(ListIcNeighborHoodFormDTO formDTO) { // QueryWrapper neighborHoodEntityQueryWrapper = new QueryWrapper<>(); 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 57fc7340fb..cd0080f548 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 @@ -272,7 +272,10 @@ public class CustomerGridServiceImpl extends BaseServiceImpl(); } + /*gridStaff.stream().forEach(g -> data.stream().filter(d -> g.getStaffId().equals(d.getStaffId()) && g.getGridId().equals(d.getGridId())).forEach(d -> g.setMobile(d.getMobile()))); + return gridStaff.stream().filter(g -> StringUtils.isNotBlank(g.getMobile())).collect(Collectors.toList());*/ return data; } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java index 4c809cb812..6130bd49c1 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java @@ -2,6 +2,9 @@ package com.epmet.service.impl; import cn.afterturn.easypoi.excel.entity.TemplateExportParams; import cn.hutool.core.bean.BeanUtil; +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.ExcelReader; +import com.alibaba.excel.read.metadata.ReadSheet; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.epmet.commons.tools.constant.NumConstant; @@ -14,6 +17,8 @@ import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.feign.ResultDataResolver; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.constants.ImportTaskConstants; import com.epmet.dao.IcBuildingDao; import com.epmet.dao.IcBuildingUnitDao; import com.epmet.dao.IcHouseDao; @@ -23,15 +28,21 @@ import com.epmet.dto.IcBuildingDTO; import com.epmet.dto.IcBuildingUnitDTO; import com.epmet.dto.IcHouseDTO; import com.epmet.dto.form.IcHouseFormDTO; +import com.epmet.dto.form.ImportInfoFormDTO; +import com.epmet.dto.form.ImportTaskCommonFormDTO; import com.epmet.dto.form.ListIcNeighborHoodFormDTO; import com.epmet.dto.result.HouseInfoDTO; import com.epmet.dto.result.IcNeighborHoodResultDTO; +import com.epmet.dto.result.ImportTaskCommonResultDTO; import com.epmet.entity.IcHouseEntity; import com.epmet.enums.HousePurposeEnums; import com.epmet.enums.HouseRentFlagEnums; import com.epmet.enums.HouseTypeEnums; import com.epmet.excel.IcHouseExcel; +import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.feign.GovOrgOpenFeignClient; +import com.epmet.model.HouseInfoModel; +import com.epmet.model.ImportHouseInfoListener; import com.epmet.redis.IcHouseRedis; import com.epmet.service.HouseService; import com.epmet.service.IcBuildingService; @@ -42,12 +53,17 @@ import com.epmet.util.ExcelPoiUtils; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Async; +import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; +import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.InputStream; import java.util.*; import java.util.stream.Collectors; @@ -77,6 +93,11 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { private IcHouseRedis icHouseRedis; @Autowired private AgencyService agencyservice; + @Autowired + private IcNeighborHoodService neighborHoodService; + @Autowired + private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient; + @Override @@ -329,4 +350,35 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { }); return result; } + + @Async + @Override + public Result dispose(MultipartFile file, ImportInfoFormDTO formDTO, Result importTask) { + ExcelReader excelReader = null; + try { + InputStream inputStream = null; + try { + inputStream = file.getInputStream(); + } catch (IOException e) { + return new Result().error("读取文件失败"); + } + excelReader = EasyExcel.read(inputStream).build(); + // 这里为了简单 所以注册了 同样的head 和Listener 自己使用功能必须不同的Listener + ReadSheet readSheet = EasyExcel.readSheet(0).head(HouseInfoModel.class) + .registerReadListener(new ImportHouseInfoListener(formDTO,icBuildingDao,icHouseRedis,neighborHoodService,icHouseService,epmetCommonServiceOpenFeignClient,importTask.getData().getTaskId())) + .build(); + excelReader.read(readSheet); + } catch (Exception e){ + ImportTaskCommonFormDTO input = new ImportTaskCommonFormDTO(); + input.setOperatorId(formDTO.getUserId()); + input.setTaskId(importTask.getData().getTaskId()); + input.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL); + epmetCommonServiceOpenFeignClient.finishImportTask(input); + } finally { + if (excelReader != null) { + excelReader.finish(); + } + } + return new Result(); + } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcBuildingServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcBuildingServiceImpl.java index ea85e2ce33..122e9755a0 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcBuildingServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcBuildingServiceImpl.java @@ -133,4 +133,24 @@ public class IcBuildingServiceImpl extends BaseServiceImpl wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(IcBuildingEntity::getNeighborHoodId, neighborHoodId); + wrapper.eq(IcBuildingEntity::getBuildingName, buildingName); + IcBuildingEntity entity = baseDao.selectOne(wrapper); + return ConvertUtils.sourceToTarget(entity, IcBuildingDTO.class); + } + } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcBuildingUnitServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcBuildingUnitServiceImpl.java index 4b8cb1f094..3b8409c0cd 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcBuildingUnitServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcBuildingUnitServiceImpl.java @@ -133,4 +133,24 @@ public class IcBuildingUnitServiceImpl extends BaseServiceImpl wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(IcBuildingUnitEntity::getBuildingId, buildingId); + wrapper.eq(IcBuildingUnitEntity::getUnitNum, unitName); + IcBuildingUnitEntity entity = baseDao.selectOne(wrapper); + return ConvertUtils.sourceToTarget(entity, IcBuildingUnitDTO.class); + } + } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java index 3d5b6fa96b..d68ba40e01 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java @@ -17,30 +17,71 @@ package com.epmet.service.impl; +import cn.afterturn.easypoi.excel.ExcelExportUtil; +import cn.afterturn.easypoi.excel.entity.ExportParams; +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.ExcelReader; +import com.alibaba.excel.read.metadata.ReadSheet; +import com.alibaba.fastjson.JSON; 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.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.dto.result.OptionResultDTO; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.redis.common.CustomerOrgRedis; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; +import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; +import com.epmet.commons.tools.redis.common.bean.GridInfoCache; import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.constant.CustomerGridConstant; +import com.epmet.constants.ImportTaskConstants; +import com.epmet.dao.CustomerGridDao; +import com.epmet.dao.IcBuildingDao; import com.epmet.dao.IcNeighborHoodDao; -import com.epmet.dto.IcNeighborHoodDTO; -import com.epmet.entity.IcNeighborHoodEntity; -import com.epmet.service.IcNeighborHoodService; +import com.epmet.dao.IcPropertyManagementDao; +import com.epmet.dto.*; +import com.epmet.dto.form.ImportInfoFormDTO; +import com.epmet.dto.form.ImportTaskCommonFormDTO; +import com.epmet.dto.result.ImportTaskCommonResultDTO; +import com.epmet.dto.result.InfoByNamesResultDTO; +import com.epmet.dto.result.UploadImgResultDTO; +import com.epmet.entity.*; +import com.epmet.excel.IcNeighborHoodExcel; +import com.epmet.feign.EpmetCommonServiceOpenFeignClient; +import com.epmet.feign.OssFeignClient; +import com.epmet.model.ImportNeighborHoodInfoListener; +import com.epmet.model.NeighborHoodInfoModel; +import com.epmet.redis.IcHouseRedis; +import com.epmet.service.*; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.ListUtils; +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.FileItemFactory; +import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.lang3.StringUtils; +import org.apache.http.entity.ContentType; +import org.apache.poi.ss.usermodel.Workbook; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.commons.CommonsMultipartFile; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Map; +import javax.annotation.Resource; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.*; +import java.util.concurrent.ExecutorService; import java.util.stream.Collectors; /** @@ -53,6 +94,28 @@ import java.util.stream.Collectors; @Service public class IcNeighborHoodServiceImpl extends BaseServiceImpl implements IcNeighborHoodService { + @Autowired + private CustomerGridDao customerGridDao; + @Autowired + private IcPropertyManagementDao propertyManagementDao; + @Autowired + private IcPropertyManagementService propertyManagementService; + @Autowired + private IcNeighborHoodPropertyService neighborHoodPropertyService; + @Resource + private IcBuildingService icBuildingService; + @Resource + private IcBuildingUnitService icBuildingUnitService; + @Autowired + private IcHouseRedis icHouseRedis; + @Autowired + private IcBuildingDao icBuildingDao; + @Autowired + private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient; + @Autowired + private OssFeignClient ossFeignClient; + @Autowired + private ExecutorService executorService; @Override public PageData page(Map params) { @@ -160,4 +223,470 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl importTask) { + log.info("neighborhoodImport start====="); + executorService.submit(() -> { + // importNeighbor(formDTO,file,importTask); + log.info("neighborhoodImport thread start====="); + ExcelReader excelReader = null; + try { + InputStream inputStream = null; + try { + inputStream = file.getInputStream(); + } catch (IOException e) { + throw new EpmetException("读取文件失败"); + } + + excelReader = EasyExcel.read(inputStream).build(); + // 这里为了简单 所以注册了 同样的head 和Listener 自己使用功能必须不同的Listener + ReadSheet readSheet = EasyExcel.readSheet(0).head(NeighborHoodInfoModel.class) + .registerReadListener(new ImportNeighborHoodInfoListener(formDTO,icHouseRedis,icBuildingDao,this,propertyManagementDao,epmetCommonServiceOpenFeignClient,importTask.getData().getTaskId())) + .build(); + log.info("neighborhoodImport build readSheet num:{}",readSheet.getSheetNo()); + excelReader.read(readSheet); + } catch (Exception e){ + log.error("neighborhoodImport import exception", e); + ImportTaskCommonFormDTO input = new ImportTaskCommonFormDTO(); + input.setOperatorId(formDTO.getUserId()); + input.setTaskId(importTask.getData().getTaskId()); + input.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL); + Result result = epmetCommonServiceOpenFeignClient.finishImportTask(input); + log.info("neighborhoodImport finishImportTask result:{}", JSON.toJSONString(result)); + } finally { + if (excelReader != null) { + excelReader.finish(); + } + } + log.info("neighborhoodImport thread end====="); + }); + + return new Result<>(); + } + + /** + * @Description 根据左侧树选中的层级,可导入对应数据: + * 1. 选中社区可导入该社区下所有小区信息、楼宇信息、房屋信息(没有匹配的小区、楼宇均新增,网格没有对应的不新增); + * 2. 选中网格可导入该网格下所有小区信息、楼宇信息、房屋信息(没有匹配的小区、楼宇均新增); + * 3. 选中小区可导入该小区下所有楼宇信息、房屋信息(没有匹配的楼宇均新增); + * 4. 选中楼宇可导入该楼宇下所有房屋信息。 + * @param formDTO + * @param result + * @author zxc + * @date 2022/2/12 2:02 下午 + */ + public Result disposeImportNeighborhood(ImportInfoFormDTO formDTO, List result){ + if (CollectionUtils.isEmpty(result)){ + return new Result().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"excel表格内没有数据"); + } + List nums = new ArrayList<>(); + List gridNames = result.stream().map(IcNeighborHoodExcel::getGridName).distinct().collect(Collectors.toList()); + // 1. 查询数据网格是否存在 + List gridInfos = customerGridDao.selectGridInfoByNames(gridNames, formDTO.getCustomerId()); + if (CollectionUtils.isEmpty(gridInfos)){ + // 网格没有对应的不新增 + for (int i = NumConstant.ONE; i <= result.size(); i++) { + nums.add(i); + } + String str = String.format("共%s条,成功导入%s条。",result.size(),0); + return new Result().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),str + "第"+nums.stream().map(String::valueOf).collect(Collectors.joining("、"))+"行未成功!"); + } + result.forEach(r -> { + for (InfoByNamesResultDTO g : gridInfos) { + if (r.getGridName().equals(g.getGridName())){ + // 能查询出网格,变为true + r.setStatus(true); + break; + } + } + }); + Map> groupStatus = result.stream().collect(Collectors.groupingBy(IcNeighborHoodExcel::getStatus)); + // 只获取能查询到的网格 + List neighborHoods = groupStatus.get(true); + // 2. 查询组织选中组织下存在的小区 + List existNames = baseDao.selectNeighborhoodNameByNames(neighborHoods.stream().map(IcNeighborHoodExcel::getNeighborHoodName).distinct().collect(Collectors.toList()), formDTO.getCustomerId()); + // 为了显示多少行插入成功,未成功 + result.forEach(r -> { + for (String s : existNames) { + if (r.getNeighborHoodName().equals(s)){ + // 数据库已存在此小区名变为true + r.setExistNameStatus(true); + break; + } + } + }); + Map> groupByExistName = neighborHoods.stream().collect(Collectors.groupingBy(IcNeighborHoodExcel::getExistNameStatus)); + // 获取需要插入的数据 + List needInsert = groupByExistName.get(false); + if (CollectionUtils.isEmpty(needInsert)){ + for (int i = NumConstant.ONE; i <= result.size(); i++) { + nums.add(i); + } + String str = String.format("共%s条,成功导入%s条。",result.size(),0); + return new Result().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),str + "第"+nums.stream().map(String::valueOf).collect(Collectors.joining("、"))+"行未成功!"); + } + if (formDTO.getOrgType().equals(CustomerGridConstant.AGENCY)){ + AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(formDTO.getOrgId()); + if (null == agencyInfo){ + throw new EpmetException("未查询到组织信息..."); + } + needInsert.forEach(n -> { + if (agencyInfo.getOrganizationName().equals(n.getAgencyName())){ + // 所属组织名一样变为true + n.setAgencyNameStatus(true); + } + }); + }else { + GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(formDTO.getOrgId()); + if (null == gridInfo){ + throw new EpmetException("未查询到网格信息..."); + } + needInsert.forEach(n -> { + if (gridInfo.getGridName().equals(n.getGridName())){ + //网格名一样变为true + n.setAgencyNameStatus(true); + } + }); + } + Map> groupByAgencyNameStatus = needInsert.stream().collect(Collectors.groupingBy(IcNeighborHoodExcel::getAgencyNameStatus)); + List finalNeedInsert = groupByAgencyNameStatus.get(true); + if (CollectionUtils.isEmpty(finalNeedInsert)){ + for (int i = NumConstant.ONE; i <= result.size(); i++) { + nums.add(i); + } + String str = String.format("共%s条,成功导入%s条。",result.size(),0); + return new Result().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),str +"第"+nums.stream().map(String::valueOf).collect(Collectors.joining("、"))+"行未成功!"); + } + Map collect = finalNeedInsert.stream().collect(Collectors.groupingBy(o -> o.getGridName() + "_" + o.getNeighborHoodName(), Collectors.counting())); + collect.forEach((k,v) -> { + if (Integer.valueOf(v.toString()).compareTo(1) > 0){ + for (IcNeighborHoodExcel r : result) { + if (k.equals(r.getGridName()+"_"+r.getNeighborHoodName())){ + r.setReStatus(true); + } + } + } + }); + List realFinalResult = new ArrayList<>(); + for (int i = NumConstant.ZERO; i < result.size(); i++) { + if (result.get(i).getStatus() == true && result.get(i).getExistNameStatus() == false && + result.get(i).getAgencyNameStatus() == true && result.get(i).getReStatus() == false){ + realFinalResult.add(result.get(i)); + } + } + List entities = ConvertUtils.sourceToTarget(realFinalResult, IcNeighborHoodEntity.class); + entities.forEach(e -> { + for (InfoByNamesResultDTO g : gridInfos) { + if (e.getGridName().equals(g.getGridName())){ + e.setAgencyId(g.getAgencyId()); + e.setAgencyPids(g.getAgencyPids()); + e.setCustomerId(formDTO.getCustomerId()); + e.setGridId(g.getGridId()); + e.setParentAgencyId(g.getParentAgencyId()); + break; + } + } + }); + // 物业表插入 + List propertyNames = finalNeedInsert.stream().map(m -> m.getPropertyName()).distinct().collect(Collectors.toList()); + List disposePropertyNames = finalNeedInsert.stream().map(m -> m.getPropertyName()).distinct().collect(Collectors.toList()); + List existPropertyNames = propertyManagementDao.selectExistNames(propertyNames); + disposePropertyNames.removeAll(existPropertyNames); + List propertyManagementEntities = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(disposePropertyNames)){ + disposePropertyNames.forEach(name -> { + IcPropertyManagementEntity e = new IcPropertyManagementEntity(); + e.setName(name); + propertyManagementEntities.add(e); + }); + } + importInsert(entities,propertyManagementEntities); + // 小区物业关系表插入 + List neighborHoodAndManagementDTOS = ConvertUtils.sourceToTarget(entities, NeighborHoodAndManagementDTO.class); + List propertyManagementInfos = propertyManagementDao.selectIdByName(propertyNames); + neighborHoodAndManagementDTOS.forEach(n -> propertyManagementInfos.stream().filter(p -> p.getName().equals(n.getPropertyName())) + .forEach(p -> { + n.setPropertyId(p.getId()); + n.setNeighborHoodId(n.getId()); + })); + List icNeighborHoodPropertyEntities = ConvertUtils.sourceToTarget(neighborHoodAndManagementDTOS, IcNeighborHoodPropertyEntity.class); + neighborHoodPropertyInsert(icNeighborHoodPropertyEntities); + + for (int i = NumConstant.ZERO; i < result.size(); i++) { + if (result.get(i).getStatus() == false || result.get(i).getExistNameStatus() == true || result.get(i).getAgencyNameStatus() == false || result.get(i).getReStatus() == true){ + nums.add(i + NumConstant.ONE); + } + } + String str = String.format("共%s条,成功导入%s条。",result.size(),entities.size()); + if (CollectionUtils.isNotEmpty(nums)){ + return new Result().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),str + "第"+nums.stream().map(String::valueOf).collect(Collectors.joining("、"))+"行未成功!"); + } + return new Result().ok(str); + } + + public Result importNeighbor(ImportInfoFormDTO formDTO, MultipartFile file,Result importTask){ + ExcelReader excelReader = null; + try { + InputStream inputStream = null; + try { + inputStream = file.getInputStream(); + } catch (IOException e) { + return new Result().error("读取文件失败"); + } + + excelReader = EasyExcel.read(inputStream).build(); + // 这里为了简单 所以注册了 同样的head 和Listener 自己使用功能必须不同的Listener + ReadSheet readSheet = EasyExcel.readSheet(0).head(NeighborHoodInfoModel.class) + .registerReadListener(new ImportNeighborHoodInfoListener(formDTO,icHouseRedis,icBuildingDao,this,propertyManagementDao,epmetCommonServiceOpenFeignClient,importTask.getData().getTaskId())) + .build(); + excelReader.read(readSheet); + } catch (Exception e){ + ImportTaskCommonFormDTO input = new ImportTaskCommonFormDTO(); + input.setOperatorId(formDTO.getUserId()); + input.setTaskId(importTask.getData().getTaskId()); + input.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL); + epmetCommonServiceOpenFeignClient.finishImportTask(input); + } finally { + if (excelReader != null) { + excelReader.finish(); + } + } + + return new Result<>(); + } + + /** + * @Description 小区插入,物业插入 + * @param entities + * @param propertyManagementEntities + * @author zxc + * @date 2022/2/13 10:09 上午 + */ + @Transactional(rollbackFor = Exception.class) + public void importInsert(List entities,List propertyManagementEntities){ + List> partition = ListUtils.partition(entities, NumConstant.ONE_HUNDRED); + partition.forEach(p -> { + insertBatch(p); + }); + List> partition1 = ListUtils.partition(propertyManagementEntities, NumConstant.ONE_HUNDRED); + partition1.forEach(p -> { + propertyManagementService.insertBatch(p); + }); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void insertPropertyManagement(List propertyManagementEntities){ + if (CollectionUtils.isEmpty(propertyManagementEntities)){ + return; + } + List> partition1 = ListUtils.partition(propertyManagementEntities, NumConstant.ONE_HUNDRED); + partition1.forEach(p -> { + propertyManagementService.insertBatch(p); + }); + } + + /** + * @Description 小区物业关系表插入 + * @param entities + * @author zxc + * @date 2022/2/13 10:09 上午 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void neighborHoodPropertyInsert(List entities){ + List> partition = ListUtils.partition(entities, NumConstant.ONE_HUNDRED); + partition.forEach(p -> { + neighborHoodPropertyService.insertBatch(p); + }); + } + + /** + * 获取导入小区,楼栋,单元ID + * + * @param formDTO + * @param list + * @Param formDTO + * @Param list + * @Return {@link List< ImportGeneralDTO >} + * @Author zhaoqifeng + * @Date 2022/2/14 9:40 + */ + @Override + public List getImportInfo(ImportInfoFormDTO formDTO, List list) { + list.forEach(item -> { + if (StringUtils.isEmpty(item.getNeighborHoodId())) { + //1.获取小区ID,判断小区是否存在,不存在则添加小区,存在则直接获取小区ID + String neighborHoodId = getNeighborHoodId(formDTO.getCustomerId(), item); + item.setNeighborHoodId(neighborHoodId); + //2.获取楼栋ID,判断楼栋是否存在,不存在则添加楼栋,存在则直接获取楼栋ID + if (StringUtils.isEmpty(item.getBuildingId()) && StringUtils.isNotEmpty(item.getBuildingName())) { + String buildingId = getBuildingId(formDTO.getCustomerId(), item); + item.setBuildingId(buildingId); + } + //3.获取单元ID,判断单元是否存在,不存在则添加单元,存在则直接获取单元ID + if (null != item.getBuildingUnit()) { + String unitId = getUnitId(formDTO.getCustomerId(), item); + item.setBuildingUnitId(unitId); + } + } else if (StringUtils.isNotEmpty(item.getNeighborHoodId()) && StringUtils.isEmpty(item.getBuildingId())) { + //获取楼栋ID,判断楼栋是否存在,不存在则添加楼栋,存在则直接获取楼栋ID + String buildingId = getBuildingId(formDTO.getCustomerId(), item); + item.setBuildingId(buildingId); + //获取单元ID,判断单元是否存在,不存在则添加单元,存在则直接获取单元ID + if (null != item.getBuildingUnit()) { + String unitId = getUnitId(formDTO.getCustomerId(), item); + item.setBuildingUnitId(unitId); + } + } + }); + + return list; + } + + /** + * 根据小区名获取小区ID,如果没有,先新增小区 + * @Param gridId + * @Param name + * @Return {@link String} + * @Author zhaoqifeng + * @Date 2022/2/14 9:50 + */ + @Transactional(rollbackFor = Exception.class) + private String getNeighborHoodId(String customerId, ImportGeneralDTO info) { + //根据网格ID和小区名获取小区信息 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(IcNeighborHoodEntity::getGridId, info.getGridId()); + wrapper.eq(IcNeighborHoodEntity::getNeighborHoodName, info.getNeighborHoodName()); + IcNeighborHoodEntity entity = baseDao.selectOne(wrapper); + if (null != entity) { + info.setNeighborHoodExistStatus(true); + return entity.getId(); + } + entity = new IcNeighborHoodEntity(); + entity.setCustomerId(customerId); + entity.setAgencyId(info.getAgencyId()); + entity.setParentAgencyId(info.getPid()); + entity.setAgencyPids(info.getPids()); + entity.setGridId(info.getGridId()); + entity.setNeighborHoodName(info.getNeighborHoodName()); + entity.setAddress(info.getAddress()); + entity.setRemark(info.getRemark()); + baseDao.insert(entity); + return entity.getId(); + } + + /** + * 获取楼栋ID + * @Param customerId + * @Param info + * @Return {@link String} + * @Author zhaoqifeng + * @Date 2022/2/14 15:36 + */ + private String getBuildingId(String customerId, ImportGeneralDTO info) { + //根据小区ID和楼栋名获取楼栋信息 + IcBuildingDTO building = icBuildingService.getBuildingInfo(info.getNeighborHoodId(), info.getBuildingName()); + if (null != building) { + info.setBuildingExistStatus(true); + return building.getId(); + } + IcBuildingEntity buildingEntity = new IcBuildingEntity(); + buildingEntity.setCustomerId(customerId); + buildingEntity.setNeighborHoodId(info.getNeighborHoodId()); + buildingEntity.setBuildingName(info.getBuildingName()); + buildingEntity.setType(null == info.getType()?NumConstant.ONE_STR:info.getType()); + buildingEntity.setSort(NumConstant.ZERO); + buildingEntity.setTotalUnitNum(info.getTotalUnitNum()); + buildingEntity.setTotalFloorNum(info.getTotalFloorNum()); + buildingEntity.setTotalHouseNum(info.getTotalHouseNum()); + icBuildingService.insert(buildingEntity); + if (null != info.getTotalUnitNum() && info.getTotalUnitNum() > NumConstant.ZERO) { + //设置楼宇单元 + List unitList = new ArrayList<>(); + for (int i =0 ; i String orgGeneralImport(Collection errorRows, Class tClass) throws IOException { + Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("导入失败的数据列表","导入失败的数据列表"), + tClass, errorRows); + + // 文件名 + String resultDescFileName = UUID.randomUUID().toString().concat(".xls"); + + FileItemFactory factory = new DiskFileItemFactory(16, null); + FileItem fileItem = factory.createItem("file", ContentType.APPLICATION_OCTET_STREAM.toString(), true, resultDescFileName); + OutputStream os = fileItem.getOutputStream(); + Result uploadResult = null; + try { + workbook.write(os); + uploadResult = ossFeignClient.uploadImportTaskDescFile(new CommonsMultipartFile(fileItem)); + } catch (Exception e) { + String errormsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【居民信息导入】上传错误描述文件:{}", errormsg); + } finally { + try { + os.close(); + } catch (IOException e) { + String errormsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【居民信息导入】上传错误描述文件关闭输出流:{}", errormsg); + } + try { + fileItem.delete(); + } catch (Exception e) { + String errormsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【居民信息导入】上传错误描述文件删除临时文件:{}", errormsg); + } + } + + if (uploadResult == null || !uploadResult.success()) { + log.error("【居民信息导入】调用OSS上传结果描述文件失败"); + return null; + } + return uploadResult.getData().getUrl(); + } + +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java index b70354aceb..c6013c1332 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java @@ -519,7 +519,7 @@ public class StaffServiceImpl implements StaffService { //2.调用user服务,新增用户信息 StaffSubmitFromDTO submitDTO = ConvertUtils.sourceToTarget(fromDTO, StaffSubmitFromDTO.class); - submitDTO.setAgencyId(fromDTO.getOrgId()); + submitDTO.setAgencyId(orgDTO.getAgencyId()); Result result = epmetUserFeignClient.addStaff(submitDTO); if (!result.success()) { if (result.getCode() != EpmetErrorCode.SERVER_ERROR.getCode()) { 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 ddd78b7407..8039b75e00 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 @@ -154,3 +154,14 @@ rocketmq: name-server: @rocketmq.nameserver@ # consume-thread-min: 2 # consume-thread-max: 2 + +thread: + # 线程池配置 + threadPool: + enableCustomize: @thread.threadPool.enable-customize@ + corePoolSize: @thread.threadPool.core-pool-size@ + maxPoolSize: @thread.threadPool.max-pool-size@ + queueCapacity: @thread.threadPool.queue-capacity@ + keepAliveSeconds: @thread.threadPool.keep-alive-seconds@ + threadNamePrefix: @thread.threadPool.thread-name-prefix@ + rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@ diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/db/migration/V0.0.11__edit_neighbor_hood.sql b/epmet-module/gov-org/gov-org-server/src/main/resources/db/migration/V0.0.11__edit_neighbor_hood.sql new file mode 100644 index 0000000000..b5ba5452f3 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/db/migration/V0.0.11__edit_neighbor_hood.sql @@ -0,0 +1,2 @@ +ALTER TABLE `epmet_gov_org`.`ic_neighbor_hood` + MODIFY COLUMN `ADDRESS` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '详细地址' AFTER `GRID_ID`; \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/db/migration/V0.0.12__addagency_grid_address.sql b/epmet-module/gov-org/gov-org-server/src/main/resources/db/migration/V0.0.12__addagency_grid_address.sql new file mode 100644 index 0000000000..dad5775467 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/db/migration/V0.0.12__addagency_grid_address.sql @@ -0,0 +1,2 @@ +alter table customer_agency add COLUMN CENTER_ADDRESS VARCHAR(128) comment '中心点位地址' AFTER LATITUDE; +alter table customer_grid add COLUMN CENTER_ADDRESS VARCHAR(128) comment '中心点位地址' AFTER LATITUDE; \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml index a70cf1d9b6..357c8cebdc 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml @@ -185,6 +185,7 @@ grid_name AS gridName, longitude AS longitude, latitude AS latitude, + CENTER_ADDRESS AS centerAddress, area_code AS areaCode, manage_district AS manageDistrict, total_user AS totalUser, @@ -242,6 +243,15 @@ contacts = #{contacts}, mobile = #{mobile}, updated_by = #{updatedBy}, + + LONGITUDE= #{longitude}, + + + LATITUDE= #{latitude}, + + + CENTER_ADDRESS= #{centerAddress}, + UPDATED_TIME=NOW() where id = #{id} @@ -806,4 +816,23 @@ + + + diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcBuildingDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcBuildingDao.xml index d4f3847235..c2482d86af 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcBuildingDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcBuildingDao.xml @@ -25,6 +25,23 @@ + + + UPDATE ic_building + set + TOTAL_HOUSE_NUM = CASE + + when id = #{n.id} then #{n.num} + end, + UPDATED_TIME = NOW() + WHERE DEL_FLAG = '0' + AND id in( + + #{n.id} + + ) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml index 32338f7927..08adc876d0 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml @@ -129,8 +129,9 @@ LEFT JOIN ic_neighbor_hood c on a.NEIGHBOR_HOOD_ID = c.ID and c.DEL_FLAG = '0' LEFT JOIN ic_building_unit d on a.BUILDING_UNIT_ID = d.ID and d.DEL_FLAG = '0' + a.del_flag = '0' - case c.AGENCY_PIDS + and case c.AGENCY_PIDS when '' then CONCAT(c.AGENCY_ID) like CONCAT(#{pids}, '%') else CONCAT(c.AGENCY_PIDS, ':', c.AGENCY_ID) like CONCAT(#{pids}, '%') end diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml index 73c23350d7..36daaf0d27 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml @@ -214,4 +214,18 @@ and a.id !=#{neighborId} + + + diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcPropertyManagementDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcPropertyManagementDao.xml index 725fdf969f..5a5cf172a3 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcPropertyManagementDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcPropertyManagementDao.xml @@ -23,4 +23,29 @@ m.DEL_FLAG = '0' AND m.`NAME` = #{name} + + + + + + + \ No newline at end of file diff --git a/epmet-module/gov-project/gov-project-server/pom.xml b/epmet-module/gov-project/gov-project-server/pom.xml index 358ea6165f..572bebf89b 100644 --- a/epmet-module/gov-project/gov-project-server/pom.xml +++ b/epmet-module/gov-project/gov-project-server/pom.xml @@ -187,6 +187,15 @@ true + + true + 5 + 8 + 20 + 60 + gov-project + callerRunsPolicy + false https://epmet-dev.elinkservice.cn/api/epmetscan/api @@ -229,6 +238,15 @@ false + + true + 5 + 8 + 20 + 60 + gov-project + callerRunsPolicy + false https://epmet-dev.elinkservice.cn/api/epmetscan/api @@ -270,6 +288,15 @@ true + + true + 5 + 8 + 20 + 60 + gov-project + callerRunsPolicy + true https://epmet-dev.elinkservice.cn/api/epmetscan/api @@ -308,6 +335,15 @@ true + + true + 5 + 8 + 20 + 60 + gov-project + callerRunsPolicy + true https://epmet-open.elinkservice.cn/api/epmetscan/api diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/GovProjectApplication.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/GovProjectApplication.java index 37c767c4b3..47fa0b89ac 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/GovProjectApplication.java +++ b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/GovProjectApplication.java @@ -5,6 +5,7 @@ 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.scheduling.annotation.EnableAsync; /** * @@ -14,6 +15,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient @EnableFeignClients +@EnableAsync @ServletComponentScan public class GovProjectApplication { public static void main(String[] args) { diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectSatisfactionStatisticsServiceImpl.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectSatisfactionStatisticsServiceImpl.java index f3925108f3..ec8d517c96 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectSatisfactionStatisticsServiceImpl.java +++ b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectSatisfactionStatisticsServiceImpl.java @@ -140,8 +140,8 @@ public class ProjectSatisfactionStatisticsServiceImpl extends BaseServiceImpl implements ProjectTraceS private ResiEventReportOrgDao resiEventReportOrgDao; @Autowired private BlockChainUploadService blockChainUploadService; + @Autowired + private YuShanSysApiService yuShanSysApiService; + @Override public List getPendProjectList(TokenDto tokenDto, ProjectListFromDTO fromDTO) { @@ -312,7 +317,10 @@ public class ProjectTraceServiceImpl implements ProjectTraceS List staffList = formDTO.getStaffList(); //1.文字内容安全校验 List list = new ArrayList<>(); - list.add(formDTO.getTitle());list.add(formDTO.getBackGround());list.add(formDTO.getPublicReply());list.add(formDTO.getInternalRemark()); + list.add(formDTO.getTitle()); + list.add(formDTO.getBackGround()); + list.add(formDTO.getPublicReply()); + list.add(formDTO.getInternalRemark()); safetyCheck(list); //2.数据准备,查询需要用到的数据 @@ -552,6 +560,12 @@ public class ProjectTraceServiceImpl implements ProjectTraceS String errorMsg = ExceptionUtils.getThrowableErrorStackTrace(e); log.error("【项目流转】上链失败,错误信息:{}", errorMsg); } + //项目立项如果是榆山街道的工作人员,需要调用【更新用户积分(双实信息更新 网格巡查)】/api/points/behavior/updateUserPoints + UpdateUserPointsFormDTO updateUserPointsFormDTO=new UpdateUserPointsFormDTO(); + updateUserPointsFormDTO.setCustomerId(projectEntity.getCustomerId()); + updateUserPointsFormDTO.setStaffId(projectEntity.getCreatedBy()); + updateUserPointsFormDTO.setBehaviorType(BehaviorTypeYuShanEnum.GRID_REPORT_EVENT.getCode()); + yuShanSysApiService.updateUserPoints(projectEntity.getCustomerId(),Arrays.asList(updateUserPointsFormDTO)); } /** diff --git a/epmet-module/gov-project/gov-project-server/src/main/resources/bootstrap.yml b/epmet-module/gov-project/gov-project-server/src/main/resources/bootstrap.yml index 7821e73e53..15aa1dcbfb 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/resources/bootstrap.yml +++ b/epmet-module/gov-project/gov-project-server/src/main/resources/bootstrap.yml @@ -141,3 +141,14 @@ shutdown: graceful: enable: true #是否开启优雅停机 waitTimeSecs: 30 # 优雅停机等待时间,超过30秒,发出告警 + +thread: + # 线程池配置 + threadPool: + enableCustomize: @thread.threadPool.enable-customize@ + corePoolSize: @thread.threadPool.core-pool-size@ + maxPoolSize: @thread.threadPool.max-pool-size@ + queueCapacity: @thread.threadPool.queue-capacity@ + keepAliveSeconds: @thread.threadPool.keep-alive-seconds@ + threadNamePrefix: @thread.threadPool.thread-name-prefix@ + rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@ diff --git a/epmet-module/gov-voice/gov-voice-server/pom.xml b/epmet-module/gov-voice/gov-voice-server/pom.xml index 305075f3a6..acee6a8306 100644 --- a/epmet-module/gov-voice/gov-voice-server/pom.xml +++ b/epmet-module/gov-voice/gov-voice-server/pom.xml @@ -132,6 +132,15 @@ true + + true + 5 + 8 + 20 + 60 + gov-voice + callerRunsPolicy + false https://epmet-dev.elinkservice.cn/api/epmetscan/api @@ -173,6 +182,15 @@ false + + true + 5 + 8 + 20 + 60 + gov-voice + callerRunsPolicy + false https://epmet-dev.elinkservice.cn/api/epmetscan/api @@ -214,6 +232,15 @@ true + + true + 5 + 8 + 20 + 60 + gov-voice + callerRunsPolicy + true https://epmet-dev.elinkservice.cn/api/epmetscan/api @@ -252,6 +279,15 @@ true + + true + 5 + 8 + 20 + 60 + gov-voice + callerRunsPolicy + true https://epmet-open.elinkservice.cn/api/epmetscan/api diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/ArticleController.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/ArticleController.java index d81affca3a..4c7457f4c3 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/ArticleController.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/ArticleController.java @@ -19,6 +19,7 @@ package com.epmet.controller; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.annotation.RequirePermission; +import com.epmet.commons.tools.aop.NoRepeatSubmit; import com.epmet.commons.tools.enums.RequirePermissionEnum; import com.epmet.commons.tools.scan.result.SyncScanResult; import com.epmet.commons.tools.security.dto.TokenDto; @@ -218,6 +219,7 @@ public class ArticleController { * @param formDTO * @throws Exception */ + @NoRepeatSubmit @PostMapping("publish") @RequirePermission(requirePermission = RequirePermissionEnum.WORK_PARTY_VOICE_PUBLISH) public Result publishArticle(@LoginUser TokenDto tokenDto, @RequestBody PublishArticleFormDTO formDTO) throws Exception { @@ -234,6 +236,7 @@ public class ArticleController { * @param formDTO * @throws Exception */ + @NoRepeatSubmit @PostMapping("manualpublish") @RequirePermission(requirePermission = RequirePermissionEnum.WORK_PARTY_VOICE_PUBLISH) public Result manualPublish(@LoginUser TokenDto tokenDto, @RequestBody PublishArticleFormDTO formDTO) throws Exception { diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/resources/bootstrap.yml b/epmet-module/gov-voice/gov-voice-server/src/main/resources/bootstrap.yml index 16425361b7..352c1d59e4 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/resources/bootstrap.yml +++ b/epmet-module/gov-voice/gov-voice-server/src/main/resources/bootstrap.yml @@ -129,3 +129,14 @@ shutdown: graceful: enable: true #是否开启优雅停机 waitTimeSecs: 30 # 优雅停机等待时间,超过30秒,发出告警 + +thread: + # 线程池配置 + threadPool: + enableCustomize: @thread.threadPool.enable-customize@ + corePoolSize: @thread.threadPool.core-pool-size@ + maxPoolSize: @thread.threadPool.max-pool-size@ + queueCapacity: @thread.threadPool.queue-capacity@ + keepAliveSeconds: @thread.threadPool.keep-alive-seconds@ + threadNamePrefix: @thread.threadPool.thread-name-prefix@ + rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@ 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 index 802f37d762..f5e8264f49 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/pom.xml +++ b/epmet-module/open-data-worker/open-data-worker-server/pom.xml @@ -140,6 +140,15 @@ true + + true + 5 + 8 + 20 + 60 + open-data-worker + callerRunsPolicy + false @@ -183,6 +192,15 @@ false + + true + 5 + 8 + 20 + 60 + open-data-worker + callerRunsPolicy + false @@ -226,6 +244,15 @@ true + + true + 5 + 8 + 20 + 60 + open-data-worker + callerRunsPolicy + true @@ -266,6 +293,15 @@ true + + true + 5 + 8 + 20 + 60 + open-data-worker + callerRunsPolicy + true 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 index 49db95eb6d..a27e8fdf66 100644 --- 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 @@ -135,4 +135,15 @@ dingTalk: rocketmq: # 是否开启mq enable: @rocketmq.enable@ - name-server: @rocketmq.nameserver@ \ No newline at end of file + name-server: @rocketmq.nameserver@ + +thread: + # 线程池配置 + threadPool: + enableCustomize: @thread.threadPool.enable-customize@ + corePoolSize: @thread.threadPool.core-pool-size@ + maxPoolSize: @thread.threadPool.max-pool-size@ + queueCapacity: @thread.threadPool.queue-capacity@ + keepAliveSeconds: @thread.threadPool.keep-alive-seconds@ + threadNamePrefix: @thread.threadPool.thread-name-prefix@ + rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@ \ No newline at end of file diff --git a/epmet-module/oper-access/oper-access-server/pom.xml b/epmet-module/oper-access/oper-access-server/pom.xml index 8d3c8706e8..0089943bf7 100644 --- a/epmet-module/oper-access/oper-access-server/pom.xml +++ b/epmet-module/oper-access/oper-access-server/pom.xml @@ -120,6 +120,15 @@ true + + true + 5 + 8 + 20 + 60 + oper-access + callerRunsPolicy + false @@ -160,6 +169,15 @@ false + + true + 5 + 8 + 20 + 60 + oper-access + callerRunsPolicy + false @@ -200,6 +218,15 @@ true + + true + 5 + 8 + 20 + 60 + oper-access + callerRunsPolicy + true @@ -237,6 +264,15 @@ true + + true + 5 + 8 + 20 + 60 + oper-access + callerRunsPolicy + true diff --git a/epmet-module/oper-access/oper-access-server/src/main/resources/bootstrap.yml b/epmet-module/oper-access/oper-access-server/src/main/resources/bootstrap.yml index ba387b80c4..9ed804a4a3 100644 --- a/epmet-module/oper-access/oper-access-server/src/main/resources/bootstrap.yml +++ b/epmet-module/oper-access/oper-access-server/src/main/resources/bootstrap.yml @@ -132,3 +132,14 @@ shutdown: graceful: enable: true #是否开启优雅停机 waitTimeSecs: 30 # 优雅停机等待时间,超过30秒,发出告警 + +thread: + # 线程池配置 + threadPool: + enableCustomize: @thread.threadPool.enable-customize@ + corePoolSize: @thread.threadPool.core-pool-size@ + maxPoolSize: @thread.threadPool.max-pool-size@ + queueCapacity: @thread.threadPool.queue-capacity@ + keepAliveSeconds: @thread.threadPool.keep-alive-seconds@ + threadNamePrefix: @thread.threadPool.thread-name-prefix@ + rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@ \ No newline at end of file diff --git a/epmet-module/oper-crm/oper-crm-server/pom.xml b/epmet-module/oper-crm/oper-crm-server/pom.xml index eaa54edf09..493dc1c3c6 100644 --- a/epmet-module/oper-crm/oper-crm-server/pom.xml +++ b/epmet-module/oper-crm/oper-crm-server/pom.xml @@ -165,6 +165,15 @@ true + + true + 5 + 8 + 20 + 60 + oper-crm + callerRunsPolicy + false @@ -205,6 +214,15 @@ false + + true + 5 + 8 + 20 + 60 + oper-crm + callerRunsPolicy + false @@ -245,6 +263,15 @@ true + + true + 5 + 8 + 20 + 60 + oper-crm + callerRunsPolicy + true @@ -285,6 +312,15 @@ true + + true + 5 + 8 + 20 + 60 + oper-crm + callerRunsPolicy + true diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/resources/bootstrap.yml b/epmet-module/oper-crm/oper-crm-server/src/main/resources/bootstrap.yml index dc81eba455..15bb6eb0be 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/resources/bootstrap.yml +++ b/epmet-module/oper-crm/oper-crm-server/src/main/resources/bootstrap.yml @@ -138,3 +138,14 @@ shutdown: graceful: enable: true #是否开启优雅停机 waitTimeSecs: 30 # 优雅停机等待时间,超过30秒,发出告警 + +thread: + # 线程池配置 + threadPool: + enableCustomize: @thread.threadPool.enable-customize@ + corePoolSize: @thread.threadPool.core-pool-size@ + maxPoolSize: @thread.threadPool.max-pool-size@ + queueCapacity: @thread.threadPool.queue-capacity@ + keepAliveSeconds: @thread.threadPool.keep-alive-seconds@ + threadNamePrefix: @thread.threadPool.thread-name-prefix@ + rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@ \ No newline at end of file diff --git a/epmet-module/oper-customize/oper-customize-server/pom.xml b/epmet-module/oper-customize/oper-customize-server/pom.xml index e28bf701fb..2b802b20f2 100644 --- a/epmet-module/oper-customize/oper-customize-server/pom.xml +++ b/epmet-module/oper-customize/oper-customize-server/pom.xml @@ -137,6 +137,15 @@ true + + true + 5 + 8 + 20 + 60 + oper-customize + callerRunsPolicy + false @@ -182,6 +191,15 @@ false + + true + 5 + 8 + 20 + 60 + oper-customize + callerRunsPolicy + false @@ -227,6 +245,15 @@ true + + true + 5 + 8 + 20 + 60 + oper-customize + callerRunsPolicy + true @@ -269,6 +296,15 @@ true + + true + 5 + 8 + 20 + 60 + oper-customize + callerRunsPolicy + true diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/resources/bootstrap.yml b/epmet-module/oper-customize/oper-customize-server/src/main/resources/bootstrap.yml index c5dec6d251..346506fb54 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/resources/bootstrap.yml +++ b/epmet-module/oper-customize/oper-customize-server/src/main/resources/bootstrap.yml @@ -136,3 +136,14 @@ shutdown: graceful: enable: true #是否开启优雅停机 waitTimeSecs: 30 # 优雅停机等待时间,超过30秒,发出告警 + +thread: + # 线程池配置 + threadPool: + enableCustomize: @thread.threadPool.enable-customize@ + corePoolSize: @thread.threadPool.core-pool-size@ + maxPoolSize: @thread.threadPool.max-pool-size@ + queueCapacity: @thread.threadPool.queue-capacity@ + keepAliveSeconds: @thread.threadPool.keep-alive-seconds@ + threadNamePrefix: @thread.threadPool.thread-name-prefix@ + rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@ \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/ResiGroupMemberDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/ResiGroupMemberDTO.java index a64ebdb042..9244410c3b 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/ResiGroupMemberDTO.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/ResiGroupMemberDTO.java @@ -65,7 +65,7 @@ public class ResiGroupMemberDTO implements Serializable { private String groupInvitationId; /** - * 状态:( 审核通过 - approved、 已禁言 - silent、 被移出群 - removed) + * 状态:( 审核通过 - approved、 已禁言 - silent、 被移出群 - removed)exit:退群 */ private String status; diff --git a/epmet-module/resi-group/resi-group-server/pom.xml b/epmet-module/resi-group/resi-group-server/pom.xml index 1a1462c00b..bd232b3aac 100644 --- a/epmet-module/resi-group/resi-group-server/pom.xml +++ b/epmet-module/resi-group/resi-group-server/pom.xml @@ -193,11 +193,14 @@ 52d9d9b0e7d0eb5b8b81c205b579e07c https://epmet-dev.elinkservice.cn/api/epmetscan/api - - 5 - 8 - 10 - 30 + + true + 5 + 8 + 20 + 60 + resi-group + callerRunsPolicy @@ -252,11 +255,14 @@ 52d9d9b0e7d0eb5b8b81c205b579e07c https://epmet-dev.elinkservice.cn/api/epmetscan/api - - 5 - 8 - 10 - 30 + + true + 5 + 8 + 20 + 60 + resi-group + callerRunsPolicy @@ -309,11 +315,14 @@ 96d788191a10ff57a125157183413004 https://epmet-dev.elinkservice.cn/api/epmetscan/api - - 5 - 8 - 10 - 30 + + true + 5 + 8 + 20 + 60 + resi-group + callerRunsPolicy @@ -365,11 +374,14 @@ 7ce17f65826539ff3e8616dccd4b70fc https://epmet-open.elinkservice.cn/api/epmetscan/api - - 5 - 8 - 10 - 30 + + true + 5 + 8 + 20 + 60 + resi-group + callerRunsPolicy diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/ResiGroupApplication.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/ResiGroupApplication.java index 0976927df0..eafe96e728 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/ResiGroupApplication.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/ResiGroupApplication.java @@ -13,6 +13,7 @@ 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.scheduling.annotation.EnableAsync; /** * 模块 @@ -24,6 +25,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @EnableDiscoveryClient @EnableFeignClients @ServletComponentScan +@EnableAsync public class ResiGroupApplication { public static void main(String[] args) { diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/config/AsyncConfig.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/config/AsyncConfig.java deleted file mode 100644 index 8a1a958939..0000000000 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/config/AsyncConfig.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.epmet.config; - -import com.epmet.properties.ThreadProperties; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.scheduling.annotation.EnableAsync; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; - -import java.util.concurrent.Executor; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.ThreadPoolExecutor; - -/** - * 线程池配置类 - */ -@Configuration -@EnableConfigurationProperties(ThreadProperties.class) -@EnableAsync -public class AsyncConfig { - - @Autowired - private ThreadProperties threadProperties; - - @Bean - public Executor executor() { - ThreadProperties.ThreadPoolProperties threadPoolProps = threadProperties.getThreadPool(); - - ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); - executor.setCorePoolSize(threadPoolProps.getCorePoolSize()); - executor.setMaxPoolSize(threadPoolProps.getMaxPoolSize()); - executor.setQueueCapacity(threadPoolProps.getQueueCapacity()); - executor.setThreadNamePrefix("epmet-resi-group-"); - // rejection-policy:当pool已经达到max size的时候,如何处理新任务 - // CALLER_RUNS:不在新线程中执行任务,而是由调用者所在的线程来执行 - executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); //对拒绝task的处理策略 - executor.setKeepAliveSeconds(threadPoolProps.getKeepAlive()); - executor.initialize(); - return executor; - } - - @Bean - public ExecutorService executorService() { - ThreadPoolTaskExecutor executor = (ThreadPoolTaskExecutor) executor(); - return executor.getThreadPoolExecutor(); - } - -} diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ExitGroupController.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ExitGroupController.java index ca8e7013fd..f49d0b2677 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ExitGroupController.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ExitGroupController.java @@ -1,6 +1,7 @@ package com.epmet.modules.group.controller; import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.aop.NoRepeatSubmit; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; @@ -54,6 +55,7 @@ public class ExitGroupController { * @description 组员自主退群 * @Date 2021/4/30 15:09 **/ + @NoRepeatSubmit @PostMapping("memexitgroup") public Result memExitGroup(@LoginUser TokenDto tokenDto, @RequestBody MemExitGroupFormDTO formDTO){ formDTO.setUserId(tokenDto.getUserId()); diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ExitGroupServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ExitGroupServiceImpl.java index 62e10b0303..f73a2e46c8 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ExitGroupServiceImpl.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ExitGroupServiceImpl.java @@ -2,6 +2,7 @@ package com.epmet.modules.group.service.impl; import com.epmet.commons.tools.constant.*; import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.form.UserRoleFormDTO; @@ -223,7 +224,7 @@ public class ExitGroupServiceImpl implements ExitGroupService { //1、当前组员是否还在群里? ResiGroupMemberDTO resiGroupMemberDTO=resiGroupMemberDao.selectGroupMemberInfo(formDTO.getGroupId(),formDTO.getUserId()); if(null == resiGroupMemberDTO){ - throw new RenException("已退出当前小组,请勿重复操作"); + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "已退出当前小组,请勿重复操作","已退出当前小组,请勿重复操作"); } //2、组长不允许退群,提示:请先转移组长身份后再退组 if(ModuleConstant.GROUP_LEADER.equals(resiGroupMemberDTO.getGroupLeaderFlag())){ diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/entity/ResiGroupMemberEntity.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/entity/ResiGroupMemberEntity.java index 0e21de29db..84f166b844 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/entity/ResiGroupMemberEntity.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/entity/ResiGroupMemberEntity.java @@ -63,7 +63,7 @@ public class ResiGroupMemberEntity extends BaseEpmetEntity { private String groupInvitationId; /** - * 状态:( 审核通过 - approved、 已禁言 - silent、 被移出群 - removed) + * 状态:( 审核通过 - approved、 已禁言 - silent、 被移出群 - removed)exit:退群 */ private String status; diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/TopicDraftServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/TopicDraftServiceImpl.java index 0d681d7368..8706317b90 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/TopicDraftServiceImpl.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/TopicDraftServiceImpl.java @@ -17,7 +17,6 @@ package com.epmet.modules.topic.service.impl; -import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; @@ -25,8 +24,8 @@ import com.epmet.commons.rocketmq.messages.GroupAchievementMQMsg; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.MqConstant; import com.epmet.commons.tools.constant.NumConstant; -import com.epmet.commons.tools.dto.form.mq.MqBaseMsgDTO; import com.epmet.commons.tools.dto.form.mq.eventmsg.BasePointEventMsg; +import com.epmet.commons.tools.enums.AchievementTypeEnum; import com.epmet.commons.tools.enums.EventEnum; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; @@ -37,19 +36,18 @@ import com.epmet.commons.tools.scan.result.AsyncScanTaskDTO; import com.epmet.commons.tools.scan.result.SyncScanResult; import com.epmet.commons.tools.scan.result.VoiceResultDTO; import com.epmet.commons.tools.security.dto.TokenDto; -import com.epmet.commons.tools.utils.*; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.utils.ScanContentUtils; import com.epmet.constant.SystemMessageType; import com.epmet.dto.form.CommonGridIdFormDTO; import com.epmet.dto.form.SystemMsgFormDTO; import com.epmet.dto.result.AllGridsByUserIdResultDTO; -import com.epmet.dto.result.UserInfoResultDTO; import com.epmet.dto.result.CommonDataFilterResultDTO; -import com.epmet.feign.EpmetMessageOpenFeignClient; import com.epmet.dto.result.UserInfoResultDTO; +import com.epmet.feign.EpmetMessageOpenFeignClient; import com.epmet.feign.GovOrgOpenFeignClient; -import com.epmet.commons.tools.enums.AchievementTypeEnum; -import com.epmet.modules.feign.EpmetUserFeignClient; -import com.epmet.modules.group.dao.GroupMessageDao; import com.epmet.modules.feign.GovOrgFeignClient; import com.epmet.modules.group.dao.GroupMessageDao; import com.epmet.modules.group.dao.ResiGroupDao; @@ -58,7 +56,6 @@ import com.epmet.modules.group.entity.GroupMessageEntity; import com.epmet.modules.group.entity.ResiGroupEntity; import com.epmet.modules.group.entity.ResiGroupStatisticalEntity; import com.epmet.modules.group.redis.ResiGroupRedis; -import com.epmet.modules.member.dao.ResiGroupMemberDao; import com.epmet.modules.member.redis.ResiGroupMemberRedis; import com.epmet.modules.member.service.ResiGroupMemberService; import com.epmet.modules.topic.dao.ResiTopicAttachmentDao; @@ -84,7 +81,6 @@ import com.epmet.resi.group.dto.topic.result.MyAuditingListResultDTO; import com.epmet.resi.group.dto.topic.result.TopicAuditResultDTO; import com.epmet.send.SendMqMsgUtil; import com.google.common.base.CharMatcher; -import com.google.common.util.concurrent.ThreadFactoryBuilder; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -97,7 +93,6 @@ import org.springframework.transaction.annotation.Transactional; import java.text.SimpleDateFormat; import java.util.*; -import java.util.concurrent.*; import java.util.stream.Collectors; /** @@ -111,11 +106,6 @@ import java.util.stream.Collectors; public class TopicDraftServiceImpl extends BaseServiceImpl implements TopicDraftService { private static Logger logger = LoggerFactory.getLogger(TopicDraftServiceImpl.class); - private ThreadFactory namedThreadFactory = new ThreadFactoryBuilder() - .setNameFormat("TopicDraftService-pool-%d").build(); - private ExecutorService threadPool = new ThreadPoolExecutor(1, 1, - 1L, TimeUnit.MINUTES, - new LinkedBlockingQueue<>(500), namedThreadFactory, new ThreadPoolExecutor.CallerRunsPolicy()); @Autowired private GovOrgOpenFeignClient govOrgOpenFeignClient; @Autowired @@ -125,12 +115,8 @@ public class TopicDraftServiceImpl extends BaseServiceImpl imageList; - + /** + * 分类名称 + */ + private String categoryName; + private String categoryId; } \ No newline at end of file diff --git a/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/form/AddStyleCategoryFormDTO.java b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/form/AddStyleCategoryFormDTO.java new file mode 100644 index 0000000000..729b9fb731 --- /dev/null +++ b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/form/AddStyleCategoryFormDTO.java @@ -0,0 +1,36 @@ +package com.epmet.resi.partymember.dto.partymember.form; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * 【党员风采分类】添加或修改分类 + */ +@Data +public class AddStyleCategoryFormDTO implements Serializable { + public interface AddUserInternalGroup { + } + + public interface AddUserShowGroup extends CustomerClientShowGroup { + } + + @NotBlank(message = "customerId不能为空", groups = AddUserInternalGroup.class) + private String customerId; + + /** + * 分类名称 + */ + @NotBlank(message = "分类名称不能为空", groups = AddUserShowGroup.class) + @Length(max = 10, groups = AddUserShowGroup.class) + private String categoryName; + + /** + * 主键 + */ + private String categoryId; + +} diff --git a/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/form/PartyMemberStyleFormDTO.java b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/form/PartyMemberStyleFormDTO.java index 6cedb15c89..40edfb678a 100644 --- a/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/form/PartyMemberStyleFormDTO.java +++ b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/form/PartyMemberStyleFormDTO.java @@ -22,4 +22,5 @@ public class PartyMemberStyleFormDTO implements Serializable { private String mainDeed; private Integer pageNo; private Integer pageSize; + private String categoryId; } diff --git a/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/form/StyleCategoryCommonFormDTO.java b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/form/StyleCategoryCommonFormDTO.java new file mode 100644 index 0000000000..a575b8a6dc --- /dev/null +++ b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/form/StyleCategoryCommonFormDTO.java @@ -0,0 +1,15 @@ +package com.epmet.resi.partymember.dto.partymember.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + + +@Data +public class StyleCategoryCommonFormDTO implements Serializable { + private static final long serialVersionUID = -291713921309878763L; + public interface AddUserInternalGroup {} + @NotBlank(message = "customerId不能为空",groups = AddUserInternalGroup.class) + private String customerId; +} diff --git a/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/form/StyleSelectListFormDTO.java b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/form/StyleSelectListFormDTO.java new file mode 100644 index 0000000000..ee39dcbf74 --- /dev/null +++ b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/form/StyleSelectListFormDTO.java @@ -0,0 +1,21 @@ +package com.epmet.resi.partymember.dto.partymember.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + + +@Data +public class StyleSelectListFormDTO implements Serializable { + + public interface AddUserInternalGroup {} + @NotBlank(message = "customerId不能为空",groups = AddUserInternalGroup.class) + private String customerId; + + /** + * query:查询条件用;新增或者编辑:addorupdate + */ + @NotBlank(message = "type不能为空",groups = AddUserInternalGroup.class) + private String type; +} diff --git a/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/form/StyleShowListFormDTO.java b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/form/StyleShowListFormDTO.java new file mode 100644 index 0000000000..20b188919a --- /dev/null +++ b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/form/StyleShowListFormDTO.java @@ -0,0 +1,23 @@ +package com.epmet.resi.partymember.dto.partymember.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +@Data +public class StyleShowListFormDTO implements Serializable { + public interface AddUserInternalGroup { + } + + @NotBlank(message = "userId不能为空", groups = AddUserInternalGroup.class) + private String userId; + @NotBlank(message = "customerId不能为空", groups = AddUserInternalGroup.class) + private String customerId; + + @NotNull(message = "pageNo不能为空", groups = AddUserInternalGroup.class) + private Integer pageNo; + @NotNull(message = "pageSize不能为空", groups = AddUserInternalGroup.class) + private Integer pageSize; +} diff --git a/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/form/UpdateStyleCategoryFormDTO.java b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/form/UpdateStyleCategoryFormDTO.java new file mode 100644 index 0000000000..0eae2aa4af --- /dev/null +++ b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/form/UpdateStyleCategoryFormDTO.java @@ -0,0 +1,30 @@ +package com.epmet.resi.partymember.dto.partymember.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; + + +@Data +public class UpdateStyleCategoryFormDTO implements Serializable { + public interface DeleteInternalGroup { + } + public interface UpdateStatusInternalGroup { + } + /** + * 主键 + */ + @NotBlank(message = "categoryId不能为空", groups = {DeleteInternalGroup.class,UpdateStatusInternalGroup.class}) + private String categoryId; + + /** + * 0:可用;1:被禁用。默认0 + */ + @NotNull(message = "beDisabled不能为空", groups = {UpdateStatusInternalGroup.class}) + private Boolean beDisabled; + + + private String userId; +} diff --git a/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/result/StyleCategoryDictResDTO.java b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/result/StyleCategoryDictResDTO.java new file mode 100644 index 0000000000..3c8767503d --- /dev/null +++ b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partymember/result/StyleCategoryDictResDTO.java @@ -0,0 +1,27 @@ +package com.epmet.resi.partymember.dto.partymember.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 【党员风采分类】列表查询 + */ +@Data +public class StyleCategoryDictResDTO implements Serializable { + /** + * 主键 + */ + private String categoryId; + + /** + * 分类名称 + */ + private String categoryName; + + /** + * 0:可用;1:被禁用。默认0 + */ + private Boolean beDisabled; + +} diff --git a/epmet-module/resi-partymember/resi-partymember-server/pom.xml b/epmet-module/resi-partymember/resi-partymember-server/pom.xml index 4c7c11b2fd..462586a0b6 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/pom.xml +++ b/epmet-module/resi-partymember/resi-partymember-server/pom.xml @@ -93,6 +93,18 @@ 2.0.0 compile + + com.epmet + common-service-client + 2.0.0 + compile + + + com.epmet + epmet-oss-client + 2.0.0 + compile + diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/IcPartymemberStyleCategoryDictController.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/IcPartymemberStyleCategoryDictController.java new file mode 100644 index 0000000000..e1212d5e56 --- /dev/null +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/IcPartymemberStyleCategoryDictController.java @@ -0,0 +1,101 @@ +package com.epmet.modules.partymember.controller; + +import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.modules.partymember.service.IcPartymemberStyleCategoryDictService; +import com.epmet.resi.partymember.dto.partymember.form.AddStyleCategoryFormDTO; +import com.epmet.resi.partymember.dto.partymember.form.StyleCategoryCommonFormDTO; +import com.epmet.resi.partymember.dto.partymember.form.StyleSelectListFormDTO; +import com.epmet.resi.partymember.dto.partymember.form.UpdateStyleCategoryFormDTO; +import com.epmet.resi.partymember.dto.partymember.result.StyleCategoryDictResDTO; +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 2022-02-12 + */ +@RestController +@RequestMapping("stylecategorydict") +public class IcPartymemberStyleCategoryDictController { + + @Autowired + private IcPartymemberStyleCategoryDictService icPartymemberStyleCategoryDictService; + + /** + * 【党员风采分类】列表查询 + * @param formDTO + * @return + */ + @PostMapping("list") + public Result> list(@RequestBody StyleCategoryCommonFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO,StyleCategoryCommonFormDTO.AddUserInternalGroup.class); + return new Result>().ok(icPartymemberStyleCategoryDictService.queryList(formDTO.getCustomerId())); + } + + /** + * 【党员风采分类】添加或修改分类 + * @param formDTO + * @return + */ + @PostMapping("addorupdate") + public Result addOrUpdate(@RequestBody AddStyleCategoryFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO, AddStyleCategoryFormDTO.AddUserInternalGroup.class,AddStyleCategoryFormDTO.AddUserShowGroup.class); + icPartymemberStyleCategoryDictService.addOrUpdate(formDTO); + return new Result(); + } + + /** + * 【党员风采分类】删除分类:删除的分类如果已经使用过,清空已经使用的记录,修改时需要重新选择, + * @param formDTO + * @return + */ + @PostMapping("delete") + public Result delete(@LoginUser TokenDto tokenDto, @RequestBody UpdateStyleCategoryFormDTO formDTO){ + formDTO.setUserId(tokenDto.getUserId()); + ValidatorUtils.validateEntity(formDTO,UpdateStyleCategoryFormDTO.DeleteInternalGroup.class); + icPartymemberStyleCategoryDictService.delete(formDTO); + return new Result(); + } + + /** + * 【党员风采分类】启用或禁用 + * @param tokenDto + * @param formDTO + * @return + */ + @PostMapping("updatestatus") + public Result updateStatus(@LoginUser TokenDto tokenDto, @RequestBody UpdateStyleCategoryFormDTO formDTO){ + formDTO.setUserId(tokenDto.getUserId()); + ValidatorUtils.validateEntity(formDTO,UpdateStyleCategoryFormDTO.UpdateStatusInternalGroup.class); + icPartymemberStyleCategoryDictService.updateStatus(formDTO); + return new Result(); + } + + /** + * 党员风采-分类下拉框 + * 查询条件中:展示所有未删除的 + * 新增活修改党员风采:展示可用的 + * + * @param formDTO + * @return + */ + @PostMapping("select-list") + public Result> list(@RequestBody StyleSelectListFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, StyleSelectListFormDTO.AddUserInternalGroup.class); + return new Result>().ok(icPartymemberStyleCategoryDictService.selectList(formDTO)); + } + + + +} \ No newline at end of file diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/IcPartymemberStyleController.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/IcPartymemberStyleController.java index cadf703b2c..b99c297700 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/IcPartymemberStyleController.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/IcPartymemberStyleController.java @@ -17,9 +17,11 @@ package com.epmet.modules.partymember.controller; +import com.baomidou.mybatisplus.extension.api.R; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.aop.NoRepeatSubmit; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ExcelUtils; @@ -27,13 +29,20 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.constants.ImportTaskConstants; +import com.epmet.dto.form.ImportTaskCommonFormDTO; +import com.epmet.dto.result.ImportTaskCommonResultDTO; +import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.modules.partymember.excel.IcPartymemberStyleExcel; import com.epmet.modules.partymember.service.IcPartymemberStyleService; import com.epmet.resi.partymember.dto.partymember.IcPartymemberStyleDTO; import com.epmet.resi.partymember.dto.partymember.form.PartyMemberStyleFormDTO; +import com.epmet.resi.partymember.dto.partymember.form.StyleShowListFormDTO; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.io.FilenameUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -59,6 +68,8 @@ public class IcPartymemberStyleController { @Autowired private IcPartymemberStyleService icPartymemberStyleService; + @Autowired + private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient; @GetMapping("page") public Result> page(@RequestParam Map params){ @@ -100,6 +111,8 @@ public class IcPartymemberStyleController { excel.setGridName(item.getGridName()); excel.setName(item.getName()); excel.setMainDeed(item.getMainDeed()); + //导出时新增分类名称 + excel.setCategoryName(item.getCategoryName()); return excel; }).collect(Collectors.toList()); } @@ -113,8 +126,39 @@ public class IcPartymemberStyleController { } @PostMapping("import") + //service方法是异步的,需要事务注解加在被调用方 否则事务不起作用 + @Transactional(rollbackFor = Exception.class) public Result importData(@LoginUser TokenDto tokenDto, HttpServletResponse response, @RequestPart("file") MultipartFile file) throws IOException { - return icPartymemberStyleService.importData(tokenDto, response, file); + // 校验文件类型 + String extension = FilenameUtils.getExtension(file.getOriginalFilename()); + if (!"xls".equals(extension) && !"xlsx".equals(extension)) { + throw new RenException("文件类型不匹配"); + } + //1.查询当前工作人员是否有再导入的党员先锋数据,有则不允许导入,没有则进行新的导入 + ImportTaskCommonFormDTO importTaskForm = new ImportTaskCommonFormDTO(); + importTaskForm.setOriginFileName(file.getOriginalFilename()); + importTaskForm.setOperatorId(tokenDto.getUserId()); + importTaskForm.setBizType(ImportTaskConstants.BIZ_TYPE_PARTY_MEMBER); + Result result = commonServiceOpenFeignClient.createImportTask(importTaskForm); + if (!result.success()) { + throw new RenException(result.getInternalMsg()); + } + //2.执行导入程序 + icPartymemberStyleService.importData(tokenDto, response, file, result.getData().getTaskId()); + + return new Result(); } + /** + * 数据分析-党员风采列表查询 + * @param tokenDto + * @return + */ + @PostMapping("showlist") + public Result> showList(@LoginUser TokenDto tokenDto, @RequestBody StyleShowListFormDTO formDTO){ + formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setUserId(tokenDto.getUserId()); + ValidatorUtils.validateEntity(formDTO,StyleShowListFormDTO.AddUserInternalGroup.class); + return new Result>().ok(icPartymemberStyleService.showList(formDTO)); + } } \ No newline at end of file diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/dao/IcPartymemberStyleCategoryDictDao.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/dao/IcPartymemberStyleCategoryDictDao.java new file mode 100644 index 0000000000..cc768ad36c --- /dev/null +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/dao/IcPartymemberStyleCategoryDictDao.java @@ -0,0 +1,20 @@ +package com.epmet.modules.partymember.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.modules.partymember.entity.IcPartymemberStyleCategoryDictEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * 党员风采分类字典表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-02-12 + */ +@Mapper +public interface IcPartymemberStyleCategoryDictDao extends BaseDao { + + Integer getMaxCategoryCode(String customerId); + + int updateToDel(@Param("categoryId") String categoryId,@Param("userId") String userId); +} \ No newline at end of file diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/dao/IcPartymemberStyleDao.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/dao/IcPartymemberStyleDao.java index de5966a068..cd78d48284 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/dao/IcPartymemberStyleDao.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/dao/IcPartymemberStyleDao.java @@ -19,7 +19,11 @@ package com.epmet.modules.partymember.dao; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.modules.partymember.entity.IcPartymemberStyleEntity; +import com.epmet.resi.partymember.dto.partymember.IcPartymemberStyleDTO; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 党员风采 @@ -29,5 +33,8 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface IcPartymemberStyleDao extends BaseDao { - + + int clearCategry(@Param("categoryId") String categoryId, @Param("userId")String userId); + + List selectShowList(@Param("agencyId")String agencyId, @Param("customerId")String customerId); } \ No newline at end of file diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/entity/IcPartymemberStyleCategoryDictEntity.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/entity/IcPartymemberStyleCategoryDictEntity.java new file mode 100644 index 0000000000..73c469dc82 --- /dev/null +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/entity/IcPartymemberStyleCategoryDictEntity.java @@ -0,0 +1,66 @@ +package com.epmet.modules.partymember.entity; + +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 2022-02-12 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("ic_partymember_style_category_dict") +public class IcPartymemberStyleCategoryDictEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户id + */ + private String customerId; + + /** + * 上级分类ID 顶级此列存储0 + */ + private String pid; + + /** + * 所有上级分类ID英文顿号隔开,顶级此列存储0 + */ + private String pids; + + /** + * 分类编码,分类编码+customer_id唯一;从1000开始 + */ + private String categoryCode; + + /** + * 上级分类编码 + */ + private String parentCategoryCode; + + /** + * 分类名称 + */ + private String categoryName; + + /** + * 分类级别1,2,3,4.... 目前只有一级 + */ + private Integer level; + + /** + * 排序 + */ + private Integer sort; + + /** + * 0:可用;1:被禁用。默认0 + */ + private Boolean beDisabled; + +} diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/entity/IcPartymemberStyleEntity.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/entity/IcPartymemberStyleEntity.java index ad3e4afe9e..fea632569a 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/entity/IcPartymemberStyleEntity.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/entity/IcPartymemberStyleEntity.java @@ -50,6 +50,11 @@ public class IcPartymemberStyleEntity extends BaseEpmetEntity { */ private String gridId; + /** + * 网格的所有上级 + */ + private String gridPids; + /** * 党员姓名 */ @@ -59,5 +64,6 @@ public class IcPartymemberStyleEntity extends BaseEpmetEntity { * 主要事迹 */ private String mainDeed; - + private String categoryId; + private String categoryCode; } diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/excel/IcPartymemberStyleExcel.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/excel/IcPartymemberStyleExcel.java index a64decdd9c..108a49b1cf 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/excel/IcPartymemberStyleExcel.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/excel/IcPartymemberStyleExcel.java @@ -40,4 +40,7 @@ public class IcPartymemberStyleExcel { @Excel(name = "主要事迹") private String mainDeed; + + @Excel(name="所属分类") + private String categoryName; } \ No newline at end of file diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/excel/IcPartymemberStyleImportExcel.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/excel/IcPartymemberStyleImportExcel.java index fa48ae5b34..38da34f534 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/excel/IcPartymemberStyleImportExcel.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/excel/IcPartymemberStyleImportExcel.java @@ -21,8 +21,10 @@ import cn.afterturn.easypoi.excel.annotation.Excel; import com.epmet.commons.tools.utils.ExcelVerifyInfo; import lombok.Data; +import javax.validation.constraints.NotBlank; + /** - * 党员风采 + * 党员风采导入 * * @author generator generator@elink-cn.com * @since v1.0.0 2021-11-18 @@ -31,14 +33,18 @@ import lombok.Data; public class IcPartymemberStyleImportExcel extends ExcelVerifyInfo { @Excel(name = "所属网格") + @NotBlank(message = "此列不能为空") private String gridName; @Excel(name = "党员姓名") + @NotBlank(message = "此列不能为空") private String name; @Excel(name = "主要事迹") + @NotBlank(message = "此列不能为空") private String mainDeed; - @Excel(name = "照片") - private String imageUrl; + @Excel(name="所属分类") + @NotBlank(message = "此列不能为空") + private String categoryName; } \ No newline at end of file diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/excel/PartyMemberImportExcel.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/excel/PartyMemberImportExcel.java new file mode 100644 index 0000000000..40bd4946ec --- /dev/null +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/excel/PartyMemberImportExcel.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.modules.partymember.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +/** + * 党员风采导入错误数据存放文件 + * @author sun + */ +@Data +public class PartyMemberImportExcel { + + @Excel(name = "所属网格", width = 30) + private String gridName; + @Excel(name = "党员姓名", width = 20) + private String name; + @Excel(name = "主要事迹", width = 30) + private String mainDeed; + @Excel(name = "所属分类", width = 30) + private String categoryName; + @Excel(name = "错误信息", width = 40) + private String errorInfo; +} \ No newline at end of file diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/IcPartymemberStyleCategoryDictService.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/IcPartymemberStyleCategoryDictService.java new file mode 100644 index 0000000000..1cbad15a09 --- /dev/null +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/IcPartymemberStyleCategoryDictService.java @@ -0,0 +1,57 @@ +package com.epmet.modules.partymember.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.modules.partymember.entity.IcPartymemberStyleCategoryDictEntity; +import com.epmet.resi.partymember.dto.partymember.form.AddStyleCategoryFormDTO; +import com.epmet.resi.partymember.dto.partymember.form.StyleSelectListFormDTO; +import com.epmet.resi.partymember.dto.partymember.form.UpdateStyleCategoryFormDTO; +import com.epmet.resi.partymember.dto.partymember.result.StyleCategoryDictResDTO; + +import java.util.List; +import java.util.Map; + +/** + * 党员风采分类字典表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-02-12 + */ +public interface IcPartymemberStyleCategoryDictService extends BaseService { + + /** + * 【党员风采分类】列表查询 + * @param customerId + * @return + */ + List queryList(String customerId); + + /** + * 党员风采分类】添加或修改分类 + * @param formDTO + */ + void addOrUpdate(AddStyleCategoryFormDTO formDTO); + + /** + * 删除的分类如果已经使用过,清空已经使用的记录,修改时需要重新选择, + * @param formDTO + */ + void delete(UpdateStyleCategoryFormDTO formDTO); + + /** + * 【党员风采分类】启用或禁用 + * 新增党员风采时不显示已经禁用的分类,已经使用了禁用的分类正常显示, + * @param formDTO + */ + void updateStatus(UpdateStyleCategoryFormDTO formDTO); + + /** + * 党员风采-分类下拉框 + * @param formDTO + * @return + */ + List selectList(StyleSelectListFormDTO formDTO); + + IcPartymemberStyleCategoryDictEntity get(String categoryId); + + Map getCategoryDictMap(String customerId); +} \ No newline at end of file diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/IcPartymemberStyleService.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/IcPartymemberStyleService.java index fb4c6e1800..533cb59262 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/IcPartymemberStyleService.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/IcPartymemberStyleService.java @@ -24,6 +24,7 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.modules.partymember.entity.IcPartymemberStyleEntity; import com.epmet.resi.partymember.dto.partymember.IcPartymemberStyleDTO; import com.epmet.resi.partymember.dto.partymember.form.PartyMemberStyleFormDTO; +import com.epmet.resi.partymember.dto.partymember.form.StyleShowListFormDTO; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; @@ -107,6 +108,12 @@ public interface IcPartymemberStyleService extends BaseService showList(StyleShowListFormDTO formDTO); } \ No newline at end of file diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/IcPartymemberStyleCategoryDictServiceImpl.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/IcPartymemberStyleCategoryDictServiceImpl.java new file mode 100644 index 0000000000..39e34e4c61 --- /dev/null +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/IcPartymemberStyleCategoryDictServiceImpl.java @@ -0,0 +1,183 @@ +package com.epmet.modules.partymember.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.modules.partymember.dao.IcPartymemberStyleCategoryDictDao; +import com.epmet.modules.partymember.dao.IcPartymemberStyleDao; +import com.epmet.modules.partymember.entity.IcPartymemberStyleCategoryDictEntity; +import com.epmet.modules.partymember.service.IcPartymemberStyleCategoryDictService; +import com.epmet.resi.partymember.dto.partymember.form.AddStyleCategoryFormDTO; +import com.epmet.resi.partymember.dto.partymember.form.StyleSelectListFormDTO; +import com.epmet.resi.partymember.dto.partymember.form.UpdateStyleCategoryFormDTO; +import com.epmet.resi.partymember.dto.partymember.result.StyleCategoryDictResDTO; +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.*; +import java.util.stream.Collectors; + +/** + * 党员风采分类字典表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-02-12 + */ +@Service +public class IcPartymemberStyleCategoryDictServiceImpl extends BaseServiceImpl implements IcPartymemberStyleCategoryDictService { + + @Autowired + private IcPartymemberStyleDao icPartymemberStyleDao; + + /** + * 【党员风采分类】列表查询 + * + * @param customerId + * @return + */ + @Override + public List queryList(String customerId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(IcPartymemberStyleCategoryDictEntity::getCustomerId, customerId); + queryWrapper.orderByDesc(IcPartymemberStyleCategoryDictEntity::getSort); + List list = baseDao.selectList(queryWrapper); + List resultList = new ArrayList<>(); + for (IcPartymemberStyleCategoryDictEntity entity : list) { + StyleCategoryDictResDTO resDTO = new StyleCategoryDictResDTO(); + resDTO.setCategoryId(entity.getId()); + resDTO.setCategoryName(entity.getCategoryName()); + resDTO.setBeDisabled(entity.getBeDisabled()); + resultList.add(resDTO); + } + return resultList; + } + + /** + * 党员风采分类】添加或修改分类 + * + * @param formDTO + */ + @Transactional(rollbackFor = Exception.class) + @Override + public void addOrUpdate(AddStyleCategoryFormDTO formDTO) { + //校验分类名称是否唯一 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(IcPartymemberStyleCategoryDictEntity::getCustomerId, formDTO.getCustomerId()) + .eq(IcPartymemberStyleCategoryDictEntity::getCategoryName, formDTO.getCategoryName()) + .ne(StringUtils.isNotBlank(formDTO.getCategoryId()), IcPartymemberStyleCategoryDictEntity::getId, formDTO.getCategoryId()); + Integer cout = baseDao.selectCount(queryWrapper); + if (cout > NumConstant.ZERO) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "分类名称已存在", "分类名称已存在"); + } + if (StringUtils.isNotBlank(formDTO.getCategoryId())) { + //更新分类名称 + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.set(IcPartymemberStyleCategoryDictEntity::getCategoryName, formDTO.getCategoryName()); + updateWrapper.eq(IcPartymemberStyleCategoryDictEntity::getId, formDTO.getCategoryId()); + baseDao.update(null, updateWrapper); + return; + } + IcPartymemberStyleCategoryDictEntity insert = new IcPartymemberStyleCategoryDictEntity(); + insert.setCategoryName(formDTO.getCategoryName()); + insert.setCustomerId(formDTO.getCustomerId()); + insert.setPid(NumConstant.ZERO_STR); + insert.setPids(NumConstant.ZERO_STR); + // 查询 当前客户下最大的一级分类数。 + Integer maxCategoryCode = baseDao.getMaxCategoryCode(formDTO.getCustomerId()); + if (NumConstant.ZERO == maxCategoryCode) { + maxCategoryCode = 1001; + } else { + maxCategoryCode++; + } + insert.setCategoryCode(String.valueOf(maxCategoryCode)); + insert.setParentCategoryCode(NumConstant.ZERO_STR); + insert.setLevel(NumConstant.ONE); + + LambdaQueryWrapper maxSortWrapper = new LambdaQueryWrapper<>(); + maxSortWrapper.eq(IcPartymemberStyleCategoryDictEntity::getCustomerId, formDTO.getCustomerId()) + .orderByDesc(IcPartymemberStyleCategoryDictEntity::getSort).last("limit 1"); + IcPartymemberStyleCategoryDictEntity max = baseDao.selectOne(maxSortWrapper); + insert.setSort(null == max ? NumConstant.ONE : max.getSort() + NumConstant.ONE); + insert.setBeDisabled(false); + baseDao.insert(insert); + } + + /** + * 删除的分类如果已经使用过,清空已经使用的记录,修改时需要重新选择, + * + * @param formDTO + */ + @Transactional(rollbackFor = Exception.class) + @Override + public void delete(UpdateStyleCategoryFormDTO formDTO) { + baseDao.updateToDel(formDTO.getCategoryId(),formDTO.getUserId()); + icPartymemberStyleDao.clearCategry(formDTO.getCategoryId(),formDTO.getUserId()); + } + + /** + * 【党员风采分类】启用或禁用 + * 新增党员风采时不显示已经禁用的分类,已经使用了禁用的分类正常显示, + * + * @param formDTO + */ + @Override + public void updateStatus(UpdateStyleCategoryFormDTO formDTO) { + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.set(IcPartymemberStyleCategoryDictEntity::getBeDisabled, formDTO.getBeDisabled()) + .set(IcPartymemberStyleCategoryDictEntity::getUpdatedBy, formDTO.getUserId()) + .set(IcPartymemberStyleCategoryDictEntity::getUpdatedTime, new Date()); + updateWrapper.eq(IcPartymemberStyleCategoryDictEntity::getId, formDTO.getCategoryId()); + baseDao.update(null, updateWrapper); + } + + /** + * 党员风采-分类下拉框 + * + * @param formDTO + * @return + */ + @Override + public List selectList(StyleSelectListFormDTO formDTO) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(IcPartymemberStyleCategoryDictEntity::getCustomerId, formDTO.getCustomerId()); + if("addorupdate".equals(formDTO.getType())){ + //查询可用的 + queryWrapper.eq(IcPartymemberStyleCategoryDictEntity::getBeDisabled,false); + } + queryWrapper.orderByAsc(IcPartymemberStyleCategoryDictEntity::getSort); + List list = baseDao.selectList(queryWrapper); + List resultList = new ArrayList<>(); + for (IcPartymemberStyleCategoryDictEntity entity : list) { + StyleCategoryDictResDTO resDTO = new StyleCategoryDictResDTO(); + resDTO.setCategoryId(entity.getId()); + resDTO.setCategoryName(entity.getCategoryName()); + resDTO.setBeDisabled(entity.getBeDisabled()); + resultList.add(resDTO); + } + return resultList; + } + + @Override + public IcPartymemberStyleCategoryDictEntity get(String categoryId) { + return baseDao.selectById(categoryId); + } + + @Override + public Map getCategoryDictMap(String customerId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(IcPartymemberStyleCategoryDictEntity::getCustomerId, customerId); + List list=baseDao.selectList(queryWrapper); + Map map=new HashMap<>(); + if(!CollectionUtils.isEmpty(list)){ + map=list.stream().collect(Collectors.toMap(IcPartymemberStyleCategoryDictEntity::getCategoryName, m -> m, (k1, k2) -> k1)); + } + return map; + } + +} \ No newline at end of file diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/IcPartymemberStyleServiceImpl.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/IcPartymemberStyleServiceImpl.java index f02233a520..6c16610b6c 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/IcPartymemberStyleServiceImpl.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/IcPartymemberStyleServiceImpl.java @@ -17,6 +17,8 @@ package com.epmet.modules.partymember.service.impl; +import cn.afterturn.easypoi.excel.ExcelExportUtil; +import cn.afterturn.easypoi.excel.entity.ExportParams; import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -26,7 +28,10 @@ import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; +import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.redis.common.CustomerOrgRedis; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; @@ -35,29 +40,48 @@ import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ExcelPoiUtils; import com.epmet.commons.tools.utils.Result; +import com.epmet.constants.ImportTaskConstants; import com.epmet.dto.CustomerGridDTO; import com.epmet.dto.form.GridOptionFormDTO; +import com.epmet.dto.form.ImportTaskCommonFormDTO; +import com.epmet.dto.result.UploadImgResultDTO; +import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.feign.GovOrgOpenFeignClient; +import com.epmet.feign.OssFeignClient; import com.epmet.modules.partymember.dao.IcPartymemberStyleDao; +import com.epmet.modules.partymember.entity.IcPartymemberStyleCategoryDictEntity; import com.epmet.modules.partymember.entity.IcPartymemberStyleEntity; import com.epmet.modules.partymember.entity.IcPartymemberStyleImageEntity; import com.epmet.modules.partymember.excel.IcPartymemberStyleImportExcel; +import com.epmet.modules.partymember.excel.PartyMemberImportExcel; +import com.epmet.modules.partymember.service.IcPartymemberStyleCategoryDictService; import com.epmet.modules.partymember.service.IcPartymemberStyleImageService; import com.epmet.modules.partymember.service.IcPartymemberStyleService; import com.epmet.resi.partymember.dto.partymember.IcPartymemberStyleDTO; import com.epmet.resi.partymember.dto.partymember.form.PartyMemberStyleFormDTO; +import com.epmet.resi.partymember.dto.partymember.form.StyleShowListFormDTO; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.FileItemFactory; +import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.lang3.StringUtils; +import org.apache.http.entity.ContentType; +import org.apache.poi.ss.usermodel.Workbook; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Async; +import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.commons.CommonsMultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import java.io.OutputStream; import java.util.*; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; @@ -70,12 +94,19 @@ import java.util.stream.Collectors; */ @Slf4j @Service +@EnableAsync public class IcPartymemberStyleServiceImpl extends BaseServiceImpl implements IcPartymemberStyleService { @Resource private IcPartymemberStyleImageService icPartymemberStyleImageService; @Resource private GovOrgOpenFeignClient govOrgOpenFeignClient; + @Resource + private IcPartymemberStyleCategoryDictService icPartymemberStyleCategoryDictService; + @Autowired + private OssFeignClient ossFeignClient; + @Autowired + private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient; @Override public PageData page(Map params) { @@ -105,6 +136,9 @@ public class IcPartymemberStyleServiceImpl extends BaseServiceImpl list = baseDao.selectList(wrapper); PageInfo pageInfo = new PageInfo<>(list); List dtoList = ConvertUtils.sourceToTarget(list, IcPartymemberStyleDTO.class); @@ -200,6 +239,8 @@ public class IcPartymemberStyleServiceImpl extends BaseServiceImpl(dtoList, pageInfo.getTotal()); @@ -216,86 +257,216 @@ public class IcPartymemberStyleServiceImpl extends BaseServiceImpl importResult = ExcelPoiUtils.importExcelMore(file, 0, 1, IcPartymemberStyleImportExcel.class); - List failList = importResult.getFailList(); - //存放错误数据行号 - List numList = new ArrayList<>(); - if (!org.springframework.util.CollectionUtils.isEmpty(failList)) { - for (IcPartymemberStyleImportExcel entity : failList) { - //打印失败的行 和失败的信息 - log.warn("第{}行,{}", entity.getRowNum(), entity.getErrorMsg()); - numList.add(entity.getRowNum()); + //@Transactional(rollbackFor = Exception.class) + @Async + public void importData(TokenDto tokenDto, HttpServletResponse response, MultipartFile file, String taskId) { + try { + log.info("党员风采导入,子线程开始执行"); + List fileList = new ArrayList<>(); + PartyMemberImportExcel excel = null; + ExcelImportResult importResult = ExcelPoiUtils.importExcelMore(file, 0, 1, IcPartymemberStyleImportExcel.class); + + List failList = importResult.getFailList(); + //存放错误数据行号 + List numList = new ArrayList<>(); + if (!org.springframework.util.CollectionUtils.isEmpty(failList)) { + for (IcPartymemberStyleImportExcel entity : failList) { + //打印失败的行 和失败的信息 + log.warn("第{}行,{}", entity.getRowNum(), entity.getErrorMsg()); + numList.add(entity.getRowNum()); + excel = new PartyMemberImportExcel(); + excel.setGridName(entity.getGridName()); + excel.setName(entity.getName()); + excel.setMainDeed(entity.getMainDeed()); + excel.setCategoryName(entity.getCategoryName()); + excel.setErrorInfo(entity.getErrorMsg()); + fileList.add(excel); + } } - } - List result = importResult.getList(); + List result = importResult.getList(); - CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId()); - //获取组织下网格信息 - GridOptionFormDTO formDTO = new GridOptionFormDTO(); - formDTO.setAgencyId(staffInfoCache.getAgencyId()); - Result> gridOptionResult = govOrgOpenFeignClient.getGridIListByAgency(staffInfoCache.getAgencyId()); - if (!gridOptionResult.success()) { - throw new EpmetException(gridOptionResult.getCode(), gridOptionResult.getMsg()); - } - Map gridMap = gridOptionResult.getData().stream().collect(Collectors.toMap(CustomerGridDTO::getGridName, CustomerGridDTO::getId)); - //1.数据校验 只允许导入当前组织下的网格的数据 - //网格名称不一样的数据舍弃 - Iterator iterator = result.iterator(); - while (iterator.hasNext()) { - IcPartymemberStyleImportExcel obj = iterator.next(); - if (null == gridMap.get(obj.getGridName().trim())) { - numList.add(obj.getRowNum()); - log.warn(String.format("不是当前组织下可导入的数据,网格名称->%s,行号->%s", obj.getGridName(), obj.getRowNum())); - iterator.remove(); + CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId()); + //获取组织下网格信息 + GridOptionFormDTO formDTO = new GridOptionFormDTO(); + formDTO.setAgencyId(staffInfoCache.getAgencyId()); + Result> gridOptionResult = govOrgOpenFeignClient.getGridIListByAgency(staffInfoCache.getAgencyId()); + if (!gridOptionResult.success()) { + throw new EpmetException(gridOptionResult.getCode(), gridOptionResult.getMsg()); } + Map gridMap = gridOptionResult.getData().stream().collect(Collectors.toMap(CustomerGridDTO::getGridName, CustomerGridDTO::getId)); + //获取党员风采所有分类:key:分类名称; + Map categoryDictMap=icPartymemberStyleCategoryDictService.getCategoryDictMap(tokenDto.getCustomerId()); + //1.数据校验 只允许导入当前组织下的网格的数据 + //网格名称不一样的数据舍弃或者分类名称不存在也舍弃 + Iterator iterator = result.iterator(); + while (iterator.hasNext()) { + IcPartymemberStyleImportExcel obj = iterator.next(); + if (null == gridMap.get(obj.getGridName().trim())) { + numList.add(obj.getRowNum()); + log.warn(String.format("不是当前组织下可导入的数据,网格名称->%s,行号->%s", obj.getGridName(), obj.getRowNum())); + excel = new PartyMemberImportExcel(); + excel.setGridName(obj.getGridName()); + excel.setName(obj.getName()); + excel.setMainDeed(obj.getMainDeed()); + excel.setCategoryName(obj.getCategoryName()); + excel.setErrorInfo("不是当前组织下网格"); + fileList.add(excel); + iterator.remove(); + continue; + } + if (null == categoryDictMap.get(obj.getCategoryName().trim())) { + numList.add(obj.getRowNum()); + log.warn(String.format("分类名称【%s】不存在,不可导入,行号->%s", obj.getCategoryName(), obj.getRowNum())); + excel = new PartyMemberImportExcel(); + excel.setGridName(obj.getGridName()); + excel.setName(obj.getName()); + excel.setMainDeed(obj.getMainDeed()); + excel.setCategoryName(obj.getCategoryName()); + excel.setErrorInfo("分类名称不存在"); + fileList.add(excel); + iterator.remove(); + } + } + /*if (CollectionUtils.isEmpty(result)) { + Collections.sort(numList); + String subList = numList.stream().map(String::valueOf).collect(Collectors.joining("、")); + return new Result().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "第" + subList + "行未成功!"); + }*/ + if (!CollectionUtils.isEmpty(result)) { + List imageList = new ArrayList<>(); + List list = result.stream().map(item -> { + IcPartymemberStyleEntity entity = new IcPartymemberStyleEntity(); + entity.setId(UUID.randomUUID().toString().replace("-", "")); + entity.setCustomerId(tokenDto.getCustomerId()); + entity.setAgencyId(staffInfoCache.getAgencyId()); + entity.setGridId(gridMap.get(item.getGridName())); + GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(entity.getGridId()); + if (null != gridInfo) { + entity.setGridPids(gridInfo.getPids()); + } + entity.setName(item.getName()); + entity.setMainDeed(item.getMainDeed()); + IcPartymemberStyleCategoryDictEntity dictEntity=categoryDictMap.get(item.getCategoryName()); + entity.setCategoryId(null == dictEntity ? StrConstant.EPMETY_STR : dictEntity.getId()); + entity.setCategoryCode(null == dictEntity ? StrConstant.EPMETY_STR : dictEntity.getCategoryCode()); + AtomicInteger i = new AtomicInteger(); + return entity; + }).collect(Collectors.toList()); + + insertBatch(list); + icPartymemberStyleImageService.insertBatch(imageList); + + /*String str = String.format("共%s条,成功导入%s条。", numList.size() + result.size(), numList.size() + result.size() - numList.size()); + if (numList.size() > NumConstant.ZERO) { + Collections.sort(numList); + String subList = numList.stream().map(String::valueOf).collect(Collectors.joining("、")); + log.warn(str + "第" + subList + "行未成功!"); + return new Result().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), str + "第" + subList + "行未成功!"); + } + return new Result().ok(str);*/ + } + //生成导入失败数据对应的文件,修改任务状态 + String url = erroeImport(fileList); + upImportTask(url, taskId, tokenDto.getUserId(), true); + } catch (Exception e) { + String errorMsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【党员风采信息导入】程序错误:{}", errorMsg); + upImportTask(null, taskId, tokenDto.getUserId(), false); } - if (CollectionUtils.isEmpty(result)) { - Collections.sort(numList); - String subList = numList.stream().map(String::valueOf).collect(Collectors.joining("、")); - return new Result().error(9999, "第" + subList + "行未成功!"); - } - List imageList = new ArrayList<>(); - List list = result.stream().map(item -> { - IcPartymemberStyleEntity entity = new IcPartymemberStyleEntity(); - entity.setId(UUID.randomUUID().toString().replace("-", "")); - entity.setCustomerId(tokenDto.getCustomerId()); - entity.setAgencyId(staffInfoCache.getAgencyId()); - entity.setGridId(gridMap.get(item.getGridName())); - entity.setName(item.getName()); - entity.setMainDeed(item.getMainDeed()); - AtomicInteger i = new AtomicInteger(); - if (StringUtils.isNotBlank(item.getImageUrl())) { - Arrays.asList(item.getImageUrl().split(StrConstant.COMMA)).forEach(url -> { - IcPartymemberStyleImageEntity urlEntity = new IcPartymemberStyleImageEntity(); - urlEntity.setImageUrl(url); - urlEntity.setCustomerId(tokenDto.getCustomerId()); - urlEntity.setStyleId(entity.getId()); - urlEntity.setSort(i.getAndIncrement()); - urlEntity.setRevision(NumConstant.ZERO); - urlEntity.setDelFlag(NumConstant.ZERO_STR); - urlEntity.setCreatedBy(tokenDto.getUserId()); - urlEntity.setUpdatedBy(tokenDto.getUserId()); - urlEntity.setCreatedTime(new Date()); - urlEntity.setUpdatedTime(new Date()); - imageList.add(urlEntity); - }); + } + + /** + * @Author sun + * @Description 党员风采导入,错误数据生成导入失败文件 + **/ + private String erroeImport(List fileList) throws IOException { + String url = ""; + //1.有错误数据则生成错误数据存放文件传到阿里云服务 + if (!org.springframework.util.CollectionUtils.isEmpty(fileList)) { + Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("导入失败的数据列表", "导入失败的数据列表"), + PartyMemberImportExcel.class, fileList); + + // 文件名 + String resultDescFileName = UUID.randomUUID().toString().concat(".xlsx"); + FileItemFactory factory = new DiskFileItemFactory(16, null); + FileItem fileItem = factory.createItem("file", ContentType.APPLICATION_OCTET_STREAM.toString(), true, resultDescFileName); + OutputStream os = fileItem.getOutputStream(); + Result uploadResult = null; + try { + workbook.write(os); + uploadResult = ossFeignClient.uploadImportTaskDescFile(new CommonsMultipartFile(fileItem)); + } catch (Exception e) { + String errormsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【党员风采信息导入】上传错误描述文件:{}", errormsg); + } finally { + try { + os.close(); + } catch (IOException e) { + String errormsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【党员风采信息导入】上传错误描述文件关闭输出流:{}", errormsg); + } + try { + fileItem.delete(); + } catch (Exception e) { + String errormsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【党员风采信息导入】上传错误描述文件删除临时文件:{}", errormsg); + } } - return entity; - }).collect(Collectors.toList()); - insertBatch(list); - icPartymemberStyleImageService.insertBatch(imageList); + if (uploadResult == null || !uploadResult.success()) { + log.error("【党员风采信息导入】调用OSS上传结果描述文件失败"); + } + url = uploadResult.getData().getUrl(); + } + return url; + } + /** + * @Author sun + * @Description 党员风采导入修改导入任务状态 + **/ + private void upImportTask(String url, String importTaskId, String staffId, Boolean status) { + //更新导入任务数据 + ImportTaskCommonFormDTO importTaskForm = new ImportTaskCommonFormDTO(); + importTaskForm.setOperatorId(staffId); + importTaskForm.setBizType(ImportTaskConstants.BIZ_TYPE_PARTY_MEMBER); + importTaskForm.setTaskId(importTaskId); + importTaskForm.setResultDescFilePath(url); + if (status && StringUtils.isBlank(url)) { + importTaskForm.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_SUCCESS); + } else { + importTaskForm.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL); + importTaskForm.setResultDesc("党员风采导入存在程序错误"); + } + Result result = commonServiceOpenFeignClient.finishImportTask(importTaskForm); + if (!result.success()) { + throw new RenException(result.getInternalMsg()); + } + } - String str = String.format("共%s条,成功导入%s条。", numList.size() + result.size(), numList.size() + result.size() - numList.size()); - if (numList.size() > NumConstant.ZERO) { - Collections.sort(numList); - String subList = numList.stream().map(String::valueOf).collect(Collectors.joining("、")); - log.warn(str + "第" + subList + "行未成功!"); - return new Result().error(9999, str + "第" + subList + "行未成功!"); + /** + * 数据分析-党员风采列表查询 + * + * @param formDTO + * @return + */ + @Override + public PageData showList(StyleShowListFormDTO formDTO) { + CustomerStaffInfoCacheResult staff = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getUserId()); + if (null == staff || StringUtils.isBlank(staff.getAgencyId())) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询当前工作人员缓存信息失败", "查询用户信息异常"); + } + PageInfo pageInfo = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()).doSelectPageInfo(() -> baseDao.selectShowList(staff.getAgencyId(), formDTO.getCustomerId())); + if (CollectionUtils.isNotEmpty(pageInfo.getList())) { + //赋值网格名称 + for (IcPartymemberStyleDTO dto : pageInfo.getList()) { + dto.setImageList(icPartymemberStyleImageService.getByStyleId(dto.getId())); + GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(dto.getGridId()); + if (null != gridInfo) { + dto.setGridName(gridInfo.getGridName()); + } + } } - return new Result().ok(str); + return new PageData<>(pageInfo.getList(), pageInfo.getTotal()); } -} \ No newline at end of file +} diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/db/migration/V0.0.2__style_dict.sql b/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/db/migration/V0.0.2__style_dict.sql new file mode 100644 index 0000000000..1881277a69 --- /dev/null +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/db/migration/V0.0.2__style_dict.sql @@ -0,0 +1,23 @@ +CREATE TABLE `ic_partymember_style_category_dict` ( + `ID` varchar(64) NOT NULL COMMENT '楼栋主键', + `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户id', + `PID` varchar(64) CHARACTER SET utf8 NOT NULL COMMENT '上级分类ID 顶级此列存储0', + `PIDS` varchar(512) CHARACTER SET utf8 NOT NULL COMMENT '所有上级分类ID英文顿号隔开,顶级此列存储0', + `CATEGORY_CODE` varchar(64) CHARACTER SET utf8 NOT NULL COMMENT '分类编码,分类编码+customer_id唯一;从1000开始', + `PARENT_CATEGORY_CODE` varchar(64) CHARACTER SET utf8 NOT NULL COMMENT '上级分类编码', + `CATEGORY_NAME` varchar(128) CHARACTER SET utf8 NOT NULL COMMENT '分类名称', + `LEVEL` int(10) NOT NULL COMMENT '分类级别1,2,3,4.... 目前只有一级', + `SORT` int(10) unsigned NOT NULL COMMENT '排序', + `BE_DISABLED` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0:可用;1:被禁用。默认0', + `DEL_FLAG` varchar(1) NOT NULL DEFAULT '0' COMMENT '删除标识 0未删除、1已删除', + `REVISION` int(11) NOT NULL DEFAULT '0' 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 '更新时间', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='党员风采分类字典表'; + + +alter table ic_partymember_style add COLUMN CATEGORY_ID VARCHAR(64) comment '分类主键' AFTER MAIN_DEED; +alter table ic_partymember_style add COLUMN CATEGORY_CODE VARCHAR(64) comment '分类编码' after CATEGORY_ID; diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/db/migration/V0.0.3__style_gridpids.sql b/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/db/migration/V0.0.3__style_gridpids.sql new file mode 100644 index 0000000000..aa3c561c66 --- /dev/null +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/db/migration/V0.0.3__style_gridpids.sql @@ -0,0 +1 @@ +alter table ic_partymember_style add COLUMN GRID_PIDS VARCHAR(255) comment '网格的所有上级' after GRID_ID; diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/mapper/partymember/IcPartymemberStyleCategoryDictDao.xml b/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/mapper/partymember/IcPartymemberStyleCategoryDictDao.xml new file mode 100644 index 0000000000..27d838e556 --- /dev/null +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/mapper/partymember/IcPartymemberStyleCategoryDictDao.xml @@ -0,0 +1,18 @@ + + + + + + + + + update ic_partymember_style_category_dict set del_flag='1',UPDATED_BY=#{userId},UPDATED_TIME=now() + where id=#{categoryId} + + \ No newline at end of file diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/mapper/partymember/IcPartymemberStyleDao.xml b/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/mapper/partymember/IcPartymemberStyleDao.xml index a8375fe173..e68586a288 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/mapper/partymember/IcPartymemberStyleDao.xml +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/mapper/partymember/IcPartymemberStyleDao.xml @@ -18,5 +18,29 @@ + + update ic_partymember_style + set CATEGORY_ID='',CATEGORY_CODE='',UPDATED_BY=#{userId},UPDATED_TIME=now() + where del_flag='0' + and CATEGORY_ID=#{categoryId} + + \ No newline at end of file diff --git a/epmet-openapi/epmet-openapi-scan/pom.xml b/epmet-openapi/epmet-openapi-scan/pom.xml index 289dd8a2f9..df86510504 100644 --- a/epmet-openapi/epmet-openapi-scan/pom.xml +++ b/epmet-openapi/epmet-openapi-scan/pom.xml @@ -107,6 +107,15 @@ true + + true + 5 + 8 + 20 + 60 + epmet-openapi-scan + callerRunsPolicy + https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4 @@ -142,6 +151,15 @@ false + + true + 5 + 8 + 20 + 60 + epmet-openapi-scan + callerRunsPolicy + https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4 @@ -172,6 +190,15 @@ true + + true + 5 + 8 + 20 + 60 + epmet-openapi-scan + callerRunsPolicy + https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4 @@ -207,6 +234,14 @@ true + + true + 5 + 8 + 20 + 60 + epmet-openapi-scan + callerRunsPolicy diff --git a/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/interceptor/ScanApiAuthInterceptor.java b/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/interceptor/ScanApiAuthInterceptor.java index 6ce851a45e..868c6e0185 100644 --- a/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/interceptor/ScanApiAuthInterceptor.java +++ b/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/interceptor/ScanApiAuthInterceptor.java @@ -33,7 +33,7 @@ public class ScanApiAuthInterceptor implements HandlerInterceptor { String ip = IpUtils.getIpAddr(request); SetOperations setOperations = redisTemplate.opsForSet(); if (!setOperations.isMember(RedisKeys.getWhiteList(), ip)) { - log.warn("preHandle ip:{} is not in whitelist", ip); + log.error("preHandle ip:{} 不在白名单内", ip); String result = JSON.toJSONString(new Result<>().error(EpmetErrorCode.ERR401.getCode(), EpmetErrorCode.ERR401.getMsg())); responseJson(response, result); return false; diff --git a/epmet-openapi/epmet-openapi-scan/src/main/resources/bootstrap.yml b/epmet-openapi/epmet-openapi-scan/src/main/resources/bootstrap.yml index 07a611bc39..108c714da6 100644 --- a/epmet-openapi/epmet-openapi-scan/src/main/resources/bootstrap.yml +++ b/epmet-openapi/epmet-openapi-scan/src/main/resources/bootstrap.yml @@ -91,3 +91,14 @@ shutdown: enable: true #是否开启优雅停机 waitTimeSecs: 30 # 优雅停机等待时间,超过30秒,发出告警 +thread: + # 线程池配置 + threadPool: + enableCustomize: @thread.threadPool.enable-customize@ + corePoolSize: @thread.threadPool.core-pool-size@ + maxPoolSize: @thread.threadPool.max-pool-size@ + queueCapacity: @thread.threadPool.queue-capacity@ + keepAliveSeconds: @thread.threadPool.keep-alive-seconds@ + threadNamePrefix: @thread.threadPool.thread-name-prefix@ + rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@ + diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/patrol/GridMemberRoutineWorkFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/patrol/GridMemberRoutineWorkFormDTO.java new file mode 100644 index 0000000000..d1c26b624b --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/patrol/GridMemberRoutineWorkFormDTO.java @@ -0,0 +1,47 @@ +package com.epmet.dto.form.patrol; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description 网格员例行工作 + * @Author sun + */ +@Data +public class GridMemberRoutineWorkFormDTO implements Serializable { + + private static final long serialVersionUID = -3522636529743412120L; + public interface RoutineWork extends CustomerClientShowGroup {} + public interface RoutineWorkDetail extends CustomerClientShowGroup {} + + /** + * 网格Id + */ + @NotBlank(message = "网格Id不能为空", groups = RoutineWork.class) + private String gridId; + + /** + * 例行工作Id + */ + @NotBlank(message = "例行工作Id不能为空", groups = RoutineWorkDetail.class) + private String routineWorkId; + + /** + * 当前页 + */ + private Integer pageNo = 1; + + /** + * 每页记录数 + */ + private Integer pageSize = 20; + + //token中客户Id + private String customerId; + //token中用户Id + private String staffId; + +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/BasicInfoResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/BasicInfoResultDTO.java index 2877fc47ed..e57abaf6a4 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/BasicInfoResultDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/BasicInfoResultDTO.java @@ -1,7 +1,6 @@ package com.epmet.dto.result; import lombok.Data; -import lombok.NoArgsConstructor; import java.io.Serializable; diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/RoutineWorkDetailResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/RoutineWorkDetailResultDTO.java new file mode 100644 index 0000000000..94335fda2b --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/RoutineWorkDetailResultDTO.java @@ -0,0 +1,84 @@ +package com.epmet.dto.result; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * @Description 网格员例行工作详情 + * @Author sun + */ +@Data +public class RoutineWorkDetailResultDTO implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 例行工作Id + */ + private String routineWorkId; + /** + * 网格Id + */ + private String gridId; + /** + * 网格名称 + */ + private String gridName; + /** + * 网格员Id + */ + private String staffId; + /** + * 网格员姓名 + */ + private String staffName; + /** + * 提交日期 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date submitTime; + /** + * 事项类型名称,一类-二类 + */ + private String workTypeName; + /** + * 重点人员是否在当地 + */ + private String isKeyPeopleLocateName; + /** + * 重点人员现状 + */ + private String keyPeopleStatus; + /** + * 事项名称 + */ + private String title; + /** + * 是否异常 + */ + private String isNormalName; + /** + * 发生日期 + */ + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date happenTime; + /** + * 发生地点 + */ + private String address; + /** + * 事项简述 + */ + private String workContent; + + //例行工作一类编码 + @JsonIgnore + private String allPCode; + //例行工作二类编码 + @JsonIgnore + private String workTypeCode; + +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/RoutineWorkListResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/RoutineWorkListResultDTO.java new file mode 100644 index 0000000000..f37dedcfbb --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/RoutineWorkListResultDTO.java @@ -0,0 +1,63 @@ +package com.epmet.dto.result; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * @Description 网格员例行工作列表 + * @Author sun + */ +@Data +public class RoutineWorkListResultDTO implements Serializable { + private static final long serialVersionUID = 1L; + /** + * 总条数 + */ + private Integer total = 0; + + /** + * 集合对象 + */ + private List list; + + @Data + public static class RoutineWorkList { + /** + * 例行工作Id + */ + private String routineWorkId; + + /** + * 标题 + */ + private String title; + + /** + * 提交日期 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date submitTime; + + /** + * 工作类型[一类-二类名称] + */ + private String workTypeName; + + /** + * 是否异常 + */ + private String isNormalName; + //例行工作一类编码 + @JsonIgnore + private String allPCode; + //例行工作二类编码 + @JsonIgnore + private String workTypeCode; + } + +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/StaffBasicInfoResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/StaffBasicInfoResultDTO.java index f981a68f8b..52c432f810 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/StaffBasicInfoResultDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/StaffBasicInfoResultDTO.java @@ -16,7 +16,7 @@ public class StaffBasicInfoResultDTO implements Serializable { * 客户Id */ private String customerId; - + private String customerName; /** * 用户Id */ diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/StatsdataResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/StatsdataResultDTO.java new file mode 100644 index 0000000000..307309f01c --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/StatsdataResultDTO.java @@ -0,0 +1,35 @@ +package com.epmet.dto.result; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * @Description 网格员例行工作数据统计 + * @Author sun + */ +@Data +public class StatsdataResultDTO implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 巡查总次数 + */ + private Integer patrolTotal; + + /** + * 巡查时长(xx小时xx分钟) + */ + private String totalTime; + @JsonIgnore + private Integer totalNum; + + /** + * 例行工作总次数 + */ + private Integer routineWorkCount; + +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java index 9cfd689cfc..d1d176cbe9 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java @@ -650,7 +650,7 @@ public interface EpmetUserOpenFeignClient { @GetMapping(value = "/epmetuser/user/queryUserClient/{userId}") Result queryUserClient(@PathVariable("userId") String userId); - @PostMapping("/epmetuser/icresidemanddict/demandoption/demandoption") + @PostMapping("/epmetuser/icresidemanddict/demandoption") Result> getDemandOptions(); @PostMapping("/epmetuser/icresiuser/categorycount") diff --git a/epmet-user/epmet-user-server/pom.xml b/epmet-user/epmet-user-server/pom.xml index 792f1abcf3..2973376472 100644 --- a/epmet-user/epmet-user-server/pom.xml +++ b/epmet-user/epmet-user-server/pom.xml @@ -154,6 +154,11 @@ 2.0.0 compile + + com.epmet + common-service-client + 2.0.0 + @@ -231,6 +236,15 @@ true 192.168.1.140:9876;192.168.1.141:9876 + + + true + 5 + 8 + 10 + 60 + epmet-user + callerRunsPolicy @@ -276,6 +290,15 @@ false 192.168.1.140:9876;192.168.1.141:9876 + + + true + 5 + 8 + 10 + 60 + epmet-user + callerRunsPolicy @@ -320,6 +343,15 @@ true 192.168.10.161:9876 + + + true + 5 + 8 + 10 + 60 + epmet-user + callerRunsPolicy @@ -363,6 +395,15 @@ true 192.168.11.187:9876;192.168.11.184:9876 + + + true + 5 + 8 + 10 + 60 + epmet-user + callerRunsPolicy diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/UserApplication.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/UserApplication.java index 106c49d028..caf839f79a 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/UserApplication.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/UserApplication.java @@ -13,6 +13,7 @@ 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.scheduling.annotation.EnableAsync; /** * 管理后台 @@ -24,6 +25,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient @EnableFeignClients +@EnableAsync @ServletComponentScan public class UserApplication { diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/bean/ResiExportBaseInfoData.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/bean/ResiExportBaseInfoData.java new file mode 100644 index 0000000000..5dc0d0b7c5 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/bean/ResiExportBaseInfoData.java @@ -0,0 +1,27 @@ +package com.epmet.bean; + +import lombok.Data; + +import java.io.Serializable; + +/** + * desc:导出居民信息 基础信息 给其他sheet使用 + */ +@Data +public class ResiExportBaseInfoData implements Serializable { + private static final long serialVersionUID = 1L; + + private String GRID_ID; + private String VILLAGE_ID; + private String BUILD_ID; + private String UNIT_ID; + private String HOME_ID; + private String IS_BDHJ; + private String NAME; + private String MOBILE; + private String GENDER; + private String ID_CARD; + private String BIRTHDAY; + private String CONTACTS; + private String CONTACTS_MOBILE; +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java index 7624198dfb..0c3adbb8fa 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java @@ -24,6 +24,7 @@ import com.alibaba.excel.write.metadata.fill.FillWrapper; import com.epmet.commons.rocketmq.messages.IcResiUserAddMQMsg; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.aop.NoRepeatSubmit; +import com.epmet.commons.tools.constant.Constant; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; @@ -33,6 +34,7 @@ import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.feign.ResultDataResolver; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisUtils; @@ -44,8 +46,8 @@ import com.epmet.commons.tools.utils.HttpClientManager; import com.epmet.commons.tools.utils.IpUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; -import com.epmet.constant.ImportTaskConstants; import com.epmet.constant.SystemMessageType; +import com.epmet.constants.ImportTaskConstants; import com.epmet.dto.IcResiUserDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.*; @@ -56,31 +58,36 @@ import com.epmet.feign.OperCustomizeOpenFeignClient; import com.epmet.feign.OssFeignClient; import com.epmet.service.IcResiUserImportService; import com.epmet.service.IcResiUserService; -import com.epmet.service.ImportTaskService; import jodd.io.FileUtil; import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.FileUtils; import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.tomcat.util.http.MimeHeaders; import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.support.StandardMultipartHttpServletRequest; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.lang.reflect.Field; import java.net.URLEncoder; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.*; +import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; @@ -93,7 +100,7 @@ import java.util.stream.Collectors; @Slf4j @RestController @RequestMapping("icresiuser") -public class IcResiUserController { +public class IcResiUserController implements ResultDataResolver { /** * 居民上传临时目录 @@ -123,9 +130,6 @@ public class IcResiUserController { private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; @Autowired private LoginUserUtil loginUserUtil; - @Autowired - private ImportTaskService importTaskService; - /** * 模板枚举 @@ -301,6 +305,7 @@ public class IcResiUserController { @RequestMapping(value = "/exportExcel") public void exportExcelByEasyExcel(@RequestHeader String customerId,@LoginUser TokenDto tokenDto, @RequestBody IcResiUserPageFormDTO pageFormDTO, HttpServletResponse response) throws Exception { //tokenDto.setUserId("9e37adcce6472152e6508a19d3683e02"); + long startM = System.currentTimeMillis(); CustomerStaffInfoCacheResult staffInfoCacheResult = CustomerStaffRedis.getStaffInfo(customerId, tokenDto.getUserId()); String staffOrgPath = null; if (StringUtils.isNotBlank(staffInfoCacheResult.getAgencyPIds()) && !NumConstant.ZERO_STR.equals(staffInfoCacheResult.getAgencyPIds())) { @@ -330,7 +335,7 @@ public class IcResiUserController { map.putIfAbsent(tableName,exportItem); String columnName = item.getColumnName().concat(item.getColumnNum() == NumConstant.ZERO ? StrConstant.EPMETY_STR : item.getColumnNum().toString()); exportItem.getItemMap().put(columnName,item); - if (item.getOptionSourceType().equals("remote")&&item.getOptionSourceValue().contains(StrConstant.QUESTION_MARK)){ + if (Constant.OPITON_SOURCE_REMOTE.equals(item.getOptionSourceType())&&item.getOptionSourceValue().contains(StrConstant.QUESTION_MARK)){ //多个参数 String[] paramArr = item.getOptionSourceValue().split(StrConstant.QUESTION_MARK_TRANSFER)[NumConstant.ONE].split(StrConstant.AND_MARK); Arrays.stream(paramArr).forEach(o->{ @@ -354,7 +359,7 @@ public class IcResiUserController { .collect(Collectors.toList()); List> resiResultList = null; - pageFormDTO.setPageSize(NumConstant.TEN_THOUSAND); + pageFormDTO.setPageSize(NumConstant.ONE_THOUSAND); for (IcResiUserTableEnum tableEnum : resiTableList) { String tableName = tableEnum.getTableName(); pageFormDTO.setPageNo(NumConstant.ONE); @@ -382,6 +387,7 @@ public class IcResiUserController { if (excelWriter != null){ excelWriter.finish(); } + log.info("exportExcelByEasyExcel resi info cost time:{}s",(System.currentTimeMillis()-startM)/NumConstant.ONE_THOUSAND); } } @@ -428,53 +434,118 @@ public class IcResiUserController { */ @NoRepeatSubmit @PostMapping("importExcel") - public void importExcelByEasyExcel(@RequestHeader("customerId") String customerId,@RequestPart("file") MultipartFile file, HttpServletResponse response) { + public Result importExcelByEasyExcel(@RequestHeader("customerId") String customerId,@RequestPart("file") MultipartFile file, HttpServletRequest multipartRequest, HttpServletResponse response) { if (file.isEmpty()) { throw new RenException("请上传文件"); } - // 校验文件类型 - String extension = FilenameUtils.getExtension(file.getOriginalFilename()); + String originalFilename = file.getOriginalFilename(); + // 一.校验文件类型 + String extension = FilenameUtils.getExtension(originalFilename); if (!"xls".equals(extension) && !"xlsx".equals(extension)) { throw new RenException("文件类型不匹配"); } String operatorId = loginUserUtil.getLoginUserId(); - String importTaskId; - // 记录导入任务 - if (importTaskService.existsProcessingTask(operatorId, ImportTaskConstants.BIZ_TYPE_RESI)) { - throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), - "已存在执行中的导入任务,请等待执行完成。", - "已存在执行中的导入任务,请等待执行完成。"); - } else { - importTaskId = importTaskService.createProcessTask(operatorId, ImportTaskConstants.BIZ_TYPE_RESI); - } + String importTaskId = icResiUserImportService.createImportTaskRecord(operatorId, ImportTaskConstants.BIZ_TYPE_RESI, originalFilename); - Path savePath = null; + // 二.缓存上传的文件 + Path importTempFileSavePath; try { String fileName = UUID.randomUUID().toString().concat(".").concat(extension); - savePath = IC_RESI_UPLOAD_DIR.resolve(fileName); + importTempFileSavePath = IC_RESI_UPLOAD_DIR.resolve(fileName); + IOUtils.copy(file.getInputStream(), new FileOutputStream(importTempFileSavePath.toString())); + } catch (Exception e) { + log.error("【上传居民信息】保存上传的文件失败:{}", ExceptionUtils.getErrorStackTrace(e)); + throw new RenException("上传失败"); + } - IOUtils.copy(file.getInputStream(), new FileOutputStream(savePath.toString())); - List formItemList = icResiUserService.listFormItems(customerId,IcFormCodeEnum.RESI_BASE_INFO.getCode()); + HttpServletRequest request = ((StandardMultipartHttpServletRequest)multipartRequest).getRequest(); - icResiUserImportService.importIcResiInfoFromExcel(importTaskId, formItemList, savePath.toString(), response); - } catch (Throwable e) { - String errorMsg = ExceptionUtils.getThrowableErrorStackTrace(e); - log.error("【导入居民信息失败】导入失败:{}", errorMsg); + HashMap headers = getHeadersFromRequest(request); + + // 三.异步执行导入 + CompletableFuture.runAsync(() -> { + + try { + // 睡眠2秒钟,等待主线程先结束,主线程会清空request对象的headers,等他执行了清空之后,我们这边再手动setHeader进去 + Thread.sleep(2000l); + System.out.println("请求头:" + headers); + } catch (InterruptedException e) { + String errorMsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【上传居民信息】失败,睡眠2s发生中断:{}", errorMsg); + return; + } - // 要将导入任务状态设置为结束但不成功 - importTaskService.finish(importTaskId, ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL, operatorId, null, e.getMessage()); - throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); - } finally { try { - if (savePath != null){ - Files.delete(savePath); + setHeaders2Request(request, headers); + + List formItemList = icResiUserService.listFormItems(customerId,IcFormCodeEnum.RESI_BASE_INFO.getCode()); + icResiUserImportService.importIcResiInfoFromExcel(importTaskId, formItemList, importTempFileSavePath.toString(), response, IC_RESI_UPLOAD_DIR); + } catch (Throwable e) { + String errorMsg = ExceptionUtils.getThrowableErrorStackTrace(e); + log.error("【导入居民信息失败】导入失败:{}", errorMsg); + + // 要将导入任务状态设置为结束但不成功。不报错即成功,没有返回值 + icResiUserImportService.finishImportTask(importTaskId, operatorId, ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL, "系统异常,请查看系统日志", null); + } finally { + try { + if (importTempFileSavePath != null){ + Files.delete(importTempFileSavePath); + } + } catch (IOException e) { + log.error("【导入居民信息失败】清理上传的文件失败:{}", ExceptionUtils.getErrorStackTrace(e)); } - } catch (IOException e) { - log.error("【导入居民信息失败】清理上传的文件失败:{}", ExceptionUtils.getErrorStackTrace(e)); + + // 清理request对象 + RequestContextHolder.resetRequestAttributes(); } + }); + + return new Result(); + } + + private HashMap getHeadersFromRequest(HttpServletRequest request) { + HashMap headers = new HashMap<>(); + Enumeration headerNames = request.getHeaderNames(); + if (headerNames != null) { + while (headerNames.hasMoreElements()) { + String name = headerNames.nextElement(); + Enumeration values = request.getHeaders(name); + while (values.hasMoreElements()) { + String value = values.nextElement(); + headers.put(name, value); + } + } + } + return headers; + } + + private void setHeaders2Request(HttpServletRequest request, HashMap headers) { + for (Map.Entry kv : headers.entrySet()) { + setParam2Header(request, kv.getKey(), kv.getValue()); + } + } + + private void setParam2Header(HttpServletRequest requestFacade, String key, String value){ + Class requestFacadeClass = requestFacade.getClass(); + try { + Field requestField = requestFacadeClass.getDeclaredField("request"); + requestField.setAccessible(true); + Object requestObject = requestField.get(requestFacade); + + Field coyoteRequestField = requestObject.getClass().getDeclaredField("coyoteRequest"); + coyoteRequestField.setAccessible(true); + Object coyoteRequestObject = coyoteRequestField.get(requestObject); + + Field headers = coyoteRequestObject.getClass().getDeclaredField("headers"); + headers.setAccessible(true); + MimeHeaders o2 = (MimeHeaders)headers.get(coyoteRequestObject); + o2.addValue(key).setString(value); + } catch (Exception e) { + e.printStackTrace(); + log.error("为子线程设置请求头出错"); } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/PatrolRoutineWorkController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/PatrolRoutineWorkController.java index 5297d84c2a..41f14362ee 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/PatrolRoutineWorkController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/PatrolRoutineWorkController.java @@ -1,21 +1,17 @@ package com.epmet.controller; -import com.alibaba.excel.EasyExcel; -import com.alibaba.excel.ExcelWriter; -import com.alibaba.excel.write.metadata.WriteSheet; +import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.aop.NoRepeatSubmit; -import com.epmet.commons.tools.utils.ExcelUtils; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.form.PatrolRoutineWorkFormDTO; import com.epmet.dto.form.PcWorkListFormDTO; +import com.epmet.dto.form.patrol.GridMemberRoutineWorkFormDTO; import com.epmet.dto.form.patrol.PatrolQueryFormDTO; -import com.epmet.dto.result.PatrolRoutineWorkResult; -import com.epmet.dto.result.PcWorkListResultDTO; -import com.epmet.excel.PcWorkListExport; +import com.epmet.dto.result.*; import com.epmet.service.PatrolRoutineWorkService; import com.github.pagehelper.Page; -import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -25,8 +21,6 @@ import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletResponse; import java.util.List; -import static io.netty.handler.codec.smtp.SmtpRequests.data; - /** * 例行工作 * @@ -85,4 +79,38 @@ public class PatrolRoutineWorkController { gridUserWorkService.pcWorkListExport(formDTO,response); } + /** + * @Author sun + * @Description 【例行工作】网格员巡查例行工作统计数据 + **/ + @PostMapping("statsdata") + public Result statsData(@LoginUser TokenDto tokenDto, @RequestBody GridMemberRoutineWorkFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, GridMemberRoutineWorkFormDTO.RoutineWork.class); + formDTO.setStaffId(tokenDto.getUserId()); + return new Result().ok(gridUserWorkService.statsData(formDTO)); + } + + /** + * @Author sun + * @Description 【例行工作】网格员例行工作列表 + **/ + @PostMapping("list") + public Result list(@LoginUser TokenDto tokenDto, @RequestBody GridMemberRoutineWorkFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, GridMemberRoutineWorkFormDTO.RoutineWork.class); + formDTO.setStaffId(tokenDto.getUserId()); + return new Result().ok(gridUserWorkService.list(formDTO)); + } + + /** + * @Author sun + * @Description 【例行工作】例行工作详情 + **/ + @PostMapping("detail") + public Result detail(@LoginUser TokenDto tokenDto, @RequestBody GridMemberRoutineWorkFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, GridMemberRoutineWorkFormDTO.RoutineWorkDetail.class); + formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setStaffId(tokenDto.getUserId()); + return new Result().ok(gridUserWorkService.detail(formDTO)); + } + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java index bc3e9f147a..35abe08623 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java @@ -27,6 +27,7 @@ import org.apache.ibatis.annotations.MapKey; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.math.BigDecimal; import java.util.List; import java.util.Map; import java.util.Set; @@ -65,109 +66,111 @@ public interface IcResiUserDao extends BaseDao { * 查询主表 * * @param icResiUserId - * @return java.util.List> + * @return java.util.List> * @author yinzuomei * @date 2021/10/28 11:20 上午 */ List> selectListMapById(@Param("customerId") String customerId, - @Param("icResiUserId")String icResiUserId); + @Param("icResiUserId") String icResiUserId); /** * 根据ic_resi_user.id去查询各个子表记录,动态传入表名 * * @param icResiUserId * @param subTableName - * @return java.util.List> + * @return java.util.List> * @author yinzuomei * @date 2021/10/28 11:19 上午 */ - List> selectSubTableRecords(@Param("customerId")String customerId, + List> selectSubTableRecords(@Param("customerId") String customerId, @Param("icResiUserId") String icResiUserId, @Param("subTableName") String subTableName); int updateToDel(String icResiUserId); - int updateSubTableToDel(@Param("subTalbeName") String subTalbeName, @Param("icResiUserId")String icResiUserId); + int updateSubTableToDel(@Param("subTalbeName") String subTalbeName, @Param("icResiUserId") String icResiUserId); /** * 接口名称 * - * @param customerId 客户id + * @param customerId 客户id * @param resultTableName 获取哪个表的数据??? - * @param conditions 前端传入的查询入参 - * @return java.util.List> + * @param conditions 前端传入的查询入参 + * @return java.util.List> * @author yinzuomei * @date 2021/11/2 10:35 上午 */ - List> dynamicQuery(@Param("customerId")String customerId, - @Param("resultTableName")String resultTableName, - @Param("conditions") List conditions, - @Param("subTables") List subTables, - @Param("currentStaffAgencyId")String currentStaffAgencyId, - @Param("staffOrgPath")String staffOrgPath); + List> dynamicQuery(@Param("customerId") String customerId, + @Param("resultTableName") String resultTableName, + @Param("conditions") List conditions, + @Param("subTables") List subTables, + @Param("currentStaffAgencyId") String currentStaffAgencyId, + @Param("staffOrgPath") String staffOrgPath); /** - * @Description 查询个人信息 * @param userId + * @Description 查询个人信息 * @author zxc * @date 2021/11/3 10:28 上午 */ PersonDataResultDTO personData(@Param("userId") String userId); /** - * @Description 根据名字,组织查询人 * @param name * @param agencyId + * @Description 根据名字,组织查询人 * @author zxc * @date 2021/11/3 2:05 下午 */ - List searchByName(@Param("name")String name, @Param("agencyId")String agencyId,@Param("pageNo")Integer pageNo); + List searchByName(@Param("name") String name, @Param("agencyId") String agencyId, @Param("pageNo") Integer pageNo); Set selectUserDemandCode(String icResiUserId); - String selectCategoryNames(@Param("customerId") String customerId,@Param("codeSet") Set codeSet); + + String selectCategoryNames(@Param("customerId") String customerId, @Param("codeSet") Set codeSet); @MapKey("HOME_ID") Map> getHomeUserCategoryCount(@Param("buildId") String buildId); /** - * @Description 根据userId查询志愿者 * @param userId + * @Description 根据userId查询志愿者 * @author zxc * @date 2021/11/5 5:44 下午 */ - List selectVolunteerByUserId(@Param("userId")String userId); + List selectVolunteerByUserId(@Param("userId") String userId); /** - * @Description 查询人员类别 * @param columns + * @Description 查询人员类别 * @author zxc * @date 2021/11/8 1:50 下午 */ - Map selectPersonType(@Param("columns")List columns,@Param("customerId")String customerId, - @Param("tableName")String tableName,@Param("userId")String userId); + Map selectPersonType(@Param("columns") List columns, @Param("customerId") String customerId, + @Param("tableName") String tableName, @Param("userId") String userId); /** * @Author sun * @Description 查询居民信息 **/ IcResiUserDTO getResiUser(IcResiUserDTO dto); + /** - * * @param agencyId * @param gridId * @param name * @return */ List selectDemandUsers(@Param("agencyId") String agencyId, - @Param("gridId")String gridId, - @Param("name")String name); + @Param("gridId") String gridId, + @Param("name") String name); - IcResiUserDTO selectIdByIdCard(@Param("customerId") String customerId, - @Param("idNum")String idNum, - @Param("icResiUserId")String icResiUserId); + IcResiUserDTO selectIdByIdCard(@Param("customerId") String customerId, + @Param("idNum") String idNum, + @Param("icResiUserId") String icResiUserId); /** * 获取居民名称,家属名称和id + * * @param isResiUserId * @return */ @@ -184,6 +187,7 @@ public interface IcResiUserDao extends BaseDao { /** * 组织内党员年龄范围统计 + * * @Param orgType * @Param orgId * @Return {@link List< OptionDataResultDTO>} @@ -194,6 +198,7 @@ public interface IcResiUserDao extends BaseDao { /** * 获取年龄范围内党员列表 + * * @Param orgType * @Param orgId * @Param min @@ -208,6 +213,7 @@ public interface IcResiUserDao extends BaseDao { /** * 党员文化程度统计 + * * @Param orgType * @Param orgId * @Return {@link List< OptionDataResultDTO>} @@ -218,6 +224,7 @@ public interface IcResiUserDao extends BaseDao { /** * 按教育程度获取党员列表 + * * @Param orgType * @Param orgId * @Param code @@ -226,17 +233,32 @@ public interface IcResiUserDao extends BaseDao { * @Date 2021/12/10 17:24 */ List getPartyMemberEducationList(@Param("orgType") String orgType, @Param("orgId") String orgId, - @Param("code") String code); + @Param("code") String code); List listIcResiInfosByUserIds(@Param("userIds") List userIds); Map getCategoryListMap(@Param("columns")List columns, @Param("icUserId") String icUserId); - Map selectResiInfoMap(@Param("idCard") String idCard); + Map selectResiInfoMap(@Param("idCard") String idCard, @Param("resiId") String resiId); List> selectResiUsers(@Param("types")List types,@Param("orgId")String orgId); List icUserCustomerIds(); List> getIcUserList(@Param("customerId") String customerId, @Param("columns")List columns); + + /** + * desc: 获取数据分析列中的 各类居民数据 + * + * @param customerId + * @param tableName + * @param columnList + * @param id 非必填 leve有值时 必填 + * @param level 非必填 + * @return java.util.Map 字段名:数量 + * @author LiuJanJun + * @date 2022/2/12 3:03 下午 + */ + Map getDataAnalyseCount(@Param("customerId") String customerId, @Param("tableName") String tableName, + @Param("columnList") List columnList, @Param("id") String id, @Param("level") String level); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcStatsResiWarnDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcStatsResiWarnDao.java index 610eeba0a0..0a46c4bc06 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcStatsResiWarnDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcStatsResiWarnDao.java @@ -48,7 +48,7 @@ public interface IcStatsResiWarnDao extends BaseDao { @Param("buildingIdList") List buildingIdList, @Param("tableName") String tableName, @Param("columnName") String columnName); - + @Deprecated Integer countListByLevelAndCol( @Param("customerId") String customerId, @Param("tableName") String tableName, diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/PatrolRoutineWorkDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/PatrolRoutineWorkDao.java index d728cc82e2..6f99cf404a 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/PatrolRoutineWorkDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/PatrolRoutineWorkDao.java @@ -22,8 +22,11 @@ import com.epmet.dto.form.PcWorkListFormDTO; import com.epmet.dto.form.patrol.PatrolQueryFormDTO; import com.epmet.dto.result.PatrolRoutineWorkResult; import com.epmet.dto.result.PcWorkListResultDTO; +import com.epmet.dto.result.RoutineWorkDetailResultDTO; +import com.epmet.dto.result.RoutineWorkListResultDTO; import com.epmet.entity.PatrolRoutineWorkEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -39,4 +42,17 @@ public interface PatrolRoutineWorkDao extends BaseDao { List selectList(PatrolQueryFormDTO formDTO); List pcWorkList(PcWorkListFormDTO formDTO); + + /** + * @Author sun + * @Description 【例行工作】网格员例行工作列表 + **/ + List staffRoutineWorkList(@Param("gridId") String gridId, @Param("staffId") String staffId); + + /** + * @Author sun + * @Description 【例行工作】例行工作详情 + **/ + RoutineWorkDetailResultDTO getDetail(@Param("routineWorkId") String routineWorkId); + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffRoleDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffRoleDao.java index 3cfb231881..8f62aef830 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffRoleDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffRoleDao.java @@ -138,6 +138,8 @@ public interface StaffRoleDao extends BaseDao { */ List staffGridRole(@Param("forms") List forms); + List staffGridRoleByIds(@Param("ids") List ids); + /** * @Description 查询角色 * @Param userIds diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StatsStaffPatrolRecordDailyDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StatsStaffPatrolRecordDailyDao.java index 15b4b8c02d..d8eba9d0b0 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StatsStaffPatrolRecordDailyDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StatsStaffPatrolRecordDailyDao.java @@ -20,6 +20,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.result.PatrolYuShanResultDTO; import com.epmet.dto.result.SelectPatrolCountResultDTO; +import com.epmet.dto.result.StatsdataResultDTO; import com.epmet.entity.StatsStaffPatrolRecordDailyEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -81,5 +82,11 @@ public interface StatsStaffPatrolRecordDailyDao extends BaseDao patrolInfo(@Param("agencyId")String agencyId); + + /** + * @Author sun + * @Description 【例行工作】网格员巡查例行工作统计数据 + **/ + StatsdataResultDTO getStatsData(@Param("gridId") String gridId, @Param("staffId") String staffId); } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/enums/IcResiUserTableEnum.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/enums/IcResiUserTableEnum.java index 9d72768f33..5bb46b6369 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/enums/IcResiUserTableEnum.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/enums/IcResiUserTableEnum.java @@ -1,6 +1,9 @@ package com.epmet.enums; import lombok.AllArgsConstructor; +import lombok.Data; + +import java.util.List; /** * @Description 描述 @@ -13,21 +16,40 @@ public enum IcResiUserTableEnum { /** * 注释 */ - IC_RESI_USER("ic_resi_user","社区居民基本信息录入表", 0, 3, null), - IC_PARTY_MEMBER("ic_party_member","党员信息录入表", 1, 2, "IS_PARTY"), - IC_ENSURE_HOUSE("ic_ensure_house","保障房人员信息录入表", 2, 2, "IS_ENSURE_HOUSE"), - IC_UNEMPLOYED("ic_unemployed","失业人员信息录入表", 3, 2, "IS_UNEMPLOYED"), - IC_VETERANS("ic_veterans","退役军人信息录入表", 4, 2, "IS_VETERANS"), - IC_UNITED_FRONT("ic_united_front","统战人员信息录入表", 5, 2, "IS_UNITED_FRONT"), - IC_VOLUNTEER("ic_volunteer","志愿者信息录入表", 6, 3, "IS_VOLUNTEER"), - IC_OLD_PEOPLE("ic_old_people","老年人信息录入表", 7, 2, "IS_OLD_PEOPLE"), - IC_SPECIAL("ic_special","特殊人群信息录入表", 8, 3, "IS_SPECIAL"); + IC_RESI_USER("ic_resi_user","社区居民基本信息录入表", 0, 3, null, true), + IC_PARTY_MEMBER("ic_party_member","党员信息录入表", 1, 2, "IS_PARTY", true), + IC_ENSURE_HOUSE("ic_ensure_house","保障房人员信息录入表", 2, 2, "IS_ENSURE_HOUSE", true), + IC_UNEMPLOYED("ic_unemployed","失业人员信息录入表", 3, 2, "IS_UNEMPLOYED", true), + IC_VETERANS("ic_veterans","退役军人信息录入表", 4, 2, "IS_VETERANS", true), + IC_UNITED_FRONT("ic_united_front","统战人员信息录入表", 5, 2, "IS_UNITED_FRONT", true), + IC_VOLUNTEER("ic_volunteer","志愿者信息录入表", 6, 3, "IS_VOLUNTEER", true), + IC_OLD_PEOPLE("ic_old_people","老年人信息录入表", 7, 2, "IS_OLD_PEOPLE", true), + IC_SPECIAL("ic_special","特殊人群信息录入表", 8, 3, "IS_SPECIAL", true), + +// 下面的是:没有实际数据库表,在ic_resi_user中有一个标记,但是导入的时候是有单独的sheet的 + IC_DBH("ic_resi_user","低保人员信息录入表", null, 2, "IS_DBH", false), + IC_YLFN("ic_resi_user","育龄妇女信息录入表", null, 2, "IS_YLFN", false), + IC_XFRY("ic_resi_user","信访人员信息录入表", null, 2, "IS_XFRY", false), + IC_KC("ic_resi_user","空巢老人信息录入表", null, 2, "IS_KC", false), + IC_SD("ic_resi_user","失独人员信息录入表", null, 2, "IS_SD", false), + IC_SN("ic_resi_user","失能人员信息录入表", null, 2, "IS_SN", false), + IC_SZ("ic_resi_user","失智人员信息录入表", null, 2, "IS_SZ", false), + IC_CJ("ic_resi_user","残疾人员信息录入表", null, 2, "IS_CJ", false), + IC_DB("ic_resi_user","大病人员信息录入表", null, 2, "IS_DB", false), + IC_MB("ic_resi_user","慢病人员信息录入表", null, 2, "IS_MB", false); private String tableName; + /** + * 表描述 && sheet名称 + */ private String tableComment; - private int sheetNo; + private Integer sheetNo; private int headRowNo; private String mainTableFlagColumnName; + /** + * 该sheet是否有数据库表 + */ + private boolean existsDBTable; /** * 根据表名获取枚举对象 @@ -63,34 +85,18 @@ public enum IcResiUserTableEnum { return tableName; } - public void setTableName(String tableName) { - this.tableName = tableName; - } - public String getTableComment() { return tableComment; } - public void setTableComment(String tableComment) { - this.tableComment = tableComment; - } - public int getSheetNo() { return sheetNo; } - public void setSheetNo(int sheetNo) { - this.sheetNo = sheetNo; - } - public int getHeadRowNo() { return headRowNo; } - public void setHeadRowNo(int headRowNo) { - this.headRowNo = headRowNo; - } - public String getMainTableFlagColumnName() { return mainTableFlagColumnName; } @@ -98,4 +104,8 @@ public enum IcResiUserTableEnum { public void setMainTableFlagColumnName(String mainTableFlagColumnName) { this.mainTableFlagColumnName = mainTableFlagColumnName; } + + public boolean isExistsDBTable() { + return existsDBTable; + } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/IcResiVirtualSheetImportListener.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/IcResiVirtualSheetImportListener.java new file mode 100644 index 0000000000..79ddbea5a9 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/IcResiVirtualSheetImportListener.java @@ -0,0 +1,44 @@ +package com.epmet.excel.handler; + +import com.alibaba.excel.context.AnalysisContext; +import com.alibaba.excel.event.AnalysisEventListener; +import com.epmet.enums.IcResiUserTableEnum; +import com.epmet.service.impl.IcResiUserImportServiceImpl; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class IcResiVirtualSheetImportListener extends AnalysisEventListener> { + + private IcResiUserImportServiceImpl importService; + + private IcResiUserTableEnum sheetEnumObject; + + /** + * 身份证号列表 + */ + private List> resiInfo = new ArrayList<>(); + + public IcResiVirtualSheetImportListener(IcResiUserImportServiceImpl importService, IcResiUserTableEnum sheetEnumObject) { + this.importService = importService; + this.sheetEnumObject = sheetEnumObject; + } + + @Override + public void invoke(Map data, AnalysisContext context) { + if (data != null && data.size() > 0) { + resiInfo.add(data); + } + } + + @Override + public void doAfterAllAnalysed(AnalysisContext context) { + try { + importService.persistIcResiVirtualSheetExtraInfo(resiInfo, sheetEnumObject); + } finally { + // 清空数据 + resiInfo.clear(); + } + } +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserImportService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserImportService.java index 35748c9ddc..7358dcd961 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserImportService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserImportService.java @@ -3,6 +3,7 @@ package com.epmet.service; import com.epmet.dto.result.FormItemResult; import javax.servlet.http.HttpServletResponse; +import java.nio.file.Path; import java.util.List; /** @@ -12,5 +13,23 @@ import java.util.List; */ public interface IcResiUserImportService { - void importIcResiInfoFromExcel(String importTaskId, List formItemList, String excelPathName, HttpServletResponse response); + void importIcResiInfoFromExcel(String importTaskId, List formItemList, String excelPathName, HttpServletResponse response, Path importTempPath); + + /** + * 创建导入任务 + * @param operatorId + * @param bizType + * @return + */ + String createImportTaskRecord(String operatorId, String bizType, String originFileName); + + /** + * 完成导入任务 + * @param importTaskId 任务ID + * @param operatorId 操作者ID + * @param processStatus 处理状态,见 ImportTaskConstants.PROCESS_STATUS_* + * @param resultDesc 结果描述,非必填 + * @param resultDescPath 结果描述文件,excel等文件,有错误的话需要传入,成功则不需要 + */ + void finishImportTask(String importTaskId, String operatorId, String processStatus, String resultDesc, String resultDescPath); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/ImportTaskService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/ImportTaskService.java deleted file mode 100644 index 65245abd98..0000000000 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/ImportTaskService.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.epmet.service; - - -/** - * - * - * @author generator generator@elink-cn.com - * @since v1.0.0 2022-02-15 - */ -public interface ImportTaskService { - - /** - * 检查指定类型该用户是否存在处理中的导入任务 - * @param operatorId 操作者ID - * @param bizType 业务类型。resi:居民 - * @return - */ - boolean existsProcessingTask(String operatorId, String bizType); - - /** - * 创建处理任务 - * @param operatorId - * @param bizType - */ - String createProcessTask(String operatorId, String bizType); - - /** - * 结束导入 - * @param taskId 任务id - * @param processStatus 处理状态 - * @param resultDescFile 结果描述文件 - * @param resultDesc 结果描述文本 - */ - Boolean finish(String taskId, String processStatus, String operatorId, String resultDescFile, String resultDesc); -} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/PatrolRoutineWorkService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/PatrolRoutineWorkService.java index 5af4a1300a..81653fea19 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/PatrolRoutineWorkService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/PatrolRoutineWorkService.java @@ -20,9 +20,9 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.dto.form.PatrolRoutineWorkFormDTO; import com.epmet.dto.form.PcWorkListFormDTO; +import com.epmet.dto.form.patrol.GridMemberRoutineWorkFormDTO; import com.epmet.dto.form.patrol.PatrolQueryFormDTO; -import com.epmet.dto.result.PatrolRoutineWorkResult; -import com.epmet.dto.result.PcWorkListResultDTO; +import com.epmet.dto.result.*; import com.epmet.entity.PatrolRoutineWorkEntity; import com.github.pagehelper.Page; @@ -58,4 +58,22 @@ public interface PatrolRoutineWorkService extends BaseService customerResult = operCrmOpenFeignClient.getCustomerInfo(dto); + if (!customerResult.success()) { + throw new RenException(customerResult.getCode(), customerResult.getMsg()); + } + if (null != customerResult.getData()) { + resultDTO.setCustomerName(customerResult.getData().getCustomerName()); + } } return new Result().ok(resultDTO); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java index 18cd3cd6ec..414a077729 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java @@ -12,9 +12,11 @@ import com.epmet.bean.ResiImportResiCategoryChangedCache; import com.epmet.bean.ResiImportChangedData; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.constant.StrConstant; +import com.epmet.commons.tools.constant.ThreadLocalConstant; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.dto.result.OptionResultDTO; import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.feign.ResultDataResolver; @@ -24,7 +26,7 @@ import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.security.user.LoginUserUtil; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; -import com.epmet.constant.ImportTaskConstants; +import com.epmet.constants.ImportTaskConstants; import com.epmet.dao.IcResiUserDao; import com.epmet.dao.IcUserChangeDetailedDao; import com.epmet.dao.IcUserChangeRecordDao; @@ -38,25 +40,27 @@ import com.epmet.entity.IcUserChangeRecordEntity; import com.epmet.entity.IcUserTransferRecordEntity; import com.epmet.enums.IcResiUserTableEnum; import com.epmet.excel.handler.IcResiImportDynamicExcelListener; -import com.epmet.feign.EpmetAdminOpenFeignClient; -import com.epmet.feign.EpmetUserOpenFeignClient; -import com.epmet.feign.GovOrgOpenFeignClient; -import com.epmet.feign.OperCustomizeOpenFeignClient; +import com.epmet.excel.handler.IcResiVirtualSheetImportListener; +import com.epmet.feign.*; import com.epmet.service.*; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import lombok.Data; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.FileItemFactory; +import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.lang3.StringUtils; +import org.apache.http.entity.ContentType; import org.apache.poi.ss.usermodel.Workbook; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.web.multipart.commons.CommonsMultipartFile; import javax.servlet.http.HttpServletResponse; -import java.io.File; -import java.io.IOException; -import java.net.URLEncoder; +import java.io.*; +import java.nio.file.Path; import java.util.*; import java.util.stream.Collectors; @@ -71,6 +75,11 @@ import java.util.stream.Collectors; @Service public class IcResiUserImportServiceImpl implements IcResiUserImportService, ResultDataResolver { + /** + * 身份证号列序号 + */ + public static final Integer ID_CARD_COLUMN_NO = 9; + // 错误和跳过excel行暂存 public static final ThreadLocal>> errorRows = new ThreadLocal<>(); @@ -87,10 +96,12 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res /** * key: itemId * value: - * key: option的中文 - * value: options的英文key,也可能是数据id + * key: 当前item的super itemId + * value: superItem的子item列表 + * key: option的中文 + * value: options的英文key,也可能是数据id */ - Cache> itemIdAndOptionsCache = CacheBuilder.newBuilder().maximumSize(500).build(); + Cache>> itemIdAndOptionsCache = CacheBuilder.newBuilder().maximumSize(500).build(); @Autowired @@ -127,8 +138,9 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res private RedisUtils redisUtils; @Autowired - private ImportTaskService importTaskService; - + private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient; + @Autowired + private OssFeignClient ossFeignClient; /** * 字表中不需要的列 @@ -195,24 +207,6 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res private String errorInfo; } - @Data - public static class SkipedRow { - - @Excel(name = "工作表") - private String sheetName; - - private String tableName; - - @Excel(name = "身份证号") - private String idCard; - - @Excel(name = "姓名") - private String name; - - @Excel(name = "信息") - private String info; - } - /** * 导入居民信息 * @param importTaskId 导入任务id @@ -221,7 +215,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res * @param response 响应对象 */ @Override - public void importIcResiInfoFromExcel(String importTaskId, List formItemList, String excelPathName, HttpServletResponse response) { + public void importIcResiInfoFromExcel(String importTaskId, List formItemList, String excelPathName, HttpServletResponse response, Path importTempPath) { String loginUserId = loginUserUtil.getLoginUserId(); String loginUserApp = loginUserUtil.getLoginUserApp(); @@ -240,8 +234,6 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res CustomerAgencyDTO agencyInfo = getResultDataOrThrowsException(govOrgOpenFeignClient.getAgencyById(currUserAgencyId), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null, null); String customerId = agencyInfo.getCustomerId(); - boolean hasErrorRows = false; - try { initImportThreadLocal(customerId); @@ -251,12 +243,13 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res // 上传附表信息 for (IcResiUserTableEnum sheet : IcResiUserTableEnum.values()) { + // 是主表 if (sheet == IcResiUserTableEnum.IC_RESI_USER) { continue; } try { - importIcResiExtraInfoFromExcel(formItemList, excelPathName, sheet.getSheetNo(), sheet.getHeadRowNo(), currUserAgencyId, loginUserId, sheet.getTableName(), customerId); + importIcResiExtraInfoFromExcel(formItemList, excelPathName, sheet, currUserAgencyId, loginUserId, customerId); } catch (Exception e) { String errorMsg = ExceptionUtils.getErrorStackTrace(e); log.error("导入IC居民附加信息【{}】错误:{}", sheet.getTableComment(), errorMsg); @@ -272,30 +265,24 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res Map categoryChangedResis = newlyOrChangedResi.get().getCategoryChangedResis(); Map transferedResis = newlyOrChangedResi.get().getTransferedResis(); - log.info("类别变动居民数:{}", categoryChangedResis.size()); - log.info("调动居民数:{}", transferedResis.size()); - //保存调动或者变更记录 saveNewResiCategoryRecord(); saveResiCategoryChangedRecord(categoryChangedResis); saveTransferedResiRecord(transferedResis); - hasErrorRows = hasErrorRows(); - - try { - // todo 做了导入记录之后,这里就要判断,没有错误就不生成文件了 - downLoadResults(hasErrorRows, response); - } catch (Exception e) { - log.error("【导入IC居民附加信息】下载导入结果信息失败:{}", ExceptionUtils.getErrorStackTrace(e)); - } - - // 更新上传记录 - if (hasErrorRows) { - importTaskService.finish(importTaskId, ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL, loginUserId, - null, null); + // 生成错误描述文件 && 更新上传记录 + LinkedList errorRows = getErrorRows(); + if (CollectionUtils.isNotEmpty(errorRows)) { + String resultDescFilePath = null; + try { + resultDescFilePath = generateResultDescFile(errorRows, importTempPath); + } catch (Exception e) { + String errorMsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【居民信息导入】", errorMsg); + } + finishImportTask(importTaskId, loginUserId, ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL,null, resultDescFilePath); } else { - importTaskService.finish(importTaskId, ImportTaskConstants.PROCESS_STATUS_FINISHED_SUCCESS, loginUserId, - null, null); + finishImportTask(importTaskId, loginUserId, ImportTaskConstants.PROCESS_STATUS_FINISHED_SUCCESS,null, null); } } catch (Exception e) { @@ -320,19 +307,16 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res } /** - * 是否有错误行 + * 返回错误行 * @return */ - private Boolean hasErrorRows() { - boolean hasError = false; - Map> tableAndErrorRows = errorRows.get(); - for (Map.Entry> entry:tableAndErrorRows.entrySet()) { - if (entry.getValue().size() != 0) { - hasError = true; - } + private LinkedList getErrorRows() { + LinkedList list = new LinkedList<>(); + for (Map.Entry> entry : errorRows.get().entrySet()) { + list.addAll(entry.getValue()); } - return hasError; + return list; } /** @@ -343,12 +327,6 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res String operatorId = loginUserUtil.getLoginUserId(); String importTag = operatorId + System.currentTimeMillis(); - // 跳过的,不导入的行 - Map> skipedRowsMap = new LinkedHashMap<>(); - for (IcResiUserTableEnum e : IcResiUserTableEnum.values()) { - skipedRowsMap.put(e.getTableName(), new LinkedList<>()); - } - // 错误信息 Map> errorRowsMap = new LinkedHashMap<>(); for (IcResiUserTableEnum e : IcResiUserTableEnum.values()) { @@ -396,19 +374,35 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res * * @param formItemList * @param excelPathName - * @param sheetNo - * @param headRowNumber + * @param sheetEnumObject sheet枚举对象 * @param currUserAgencyId * @param currentUserId - * @param targetTableName 要插入哪一个表 * @return */ - private void importIcResiExtraInfoFromExcel(List formItemList, String excelPathName, int sheetNo, int headRowNumber, String currUserAgencyId, String currentUserId, - String targetTableName, String customerId) { - - IcResiImportDynamicExcelListener readListener = new IcResiImportDynamicExcelListener(this, customerId, currentUserId, currUserAgencyId, null, - false, targetTableName, formItemList, headRowNumber); - EasyExcelFactory.read(new File(excelPathName)).registerReadListener(readListener).headRowNumber(headRowNumber).sheet(sheetNo).doRead(); + private void importIcResiExtraInfoFromExcel(List formItemList, String excelPathName, IcResiUserTableEnum sheetEnumObject, String currUserAgencyId, + String currentUserId, String customerId) { + + // 如果该sheet对应有实际的数据库表,使用items动态的解析 + if (sheetEnumObject.isExistsDBTable()) { + IcResiImportDynamicExcelListener readListener = new IcResiImportDynamicExcelListener( + this, customerId, currentUserId, currUserAgencyId, null, + false, sheetEnumObject.getTableName(), formItemList, sheetEnumObject.getHeadRowNo()); + + EasyExcelFactory.read(new File(excelPathName)) + .registerReadListener(readListener) + .headRowNumber(sheetEnumObject.getHeadRowNo()) + .sheet(sheetEnumObject.getTableComment()) + .doRead(); + } else { + // 实际上并不存在该sheet对应的数据库表,此时无法使用items解析,就要读取固定的ID_CARD字段数据,更新主表字段为true + IcResiVirtualSheetImportListener vitualSheetReadListener = new IcResiVirtualSheetImportListener(this, sheetEnumObject); + + EasyExcelFactory.read(new File(excelPathName)) + .registerReadListener(vitualSheetReadListener) + .headRowNumber(sheetEnumObject.getHeadRowNo()) + .sheet(sheetEnumObject.getTableComment()) + .doRead(); + } } /** @@ -431,7 +425,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res String idCard = columnAndValues.get("ID_CARD"); - Map existingResiMap = icResiUserDao.selectResiInfoMap(idCard); + Map existingResiMap = icResiUserDao.selectResiInfoMap(idCard, null); if (existingResiMap == null) { // 新导入的居民,因为还没有读取子sheet,所以这些居民类别没有办法获取,先默认设置成0,后面读取子sheet的时候再更新 @@ -443,6 +437,16 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res columnAndValues.put("IS_UNITED_FRONT", "0"); columnAndValues.put("IS_VETERANS", "0"); columnAndValues.put("IS_VOLUNTEER", "0"); + columnAndValues.put("IS_DBH", "0"); + columnAndValues.put("IS_YLFN", "0"); + columnAndValues.put("IS_XFRY", "0"); + columnAndValues.put("IS_KC", "0"); + columnAndValues.put("IS_SD", "0"); + columnAndValues.put("IS_SN", "0"); + columnAndValues.put("IS_SZ", "0"); + columnAndValues.put("IS_CJ", "0"); + columnAndValues.put("IS_DB", "0"); + columnAndValues.put("IS_MB", "0"); } else { // 该居民已存在,要做更新操作,因为还没有读取子sheet,所以这些居民最新类别没有办法获取,先设置上旧的数据 columnAndValues.put("IS_ENSURE_HOUSE", existingResiMap.get("IS_ENSURE_HOUSE")); @@ -453,6 +457,16 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res columnAndValues.put("IS_UNITED_FRONT", existingResiMap.get("IS_UNITED_FRONT")); columnAndValues.put("IS_VETERANS", existingResiMap.get("IS_VETERANS")); columnAndValues.put("IS_VOLUNTEER", existingResiMap.get("IS_VOLUNTEER")); + columnAndValues.put("IS_DBH", existingResiMap.get("IS_DBH")); + columnAndValues.put("IS_YLFN", existingResiMap.get("IS_YLFN")); + columnAndValues.put("IS_XFRY", existingResiMap.get("IS_XFRY")); + columnAndValues.put("IS_KC", existingResiMap.get("IS_KC")); + columnAndValues.put("IS_SD", existingResiMap.get("IS_SD")); + columnAndValues.put("IS_SN", existingResiMap.get("IS_SN")); + columnAndValues.put("IS_SZ", existingResiMap.get("IS_SZ")); + columnAndValues.put("IS_CJ", existingResiMap.get("IS_CJ")); + columnAndValues.put("IS_DB", existingResiMap.get("IS_DB")); + columnAndValues.put("IS_MB", existingResiMap.get("IS_MB")); } columnAndValues.put("AGENCY_ID", currUserAgencyId); @@ -469,12 +483,6 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res ResiImportChangedData transferData; if ((transferData = this.getResiImportTrasferData(existingResiMap, columnAndValues)) != null) { newlyOrChangedResi.get().getTransferedResis().put(existingResiMap.get("ID"), transferData); - } else { - // 组织维度没有发生变化,看是否有居民类型变更 - ResiImportChangedData d = getResiImportCategoryChangedData(existingResiMap, columnAndValues); - if (d != null) { - newlyOrChangedResi.get().getCategoryChangedResis().put(existingResiMap.get("ID"), d); - } } } else { // 新增居民 @@ -482,22 +490,8 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res columnAndValues.put("CREATED_BY", currentUserId); columnAndValues.put("ID", resiId); - icResiUserDao.add(tableName, columnAndValues); - // 过滤出本居民含有哪些类别 - Map resiCategories = resiCategoryColumnNameAndLabel.get().keySet() - .stream() - .filter((categoryColumnName) -> "1".equals(columnAndValues.get(categoryColumnName))) - .collect(Collectors.toMap((k) -> k, (k) -> columnAndValues.get(k))); - -// newlyOrChangedResi.get().getNewResis().put(resiId, -// new ResiImportCategoryData(columnAndValues.get("AGENCY_ID"), -// columnAndValues.get("GRID_ID"), -// columnAndValues.get("VILLAGE_ID"), -// columnAndValues.get("BUILD_ID"), -// columnAndValues.get("UNIT_ID"), -// columnAndValues.get("HOME_ID"), -// resiCategories)); + icResiUserDao.add(tableName, columnAndValues); ResiImportCategoryData categoryData = new ResiImportCategoryData(resiId, columnAndValues.get("AGENCY_ID"), @@ -506,7 +500,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res columnAndValues.get("BUILD_ID"), columnAndValues.get("UNIT_ID"), columnAndValues.get("HOME_ID"), - resiCategories); + new HashMap<>()); redisUtils.hMSet(RedisKeys.icResiImportResiCategoryKey(newlyOrChangedResi.get().getImportTag(), "add", resiId), BeanUtil.beanToMap(categoryData)); categoryData = null; @@ -514,7 +508,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res } catch (Exception e) { String errorMsg; - if (e instanceof RenException) { + if (e instanceof RenException | e instanceof EpmetException) { errorMsg = e.getMessage(); } else { errorMsg = "未知系统错误"; @@ -564,13 +558,13 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res } // 检查用户是否存在 - Map resiInfoMap = icResiUserDao.selectResiInfoMap(idCard); + Map existResiInfoMap = icResiUserDao.selectResiInfoMap(idCard, null); - if (resiInfoMap == null || resiInfoMap.size() == 0) { + if (existResiInfoMap == null || existResiInfoMap.size() == 0) { throw new RenException(EpmetErrorCode.RESI_NOT_FOUND.getCode(), String.format("身份证号为【%s】的居民信息未找到,请确认该居民信息存在", idCard)); } - String icResiId = resiInfoMap.get("ID"); + String icResiId = existResiInfoMap.get("ID"); columnAndValues.put("IC_RESI_USER", icResiId); columnAndValues.put("CUSTOMER_ID", loginUserUtil.getLoginUserCustomerId()); @@ -598,7 +592,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res // 保存到类别变更缓存中 saveSubTableInfoToCategoryChangedResiCache(icResiId, Objects.requireNonNull(IcResiUserTableEnum.getObjectByTableName(targetTableName)).getMainTableFlagColumnName(), - resiInfoMap); + existResiInfoMap); } catch (Exception e) { String errorMsg; @@ -621,6 +615,45 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res } } + /** + * 虚拟(不对应实际的数据库表)sheet的数据导入持久化 + * @param sheetEnumObject + */ + public void persistIcResiVirtualSheetExtraInfo(List> resiInfo, IcResiUserTableEnum sheetEnumObject) { + for (Map columnAndValues : resiInfo) { + String idCard = columnAndValues.get(ID_CARD_COLUMN_NO); + try { + Map resiInfoMap = icResiUserDao.selectResiInfoMap(idCard, null); + + if (resiInfoMap == null || resiInfoMap.size() == 0) { + throw new RenException(EpmetErrorCode.RESI_NOT_FOUND.getCode(), String.format("身份证号为【%s】的居民信息未找到,请确认该居民信息存在", idCard)); + } + String icResiId = resiInfoMap.get("ID"); + + // 更新主表中该居民类型字段为true + updateMainTableResiTypeFlag(sheetEnumObject, icResiId); + + // 保存类别变更信息 + saveSubTableInfoToCategoryChangedResiCache(icResiId, sheetEnumObject.getMainTableFlagColumnName(), resiInfoMap); + } catch (Exception e) { + String errorMsg; + if (e instanceof RenException || e instanceof EpmetException) { + errorMsg = e.getMessage(); + } else { + errorMsg = "未知系统错误"; + log.error(ExceptionUtils.getErrorStackTrace(e)); + } + + ErrorRow errorRow = new ErrorRow(); + errorRow.setName(columnAndValues.get("NAME")); + errorRow.setIdCard(idCard); + errorRow.setErrorInfo(errorMsg); + errorRow.setTableName(sheetEnumObject.getTableName()); + errorRows.get().get(sheetEnumObject.getTableName()).add(errorRow); + } + } + } + /** * 去掉多余的列 * @param originColumnAndValues @@ -661,7 +694,9 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res for (Map.Entry itemIdAndColumnWrapper : itemIdAndColumnWrappers.entrySet()) { + String itemId = itemIdAndColumnWrapper.getKey(); ColumnWrapper columnWrapper = itemIdAndColumnWrapper.getValue(); + if ("input".equals(columnWrapper.getItemType()) || "textarea".equals(columnWrapper.getItemType()) || "datepicker".equals(columnWrapper.getItemType()) @@ -687,13 +722,37 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res columnWrapper.setColValue(colValue); } else { // remote类型。优先从缓存取 - Map optionsOfItem = itemIdAndOptionsCache.getIfPresent(itemIdAndColumnWrapper.getKey()); - if (optionsOfItem == null || optionsOfItem.size() == 0) { - optionsOfItem = listRemoteOptions(itemIdAndColumnWrappers, columnWrapper.getOptionSourceValue(), currUserAgencyId, "saveorupdate"); - itemIdAndOptionsCache.put(itemIdAndColumnWrapper.getKey(), optionsOfItem); + String fullUri = columnWrapper.getOptionSourceValue(); + String[] uriParts = splitOptionSourceUrl(fullUri); + String pureUri = uriParts[0]; + String superItemId = uriParts[1]; + String superColumValue; + + if (StringUtils.isNotBlank(superItemId)) { + superColumValue = itemIdAndColumnWrappers.get(superItemId).getColValue(); + } else { + superColumValue = "-"; + } + + Map> superOptions = itemIdAndOptionsCache.getIfPresent(itemId); + if (superOptions != null && superOptions.size() > 0) { + Map options = superOptions.get(superColumValue); + if (options == null || options.size() == 0) { + options = listRemoteOptions(pureUri, superItemId, itemIdAndColumnWrappers, currUserAgencyId, "saveorupdate"); + superOptions.put(superColumValue, options); + } + + String colValue = options.get(cellContent); + columnWrapper.setColValue(colValue); + } else { + Map options = listRemoteOptions(pureUri, superItemId, itemIdAndColumnWrappers, currUserAgencyId, "saveorupdate"); + superOptions = new HashMap<>(); + superOptions.put(superColumValue, options); + itemIdAndOptionsCache.put(itemId, superOptions); + + String colValue = options.get(cellContent); + columnWrapper.setColValue(colValue); } - String colValue = optionsOfItem.get(cellContent); - columnWrapper.setColValue(colValue); } } else if ("checkbox".equals(columnWrapper.getItemType())) { String checkBoxColValue = getCheckBoxColValue(columnWrapper, row, checkBoxOptionColumnIdxAndLabel); @@ -899,28 +958,37 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res } /** - * 远程获取options + * 分割sourceUrl为纯url和父itemId * @param fullUri - * @return + * @return [ pureUri, cascadeItemId(父itemId) ] */ - public Map listRemoteOptions(Map columnWrappers, String fullUri, String currUserAgencyId, String purpose) { + public String[] splitOptionSourceUrl(String fullUri) { String pureUri = null; String cascadeItemId = null; - ColumnWrapper cascadeItemColumnWrapper = null; if (fullUri.indexOf(StrConstant.QUESTION_MARK) != -1) { String[] uriParts = fullUri.split(StrConstant.QUESTION_MARK_TRANSFER); pureUri = uriParts[0]; cascadeItemId = uriParts[1]; - - // 根据uri上的id,找到关联的itemid,从而找到关联的item的值 - if (columnWrappers != null){ - cascadeItemColumnWrapper = columnWrappers.get(cascadeItemId); - } } else { pureUri = fullUri; } + return new String[] { pureUri, cascadeItemId }; + } + + /** + * 远程获取options + * @return + */ + public Map listRemoteOptions(String pureUri, String cascadeItemId, Map columnWrappers, String currUserAgencyId, String purpose) { + ColumnWrapper cascadeItemColumnWrapper = null; + + // 根据uri上的id,找到关联的itemid,从而找到关联的item的值 + if (columnWrappers != null && StringUtils.isNotBlank(cascadeItemId)){ + cascadeItemColumnWrapper = columnWrappers.get(cascadeItemId); + } + List options = null; switch (pureUri) { @@ -1029,38 +1097,51 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res private void updateMainTableResiTypeFlag(IcResiUserTableEnum icResiUserTableEnum, String resiUserId) { HashMap map = new HashMap<>(); map.put(icResiUserTableEnum.getMainTableFlagColumnName(), true); - icResiUserDao.upTable("ic_resi_user", resiUserId, map); + icResiUserDao.upTable(IcResiUserTableEnum.IC_RESI_USER.getTableName(), resiUserId, map); } /** - * 下载导入结果 - * @param response + * 生成导入结果 * @throws IOException */ - public void downLoadResults(Boolean hasErrorRows, HttpServletResponse response) throws IOException { - String fileName; - - // 判断是否有错误信息,以确定文件名 - if (hasErrorRows) { - fileName = "导入失败条目清单.xls"; - } else { - fileName = "导入成功.xls"; + public String generateResultDescFile(LinkedList errorRows, Path importTempDir) throws IOException { + errorRows.forEach(row -> {row.setSheetName(IcResiUserTableEnum.getObjectByTableName(row.tableName).getTableComment());}); + Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("导入失败的数据列表","导入失败的数据列表"), + ErrorRow.class, errorRows); + + // 文件名 + String resultDescFileName = UUID.randomUUID().toString().concat(".xls"); + + FileItemFactory factory = new DiskFileItemFactory(16, null); + FileItem fileItem = factory.createItem("file", ContentType.APPLICATION_OCTET_STREAM.toString(), true, resultDescFileName); + OutputStream os = fileItem.getOutputStream(); + Result uploadResult = null; + try { + workbook.write(os); + uploadResult = ossFeignClient.uploadImportTaskDescFile(new CommonsMultipartFile(fileItem)); + } catch (Exception e) { + String errormsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【居民信息导入】上传错误描述文件:{}", errormsg); + } finally { + try { + os.close(); + } catch (IOException e) { + String errormsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【居民信息导入】上传错误描述文件关闭输出流:{}", errormsg); + } + try { + fileItem.delete(); + } catch (Exception e) { + String errormsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【居民信息导入】上传错误描述文件删除临时文件:{}", errormsg); + } } - response.setHeader("Access-Control-Expose-Headers", "Content-Disposition"); - response.setHeader("content-Type", "application/vnd.ms-excel"); - response.setHeader("Content-Disposition", "attachment;fileName=" + URLEncoder.encode(fileName, "UTF-8")); - LinkedList list = new LinkedList<>(); - for (Map.Entry> entry : errorRows.get().entrySet()) { - list.addAll(entry.getValue()); + if (uploadResult == null || !uploadResult.success()) { + log.error("【居民信息导入】调用OSS上传结果描述文件失败"); + return null; } - - list.forEach(row -> {row.setSheetName(IcResiUserTableEnum.getObjectByTableName(row.tableName).getTableComment());}); - - Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("导入失败的列表","导入失败列表(没有数据说明全部成功)"), - ErrorRow.class, list); - - workbook.write(response.getOutputStream()); + return uploadResult.getData().getUrl(); } /** @@ -1083,93 +1164,6 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res return null; } - HashMap existingResiCategories = new HashMap<>(); - HashMap newResiCategories = new HashMap<>(); - - for (String categoryColumnName : resiCategoryColumnNameAndLabel.get().keySet()) { - String oldCategoryValue = existingResiMap.get(categoryColumnName); - String newCategoryValue = newResiMap.get(categoryColumnName); - - if (StringUtils.isBlank(oldCategoryValue)) oldCategoryValue = "0"; - if (StringUtils.isBlank(newCategoryValue)) newCategoryValue = "0"; - - if ("1".equals(oldCategoryValue) || "1".equals(newCategoryValue)) { - // 新旧值有一个为1,则放入 - existingResiCategories.put(categoryColumnName, oldCategoryValue); - newResiCategories.put(categoryColumnName, newCategoryValue); - } - -// if ("1".equals(oldCategoryValue)) { -// existingResiCategories.put(categoryColumnName, oldCategoryValue); -// } -// -// if ("1".equals(newCategoryValue)) { -// newResiCategories.put(categoryColumnName, newCategoryValue); -// } - } - - ResiImportCategoryData oldOne = new ResiImportCategoryData( - existingResiMap.get("ID"), - existingResiMap.get("AGENCY_ID"), - existingResiMap.get("GRID_ID"), - existingResiMap.get("VILLAGE_ID"), - existingResiMap.get("BUILD_ID"), - existingResiMap.get("UNIT_ID"), - existingResiMap.get("HOME_ID"), - existingResiCategories); - - ResiImportCategoryData newOne = new ResiImportCategoryData( - newResiMap.get("ID"), - newResiMap.get("AGENCY_ID"), - newResiMap.get("GRID_ID"), - newResiMap.get("VILLAGE_ID"), - newResiMap.get("BUILD_ID"), - newResiMap.get("UNIT_ID"), - newResiMap.get("HOME_ID"), - newResiCategories); - - return new ResiImportChangedData(oldOne, newOne); - } - - /** - * 类别变更的居民信息封装。只要发生变化,0或者1都要保存 - * 1. - * @param existingResiMap - * @param newResiMap - * @return - */ - private ResiImportChangedData getResiImportCategoryChangedData(Map existingResiMap, Map newResiMap) { - // 发生变化的类别列明 - HashMap oldCategories = new HashMap<>(); - HashMap newCategories = new HashMap<>(); - - Set categoryColumnNames = resiCategoryColumnNameAndLabel.get().keySet(); - for (String categoryColumnName : categoryColumnNames) { - - String existingColumnValue = existingResiMap.get(categoryColumnName); - String newColumnValue = newResiMap.get(categoryColumnName); - - // 先转为0再对比 - if (StringUtils.isBlank(existingColumnValue)) existingColumnValue = "0"; - if (StringUtils.isBlank(newColumnValue)) newColumnValue = "0"; - - if (!existingColumnValue.equals(newColumnValue)) { - oldCategories.put(categoryColumnName, existingColumnValue); - newCategories.put(categoryColumnName, newColumnValue); - } - -// if (StringUtils.isAllBlank(existingColumnValue, newColumnValue)) { -// // 都为空,则没发生变化 -// continue; -// } else { -// -// } - } - - if (oldCategories.size() == 0) { - return null; - } - ResiImportCategoryData oldOne = new ResiImportCategoryData( existingResiMap.get("ID"), existingResiMap.get("AGENCY_ID"), @@ -1178,7 +1172,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res existingResiMap.get("BUILD_ID"), existingResiMap.get("UNIT_ID"), existingResiMap.get("HOME_ID"), - oldCategories); + new HashMap<>()); ResiImportCategoryData newOne = new ResiImportCategoryData( newResiMap.get("ID"), @@ -1188,7 +1182,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res newResiMap.get("BUILD_ID"), newResiMap.get("UNIT_ID"), newResiMap.get("HOME_ID"), - newCategories); + new HashMap<>()); return new ResiImportChangedData(oldOne, newOne); } @@ -1197,20 +1191,19 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res * * @param icResiId 居民id * @param columnName 该项信息在主表的列名 + * @param existResiInfoMap 已存在的居民信息map */ - private void saveSubTableInfoToCategoryChangedResiCache(String icResiId, String columnName, Map resiInfoMap) { + private void saveSubTableInfoToCategoryChangedResiCache(String icResiId, String columnName, Map existResiInfoMap) { ResiImportResiCategoryChangedCache cc = newlyOrChangedResi.get(); -// Map newResis = cc.getNewResis(); Map categoryChangedResis = cc.getCategoryChangedResis(); Map transferedResis = cc.getTransferedResis(); -// ResiImportCategoryData newResi = newResis.get(icResiId); + // 为新增居民 String userCateRedisKey = RedisKeys.icResiImportResiCategoryKey(newlyOrChangedResi.get().getImportTag(), "add", icResiId); - Map < String, Object > addUserMap = redisUtils.hGetAll(userCateRedisKey); - if (addUserMap != null) { - //说明是新增居民 + Map addUserMap = redisUtils.hGetAll(userCateRedisKey); + if (addUserMap != null && addUserMap.size() > 0) { ResiImportCategoryData newResiCateData = ConvertUtils.mapToEntity(addUserMap, ResiImportCategoryData.class); newResiCateData.getCategories().put(columnName, "1"); redisUtils.hMSet(userCateRedisKey, BeanUtil.beanToMap(newResiCateData)); @@ -1218,47 +1211,53 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res return; } - ResiImportChangedData categoryChangedData = categoryChangedResis.get(icResiId); - if (categoryChangedData != null) { - // 说明是类别变更的居民 - Map oldCategories = categoryChangedData.getOldData().getCategories(); - Map newCategories = categoryChangedData.getNewData().getCategories(); - - if ("0".equals(resiInfoMap.get(columnName))) { - oldCategories.put(columnName, "0"); - newCategories.put(columnName, "1"); - } - - return; - } + String oldValue = existResiInfoMap.get(columnName); + // 为发生调动的居民。不管标志相同与否都往里面put ResiImportChangedData transferedData = transferedResis.get(icResiId); if (transferedData != null) { - // 说明是发生调动的居民,新数据值为1 Map newCategories = transferedData.getNewData().getCategories(); Map oldCategories = transferedData.getOldData().getCategories(); - String oldValue = resiInfoMap.get(columnName); - if (StringUtils.isBlank(oldValue)) { - oldValue = "0"; - } - - oldCategories.put(columnName, oldValue); + oldCategories.put(columnName, oldValue); newCategories.put(columnName, "1"); return; } - if ("0".equals(resiInfoMap.get(columnName))) { - // 非新增,非调动,变更的数据不在主sheet中,而在附sheet中。看是否发生人员类型变更(从0->1) - ResiImportCategoryData oldOne = new ResiImportCategoryData(); - ResiImportCategoryData newOne = new ResiImportCategoryData(); + // 类别变更的居民。不管标志相同与否都往里面put + ResiImportChangedData categoryChangedData = categoryChangedResis.get(icResiId); + if (categoryChangedData != null) { + Map oldCategories = categoryChangedData.getOldData().getCategories(); + Map newCategories = categoryChangedData.getNewData().getCategories(); - oldOne.getCategories().put(columnName, "0"); - newOne.getCategories().put(columnName, "1"); + oldCategories.put(columnName, oldValue); + newCategories.put(columnName, "1"); - ResiImportChangedData cd = new ResiImportChangedData(oldOne, newOne); - categoryChangedResis.put(icResiId, cd); + return; } + + // 非新增,非调动,可能是类别变更的,只是主表中没有数据,只有附加表的数据 + ResiImportCategoryData oldOne = new ResiImportCategoryData(); + ResiImportCategoryData newOne = new ResiImportCategoryData(); + + oldOne.setAgencyId(existResiInfoMap.get("AGENCY_ID")); + oldOne.setGridId(existResiInfoMap.get("GRID_ID")); + oldOne.setVillageId(existResiInfoMap.get("VILLAGE_ID")); + oldOne.setBuildId(existResiInfoMap.get("BUILD_ID")); + oldOne.setUnitId(existResiInfoMap.get("UNIT_ID")); + oldOne.setHomeId(existResiInfoMap.get("HOME_ID")); + oldOne.getCategories().put(columnName, oldValue); + + newOne.setAgencyId(existResiInfoMap.get("AGENCY_ID")); + newOne.setGridId(existResiInfoMap.get("GRID_ID")); + newOne.setVillageId(existResiInfoMap.get("VILLAGE_ID")); + newOne.setBuildId(existResiInfoMap.get("BUILD_ID")); + newOne.setUnitId(existResiInfoMap.get("UNIT_ID")); + newOne.setHomeId(existResiInfoMap.get("HOME_ID")); + newOne.getCategories().put(columnName, "1"); + + ResiImportChangedData cd = new ResiImportChangedData(oldOne, newOne); + categoryChangedResis.put(icResiId, cd); } /** @@ -1278,7 +1277,9 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res Map oldCategories = oldData.getCategories(); Map newCategories = newData.getCategories(); - fillResiSubCategoryInfo4TransferAndCategoryChange(oldData, newData); + Map resiInfoMap = icResiUserDao.selectResiInfoMap(null, resiId); + + fillResiSubCategoryInfo4TransferAndCategoryChange(oldData, newData, resiInfoMap); StringBuilder sbBefore = new StringBuilder(""); StringBuilder sbAfter = new StringBuilder(""); @@ -1295,23 +1296,19 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res } // 生成changeRecord并存入 - IcResiUserEntity resiInfo = icResiUserDao.selectById(resiId); - IcUserChangeRecordEntity changeRecord = fillChangeRecord(loginUserUtil.getLoginUserCustomerId(), resiId, resiInfo.getName(), null, loginUserUtil.getLoginUserId(), + IcUserChangeRecordEntity changeRecord = fillChangeRecord(loginUserUtil.getLoginUserCustomerId(), resiId, resiInfoMap.get("NAME"), null, loginUserUtil.getLoginUserId(), operator.getRealName() , descBefore, descAfter, "category", "类别", "", now); icUserChangeRecordDao.insert(changeRecord); for (Map.Entry columnEntry : newCategories.entrySet()) { String newValue = columnEntry.getValue(); String oldValue = oldCategories.get(columnEntry.getKey()); - oldValue = oldValue == null ? "0" : oldValue; if (newValue.equals(oldValue)) { // 新旧值相等,跳过 continue; } - int value = newValue.equals("1") && oldValue.equals("0") ? 1 : -1; - String agencyId = newData.getAgencyId(); String gridId = newData.getGridId(); String villageId = newData.getVillageId(); @@ -1319,17 +1316,9 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res String unitId = newData.getUnitId(); String homeId = newData.getHomeId(); - // 如果只有附加表信息,但是没有主表信息,并且附加表基础信息很多空着的,此处需要从主表获取了然后填充一下该信息 - if (agencyId == null) agencyId = resiInfo.getAgencyId(); - if (gridId == null) gridId = resiInfo.getGridId(); - if (villageId == null) villageId = resiInfo.getVillageId(); - if (buildId == null) buildId = resiInfo.getBuildId(); - if (unitId == null) unitId = resiInfo.getUnitId(); - if (homeId == null) homeId = resiInfo.getHomeId(); - IcUserChangeDetailedEntity newDetail = fillChangeDetail(loginUserUtil.getLoginUserCustomerId(), resiId, changeRecord.getId(), agencyId, gridId, villageId, buildId, unitId, - homeId, "category", "类别", columnEntry.getKey(), value, resiInfo.getPids()); + homeId, "category", "类别", columnEntry.getKey(), 1, resiInfoMap.get("PIDS")); icUserChangeDetailedDao.insert(newDetail); } @@ -1387,10 +1376,10 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res icUserChangeRecordDao.insert(changeRecord); // 插入changeDetail - for (Map.Entry column : newResiInfoObj.getCategories().entrySet()) { + for (Map.Entry mainTableColumn : newResiInfoObj.getCategories().entrySet()) { IcUserChangeDetailedEntity changedetail = fillChangeDetail(loginUserUtil.getLoginUserCustomerId(), newResiInfoObj.getResiId(), changeRecord.getId(), newResiInfoObj.getAgencyId(), newResiInfoObj.getGridId(), newResiInfoObj.getVillageId(), newResiInfoObj.getBuildId(), newResiInfoObj.getUnitId(), - newResiInfoObj.getHomeId(), "add", "新增", column.getKey(), 1, resiInfo.getPids()); + newResiInfoObj.getHomeId(), "add", "新增", mainTableColumn.getKey(), 1, resiInfo.getPids()); icUserChangeDetailedDao.insert(changedetail); changedetail = null; @@ -1413,11 +1402,15 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res for (Map.Entry resi : transferedResis.entrySet()) { String resiId = resi.getKey(); + Map resiInfoMap = icResiUserDao.selectResiInfoMap(null, resiId); + String resiName = resiInfoMap.get("NAME"); + String pids = resiInfoMap.get("PIDS"); + ResiImportCategoryData oldData = resi.getValue().getOldData(); ResiImportCategoryData newData = resi.getValue().getNewData(); // 把附加表的旧数据填充到新数据中 - fillResiSubCategoryInfo4TransferAndCategoryChange(oldData, newData); + fillResiSubCategoryInfo4TransferAndCategoryChange(oldData, newData, resiInfoMap); StringBuilder sbBefore = new StringBuilder(); StringBuilder sbAfter = new StringBuilder(); @@ -1428,7 +1421,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res String oldBuildId = oldData.getBuildId(); String oldUnitId = oldData.getUnitId(); String oldHomeId = oldData.getHomeId(); - // + String newAgencyId = newData.getAgencyId(); String newGridId = newData.getGridId(); String newvillageId = newData.getVillageId(); @@ -1438,22 +1431,22 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res IcResiUserOrgMsgFormDTO oldOrgFormDTO = new IcResiUserOrgMsgFormDTO(); oldOrgFormDTO.setCustomerId(customerId); - oldOrgFormDTO.setAgencyId(oldData.getAgencyId()); - oldOrgFormDTO.setGridId(oldData.getGridId()); - oldOrgFormDTO.setNeighborHoodId(oldData.getVillageId()); - oldOrgFormDTO.setBuildingId(oldData.getBuildId()); - oldOrgFormDTO.setBuildingUnitId(oldData.getUnitId()); - oldOrgFormDTO.setHouseId(oldData.getHomeId()); + oldOrgFormDTO.setAgencyId(oldAgencyId); + oldOrgFormDTO.setGridId(oldGridId); + oldOrgFormDTO.setNeighborHoodId(oldvillageId); + oldOrgFormDTO.setBuildingId(oldBuildId); + oldOrgFormDTO.setBuildingUnitId(oldUnitId); + oldOrgFormDTO.setHouseId(oldHomeId); Result oldOrgInfoRst = govOrgOpenFeignClient.icResiUserOrgMsg(oldOrgFormDTO); IcResiUserOrgMsgFormDTO newOrgInfo = new IcResiUserOrgMsgFormDTO(); newOrgInfo.setCustomerId(customerId); - newOrgInfo.setAgencyId(newData.getAgencyId()); - newOrgInfo.setGridId(newData.getGridId()); - newOrgInfo.setNeighborHoodId(newData.getVillageId()); - newOrgInfo.setBuildingId(newData.getBuildId()); - newOrgInfo.setBuildingUnitId(newData.getUnitId()); - newOrgInfo.setHouseId(newData.getHomeId()); + newOrgInfo.setAgencyId(newAgencyId); + newOrgInfo.setGridId(newGridId); + newOrgInfo.setNeighborHoodId(newvillageId); + newOrgInfo.setBuildingId(newBuildId); + newOrgInfo.setBuildingUnitId(newUnitId); + newOrgInfo.setHouseId(newHomeId); Result newOrgInfoRst = govOrgOpenFeignClient.icResiUserOrgMsg(newOrgInfo); IcResiUserOrgMsgResultDTO oldOrg = null; @@ -1516,16 +1509,14 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res } } - IcResiUserEntity resiInfo = icResiUserDao.selectById(resiId); - // 保存 transferRecord - IcUserTransferRecordEntity transferRecord = fillTransferRecord(resiInfo, operator, customerId, oldAgencyId, oldGridId, - oldvillageId, oldBuildId, oldUnitId, oldHomeId, customerId, + IcUserTransferRecordEntity transferRecord = fillTransferRecord(resiId, resiName, operator, customerId, + oldAgencyId, oldGridId, oldvillageId, oldBuildId, oldUnitId, oldHomeId, customerId, newAgencyId, newGridId, newvillageId, newBuildId, newUnitId, newHomeId, oldOrg, newOrg); icUserTransferRecordDao.insert(transferRecord); // 保存 调动changeRecord - IcUserChangeRecordEntity transferChangeRecord = fillChangeRecord(customerId, resiId, resiInfo.getName(), transferRecord.getId(), operator.getStaffId(), + IcUserChangeRecordEntity transferChangeRecord = fillChangeRecord(customerId, resiId, resiName, transferRecord.getId(), operator.getStaffId(), operator.getRealName(), sbBefore.toString(), sbAfter.toString(), "transfer", "调动", "", now); icUserChangeRecordDao.insert(transferChangeRecord); @@ -1534,17 +1525,14 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res sbAfter = new StringBuilder(); // 过滤居民类别的key并集 - Set bingji = new HashSet<>(); - newData.getCategories().keySet().forEach((k) -> bingji.add(k)); - oldData.getCategories().keySet().forEach((k) -> bingji.add(k)); +// Set bingji = new HashSet<>(); +// newData.getCategories().keySet().forEach((k) -> bingji.add(k)); +// oldData.getCategories().keySet().forEach((k) -> bingji.add(k)); - for (String category : bingji) { + for (String category : newData.getCategories().keySet()) { String newColumnValue = newData.getCategories().get(category); String oldColumnValue = oldData.getCategories().get(category); - if (oldColumnValue == null) oldColumnValue = "0"; - if (newColumnValue == null) newColumnValue = "0"; - if (newColumnValue.equals(oldColumnValue)) { continue; } @@ -1562,7 +1550,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res String categoryDescAfter = sbAfter.toString(); if (!StringUtils.isAllBlank(categoryDescBefore, categoryDescAfter)) { - IcUserChangeRecordEntity categoryChangeRecord = fillChangeRecord(customerId, resiId, resiInfo.getName(), transferRecord.getId(), operator.getStaffId(), + IcUserChangeRecordEntity categoryChangeRecord = fillChangeRecord(customerId, resiId, resiName, transferRecord.getId(), operator.getStaffId(), operator.getRealName(), categoryDescBefore, categoryDescAfter , "category", "类别", "", now); icUserChangeRecordDao.insert(categoryChangeRecord); } @@ -1575,9 +1563,9 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res // 之前是这个类型,那这个类型需要-1 String oldValue = oldCategories.getValue(); if ("1".equals(oldValue)) { - IcUserChangeDetailedEntity changeDetail = fillChangeDetail(customerId, resiId, transferChangeRecord.getId(), oldData.getAgencyId(), - oldData.getGridId(), oldData.getVillageId(), oldData.getBuildId(), oldData.getUnitId(), - oldData.getHomeId(), transferChangeRecord.getType(), transferChangeRecord.getTypeName(), key, -1, resiInfo.getPids()); + IcUserChangeDetailedEntity changeDetail = fillChangeDetail(customerId, resiId, transferChangeRecord.getId(), oldAgencyId, + oldGridId, oldvillageId, oldBuildId, oldUnitId, + oldHomeId, transferChangeRecord.getType(), transferChangeRecord.getTypeName(), key, -1, pids); icUserChangeDetailedDao.insert(changeDetail); } } @@ -1589,9 +1577,9 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res // 现在是这个类型,这个类型要+1 if ("1".equals(newValue)) { - IcUserChangeDetailedEntity changeDetail = fillChangeDetail(customerId, resiId, transferChangeRecord.getId(), newData.getAgencyId(), - newData.getGridId(), newData.getVillageId(), newData.getBuildId(), newData.getUnitId(), - newData.getHomeId(), transferChangeRecord.getType(), transferChangeRecord.getTypeName(), key, 1, resiInfo.getPids()); + IcUserChangeDetailedEntity changeDetail = fillChangeDetail(customerId, resiId, transferChangeRecord.getId(), newAgencyId, + newGridId, newvillageId, newBuildId, newUnitId, + newHomeId, transferChangeRecord.getType(), transferChangeRecord.getTypeName(), key, 1, pids); icUserChangeDetailedDao.insert(changeDetail); } } @@ -1604,18 +1592,43 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res * @param oldData * @param newData */ - private void fillResiSubCategoryInfo4TransferAndCategoryChange(ResiImportCategoryData oldData, ResiImportCategoryData newData) { - for (String category : oldData.getCategories().keySet()) { - String newValue = newData.getCategories().get(category); - String oldValue = oldData.getCategories().get(category); - - // 如果新数据中没有或者是0,并且是附加表信息,并且旧数据是1, 拿旧数据的过来 - if ((newValue == null || "0".equals(newValue)) - && "1".equals(oldValue) - && IcResiUserTableEnum.existsColumn(category)) { - newData.getCategories().put(category, "1"); + private void fillResiSubCategoryInfo4TransferAndCategoryChange(ResiImportCategoryData oldData, ResiImportCategoryData newData, Map resiInfoMap) { + + Map oldCates = oldData.getCategories(); + Map newCates = newData.getCategories(); + + for (IcResiUserTableEnum c : IcResiUserTableEnum.values()) { + // 主表,跳过 + String mainTableColumnName = c.getMainTableFlagColumnName(); + if (mainTableColumnName == null) { + return; + } + + // 不为空,说明本次导入含有该居民的类别信息,不需要补充 + String oldValue = oldCates.get(mainTableColumnName); + if (StringUtils.isNotBlank(oldValue)) { + return; + } + + // 本次导入不含有该居民类别信息,db中存储的数据,如果是1,newValue和oldValue都应该为1 + oldValue = resiInfoMap.get(mainTableColumnName); + if ("1".equals(oldValue)) { + oldCates.put(mainTableColumnName, oldValue); + newCates.put(mainTableColumnName, oldValue); } } + +// for (String category : oldData.getCategories().keySet()) { +// String newValue = newData.getCategories().get(category); +// String oldValue = oldData.getCategories().get(category); +// +// // 如果新数据中没有或者是0,并且是附加表信息,并且旧数据是1, 拿旧数据的过来 +// if ((newValue == null || "0".equals(newValue)) +// && "1".equals(oldValue) +// && IcResiUserTableEnum.existsColumn(category)) { +// newData.getCategories().put(category, "1"); +// } +// } } /** @@ -1695,7 +1708,6 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res /** * 填充调动记录 - * @param resiInfo * @param operator * @param oldCustomerId * @param oldAgencyId @@ -1713,15 +1725,15 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res * @param newHomeId * @return */ - private IcUserTransferRecordEntity fillTransferRecord(IcResiUserEntity resiInfo, CustomerStaffInfoCacheResult operator, String oldCustomerId, String oldAgencyId, String oldGridId, + private IcUserTransferRecordEntity fillTransferRecord(String resiId, String resiName, CustomerStaffInfoCacheResult operator, String oldCustomerId, String oldAgencyId, String oldGridId, String oldVillageId, String oldBuildId, String oldUnitId, String oldHomeId, String newCustomerId, String newAgencyId, String newGridId, String newVillageId, String newBuildId, String newUnitId, String newHomeId, IcResiUserOrgMsgResultDTO oldOrg, IcResiUserOrgMsgResultDTO newOrg) { IcUserTransferRecordEntity recordEntity = new IcUserTransferRecordEntity(); - recordEntity.setIcUserId(resiInfo.getId()); + recordEntity.setIcUserId(resiId); recordEntity.setOperatorId(operator.getStaffId()); - recordEntity.setIcUserName(resiInfo.getName()); + recordEntity.setIcUserName(resiName); recordEntity.setOperatorName(operator.getRealName()); recordEntity.setOldCustomerId(oldCustomerId); recordEntity.setOldAgencyId(oldAgencyId); @@ -1755,45 +1767,45 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res return recordEntity; } + /** + * 创建导入任务 + * @param operatorId + * @param bizType + * @return + */ + public String createImportTaskRecord(String operatorId, String bizType, String originFilename) { + ImportTaskCommonFormDTO importTaskForm = new ImportTaskCommonFormDTO(); + importTaskForm.setOperatorId(operatorId); + importTaskForm.setBizType(bizType); + importTaskForm.setOriginFileName(originFilename); + Result result = commonServiceOpenFeignClient.createImportTask(importTaskForm); + if (result != null && !result.success()) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), result.getMsg(), result.getMsg()); + } + return result.getData().getTaskId(); + } - - //private IcUserTransferRecordEntity fillTransferRecord(String resiId, String resiName, String operatorId, String operatorName, String oldCustomerId, - // String oldAgencyId, String oldAgencyName, String oldGridId, String oldGridName, String neighborhoodId, - // String neighborhoodName, String oldBuildingId, String oldBuildingName, ) { - - //IcUserTransferRecordEntity recordEntity = new IcUserTransferRecordEntity(); - //recordEntity.setIcUserId(); - //recordEntity.setOperatorId(); - //recordEntity.setIcUserName(); - //recordEntity.setOperatorName(); - //recordEntity.setOldCustomerId(); - //recordEntity.setOldAgencyId(); - //recordEntity.setOldAgencyName(); - //recordEntity.setOldGridId(); - //recordEntity.setOldGridName(); - //recordEntity.setOldNeighborHoodId(); - //recordEntity.setOldNeighborHoodName(); - //recordEntity.setOldBuildingId(); - //recordEntity.setOldBuildingName(); - //recordEntity.setOldBuildingUnitId(); - //recordEntity.setOldBuildingUnitName(); - //recordEntity.setOldHouseId(); - //recordEntity.setOldHouseName(); - //recordEntity.setTransferTime(); - //recordEntity.setRemark(); - //recordEntity.setNewCustomerId(); - //recordEntity.setNewAgencyId(); - //recordEntity.setNewAgencyName(); - //recordEntity.setNewGridId(); - //recordEntity.setNewGridName(); - //recordEntity.setNewNeighborHoodId(); - //recordEntity.setNewNeighborHoodName(); - //recordEntity.setNewBuildingId(); - //recordEntity.setNewBuildingName(); - //recordEntity.setNewBuildingUnitId(); - //recordEntity.setNewBuildingUnitName(); - //recordEntity.setNewHouseId(); - //recordEntity.setNewHouseName(); - //} + /** + * 完成导入任务 + * @param importTaskId 任务ID + * @param operatorId 操作者ID + * @param processStatus 处理状态,见 ImportTaskConstants.PROCESS_STATUS_* + * @param resultDesc 结果描述,非必填 + * @param resultDescPath 结果描述文件,excel等文件,有错误的话需要传入,成功则不需要 + */ + public void finishImportTask(String importTaskId, String operatorId, String processStatus, String resultDesc, String resultDescPath) { + ImportTaskCommonFormDTO importFinishTaskForm = new ImportTaskCommonFormDTO(); + importFinishTaskForm.setTaskId(importTaskId); + importFinishTaskForm.setProcessStatus(processStatus); + importFinishTaskForm.setOperatorId(operatorId); + importFinishTaskForm.setResultDesc(resultDesc); + importFinishTaskForm.setResultDescFilePath(resultDescPath); + + Result result = commonServiceOpenFeignClient.finishImportTask(importFinishTaskForm); + if (result == null || !result.success()) { + log.error("【居民信息导入】结束导入任务失败:taskId:{}, processStatus:{}, operatorId:{}, resultDesc:{}, resultDescPath:{}", + importTaskId, processStatus, operatorId, resultDesc, resultDescPath); + } + } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java index 5709333e9b..bab73c6909 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java @@ -20,11 +20,9 @@ package com.epmet.service.impl; import cn.hutool.core.bean.BeanUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.epmet.bean.ResiExportBaseInfoData; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; -import com.epmet.commons.tools.constant.FieldConstant; -import com.epmet.commons.tools.constant.NumConstant; -import com.epmet.commons.tools.constant.ServiceConstant; -import com.epmet.commons.tools.constant.StrConstant; +import com.epmet.commons.tools.constant.*; import com.epmet.commons.tools.dto.form.DictListFormDTO; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.dto.result.DictListResultDTO; @@ -42,8 +40,10 @@ import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; import com.epmet.commons.tools.redis.common.bean.GridInfoCache; import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.security.user.LoginUserUtil; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.commons.tools.utils.HttpContextUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.constant.IcPlatformConstant; import com.epmet.constant.IcResiUserConstant; @@ -69,14 +69,18 @@ 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.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; import java.math.RoundingMode; import java.sql.Date; import java.sql.Timestamp; import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.TimeUnit; import java.util.function.Function; import java.util.stream.Collectors; @@ -114,6 +118,8 @@ public class IcResiUserServiceImpl extends BaseServiceImpl getWrapper(Map params){ String id = (String)params.get(FieldConstant.ID_HUMP); @@ -638,7 +644,7 @@ public class IcResiUserServiceImpl extends BaseServiceImpl nameList=new ArrayList<>(); for(String codePath:demandCodePath){ - if(codePath.contains(StrConstant.COMMA)){ + if (StringUtils.isNotBlank(codePath) && codePath.contains(StrConstant.COMMA)) { String[] codeAtt=codePath.split(StrConstant.COMMA); String code=codeAtt[codeAtt.length-1]; if(StringUtils.isNotBlank(code)&&demandDictMap.containsKey(code)){ @@ -881,7 +887,7 @@ public class IcResiUserServiceImpl extends BaseServiceImpl> mapListPage = PageHelper.startPage(pageFormDTO.getPageNo(), pageFormDTO.getPageSize(), pageFormDTO.getPageFlag()).doSelectPage(() -> { this.dynamicQuery(pageFormDTO.getCustomerId(), pageFormDTO.getFormCode(), baseTableName, pageFormDTO.getConditions(), currentStaffAgencyId, staffOrgPath); }); - mapListPage.getResult().stream().filter(Objects::nonNull).forEach(resiUser -> { + mapListPage.getResult().parallelStream().filter(Objects::nonNull).forEach(resiUser -> { String resiId = null; //获取用户Id if (IcResiUserConstant.IC_RESI_USER.equals(baseTableName)) { @@ -905,28 +911,33 @@ public class IcResiUserServiceImpl extends BaseServiceImpl originalConditionMap = new HashMap<>(); - for (FormItemResult e : formItemMap.getItemMap().values()) { + Map originalConditionMap = new ConcurrentHashMap<>(); + formItemMap.getItemMap().values().parallelStream().forEach(e->{ String columnName = getColumnName(e); Object temp = resiUser.get(columnName); String vauleStr = temp == null ? StrConstant.EPMETY_STR : temp.toString(); originalConditionMap.putIfAbsent(columnName,vauleStr); - if ("remote".equals(e.getOptionSourceType()) && StringUtils.isNotBlank(vauleStr)) { + if (Constant.OPITON_SOURCE_REMOTE.equals(e.getOptionSourceType()) && StringUtils.isNotBlank(vauleStr)) { putRemoteValue(formItemMap.getRemoteItemConditionMap().get(e.getItemId()), currentStaffAgencyId, resiUser,originalConditionMap, e, columnName, vauleStr); } else { putOptionValue(resiUser, e, columnName, vauleStr); } + }); - } - if (!IcResiUserConstant.IC_RESI_USER.equals(baseTableName)) { - Map o = redisUtils.hGetAll(RedisKeys.getExportResiBaseInfoKey(resiId)); - if (o != null){ - resiUser.putAll(o); + if (IcResiUserConstant.IC_RESI_USER.equals(baseTableName)) { + //把人放入redis缓存 便于后面的sheet使用基础信息 + ResiExportBaseInfoData infoData = ConvertUtils.mapToEntity(resiUser, ResiExportBaseInfoData.class); + redisTemplate.opsForValue().set(RedisKeys.getExportResiBaseInfoKey(resiId), infoData,RedisUtils.MINUTE_THIRTY_EXPIRE, TimeUnit.SECONDS); + } else { + ResiExportBaseInfoData temp = (ResiExportBaseInfoData) redisTemplate.opsForValue().get(RedisKeys.getExportResiBaseInfoKey(resiId)); + if (temp != null){ + try { + resiUser.putAll(ConvertUtils.entityToMap(temp)); + } catch (Exception e) { + log.error("entityToMap exception,temp:{}",temp); + } } - return; } - //把人放入redis缓存 便于后面的sheet使用基础信息 - redisUtils.hMSet(RedisKeys.getExportResiBaseInfoKey(resiId),resiUser,RedisUtils.MINUTE_THIRTY_EXPIRE); }); remoteOptionCacheMap.clear(); return mapListPage.getResult(); @@ -962,9 +973,11 @@ public class IcResiUserServiceImpl extends BaseServiceImpl remoteOptions = icResiUserImportService.listRemoteOptions(columnWrappers, e.getOptionSourceValue(), currentStaffAgencyId, "query"); + String[] parts = icResiUserImportService.splitOptionSourceUrl(e.getOptionSourceValue()); + + Map remoteOptions = icResiUserImportService.listRemoteOptions(parts[0], parts[1], columnWrappers, currentStaffAgencyId, "query"); if (FormItemTypeEnum.CHECKBOX.getCode().equals(e.getItemType())) { - remoteOptions.forEach((label, value) -> map.put(value, vauleStr.contains(value) ? "是" : "否")); + remoteOptions.forEach((label, value) -> map.put(value, vauleStr.contains(value) ? StrConstant.YES : StrConstant.NO)); } else if (FormItemTypeEnum.SELECT.getCode().equals(e.getItemType())) { remoteOptions.forEach((label, value) -> { if (vauleStr.equals(value)) { @@ -984,7 +997,7 @@ public class IcResiUserServiceImpl extends BaseServiceImpl { - map.put(optionDTO.getValue(), vauleStr.contains(optionDTO.getValue()) ? "是" : "否"); + map.put(optionDTO.getValue(), vauleStr.contains(optionDTO.getValue()) ? StrConstant.YES : StrConstant.NO); }); break; case SELECT: diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/ImportTaskServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/ImportTaskServiceImpl.java deleted file mode 100644 index d80ee5d9a6..0000000000 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/ImportTaskServiceImpl.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.epmet.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.epmet.constant.ImportTaskConstants; -import com.epmet.dao.ImportTaskDao; -import com.epmet.entity.ImportTaskEntity; -import com.epmet.service.ImportTaskService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.Date; - -/** - * - * - * @author generator generator@elink-cn.com - * @since v1.0.0 2022-02-15 - */ -@Service -public class ImportTaskServiceImpl implements ImportTaskService { - - @Autowired - private ImportTaskDao importRecordDao; - - /** - * 该用户,该业务类型,是否有正在处理的导入任务 - * @param operatorId 操作者ID - * @param bizType 业务类型。resi:居民 - * @return - */ - @Override - public boolean existsProcessingTask(String operatorId, String bizType) { - LambdaQueryWrapper query = new LambdaQueryWrapper<>(); - query.eq(ImportTaskEntity::getOperatorId, operatorId); - query.eq(ImportTaskEntity::getBizType, bizType); - query.eq(ImportTaskEntity::getProcessStatus, ImportTaskConstants.PROCESS_STATUS_PROCESSING); - - return importRecordDao.selectCount(query) > 0; - } - - @Override - public String createProcessTask(String operatorId, String bizType) { - ImportTaskEntity importRecord = new ImportTaskEntity(); - importRecord.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_PROCESSING); - importRecord.setOperatorId(operatorId); - importRecord.setBizType(bizType); - importRecord.setStartTime(new Date()); - - importRecordDao.insert(importRecord); - return importRecord.getId(); - } - - @Override - public Boolean finish(String taskId, String processStatus, String operatorId, String resultDescFile, String resultDesc) { - return importRecordDao.finish(taskId, processStatus, operatorId, resultDesc, resultDescFile) > 0; - } -} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/PatrolRoutineWorkServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/PatrolRoutineWorkServiceImpl.java index bc850e1d2c..df3d1c3418 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/PatrolRoutineWorkServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/PatrolRoutineWorkServiceImpl.java @@ -25,29 +25,33 @@ import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.rocketmq.messages.BaseMQMsgDTO; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; +import com.epmet.commons.tools.dto.form.UpdateUserPointsFormDTO; +import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.dto.result.DictTreeResultDTO; +import com.epmet.commons.tools.enums.BehaviorTypeYuShanEnum; import com.epmet.commons.tools.enums.DictTypeEnum; import com.epmet.commons.tools.enums.OrgTypeEnum; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.redis.common.CustomerOrgRedis; +import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; import com.epmet.commons.tools.redis.common.bean.GridInfoCache; import com.epmet.commons.tools.security.user.LoginUserUtil; import com.epmet.commons.tools.utils.ConvertUtils; -import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.ExcelUtils; import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.utils.YuShanSysApiService; import com.epmet.constant.SystemMessageType; import com.epmet.dao.PatrolRoutineWorkDao; +import com.epmet.dao.StatsStaffPatrolRecordDailyDao; import com.epmet.dto.CustomerGridDTO; import com.epmet.dto.form.CustomerGridFormDTO; import com.epmet.dto.form.PatrolRoutineWorkFormDTO; import com.epmet.dto.form.PcWorkListFormDTO; +import com.epmet.dto.form.patrol.GridMemberRoutineWorkFormDTO; import com.epmet.dto.form.patrol.PatrolQueryFormDTO; -import com.epmet.dto.result.AllGridsByUserIdResultDTO; -import com.epmet.dto.result.PatrolRoutineWorkResult; -import com.epmet.dto.result.PcWorkListResultDTO; +import com.epmet.dto.result.*; import com.epmet.entity.PatrolRoutineWorkEntity; import com.epmet.entity.PatrolRoutineWorkTypeEntity; import com.epmet.excel.PcWorkListExport; @@ -61,6 +65,7 @@ import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -68,13 +73,10 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import javax.servlet.http.HttpServletResponse; -import java.beans.Encoder; import java.net.URLEncoder; import java.util.*; import java.util.stream.Collectors; -import static com.epmet.commons.tools.utils.DateUtils.DATE_PATTERN; - /** * 巡查例行工作 * @@ -94,6 +96,10 @@ public class PatrolRoutineWorkServiceImpl extends BaseServiceImpl NumConstant.ZERO ? resultDTO.getTotalNum() / 60 : 0); + String patrolDuration = (minutes / 60 > 0 ? minutes / 60 + "小时" : "") + (minutes % 60 > 0 ? minutes % 60 + "分钟" : "0分钟"); + resultDTO.setTotalTime(patrolDuration); + + return resultDTO; + } + + /** + * @Author sun + * @Description 【例行工作】网格员例行工作列表 + **/ + @Override + public RoutineWorkListResultDTO list(GridMemberRoutineWorkFormDTO formDTO) { + RoutineWorkListResultDTO resultDTO = new RoutineWorkListResultDTO(); + //1.按条件查询网格员例行工作列表数据 + PageInfo result = + PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()).doSelectPageInfo(() -> baseDao.staffRoutineWorkList(formDTO.getGridId(), formDTO.getStaffId())); + if (org.springframework.util.CollectionUtils.isEmpty(result.getList())) { + return resultDTO; + } + + //2.查询分类编码字典数据 + Result> unitTypeMap = adminOpenFeignClient.dictMap(DictTypeEnum.PATROL_WORK_TYPE.getCode()); + if (!unitTypeMap.success() || MapUtils.isEmpty(unitTypeMap.getData())) { + throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), "获取例行工作类型字典表数据失败!"); + } + Map map = unitTypeMap.getData(); + + //3.封装数据并返回 + result.getList().forEach(re -> { + re.setWorkTypeName(map.get(re.getWorkTypeCode()) + "-" + map.get(re.getWorkTypeCode())); + }); + resultDTO.setTotal((int) result.getTotal()); + resultDTO.setList(result.getList()); + return resultDTO; + } + + /** + * @Author sun + * @Description 【例行工作】例行工作详情 + **/ + @Override + public RoutineWorkDetailResultDTO detail(GridMemberRoutineWorkFormDTO formDTO) { + //1.查询例行工作详情数据 + RoutineWorkDetailResultDTO resultDTO = baseDao.getDetail(formDTO.getRoutineWorkId()); + if (null == resultDTO) { + return new RoutineWorkDetailResultDTO(); + } + //2.获取工作人员缓存信息 + CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getStaffId()); + if (null == staffInfo) { + throw new EpmetException(String.format("查询工作人员%s缓存信息失败...", formDTO.getStaffId())); + } + //3.获取网格缓存信息 + GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(resultDTO.getGridId()); + if (null == gridInfo) { + throw new EpmetException(String.format("未查询到网格{%s}信息", resultDTO.getGridId())); + } + if (StringUtils.isEmpty(gridInfo.getAgencyName())) { + AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(gridInfo.getPid()); + gridInfo.setAgencyName(agencyInfo.getOrganizationName()); + } + //4.获取例行工作类型字典表数据 + Result> unitTypeMap = adminOpenFeignClient.dictMap(DictTypeEnum.PATROL_WORK_TYPE.getCode()); + if (!unitTypeMap.success() || MapUtils.isEmpty(unitTypeMap.getData())) { + throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), "获取例行工作类型字典表数据失败!"); + } + //5.封装数据并返回 + resultDTO.setGridName(gridInfo.getAgencyName() + "-" + gridInfo.getGridName()); + resultDTO.setStaffName(staffInfo.getRealName()); + resultDTO.setWorkTypeName(unitTypeMap.getData().get(resultDTO.getAllPCode()) + "-" + unitTypeMap.getData().get(resultDTO.getWorkTypeCode())); + return resultDTO; + + } + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffPatrolRecordServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffPatrolRecordServiceImpl.java index 9ddd74e7aa..770cf8f650 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffPatrolRecordServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffPatrolRecordServiceImpl.java @@ -9,8 +9,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.rocketmq.messages.StaffPatrolMQMsg; import com.epmet.commons.tools.constant.NumConstant; -import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.constant.StrConstant; +import com.epmet.commons.tools.dto.form.UpdateUserPointsFormDTO; +import com.epmet.commons.tools.enums.BehaviorTypeYuShanEnum; import com.epmet.commons.tools.enums.OrgTypeEnum; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; @@ -21,10 +22,7 @@ import com.epmet.commons.tools.redis.common.CustomerOrgRedis; import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; import com.epmet.commons.tools.redis.common.bean.GridInfoCache; import com.epmet.commons.tools.security.dto.TokenDto; -import com.epmet.commons.tools.utils.ConvertUtils; -import com.epmet.commons.tools.utils.DateUtils; -import com.epmet.commons.tools.utils.ExcelUtils; -import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.utils.*; import com.epmet.constant.PatrolConstant; import com.epmet.constant.SystemMessageType; import com.epmet.dao.CustomerStaffDao; @@ -58,8 +56,6 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; @@ -92,7 +88,8 @@ public class StaffPatrolRecordServiceImpl extends BaseServiceImplsendPatrolMsg(e, SystemMessageType.USER_PATROL_STOP)); + list.forEach(e-> { + sendPatrolMsg(e, SystemMessageType.USER_PATROL_STOP); + //网格员结束巡查,如果是榆山街道的工作人员,需要调用【更新用户积分(双实信息更新 网格巡查)】/api/points/behavior/updateUserPoints + UpdateUserPointsFormDTO updateUserPointsFormDTO=new UpdateUserPointsFormDTO(); + updateUserPointsFormDTO.setCustomerId(e.getCustomerId()); + updateUserPointsFormDTO.setStaffId(e.getStaffId()); + updateUserPointsFormDTO.setBehaviorType(BehaviorTypeYuShanEnum.GRID_PATROL.getCode()); + yuShanSysApiService.updateUserPoints(e.getCustomerId(),Arrays.asList(updateUserPointsFormDTO)); + }); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffRoleServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffRoleServiceImpl.java index fca7a68aed..6b69b9506b 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffRoleServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffRoleServiceImpl.java @@ -32,6 +32,7 @@ import com.epmet.entity.StaffRoleEntity; import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.service.StaffRoleService; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.ListUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -136,6 +137,8 @@ public class StaffRoleServiceImpl extends BaseServiceImpl(); } + List userIds = forms.stream().map(m -> m.getStaffId()).distinct().collect(Collectors.toList()); +// List result = baseDao.staffGridRoleByIds(userIds); List result = baseDao.staffGridRole(forms); if (CollectionUtils.isEmpty(result)){ return new ArrayList<>(); diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StatsResiWarnServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StatsResiWarnServiceImpl.java index 5178ecbd3a..c6b33e482b 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StatsResiWarnServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StatsResiWarnServiceImpl.java @@ -27,6 +27,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import javax.annotation.Resource; +import java.math.BigDecimal; import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; @@ -189,6 +190,20 @@ public class StatsResiWarnServiceImpl implements StatsResiWarnService { List icResiCategoryStatsConfigDTOList = statsResult.getData(); //获取tableName 和columnName List result = new ArrayList<>(); + //tableName List + Map> paramMap = new HashMap<>(); + icResiCategoryStatsConfigDTOList.forEach(config->{ + List list = paramMap.getOrDefault(config.getTableName(), new ArrayList<>()); + list.add(config.getColumnName()); + paramMap.put(config.getTableName(),list); + }); + Map> tableColumnCountMap = new HashMap<>(); + paramMap.forEach((tableName,columnList) ->{ + Map countMap = icResiUserDao.getDataAnalyseCount(customerId,tableName,columnList, id,level); + if (countMap != null){ + tableColumnCountMap.put(tableName,countMap); + } + }); icResiCategoryStatsConfigDTOList.forEach(item->{ IcStatsResiResultDTO resultDTO = new IcStatsResiResultDTO(); resultDTO.setId(item.getId()); @@ -197,8 +212,9 @@ public class StatsResiWarnServiceImpl implements StatsResiWarnService { resultDTO.setHouseShowIcon(item.getHouseShowIcon()); resultDTO.setManagementIcon(item.getManagementIcon()); //根据id ,level 获取count - Integer count = icStatsResiWarnDao.countListByLevelAndCol(customerId,item.getTableName(),item.getColumnName(),id,level); - resultDTO.setCount(count); + //Integer count = icStatsResiWarnDao.countListByLevelAndCol(customerId,item.getTableName(),item.getColumnName(),id,level); + Map orDefault = tableColumnCountMap.getOrDefault(item.getTableName(), new HashMap<>()); + resultDTO.setCount(orDefault.getOrDefault(item.getColumnName(), NumConstant.ZERO_DECIMAL).intValue()); result.add(resultDTO); }); return result; diff --git a/epmet-user/epmet-user-server/src/main/resources/bootstrap.yml b/epmet-user/epmet-user-server/src/main/resources/bootstrap.yml index cce9a52831..37b078e18f 100644 --- a/epmet-user/epmet-user-server/src/main/resources/bootstrap.yml +++ b/epmet-user/epmet-user-server/src/main/resources/bootstrap.yml @@ -165,3 +165,14 @@ shutdown: graceful: enable: true #是否开启优雅停机 waitTimeSecs: 30 # 优雅停机等待时间,超过30秒,发出告警 + +thread: + # 线程池配置 + threadPool: + enableCustomize: @thread.threadPool.enable-customize@ + corePoolSize: @thread.threadPool.core-pool-size@ + maxPoolSize: @thread.threadPool.max-pool-size@ + queueCapacity: @thread.threadPool.queue-capacity@ + keepAliveSeconds: @thread.threadPool.keep-alive-seconds@ + threadNamePrefix: @thread.threadPool.thread-name-prefix@ + rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@ \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml index 14feeb27b8..ff945fede7 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml @@ -552,8 +552,12 @@ @@ -594,4 +598,34 @@ ORDER BY iru.created_time ASC + diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/PatrolRoutineWorkDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/PatrolRoutineWorkDao.xml index 78cf718131..5d155dbe82 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/PatrolRoutineWorkDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/PatrolRoutineWorkDao.xml @@ -86,5 +86,47 @@ SELECT WORK_TYPE_CODE AS workTypeCode FROM patrol_routine_work_type WHERE DEL_FLAG = 0 AND ROUTINE_WORK_ID = #{wid} + + + + diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/StaffRoleDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/StaffRoleDao.xml index 777ef27ee8..6ce9736f4d 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/StaffRoleDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/StaffRoleDao.xml @@ -210,6 +210,23 @@ + + + + \ No newline at end of file