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 1a39f596..da052df2 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 @@ -19,6 +19,7 @@ import com.njcn.gather.detection.util.socket.web.WebSocketHandler; import com.njcn.gather.device.device.pojo.po.PqDev; import com.njcn.gather.device.device.pojo.vo.PreDetection; import com.njcn.gather.device.device.service.IPqDevService; +import com.njcn.gather.device.script.pojo.param.PqScriptCheckDataParam; import com.njcn.gather.device.script.pojo.param.PqScriptIssueParam; import com.njcn.gather.device.script.pojo.po.SourceIssue; import com.njcn.gather.device.script.service.IPqScriptCheckDataService; @@ -46,8 +47,6 @@ import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; import java.util.*; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Function; import java.util.stream.Collectors; @@ -85,7 +84,7 @@ public class SocketDevResponseService { private final IAdPlanService adPlanService; - private final ExecutorService executorPool = Executors.newFixedThreadPool(10); +// private final ExecutorService executorPool = Executors.newFixedThreadPool(10); /** @@ -986,7 +985,12 @@ public class SocketDevResponseService { SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, JSON.toJSONString(xuMsg)); } else { //TODO 是否最终检测完成需要推送给用户 - iPqDevService.updateResult(param.getDevIds(), param.getCode()); + PqScriptCheckDataParam checkDataParam=new PqScriptCheckDataParam(); + checkDataParam.setScriptId(param.getScriptId()); + checkDataParam.setIsValueTypeName(false); + List valueType = iPqScriptCheckDataService.getValueType(checkDataParam); + + iPqDevService.updateResult(param.getDevIds(),valueType, param.getCode()); CnSocketUtil.quitSend(param); } successComm.clear(); diff --git a/device/src/main/java/com/njcn/gather/device/device/service/IPqDevService.java b/device/src/main/java/com/njcn/gather/device/device/service/IPqDevService.java index b5a85d85..38db9f2c 100644 --- a/device/src/main/java/com/njcn/gather/device/device/service/IPqDevService.java +++ b/device/src/main/java/com/njcn/gather/device/device/service/IPqDevService.java @@ -177,10 +177,11 @@ public interface IPqDevService extends IService { /** * 正式监测完成,修改中断状态 * @param ids + * @param valueType * @param code * @return */ - boolean updateResult(List ids,String code); + boolean updateResult(List ids,List valueType ,String code); void updatePqDevReportState(String devId, int i); diff --git a/device/src/main/java/com/njcn/gather/device/device/service/impl/PqDevServiceImpl.java b/device/src/main/java/com/njcn/gather/device/device/service/impl/PqDevServiceImpl.java index 05afe7f0..43b84069 100644 --- a/device/src/main/java/com/njcn/gather/device/device/service/impl/PqDevServiceImpl.java +++ b/device/src/main/java/com/njcn/gather/device/device/service/impl/PqDevServiceImpl.java @@ -489,9 +489,9 @@ public class PqDevServiceImpl extends ServiceImpl implements @Override - public boolean updateResult(List ids, String code) { + public boolean updateResult(List ids,List valueType, String code) { if (CollUtil.isNotEmpty(ids)) { - Map result = detectionDataDealService.devResult(ids, code); + Map result = detectionDataDealService.devResult(ids,valueType, code); List list = this.list(new LambdaQueryWrapper().in(PqDev::getId, ids)); for (PqDev pqDev : list) { if (result.containsKey(pqDev.getId())) { diff --git a/device/src/main/java/com/njcn/gather/device/script/service/impl/PqScriptCheckDataServiceImpl.java b/device/src/main/java/com/njcn/gather/device/script/service/impl/PqScriptCheckDataServiceImpl.java index 78c7ccf7..000dfa8a 100644 --- a/device/src/main/java/com/njcn/gather/device/script/service/impl/PqScriptCheckDataServiceImpl.java +++ b/device/src/main/java/com/njcn/gather/device/script/service/impl/PqScriptCheckDataServiceImpl.java @@ -1,15 +1,14 @@ package com.njcn.gather.device.script.service.impl; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.github.yulichang.toolkit.JoinWrappers; import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.njcn.common.pojo.enums.common.DataStateEnum; import com.njcn.gather.device.script.mapper.PqScriptCheckDataMapper; import com.njcn.gather.device.script.pojo.param.PqScriptCheckDataParam; import com.njcn.gather.device.script.pojo.po.PqScriptCheckData; -import com.njcn.gather.device.script.pojo.vo.PqScriptCheckDataVO; import com.njcn.gather.device.script.service.IPqScriptCheckDataService; import com.njcn.gather.system.dictionary.mapper.DictTreeMapper; import com.njcn.gather.system.dictionary.pojo.po.DictTree; @@ -18,7 +17,6 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -45,7 +43,7 @@ public class PqScriptCheckDataServiceImpl extends ServiceImpl scriptDtlIndex, Boolean isValueType) { + if(ObjectUtil.isNull(isValueType)){ + isValueType=false; + } StringBuffer buffer = new StringBuffer(); buffer.append("输入:"); appendValue(scriptDtlIndex, buffer, "Freq", "频率", ResultUnitEnum.FREQ_UNIT.getUnit(), null); diff --git a/storage/src/main/java/com/njcn/gather/storage/mapper/mapping/TableGenMapper.xml b/storage/src/main/java/com/njcn/gather/storage/mapper/mapping/TableGenMapper.xml index 66e890b3..88f232b4 100644 --- a/storage/src/main/java/com/njcn/gather/storage/mapper/mapping/TableGenMapper.xml +++ b/storage/src/main/java/com/njcn/gather/storage/mapper/mapping/TableGenMapper.xml @@ -10,6 +10,7 @@ Sort int(4) NOT NULL COMMENT '总检测脚本中的测试项序号', AD_Type CHAR(32) NOT NULL COMMENT '检测指标,字典表', Data_Type CHAR(32) NOT NULL COMMENT '数据指标,只有数据源为分钟统计时候才会使用(最大、最小、平均、CP95,默认平均值),字典表', + Result_Flag int(1) COMMENT '1不合格 2合格 4无法处理', A_Value varchar(30) DEFAULT NULL COMMENT 'A相值', B_Value varchar(30) DEFAULT NULL COMMENT 'B相值', C_Value varchar(30) DEFAULT NULL COMMENT 'C相值', @@ -37,7 +38,7 @@ B_Value json NULL COMMENT 'B相值', C_Value json NULL COMMENT 'C相值', T_Value json NULL COMMENT 'T相值(没有相别的则存这里)', - PRIMARY KEY (Monitor_Id, Script_Id, Sort, AD_Type) + PRIMARY KEY (Monitor_Id, Script_Id, Sort, AD_Type,Data_Type) ) COMMENT='监测数据表'; diff --git a/storage/src/main/java/com/njcn/gather/storage/service/DetectionDataDealService.java b/storage/src/main/java/com/njcn/gather/storage/service/DetectionDataDealService.java index 193f2555..82eb14cb 100644 --- a/storage/src/main/java/com/njcn/gather/storage/service/DetectionDataDealService.java +++ b/storage/src/main/java/com/njcn/gather/storage/service/DetectionDataDealService.java @@ -23,8 +23,9 @@ public interface DetectionDataDealService extends IReplenishMybatisService devResult(List ids,String code); + Map devResult(List ids,List valueType,String code); } 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 1d1fc695..f57fae22 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 @@ -20,7 +20,9 @@ import com.njcn.gather.storage.pojo.po.AdNonHarmonicResult; import com.njcn.gather.storage.pojo.vo.RawDataVO; import com.njcn.gather.storage.pojo.vo.RawResultDataVO; import com.njcn.gather.storage.service.AdHarmonicService; -import io.swagger.models.auth.In; +import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum; +import com.njcn.gather.system.dictionary.pojo.po.DictData; +import com.njcn.gather.system.dictionary.service.IDictDataService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -40,6 +42,7 @@ import java.util.stream.Collectors; public class AdHarmonicServiceImpl extends ServiceImpl implements AdHarmonicService { private final AdNonHarmonicMapper adNonHarmonicMapper; + private final IDictDataService dictDataService; @Override public List get(String scriptId, List sort, String deviceId, String chnNum, Integer code) { @@ -129,42 +132,51 @@ public class AdHarmonicServiceImpl extends ServiceImpl adHarmonicResults = this.getBaseMapper().selectJoinList(AdHarmonicResult.class, wrapper); - List harmNum = param.getHarmNum(); - Map info=new LinkedHashMap<>(3); - RawResultDataVO dataVO; - for (AdHarmonicResult harmonicResult : adHarmonicResults) { - for (Double i : harmNum) { - dataVO = new RawResultDataVO(); - dataVO.setHarmNum(i); - dataVO.setIsData(harmonicResult.getResultFlag()); - dataVO.setUnit("%"); - try { - Field fieldA = harmonicResult.getClass().getDeclaredField("aValue" + isHarmOrInHarm(i).intValue()); - fieldA.setAccessible(true); - RawResultDataVO.DetectionData a = JSON.parseObject(fieldA.get(harmonicResult)+"", RawResultDataVO.DetectionData.class); - dataVO.setDataA(a); + if(CollUtil.isNotEmpty(adHarmonicResults)){ + List harmNum = param.getHarmNum(); + RawResultDataVO dataVO; + DictData dictData = dictDataService.getDictDataById(adHarmonicResults.get(0).getAdType()); + String unit; + if(DictDataEnum.I2_50.getCode().equals(dictData.getCode())||DictDataEnum.SI_1_49.getCode().equals(dictData.getCode())){ + unit="A"; + }else{ + unit="%"; + } + for (AdHarmonicResult harmonicResult : adHarmonicResults) { + for (Double i : harmNum) { + dataVO = new RawResultDataVO(); + dataVO.setHarmNum(i); + dataVO.setIsData(harmonicResult.getResultFlag()); + dataVO.setUnit(unit); + try { + Field fieldA = harmonicResult.getClass().getDeclaredField("aValue" + isHarmOrInHarm(i).intValue()); + fieldA.setAccessible(true); + RawResultDataVO.DetectionData a = JSON.parseObject(fieldA.get(harmonicResult)+"", RawResultDataVO.DetectionData.class); + dataVO.setDataA(a); - Field fieldB = harmonicResult.getClass().getDeclaredField("bValue" + isHarmOrInHarm(i).intValue()); - fieldB.setAccessible(true); - RawResultDataVO.DetectionData b = JSON.parseObject(fieldB.get(harmonicResult)+"", RawResultDataVO.DetectionData.class); - dataVO.setDataB(b); + Field fieldB = harmonicResult.getClass().getDeclaredField("bValue" + isHarmOrInHarm(i).intValue()); + fieldB.setAccessible(true); + RawResultDataVO.DetectionData b = JSON.parseObject(fieldB.get(harmonicResult)+"", RawResultDataVO.DetectionData.class); + dataVO.setDataB(b); - Field fieldC = harmonicResult.getClass().getDeclaredField("cValue" + isHarmOrInHarm(i).intValue()); - fieldC.setAccessible(true); - RawResultDataVO.DetectionData c = JSON.parseObject(fieldC.get(harmonicResult)+"", RawResultDataVO.DetectionData.class); - dataVO.setDataC(c); - if(ObjectUtil.isNotNull(a)){ - dataVO.setRadius(a.getRadius()); + Field fieldC = harmonicResult.getClass().getDeclaredField("cValue" + isHarmOrInHarm(i).intValue()); + fieldC.setAccessible(true); + RawResultDataVO.DetectionData c = JSON.parseObject(fieldC.get(harmonicResult)+"", RawResultDataVO.DetectionData.class); + dataVO.setDataC(c); + if(ObjectUtil.isNotNull(a)){ + dataVO.setRadius(a.getRadius()); + } + } catch (NoSuchFieldException e) { + throw new RuntimeException(e); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); } - } catch (NoSuchFieldException e) { - throw new RuntimeException(e); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); + info.put(String.valueOf(i),dataVO) ; } - info.put(String.valueOf(i),dataVO) ; } } + DynamicTableNameHandler.remove(); return info; } diff --git a/storage/src/main/java/com/njcn/gather/storage/service/impl/DetectionDataServiceImpl.java b/storage/src/main/java/com/njcn/gather/storage/service/impl/DetectionDataServiceImpl.java index 7457382d..4177e988 100644 --- a/storage/src/main/java/com/njcn/gather/storage/service/impl/DetectionDataServiceImpl.java +++ b/storage/src/main/java/com/njcn/gather/storage/service/impl/DetectionDataServiceImpl.java @@ -94,12 +94,13 @@ public class DetectionDataServiceImpl extends ReplenishMybatisServiceImpl devResult(List ids,String code) { + public Map devResult(List ids,List valueType,String code) { List noHarm=new ArrayList<>(); for (String id : ids) { DynamicTableNameHandler.setTableName("ad_non_harmonic_result_" + code); noHarm.addAll(adNonHarmonicService.list( new LambdaQueryWrapper() .like(AdNonHarmonicResult::getMonitorId,id) + .in(CollUtil.isNotEmpty(valueType),AdNonHarmonicResult::getAdType,valueType) )) ; } DynamicTableNameHandler.remove(); @@ -108,6 +109,7 @@ public class DetectionDataServiceImpl extends ReplenishMybatisServiceImpl() .like(AdHarmonicResult::getMonitorId,id) + .in(CollUtil.isNotEmpty(valueType),AdHarmonicResult::getAdType,valueType) )) ; } DynamicTableNameHandler.remove(); diff --git a/system/src/main/java/com/njcn/gather/system/dictionary/pojo/enums/DictDataEnum.java b/system/src/main/java/com/njcn/gather/system/dictionary/pojo/enums/DictDataEnum.java index 2b16ebc1..aae287b1 100644 --- a/system/src/main/java/com/njcn/gather/system/dictionary/pojo/enums/DictDataEnum.java +++ b/system/src/main/java/com/njcn/gather/system/dictionary/pojo/enums/DictDataEnum.java @@ -28,8 +28,11 @@ public enum DictDataEnum { AVG_VALUE("平均值", "Avg_value"), Own_value("所有值", "Own_value"), - - + /** + * 字典树code + */ + I2_50("谐波电流幅值", "I2-50"), + SI_1_49("间谐波电流幅值", "SI_1-49"), ;