问题单整改

This commit is contained in:
zhuxinyu
2023-05-05 13:02:44 +08:00
parent bc603fdb5e
commit d4ba963d98
5 changed files with 21 additions and 33 deletions

View File

@@ -85,9 +85,12 @@ public class RmpEventDetailPO implements Serializable {
private String sagsource; private String sagsource;
@ApiModelProperty(value = "开始时间") @ApiModelProperty(value = "开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS", timezone = "GMT+8")
private LocalDateTime startTime; private LocalDateTime startTime;
@ApiModelProperty(value = "格式化开始时间")
@TableField(exist = false)
private String formatTime;
@ApiModelProperty(value = "持续时间,单位秒") @ApiModelProperty(value = "持续时间,单位秒")
private Double duration; private Double duration;

View File

@@ -954,7 +954,7 @@ public class EventAnalysisServiceImpl implements EventAnalysisService {
Integer endMonth = Integer.parseInt(endTime.substring(5, 7)); Integer endMonth = Integer.parseInt(endTime.substring(5, 7));
Integer startYear = Integer.parseInt(startTime.substring(0, 4)); Integer startYear = Integer.parseInt(startTime.substring(0, 4));
Integer endYear = Integer.parseInt(endTime.substring(0, 4)); Integer endYear = Integer.parseInt(endTime.substring(0, 4));
if (statisticsParam.getFlag() == 0) { if (statisticsParam.getFlag()==0) {
while (startYear != endYear && startMonth != endMonth) { while (startYear != endYear && startMonth != endMonth) {
builder1.delete(0, builder1.length()); builder1.delete(0, builder1.length());
builder2.delete(0, builder2.length()); builder2.delete(0, builder2.length());
@@ -1019,12 +1019,12 @@ public class EventAnalysisServiceImpl implements EventAnalysisService {
); );
Map<String, List<RmpEventDetailPO>> map = eventDetailList.stream().filter(x -> data.getId().equals(x.getEventType())) Map<String, List<RmpEventDetailPO>> map = eventDetailList.stream().filter(x -> data.getId().equals(x.getEventType()))
.collect(Collectors.groupingBy(s -> s.getStartTime().toString())); .peek(t ->t.setFormatTime(t.getStartTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))))
.collect(Collectors.groupingBy(RmpEventDetailPO::getFormatTime));
Set<String> keySet = map.keySet(); Set<String> keySet = map.keySet();
LocalDate parse1 = LocalDate.parse(startTime); LocalDate parse1 = LocalDate.parse(startTime);
LocalDate parse2 = LocalDate.parse(endTime); LocalDate parse2 = LocalDate.parse(endTime);
while (!parse1.equals(parse2.plus(1, ChronoUnit.DAYS))) { while (!parse1.equals(parse2.plus(1, ChronoUnit.DAYS))){
if (keySet.contains(parse1.toString())) { if (keySet.contains(parse1.toString())) {
// List<EventDetailNew> eventDetailNews = map.get(parse1.toString()); // List<EventDetailNew> eventDetailNews = map.get(parse1.toString());
List<RmpEventDetailPO> eventDetailNews = map.get(parse1.toString()); List<RmpEventDetailPO> eventDetailNews = map.get(parse1.toString());
@@ -1067,7 +1067,7 @@ public class EventAnalysisServiceImpl implements EventAnalysisService {
} }
@Override @Override
public StatisticVO getStatistic(StatisticsParam statisticsParam) { public StatisticVO getStatistic (StatisticsParam statisticsParam) {
StatisticVO result = new StatisticVO(); StatisticVO result = new StatisticVO();
List<EventDetail> list = new ArrayList<>(); List<EventDetail> list = new ArrayList<>();
List<ReasonsVO> reasonsVOS = new ArrayList<>(); List<ReasonsVO> reasonsVOS = new ArrayList<>();
@@ -1107,8 +1107,8 @@ public class EventAnalysisServiceImpl implements EventAnalysisService {
for (DictData data : typeData) { for (DictData data : typeData) {
typeMap.put(data.getName(), 0); typeMap.put(data.getName(), 0);
if (detail.getAdvanceType().equals(data.getId())) { if (detail.getAdvanceType().equals(data.getId())) {
details = BeanUtil.copyProperties(detail, EventDetail.class); // details = BeanUtil.copyProperties(detail, EventDetail.class);
detail.setAdvanceType(data.getName()); details.setAdvanceType(data.getName());
} }
} }
list.add(details); list.add(details);

View File

@@ -27,27 +27,25 @@ public class TopMsgPO extends BaseEntity {
*/ */
private Integer deviceLevel; private Integer deviceLevel;
private Integer offtimeFlag;
/** /**
* 通信中断次数 * 通信中断次数
*/ */
private Integer comOutCount; private Integer comOutCount;
/** /**
* 通信中断时间段描述 * 通信中断时间段描述
*/ */
private String comOutDescription; private String comOutDescription;
/** /**
* 数据完整性标识 0.不达标 1.达标 * 数据完整性标识 0.不达标 1.达标
*/ */
private Integer integrityFlag; private Integer integrityFlag;
/** /**
* 数据完成性百分比 * 数据完成性百分比
*/ */
private Float integrityValue; private Float integrityValue;
private Integer alarmCountFlag;
/** /**
* 告警次数 * 告警次数
*/ */
@@ -58,8 +56,6 @@ public class TopMsgPO extends BaseEntity {
*/ */
private String alarmDesc; private String alarmDesc;
private Integer alarmCountFlag;
/** /**
* 流量超标标识 0.不达标 1.达标 * 流量超标标识 0.不达标 1.达标
*/ */
@@ -74,8 +70,6 @@ public class TopMsgPO extends BaseEntity {
private float onlineRateValue; private float onlineRateValue;
private Integer offtimeFlag;
private List<Communicate> communicates; private List<Communicate> communicates;
/** /**

View File

@@ -58,7 +58,7 @@
<select id="getIntegrityByLineIds" resultType="com.njcn.prepare.harmonic.pojo.mysql.po.line.AlarmPO"> <select id="getIntegrityByLineIds" resultType="com.njcn.prepare.harmonic.pojo.mysql.po.line.AlarmPO">
SELECT SELECT
device.id AS deviceId, device.id AS deviceId,
IFNULL(SUM(integrity.due_time),0) AS due, IFNULL(SUM(integrity.due_time),3.14159) AS due,
IFNULL(SUM(integrity.real_time),0) AS `real`, IFNULL(SUM(integrity.real_time),0) AS `real`,
CONVERT(SUM(integrity.real_time)*100/SUM(integrity.due_time),DECIMAL(15,2)) AS integrity CONVERT(SUM(integrity.real_time)*100/SUM(integrity.due_time),DECIMAL(15,2)) AS integrity
FROM r_stat_integrity_d integrity FROM r_stat_integrity_d integrity
@@ -93,7 +93,7 @@
#{item} #{item}
</foreach> </foreach>
AND AND
DATE_FORMAT(cmf.Time_Id,'%Y-%m') =#{time} DATE_FORMAT(cmf.Time_Id,'%Y-%m') = #{time}
) t ) t
ORDER BY flowProportion DESC ORDER BY flowProportion DESC
</select> </select>
@@ -150,7 +150,7 @@
<select id="getOnlineRateByDevice" resultType="com.njcn.prepare.harmonic.pojo.mysql.po.line.AlarmPO"> <select id="getOnlineRateByDevice" resultType="com.njcn.prepare.harmonic.pojo.mysql.po.line.AlarmPO">
SELECT SELECT
rsod.dev_index, rsod.dev_index deviceId,
rsod.online_min/(rsod.online_min+rsod.offline_min) onlineRate rsod.online_min/(rsod.online_min+rsod.offline_min) onlineRate
FROM r_stat_onlinerate_d rsod FROM r_stat_onlinerate_d rsod
WHERE rsod.dev_index IN WHERE rsod.dev_index IN

View File

@@ -73,12 +73,11 @@ public class DeviceAbnormaStatisticsServiceImpl implements DeviceAbnormalStatist
DateUtil.endOfDay(DateUtil.parse(param.getTime()))); DateUtil.endOfDay(DateUtil.parse(param.getTime())));
Map<String, List<AlarmPO>> deviceOnlineMap = deviceOnlineRate.stream().collect(Collectors.groupingBy(AlarmPO::getDeviceId)); Map<String, List<AlarmPO>> deviceOnlineMap = deviceOnlineRate.stream().collect(Collectors.groupingBy(AlarmPO::getDeviceId));
// 获取设备流量 // 获取设备流量
List<AlarmPO> deviceFlow = deviceAbnormaStatisticsMapper.getFlowByDevice(devIds,param.getTime().substring(0,6)); List<AlarmPO> deviceFlow = deviceAbnormaStatisticsMapper.getFlowByDevice(devIds,param.getTime().substring(0,7));
if (CollectionUtil.isNotEmpty(deviceFlow)) { if (CollectionUtil.isNotEmpty(deviceFlow)) {
deviceFlowMap = deviceFlow.stream().collect(Collectors.groupingBy(AlarmPO::getDeviceId)); deviceFlowMap = deviceFlow.stream().collect(Collectors.groupingBy(AlarmPO::getDeviceId));
} }
// 获取通信中断信息 // 获取通信中断信息
// List<String> list = Arrays.asList("025fa0e4c91f72ad7f1c1bd29026f20a");
List<TopMsgPO> comMsgs = getCommunicate(devIds, 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));
@@ -86,17 +85,8 @@ public class DeviceAbnormaStatisticsServiceImpl implements DeviceAbnormalStatist
// 整合装置信息 // 整合装置信息
List<TopMsgPO> topMsgPOS = new ArrayList<>(); List<TopMsgPO> topMsgPOS = new ArrayList<>();
for (Map.Entry<String, List<AlarmPO>> devEntry : devMap.entrySet()) { for (Map.Entry<String, List<AlarmPO>> devEntry : devMap.entrySet()) {
// if (!lineIntegrityMap.containsKey(devEntry.getKey()) && !lineAlarmsMap.containsKey(devEntry.getKey())
// && !deviceFlowMap.containsKey(devEntry.getKey()) && !comMap.containsKey(devEntry.getKey()) && !deviceOnlineMap.containsKey(devEntry.getKey())) {
// continue;
// }
TopMsgPO topMsg = new TopMsgPO(); TopMsgPO topMsg = new TopMsgPO();
topMsg.setDevId(devEntry.getKey()); topMsg.setDevId(devEntry.getKey());
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); int deviceLevel = devEntry.getValue().stream().mapToInt(AlarmPO::getLevel).min().orElse(-1);
// 装置等级 // 装置等级
topMsg.setDeviceLevel(deviceLevel); topMsg.setDeviceLevel(deviceLevel);
@@ -118,6 +108,7 @@ public class DeviceAbnormaStatisticsServiceImpl implements DeviceAbnormalStatist
topMsg.setAlarmCount(alarmCount); topMsg.setAlarmCount(alarmCount);
topMsg.setAlarmDesc(alarmDesc); topMsg.setAlarmDesc(alarmDesc);
} else { } else {
topMsg.setAlarmCountFlag(1);
topMsg.setAlarmCount(0); topMsg.setAlarmCount(0);
} }
// 在线率 // 在线率
@@ -158,8 +149,8 @@ public class DeviceAbnormaStatisticsServiceImpl implements DeviceAbnormalStatist
log.error("ParseException "+e); log.error("ParseException "+e);
} }
} }
if (topMsg.getFlowFlag() !=1 || topMsg.getIntegrityFlag() !=1 || topMsg.getOfftimeFlag() != 1 if (topMsg.getFlowFlag() ==0 || topMsg.getIntegrityFlag() ==0 || topMsg.getOfftimeFlag() == 0
|| topMsg.getAlarmCountFlag() !=1 || topMsg.getOnlineRateFlag() !=1) { || topMsg.getAlarmCountFlag() ==0 || topMsg.getOnlineRateFlag() ==0) {
topMsgPOS.add(topMsg); topMsgPOS.add(topMsg);
} }
@@ -167,7 +158,7 @@ public class DeviceAbnormaStatisticsServiceImpl implements DeviceAbnormalStatist
return deviceAbnormaStatisticsMapper.insertTopMsg(topMsgPOS); return deviceAbnormaStatisticsMapper.insertTopMsg(topMsgPOS);
} }
public List<TopMsgPO> getCommunicate(List<String> devs, String time) { public List<TopMsgPO> getCommunicate(List<String> devs, String time) {
// 组装sql语句 // 组装sql语句
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(time))).append("' and ").append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(time))).append("' and "); stringBuilder.append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(time))).append("' and ").append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(time))).append("' and ");