This commit is contained in:
caozehui
2025-03-07 14:30:02 +08:00
parent 1f5916e898
commit 2261a786a4
3 changed files with 63 additions and 18 deletions

View File

@@ -65,7 +65,7 @@ public class PreDetectionController extends BaseController {
@PostMapping("/ytxCheckSimulate")
@OperateInfo
@ApiOperation("模拟检测-通讯校验")
@ApiOperation("模拟检测-通讯校验")
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
public HttpResult<String> ytxCheckSimulate(@RequestBody @Validated SimulateDetectionParam param) {
String methodDescribe = getMethodDescribe("ytxCheckSimulate");
@@ -78,7 +78,7 @@ public class PreDetectionController extends BaseController {
*/
@PostMapping("/startSimulateTest")
@OperateInfo
@ApiOperation("模拟检测")
@ApiOperation("模拟检测-下发脚本")
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
public HttpResult<String> startTestSimulate(@RequestBody @Validated SimulateDetectionParam param) {
String methodDescribe = getMethodDescribe("startTestSimulate");
@@ -91,7 +91,7 @@ public class PreDetectionController extends BaseController {
*/
@PostMapping("/closeSimulateTest")
@OperateInfo
@ApiOperation("停止模拟检测")
@ApiOperation("模拟检测-停止")
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
public HttpResult<String> closeSimulateTest(@RequestBody @Validated SimulateDetectionParam param) {
String methodDescribe = getMethodDescribe("closeSimulateTest");

View File

@@ -64,7 +64,7 @@ public class SocketSourceResponseService {
if (ObjectUtil.isNotNull(param.getPlanId())) {
detectionDev(param, socketDataMsg);
} else {
System.out.println("模拟检测-源初始化成功");
handleYtxjySimulate(param, socketDataMsg);
}
break;
//相序检测
@@ -94,6 +94,57 @@ public class SocketSourceResponseService {
}
}
private void handleYtxjySimulate(PreDetectionParam param, SocketDataMsg socketDataMsg) {
SourceResponseCodeEnum dictDataEnumByCode = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode());
if (ObjectUtil.isNotNull(dictDataEnumByCode)) {
switch (dictDataEnumByCode) {
case SUCCESS:
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
System.out.println("模拟检测-源初始化成功");
break;
case UNPROCESSED_BUSINESS:
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
break;
case SOURCE_CONNECTION_ERROR:
CnSocketUtil.quitSendSource(param);
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
break;
case CONTROLLED_SOURCE_ERROR:
CnSocketUtil.quitSendSource(param);
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
break;
case TEST_ITEM_PARSING_ERROR:
CnSocketUtil.quitSendSource(param);
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
break;
case SOURCE_CONTROL_ERROR:
CnSocketUtil.quitSendSource(param);
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
break;
case TARGET_SOURCE_ERROR:
CnSocketUtil.quitSendSource(param);
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
break;
case NOT_INITIALIZED:
CnSocketUtil.quitSendSource(param);
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
break;
case UNKNOWN_ERROR:
CnSocketUtil.quitSendSource(param);
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
break;
case UNABLE_TO_RESPOND:
CnSocketUtil.quitSendSource(param);
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
break;
default:
CnSocketUtil.sendUnSocket(param.getUserPageId());
break;
}
}
}
/**
* 处理模拟检测时,通信模块返回报文
*

View File

@@ -159,12 +159,6 @@ public class PreDetectionServiceImpl implements PreDetectionService {
}
private void sendYtxSocketSimulate(PreDetectionParam param) {
//AdPlan plan = iAdPlanService.getById(param.getPlanId());
//AdPlanSource planSource = adPlanSourceService.getOne(new LambdaQueryWrapper<AdPlanSource>().eq(AdPlanSource::getPlanId, param.getPlanId()));
//param.setSourceId(planSource.getSourceId());
//param.setScriptId(plan.getScriptId());
//param.setErrorSysId(plan.getErrorSysId());
//param.setCode(String.valueOf(plan.getCode()));
SourceInitialize sourceParam = pqSourceService.getSourceInitializeParam(param.getSourceId());
param.setSourceId(sourceParam.getSourceId());
WebServiceManager.addPreDetectionParam(param);
@@ -248,14 +242,14 @@ public class PreDetectionServiceImpl implements PreDetectionService {
@Override
public void sendScript(SimulateDetectionParam param) {
// Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + source);
// if (Objects.isNull(channel) || !channel.isActive()) {
// // 进行源通信连接
// PreDetectionParam preDetectionParam = new PreDetectionParam();
// preDetectionParam.setSourceId(param.getSourceId());
// preDetectionParam.setUserPageId(param.getUserPageId());
// this.sendYtxSocketSimulate(preDetectionParam);
// }
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + source);
if (Objects.isNull(channel) || !channel.isActive()) {
// 进行源通信连接
PreDetectionParam preDetectionParam = new PreDetectionParam();
preDetectionParam.setSourceId(param.getSourceId());
preDetectionParam.setUserPageId(param.getUserPageId());
this.sendYtxSocketSimulate(preDetectionParam);
}
//组装源控制脚本
PqScriptIssueParam issueParam = new PqScriptIssueParam();
//issueParam.setPlanId(param.getPlanId());