diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DingdingMsgSender.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DingdingMsgSender.java index 40420d1be7..4250c158b8 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DingdingMsgSender.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DingdingMsgSender.java @@ -2,8 +2,6 @@ package com.epmet.commons.tools.utils; import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.dto.form.DingTalkTextMsg; -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; import com.google.common.collect.Lists; import org.apache.commons.codec.binary.Base64; import org.apache.commons.lang3.StringUtils; @@ -17,8 +15,6 @@ import javax.crypto.spec.SecretKeySpec; import java.io.IOException; import java.net.URLEncoder; import java.util.concurrent.ArrayBlockingQueue; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; /** * desc: 发送消息工具类 @@ -43,15 +39,8 @@ public class DingdingMsgSender { */ private ArrayBlockingQueue msgQueue = new ArrayBlockingQueue<>(maxQueueSize); - private volatile boolean running = false; - private Cache limitCache = CacheBuilder.newBuilder().expireAfterWrite(1, TimeUnit.MINUTES).maximumSize(1000).build(); - - public DingdingMsgSender() { - - } - private void handleMsg() { DingTalkTextMsg msg = null; @@ -59,18 +48,7 @@ public class DingdingMsgSender { //阻塞取元素 msg = msgQueue.take(); if (msg != null) { - AtomicInteger limitCount = limitCache.getIfPresent(msg.getWebHook()); - if (limitCount == null) { - limitCount = new AtomicInteger(1); - limitCache.put(msg.getWebHook(), limitCount); - } - if (limitCount.intValue() > maxQueueSize) { - msgQueue.offer(msg); - Thread.sleep(1000); - } else { - sendPostByJSON(msg); - limitCount.addAndGet(1); - } + sendPostByJSON(msg); } else { Thread.sleep(1000); } diff --git a/epmet-module/data-report/data-report-server/deploy/docker-compose-dev.yml b/epmet-module/data-report/data-report-server/deploy/docker-compose-dev.yml index 06d8740880..dea1fde0fd 100644 --- a/epmet-module/data-report/data-report-server/deploy/docker-compose-dev.yml +++ b/epmet-module/data-report/data-report-server/deploy/docker-compose-dev.yml @@ -2,7 +2,7 @@ version: "3.7" services: data-report-server: container_name: data-report-server-dev - image: 192.168.1.130:10080/epmet-cloud-dev/data-report-server:0.3.16 + image: 192.168.1.130:10080/epmet-cloud-dev/data-report-server:0.3.17 ports: - "8109:8109" network_mode: host # 使用现有网络 diff --git a/epmet-module/data-report/data-report-server/pom.xml b/epmet-module/data-report/data-report-server/pom.xml index 293500ea7b..a79c50eef2 100644 --- a/epmet-module/data-report/data-report-server/pom.xml +++ b/epmet-module/data-report/data-report-server/pom.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - 0.3.16 + 0.3.17 data-report-server diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/user/UserAnalysisDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/user/UserAnalysisDao.xml index a36fe93ab5..29e482c554 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/user/UserAnalysisDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/user/UserAnalysisDao.xml @@ -57,8 +57,8 @@ m.id, m.DATE_ID AS currentDate, m.DATE_ID AS dateId, - m.REG_TOTAL AS regTotal, - 0 AS partiTotal, + m.REG_TOTAL AS partiTotal, + 0 AS regTotal, m.PARTYMEMBER_TOTAL AS partymemberTotal, m.PARTYMEMBER_PROPORTION*100 AS partymemberProportionValue, m.WARM_HEARTED_TOTAL AS warmHeartedTotal, diff --git a/epmet-module/data-statistical/data-statistical-server/deploy/docker-compose-dev.yml b/epmet-module/data-statistical/data-statistical-server/deploy/docker-compose-dev.yml index 0f567c71b9..0ea8dc6ffa 100644 --- a/epmet-module/data-statistical/data-statistical-server/deploy/docker-compose-dev.yml +++ b/epmet-module/data-statistical/data-statistical-server/deploy/docker-compose-dev.yml @@ -2,7 +2,7 @@ version: "3.7" services: data-statistical-server: container_name: data-statistical-server-dev - image: 192.168.1.130:10080/epmet-cloud-dev/data-statistical-server:0.3.21 + image: 192.168.1.130:10080/epmet-cloud-dev/data-statistical-server:0.3.22 ports: - "8108:8108" network_mode: host # 使用现有网络 diff --git a/epmet-module/data-statistical/data-statistical-server/pom.xml b/epmet-module/data-statistical/data-statistical-server/pom.xml index ccae6bd2af..4e2dfff3a8 100644 --- a/epmet-module/data-statistical/data-statistical-server/pom.xml +++ b/epmet-module/data-statistical/data-statistical-server/pom.xml @@ -2,7 +2,7 @@ - 0.3.21 + 0.3.22 data-statistical com.epmet @@ -159,7 +159,7 @@ 6379 123456 - true + false 122.152.200.70:8848 fcd6fc8f-ca3a-4b01-8026-2b05cdc5976b diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/topic/impl/TopicServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/topic/impl/TopicServiceImpl.java index a4e9ecbc6a..77df964e59 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/topic/impl/TopicServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/topic/impl/TopicServiceImpl.java @@ -921,4 +921,333 @@ public class TopicServiceImpl implements TopicService { } + /** + * @Description 根据话题状态的维度自动匹配、分析数据 + * @param + * @return + * @author wangc + * @date 2020.06.30 17:04 + **/ + void analyzeTopicGroupByIssueStatus(Map> subGridOfAgency, List agencies, Map> gridGroupMap, Map> topicOperationMap, Date targetDate, TopicStatisticalData dataPacket, List statusDimension, DimIdGenerator.DimIdBean timeDimension){ + //Boolean isMonthEnd = false; + Calendar calendar = Calendar.getInstance(); + calendar.setTime(new Date()); + //前一天零点 + calendar.add(Calendar.DATE, NumConstant.ONE_NEG); + calendar.set(Calendar.HOUR_OF_DAY, NumConstant.ZERO); + calendar.set(Calendar.MINUTE, NumConstant.ZERO); + calendar.set(Calendar.SECOND, NumConstant.ZERO); + Date targetDateCheck = null == targetDate ? calendar.getTime() : targetDate; + + calendar.setTime(targetDateCheck); + //如果目标日期是当月的最后一天 + //if(calendar.get(Calendar.DATE) == calendar.getActualMaximum(Calendar.DAY_OF_MONTH)){ + //求出这个月的第一天 + calendar.setTime(new Date()); + calendar.set(Calendar.DAY_OF_MONTH, NumConstant.ONE); + calendar.set(Calendar.HOUR_OF_DAY, NumConstant.ZERO); + calendar.set(Calendar.MINUTE, NumConstant.ZERO); + calendar.set(Calendar.SECOND, NumConstant.ZERO); + + // isMonthEnd = true; + //} + + //计算百分比使用,保留小数点后两位 + NumberFormat numberFormat = NumberFormat.getInstance(); + numberFormat.setMaximumFractionDigits(NumConstant.SIX); + + Map statusMap = new HashMap<>(); + statusDimension.forEach(status -> statusMap.put(status.getId(),status)); + Map agencyMap = new HashMap<>(); + agencies.forEach(agency -> {agencyMap.put(agency.getAgencyId(),agency);}); + + + List groupList = new LinkedList<>(); + for(Map.Entry> entry : gridGroupMap.entrySet()){ + if(null != entry.getValue() && entry.getValue().size() > NumConstant.ZERO) + groupList.addAll(entry.getValue()); + } + + //key -> groupId + Map groupTopicData = traverseGroupTopic(groupList,topicOperationMap); + Map gridDistinct = new HashMap<>(); + agencies.forEach(agency -> { + if(null != agency.getGridIds() && agency.getGridIds().size() > NumConstant.ZERO){ + agency.getGridIds().forEach(grid -> { + gridDistinct.put(grid,false); + }); + } + }); + + for(Map.Entry> entry : subGridOfAgency.entrySet()){ + + FactTopicIssueAgencyDailyDTO issueAgencyD = new FactTopicIssueAgencyDailyDTO(); + FactTopicTotalAgencyDailyDTO totalAgencyD = new FactTopicTotalAgencyDailyDTO(); + + //initAgencyDailyDTO(entry.getKey(),agencyMap.get(entry.getKey()).getPid(),agencyMap.get(entry.getKey()).getCustomerId(),timeDimension,statusMap,issueAgencyD,totalAgencyD); + + + statusMap.forEach((k,v) -> { + //无状态标识 + boolean noStatusFlag = false; + if(StringUtils.equals(k,"discussing")){ + noStatusFlag = true; + } + final boolean noStatusFlagFinal = noStatusFlag; + + //k:状态的key + //对应状态key的一条话题-状态记录 + FactTopicStatusAgencyDailyDTO topicAgencyD = new FactTopicStatusAgencyDailyDTO(); + topicAgencyD.setTopicStatusId(k); + //initAgencyDailyDTO + + if(null != entry.getValue() && entry.getValue().size() > NumConstant.ZERO){ + entry.getValue().forEach(gridId -> { + + + FactTopicStatusGridDailyDTO topicGridD = new FactTopicStatusGridDailyDTO(); + + topicGridD.setTopicStatusId(k); + + FactTopicIssueGridDailyDTO issueGridD = new FactTopicIssueGridDailyDTO(); + FactTopicTotalGridDailyDTO totalGirdD = new FactTopicTotalGridDailyDTO(); + + //init + //if(noStatusFlagFinal){ + //initGridDailyDTO(entry.getKey(),gridId,agencyMap.get(entry.getKey()).getCustomerId(),timeDimension,statusMap,issueGridD,totalGirdD,topicGridD_discussing); + //}else{ + //initGridDailyDTO(entry.getKey(),gridId,agencyMap.get(entry.getKey()).getCustomerId(),timeDimension,statusMap,topicGridD_discussing); + //} + + + List groups = gridGroupMap.get(gridId); + if(null != groups && groups.size() > NumConstant.ZERO) { + groups.forEach(group -> { + if (null != group && StringUtils.isNotBlank(group.getGroupId())) { + + if(noStatusFlagFinal) { + issueAgencyD.setIssueIncr(issueAgencyD.getIssueIncr() + groupTopicData.get(group.getGroupId()).getIssueIncr()); + issueAgencyD.setIssueTotal(issueAgencyD.getIssueTotal() + groupTopicData.get(group.getGroupId()).getIssueTotal()); + totalAgencyD.setIssueTotalCount(issueAgencyD.getIssueTotal()); + totalAgencyD.setHiddenTotalCount(totalAgencyD.getHiddenTotalCount() + groupTopicData.get(group.getGroupId()).getHiddenTotal()); + totalAgencyD.setTopicIncr(totalAgencyD.getTopicIncr() + groupTopicData.get(group.getGroupId()).getTopicIncr()); + totalAgencyD.setTopicTotal(totalAgencyD.getTopicTotal() + groupTopicData.get(group.getGroupId()).getTotal()); + issueGridD.setIssueIncr(issueGridD.getIssueIncr() + groupTopicData.get(group.getGroupId()).getIssueIncr()); + issueGridD.setIssueTotal(issueGridD.getIssueTotal() + groupTopicData.get(group.getGroupId()).getIssueTotal()); + totalGirdD.setIssueTotalCount(issueGridD.getIssueTotal()); + totalGirdD.setHiddenTotalCount(totalGirdD.getHiddenTotalCount() + groupTopicData.get(group.getGroupId()).getHiddenTotal()); + totalGirdD.setTopicIncr(totalGirdD.getTopicIncr() + groupTopicData.get(group.getGroupId()).getTopicIncr()); + totalGirdD.setTopicTotal(totalGirdD.getTopicTotal() + groupTopicData.get(group.getGroupId()).getTotal()); + } + + + + GroupTopicData data = groupTopicData.get(group.getGroupId()); + if (null != data) { + + //根据当前的话题状态key,去data中取相应的数据 + switch(k){ + case "discussing": + + topicAgencyD.setTopicCount(topicAgencyD.getTopicCount() + data.getDiscussingTotal()); + topicAgencyD.setTopicIncrement(topicAgencyD.getTopicIncrement() + data.getDiscussingIncr()); + + topicGridD.setTopicCount(topicGridD.getTopicCount() + data.getDiscussingTotal()); + topicGridD.setTopicIncrement(topicGridD.getTopicIncrement() + data.getDiscussingIncr()); + break; + case "hidden": + + topicAgencyD.setTopicCount(topicAgencyD.getTopicCount() + data.getHiddenTotal()); + topicAgencyD.setTopicIncrement(topicAgencyD.getTopicIncrement() + data.getHiddenIncr()); + + topicGridD.setTopicCount(topicGridD.getTopicCount() + data.getHiddenTotal()); + topicGridD.setTopicIncrement(topicGridD.getTopicIncrement() + data.getHiddenIncr()); + break; + case "closed": + + topicAgencyD.setTopicCount(topicAgencyD.getTopicCount() + data.getClosedTotal()); + topicAgencyD.setTopicIncrement(topicAgencyD.getTopicIncrement() + data.getClosedIncr()); + + topicGridD.setTopicCount(topicGridD.getTopicCount() + data.getClosedTotal()); + topicGridD.setTopicIncrement(topicGridD.getTopicIncrement() + data.getClosedIncr()); + break; + } + + } + + } + + + }); + } + //网格-百分比 + //setGridTopicProportion(numberFormat, topicGridD, totalGirdD); + + if(!gridDistinct.get(gridId)) { + + //setGridDailyDataPacket(dataPacket, issueGridD, totalGirdD, topicGridD_discussing, topicGridD_hidden, topicGridD_closed); + /* + if(noStatusFlagFinal){ + set :: issueGridD | totalGridD | topicGridD + }else{ + set :: topicGridD + } + */ + gridDistinct.put(gridId,true); + } + + + + }); + + + } + //机关-百分比 + //setAgencyTopicProportion(numberFormat,topicAgencyD,totalAgencyD); + + + + //setAgencyDailyDataPacket(dataPacket,issueAgencyD,totalAgencyD,topicAgencyD_discussing,topicAgencyD_hidden,topicAgencyD_closed); + /* + if(noStatusFlagFinal){ + set :: issueAgencyD | totalAgencyD | topicAgencyD + }else{ + set :: topicAgencyD + } + */ + + }); + + + } + + gridDistinct.forEach((k,v) -> { + gridDistinct.put(k,false); + }); + + List topicsBetweenTimeRange = topicDao.selectGroupOrderByGridBetweenTimeRange(calendar.getTime(),targetDate,dataPacket.getCustomerId()); + //key : gridId + Map> GridGroupMapBetweenTimeRange = + topicsBetweenTimeRange.stream().collect(Collectors.groupingBy(ResiGroupTopicResultDTO::getGridId)); + List groupListBetweenTimeRange = new LinkedList<>(); + + for(Map.Entry> entryBetweenTimeRange : GridGroupMapBetweenTimeRange.entrySet()){ + if(null != entryBetweenTimeRange.getValue() && entryBetweenTimeRange.getValue().size() > NumConstant.ZERO) + groupListBetweenTimeRange.addAll(entryBetweenTimeRange.getValue()); + } + List operationsBetweenTimeRange = + topicDao.selectTopicOperationRecordBetweenTimeRange(calendar.getTime(),targetDate); + + //key: topicId + Map> topicOperationMapBetweenTimeRange = + operationsBetweenTimeRange.stream().collect(Collectors.groupingBy(ResiTopicOperationResultDTO::getTopicId)); + //key: groupId + Map groupTopicDataBetweenTimeRange = traverseGroupTopic(groupListBetweenTimeRange,topicOperationMapBetweenTimeRange); + + for(Map.Entry> entry : subGridOfAgency.entrySet()){ + + FactTopicIssueAgencyMonthlyDTO issueAgencyM = new FactTopicIssueAgencyMonthlyDTO(); + + + //initAgencyMonthlyDTO(entry.getKey(),agencyMap.get(entry.getKey()).getPid(),agencyMap.get(entry.getKey()).getCustomerId(),timeDimension,statusMap,issueAgencyM); + + + statusMap.forEach((k,v) -> { + boolean noStatusFlag = false; + if(StringUtils.equals(k,"discussing")){ + noStatusFlag = true; + } + final boolean noStatusFlagFinal = noStatusFlag; + + FactTopicStatusAgencyMonthlyDTO topicAgencyM = new FactTopicStatusAgencyMonthlyDTO(); + topicAgencyM.setTopicStatusId(k); + + if(null != entry.getValue() && entry.getValue().size() > NumConstant.ZERO){ + entry.getValue().forEach(gridId -> { + + + FactTopicIssueGridMonthlyDTO issueGridM = new FactTopicIssueGridMonthlyDTO(); + initGridMonthlyDTO(entry.getKey(),gridId,agencyMap.get(entry.getKey()).getCustomerId(),timeDimension,issueGridM); + + + List groups = gridGroupMap.get(gridId); + if(null != groups) { + groups.forEach(group -> { + if (null != group && StringUtils.isNotBlank(group.getGroupId())) { + + if(noStatusFlagFinal) { + + issueAgencyM.setIssueIncr(issueAgencyM.getIssueIncr() + groupTopicDataBetweenTimeRange.get(group.getGroupId()).getIssueIncr()); + issueAgencyM.setIssueTotal(issueAgencyM.getIssueTotal() + groupTopicDataBetweenTimeRange.get(group.getGroupId()).getIssueTotal()); + issueGridM.setIssueIncr(issueGridM.getIssueIncr() + groupTopicDataBetweenTimeRange.get(group.getGroupId()).getIssueIncr()); + issueGridM.setIssueTotal(issueGridM.getIssueTotal() + groupTopicDataBetweenTimeRange.get(group.getGroupId()).getIssueTotal()); + + } + + GroupTopicData data = groupTopicDataBetweenTimeRange.get(group.getGroupId()); + if (null != data) { + + switch(k){ + case "discussing": + + topicAgencyM.setTopicCount(topicAgencyM.getTopicCount() + data.getDiscussingTotal()); + topicAgencyM.setTopicIncr(topicAgencyM.getTopicIncr() + data.getDiscussingIncr()); + break; + case "hidden": + + topicAgencyM.setTopicCount(topicAgencyM.getTopicCount() + data.getHiddenTotal()); + topicAgencyM.setTopicIncr(topicAgencyM.getTopicIncr() + data.getHiddenIncr()); + break; + case "closed": + + topicAgencyM.setTopicCount(topicAgencyM.getTopicCount() + data.getClosedTotal()); + topicAgencyM.setTopicIncr(topicAgencyM.getTopicIncr() + data.getClosedIncr()); + break; + } + + + } + + } + + + }); + } + + if(!gridDistinct.get(gridId)) { + + setGridMonthlyDataPacket(dataPacket, issueGridM); + } + + gridDistinct.put(gridId,true); + }); + + + } + + //机关-百分比 + //Integer topicTotal = dataPacket.getTotalAgencyDailyList().stream().filter( obj -> StringUtils.equals(obj.getAgencyId(),entry.getKey())).findFirst().get().getTopicTotal(); + //setAgencyTopicMonthlyProportion(numberFormat,topicAgencyM,topicTotal); + + + /* + if(noStatusFlagFinal){ + set :: issueAgencyM | topicAgencyM + }else{ + set topicAgencyM + } + + */ + }); + + + + } + + + + + } + + } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java index f7655f12a7..3882b0d524 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java @@ -186,15 +186,17 @@ public class UserServiceImpl implements UserService { Boolean isMonthBeginning = true; Calendar calendar =Calendar.getInstance(); + //求出T-1 calendar.setTime(new Date()); calendar.add(Calendar.DATE, NumConstant.ONE_NEG); Date targetDateCheck = null == targetDate ? calendar.getTime() : targetDate; + //指定日期 OR T-1 calendar.setTime(targetDateCheck); //如果目标日期不是是当月的第一天 if(calendar.get(Calendar.DATE) != calendar.getActualMinimum(Calendar.DAY_OF_MONTH)){ //求出这个月的第一天 - calendar.setTime(new Date()); + calendar.set(Calendar.DAY_OF_MONTH, NumConstant.ONE); calendar.set(Calendar.HOUR_OF_DAY, NumConstant.ZERO); calendar.set(Calendar.MINUTE, NumConstant.ZERO); @@ -255,7 +257,7 @@ public class UserServiceImpl implements UserService { regAgencyD.setPartymemberTotal(partyRegData.getTotal()); regAgencyD.setRegIncr(regData.getIncr()); regAgencyD.setWarmIncr(warmRegData.getIncr()); - regAgencyD.setPartymemberIncr(partiData.getIncr()); + regAgencyD.setPartymemberIncr(partyPartiData.getIncr()); regAgencyD.setResiProportion(new BigDecimal(NumConstant.ONE)); regAgencyD.setPartymemberProportion(null == regData.getTotal() || regData.getTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float)partyRegData.getTotal()/(float)regData.getTotal() ))); regAgencyD.setWarmHeartedProportion(null == regData.getTotal() || regData.getTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float)warmRegData.getTotal()/(float)regData.getTotal() ))); @@ -312,7 +314,7 @@ public class UserServiceImpl implements UserService { regAgencyM.setPartymemberTotal(partyRegData.getTotal()); regAgencyM.setRegIncr(regData.getIncr()); regAgencyM.setWarmIncr(warmRegData.getIncr()); - regAgencyM.setPartymemberIncr(partiData.getIncr()); + regAgencyM.setPartymemberIncr(partyPartiData.getIncr()); regAgencyM.setResiProportion(new BigDecimal(NumConstant.ONE)); regAgencyM.setPartymemberProportion(regAgencyD.getPartymemberProportion()); regAgencyM.setWarmHeartedProportion(regAgencyD.getWarmHeartedProportion());