问题单修复

This commit is contained in:
zhuxinyu
2023-04-23 11:29:04 +08:00
parent 3f4a1254bf
commit 87f08d8558
9 changed files with 109 additions and 85 deletions

View File

@@ -12,7 +12,7 @@ import java.util.List;
public interface RStatLimitTargetMapper extends BaseMapper<RStatLimitTargetDPO> { public interface RStatLimitTargetMapper extends BaseMapper<RStatLimitTargetDPO> {
Page<MonitorOverLimitVO> getSumLimitTargetPage(Page<RStatLimitRateDPO> p, Page<MonitorOverLimitVO> getSumLimitTargetPage(Page<MonitorOverLimitVO>p,
@Param("ids") List<String> lineIndexes, @Param("ids") List<String> lineIndexes,
@Param("startTime") DateTime startTime, @Param("endTime") DateTime endTime); @Param("startTime") DateTime startTime, @Param("endTime") DateTime endTime);
} }

View File

@@ -295,13 +295,10 @@ public class AnalyzeServiceImpl implements IAnalyzeService {
lineList.addAll(item.getLineIndexes()); lineList.addAll(item.getLineIndexes());
}); });
} }
Page<RStatLimitRateDPO> p = new Page<>();
p.setSize(param.getPageSize());
p.setCurrent(param.getPageNum());
if (CollectionUtil.isNotEmpty(lineList)) { if (CollectionUtil.isNotEmpty(lineList)) {
Page<MonitorOverLimitVO> sumLimitRatePage = targetMapper.getSumLimitTargetPage(p, lineList, DateUtil.beginOfDay(DateUtil.parse(param.getSearchBeginTime())), page = targetMapper.getSumLimitTargetPage(page, lineList, DateUtil.beginOfDay(DateUtil.parse(param.getSearchBeginTime())),
DateUtil.endOfDay(DateUtil.parse(param.getSearchEndTime()))); DateUtil.endOfDay(DateUtil.parse(param.getSearchEndTime())));
List<MonitorOverLimitVO> pageRecords = sumLimitRatePage.getRecords(); List<MonitorOverLimitVO> pageRecords = page.getRecords();
if (CollectionUtils.isEmpty(pageRecords)) { if (CollectionUtils.isEmpty(pageRecords)) {
return page; return page;
} }
@@ -360,9 +357,8 @@ public class AnalyzeServiceImpl implements IAnalyzeService {
} }
if (!CollectionUtils.isEmpty(result)){ if (!CollectionUtils.isEmpty(result)){
List<MonitorOverLimitVO> recordList = new ArrayList<>();
//默认 根据在线监测点个数 倒叙排序 //默认 根据在线监测点个数 倒叙排序
recordList = result.stream().sorted(Comparator.comparing(MonitorOverLimitVO::getOverDay).reversed()).collect(Collectors.toList()); List<MonitorOverLimitVO> recordList = result.stream().sorted(Comparator.comparing(MonitorOverLimitVO::getOverDay).reversed()).collect(Collectors.toList());
page.setRecords(recordList); page.setRecords(recordList);
return page; return page;
} }

View File

@@ -50,5 +50,9 @@ public class Communicate {
@Column(name = "description") @Column(name = "description")
private String remark; private String remark;
private Integer duration;
private String desc;
} }

View File

@@ -1,5 +1,6 @@
package com.njcn.prepare.harmonic.pojo.mysql.po.line; package com.njcn.prepare.harmonic.pojo.mysql.po.line;
import cn.hutool.core.date.DateTime;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.njcn.db.bo.BaseEntity; import com.njcn.db.bo.BaseEntity;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
@@ -46,8 +47,7 @@ public class AlarmPO implements Serializable {
*/ */
private Integer alarmCount; private Integer alarmCount;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone ="GMT+8") private String updateTime;
private LocalDateTime updateTime;
/** /**
* 1.装置 2.监测点 * 1.装置 2.监测点

View File

@@ -1,6 +1,7 @@
package com.njcn.prepare.harmonic.pojo.mysql.po.line; package com.njcn.prepare.harmonic.pojo.mysql.po.line;
import com.njcn.db.bo.BaseEntity; import com.njcn.db.bo.BaseEntity;
import com.njcn.prepare.harmonic.pojo.influxdb.po.Communicate;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@@ -31,11 +32,10 @@ public class TopMsgPO extends BaseEntity {
*/ */
private Integer comOutCount; private Integer comOutCount;
/** /**
* 通信中断时间段描述 * 通信中断时间段描述
*/ */
private List<String> comOutDesc;
private String comOutDescription; private String comOutDescription;
/** /**
@@ -74,10 +74,10 @@ public class TopMsgPO extends BaseEntity {
private float onlineRateValue; private float onlineRateValue;
private Integer offtimeValue;
private Integer offtimeFlag; private Integer offtimeFlag;
private List<Communicate> communicates;
/** /**
* 状态 0.删除 1.正常 * 状态 0.删除 1.正常
*/ */

View File

@@ -40,7 +40,7 @@
SELECT line.Id AS id, SELECT line.Id AS id,
device.Id AS deviceId, device.Id AS deviceId,
sdd.Algo_Describe AS level, sdd.Algo_Describe AS level,
device.Update_Time AS updateTime DATE_FORMAT(pd.Update_Time, "%Y-%m-%d %H:%i:%s") AS updateTime
FROM pq_line line FROM pq_line line
INNER JOIN pq_line vol ON line.pid=vol.id INNER JOIN pq_line vol ON line.pid=vol.id
INNER JOIN pq_line device ON vol.pid=device.id INNER JOIN pq_line device ON vol.pid=device.id
@@ -101,16 +101,17 @@
FROM FROM
( (
SELECT SELECT
cmf.Dev_Id deviceId, device.id deviceId,
IFNULL(d.flow, (select flow from cld_flow_meal where type = 0 and flag = 1)) + IFNULL(d1.flow, 0) flowMeal, IFNULL(d.flow, (select flow from cld_flow_meal where type = 0 and flag = 1)) + IFNULL(d1.flow, 0) flowMeal,
IFNULL(cmf.Actual_Value,0) actualValue, IFNULL(cmf.Actual_Value/1024/1024,0) actualValue,
rsod.online_min/1440 onlineRate rsod.online_min/(rsod.online_min+rsod.offline_min) onlineRate
FROM cld_month_flow cmf FROM pq_line device
LEFT JOIN cld_month_flow cmf ON cmf.Dev_Id = device.id
LEFT JOIN cld_dev_meal c ON cmf.Dev_Id = c.Line_Id LEFT JOIN cld_dev_meal c ON cmf.Dev_Id = c.Line_Id
LEFT JOIN cld_flow_meal d ON c.Base_Meal_Id = d.id LEFT JOIN cld_flow_meal d ON c.Base_Meal_Id = d.id
LEFT JOIN cld_flow_meal d1 ON c.Ream_Meal_Id = d1.id LEFT JOIN cld_flow_meal d1 ON c.Ream_Meal_Id = d1.id
LEFT JOIN r_stat_onlinerate_d rsod ON rsod.dev_index = cmf.Dev_Id LEFT JOIN r_stat_onlinerate_d rsod ON rsod.dev_index = device.id
WHERE cmf.Dev_Id IN WHERE device.id IN
<foreach collection="list" index="index" item="item" open="(" separator="," close=")"> <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item} #{item}
</foreach> </foreach>

View File

@@ -22,6 +22,7 @@ import java.math.RoundingMode;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.*; import java.time.*;
import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -48,6 +49,9 @@ public class DeviceAbnormaStatisticsServiceImpl implements DeviceAbnormalStatist
List<String> monotorIds = lines.stream().map(AlarmPO::getId).collect(Collectors.toList()); List<String> monotorIds = lines.stream().map(AlarmPO::getId).collect(Collectors.toList());
// 装置id集合 // 装置id集合
List<String> devIds = new ArrayList<>(devMap.keySet()); List<String> devIds = new ArrayList<>(devMap.keySet());
// 获取异常告警策略
List<AlarmStrategyVO> alarmStrategyVOS = deviceAbnormaStatisticsMapper.selectAlarmStrategy();
Map<Integer, List<AlarmStrategyVO>> levMap = alarmStrategyVOS.stream().collect(Collectors.groupingBy(AlarmStrategyVO::getAlgoDesc));
// 获取监测点数据完整性 // 获取监测点数据完整性
List<AlarmPO> lineIntegritys = deviceAbnormaStatisticsMapper.getIntegrityByLineIds( List<AlarmPO> lineIntegritys = deviceAbnormaStatisticsMapper.getIntegrityByLineIds(
monotorIds, monotorIds,
@@ -68,41 +72,45 @@ public class DeviceAbnormaStatisticsServiceImpl implements DeviceAbnormalStatist
if (CollectionUtil.isNotEmpty(deviceFlowAndOnlineRate)) { if (CollectionUtil.isNotEmpty(deviceFlowAndOnlineRate)) {
deviceFlowAndOnlineRateMap = deviceFlowAndOnlineRate.stream().collect(Collectors.groupingBy(AlarmPO::getDeviceId)); deviceFlowAndOnlineRateMap = deviceFlowAndOnlineRate.stream().collect(Collectors.groupingBy(AlarmPO::getDeviceId));
} }
// 获取通信中断信息 // 获取通信中断信息
// List<String> list = Arrays.asList("025fa0e4c91f72ad7f1c1bd29026f20a"); // List<String> list = Arrays.asList("025fa0e4c91f72ad7f1c1bd29026f20a");
List<TopMsgPO> comMsgs = getCommunicate(devIds, param.getTime(), param.getTime()); List<TopMsgPO> comMsgs = getCommunicate(devIds, param.getTime());
if (CollectionUtil.isNotEmpty(comMsgs)) { if (CollectionUtil.isNotEmpty(comMsgs)) {
comMap = comMsgs.stream().collect(Collectors.groupingBy(TopMsgPO::getDevId)); comMap = comMsgs.stream().collect(Collectors.groupingBy(TopMsgPO::getDevId));
} }
// 比对告警策略并落表
List<AlarmStrategyVO> alarmStrategyVOS = deviceAbnormaStatisticsMapper.selectAlarmStrategy();
Map<Integer, List<AlarmStrategyVO>> levMap = alarmStrategyVOS.stream().collect(Collectors.groupingBy(AlarmStrategyVO::getAlgoDesc));
// 整合装置信息 // 整合装置信息
List<TopMsgPO> topMsgPOS = new ArrayList<>(); List<TopMsgPO> topMsgPOS = new ArrayList<>();
for (Map.Entry<String, List<AlarmPO>> alarmEntry : devMap.entrySet()) { for (Map.Entry<String, List<AlarmPO>> devEntry : devMap.entrySet()) {
if (!lineIntegrityMap.containsKey(alarmEntry.getKey()) && !lineAlarmsMap.containsKey(alarmEntry.getKey()) if (!lineIntegrityMap.containsKey(devEntry.getKey()) && !lineAlarmsMap.containsKey(devEntry.getKey())
&& !deviceFlowAndOnlineRateMap.containsKey(alarmEntry.getKey()) && !comMap.containsKey(alarmEntry.getKey())) { && !deviceFlowAndOnlineRateMap.containsKey(devEntry.getKey()) && !comMap.containsKey(devEntry.getKey())) {
continue; continue;
} }
TopMsgPO topMsg = new TopMsgPO(); TopMsgPO topMsg = new TopMsgPO();
topMsg.setDevId(alarmEntry.getKey()); topMsg.setDevId(devEntry.getKey());
int deviceLevel = alarmEntry.getValue().stream().mapToInt(AlarmPO::getLevel).min().orElse(-1); topMsg.setIntegrityFlag(1);
topMsg.setOfftimeFlag(1);
topMsg.setFlowFlag(1);
topMsg.setOnlineRateFlag(1);
topMsg.setAlarmCountFlag(1);
int deviceLevel = devEntry.getValue().stream().mapToInt(AlarmPO::getLevel).min().orElse(-1);
// 装置等级
topMsg.setDeviceLevel(deviceLevel); topMsg.setDeviceLevel(deviceLevel);
// 等级对应的告警策略
AlarmStrategyVO alarmStrategyVO = levMap.get(deviceLevel).get(0); AlarmStrategyVO alarmStrategyVO = levMap.get(deviceLevel).get(0);
// 数据完整性 // 数据完整性
if (lineIntegrityMap.containsKey(alarmEntry.getKey())) { if (lineIntegrityMap.containsKey(devEntry.getKey())) {
Integer due = lineIntegrityMap.get(alarmEntry.getKey()).get(0).getDue(); Integer due = lineIntegrityMap.get(devEntry.getKey()).get(0).getDue();
Integer real = lineIntegrityMap.get(alarmEntry.getKey()).get(0).getReal(); Integer real = lineIntegrityMap.get(devEntry.getKey()).get(0).getReal();
float integrity = BigDecimal.valueOf((float) real *100 / due).setScale(2, RoundingMode.HALF_UP).floatValue(); float integrity = BigDecimal.valueOf((float) real *100 / due).setScale(2, RoundingMode.HALF_UP).floatValue();
topMsg.setIntegrityFlag(integrity < alarmStrategyVO.getIntegrityValue() ? 0 : 1); topMsg.setIntegrityFlag(integrity < alarmStrategyVO.getIntegrityValue() ? 0 : 1);
topMsg.setIntegrityValue(integrity); topMsg.setIntegrityValue(integrity);
} else {
topMsg.setIntegrityFlag(-1);
} }
// 装置告警 // 装置告警
if (lineAlarmsMap.containsKey(alarmEntry.getKey())) { if (lineAlarmsMap.containsKey(devEntry.getKey())) {
List<AlarmPO> lineAlarmPOS = lineAlarmsMap.get(alarmEntry.getKey()); List<AlarmPO> lineAlarmPOS = lineAlarmsMap.get(devEntry.getKey());
int alarmCount = lineAlarmPOS.stream().mapToInt(AlarmPO::getAlarmCount).sum(); int alarmCount = lineAlarmPOS.stream().mapToInt(AlarmPO::getAlarmCount).sum();
String alarmDesc = String.join(",", lineAlarmPOS.stream().map(AlarmPO::getAlarmDesc).collect(Collectors.toList())); String alarmDesc = String.join(",", lineAlarmPOS.stream().map(AlarmPO::getAlarmDesc).collect(Collectors.toList()));
topMsg.setAlarmCountFlag(alarmCount > alarmStrategyVO.getWarnValue() ? 0 : 1); topMsg.setAlarmCountFlag(alarmCount > alarmStrategyVO.getWarnValue() ? 0 : 1);
@@ -112,8 +120,8 @@ public class DeviceAbnormaStatisticsServiceImpl implements DeviceAbnormalStatist
topMsg.setAlarmCount(0); topMsg.setAlarmCount(0);
} }
// 流量和在线率 // 流量和在线率
if (deviceFlowAndOnlineRateMap.containsKey(alarmEntry.getKey())) { if (deviceFlowAndOnlineRateMap.containsKey(devEntry.getKey())) {
AlarmPO alarmPO = deviceFlowAndOnlineRateMap.get(alarmEntry.getKey()).get(0); AlarmPO alarmPO = deviceFlowAndOnlineRateMap.get(devEntry.getKey()).get(0);
topMsg.setFlowFlag(alarmPO.getActualValue() > alarmPO.getFlowMeal() ? 0 : 1); topMsg.setFlowFlag(alarmPO.getActualValue() > alarmPO.getFlowMeal() ? 0 : 1);
topMsg.setOnlineRateFlag(alarmPO.getOnlineRate() *100 < alarmStrategyVO.getOnlineValue() ? 0 : 1); topMsg.setOnlineRateFlag(alarmPO.getOnlineRate() *100 < alarmStrategyVO.getOnlineValue() ? 0 : 1);
topMsg.setFlowValue(alarmPO.getFlowProportion()); topMsg.setFlowValue(alarmPO.getFlowProportion());
@@ -123,29 +131,34 @@ public class DeviceAbnormaStatisticsServiceImpl implements DeviceAbnormalStatist
topMsg.setOnlineRateFlag(-1); topMsg.setOnlineRateFlag(-1);
} }
if (comMap.containsKey(alarmEntry.getKey())) { if (comMap.containsKey(devEntry.getKey())) {
TopMsgPO comOutPO = comMap.get(alarmEntry.getKey()).get(0); TopMsgPO comOutPO = comMap.get(devEntry.getKey()).get(0);
topMsg.setOfftimeFlag(comOutPO.getOfftimeValue() > alarmStrategyVO.getOffTimeValue() ? 0 :1); List<Communicate> abnormals = comOutPO.getCommunicates().stream().filter(t -> t.getDuration() > alarmStrategyVO.getOffTimeValue()).collect(Collectors.toList());
topMsg.setComOutCount(comOutPO.getComOutCount()); topMsg.setOfftimeFlag(abnormals.size() > 0 ? 0 :1);
topMsg.setComOutDescription(String.join(",",comOutPO.getComOutDesc())); topMsg.setComOutCount(abnormals.size());
List<String> abnormalDesc = abnormals.stream().map(Communicate::getDesc).collect(Collectors.toList());
topMsg.setComOutDescription(String.join(",",abnormalDesc));
} else { } else {
try {
if (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(devEntry.getValue().get(0).getUpdateTime()).after(DateUtil.endOfDay(DateUtil.parse(param.getTime())))) {
topMsg.setOfftimeFlag(0); topMsg.setOfftimeFlag(0);
String updateTime = localDateTimeFormat(alarmEntry.getValue().get(0).getUpdateTime());
long time = DateUtil.endOfDay(DateUtil.parse(param.getTime())).getTime() -
alarmEntry.getValue().get(0).getUpdateTime().toInstant(ZoneOffset.ofHours(8)).toEpochMilli();
topMsg.setOfftimeValue((int)(time/1000/60));
topMsg.setComOutCount(1); topMsg.setComOutCount(1);
topMsg.setComOutDescription(updateTime+""+DateUtil.endOfDay(DateUtil.parse(param.getTime()))); topMsg.setComOutDescription(DateUtil.beginOfDay(DateUtil.parse(param.getTime()))+""+devEntry.getValue().get(0).getUpdateTime());
} else if (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(devEntry.getValue().get(0).getUpdateTime()).before(DateUtil.beginOfDay(DateUtil.parse(param.getTime())))) {
topMsg.setOfftimeFlag(1);
topMsg.setComOutCount(0);
} }
if (topMsg.getFlowFlag() != 1 || topMsg.getIntegrityFlag() != 1 || topMsg.getOfftimeFlag() != 0 } catch (ParseException e) {
|| topMsg.getAlarmCountFlag() != 1 || topMsg.getOnlineRateFlag() != 1) { log.error("ParseException "+e);
}
}
if (topMsg.getFlowFlag() !=1 || topMsg.getIntegrityFlag() !=1 || topMsg.getOfftimeFlag() != 1
|| topMsg.getAlarmCountFlag() !=1 || topMsg.getOnlineRateFlag() !=1) {
topMsgPOS.add(topMsg); topMsgPOS.add(topMsg);
} }
} }
return deviceAbnormaStatisticsMapper.insertTopMsg(topMsgPOS); return deviceAbnormaStatisticsMapper.insertTopMsg(topMsgPOS);
} }
public String localDateTimeFormat(LocalDateTime localDateTime) { public String localDateTimeFormat(LocalDateTime localDateTime) {
@@ -156,12 +169,10 @@ public class DeviceAbnormaStatisticsServiceImpl implements DeviceAbnormalStatist
String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(instant.toEpochMilli()); String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(instant.toEpochMilli());
return format; return format;
} }
public List<TopMsgPO> getCommunicate(List<String> devs, String startTime, String endTime) { public List<TopMsgPO> getCommunicate(List<String> devs, String time) {
// startTime ="2023-04-02"; // 组装sql语句
// endTime = "2023-04-02";
//组装sql语句
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(startTime))).append("' and ").append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(endTime))).append("' and "); stringBuilder.append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(time))).append("' and ").append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(time))).append("' and ");
for (int i = 0; i < devs.size(); i++) { for (int i = 0; i < devs.size(); i++) {
if (devs.size() - i != 1) { if (devs.size() - i != 1) {
stringBuilder.append("dev_id ='").append(devs.get(i)).append("' or "); stringBuilder.append("dev_id ='").append(devs.get(i)).append("' or ");
@@ -170,7 +181,7 @@ public class DeviceAbnormaStatisticsServiceImpl implements DeviceAbnormalStatist
} }
} }
String sql = "select * from " + InfluxDBPublicParam.PQS_COMMUNICATE + " where " + stringBuilder.toString() + InfluxDBPublicParam.TIME_ZONE; String sql = "select * from " + InfluxDBPublicParam.PQS_COMMUNICATE + " where " + stringBuilder.toString() + InfluxDBPublicParam.TIME_ZONE;
//获取暂降事件 // 获取暂降事件
QueryResult result = influxDbUtils.query(sql); QueryResult result = influxDbUtils.query(sql);
InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
List<Communicate> communicates = influxDBResultMapper.toPOJO(result, Communicate.class); List<Communicate> communicates = influxDBResultMapper.toPOJO(result, Communicate.class);
@@ -180,34 +191,39 @@ public class DeviceAbnormaStatisticsServiceImpl implements DeviceAbnormalStatist
} }
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Map<String, List<Communicate>> comMap = communicates.stream().collect(Collectors.groupingBy(Communicate::getDevId)); Map<String, List<Communicate>> comMap = communicates.stream().collect(Collectors.groupingBy(Communicate::getDevId));
for (Map.Entry<String, List<Communicate>> comEntry : comMap.entrySet()) { for (Map.Entry<String, List<Communicate>> entry : comMap.entrySet()) {
TopMsgPO topMsgPO = new TopMsgPO(); List<String> comOutDesc = new ArrayList<>(); String key = entry.getKey();
topMsgPO.setDevId(comEntry.getKey()); List<Communicate> value = entry.getValue();
TopMsgPO topMsgPO = new TopMsgPO();
List<Communicate> comOuts = new ArrayList<>();
topMsgPO.setDevId(key);
// 根据日期排序 // 根据日期排序
List<Communicate> sortedList = comEntry.getValue().stream().sorted(Comparator.comparing(Communicate::getUpdateTime)).collect(Collectors.toList()); List<Communicate> sortedList = value.stream().sorted(Comparator.comparing(Communicate::getUpdateTime)).collect(Collectors.toList());
Long mills = 0l;
if (sortedList.get(0).getType() == 1) { if (sortedList.get(0).getType() == 1) {
long time = Date.from(sortedList.get(0).getUpdateTime()).getTime() - DateUtil.beginOfDay(DateUtil.parse(startTime)).getTime(); Communicate communicate = new Communicate();
mills += time; int durationTime = (int) (Date.from(sortedList.get(0).getUpdateTime()).getTime() - DateUtil.beginOfDay(DateUtil.parse(time)).getTime())/1000/60;
comOutDesc.add((DateUtil.beginOfDay(DateUtil.parse(startTime)))+""+formatter.format(Date.from(sortedList.get(0).getUpdateTime()))); communicate.setDuration(durationTime);
communicate.setDesc((DateUtil.beginOfDay(DateUtil.parse(time))) + "" + formatter.format(Date.from(sortedList.get(0).getUpdateTime())));
comOuts.add(communicate);
} }
for (int i = 0; i <sortedList.size() ; i++) { for (int i = 0; i < sortedList.size(); i++) {
if (sortedList.get(i).getType()==0 && i<sortedList.size()-1) { if (sortedList.get(i).getType() == 0 && i < sortedList.size() - 1) {
long time = Date.from(sortedList.get(i+1).getUpdateTime()).getTime() - Date.from(sortedList.get(i).getUpdateTime()).getTime(); Communicate communicate = new Communicate();
mills += time; int durationTime = (int) (Date.from(sortedList.get(i + 1).getUpdateTime()).getTime() - Date.from(sortedList.get(i).getUpdateTime()).getTime())/1000/60;
String comOutTime =formatter.format(Date.from(sortedList.get(i).getUpdateTime()))+""+ formatter.format(Date.from(sortedList.get(i+1).getUpdateTime())); communicate.setDuration(durationTime);
comOutDesc.add(comOutTime); String comOut = formatter.format(Date.from(sortedList.get(i).getUpdateTime())) + "" + formatter.format(Date.from(sortedList.get(i + 1).getUpdateTime()));
} else if (sortedList.get(i).getType()==0 && i==sortedList.size()-1) { communicate.setDesc(comOut);
long time = DateUtil.endOfDay(DateUtil.parse(endTime)).getTime() - Date.from(sortedList.get(i).getUpdateTime()).getTime(); comOuts.add(communicate);
mills += time; } else if (sortedList.get(i).getType() == 0 && i == sortedList.size() - 1) {
String comOutTime = formatter.format(Date.from(sortedList.get(i).getUpdateTime())) +""+ DateUtil.endOfDay(DateUtil.parse(endTime)); Communicate communicate = new Communicate();
comOutDesc.add(comOutTime); int durationTime = (int) (DateUtil.endOfDay(DateUtil.parse(time)).getTime() - Date.from(sortedList.get(i).getUpdateTime()).getTime()) / 1000 / 60;
communicate.setDuration(durationTime);
String comOut = formatter.format(Date.from(sortedList.get(i).getUpdateTime())) + "" + DateUtil.endOfDay(DateUtil.parse(time));
communicate.setDesc(comOut);
comOuts.add(communicate);
} }
} }
topMsgPO.setOfftimeValue( (int)(mills / 1000 / 60)); topMsgPO.setCommunicates(comOuts);
topMsgPO.setComOutDesc(comOutDesc);
// 通信中断次数
topMsgPO.setComOutCount(comOutDesc.size());
comMsgs.add(topMsgPO); comMsgs.add(topMsgPO);
} }
return comMsgs; return comMsgs;

View File

@@ -37,12 +37,15 @@ public class ConfigParam {
*/ */
@ApiModelProperty("审计日志大小MB") @ApiModelProperty("审计日志大小MB")
@NotNull(message = "审计日志大小不可为空") @NotNull(message = "审计日志大小不可为空")
@Min(value = 0,message = "审计日志大小不能小于0")
private BigDecimal logSize; private BigDecimal logSize;
/** /**
* 审计日志大小 * 审计日志大小
*/ */
@ApiModelProperty("审计日志存储时间1-6个月默认3个月") @ApiModelProperty("审计日志存储时间1-6个月默认3个月")
@Min(value = 1,message = "审计日志保留时间不能小于1")
@Max(value = 6,message = "审计日志保留时间不能大于6")
private Integer logTime; private Integer logTime;
/** /**

View File

@@ -13,9 +13,11 @@ import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors;
/** /**
* <p> * <p>
@@ -81,7 +83,9 @@ public class ConfigServiceImpl extends ServiceImpl<ConfigMapper, Config> impleme
@Override @Override
public List<Config> getList() { public List<Config> getList() {
return this.baseMapper.getList(); List<Config> list = this.baseMapper.getList();
List<Config> filterList = list.stream().filter(t -> t.getLogTime() > 0 && t.getLogSize().compareTo(new BigDecimal(0))==1).collect(Collectors.toList());
return filterList;
} }