1.正式检测-检测详情表格数据代码提交
This commit is contained in:
@@ -2,7 +2,6 @@ package com.njcn.gather.storage.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author wr
|
||||
@@ -26,20 +25,20 @@ public class RawDataVO {
|
||||
/**
|
||||
* A相数据
|
||||
*/
|
||||
private BigDecimal dataA;
|
||||
private String dataA;
|
||||
|
||||
/**
|
||||
* B相数据
|
||||
*/
|
||||
private BigDecimal dataB;
|
||||
private String dataB;
|
||||
|
||||
/**
|
||||
* C相数据
|
||||
*/
|
||||
private BigDecimal dataC;
|
||||
private String dataC;
|
||||
|
||||
/**
|
||||
* C相数据
|
||||
* T相数据
|
||||
*/
|
||||
private BigDecimal dataT;
|
||||
private String dataT;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.njcn.gather.storage.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author wr
|
||||
* @description
|
||||
* @date 2025/1/2 15:53
|
||||
*/
|
||||
@Data
|
||||
public class RawResultDataVO {
|
||||
|
||||
|
||||
/**
|
||||
* 是否是符合数据
|
||||
*/
|
||||
private Integer isData;
|
||||
|
||||
/**
|
||||
* 第几次谐波
|
||||
*/
|
||||
private Double harmNum;
|
||||
|
||||
/**
|
||||
* 误差范围
|
||||
*/
|
||||
private String radius;
|
||||
|
||||
/**
|
||||
* A相数据
|
||||
*/
|
||||
private DetectionData dataA;
|
||||
|
||||
/**
|
||||
* B相数据
|
||||
*/
|
||||
private DetectionData dataB;
|
||||
|
||||
/**
|
||||
* C相数据
|
||||
*/
|
||||
private DetectionData dataC;
|
||||
|
||||
/**
|
||||
* C相数据
|
||||
*/
|
||||
private DetectionData dataT;
|
||||
|
||||
@Data
|
||||
public static class DetectionData {
|
||||
|
||||
/**
|
||||
* 第几次谐波
|
||||
*/
|
||||
private Double num;
|
||||
|
||||
/**
|
||||
* 是否是符合数据
|
||||
*/
|
||||
private Integer isData;
|
||||
|
||||
/**
|
||||
* 装置原始数据
|
||||
*/
|
||||
private BigDecimal data;
|
||||
|
||||
/**
|
||||
* 检测源定值
|
||||
*/
|
||||
private BigDecimal resultData;
|
||||
|
||||
/**
|
||||
* 误差范围
|
||||
*/
|
||||
private String radius;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ 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.vo.RawDataVO;
|
||||
import com.njcn.gather.storage.pojo.vo.RawResultDataVO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -33,5 +34,12 @@ public interface AdHarmonicService extends IService<AdHarmonicResult> {
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
Map<String, List<RawDataVO>> listResultData(StorageParam param);
|
||||
Map<String, List<RawDataVO>> listHarmData(StorageParam param);
|
||||
|
||||
/**
|
||||
* 查询结果数据
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
Map<String, RawResultDataVO> listHarmResultData(StorageParam param) ;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.njcn.gather.storage.pojo.param.StorageParam;
|
||||
import com.njcn.gather.storage.pojo.po.AdBaseResult;
|
||||
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 java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -16,17 +17,26 @@ public interface AdNonHarmonicService extends IService<AdNonHarmonicResult> {
|
||||
* 根据设备ID和通道号获取非谐波结果
|
||||
*
|
||||
* @param scriptId 脚本ID
|
||||
* @param sort 总检测脚本中的测试项序号列表
|
||||
* @param sort 总检测脚本中的测试项序号列表
|
||||
* @param deviceId 设备ID
|
||||
* @param chnNum 通道号,从1开始
|
||||
* @return 非谐波结果
|
||||
*/
|
||||
List<AdBaseResult> get(String scriptId, List<Integer> sort, String deviceId, String chnNum,Integer code);
|
||||
List<AdBaseResult> get(String scriptId, List<Integer> sort, String deviceId, String chnNum, Integer code);
|
||||
|
||||
/**
|
||||
* 非谐波原始数据展示
|
||||
*
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
Map<String,List<RawDataVO>> listNonResultData(StorageParam param) ;
|
||||
Map<String, List<RawDataVO>> listNonHarmData(StorageParam param);
|
||||
|
||||
/**
|
||||
* 非谐波原始数据展示
|
||||
*
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
Map<String, RawResultDataVO> listNonHarmResultData(StorageParam param);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.njcn.db.mybatisplus.handler.DynamicTableNameHandler;
|
||||
@@ -12,6 +13,7 @@ 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.vo.RawDataVO;
|
||||
import com.njcn.gather.storage.pojo.vo.RawResultDataVO;
|
||||
import com.njcn.gather.storage.service.AdHarmonicService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -19,10 +21,7 @@ import java.lang.reflect.Field;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -48,7 +47,7 @@ public class AdHarmonicServiceImpl extends ServiceImpl<AdHarmonicMappper, AdHarm
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<RawDataVO>> listResultData(StorageParam param) {
|
||||
public Map<String, List<RawDataVO>> listHarmData(StorageParam param) {
|
||||
String prefix = "ad_harmonic_";
|
||||
DynamicTableNameHandler.setTableName(prefix + param.getCode());
|
||||
MPJLambdaWrapper<AdHarmonicResult> wrapper = new MPJLambdaWrapper<>();
|
||||
@@ -76,17 +75,17 @@ public class AdHarmonicServiceImpl extends ServiceImpl<AdHarmonicMappper, AdHarm
|
||||
Field fieldA = harmonicResult.getClass().getDeclaredField("aValue" + isHarmOrInHarm(i).intValue());
|
||||
fieldA.setAccessible(true);
|
||||
BigDecimal decimalA = new BigDecimal(fieldA.get(harmonicResult)+"");
|
||||
dataVO.setDataA(decimalA);
|
||||
dataVO.setDataA(decimalA.toPlainString());
|
||||
|
||||
Field fieldB = harmonicResult.getClass().getDeclaredField("bValue" + isHarmOrInHarm(i).intValue());
|
||||
fieldB.setAccessible(true);
|
||||
BigDecimal decimalB = new BigDecimal(fieldB.get(harmonicResult)+"");
|
||||
dataVO.setDataB(decimalB);
|
||||
dataVO.setDataB(decimalB.toPlainString());
|
||||
|
||||
Field fieldC = harmonicResult.getClass().getDeclaredField("cValue" + isHarmOrInHarm(i).intValue());
|
||||
fieldC.setAccessible(true);
|
||||
BigDecimal decimalC = new BigDecimal(fieldC.get(harmonicResult)+"");
|
||||
dataVO.setDataC(decimalC);
|
||||
dataVO.setDataC(decimalC.toPlainString());
|
||||
} catch (NoSuchFieldException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
@@ -106,6 +105,56 @@ public class AdHarmonicServiceImpl extends ServiceImpl<AdHarmonicMappper, AdHarm
|
||||
return info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, RawResultDataVO> listHarmResultData(StorageParam param) {
|
||||
String prefix = "ad_harmonic_result_";
|
||||
DynamicTableNameHandler.setTableName(prefix + param.getCode());
|
||||
MPJLambdaWrapper<AdHarmonicResult> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.like(AdHarmonicResult::getMonitorId, param.getDevId() + "_" + param.getDevNum())
|
||||
.eq(ObjectUtil.isNotNull(param.getScriptId()), AdHarmonicResult::getScriptId, param.getScriptId())
|
||||
.in(ObjectUtil.isNotEmpty(param.getIndex()), AdHarmonicResult::getSort, param.getIndex())
|
||||
.orderByAsc(AdHarmonicResult::getTimeId);
|
||||
|
||||
List<AdHarmonicResult> adHarmonicResults = this.getBaseMapper().selectJoinList(AdHarmonicResult.class, wrapper);
|
||||
List<Double> harmNum = param.getHarmNum();
|
||||
|
||||
Map<String, RawResultDataVO> info=new HashMap<>(3);
|
||||
RawResultDataVO dataVO;
|
||||
for (AdHarmonicResult harmonicResult : adHarmonicResults) {
|
||||
for (Double i : harmNum) {
|
||||
dataVO = new RawResultDataVO();
|
||||
dataVO.setHarmNum(i);
|
||||
dataVO.setIsData(harmonicResult.getResultFlag());
|
||||
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 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);
|
||||
}
|
||||
info.put(String.valueOf(i),dataVO) ;
|
||||
}
|
||||
}
|
||||
DynamicTableNameHandler.remove();
|
||||
return info;
|
||||
}
|
||||
|
||||
public Double isHarmOrInHarm(Double value) {
|
||||
if (value == value.longValue()) {
|
||||
return value;
|
||||
|
||||
@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.njcn.db.mybatisplus.handler.DynamicTableNameHandler;
|
||||
@@ -12,6 +13,7 @@ import com.njcn.gather.storage.pojo.param.StorageParam;
|
||||
import com.njcn.gather.storage.pojo.po.AdBaseResult;
|
||||
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.AdNonHarmonicService;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
|
||||
import com.njcn.gather.system.dictionary.service.IDictTreeService;
|
||||
@@ -21,6 +23,7 @@ import org.springframework.stereotype.Service;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -51,7 +54,7 @@ public class AdNonHarmonicServiceImpl extends ServiceImpl<AdNonHarmonicMapper, A
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<RawDataVO>> listNonResultData(StorageParam param) {
|
||||
public Map<String, List<RawDataVO>> listNonHarmData(StorageParam param) {
|
||||
String prefix = "ad_non_harmonic_";
|
||||
DynamicTableNameHandler.setTableName(prefix + param.getCode());
|
||||
MPJLambdaWrapper<AdNonHarmonicResult> wrapper = new MPJLambdaWrapper<>();
|
||||
@@ -70,13 +73,56 @@ public class AdNonHarmonicServiceImpl extends ServiceImpl<AdNonHarmonicMapper, A
|
||||
for (AdNonHarmonicResult result : value) {
|
||||
RawDataVO dataVO = new RawDataVO();
|
||||
dataVO.setTime(result.getTimeId().format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
dataVO.setDataA(ObjectUtil.isNotNull(result.getAValue())?new BigDecimal(result.getAValue()):null);
|
||||
dataVO.setDataB(ObjectUtil.isNotNull(result.getBValue())?new BigDecimal(result.getBValue()):null);
|
||||
dataVO.setDataC(ObjectUtil.isNotNull(result.getCValue())?new BigDecimal(result.getCValue()):null);
|
||||
dataVO.setDataT(ObjectUtil.isNotNull(result.getTValue())?new BigDecimal(result.getTValue()):null);
|
||||
dataVO.setDataA(ObjectUtil.isNotNull(result.getAValue()) ? new BigDecimal(result.getAValue()).toPlainString() : null);
|
||||
dataVO.setDataB(ObjectUtil.isNotNull(result.getBValue()) ? new BigDecimal(result.getBValue()).toPlainString() : null);
|
||||
dataVO.setDataC(ObjectUtil.isNotNull(result.getCValue()) ? new BigDecimal(result.getCValue()).toPlainString() : null);
|
||||
dataVO.setDataT(ObjectUtil.isNotNull(result.getTValue()) ? new BigDecimal(result.getTValue()).toPlainString() : null);
|
||||
rawDataVOS.add(dataVO);
|
||||
}
|
||||
info.put(key,rawDataVOS);
|
||||
info.put(treeName, rawDataVOS);
|
||||
}
|
||||
});
|
||||
DynamicTableNameHandler.remove();
|
||||
return info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, RawResultDataVO> listNonHarmResultData(StorageParam param) {
|
||||
String prefix = "ad_non_harmonic_result_";
|
||||
DynamicTableNameHandler.setTableName(prefix + param.getCode());
|
||||
MPJLambdaWrapper<AdNonHarmonicResult> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.like(AdNonHarmonicResult::getMonitorId, param.getDevId() + "_" + param.getDevNum())
|
||||
.eq(ObjectUtil.isNotNull(param.getScriptId()), AdNonHarmonicResult::getScriptId, param.getScriptId())
|
||||
.in(ObjectUtil.isNotEmpty(param.getIndex()), AdNonHarmonicResult::getSort, param.getIndex());
|
||||
|
||||
List<AdNonHarmonicResult> adHarmonicResults = this.getBaseMapper().selectJoinList(AdNonHarmonicResult.class, wrapper);
|
||||
|
||||
Map<String, RawResultDataVO> info = new HashMap<>(2);
|
||||
Map<String, AdNonHarmonicResult> adTypeMap = adHarmonicResults.stream().collect(Collectors.toMap(AdNonHarmonicResult::getAdType, Function.identity()));
|
||||
List<DictTree> dictTreeById = dictTreeService.getDictTreeById(new ArrayList<>(adTypeMap.keySet()));
|
||||
|
||||
Map<String, String> dictTreeByName = dictTreeById.stream().collect(Collectors.toMap(DictTree::getId, DictTree::getName));
|
||||
adTypeMap.forEach((key, result) -> {
|
||||
if (dictTreeByName.containsKey(key)) {
|
||||
String treeName = dictTreeByName.get(key);
|
||||
RawResultDataVO dataVO = new RawResultDataVO();
|
||||
dataVO.setIsData(result.getResultFlag());
|
||||
RawResultDataVO.DetectionData a = JSON.parseObject(result.getAValue(), RawResultDataVO.DetectionData.class);
|
||||
RawResultDataVO.DetectionData b = JSON.parseObject(result.getBValue(), RawResultDataVO.DetectionData.class);
|
||||
RawResultDataVO.DetectionData c = JSON.parseObject(result.getCValue(), RawResultDataVO.DetectionData.class);
|
||||
RawResultDataVO.DetectionData t = JSON.parseObject(result.getTValue(), RawResultDataVO.DetectionData.class);
|
||||
dataVO.setDataA(a);
|
||||
dataVO.setDataB(b);
|
||||
dataVO.setDataC(c);
|
||||
dataVO.setDataC(t);
|
||||
if(ObjectUtil.isNotNull(t)){
|
||||
dataVO.setRadius(t.getRadius());
|
||||
}else{
|
||||
if(ObjectUtil.isNotNull(b)){
|
||||
dataVO.setRadius(b.getRadius());
|
||||
}
|
||||
}
|
||||
info.put(treeName, dataVO);
|
||||
}
|
||||
});
|
||||
DynamicTableNameHandler.remove();
|
||||
|
||||
Reference in New Issue
Block a user