|
|
|
@ -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<MessagePushRec
|
|
|
|
|
messagePushRecordTypeVo.setMessagePushRecordList(value); |
|
|
|
|
messagePushRecordTypeVos.add(messagePushRecordTypeVo); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//封装typeName的数据
|
|
|
|
|
messagePushRecordTypeVos.forEach(item1 -> { |
|
|
|
|
List<MessagePushRecordVo> 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<YearMonth> previousMonth = this.getPreviousMonth(); |
|
|
|
|
//创建新的数组 List<MessagePushRecordVo>
|
|
|
|
|
List<MessagePushRecordVo> 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<MessagePushRecordVo>
|
|
|
|
|
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<MessagePushRecordVo> 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<MessagePushRec
|
|
|
|
|
case 3: |
|
|
|
|
value = PushStatEnum.CONFIRMED.getValue(); |
|
|
|
|
break; |
|
|
|
|
case 4: |
|
|
|
|
log.error("状态异常,没有这状态"); |
|
|
|
|
default: |
|
|
|
|
value = DictCache.getValue("messageStatus", key); |
|
|
|
|
if (value == null) { |
|
|
|
|
log.error("状态异常,没有这状态"); |
|
|
|
|
value = String.valueOf(key); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
return value; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* type ===> 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<MessagePushRec
|
|
|
|
|
case "inspect": |
|
|
|
|
value = "巡检消息"; |
|
|
|
|
break; |
|
|
|
|
case "": |
|
|
|
|
log.error("状态业务分类,没有这状态"); |
|
|
|
|
case "warning": |
|
|
|
|
value = "告警消息"; |
|
|
|
|
default: |
|
|
|
|
value = DictCache.getValue("businessClassify", key); |
|
|
|
|
if (value == null) { |
|
|
|
|
log.error("状态业务分类,没有这状态"); |
|
|
|
|
value = key; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
return value; |
|
|
|
@ -321,4 +412,17 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl<MessagePushRec
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 往前推12个月,获取以往12个月的数据 |
|
|
|
|
*/ |
|
|
|
|
private List<YearMonth> getPreviousMonth() { |
|
|
|
|
List<YearMonth> month = new ArrayList<>(); |
|
|
|
|
YearMonth today = YearMonth.now(); |
|
|
|
|
for (int i = 0; i <= 11; i++) { |
|
|
|
|
YearMonth localDate = today.minusMonths(i); |
|
|
|
|
month.add(localDate); |
|
|
|
|
} |
|
|
|
|
return month; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|