代码调整

This commit is contained in:
caozehui
2025-04-01 09:50:53 +08:00
parent 00bda55ddd
commit 9b1b21dad5
9 changed files with 43 additions and 47 deletions

View File

@@ -149,32 +149,32 @@ public class PreDetectionController extends BaseController {
/**
* 测试
*/
@PostMapping("/startTest")
@OperateInfo
@ApiOperation("测试")
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
public HttpResult<String> startTest(@RequestBody PreDetectionParam param) {
String methodDescribe = getMethodDescribe("startTest");
//preDetectionService.startTest(param);
List<PreDetection> pqDevList = iPqDevService.getDevInfo(param.getDevIds());
XiNumberManager.xiDevList = pqDevList;
String s = param.getUserPageId() + "_Dev";
SocketMsg<String> socketMsg = new SocketMsg<>();
socketMsg.setRequestId(SourceOperateCodeEnum.Coefficient_Check.getValue());
socketMsg.setOperateCode(SourceOperateCodeEnum.DATA_CHNFACTOR$01.getValue());
PreDetection preDetection = pqDevList.get(0);
Map<String, Object> map = new HashMap<>();
map.put("devIP", preDetection.getDevIP());
map.put("chnNum", preDetection.getDevChns());
socketMsg.setData(JSON.toJSONString(map));
NettyClient.socketClient("192.168.1.138", 61000, param, JSON.toJSONString(socketMsg), new NettyDevClientHandler(param, socketDevResponseService));
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
// @PostMapping("/startTest")
// @OperateInfo
// @ApiOperation("测试")
// @ApiImplicitParam(name = "param", value = "查询参数", required = true)
// public HttpResult<String> startTest(@RequestBody PreDetectionParam param) {
// String methodDescribe = getMethodDescribe("startTest");
// //preDetectionService.startTest(param);
//
//
// List<PreDetection> pqDevList = iPqDevService.getDevInfo(param.getDevIds());
// XiNumberManager.xiDevList = pqDevList;
// String s = param.getUserPageId() + "_Dev";
// SocketMsg<String> socketMsg = new SocketMsg<>();
// socketMsg.setRequestId(SourceOperateCodeEnum.Coefficient_Check.getValue());
// socketMsg.setOperateCode(SourceOperateCodeEnum.DATA_CHNFACTOR$01.getValue());
// PreDetection preDetection = pqDevList.get(0);
// Map<String, Object> map = new HashMap<>();
// map.put("devIP", preDetection.getDevIP());
// map.put("chnNum", preDetection.getDevChns());
// socketMsg.setData(JSON.toJSONString(map));
//
//
// NettyClient.socketClient("192.168.1.138", 61000, param, JSON.toJSONString(socketMsg), new NettyDevClientHandler(param, socketDevResponseService));
//
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
// }
}

View File

@@ -93,7 +93,7 @@ public class SocketDevResponseService {
*/
List<DevData> devInfo = new ArrayList<>();
Map<String, DevData> devDataMap = new HashMap<>();
//Map<String, DevData> devDataMap = new HashMap<>();
/**
* 成功结束的测点
@@ -785,14 +785,16 @@ public class SocketDevResponseService {
storageParam.setScriptId(param.getScriptId());
List<Integer> indexes = adHarmonicService.getIndex(storageParam, true);
issueParam.setIndexList(indexes);
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.COEFFICIENT_TEST.getValue());
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.RE_ERROR_TEST.getValue());
} else {
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.FORMAL_TEST.getValue());
}
//正式检测
sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam);
sourceIssues = sourceIssues.stream().sorted(Comparator.comparing(SourceIssue::getIndex)).collect(Collectors.toList());
// 存放所有检测小项
SocketManager.addSourceList(sourceIssues);
// 按照大项分组。key为大项codevalue为小项个数
Map<String, Long> sourceIssueMap = sourceIssues.stream().collect(Collectors.groupingBy(SourceIssue::getType, Collectors.counting()));
SocketManager.initMap(sourceIssueMap);
@@ -1468,7 +1470,7 @@ public class SocketDevResponseService {
//初始化相序集合
this.devInfo.clear();
this.devDataMap.clear();
//this.devDataMap.clear(); //好像没有用到
FormalTestManager.realDataXiList.clear();
this.targetTestMap.clear();

View File

@@ -64,6 +64,7 @@ public class SocketSourceResponseService {
if (ObjectUtil.isNotNull(param.getPlanId())) {
detectionDev(param, socketDataMsg);
} else {
// 程控源-源通信校验
handleYtxjySimulate(param, socketDataMsg);
}
break;

View File

@@ -14,7 +14,10 @@ public enum DetectionResponseEnum {
PLAN_AND_SOURCE_NOT("A020003", "计划和源关系不存在"),
ITEM_TEST_NOT("A020004", "检测项为空"),
PLAN_DEV_IP_HAS("A20005","当前计划检测装置ip重复"),
SOURCE_NOT_CONNECT("A020006", "源未连接");
SOURCE_NOT_CONNECT("A020006", "源未连接"),
SCRIPT_CHECK_DATA_NOT_EXIST("A020040","测试脚本项暂无配置" );
private final String code;
private final String message;

View File

@@ -24,9 +24,6 @@ public interface PreDetectionService {
void coefficientCheck(PreDetectionParam param);
boolean startTest(PreDetectionParam param);
boolean temStopTest();

View File

@@ -162,9 +162,6 @@ public class PreDetectionServiceImpl implements PreDetectionService {
param.setSourceId(sourceParam.getSourceId());
WebServiceManager.addPreDetectionParam(param);
if (ObjectUtil.isNotNull(sourceParam)) {
//开始组装socket报文请求头
//socketDevResponseService.initList(param);
//socketSourceResponseService.initList(param);
SocketMsg<String> socketMsg = new SocketMsg<>();
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_YTXJY.getValue());
socketMsg.setOperateCode(SourceOperateCodeEnum.INIT_GATHER.getValue());
@@ -175,15 +172,6 @@ public class PreDetectionServiceImpl implements PreDetectionService {
}
}
@Override
public boolean startTest(PreDetectionParam param) {
socketDevResponseService.initList(param);
NettyClient.socketClient(ip, port, param, "start\n", new NettySourceClientHandler(param, sourceResponseService));
return true;
}
@Override
public boolean temStopTest() {
FormalTestManager.stopFlag = true;

View File

@@ -19,7 +19,10 @@ import java.util.concurrent.CopyOnWriteArrayList;
*/
public class SocketManager {
// key为userIdxxx_Source、xxx_Devvalue为channel
private static final Map<String, Channel> socketSessions = new ConcurrentHashMap<>();
// key为userIdxxx_Source、xxx_Devvalue为group
private static final Map<String, NioEventLoopGroup> socketGroup = new ConcurrentHashMap<>();
public static void addUser(String userId, Channel channel) {

View File

@@ -37,6 +37,6 @@ public class PqScriptIssueParam {
@ApiModelProperty("表明指标类型例如Freq频率下的影响、Base额定下的影响、VOL电压下的影响")
private String scriptSubType;
@ApiModelProperty("脚本下发类型")
@ApiModelProperty("脚本下发类型") //在程控源功能中使用。因为在程控源功能中不知道装置的类型即不知道额定电压、额定电流而在正式检测时知道装置的类型。为了区分0表示正式检测1表示程控源功能。
private int type;
}

View File

@@ -9,6 +9,7 @@ import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.gather.detection.pojo.enums.DetectionCodeEnum;
import com.njcn.gather.detection.pojo.enums.DetectionResponseEnum;
import com.njcn.gather.script.mapper.PqScriptCheckDataMapper;
import com.njcn.gather.script.pojo.param.PqScriptCheckDataParam;
import com.njcn.gather.script.pojo.po.PqScriptCheckData;
@@ -80,7 +81,8 @@ public class PqScriptCheckDataServiceImpl extends ServiceImpl<PqScriptCheckDataM
.eq(PqScriptCheckData::getEnable, DataStateEnum.ENABLE.getCode());
List<PqScriptCheckData> pqScriptCheckData = this.baseMapper.selectList(queryWrapper);
if(CollUtil.isEmpty(pqScriptCheckData)){
throw new BusinessException(CommonResponseEnum.FAIL,"测试脚本项暂无配置");
// throw new BusinessException(CommonResponseEnum.FAIL,"测试脚本项暂无配置");
throw new BusinessException(DetectionResponseEnum.SCRIPT_CHECK_DATA_NOT_EXIST);
}
List<String> valueTypeList = pqScriptCheckData.stream().map(PqScriptCheckData::getValueType).distinct().collect(Collectors.toList());
LambdaQueryWrapper<DictTree> dictTreeLambdaQueryWrapper = new LambdaQueryWrapper<>();