程控源调整
This commit is contained in:
@@ -106,12 +106,24 @@ public class PreDetectionController extends BaseController {
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<?> startTestSimulate(@RequestBody @Validated SimulateDetectionParam param) {
|
||||
String methodDescribe = getMethodDescribe("startTestSimulate");
|
||||
HttpResult<DetectionLockHolderVO> busy = requireHolderSelf();
|
||||
// ContrastDetectionParam 无 userPageId 字段,用 loginName 作为会话标识(与 WS 会话 key 一致)
|
||||
HttpResult<DetectionLockHolderVO> busy = tryAcquireLock(param.getUserPageId());
|
||||
if (busy != null) {
|
||||
return busy;
|
||||
}
|
||||
preDetectionService.sendScript(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
// 同步阶段抛异常时回滚锁,理由同 startPreTest
|
||||
boolean keepLock = false;
|
||||
try {
|
||||
FormalTestManager.stopTime = 0;
|
||||
FormalTestManager.hasStopFlag = false;
|
||||
preDetectionService.sendScript(param);
|
||||
keepLock = true;
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} finally {
|
||||
if (!keepLock) {
|
||||
releaseLockSelf("START_CONTRAST_SYNC_FAILED");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -121,6 +121,15 @@ public class SocketSourceResponseService {
|
||||
sendErrorAndQuit(param, socketDataMsg, errorCode.getMessage());
|
||||
}
|
||||
|
||||
private void sendSimulateInitFailure(PreDetectionParam param, String errorMessage) {
|
||||
SocketDataMsg socketDataMsg = new SocketDataMsg();
|
||||
socketDataMsg.setRequestId(SourceOperateCodeEnum.YJC_YTXJY.getValue());
|
||||
socketDataMsg.setOperateCode(SourceOperateCodeEnum.INIT_GATHER.getValue());
|
||||
socketDataMsg.setCode(SourceResponseCodeEnum.UNKNOWN_ERROR.getCode());
|
||||
socketDataMsg.setData(errorMessage);
|
||||
sendWebSocketMessage(param.getUserPageId(), socketDataMsg);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 当前检测会话中的设备列表
|
||||
@@ -214,12 +223,12 @@ public class SocketSourceResponseService {
|
||||
break;
|
||||
|
||||
default:
|
||||
// TODO: 记录未知操作码到日志,并向前端发送友好提示
|
||||
sendSimulateInitFailure(param, "未知操作码");
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// TODO: 向前端发送错误提示
|
||||
log.error("程控源响应消息操作码解析失败,原始消息: {}, 解析结果: {}", msg, enumByCode);
|
||||
sendSimulateInitFailure(param, "未知操作码");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,10 +281,11 @@ public class SocketSourceResponseService {
|
||||
sendWebSocketMessage(param.getUserPageId(), socketDataMsg);
|
||||
break;
|
||||
default:
|
||||
// 未识别的响应码:发送通用错误消息
|
||||
WebServiceManager.sendUnknownErrorMessage(param.getUserPageId());
|
||||
sendSimulateInitFailure(param, "未知状态码");
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
sendSimulateInitFailure(param, "未知状态码");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -223,6 +223,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
private void sendYtxSocketSimulate(PreDetectionParam param) {
|
||||
SourceInitialize sourceParam = pqSourceService.getSourceInitializeParam(param.getSourceId());
|
||||
param.setSourceId(sourceParam.getSourceId());
|
||||
param.setSourceName(sourceParam.getSourceId());
|
||||
String loginName = RequestUtil.getLoginNameByToken();
|
||||
WebServiceManager.addPreDetectionParam(loginName, param);
|
||||
if (ObjectUtil.isNotNull(sourceParam)) {
|
||||
|
||||
@@ -90,7 +90,7 @@ public class NettySourceClientHandler extends SimpleChannelInboundHandler<String
|
||||
}
|
||||
|
||||
String userId = webUser.getUserPageId();
|
||||
log.debug("源设备接收服务端数据, userId: {}, message: {}", userId, msg);
|
||||
log.info("source接收server端数据, userId: {}, message: {}", userId, msg);
|
||||
|
||||
try {
|
||||
// 委托给专门的响应处理服务处理业务逻辑
|
||||
|
||||
Reference in New Issue
Block a user