Commit 19f472cf authored by duanruiming's avatar duanruiming

优化海康相位控制服务,增加相位列表参数

parent 4f627088
...@@ -24,6 +24,7 @@ import net.wanji.utc.util.FieldUtil; ...@@ -24,6 +24,7 @@ import net.wanji.utc.util.FieldUtil;
import net.wanji.utc.util.PathUtil; import net.wanji.utc.util.PathUtil;
import net.wanji.utc.vo.*; import net.wanji.utc.vo.*;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.*; import java.util.*;
...@@ -264,22 +265,41 @@ public class HKControlCommandServiceImpl implements ControlCommandService { ...@@ -264,22 +265,41 @@ public class HKControlCommandServiceImpl implements ControlCommandService {
if (commandVO.getCommand().equals(TRUE)) { if (commandVO.getCommand().equals(TRUE)) {
Map<String, Object> param = new HashMap<String, Object>() { Map<String, Object> param = new HashMap<String, Object>() {
{ {
//put("crossCode", commandVO.getCrossCode());
put("crossCode", manufacturerInfoPO.getName()); put("crossCode", manufacturerInfoPO.getName());
put("controlType", LOCK_RUNNING_CONTROL); put("controlType", LOCK_RUNNING_CONTROL);
} }
}; };
// 获取某一路口下海康相位和车道关系
//Map<Integer, JSONArray> laneArrayMap = getPhaseRelationLanes(commandVO.getCrossCode());
Map<Integer, JSONArray> laneArrayMap = getPhaseRelationLanes(manufacturerInfoPO.getName());
// 控制命令为灯态锁定时,设置相关车道参数信息 // 控制命令为灯态锁定时,设置相关车道参数信息
//List<SignalRunring> runrings = getSignalInfoVos(commandVO.getCrossCode()).get(0).getRunrings(); //List<SignalRunring> runrings = getSignalInfoVos(commandVO.getCrossCode()).get(0).getRunrings();
// HK 为单环 // HK 为单环
// 获取当前运行方案的相位id // 获取当前运行方案的相位id
Integer phaseId;
List<Map<String, Object>> laneList = new ArrayList<>();
if (CollectionUtils.isEmpty(commandVO.getPhaseList())) {
LightsStatusVO statusVO = getSignalInfoVos(manufacturerInfoPO.getName()).get(0); LightsStatusVO statusVO = getSignalInfoVos(manufacturerInfoPO.getName()).get(0);
Integer phaseId = Integer.valueOf(statusVO.getPhaseId()); phaseId = Integer.valueOf(statusVO.getPhaseId());
// 获取某一路口下海康相位和车道关系 JSONArray jsonArray = laneArrayMap.get(phaseId);
//Map<Integer, JSONArray> laneArrayMap = getPhaseRelationLanes(commandVO.getCrossCode()); for (int i = 0; i < jsonArray.size(); i++) {
Map<Integer, JSONArray> laneArrayMap = getPhaseRelationLanes(manufacturerInfoPO.getName()); JSONObject jsonObject = jsonArray.getJSONObject(i);
Map<String, Object> laneMap = new HashMap<>();
laneMap.put("laneNo", jsonObject.getInteger("laneNo"));
laneMap.put("turn", jsonObject.getInteger("turn"));
laneMap.put("direction", jsonObject.getInteger("direction"));
laneList.add(laneMap);
}
param.put("laneInfos", laneList);
param.put("controlNo", 0);
// 控制时长,单位 s,0 则持续控制
param.put("duration", Objects.isNull(commandVO.getDuration()) || commandVO.getDuration() == 0 ? 999 : commandVO.getDuration());
} else {
List<Integer> phaseList = commandVO.getPhaseList();
for (Integer phaseNo : phaseList) {
phaseId = phaseNo;
JSONArray jsonArray = laneArrayMap.get(phaseId); JSONArray jsonArray = laneArrayMap.get(phaseId);
List<Map<String, Object>> laneList = new ArrayList<>();
for (int i = 0; i < jsonArray.size(); i++) { for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i); JSONObject jsonObject = jsonArray.getJSONObject(i);
Map<String, Object> laneMap = new HashMap<>(); Map<String, Object> laneMap = new HashMap<>();
...@@ -288,10 +308,13 @@ public class HKControlCommandServiceImpl implements ControlCommandService { ...@@ -288,10 +308,13 @@ public class HKControlCommandServiceImpl implements ControlCommandService {
laneMap.put("direction", jsonObject.getInteger("direction")); laneMap.put("direction", jsonObject.getInteger("direction"));
laneList.add(laneMap); laneList.add(laneMap);
} }
}
}
param.put("laneInfos", laneList); param.put("laneInfos", laneList);
param.put("controlNo", 0); param.put("controlNo", 0);
// 控制时长,单位 s,0 则持续控制 // 控制时长,单位 s,0 则持续控制
param.put("duration", Objects.isNull(commandVO.getDuration()) || commandVO.getDuration() == 0 ? 999 : commandVO.getDuration()); param.put("duration", Objects.isNull(commandVO.getDuration()) || commandVO.getDuration() == 0 ? 999 : commandVO.getDuration());
String strResult = ArtemisHttpUtil.doPostStringArtemis(artemisConfig, String strResult = ArtemisHttpUtil.doPostStringArtemis(artemisConfig,
PathUtil.getPathMapByApiCode("setSignalControl"), PathUtil.getPathMapByApiCode("setSignalControl"),
JSON.toJSONString(param), null, null, "application/json", null); JSON.toJSONString(param), null, null, "application/json", null);
......
...@@ -8,6 +8,7 @@ import javax.validation.constraints.Max; ...@@ -8,6 +8,7 @@ import javax.validation.constraints.Max;
import javax.validation.constraints.Min; import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.util.List;
/** /**
* 控制指令VO * 控制指令VO
...@@ -23,9 +24,6 @@ public class ControlCommandVO { ...@@ -23,9 +24,6 @@ public class ControlCommandVO {
@NotBlank(message = "路口编号不可为空") @NotBlank(message = "路口编号不可为空")
private String crossCode; private String crossCode;
/**
* 1 锁定; 0 取消
*/
@ApiModelProperty(value = "1是;0否") @ApiModelProperty(value = "1是;0否")
@NotNull(message = "控制类型不可为空,1是;0否") @NotNull(message = "控制类型不可为空,1是;0否")
@Max(value = 1, message = "控制类型:1是;0否") @Max(value = 1, message = "控制类型:1是;0否")
...@@ -35,4 +33,7 @@ public class ControlCommandVO { ...@@ -35,4 +33,7 @@ public class ControlCommandVO {
@ApiModelProperty(value = "持续时间") @ApiModelProperty(value = "持续时间")
private Integer duration; private Integer duration;
@ApiModelProperty(value = "锁定相位列表")
private List<Integer> phaseList;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment