Browse Source

更改智能发布中的发布内容-计算公里数

develop
Mr.Wang 8 months ago
parent
commit
0ccf315ec8
  1. 59
      zc-business/src/main/java/com/zc/business/service/impl/DcEmergencyPlansServiceImpl.java

59
zc-business/src/main/java/com/zc/business/service/impl/DcEmergencyPlansServiceImpl.java

@ -167,12 +167,12 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
&& executeConfig.get("operationType").equals("2")) {
// 执行操作中智能发布语音广播
String content = intelligentPublishingOfInformation(dcEvent);
updateIntelligentPublishingContent(dcExecuteAction,markArray,dcEvent,content);
updateIntelligentPublishingContent(dcExecuteAction,markArray,dcEvent,content,dcEvent.getDirection());
} else if (dcExecuteAction.getDeviceType() == DeviceTypeEnum.VARIABLE_INFORMATION_FLAG.getCode()
&& executeConfig.get("operationType").equals("2")) {
// 执行操作中智能发布情报板
String content = intelligentPublishingOfInformation(dcEvent);
updateIntelligentPublishingContent(dcExecuteAction,markArray,dcEvent,content);
updateIntelligentPublishingContent(dcExecuteAction,markArray,dcEvent,content,dcEvent.getDirection());
}
});
});
@ -181,7 +181,11 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
/**
* 更改智能发布中的发布内容-计算公里数
*/
public void updateIntelligentPublishingContent(DcExecuteAction dcExecuteAction, String[] markArray, DcEvent dcEvent,String content) {
public void updateIntelligentPublishingContent(DcExecuteAction dcExecuteAction,
String[] markArray,
DcEvent dcEvent,
String content,
String direction) {
List<DcDevice> deviceList = ruleFiltering(dcExecuteAction, markArray, dcEvent.getDirection());
JSONObject executeConfig = JSON.parseObject(dcExecuteAction.getExecuteConfig());
List<Map<String,Object>> contentList = new ArrayList<>();
@ -199,13 +203,25 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
// 不足三位 补零
deviceMarkArray[1] = String.format("%0" + 3 + "d", deviceMarkArray[1]);
}
kilometers = Math.abs(Integer.parseInt(deviceMarkArray[0]) - Integer.parseInt(markArray[0]));
meters = Math.abs(Integer.parseInt(deviceMarkArray[1]) - Integer.parseInt(markArray[1]));
if (direction.equals("菏泽方向") || direction.equals("1")) {
kilometers = Math.abs(Integer.parseInt(markArray[0]) - Integer.parseInt(deviceMarkArray[0]));
meters = Integer.parseInt(markArray[1]) - Integer.parseInt(deviceMarkArray[1]);
}else {
kilometers = Math.abs(Integer.parseInt(deviceMarkArray[0]) - Integer.parseInt(markArray[0]));
meters = Integer.parseInt(deviceMarkArray[1]) - Integer.parseInt(markArray[1]);
}
double roundedDistance = Math.round((kilometers + meters / 1000.0) * 10.0) / 10.0;
if (roundedDistance < 1) {
map.put("content",content.replace("*",(int) (roundedDistance * 1000)+"米"));
}else {
map.put("content",content.replace("*",roundedDistance+"公里"));
if (roundedDistance % 1 == 0) {
// 去除掉1.0公里的情况
map.put("content",content.replace("*",(int)roundedDistance+"公里"));
}else {
map.put("content",content.replace("*",roundedDistance+"公里"));
}
}
if (dcExecuteAction.getDeviceType() == DeviceTypeEnum.VARIABLE_INFORMATION_FLAG.getCode()) {
@ -392,7 +408,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
} else if (searchRule.equals(2)) {
// 事件上游最近
if (direction.equals("菏泽方向")) {
if (direction.equals("菏泽方向") || direction.equals("1")) {
// 上行 取最大的几个
start.add("55");
start.add("379");
@ -431,8 +447,8 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
}
} else if (searchRule.equals(3)) {
// 事件下游最近
if (direction.equals("菏泽方向")) {
// 事件下游最近 没有这个类型
if (direction.equals("菏泽方向") || direction.equals("1")) {
// 上行 取最大的几个
start.add(markArray[0]);
start.add(markArray[1]);
@ -486,8 +502,29 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
// 根据桩号范围,查询附近设备
dcDevices = dcDeviceService.devicePileNumberQueryDevice(parameter);
}
return dcDevices;
//将0公里和负数的设备去掉
return dcDevices.stream()
.filter(device -> {
device.setStakeMark(device.getStakeMark().replace("K", ""));
String[] deviceMarkArray = device.getStakeMark().split("\\+");
if (deviceMarkArray[1].length() < 3) {
deviceMarkArray[1] = String.format("%0" + 3 + "d", deviceMarkArray[1]);
}
int kilometers = 0;
int meters = 0;
if (direction.equals("菏泽方向") || direction.equals("1")) {
// 菏泽方向 桩号增大 设备桩号要小于事件桩号
kilometers = Integer.parseInt(markArray[0]) - Integer.parseInt(deviceMarkArray[0]);
meters = Integer.parseInt(markArray[1]) - Integer.parseInt(deviceMarkArray[1]);
}else {
// 济南方向 桩号减小 设备桩号要大于事件桩号
kilometers = Integer.parseInt(deviceMarkArray[0]) - Integer.parseInt(markArray[0]);
meters = Integer.parseInt(deviceMarkArray[1]) - Integer.parseInt(markArray[1]);
}
double roundedDistance = Math.round((kilometers + meters / 1000.0) * 10.0) / 10.0;
return kilometers >= 0 && roundedDistance > 0;
})
.collect(Collectors.toList());
}

Loading…
Cancel
Save