Browse Source

Merge remote-tracking branch 'origin/develop' into develop

develop
lau572 3 weeks ago
parent
commit
33926a28ee
  1. 29
      zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java
  2. 2
      zc-business/src/main/java/com/zc/business/controller/DcDeviceOnlineController.java
  3. 12
      zc-business/src/main/java/com/zc/business/service/impl/DcSwitchServiceImpl.java
  4. 10
      zc-business/src/main/resources/mapper/OnlineSumMapper.xml

29
zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java

@ -457,8 +457,10 @@ public class DcDeviceController extends BaseController {
//转换为 double 类型,去除单位 //转换为 double 类型,去除单位
String valueWithoutUnit = formatValueStr.replaceAll("[^\\d.]", ""); String valueWithoutUnit = formatValueStr.replaceAll("[^\\d.]", "");
double formatValue = Double.parseDouble(decimalFormat.format(valueWithoutUnit)); // double formatValue = Double.parseDouble(valueWithoutUnit);
double parsedValue = Double.parseDouble(valueWithoutUnit);
// 保留两位小数
double formatValue = Double.parseDouble(decimalFormat.format(parsedValue));
// 汇总每个小时的数据 // 汇总每个小时的数据
deviceHourlyAggregates.merge(key, formatValue, Double::sum); deviceHourlyAggregates.merge(key, formatValue, Double::sum);
} }
@ -505,7 +507,10 @@ public class DcDeviceController extends BaseController {
String property = data.get("property").getAsString(); String property = data.get("property").getAsString();
String formatValueStr = data.get("formatValue").getAsString(); String formatValueStr = data.get("formatValue").getAsString();
String valueWithoutUnit = formatValueStr.replaceAll("[^\\d.]", ""); String valueWithoutUnit = formatValueStr.replaceAll("[^\\d.]", "");
double value = Double.parseDouble(decimalFormat.format(valueWithoutUnit));
double value2 = Double.parseDouble(valueWithoutUnit);
double value = Double.parseDouble(decimalFormat.format(value2));
attributeMap.merge(property, value, (oldVal, newVal) -> oldVal + newVal); attributeMap.merge(property, value, (oldVal, newVal) -> oldVal + newVal);
} }
} }
@ -897,8 +902,26 @@ public class DcDeviceController extends BaseController {
//获取要回滚的数据 //获取要回滚的数据
JSONObject mdJSONObject = (JSONObject) JSON.toJSON(getDeviceLatestProperty(iotDeviceId, UniversalEnum.MD.getValue()).get("data")); JSONObject mdJSONObject = (JSONObject) JSON.toJSON(getDeviceLatestProperty(iotDeviceId, UniversalEnum.MD.getValue()).get("data"));
if (mdJSONObject==null) {
JSONObject result = new JSONObject();
result.put("device", device.getString("id"));
result.put("deviceType", device.getInteger("deviceType"));
result.put("functionId", UniversalEnum.MD.getValue());
result.put("result", AjaxResult.error());
resultArray.add(result);
break;
}
String mdValue = mdJSONObject.getString("value"); String mdValue = mdJSONObject.getString("value");
JSONObject tmJSONObject = (JSONObject) JSON.toJSON(getDeviceLatestProperty(iotDeviceId, UniversalEnum.TM.getValue()).get("data")); JSONObject tmJSONObject = (JSONObject) JSON.toJSON(getDeviceLatestProperty(iotDeviceId, UniversalEnum.TM.getValue()).get("data"));
if (tmJSONObject==null) {
JSONObject result = new JSONObject();
result.put("device", device.getString("id"));
result.put("deviceType", device.getInteger("deviceType"));
result.put("functionId", UniversalEnum.TM.getValue());
result.put("result", AjaxResult.error());
resultArray.add(result);
break;
}
String tmValue = tmJSONObject.getString("value"); String tmValue = tmJSONObject.getString("value");
//循环执行功能 //循环执行功能
for (Object function : functions) { for (Object function : functions) {

2
zc-business/src/main/java/com/zc/business/controller/DcDeviceOnlineController.java

@ -496,7 +496,7 @@ public class DcDeviceOnlineController extends BaseController {
List<Double> lossRate = new ArrayList<>(); List<Double> lossRate = new ArrayList<>();
List<Double> rttAvg = new ArrayList<>(); List<Double> rttAvg = new ArrayList<>();
onlineLogs.stream().sorted(Comparator.comparing(OnlineLog::getMonitorTime)).forEach(onlineLog -> { onlineLogs.stream().sorted(Comparator.comparing(OnlineLog::getMonitorTime)).forEach(onlineLog -> {
xAxis.add(onlineLog.getMonitorTime().format(DateTimeFormatter.ofPattern("HH:mm"))); xAxis.add(onlineLog.getMonitorTime().format(DateTimeFormatter.ofPattern("HH:mm:ss")));
lossRate.add(onlineLog.getLossRate()); lossRate.add(onlineLog.getLossRate());
rttAvg.add(onlineLog.getRttAvg()); rttAvg.add(onlineLog.getRttAvg());
}); });

12
zc-business/src/main/java/com/zc/business/service/impl/DcSwitchServiceImpl.java

@ -208,19 +208,19 @@ public class DcSwitchServiceImpl extends ServiceImpl<DcSwitchMapper, DcSwitch> i
.filter(dcSwitch -> dcSwitch.getDeviceList().contains(deviceIdString)) .filter(dcSwitch -> dcSwitch.getDeviceList().contains(deviceIdString))
.findFirst().map(DcSwitch::getSwitchIp).orElse(null); .findFirst().map(DcSwitch::getSwitchIp).orElse(null);
if (StringUtils.isBlank(switchIp)){ //switchIp为空不存在交换机ip if (StringUtils.isBlank(switchIp)){ //switchIp为空不存在交换机ip
redisCache.setCacheObject(DEVICEDIAGNOSTICS+deviceIp,"未查询到相关的二层交换机",2, TimeUnit.MINUTES); redisCache.setCacheObject(DEVICEDIAGNOSTICS+deviceIp,"未查询到相关的交换机",2, TimeUnit.MINUTES);
return AjaxResult.success("未查询到相关的二层交换机"); return AjaxResult.success("未查询到相关的交换机");
} }
List<DcSwitch> switchList = dcSwitchMapper.getSwitchName(switchIp); List<DcSwitch> switchList = dcSwitchMapper.getSwitchName(switchIp);
if (switchList.size()!=1){ if (switchList.size()!=1){
redisCache.setCacheObject(DEVICEDIAGNOSTICS+deviceIp,"二层交换机IP存在冲突",2, TimeUnit.MINUTES); redisCache.setCacheObject(DEVICEDIAGNOSTICS+deviceIp,"交换机IP存在冲突",2, TimeUnit.MINUTES);
return AjaxResult.success("二层交换机IP存在冲突"); return AjaxResult.success("交换机IP存在冲突");
}else { }else {
for (DcSwitch switchListValue:switchList) { for (DcSwitch switchListValue:switchList) {
InetAddress newSwitchIp = InetAddress.getByName(switchIp); InetAddress newSwitchIp = InetAddress.getByName(switchIp);
if (!newSwitchIp.isReachable(UniversalEnum.FIVE_THOUSAND.getNumber())) { if (!newSwitchIp.isReachable(UniversalEnum.FIVE_THOUSAND.getNumber())) {
redisCache.setCacheObject(DEVICEDIAGNOSTICS+deviceIp,"设备二层交换机"+switchListValue.getSwitchName()+"网络异常",2, TimeUnit.MINUTES); redisCache.setCacheObject(DEVICEDIAGNOSTICS+deviceIp,"设备交换机"+switchListValue.getSwitchName()+"网络异常",2, TimeUnit.MINUTES);
return AjaxResult.success("设备二层交换机"+switchListValue.getSwitchName()+"网络异常"); return AjaxResult.success("设备交换机"+switchListValue.getSwitchName()+"网络异常");
} }
} }
} }

10
zc-business/src/main/resources/mapper/OnlineSumMapper.xml

@ -88,10 +88,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
offline_rate,loss_rate,rtt_avg,network_quality,statistical_date offline_rate,loss_rate,rtt_avg,network_quality,statistical_date
from dc_device d from dc_device d
join dc_online_sum s on s.device_id = d.id join dc_online_sum s on s.device_id = d.id
JOIN
(SELECT device_id, MAX(statistical_date) AS max_date
FROM dc_online_sum
WHERE DATE(statistical_date) = CURDATE()
GROUP BY device_id) s_max
ON
s.device_id = s_max.device_id AND s.statistical_date = s_max.max_date
where where
DATE(s.statistical_date) = CURDATE()
<if test="type.length != 0"> <if test="type.length != 0">
and (d.device_type in (d.device_type in
<foreach item="typeItem" collection="type" open="(" separator="," close=")"> <foreach item="typeItem" collection="type" open="(" separator="," close=")">
#{typeItem} #{typeItem}
</foreach> </foreach>

Loading…
Cancel
Save