Commit e1876760 authored by zhouleilei's avatar zhouleilei

神思定制化-海信信号机步进指令下发/取消

新增锁相/解除锁相功能
parent 8668906d
......@@ -154,7 +154,7 @@ public class ControlCommandController {
@AspectLog(description = "恢复时间表-恢复路口时间表执行(恢复固定配时)", operationType = BaseEnum.OperationTypeEnum.UPDATE)
@ApiOperation(value = "恢复时间表-恢复路口时间表执行(恢复固定配时)", notes = "恢复时间表-恢复路口时间表执行(恢复固定配时)")
@PostMapping("/recoverSchedule")
public JsonViewObject recoverSchedule(@RequestParam String crossCode) throws Exception {
public JsonViewObject recoverSchedule(@RequestParam @Validated String crossCode) throws Exception {
return controlCommandService.recoverSchedule(crossCode);
}
......@@ -205,7 +205,7 @@ public class ControlCommandController {
/**
* 步进相位
*/
@AspectLog(description = "步进相位", operationType = BaseEnum.OperationTypeEnum.UPDATE)
@AspectLog(description = "步进相位-神思定制化", operationType = BaseEnum.OperationTypeEnum.UPDATE)
@ApiOperation(value = "步进相位", notes = "步进相位")
@PostMapping("/stepingPhase")
public JsonViewObject stepingPhase(@RequestBody @Validated StepingPhaseDTO stepingPhaseDTO) throws Exception{
......
......@@ -18,7 +18,10 @@ import net.wanji.utc.hisense.pojo.result.CrossSchemeRings;
import net.wanji.utc.hisense.service.StaticInfoService;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.constraints.NotNull;
import javax.ws.rs.core.MediaType;
......@@ -98,7 +101,7 @@ public class StaticInfoController {
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = CoordinationStatus.class)
})
public JsonViewObject crossPlanId(@NotNull String crossId) throws Exception {
public JsonViewObject crossPlanId(@NotNull String crossId) throws Exception {
CoordinationStatus coordinationStatus = staticInfoService.crossPlan(crossId);
if (ObjectUtils.isNotEmpty(coordinationStatus)) {
return JsonViewObject.newInstance().success(coordinationStatus);
......
......@@ -35,6 +35,10 @@ public class CrossSchemeRings {
* 方案中环的个数
*/
private String ringCount;
/**
* 相位差
*/
private String offset;
/**
* 环中相位的顺序,i 表示环号。相位号之间用空格隔开,屏障之间用下划线”_”分隔。
*/
......
......@@ -16,6 +16,7 @@ import net.wanji.utc.hisense.service.ControlCommandService;
import net.wanji.utc.hisense.util.OkHttpClientUtil;
import org.apache.commons.lang3.ObjectUtils;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.springframework.beans.factory.annotation.Value;
......@@ -55,7 +56,52 @@ public class ControlCommandServiceImpl implements ControlCommandService {
@Override
public JsonViewObject lockControl(ControlCommandVO commandVO) throws Exception {
return null;
CrossInfoPOExt crossInfoPOExt = crossInfoMapper.selectById(commandVO.getCrossCode());
//组装document
Document document = OperationBaseDom.generateBaseDoc();
Element element = (Element) document.selectSingleNode(HttpConstants.SYSTEMSCRIPTION);
element.addElement(HttpConstants.MESSAGETYPE).setText(HttpConstants.MESSAGETYPE_22);
Element messageContent = (Element) document.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_MESSAGECONTENT);
messageContent.addElement(HttpConstants.SPOT).setText(crossInfoPOExt.getCode());
messageContent.addElement(HttpConstants.CTRLSTEP).setText("0");
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
if (commandVO.getCommand() == 1) {
//锁相
messageContent.addElement(HttpConstants.COMMAND).setText("1");
} else if (commandVO.getCommand() == 0) {
//解锁
messageContent.addElement(HttpConstants.COMMAND).setText("0");
}
//相位驻留
// String xmlPost = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML());
String xmlPost = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<systemScription System=\"TCIP\" Version=\"1.0\">\n" +
" <subSystem>Hisense</subSystem>\n" +
" <messageType>12</messageType>\n" +
" <isRequest>0</isRequest>\n" +
" <seq>20241103155205549244</seq>\n" +
" <needResponse>1</needResponse>\n" +
" <result>1</result>\n" +
" <flag>0</flag>\n" +
" <tStamp>1731037114609</tStamp>\n" +
" <messageContent>\n" +
" <Spot>311358</Spot>\n" +
" <CoordPatternStatus>4</CoordPatternStatus>\n" +
" <CoordCycleStatus>160</CoordCycleStatus>\n" +
" <CoordSyncStatus>123</CoordSyncStatus>\n" +
" </messageContent>\n" +
"</systemScription>";
if (StringUtils.isNotBlank(xmlPost)) {
Document extendPost = DocumentHelper.parseText(xmlPost);
String extendResult = extendPost.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_RESULT).getText();
if (HttpConstants.RESULT_1.equals(extendResult) || HttpConstants.RESULT_2.equals(extendResult)) {
return jsonViewObject.success("相位锁定/解锁 - 控制成功");
}else {
return jsonViewObject.fail("相位锁定/解锁 - 控制失败");
}
}
return jsonViewObject.fail("相位锁定/解锁 - 控制失败");
}
@Override
......@@ -75,27 +121,97 @@ public class ControlCommandServiceImpl implements ControlCommandService {
stepNum = 1;
}
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
//给海信发送http请求
for (int i = 0; i < stepNum; i++) {
//步进需要下发两次命令
OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML());
String post = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML());
if (StringUtils.isNotBlank(post)) {
Document postResult = DocumentHelper.parseText(post);
String result = postResult.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_RESULT).getText();
if (HttpConstants.RESULT_1.equals(result) || HttpConstants.RESULT_2.equals(result)) {
log.info("路口号 :{},第 {} 次步进成功,result:{}", crossInfoPOExt.getCode(), i + 1, result);
} else {
log.error("路口号 :{},第 {} 次步进失败,result:{}", crossInfoPOExt.getCode(), i + 1, result);
return jsonViewObject.fail("相位步进失败,路口号:" + crossInfoPOExt.getCode());
if (command == 0) {
//取消步进
// boolean isOk = sendMesIsOk(document.asXML());
boolean isOk = true;
if (isOk) {
return jsonViewObject.success("取消步进 - 控制成功");
} else {
return jsonViewObject.fail("取消步进 - 控制失败");
}
} else {
//相位驻留
// String xmlPost = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML());
String xmlPost = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<systemScription System=\"TCIP\" Version=\"1.0\">\n" +
" <subSystem>Hisense</subSystem>\n" +
" <messageType>12</messageType>\n" +
" <isRequest>0</isRequest>\n" +
" <seq>20241103155205549244</seq>\n" +
" <needResponse>1</needResponse>\n" +
" <result>1</result>\n" +
" <flag>0</flag>\n" +
" <tStamp>1731037114609</tStamp>\n" +
" <messageContent>\n" +
" <Spot>311358</Spot>\n" +
" <CoordPatternStatus>4</CoordPatternStatus>\n" +
" <CoordCycleStatus>160</CoordCycleStatus>\n" +
" <CoordSyncStatus>123</CoordSyncStatus>\n" +
" </messageContent>\n" +
"</systemScription>";
if (StringUtils.isNotBlank(xmlPost)) {
Document extendPost = DocumentHelper.parseText(xmlPost);
String extendResult = extendPost.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_RESULT).getText();
if (HttpConstants.RESULT_1.equals(extendResult) || HttpConstants.RESULT_2.equals(extendResult)) {
//开始步进
//给海信发送http请求
for (int i = 0; i < stepNum; i++) {
// String post = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML());
String post = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<systemScription System=\"TCIP\" Version=\"1.0\">\n" +
" <subSystem>Hisense</subSystem>\n" +
" <messageType>12</messageType>\n" +
" <isRequest>0</isRequest>\n" +
" <seq>20241103155205549244</seq>\n" +
" <needResponse>1</needResponse>\n" +
" <result>1</result>\n" +
" <flag>0</flag>\n" +
" <tStamp>1731037114609</tStamp>\n" +
" <messageContent>\n" +
" <Spot>311358</Spot>\n" +
" <CoordPatternStatus>4</CoordPatternStatus>\n" +
" <CoordCycleStatus>160</CoordCycleStatus>\n" +
" <CoordSyncStatus>123</CoordSyncStatus>\n" +
" </messageContent>\n" +
"</systemScription>";
if (StringUtils.isNotBlank(post)) {
Document postResult = DocumentHelper.parseText(post);
String result = postResult.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_RESULT).getText();
if (HttpConstants.RESULT_1.equals(result) || HttpConstants.RESULT_2.equals(result)) {
log.info("路口号 :{},第 {} 次步进成功,result:{}", code, i + 1, result);
} else {
log.error("路口号 :{},第 {} 次步进失败,result:{}", code, i + 1, result);
messageContent.selectSingleNode(HttpConstants.COMMAND).setText("0");
//取消步进
// boolean isOk = sendMesIsOk(document.asXML());
boolean isOk = true;
if (isOk) {
return jsonViewObject.fail("相位步进失败,取消步进成功,路口号: " + code);
} else {
return jsonViewObject.fail("相位步进失败,取消步进失败,路口号: " + code);
}
}
//停顿10ms
Thread.sleep(10);
} else {
messageContent.selectSingleNode(HttpConstants.COMMAND).setText("0");
//取消步进
// boolean isOk = sendMesIsOk(document.asXML());
boolean isOk = true;
if (isOk) {
return jsonViewObject.fail("相位步进失败,取消步进成功,路口号: " + code);
} else {
return jsonViewObject.fail("相位步进失败,取消步进失败,路口号: " + code);
}
}
}
}
//停顿10ms
Thread.sleep(10);
} else {
return jsonViewObject.fail("相位步进失败,路口号: " + crossInfoPOExt.getCode());
return jsonViewObject.fail("相位步进 - 控制失败");
}
}
return jsonViewObject.success("相位步进 - 控制成功");
return jsonViewObject.fail("相位步进 - 控制失败");
}
@Override
......@@ -112,11 +228,27 @@ public class ControlCommandServiceImpl implements ControlCommandService {
element.addElement(HttpConstants.MESSAGETYPE).setText(HttpConstants.MESSAGETYPE_16);
Element messageContent = (Element) document.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_MESSAGECONTENT);
messageContent.addElement(HttpConstants.SPOT).setText(crossInfoPOExt.getCode());
//暂时按照神思的写死
messageContent.addElement(HttpConstants.PATTERN).setText("0");
//给海信发送http请求
String post = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML());
// String post = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML());
String post = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<systemScription System=\"TCIP\" Version=\"1.0\">\n" +
" <subSystem>Hisense</subSystem>\n" +
" <messageType>12</messageType>\n" +
" <isRequest>0</isRequest>\n" +
" <seq>20241103155205549244</seq>\n" +
" <needResponse>1</needResponse>\n" +
" <result>1</result>\n" +
" <flag>0</flag>\n" +
" <tStamp>1731037114609</tStamp>\n" +
" <messageContent>\n" +
" <Spot>311358</Spot>\n" +
" <CoordPatternStatus>4</CoordPatternStatus>\n" +
" <CoordCycleStatus>160</CoordCycleStatus>\n" +
" <CoordSyncStatus>123</CoordSyncStatus>\n" +
" </messageContent>\n" +
"</systemScription>";
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
if (StringUtils.isBlank(post)) {
log.error("5.10. 手动方案控制- 恢复固定配时 失败");
......@@ -154,7 +286,7 @@ public class ControlCommandServiceImpl implements ControlCommandService {
@Override
public JsonViewObject tempSchemeDetail(TempSchemeSendVO tempSchemeSendVO) throws Exception {
CrossInfoPOExt crossInfoPOExt = crossInfoMapper.selectById(tempSchemeSendVO.getCrossCode());
CrossInfoPOExt crossInfoPOExt = crossInfoMapper.selectById(tempSchemeSendVO.getCrossId());
//组装document
Document document = OperationBaseDom.generateBaseDoc();
Element element = (Element) document.selectSingleNode(HttpConstants.SYSTEMSCRIPTION);
......@@ -178,7 +310,24 @@ public class ControlCommandServiceImpl implements ControlCommandService {
messageContent.addElement(HttpConstants.SPLIT).setText(tempSchemeSendVO.getSplit());
//给海信发送http请求
String post = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML());
// String post = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML());
String post = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<systemScription System=\"TCIP\" Version=\"1.0\">\n" +
" <subSystem>Hisense</subSystem>\n" +
" <messageType>12</messageType>\n" +
" <isRequest>0</isRequest>\n" +
" <seq>20241103155205549244</seq>\n" +
" <needResponse>1</needResponse>\n" +
" <result>1</result>\n" +
" <flag>0</flag>\n" +
" <tStamp>1731037114609</tStamp>\n" +
" <messageContent>\n" +
" <Spot>311358</Spot>\n" +
" <CoordPatternStatus>4</CoordPatternStatus>\n" +
" <CoordCycleStatus>160</CoordCycleStatus>\n" +
" <CoordSyncStatus>123</CoordSyncStatus>\n" +
" </messageContent>\n" +
"</systemScription>";
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
if (StringUtils.isBlank(post)) {
log.error("HTTP请求 5.16. 方案优化控制 失败");
......@@ -217,7 +366,24 @@ public class ControlCommandServiceImpl implements ControlCommandService {
messageContent.addElement(HttpConstants.CTRLSTEP).setText("0");
//给海信发送http请求
String post = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML());
// String post = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML());
String post = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<systemScription System=\"TCIP\" Version=\"1.0\">\n" +
" <subSystem>Hisense</subSystem>\n" +
" <messageType>12</messageType>\n" +
" <isRequest>0</isRequest>\n" +
" <seq>20241103155205549244</seq>\n" +
" <needResponse>1</needResponse>\n" +
" <result>1</result>\n" +
" <flag>0</flag>\n" +
" <tStamp>1731037114609</tStamp>\n" +
" <messageContent>\n" +
" <Spot>311358</Spot>\n" +
" <CoordPatternStatus>4</CoordPatternStatus>\n" +
" <CoordCycleStatus>160</CoordCycleStatus>\n" +
" <CoordSyncStatus>123</CoordSyncStatus>\n" +
" </messageContent>\n" +
"</systemScription>";
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
if (StringUtils.isBlank(post)) {
log.error("HTTP请求 5.12. 步进及取消控制 失败");
......@@ -231,7 +397,24 @@ public class ControlCommandServiceImpl implements ControlCommandService {
//执行成功,开始延长
Thread.sleep(extendPhaseDTO.getExtendTime() * 1000);
//给海信发送http请求
String post1 = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML());
// String post1 = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML());
String post1 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<systemScription System=\"TCIP\" Version=\"1.0\">\n" +
" <subSystem>Hisense</subSystem>\n" +
" <messageType>12</messageType>\n" +
" <isRequest>0</isRequest>\n" +
" <seq>20241103155205549244</seq>\n" +
" <needResponse>1</needResponse>\n" +
" <result>1</result>\n" +
" <flag>0</flag>\n" +
" <tStamp>1731037114609</tStamp>\n" +
" <messageContent>\n" +
" <Spot>311358</Spot>\n" +
" <CoordPatternStatus>4</CoordPatternStatus>\n" +
" <CoordCycleStatus>160</CoordCycleStatus>\n" +
" <CoordSyncStatus>123</CoordSyncStatus>\n" +
" </messageContent>\n" +
"</systemScription>";
if (StringUtils.isNotBlank(post1)) {
Document extendPost = DocumentHelper.parseText(post1);
String extendResult = extendPost.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_RESULT).getText();
......@@ -243,7 +426,24 @@ public class ControlCommandServiceImpl implements ControlCommandService {
log.error("HTTP请求 5.12. 步进及取消控制 失败");
//重新发起三次取消控制请求
for (int j = 0; j < 3; j++) {
String httpPost = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML());
// String httpPost = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML());
String httpPost = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<systemScription System=\"TCIP\" Version=\"1.0\">\n" +
" <subSystem>Hisense</subSystem>\n" +
" <messageType>12</messageType>\n" +
" <isRequest>0</isRequest>\n" +
" <seq>20241103155205549244</seq>\n" +
" <needResponse>1</needResponse>\n" +
" <result>1</result>\n" +
" <flag>0</flag>\n" +
" <tStamp>1731037114609</tStamp>\n" +
" <messageContent>\n" +
" <Spot>311358</Spot>\n" +
" <CoordPatternStatus>4</CoordPatternStatus>\n" +
" <CoordCycleStatus>160</CoordCycleStatus>\n" +
" <CoordSyncStatus>123</CoordSyncStatus>\n" +
" </messageContent>\n" +
"</systemScription>";
if (StringUtils.isNotBlank(httpPost)) {
Document extendPost = DocumentHelper.parseText(httpPost);
String extendResult = extendPost.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_RESULT).getText();
......@@ -273,7 +473,7 @@ public class ControlCommandServiceImpl implements ControlCommandService {
@Override
public JsonViewObject stepingPhase(StepingPhaseDTO stepingPhaseDTO) throws Exception {
if (ObjectUtils.isEmpty(stepingPhaseDTO.getStepCount())) {
if (ObjectUtils.isEmpty(stepingPhaseDTO.getStepCount()) || stepingPhaseDTO.getStepCount() == 0) {
//默认步进1次
stepingPhaseDTO.setStepCount(1);
}
......@@ -284,31 +484,136 @@ public class ControlCommandServiceImpl implements ControlCommandService {
element.addElement(HttpConstants.MESSAGETYPE).setText(HttpConstants.MESSAGETYPE_22);
Element messageContent = (Element) document.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_MESSAGECONTENT);
messageContent.addElement(HttpConstants.SPOT).setText(crossInfoPOExt.getCode());
//暂时按照神思的写死
messageContent.addElement(HttpConstants.COMMAND).setText("1");
messageContent.addElement(HttpConstants.COMMAND).setText(stepingPhaseDTO.getCommand() + "");
//海信现在只支持0
messageContent.addElement(HttpConstants.CTRLSTEP).setText("0");
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
if (stepingPhaseDTO.getCommand() == 0) {
//取消步进
// boolean isOk = sendMesIsOk(document.asXML());
boolean isOk = true;
if (true) {
return jsonViewObject.success("取消步进 - 控制成功");
} else {
return jsonViewObject.fail("取消步进 - 控制失败");
}
} else if (stepingPhaseDTO.getCommand() == 1) {
//逻辑:第一次发送步进指令是相位驻留,以后发送才是相位步进,步进成功则取消步进。步进失败,也立即下发取消步进控制
//相位驻留
// String xmlPost = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML());
String xmlPost = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<systemScription System=\"TCIP\" Version=\"1.0\">\n" +
" <subSystem>Hisense</subSystem>\n" +
" <messageType>12</messageType>\n" +
" <isRequest>0</isRequest>\n" +
" <seq>20241103155205549244</seq>\n" +
" <needResponse>1</needResponse>\n" +
" <result>1</result>\n" +
" <flag>0</flag>\n" +
" <tStamp>1731037114609</tStamp>\n" +
" <messageContent>\n" +
" <Spot>311358</Spot>\n" +
" <CoordPatternStatus>4</CoordPatternStatus>\n" +
" <CoordCycleStatus>160</CoordCycleStatus>\n" +
" <CoordSyncStatus>123</CoordSyncStatus>\n" +
" </messageContent>\n" +
"</systemScription>";
//给海信发送http请求
for (int i = 0; i < stepingPhaseDTO.getStepCount(); i++) {
String post = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML());
if (StringUtils.isNotBlank(post)) {
Document postResult = DocumentHelper.parseText(post);
String result = postResult.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_RESULT).getText();
if (HttpConstants.RESULT_1.equals(result) || HttpConstants.RESULT_2.equals(result)) {
log.info("路口号 :{},第 {} 次步进成功,result:{}", stepingPhaseDTO.getCrossId(), i + 1, result);
jsonViewObject = jsonViewObject.success("相位步进 - 控制成功");
} else {
log.error("路口号 :{},第 {} 次步进失败,result:{}", stepingPhaseDTO.getCrossId(), i + 1, result);
return jsonViewObject.fail("相位步进失败,路口号:" + stepingPhaseDTO.getCrossId());
if (StringUtils.isNotBlank(xmlPost)) {
Document extendPost = DocumentHelper.parseText(xmlPost);
String extendResult = extendPost.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_RESULT).getText();
if (HttpConstants.RESULT_1.equals(extendResult) || HttpConstants.RESULT_2.equals(extendResult)) {
//开始步进
//给海信发送http请求
for (int i = 0; i < stepingPhaseDTO.getStepCount(); i++) {
// String post = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML());
String post = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<systemScription System=\"TCIP\" Version=\"1.0\">\n" +
" <subSystem>Hisense</subSystem>\n" +
" <messageType>12</messageType>\n" +
" <isRequest>0</isRequest>\n" +
" <seq>20241103155205549244</seq>\n" +
" <needResponse>1</needResponse>\n" +
" <result>1</result>\n" +
" <flag>0</flag>\n" +
" <tStamp>1731037114609</tStamp>\n" +
" <messageContent>\n" +
" <Spot>311358</Spot>\n" +
" <CoordPatternStatus>4</CoordPatternStatus>\n" +
" <CoordCycleStatus>160</CoordCycleStatus>\n" +
" <CoordSyncStatus>123</CoordSyncStatus>\n" +
" </messageContent>\n" +
"</systemScription>";
if (StringUtils.isNotBlank(post)) {
Document postResult = DocumentHelper.parseText(post);
String result = postResult.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_RESULT).getText();
if (HttpConstants.RESULT_1.equals(result) || HttpConstants.RESULT_2.equals(result)) {
log.info("路口号 :{},第 {} 次步进成功,result:{}", stepingPhaseDTO.getCrossId(), i + 1, result);
} else {
log.error("路口号 :{},第 {} 次步进失败,result:{}", stepingPhaseDTO.getCrossId(), i + 1, result);
messageContent.selectSingleNode(HttpConstants.COMMAND).setText("0");
//取消步进
// boolean isOk = sendMesIsOk(document.asXML());
boolean isOk = true;
if (isOk) {
return jsonViewObject.fail("相位步进失败,取消步进成功,路口号: " + stepingPhaseDTO.getCrossId());
} else {
return jsonViewObject.fail("相位步进失败,取消步进失败,路口号: " + stepingPhaseDTO.getCrossId());
}
}
//停顿10ms
Thread.sleep(10);
} else {
messageContent.selectSingleNode(HttpConstants.COMMAND).setText("0");
//取消步进
// boolean isOk = sendMesIsOk(document.asXML());
boolean isOk = true;
if (isOk) {
return jsonViewObject.fail("相位步进失败,取消步进成功,路口号: " + stepingPhaseDTO.getCrossId());
} else {
return jsonViewObject.fail("相位步进失败,取消步进失败,路口号: " + stepingPhaseDTO.getCrossId());
}
}
}
messageContent.selectSingleNode(HttpConstants.COMMAND).setText("0");
//取消步进
// boolean isOk = sendMesIsOk(document.asXML());
boolean isOk = true;
if (isOk) {
return jsonViewObject.success("相位步进成功,,路口号: " + stepingPhaseDTO.getCrossId());
} else {
return jsonViewObject.fail("相位步进成功,但取消步进失败,路口号: " + stepingPhaseDTO.getCrossId());
}
}
//停顿10ms
Thread.sleep(10);
} else {
return jsonViewObject.fail("相位步进失败,路口号: " + stepingPhaseDTO.getCrossId());
return jsonViewObject.fail("相位步进 - 控制失败");
}
}
return jsonViewObject.fail("相位步进 - 控制失败");
}
private boolean sendMesIsOk(String xml) throws DocumentException, InterruptedException {
String post = OkHttpClientUtil.xmlPost(hisenseUrl, xml);
if (StringUtils.isBlank(post)) {
return false;
}
return jsonViewObject;
Document postResult = DocumentHelper.parseText(post);
String result = postResult.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_RESULT).getText();
if (HttpConstants.RESULT_1.equals(result) || HttpConstants.RESULT_2.equals(result)) {
return true;
} else {
//连续重试发三次
for (int i = 0; i < 3; i++) {
post = OkHttpClientUtil.xmlPost(hisenseUrl, xml);
postResult = DocumentHelper.parseText(post);
result = postResult.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_RESULT).getText();
if (HttpConstants.RESULT_1.equals(result) || HttpConstants.RESULT_2.equals(result)) {
return true;
}
Thread.sleep(1000);
}
}
return false;
}
}
......@@ -138,7 +138,7 @@ public class StaticInfoServiceImpl implements StaticInfoService {
String CoordCycleStatus = postResult.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_MESSAGECONTENT).valueOf("CoordCycleStatus");
String CoordSyncStatus = postResult.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_MESSAGECONTENT).valueOf("CoordSyncStatus");
CoordinationStatus coordinationStatus = CoordinationStatus.builder()
.spot(spot)
.spot(crossId)
.coordPatternStatus(CoordPatternStatus)
.coordCycleStatus(CoordCycleStatus)
.coordSyncStatus(CoordSyncStatus)
......@@ -173,17 +173,18 @@ public class StaticInfoServiceImpl implements StaticInfoService {
String result = postResult.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_RESULT).getText();
if (HttpConstants.RESULT_1.equals(result)){
//成功
String spot = postResult.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_MESSAGECONTENT).valueOf("Spot");
String patternRest = postResult.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_MESSAGECONTENT).valueOf("Pattern");
String cycleLen = postResult.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_MESSAGECONTENT).valueOf("CycleLen");
String ringCount = postResult.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_MESSAGECONTENT).valueOf("RingCount");
String offset = postResult.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_MESSAGECONTENT).valueOf("Offset");
List<Element> cycleElementList = postResult.selectNodes(HttpConstants.SYSTEMSCRIPTION_MESSAGECONTENT + "/CycleList");
List<Element> phaseElementList = postResult.selectNodes(HttpConstants.SYSTEMSCRIPTION_MESSAGECONTENT + "/PhaseList");
CrossSchemeRings crossSchemeRings = new CrossSchemeRings();
crossSchemeRings.setSpot(spot);
crossSchemeRings.setSpot(crossSchemeRingsDTO.getCrossId());
crossSchemeRings.setPattern(patternRest);
crossSchemeRings.setRingCount(ringCount);
crossSchemeRings.setCycleLen(cycleLen);
crossSchemeRings.setOffset(offset);
JSONObject jsonObject = new JSONObject();
for (Element cycle : cycleElementList) {
......
......@@ -8,6 +8,7 @@ import lombok.extern.slf4j.Slf4j;
import net.wanji.common.annotation.aspect.AspectLog;
import net.wanji.common.enums.BaseEnum;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.databus.dto.CrossIdDTO;
import net.wanji.databus.dto.ExtendPhaseDTO;
import net.wanji.databus.dto.StepingPhaseDTO;
import net.wanji.databus.vo.TempSchemeSendVO;
......@@ -164,14 +165,14 @@ public class ControlCommandController {
/**
* 恢复时间表
*
* @param crossCode
* @param crossIdDTO
* @return
*/
@AspectLog(description = "恢复时间表-恢复路口时间表执行", operationType = BaseEnum.OperationTypeEnum.UPDATE)
@ApiOperation(value = "恢复时间表-恢复路口时间表执行", notes = "恢复时间表-恢复路口时间表执行")
@PostMapping("/recoverSchedule")
public JsonViewObject recoverSchedule(@RequestParam String crossCode) throws Exception {
return controlCommandStrategyService.recoverScheduleStrategy(crossCode);
public JsonViewObject recoverSchedule(@Validated @RequestBody CrossIdDTO crossIdDTO) throws Exception {
return controlCommandStrategyService.recoverScheduleStrategy(crossIdDTO.getCrossId());
}
/**
......@@ -255,6 +256,8 @@ public class ControlCommandController {
@ApiOperation(value = "海信-步进相位", notes = "海信-步进相位")
@PostMapping("/stepingPhase")
public JsonViewObject stepingPhase(@RequestBody @Validated StepingPhaseDTO stepingPhaseDTO) throws Exception{
//调用信控系统的步进功能,该controller为了保证对外提供的接口参数统一放在body里
// return controlCommandStrategyService.stepControlStrategy(stepingPhaseDTO.getCrossId(), stepingPhaseDTO.getCommand(), stepingPhaseDTO.getStepCount());
return controlCommandStrategyService.stepingPhase(stepingPhaseDTO);
}
......
......@@ -129,8 +129,8 @@ public class StaticInfoController {
@ApiResponse(code = 200, message = "OK", response = CrossSchedulesPO.class)
})
@ApiOperation(value = "获取当前运行方案号", notes = "获取当前运行方案号")
public JsonViewObject crossSchemeNo(@RequestParam String crossId) throws Exception {
return staticInfoService.crossSchemeNo(crossId);
public JsonViewObject crossSchemeNo(@Validated @RequestBody CrossIdDTO crossIdDTO) throws Exception {
return staticInfoService.crossSchemeNo(crossIdDTO.getCrossId());
}
@AspectLog(description = "方案环图请求", operationType = BaseEnum.OperationTypeEnum.QUERY)
@PostMapping(value = "/crossSchemeRings", produces = MediaType.APPLICATION_JSON)
......
......@@ -359,7 +359,7 @@ public class ControlCommandStrategyServiceImpl implements ControlCommandStrategy
@Override
public JsonViewObject tempSchemeDetail(TempSchemeSendVO tempSchemeSendVO) throws Exception {
String manufacturerCode = crossInfoCache.getManufacturerCodeByCrossId(tempSchemeSendVO.getCrossCode());
String manufacturerCode = crossInfoCache.getManufacturerCodeByCrossId(tempSchemeSendVO.getCrossId());
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
if (StringUtils.equals(BasicEnum.ManufacturerEnum.HK.getCode(), manufacturerCode)) {
} else {
......
......@@ -182,7 +182,7 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService {
*/
//海信协议
TempSchemeSendVO tempSchemeSendVO = getTempSchemeSendVO(schemeOptSendVO);
String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(tempSchemeSendVO.getCrossCode());
String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(tempSchemeSendVO.getCrossId());
jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).tempSchemeDetail(tempSchemeSendVO);
if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
return jsonViewObject.success("万集标准协议下发临时方案成功!");
......@@ -199,7 +199,7 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService {
TempSchemeSendVO tempSchemeSendVO = new TempSchemeSendVO();
//路口号
String crossCode = schemeOptSendVO.getCrossCode();
tempSchemeSendVO.setCrossCode(crossCode);
tempSchemeSendVO.setCrossId(crossCode);
List<SchemeSendVO.Pattern> patternList = schemeOptSendVO.getPatternList();
if (Optional.ofNullable(patternList).isPresent()) {
//现在系统只传一个方案
......@@ -240,7 +240,7 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService {
}
@Override
public JsonViewObject tempSchemeDetail(TempSchemeSendVO tempSchemeSendVO) throws Exception {
String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(tempSchemeSendVO.getCrossCode());
String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(tempSchemeSendVO.getCrossId());
JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).tempSchemeDetail(tempSchemeSendVO);
if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
return jsonViewObject.success("下发临时方案成功!");
......@@ -263,8 +263,8 @@ public class WanJiControlCommandServiceImpl implements ControlCommandService {
String manufacturerIdCode = crossInfoCache.getManufacturerCodeByCrossId(stepingPhaseDTO.getCrossId());
JsonViewObject jsonViewObject = utcFeignClientCache.getUtcFeignClientService(manufacturerIdCode).stepingPhase(stepingPhaseDTO);
if (StringUtils.endsWithIgnoreCase("success", jsonViewObject.getStatus())) {
return jsonViewObject.success("海信-步进相位成功!");
return jsonViewObject.success("步进相位成功!");
}
return jsonViewObject.fail("海信-步进相位失败!");
return jsonViewObject.fail("步进相位失败!");
}
}
package net.wanji.databus.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
/**
* @ClassName CrossIdDTO
* @Description crossId参数
* @Author zhouleilei
* @Date 2024/11/8 11:30
*/
@Data
@Valid
@ApiModel(value="根据路口编号查询", description="")
public class CrossIdDTO {
@ApiModelProperty(value = "路口ID")
@Pattern(regexp = "^[A-Za-z0-9]{11}$", message = "路口编号只能包含英文、数字,必须11个字符")
@NotNull(message = "crossId不能为空")
private String crossId;
}
......@@ -26,6 +26,11 @@ public class StepingPhaseDTO {
@NotNull(message = "crossId不能为空")
private String crossId;
@ApiModelProperty(value = "跳过几个相位,跳过几个相位")
@ApiModelProperty(value = "0 顺序步进 n 跳过n个相位")
@NotNull(message = "stepCount不能为空")
private Integer stepCount;
@ApiModelProperty(value = "1 开始步进 0 取消步进")
@NotNull(message = "command不能为空")
private Integer command;
}
package net.wanji.databus.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
......@@ -18,23 +18,26 @@ public class TempSchemeSendVO {
@ApiModelProperty(value = "路口编号", notes = "路口编号")
@Pattern(regexp = "^[A-Za-z0-9]{11}$", message = "路口编号只能包含英文、数字,必须11个字符")
@NotBlank(message = "路口编号不可为空")
private String crossCode;
private String crossId;
@ApiModelProperty(value = "基础方案号", notes = "优化的基础方案号,该方案号需在信号机提前配置")
@NotBlank(message = "基础方案号不能为空")
@NotBlank(message = "基础方案号pattern不能为空")
private String pattern;
@ApiModelProperty(value = "周期长", notes = "需要优化的周期长,单位秒")
@NotBlank(message = "周期长不能为空")
@NotBlank(message = "cycle不能为空")
private String cycle;
@ApiModelProperty(value = "相位差", notes = "相位差。需要优化的相位差,单位秒")
@NotBlank(message = "offset不能为空")
private String offset;
@ApiModelProperty(value = "优化模式", notes = "目前支持 Type=1(预案模式,按时间调整),Type=15(瓶颈模式,\n" +
"按比例调整)")
@NotBlank(message = "type不能为空")
private String type;
@ApiModelProperty(value = "比值", notes = "Type=1 时为预案模式,值为绿信比时间,Type=15 时为瓶颈模式,值为调整比例")
@ApiModelProperty(value = "绿信比时间", notes = "Type=1 时为预案模式,值为绿信比时间,Type=15 时为瓶颈模式,值为调整比例")
@NotBlank(message = "split不能为空")
private String split;
}
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