Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
27d8757300 |
@@ -11,13 +11,10 @@ import com.njcn.gather.detection.lock.DetectionLock;
|
|||||||
import com.njcn.gather.detection.lock.DetectionLockManager;
|
import com.njcn.gather.detection.lock.DetectionLockManager;
|
||||||
import com.njcn.gather.detection.lock.DetectionLockManager.AcquireResult;
|
import com.njcn.gather.detection.lock.DetectionLockManager.AcquireResult;
|
||||||
import com.njcn.gather.detection.pojo.enums.DetectionResponseEnum;
|
import com.njcn.gather.detection.pojo.enums.DetectionResponseEnum;
|
||||||
import com.njcn.gather.detection.pojo.param.ClosePreTestParam;
|
|
||||||
import com.njcn.gather.detection.pojo.param.ContrastDetectionParam;
|
import com.njcn.gather.detection.pojo.param.ContrastDetectionParam;
|
||||||
import com.njcn.gather.detection.pojo.param.FormalProgressParam;
|
|
||||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||||
import com.njcn.gather.detection.pojo.param.SimulateDetectionParam;
|
import com.njcn.gather.detection.pojo.param.SimulateDetectionParam;
|
||||||
import com.njcn.gather.detection.pojo.vo.DetectionLockHolderVO;
|
import com.njcn.gather.detection.pojo.vo.DetectionLockHolderVO;
|
||||||
import com.njcn.gather.detection.pojo.vo.FormalProgressVO;
|
|
||||||
import com.njcn.gather.detection.service.PreDetectionService;
|
import com.njcn.gather.detection.service.PreDetectionService;
|
||||||
import com.njcn.gather.detection.util.socket.FormalTestManager;
|
import com.njcn.gather.detection.util.socket.FormalTestManager;
|
||||||
import com.njcn.gather.user.user.pojo.po.SysUser;
|
import com.njcn.gather.user.user.pojo.po.SysUser;
|
||||||
@@ -67,7 +64,8 @@ public class PreDetectionController extends BaseController {
|
|||||||
boolean keepLock = false;
|
boolean keepLock = false;
|
||||||
try {
|
try {
|
||||||
// 重置 FormalTestManager 暂停计数残留,避免上次暂停残留计数误触发 R4
|
// 重置 FormalTestManager 暂停计数残留,避免上次暂停残留计数误触发 R4
|
||||||
FormalTestManager.clearPauseState();
|
FormalTestManager.stopTime = 0;
|
||||||
|
FormalTestManager.hasStopFlag = false;
|
||||||
preDetectionService.sourceCommunicationCheck(param);
|
preDetectionService.sourceCommunicationCheck(param);
|
||||||
keepLock = true;
|
keepLock = true;
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
@@ -116,7 +114,8 @@ public class PreDetectionController extends BaseController {
|
|||||||
// 同步阶段抛异常时回滚锁,理由同 startPreTest
|
// 同步阶段抛异常时回滚锁,理由同 startPreTest
|
||||||
boolean keepLock = false;
|
boolean keepLock = false;
|
||||||
try {
|
try {
|
||||||
FormalTestManager.clearPauseState();
|
FormalTestManager.stopTime = 0;
|
||||||
|
FormalTestManager.hasStopFlag = false;
|
||||||
preDetectionService.sendScript(param);
|
preDetectionService.sendScript(param);
|
||||||
keepLock = true;
|
keepLock = true;
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
@@ -169,30 +168,20 @@ public class PreDetectionController extends BaseController {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 暂停检测,兼容旧前端:默认等待当前小项完成后暂停。
|
* 暂停检测
|
||||||
*/
|
*/
|
||||||
@GetMapping("/closePreTest")
|
@GetMapping("/closePreTest")
|
||||||
@OperateInfo
|
@OperateInfo
|
||||||
@ApiOperation("暂停检测")
|
@ApiOperation("暂停检测")
|
||||||
|
@ApiImplicitParam(name = "param", value = "参数", required = true)
|
||||||
public HttpResult<?> temStopTest() {
|
public HttpResult<?> temStopTest() {
|
||||||
return closePreTest(new ClosePreTestParam());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 暂停检测
|
|
||||||
*/
|
|
||||||
@PostMapping("/closePreTest")
|
|
||||||
@OperateInfo
|
|
||||||
@ApiOperation("暂停检测")
|
|
||||||
public HttpResult<?> closePreTest(@RequestBody(required = false) ClosePreTestParam param) {
|
|
||||||
String methodDescribe = getMethodDescribe("temStopTest");
|
String methodDescribe = getMethodDescribe("temStopTest");
|
||||||
HttpResult<DetectionLockHolderVO> busy = requireHolderSelf();
|
HttpResult<DetectionLockHolderVO> busy = requireHolderSelf();
|
||||||
if (busy != null) {
|
if (busy != null) {
|
||||||
return busy;
|
return busy;
|
||||||
}
|
}
|
||||||
// 暂停保持锁(spec §2.3),不释放
|
// 暂停保持锁(spec §2.3),不释放
|
||||||
ClosePreTestParam request = param == null ? new ClosePreTestParam() : param;
|
preDetectionService.temStopTest();
|
||||||
preDetectionService.temStopTest(RequestUtil.getLoginNameByToken(), request.isWaitCurrentItem());
|
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,36 +202,6 @@ public class PreDetectionController extends BaseController {
|
|||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/saveFormalProgress")
|
|
||||||
@OperateInfo
|
|
||||||
@ApiOperation("保存正式检测暂存进度")
|
|
||||||
public HttpResult<?> saveFormalProgress(@RequestBody @Validated FormalProgressParam param) {
|
|
||||||
String methodDescribe = getMethodDescribe("saveFormalProgress");
|
|
||||||
HttpResult<DetectionLockHolderVO> busy = requireHolderSelf();
|
|
||||||
if (busy != null) {
|
|
||||||
return busy;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
preDetectionService.saveFormalProgress(param);
|
|
||||||
} finally {
|
|
||||||
releaseLockSelf("SAVE_FORMAL_PROGRESS");
|
|
||||||
}
|
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/formalProgress")
|
|
||||||
@OperateInfo
|
|
||||||
@ApiOperation("查询正式检测暂存进度并放行续检")
|
|
||||||
public HttpResult<?> formalProgress(@RequestBody @Validated FormalProgressParam param) {
|
|
||||||
String methodDescribe = getMethodDescribe("formalProgress");
|
|
||||||
HttpResult<DetectionLockHolderVO> busy = requireHolderSelf();
|
|
||||||
if (busy != null) {
|
|
||||||
return busy;
|
|
||||||
}
|
|
||||||
FormalProgressVO data = preDetectionService.formalProgress(param);
|
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, data, methodDescribe);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 开始比对检测(包括预检测、正式检测)通用入口
|
* 开始比对检测(包括预检测、正式检测)通用入口
|
||||||
@@ -261,7 +220,8 @@ public class PreDetectionController extends BaseController {
|
|||||||
// 同步阶段抛异常时回滚锁,理由同 startPreTest
|
// 同步阶段抛异常时回滚锁,理由同 startPreTest
|
||||||
boolean keepLock = false;
|
boolean keepLock = false;
|
||||||
try {
|
try {
|
||||||
FormalTestManager.clearPauseState();
|
FormalTestManager.stopTime = 0;
|
||||||
|
FormalTestManager.hasStopFlag = false;
|
||||||
preDetectionService.startContrastTest(param);
|
preDetectionService.startContrastTest(param);
|
||||||
keepLock = true;
|
keepLock = true;
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ import com.njcn.gather.monitor.service.IPqMonitorService;
|
|||||||
import com.njcn.gather.plan.pojo.enums.DataSourceEnum;
|
import com.njcn.gather.plan.pojo.enums.DataSourceEnum;
|
||||||
import com.njcn.gather.plan.service.IAdPlanService;
|
import com.njcn.gather.plan.service.IAdPlanService;
|
||||||
import com.njcn.gather.plan.service.IAdPlanTestConfigService;
|
import com.njcn.gather.plan.service.IAdPlanTestConfigService;
|
||||||
import com.njcn.gather.report.pojo.enums.PowerIndexEnum;
|
|
||||||
import com.njcn.gather.storage.pojo.po.ContrastHarmonicResult;
|
import com.njcn.gather.storage.pojo.po.ContrastHarmonicResult;
|
||||||
import com.njcn.gather.storage.pojo.po.ContrastNonHarmonicResult;
|
import com.njcn.gather.storage.pojo.po.ContrastNonHarmonicResult;
|
||||||
import com.njcn.gather.storage.service.DetectionDataDealService;
|
import com.njcn.gather.storage.service.DetectionDataDealService;
|
||||||
@@ -133,17 +132,17 @@ public class SocketContrastResponseService {
|
|||||||
private final PathConfig pathConfig;
|
private final PathConfig pathConfig;
|
||||||
|
|
||||||
public static final Map<String, List<String>> testItemCodeMap = new HashMap() {{
|
public static final Map<String, List<String>> testItemCodeMap = new HashMap() {{
|
||||||
put(PowerIndexEnum.FREQ.getKey(), Arrays.asList(DetectionCodeEnum.FREQ.getCode()));
|
put("FREQ", Arrays.asList(DetectionCodeEnum.FREQ.getCode()));
|
||||||
put(PowerIndexEnum.V.getKey(), Arrays.asList(DetectionCodeEnum.VRMS.getCode(), DetectionCodeEnum.PVRMS.getCode()));
|
put("V", Arrays.asList(DetectionCodeEnum.VRMS.getCode(), DetectionCodeEnum.PVRMS.getCode()));
|
||||||
put(PowerIndexEnum.HV.getKey(), Arrays.asList(DetectionCodeEnum.V2_50.getCode(), DetectionCodeEnum.PV2_50.getCode()));
|
put("HV", Arrays.asList(DetectionCodeEnum.V2_50.getCode(), DetectionCodeEnum.PV2_50.getCode()));
|
||||||
put(PowerIndexEnum.HI.getKey(), Arrays.asList(DetectionCodeEnum.I2_50.getCode()));
|
put("HI", Arrays.asList(DetectionCodeEnum.I2_50.getCode()));
|
||||||
put(PowerIndexEnum.HP.getKey(), Arrays.asList(DetectionCodeEnum.P2_50.getCode()));
|
put("HP", Arrays.asList(DetectionCodeEnum.P2_50.getCode()));
|
||||||
put(PowerIndexEnum.HSV.getKey(), Arrays.asList(DetectionCodeEnum.SV_1_49.getCode(), DetectionCodeEnum.PSV_1_49.getCode()));
|
put("HSV", Arrays.asList(DetectionCodeEnum.SV_1_49.getCode(), DetectionCodeEnum.PSV_1_49.getCode()));
|
||||||
put(PowerIndexEnum.HSI.getKey(), Arrays.asList(DetectionCodeEnum.SI_1_49.getCode()));
|
put("HSI", Arrays.asList(DetectionCodeEnum.SI_1_49.getCode()));
|
||||||
put(PowerIndexEnum.I.getKey(), Arrays.asList(DetectionCodeEnum.IRMS.getCode()));
|
put("I", Arrays.asList(DetectionCodeEnum.IRMS.getCode()));
|
||||||
put(PowerIndexEnum.IMBV.getKey(), Arrays.asList(DetectionCodeEnum.V_UNBAN.getCode()));
|
put("IMBV", Arrays.asList(DetectionCodeEnum.V_UNBAN.getCode()));
|
||||||
put(PowerIndexEnum.IMBA.getKey(), Arrays.asList(DetectionCodeEnum.I_UNBAN.getCode()));
|
put("IMBA", Arrays.asList(DetectionCodeEnum.I_UNBAN.getCode()));
|
||||||
put(PowerIndexEnum.F.getKey(), Arrays.asList(DetectionCodeEnum.PST.getCode()));
|
put("F", Arrays.asList(DetectionCodeEnum.PST.getCode()));
|
||||||
}};
|
}};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -308,7 +307,7 @@ public class SocketContrastResponseService {
|
|||||||
FormalTestManager.numMap.clear();
|
FormalTestManager.numMap.clear();
|
||||||
FormalTestManager.numMap.putAll(numMap);
|
FormalTestManager.numMap.putAll(numMap);
|
||||||
SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
|
SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
|
||||||
if (param.isFormalTestSelected()) {
|
if (param.getTestItemList().get(2)) {
|
||||||
numMap.forEach((devMonitorId, num) -> {
|
numMap.forEach((devMonitorId, num) -> {
|
||||||
if (oneConfig.getMaxTime() < num) {
|
if (oneConfig.getMaxTime() < num) {
|
||||||
throw new BusinessException(DetectionResponseEnum.EXCEED_MAX_TIME);
|
throw new BusinessException(DetectionResponseEnum.EXCEED_MAX_TIME);
|
||||||
@@ -1155,7 +1154,7 @@ public class SocketContrastResponseService {
|
|||||||
|
|
||||||
private void sendFormalTest(String s, PreDetectionParam param, SourceOperateCodeEnum requestOperateCode, SourceOperateCodeEnum quitOperateCode) {
|
private void sendFormalTest(String s, PreDetectionParam param, SourceOperateCodeEnum requestOperateCode, SourceOperateCodeEnum quitOperateCode) {
|
||||||
// 后续做正式检测
|
// 后续做正式检测
|
||||||
if (param.isFormalTestSelected()) {
|
if (param.getTestItemList().get(2)) {
|
||||||
System.out.println("开始正式检测!");
|
System.out.println("开始正式检测!");
|
||||||
if (ObjectUtil.isNotNull(FormalTestManager.nonWaveDataSourceEnum)) {
|
if (ObjectUtil.isNotNull(FormalTestManager.nonWaveDataSourceEnum)) {
|
||||||
SocketMsg<String> socketMsg = new SocketMsg<>();
|
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import com.njcn.gather.device.service.IPqDevService;
|
|||||||
import com.njcn.gather.device.service.IPqDevSubService;
|
import com.njcn.gather.device.service.IPqDevSubService;
|
||||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||||
import com.njcn.gather.plan.service.IAdPlanService;
|
import com.njcn.gather.plan.service.IAdPlanService;
|
||||||
import com.njcn.gather.report.pojo.enums.PowerIndexEnum;
|
import com.njcn.gather.result.pojo.enums.ResultUnitEnum;
|
||||||
import com.njcn.gather.result.service.IResultService;
|
import com.njcn.gather.result.service.IResultService;
|
||||||
import com.njcn.gather.script.pojo.param.PqScriptCheckDataParam;
|
import com.njcn.gather.script.pojo.param.PqScriptCheckDataParam;
|
||||||
import com.njcn.gather.script.pojo.param.PqScriptIssueParam;
|
import com.njcn.gather.script.pojo.param.PqScriptIssueParam;
|
||||||
@@ -45,6 +45,7 @@ import com.njcn.gather.storage.service.SimAndDigHarmonicService;
|
|||||||
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
||||||
import com.njcn.gather.system.dictionary.pojo.po.DictData;
|
import com.njcn.gather.system.dictionary.pojo.po.DictData;
|
||||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||||
|
import com.njcn.gather.system.pojo.enums.DicDataEnum;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -68,7 +69,7 @@ public class SocketDevResponseService {
|
|||||||
|
|
||||||
private List<String> icdTypeList;
|
private List<String> icdTypeList;
|
||||||
|
|
||||||
private final List<String> nonHarmonicList = Stream.of(PowerIndexEnum.FREQ.getKey(), PowerIndexEnum.V.getKey(), PowerIndexEnum.I.getKey(), PowerIndexEnum.IMBV.getKey(), PowerIndexEnum.IMBA.getKey(), PowerIndexEnum.VOLTAGE.getKey(), PowerIndexEnum.F.getKey(), PowerIndexEnum.LF.getKey()).collect(Collectors.toList());
|
private final List<String> nonHarmonicList = Stream.of(DicDataEnum.FREQ.getCode(), DicDataEnum.V.getCode(), DicDataEnum.I.getCode(), DicDataEnum.IMBV.getCode(), DicDataEnum.IMBA.getCode(), DicDataEnum.VOLTAGE.getCode(), DicDataEnum.F.getCode()).collect(Collectors.toList());
|
||||||
|
|
||||||
private final IPqDevService iPqDevService;
|
private final IPqDevService iPqDevService;
|
||||||
private final IPqDevSubService iPqDevSubService;
|
private final IPqDevSubService iPqDevSubService;
|
||||||
@@ -397,8 +398,72 @@ public class SocketDevResponseService {
|
|||||||
sendWebSocket(param.getUserPageId(), SourceOperateCodeEnum.Coefficient_Check.getValue(), SourceOperateCodeEnum.small_comp_end.getValue(), XiNumberManager.devParameterList.get(1));
|
sendWebSocket(param.getUserPageId(), SourceOperateCodeEnum.Coefficient_Check.getValue(), SourceOperateCodeEnum.small_comp_end.getValue(), XiNumberManager.devParameterList.get(1));
|
||||||
System.out.println("-------------------------已经全部结束----------------------");
|
System.out.println("-------------------------已经全部结束----------------------");
|
||||||
|
|
||||||
if (param.isFormalTestSelected()) {
|
if (param.getTestItemList().get(2)) {
|
||||||
startFormalScripts(param, null, param.isResumeFormal());
|
//如果后续做正式检测
|
||||||
|
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
||||||
|
issueParam.setSourceId(param.getSourceName());
|
||||||
|
issueParam.setPlanId(param.getPlanId());
|
||||||
|
issueParam.setSourceId(param.getSourceId());
|
||||||
|
issueParam.setDevIds(param.getDevIds());
|
||||||
|
issueParam.setScriptId(param.getScriptId());
|
||||||
|
|
||||||
|
if (param.getReCheckType().equals(SourceOperateCodeEnum.RE_ERROR_TEST.getValue())) {
|
||||||
|
//不合格项复检
|
||||||
|
Set<Integer> indexes = new HashSet<>();
|
||||||
|
StorageParam storageParam = new StorageParam();
|
||||||
|
storageParam.setCode(param.getCode());
|
||||||
|
storageParam.setScriptId(param.getScriptId());
|
||||||
|
param.getDevIds().forEach(devId -> {
|
||||||
|
storageParam.setDevId(devId);
|
||||||
|
indexes.addAll(adHarmonicService.getIndex(storageParam));
|
||||||
|
});
|
||||||
|
issueParam.setIndexList(indexes.stream().collect(Collectors.toList()));
|
||||||
|
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.RE_ERROR_TEST.getValue());
|
||||||
|
} else {
|
||||||
|
issueParam.setIsPhaseSequence(CommonEnum.FORMAL_TEST.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||||
|
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||||
|
List<SourceIssue> sourceIssues;
|
||||||
|
|
||||||
|
//正式检测
|
||||||
|
sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam);
|
||||||
|
sourceIssues = sourceIssues.stream().sorted(Comparator.comparing(SourceIssue::getIndex)).collect(Collectors.toList());
|
||||||
|
// 使用 LinkedHashMap 保持分组顺序
|
||||||
|
Map<String, List<SourceIssue>> groupedIssues = sourceIssues.stream()
|
||||||
|
.collect(Collectors.groupingBy(
|
||||||
|
SourceIssue::getType,
|
||||||
|
LinkedHashMap::new,
|
||||||
|
Collectors.toList()
|
||||||
|
));
|
||||||
|
|
||||||
|
// 将分组后的元素合并成一个新的集合,保持原有顺序
|
||||||
|
sourceIssues = groupedIssues.values().stream()
|
||||||
|
.flatMap(List::stream)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
// 存放所有检测小项
|
||||||
|
SocketManager.addSourceList(sourceIssues);
|
||||||
|
// 按照大项分组。key为大项code,value为小项个数
|
||||||
|
Map<String, Long> sourceIssueMap = sourceIssues.stream().collect(Collectors.groupingBy(SourceIssue::getType, Collectors.counting()));
|
||||||
|
SocketManager.initMap(sourceIssueMap);
|
||||||
|
|
||||||
|
//告诉前端当前项开始了
|
||||||
|
WebSocketVO<Object> webSocketVO = new WebSocketVO<>();
|
||||||
|
FormalTestManager.currentIssue = sourceIssues.get(0);
|
||||||
|
String type = sourceIssues.get(0).getType();
|
||||||
|
if (ResultUnitEnum.P.getCode().equals(type)) {
|
||||||
|
sourceIssues.get(0).setType(ResultUnitEnum.V_ABSOLUTELY.getCode());
|
||||||
|
webSocketVO.setRequestId(ResultUnitEnum.P.getCode() + CnSocketUtil.START_TAG);
|
||||||
|
} else {
|
||||||
|
webSocketVO.setRequestId(sourceIssues.get(0).getType() + CnSocketUtil.START_TAG);
|
||||||
|
}
|
||||||
|
socketMsg.setData(JSON.toJSONString(sourceIssues.get(0)));
|
||||||
|
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + CnSocketUtil.STEP_TAG + type);
|
||||||
|
SocketManager.sendMsg(param.getUserPageId() + CnSocketUtil.SOURCE_TAG, JSON.toJSONString(socketMsg));
|
||||||
|
|
||||||
|
webSocketVO.setDesc(null);
|
||||||
|
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(webSocketVO));
|
||||||
} else {
|
} else {
|
||||||
//后续什么都不做
|
//后续什么都不做
|
||||||
CnSocketUtil.quitSend(param);
|
CnSocketUtil.quitSend(param);
|
||||||
@@ -550,7 +615,7 @@ public class SocketDevResponseService {
|
|||||||
private BigDecimal rangeNum(double num1, double num2, String type) {
|
private BigDecimal rangeNum(double num1, double num2, String type) {
|
||||||
double diff = Math.abs(num1 - num2);
|
double diff = Math.abs(num1 - num2);
|
||||||
double larger = Math.max(num1, num2);
|
double larger = Math.max(num1, num2);
|
||||||
if (PowerIndexEnum.V.getKey().equals(type)) {
|
if (DicDataEnum.V.getCode().equals(type)) {
|
||||||
return BigDecimal.valueOf(num1 - num2).setScale(4, RoundingMode.HALF_UP);
|
return BigDecimal.valueOf(num1 - num2).setScale(4, RoundingMode.HALF_UP);
|
||||||
} else {
|
} else {
|
||||||
return BigDecimal.valueOf(diff / larger).multiply(BigDecimal.valueOf(100)).setScale(4, RoundingMode.HALF_UP);
|
return BigDecimal.valueOf(diff / larger).multiply(BigDecimal.valueOf(100)).setScale(4, RoundingMode.HALF_UP);
|
||||||
@@ -613,12 +678,12 @@ public class SocketDevResponseService {
|
|||||||
coefficientVO.setBIeXi(isWithinTenPercent(optionalIB, devParameter.getDevCurr(), iLimit) ? "合格" : "不合格");
|
coefficientVO.setBIeXi(isWithinTenPercent(optionalIB, devParameter.getDevCurr(), iLimit) ? "合格" : "不合格");
|
||||||
coefficientVO.setCIeXi(isWithinTenPercent(optionalIC, devParameter.getDevCurr(), iLimit) ? "合格" : "不合格");
|
coefficientVO.setCIeXi(isWithinTenPercent(optionalIC, devParameter.getDevCurr(), iLimit) ? "合格" : "不合格");
|
||||||
|
|
||||||
coefficientVO.setAV(rangeNum(optionalA, devParameter.getDevVolt(), PowerIndexEnum.V.getKey()).toString());
|
coefficientVO.setAV(rangeNum(optionalA, devParameter.getDevVolt(), DicDataEnum.V.getCode()).toString());
|
||||||
coefficientVO.setBV(rangeNum(optionalB, devParameter.getDevVolt(), PowerIndexEnum.V.getKey()).toString());
|
coefficientVO.setBV(rangeNum(optionalB, devParameter.getDevVolt(), DicDataEnum.V.getCode()).toString());
|
||||||
coefficientVO.setCV(rangeNum(optionalC, devParameter.getDevVolt(), PowerIndexEnum.V.getKey()).toString());
|
coefficientVO.setCV(rangeNum(optionalC, devParameter.getDevVolt(), DicDataEnum.V.getCode()).toString());
|
||||||
coefficientVO.setAI(rangeNum(optionalIA, devParameter.getDevCurr(), PowerIndexEnum.I.getKey()).toString());
|
coefficientVO.setAI(rangeNum(optionalIA, devParameter.getDevCurr(), DicDataEnum.I.getCode()).toString());
|
||||||
coefficientVO.setBI(rangeNum(optionalIB, devParameter.getDevCurr(), PowerIndexEnum.I.getKey()).toString());
|
coefficientVO.setBI(rangeNum(optionalIB, devParameter.getDevCurr(), DicDataEnum.I.getCode()).toString());
|
||||||
coefficientVO.setCI(rangeNum(optionalIC, devParameter.getDevCurr(), PowerIndexEnum.I.getKey()).toString());
|
coefficientVO.setCI(rangeNum(optionalIC, devParameter.getDevCurr(), DicDataEnum.I.getCode()).toString());
|
||||||
|
|
||||||
if ("不合格".equals(coefficientVO.getAVuXi()) || "不合格".equals(coefficientVO.getBVuXi()) || "不合格".equals(coefficientVO.getCVuXi()) || "不合格".equals(coefficientVO.getAIeXi()) || "不合格".equals(coefficientVO.getBIeXi()) || "不合格".equals(coefficientVO.getCIeXi())) {
|
if ("不合格".equals(coefficientVO.getAVuXi()) || "不合格".equals(coefficientVO.getBVuXi()) || "不合格".equals(coefficientVO.getCVuXi()) || "不合格".equals(coefficientVO.getAIeXi()) || "不合格".equals(coefficientVO.getBIeXi()) || "不合格".equals(coefficientVO.getCIeXi())) {
|
||||||
coefficientVO.setResultFlag(0);
|
coefficientVO.setResultFlag(0);
|
||||||
@@ -796,7 +861,7 @@ public class SocketDevResponseService {
|
|||||||
boolean isContinue = true;
|
boolean isContinue = true;
|
||||||
List<String> descList = icdCheckData.getResultData().stream().map(
|
List<String> descList = icdCheckData.getResultData().stream().map(
|
||||||
obj -> {
|
obj -> {
|
||||||
if (DetectionCodeEnum.MAG.getCode().equals(obj.getDesc()) || DetectionCodeEnum.DUR.getCode().equals(obj.getDesc()) || DetectionCodeEnum.PST.getCode().equals(obj.getDesc()) || DetectionCodeEnum.PLT.getCode().equals(obj.getDesc())) {
|
if (DetectionCodeEnum.MAG.getCode().equals(obj.getDesc()) || DetectionCodeEnum.DUR.getCode().equals(obj.getDesc()) || DetectionCodeEnum.PST.getCode().equals(obj.getDesc())) {
|
||||||
return DetectionCodeEnum.AVG_PREFIX.getCode() + obj.getDesc();
|
return DetectionCodeEnum.AVG_PREFIX.getCode() + obj.getDesc();
|
||||||
} else {
|
} else {
|
||||||
return DetectionCodeEnum.REAL_PREFIX.getCode() + obj.getDesc();
|
return DetectionCodeEnum.REAL_PREFIX.getCode() + obj.getDesc();
|
||||||
@@ -847,70 +912,69 @@ public class SocketDevResponseService {
|
|||||||
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||||
List<SourceIssue> sourceIssues;
|
List<SourceIssue> sourceIssues;
|
||||||
// 做预检测、后续做系数校准
|
// 做预检测、后续做系数校准
|
||||||
// if (param.isPreTestSelected() || param.isCoefficientSelected() || param.isFormalTestSelected()) {
|
if (param.getTestItemList().get(0) || param.getTestItemList().get(1)) {
|
||||||
issueParam.setIsPhaseSequence(CommonEnum.PHASE_TEST.getValue());
|
issueParam.setIsPhaseSequence(CommonEnum.PHASE_TEST.getValue());
|
||||||
sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam);
|
sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam);
|
||||||
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_XUJY.getValue());
|
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_XUJY.getValue());
|
||||||
socketMsg.setData(JSON.toJSONString(sourceIssues.get(0)));
|
socketMsg.setData(JSON.toJSONString(sourceIssues.get(0)));
|
||||||
SocketManager.sendMsg(param.getUserPageId() + CnSocketUtil.SOURCE_TAG, JSON.toJSONString(socketMsg));
|
SocketManager.sendMsg(param.getUserPageId() + CnSocketUtil.SOURCE_TAG, JSON.toJSONString(socketMsg));
|
||||||
// }
|
} else if (param.getTestItemList().get(2)) {
|
||||||
// else if (param.isFormalTestSelected()) {
|
// 后续做正式检测
|
||||||
// // 后续做正式检测
|
if (param.getReCheckType().equals(SourceOperateCodeEnum.RE_ERROR_TEST.getValue())) {
|
||||||
// if (param.getReCheckType().equals(SourceOperateCodeEnum.RE_ERROR_TEST.getValue())) {
|
//不合格项复检
|
||||||
// //不合格项复检
|
Set<Integer> indexes = new HashSet<>();
|
||||||
// Set<Integer> indexes = new HashSet<>();
|
StorageParam storageParam = new StorageParam();
|
||||||
// StorageParam storageParam = new StorageParam();
|
storageParam.setCode(param.getCode());
|
||||||
// storageParam.setCode(param.getCode());
|
storageParam.setScriptId(param.getScriptId());
|
||||||
// storageParam.setScriptId(param.getScriptId());
|
param.getDevIds().forEach(devId -> {
|
||||||
// param.getDevIds().forEach(devId -> {
|
storageParam.setDevId(devId);
|
||||||
// storageParam.setDevId(devId);
|
indexes.addAll(adHarmonicService.getIndex(storageParam));
|
||||||
// indexes.addAll(adHarmonicService.getIndex(storageParam));
|
});
|
||||||
// });
|
issueParam.setIndexList(indexes.stream().collect(Collectors.toList()));
|
||||||
// issueParam.setIndexList(indexes.stream().collect(Collectors.toList()));
|
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.RE_ERROR_TEST.getValue());
|
||||||
// issueParam.setIsPhaseSequence(SourceOperateCodeEnum.RE_ERROR_TEST.getValue());
|
} else {
|
||||||
// } else {
|
issueParam.setIsPhaseSequence(CommonEnum.FORMAL_TEST.getValue());
|
||||||
// issueParam.setIsPhaseSequence(CommonEnum.FORMAL_TEST.getValue());
|
}
|
||||||
// }
|
//正式检测
|
||||||
// //正式检测
|
sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam);
|
||||||
// sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam);
|
sourceIssues = sourceIssues.stream().sorted(Comparator.comparing(SourceIssue::getIndex)).collect(Collectors.toList());
|
||||||
// sourceIssues = sourceIssues.stream().sorted(Comparator.comparing(SourceIssue::getIndex)).collect(Collectors.toList());
|
// 使用 LinkedHashMap 保持分组顺序
|
||||||
// // 使用 LinkedHashMap 保持分组顺序
|
Map<String, List<SourceIssue>> groupedIssues = sourceIssues.stream()
|
||||||
// Map<String, List<SourceIssue>> groupedIssues = sourceIssues.stream()
|
.collect(Collectors.groupingBy(
|
||||||
// .collect(Collectors.groupingBy(
|
SourceIssue::getType,
|
||||||
// SourceIssue::getType,
|
LinkedHashMap::new,
|
||||||
// LinkedHashMap::new,
|
Collectors.toList()
|
||||||
// Collectors.toList()
|
));
|
||||||
// ));
|
|
||||||
//
|
// 将分组后的元素合并成一个新的集合,保持原有顺序
|
||||||
// // 将分组后的元素合并成一个新的集合,保持原有顺序
|
sourceIssues = groupedIssues.values().stream()
|
||||||
// sourceIssues = groupedIssues.values().stream()
|
.flatMap(List::stream)
|
||||||
// .flatMap(List::stream)
|
.collect(Collectors.toList());
|
||||||
// .collect(Collectors.toList());
|
// 存放所有检测小项
|
||||||
// // 存放所有检测小项
|
SocketManager.addSourceList(sourceIssues);
|
||||||
// SocketManager.addSourceList(sourceIssues);
|
// 按照大项分组。key为大项code,value为小项个数
|
||||||
// // 按照大项分组。key为大项code,value为小项个数
|
Map<String, Long> sourceIssueMap = sourceIssues.stream().collect(Collectors.groupingBy(SourceIssue::getType, Collectors.counting()));
|
||||||
// Map<String, Long> sourceIssueMap = sourceIssues.stream().collect(Collectors.groupingBy(SourceIssue::getType, Collectors.counting()));
|
SocketManager.initMap(sourceIssueMap);
|
||||||
// SocketManager.initMap(sourceIssueMap);
|
|
||||||
//
|
//告诉前端当前项开始了
|
||||||
// //告诉前端当前项开始了
|
WebSocketVO<Object> webSocketVO = new WebSocketVO<>();
|
||||||
// WebSocketVO<Object> webSocketVO = new WebSocketVO<>();
|
String type = sourceIssues.get(0).getType();
|
||||||
// String type = sourceIssues.get(0).getType();
|
if (StrUtil.isNotBlank(sourceIssues.get(0).getOtherType())) {
|
||||||
// if (StrUtil.isNotBlank(sourceIssues.get(0).getOtherType())) {
|
sourceIssues.get(0).setType(ResultUnitEnum.V_ABSOLUTELY.getCode());
|
||||||
// sourceIssues.get(0).setType(PowerIndexEnum.V.getKey());
|
webSocketVO.setRequestId(sourceIssues.get(0).getOtherType() + CnSocketUtil.START_TAG);
|
||||||
// webSocketVO.setRequestId(sourceIssues.get(0).getOtherType() + CnSocketUtil.START_TAG);
|
type = sourceIssues.get(0).getOtherType();
|
||||||
// type = sourceIssues.get(0).getOtherType();
|
} else {
|
||||||
// } else {
|
webSocketVO.setRequestId(sourceIssues.get(0).getType() + CnSocketUtil.START_TAG);
|
||||||
// webSocketVO.setRequestId(sourceIssues.get(0).getType() + CnSocketUtil.START_TAG);
|
}
|
||||||
// }
|
FormalTestManager.currentIssue = sourceIssues.get(0);
|
||||||
// FormalTestManager.currentIssue = sourceIssues.get(0);
|
socketMsg.setData(JSON.toJSONString(sourceIssues.get(0)));
|
||||||
// socketMsg.setData(JSON.toJSONString(sourceIssues.get(0)));
|
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + CnSocketUtil.STEP_TAG + type);
|
||||||
// socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + CnSocketUtil.STEP_TAG + type);
|
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||||
// socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
SocketManager.sendMsg(param.getUserPageId() + CnSocketUtil.SOURCE_TAG, JSON.toJSONString(socketMsg));
|
||||||
// SocketManager.sendMsg(param.getUserPageId() + CnSocketUtil.SOURCE_TAG, JSON.toJSONString(socketMsg));
|
|
||||||
//
|
webSocketVO.setDesc(null);
|
||||||
// webSocketVO.setDesc(null);
|
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(webSocketVO));
|
||||||
// WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(webSocketVO));
|
}
|
||||||
// }
|
|
||||||
} else {
|
} else {
|
||||||
// 发送下一个脚本与icd校验
|
// 发送下一个脚本与icd校验
|
||||||
String icdType = icdTypeList.stream().filter(it -> !icdCheckDataMap.containsKey(it)).findFirst().orElse(null);
|
String icdType = icdTypeList.stream().filter(it -> !icdCheckDataMap.containsKey(it)).findFirst().orElse(null);
|
||||||
@@ -1083,7 +1147,7 @@ public class SocketDevResponseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 后续做系数校准
|
// 后续做系数校准
|
||||||
if (param.isCoefficientSelected()) {
|
if (param.getTestItemList().get(1)) {
|
||||||
WebSocketVO<Object> webSocketVO = new WebSocketVO<>();
|
WebSocketVO<Object> webSocketVO = new WebSocketVO<>();
|
||||||
webSocketVO.setRequestId(SourceOperateCodeEnum.Coefficient_Check.getValue());
|
webSocketVO.setRequestId(SourceOperateCodeEnum.Coefficient_Check.getValue());
|
||||||
webSocketVO.setOperateCode(SourceOperateCodeEnum.big_start.getValue());
|
webSocketVO.setOperateCode(SourceOperateCodeEnum.big_start.getValue());
|
||||||
@@ -1107,8 +1171,70 @@ public class SocketDevResponseService {
|
|||||||
XiNumberManager.smallDevXiNumDataMap.clear();
|
XiNumberManager.smallDevXiNumDataMap.clear();
|
||||||
|
|
||||||
System.out.println("开始系数校准》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》");
|
System.out.println("开始系数校准》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》");
|
||||||
} else if (param.isFormalTestSelected()) {
|
} else if (param.getTestItemList().get(2)) {
|
||||||
startFormalScripts(param, null, param.isResumeFormal());
|
// 后续做正式检测
|
||||||
|
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
||||||
|
issueParam.setSourceId(param.getSourceName());
|
||||||
|
issueParam.setPlanId(param.getPlanId());
|
||||||
|
issueParam.setDevIds(param.getDevIds());
|
||||||
|
issueParam.setScriptId(param.getScriptId());
|
||||||
|
|
||||||
|
if (param.getReCheckType().equals(SourceOperateCodeEnum.RE_ERROR_TEST.getValue())) {
|
||||||
|
//不合格项复检
|
||||||
|
Set<Integer> indexes = new HashSet<>();
|
||||||
|
StorageParam storageParam = new StorageParam();
|
||||||
|
storageParam.setCode(param.getCode());
|
||||||
|
storageParam.setScriptId(param.getScriptId());
|
||||||
|
param.getDevIds().forEach(devId -> {
|
||||||
|
storageParam.setDevId(devId);
|
||||||
|
indexes.addAll(adHarmonicService.getIndex(storageParam));
|
||||||
|
});
|
||||||
|
issueParam.setIndexList(indexes.stream().collect(Collectors.toList()));
|
||||||
|
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.RE_ERROR_TEST.getValue());
|
||||||
|
} else {
|
||||||
|
issueParam.setIsPhaseSequence(CommonEnum.FORMAL_TEST.getValue());
|
||||||
|
}
|
||||||
|
//正式检测
|
||||||
|
sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam);
|
||||||
|
sourceIssues = sourceIssues.stream().sorted(Comparator.comparing(SourceIssue::getIndex)).collect(Collectors.toList());
|
||||||
|
// 使用 LinkedHashMap 保持分组顺序
|
||||||
|
Map<String, List<SourceIssue>> groupedIssues = sourceIssues.stream()
|
||||||
|
.collect(Collectors.groupingBy(
|
||||||
|
SourceIssue::getType,
|
||||||
|
LinkedHashMap::new,
|
||||||
|
Collectors.toList()
|
||||||
|
));
|
||||||
|
|
||||||
|
// 将分组后的元素合并成一个新的集合,保持原有顺序
|
||||||
|
sourceIssues = groupedIssues.values().stream()
|
||||||
|
.flatMap(List::stream)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
// 存放所有检测小项
|
||||||
|
SocketManager.addSourceList(sourceIssues);
|
||||||
|
// 按照大项分组。key为大项code,value为小项个数
|
||||||
|
Map<String, Long> sourceIssueMap = sourceIssues.stream().collect(Collectors.groupingBy(SourceIssue::getType, Collectors.counting()));
|
||||||
|
SocketManager.initMap(sourceIssueMap);
|
||||||
|
|
||||||
|
//告诉前端当前项开始了
|
||||||
|
WebSocketVO<Object> webSocketVO = new WebSocketVO<>();
|
||||||
|
|
||||||
|
String type = sourceIssues.get(0).getType();
|
||||||
|
if (StrUtil.isNotBlank(sourceIssues.get(0).getOtherType())) {
|
||||||
|
sourceIssues.get(0).setType(ResultUnitEnum.V_ABSOLUTELY.getCode());
|
||||||
|
webSocketVO.setRequestId(sourceIssues.get(0).getOtherType() + CnSocketUtil.START_TAG);
|
||||||
|
type = sourceIssues.get(0).getOtherType();
|
||||||
|
} else {
|
||||||
|
webSocketVO.setRequestId(sourceIssues.get(0).getType() + CnSocketUtil.START_TAG);
|
||||||
|
}
|
||||||
|
|
||||||
|
FormalTestManager.currentIssue = sourceIssues.get(0);
|
||||||
|
socketMsg.setData(JSON.toJSONString(sourceIssues.get(0)));
|
||||||
|
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + CnSocketUtil.STEP_TAG + type);
|
||||||
|
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||||
|
SocketManager.sendMsg(param.getUserPageId() + CnSocketUtil.SOURCE_TAG, JSON.toJSONString(socketMsg));
|
||||||
|
|
||||||
|
webSocketVO.setDesc(null);
|
||||||
|
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(webSocketVO));
|
||||||
} else {
|
} else {
|
||||||
//后续什么都不做
|
//后续什么都不做
|
||||||
System.out.println("预检测流程结束-----------------关闭源");
|
System.out.println("预检测流程结束-----------------关闭源");
|
||||||
@@ -1153,155 +1279,6 @@ public class SocketDevResponseService {
|
|||||||
// key为 检测大项对应的code,value为当前大项的检测结果
|
// key为 检测大项对应的code,value为当前大项的检测结果
|
||||||
Map<String, List<DevLineTestResult>> targetTestMap = new HashMap<>();
|
Map<String, List<DevLineTestResult>> targetTestMap = new HashMap<>();
|
||||||
|
|
||||||
public void startFormalAfterProgressRestore(PreDetectionParam param, Integer nextSort) {
|
|
||||||
FormalTestManager.resumeFormalPending = false;
|
|
||||||
FormalTestManager.resumeNextSort = nextSort;
|
|
||||||
if (nextSort == null) {
|
|
||||||
WebServiceManager.sendDetectionMessage(param.getUserPageId(), "formal_progress_no_next", null, null, null);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
startFormalScripts(param, nextSort, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void startFormalScripts(PreDetectionParam param, Integer startSort, boolean waitForProgressRestore) {
|
|
||||||
List<SourceIssue> sourceIssues = buildFormalIssues(param);
|
|
||||||
if (ObjectUtil.isNotNull(startSort)) {
|
|
||||||
sourceIssues = sourceIssues.stream()
|
|
||||||
.filter(issue -> issue.getIndex() >= startSort)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
sourceIssues = sourceIssues.stream()
|
|
||||||
.sorted(Comparator.comparing(SourceIssue::getIndex))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
Map<String, List<SourceIssue>> groupedIssues = sourceIssues.stream()
|
|
||||||
.collect(Collectors.groupingBy(SourceIssue::getType, LinkedHashMap::new, Collectors.toList()));
|
|
||||||
sourceIssues = groupedIssues.values().stream().flatMap(List::stream).collect(Collectors.toList());
|
|
||||||
if (!param.isResumeFormal() && CollUtil.isNotEmpty(sourceIssues)) {
|
|
||||||
iPqDevService.clearFormalProgressForNewRun(param.getDevIds());
|
|
||||||
}
|
|
||||||
SocketManager.addSourceList(sourceIssues);
|
|
||||||
Map<String, Long> sourceIssueMap = sourceIssues.stream()
|
|
||||||
.collect(Collectors.groupingBy(SourceIssue::getType, Collectors.counting()));
|
|
||||||
SocketManager.initMap(sourceIssueMap);
|
|
||||||
|
|
||||||
if (waitForProgressRestore) {
|
|
||||||
FormalTestManager.resumeFormalPending = true;
|
|
||||||
WebServiceManager.sendDetectionMessage(param.getUserPageId(), "formal_progress_required", null, null, null);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
sendFirstFormalIssue(param, sourceIssues);
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<SourceIssue> buildFormalIssues(PreDetectionParam param) {
|
|
||||||
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
|
||||||
issueParam.setSourceId(param.getSourceName());
|
|
||||||
issueParam.setPlanId(param.getPlanId());
|
|
||||||
issueParam.setDevIds(param.getDevIds());
|
|
||||||
issueParam.setScriptId(param.getScriptId());
|
|
||||||
|
|
||||||
if (!param.isResumeFormal() && SourceOperateCodeEnum.RE_ERROR_TEST.getValue().equals(param.getReCheckType())) {
|
|
||||||
Set<Integer> indexes = new HashSet<>();
|
|
||||||
StorageParam storageParam = new StorageParam();
|
|
||||||
storageParam.setCode(param.getCode());
|
|
||||||
storageParam.setScriptId(param.getScriptId());
|
|
||||||
param.getDevIds().forEach(devId -> {
|
|
||||||
storageParam.setDevId(devId);
|
|
||||||
indexes.addAll(adHarmonicService.getIndex(storageParam));
|
|
||||||
});
|
|
||||||
issueParam.setIndexList(indexes.stream().collect(Collectors.toList()));
|
|
||||||
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.RE_ERROR_TEST.getValue());
|
|
||||||
} else {
|
|
||||||
issueParam.setIsPhaseSequence(CommonEnum.FORMAL_TEST.getValue());
|
|
||||||
}
|
|
||||||
return pqScriptDtlsService.listSourceIssue(issueParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sendFirstFormalIssue(PreDetectionParam param, List<SourceIssue> sourceIssues) {
|
|
||||||
if (CollUtil.isEmpty(sourceIssues)) {
|
|
||||||
WebServiceManager.sendDetectionMessage(param.getUserPageId(), "formal_progress_no_next", null, null, null);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
SourceIssue firstIssue = sourceIssues.get(0);
|
|
||||||
WebSocketVO<Object> webSocketVO = new WebSocketVO<>();
|
|
||||||
String type = firstIssue.getType();
|
|
||||||
if (StrUtil.isNotBlank(firstIssue.getOtherType())) {
|
|
||||||
firstIssue.setType(PowerIndexEnum.LF.getKey().equals(firstIssue.getOtherType()) ? PowerIndexEnum.F.getKey() : PowerIndexEnum.V.getKey());
|
|
||||||
webSocketVO.setRequestId(firstIssue.getOtherType() + CnSocketUtil.START_TAG);
|
|
||||||
type = firstIssue.getOtherType();
|
|
||||||
} else {
|
|
||||||
webSocketVO.setRequestId(firstIssue.getType() + CnSocketUtil.START_TAG);
|
|
||||||
}
|
|
||||||
FormalTestManager.currentIssue = firstIssue;
|
|
||||||
FormalTestManager.resumeFormalStartTime = LocalDateTime.now();
|
|
||||||
sendFormalCurrentItem(param, firstIssue, type);
|
|
||||||
|
|
||||||
SocketMsg<String> socketMsg = new SocketMsg<>();
|
|
||||||
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
|
||||||
socketMsg.setData(JSON.toJSONString(firstIssue));
|
|
||||||
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + CnSocketUtil.STEP_TAG + type);
|
|
||||||
SocketManager.sendMsg(param.getUserPageId() + CnSocketUtil.SOURCE_TAG, JSON.toJSONString(socketMsg));
|
|
||||||
|
|
||||||
webSocketVO.setDesc(null);
|
|
||||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(webSocketVO));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sendFormalCurrentItem(PreDetectionParam param, SourceIssue issue, String displayType) {
|
|
||||||
if (issue == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
FormalTestManager.currentIssue = issue;
|
|
||||||
String type = StrUtil.isNotBlank(displayType) ? displayType : issue.getType();
|
|
||||||
PowerIndexEnum powerIndexEnum = PowerIndexEnum.getByKey(type);
|
|
||||||
String typeName = powerIndexEnum == null ? type : powerIndexEnum.getDesc();
|
|
||||||
FormalCurrentItemVO currentItem = new FormalCurrentItemVO(
|
|
||||||
type,
|
|
||||||
typeName,
|
|
||||||
issue.getIndex(),
|
|
||||||
StrUtil.blankToDefault(issue.getDesc(), "当前检测小项")
|
|
||||||
);
|
|
||||||
WebServiceManager.sendDetectionMessage(param.getUserPageId(), "formal_current_item", "current", currentItem, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加并且按照slowValueTimeList中的时间去重
|
|
||||||
*
|
|
||||||
* @param devDataList
|
|
||||||
* @param devData
|
|
||||||
*/
|
|
||||||
private void addAndRemoveDuplicate(List<DevData> devDataList, DevData devData) {
|
|
||||||
if (ObjectUtil.isNotNull(devData) && CollUtil.isNotEmpty(devData.getSlowValueTimeList())) {
|
|
||||||
List<DevData.SlowValueTimeDTO> slowValueTimeList1 = devData.getSlowValueTimeList();
|
|
||||||
|
|
||||||
long count1 = devDataList.stream().flatMap(devData1 -> devData.getSlowValueTimeList().stream()).filter(slowValueTimeDTO -> {
|
|
||||||
long count2 = slowValueTimeList1.stream().filter(slowValueTimeDTO1 -> {
|
|
||||||
if (slowValueTimeDTO.getDesc().equals(slowValueTimeDTO1.getDesc())) {
|
|
||||||
DevData.SlowValueTimeDTO.ListDTO list = slowValueTimeDTO.getList();
|
|
||||||
DevData.SlowValueTimeDTO.ListDTO list1 = slowValueTimeDTO1.getList();
|
|
||||||
String a = list.getA();
|
|
||||||
String b = list.getB();
|
|
||||||
String c = list.getC();
|
|
||||||
String t = list.getT();
|
|
||||||
|
|
||||||
String a1 = list1.getA();
|
|
||||||
String b1 = list1.getB();
|
|
||||||
String c1 = list1.getC();
|
|
||||||
String t1 = list1.getT();
|
|
||||||
if (StrUtil.equals(a, a1) && StrUtil.equals(b, b1) && StrUtil.equals(c, c1) && StrUtil.equals(t, t1)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}).count();
|
|
||||||
|
|
||||||
return count2 > 0;
|
|
||||||
}).count();
|
|
||||||
|
|
||||||
if (count1 <= 0) {
|
|
||||||
devDataList.add(devData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 正式检测
|
* 正式检测
|
||||||
*/
|
*/
|
||||||
@@ -1310,40 +1287,16 @@ public class SocketDevResponseService {
|
|||||||
DevData devData = JSON.parseObject(data, DevData.class); //DevData的id值为 设备id_通道号 这种形式
|
DevData devData = JSON.parseObject(data, DevData.class); //DevData的id值为 设备id_通道号 这种形式
|
||||||
SourceResponseCodeEnum dictDataEnumByCode = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode());
|
SourceResponseCodeEnum dictDataEnumByCode = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode());
|
||||||
SourceIssue sourceIssue = SocketManager.getSourceList().get(0);
|
SourceIssue sourceIssue = SocketManager.getSourceList().get(0);
|
||||||
if (FormalTestManager.isImmediatePause()) {
|
|
||||||
successComm.clear();
|
|
||||||
FormalTestManager.realDataXiList.clear();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (Objects.requireNonNull(dictDataEnumByCode)) {
|
switch (Objects.requireNonNull(dictDataEnumByCode)) {
|
||||||
case SUCCESS:
|
case SUCCESS:
|
||||||
if (devData.getResult()) {
|
if (devData.getResult()) {
|
||||||
// 判断是否是长闪数据
|
FormalTestManager.realDataXiList.add(devData);
|
||||||
if (PowerIndexEnum.LF.getKey().equals(sourceIssue.getOtherType())) {
|
successComm.add(devData.getId());
|
||||||
List<DevData.SqlDataDTO> sqlData = devData.getSqlData();
|
|
||||||
if (CollUtil.isNotEmpty(sqlData)) {
|
|
||||||
if (isEvenHour(devData.getTime())) {
|
|
||||||
if (FormalTestManager.longFlickerDataCount >= FormalTestManager.monitorIdListComm.size()) {
|
|
||||||
FormalTestManager.realDataXiList.add(devData);
|
|
||||||
successComm.add(devData.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
//成功收到数据后重置超时统计时间
|
//成功收到数据后重置超时统计时间
|
||||||
if (SocketManager.clockMap.containsKey(sourceIssue.getIndex())) {
|
if (SocketManager.clockMap.containsKey(sourceIssue.getIndex())) {
|
||||||
SocketManager.clockMap.put(sourceIssue.getIndex(), 0L);
|
SocketManager.clockMap.put(sourceIssue.getIndex(), 0L);
|
||||||
}
|
|
||||||
FormalTestManager.longFlickerDataCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
FormalTestManager.realDataXiList.add(devData);
|
|
||||||
successComm.add(devData.getId());
|
|
||||||
|
|
||||||
//成功收到数据后重置超时统计时间
|
|
||||||
if (SocketManager.clockMap.containsKey(sourceIssue.getIndex())) {
|
|
||||||
SocketManager.clockMap.put(sourceIssue.getIndex(), 0L);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//当成功的通道数量和检测通道数量相同时进入
|
//当成功的通道数量和检测通道数量相同时进入
|
||||||
@@ -1400,10 +1353,9 @@ public class SocketDevResponseService {
|
|||||||
WebServiceManager.sendDetectionMessage(param.getUserPageId(), socketDataMsg.getRequestId().split(CnSocketUtil.STEP_TAG)[1] + CnSocketUtil.END_TAG, null, resultList, null);
|
WebServiceManager.sendDetectionMessage(param.getUserPageId(), socketDataMsg.getRequestId().split(CnSocketUtil.STEP_TAG)[1] + CnSocketUtil.END_TAG, null, resultList, null);
|
||||||
}
|
}
|
||||||
//在这一步判断是否已经触发暂停按钮
|
//在这一步判断是否已经触发暂停按钮
|
||||||
if (FormalTestManager.stopFlag
|
if (FormalTestManager.stopFlag && CollUtil.isNotEmpty(SocketManager.getSourceList())) {
|
||||||
&& FormalTestManager.isWaitCurrentItemPause()
|
FormalTestManager.stopTime = 0;
|
||||||
&& CollUtil.isNotEmpty(SocketManager.getSourceList())) {
|
FormalTestManager.hasStopFlag = true;
|
||||||
FormalTestManager.markPausedAfterCurrentItem();
|
|
||||||
successComm.clear();
|
successComm.clear();
|
||||||
FormalTestManager.realDataXiList.clear();
|
FormalTestManager.realDataXiList.clear();
|
||||||
sendWebSocket(param.getUserPageId(), "preStopTest", "stop", null);
|
sendWebSocket(param.getUserPageId(), "preStopTest", "stop", null);
|
||||||
@@ -1417,7 +1369,7 @@ public class SocketDevResponseService {
|
|||||||
|
|
||||||
String type = sourceIssues.getType();
|
String type = sourceIssues.getType();
|
||||||
if (StrUtil.isNotBlank(sourceIssues.getOtherType())) {
|
if (StrUtil.isNotBlank(sourceIssues.getOtherType())) {
|
||||||
sourceIssues.setType(PowerIndexEnum.LF.getKey().equals(sourceIssues.getOtherType()) ? PowerIndexEnum.F.getKey() : PowerIndexEnum.V.getKey());
|
sourceIssues.setType(ResultUnitEnum.V_ABSOLUTELY.getCode());
|
||||||
type = sourceIssues.getOtherType();
|
type = sourceIssues.getOtherType();
|
||||||
}
|
}
|
||||||
// 如果上一个大项检测完成,则检测下一个大项,并向前端推送消息
|
// 如果上一个大项检测完成,则检测下一个大项,并向前端推送消息
|
||||||
@@ -1430,8 +1382,6 @@ public class SocketDevResponseService {
|
|||||||
xuMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
xuMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||||
xuMsg.setData(JSON.toJSONString(sourceIssues));
|
xuMsg.setData(JSON.toJSONString(sourceIssues));
|
||||||
xuMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + CnSocketUtil.STEP_TAG + type);
|
xuMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + CnSocketUtil.STEP_TAG + type);
|
||||||
FormalTestManager.currentIssue = sourceIssues;
|
|
||||||
sendFormalCurrentItem(param, sourceIssues, type);
|
|
||||||
SocketManager.sendMsg(param.getUserPageId() + CnSocketUtil.SOURCE_TAG, JSON.toJSONString(xuMsg));
|
SocketManager.sendMsg(param.getUserPageId() + CnSocketUtil.SOURCE_TAG, JSON.toJSONString(xuMsg));
|
||||||
} else {
|
} else {
|
||||||
//TODO 是否最终检测完成需要推送给用户
|
//TODO 是否最终检测完成需要推送给用户
|
||||||
@@ -1825,7 +1775,9 @@ public class SocketDevResponseService {
|
|||||||
SocketManager.clockMap.clear();
|
SocketManager.clockMap.clear();
|
||||||
successComm.clear();
|
successComm.clear();
|
||||||
|
|
||||||
FormalTestManager.clearPauseState();
|
FormalTestManager.stopFlag = false;
|
||||||
|
FormalTestManager.hasStopFlag = false;
|
||||||
|
FormalTestManager.stopTime = 0;
|
||||||
|
|
||||||
//初始化相序集合
|
//初始化相序集合
|
||||||
this.devInfo.clear();
|
this.devInfo.clear();
|
||||||
@@ -1863,7 +1815,7 @@ public class SocketDevResponseService {
|
|||||||
//字典树
|
//字典树
|
||||||
SocketManager.valueTypeMap = iPqScriptCheckDataService.getValueTypeMap(param.getScriptId());
|
SocketManager.valueTypeMap = iPqScriptCheckDataService.getValueTypeMap(param.getScriptId());
|
||||||
|
|
||||||
if (param.isCoefficientSelected()) {
|
if (param.getTestItemList().get(1)) {
|
||||||
initXiManager(param);
|
initXiManager(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1995,16 +1947,6 @@ public class SocketDevResponseService {
|
|||||||
System.out.println(XiNumberManager.xiSourceIssueList);
|
System.out.println(XiNumberManager.xiSourceIssueList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断时间是否为偶数小时
|
|
||||||
*
|
|
||||||
* @param timeStr
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private boolean isEvenHour(String timeStr) {
|
|
||||||
LocalDateTime localDateTime = DetectionUtil.timeFormat(timeStr, DetectionUtil.FORMATTER);
|
|
||||||
return localDateTime.getHour() % 2 == 0 && localDateTime.getMinute() == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 原始数据入库
|
* 原始数据入库
|
||||||
@@ -2072,7 +2014,7 @@ public class SocketDevResponseService {
|
|||||||
adHarmonicResult.setAdType(checkDataMap.get(sqlDataDTO.getDesc()));
|
adHarmonicResult.setAdType(checkDataMap.get(sqlDataDTO.getDesc()));
|
||||||
adHarmonicResult.setDataType(sourceIssue.getDataType());
|
adHarmonicResult.setDataType(sourceIssue.getDataType());
|
||||||
|
|
||||||
if (!PowerIndexEnum.HSV.getKey().equals(sourceIssue.getType()) && !PowerIndexEnum.HSI.getKey().equals(sourceIssue.getType()) && !PowerIndexEnum.HP.getKey().equals(sourceIssue.getType())) {
|
if (!DicDataEnum.HSV.getCode().equals(sourceIssue.getType()) && !DicDataEnum.HSI.getCode().equals(sourceIssue.getType()) && !DicDataEnum.HP.getCode().equals(sourceIssue.getType())) {
|
||||||
if (CollUtil.isNotEmpty(data.getSqlData())) {
|
if (CollUtil.isNotEmpty(data.getSqlData())) {
|
||||||
DevData.SqlDataDTO.ListDTO vvv = data.getSqlData().stream().filter(it -> it.getDesc().equals(dui)).collect(Collectors.toList()).get(0).getList();
|
DevData.SqlDataDTO.ListDTO vvv = data.getSqlData().stream().filter(it -> it.getDesc().equals(dui)).collect(Collectors.toList()).get(0).getList();
|
||||||
Double aV = vvv.getA();
|
Double aV = vvv.getA();
|
||||||
@@ -2097,7 +2039,7 @@ public class SocketDevResponseService {
|
|||||||
List<String> c = tem.getC();
|
List<String> c = tem.getC();
|
||||||
|
|
||||||
Class<SimAndDigHarmonicResult> example = (Class<SimAndDigHarmonicResult>) adHarmonicResult.getClass();
|
Class<SimAndDigHarmonicResult> example = (Class<SimAndDigHarmonicResult>) adHarmonicResult.getClass();
|
||||||
if (PowerIndexEnum.HSV.getKey().equals(sourceIssue.getType()) || PowerIndexEnum.HSI.getKey().equals(sourceIssue.getType())) {
|
if (DicDataEnum.HSV.getCode().equals(sourceIssue.getType()) || DicDataEnum.HSI.getCode().equals(sourceIssue.getType())) {
|
||||||
for (int i = 1; i < a.size() + 1; i++) {
|
for (int i = 1; i < a.size() + 1; i++) {
|
||||||
try {
|
try {
|
||||||
Field aField = example.getDeclaredField("aValue" + i);
|
Field aField = example.getDeclaredField("aValue" + i);
|
||||||
|
|||||||
@@ -17,10 +17,11 @@ import com.njcn.gather.device.pojo.vo.PreDetection;
|
|||||||
import com.njcn.gather.device.service.IPqDevService;
|
import com.njcn.gather.device.service.IPqDevService;
|
||||||
import com.njcn.gather.plan.pojo.po.AdPlanSource;
|
import com.njcn.gather.plan.pojo.po.AdPlanSource;
|
||||||
import com.njcn.gather.plan.service.IAdPlanSourceService;
|
import com.njcn.gather.plan.service.IAdPlanSourceService;
|
||||||
import com.njcn.gather.report.pojo.enums.PowerIndexEnum;
|
import com.njcn.gather.result.pojo.enums.ResultUnitEnum;
|
||||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||||
import com.njcn.gather.source.pojo.po.SourceInitialize;
|
import com.njcn.gather.source.pojo.po.SourceInitialize;
|
||||||
import com.njcn.gather.source.service.IPqSourceService;
|
import com.njcn.gather.source.service.IPqSourceService;
|
||||||
|
import com.njcn.gather.system.pojo.enums.DicDataEnum;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
@@ -385,8 +386,8 @@ public class SocketSourceResponseService {
|
|||||||
|
|
||||||
//重新下发脚本
|
//重新下发脚本
|
||||||
String type = FormalTestManager.currentIssue.getType();
|
String type = FormalTestManager.currentIssue.getType();
|
||||||
if (PowerIndexEnum.P.getKey().equals(type)) {
|
if (ResultUnitEnum.P.getCode().equals(type)) {
|
||||||
FormalTestManager.currentIssue.setType(PowerIndexEnum.V.getKey());
|
FormalTestManager.currentIssue.setType(ResultUnitEnum.V_ABSOLUTELY.getCode());
|
||||||
}
|
}
|
||||||
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||||
socketMsg.setData(JSON.toJSONString(FormalTestManager.currentIssue));
|
socketMsg.setData(JSON.toJSONString(FormalTestManager.currentIssue));
|
||||||
@@ -537,21 +538,14 @@ public class SocketSourceResponseService {
|
|||||||
int ignoreCount;
|
int ignoreCount;
|
||||||
int readData;
|
int readData;
|
||||||
|
|
||||||
if (PowerIndexEnum.F.getKey().equals(sourceIssue.getType())) {
|
if (DicDataEnum.F.getCode().equals(sourceIssue.getType())) {
|
||||||
// 短时间闪变检测:数据变化较慢,只需少量预热和读取
|
// 闪变检测:数据变化较慢,只需少量预热和读取
|
||||||
// 短时间闪变测量稳定性好,预热1次即可
|
// 闪变测量稳定性好,预热1次即可
|
||||||
ignoreCount = 1;
|
ignoreCount = 1;
|
||||||
// 读取2次数据计算闪变值
|
// 读取2次数据计算闪变值
|
||||||
readData = 2;
|
readData = 2;
|
||||||
|
|
||||||
if (PowerIndexEnum.LF.getKey().equals(sourceIssue.getOtherType())) {
|
|
||||||
FormalTestManager.longFlickerDataCount = 0;
|
|
||||||
// 长时间闪变检测
|
|
||||||
ignoreCount = 0;
|
|
||||||
readData = 0;
|
|
||||||
}
|
|
||||||
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_01.getValue());
|
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_01.getValue());
|
||||||
} else if (PowerIndexEnum.VOLTAGE.getKey().equals(sourceIssue.getType())) {
|
} else if (DicDataEnum.VOLTAGE.getCode().equals(sourceIssue.getType())) {
|
||||||
// 暂态电压检测:需要更多预热时间,但只读取一次快照
|
// 暂态电压检测:需要更多预热时间,但只读取一次快照
|
||||||
// 暂态事件需要5次预热确保触发稳定
|
// 暂态事件需要5次预热确保触发稳定
|
||||||
ignoreCount = 5;
|
ignoreCount = 5;
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ public enum DetectionCodeEnum {
|
|||||||
I_UNBAN("I_UNBAN", "三相电流负序不平衡度"),
|
I_UNBAN("I_UNBAN", "三相电流负序不平衡度"),
|
||||||
SeqA("SeqA", "电流序分量"),
|
SeqA("SeqA", "电流序分量"),
|
||||||
PST("PST", "短时间闪变"),
|
PST("PST", "短时间闪变"),
|
||||||
PLT("PLT", "长时间闪变"),
|
|
||||||
W("W", "总有功功率"),
|
W("W", "总有功功率"),
|
||||||
VARW("VARW", "总无功功率"),
|
VARW("VARW", "总无功功率"),
|
||||||
VAW("VAW", "总视在功率"),
|
VAW("VAW", "总视在功率"),
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
package com.njcn.gather.detection.pojo.param;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class ClosePreTestParam {
|
|
||||||
|
|
||||||
private Boolean waitCurrentItem;
|
|
||||||
|
|
||||||
public boolean isWaitCurrentItem() {
|
|
||||||
return !Boolean.FALSE.equals(waitCurrentItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -38,31 +38,10 @@ public class ContrastDetectionParam {
|
|||||||
@NotEmpty(message = DetectionValidMessage.PAIRS_NOT_EMPTY)
|
@NotEmpty(message = DetectionValidMessage.PAIRS_NOT_EMPTY)
|
||||||
private Map<String, String> pairs;
|
private Map<String, String> pairs;
|
||||||
/**
|
/**
|
||||||
* 检测项列表。第一个元素为预检测、第二个元素为系数校准、第三个元素为守时校验、第四个元素为正式检测。
|
* 检测项列表。第一个元素为预检测、第二个元素为系数校准、第三个元素为正式检测
|
||||||
* 比对场景暂不支持系数校准和守时校验,第二、第三个元素固定为 false。
|
|
||||||
*/
|
*/
|
||||||
private List<Boolean> testItemList;
|
private List<Boolean> testItemList;
|
||||||
|
|
||||||
public boolean isPreTestSelected() {
|
|
||||||
return isTestItemSelected(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCoefficientSelected() {
|
|
||||||
return isTestItemSelected(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isTimeCheckSelected() {
|
|
||||||
return isTestItemSelected(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isFormalTestSelected() {
|
|
||||||
return isTestItemSelected(3);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isTestItemSelected(int index) {
|
|
||||||
return testItemList != null && testItemList.size() > index && Boolean.TRUE.equals(testItemList.get(index));
|
|
||||||
}
|
|
||||||
|
|
||||||
private String userId;
|
private String userId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
package com.njcn.gather.detection.pojo.param;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
|
||||||
import javax.validation.constraints.NotEmpty;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class FormalProgressParam {
|
|
||||||
@NotBlank(message = "计划id不可为空")
|
|
||||||
private String planId;
|
|
||||||
|
|
||||||
@NotEmpty(message = "装置不能为空")
|
|
||||||
private List<String> devIds;
|
|
||||||
|
|
||||||
private String userPageId;
|
|
||||||
|
|
||||||
private String userId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存暂存进度时必传;查询/放行续检时以后端设备表为准。
|
|
||||||
*/
|
|
||||||
private Integer formalCheckTime;
|
|
||||||
}
|
|
||||||
@@ -5,6 +5,7 @@ import lombok.Data;
|
|||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author wr
|
* @author wr
|
||||||
@@ -75,36 +76,7 @@ public class PreDetectionParam {
|
|||||||
private Float humidity;
|
private Float humidity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检测项列表。第一个元素为预检测、第二个元素为系数校准、第三个元素为守时校验、第四个元素为正式检测
|
* 检测项列表。第一个元素为预检测、第二个元素为系数校准、第三个元素为正式检测
|
||||||
*/
|
*/
|
||||||
private List<Boolean> testItemList;
|
private List<Boolean> testItemList;
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否从正式检测暂存进度续检
|
|
||||||
*/
|
|
||||||
private Boolean resumeFormal;
|
|
||||||
|
|
||||||
public boolean isPreTestSelected() {
|
|
||||||
return isTestItemSelected(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCoefficientSelected() {
|
|
||||||
return isTestItemSelected(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isTimeCheckSelected() {
|
|
||||||
return isTestItemSelected(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isFormalTestSelected() {
|
|
||||||
return isTestItemSelected(3);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isResumeFormal() {
|
|
||||||
return Boolean.TRUE.equals(resumeFormal);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isTestItemSelected(int index) {
|
|
||||||
return testItemList != null && testItemList.size() > index && Boolean.TRUE.equals(testItemList.get(index));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,9 +33,6 @@ public class DevData {
|
|||||||
@JSONField(name = "SqlDataHarm", ordinal = 5)
|
@JSONField(name = "SqlDataHarm", ordinal = 5)
|
||||||
private List<SqlDataHarmDTO> sqlDataHarm;
|
private List<SqlDataHarmDTO> sqlDataHarm;
|
||||||
|
|
||||||
@JSONField(name = "SlowValueTimeList", ordinal = 6)
|
|
||||||
private List<SlowValueTimeDTO> slowValueTimeList;
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@Data
|
@Data
|
||||||
public static class SqlDataDTO {
|
public static class SqlDataDTO {
|
||||||
@@ -85,30 +82,4 @@ public class DevData {
|
|||||||
private List<String> c;
|
private List<String> c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class SlowValueTimeDTO {
|
|
||||||
@JSONField(name = "type", ordinal = 1)
|
|
||||||
private String type; // 类似于 real、avg 、max、min、cp95
|
|
||||||
|
|
||||||
@JSONField(name = "desc", ordinal = 2)
|
|
||||||
private String desc; // 类似于 FREQ、PST、IRMS、VRMS等指标项
|
|
||||||
|
|
||||||
@JSONField(name = "list", ordinal = 3)
|
|
||||||
private ListDTO list;
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class ListDTO {
|
|
||||||
@JSONField(name = "A", ordinal = 1)
|
|
||||||
private String a; // 表示时间 "2026-07-15T08:42:54.705"
|
|
||||||
@JSONField(name = "B", ordinal = 2)
|
|
||||||
private String b;
|
|
||||||
@JSONField(name = "C", ordinal = 3)
|
|
||||||
private String c;
|
|
||||||
@JSONField(name = "T", ordinal = 4)
|
|
||||||
private String t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
package com.njcn.gather.detection.pojo.vo;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class FormalCurrentItemVO {
|
|
||||||
|
|
||||||
private String type;
|
|
||||||
|
|
||||||
private String typeName;
|
|
||||||
|
|
||||||
private Integer index;
|
|
||||||
|
|
||||||
private String desc;
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
package com.njcn.gather.detection.pojo.vo;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class FormalProgressVO {
|
|
||||||
private Integer formalCheckTime;
|
|
||||||
private Integer minMaxSort;
|
|
||||||
private Integer nextSort;
|
|
||||||
private Double process;
|
|
||||||
private List<TableRow> tableRows = new ArrayList<>();
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class TableRow {
|
|
||||||
private String scriptType;
|
|
||||||
private String scriptCode;
|
|
||||||
private String scriptName;
|
|
||||||
private List<DeviceResult> devices = new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class DeviceResult {
|
|
||||||
private String deviceId;
|
|
||||||
private String deviceName;
|
|
||||||
private List<Integer> chnResult = new ArrayList<>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package com.njcn.gather.detection.service;
|
|
||||||
|
|
||||||
import com.njcn.gather.detection.pojo.param.FormalProgressParam;
|
|
||||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
|
||||||
import com.njcn.gather.detection.pojo.vo.FormalProgressVO;
|
|
||||||
|
|
||||||
public interface FormalProgressService {
|
|
||||||
FormalProgressVO restoreAndRelease(FormalProgressParam param);
|
|
||||||
|
|
||||||
Integer calculateNextSort(PreDetectionParam param);
|
|
||||||
}
|
|
||||||
@@ -1,10 +1,8 @@
|
|||||||
package com.njcn.gather.detection.service;
|
package com.njcn.gather.detection.service;
|
||||||
|
|
||||||
import com.njcn.gather.detection.pojo.param.ContrastDetectionParam;
|
import com.njcn.gather.detection.pojo.param.ContrastDetectionParam;
|
||||||
import com.njcn.gather.detection.pojo.param.FormalProgressParam;
|
|
||||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||||
import com.njcn.gather.detection.pojo.param.SimulateDetectionParam;
|
import com.njcn.gather.detection.pojo.param.SimulateDetectionParam;
|
||||||
import com.njcn.gather.detection.pojo.vo.FormalProgressVO;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -30,15 +28,11 @@ public interface PreDetectionService {
|
|||||||
void coefficientCheck(PreDetectionParam param);
|
void coefficientCheck(PreDetectionParam param);
|
||||||
|
|
||||||
|
|
||||||
boolean temStopTest(String userPageId, boolean waitCurrentItem);
|
boolean temStopTest();
|
||||||
|
|
||||||
|
|
||||||
boolean restartTemTest(PreDetectionParam param);
|
boolean restartTemTest(PreDetectionParam param);
|
||||||
|
|
||||||
void saveFormalProgress(FormalProgressParam param);
|
|
||||||
|
|
||||||
FormalProgressVO formalProgress(FormalProgressParam param);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 模拟测试-源通讯校验
|
* 模拟测试-源通讯校验
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import com.njcn.gather.monitor.pojo.po.PqMonitor;
|
|||||||
import com.njcn.gather.monitor.service.IPqMonitorService;
|
import com.njcn.gather.monitor.service.IPqMonitorService;
|
||||||
import com.njcn.gather.plan.pojo.enums.DataSourceEnum;
|
import com.njcn.gather.plan.pojo.enums.DataSourceEnum;
|
||||||
import com.njcn.gather.report.pojo.enums.PowerIndexEnum;
|
import com.njcn.gather.report.pojo.enums.PowerIndexEnum;
|
||||||
|
import com.njcn.gather.result.pojo.enums.ResultUnitEnum;
|
||||||
import com.njcn.gather.script.mapper.PqScriptMapper;
|
import com.njcn.gather.script.mapper.PqScriptMapper;
|
||||||
import com.njcn.gather.script.pojo.po.PqScriptCheckData;
|
import com.njcn.gather.script.pojo.po.PqScriptCheckData;
|
||||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||||
@@ -81,6 +82,7 @@ public class DetectionServiceImpl {
|
|||||||
public static final String TYPE_T = "T";
|
public static final String TYPE_T = "T";
|
||||||
private final String U = "U";
|
private final String U = "U";
|
||||||
private final String I = "I";
|
private final String I = "I";
|
||||||
|
private final String F = "F";
|
||||||
private final String HP = "HP";
|
private final String HP = "HP";
|
||||||
private final String P = "P";
|
private final String P = "P";
|
||||||
private final String MAG = "MAG";
|
private final String MAG = "MAG";
|
||||||
@@ -161,31 +163,33 @@ public class DetectionServiceImpl {
|
|||||||
param.setIn(sourceIssue.getFIn());
|
param.setIn(sourceIssue.getFIn());
|
||||||
SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
|
SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
|
||||||
List<ErrDtlsCheckDataVO> errDtlsCheckData = pqErrSysDtlsService.listByPqErrSysIdAndTypes(param);
|
List<ErrDtlsCheckDataVO> errDtlsCheckData = pqErrSysDtlsService.listByPqErrSysIdAndTypes(param);
|
||||||
PowerIndexEnum powerIndexEnum = PowerIndexEnum.getByKey(sourceIssue.getType());
|
ResultUnitEnum resultUnitEnumByCode = ResultUnitEnum.getResultUnitEnumByCode(sourceIssue.getType());
|
||||||
if (StrUtil.isNotBlank(sourceIssue.getOtherType())) {
|
if (StrUtil.isNotBlank(sourceIssue.getOtherType())) {
|
||||||
powerIndexEnum = PowerIndexEnum.getByKey(sourceIssue.getOtherType());
|
resultUnitEnumByCode = ResultUnitEnum.getResultUnitEnumByCode(sourceIssue.getOtherType());
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (powerIndexEnum) {
|
switch (resultUnitEnumByCode) {
|
||||||
/**
|
/**
|
||||||
* 频率
|
* 频率
|
||||||
*/
|
*/
|
||||||
case FREQ:
|
case FREQ:
|
||||||
return isQualified(dev, devIdMapComm, errDtlsCheckData, PowerIndexEnum.FREQ.getKey(), sourceIssue, dataRule, code, oneConfig.getScale());
|
return isQualified(dev, devIdMapComm, errDtlsCheckData, F, sourceIssue, dataRule, code, oneConfig.getScale());
|
||||||
case P:
|
case P:
|
||||||
return isQualified(dev, devIdMapComm, errDtlsCheckData, PowerIndexEnum.P.getKey(), sourceIssue, dataRule, code, oneConfig.getScale());
|
return isQualified(dev, devIdMapComm, errDtlsCheckData, P, sourceIssue, dataRule, code, oneConfig.getScale());
|
||||||
case ANGLE:
|
case ANGLE:
|
||||||
return isQualified(dev, devIdMapComm, errDtlsCheckData, PowerIndexEnum.ANGLE.getKey(), sourceIssue, dataRule, code, oneConfig.getScale());
|
return isQualified(dev, devIdMapComm, errDtlsCheckData, resultUnitEnumByCode.getCode(), sourceIssue, dataRule, code, oneConfig.getScale());
|
||||||
/**
|
/**
|
||||||
* 电压
|
* 电压
|
||||||
*/
|
*/
|
||||||
case V:
|
case V_RELATIVE:
|
||||||
return isQualified(dev, devIdMapComm, errDtlsCheckData, PowerIndexEnum.V.getKey(), sourceIssue, dataRule, code, oneConfig.getScale());
|
case V_ABSOLUTELY:
|
||||||
|
return isQualified(dev, devIdMapComm, errDtlsCheckData, U, sourceIssue, dataRule, code, oneConfig.getScale());
|
||||||
/**
|
/**
|
||||||
* 电流
|
* 电流
|
||||||
*/
|
*/
|
||||||
case I:
|
case I_RELATIVE:
|
||||||
return isQualified(dev, devIdMapComm, errDtlsCheckData, PowerIndexEnum.I.getKey(), sourceIssue, dataRule, code, oneConfig.getScale());
|
case I_ABSOLUTELY:
|
||||||
|
return isQualified(dev, devIdMapComm, errDtlsCheckData, I, sourceIssue, dataRule, code, oneConfig.getScale());
|
||||||
/**
|
/**
|
||||||
* 谐波
|
* 谐波
|
||||||
*/
|
*/
|
||||||
@@ -226,12 +230,12 @@ public class DetectionServiceImpl {
|
|||||||
* 闪变
|
* 闪变
|
||||||
*/
|
*/
|
||||||
case F:
|
case F:
|
||||||
case LF:
|
|
||||||
return isUnBalanceOrFlickerQualified(dev, devIdMapComm, errDtlsCheckData, DetectionCodeEnum.PST.getCode(), sourceIssue, dataRule, code, oneConfig.getScale());
|
return isUnBalanceOrFlickerQualified(dev, devIdMapComm, errDtlsCheckData, DetectionCodeEnum.PST.getCode(), sourceIssue, dataRule, code, oneConfig.getScale());
|
||||||
/**
|
/**
|
||||||
* 暂态
|
* 暂态
|
||||||
*/
|
*/
|
||||||
case VOLTAGE:
|
case VOLTAGE_MAG:
|
||||||
|
case VOLTAGE_DUR:
|
||||||
return isVoltageQualified(dev, devIdMapComm, errDtlsCheckData, sourceIssue, dataRule, code, oneConfig.getScale());
|
return isVoltageQualified(dev, devIdMapComm, errDtlsCheckData, sourceIssue, dataRule, code, oneConfig.getScale());
|
||||||
default:
|
default:
|
||||||
return isUnknownQualified(dev, devIdMapComm, errDtlsCheckData, sourceIssue, dataRule, code, oneConfig.getScale());
|
return isUnknownQualified(dev, devIdMapComm, errDtlsCheckData, sourceIssue, dataRule, code, oneConfig.getScale());
|
||||||
@@ -424,17 +428,17 @@ public class DetectionServiceImpl {
|
|||||||
dtlsCheckData = errDtlsCheckData.stream().filter(x -> x.getValueTypeCode().equals(splitArr[1])).collect(Collectors.toList());
|
dtlsCheckData = errDtlsCheckData.stream().filter(x -> x.getValueTypeCode().equals(splitArr[1])).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
Double fData = 1.0;
|
Double fData = 1.0;
|
||||||
if (PowerIndexEnum.V.getKey().equals(type)) {
|
if (U.equals(type)) {
|
||||||
fData = sourceIssue.getFUn();
|
fData = sourceIssue.getFUn();
|
||||||
}
|
}
|
||||||
if (PowerIndexEnum.I.getKey().equals(type)) {
|
if (I.equals(type)) {
|
||||||
fData = sourceIssue.getFIn();
|
fData = sourceIssue.getFIn();
|
||||||
}
|
}
|
||||||
if (PowerIndexEnum.FREQ.getKey().equals(type)) {
|
if (F.equals(type)) {
|
||||||
fData = sourceIssue.getFFreq();
|
fData = sourceIssue.getFFreq();
|
||||||
}
|
}
|
||||||
if (PowerIndexEnum.P.getKey().equals(type)) {
|
if (P.equals(type)) {
|
||||||
if (!DetectionCodeEnum.PF.getCode().equals(splitArr[1]) && !DetectionCodeEnum.TOTPF.getCode().equals(splitArr[1])) {
|
if (!DetectionCodeEnum.PF.getCode().equals(splitArr[1])) {
|
||||||
Boolean valueType = pqScriptMapper.selectScriptIsValueType(sourceIssue.getScriptId());
|
Boolean valueType = pqScriptMapper.selectScriptIsValueType(sourceIssue.getScriptId());
|
||||||
if (valueType) {
|
if (valueType) {
|
||||||
fData = sourceIssue.getFUn() * sourceIssue.getFIn() / 100;
|
fData = sourceIssue.getFUn() * sourceIssue.getFIn() / 100;
|
||||||
@@ -484,7 +488,7 @@ public class DetectionServiceImpl {
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
if (CollUtil.isNotEmpty(checkData)) {
|
if (CollUtil.isNotEmpty(checkData)) {
|
||||||
List<Double> phaseValue = map.get(phase);
|
List<Double> phaseValue = map.get(phase);
|
||||||
if (PowerIndexEnum.ANGLE.getKey().equals(type)) {
|
if (ResultUnitEnum.ANGLE.getCode().equals(type)) {
|
||||||
phaseValue = phaseValue.stream().map(x -> {
|
phaseValue = phaseValue.stream().map(x -> {
|
||||||
// 原始误差值
|
// 原始误差值
|
||||||
double originDiff = x - checkData.get(0).getValue();
|
double originDiff = x - checkData.get(0).getValue();
|
||||||
@@ -539,15 +543,11 @@ public class DetectionServiceImpl {
|
|||||||
SourceIssue sourceIssue,
|
SourceIssue sourceIssue,
|
||||||
DictDataEnum dataRule,
|
DictDataEnum dataRule,
|
||||||
Integer num, Integer scale) {
|
Integer num, Integer scale) {
|
||||||
Double fDataA = 1.0;
|
Double fData = 1.0;
|
||||||
Double fDataB = 1.0;
|
|
||||||
Double fDataC = 1.0;
|
|
||||||
String fundCode = "";
|
String fundCode = "";
|
||||||
String harmCode = "";
|
String harmCode = "";
|
||||||
if (U.equals(type)) {
|
if (U.equals(type)) {
|
||||||
fDataA = sourceIssue.getChannelList().stream().filter(x -> x.getChannelType().contains("Ua")).findFirst().get().getFAmp();
|
fData = sourceIssue.getFUn();
|
||||||
fDataB = sourceIssue.getChannelList().stream().filter(x -> x.getChannelType().contains("Ub")).findFirst().get().getFAmp();
|
|
||||||
fDataC = sourceIssue.getChannelList().stream().filter(x -> x.getChannelType().contains("Uc")).findFirst().get().getFAmp();
|
|
||||||
fundCode = DetectionCodeEnum.U1.getCode();
|
fundCode = DetectionCodeEnum.U1.getCode();
|
||||||
if (num == 1) {
|
if (num == 1) {
|
||||||
harmCode = DetectionCodeEnum.SV_1_49.getCode();
|
harmCode = DetectionCodeEnum.SV_1_49.getCode();
|
||||||
@@ -556,9 +556,7 @@ public class DetectionServiceImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (I.equals(type)) {
|
if (I.equals(type)) {
|
||||||
fDataA = sourceIssue.getChannelList().stream().filter(x -> x.getChannelType().contains("Ia")).findFirst().get().getFAmp();
|
fData = sourceIssue.getFIn();
|
||||||
fDataB = sourceIssue.getChannelList().stream().filter(x -> x.getChannelType().contains("Ib")).findFirst().get().getFAmp();
|
|
||||||
fDataC = sourceIssue.getChannelList().stream().filter(x -> x.getChannelType().contains("Ic")).findFirst().get().getFAmp();
|
|
||||||
fundCode = DetectionCodeEnum.I1.getCode();
|
fundCode = DetectionCodeEnum.I1.getCode();
|
||||||
if (num == 1) {
|
if (num == 1) {
|
||||||
harmCode = DetectionCodeEnum.SI_1_49.getCode();
|
harmCode = DetectionCodeEnum.SI_1_49.getCode();
|
||||||
@@ -567,9 +565,7 @@ public class DetectionServiceImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (HP.equals(type)) {
|
if (HP.equals(type)) {
|
||||||
fDataA = (sourceIssue.getFIn() * sourceIssue.getFUn()) * 0.01;
|
fData = (sourceIssue.getFIn() * sourceIssue.getFUn()) * 0.01;
|
||||||
fDataB = (sourceIssue.getFIn() * sourceIssue.getFUn()) * 0.01;
|
|
||||||
fDataC = (sourceIssue.getFIn() * sourceIssue.getFUn()) * 0.01;
|
|
||||||
harmCode = DetectionCodeEnum.P2_50.getCode();
|
harmCode = DetectionCodeEnum.P2_50.getCode();
|
||||||
}
|
}
|
||||||
// if (P.equals(type)) {
|
// if (P.equals(type)) {
|
||||||
@@ -595,9 +591,9 @@ public class DetectionServiceImpl {
|
|||||||
pqErrSysDtls = adDtlsCheckData.get(0).getErrSysDtls();
|
pqErrSysDtls = adDtlsCheckData.get(0).getErrSysDtls();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<DetectionData> integerBooleanA = harmRangeComparison(isQualified, pqErrSysDtls, type, TYPE_A, sourceIssue, dataRule, devMap.get(TYPE_A), fDataA, num, scale);
|
List<DetectionData> integerBooleanA = harmRangeComparison(isQualified, pqErrSysDtls, type, TYPE_A, sourceIssue, dataRule, devMap.get(TYPE_A), fData, num, scale);
|
||||||
List<DetectionData> integerBooleanB = harmRangeComparison(isQualified, pqErrSysDtls, type, TYPE_B, sourceIssue, dataRule, devMap.get(TYPE_B), fDataB, num, scale);
|
List<DetectionData> integerBooleanB = harmRangeComparison(isQualified, pqErrSysDtls, type, TYPE_B, sourceIssue, dataRule, devMap.get(TYPE_B), fData, num, scale);
|
||||||
List<DetectionData> integerBooleanC = harmRangeComparison(isQualified, pqErrSysDtls, type, TYPE_C, sourceIssue, dataRule, devMap.get(TYPE_C), fDataC, num, scale);
|
List<DetectionData> integerBooleanC = harmRangeComparison(isQualified, pqErrSysDtls, type, TYPE_C, sourceIssue, dataRule, devMap.get(TYPE_C), fData, num, scale);
|
||||||
harmonicResult.setDataType(sourceIssue.getDataType());
|
harmonicResult.setDataType(sourceIssue.getDataType());
|
||||||
reflectHarmonic(false, "a", integerBooleanA, harmonicResult, num);
|
reflectHarmonic(false, "a", integerBooleanA, harmonicResult, num);
|
||||||
reflectHarmonic(false, "b", integerBooleanB, harmonicResult, num);
|
reflectHarmonic(false, "b", integerBooleanB, harmonicResult, num);
|
||||||
@@ -668,7 +664,7 @@ public class DetectionServiceImpl {
|
|||||||
}
|
}
|
||||||
result.setResultFlag(isQualified);
|
result.setResultFlag(isQualified);
|
||||||
// 闪变
|
// 闪变
|
||||||
if (DetectionCodeEnum.PST.getCode().equals(splitArr[1]) || DetectionCodeEnum.PLT.getCode().equals(splitArr[1]) || DetectionCodeEnum.SeqV.getCode().equals(splitArr[1]) || DetectionCodeEnum.SeqA.getCode().equals(splitArr[1])) {
|
if (DetectionCodeEnum.PST.getCode().equals(splitArr[1]) || DetectionCodeEnum.SeqV.getCode().equals(splitArr[1]) || DetectionCodeEnum.SeqA.getCode().equals(splitArr[1])) {
|
||||||
|
|
||||||
//取出源所对应的相别信息
|
//取出源所对应的相别信息
|
||||||
List<PqScriptCheckData> channelTypeAList = checkData.stream()
|
List<PqScriptCheckData> channelTypeAList = checkData.stream()
|
||||||
|
|||||||
@@ -1,218 +0,0 @@
|
|||||||
package com.njcn.gather.detection.service.impl;
|
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
|
||||||
import com.njcn.gather.detection.handler.SocketDevResponseService;
|
|
||||||
import com.njcn.gather.detection.pojo.param.FormalProgressParam;
|
|
||||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
|
||||||
import com.njcn.gather.detection.pojo.vo.FormalProgressVO;
|
|
||||||
import com.njcn.gather.detection.service.FormalProgressService;
|
|
||||||
import com.njcn.gather.detection.util.socket.websocket.WebServiceManager;
|
|
||||||
import com.njcn.gather.device.pojo.enums.CommonEnum;
|
|
||||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
|
||||||
import com.njcn.gather.device.service.IPqDevService;
|
|
||||||
import com.njcn.gather.script.pojo.param.PqScriptIssueParam;
|
|
||||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
|
||||||
import com.njcn.gather.script.service.IPqScriptDtlsService;
|
|
||||||
import com.njcn.gather.storage.pojo.po.SimAndDigBaseResult;
|
|
||||||
import com.njcn.gather.storage.service.SimAndDigHarmonicService;
|
|
||||||
import com.njcn.gather.storage.service.SimAndDigNonHarmonicService;
|
|
||||||
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
|
|
||||||
import com.njcn.gather.system.dictionary.service.IDictTreeService;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
@Slf4j
|
|
||||||
public class FormalProgressServiceImpl implements FormalProgressService {
|
|
||||||
|
|
||||||
private static final long RESUME_RELEASE_DELAY_MILLIS = 300L;
|
|
||||||
|
|
||||||
private final IPqDevService pqDevService;
|
|
||||||
private final IPqScriptDtlsService pqScriptDtlsService;
|
|
||||||
private final IDictTreeService dictTreeService;
|
|
||||||
private final SimAndDigHarmonicService harmonicService;
|
|
||||||
private final SimAndDigNonHarmonicService nonHarmonicService;
|
|
||||||
private final SocketDevResponseService socketDevResponseService;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FormalProgressVO restoreAndRelease(FormalProgressParam param) {
|
|
||||||
PreDetectionParam preParam = WebServiceManager.getPreDetectionParam(param.getUserPageId());
|
|
||||||
if (preParam == null) {
|
|
||||||
throw new BusinessException(CommonResponseEnum.FAIL, "未找到续检上下文,请重新开始检测");
|
|
||||||
}
|
|
||||||
FormalProgressVO vo = buildSnapshot(preParam, param.getDevIds());
|
|
||||||
releaseResumeAfterSnapshotApplied(preParam, vo.getNextSort());
|
|
||||||
return vo;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer calculateNextSort(PreDetectionParam param) {
|
|
||||||
return buildSnapshot(param, param.getDevIds()).getNextSort();
|
|
||||||
}
|
|
||||||
|
|
||||||
private FormalProgressVO buildSnapshot(PreDetectionParam param, List<String> devIds) {
|
|
||||||
FormalProgressVO vo = new FormalProgressVO();
|
|
||||||
vo.setFormalCheckTime(pqDevService.getMinFormalCheckTime(devIds));
|
|
||||||
|
|
||||||
Map<String, Integer> harmonicMax = harmonicService.maxSortByDevIds(param.getCode(), param.getScriptId(), devIds);
|
|
||||||
Map<String, Integer> nonHarmonicMax = nonHarmonicService.maxSortByDevIds(param.getCode(), param.getScriptId(), devIds);
|
|
||||||
|
|
||||||
Integer minMaxSort = devIds.stream()
|
|
||||||
.map(devId -> Math.max(harmonicMax.getOrDefault(devId, -1), nonHarmonicMax.getOrDefault(devId, -1)))
|
|
||||||
.min(Integer::compareTo)
|
|
||||||
.orElse(-1);
|
|
||||||
vo.setMinMaxSort(minMaxSort);
|
|
||||||
|
|
||||||
List<SourceIssue> allIssues = buildAllFormalIssues(param);
|
|
||||||
List<Integer> allSorts = allIssues.stream()
|
|
||||||
.map(SourceIssue::getIndex)
|
|
||||||
.filter(sort -> sort != null && sort >= 0)
|
|
||||||
.sorted()
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
Integer nextSort = allSorts.stream()
|
|
||||||
.filter(sort -> sort > minMaxSort)
|
|
||||||
.findFirst()
|
|
||||||
.orElse(null);
|
|
||||||
vo.setNextSort(nextSort);
|
|
||||||
|
|
||||||
Set<String> completedTypes = completedBigTypes(allIssues, minMaxSort);
|
|
||||||
long totalBigTypes = allIssues.stream().map(SourceIssue::getType).distinct().count();
|
|
||||||
vo.setProcess(totalBigTypes == 0 ? 0D : completedTypes.size() * 100D / totalBigTypes);
|
|
||||||
vo.setTableRows(buildRows(param, devIds, allIssues, completedTypes));
|
|
||||||
return vo;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void releaseResumeAfterSnapshotApplied(PreDetectionParam preParam, Integer nextSort) {
|
|
||||||
CompletableFuture.runAsync(() -> {
|
|
||||||
try {
|
|
||||||
Thread.sleep(RESUME_RELEASE_DELAY_MILLIS);
|
|
||||||
socketDevResponseService.startFormalAfterProgressRestore(preParam, nextSort);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
log.warn("正式检测续检放行等待被中断", e);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("正式检测续检放行失败", e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<SourceIssue> buildAllFormalIssues(PreDetectionParam param) {
|
|
||||||
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
|
||||||
issueParam.setPlanId(param.getPlanId());
|
|
||||||
issueParam.setSourceId(param.getSourceName());
|
|
||||||
issueParam.setDevIds(param.getDevIds());
|
|
||||||
issueParam.setScriptId(param.getScriptId());
|
|
||||||
issueParam.setIsPhaseSequence(CommonEnum.FORMAL_TEST.getValue());
|
|
||||||
return pqScriptDtlsService.listSourceIssue(issueParam)
|
|
||||||
.stream()
|
|
||||||
.sorted(Comparator.comparing(SourceIssue::getIndex))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
private Set<String> completedBigTypes(List<SourceIssue> issues, Integer minMaxSort) {
|
|
||||||
return issues.stream()
|
|
||||||
.collect(Collectors.groupingBy(SourceIssue::getType, LinkedHashMap::new, Collectors.toList()))
|
|
||||||
.entrySet()
|
|
||||||
.stream()
|
|
||||||
.filter(entry -> entry.getValue().stream().allMatch(issue -> issue.getIndex() <= minMaxSort))
|
|
||||||
.map(Map.Entry::getKey)
|
|
||||||
.collect(Collectors.toCollection(LinkedHashSet::new));
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<FormalProgressVO.TableRow> buildRows(PreDetectionParam param,
|
|
||||||
List<String> devIds,
|
|
||||||
List<SourceIssue> issues,
|
|
||||||
Set<String> completedTypes) {
|
|
||||||
Map<String, List<SourceIssue>> byType = issues.stream()
|
|
||||||
.collect(Collectors.groupingBy(SourceIssue::getType, LinkedHashMap::new, Collectors.toList()));
|
|
||||||
if (byType.isEmpty()) {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
Map<String, DictTree> dictTreeByCode = dictTreeService.lambdaQuery()
|
|
||||||
.in(DictTree::getCode, byType.keySet())
|
|
||||||
.list()
|
|
||||||
.stream()
|
|
||||||
.collect(Collectors.toMap(DictTree::getCode, dictTree -> dictTree, (left, right) -> left));
|
|
||||||
return byType.entrySet().stream().map(entry -> {
|
|
||||||
List<SourceIssue> typeIssues = entry.getValue();
|
|
||||||
boolean completed = completedTypes.contains(entry.getKey());
|
|
||||||
DictTree dictTree = dictTreeByCode.get(entry.getKey());
|
|
||||||
FormalProgressVO.TableRow row = new FormalProgressVO.TableRow();
|
|
||||||
row.setScriptCode(entry.getKey());
|
|
||||||
row.setScriptName(dictTree.getName());
|
|
||||||
row.setScriptType(dictTree.getId());
|
|
||||||
row.setDevices(completed
|
|
||||||
? buildCompletedDeviceResults(param, devIds, typeIssues)
|
|
||||||
: buildUnknownDeviceResults(devIds));
|
|
||||||
return row;
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<FormalProgressVO.DeviceResult> buildUnknownDeviceResults(List<String> devIds) {
|
|
||||||
return pqDevService.getDevInfo(devIds).stream().map(dev -> {
|
|
||||||
FormalProgressVO.DeviceResult item = new FormalProgressVO.DeviceResult();
|
|
||||||
item.setDeviceId(dev.getDevId());
|
|
||||||
item.setDeviceName(dev.getDevName());
|
|
||||||
item.setChnResult(dev.getMonitorList().stream().map(monitor -> -1).collect(Collectors.toList()));
|
|
||||||
return item;
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<FormalProgressVO.DeviceResult> buildCompletedDeviceResults(PreDetectionParam param,
|
|
||||||
List<String> devIds,
|
|
||||||
List<SourceIssue> typeIssues) {
|
|
||||||
List<Integer> sorts = typeIssues.stream().map(SourceIssue::getIndex).distinct().collect(Collectors.toList());
|
|
||||||
List<SimAndDigBaseResult> rows = new ArrayList<>();
|
|
||||||
rows.addAll(harmonicService.listByDevIdsAndSorts(param.getCode(), param.getScriptId(), devIds, sorts));
|
|
||||||
rows.addAll(nonHarmonicService.listByDevIdsAndSorts(param.getCode(), param.getScriptId(), devIds, sorts));
|
|
||||||
|
|
||||||
Map<String, List<Integer>> flagMap = rows.stream()
|
|
||||||
.filter(row -> row.getResultFlag() != null)
|
|
||||||
.collect(Collectors.groupingBy(SimAndDigBaseResult::getDevMonitorId,
|
|
||||||
Collectors.mapping(SimAndDigBaseResult::getResultFlag, Collectors.toList())));
|
|
||||||
|
|
||||||
return pqDevService.getDevInfo(devIds).stream().map(dev -> {
|
|
||||||
FormalProgressVO.DeviceResult item = new FormalProgressVO.DeviceResult();
|
|
||||||
item.setDeviceId(dev.getDevId());
|
|
||||||
item.setDeviceName(dev.getDevName());
|
|
||||||
item.setChnResult(dev.getMonitorList().stream()
|
|
||||||
.map(monitor -> mergeResultFlags(resolveResultFlags(flagMap, dev, monitor)))
|
|
||||||
.collect(Collectors.toList()));
|
|
||||||
return item;
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<Integer> resolveResultFlags(Map<String, List<Integer>> flagMap, PreDetection dev, PreDetection.MonitorListDTO monitor) {
|
|
||||||
List<Integer> flags = new ArrayList<>();
|
|
||||||
List<Integer> byDevLine = flagMap.get(dev.getDevId() + "_" + monitor.getLine());
|
|
||||||
if (CollUtil.isNotEmpty(byDevLine)) {
|
|
||||||
flags.addAll(byDevLine);
|
|
||||||
}
|
|
||||||
List<Integer> byLineId = flagMap.get(monitor.getLineId());
|
|
||||||
if (CollUtil.isNotEmpty(byLineId)) {
|
|
||||||
flags.addAll(byLineId);
|
|
||||||
}
|
|
||||||
return flags;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Integer mergeResultFlags(List<Integer> flags) {
|
|
||||||
if (CollUtil.isEmpty(flags)) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
List<Integer> effective = flags.stream()
|
|
||||||
.filter(flag -> flag != null && flag != 4 && flag != 5)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
if (CollUtil.isNotEmpty(effective)) {
|
|
||||||
return effective.stream().max(Integer::compareTo).orElse(1);
|
|
||||||
}
|
|
||||||
return flags.get(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,8 +6,6 @@ import cn.hutool.core.util.ObjectUtil;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
||||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.gather.detection.handler.SocketContrastResponseService;
|
import com.njcn.gather.detection.handler.SocketContrastResponseService;
|
||||||
import com.njcn.gather.detection.handler.SocketDevResponseService;
|
import com.njcn.gather.detection.handler.SocketDevResponseService;
|
||||||
@@ -16,12 +14,9 @@ import com.njcn.gather.detection.pojo.constant.DetectionCommunicateConstant;
|
|||||||
import com.njcn.gather.detection.pojo.enums.DetectionResponseEnum;
|
import com.njcn.gather.detection.pojo.enums.DetectionResponseEnum;
|
||||||
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||||
import com.njcn.gather.detection.pojo.param.ContrastDetectionParam;
|
import com.njcn.gather.detection.pojo.param.ContrastDetectionParam;
|
||||||
import com.njcn.gather.detection.pojo.param.FormalProgressParam;
|
|
||||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||||
import com.njcn.gather.detection.pojo.param.SimulateDetectionParam;
|
import com.njcn.gather.detection.pojo.param.SimulateDetectionParam;
|
||||||
import com.njcn.gather.detection.pojo.vo.FormalProgressVO;
|
|
||||||
import com.njcn.gather.detection.pojo.vo.SocketMsg;
|
import com.njcn.gather.detection.pojo.vo.SocketMsg;
|
||||||
import com.njcn.gather.detection.service.FormalProgressService;
|
|
||||||
import com.njcn.gather.detection.service.PreDetectionService;
|
import com.njcn.gather.detection.service.PreDetectionService;
|
||||||
import com.njcn.gather.detection.util.business.DetectionCommunicateUtil;
|
import com.njcn.gather.detection.util.business.DetectionCommunicateUtil;
|
||||||
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
||||||
@@ -30,20 +25,15 @@ import com.njcn.gather.detection.util.socket.SocketManager;
|
|||||||
import com.njcn.gather.detection.util.socket.XiNumberManager;
|
import com.njcn.gather.detection.util.socket.XiNumberManager;
|
||||||
import com.njcn.gather.detection.util.socket.cilent.NettyContrastClientHandler;
|
import com.njcn.gather.detection.util.socket.cilent.NettyContrastClientHandler;
|
||||||
import com.njcn.gather.detection.util.socket.websocket.WebServiceManager;
|
import com.njcn.gather.detection.util.socket.websocket.WebServiceManager;
|
||||||
import com.njcn.gather.device.pojo.enums.CheckResultEnum;
|
|
||||||
import com.njcn.gather.device.pojo.enums.CheckStateEnum;
|
|
||||||
import com.njcn.gather.device.pojo.enums.CommonEnum;
|
|
||||||
import com.njcn.gather.device.pojo.po.PqDev;
|
import com.njcn.gather.device.pojo.po.PqDev;
|
||||||
import com.njcn.gather.device.pojo.po.PqDevSub;
|
|
||||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||||
import com.njcn.gather.device.service.IPqDevService;
|
import com.njcn.gather.device.service.IPqDevService;
|
||||||
import com.njcn.gather.device.service.IPqDevSubService;
|
|
||||||
import com.njcn.gather.plan.pojo.enums.DataSourceEnum;
|
import com.njcn.gather.plan.pojo.enums.DataSourceEnum;
|
||||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||||
import com.njcn.gather.plan.pojo.po.AdPlanSource;
|
import com.njcn.gather.plan.pojo.po.AdPlanSource;
|
||||||
import com.njcn.gather.plan.service.IAdPlanService;
|
import com.njcn.gather.plan.service.IAdPlanService;
|
||||||
import com.njcn.gather.plan.service.IAdPlanSourceService;
|
import com.njcn.gather.plan.service.IAdPlanSourceService;
|
||||||
import com.njcn.gather.report.pojo.enums.PowerIndexEnum;
|
import com.njcn.gather.result.pojo.enums.ResultUnitEnum;
|
||||||
import com.njcn.gather.script.pojo.param.PqScriptCheckDataParam;
|
import com.njcn.gather.script.pojo.param.PqScriptCheckDataParam;
|
||||||
import com.njcn.gather.script.pojo.param.PqScriptIssueParam;
|
import com.njcn.gather.script.pojo.param.PqScriptIssueParam;
|
||||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||||
@@ -51,8 +41,6 @@ import com.njcn.gather.script.service.IPqScriptCheckDataService;
|
|||||||
import com.njcn.gather.script.service.IPqScriptDtlsService;
|
import com.njcn.gather.script.service.IPqScriptDtlsService;
|
||||||
import com.njcn.gather.source.pojo.po.SourceInitialize;
|
import com.njcn.gather.source.pojo.po.SourceInitialize;
|
||||||
import com.njcn.gather.source.service.IPqSourceService;
|
import com.njcn.gather.source.service.IPqSourceService;
|
||||||
import com.njcn.gather.storage.service.SimAndDigHarmonicService;
|
|
||||||
import com.njcn.gather.storage.service.SimAndDigNonHarmonicService;
|
|
||||||
import com.njcn.gather.system.cfg.service.ISysTestConfigService;
|
import com.njcn.gather.system.cfg.service.ISysTestConfigService;
|
||||||
import com.njcn.gather.system.config.PathConfig;
|
import com.njcn.gather.system.config.PathConfig;
|
||||||
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
||||||
@@ -62,6 +50,7 @@ import com.njcn.web.utils.RequestUtil;
|
|||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.servlet.ServletOutputStream;
|
import javax.servlet.ServletOutputStream;
|
||||||
@@ -93,13 +82,9 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
|||||||
private final IPqScriptCheckDataService iPqScriptCheckDataService;
|
private final IPqScriptCheckDataService iPqScriptCheckDataService;
|
||||||
private final SocketManager socketManager;
|
private final SocketManager socketManager;
|
||||||
private final ISysTestConfigService sysTestConfigService;
|
private final ISysTestConfigService sysTestConfigService;
|
||||||
private final FormalProgressService formalProgressService;
|
|
||||||
private final IPqDevSubService pqDevSubService;
|
|
||||||
private final SimAndDigHarmonicService harmonicService;
|
|
||||||
private final SimAndDigNonHarmonicService nonHarmonicService;
|
|
||||||
|
|
||||||
|
|
||||||
// @Value("${report.reportDir}")
|
// @Value("${report.reportDir}")
|
||||||
// private String alignDataFilePath;
|
// private String alignDataFilePath;
|
||||||
private final PathConfig pathConfig;
|
private final PathConfig pathConfig;
|
||||||
|
|
||||||
@@ -118,28 +103,6 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
|||||||
param.setScriptId(plan.getScriptId());
|
param.setScriptId(plan.getScriptId());
|
||||||
param.setErrorSysId(plan.getErrorSysId());
|
param.setErrorSysId(plan.getErrorSysId());
|
||||||
param.setCode(String.valueOf(plan.getCode()));
|
param.setCode(String.valueOf(plan.getCode()));
|
||||||
if (param.isFormalTestSelected()) {
|
|
||||||
List<PqDevSub> devSubs = pqDevSubService.lambdaQuery()
|
|
||||||
.in(PqDevSub::getDevId, param.getDevIds())
|
|
||||||
.list();
|
|
||||||
boolean hasSaved = devSubs.stream().anyMatch(this::isSavedFormalProgress);
|
|
||||||
if (param.isResumeFormal() && !hasSaved) {
|
|
||||||
throw new BusinessException(CommonResponseEnum.FAIL, "未找到正式检测暂存进度");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (param.isFormalTestSelected() && !param.isResumeFormal()) {
|
|
||||||
FormalTestManager.resumeBaseFormalCheckTime = null;
|
|
||||||
FormalTestManager.resumeFormalStartTime = null;
|
|
||||||
FormalTestManager.resumeNextSort = null;
|
|
||||||
FormalTestManager.resumeFormalPending = false;
|
|
||||||
}
|
|
||||||
if (param.isFormalTestSelected() && param.isResumeFormal()) {
|
|
||||||
FormalTestManager.resumeBaseFormalCheckTime = iPqDevService.getMinFormalCheckTime(param.getDevIds());
|
|
||||||
pqDevSubService.lambdaUpdate()
|
|
||||||
.set(PqDevSub::getCheckState, CheckStateEnum.CHECKING.getValue())
|
|
||||||
.in(PqDevSub::getDevId, param.getDevIds())
|
|
||||||
.update();
|
|
||||||
}
|
|
||||||
if (ObjectUtil.isNotNull(plan)) {
|
if (ObjectUtil.isNotNull(plan)) {
|
||||||
String code = dictDataService.getDictDataById(plan.getPattern()).getCode();
|
String code = dictDataService.getDictDataById(plan.getPattern()).getCode();
|
||||||
DictDataEnum dictDataEnumByCode = DictDataEnum.getDictDataEnumByCode(code);
|
DictDataEnum dictDataEnumByCode = DictDataEnum.getDictDataEnumByCode(code);
|
||||||
@@ -277,273 +240,40 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean temStopTest(String userPageId, boolean waitCurrentItem) {
|
public boolean temStopTest() {
|
||||||
if (waitCurrentItem) {
|
FormalTestManager.stopFlag = true;
|
||||||
FormalTestManager.requestWaitPause();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
FormalTestManager.requestImmediatePause();
|
|
||||||
SocketManager.ensureFirst(FormalTestManager.currentIssue);
|
|
||||||
socketDevResponseService.initRestart();
|
|
||||||
PreDetectionParam runtimeParam = WebServiceManager.getPreDetectionParam(userPageId);
|
|
||||||
String pushUserPageId = runtimeParam != null && StrUtil.isNotBlank(runtimeParam.getUserPageId())
|
|
||||||
? runtimeParam.getUserPageId()
|
|
||||||
: userPageId;
|
|
||||||
WebServiceManager.sendDetectionMessage(pushUserPageId, "preStopTest", "stop", null, null);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean restartTemTest(PreDetectionParam param) {
|
public boolean restartTemTest(PreDetectionParam param) {
|
||||||
PreDetectionParam runtimeParam = WebServiceManager.getPreDetectionParam(param.getUserPageId());
|
FormalTestManager.stopFlag = false;
|
||||||
if (runtimeParam == null) {
|
|
||||||
if (StrUtil.isBlank(param.getSourceId()) || StrUtil.isBlank(param.getScriptId()) || StrUtil.isBlank(param.getCode())) {
|
|
||||||
throw new BusinessException(CommonResponseEnum.FAIL, "未找到暂停检测上下文,请重新开始检测");
|
|
||||||
}
|
|
||||||
runtimeParam = param;
|
|
||||||
}
|
|
||||||
FormalTestManager.clearPauseState();
|
|
||||||
socketDevResponseService.initRestart();
|
socketDevResponseService.initRestart();
|
||||||
List<SourceIssue> sourceIssueList = SocketManager.getSourceList();
|
List<SourceIssue> sourceIssueList = SocketManager.getSourceList();
|
||||||
if (StrUtil.isBlank(runtimeParam.getSourceName()) && StrUtil.isNotBlank(runtimeParam.getSourceId())) {
|
SourceInitialize sourceInitialize = pqSourceService.getSourceInitializeParam(param.getSourceId());
|
||||||
SourceInitialize sourceInitialize = pqSourceService.getSourceInitializeParam(runtimeParam.getSourceId());
|
param.setSourceName(sourceInitialize.getSourceId());
|
||||||
if (sourceInitialize == null) {
|
|
||||||
throw new BusinessException(DetectionResponseEnum.SOURCE_INFO_NOT);
|
|
||||||
}
|
|
||||||
runtimeParam.setSourceName(sourceInitialize.getSourceId());
|
|
||||||
}
|
|
||||||
if (CollUtil.isNotEmpty(sourceIssueList)) {
|
if (CollUtil.isNotEmpty(sourceIssueList)) {
|
||||||
SourceIssue sourceIssues = SocketManager.getSourceList().get(0);
|
SourceIssue sourceIssues = SocketManager.getSourceList().get(0);
|
||||||
String type = resolveFormalIssueType(sourceIssues);
|
|
||||||
sendBigItemStartIfFirstFormalIssue(runtimeParam, sourceIssues, type);
|
|
||||||
if (StrUtil.isNotBlank(sourceIssues.getOtherType())) {
|
|
||||||
sourceIssues.setType(PowerIndexEnum.LF.getKey().equals(sourceIssues.getOtherType()) ? PowerIndexEnum.F.getKey() : PowerIndexEnum.V.getKey());
|
|
||||||
}
|
|
||||||
SocketMsg<String> xuMsg = new SocketMsg<>();
|
SocketMsg<String> xuMsg = new SocketMsg<>();
|
||||||
xuMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
xuMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||||
xuMsg.setData(JSON.toJSONString(sourceIssues));
|
xuMsg.setData(JSON.toJSONString(sourceIssues));
|
||||||
xuMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + "&&" + type);
|
xuMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + "&&" + sourceIssues.getType());
|
||||||
SocketManager.sendMsg(runtimeParam.getUserPageId() + DetectionCommunicateConstant.SOURCE, JSON.toJSONString(xuMsg));
|
SocketManager.sendMsg(param.getUserPageId() + DetectionCommunicateConstant.SOURCE, JSON.toJSONString(xuMsg));
|
||||||
// Resume_Success
|
// Resume_Success
|
||||||
} else {
|
} else {
|
||||||
//TODO 是否最终检测完成需要推送给用户 检测完成
|
//TODO 是否最终检测完成需要推送给用户 检测完成
|
||||||
PqScriptCheckDataParam checkDataParam = new PqScriptCheckDataParam();
|
PqScriptCheckDataParam checkDataParam = new PqScriptCheckDataParam();
|
||||||
checkDataParam.setScriptId(runtimeParam.getScriptId());
|
checkDataParam.setScriptId(param.getScriptId());
|
||||||
checkDataParam.setIsValueTypeName(false);
|
checkDataParam.setIsValueTypeName(false);
|
||||||
List<String> adType = iPqScriptCheckDataService.getValueType(checkDataParam);
|
List<String> adType = iPqScriptCheckDataService.getValueType(checkDataParam);
|
||||||
|
|
||||||
iPqDevService.updateResult(runtimeParam.getDevIds(), adType, runtimeParam.getCode(), runtimeParam.getUserId(), runtimeParam.getTemperature(), runtimeParam.getHumidity(), true);
|
iPqDevService.updateResult(param.getDevIds(), adType, param.getCode(), param.getUserId(), param.getTemperature(), param.getHumidity(), true);
|
||||||
CnSocketUtil.quitSend(runtimeParam);
|
CnSocketUtil.quitSend(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void saveFormalProgress(FormalProgressParam param) {
|
|
||||||
if (param.getFormalCheckTime() == null) {
|
|
||||||
throw new BusinessException(CommonResponseEnum.FAIL, "正式检测耗时不能为空");
|
|
||||||
}
|
|
||||||
PreDetectionParam preParam = WebServiceManager.getPreDetectionParam(param.getUserPageId());
|
|
||||||
Map<String, Integer> checkResultMap = summarizeSavedFormalCheckResult(param, preParam);
|
|
||||||
Integer formalCheckTime = Math.max(param.getFormalCheckTime(), 1);
|
|
||||||
Map<Integer, List<String>> devIdsByResult = param.getDevIds().stream()
|
|
||||||
.collect(Collectors.groupingBy(devId -> checkResultMap.getOrDefault(devId, CheckResultEnum.UNCHECKED.getValue())));
|
|
||||||
devIdsByResult.forEach((checkResult, devIds) -> pqDevSubService.update(new LambdaUpdateWrapper<PqDevSub>()
|
|
||||||
.set(PqDevSub::getCheckState, CheckStateEnum.CHECKING.getValue())
|
|
||||||
.set(PqDevSub::getFormalCheckTime, formalCheckTime)
|
|
||||||
.set(PqDevSub::getCheckResult, checkResult)
|
|
||||||
.in(PqDevSub::getDevId, devIds)));
|
|
||||||
refreshPlanTestState(param.getPlanId());
|
|
||||||
|
|
||||||
if (preParam != null) {
|
|
||||||
CnSocketUtil.quitSend(preParam);
|
|
||||||
}
|
|
||||||
SocketManager.clearFormalRuntime();
|
|
||||||
FormalTestManager.clearFormalRuntime();
|
|
||||||
WebServiceManager.removePreDetectionParam(param.getUserPageId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FormalProgressVO formalProgress(FormalProgressParam param) {
|
|
||||||
return formalProgressService.restoreAndRelease(param);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<String, Integer> summarizeSavedFormalCheckResult(FormalProgressParam param, PreDetectionParam preParam) {
|
|
||||||
Map<String, Integer> result = new HashMap<>();
|
|
||||||
if (CollUtil.isEmpty(param.getDevIds())) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
param.getDevIds().forEach(devId -> result.put(devId, CheckResultEnum.UNCHECKED.getValue()));
|
|
||||||
|
|
||||||
AdPlan plan = iAdPlanService.getById(param.getPlanId());
|
|
||||||
String code = preParam != null && StrUtil.isNotBlank(preParam.getCode())
|
|
||||||
? preParam.getCode()
|
|
||||||
: plan != null && plan.getCode() != null ? String.valueOf(plan.getCode()) : null;
|
|
||||||
String scriptId = preParam != null && StrUtil.isNotBlank(preParam.getScriptId())
|
|
||||||
? preParam.getScriptId()
|
|
||||||
: plan != null ? plan.getScriptId() : null;
|
|
||||||
if (StrUtil.isBlank(code) || StrUtil.isBlank(scriptId)) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Integer> completedSorts = resolveCompletedFormalSorts(preParam);
|
|
||||||
if (completedSorts != null && CollUtil.isEmpty(completedSorts)) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, List<Integer>> resultFlags = new HashMap<>();
|
|
||||||
mergeResultFlags(resultFlags, nonHarmonicService.resultFlagsByDevIdsAndSorts(code, scriptId, param.getDevIds(), completedSorts));
|
|
||||||
mergeResultFlags(resultFlags, harmonicService.resultFlagsByDevIdsAndSorts(code, scriptId, param.getDevIds(), completedSorts));
|
|
||||||
param.getDevIds().forEach(devId -> result.put(devId, toCheckResult(resultFlags.get(devId))));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<Integer> resolveCompletedFormalSorts(PreDetectionParam preParam) {
|
|
||||||
if (preParam == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
List<SourceIssue> allIssues = buildAllFormalIssues(preParam);
|
|
||||||
if (CollUtil.isEmpty(allIssues)) {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
List<SourceIssue> remainingIssues = SocketManager.getSourceList();
|
|
||||||
Set<Integer> remainingSorts = CollUtil.isEmpty(remainingIssues)
|
|
||||||
? Collections.emptySet()
|
|
||||||
: remainingIssues.stream()
|
|
||||||
.map(SourceIssue::getIndex)
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.collect(Collectors.toSet());
|
|
||||||
return allIssues.stream()
|
|
||||||
.map(SourceIssue::getIndex)
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.filter(sort -> !remainingSorts.contains(sort))
|
|
||||||
.distinct()
|
|
||||||
.sorted()
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<SourceIssue> buildAllFormalIssues(PreDetectionParam param) {
|
|
||||||
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
|
||||||
issueParam.setPlanId(param.getPlanId());
|
|
||||||
issueParam.setSourceId(param.getSourceName());
|
|
||||||
issueParam.setDevIds(param.getDevIds());
|
|
||||||
issueParam.setScriptId(param.getScriptId());
|
|
||||||
issueParam.setIsPhaseSequence(CommonEnum.FORMAL_TEST.getValue());
|
|
||||||
return pqScriptDtlsService.listSourceIssue(issueParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sendBigItemStartIfFirstFormalIssue(PreDetectionParam param, SourceIssue currentIssue, String type) {
|
|
||||||
if (param == null || currentIssue == null || currentIssue.getIndex() == null || StrUtil.isBlank(type)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
List<SourceIssue> allIssues = buildAllFormalIssues(param);
|
|
||||||
if (isFirstFormalIssueOfBigItem(allIssues, currentIssue, type)) {
|
|
||||||
WebServiceManager.sendDetectionMessage(param.getUserPageId(), type + CnSocketUtil.START_TAG, null, new ArrayList<>(), null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static boolean isFirstFormalIssueOfBigItem(List<SourceIssue> allIssues, SourceIssue currentIssue, String type) {
|
|
||||||
if (CollUtil.isEmpty(allIssues) || currentIssue == null || currentIssue.getIndex() == null || StrUtil.isBlank(type)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Integer firstSort = allIssues.stream()
|
|
||||||
.filter(issue -> type.equals(resolveFormalIssueType(issue)))
|
|
||||||
.map(SourceIssue::getIndex)
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.min(Integer::compareTo)
|
|
||||||
.orElse(null);
|
|
||||||
return Objects.equals(firstSort, currentIssue.getIndex());
|
|
||||||
}
|
|
||||||
|
|
||||||
static String resolveFormalIssueType(SourceIssue issue) {
|
|
||||||
if (issue == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return StrUtil.isNotBlank(issue.getOtherType()) ? issue.getOtherType() : issue.getType();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void mergeResultFlags(Map<String, List<Integer>> target, Map<String, List<Integer>> source) {
|
|
||||||
if (CollUtil.isEmpty(source)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
source.forEach((devId, flags) -> target.computeIfAbsent(devId, key -> new ArrayList<>()).addAll(flags));
|
|
||||||
}
|
|
||||||
|
|
||||||
private Integer toCheckResult(List<Integer> resultFlags) {
|
|
||||||
if (CollUtil.isEmpty(resultFlags)) {
|
|
||||||
return CheckResultEnum.UNCHECKED.getValue();
|
|
||||||
}
|
|
||||||
List<Integer> effectiveFlags = resultFlags.stream()
|
|
||||||
.filter(flag -> flag != null && flag != 4 && flag != 5)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
if (CollUtil.isEmpty(effectiveFlags)) {
|
|
||||||
return CheckResultEnum.ACCORD.getValue();
|
|
||||||
}
|
|
||||||
boolean hasFailed = effectiveFlags.stream().anyMatch(flag -> !Objects.equals(flag, 1));
|
|
||||||
return hasFailed ? CheckResultEnum.NOT_ACCORD.getValue() : CheckResultEnum.ACCORD.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isSavedFormalProgress(PqDevSub dev) {
|
|
||||||
return CheckStateEnum.CHECKING.getValue().equals(dev.getCheckState())
|
|
||||||
&& ObjectUtil.isNotNull(dev.getFormalCheckTime())
|
|
||||||
&& dev.getFormalCheckTime() > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void refreshPlanTestState(String planId) {
|
|
||||||
if (StrUtil.isBlank(planId)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
List<String> planDevIds = iPqDevService.lambdaQuery()
|
|
||||||
.eq(PqDev::getPlanId, planId)
|
|
||||||
.list()
|
|
||||||
.stream()
|
|
||||||
.map(PqDev::getId)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
if (CollUtil.isEmpty(planDevIds)) {
|
|
||||||
iAdPlanService.lambdaUpdate()
|
|
||||||
.set(AdPlan::getTestState, CheckStateEnum.UNCHECKED.getValue())
|
|
||||||
.set(AdPlan::getResult, CheckResultEnum.UNCHECKED.getValue())
|
|
||||||
.eq(AdPlan::getId, planId)
|
|
||||||
.update();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
List<PqDevSub> devSubs = pqDevSubService.lambdaQuery()
|
|
||||||
.in(PqDevSub::getDevId, planDevIds)
|
|
||||||
.list();
|
|
||||||
boolean allUnchecked = devSubs.stream()
|
|
||||||
.allMatch(dev -> CheckStateEnum.UNCHECKED.getValue().equals(dev.getCheckState()));
|
|
||||||
boolean allArchived = CollUtil.isNotEmpty(devSubs) && devSubs.stream()
|
|
||||||
.allMatch(dev -> dev.getCheckState() != null && dev.getCheckState() >= CheckStateEnum.DOCUMENTED.getValue());
|
|
||||||
Integer testState = allUnchecked
|
|
||||||
? CheckStateEnum.UNCHECKED.getValue()
|
|
||||||
: allArchived ? CheckStateEnum.CHECKED.getValue() : CheckStateEnum.CHECKING.getValue();
|
|
||||||
Integer planResult = resolvePlanCheckResult(devSubs);
|
|
||||||
iAdPlanService.lambdaUpdate()
|
|
||||||
.set(AdPlan::getTestState, testState)
|
|
||||||
.set(AdPlan::getResult, planResult)
|
|
||||||
.eq(AdPlan::getId, planId)
|
|
||||||
.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Integer resolvePlanCheckResult(List<PqDevSub> devSubs) {
|
|
||||||
if (CollUtil.isEmpty(devSubs)) {
|
|
||||||
return CheckResultEnum.UNCHECKED.getValue();
|
|
||||||
}
|
|
||||||
Set<Integer> resultSet = devSubs.stream()
|
|
||||||
.map(PqDevSub::getCheckResult)
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.collect(Collectors.toSet());
|
|
||||||
if (resultSet.contains(CheckResultEnum.NOT_ACCORD.getValue())) {
|
|
||||||
return CheckResultEnum.NOT_ACCORD.getValue();
|
|
||||||
}
|
|
||||||
if (resultSet.contains(CheckResultEnum.UNCHECKED.getValue()) || CollUtil.isEmpty(resultSet)) {
|
|
||||||
return CheckResultEnum.UNCHECKED.getValue();
|
|
||||||
}
|
|
||||||
return CheckResultEnum.ACCORD.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ytxCheckSimulate(SimulateDetectionParam param) {
|
public void ytxCheckSimulate(SimulateDetectionParam param) {
|
||||||
PreDetectionParam preDetectionParam = new PreDetectionParam();
|
PreDetectionParam preDetectionParam = new PreDetectionParam();
|
||||||
@@ -582,7 +312,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
|||||||
SourceIssue sourceIssue = sourceIssues.get(0);
|
SourceIssue sourceIssue = sourceIssues.get(0);
|
||||||
String type = sourceIssue.getType();
|
String type = sourceIssue.getType();
|
||||||
if (StrUtil.isNotBlank(sourceIssue.getOtherType())) {
|
if (StrUtil.isNotBlank(sourceIssue.getOtherType())) {
|
||||||
sourceIssue.setType(PowerIndexEnum.LF.getKey().equals(sourceIssue.getOtherType()) ? PowerIndexEnum.F.getKey() : PowerIndexEnum.V.getKey());
|
sourceIssue.setType(ResultUnitEnum.V_ABSOLUTELY.getCode());
|
||||||
type = sourceIssue.getOtherType();
|
type = sourceIssue.getOtherType();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -732,4 +462,4 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -14,7 +14,10 @@ import com.njcn.gather.script.pojo.po.SourceIssue;
|
|||||||
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
@@ -84,14 +87,6 @@ public class FormalTestManager {
|
|||||||
*/
|
*/
|
||||||
public static Integer stopTime = 0;
|
public static Integer stopTime = 0;
|
||||||
|
|
||||||
public enum PauseMode {
|
|
||||||
NONE,
|
|
||||||
WAIT_CURRENT_ITEM,
|
|
||||||
IMMEDIATE
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PauseMode pauseMode = PauseMode.NONE;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当前正在检测的计划
|
* 当前正在检测的计划
|
||||||
*/
|
*/
|
||||||
@@ -225,66 +220,9 @@ public class FormalTestManager {
|
|||||||
*/
|
*/
|
||||||
public static LocalDateTime checkStartTime;
|
public static LocalDateTime checkStartTime;
|
||||||
|
|
||||||
public static boolean resumeFormalPending;
|
|
||||||
|
|
||||||
public static Integer resumeNextSort;
|
|
||||||
|
|
||||||
public static Integer resumeBaseFormalCheckTime;
|
|
||||||
|
|
||||||
public static LocalDateTime resumeFormalStartTime;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数模式 检测类型"1"-"全部检测" , "2"-"不合格项复检"
|
* 数模式 检测类型"1"-"全部检测" , "2"-"不合格项复检"
|
||||||
*/
|
*/
|
||||||
public static String reCheckType;
|
public static String reCheckType;
|
||||||
|
|
||||||
public static Integer longFlickerDataCount;
|
|
||||||
|
|
||||||
public static void requestWaitPause() {
|
|
||||||
stopFlag = true;
|
|
||||||
hasStopFlag = false;
|
|
||||||
stopTime = 0;
|
|
||||||
pauseMode = PauseMode.WAIT_CURRENT_ITEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void requestImmediatePause() {
|
|
||||||
stopFlag = true;
|
|
||||||
hasStopFlag = true;
|
|
||||||
stopTime = 0;
|
|
||||||
pauseMode = PauseMode.IMMEDIATE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void markPausedAfterCurrentItem() {
|
|
||||||
stopFlag = true;
|
|
||||||
hasStopFlag = true;
|
|
||||||
stopTime = 0;
|
|
||||||
pauseMode = PauseMode.WAIT_CURRENT_ITEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isWaitCurrentItemPause() {
|
|
||||||
return pauseMode == PauseMode.WAIT_CURRENT_ITEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isImmediatePause() {
|
|
||||||
return pauseMode == PauseMode.IMMEDIATE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void clearPauseState() {
|
|
||||||
stopFlag = false;
|
|
||||||
hasStopFlag = false;
|
|
||||||
stopTime = 0;
|
|
||||||
pauseMode = PauseMode.NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static void clearFormalRuntime() {
|
|
||||||
clearPauseState();
|
|
||||||
resumeFormalPending = false;
|
|
||||||
resumeNextSort = null;
|
|
||||||
resumeBaseFormalCheckTime = null;
|
|
||||||
resumeFormalStartTime = null;
|
|
||||||
realDataXiList.clear();
|
|
||||||
currentIssue = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -297,7 +297,7 @@ public class SocketManager {
|
|||||||
private static List<SourceIssue> sourceIssueList = new CopyOnWriteArrayList<>();
|
private static List<SourceIssue> sourceIssueList = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用于存储pq_script_checkdata表里Value_Type与树字典表code。key为code,value为id值
|
* 用于存储pq_script_checkdata表里Value_Type与树字典表code
|
||||||
*/
|
*/
|
||||||
public static Map<String, String> valueTypeMap = new HashMap<>();
|
public static Map<String, String> valueTypeMap = new HashMap<>();
|
||||||
|
|
||||||
@@ -326,22 +326,6 @@ public class SocketManager {
|
|||||||
sourceIssueList.removeIf(s -> index.equals(s.getIndex()));
|
sourceIssueList.removeIf(s -> index.equals(s.getIndex()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ensureFirst(SourceIssue issue) {
|
|
||||||
if (issue == null || issue.getIndex() == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (sourceIssueList.isEmpty()) {
|
|
||||||
sourceIssueList.add(0, issue);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
SourceIssue first = sourceIssueList.get(0);
|
|
||||||
if (issue.getIndex().equals(first.getIndex())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
sourceIssueList.removeIf(s -> issue.getIndex().equals(s.getIndex()));
|
|
||||||
sourceIssueList.add(0, issue);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void delSourceTarget(String sourceTag) {
|
public static void delSourceTarget(String sourceTag) {
|
||||||
targetMap.remove(sourceTag);
|
targetMap.remove(sourceTag);
|
||||||
}
|
}
|
||||||
@@ -359,11 +343,6 @@ public class SocketManager {
|
|||||||
return targetMap.get(scriptType);
|
return targetMap.get(scriptType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearFormalRuntime() {
|
|
||||||
sourceIssueList.clear();
|
|
||||||
targetMap.clear();
|
|
||||||
valueTypeMap.clear();
|
|
||||||
clockMap.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -15,8 +15,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.websocket.WebServiceManager;
|
import com.njcn.gather.detection.util.socket.websocket.WebServiceManager;
|
||||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||||
import com.njcn.gather.report.pojo.enums.PowerIndexEnum;
|
|
||||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||||
|
import com.njcn.gather.system.pojo.enums.DicDataEnum;
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.channel.SimpleChannelInboundHandler;
|
import io.netty.channel.SimpleChannelInboundHandler;
|
||||||
@@ -55,22 +55,17 @@ import java.util.stream.Collectors;
|
|||||||
public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 短闪检测超时时间:20分钟+100秒(1300秒)
|
* 闪变检测超时时间:20分钟(1300秒)
|
||||||
*/
|
*/
|
||||||
private static final long SHORT_FLICKER_TIMEOUT = 1300L;
|
private static final long FLICKER_TIMEOUT = 1300L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 长闪检测超时时间:120分钟+30分
|
* 统计数据检测超时时间:3分钟(180秒)
|
||||||
*/
|
*/
|
||||||
private static final long LONG_FLICKER_TIMEOUT = 120 * 60 + 30 * 60;
|
private static final long STATISTICS_TIMEOUT = 180L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 统计数据检测超时时间:3分钟+100秒(190秒)
|
* 实时数据检测超时时间:1分钟(60秒)
|
||||||
*/
|
|
||||||
private static final long STATISTICS_TIMEOUT = 190L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 实时数据检测超时时间:1分钟*3
|
|
||||||
*/
|
*/
|
||||||
private static final long REALTIME_TIMEOUT = 60 * 3L;
|
private static final long REALTIME_TIMEOUT = 60 * 3L;
|
||||||
|
|
||||||
@@ -273,7 +268,8 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
|||||||
DetectionLockManager.getInstance().releaseIfHeldBy(cur.getUserId(), "PAUSE_TIMEOUT");
|
DetectionLockManager.getInstance().releaseIfHeldBy(cur.getUserId(), "PAUSE_TIMEOUT");
|
||||||
}
|
}
|
||||||
// 重置 FormalTestManager 状态,避免下次进入误判
|
// 重置 FormalTestManager 状态,避免下次进入误判
|
||||||
FormalTestManager.clearPauseState();
|
FormalTestManager.stopTime = 0;
|
||||||
|
FormalTestManager.hasStopFlag = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,13 +303,12 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
|||||||
private boolean isTimeout(SourceIssue sourceIssue) {
|
private boolean isTimeout(SourceIssue sourceIssue) {
|
||||||
long currentTime = SocketManager.clockMap.get(sourceIssue.getIndex());
|
long currentTime = SocketManager.clockMap.get(sourceIssue.getIndex());
|
||||||
String type = sourceIssue.getType();
|
String type = sourceIssue.getType();
|
||||||
String otherType = sourceIssue.getOtherType();
|
|
||||||
|
|
||||||
if (PowerIndexEnum.LF.getKey().equals(otherType)) {
|
// 根据不同检测类型使用不同的超时阈值
|
||||||
return currentTime >= LONG_FLICKER_TIMEOUT;
|
if (DicDataEnum.F.getCode().equals(type)) {
|
||||||
} else if (PowerIndexEnum.F.getKey().equals(type)) {
|
// 闪变检测:需要更长时间,20分钟超时
|
||||||
return currentTime >= SHORT_FLICKER_TIMEOUT;
|
return currentTime >= FLICKER_TIMEOUT;
|
||||||
} else if (PowerIndexEnum.VOLTAGE.getKey().equals(type) || PowerIndexEnum.HP.getKey().equals(type)) {
|
} else if (DicDataEnum.VOLTAGE.getCode().equals(type) || DicDataEnum.HP.getCode().equals(type)) {
|
||||||
// 统计数据类型(电压、谐波):中等时间,3分钟超时
|
// 统计数据类型(电压、谐波):中等时间,3分钟超时
|
||||||
return currentTime >= STATISTICS_TIMEOUT;
|
return currentTime >= STATISTICS_TIMEOUT;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -371,7 +371,7 @@ public class WebSocketHandler extends SimpleChannelInboundHandler<TextWebSocketF
|
|||||||
if (ObjectUtil.isNotNull(preDetectionParam)) {
|
if (ObjectUtil.isNotNull(preDetectionParam)) {
|
||||||
// 使用该用户的检测参数关闭Socket连接
|
// 使用该用户的检测参数关闭Socket连接
|
||||||
log.info("使用用户检测参数关闭Socket连接,userId: {}", userId);
|
log.info("使用用户检测参数关闭Socket连接,userId: {}", userId);
|
||||||
if (FormalTestManager.patternEnum.equals(PatternEnum.CONTRAST)) {
|
if (PatternEnum.CONTRAST.equals(FormalTestManager.patternEnum)) {
|
||||||
CnSocketUtil.contrastSendquit(preDetectionParam.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_01, false);
|
CnSocketUtil.contrastSendquit(preDetectionParam.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_01, false);
|
||||||
CnSocketUtil.contrastSendquit(preDetectionParam.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_02, false);
|
CnSocketUtil.contrastSendquit(preDetectionParam.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_02, false);
|
||||||
CnSocketUtil.contrastSendquit(preDetectionParam.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_03, false);
|
CnSocketUtil.contrastSendquit(preDetectionParam.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_03, false);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ public enum CheckStateEnum {
|
|||||||
CHECKING("检测中", 1),
|
CHECKING("检测中", 1),
|
||||||
CHECKED("检测完成", 2),
|
CHECKED("检测完成", 2),
|
||||||
/**
|
/**
|
||||||
* 检测计划没有归档状态,只有未检、检测中、检测完成三种状态。被检设备有归档状态
|
* 检测计划没有该状态,只有未检、检测中、检测完成三种状态。被检设备有这种状态
|
||||||
*/
|
*/
|
||||||
DOCUMENTED("归档", 3);
|
DOCUMENTED("归档", 3);
|
||||||
|
|
||||||
|
|||||||
@@ -67,30 +67,6 @@ public class PqDevSub {
|
|||||||
@TableField("Check_End_Time")
|
@TableField("Check_End_Time")
|
||||||
private LocalDateTime checkEndTime;
|
private LocalDateTime checkEndTime;
|
||||||
|
|
||||||
/**
|
|
||||||
* 守时检测-装置开始时间(ms)
|
|
||||||
*/
|
|
||||||
@TableField("Dev_Time_Check_Start")
|
|
||||||
private LocalDateTime devTimeCheckStart;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 守时检测-装置结束时间(ms)
|
|
||||||
*/
|
|
||||||
@TableField("Dev_Time_Check_End")
|
|
||||||
private LocalDateTime devTimeCheckEnd;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 守时检测-源开始时间(ms)
|
|
||||||
*/
|
|
||||||
@TableField("Source_Time_Check_Start")
|
|
||||||
private LocalDateTime sourceTimeCheckStart;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 守时检测-源结束时间(ms)
|
|
||||||
*/
|
|
||||||
@TableField("Source_Time_Check_End")
|
|
||||||
private LocalDateTime sourceTimeCheckEnd;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 预检测耗时
|
* 预检测耗时
|
||||||
*/
|
*/
|
||||||
@@ -106,12 +82,6 @@ public class PqDevSub {
|
|||||||
*/
|
*/
|
||||||
private Integer formalCheckTime;
|
private Integer formalCheckTime;
|
||||||
|
|
||||||
/**
|
|
||||||
* 走时误差(s/d)
|
|
||||||
*/
|
|
||||||
@TableField("Time_Check_error")
|
|
||||||
private LocalDateTime timeCheckError;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 温度
|
* 温度
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -83,26 +83,6 @@ public class PqDevVO extends PqDev {
|
|||||||
*/
|
*/
|
||||||
private LocalDateTime checkEndTime;
|
private LocalDateTime checkEndTime;
|
||||||
|
|
||||||
/**
|
|
||||||
* 守时检测-装置开始时间(ms)
|
|
||||||
*/
|
|
||||||
private LocalDateTime devTimeCheckStart;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 守时检测-装置结束时间(ms)
|
|
||||||
*/
|
|
||||||
private LocalDateTime devTimeCheckEnd;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 守时检测-源开始时间(ms)
|
|
||||||
*/
|
|
||||||
private LocalDateTime sourceTimeCheckStart;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 守时检测-源结束时间(ms)
|
|
||||||
*/
|
|
||||||
private LocalDateTime sourceTimeCheckEnd;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 预检测耗时
|
* 预检测耗时
|
||||||
*/
|
*/
|
||||||
@@ -118,11 +98,6 @@ public class PqDevVO extends PqDev {
|
|||||||
*/
|
*/
|
||||||
private Integer formalCheckTime;
|
private Integer formalCheckTime;
|
||||||
|
|
||||||
/**
|
|
||||||
* 走时误差(s/d)
|
|
||||||
*/
|
|
||||||
private LocalDateTime timeCheckError;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 温度
|
* 温度
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -129,13 +129,6 @@ public interface IPqDevService extends IService<PqDev> {
|
|||||||
*/
|
*/
|
||||||
boolean updateResult(List<String> ids, List<String> adType, String code, String userId, Float temperature, Float humidity, boolean updateCheckNum);
|
boolean updateResult(List<String> ids, List<String> adType, String code, String userId, Float temperature, Float humidity, boolean updateCheckNum);
|
||||||
|
|
||||||
/**
|
|
||||||
* 新一轮正式检测真正开始前,仅清理原检测中设备的暂存耗时,并把本次设备置为检测中。
|
|
||||||
*/
|
|
||||||
void clearFormalProgressForNewRun(List<String> devIds);
|
|
||||||
|
|
||||||
Integer getMinFormalCheckTime(List<String> devIds);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 比对式-修改设备状态
|
* 比对式-修改设备状态
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -367,8 +367,24 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
|||||||
List<String> notUnchecked = list.stream().filter(x -> !CheckStateEnum.UNCHECKED.getValue().equals(x.getCheckState())).map(PqDevSub::getDevId).distinct().collect(Collectors.toList());
|
List<String> notUnchecked = list.stream().filter(x -> !CheckStateEnum.UNCHECKED.getValue().equals(x.getCheckState())).map(PqDevSub::getDevId).distinct().collect(Collectors.toList());
|
||||||
|
|
||||||
if (CollUtil.isNotEmpty(notUnchecked)) {
|
if (CollUtil.isNotEmpty(notUnchecked)) {
|
||||||
boolean allArchived = list.stream().allMatch(x -> x.getCheckState() != null && x.getCheckState() >= CheckStateEnum.DOCUMENTED.getValue());
|
List<String> unchecked = list.stream().filter(x -> CheckStateEnum.UNCHECKED.getValue().equals(x.getCheckState())).map(PqDevSub::getDevId).distinct().collect(Collectors.toList());
|
||||||
return allArchived ? CheckStateEnum.CHECKED.getValue() : CheckStateEnum.CHECKING.getValue();
|
//计划未检测
|
||||||
|
if (CollUtil.isNotEmpty(unchecked)) {
|
||||||
|
return CheckStateEnum.CHECKING.getValue();
|
||||||
|
}
|
||||||
|
//计划检测中
|
||||||
|
List<String> checking = list.stream().filter(x -> x.getCheckState().equals(CheckStateEnum.CHECKED.getValue()) &&
|
||||||
|
!CheckStateEnum.DOCUMENTED.getValue().equals(x.getCheckState())
|
||||||
|
).map(PqDevSub::getDevId).distinct().collect(Collectors.toList());
|
||||||
|
if (checking.size() == notUnchecked.size()) {
|
||||||
|
return CheckStateEnum.CHECKING.getValue();
|
||||||
|
}
|
||||||
|
//检测完成
|
||||||
|
List<String> checked = list.stream().filter(x -> CheckStateEnum.DOCUMENTED.getValue().equals(x.getCheckState())).map(PqDevSub::getDevId).distinct().collect(Collectors.toList());
|
||||||
|
if (checked.size() == notUnchecked.size()) {
|
||||||
|
return CheckStateEnum.CHECKED.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return CheckStateEnum.UNCHECKED.getValue();
|
return CheckStateEnum.UNCHECKED.getValue();
|
||||||
@@ -531,45 +547,6 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
|||||||
return preDetections;
|
return preDetections;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clearFormalProgressForNewRun(List<String> devIds) {
|
|
||||||
if (CollUtil.isEmpty(devIds)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
List<PqDevSub> devSubs = pqDevSubService.lambdaQuery()
|
|
||||||
.in(PqDevSub::getDevId, devIds)
|
|
||||||
.list();
|
|
||||||
List<String> resetFormalCheckIds = devSubs.stream()
|
|
||||||
.filter(dev -> CheckStateEnum.CHECKING.getValue().equals(dev.getCheckState()))
|
|
||||||
.map(PqDevSub::getDevId)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
if (CollUtil.isNotEmpty(resetFormalCheckIds)) {
|
|
||||||
pqDevSubService.lambdaUpdate()
|
|
||||||
.set(PqDevSub::getFormalCheckTime, 0)
|
|
||||||
.in(PqDevSub::getDevId, resetFormalCheckIds)
|
|
||||||
.update();
|
|
||||||
}
|
|
||||||
pqDevSubService.lambdaUpdate()
|
|
||||||
.set(PqDevSub::getCheckState, CheckStateEnum.CHECKING.getValue())
|
|
||||||
.in(PqDevSub::getDevId, devIds)
|
|
||||||
.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer getMinFormalCheckTime(List<String> devIds) {
|
|
||||||
if (CollUtil.isEmpty(devIds)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return pqDevSubService.lambdaQuery()
|
|
||||||
.in(PqDevSub::getDevId, devIds)
|
|
||||||
.list()
|
|
||||||
.stream()
|
|
||||||
.map(PqDevSub::getFormalCheckTime)
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.min(Integer::compareTo)
|
|
||||||
.orElse(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateResult(List<String> ids, List<String> adType, String code, String userId, Float temperature, Float humidity, boolean updateCheckNum) {
|
public boolean updateResult(List<String> ids, List<String> adType, String code, String userId, Float temperature, Float humidity, boolean updateCheckNum) {
|
||||||
@@ -613,21 +590,6 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
|||||||
}
|
}
|
||||||
wrapper.set(PqDevSub::getReportState, DevReportStateEnum.NOT_GENERATED.getValue());
|
wrapper.set(PqDevSub::getReportState, DevReportStateEnum.NOT_GENERATED.getValue());
|
||||||
}
|
}
|
||||||
if (ObjectUtil.isNotNull(FormalTestManager.resumeBaseFormalCheckTime)
|
|
||||||
&& ObjectUtil.isNotNull(FormalTestManager.resumeFormalStartTime)) {
|
|
||||||
int elapsedSeconds = (int) java.time.Duration.between(
|
|
||||||
FormalTestManager.resumeFormalStartTime,
|
|
||||||
LocalDateTime.now()
|
|
||||||
).getSeconds();
|
|
||||||
wrapper.set(PqDevSub::getFormalCheckTime,
|
|
||||||
FormalTestManager.resumeBaseFormalCheckTime + Math.max(elapsedSeconds, 0));
|
|
||||||
} else if (updateCheckNum && ObjectUtil.isNotNull(FormalTestManager.checkStartTime)) {
|
|
||||||
int elapsedSeconds = (int) java.time.Duration.between(
|
|
||||||
FormalTestManager.checkStartTime,
|
|
||||||
LocalDateTime.now()
|
|
||||||
).getSeconds();
|
|
||||||
wrapper.set(PqDevSub::getFormalCheckTime, Math.max(elapsedSeconds, 0));
|
|
||||||
}
|
|
||||||
wrapper.set(PqDevSub::getRecheckNum, i)
|
wrapper.set(PqDevSub::getRecheckNum, i)
|
||||||
.set(PqDevSub::getCheckState, checkState);
|
.set(PqDevSub::getCheckState, checkState);
|
||||||
pqDevSubService.update(wrapper);
|
pqDevSubService.update(wrapper);
|
||||||
@@ -646,14 +608,19 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
|||||||
this.baseMapper.updatePlanCheckResult(pqDevVo.getPlanId(), CheckResultEnum.ACCORD.getValue());
|
this.baseMapper.updatePlanCheckResult(pqDevVo.getPlanId(), CheckResultEnum.ACCORD.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean allUnchecked = pqDevVOList.stream().allMatch(obj -> CheckStateEnum.UNCHECKED.getValue().equals(obj.getCheckState()));
|
set = pqDevVOList.stream().map(PqDevVO::getCheckState).collect(Collectors.toSet());
|
||||||
boolean allArchived = pqDevVOList.stream().allMatch(obj -> obj.getCheckState() != null && obj.getCheckState() >= CheckStateEnum.DOCUMENTED.getValue());
|
if (set.contains(CheckStateEnum.UNCHECKED.getValue())) {
|
||||||
if (allUnchecked) {
|
|
||||||
this.baseMapper.updatePlanTestState(pqDevVo.getPlanId(), CheckStateEnum.UNCHECKED.getValue());
|
|
||||||
} else if (allArchived) {
|
|
||||||
this.baseMapper.updatePlanTestState(pqDevVo.getPlanId(), CheckStateEnum.CHECKED.getValue());
|
|
||||||
} else {
|
|
||||||
this.baseMapper.updatePlanTestState(pqDevVo.getPlanId(), CheckStateEnum.CHECKING.getValue());
|
this.baseMapper.updatePlanTestState(pqDevVo.getPlanId(), CheckStateEnum.CHECKING.getValue());
|
||||||
|
} else {
|
||||||
|
if (checkState.equals(CheckStateEnum.DOCUMENTED.getValue())) {
|
||||||
|
long count = pqDevVOList.stream().filter(obj -> !CheckStateEnum.DOCUMENTED.getValue().equals(obj.getCheckState())).count();
|
||||||
|
if (count == 0) {
|
||||||
|
// 如果非归档状态的设备数量为0,则更新计划已完成
|
||||||
|
this.baseMapper.finishPlan(pqDevVo.getPlanId());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.baseMapper.updatePlanTestState(pqDevVo.getPlanId(), CheckStateEnum.CHECKING.getValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -710,7 +677,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
|||||||
List<PqDevVO> pqDevVOList = this.baseMapper.selectByQueryParam(param);
|
List<PqDevVO> pqDevVOList = this.baseMapper.selectByQueryParam(param);
|
||||||
|
|
||||||
if (CollUtil.isNotEmpty(pqDevVOList)) {
|
if (CollUtil.isNotEmpty(pqDevVOList)) {
|
||||||
Set<Integer> set = pqDevVOList.stream().filter(obj -> obj.getCheckState() != null && obj.getCheckState() >= CheckStateEnum.CHECKED.getValue()).map(PqDevVO::getCheckResult).collect(Collectors.toSet());
|
Set<Integer> set = pqDevVOList.stream().filter(obj -> CheckStateEnum.CHECKED.getValue().equals(obj.getCheckState()) || CheckStateEnum.DOCUMENTED.getValue().equals(obj.getCheckState())).map(PqDevVO::getCheckResult).collect(Collectors.toSet());
|
||||||
if (checkState == CheckStateEnum.CHECKED.getValue()) {
|
if (checkState == CheckStateEnum.CHECKED.getValue()) {
|
||||||
set.add(checkResult);
|
set.add(checkResult);
|
||||||
}
|
}
|
||||||
@@ -727,22 +694,20 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
boolean allUnchecked = pqDevVOList.stream().allMatch(obj -> CheckStateEnum.UNCHECKED.getValue().equals(obj.getCheckState()));
|
set = pqDevVOList.stream().map(PqDevVO::getCheckState).collect(Collectors.toSet());
|
||||||
boolean allArchived = pqDevVOList.stream().allMatch(obj -> obj.getCheckState() != null && obj.getCheckState() >= CheckStateEnum.DOCUMENTED.getValue());
|
if (set.contains(CheckStateEnum.UNCHECKED.getValue())) {
|
||||||
if (allUnchecked) {
|
|
||||||
this.baseMapper.updatePlanTestState(planId, CheckStateEnum.UNCHECKED.getValue());
|
|
||||||
} else if (allArchived) {
|
|
||||||
this.baseMapper.updatePlanTestState(planId, CheckStateEnum.CHECKED.getValue());
|
|
||||||
} else {
|
|
||||||
this.baseMapper.updatePlanTestState(planId, CheckStateEnum.CHECKING.getValue());
|
this.baseMapper.updatePlanTestState(planId, CheckStateEnum.CHECKING.getValue());
|
||||||
|
} else if (set.contains(CheckStateEnum.CHECKING.getValue())) {
|
||||||
|
this.baseMapper.updatePlanTestState(planId, CheckStateEnum.CHECKING.getValue());
|
||||||
|
} else {
|
||||||
|
this.baseMapper.updatePlanTestState(planId, CheckStateEnum.CHECKED.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveCheckHistory(PqDevVO pqDevVo, Integer recheckNum, Integer checkState, String userId) {
|
private void saveCheckHistory(PqDevVO pqDevVo, Integer recheckNum, Integer checkState, String userId) {
|
||||||
if (ObjectUtil.isNull(pqDevVo)
|
if (ObjectUtil.isNull(pqDevVo)
|
||||||
|| checkState == null
|
|| (!CheckStateEnum.CHECKED.getValue().equals(checkState) && !CheckStateEnum.DOCUMENTED.getValue().equals(checkState))) {
|
||||||
|| checkState < CheckStateEnum.CHECKED.getValue()) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
AdPlan plan = adPlanMapper.selectById(pqDevVo.getPlanId());
|
AdPlan plan = adPlanMapper.selectById(pqDevVo.getPlanId());
|
||||||
@@ -758,8 +723,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
|||||||
private void saveCheckHistory(String devId, String userId) {
|
private void saveCheckHistory(String devId, String userId) {
|
||||||
PqDevVO pqDevVo = this.baseMapper.selectByDevId(devId);
|
PqDevVO pqDevVo = this.baseMapper.selectByDevId(devId);
|
||||||
if (ObjectUtil.isNull(pqDevVo)
|
if (ObjectUtil.isNull(pqDevVo)
|
||||||
|| pqDevVo.getCheckState() == null
|
|| (!CheckStateEnum.CHECKED.getValue().equals(pqDevVo.getCheckState()) && !CheckStateEnum.DOCUMENTED.getValue().equals(pqDevVo.getCheckState()))) {
|
||||||
|| pqDevVo.getCheckState() < CheckStateEnum.CHECKED.getValue()) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
AdPlan plan = adPlanMapper.selectById(pqDevVo.getPlanId());
|
AdPlan plan = adPlanMapper.selectById(pqDevVo.getPlanId());
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ public class PqMonitorServiceImpl extends ServiceImpl<PqMonitorMapper, PqMonitor
|
|||||||
this.baseMapper.updateDeviceReportRState(devId, DevReportStateEnum.NOT_GENERATED.getValue());
|
this.baseMapper.updateDeviceReportRState(devId, DevReportStateEnum.NOT_GENERATED.getValue());
|
||||||
}
|
}
|
||||||
if (enableCheckMonitorList.size() > checkedMonitorList.size() && checkedMonitorList.size() > 0) {
|
if (enableCheckMonitorList.size() > checkedMonitorList.size() && checkedMonitorList.size() > 0) {
|
||||||
this.baseMapper.updateDeviceCheckState(devId, CheckStateEnum.UNCHECKED.getValue());
|
this.baseMapper.updateDeviceCheckState(devId, CheckStateEnum.CHECKING.getValue());
|
||||||
this.baseMapper.updateDeviceReportRState(devId, DevReportStateEnum.NOT_GENERATED.getValue());
|
this.baseMapper.updateDeviceReportRState(devId, DevReportStateEnum.NOT_GENERATED.getValue());
|
||||||
}
|
}
|
||||||
if (enableCheckMonitorList.size() > 0 && checkedMonitorList.size() == 0) {
|
if (enableCheckMonitorList.size() > 0 && checkedMonitorList.size() == 0) {
|
||||||
@@ -142,14 +142,13 @@ public class PqMonitorServiceImpl extends ServiceImpl<PqMonitorMapper, PqMonitor
|
|||||||
List<PqDevSub> devSubList = this.baseMapper.listDevSubByPlanId(plan.getId());
|
List<PqDevSub> devSubList = this.baseMapper.listDevSubByPlanId(plan.getId());
|
||||||
|
|
||||||
List<PqDevSub> checkedDevSubList = devSubList.stream().filter(pqDevSub -> pqDevSub.getCheckState() == CheckStateEnum.CHECKED.getValue()).collect(Collectors.toList());
|
List<PqDevSub> checkedDevSubList = devSubList.stream().filter(pqDevSub -> pqDevSub.getCheckState() == CheckStateEnum.CHECKED.getValue()).collect(Collectors.toList());
|
||||||
boolean allUnchecked = devSubList.stream().allMatch(pqDevSub -> CheckStateEnum.UNCHECKED.getValue().equals(pqDevSub.getCheckState()));
|
List<PqDevSub> checkingDevSubList = devSubList.stream().filter(pqDevSub -> pqDevSub.getCheckState() == CheckStateEnum.CHECKING.getValue()).collect(Collectors.toList());
|
||||||
boolean allArchived = devSubList.stream().allMatch(pqDevSub -> pqDevSub.getCheckState() != null && pqDevSub.getCheckState() >= CheckStateEnum.DOCUMENTED.getValue());
|
if (checkedDevSubList.size() == devSubList.size() && devSubList.size() > 0) {
|
||||||
if (allArchived && CollUtil.isNotEmpty(devSubList)) {
|
|
||||||
this.baseMapper.updatePlanCheckState(plan.getId(), CheckStateEnum.CHECKED.getValue());
|
this.baseMapper.updatePlanCheckState(plan.getId(), CheckStateEnum.CHECKED.getValue());
|
||||||
} else if (allUnchecked) {
|
} else if (checkedDevSubList.size() > 0 || checkingDevSubList.size() > 0) {
|
||||||
this.baseMapper.updatePlanCheckState(plan.getId(), CheckStateEnum.UNCHECKED.getValue());
|
|
||||||
} else {
|
|
||||||
this.baseMapper.updatePlanCheckState(plan.getId(), CheckStateEnum.CHECKING.getValue());
|
this.baseMapper.updatePlanCheckState(plan.getId(), CheckStateEnum.CHECKING.getValue());
|
||||||
|
} else {
|
||||||
|
this.baseMapper.updatePlanCheckState(plan.getId(), CheckStateEnum.UNCHECKED.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
List<PqDevSub> accordDevSubList = checkedDevSubList.stream().filter(pqDevSub -> pqDevSub.getCheckResult() == CheckResultEnum.ACCORD.getValue()).collect(Collectors.toList());
|
List<PqDevSub> accordDevSubList = checkedDevSubList.stream().filter(pqDevSub -> pqDevSub.getCheckResult() == CheckResultEnum.ACCORD.getValue()).collect(Collectors.toList());
|
||||||
@@ -373,6 +372,10 @@ public class PqMonitorServiceImpl extends ServiceImpl<PqMonitorMapper, PqMonitor
|
|||||||
|
|
||||||
if (checkedNumList.containsAll(allNumList)) {
|
if (checkedNumList.containsAll(allNumList)) {
|
||||||
return CheckStateEnum.CHECKED.getValue();
|
return CheckStateEnum.CHECKED.getValue();
|
||||||
|
} else {
|
||||||
|
if (checkedNumList.size() > 0) {
|
||||||
|
return CheckStateEnum.CHECKING.getValue();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return CheckStateEnum.UNCHECKED.getValue();
|
return CheckStateEnum.UNCHECKED.getValue();
|
||||||
|
|||||||
@@ -36,11 +36,6 @@ public class PlanStatisticsVO {
|
|||||||
*/
|
*/
|
||||||
private Integer uncheckedDeviceCount;
|
private Integer uncheckedDeviceCount;
|
||||||
|
|
||||||
/**
|
|
||||||
* 检测中设备总数。
|
|
||||||
*/
|
|
||||||
private Integer checkingDeviceCount;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 第一次检测合格的设备数量。
|
* 第一次检测合格的设备数量。
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -436,14 +436,20 @@ public class AsyncPlanHandler {
|
|||||||
planIds.add(planId);
|
planIds.add(planId);
|
||||||
List<String> devIds = pqDevService.lambdaQuery().in(PqDev::getPlanId, planIds).list().stream().map(PqDev::getId).collect(Collectors.toList());
|
List<String> devIds = pqDevService.lambdaQuery().in(PqDev::getPlanId, planIds).list().stream().map(PqDev::getId).collect(Collectors.toList());
|
||||||
List<PqDevSub> devSubs = pqDevSubService.lambdaQuery().in(PqDevSub::getDevId, devIds).list();
|
List<PqDevSub> devSubs = pqDevSubService.lambdaQuery().in(PqDevSub::getDevId, devIds).list();
|
||||||
boolean allUnchecked = devSubs.stream().allMatch(sub -> CheckStateEnum.UNCHECKED.getValue().equals(sub.getCheckState()));
|
long checkedCount = devSubs.stream().filter(sub -> sub.getCheckState().equals(CheckStateEnum.CHECKED.getValue())).count();
|
||||||
boolean allArchived = devSubs.stream().allMatch(sub -> sub.getCheckState() != null && sub.getCheckState() >= CheckStateEnum.DOCUMENTED.getValue());
|
if (checkedCount > 0) {
|
||||||
if (allUnchecked) {
|
|
||||||
plan.setTestState(CheckStateEnum.UNCHECKED.getValue());
|
|
||||||
} else if (allArchived && !devSubs.isEmpty()) {
|
|
||||||
plan.setTestState(CheckStateEnum.CHECKED.getValue());
|
|
||||||
} else {
|
|
||||||
plan.setTestState(CheckStateEnum.CHECKING.getValue());
|
plan.setTestState(CheckStateEnum.CHECKING.getValue());
|
||||||
|
// 都已检测完成
|
||||||
|
if (checkedCount == devSubs.size()) {
|
||||||
|
plan.setTestState(CheckStateEnum.CHECKED.getValue());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
plan.setTestState(CheckStateEnum.UNCHECKED.getValue());
|
||||||
|
// 是否有检测中
|
||||||
|
long checkingCount = devSubs.stream().filter(sub -> sub.getCheckState().equals(CheckStateEnum.CHECKING.getValue())).count();
|
||||||
|
if (checkingCount > 0) {
|
||||||
|
plan.setTestState(CheckStateEnum.CHECKING.getValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
adPlanService.updateById(plan);
|
adPlanService.updateById(plan);
|
||||||
LocalDateTime endTime = LocalDateTime.now();
|
LocalDateTime endTime = LocalDateTime.now();
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
|||||||
}
|
}
|
||||||
List<PqDevVO> pqDevVOList = pqDevMapper.selectByQueryParam(queryParam1);
|
List<PqDevVO> pqDevVOList = pqDevMapper.selectByQueryParam(queryParam1);
|
||||||
if (CollUtil.isNotEmpty(pqDevVOList)) {
|
if (CollUtil.isNotEmpty(pqDevVOList)) {
|
||||||
long count = pqDevVOList.stream().filter(pqDev -> pqDev.getCheckState() != null && pqDev.getCheckState() >= CheckStateEnum.CHECKED.getValue()).count();
|
long count = pqDevVOList.stream().filter(pqDev -> CheckStateEnum.CHECKED.getValue().equals(pqDev.getCheckState()) || CheckStateEnum.DOCUMENTED.getValue().equals(pqDev.getCheckState())).count();
|
||||||
adPlanVO.setProgress((float) count / pqDevVOList.size());
|
adPlanVO.setProgress((float) count / pqDevVOList.size());
|
||||||
} else {
|
} else {
|
||||||
adPlanVO.setProgress(0.0f);
|
adPlanVO.setProgress(0.0f);
|
||||||
@@ -405,13 +405,10 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
|||||||
PqDevParam.QueryParam queryParam = new PqDevParam.QueryParam();
|
PqDevParam.QueryParam queryParam = new PqDevParam.QueryParam();
|
||||||
queryParam.setPlanIdList(Collections.singletonList(plan1.getId()));
|
queryParam.setPlanIdList(Collections.singletonList(plan1.getId()));
|
||||||
List<PqDevVO> pqDevVOS = pqDevService.listByPlanId(queryParam);
|
List<PqDevVO> pqDevVOS = pqDevService.listByPlanId(queryParam);
|
||||||
boolean allUnchecked = pqDevVOS.stream().allMatch(pqDevVO -> CheckStateEnum.UNCHECKED.getValue().equals(pqDevVO.getCheckState()));
|
long checkedCount = pqDevVOS.stream().filter(pqDevVO -> pqDevVO.getCheckState().equals(CheckStateEnum.CHECKED.getValue())).count();
|
||||||
boolean allArchived = pqDevVOS.stream().allMatch(pqDevVO -> pqDevVO.getCheckState() != null && pqDevVO.getCheckState() >= CheckStateEnum.DOCUMENTED.getValue());
|
if (checkedCount == pqDevVOS.size()) {
|
||||||
if (allUnchecked) {
|
|
||||||
plan1.setTestState(CheckStateEnum.UNCHECKED.getValue());
|
|
||||||
} else if (allArchived && !pqDevVOS.isEmpty()) {
|
|
||||||
plan1.setTestState(CheckStateEnum.CHECKED.getValue());
|
plan1.setTestState(CheckStateEnum.CHECKED.getValue());
|
||||||
} else {
|
} else if (checkedCount > 0) {
|
||||||
plan1.setTestState(CheckStateEnum.CHECKING.getValue());
|
plan1.setTestState(CheckStateEnum.CHECKING.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -835,19 +832,12 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
|||||||
List<PqDevVO> checkedDevices = planDevices.stream()
|
List<PqDevVO> checkedDevices = planDevices.stream()
|
||||||
.filter(this::isCheckedDevice)
|
.filter(this::isCheckedDevice)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
int uncheckedDeviceCount = (int) planDevices.stream()
|
|
||||||
.filter(dev -> Objects.equals(dev.getCheckState(), CheckStateEnum.UNCHECKED.getValue()))
|
|
||||||
.count();
|
|
||||||
int checkingDeviceCount = (int) planDevices.stream()
|
|
||||||
.filter(dev -> Objects.equals(dev.getCheckState(), CheckStateEnum.CHECKING.getValue()))
|
|
||||||
.count();
|
|
||||||
PlanStatisticsVO statistics = new PlanStatisticsVO();
|
PlanStatisticsVO statistics = new PlanStatisticsVO();
|
||||||
statistics.setPlanId(plan.getId());
|
statistics.setPlanId(plan.getId());
|
||||||
statistics.setPlanName(plan.getName());
|
statistics.setPlanName(plan.getName());
|
||||||
statistics.setManufacturerOptions(buildManufacturerOptions(allPlanDevices, param.getDevType()));
|
statistics.setManufacturerOptions(buildManufacturerOptions(allPlanDevices, param.getDevType()));
|
||||||
statistics.setDevTypeOptions(buildDevTypeOptions(allPlanDevices, param.getManufacturer()));
|
statistics.setDevTypeOptions(buildDevTypeOptions(allPlanDevices, param.getManufacturer()));
|
||||||
statistics.setUncheckedDeviceCount(uncheckedDeviceCount);
|
statistics.setUncheckedDeviceCount(planDevices.size() - checkedDevices.size());
|
||||||
statistics.setCheckingDeviceCount(checkingDeviceCount);
|
|
||||||
statistics.setCheckedDeviceCount(checkedDevices.size());
|
statistics.setCheckedDeviceCount(checkedDevices.size());
|
||||||
statistics.setTotalCheckCount(checkedDevices.stream().mapToInt(dev -> defaultZero(dev.getRecheckNum())).sum());
|
statistics.setTotalCheckCount(checkedDevices.stream().mapToInt(dev -> defaultZero(dev.getRecheckNum())).sum());
|
||||||
|
|
||||||
@@ -945,8 +935,9 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isCheckedDevice(PqDevVO dev) {
|
private boolean isCheckedDevice(PqDevVO dev) {
|
||||||
Integer checkState = dev.getCheckState();
|
return (Objects.equals(dev.getCheckState(), CheckStateEnum.CHECKED.getValue())
|
||||||
return checkState != null && checkState >= CheckStateEnum.CHECKED.getValue();
|
|| Objects.equals(dev.getCheckState(), CheckStateEnum.DOCUMENTED.getValue()))
|
||||||
|
&& !Objects.equals(dev.getCheckResult(), CheckResultEnum.UNCHECKED.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<PlanStatisticsItemVO> buildItemDistributions(AdPlan plan, List<PqDevVO> checkedDevices) {
|
private List<PlanStatisticsItemVO> buildItemDistributions(AdPlan plan, List<PqDevVO> checkedDevices) {
|
||||||
@@ -1244,22 +1235,26 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
|||||||
// 0-解绑、1-绑定
|
// 0-解绑、1-绑定
|
||||||
if (param.getBindFlag().equals(1)) {
|
if (param.getBindFlag().equals(1)) {
|
||||||
pqDevService.lambdaUpdate().set(PqDev::getPlanId, plan.getId()).in(PqDev::getId, param.getDevIds()).update();
|
pqDevService.lambdaUpdate().set(PqDev::getPlanId, plan.getId()).in(PqDev::getId, param.getDevIds()).update();
|
||||||
|
// 绑定被检设备,若检测计划已检测完成,则修改为检测中
|
||||||
|
if (plan.getTestState().equals(CheckStateEnum.CHECKED.getValue())) {
|
||||||
|
plan.setTestState(CheckStateEnum.CHECKING.getValue());
|
||||||
|
this.updateById(plan);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
pqDevService.lambdaUpdate().set(PqDev::getPlanId, plan.getFatherPlanId()).in(PqDev::getId, param.getDevIds()).update();
|
pqDevService.lambdaUpdate().set(PqDev::getPlanId, plan.getFatherPlanId()).in(PqDev::getId, param.getDevIds()).update();
|
||||||
|
// 解绑被检设备,若检测计划检测中,且所有设备已检测完成,则修改为检测完成
|
||||||
|
if (plan.getTestState().equals(CheckStateEnum.CHECKING.getValue())) {
|
||||||
|
PqDevParam.QueryParam queryParam = new PqDevParam.QueryParam();
|
||||||
|
queryParam.setPlanIdList(Collections.singletonList(plan.getId()));
|
||||||
|
List<PqDevVO> pqDevVOS = pqDevService.listByPlanId(queryParam);
|
||||||
|
long checkedCount = pqDevVOS.stream().filter(pqDevVO -> pqDevVO.getCheckState().equals(CheckStateEnum.CHECKED.getValue())).count();
|
||||||
|
if (checkedCount == pqDevVOS.size()) {
|
||||||
|
plan.setTestState(CheckStateEnum.CHECKED.getValue());
|
||||||
|
this.updateById(plan);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
PqDevParam.QueryParam queryParam = new PqDevParam.QueryParam();
|
|
||||||
queryParam.setPlanIdList(Collections.singletonList(plan.getId()));
|
|
||||||
List<PqDevVO> pqDevVOS = pqDevService.listByPlanId(queryParam);
|
|
||||||
boolean allUnchecked = pqDevVOS.stream().allMatch(pqDevVO -> CheckStateEnum.UNCHECKED.getValue().equals(pqDevVO.getCheckState()));
|
|
||||||
boolean allArchived = pqDevVOS.stream().allMatch(pqDevVO -> pqDevVO.getCheckState() != null && pqDevVO.getCheckState() >= CheckStateEnum.DOCUMENTED.getValue());
|
|
||||||
if (allUnchecked) {
|
|
||||||
plan.setTestState(CheckStateEnum.UNCHECKED.getValue());
|
|
||||||
} else if (allArchived && !pqDevVOS.isEmpty()) {
|
|
||||||
plan.setTestState(CheckStateEnum.CHECKED.getValue());
|
|
||||||
} else {
|
|
||||||
plan.setTestState(CheckStateEnum.CHECKING.getValue());
|
|
||||||
}
|
|
||||||
this.updateById(plan);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import lombok.Getter;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 电能质量测试大项枚举
|
* 电能质量测试大项枚举
|
||||||
*
|
|
||||||
* @author hongawen
|
* @author hongawen
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
* @data 2025/3/27 18:29
|
* @data 2025/3/27 18:29
|
||||||
@@ -14,22 +13,22 @@ public enum PowerIndexEnum {
|
|||||||
|
|
||||||
|
|
||||||
UNKNOWN("UNKNOWN", "未知指标"),
|
UNKNOWN("UNKNOWN", "未知指标"),
|
||||||
LINE_TITLE("LINE_TITLE", "测量回路"),
|
|
||||||
FREQ("FREQ", "频率"),
|
FREQ("FREQ", "频率"),
|
||||||
|
LINE_TITLE("LINE_TITLE", "测量回路"),
|
||||||
V("V", "电压"),
|
V("V", "电压"),
|
||||||
HV("HV", "谐波电压"),
|
|
||||||
HI("HI", "谐波电流"),
|
|
||||||
HP("HP", "谐波有功功率"),
|
|
||||||
HSV("HSV", "间谐波电压"),
|
|
||||||
HSI("HSI", "间谐波电流"),
|
|
||||||
VOLTAGE("VOLTAGE", "电压暂降、暂升及短时中断"),
|
|
||||||
I("I", "电流"),
|
I("I", "电流"),
|
||||||
|
P("P", "功率"),
|
||||||
|
ANGLE("Angle", "基波相位"),
|
||||||
IMBV("IMBV", "负序电压不平衡度"),
|
IMBV("IMBV", "负序电压不平衡度"),
|
||||||
IMBA("IMBA", "负序电流不平衡度"),
|
IMBA("IMBA", "负序电流不平衡度"),
|
||||||
F("F", "短时电压闪变"),
|
F("F", "短时电压闪变"),
|
||||||
LF("LF", "长时电压闪变"),
|
HP("HP", "谐波有功功率"),
|
||||||
P("P", "功率"),
|
HV("HV", "谐波电压"),
|
||||||
ANGLE("Angle", "基波相位");
|
HI("HI", "谐波电流"),
|
||||||
|
HSV("HSV", "间谐波电压"),
|
||||||
|
HSI("HSI", "间谐波电流"),
|
||||||
|
VOLTAGE("VOLTAGE", "电压暂降、暂升及短时中断"),
|
||||||
|
PST("PST", "短时间闪变");
|
||||||
|
|
||||||
private String key;
|
private String key;
|
||||||
|
|
||||||
|
|||||||
@@ -2220,7 +2220,7 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
|||||||
queryParam.setPlanIdList(Arrays.asList(tempPqDevVO.getPlanId()));
|
queryParam.setPlanIdList(Arrays.asList(tempPqDevVO.getPlanId()));
|
||||||
List<PqDevVO> pqDevVOList1 = pqDevMapper.selectByQueryParam(queryParam);
|
List<PqDevVO> pqDevVOList1 = pqDevMapper.selectByQueryParam(queryParam);
|
||||||
|
|
||||||
long count = pqDevVOList1.stream().filter(obj -> obj.getCheckState() == null || obj.getCheckState() < CheckStateEnum.DOCUMENTED.getValue()).count();
|
long count = pqDevVOList1.stream().filter(obj -> !CheckStateEnum.DOCUMENTED.getValue().equals(obj.getCheckState())).count();
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
// 如果非归档状态的设备数量为0,则更新计划已完成
|
// 如果非归档状态的设备数量为0,则更新计划已完成
|
||||||
pqDevMapper.finishPlan(pqDevVO.getPlanId());
|
pqDevMapper.finishPlan(pqDevVO.getPlanId());
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ import com.njcn.gather.system.dictionary.pojo.po.DictData;
|
|||||||
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
|
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
|
||||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||||
import com.njcn.gather.system.dictionary.service.IDictTreeService;
|
import com.njcn.gather.system.dictionary.service.IDictTreeService;
|
||||||
|
import com.njcn.gather.system.pojo.enums.DicDataEnum;
|
||||||
import com.njcn.gather.util.StorageUtil;
|
import com.njcn.gather.util.StorageUtil;
|
||||||
import com.njcn.http.util.RestTemplateUtil;
|
import com.njcn.http.util.RestTemplateUtil;
|
||||||
import com.njcn.web.utils.ExcelUtil;
|
import com.njcn.web.utils.ExcelUtil;
|
||||||
@@ -2203,15 +2204,15 @@ public class ResultServiceImpl implements IResultService {
|
|||||||
DictTree dictTree = dictTreeList.get(0);
|
DictTree dictTree = dictTreeList.get(0);
|
||||||
|
|
||||||
String unit = StorageUtil.unit(dictTree.getCode());
|
String unit = StorageUtil.unit(dictTree.getCode());
|
||||||
if (PowerIndexEnum.HV.getKey().equals(dictTree.getCode()) || PowerIndexEnum.HI.getKey().equals(dictTree.getCode())) {
|
if (DicDataEnum.HV.getCode().equals(dictTree.getCode()) || DicDataEnum.HI.getCode().equals(dictTree.getCode())) {
|
||||||
unit = "%";
|
unit = "%";
|
||||||
if (PowerIndexEnum.HI.getKey().equals(dictTree.getCode())) {
|
if (DicDataEnum.HI.getCode().equals(dictTree.getCode())) {
|
||||||
unit = "A";
|
unit = "A";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (PowerIndexEnum.HSV.getKey().equals(dictTree.getCode()) || PowerIndexEnum.HSI.getKey().equals(dictTree.getCode())) {
|
if (DicDataEnum.HSV.getCode().equals(dictTree.getCode()) || DicDataEnum.HSI.getCode().equals(dictTree.getCode())) {
|
||||||
unit = "%";
|
unit = "%";
|
||||||
if (PowerIndexEnum.HSI.getKey().equals(dictTree.getCode())) {
|
if (DicDataEnum.HSI.getCode().equals(dictTree.getCode())) {
|
||||||
unit = "A";
|
unit = "A";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3423,10 +3424,10 @@ public class ResultServiceImpl implements IResultService {
|
|||||||
if (CollUtil.isNotEmpty(contrastHarmonicResults)) {
|
if (CollUtil.isNotEmpty(contrastHarmonicResults)) {
|
||||||
ContrastHarmonicResult contrastHarmonicResult = contrastHarmonicResults.get(0);
|
ContrastHarmonicResult contrastHarmonicResult = contrastHarmonicResults.get(0);
|
||||||
List<Double> harmonicNum = null;
|
List<Double> harmonicNum = null;
|
||||||
if (PowerIndexEnum.HV.getKey().equals(dictTree.getCode()) || PowerIndexEnum.HI.getKey().equals(dictTree.getCode()) || PowerIndexEnum.HP.getKey().equals(dictTree.getCode())) {
|
if (DicDataEnum.HV.getCode().equals(dictTree.getCode()) || DicDataEnum.HI.getCode().equals(dictTree.getCode()) || DicDataEnum.HP.getCode().equals(dictTree.getCode())) {
|
||||||
harmonicNum = Stream.iterate(2.0, n -> n + 1).limit(49).collect(Collectors.toList());
|
harmonicNum = Stream.iterate(2.0, n -> n + 1).limit(49).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
if (PowerIndexEnum.HSV.getKey().equals(dictTree.getCode()) || PowerIndexEnum.HSI.getKey().equals(dictTree.getCode())) {
|
if (DicDataEnum.HSV.getCode().equals(dictTree.getCode()) || DicDataEnum.HSI.getCode().equals(dictTree.getCode())) {
|
||||||
harmonicNum = Stream.iterate(0.5, n -> n + 1).limit(50).collect(Collectors.toList());
|
harmonicNum = Stream.iterate(0.5, n -> n + 1).limit(50).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
for (Double n : harmonicNum) {
|
for (Double n : harmonicNum) {
|
||||||
@@ -3492,7 +3493,7 @@ public class ResultServiceImpl implements IResultService {
|
|||||||
|
|
||||||
ContrastNonHarmonicResult contrastNonHarmonicResultStdDev = stdDevNonHarmonicRawDataList.get(i);
|
ContrastNonHarmonicResult contrastNonHarmonicResultStdDev = stdDevNonHarmonicRawDataList.get(i);
|
||||||
rawDataVO.setTimeStdDev(contrastNonHarmonicResultStdDev.getTimeId().format(dtf));
|
rawDataVO.setTimeStdDev(contrastNonHarmonicResultStdDev.getTimeId().format(dtf));
|
||||||
if (!PowerIndexEnum.IMBV.getKey().equals(dictTree.getCode()) && !PowerIndexEnum.IMBA.getKey().equals(dictTree.getCode())) {
|
if (!DicDataEnum.IMBV.getCode().equals(dictTree.getCode()) && !DicDataEnum.IMBA.getCode().equals(dictTree.getCode())) {
|
||||||
rawDataVO.setUaDev(getValue(contrastNonHarmonicResultDev.getAValue()));
|
rawDataVO.setUaDev(getValue(contrastNonHarmonicResultDev.getAValue()));
|
||||||
rawDataVO.setUcDev(getValue(contrastNonHarmonicResultDev.getCValue()));
|
rawDataVO.setUcDev(getValue(contrastNonHarmonicResultDev.getCValue()));
|
||||||
rawDataVO.setUaStdDev(getValue(contrastNonHarmonicResultStdDev.getAValue()));
|
rawDataVO.setUaStdDev(getValue(contrastNonHarmonicResultStdDev.getAValue()));
|
||||||
@@ -3511,11 +3512,11 @@ public class ResultServiceImpl implements IResultService {
|
|||||||
if (CollUtil.isNotEmpty(devHarmonicRawDataList) && CollUtil.isNotEmpty(stdDevHarmonicRawDataList)) {
|
if (CollUtil.isNotEmpty(devHarmonicRawDataList) && CollUtil.isNotEmpty(stdDevHarmonicRawDataList)) {
|
||||||
List<Double> harmonicNum = null;
|
List<Double> harmonicNum = null;
|
||||||
boolean isHarm = true;
|
boolean isHarm = true;
|
||||||
if (PowerIndexEnum.HV.getKey().equals(dictTree.getCode()) || PowerIndexEnum.HI.getKey().equals(dictTree.getCode()) || PowerIndexEnum.HP.getKey().equals(dictTree.getCode())) {
|
if (DicDataEnum.HV.getCode().equals(dictTree.getCode()) || DicDataEnum.HI.getCode().equals(dictTree.getCode()) || DicDataEnum.HP.getCode().equals(dictTree.getCode())) {
|
||||||
harmonicNum = Stream.iterate(2.0, n -> n + 1).limit(49).collect(Collectors.toList());
|
harmonicNum = Stream.iterate(2.0, n -> n + 1).limit(49).collect(Collectors.toList());
|
||||||
isHarm = true;
|
isHarm = true;
|
||||||
}
|
}
|
||||||
if (PowerIndexEnum.HSV.getKey().equals(dictTree.getCode()) || PowerIndexEnum.HSI.getKey().equals(dictTree.getCode())) {
|
if (DicDataEnum.HSV.getCode().equals(dictTree.getCode()) || DicDataEnum.HSI.getCode().equals(dictTree.getCode())) {
|
||||||
harmonicNum = Stream.iterate(0.5, n -> n + 1).limit(50).collect(Collectors.toList());
|
harmonicNum = Stream.iterate(0.5, n -> n + 1).limit(50).collect(Collectors.toList());
|
||||||
isHarm = false;
|
isHarm = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import com.njcn.gather.device.pojo.vo.PqDevVO;
|
|||||||
import com.njcn.gather.device.service.IPqDevService;
|
import com.njcn.gather.device.service.IPqDevService;
|
||||||
import com.njcn.gather.plan.mapper.AdPlanMapper;
|
import com.njcn.gather.plan.mapper.AdPlanMapper;
|
||||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||||
import com.njcn.gather.report.pojo.enums.PowerIndexEnum;
|
import com.njcn.gather.result.pojo.enums.ResultUnitEnum;
|
||||||
import com.njcn.gather.script.mapper.PqScriptCheckDataMapper;
|
import com.njcn.gather.script.mapper.PqScriptCheckDataMapper;
|
||||||
import com.njcn.gather.script.mapper.PqScriptDtlsMapper;
|
import com.njcn.gather.script.mapper.PqScriptDtlsMapper;
|
||||||
import com.njcn.gather.script.mapper.PqScriptMapper;
|
import com.njcn.gather.script.mapper.PqScriptMapper;
|
||||||
@@ -37,10 +37,12 @@ import com.njcn.gather.script.util.ThreePhaseUnbalance;
|
|||||||
import com.njcn.gather.source.service.IPqSourceService;
|
import com.njcn.gather.source.service.IPqSourceService;
|
||||||
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
|
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
|
||||||
import com.njcn.gather.system.dictionary.service.IDictTreeService;
|
import com.njcn.gather.system.dictionary.service.IDictTreeService;
|
||||||
|
import com.njcn.gather.system.pojo.enums.DicDataEnum;
|
||||||
import com.njcn.gather.type.pojo.po.DevType;
|
import com.njcn.gather.type.pojo.po.DevType;
|
||||||
import com.njcn.gather.type.service.IDevTypeService;
|
import com.njcn.gather.type.service.IDevTypeService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@@ -67,7 +69,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
private final static String INHARM_I = "InHarm_I";
|
private final static String INHARM_I = "InHarm_I";
|
||||||
private final static String DIP = "Dip";
|
private final static String DIP = "Dip";
|
||||||
private final static String FLICKER = "Flicker";
|
private final static String FLICKER = "Flicker";
|
||||||
// @Value("${Dip.fPreTime}")
|
// @Value("${Dip.fPreTime}")
|
||||||
// private Double fPreTime;
|
// private Double fPreTime;
|
||||||
// @Value("${Dip.fRampIn}")
|
// @Value("${Dip.fRampIn}")
|
||||||
// private Double fRampIn;
|
// private Double fRampIn;
|
||||||
@@ -203,7 +205,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
checkDataParam.setScriptId(freqDtls.getScriptId());
|
checkDataParam.setScriptId(freqDtls.getScriptId());
|
||||||
checkDataParam.setIndex(freqDtls.getScriptIndex());
|
checkDataParam.setIndex(freqDtls.getScriptIndex());
|
||||||
checkDataParam.setIsValueTypeName(true);
|
checkDataParam.setIsValueTypeName(true);
|
||||||
if (PowerIndexEnum.F.getKey().equals(issue.getType()) || PowerIndexEnum.LF.getKey().equals(issue.getType()) || PowerIndexEnum.VOLTAGE.getKey().equals(issue.getType())) {
|
if (DicDataEnum.F.getCode().equals(issue.getType()) || DicDataEnum.VOLTAGE.getCode().equals(issue.getType())) {
|
||||||
checkDataParam.setDataType("avg");
|
checkDataParam.setDataType("avg");
|
||||||
issue.setDataType("avg");
|
issue.setDataType("avg");
|
||||||
} else {
|
} else {
|
||||||
@@ -245,7 +247,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
issueAdd(curList, dtlsIList, HARM_I, INHARM_I, freqDtls.getValue(), "I", channelListDTOS, checkDataParam, devFly, isValueType);
|
issueAdd(curList, dtlsIList, HARM_I, INHARM_I, freqDtls.getValue(), "I", channelListDTOS, checkDataParam, devFly, isValueType);
|
||||||
|
|
||||||
issue.setChannelList(channelListDTOS);
|
issue.setChannelList(channelListDTOS);
|
||||||
if (PowerIndexEnum.P.getKey().equals(issue.getType()) || PowerIndexEnum.ANGLE.getKey().equals(issue.getType()) || PowerIndexEnum.LF.getKey().equals(issue.getType())) {
|
if (ResultUnitEnum.P.getCode().equals(issue.getType()) || ResultUnitEnum.ANGLE.getCode().equals(issue.getType())) {
|
||||||
issue.setOtherType(issue.getType());
|
issue.setOtherType(issue.getType());
|
||||||
} else {
|
} else {
|
||||||
issue.setOtherType(null);
|
issue.setOtherType(null);
|
||||||
@@ -628,7 +630,6 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
unbanSeqCheck(info, channelListDTO, channelI, checkArchive);
|
unbanSeqCheck(info, channelListDTO, channelI, checkArchive);
|
||||||
break;
|
break;
|
||||||
case PST:
|
case PST:
|
||||||
case PLT:
|
|
||||||
if (CollUtil.isNotEmpty(channelList)) {
|
if (CollUtil.isNotEmpty(channelList)) {
|
||||||
channelU = channelList.stream().filter(x -> x.getChannelType().contains("U")).collect(Collectors.toList());
|
channelU = channelList.stream().filter(x -> x.getChannelType().contains("U")).collect(Collectors.toList());
|
||||||
for (PqScriptDtlsParam.ChannelListDTO listDTO : channelU) {
|
for (PqScriptDtlsParam.ChannelListDTO listDTO : channelU) {
|
||||||
@@ -664,7 +665,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
if (v == 90 || v == -90 || v == 270 || v == -270) {
|
if (v == 90 || v == -90 || v == 270 || v == -270) {
|
||||||
checkData.setValue(0.0);
|
checkData.setValue(0.0);
|
||||||
} else {
|
} else {
|
||||||
checkData.setValue(channelI.get(0).getFAmp() * listDTO.getFAmp() / radio * Math.cos(v * Math.PI / 180));
|
checkData.setValue(channelI.get(0).getFAmp() * listDTO.getFAmp() * Math.cos(v * Math.PI / 180));
|
||||||
}
|
}
|
||||||
setCheck(info, checkData, channelListDTO, checkArchive, listDTO);
|
setCheck(info, checkData, channelListDTO, checkArchive, listDTO);
|
||||||
}
|
}
|
||||||
@@ -689,7 +690,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
if (v == 0 || v == 360 || v == 180 || v == -180) {
|
if (v == 0 || v == 360 || v == 180 || v == -180) {
|
||||||
checkData.setValue(0.0);
|
checkData.setValue(0.0);
|
||||||
} else {
|
} else {
|
||||||
checkData.setValue(channelI.get(0).getFAmp() * listDTO.getFAmp() / radio * Math.sin(v * Math.PI / 180));
|
checkData.setValue(channelI.get(0).getFAmp() * listDTO.getFAmp() * Math.sin(v * Math.PI / 180));
|
||||||
}
|
}
|
||||||
// if (valueType) {
|
// if (valueType) {
|
||||||
// checkData.setValue(checkData.getValue() * 57.74 * 5);
|
// checkData.setValue(checkData.getValue() * 57.74 * 5);
|
||||||
@@ -759,7 +760,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
if (v == 90 || v == -90 || v == 270 || v == -270) {
|
if (v == 90 || v == -90 || v == 270 || v == -270) {
|
||||||
value += 0.0;
|
value += 0.0;
|
||||||
} else {
|
} else {
|
||||||
value += channelI.get(0).getFAmp() * listDTO.getFAmp() / radio * Math.cos(v * Math.PI / 180);
|
value += channelI.get(0).getFAmp() * listDTO.getFAmp() * Math.cos(v * Math.PI / 180);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -788,7 +789,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
if (v == 0 || v == 360 || v == 180 || v == -180) {
|
if (v == 0 || v == 360 || v == 180 || v == -180) {
|
||||||
value += 0.0;
|
value += 0.0;
|
||||||
} else {
|
} else {
|
||||||
value += channelI.get(0).getFAmp() * listDTO.getFAmp() / radio * Math.sin(v * Math.PI / 180);
|
value += channelI.get(0).getFAmp() * listDTO.getFAmp() * Math.sin(v * Math.PI / 180);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -812,7 +813,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
.filter(x -> x.getChannelType().contains("I" + listDTO.getChannelType().substring(1, 2)))
|
.filter(x -> x.getChannelType().contains("I" + listDTO.getChannelType().substring(1, 2)))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
if (CollUtil.isNotEmpty(channelI)) {
|
if (CollUtil.isNotEmpty(channelI)) {
|
||||||
value += channelI.get(0).getFAmp() * listDTO.getFAmp() / radio;
|
value += channelI.get(0).getFAmp() * listDTO.getFAmp();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
checkData = new PqScriptDtlsParam.CheckData();
|
checkData = new PqScriptDtlsParam.CheckData();
|
||||||
@@ -842,9 +843,9 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
if (v == 90 || v == -90 || v == 270 || v == -270) {
|
if (v == 90 || v == -90 || v == 270 || v == -270) {
|
||||||
valueTotW += 0.0;
|
valueTotW += 0.0;
|
||||||
} else {
|
} else {
|
||||||
valueTotW += channelI.get(0).getFAmp() * listDTO.getFAmp() / radio * Math.cos(v * Math.PI / 180);
|
valueTotW += channelI.get(0).getFAmp() * listDTO.getFAmp() * Math.cos(v * Math.PI / 180);
|
||||||
}
|
}
|
||||||
valueTotVA += channelI.get(0).getFAmp() * listDTO.getFAmp() / radio;
|
valueTotVA += channelI.get(0).getFAmp() * listDTO.getFAmp();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
checkData = new PqScriptDtlsParam.CheckData();
|
checkData = new PqScriptDtlsParam.CheckData();
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
package com.njcn.gather.detection.service.impl;
|
|
||||||
|
|
||||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
public class PreDetectionServiceImplTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void isFirstFormalIssueOfBigItem_returnsTrueForFirstIssueOfType() {
|
|
||||||
List<SourceIssue> allIssues = Arrays.asList(issue(10, "voltage"), issue(20, "voltage"), issue(30, "current"));
|
|
||||||
|
|
||||||
assertTrue(PreDetectionServiceImpl.isFirstFormalIssueOfBigItem(allIssues, issue(10, "voltage"), "voltage"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void isFirstFormalIssueOfBigItem_returnsFalseWhenResumingInsideSameBigItem() {
|
|
||||||
List<SourceIssue> allIssues = Arrays.asList(issue(10, "voltage"), issue(20, "voltage"), issue(30, "current"));
|
|
||||||
|
|
||||||
assertFalse(PreDetectionServiceImpl.isFirstFormalIssueOfBigItem(allIssues, issue(20, "voltage"), "voltage"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void isFirstFormalIssueOfBigItem_usesOtherTypeAsBigItemType() {
|
|
||||||
List<SourceIssue> allIssues = Arrays.asList(otherTypeIssue(10, "V", "voltage"), otherTypeIssue(20, "V", "voltage"));
|
|
||||||
|
|
||||||
assertTrue(PreDetectionServiceImpl.isFirstFormalIssueOfBigItem(allIssues, otherTypeIssue(10, "V", "voltage"), "voltage"));
|
|
||||||
}
|
|
||||||
|
|
||||||
private SourceIssue issue(Integer index, String type) {
|
|
||||||
SourceIssue issue = new SourceIssue();
|
|
||||||
issue.setIndex(index);
|
|
||||||
issue.setType(type);
|
|
||||||
return issue;
|
|
||||||
}
|
|
||||||
|
|
||||||
private SourceIssue otherTypeIssue(Integer index, String type, String otherType) {
|
|
||||||
SourceIssue issue = issue(index, type);
|
|
||||||
issue.setOtherType(otherType);
|
|
||||||
return issue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
package com.njcn.gather.detection.util.socket;
|
|
||||||
|
|
||||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertSame;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
public class FormalTestManagerPauseTest {
|
|
||||||
|
|
||||||
@After
|
|
||||||
public void tearDown() {
|
|
||||||
FormalTestManager.clearFormalRuntime();
|
|
||||||
SocketManager.clearFormalRuntime();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void requestWaitPause_keepsPauseDeferredUntilCurrentItemFinishes() {
|
|
||||||
FormalTestManager.requestWaitPause();
|
|
||||||
|
|
||||||
assertTrue(FormalTestManager.stopFlag);
|
|
||||||
assertFalse(FormalTestManager.hasStopFlag);
|
|
||||||
assertTrue(FormalTestManager.isWaitCurrentItemPause());
|
|
||||||
assertFalse(FormalTestManager.isImmediatePause());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void requestImmediatePause_entersPausedStateImmediately() {
|
|
||||||
FormalTestManager.requestImmediatePause();
|
|
||||||
|
|
||||||
assertTrue(FormalTestManager.stopFlag);
|
|
||||||
assertTrue(FormalTestManager.hasStopFlag);
|
|
||||||
assertFalse(FormalTestManager.isWaitCurrentItemPause());
|
|
||||||
assertTrue(FormalTestManager.isImmediatePause());
|
|
||||||
assertEquals(Integer.valueOf(0), FormalTestManager.stopTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void ensureFirst_keepsCurrentIssueAtQueueHead() {
|
|
||||||
SourceIssue first = issue(1, "V");
|
|
||||||
SourceIssue second = issue(2, "I");
|
|
||||||
SocketManager.addSourceList(new ArrayList<>(Arrays.asList(second)));
|
|
||||||
|
|
||||||
SocketManager.ensureFirst(first);
|
|
||||||
|
|
||||||
assertSame(first, SocketManager.getSourceList().get(0));
|
|
||||||
assertSame(second, SocketManager.getSourceList().get(1));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void ensureFirst_doesNotDuplicateExistingHead() {
|
|
||||||
SourceIssue first = issue(1, "V");
|
|
||||||
SocketManager.addSourceList(new ArrayList<>(Arrays.asList(first)));
|
|
||||||
|
|
||||||
SocketManager.ensureFirst(first);
|
|
||||||
|
|
||||||
assertEquals(1, SocketManager.getSourceList().size());
|
|
||||||
assertSame(first, SocketManager.getSourceList().get(0));
|
|
||||||
}
|
|
||||||
|
|
||||||
private SourceIssue issue(Integer index, String type) {
|
|
||||||
SourceIssue issue = new SourceIssue();
|
|
||||||
issue.setIndex(index);
|
|
||||||
issue.setType(type);
|
|
||||||
issue.setDesc(type + " item");
|
|
||||||
return issue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -74,10 +74,4 @@ public interface SimAndDigHarmonicService extends IService<SimAndDigHarmonicResu
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<SimAndDigHarmonicResult> listAllRawData(String scriptId, String code, String devId);
|
List<SimAndDigHarmonicResult> listAllRawData(String scriptId, String code, String devId);
|
||||||
|
|
||||||
Map<String, Integer> maxSortByDevIds(String code, String scriptId, List<String> devIds);
|
|
||||||
|
|
||||||
List<SimAndDigHarmonicResult> listByDevIdsAndSorts(String code, String scriptId, List<String> devIds, List<Integer> sorts);
|
|
||||||
|
|
||||||
Map<String, List<Integer>> resultFlagsByDevIdsAndSorts(String code, String scriptId, List<String> devIds, List<Integer> sorts);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,10 +79,4 @@ public interface SimAndDigNonHarmonicService extends IService<SimAndDigNonHarmon
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<SimAndDigNonHarmonicResult> listAllSimAndDigRawData(String scriptId, String code, String devId);
|
List<SimAndDigNonHarmonicResult> listAllSimAndDigRawData(String scriptId, String code, String devId);
|
||||||
|
|
||||||
Map<String, Integer> maxSortByDevIds(String code, String scriptId, List<String> devIds);
|
|
||||||
|
|
||||||
List<SimAndDigNonHarmonicResult> listByDevIdsAndSorts(String code, String scriptId, List<String> devIds, List<Integer> sorts);
|
|
||||||
|
|
||||||
Map<String, List<Integer>> resultFlagsByDevIdsAndSorts(String code, String scriptId, List<String> devIds, List<Integer> sorts);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -276,96 +276,4 @@ public class SimAndDigHarmonicServiceImpl extends ServiceImpl<SimAndDigHarmonicM
|
|||||||
DynamicTableNameHandler.remove();
|
DynamicTableNameHandler.remove();
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, Integer> maxSortByDevIds(String code, String scriptId, List<String> devIds) {
|
|
||||||
Map<String, Integer> result = new HashMap<>();
|
|
||||||
if (CollUtil.isEmpty(devIds)) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
DynamicTableNameHandler.setTableName("ad_harmonic_result_" + code);
|
|
||||||
try {
|
|
||||||
LambdaQueryWrapper<SimAndDigHarmonicResult> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.select(SimAndDigHarmonicResult::getDevMonitorId, SimAndDigHarmonicResult::getSort)
|
|
||||||
.eq(SimAndDigHarmonicResult::getScriptId, scriptId)
|
|
||||||
.and(w -> {
|
|
||||||
for (String devId : devIds) {
|
|
||||||
w.or().likeRight(SimAndDigHarmonicResult::getDevMonitorId, devId + "_");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.list(wrapper).forEach(row -> {
|
|
||||||
String devId = row.getDevMonitorId().split("_")[0];
|
|
||||||
result.merge(devId, row.getSort(), Math::max);
|
|
||||||
});
|
|
||||||
return result;
|
|
||||||
} finally {
|
|
||||||
DynamicTableNameHandler.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<SimAndDigHarmonicResult> listByDevIdsAndSorts(String code, String scriptId, List<String> devIds, List<Integer> sorts) {
|
|
||||||
if (CollUtil.isEmpty(devIds) || CollUtil.isEmpty(sorts)) {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
DynamicTableNameHandler.setTableName("ad_harmonic_result_" + code);
|
|
||||||
try {
|
|
||||||
LambdaQueryWrapper<SimAndDigHarmonicResult> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SimAndDigHarmonicResult::getScriptId, scriptId)
|
|
||||||
.in(SimAndDigHarmonicResult::getSort, sorts)
|
|
||||||
.and(w -> {
|
|
||||||
for (String devId : devIds) {
|
|
||||||
w.or().likeRight(SimAndDigHarmonicResult::getDevMonitorId, devId + "_");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return this.list(wrapper);
|
|
||||||
} finally {
|
|
||||||
DynamicTableNameHandler.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, List<Integer>> resultFlagsByDevIdsAndSorts(String code, String scriptId, List<String> devIds, List<Integer> sorts) {
|
|
||||||
Map<String, List<Integer>> result = new HashMap<>();
|
|
||||||
if (CollUtil.isEmpty(devIds) || StrUtil.isBlank(code)) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
if (sorts != null && CollUtil.isEmpty(sorts)) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
DynamicTableNameHandler.setTableName("ad_harmonic_result_" + code);
|
|
||||||
try {
|
|
||||||
LambdaQueryWrapper<SimAndDigHarmonicResult> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.select(SimAndDigHarmonicResult::getDevMonitorId,
|
|
||||||
SimAndDigHarmonicResult::getResultFlag)
|
|
||||||
.eq(StrUtil.isNotBlank(scriptId), SimAndDigHarmonicResult::getScriptId, scriptId)
|
|
||||||
.in(CollUtil.isNotEmpty(sorts), SimAndDigHarmonicResult::getSort, sorts)
|
|
||||||
.and(w -> {
|
|
||||||
for (String devId : devIds) {
|
|
||||||
w.or().likeRight(SimAndDigHarmonicResult::getDevMonitorId, devId + "_");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.list(wrapper).forEach(row -> {
|
|
||||||
String devId = resolveDevId(row.getDevMonitorId(), devIds);
|
|
||||||
if (StrUtil.isNotBlank(devId) && row.getResultFlag() != null) {
|
|
||||||
result.computeIfAbsent(devId, key -> new ArrayList<>()).add(row.getResultFlag());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return result;
|
|
||||||
} finally {
|
|
||||||
DynamicTableNameHandler.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String resolveDevId(String devMonitorId, List<String> devIds) {
|
|
||||||
if (StrUtil.isBlank(devMonitorId)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
for (String devId : devIds) {
|
|
||||||
if (StrUtil.isNotBlank(devId) && devMonitorId.startsWith(devId + "_")) {
|
|
||||||
return devId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import cn.hutool.core.date.DatePattern;
|
|||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||||
import com.njcn.db.mybatisplus.handler.DynamicTableNameHandler;
|
import com.njcn.db.mybatisplus.handler.DynamicTableNameHandler;
|
||||||
@@ -212,96 +211,5 @@ public class SimAndDigNonHarmonicServiceImpl extends ServiceImpl<SimAndDigNonHar
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, Integer> maxSortByDevIds(String code, String scriptId, List<String> devIds) {
|
|
||||||
Map<String, Integer> result = new HashMap<>();
|
|
||||||
if (CollUtil.isEmpty(devIds)) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
DynamicTableNameHandler.setTableName("ad_non_harmonic_result_" + code);
|
|
||||||
try {
|
|
||||||
LambdaQueryWrapper<SimAndDigNonHarmonicResult> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.select(SimAndDigNonHarmonicResult::getDevMonitorId, SimAndDigNonHarmonicResult::getSort)
|
|
||||||
.eq(SimAndDigNonHarmonicResult::getScriptId, scriptId)
|
|
||||||
.and(w -> {
|
|
||||||
for (String devId : devIds) {
|
|
||||||
w.or().likeRight(SimAndDigNonHarmonicResult::getDevMonitorId, devId + "_");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.list(wrapper).forEach(row -> {
|
|
||||||
String devId = row.getDevMonitorId().split("_")[0];
|
|
||||||
result.merge(devId, row.getSort(), Math::max);
|
|
||||||
});
|
|
||||||
return result;
|
|
||||||
} finally {
|
|
||||||
DynamicTableNameHandler.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<SimAndDigNonHarmonicResult> listByDevIdsAndSorts(String code, String scriptId, List<String> devIds, List<Integer> sorts) {
|
|
||||||
if (CollUtil.isEmpty(devIds) || CollUtil.isEmpty(sorts)) {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
DynamicTableNameHandler.setTableName("ad_non_harmonic_result_" + code);
|
|
||||||
try {
|
|
||||||
LambdaQueryWrapper<SimAndDigNonHarmonicResult> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SimAndDigNonHarmonicResult::getScriptId, scriptId)
|
|
||||||
.in(SimAndDigNonHarmonicResult::getSort, sorts)
|
|
||||||
.and(w -> {
|
|
||||||
for (String devId : devIds) {
|
|
||||||
w.or().likeRight(SimAndDigNonHarmonicResult::getDevMonitorId, devId + "_");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return this.list(wrapper);
|
|
||||||
} finally {
|
|
||||||
DynamicTableNameHandler.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, List<Integer>> resultFlagsByDevIdsAndSorts(String code, String scriptId, List<String> devIds, List<Integer> sorts) {
|
|
||||||
Map<String, List<Integer>> result = new HashMap<>();
|
|
||||||
if (CollUtil.isEmpty(devIds) || StrUtil.isBlank(code)) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
if (sorts != null && CollUtil.isEmpty(sorts)) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
DynamicTableNameHandler.setTableName("ad_non_harmonic_result_" + code);
|
|
||||||
try {
|
|
||||||
LambdaQueryWrapper<SimAndDigNonHarmonicResult> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.select(SimAndDigNonHarmonicResult::getDevMonitorId,
|
|
||||||
SimAndDigNonHarmonicResult::getResultFlag)
|
|
||||||
.eq(StrUtil.isNotBlank(scriptId), SimAndDigNonHarmonicResult::getScriptId, scriptId)
|
|
||||||
.in(CollUtil.isNotEmpty(sorts), SimAndDigNonHarmonicResult::getSort, sorts)
|
|
||||||
.and(w -> {
|
|
||||||
for (String devId : devIds) {
|
|
||||||
w.or().likeRight(SimAndDigNonHarmonicResult::getDevMonitorId, devId + "_");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.list(wrapper).forEach(row -> {
|
|
||||||
String devId = resolveDevId(row.getDevMonitorId(), devIds);
|
|
||||||
if (StrUtil.isNotBlank(devId) && row.getResultFlag() != null) {
|
|
||||||
result.computeIfAbsent(devId, key -> new ArrayList<>()).add(row.getResultFlag());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return result;
|
|
||||||
} finally {
|
|
||||||
DynamicTableNameHandler.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String resolveDevId(String devMonitorId, List<String> devIds) {
|
|
||||||
if (StrUtil.isBlank(devMonitorId)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
for (String devId : devIds) {
|
|
||||||
if (StrUtil.isNotBlank(devId) && devMonitorId.startsWith(devId + "_")) {
|
|
||||||
return devId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
package com.njcn.gather.system.pojo.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author cdf
|
||||||
|
* @version 1.0.0
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public enum DicDataEnum {
|
||||||
|
|
||||||
|
|
||||||
|
FREQ("FREQ","频率"),
|
||||||
|
V("V","电压"),
|
||||||
|
I("I","电流"),
|
||||||
|
IMBV("IMBV","三相电压不平衡度"),
|
||||||
|
IMBA("IMBA","三相电流不平衡度"),
|
||||||
|
|
||||||
|
HV("HV","谐波电压"),
|
||||||
|
HI("HI","谐波电流"),
|
||||||
|
HP("HP","谐波有功功率"),
|
||||||
|
HSV("HSV","间谐波电压"),
|
||||||
|
HSI("HSI","间谐波电流"),
|
||||||
|
VOLTAGE("VOLTAGE","暂态"),
|
||||||
|
F("F","闪变"),
|
||||||
|
P("P","功率")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
private final String code;
|
||||||
|
|
||||||
|
private final String message;
|
||||||
|
|
||||||
|
DicDataEnum(String code, String message) {
|
||||||
|
this.code = code;
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DicDataEnum getEnumByCode(String code) {
|
||||||
|
for (DicDataEnum e : DicDataEnum.values()) {
|
||||||
|
if (e.getCode().equals(code)) {
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getMessageByCode(String code) {
|
||||||
|
DicDataEnum e = getEnumByCode(code);
|
||||||
|
if (e!= null) {
|
||||||
|
return e.getMessage();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user