Commit edffcbec authored by zhouleilei's avatar zhouleilei

控制指令添加异常捕获

parent e7f07544
...@@ -90,7 +90,12 @@ public class ControlCommandServiceImpl implements ControlCommandService { ...@@ -90,7 +90,12 @@ public class ControlCommandServiceImpl implements ControlCommandService {
messageContent.addElement(HttpConstants.COMMAND).setText("0"); messageContent.addElement(HttpConstants.COMMAND).setText("0");
} }
//相位驻留 //相位驻留
String xmlPost = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML()); String xmlPost = null;
try {
xmlPost = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML());
} catch (Exception e) {
throw new RuntimeException(e);
}
log.info("第一次锁相/解锁 海信返回msg:{}",xmlPost); log.info("第一次锁相/解锁 海信返回msg:{}",xmlPost);
/*String xmlPost = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + /*String xmlPost = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<systemScription System=\"TCIP\" Version=\"1.0\">\n" + "<systemScription System=\"TCIP\" Version=\"1.0\">\n" +
...@@ -110,8 +115,13 @@ public class ControlCommandServiceImpl implements ControlCommandService { ...@@ -110,8 +115,13 @@ public class ControlCommandServiceImpl implements ControlCommandService {
" </messageContent>\n" + " </messageContent>\n" +
"</systemScription>";*/ "</systemScription>";*/
if (StringUtils.isNotBlank(xmlPost)) { if (StringUtils.isNotBlank(xmlPost)) {
Document extendPost = DocumentHelper.parseText(xmlPost); String extendResult = null;
String extendResult = extendPost.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_RESULT).getText(); try {
Document extendPost = DocumentHelper.parseText(xmlPost);
extendResult = extendPost.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_RESULT).getText();
} catch (DocumentException e) {
throw new RuntimeException(e);
}
if (HttpConstants.RESULT_1.equals(extendResult) || HttpConstants.RESULT_2.equals(extendResult)) { if (HttpConstants.RESULT_1.equals(extendResult) || HttpConstants.RESULT_2.equals(extendResult)) {
if (commandVO.getCommand() == 1){ if (commandVO.getCommand() == 1){
Integer duration = commandVO.getDuration(); Integer duration = commandVO.getDuration();
...@@ -167,7 +177,12 @@ public class ControlCommandServiceImpl implements ControlCommandService { ...@@ -167,7 +177,12 @@ public class ControlCommandServiceImpl implements ControlCommandService {
//逻辑:第一次发送步进指令是相位驻留,以后发送才是相位步进,步进成功则取消步进。步进失败,也立即下发取消步进控制 //逻辑:第一次发送步进指令是相位驻留,以后发送才是相位步进,步进成功则取消步进。步进失败,也立即下发取消步进控制
//相位驻留 //相位驻留
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
String xmlPost = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML()); String xmlPost = null;
try {
xmlPost = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML());
} catch (Exception e) {
throw new RuntimeException(e);
}
long end = System.currentTimeMillis(); long end = System.currentTimeMillis();
log.info("相位驻留 耗时: {} ms,msg:{}", end - start,xmlPost); log.info("相位驻留 耗时: {} ms,msg:{}", end - start,xmlPost);
/*String xmlPost = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + /*String xmlPost = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
...@@ -189,14 +204,24 @@ public class ControlCommandServiceImpl implements ControlCommandService { ...@@ -189,14 +204,24 @@ public class ControlCommandServiceImpl implements ControlCommandService {
"</systemScription>";*/ "</systemScription>";*/
if (StringUtils.isNotBlank(xmlPost)) { if (StringUtils.isNotBlank(xmlPost)) {
Document extendPost = DocumentHelper.parseText(xmlPost); String extendResult = null;
String extendResult = extendPost.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_RESULT).getText(); try {
Document extendPost = DocumentHelper.parseText(xmlPost);
extendResult = extendPost.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_RESULT).getText();
} catch (DocumentException e) {
throw new RuntimeException(e);
}
if (HttpConstants.RESULT_1.equals(extendResult) || HttpConstants.RESULT_2.equals(extendResult)) { if (HttpConstants.RESULT_1.equals(extendResult) || HttpConstants.RESULT_2.equals(extendResult)) {
//开始步进 //开始步进
//给海信发送http请求 //给海信发送http请求
for (int i = 0; i < stepNum; i++) { for (int i = 0; i < stepNum; i++) {
long s = System.currentTimeMillis(); long s = System.currentTimeMillis();
String post = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML()); String post = null;
try {
post = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML());
} catch (Exception e) {
throw new RuntimeException(e);
}
long e = System.currentTimeMillis(); long e = System.currentTimeMillis();
log.info("相位步进 耗时: {} ms,msg:{}", e - s,post); log.info("相位步进 耗时: {} ms,msg:{}", e - s,post);
/*String post = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + /*String post = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
...@@ -217,8 +242,13 @@ public class ControlCommandServiceImpl implements ControlCommandService { ...@@ -217,8 +242,13 @@ public class ControlCommandServiceImpl implements ControlCommandService {
" </messageContent>\n" + " </messageContent>\n" +
"</systemScription>";*/ "</systemScription>";*/
if (StringUtils.isNotBlank(post)) { if (StringUtils.isNotBlank(post)) {
Document postResult = DocumentHelper.parseText(post); String result = null;
String result = postResult.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_RESULT).getText(); try {
Document postResult = DocumentHelper.parseText(post);
result = postResult.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_RESULT).getText();
} catch (DocumentException ex) {
throw new RuntimeException(ex);
}
if (HttpConstants.RESULT_1.equals(result) || HttpConstants.RESULT_2.equals(result)) { if (HttpConstants.RESULT_1.equals(result) || HttpConstants.RESULT_2.equals(result)) {
log.info("路口号 :{},第 {} 次步进成功,result:{}", code, i + 1, result); log.info("路口号 :{},第 {} 次步进成功,result:{}", code, i + 1, result);
} else { } else {
...@@ -459,7 +489,12 @@ public class ControlCommandServiceImpl implements ControlCommandService { ...@@ -459,7 +489,12 @@ public class ControlCommandServiceImpl implements ControlCommandService {
messageContent.addElement(HttpConstants.PATTERN).setText("0"); messageContent.addElement(HttpConstants.PATTERN).setText("0");
//给海信发送http请求 //给海信发送http请求
String post = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML()); String post = null;
try {
post = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML());
} catch (Exception e) {
throw new RuntimeException(e);
}
/*String post = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + /*String post = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<systemScription System=\"TCIP\" Version=\"1.0\">\n" + "<systemScription System=\"TCIP\" Version=\"1.0\">\n" +
" <subSystem>Hisense</subSystem>\n" + " <subSystem>Hisense</subSystem>\n" +
...@@ -482,8 +517,13 @@ public class ControlCommandServiceImpl implements ControlCommandService { ...@@ -482,8 +517,13 @@ public class ControlCommandServiceImpl implements ControlCommandService {
log.error(" 手动方案控制- 恢复固定配时 失败"); log.error(" 手动方案控制- 恢复固定配时 失败");
return jsonViewObject.fail(" 手动方案控制- 恢复固定配时 失败"); return jsonViewObject.fail(" 手动方案控制- 恢复固定配时 失败");
} }
Document postResult = DocumentHelper.parseText(post); String result = null;
String result = postResult.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_RESULT).getText(); try {
Document postResult = DocumentHelper.parseText(post);
result = postResult.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_RESULT).getText();
} catch (DocumentException e) {
throw new RuntimeException(e);
}
if (HttpConstants.RESULT_1.equals(result)) { if (HttpConstants.RESULT_1.equals(result)) {
//指令下发成功 //指令下发成功
...@@ -529,7 +569,12 @@ public class ControlCommandServiceImpl implements ControlCommandService { ...@@ -529,7 +569,12 @@ public class ControlCommandServiceImpl implements ControlCommandService {
messageContent.addElement(HttpConstants.SPLIT).setText(tempSchemeSendVO.getSplit().replaceAll(" ", ",")); messageContent.addElement(HttpConstants.SPLIT).setText(tempSchemeSendVO.getSplit().replaceAll(" ", ","));
//给海信发送http请求 //给海信发送http请求
String post = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML()); String post = null;
try {
post = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML());
} catch (Exception e) {
throw new RuntimeException(e);
}
/*String post = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + /*String post = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<systemScription System=\"TCIP\" Version=\"1.0\">\n" + "<systemScription System=\"TCIP\" Version=\"1.0\">\n" +
" <subSystem>Hisense</subSystem>\n" + " <subSystem>Hisense</subSystem>\n" +
...@@ -552,8 +597,13 @@ public class ControlCommandServiceImpl implements ControlCommandService { ...@@ -552,8 +597,13 @@ public class ControlCommandServiceImpl implements ControlCommandService {
log.error("HTTP请求 5.16. 方案优化控制 失败"); log.error("HTTP请求 5.16. 方案优化控制 失败");
return jsonViewObject.fail("HTTP请求 5.16. 方案优化控制 失败"); return jsonViewObject.fail("HTTP请求 5.16. 方案优化控制 失败");
} }
Document postResult = DocumentHelper.parseText(post); String result = null;
String result = postResult.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_RESULT).getText(); try {
Document postResult = DocumentHelper.parseText(post);
result = postResult.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_RESULT).getText();
} catch (DocumentException e) {
throw new RuntimeException(e);
}
if (HttpConstants.RESULT_1.equals(result)) { if (HttpConstants.RESULT_1.equals(result)) {
//指令下发成功 //指令下发成功
...@@ -728,7 +778,12 @@ public class ControlCommandServiceImpl implements ControlCommandService { ...@@ -728,7 +778,12 @@ public class ControlCommandServiceImpl implements ControlCommandService {
messageContent.addElement(HttpConstants.CTRLSTEP).setText("0"); messageContent.addElement(HttpConstants.CTRLSTEP).setText("0");
//给海信发送http请求 //给海信发送http请求
String post = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML()); String post = null;
try {
post = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML());
} catch (Exception e) {
throw new RuntimeException(e);
}
/*String post = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + /*String post = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<systemScription System=\"TCIP\" Version=\"1.0\">\n" + "<systemScription System=\"TCIP\" Version=\"1.0\">\n" +
" <subSystem>Hisense</subSystem>\n" + " <subSystem>Hisense</subSystem>\n" +
...@@ -751,8 +806,13 @@ public class ControlCommandServiceImpl implements ControlCommandService { ...@@ -751,8 +806,13 @@ public class ControlCommandServiceImpl implements ControlCommandService {
log.error("HTTP请求 5.12. 步进及取消控制 失败"); log.error("HTTP请求 5.12. 步进及取消控制 失败");
return jsonViewObject.fail("HTTP请求 5.12. 步进及取消控制 失败"); return jsonViewObject.fail("HTTP请求 5.12. 步进及取消控制 失败");
} }
Document postResult = DocumentHelper.parseText(post); String result = null;
String result = postResult.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_RESULT).getText(); try {
Document postResult = DocumentHelper.parseText(post);
result = postResult.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_RESULT).getText();
} catch (DocumentException e) {
throw new RuntimeException(e);
}
if (HttpConstants.RESULT_1.equals(result) || HttpConstants.RESULT_2.equals(result)) { if (HttpConstants.RESULT_1.equals(result) || HttpConstants.RESULT_2.equals(result)) {
//执行成功,开始延长 //执行成功,开始延长
...@@ -760,7 +820,12 @@ public class ControlCommandServiceImpl implements ControlCommandService { ...@@ -760,7 +820,12 @@ public class ControlCommandServiceImpl implements ControlCommandService {
//延长结束,解除步进 //延长结束,解除步进
messageContent.selectSingleNode(HttpConstants.COMMAND).setText("0"); messageContent.selectSingleNode(HttpConstants.COMMAND).setText("0");
//给海信发送http请求 //给海信发送http请求
String post1 = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML()); String post1 = null;
try {
post1 = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML());
} catch (Exception e) {
throw new RuntimeException(e);
}
/*String post1 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + /*String post1 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<systemScription System=\"TCIP\" Version=\"1.0\">\n" + "<systemScription System=\"TCIP\" Version=\"1.0\">\n" +
" <subSystem>Hisense</subSystem>\n" + " <subSystem>Hisense</subSystem>\n" +
...@@ -779,8 +844,13 @@ public class ControlCommandServiceImpl implements ControlCommandService { ...@@ -779,8 +844,13 @@ public class ControlCommandServiceImpl implements ControlCommandService {
" </messageContent>\n" + " </messageContent>\n" +
"</systemScription>";*/ "</systemScription>";*/
if (StringUtils.isNotBlank(post1)) { if (StringUtils.isNotBlank(post1)) {
Document extendPost = DocumentHelper.parseText(post1); String extendResult = null;
String extendResult = extendPost.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_RESULT).getText(); try {
Document extendPost = DocumentHelper.parseText(post1);
extendResult = extendPost.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_RESULT).getText();
} catch (DocumentException e) {
throw new RuntimeException(e);
}
if (HttpConstants.RESULT_1.equals(extendResult) || HttpConstants.RESULT_2.equals(extendResult)) { if (HttpConstants.RESULT_1.equals(extendResult) || HttpConstants.RESULT_2.equals(extendResult)) {
return jsonViewObject.success("延长相位 - 控制成功"); return jsonViewObject.success("延长相位 - 控制成功");
} }
...@@ -789,7 +859,12 @@ public class ControlCommandServiceImpl implements ControlCommandService { ...@@ -789,7 +859,12 @@ public class ControlCommandServiceImpl implements ControlCommandService {
log.error("HTTP请求 5.12. 步进及取消控制 失败"); log.error("HTTP请求 5.12. 步进及取消控制 失败");
//重新发起三次取消控制请求 //重新发起三次取消控制请求
for (int j = 0; j < 3; j++) { for (int j = 0; j < 3; j++) {
String httpPost = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML()); String httpPost = null;
try {
httpPost = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML());
} catch (Exception e) {
throw new RuntimeException(e);
}
/*String httpPost = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + /*String httpPost = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<systemScription System=\"TCIP\" Version=\"1.0\">\n" + "<systemScription System=\"TCIP\" Version=\"1.0\">\n" +
" <subSystem>Hisense</subSystem>\n" + " <subSystem>Hisense</subSystem>\n" +
...@@ -808,8 +883,13 @@ public class ControlCommandServiceImpl implements ControlCommandService { ...@@ -808,8 +883,13 @@ public class ControlCommandServiceImpl implements ControlCommandService {
" </messageContent>\n" + " </messageContent>\n" +
"</systemScription>";*/ "</systemScription>";*/
if (StringUtils.isNotBlank(httpPost)) { if (StringUtils.isNotBlank(httpPost)) {
Document extendPost = DocumentHelper.parseText(httpPost); String extendResult = null;
String extendResult = extendPost.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_RESULT).getText(); try {
Document extendPost = DocumentHelper.parseText(httpPost);
extendResult = extendPost.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_RESULT).getText();
} catch (DocumentException e) {
throw new RuntimeException(e);
}
if (HttpConstants.RESULT_1.equals(extendResult) || HttpConstants.RESULT_2.equals(extendResult)) { if (HttpConstants.RESULT_1.equals(extendResult) || HttpConstants.RESULT_2.equals(extendResult)) {
return jsonViewObject.success("延长相位 - 控制成功"); return jsonViewObject.success("延长相位 - 控制成功");
} }
...@@ -821,10 +901,20 @@ public class ControlCommandServiceImpl implements ControlCommandService { ...@@ -821,10 +901,20 @@ public class ControlCommandServiceImpl implements ControlCommandService {
messageContent.selectSingleNode(HttpConstants.COMMAND).setText("0"); messageContent.selectSingleNode(HttpConstants.COMMAND).setText("0");
//重新发起三次取消控制请求 //重新发起三次取消控制请求
for (int j = 0; j < 3; j++) { for (int j = 0; j < 3; j++) {
String httpPost = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML()); String httpPost = null;
try {
httpPost = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML());
} catch (Exception e) {
throw new RuntimeException(e);
}
if (StringUtils.isNotBlank(httpPost)) { if (StringUtils.isNotBlank(httpPost)) {
Document extendPost = DocumentHelper.parseText(httpPost); String extendResult = null;
String extendResult = extendPost.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_RESULT).getText(); try {
Document extendPost = DocumentHelper.parseText(httpPost);
extendResult = extendPost.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_RESULT).getText();
} catch (DocumentException e) {
throw new RuntimeException(e);
}
if (HttpConstants.RESULT_1.equals(extendResult) || HttpConstants.RESULT_2.equals(extendResult)) { if (HttpConstants.RESULT_1.equals(extendResult) || HttpConstants.RESULT_2.equals(extendResult)) {
return jsonViewObject.success("延长相位 - 控制成功"); return jsonViewObject.success("延长相位 - 控制成功");
} }
...@@ -864,7 +954,12 @@ public class ControlCommandServiceImpl implements ControlCommandService { ...@@ -864,7 +954,12 @@ public class ControlCommandServiceImpl implements ControlCommandService {
} else if (stepingPhaseDTO.getCommand() == 1) { } else if (stepingPhaseDTO.getCommand() == 1) {
//逻辑:第一次发送步进指令是相位驻留,以后发送才是相位步进,步进成功则取消步进。步进失败,也立即下发取消步进控制 //逻辑:第一次发送步进指令是相位驻留,以后发送才是相位步进,步进成功则取消步进。步进失败,也立即下发取消步进控制
//相位驻留 //相位驻留
String xmlPost = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML()); String xmlPost = null;
try {
xmlPost = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML());
} catch (Exception e) {
throw new RuntimeException(e);
}
/* String xmlPost = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + /* String xmlPost = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<systemScription System=\"TCIP\" Version=\"1.0\">\n" + "<systemScription System=\"TCIP\" Version=\"1.0\">\n" +
" <subSystem>Hisense</subSystem>\n" + " <subSystem>Hisense</subSystem>\n" +
...@@ -884,13 +979,23 @@ public class ControlCommandServiceImpl implements ControlCommandService { ...@@ -884,13 +979,23 @@ public class ControlCommandServiceImpl implements ControlCommandService {
"</systemScription>";*/ "</systemScription>";*/
if (StringUtils.isNotBlank(xmlPost)) { if (StringUtils.isNotBlank(xmlPost)) {
Document extendPost = DocumentHelper.parseText(xmlPost); String extendResult = null;
String extendResult = extendPost.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_RESULT).getText(); try {
Document extendPost = DocumentHelper.parseText(xmlPost);
extendResult = extendPost.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_RESULT).getText();
} catch (DocumentException e) {
throw new RuntimeException(e);
}
if (HttpConstants.RESULT_1.equals(extendResult) || HttpConstants.RESULT_2.equals(extendResult)) { if (HttpConstants.RESULT_1.equals(extendResult) || HttpConstants.RESULT_2.equals(extendResult)) {
//开始步进 //开始步进
//给海信发送http请求 //给海信发送http请求
for (int i = 0; i < stepingPhaseDTO.getStepCount(); i++) { for (int i = 0; i < stepingPhaseDTO.getStepCount(); i++) {
String post = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML()); String post = null;
try {
post = OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML());
} catch (Exception e) {
throw new RuntimeException(e);
}
/*String post = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + /*String post = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<systemScription System=\"TCIP\" Version=\"1.0\">\n" + "<systemScription System=\"TCIP\" Version=\"1.0\">\n" +
" <subSystem>Hisense</subSystem>\n" + " <subSystem>Hisense</subSystem>\n" +
...@@ -909,8 +1014,13 @@ public class ControlCommandServiceImpl implements ControlCommandService { ...@@ -909,8 +1014,13 @@ public class ControlCommandServiceImpl implements ControlCommandService {
" </messageContent>\n" + " </messageContent>\n" +
"</systemScription>";*/ "</systemScription>";*/
if (StringUtils.isNotBlank(post)) { if (StringUtils.isNotBlank(post)) {
Document postResult = DocumentHelper.parseText(post); String result = null;
String result = postResult.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_RESULT).getText(); try {
Document postResult = DocumentHelper.parseText(post);
result = postResult.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_RESULT).getText();
} catch (DocumentException e) {
throw new RuntimeException(e);
}
if (HttpConstants.RESULT_1.equals(result) || HttpConstants.RESULT_2.equals(result)) { if (HttpConstants.RESULT_1.equals(result) || HttpConstants.RESULT_2.equals(result)) {
log.info("路口号 :{},第 {} 次步进成功,result:{}", stepingPhaseDTO.getCrossId(), i + 1, result); log.info("路口号 :{},第 {} 次步进成功,result:{}", stepingPhaseDTO.getCrossId(), i + 1, result);
} else { } else {
...@@ -958,20 +1068,35 @@ public class ControlCommandServiceImpl implements ControlCommandService { ...@@ -958,20 +1068,35 @@ public class ControlCommandServiceImpl implements ControlCommandService {
} }
private boolean sendMesIsOk(String xml) throws DocumentException, InterruptedException { private boolean sendMesIsOk(String xml) throws DocumentException, InterruptedException {
String post = OkHttpClientUtil.xmlPost(hisenseUrl, xml); String post = null;
try {
post = OkHttpClientUtil.xmlPost(hisenseUrl, xml);
} catch (Exception e) {
throw new RuntimeException(e);
}
if (StringUtils.isBlank(post)) { if (StringUtils.isBlank(post)) {
return false; return false;
} }
Document postResult = DocumentHelper.parseText(post); Document postResult = null;
String result = postResult.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_RESULT).getText(); String result = null;
try {
postResult = DocumentHelper.parseText(post);
result = postResult.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_RESULT).getText();
} catch (DocumentException e) {
throw new RuntimeException(e);
}
if (HttpConstants.RESULT_1.equals(result) || HttpConstants.RESULT_2.equals(result)) { if (HttpConstants.RESULT_1.equals(result) || HttpConstants.RESULT_2.equals(result)) {
return true; return true;
} else { } else {
//连续重试发三次 //连续重试发三次
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
post = OkHttpClientUtil.xmlPost(hisenseUrl, xml); try {
postResult = DocumentHelper.parseText(post); post = OkHttpClientUtil.xmlPost(hisenseUrl, xml);
result = postResult.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_RESULT).getText(); postResult = DocumentHelper.parseText(post);
result = postResult.selectSingleNode(HttpConstants.SYSTEMSCRIPTION_RESULT).getText();
} catch (DocumentException e) {
throw new RuntimeException(e);
}
if (HttpConstants.RESULT_1.equals(result) || HttpConstants.RESULT_2.equals(result)) { if (HttpConstants.RESULT_1.equals(result) || HttpConstants.RESULT_2.equals(result)) {
return true; return true;
} }
......
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