|
@@ -15,6 +15,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.net.InetAddress;
|
|
import java.net.InetAddress;
|
|
import java.net.UnknownHostException;
|
|
import java.net.UnknownHostException;
|
|
|
|
+import java.text.MessageFormat;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
|
|
|
|
@@ -127,7 +128,6 @@ public class CommCheckService {
|
|
}
|
|
}
|
|
//
|
|
//
|
|
socketService.tryOpenAll();
|
|
socketService.tryOpenAll();
|
|
- //
|
|
|
|
int retryTotalCount;
|
|
int retryTotalCount;
|
|
if (important) {
|
|
if (important) {
|
|
retryTotalCount = CommConst.RETRY_COUNT_WHICH_SIM_IMPORTANT;
|
|
retryTotalCount = CommConst.RETRY_COUNT_WHICH_SIM_IMPORTANT;
|
|
@@ -149,13 +149,18 @@ public class CommCheckService {
|
|
seatService.updateSimIdBySeatNum(seat.getSeatNum(), sim.getSimId());
|
|
seatService.updateSimIdBySeatNum(seat.getSeatNum(), sim.getSimId());
|
|
// 更新Sim状态
|
|
// 更新Sim状态
|
|
simService.updateSimStateBySimId(sim.getSimId(), Sim.State.ONLINE);
|
|
simService.updateSimStateBySimId(sim.getSimId(), Sim.State.ONLINE);
|
|
- return AjaxResult.success("成功,检查一个座次[" + seat.getSeatNum() + "]OK!模拟器[" + sim.getSimNum() + "]在线。");
|
|
|
|
|
|
+
|
|
|
|
+ String msgTemp = "座号[{0}]-模拟器[{1}]型[{2}]在线";
|
|
|
|
+ String msg = MessageFormat.format(msgTemp, seat.getSeatNum(), Sim.TYPE_NAME_MAP.get(sim.getSimType()), sim.getSimNum());
|
|
|
|
+ return AjaxResult.success(msg);
|
|
} else if (Objects.equals(result, SimMsg.Result.RECEIVE_CHECK_FAIL)) {
|
|
} else if (Objects.equals(result, SimMsg.Result.RECEIVE_CHECK_FAIL)) {
|
|
return AjaxResult.error("失败,报文回复异常。");
|
|
return AjaxResult.error("失败,报文回复异常。");
|
|
} else if (Objects.equals(result, SimMsg.Result.SOCKET_EXCEPTION)) {
|
|
} else if (Objects.equals(result, SimMsg.Result.SOCKET_EXCEPTION)) {
|
|
// 更新SimId
|
|
// 更新SimId
|
|
seatService.updateSimIdBySeatNum(seat.getSeatNum(), Sim.ID_0);
|
|
seatService.updateSimIdBySeatNum(seat.getSeatNum(), Sim.ID_0);
|
|
- return AjaxResult.success("成功,检查一个座次[" + seat.getSeatNum() + "]OK!未连接模拟器。");
|
|
|
|
|
|
+ String msgTemp = "座号[{0}]-没有连接任何接模拟器,检查线缆连接和线缆开关";
|
|
|
|
+ String msg = MessageFormat.format(msgTemp, seat.getSeatNum());
|
|
|
|
+ return AjaxResult.success(msg);
|
|
}
|
|
}
|
|
return AjaxResult.error("失败");
|
|
return AjaxResult.error("失败");
|
|
}
|
|
}
|
|
@@ -168,6 +173,9 @@ public class CommCheckService {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public AjaxResult checkOneSimOnlineState(final Long simId) {
|
|
public AjaxResult checkOneSimOnlineState(final Long simId) {
|
|
|
|
+ if (simId == null || simId <= 0) {
|
|
|
|
+ return AjaxResult.error("没有连接任何接模拟器,<br>检查线缆连接和线缆开关!");
|
|
|
|
+ }
|
|
Sim sim = simService.selectSimBySimId(simId);
|
|
Sim sim = simService.selectSimBySimId(simId);
|
|
if (sim != null) {
|
|
if (sim != null) {
|
|
switch (sim.getSimState()) {
|
|
switch (sim.getSimState()) {
|
|
@@ -206,7 +214,7 @@ public class CommCheckService {
|
|
return AjaxResult.error("模拟器ID[" + seat.getCurrentSimId() + "]不存在!");
|
|
return AjaxResult.error("模拟器ID[" + seat.getCurrentSimId() + "]不存在!");
|
|
}
|
|
}
|
|
//
|
|
//
|
|
- final String msgError = "连接模拟器类型或序列号不正确!应该连接型号:";
|
|
|
|
|
|
+ final String msgErrorTemp = "连接模拟器类型或序列号不正确!<br>应该连接模拟器型号:<br>";
|
|
final String msgOk = "连接模拟器类型或序列号正确!";
|
|
final String msgOk = "连接模拟器类型或序列号正确!";
|
|
int retryTotalCount;
|
|
int retryTotalCount;
|
|
if (important) {
|
|
if (important) {
|
|
@@ -224,21 +232,21 @@ public class CommCheckService {
|
|
if (content.startsWith(CommConst.TYPE_0001_SN_PREFIX) && content.endsWith(sim.getSimNum())) {
|
|
if (content.startsWith(CommConst.TYPE_0001_SN_PREFIX) && content.endsWith(sim.getSimNum())) {
|
|
return AjaxResult.success(msgOk);
|
|
return AjaxResult.success(msgOk);
|
|
} else {
|
|
} else {
|
|
- return AjaxResult.error(msgError + Sim.TYPE_NAME_MAP.get(targetSimType));
|
|
|
|
|
|
+ return AjaxResult.error(msgErrorTemp + Sim.TYPE_NAME_MAP.get(targetSimType));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
case Sim.TYPE_0002 -> {
|
|
case Sim.TYPE_0002 -> {
|
|
if (content.startsWith(CommConst.TYPE_0002_SN_PREFIX) && content.endsWith(sim.getSimNum())) {
|
|
if (content.startsWith(CommConst.TYPE_0002_SN_PREFIX) && content.endsWith(sim.getSimNum())) {
|
|
return AjaxResult.success(msgOk);
|
|
return AjaxResult.success(msgOk);
|
|
} else {
|
|
} else {
|
|
- return AjaxResult.error(msgError + Sim.TYPE_NAME_MAP.get(targetSimType));
|
|
|
|
|
|
+ return AjaxResult.error(msgErrorTemp + Sim.TYPE_NAME_MAP.get(targetSimType));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
case Sim.TYPE_0003 -> {
|
|
case Sim.TYPE_0003 -> {
|
|
if (content.startsWith(CommConst.TYPE_0003_SN_PREFIX) && content.endsWith(sim.getSimNum())) {
|
|
if (content.startsWith(CommConst.TYPE_0003_SN_PREFIX) && content.endsWith(sim.getSimNum())) {
|
|
return AjaxResult.success(msgOk);
|
|
return AjaxResult.success(msgOk);
|
|
} else {
|
|
} else {
|
|
- return AjaxResult.error(msgError + Sim.TYPE_NAME_MAP.get(targetSimType));
|
|
|
|
|
|
+ return AjaxResult.error(msgErrorTemp + Sim.TYPE_NAME_MAP.get(targetSimType));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
default -> throw new IllegalStateException("Unexpected value: " + targetSimType);
|
|
default -> throw new IllegalStateException("Unexpected value: " + targetSimType);
|