代码调整
This commit is contained in:
@@ -19,6 +19,7 @@ import io.swagger.annotations.ApiImplicitParam;
|
|||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -52,7 +53,7 @@ public class PreDetectionController extends BaseController {
|
|||||||
@OperateInfo
|
@OperateInfo
|
||||||
@ApiOperation("开始检测")
|
@ApiOperation("开始检测")
|
||||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||||
public HttpResult<String> startPreTest(@RequestBody PreDetectionParam param){
|
public HttpResult<String> startPreTest(@RequestBody @Validated PreDetectionParam param){
|
||||||
String methodDescribe = getMethodDescribe("startPreTest");
|
String methodDescribe = getMethodDescribe("startPreTest");
|
||||||
preDetectionService.sourceCommunicationCheck(param);
|
preDetectionService.sourceCommunicationCheck(param);
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
|||||||
@@ -164,6 +164,8 @@ public class SocketSourceResponseService {
|
|||||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||||
break;
|
break;
|
||||||
case SOURCE_CONNECTION_ERROR:
|
case SOURCE_CONNECTION_ERROR:
|
||||||
|
CnSocketUtil.quitSendSource(param);
|
||||||
|
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||||
case CONTROLLED_SOURCE_ERROR:
|
case CONTROLLED_SOURCE_ERROR:
|
||||||
CnSocketUtil.quitSendSource(param);
|
CnSocketUtil.quitSendSource(param);
|
||||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ public enum DetectionResponseEnum {
|
|||||||
PLAN_PATTERN_NOT("A020001", "计划模式查询为空"),
|
PLAN_PATTERN_NOT("A020001", "计划模式查询为空"),
|
||||||
SOURCE_INFO_NOT("A020002", "源表信息不存在"),
|
SOURCE_INFO_NOT("A020002", "源表信息不存在"),
|
||||||
PLAN_AND_SOURCE_NOT("A020003", "计划和源关系不存在"),
|
PLAN_AND_SOURCE_NOT("A020003", "计划和源关系不存在"),
|
||||||
ITEM_TEST_NOT("A020003", "检测项为空")
|
ITEM_TEST_NOT("A020004", "检测项为空"),
|
||||||
|
PLAN_DEV_IP_HAS("A20005","当前计划检测装置ip重复")
|
||||||
;
|
;
|
||||||
|
|
||||||
private final String code;
|
private final String code;
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package com.njcn.gather.detection.pojo.param;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -20,6 +22,7 @@ public class PreDetectionParam {
|
|||||||
/**
|
/**
|
||||||
* 检测计划id
|
* 检测计划id
|
||||||
*/
|
*/
|
||||||
|
@NotBlank(message = "计划id不可为空")
|
||||||
private String planId;
|
private String planId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,6 +43,7 @@ public class PreDetectionParam {
|
|||||||
/**
|
/**
|
||||||
* 检测终端id集合
|
* 检测终端id集合
|
||||||
*/
|
*/
|
||||||
|
@NotEmpty(message = "装置不能为空")
|
||||||
private List<String> devIds;
|
private List<String> devIds;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ import com.njcn.gather.detection.util.socket.FormalTestManager;
|
|||||||
import com.njcn.gather.detection.util.socket.SocketManager;
|
import com.njcn.gather.detection.util.socket.SocketManager;
|
||||||
import com.njcn.gather.detection.util.socket.cilent.NettyClient;
|
import com.njcn.gather.detection.util.socket.cilent.NettyClient;
|
||||||
import com.njcn.gather.detection.util.socket.cilent.NettySourceClientHandler;
|
import com.njcn.gather.detection.util.socket.cilent.NettySourceClientHandler;
|
||||||
|
import com.njcn.gather.device.pojo.enums.DevResponseEnum;
|
||||||
|
import com.njcn.gather.device.pojo.po.PqDev;
|
||||||
import com.njcn.gather.device.service.IPqDevService;
|
import com.njcn.gather.device.service.IPqDevService;
|
||||||
import com.njcn.gather.script.pojo.param.PqScriptCheckDataParam;
|
import com.njcn.gather.script.pojo.param.PqScriptCheckDataParam;
|
||||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||||
@@ -39,6 +41,7 @@ import org.springframework.stereotype.Service;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@@ -70,8 +73,8 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sourceCommunicationCheck(PreDetectionParam param) {
|
public void sourceCommunicationCheck(PreDetectionParam param) {
|
||||||
|
commCheck(param);
|
||||||
specialDeal(param);
|
specialDeal(param);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
先组装源通讯协议
|
先组装源通讯协议
|
||||||
查询计划什么模式的(除了对比式,其他都是一个计划对应一个源)
|
查询计划什么模式的(除了对比式,其他都是一个计划对应一个源)
|
||||||
@@ -152,7 +155,6 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean startTest(PreDetectionParam param) {
|
public boolean startTest(PreDetectionParam param) {
|
||||||
|
|
||||||
socketDevResponseService.initList(param);
|
socketDevResponseService.initList(param);
|
||||||
NettyClient.socketClient(ip, port, param, "start\n", new NettySourceClientHandler(param, sourceResponseService));
|
NettyClient.socketClient(ip, port, param, "start\n", new NettySourceClientHandler(param, sourceResponseService));
|
||||||
|
|
||||||
@@ -168,29 +170,6 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
|||||||
@Override
|
@Override
|
||||||
public boolean restartTemTest(PreDetectionParam param) {
|
public boolean restartTemTest(PreDetectionParam param) {
|
||||||
FormalTestManager.stopFlag = false;
|
FormalTestManager.stopFlag = false;
|
||||||
/* specialDeal(param);
|
|
||||||
AdPlanSource planSource = adPlanSourceService.getOne(new LambdaQueryWrapper<AdPlanSource>().eq(AdPlanSource::getPlanId, param.getPlanId()));
|
|
||||||
if (ObjectUtil.isNotNull(planSource)) {
|
|
||||||
SourceInitialize sourceParam = pqSourceService.getSourceInitializeParam(planSource.getSourceId());
|
|
||||||
if (Objects.isNull(sourceParam)) {
|
|
||||||
throw new BusinessException(DetectionResponseEnum.SOURCE_INFO_NOT);
|
|
||||||
}
|
|
||||||
param.setSourceId(sourceParam.getSourceId());
|
|
||||||
|
|
||||||
if (CollUtil.isNotEmpty(SocketManager.getSourceList())) {
|
|
||||||
//开始组装socket报文请求头
|
|
||||||
socketDevResponseService.initRestart();
|
|
||||||
SocketMsg<String> msg = new SocketMsg<>();
|
|
||||||
msg.setRequestId(SourceOperateCodeEnum.YJC_YTXJY.getValue());
|
|
||||||
msg.setOperateCode(SourceOperateCodeEnum.INIT_GATHER.getValue());
|
|
||||||
msg.setData(JSON.toJSONString(sourceParam));
|
|
||||||
NettyClient.socketClient(ip, port, param, JSON.toJSONString(msg), new NettySourceClientHandler(param, sourceResponseService));
|
|
||||||
} else {
|
|
||||||
throw new BusinessException(DetectionResponseEnum.ITEM_TEST_NOT);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw new BusinessException(DetectionResponseEnum.PLAN_AND_SOURCE_NOT);
|
|
||||||
}*/
|
|
||||||
List<SourceIssue> sourceIssueList = SocketManager.getSourceList();
|
List<SourceIssue> sourceIssueList = SocketManager.getSourceList();
|
||||||
if (CollUtil.isNotEmpty(sourceIssueList)) {
|
if (CollUtil.isNotEmpty(sourceIssueList)) {
|
||||||
SourceIssue sourceIssues = SocketManager.getSourceList().get(0);
|
SourceIssue sourceIssues = SocketManager.getSourceList().get(0);
|
||||||
@@ -213,6 +192,11 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对重复发起或者异常发起的检测进行关闭源操作
|
||||||
|
* @param param
|
||||||
|
*/
|
||||||
private void specialDeal(PreDetectionParam param) {
|
private void specialDeal(PreDetectionParam param) {
|
||||||
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + source);
|
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + source);
|
||||||
if (Objects.nonNull(channel) && channel.isActive()) {
|
if (Objects.nonNull(channel) && channel.isActive()) {
|
||||||
@@ -235,4 +219,16 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验
|
||||||
|
*/
|
||||||
|
private void commCheck(PreDetectionParam param){
|
||||||
|
List<PqDev> pqDevList = iPqDevService.listByIds(param.getDevIds());
|
||||||
|
List<String> ipList = pqDevList.stream().map(PqDev::getIp).distinct().collect(Collectors.toList());
|
||||||
|
if(ipList.size()!=param.getDevIds().size()){
|
||||||
|
throw new BusinessException(DetectionResponseEnum.PLAN_DEV_IP_HAS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user