From 21395db1204617c4b9e0acf1b1b28005a0b189ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AE=B5=E9=A3=9E=E5=AE=87?= <2684146481@qq.com> Date: Thu, 13 Apr 2023 12:40:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=B6=88=E6=81=AF=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vo/msgpushrecord/MessagePushRecordTypeVo.java | 4 + .../vo/msgpushrecord/MessagePushRecordVo.java | 6 ++ .../message/mapper/MessagePushRecordMapper.xml | 1 + .../service/impl/MessagePushRecordServiceImpl.java | 112 ++++++++++++++++++++- .../hzims/operational/OperationApplication.java | 9 ++ 5 files changed, 128 insertions(+), 4 deletions(-) diff --git a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/MessagePushRecordTypeVo.java b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/MessagePushRecordTypeVo.java index 8ed09ba..a1ce5ed 100644 --- a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/MessagePushRecordTypeVo.java +++ b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/MessagePushRecordTypeVo.java @@ -17,6 +17,10 @@ public class MessagePushRecordTypeVo { * 消息类型 */ private String type; + /** + * 消息类型名称 + */ + private String typeName; private List messagePushRecordList; } diff --git a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/MessagePushRecordVo.java b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/MessagePushRecordVo.java index 0362dd8..444ef94 100644 --- a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/MessagePushRecordVo.java +++ b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/MessagePushRecordVo.java @@ -40,6 +40,12 @@ public class MessagePushRecordVo implements Serializable { */ private String type; + + /** + * 消息类型名称 + */ + private String typeName; + /** * 统计数量 */ diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.xml b/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.xml index 0412c8c..0eb5aa4 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.xml +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.xml @@ -22,6 +22,7 @@ from hzims_message_push_record IS_DELETED = 0 + and PLAN_TIME BETWEEN DATE_SUB(NOW(), INTERVAL 12 MONTH) AND NOW() and DEPT_ID = #{vo.stationCode} diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java index d98330d..b18aefd 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java @@ -34,10 +34,13 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.Assert; import javax.validation.Valid; +import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.Year; import java.time.YearMonth; import java.time.format.DateTimeFormatter; import java.util.ArrayList; +import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -146,6 +149,52 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl { + List messagePushRecordList = item1.getMessagePushRecordList(); + //String messageType = DictCache.getValue("messageType", item1.getType()); + //System.out.println("messageType = " + messageType); + String typeByName = getTypeByName(item1.getType()); + item1.setTypeName(typeByName); + //获取以往12个月的数据 + List previousMonth = this.getPreviousMonth(); + //创建新的数组 List + List lists = new ArrayList<>(); + messagePushRecordList.forEach(item2 -> { + YearMonth strMonth = item2.getStrMonth(); + // 字符串转localDate 获取月份 + item2.setMonth(strMonth.getMonthValue()); + item2.setYear(strMonth.getYear()); + if (previousMonth.contains(strMonth)) { + previousMonth.remove(strMonth); + } + //封装typeValue + item2.setTypeName(typeByName); + lists.add(item2); + }); + + //如果还存在YearMonth,把MessagePushRecordVo添加到新的数组 List + if (CollectionUtils.isNotEmpty(previousMonth)) { + for (YearMonth yearMonth : previousMonth) { + MessagePushRecordVo messagePushRecordVo = new MessagePushRecordVo(); + messagePushRecordVo.setYear(yearMonth.getYear()); + messagePushRecordVo.setMonth(yearMonth.getMonthValue()); + messagePushRecordVo.setType(item1.getType()); + messagePushRecordVo.setPower(0L); + messagePushRecordVo.setStrMonth(yearMonth); + //封装typeValue + messagePushRecordVo.setTypeName(typeByName); + lists.add(messagePushRecordVo); + } + } + List newLists = lists.stream().sorted(Comparator.comparing(MessagePushRecordVo::getStrMonth).reversed()).collect(Collectors.toList()); + // 封装到 setMessagePushRecordList + item1.setMessagePushRecordList(newLists); + }); + + return messagePushRecordTypeVos; } @@ -271,8 +320,44 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl typeName + * + * @param key 状态 + */ + private String getTypeByName(String key) { + String value = null; + switch (key) { + case "appPush": + value = "app推送"; + break; + case "smsPush": + value = "短信推送"; + break; + case "websocketPush": + value = "web推送"; + break; + case "mailPush": + value = "邮件推送"; + break; + default: + value = DictCache.getValue("messageType", key); + if (value == null) { + log.error("状态异常,没有这状态"); + value = key; + } break; } return value; @@ -300,8 +385,14 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl getPreviousMonth() { + List month = new ArrayList<>(); + YearMonth today = YearMonth.now(); + for (int i = 0; i <= 11; i++) { + YearMonth localDate = today.minusMonths(i); + month.add(localDate); + } + return month; + } + } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/OperationApplication.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/OperationApplication.java index e8cca7f..42143c2 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/OperationApplication.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/OperationApplication.java @@ -40,6 +40,15 @@ import javax.annotation.Resource; @Resource public class OperationApplication extends SpringBootServletInitializer { + static{ + System.setProperty("--spring.cloud.nacos.discovery.server-addr", "http://175.6.40.67:10042"); + System.setProperty("--spring.cloud.nacos.config.server-addr", "http://175.6.40.67:10042"); + System.setProperty("--spring.cloud.nacos.username", "nacos"); + System.setProperty("--spring.cloud.nacos.password", "nacos"); + } + + + public static void main(String[] args) { BladeApplication.run(OperationalConstants.APP_NAME, OperationApplication.class, args); }