问题单整改

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

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

View File

@@ -73,12 +73,11 @@ public class DeviceAbnormaStatisticsServiceImpl implements DeviceAbnormalStatist
DateUtil.endOfDay(DateUtil.parse(param.getTime())));
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)) {
deviceFlowMap = deviceFlow.stream().collect(Collectors.groupingBy(AlarmPO::getDeviceId));
}
// 获取通信中断信息
// List<String> list = Arrays.asList("025fa0e4c91f72ad7f1c1bd29026f20a");
List<TopMsgPO> comMsgs = getCommunicate(devIds, param.getTime());
if (CollectionUtil.isNotEmpty(comMsgs)) {
comMap = comMsgs.stream().collect(Collectors.groupingBy(TopMsgPO::getDevId));
@@ -86,17 +85,8 @@ public class DeviceAbnormaStatisticsServiceImpl implements DeviceAbnormalStatist
// 整合装置信息
List<TopMsgPO> topMsgPOS = new ArrayList<>();
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();
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);
// 装置等级
topMsg.setDeviceLevel(deviceLevel);
@@ -118,6 +108,7 @@ public class DeviceAbnormaStatisticsServiceImpl implements DeviceAbnormalStatist
topMsg.setAlarmCount(alarmCount);
topMsg.setAlarmDesc(alarmDesc);
} else {
topMsg.setAlarmCountFlag(1);
topMsg.setAlarmCount(0);
}
// 在线率
@@ -158,8 +149,8 @@ public class DeviceAbnormaStatisticsServiceImpl implements DeviceAbnormalStatist
log.error("ParseException "+e);
}
}
if (topMsg.getFlowFlag() !=1 || topMsg.getIntegrityFlag() !=1 || topMsg.getOfftimeFlag() != 1
|| topMsg.getAlarmCountFlag() !=1 || topMsg.getOnlineRateFlag() !=1) {
if (topMsg.getFlowFlag() ==0 || topMsg.getIntegrityFlag() ==0 || topMsg.getOfftimeFlag() == 0
|| topMsg.getAlarmCountFlag() ==0 || topMsg.getOnlineRateFlag() ==0) {
topMsgPOS.add(topMsg);
}
@@ -167,7 +158,7 @@ public class DeviceAbnormaStatisticsServiceImpl implements DeviceAbnormalStatist
return deviceAbnormaStatisticsMapper.insertTopMsg(topMsgPOS);
}
public List<TopMsgPO> getCommunicate(List<String> devs, String time) {
public List<TopMsgPO> getCommunicate(List<String> devs, String time) {
// 组装sql语句
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 ");