Browse Source

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

develop
wangsixiang 8 months ago
parent
commit
ded57422af
  1. 52
      zc-business/src/main/java/com/zc/business/controller/StatusController.java
  2. 18
      zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java
  3. 2
      zc-business/src/main/resources/mapper/business/DcDeviceMapper.xml

52
zc-business/src/main/java/com/zc/business/controller/StatusController.java

@ -253,9 +253,23 @@ public class StatusController extends BaseController {
Map<String, List<Status>> typeMap = lastEntry.stream().filter(iteam -> iteam.getType() != null).collect(Collectors.groupingBy(Status::getType));
Map<String, Map<String, String>> subMap = new HashMap<>();
for (Map.Entry<String, List<Status>> entrys : typeMap.entrySet()) {
itemTypeMap.forEach((key, value) -> {
Map<String, String> maps = new HashMap<>();
List<Status> groupItems = entrys.getValue();
List<Status> groupItems = typeMap.get(key);
if (groupItems == null) {
//丢包率
maps.put("lostRate", "0%");
//在线率
maps.put("sucessRate", "0%");
//离线率
maps.put("failRate", "0%");
//已使用数量
maps.put("sumUseState", "0");
//总数
maps.put("sum", String.valueOf(dcDeviceList.stream().filter(item -> Objects.equals(item.getDeviceType(), key)).map(DcDevice::getSumAll).collect(Collectors.toList()).get(0)));
subMap.put(itemTypeMap.get(key), maps);
} else {
double lostRate = groupItems.stream()
.mapToDouble(Status -> Double.parseDouble(Status.getLostRate().replace("%", ""))) // 去掉%,并转换为double
.average().getAsDouble();
@ -272,11 +286,37 @@ public class StatusController extends BaseController {
//已使用数量
maps.put("sumUseState", String.valueOf(groupItems.size()));
//总数
maps.put("sum", String.valueOf(dcDeviceList.stream().filter(item -> Objects.equals(item.getDeviceType(), entrys.getKey())).map(DcDevice::getSumAll).collect(Collectors.toList()).get(0)));
if(itemTypeMap.get(entrys.getKey())!=null) {
subMap.put(itemTypeMap.get(entrys.getKey()), maps);
}
maps.put("sum", String.valueOf(dcDeviceList.stream().filter(item -> Objects.equals(item.getDeviceType(), key)).map(DcDevice::getSumAll).collect(Collectors.toList()).get(0)));
subMap.put(itemTypeMap.get(key), maps);
}
});
//for (Map.Entry<String, List<Status>> entrys : typeMap.entrySet()) {
// Map<String, String> maps=new HashMap<>();
// List<Status> groupItems = entrys.getValue();
// double lostRate = groupItems.stream()
// .mapToDouble(Status -> Double.parseDouble(Status.getLostRate().replace("%", ""))) // 去掉%,并转换为double
// .average().getAsDouble();
// double sucessRate = groupItems.stream()
// .mapToDouble(Status -> Double.parseDouble(Status.getSuccessRate().replace("%", ""))) // 去掉%,并转换为double
// .average().getAsDouble();
// String failRate=String.format("%.2f", (100-sucessRate))+"%";
// //丢包率
// maps.put("lostRate",String.format("%.2f", lostRate)+"%");
// //在线率
// maps.put("sucessRate",String.format("%.2f", sucessRate)+"%");
// //离线率
// maps.put("failRate",failRate);
// //已使用数量
// maps.put("sumUseState",String.valueOf(groupItems.size()));
// //总数
// maps.put("sum", String.valueOf(dcDeviceList.stream().filter(item -> Objects.equals(item.getDeviceType(), entrys.getKey())).map(DcDevice::getSumAll).collect(Collectors.toList()).get(0)));
// if(itemTypeMap.get(entrys.getKey())!=null) {
// subMap.put(itemTypeMap.get(entrys.getKey()), maps);
//
// }
//}
Map<String, String> maps=new HashMap<>();
double lostRate = lastEntry.stream()
.mapToDouble(Status -> Double.parseDouble(Status.getLostRate().replace("%", ""))) // 去掉%,并转换为double

18
zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java

@ -174,9 +174,22 @@ public class DeviceMessageHandler {
String warningSubclass = data.getString("warningSubclass");
// 子类型
dcWarning.setWarningSubclass(warningSubclass);
//桩号,方向
String stakeMarkDescription = data.getString("stakeMarkDescription");
String title = stakeMarkDescription + WarningSubclassEnum.getDecorateInfo(warningSubclass);
String direction = "";
String[] arr = stakeMarkDescription.split(" ");
//方向
if (arr[2] != null) {
if (arr[2].equals("上行")) {
direction=arr[0]+" "+arr[1]+ " 菏泽方向 ";
}
if (arr[2].equals("下行")) {
direction=arr[0]+" "+arr[1]+ " 济南方向 ";
}
}
String title = direction + WarningSubclassEnum.getDecorateInfo(warningSubclass);
// 标题
dcWarning.setWarningTitle(title);
dcWarning.setRemark(DateUtil.formatDateTime(DateUtil.date(captureTime)) + " " + title);
@ -208,6 +221,7 @@ public class DeviceMessageHandler {
/* JSONObject combinedData = new JSONObject();
combinedData.put("address", otherConfig);*/
dcWarning.setOtherConfig(otherConfig.toString());
dcWarningService.insertDcWarning(dcWarning);
}

2
zc-business/src/main/resources/mapper/business/DcDeviceMapper.xml

@ -92,7 +92,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="productionDate != null and productionDate != ''">and t1.production_date = #{productionDate}</if>
<if test="durableYears != null and durableYears != ''">and t1.durable_years = #{durableYears}</if>
<if test="installationSite != null and installationSite != ''">and t1.installation_site = #{installationSite}</if>
<if test="useState != null and useState != ''">and t1.use_state = #{useState}</if>
<if test="useState != null">and t1.use_state = #{useState}</if>
<if test="deviceState != null and deviceState != ''">and t1.device_state = #{deviceState}</if>
<if test="otherConfig != null and otherConfig != ''">and json_extract(t1.other_config,'$.childType') = #{otherConfig}</if>
<if test="remark != null and remark != ''">and t1.remark = #{remark}</if>

Loading…
Cancel
Save