1.正式检测代码详情检测表格代码提交

This commit is contained in:
wr
2025-01-05 13:57:38 +08:00
parent 949aa83539
commit ea8a2bd8e7
10 changed files with 210 additions and 44 deletions

View File

@@ -2,6 +2,8 @@ package com.njcn.gather.storage.pojo.param;
import lombok.Data;
import java.util.List;
/**
* @author wr
* @description
@@ -34,4 +36,9 @@ public class StorageParam {
* 自动生成,用于生成数据表后缀
*/
private Integer code;
/**
* 谐波次数
*/
private List<Double> harmNum;
}

View File

@@ -37,4 +37,9 @@ public class RawDataVO {
* C相数据
*/
private BigDecimal dataC;
/**
* C相数据
*/
private BigDecimal dataT;
}

View File

@@ -1,10 +1,13 @@
package com.njcn.gather.storage.service;
import com.baomidou.mybatisplus.extension.service.IService;
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 java.util.List;
import java.util.Map;
/**
* @author caozehui
@@ -16,11 +19,19 @@ public interface AdHarmonicService extends IService<AdHarmonicResult> {
* 根据设备ID和通道号获取谐波结果
*
* @param scriptId 脚本id
* @param sort 序号列表
* @param sort 序号列表
* @param deviceId 设备ID
* @param chnNum 通道号从1开始
* @param code 计划code
* @param code 计划code
* @return 谐波结果
*/
List<AdBaseResult> get(String scriptId, List<Integer> sort, String deviceId, String chnNum,Integer code);
List<AdBaseResult> get(String scriptId, List<Integer> index, String deviceId, String chnNum, Integer code);
/**
* 查询原始数据
*
* @param param
* @return
*/
Map<String, List<RawDataVO>> listResultData(StorageParam param);
}

View File

@@ -1,10 +1,13 @@
package com.njcn.gather.storage.service;
import com.baomidou.mybatisplus.extension.service.IService;
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 java.util.List;
import java.util.Map;
public interface AdNonHarmonicService extends IService<AdNonHarmonicResult> {
@@ -20,5 +23,10 @@ public interface AdNonHarmonicService extends IService<AdNonHarmonicResult> {
*/
List<AdBaseResult> get(String scriptId, List<Integer> sort, String deviceId, String chnNum,Integer code);
/**
* 非谐波原始数据展示
* @param param
* @return
*/
Map<String,List<RawDataVO>> listNonResultData(StorageParam param) ;
}

View File

@@ -2,17 +2,27 @@ package com.njcn.gather.storage.service.impl;
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.njcn.db.mybatisplus.handler.DynamicTableNameHandler;
import com.njcn.gather.storage.mapper.AdHarmonicMappper;
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.service.AdHarmonicService;
import org.springframework.stereotype.Service;
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;
/**
* @author caozehui
@@ -21,9 +31,9 @@ import java.util.List;
@Service
public class AdHarmonicServiceImpl extends ServiceImpl<AdHarmonicMappper, AdHarmonicResult> implements AdHarmonicService {
@Override
public List<AdBaseResult> get(String scriptId, List<Integer> sort, String deviceId, String chnNum,Integer code ) {
public List<AdBaseResult> get(String scriptId, List<Integer> sort, String deviceId, String chnNum, Integer code) {
String prefix = "ad_harmonic_result_";
DynamicTableNameHandler.setTableName(prefix +code);
DynamicTableNameHandler.setTableName(prefix + code);
MPJLambdaWrapper<AdHarmonicResult> wrapper = new MPJLambdaWrapper<>();
String monitorId = deviceId + "_" + chnNum;
if ("-1".equals(chnNum)) {
@@ -36,4 +46,71 @@ public class AdHarmonicServiceImpl extends ServiceImpl<AdHarmonicMappper, AdHarm
DynamicTableNameHandler.remove();
return BeanUtil.copyToList(list, AdBaseResult.class);
}
@Override
public Map<String, List<RawDataVO>> listResultData(StorageParam param) {
String prefix = "ad_harmonic_";
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, List<RawDataVO>> info=new HashMap<>(3);
RawDataVO dataVO;
List<RawDataVO> rawDataVOS;
for (AdHarmonicResult harmonicResult : adHarmonicResults) {
for (Double i : harmNum) {
dataVO = new RawDataVO();
dataVO.setHarmNum(i);
try {
Field timeId = harmonicResult.getClass().getDeclaredField("timeId");
timeId.setAccessible(true);
LocalDateTime localDateTime = (LocalDateTime) timeId.get(harmonicResult);
dataVO.setTime(localDateTime.format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)));
Field fieldA = harmonicResult.getClass().getDeclaredField("aValue" + isHarmOrInHarm(i).intValue());
fieldA.setAccessible(true);
BigDecimal decimalA = new BigDecimal(fieldA.get(harmonicResult)+"");
dataVO.setDataA(decimalA);
Field fieldB = harmonicResult.getClass().getDeclaredField("bValue" + isHarmOrInHarm(i).intValue());
fieldB.setAccessible(true);
BigDecimal decimalB = new BigDecimal(fieldB.get(harmonicResult)+"");
dataVO.setDataB(decimalB);
Field fieldC = harmonicResult.getClass().getDeclaredField("cValue" + isHarmOrInHarm(i).intValue());
fieldC.setAccessible(true);
BigDecimal decimalC = new BigDecimal(fieldC.get(harmonicResult)+"");
dataVO.setDataC(decimalC);
} catch (NoSuchFieldException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
if(info.containsKey(String.valueOf(i))){
info.get(String.valueOf(i)).add(dataVO);
}else{
rawDataVOS=new ArrayList<>();
rawDataVOS.add(dataVO);
info.put(String.valueOf(i),rawDataVOS) ;
}
}
}
DynamicTableNameHandler.remove();
return info;
}
public Double isHarmOrInHarm(Double value) {
if (value == value.longValue()) {
return value;
} else {
return value + 0.5;
}
}
}

View File

@@ -2,24 +2,36 @@ package com.njcn.gather.storage.service.impl;
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.njcn.db.mybatisplus.handler.DynamicTableNameHandler;
import com.njcn.gather.storage.mapper.AdNonHarmonicMapper;
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.service.AdNonHarmonicService;
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
import com.njcn.gather.system.dictionary.service.IDictTreeService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
import java.math.BigDecimal;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
/**
*
*/
@Service
@RequiredArgsConstructor
public class AdNonHarmonicServiceImpl extends ServiceImpl<AdNonHarmonicMapper, AdNonHarmonicResult> implements AdNonHarmonicService {
private final IDictTreeService dictTreeService;
@Override
public List<AdBaseResult> get(String scriptId, List<Integer> sort, String deviceId, String chnNum, Integer code) {
String prefix = "ad_non_harmonic_result_";
@@ -37,4 +49,37 @@ public class AdNonHarmonicServiceImpl extends ServiceImpl<AdNonHarmonicMapper, A
DynamicTableNameHandler.remove();
return BeanUtil.copyToList(list, AdBaseResult.class);
}
@Override
public Map<String, List<RawDataVO>> listNonResultData(StorageParam param) {
String prefix = "ad_non_harmonic_";
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, List<RawDataVO>> info = new HashMap<>(2);
Map<String, List<AdNonHarmonicResult>> adTypeMap = adHarmonicResults.stream().collect(Collectors.groupingBy(AdNonHarmonicResult::getAdType));
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, value) -> {
if (dictTreeByName.containsKey(key)) {
String treeName = dictTreeByName.get(key);
List<RawDataVO> rawDataVOS = new ArrayList<>();
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);
rawDataVOS.add(dataVO);
}
info.put(key,rawDataVOS);
}
});
DynamicTableNameHandler.remove();
return info;
}
}