|
|
@@ -125,38 +125,78 @@ public class LabExitLineVertexServiceImpl implements ILabExitLineVertexService {
|
|
|
*/
|
|
|
@Override
|
|
|
public Map <String, Object> executeEvacuation(LabExitLineEvacuationVo labExitLineEvacuationVo) {
|
|
|
- LabExitLineVertex labExitLineVertex = new LabExitLineVertex();
|
|
|
- labExitLineVertex.setBuildId(labExitLineEvacuationVo.getBuildId());
|
|
|
- labExitLineVertex.setFloorId(labExitLineEvacuationVo.getFloorId());
|
|
|
- List <LabExitLineVertex> labExitLineVOList = labExitLineVertexMapper.selectLabExitLineVertexList(labExitLineVertex);
|
|
|
- if (labExitLineVOList.size() > 0) {
|
|
|
- String relationData = labExitLineVOList.get(0).getRelationalData();
|
|
|
- List <LabExitLineJoinPointVO> newRelationalData = JSONArray.parseArray(relationData, LabExitLineJoinPointVO.class);
|
|
|
- //调用坏点计算
|
|
|
- badPoints(newRelationalData, labExitLineEvacuationVo);
|
|
|
- //设置顶点数
|
|
|
- V = newRelationalData.size();
|
|
|
- //floyd计算顶点到各个点的线路
|
|
|
- ArrayList <Integer[][]> list = flody(newRelationalData);
|
|
|
- //这里需要在通过floyd计算一次原始数据,作为发生预案的楼层,只有一个疏散口,那么所有的实验室,都向这个疏散口撤离。
|
|
|
- List <LabExitLineJoinPointVO> oldRelationalData = JSONArray.parseArray(relationData, LabExitLineJoinPointVO.class);
|
|
|
- ArrayList <Integer[][]> oldList = flody(oldRelationalData);
|
|
|
- //计算楼层各个实验室的逃生线路
|
|
|
- Map <String, Object> joinPointVOS = displayPath(list, newRelationalData, labExitLineEvacuationVo, oldList, oldRelationalData);
|
|
|
- return joinPointVOS;
|
|
|
+ //todo 根据实验室id查询出对应的pointName数据
|
|
|
+ LabBuildFloorLayout labBuildFloorLayout = new LabBuildFloorLayout();
|
|
|
+ labBuildFloorLayout.setBuildId(labExitLineEvacuationVo.getBuildId());
|
|
|
+ labBuildFloorLayout.setFloorId(labExitLineEvacuationVo.getFloorId());
|
|
|
+ labBuildFloorLayout.setSubId(labExitLineEvacuationVo.getSubId());
|
|
|
+ List <LabBuildFloorLayoutVo> layoutVoList = labBuildFloorLayoutMapper.selectLabBuildFloorLayoutList(labBuildFloorLayout);
|
|
|
+ if(layoutVoList.size()>0){
|
|
|
+ LabBuildFloorLayoutVo floorLayoutVo = layoutVoList.get(0);
|
|
|
+ labExitLineEvacuationVo.getBadPointNames().add(floorLayoutVo.getPointName());
|
|
|
+
|
|
|
+ LabExitLineVertex labExitLineVertex = new LabExitLineVertex();
|
|
|
+ labExitLineVertex.setBuildId(labExitLineEvacuationVo.getBuildId());
|
|
|
+ labExitLineVertex.setFloorId(labExitLineEvacuationVo.getFloorId());
|
|
|
+ List <LabExitLineVertex> labExitLineVOList = labExitLineVertexMapper.selectLabExitLineVertexList(labExitLineVertex);
|
|
|
+ if (labExitLineVOList.size() > 0) {
|
|
|
+ String relationData = labExitLineVOList.get(0).getRelationalData();
|
|
|
+ List <LabExitLineJoinPointVO> newRelationalData = JSONArray.parseArray(relationData, LabExitLineJoinPointVO.class);
|
|
|
+ //todo 这里赛选出pointName 的对应的key 的真实pointName 这里赛选门对应的坏点和实验室对应的起点标记坏点
|
|
|
+ Optional.ofNullable(newRelationalData)
|
|
|
+ .orElseGet(Collections::emptyList)
|
|
|
+ .stream()
|
|
|
+ .forEach(a->Optional.ofNullable(labExitLineEvacuationVo.getBadPointNames())
|
|
|
+ .orElseGet(Collections::emptyList)
|
|
|
+ .stream()
|
|
|
+ .filter(b->b.equals(a.getKey()))
|
|
|
+ .forEach(b->{
|
|
|
+ //调用坏点计算
|
|
|
+ badPoints(newRelationalData, a.getPointName());
|
|
|
+ if(a.getKey().equals(floorLayoutVo.getPointName())){
|
|
|
+ labExitLineEvacuationVo.setStartPointName(a.getPointName());
|
|
|
+ }
|
|
|
+ }));
|
|
|
+
|
|
|
+ //设置顶点数
|
|
|
+ V = newRelationalData.size();
|
|
|
+ //floyd计算顶点到各个点的线路
|
|
|
+ ArrayList <Integer[][]> list = flody(newRelationalData);
|
|
|
+
|
|
|
+ //这里需要在通过floyd计算一次原始数据,作为发生预案的楼层,只有一个疏散口,那么所有的实验室,都向这个疏散口撤离。
|
|
|
+ List <LabExitLineJoinPointVO> oldRelationalData = JSONArray.parseArray(relationData, LabExitLineJoinPointVO.class);
|
|
|
+ //todo 这里只赛选门对应的坏点的数据,用作计算备用线路用
|
|
|
+ Optional.ofNullable(oldRelationalData)
|
|
|
+ .orElseGet(Collections::emptyList)
|
|
|
+ .stream()
|
|
|
+ .forEach(a->Optional.ofNullable(labExitLineEvacuationVo.getBadPointNames())
|
|
|
+ .orElseGet(Collections::emptyList)
|
|
|
+ .stream()
|
|
|
+ .filter(b->b.equals(a.getKey()))
|
|
|
+ .forEach(b->{
|
|
|
+ //调用坏点计算
|
|
|
+ badPoints(newRelationalData, a.getPointName());
|
|
|
+ }));
|
|
|
+ ArrayList <Integer[][]> oldList = flody(oldRelationalData);
|
|
|
+ //计算楼层各个实验室的逃生线路
|
|
|
+ Map <String, Object> joinPointVOS = displayPath(list, newRelationalData, labExitLineEvacuationVo, oldList, oldRelationalData);
|
|
|
+ return joinPointVOS;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
|
|
|
//todo 计算坏点(目前只有发生预案的实验室需要标记为坏点),需要把非坏点关联坏点点位全部改成无限大
|
|
|
- public void badPoints(List <LabExitLineJoinPointVO> newRelationalData, LabExitLineEvacuationVo labExitLineEvacuationVo) {
|
|
|
+ public void badPoints(List <LabExitLineJoinPointVO> newRelationalData, String badPointName) {
|
|
|
+ //这里计算预案发生的实验室坏点
|
|
|
Optional.ofNullable(newRelationalData).orElseGet(Collections::emptyList)
|
|
|
.parallelStream()
|
|
|
- .filter(a -> !a.getPointName().equals(labExitLineEvacuationVo.getStartPointName()))
|
|
|
+ .filter(a -> !a.getPointName().equals(badPointName))
|
|
|
.forEach(a -> Optional.ofNullable(a.getPointVOList()).orElseGet(Collections::emptyList)
|
|
|
.stream()
|
|
|
- .filter(b -> b.getPointName().equals(labExitLineEvacuationVo.getStartPointName()))
|
|
|
+ .filter(b -> b.getPointName().equals(badPointName))
|
|
|
.forEach(b -> b.setPointDistance(M))
|
|
|
);
|
|
|
}
|
|
|
@@ -178,7 +218,7 @@ public class LabExitLineVertexServiceImpl implements ILabExitLineVertexService {
|
|
|
for (int j = 0; j < V; j++) {
|
|
|
if (i != j) {//只是避免了vi->vi的输出
|
|
|
if (linePointVOList.get(i).getPointAttribute() == 4 && linePointVOList.get(i).getPointVOList().get(j).getPointAttribute() == 1) {
|
|
|
- CompletableFuture <Map <String, Object>> setCompletableFuture = optimalRoute(linePointVOList, path, chain, i, j, oldList, oldRelationalData);
|
|
|
+ CompletableFuture <Map <String, Object>> setCompletableFuture = optimalRoute(linePointVOList, path, chain, i, j, oldList, oldRelationalData,labExitLineEvacuationVo);
|
|
|
completableFutures.add(setCompletableFuture);
|
|
|
}
|
|
|
}
|
|
|
@@ -194,7 +234,7 @@ public class LabExitLineVertexServiceImpl implements ILabExitLineVertexService {
|
|
|
//todo 预案触发实验室的主线路到逃生点全部返回,其他实验室赛选过滤最优线路,如果和主线路有重叠或者逆向,需要移除重叠以后的数据点。
|
|
|
public Map <String, Object> filterLinePoint(List <CompletableFuture <Map <String, Object>>> completableFutures, final String startPointName, LabExitLineEvacuationVo labExitLineEvacuationVo) {
|
|
|
//todo 断言名字是否相同
|
|
|
- Predicate <String> checkPointName = x -> x.equals(startPointName);
|
|
|
+ Predicate <String> checkPointName = x -> startPointName.equals(x);
|
|
|
List <List <LabExitLineJoinPointVO>> startPointList = new ArrayList <>();
|
|
|
Map <String, Integer> sortKeyMap = new LinkedHashMap <>();
|
|
|
Map <String, List <LabExitLineJoinPointVO>> otherPointMap = new LinkedHashMap <>();
|
|
|
@@ -203,13 +243,15 @@ public class LabExitLineVertexServiceImpl implements ILabExitLineVertexService {
|
|
|
.forEach(a -> {
|
|
|
try {
|
|
|
String pointName = (String) a.get().get("pointName");
|
|
|
- if (checkPointName.test(pointName)) {
|
|
|
- startPointList.add((List <LabExitLineJoinPointVO>) a.get().get("joinPointVOS"));
|
|
|
- } else {
|
|
|
- LabExitLineJoinPointVO pointDistanceVo = (LabExitLineJoinPointVO) a.get().get("pointDistanceVo");
|
|
|
- if (sortKeyMap.get(pointName) == null || sortKeyMap.get(pointName) > pointDistanceVo.getPointDistance()) {
|
|
|
- sortKeyMap.put(pointName, pointDistanceVo.getPointDistance());
|
|
|
- otherPointMap.put(pointName, (List <LabExitLineJoinPointVO>) a.get().get("joinPointVOS"));
|
|
|
+ if(StringUtils.isNotNull(pointName)){
|
|
|
+ if (checkPointName.test(pointName)) {
|
|
|
+ startPointList.add((List <LabExitLineJoinPointVO>) a.get().get("joinPointVOS"));
|
|
|
+ } else {
|
|
|
+ LabExitLineJoinPointVO pointDistanceVo = (LabExitLineJoinPointVO) a.get().get("pointDistanceVo");
|
|
|
+ if (sortKeyMap.get(pointName) == null || sortKeyMap.get(pointName) > pointDistanceVo.getPointDistance()) {
|
|
|
+ sortKeyMap.put(pointName, pointDistanceVo.getPointDistance());
|
|
|
+ otherPointMap.put(pointName, (List <LabExitLineJoinPointVO>) a.get().get("joinPointVOS"));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
} catch (InterruptedException e) {
|
|
|
@@ -248,12 +290,15 @@ public class LabExitLineVertexServiceImpl implements ILabExitLineVertexService {
|
|
|
//todo 这里需要两层for循环,比对点名称一样的,开启继电器开关
|
|
|
Consumer<LabExitPointRelay> consumer = a->Optional.ofNullable(lightPointList).orElseGet(Collections::emptySet)
|
|
|
.stream()
|
|
|
- .filter(b->b.getPointName().equals(a.getPointName()))
|
|
|
+ .filter(b->b.getKey().equals(a.getPointName()))
|
|
|
.forEach(b->{
|
|
|
- //这里打卡继电器的开关
|
|
|
- socketService.sendCommand(Symbol.order.control, a.getRelayCode(), Symbol.command.open, a.getRelayBit());
|
|
|
try {
|
|
|
- Thread.sleep(timeWaitConfigUtils.getWaitTime());
|
|
|
+ if(a.getRelayType().intValue()==1){
|
|
|
+ //这里打卡继电器的开关
|
|
|
+ socketService.sendCommand(Symbol.order.control, a.getRelayCode(), Symbol.command.open, a.getRelayBit());
|
|
|
+ Thread.sleep(timeWaitConfigUtils.getWaitTime());
|
|
|
+ }
|
|
|
+
|
|
|
} catch (InterruptedException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
@@ -393,7 +438,7 @@ public class LabExitLineVertexServiceImpl implements ILabExitLineVertexService {
|
|
|
|
|
|
|
|
|
//todo 针对实验室计算出当前实验室的各种线路,过滤到最优线路
|
|
|
- public CompletableFuture <Map <String, Object>> optimalRoute(List <LabExitLineJoinPointVO> linePointVOList, Integer[][] path, Integer[] chain, int i, int j, ArrayList <Integer[][]> oldList, List <LabExitLineJoinPointVO> oldRelationalData) {
|
|
|
+ public CompletableFuture <Map <String, Object>> optimalRoute(List <LabExitLineJoinPointVO> linePointVOList, Integer[][] path, Integer[] chain, int i, int j, ArrayList <Integer[][]> oldList, List <LabExitLineJoinPointVO> oldRelationalData,LabExitLineEvacuationVo labExitLineEvacuationVo) {
|
|
|
//输出源到目的地
|
|
|
logger.info("\n " + (linePointVOList.get(i).getPointName()) + "->" + (linePointVOList.get(i).getPointVOList().get(j).getPointName()) + " ");
|
|
|
//保存两个点之间的途径点。
|
|
|
@@ -404,20 +449,7 @@ public class LabExitLineVertexServiceImpl implements ILabExitLineVertexService {
|
|
|
if (linePointVOList.get(i).getPointVOList().get(j).getPointDistance() == M) {
|
|
|
logger.info(" NA ");
|
|
|
//todo 这里原来是NA,也就是说没有匹配到线路,如果线路出现坏点,并且没有其他备用线路,那么就选择坏点线路
|
|
|
- int countPoint = 0;
|
|
|
- for (int x = 0; x < V; x++) {
|
|
|
- for (int y = 0; y < V; y++) {
|
|
|
- if (x != y) {//只是避免了vi->vi的输出
|
|
|
- if (oldRelationalData.get(x).getPointAttribute() == 4 && oldRelationalData.get(x).getPointVOList().get(y).getPointAttribute() == 1) {
|
|
|
- if (linePointVOList.get(i).getPointName().equals(oldRelationalData.get(x).getPointVOList().get(y).getPointName())) {
|
|
|
- countPoint++;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- // todo 这里需要在做一次线路计算,出现NA有可能是实验室发生预案后,其他实验室路径这个实验室已经被标记坏点,但是其他实验室有没有备用线路选择,所以只能继续往危险的实验室路径撤离。
|
|
|
- if (countPoint < 1) {
|
|
|
+ if(!labExitLineEvacuationVo.getStartPointName().equals(linePointVOList.get(i).getPointName())){
|
|
|
getHistoryLinePoint(oldRelationalData, oldList.get(0), chain, i, j, joinPointVOS);
|
|
|
}
|
|
|
} else {
|
|
|
@@ -425,8 +457,10 @@ public class LabExitLineVertexServiceImpl implements ILabExitLineVertexService {
|
|
|
}
|
|
|
|
|
|
joinPointMap.put("joinPointVOS", joinPointVOS);
|
|
|
- joinPointMap.put("pointName", linePointVOList.get(i).getPointName());
|
|
|
- joinPointMap.put("pointDistanceVo", linePointVOList.get(i).getPointVOList().get(j));
|
|
|
+ if(joinPointVOS.size()>0){
|
|
|
+ joinPointMap.put("pointName", linePointVOList.get(i).getPointName());
|
|
|
+ joinPointMap.put("pointDistanceVo", linePointVOList.get(i).getPointVOList().get(j));
|
|
|
+ }
|
|
|
|
|
|
return CompletableFuture.completedFuture(joinPointMap);
|
|
|
}
|