From fd6135acc1772268b22c86ab325337620292f9c5 Mon Sep 17 00:00:00 2001 From: jianjun Date: Sat, 26 Mar 2022 09:13:21 +0800 Subject: [PATCH 01/19] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ScreenExtractDailyController.java | 18 +++++++++--------- .../impl/ScreenExtractServiceImpl.java | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) 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 466774ecc5..efc03d5e79 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 @@ -39,15 +39,15 @@ public class ScreenExtractDailyController { */ @PostMapping("extractdailyall") public Result screenExtractDaily(@RequestBody ExtractOriginFormDTO extractOriginFormDTO) { - executorService.submit(() -> { - log.info("screenExtractDaily start,param:{}", JSON.toJSONString(extractOriginFormDTO)); - try { - screenExtractService.extractDailyAll(extractOriginFormDTO); - log.info("screenExtractDaily end"); - } catch (Exception e) { - log.error("screenExtractDaily exception", e); - } - }); + + log.info("screenExtractDaily start,param:{}", JSON.toJSONString(extractOriginFormDTO)); + try { + screenExtractService.extractDailyAll(extractOriginFormDTO); + log.info("screenExtractDaily end"); + } catch (Exception e) { + log.error("screenExtractDaily exception", e); + } + return new Result(); } 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 e3ed39133b..b3217ceef5 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 @@ -342,7 +342,7 @@ public class ScreenExtractServiceImpl implements ScreenExtractService { } log.info("===== extractDaily method end customerId:{}======",customerId); } catch (Exception e) { - log.error("extractDaily exception msg:{}", e); + log.error("extractDaily exception msg", e); } finally { distributedLock.unLock(lock); } From 7e41369e96315181e987e2a21e25c7fecf29c75b Mon Sep 17 00:00:00 2001 From: jianjun Date: Sun, 27 Mar 2022 18:13:51 +0800 Subject: [PATCH 02/19] =?UTF-8?q?=E6=B6=88=E8=B4=B9=E5=B7=A1=E6=9F=A5?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../listener/OpenDataPatrolChangeEventListener.java | 9 +++++---- .../service/impl/UserPatrolRecordServiceImpl.java | 13 +++---------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataPatrolChangeEventListener.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataPatrolChangeEventListener.java index a9c2b50e57..c2cd63b509 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataPatrolChangeEventListener.java +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataPatrolChangeEventListener.java @@ -6,6 +6,8 @@ import com.epmet.commons.rocketmq.messages.StaffPatrolMQMsg; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.distributedlock.DistributedLock; +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.redis.RedisKeys; @@ -77,10 +79,6 @@ public class OpenDataPatrolChangeEventListener implements MessageListenerConcurr if (!StrConstant.PY_CUSTOMER.equals(msgObj.getCustomerId())) { return; } - if (msgObj == null) { - log.warn("consumeMessage msg body is blank"); - return; - } RLock lock = null; try { lock = distributedLock.getLock(String.format("lock:open_data_patrol:%s:%s",tags, msgObj.getObjectId()), @@ -104,6 +102,9 @@ public class OpenDataPatrolChangeEventListener implements MessageListenerConcurr log.error("错误的消息类型:{}", tags); } + if (aBoolean == null || !aBoolean){ + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"消费失败!"); + } } catch (RenException e) { // 如果是我们手动抛出的异常,说明在业务可控范围内。目前不需要MQ重试 diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/UserPatrolRecordServiceImpl.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/UserPatrolRecordServiceImpl.java index 064b6c9219..c8a6b37881 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/UserPatrolRecordServiceImpl.java +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/UserPatrolRecordServiceImpl.java @@ -71,12 +71,8 @@ public class UserPatrolRecordServiceImpl extends BaseServiceImpl data = record.getData(); if (CollectionUtils.isEmpty(data)) { - //数据已被删除了 - //暂时设置error 用于排错 - log.error("insertPatrolRecord获取巡查记录返回为空,param:{}", JSON.toJSONString(midPatrolFormDTO)); - int effectRow = baseDao.deleteById(patrolRecordForm.getId()); - log.warn("del effectRow:{}", effectRow); - throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode()); + //数据还未被插入 + throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(),"获取巡查记录返回为空,param:"+ JSON.toJSONString(midPatrolFormDTO)); } List insertList = new ArrayList<>(); data.forEach(o-> insertList.add(buildEntity(o))); @@ -103,10 +99,7 @@ public class UserPatrolRecordServiceImpl extends BaseServiceImpl{ UserPatrolRecordEntity recordEntity = buildEntity(o); From 33661f258e7a9e5388b5027adf4ea0db8d4817eb Mon Sep 17 00:00:00 2001 From: jianjun Date: Sun, 27 Mar 2022 21:41:58 +0800 Subject: [PATCH 03/19] =?UTF-8?q?id=20=E9=87=8D=E5=A4=8D=20=E8=AF=95?= =?UTF-8?q?=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- epmet-user/epmet-user-server/src/main/resources/bootstrap.yml | 3 +++ 1 file changed, 3 insertions(+) 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 8636a8411e..a9ec2fcadb 100644 --- a/epmet-user/epmet-user-server/src/main/resources/bootstrap.yml +++ b/epmet-user/epmet-user-server/src/main/resources/bootstrap.yml @@ -106,6 +106,9 @@ mybatis-plus: field-strategy: NOT_NULL #驼峰下划线转换 column-underline: true + worker-id: ${random.int(1,31)} + datacenter-id: ${random.int(1,31)} + banner: false #原生配置 configuration: From ce0eb794e2d7ce1346daaf55a140d381ac7a8814 Mon Sep 17 00:00:00 2001 From: jianjun Date: Sun, 27 Mar 2022 21:53:28 +0800 Subject: [PATCH 04/19] =?UTF-8?q?=E8=B6=85=E6=97=B6=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../opendata/service/impl/BaseDisputeProcessServiceImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BaseDisputeProcessServiceImpl.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BaseDisputeProcessServiceImpl.java index 0716e24990..81ca02745e 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BaseDisputeProcessServiceImpl.java +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BaseDisputeProcessServiceImpl.java @@ -72,8 +72,10 @@ public class BaseDisputeProcessServiceImpl extends BaseServiceImpl> result = dataStatisticalOpenFeignClient.getEventInfo(formDTO); if (!result.success()) { + log.error("getEventinfo cost:{}ms",System.currentTimeMillis()-start); throw new RenException(result.getInternalMsg()); } Map deptMap = exDeptService.getDeptDTOMap(); From 26e7db0ca0ac2659dc9937b63e23cc4bceabd9a0 Mon Sep 17 00:00:00 2001 From: jianjun Date: Mon, 28 Mar 2022 10:37:17 +0800 Subject: [PATCH 05/19] =?UTF-8?q?stats=20=E9=85=8D=E7=BD=AEdriud=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E6=B1=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../screen/impl/ScreenProjectDataServiceImpl.java | 2 +- .../data-statistical-server/src/main/resources/bootstrap.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectDataServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectDataServiceImpl.java index 0ae964e3ee..db975af203 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectDataServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectDataServiceImpl.java @@ -306,7 +306,7 @@ public class ScreenProjectDataServiceImpl extends BaseServiceImpl getProjectList(String customerId, List projectId, Integer pageNo, Integer pageSize) { - PageHelper.startPage(pageNo, pageSize); + PageHelper.startPage(pageNo, pageSize, false); return baseDao.selectProjectList(customerId, projectId); } 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 b159668ec9..c5046e114c 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 @@ -28,6 +28,7 @@ spring: url: @datasource.druid.stats.url@ username: @datasource.druid.stats.username@ password: @datasource.druid.stats.password@ + maxActive: 50 cloud: nacos: discovery: From 09d19f519b4af416b959d5435d03d13eac89de8b Mon Sep 17 00:00:00 2001 From: jianjun Date: Mon, 28 Mar 2022 11:09:26 +0800 Subject: [PATCH 06/19] =?UTF-8?q?stats=20=E9=85=8D=E7=BD=AEdriud=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E6=B1=A0=20=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data-statistical-server/src/main/resources/bootstrap.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 c5046e114c..92803d4ba5 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 @@ -28,7 +28,7 @@ spring: url: @datasource.druid.stats.url@ username: @datasource.druid.stats.username@ password: @datasource.druid.stats.password@ - maxActive: 50 + maxActive: 60 cloud: nacos: discovery: @@ -174,6 +174,7 @@ dynamic: url: @datasource.druid.evaluationIndex.url@ username: @datasource.druid.evaluationIndex.username@ password: @datasource.druid.evaluationIndex.password@ + maxActive: 50 partyMember: driver-class-name: com.mysql.cj.jdbc.Driver url: @datasource.druid.partyMember.url@ From 6625dd2adf2e694e8ce1492d50dbaf17d5d75975 Mon Sep 17 00:00:00 2001 From: jianjun Date: Mon, 28 Mar 2022 14:50:01 +0800 Subject: [PATCH 07/19] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/epmet/UserApplication.java | 2 + .../main/java/com/epmet/util/MySequence.java | 214 ++++++++++++++++++ .../epmetuser/test/UserControllerTest.java | 17 ++ 3 files changed, 233 insertions(+) create mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/util/MySequence.java 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 caf839f79a..6f90b55f0a 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 @@ -8,6 +8,7 @@ package com.epmet; +import com.epmet.util.MySequence; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.web.servlet.ServletComponentScan; @@ -31,6 +32,7 @@ public class UserApplication { public static void main(String[] args) { SpringApplication.run(UserApplication.class, args); + MySequence identifierGenerator = new MySequence(); } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/util/MySequence.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/util/MySequence.java new file mode 100644 index 0000000000..28475b916f --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/util/MySequence.java @@ -0,0 +1,214 @@ +/* + * Copyright (c) 2011-2021, baomidou (jobob@qq.com). + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.epmet.util; + +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.toolkit.Assert; +import com.baomidou.mybatisplus.core.toolkit.StringPool; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.baomidou.mybatisplus.core.toolkit.SystemClock; +import com.epmet.commons.tools.utils.HttpClientManager; +import lombok.extern.slf4j.Slf4j; +import org.apache.ibatis.logging.Log; +import org.apache.ibatis.logging.LogFactory; + +import java.lang.management.ManagementFactory; +import java.net.InetAddress; +import java.net.NetworkInterface; +import java.util.concurrent.ThreadLocalRandom; + +/** + * 分布式高效有序 ID 生产黑科技(sequence) + * + *

优化开源项目:https://gitee.com/yu120/sequence

+ * + * @author hubin + * @since 2016-08-18 + */ +@Slf4j +public class MySequence { + + private static final Log logger = LogFactory.getLog(MySequence.class); + /** + * 时间起始标记点,作为基准,一般取系统的最近时间(一旦确定不能变动) + */ + private final long twepoch = 1288834974657L; + /** + * 机器标识位数 + */ + private final long workerIdBits = 5L; + private final long datacenterIdBits = 5L; + private final long maxWorkerId = -1L ^ (-1L << workerIdBits); + private final long maxDatacenterId = -1L ^ (-1L << datacenterIdBits); + /** + * 毫秒内自增位 + */ + private final long sequenceBits = 12L; + private final long workerIdShift = sequenceBits; + private final long datacenterIdShift = sequenceBits + workerIdBits; + /** + * 时间戳左移动位 + */ + private final long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits; + private final long sequenceMask = -1L ^ (-1L << sequenceBits); + + private final long workerId; + + /** + * 数据标识 ID 部分 + */ + private final long datacenterId; + /** + * 并发控制 + */ + private long sequence = 0L; + /** + * 上次生产 ID 时间戳 + */ + private long lastTimestamp = -1L; + + public MySequence() { + this.datacenterId = getDatacenterId(maxDatacenterId); + this.workerId = getMaxWorkerId(datacenterId, maxWorkerId); + String msg = "MySequence datacenterId:" + this.datacenterId + ";workerId:" + this.workerId; + log.info(msg); + HttpClientManager.getInstance().sendAlarmMsg(msg); + } + + /** + * 有参构造器 + * + * @param workerId 工作机器 ID + * @param datacenterId 序列号 + */ + public MySequence(long workerId, long datacenterId) { + Assert.isFalse(workerId > maxWorkerId || workerId < 0, + String.format("MySequence worker Id can't be greater than %d or less than 0", maxWorkerId)); + Assert.isFalse(datacenterId > maxDatacenterId || datacenterId < 0, + String.format("MySequence datacenter Id can't be greater than %d or less than 0", maxDatacenterId)); + this.workerId = workerId; + this.datacenterId = datacenterId; + } + + /** + * 获取 maxWorkerId + */ + protected static long getMaxWorkerId(long datacenterId, long maxWorkerId) { + StringBuilder mpid = new StringBuilder(); + mpid.append(datacenterId); + String name = ManagementFactory.getRuntimeMXBean().getName(); + String msg = "MySequence getMaxWorkerId name:" + name; + log.info(msg); + HttpClientManager.getInstance().sendAlarmMsg(msg); + if (StringUtils.isNotBlank(name)) { + /* + * GET jvmPid + */ + mpid.append(name.split(StringPool.AT)[0]); + } + /* + * MAC + PID 的 hashcode 获取16个低位 + */ + return (mpid.toString().hashCode() & 0xffff) % (maxWorkerId + 1); + } + + /** + * 数据标识id部分 + */ + protected static long getDatacenterId(long maxDatacenterId) { + long id = 0L; + try { + InetAddress ip = InetAddress.getLocalHost(); + NetworkInterface network = NetworkInterface.getByInetAddress(ip); + String msg = "MySequence ip:" + JSON.toJSONString(ip) + ";network: " + JSON.toJSONString(network); + log.info(msg); + HttpClientManager.getInstance().sendAlarmMsg(msg); + if (network == null) { + id = 1L; + log.info("MySequen cenetwork ==null "); + } else { + byte[] mac = network.getHardwareAddress(); + if (null != mac) { + id = ((0x000000FF & (long) mac[mac.length - 2]) | (0x0000FF00 & (((long) mac[mac.length - 1]) << 8))) >> 6; + id = id % (maxDatacenterId + 1); + } + } + } catch (Exception e) { + logger.warn(" getDatacenterId: " + e.getMessage()); + } + return id; + } + + /** + * 获取下一个 ID + * + * @return 下一个 ID + */ + public synchronized long nextId() { + long timestamp = timeGen(); + //闰秒 + if (timestamp < lastTimestamp) { + long offset = lastTimestamp - timestamp; + if (offset <= 5) { + try { + wait(offset << 1); + timestamp = timeGen(); + if (timestamp < lastTimestamp) { + throw new RuntimeException(String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", offset)); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } else { + throw new RuntimeException(String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", offset)); + } + } + + if (lastTimestamp == timestamp) { + // 相同毫秒内,序列号自增 + sequence = (sequence + 1) & sequenceMask; + if (sequence == 0) { + // 同一毫秒的序列数已经达到最大 + timestamp = tilNextMillis(lastTimestamp); + } + } else { + // 不同毫秒内,序列号置为 1 - 3 随机数 + sequence = ThreadLocalRandom.current().nextLong(1, 3); + } + + lastTimestamp = timestamp; + + // 时间戳部分 | 数据中心部分 | 机器标识部分 | 序列号部分 + return ((timestamp - twepoch) << timestampLeftShift) + | (datacenterId << datacenterIdShift) + | (workerId << workerIdShift) + | sequence; + } + + protected long tilNextMillis(long lastTimestamp) { + long timestamp = timeGen(); + while (timestamp <= lastTimestamp) { + timestamp = timeGen(); + } + return timestamp; + } + + protected long timeGen() { + return SystemClock.now(); + } + +} + diff --git a/epmet-user/epmet-user-server/src/test/java/com/epmet/epmetuser/test/UserControllerTest.java b/epmet-user/epmet-user-server/src/test/java/com/epmet/epmetuser/test/UserControllerTest.java index 06d674a4e3..751a7b7be1 100644 --- a/epmet-user/epmet-user-server/src/test/java/com/epmet/epmetuser/test/UserControllerTest.java +++ b/epmet-user/epmet-user-server/src/test/java/com/epmet/epmetuser/test/UserControllerTest.java @@ -1,7 +1,10 @@ package com.epmet.epmetuser.test; +import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.epmet.commons.tools.constant.AppClientConstant; +import com.epmet.dao.UserDao; import com.epmet.dto.result.LoginUserDetailsResultDTO; +import com.epmet.entity.UserEntity; import com.epmet.service.UserService; import org.junit.Test; import org.junit.runner.RunWith; @@ -15,11 +18,25 @@ public class UserControllerTest { @Autowired private UserService userService; + @Autowired + private UserDao userDao; @Test public void getLoginUserDetails() { LoginUserDetailsResultDTO loginUserDetails = userService.getLoginUserDetails(AppClientConstant.APP_GOV, AppClientConstant.CLIENT_WXMP, "4aaab913d9f11d90a2cb4dd21b075259"); System.out.println(loginUserDetails); } + @Test + public void insertUser() { + UserEntity entity = new UserEntity(); + + entity.setCustomerId("test_ljj"); + String idStr = IdWorker.getIdStr(); + System.out.println(idStr); + + + //int insert = userDao.insert(entity); + //System.out.println(insert); + } } From 2dd4f1b22069b22b21690ed125a6609c08ed0bab Mon Sep 17 00:00:00 2001 From: jianjun Date: Mon, 28 Mar 2022 15:53:27 +0800 Subject: [PATCH 08/19] =?UTF-8?q?id=E7=94=9F=E6=88=90=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mybatis/config/MybatisPlusConfig.java | 27 +++++++++++++++++-- .../main/java/com/epmet/UserApplication.java | 2 -- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/config/MybatisPlusConfig.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/config/MybatisPlusConfig.java index 8ef978f3c3..b61f2fefb1 100644 --- a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/config/MybatisPlusConfig.java +++ b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/config/MybatisPlusConfig.java @@ -1,29 +1,38 @@ /** * Copyright (c) 2018 人人开源 All rights reserved. - * + *

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

* 版权所有,侵权必究! */ package com.epmet.commons.mybatis.config; import com.baomidou.mybatisplus.annotation.DbType; +import com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator; import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; import com.epmet.commons.mybatis.interceptor.DataFilterInterceptor; +import com.epmet.commons.tools.redis.RedisUtils; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.annotation.Order; +import java.util.Random; + /** * mybatis-plus配置 * * @author Mark sunlightcs@gmail.com * @since 1.0.0 */ +@Slf4j @Configuration public class MybatisPlusConfig { + @Autowired + private RedisUtils redisUtils; /** * 配置数据权限 @@ -45,4 +54,18 @@ public class MybatisPlusConfig { return interceptor; } + /** + * id生成器指定2个参数 防止id重复 + */ + @Bean + @Order(0) + public DefaultIdentifierGenerator myIdentifierGenerator() { + Random random = new Random(); + int workerId = random.nextInt(30) + 1; + int dataCenterId = random.nextInt(30) + 1; + DefaultIdentifierGenerator interceptor = new DefaultIdentifierGenerator(workerId, dataCenterId); + log.info("workerId:{},dataCenterId:{}", workerId, dataCenterId); + return interceptor; + } + } 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 6f90b55f0a..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 @@ -8,7 +8,6 @@ package com.epmet; -import com.epmet.util.MySequence; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.web.servlet.ServletComponentScan; @@ -32,7 +31,6 @@ public class UserApplication { public static void main(String[] args) { SpringApplication.run(UserApplication.class, args); - MySequence identifierGenerator = new MySequence(); } } From e03de9c6d886e9e6042319dfcffebd4f78e74c53 Mon Sep 17 00:00:00 2001 From: jianjun Date: Mon, 28 Mar 2022 16:08:47 +0800 Subject: [PATCH 09/19] =?UTF-8?q?=E7=BA=BF=E7=A8=8B=E6=B1=A0=E4=B8=8D?= =?UTF-8?q?=E5=A4=9F=E7=94=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data-statistical-server/src/main/resources/bootstrap.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 92803d4ba5..530c216a2d 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 @@ -28,7 +28,7 @@ spring: url: @datasource.druid.stats.url@ username: @datasource.druid.stats.username@ password: @datasource.druid.stats.password@ - maxActive: 60 + max-active: 100 cloud: nacos: discovery: @@ -174,7 +174,7 @@ dynamic: url: @datasource.druid.evaluationIndex.url@ username: @datasource.druid.evaluationIndex.username@ password: @datasource.druid.evaluationIndex.password@ - maxActive: 50 + max-active: 100 partyMember: driver-class-name: com.mysql.cj.jdbc.Driver url: @datasource.druid.partyMember.url@ From 410dd207f4da38f435cab8575732084c20c25eaf Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Tue, 29 Mar 2022 09:28:43 +0800 Subject: [PATCH 10/19] =?UTF-8?q?bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/epmet/service/impl/UserBadgeServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java index 8854f92192..a808b172e7 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java @@ -279,7 +279,8 @@ public class UserBadgeServiceImpl implements UserBadgeService { userBadgeDao.insertUserBadgeCertificateRecord(form); //TODO 站内信发送 String badgeName = badgeDao.selectBadgeName(form.getCustomerId(), form.getBadgeId()); - String msg = String.format(BadgeConstant.MESSAGE_CONTENT, userBaseInfoResultDTOS.get(NumConstant.ZERO).getDistrict().concat(userBaseInfoResultDTOS.get(NumConstant.ZERO).getRealName()), badgeName); + String s = StringUtils.isBlank(userBaseInfoResultDTOS.get(NumConstant.ZERO).getDistrict()) ? userBaseInfoResultDTOS.get(NumConstant.ZERO).getRealName() : userBaseInfoResultDTOS.get(NumConstant.ZERO).getDistrict().concat(userBaseInfoResultDTOS.get(NumConstant.ZERO).getRealName()); + String msg = String.format(BadgeConstant.MESSAGE_CONTENT, s, badgeName); // 记录待审核id,和消息类型 sendMessage(BadgeConstant.AUTH_TITLE,msg,form.getGridId(),form.getUserId(),form.getCustomerId(), UserMessageTypeConstant.BADGE_AUTH_APPLY, From 1b1f941a567bbd649d63c63f76d7ed801737ab5f Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Tue, 29 Mar 2022 13:57:47 +0800 Subject: [PATCH 11/19] =?UTF-8?q?=E6=88=BF=E5=B1=8B=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/epmet/dto/ImportGeneralDTO.java | 2 +- .../java/com/epmet/model/HouseErrorInfoModel.java | 3 +++ .../main/java/com/epmet/model/HouseInfoModel.java | 6 +++++- .../com/epmet/model/ImportHouseInfoListener.java | 6 +++++- .../service/impl/IcBuildingUnitServiceImpl.java | 2 +- .../service/impl/IcNeighborHoodServiceImpl.java | 13 ++++++++----- .../src/main/resources/mapper/IcBuildingDao.xml | 2 +- 7 files changed, 24 insertions(+), 10 deletions(-) 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 index 1d4419e661..510fe28f3b 100644 --- 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 @@ -68,7 +68,7 @@ public class ImportGeneralDTO implements Serializable { /** * 单元号、ID */ - private Integer buildingUnit; + private String buildingUnit; private String buildingUnitId; /** 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 index 5d2a444f90..5e40937562 100644 --- 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 @@ -13,6 +13,9 @@ import org.hibernate.validator.constraints.Length; @Data public class HouseErrorInfoModel { + @Excel(name = "行号", width = 10) + private Integer num; + @Excel(name = "所属小区", width = 20) private String neighborHoodName; 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 index 9330a1a2d0..be716f7c94 100644 --- 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 @@ -1,5 +1,6 @@ package com.epmet.model; +import com.alibaba.excel.annotation.ExcelIgnore; import com.alibaba.excel.annotation.ExcelProperty; import lombok.Data; import org.hibernate.validator.constraints.Length; @@ -26,7 +27,7 @@ public class HouseInfoModel { private String buildingName; @ExcelProperty(value = "单元号") - private Integer buildingUnit; + private String buildingUnit; @ExcelProperty(value = "门牌号") private String doorName; @@ -49,4 +50,7 @@ public class HouseInfoModel { @ExcelProperty(value = "房主身份证") private String ownerIdCard; + @ExcelIgnore + private Integer num; + } 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 index ea8c98c040..75ede97f0d 100644 --- 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 @@ -90,6 +90,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener wrapper = new LambdaQueryWrapper<>(); wrapper.eq(IcBuildingUnitEntity::getBuildingId, buildingId); - wrapper.eq(IcBuildingUnitEntity::getUnitNum, unitName); + wrapper.eq(IcBuildingUnitEntity::getUnitName, unitName); IcBuildingUnitEntity entity = baseDao.selectOne(wrapper); return ConvertUtils.sourceToTarget(entity, IcBuildingUnitDTO.class); } 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 f2b50748eb..03592a78c0 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 @@ -523,7 +523,7 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl SELECT u.ID AS buildingUnitId, - u.UNIT_NUM AS buildingUnit, + u.UNIT_NAME AS buildingUnit, u.BUILDING_ID,b.NEIGHBOR_HOOD_ID FROM ic_building_unit u INNER JOIN ic_building b ON (b.ID = u.BUILDING_ID AND b.DEL_FLAG = '0') From 2a7d61412cc1d76401092260062d123a4a2379b9 Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Tue, 29 Mar 2022 14:06:33 +0800 Subject: [PATCH 12/19] =?UTF-8?q?=E6=96=B0=E5=A2=9E=201.=E5=B1=85=E6=B0=91?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=EF=BC=8C=E6=8E=A8=E9=80=81mq=E6=B6=88?= =?UTF-8?q?=E6=81=AF=EF=BC=8C=E8=BF=9B=E8=A1=8C=E7=9B=B8=E5=85=B3=E5=8A=A8?= =?UTF-8?q?=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/controller/IcResiUserController.java | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 08930bbb75..c7e6bad9df 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.AppClientConstant; import com.epmet.commons.tools.constant.Constant; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; @@ -486,6 +487,15 @@ public class IcResiUserController implements ResultDataResolver { } catch (IOException e) { log.error("【导入居民信息失败】清理上传的文件失败:{}", ExceptionUtils.getErrorStackTrace(e)); } + + //推送MQ事件 + IcResiUserAddMQMsg mqMsg = new IcResiUserAddMQMsg(); + mqMsg.setCustomerId(EpmetRequestHolder.getHeader(AppClientConstant.CUSTOMER_ID)); + //mqMsg.setIcResiUser(resiUserId); + SystemMsgFormDTO form = new SystemMsgFormDTO(); + form.setMessageType(SystemMessageType.IC_RESI_USER_ADD); + form.setContent(mqMsg); + epmetMessageOpenFeignClient.sendSystemMsgByMQ(form); } }); From dc2dda83d466e7fad284b697721350cf5ba4a38c Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Tue, 29 Mar 2022 14:09:55 +0800 Subject: [PATCH 13/19] =?UTF-8?q?=E6=B3=A8=E9=87=8A=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=A5=BC=E6=A0=8B=E6=88=B7=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/model/ImportHouseInfoListener.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 index d933f547c7..31640c8206 100644 --- 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 @@ -67,7 +67,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener buildingIdSet = new ConcurrentHashSet<>(); +// private Set buildingIdSet = new ConcurrentHashSet<>(); private ImportInfoFormDTO formDTO; private IcBuildingDao icBuildingDao; @@ -539,13 +539,13 @@ public class ImportHouseInfoListener extends AnalysisEventListener houseNum = icBuildingDao.selectHouseNum(buildingIdSet); if (!CollectionUtils.isEmpty(houseNum)){ icBuildingDao.allUpdateHouseNum(houseNum); } buildingIdSet = null; - } + }*/ // 删除缓存 icHouseRedis.delTemporaryCacheGrids(formDTO.getCustomerId(), formDTO.getUserId()); icHouseRedis.delTemporaryCacheNeighBorHood(formDTO.getCustomerId(), formDTO.getUserId()); @@ -586,7 +586,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener houses){ if (!CollectionUtils.isEmpty(houses)){ icHouseService.insertBatch(ConvertUtils.sourceToTarget(houses, IcHouseEntity.class)); - buildingIdSet.addAll(houses.stream().map(ImportGeneralDTO::getBuildingId).collect(Collectors.toSet())); +// buildingIdSet.addAll(houses.stream().map(ImportGeneralDTO::getBuildingId).collect(Collectors.toSet())); } } @@ -594,7 +594,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener houses){ if (!CollectionUtils.isEmpty(houses)){ icHouseService.houseUpdate(houses); - buildingIdSet.addAll(houses.stream().map(ImportGeneralDTO::getBuildingId).collect(Collectors.toSet())); +// buildingIdSet.addAll(houses.stream().map(ImportGeneralDTO::getBuildingId).collect(Collectors.toSet())); } } From a2d8facf76cc3ec77acd63331c541ba76b41b233 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Tue, 29 Mar 2022 14:16:45 +0800 Subject: [PATCH 14/19] =?UTF-8?q?=E8=A1=A8=E5=A4=B4=E5=A4=87=E6=B3=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/epmet/model/HouseErrorInfoModel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 5e40937562..792192c7d7 100644 --- 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 @@ -13,7 +13,7 @@ import org.hibernate.validator.constraints.Length; @Data public class HouseErrorInfoModel { - @Excel(name = "行号", width = 10) + @Excel(name = "行号(不计算表头)", width = 20) private Integer num; @Excel(name = "所属小区", width = 20) From 4d1334368c7f09cb19d8b711eb87f0e0144ac73b Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Tue, 29 Mar 2022 15:18:38 +0800 Subject: [PATCH 15/19] =?UTF-8?q?=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/epmet/model/ImportHouseInfoListener.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 index 31640c8206..4cd6ae33d6 100644 --- 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 @@ -139,10 +139,11 @@ public class ImportHouseInfoListener extends AnalysisEventListener Date: Tue, 29 Mar 2022 16:39:11 +0800 Subject: [PATCH 16/19] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E8=BF=90=E8=90=A5?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=20=E7=BD=91=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/commons/tools/utils/ExcelUtils.java | 30 ++- .../tools/utils/excel/ExportMultiView.java | 23 +++ .../form/CustomerDataManageFormDTO.java | 5 + .../result/CustomerDataManageResultDTO.java | 1 + .../ScreenAgencyOrGridListDTO.java | 4 + .../ScreenCustomerGridDTO.java | 64 +------ .../controller/DataStatsController.java | 11 +- .../evaluationindex/EvaluationIndexDao.java | 26 ++- .../excel/CustomerDataManageExcel.java | 28 +-- .../datastats/impl/DataStatsServiceImpl.java | 174 +++++++++++------- .../EvaluationIndexService.java | 4 +- .../impl/EvaluationIndexServiceImpl.java | 25 ++- .../evaluationindex/EvaluationIndexDao.xml | 21 ++- 13 files changed, 248 insertions(+), 168 deletions(-) create mode 100644 epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/excel/ExportMultiView.java diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ExcelUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ExcelUtils.java index 754cdf012d..90b840f4f7 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ExcelUtils.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ExcelUtils.java @@ -10,6 +10,8 @@ package com.epmet.commons.tools.utils; import cn.afterturn.easypoi.excel.ExcelExportUtil; import cn.afterturn.easypoi.excel.entity.ExportParams; +import cn.afterturn.easypoi.excel.entity.enmus.ExcelType; +import com.epmet.commons.tools.utils.excel.ExportMultiView; import org.apache.commons.lang3.StringUtils; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; @@ -19,12 +21,8 @@ import org.springframework.util.CollectionUtils; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import java.io.IOException; -import java.io.OutputStream; import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.List; +import java.util.*; /** * Excel工具类 @@ -121,8 +119,11 @@ public class ExcelUtils { out.flush(); out.close(); } - public static OutputStream getOutputStreamForExcel(String fileName, HttpServletResponse response) throws Exception { + public static ServletOutputStream getOutputStreamForExcel(String fileName, HttpServletResponse response) throws Exception { fileName = URLEncoder.encode(fileName, "UTF-8"); + if (!fileName.endsWith(".xls") ||!fileName.endsWith(".xlsx")){ + fileName = fileName + ".xlsx"; + } response.setContentType("application/vnd.ms-excel"); response.setCharacterEncoding("utf8"); response.setHeader("Content-Disposition", "attachment;filename=" + fileName); @@ -131,4 +132,21 @@ public class ExcelUtils { return response.getOutputStream(); } + public static void exportMultiSheetExcel(String fileName, List list, HttpServletResponse response) throws Exception { + List> excel = new ArrayList<>(); + for(ExportMultiView view :list){ + Map sheet = new HashMap<>(); + sheet.put("title",view.getExportParams()); + sheet.put("entity",view.getCls()); + List dataList = view.getDataList(); + sheet.put("data", dataList); + excel.add(sheet); + } + Workbook workbook = ExcelExportUtil.exportExcel(excel, ExcelType.XSSF); + ServletOutputStream outputStream = ExcelUtils.getOutputStreamForExcel(fileName, response); + workbook.write(outputStream); + outputStream.flush(); + outputStream.close(); + } + } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/excel/ExportMultiView.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/excel/ExportMultiView.java new file mode 100644 index 0000000000..815585a1e3 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/excel/ExportMultiView.java @@ -0,0 +1,23 @@ +package com.epmet.commons.tools.utils.excel; + +import cn.afterturn.easypoi.excel.entity.ExportParams; +import lombok.AllArgsConstructor; +import lombok.Data; + +import java.util.List; + +/** + * desc:easypoi 导出多个sheet + * + * @author: LiuJanJun + * @date: 2022/3/29 1:13 下午 + * @version: 1.0 + */ +@Data +@AllArgsConstructor +public class ExportMultiView { + private ExportParams exportParams; + private List dataList; + private Class cls; + +} diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/form/CustomerDataManageFormDTO.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/form/CustomerDataManageFormDTO.java index e707ef6d6c..3b8b737a37 100644 --- a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/form/CustomerDataManageFormDTO.java +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/form/CustomerDataManageFormDTO.java @@ -64,4 +64,9 @@ public class CustomerDataManageFormDTO implements Serializable { private String sourceType; //数据类型【组织agency 网格grid】 private String dataType; + + /** + * desc:是否是导出 + */ + private boolean export; } 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 f293af93d0..8ea839f03f 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 @@ -14,6 +14,7 @@ import java.util.List; public class CustomerDataManageResultDTO { List list = new ArrayList<>(); + List allGridList = new ArrayList<>(); private Integer total; @Data diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/ScreenAgencyOrGridListDTO.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/ScreenAgencyOrGridListDTO.java index 02c5c9cbc8..87e494d0b9 100644 --- a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/ScreenAgencyOrGridListDTO.java +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/ScreenAgencyOrGridListDTO.java @@ -16,6 +16,10 @@ public class ScreenAgencyOrGridListDTO implements Serializable { private String level; //直属下级组织或网格集合 private List agencyGridList; + /** + * 所有下级网格列表 + */ + private List allGridList; @Data public static class AgencyGrid { diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/ScreenCustomerGridDTO.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/ScreenCustomerGridDTO.java index e57fd42ac5..fc22bd2fb4 100644 --- a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/ScreenCustomerGridDTO.java +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/ScreenCustomerGridDTO.java @@ -20,7 +20,6 @@ package com.epmet.dataaggre.dto.evaluationindex; import lombok.Data; import java.io.Serializable; -import java.util.Date; /** @@ -54,66 +53,5 @@ public class ScreenCustomerGridDTO implements Serializable { */ private String gridName; - /** - * 网格所属组织id - */ - private String parentAgencyId; - - /** - * 坐标区域 - */ - private String areaMarks; - - /** - * 中心点位 - */ - private String centerMark; - - /** - * 党支部(=网格)的位置 - */ - private String partyMark; - - /** - * 删除标识 0.未删除 1.已删除 - */ - private Integer delFlag; - - /** - * 乐观锁 - */ - private Integer revision; - - /** - * 创建人 - */ - private String createdBy; - - /** - * 创建时间 - */ - private Date createdTime; - - /** - * 更新人 - */ - private String updatedBy; - - /** - * 更新时间 - */ - private Date updatedTime; - - /** - * 数据更新至: yyyy|yyyyMM|yyyyMMdd(08-21新增) - */ - private String dataEndTime; - - /** - * 所有上级ID,用英文逗号分开 - */ - private String allParentIds; - private String pid; - private String pids; -} \ No newline at end of file +} diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/DataStatsController.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/DataStatsController.java index 9e1929056d..8cd9f886db 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/DataStatsController.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/DataStatsController.java @@ -1,21 +1,20 @@ package com.epmet.dataaggre.controller; import com.epmet.commons.tools.exception.RenException; -import com.epmet.commons.tools.utils.ExcelUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dataaggre.dto.datastats.form.*; import com.epmet.dataaggre.dto.datastats.result.*; -import com.epmet.dataaggre.excel.CustomerDataManageExcel; import com.epmet.dataaggre.service.datastats.DataStatsService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; +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 javax.servlet.http.HttpServletResponse; import java.text.ParseException; -import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; /** * @Author sun @@ -228,6 +227,7 @@ public class DataStatsController { @PostMapping("operateexport") public void CustomerDataManage(@RequestBody CustomerDataManageFormDTO formDTO, HttpServletResponse response) throws Exception { ValidatorUtils.validateEntity(formDTO, CustomerDataManageFormDTO.CustomerDataManageForm.class); + formDTO.setExport(true); dataStatsService.CustomerDataManage(formDTO,response); } @@ -239,6 +239,7 @@ public class DataStatsController { @PostMapping("operatedata") public Result operatedata(@RequestBody CustomerDataManageFormDTO formDTO) throws ParseException { ValidatorUtils.validateEntity(formDTO, CustomerDataManageFormDTO.CustomerDataManageForm.class); + formDTO.setExport(true); return new Result().ok(dataStatsService.operateExport(formDTO)); } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/evaluationindex/EvaluationIndexDao.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/evaluationindex/EvaluationIndexDao.java index da7f97b6bf..ab22fe402c 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/evaluationindex/EvaluationIndexDao.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/evaluationindex/EvaluationIndexDao.java @@ -32,7 +32,7 @@ import java.util.List; /** * @Author sun - * @Description 指标统计服务 + * @Description 指标统计服务 */ @Mapper public interface EvaluationIndexDao { @@ -64,20 +64,22 @@ public interface EvaluationIndexDao { /** * 根据组织Id查询治理指数 - * @author zhaoqifeng - * @date 2021/6/25 16:36 + * * @param agencyIds * @param dateId * @return java.util.List + * @author zhaoqifeng + * @date 2021/6/25 16:36 */ ScreenGovernRankDataDailyDTO getGovernRankList(@Param("agencyIds") List agencyIds, @Param("dateId") String dateId); /** * 获取组织信息 - * @author zhaoqifeng - * @date 2021/6/29 13:58 + * * @param agencyId * @return com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerAgencyDTO + * @author zhaoqifeng + * @date 2021/6/29 13:58 */ ScreenCustomerAgencyDTO getAgencyInfo(@Param("agencyId") String agencyId); @@ -100,12 +102,12 @@ public interface EvaluationIndexDao { List getSubAgencyListByAgency(@Param("agencyId") String agencyId, @Param("areaCode") String areaCode, @Param("list") List list); /** - * @Description 根据组织ID查询组织名 + * @Description 根据组织ID查询组织名 * @Param agencyId * @author zxc * @date 2021/9/10 3:54 下午 */ - String selectAgencyNameByAgencyId(@Param("agencyId")String agencyId); + String selectAgencyNameByAgencyId(@Param("agencyId") String agencyId); /** * @Description 按dateId查询组织下一级分类项目总数统计 @@ -118,4 +120,12 @@ public interface EvaluationIndexDao { * @author sun */ List getGridProejctToProjectMain(GridLivelyFormDTO formDTO); -} \ No newline at end of file + + /** + * desc:根据组织全路径 获取所有网格 + * + * @param fullAgencyPath + * @return + */ + List getSubAllGridByAgencyPath(@Param("fullAgencyPath") String fullAgencyPath); +} 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 65f55557fe..024562fdf4 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 @@ -5,49 +5,49 @@ import lombok.Data; /** * @Author zxc - * @DateTime 2021/9/10 10:15 上午 + * @DateTime 2021/9/10 10:10 上午 * @DESC */ @Data public class CustomerDataManageExcel { - @Excel(name = "组织") + @Excel(name = "组织",width = 20) private String orgName; - @Excel(name = "用户数") + @Excel(name = "用户数",width = 10) private Integer userCount; - @Excel(name = "居民数") + @Excel(name = "居民数",width = 10) private Integer residentCount; - @Excel(name = "党员数") + @Excel(name = "党员数",width = 10) private Integer partyMemberCount; - @Excel(name = "小组数") + @Excel(name = "小组数",width = 10) private Integer groupCount; - @Excel(name = "话题数") + @Excel(name = "话题数",width = 10) private Integer topicCount; - @Excel(name = "议题数") + @Excel(name = "议题数",width = 10) private Integer issueCount; - @Excel(name = "项目数") + @Excel(name = "项目数",width = 10) private Integer projectCount; - @Excel(name = "结案项目数") + @Excel(name = "结案项目数",width = 10) private Integer closedProjectCount; - @Excel(name = "巡查人数") + @Excel(name = "巡查人数",width = 10) private Integer patrolPeopleCount; - @Excel(name = "巡查次数") + @Excel(name = "巡查次数",width = 10) private Integer patrolCount; - @Excel(name = "巡查时长") + @Excel(name = "巡查时长",width = 15) private String patrolDuration; - @Excel(name = "例行工作次数") + @Excel(name = "例行工作次数",width = 15) private Integer patrolRoutineWorkTimes; /** 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 fbf54c353c..afa93f3853 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,61 +1,63 @@ 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.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.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 cn.afterturn.easypoi.excel.entity.ExportParams; +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.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.commons.tools.utils.excel.ExportMultiView; +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.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; /** * @Author sun @@ -1878,7 +1880,32 @@ 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(); + CustomerDataManageResultDTO operateExport = operateExport(formDTO); + List result = operateExport.getList(); + setTotal(result); + formDTO.setStartTime(openTime); + String fileName = excelName(formDTO); + + ExportParams exportParams = new ExportParams(fileName,fileName); + //exportParams.setAutoSize(true); + List exportList = new ArrayList<>(); + List excelList = ConvertUtils.sourceToTarget(result, CustomerDataManageExcel.class); + exportList.add(new ExportMultiView(exportParams,excelList,CustomerDataManageExcel.class)); + if (formDTO.isExport()){ + List gridResult = operateExport.getAllGridList(); + setTotal(gridResult); + ExportParams exportParams2 = new ExportParams(fileName,"网格数据"); + //exportParams2.setAutoSize(true); + List excelList2 = ConvertUtils.sourceToTarget(gridResult, CustomerDataManageExcel.class); + exportList.add(new ExportMultiView(exportParams2,excelList2,CustomerDataManageExcel.class)); + } + //ExcelUtils.exportExcelToTargetDisposeAll(response,fileName,result, CustomerDataManageExcel.class); + + ExcelUtils.exportMultiSheetExcel(fileName, exportList, response); + + } + + public void setTotal(List result) { if (!CollectionUtils.isEmpty(result)){ CustomerDataManageResultDTO.CustomerDataManage c = new CustomerDataManageResultDTO.CustomerDataManage(); c.setOrgName("合计"); @@ -1897,9 +1924,6 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve c.setPatrolDuration(getHm(c.getPatrolDurationInteger())); result.add(c); } - formDTO.setStartTime(openTime); - String fileName = excelName(formDTO); - ExcelUtils.exportExcelToTargetDisposeAll(response,fileName,result, CustomerDataManageExcel.class); } /** @@ -1958,8 +1982,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve */ @Override public CustomerDataManageResultDTO operateExport(CustomerDataManageFormDTO formDTO) throws ParseException { - CustomerDataManageResultDTO resultDTO = new CustomerDataManageResultDTO(); - List dataManageList = new ArrayList<>(); + //1.必要参数校验及处理 String startTimeForm = formDTO.getStartTime(); if ("Interval".equals(formDTO.getType()) && StringUtils.isEmpty(startTimeForm)) { @@ -1974,7 +1997,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve } //2.查询组织信息,判断查询下级组织还是网格数据 - ScreenAgencyOrGridListDTO agencyGrid = indexService.getSubAgencyOrGridList(formDTO.getAgencyId()); + ScreenAgencyOrGridListDTO agencyGrid = indexService.getSubAgencyOrGridList(formDTO.getAgencyId(), formDTO.isExport()); if (null == agencyGrid) { return new CustomerDataManageResultDTO(); } @@ -1982,7 +2005,22 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve List idList = agencyGrid.getAgencyGridList().stream().map(ScreenAgencyOrGridListDTO.AgencyGrid::getOrgId).collect(Collectors.toList()); formDTO.setDataType(!OrgLevelEnum.COMMUNITY.getCode().equals(agencyGrid.getLevel()) ? OrgTypeEnum.AGENCY.getCode() : OrgTypeEnum.GRID.getCode()); formDTO.setIdList(idList); + //获取组织级别数据 + CustomerDataManageResultDTO resultDTO = getDataManageResultDTO(formDTO, startTimeForm, agencyGrid.getAgencyGridList(),agencyGrid.getLevel()); resultDTO.setTotal(idList.size()); + if (formDTO.isExport()){ + formDTO.setDataType(OrgTypeEnum.GRID.getCode()); + idList = agencyGrid.getAllGridList().stream().map(ScreenAgencyOrGridListDTO.AgencyGrid::getOrgId).collect(Collectors.toList()); + formDTO.setIdList(idList); + CustomerDataManageResultDTO allGridData = getDataManageResultDTO(formDTO, startTimeForm, agencyGrid.getAllGridList(),agencyGrid.getLevel()); + resultDTO.setAllGridList(allGridData.getList()); + } + return resultDTO; + } + + public CustomerDataManageResultDTO getDataManageResultDTO(CustomerDataManageFormDTO formDTO, String startTimeForm, List agencyGridList,String orgLevel) { + CustomerDataManageResultDTO resultDTO = new CustomerDataManageResultDTO(); + List dataManageList = new ArrayList<>(); //3.查询截止日期用户、群组、话题、议题、项目、巡查数据 formDTO.setSourceType("end"); @@ -2029,7 +2067,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve } //5.封装数据 - for (ScreenAgencyOrGridListDTO.AgencyGrid org : agencyGrid.getAgencyGridList()) { + for (ScreenAgencyOrGridListDTO.AgencyGrid org : agencyGridList) { CustomerDataManageResultDTO.CustomerDataManage dto = new CustomerDataManageResultDTO.CustomerDataManage(); dto.setOrgId(org.getOrgId()); dto.setOrgName(org.getOrgName()); @@ -2083,12 +2121,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve int patrolDurationInteger = NumConstant.ZERO; HashSet set = new HashSet(); for (CustomerDataManageResultDTO.CustomerDataManage u : patrolEnd) { - if (OrgLevelEnum.COMMUNITY.getCode().equals(agencyGrid.getLevel()) && org.getOrgId().equals(u.getOrgId())) { + if (OrgLevelEnum.COMMUNITY.getCode().equals(orgLevel) && org.getOrgId().equals(u.getOrgId())) { patroCount += u.getPatrolCount(); patrolDurationInteger += u.getPatrolDurationInteger(); set.add(u.getStaffId()); } - if (!OrgLevelEnum.COMMUNITY.getCode().equals(agencyGrid.getLevel()) && u.getOrgId().contains(org.getOrgId())) { + if (!OrgLevelEnum.COMMUNITY.getCode().equals(orgLevel) && u.getOrgId().contains(org.getOrgId())) { patroCount += u.getPatrolCount(); patrolDurationInteger += u.getPatrolDurationInteger(); set.add(u.getStaffId()); @@ -2099,10 +2137,10 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve 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())) { + if (OrgLevelEnum.COMMUNITY.getCode().equals(orgLevel) && 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())) { + } else if (!OrgLevelEnum.COMMUNITY.getCode().equals(orgLevel) && work.getOrgId().contains(org.getOrgId())) { patrolRoutineWorkTimes += work.getPatrolRoutineWorkTimes(); set.add(work.getStaffId()); } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/EvaluationIndexService.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/EvaluationIndexService.java index 381b6f9625..a5260a60ba 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/EvaluationIndexService.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/EvaluationIndexService.java @@ -44,6 +44,8 @@ public interface EvaluationIndexService { */ List getSubGridList(String agencyId); + List getSubAllGridByAgencyPath(String fullAgencyPath); + /** * 根据组织ID获取治理指数 * @author zhaoqifeng @@ -88,7 +90,7 @@ public interface EvaluationIndexService { * @Description 根据组织Id判断查询直属下级组织/网格列表,组织存在子客户的查询包含子客户组织数据 * @author sun */ - ScreenAgencyOrGridListDTO getSubAgencyOrGridList(String agencyId); + ScreenAgencyOrGridListDTO getSubAgencyOrGridList(String agencyId, Boolean isGetSubAllGrid); /** * @Description 按dateId查询组织下一级分类项目总数统计 diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/impl/EvaluationIndexServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/impl/EvaluationIndexServiceImpl.java index 3e8f60d6a9..66f964c3d9 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/impl/EvaluationIndexServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/impl/EvaluationIndexServiceImpl.java @@ -1,8 +1,9 @@ package com.epmet.dataaggre.service.evaluationindex.impl; import com.epmet.commons.dynamic.datasource.annotation.DataSource; +import com.epmet.commons.tools.constant.StrConstant; +import com.epmet.commons.tools.enums.OrgLevelEnum; import com.epmet.commons.tools.exception.RenException; -import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.dataaggre.constant.DataSourceConstant; import com.epmet.dataaggre.dao.evaluationindex.EvaluationIndexDao; import com.epmet.dataaggre.dto.datastats.form.GovrnRatioFormDTO; @@ -75,6 +76,15 @@ public class EvaluationIndexServiceImpl implements EvaluationIndexService { return evaluationIndexDao.getSubGridList(agencyId); } + /** + * @Description 查询所有下级网格 + * @author sun + */ + @Override + public List getSubAllGridByAgencyPath(String fullAgencyPath) { + return evaluationIndexDao.getSubAllGridByAgencyPath(fullAgencyPath); + } + /** * 根据组织ID获取治理指数 * @@ -165,7 +175,7 @@ public class EvaluationIndexServiceImpl implements EvaluationIndexService { * @author sun */ @Override - public ScreenAgencyOrGridListDTO getSubAgencyOrGridList(String agencyId) { + public ScreenAgencyOrGridListDTO getSubAgencyOrGridList(String agencyId, Boolean isGetSubAllGrid) { ScreenAgencyOrGridListDTO resultDTO = new ScreenAgencyOrGridListDTO(); List agencyGridList = new ArrayList<>(); //1.查询组织信息 @@ -178,6 +188,17 @@ public class EvaluationIndexServiceImpl implements EvaluationIndexService { List agencyList = new ArrayList<>(); List gridList = new ArrayList<>(); List finalAgencyGridList = agencyGridList; + if (isGetSubAllGrid && OrgLevelEnum.STREET.getCode().equals(dto.getLevel())){ + gridList = evaluationIndexDao.getSubAllGridByAgencyPath(dto.getPids().concat(StrConstant.COLON).concat(dto.getAgencyId())); + List allGridList = new ArrayList<>(); + gridList.forEach(gr->{ + ScreenAgencyOrGridListDTO.AgencyGrid org = new ScreenAgencyOrGridListDTO.AgencyGrid(); + org.setOrgId(gr.getGridId()); + org.setOrgName(gr.getGridName()); + allGridList.add(org); + }); + resultDTO.setAllGridList(allGridList); + } if (!"community".equals(dto.getLevel())) { //2-1.直属下级组织列表 //2.判断客户是否存在子客户 diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/evaluationindex/EvaluationIndexDao.xml b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/evaluationindex/EvaluationIndexDao.xml index 37f8d40bd6..d6bd5022b9 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/evaluationindex/EvaluationIndexDao.xml +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/evaluationindex/EvaluationIndexDao.xml @@ -118,7 +118,8 @@ agency_name AS agencyName, level AS level, area_code AS areaCode, - parent_area_code AS parentAreaCode + parent_area_code AS parentAreaCode, + pids pids FROM screen_customer_agency WHERE @@ -211,5 +212,23 @@ AND all_parent_ids LIKE CONCAT('%', #{agencyId}, '%') GROUP BY org_id, DATE_FORMAT(project_create_time, "%Y%m%d") + From 047205cf350a9f688d0940e59a16645442d3ea29 Mon Sep 17 00:00:00 2001 From: jianjun Date: Tue, 29 Mar 2022 16:39:40 +0800 Subject: [PATCH 17/19] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E8=BF=90=E8=90=A5?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=20=E7=BD=91=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/dataaggre/controller/DataStatsController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/DataStatsController.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/DataStatsController.java index 8cd9f886db..a4d88b3a91 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/DataStatsController.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/DataStatsController.java @@ -239,7 +239,7 @@ public class DataStatsController { @PostMapping("operatedata") public Result operatedata(@RequestBody CustomerDataManageFormDTO formDTO) throws ParseException { ValidatorUtils.validateEntity(formDTO, CustomerDataManageFormDTO.CustomerDataManageForm.class); - formDTO.setExport(true); + formDTO.setExport(false); return new Result().ok(dataStatsService.operateExport(formDTO)); } From d50e63628da6b04f2057743f13baf7f4378af049 Mon Sep 17 00:00:00 2001 From: jianjun Date: Tue, 29 Mar 2022 17:00:54 +0800 Subject: [PATCH 18/19] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E8=BF=90=E8=90=A5?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=20=E7=BD=91=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/commons/tools/utils/ExcelUtils.java | 10 ++++++++-- .../commons/tools/utils/excel/ExportMultiView.java | 9 +++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ExcelUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ExcelUtils.java index 90b840f4f7..9bc34d0a39 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ExcelUtils.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ExcelUtils.java @@ -132,14 +132,20 @@ public class ExcelUtils { return response.getOutputStream(); } + /** + * desc:easypoi导出多个sheet + * @param fileName + * @param list + * @param response + * @throws Exception + */ public static void exportMultiSheetExcel(String fileName, List list, HttpServletResponse response) throws Exception { List> excel = new ArrayList<>(); for(ExportMultiView view :list){ Map sheet = new HashMap<>(); sheet.put("title",view.getExportParams()); sheet.put("entity",view.getCls()); - List dataList = view.getDataList(); - sheet.put("data", dataList); + sheet.put("data", view.getDataList()); excel.add(sheet); } Workbook workbook = ExcelExportUtil.exportExcel(excel, ExcelType.XSSF); diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/excel/ExportMultiView.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/excel/ExportMultiView.java index 815585a1e3..ff69b2c4b0 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/excel/ExportMultiView.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/excel/ExportMultiView.java @@ -16,8 +16,17 @@ import java.util.List; @Data @AllArgsConstructor public class ExportMultiView { + /** + * 导出的参数 比如设置表头 + */ private ExportParams exportParams; + /** + * 要导出的数据列 + */ private List dataList; + /** + * excel对应的类 + */ private Class cls; } From da247b3beb09d3fd50981cc5e91a1cc56ed5e412 Mon Sep 17 00:00:00 2001 From: jianjun Date: Tue, 29 Mar 2022 17:57:49 +0800 Subject: [PATCH 19/19] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E7=BB=84=E7=BB=87like=E5=90=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../evaluationindex/impl/EvaluationIndexServiceImpl.java | 2 +- .../resources/mapper/evaluationindex/EvaluationIndexDao.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/impl/EvaluationIndexServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/impl/EvaluationIndexServiceImpl.java index 66f964c3d9..02d9687ec1 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/impl/EvaluationIndexServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/impl/EvaluationIndexServiceImpl.java @@ -189,7 +189,7 @@ public class EvaluationIndexServiceImpl implements EvaluationIndexService { List gridList = new ArrayList<>(); List finalAgencyGridList = agencyGridList; if (isGetSubAllGrid && OrgLevelEnum.STREET.getCode().equals(dto.getLevel())){ - gridList = evaluationIndexDao.getSubAllGridByAgencyPath(dto.getPids().concat(StrConstant.COLON).concat(dto.getAgencyId())); + gridList = evaluationIndexDao.getSubAllGridByAgencyPath(dto.getAgencyId()); List allGridList = new ArrayList<>(); gridList.forEach(gr->{ ScreenAgencyOrGridListDTO.AgencyGrid org = new ScreenAgencyOrGridListDTO.AgencyGrid(); diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/evaluationindex/EvaluationIndexDao.xml b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/evaluationindex/EvaluationIndexDao.xml index d6bd5022b9..b66738866f 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/evaluationindex/EvaluationIndexDao.xml +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/evaluationindex/EvaluationIndexDao.xml @@ -227,7 +227,7 @@ screen_customer_grid WHERE del_flag = '0' - AND all_parent_ids LIKE concat(#{fullAgencyPath},'%') + AND all_parent_ids LIKE concat('%',#{fullAgencyPath},'%') order by parentAgencyId,gridName