diff --git a/detection/src/main/java/com/njcn/gather/detection/handler/SocketDevResponseService.java b/detection/src/main/java/com/njcn/gather/detection/handler/SocketDevResponseService.java index c0f52855..4e09c077 100644 --- a/detection/src/main/java/com/njcn/gather/detection/handler/SocketDevResponseService.java +++ b/detection/src/main/java/com/njcn/gather/detection/handler/SocketDevResponseService.java @@ -92,6 +92,7 @@ public class SocketDevResponseService { private final ISysTestConfigService sysTestConfigService; private final AdHarmonicService adHarmonicService; private final IAdPlanService adPlanService; + private final IPqScriptCheckDataService pqScriptCheckDataService; @Value("${phaseAngle.isEnable}") private Boolean isPhaseAngle; @@ -844,15 +845,17 @@ public class SocketDevResponseService { if (param.getOperateType().equals(SourceOperateCodeEnum.RE_ERROR_TEST.getValue())) { //不合格项复检 - List indexes = new ArrayList<>(); + Set 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, true)); + indexes.addAll(adHarmonicService.getIndex(storageParam)); }); - issueParam.setIndexList(indexes); + List notErrorCheckIndex = pqScriptCheckDataService.listNotErrorCheckIndex(param.getScriptId()); + indexes.removeAll(notErrorCheckIndex); + issueParam.setIndexList(indexes.stream().collect(Collectors.toList())); issueParam.setIsPhaseSequence(SourceOperateCodeEnum.RE_ERROR_TEST.getValue()); } else { issueParam.setIsPhaseSequence(SourceOperateCodeEnum.FORMAL_TEST.getValue()); diff --git a/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java b/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java index d5cc55a7..8aac6e2c 100644 --- a/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java @@ -39,6 +39,7 @@ import com.njcn.gather.plan.service.IAdPlanSourceService; import com.njcn.gather.pojo.enums.DetectionResponseEnum; import com.njcn.gather.report.pojo.po.PqReport; import com.njcn.gather.script.pojo.po.PqScriptDtls; +import com.njcn.gather.script.service.IPqScriptCheckDataService; import com.njcn.gather.script.service.IPqScriptDtlsService; import com.njcn.gather.script.service.IPqScriptService; import com.njcn.gather.source.pojo.po.PqSource; @@ -103,6 +104,7 @@ public class AdPlanServiceImpl extends ServiceImpl impleme private final IDevTypeService devTypeService; private final IDictTypeService dictTypeService; private final AdHarmonicService adHarmonicService; + private final IPqScriptCheckDataService pqScriptCheckDataService; @Override public Page listAdPlan(AdPlanParam.QueryParam queryParam) { @@ -330,15 +332,16 @@ public class AdPlanServiceImpl extends ServiceImpl impleme // // scriptDtlsList = scriptDtlsList.stream().filter(obj -> !sortSet.contains(obj.getScriptIndex())).collect(Collectors.toList()); // } - List indexes = new ArrayList<>(); + List notErrorCheckIndex = pqScriptCheckDataService.listNotErrorCheckIndex(scriptId); + Set indexes = new HashSet<>(); StorageParam storageParam = new StorageParam(); storageParam.setCode(adPlan.getCode() + ""); storageParam.setScriptId(adPlan.getScriptId()); devIds.forEach(devId -> { storageParam.setDevId(devId); - indexes.addAll(adHarmonicService.getIndex(storageParam, true)); + indexes.addAll(adHarmonicService.getIndex(storageParam)); }); - + indexes.removeAll(notErrorCheckIndex); scriptDtlsList = scriptDtlsList.stream().filter(obj -> indexes.contains(obj.getScriptIndex())).collect(Collectors.toList()); } diff --git a/detection/src/main/java/com/njcn/gather/script/service/IPqScriptCheckDataService.java b/detection/src/main/java/com/njcn/gather/script/service/IPqScriptCheckDataService.java index ac320d83..077aa87c 100644 --- a/detection/src/main/java/com/njcn/gather/script/service/IPqScriptCheckDataService.java +++ b/detection/src/main/java/com/njcn/gather/script/service/IPqScriptCheckDataService.java @@ -51,4 +51,12 @@ public interface IPqScriptCheckDataService extends IService { * @return */ boolean deleteByScriptIds(List ids); + + /** + * 根据脚本id查询出不参与误差比较的检查项对应的index + * + * @param scriptId + * @return + */ + List listNotErrorCheckIndex(String scriptId); } diff --git a/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptCheckDataServiceImpl.java b/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptCheckDataServiceImpl.java index 8856f982..68407db6 100644 --- a/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptCheckDataServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptCheckDataServiceImpl.java @@ -20,7 +20,9 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; import java.util.stream.Collectors; @@ -34,14 +36,14 @@ import java.util.stream.Collectors; @RequiredArgsConstructor public class PqScriptCheckDataServiceImpl extends ServiceImpl implements IPqScriptCheckDataService { - private final String SYMBOL="$"; + private final String SYMBOL = "$"; private final DictTreeMapper dictTreeMapper; @Override public List getValueType(PqScriptCheckDataParam param) { String dataType = param.getDataType(); - if(StrUtil.isNotBlank(dataType)){ + if (StrUtil.isNotBlank(dataType)) { String[] split = dataType.split(","); if (split.length > 1) { dataType = split[0]; @@ -60,7 +62,7 @@ public class PqScriptCheckDataServiceImpl extends ServiceImpl checkData = pqScriptCheckData.stream().map(x -> finalDataType + SYMBOL + x.getValueType()).distinct().collect(Collectors.toList()); - String U = finalDataType + SYMBOL+ DetectionCodeEnum.U1.getCode(); + String U = finalDataType + SYMBOL + DetectionCodeEnum.U1.getCode(); if (!checkData.contains(U)) { if (checkData.contains(finalDataType + SYMBOL + DetectionCodeEnum.V2_50.getCode())) { checkData.add(U); @@ -143,4 +145,13 @@ public class PqScriptCheckDataServiceImpl extends ServiceImpl ids) { return this.remove(new LambdaQueryWrapper().in(PqScriptCheckData::getScriptId, ids)); } + + @Override + public List listNotErrorCheckIndex(String scriptId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.select(PqScriptCheckData::getScriptIndex) + .eq(PqScriptCheckData::getScriptId, scriptId) + .eq(PqScriptCheckData::getErrorFlag, 0); + return this.list(wrapper).stream().map(PqScriptCheckData::getScriptIndex).distinct().collect(Collectors.toList()); + } } diff --git a/storage/src/main/java/com/njcn/gather/storage/service/AdHarmonicService.java b/storage/src/main/java/com/njcn/gather/storage/service/AdHarmonicService.java index d848465b..ad97fa25 100644 --- a/storage/src/main/java/com/njcn/gather/storage/service/AdHarmonicService.java +++ b/storage/src/main/java/com/njcn/gather/storage/service/AdHarmonicService.java @@ -48,10 +48,9 @@ public interface AdHarmonicService extends IService { * 获取索引 * * @param param - * @param isExculdePhaseAngle 是否排除电压相角、电流相角 * @return */ - List getIndex(StorageParam param, Boolean isExculdePhaseAngle); + List getIndex(StorageParam param); AdHarmonicResult getSingleResult(SingleNonHarmParam singleNonHarmParam); 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 d60d681e..66f2b050 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 @@ -81,7 +81,7 @@ public class AdHarmonicServiceImpl extends ServiceImpl dictTreeById = dictTreeService.getDictTreeById(new ArrayList<>(adMap.keySet())); Map dictTreeByName = dictTreeById.stream().collect(Collectors.toMap(DictTree::getId, Function.identity())); Map> info = new LinkedHashMap<>(3); - adMap.forEach((ad,value)->{ + adMap.forEach((ad, value) -> { if (dictTreeByName.containsKey(ad)) { DictTree dictData = dictTreeByName.get(ad); List rawDataVOS = new ArrayList<>(); @@ -147,7 +147,7 @@ public class AdHarmonicServiceImpl extends ServiceImpl dictTreeById = dictTreeService.getDictTreeById(new ArrayList<>(adMap.keySet())); Map dictTreeByName = dictTreeById.stream().collect(Collectors.toMap(DictTree::getId, Function.identity())); Map> info = new LinkedHashMap<>(3); - adMap.forEach((ad,value)->{ + adMap.forEach((ad, value) -> { if (dictTreeByName.containsKey(ad)) { DictTree dictData = dictTreeByName.get(ad); List rawDataVOS = new ArrayList<>(); @@ -201,7 +201,7 @@ public class AdHarmonicServiceImpl extends ServiceImpl getIndex(StorageParam param, Boolean isExculdePhaseAngle) { + public List getIndex(StorageParam param) { String prefix = "ad_harmonic_result_"; String prefixNon = "ad_non_harmonic_result_"; DynamicTableNameHandler.setTableName(prefix + param.getCode()); @@ -211,7 +211,7 @@ public class AdHarmonicServiceImpl extends ServiceImpl adHarmonicResultList = this.list(lambdaQueryWrapper); - List indexes = new ArrayList<>(adHarmonicResultList.stream().map(AdHarmonicResult::getSort).collect(Collectors.toList())); + List indexes = new ArrayList<>(adHarmonicResultList.stream().map(AdHarmonicResult::getSort).distinct().collect(Collectors.toList())); DynamicTableNameHandler.setTableName(prefixNon + param.getCode()); LambdaQueryWrapper resultLambdaQueryWrapper = new LambdaQueryWrapper<>(); @@ -219,13 +219,8 @@ public class AdHarmonicServiceImpl extends ServiceImpl phaseAngleIds = dictTreeMapper.getPhaseAngleIds(); - resultLambdaQueryWrapper.notIn(AdNonHarmonicResult::getAdType, phaseAngleIds); - } List nonHarmonicResults = adNonHarmonicMapper.selectList(resultLambdaQueryWrapper); - indexes.addAll(nonHarmonicResults.stream().map(AdNonHarmonicResult::getSort).collect(Collectors.toList())); + indexes.addAll(nonHarmonicResults.stream().map(AdNonHarmonicResult::getSort).distinct().collect(Collectors.toList())); DynamicTableNameHandler.remove(); return indexes; }