diff --git a/detection/src/main/java/com/njcn/gather/detection/pojo/param/SimulateDetectionParam.java b/detection/src/main/java/com/njcn/gather/detection/pojo/param/SimulateDetectionParam.java index 8d1b3f02..519e7aaa 100644 --- a/detection/src/main/java/com/njcn/gather/detection/pojo/param/SimulateDetectionParam.java +++ b/detection/src/main/java/com/njcn/gather/detection/pojo/param/SimulateDetectionParam.java @@ -39,10 +39,4 @@ public class SimulateDetectionParam { */ @NotBlank(message = PqSourceValidMessage.ID_NOT_BLANK) private String sourceId; - - /** - * 脚本值类型 1绝对值脚本、2相对值脚本 - */ - @NotNull(message = PqScriptValidMessage.VALUE_TYPE_NOT_NULL) - private int valueType; } diff --git a/detection/src/main/java/com/njcn/gather/detection/service/impl/DetectionServiceImpl.java b/detection/src/main/java/com/njcn/gather/detection/service/impl/DetectionServiceImpl.java index ae120db8..0a09ebec 100644 --- a/detection/src/main/java/com/njcn/gather/detection/service/impl/DetectionServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/detection/service/impl/DetectionServiceImpl.java @@ -948,7 +948,11 @@ public class DetectionServiceImpl { .sorted().distinct().collect(Collectors.toList())); } for (DevData devData : dev) { - Optional first = devData.getSqlData().stream().filter(x -> x.getDesc().equals(fundCode)).collect(Collectors.toList()).stream().findFirst(); + List sqlDataDTOList = devData.getSqlData(); + Optional first = Optional.empty(); + if(CollUtil.isNotEmpty(sqlDataDTOList)){ + first = sqlDataDTOList.stream().filter(x -> x.getDesc().equals(fundCode)).collect(Collectors.toList()).stream().findFirst(); + } DevData.SqlDataDTO fund = null; if (first.isPresent()) { fund = first.get(); diff --git a/detection/src/main/java/com/njcn/gather/detection/service/impl/PreDetectionServiceImpl.java b/detection/src/main/java/com/njcn/gather/detection/service/impl/PreDetectionServiceImpl.java index 0f97f6c6..86d563d7 100644 --- a/detection/src/main/java/com/njcn/gather/detection/service/impl/PreDetectionServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/detection/service/impl/PreDetectionServiceImpl.java @@ -4,7 +4,6 @@ package com.njcn.gather.detection.service.impl; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.njcn.common.pojo.exception.BusinessException; import com.njcn.gather.detection.handler.SocketDevResponseService; @@ -13,7 +12,6 @@ import com.njcn.gather.detection.pojo.enums.DetectionResponseEnum; import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum; import com.njcn.gather.detection.pojo.param.PreDetectionParam; import com.njcn.gather.detection.pojo.param.SimulateDetectionParam; -import com.njcn.gather.detection.pojo.vo.SocketDataMsg; import com.njcn.gather.detection.pojo.vo.SocketMsg; import com.njcn.gather.detection.service.PreDetectionService; import com.njcn.gather.detection.util.socket.CnSocketUtil; @@ -43,7 +41,6 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; -import java.util.ArrayList; import java.util.Comparator; import java.util.List; import java.util.Objects; @@ -261,10 +258,8 @@ public class PreDetectionServiceImpl implements PreDetectionService { //issueParam.setDevIds(param.getDevIds()); issueParam.setScriptId(param.getScriptId()); issueParam.setType(1); - issueParam.setValueType(param.getValueType()); // 设置脚本类型 issueParam.setIsPhaseSequence(SourceOperateCodeEnum.SIMULATE_TEST.getValue()); - List sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam); sourceIssues = sourceIssues.stream() .filter(s -> s.getIndex().equals(param.getScriptIndex())) diff --git a/detection/src/main/java/com/njcn/gather/detection/util/socket/MsgUtil.java b/detection/src/main/java/com/njcn/gather/detection/util/socket/MsgUtil.java index 8244f030..08c5f5eb 100644 --- a/detection/src/main/java/com/njcn/gather/detection/util/socket/MsgUtil.java +++ b/detection/src/main/java/com/njcn/gather/detection/util/socket/MsgUtil.java @@ -78,7 +78,7 @@ public class MsgUtil { public static List toList(List nonHarm, List harm) { List info = new ArrayList<>(); - if (CollUtil.isNotEmpty(nonHarm)) { +// if (CollUtil.isNotEmpty(nonHarm)) { if (CollUtil.isNotEmpty(nonHarm)) { Map> noHarmMap = nonHarm.stream() .collect(Collectors.groupingBy(x -> x.getMonitorId() + "_" + x.getTimeId().format(DateTimeFormatter.ofPattern(DatePattern.UTC_SIMPLE_MS_PATTERN)) + "_" + x.getSort())); @@ -116,7 +116,7 @@ public class MsgUtil { dataDTO = new DevData.SqlDataHarmDTO(); dataDTO.setType(harmonicResult.getDataType()); dataDTO.setDesc(harmonicResult.getAdType()); - dataDTO.setNum(49); + dataDTO.setNum(50); DevData.SqlDataHarmDTO.ListDTO listDTO = new DevData.SqlDataHarmDTO.ListDTO(); listDTO.setA(reflectHarmonicValue("a", harmonicResult)); listDTO.setB(reflectHarmonicValue("b", harmonicResult)); @@ -137,14 +137,14 @@ public class MsgUtil { }); } - } +// } return info; } private static List reflectHarmonicValue(String phase, AdHarmonicResult adHarmonicResult) { List info = new ArrayList<>(); - for (int i = 2; i < 50; i++) { + for (int i = 2; i <= 50; i++) { String fieldName = phase + "Value" + i; try { Field idField = AdHarmonicResult.class.getDeclaredField(fieldName); diff --git a/detection/src/main/java/com/njcn/gather/result/service/impl/ResultServiceImpl.java b/detection/src/main/java/com/njcn/gather/result/service/impl/ResultServiceImpl.java index e1e4e23d..b27f2b09 100644 --- a/detection/src/main/java/com/njcn/gather/result/service/impl/ResultServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/result/service/impl/ResultServiceImpl.java @@ -13,7 +13,6 @@ import com.njcn.gather.detection.pojo.param.PreDetectionParam; import com.njcn.gather.detection.pojo.po.DevData; import com.njcn.gather.detection.service.impl.DetectionServiceImpl; import com.njcn.gather.detection.util.socket.MsgUtil; -import com.njcn.gather.device.pojo.po.PqDev; import com.njcn.gather.device.service.IPqDevService; import com.njcn.gather.plan.pojo.po.AdPlan; import com.njcn.gather.plan.service.IAdPlanService; @@ -36,6 +35,7 @@ import com.njcn.gather.script.util.ScriptDtlsDesc; import com.njcn.gather.storage.mapper.TableGenMapper; import com.njcn.gather.storage.pojo.param.StorageParam; import com.njcn.gather.storage.pojo.po.AdBaseResult; +import com.njcn.gather.storage.pojo.po.AdHarmonicResult; import com.njcn.gather.storage.pojo.po.AdNonHarmonicResult; import com.njcn.gather.storage.pojo.vo.RawDataVO; import com.njcn.gather.storage.service.AdHarmonicService; @@ -202,7 +202,7 @@ public class ResultServiceImpl implements IResultService { dtlType.setIndex(index); dtlType.setScriptType(scriptDtlIndexList.get(0).getScriptType()); ratedScriptTypeName(scriptDtlIndexList, isValueType, dtlType, dictTree); - dtlType.setSourceDesc(ScriptDtlsDesc.getStringBuffer(scriptDtlIndexList,false, isValueType).toString()); + dtlType.setSourceDesc(ScriptDtlsDesc.getStringBuffer(scriptDtlIndexList, false, isValueType).toString()); if (finalResultMap.containsKey(index)) { dtlType.setFly(conform(finalResultMap.get(index))); } @@ -253,7 +253,7 @@ public class ResultServiceImpl implements IResultService { if ("Freq".equals(subKey)) { freqScriptTypeName(scriptDtlIndexList, dictTree, isValueType, dtlType); } - dtlType.setSourceDesc(ScriptDtlsDesc.getStringBuffer(scriptDtlIndexList,false, isValueType).toString()); + dtlType.setSourceDesc(ScriptDtlsDesc.getStringBuffer(scriptDtlIndexList, false, isValueType).toString()); if (finalResultMap.containsKey(index)) { dtlType.setFly(conform(finalResultMap.get(index))); } @@ -296,7 +296,7 @@ public class ResultServiceImpl implements IResultService { dlt.setScriptTypeName("特征幅值=" + dtls.getTransValue() + "%Un,持续时间=" + dtls.getRetainTime().intValue() + "周波"); dlt.setIndex(dtls.getScriptIndex()); dlt.setScriptType(scriptDtlIndexList.get(0).getScriptType()); - dlt.setSourceDesc(ScriptDtlsDesc.getStringBuffer(scriptDtlIndexList,false, isValueType).toString()); + dlt.setSourceDesc(ScriptDtlsDesc.getStringBuffer(scriptDtlIndexList, false, isValueType).toString()); if (finalResultMap.containsKey(dtls.getScriptIndex())) { dlt.setFly(conform(finalResultMap.get(dtls.getScriptIndex()))); } @@ -932,11 +932,11 @@ public class ResultServiceImpl implements IResultService { param.setCode(code); param.setErrorSysId(errorSysId); param.setDevIds(Arrays.asList(devId)); - param.setCode(code+"_temp"); + param.setCode(code + "_temp"); Map devIdMapComm = new HashMap<>(); - PqDev dev = pqDevService.getById(devId); - devIdMapComm.put(devId,devId); +// PqDev dev = pqDevService.getById(devId); + devIdMapComm.put(devId, devId); SysTestConfig oneConfig = sysTestConfigService.getOneConfig(); DictDataEnum dataRule; @@ -947,8 +947,11 @@ public class ResultServiceImpl implements IResultService { } List allNonHarmonicRawData = adNonHarmonicService.listAll(code, devId); - LinkedHashMap> map = allNonHarmonicRawData.stream().sorted(Comparator.comparing(AdNonHarmonicResult::getSort)) + LinkedHashMap> nonHarmonicMap = allNonHarmonicRawData.stream().sorted(Comparator.comparing(AdNonHarmonicResult::getSort)) .collect(Collectors.groupingBy(AdNonHarmonicResult::getSort, LinkedHashMap::new, Collectors.toList())); + List allHarmonicRawData = adHarmonicService.lisAll(code, devId); + LinkedHashMap> harmonicMap = allHarmonicRawData.stream().sorted(Comparator.comparing(AdHarmonicResult::getSort)) + .collect(Collectors.groupingBy(AdHarmonicResult::getSort, LinkedHashMap::new, Collectors.toList())); PqScriptIssueParam issueParam = new PqScriptIssueParam(); issueParam.setPlanId(planId); @@ -962,15 +965,29 @@ public class ResultServiceImpl implements IResultService { List sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam); sourceIssues.forEach(sourceIssue -> { - List realDataXiList = MsgUtil.toList(map.get(sourceIssue.getIndex()), null); + List realDataXiList = MsgUtil.toList(nonHarmonicMap.get(sourceIssue.getIndex()), harmonicMap.get(sourceIssue.getIndex())); for (int i = 0; i < realDataXiList.size(); i++) { DevData devData = realDataXiList.get(i); List sqlData = devData.getSqlData(); - if(CollUtil.isNotEmpty(sqlData)){ + if (CollUtil.isNotEmpty(sqlData)) { for (int j = 0; j < sqlData.size(); j++) { DevData.SqlDataDTO sqlDataDTO = sqlData.get(j); String desc = sqlDataDTO.getDesc(); - if(StrUtil.isNotBlank(desc)){ + if (StrUtil.isNotBlank(desc)) { + DictTree dictTree = dictTreeService.getById(desc); + if (ObjectUtil.isNotNull(dictTree)) { + sqlDataDTO.setDesc(dictTree.getCode()); + } + } + } + } + + List sqlDataHarm = devData.getSqlDataHarm(); + if (CollUtil.isNotEmpty(sqlDataHarm)) { + for (int j = 0; j < sqlDataHarm.size(); j++) { + DevData.SqlDataHarmDTO sqlDataDTO = sqlDataHarm.get(j); + String desc = sqlDataDTO.getDesc(); + if (StrUtil.isNotBlank(desc)) { DictTree dictTree = dictTreeService.getById(desc); if (ObjectUtil.isNotNull(dictTree)) { sqlDataDTO.setDesc(dictTree.getCode()); diff --git a/detection/src/main/java/com/njcn/gather/script/pojo/constant/PqScriptValidMessage.java b/detection/src/main/java/com/njcn/gather/script/pojo/constant/PqScriptValidMessage.java index c33ea6cd..02e1e2c7 100644 --- a/detection/src/main/java/com/njcn/gather/script/pojo/constant/PqScriptValidMessage.java +++ b/detection/src/main/java/com/njcn/gather/script/pojo/constant/PqScriptValidMessage.java @@ -7,5 +7,5 @@ package com.njcn.gather.script.pojo.constant; public interface PqScriptValidMessage { String INDEX_NOT_NULL = "index不能为空"; - String VALUE_TYPE_NOT_NULL = "脚本值类型不能为空"; + String VALUE_TYPE_NOT_BLANK = "脚本值类型不能为空"; } diff --git a/detection/src/main/java/com/njcn/gather/script/pojo/param/PqScriptIssueParam.java b/detection/src/main/java/com/njcn/gather/script/pojo/param/PqScriptIssueParam.java index 840d48a4..c0666475 100644 --- a/detection/src/main/java/com/njcn/gather/script/pojo/param/PqScriptIssueParam.java +++ b/detection/src/main/java/com/njcn/gather/script/pojo/param/PqScriptIssueParam.java @@ -39,8 +39,4 @@ public class PqScriptIssueParam { @ApiModelProperty("脚本下发类型") private int type; - - @ApiModelProperty("脚本值类型") - private int valueType; - } diff --git a/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptDtlsServiceImpl.java b/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptDtlsServiceImpl.java index d8e744ea..793c2723 100644 --- a/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptDtlsServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptDtlsServiceImpl.java @@ -830,12 +830,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl { List getIndex(StorageParam param,Boolean isExculdePhaseAngle); AdHarmonicResult getSingleResult(SingleNonHarmParam singleNonHarmParam); + + /** + * 获取所有谐波原始数据 + * + * @param code + * @param devId 设备ID + * @return + */ + List lisAll(String code, String devId); } diff --git a/storage/src/main/java/com/njcn/gather/storage/service/impl/AdHarmonicServiceImpl.java b/storage/src/main/java/com/njcn/gather/storage/service/impl/AdHarmonicServiceImpl.java index 56d59278..9e9a5a82 100644 --- a/storage/src/main/java/com/njcn/gather/storage/service/impl/AdHarmonicServiceImpl.java +++ b/storage/src/main/java/com/njcn/gather/storage/service/impl/AdHarmonicServiceImpl.java @@ -234,6 +234,17 @@ public class AdHarmonicServiceImpl extends ServiceImpl lisAll(String code, String devId) { + String prefix = "ad_harmonic_" + code; + DynamicTableNameHandler.setTableName(prefix); + MPJLambdaWrapper wrapper = new MPJLambdaWrapper<>(); + wrapper.likeRight(AdHarmonicResult::getMonitorId, devId); + List results = this.getBaseMapper().selectJoinList(AdHarmonicResult.class, wrapper); + DynamicTableNameHandler.remove(); + return results; + } + private Integer setResultFlag(List numbers) { List isData = numbers.stream().filter(x -> ObjectUtil.isNotNull(x.getData())).filter(x -> 4 != x.getIsData()).map(RawResultDataVO.DetectionData::getIsData).distinct().collect(Collectors.toList()); return getInteger(isData); diff --git a/storage/src/main/java/com/njcn/gather/storage/service/impl/AdNonHarmonicServiceImpl.java b/storage/src/main/java/com/njcn/gather/storage/service/impl/AdNonHarmonicServiceImpl.java index efcc67ee..27cf03fc 100644 --- a/storage/src/main/java/com/njcn/gather/storage/service/impl/AdNonHarmonicServiceImpl.java +++ b/storage/src/main/java/com/njcn/gather/storage/service/impl/AdNonHarmonicServiceImpl.java @@ -159,9 +159,9 @@ public class AdNonHarmonicServiceImpl extends ServiceImpl wrapper = new MPJLambdaWrapper<>(); wrapper.likeRight(AdNonHarmonicResult::getMonitorId, devId); - List adHarmonicResults = this.getBaseMapper().selectJoinList(AdNonHarmonicResult.class, wrapper); + List results = this.getBaseMapper().selectJoinList(AdNonHarmonicResult.class, wrapper); DynamicTableNameHandler.remove(); - return adHarmonicResults; + return results; } private String unit(String code) {