切换误差体系-未做完
This commit is contained in:
@@ -14,10 +14,6 @@ public class SimulateDetectionParam {
|
|||||||
*/
|
*/
|
||||||
private String operateType = "9";
|
private String operateType = "9";
|
||||||
|
|
||||||
/**
|
|
||||||
* 数字、模拟、比对
|
|
||||||
*/
|
|
||||||
private String pattern;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户功能组成唯一标识 zhangsan_test
|
* 用户功能组成唯一标识 zhangsan_test
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ public class MsgUtil {
|
|||||||
return JSON.toJSONString(socketDataMsg);
|
return JSON.toJSONString(socketDataMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DevData> toList(List<AdNonHarmonicResult> nonHarm, List<AdHarmonicResult> harm) {
|
public static List<DevData> toList(List<AdNonHarmonicResult> nonHarm, List<AdHarmonicResult> harm) {
|
||||||
List<DevData> info = new ArrayList<>();
|
List<DevData> info = new ArrayList<>();
|
||||||
if (CollUtil.isNotEmpty(nonHarm)) {
|
if (CollUtil.isNotEmpty(nonHarm)) {
|
||||||
if (CollUtil.isNotEmpty(nonHarm)) {
|
if (CollUtil.isNotEmpty(nonHarm)) {
|
||||||
@@ -85,8 +85,8 @@ public class MsgUtil {
|
|||||||
noHarmMap.forEach((key, value) -> {
|
noHarmMap.forEach((key, value) -> {
|
||||||
String[] split = key.split("_");
|
String[] split = key.split("_");
|
||||||
DevData data = new DevData();
|
DevData data = new DevData();
|
||||||
data.setTime(split[1]);
|
data.setTime(split[2]);
|
||||||
data.setId(split[0]);
|
data.setId(split[0]+"_"+split[1]);
|
||||||
List<DevData.SqlDataDTO> sqlDataDTOS = new ArrayList<>();
|
List<DevData.SqlDataDTO> sqlDataDTOS = new ArrayList<>();
|
||||||
DevData.SqlDataDTO sqlDataDTO;
|
DevData.SqlDataDTO sqlDataDTO;
|
||||||
for (AdNonHarmonicResult result : value) {
|
for (AdNonHarmonicResult result : value) {
|
||||||
@@ -129,8 +129,8 @@ public class MsgUtil {
|
|||||||
} else {
|
} else {
|
||||||
String[] split = key.split("_");
|
String[] split = key.split("_");
|
||||||
DevData data = new DevData();
|
DevData data = new DevData();
|
||||||
data.setTime(split[1]);
|
data.setTime(split[2]);
|
||||||
data.setId(split[0]);
|
data.setId(split[0]+"_"+split[1]);
|
||||||
data.setSqlDataHarm(sqlDataDTOS);
|
data.setSqlDataHarm(sqlDataDTOS);
|
||||||
info.add(data);
|
info.add(data);
|
||||||
}
|
}
|
||||||
@@ -142,7 +142,7 @@ public class MsgUtil {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> reflectHarmonicValue(String phase, AdHarmonicResult adHarmonicResult) {
|
private static List<String> reflectHarmonicValue(String phase, AdHarmonicResult adHarmonicResult) {
|
||||||
List<String> info = new ArrayList<>();
|
List<String> info = new ArrayList<>();
|
||||||
for (int i = 2; i < 50; i++) {
|
for (int i = 2; i < 50; i++) {
|
||||||
String fieldName = phase + "Value" + i;
|
String fieldName = phase + "Value" + i;
|
||||||
|
|||||||
@@ -86,4 +86,16 @@ public class ResultController extends BaseController {
|
|||||||
|
|
||||||
resultService.exportRawData(queryParam);
|
resultService.exportRawData(queryParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
|
||||||
|
@PostMapping("/changeErrorSystem")
|
||||||
|
@ApiOperation("更换误差体系")
|
||||||
|
@ApiImplicitParam(name = "param", value = "修改参数", required = true)
|
||||||
|
public HttpResult<Object> changeErrorSystem(@RequestBody ResultParam.ChangeErrorSystemParam param) {
|
||||||
|
String methodDescribe = getMethodDescribe("changeErrorSystem");
|
||||||
|
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, param);
|
||||||
|
|
||||||
|
resultService.changeErrorSystem(param);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,4 +64,28 @@ public class ResultParam {
|
|||||||
// 通道号,当为-1时,表示查询所有通道号,否则只查询指定通道号
|
// 通道号,当为-1时,表示查询所有通道号,否则只查询指定通道号
|
||||||
private String chnNum;
|
private String chnNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class ChangeErrorSystemParam {
|
||||||
|
@ApiModelProperty(value = "检测计划Id", required = true)
|
||||||
|
@NotBlank(message = DevValidMessage.PLAN_ID_NOT_NULL)
|
||||||
|
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.PLAN_ID_FORMAT_ERROR)
|
||||||
|
private String planId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "脚本Id", required = true)
|
||||||
|
@NotBlank(message = DevValidMessage.SCRIPT_ID_NOT_BLANK)
|
||||||
|
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.SCRIPT_ID_FORMAT_ERROR)
|
||||||
|
private String scriptId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "误差体系Id", required = true)
|
||||||
|
@NotBlank(message = DevValidMessage.ERROR_SYS_ID_NOT_BLANK)
|
||||||
|
private String errorSysId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "设备Id", required = true)
|
||||||
|
@NotBlank(message = DevValidMessage.DEV_ID_NOT_BLANK)
|
||||||
|
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.DEV_ID_FORMAT_ERROR)
|
||||||
|
private String deviceId;
|
||||||
|
|
||||||
|
private Integer code;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,4 +45,11 @@ public interface IResultService {
|
|||||||
* @param param
|
* @param param
|
||||||
*/
|
*/
|
||||||
void exportRawData(ResultParam param);
|
void exportRawData(ResultParam param);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更换误差体系
|
||||||
|
*
|
||||||
|
* @param param
|
||||||
|
*/
|
||||||
|
void changeErrorSystem(ResultParam.ChangeErrorSystemParam param);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,12 @@ import cn.hutool.core.util.StrUtil;
|
|||||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
|
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||||
|
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.device.service.IPqDevService;
|
||||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||||
import com.njcn.gather.plan.service.IAdPlanService;
|
import com.njcn.gather.plan.service.IAdPlanService;
|
||||||
@@ -20,23 +26,30 @@ import com.njcn.gather.result.pojo.vo.ResultVO;
|
|||||||
import com.njcn.gather.result.pojo.vo.TreeDataVO;
|
import com.njcn.gather.result.pojo.vo.TreeDataVO;
|
||||||
import com.njcn.gather.result.service.IResultService;
|
import com.njcn.gather.result.service.IResultService;
|
||||||
import com.njcn.gather.script.mapper.PqScriptMapper;
|
import com.njcn.gather.script.mapper.PqScriptMapper;
|
||||||
|
import com.njcn.gather.script.pojo.param.PqScriptIssueParam;
|
||||||
import com.njcn.gather.script.pojo.po.PqScriptCheckData;
|
import com.njcn.gather.script.pojo.po.PqScriptCheckData;
|
||||||
import com.njcn.gather.script.pojo.po.PqScriptDtls;
|
import com.njcn.gather.script.pojo.po.PqScriptDtls;
|
||||||
|
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||||
import com.njcn.gather.script.service.IPqScriptCheckDataService;
|
import com.njcn.gather.script.service.IPqScriptCheckDataService;
|
||||||
import com.njcn.gather.script.service.IPqScriptDtlsService;
|
import com.njcn.gather.script.service.IPqScriptDtlsService;
|
||||||
import com.njcn.gather.script.util.ScriptDtlsDesc;
|
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.param.StorageParam;
|
||||||
import com.njcn.gather.storage.pojo.po.AdBaseResult;
|
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.RawDataVO;
|
||||||
import com.njcn.gather.storage.service.AdHarmonicService;
|
import com.njcn.gather.storage.service.AdHarmonicService;
|
||||||
import com.njcn.gather.storage.service.AdNonHarmonicService;
|
import com.njcn.gather.storage.service.AdNonHarmonicService;
|
||||||
|
import com.njcn.gather.system.config.pojo.po.SysTestConfig;
|
||||||
import com.njcn.gather.system.config.service.ISysTestConfigService;
|
import com.njcn.gather.system.config.service.ISysTestConfigService;
|
||||||
|
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
||||||
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
|
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
|
||||||
import com.njcn.gather.system.dictionary.service.IDictTreeService;
|
import com.njcn.gather.system.dictionary.service.IDictTreeService;
|
||||||
import com.njcn.web.utils.ExcelUtil;
|
import com.njcn.web.utils.ExcelUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
@@ -60,6 +73,8 @@ public class ResultServiceImpl implements IResultService {
|
|||||||
private final PqScriptMapper scriptMapper;
|
private final PqScriptMapper scriptMapper;
|
||||||
private final IDictTreeService dictTreeService;
|
private final IDictTreeService dictTreeService;
|
||||||
private final IPqScriptCheckDataService pqScriptCheckDataService;
|
private final IPqScriptCheckDataService pqScriptCheckDataService;
|
||||||
|
private final TableGenMapper tableGenMapper;
|
||||||
|
private final DetectionServiceImpl detectionServiceImpl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 谐波类code,取树形字典表中的code
|
* 谐波类code,取树形字典表中的code
|
||||||
@@ -127,10 +142,10 @@ public class ResultServiceImpl implements IResultService {
|
|||||||
.eq(StrUtil.isNotBlank(param.getScriptId()), PqScriptDtls::getScriptId, param.getScriptId())
|
.eq(StrUtil.isNotBlank(param.getScriptId()), PqScriptDtls::getScriptId, param.getScriptId())
|
||||||
.eq(StrUtil.isNotBlank(param.getScriptType()), PqScriptDtls::getScriptType, param.getScriptType())
|
.eq(StrUtil.isNotBlank(param.getScriptType()), PqScriptDtls::getScriptType, param.getScriptType())
|
||||||
.ne(PqScriptDtls::getScriptIndex, -1)
|
.ne(PqScriptDtls::getScriptIndex, -1)
|
||||||
.eq(StrUtil.isNotBlank(param.getDevId()),PqScriptDtls::getEnable, DataStateEnum.ENABLE.getCode())
|
.eq(StrUtil.isNotBlank(param.getDevId()), PqScriptDtls::getEnable, DataStateEnum.ENABLE.getCode())
|
||||||
);
|
);
|
||||||
Map<Integer, Set<Integer>> resultMap = new HashMap<>(5);
|
Map<Integer, Set<Integer>> resultMap = new HashMap<>(5);
|
||||||
if(StrUtil.isNotBlank(param.getDevId())){
|
if (StrUtil.isNotBlank(param.getDevId())) {
|
||||||
List<AdBaseResult> allResultList = new ArrayList<>();
|
List<AdBaseResult> allResultList = new ArrayList<>();
|
||||||
List<Integer> indexList = new ArrayList<>();
|
List<Integer> indexList = new ArrayList<>();
|
||||||
if (StrUtil.isNotBlank(param.getScriptType())) {
|
if (StrUtil.isNotBlank(param.getScriptType())) {
|
||||||
@@ -176,7 +191,7 @@ public class ResultServiceImpl implements IResultService {
|
|||||||
subTypeMap.forEach((subKey, subValue) -> {
|
subTypeMap.forEach((subKey, subValue) -> {
|
||||||
if (!"VOLTAGE".equals(dictTree.getCode())) {
|
if (!"VOLTAGE".equals(dictTree.getCode())) {
|
||||||
TreeDataVO subType = new TreeDataVO();
|
TreeDataVO subType = new TreeDataVO();
|
||||||
subType.setScriptTypeName(!subName.containsKey(subKey)?"":subName.get(subKey).replace("XX", dictTree.getName()));
|
subType.setScriptTypeName(!subName.containsKey(subKey) ? "" : subName.get(subKey).replace("XX", dictTree.getName()));
|
||||||
subType.setScriptTypeCode(subKey);
|
subType.setScriptTypeCode(subKey);
|
||||||
LinkedHashMap<Integer, List<PqScriptDtls>> indexMap = subValue.stream()
|
LinkedHashMap<Integer, List<PqScriptDtls>> indexMap = subValue.stream()
|
||||||
.sorted(Comparator.comparing(PqScriptDtls::getScriptIndex))
|
.sorted(Comparator.comparing(PqScriptDtls::getScriptIndex))
|
||||||
@@ -213,13 +228,13 @@ public class ResultServiceImpl implements IResultService {
|
|||||||
.collect(Collectors.groupingBy(PqScriptDtls::getScriptSubType, LinkedHashMap::new, Collectors.toList()));
|
.collect(Collectors.groupingBy(PqScriptDtls::getScriptSubType, LinkedHashMap::new, Collectors.toList()));
|
||||||
if (CollUtil.isNotEmpty(subSingleTypeMap)) {
|
if (CollUtil.isNotEmpty(subSingleTypeMap)) {
|
||||||
TreeDataVO subType = new TreeDataVO();
|
TreeDataVO subType = new TreeDataVO();
|
||||||
subType.setScriptTypeName(!subName.containsKey("Single")?"":subName.get("Single").replace("XX", dictTree.getName()));
|
subType.setScriptTypeName(!subName.containsKey("Single") ? "" : subName.get("Single").replace("XX", dictTree.getName()));
|
||||||
subType.setScriptTypeCode(dictTree.getCode());
|
subType.setScriptTypeCode(dictTree.getCode());
|
||||||
//单影响量下频率准测量集合
|
//单影响量下频率准测量集合
|
||||||
List<TreeDataVO> subSingleList = new ArrayList<>();
|
List<TreeDataVO> subSingleList = new ArrayList<>();
|
||||||
subSingleTypeMap.forEach((subKey, subValue) -> {
|
subSingleTypeMap.forEach((subKey, subValue) -> {
|
||||||
TreeDataVO treeDataVO = new TreeDataVO();
|
TreeDataVO treeDataVO = new TreeDataVO();
|
||||||
treeDataVO.setScriptTypeName(!subName.containsKey(subKey)?"":subName.get(subKey).replace("XX", dictTree.getName()));
|
treeDataVO.setScriptTypeName(!subName.containsKey(subKey) ? "" : subName.get(subKey).replace("XX", dictTree.getName()));
|
||||||
treeDataVO.setScriptTypeCode(subKey);
|
treeDataVO.setScriptTypeCode(subKey);
|
||||||
List<TreeDataVO> subTypeList = new ArrayList<>();
|
List<TreeDataVO> subTypeList = new ArrayList<>();
|
||||||
|
|
||||||
@@ -272,7 +287,7 @@ public class ResultServiceImpl implements IResultService {
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
TreeDataVO vo = new TreeDataVO();
|
TreeDataVO vo = new TreeDataVO();
|
||||||
vo.setScriptTypeName(name);
|
vo.setScriptTypeName(name);
|
||||||
vo.setScriptTypeCode("Base_"+start+"_"+end);
|
vo.setScriptTypeCode("Base_" + start + "_" + end);
|
||||||
TreeDataVO dlt;
|
TreeDataVO dlt;
|
||||||
for (PqScriptDtls dtls : dip) {
|
for (PqScriptDtls dtls : dip) {
|
||||||
dlt = new TreeDataVO();
|
dlt = new TreeDataVO();
|
||||||
@@ -839,6 +854,13 @@ public class ResultServiceImpl implements IResultService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void changeErrorSystem(ResultParam.ChangeErrorSystemParam param) {
|
||||||
|
this.createTempResultTable(param.getCode() + "");
|
||||||
|
this.insertTempResultTable(param.getPlanId(), param.getScriptId(), param.getCode() + "", param.getErrorSysId(), param.getDeviceId());
|
||||||
|
}
|
||||||
|
|
||||||
private Integer conform(Set<Integer> numbers) {
|
private Integer conform(Set<Integer> numbers) {
|
||||||
if (CollUtil.isNotEmpty(numbers)) {
|
if (CollUtil.isNotEmpty(numbers)) {
|
||||||
if (numbers.size() > 1) {
|
if (numbers.size() > 1) {
|
||||||
@@ -859,4 +881,105 @@ public class ResultServiceImpl implements IResultService {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拷贝结果表
|
||||||
|
*
|
||||||
|
* @param code
|
||||||
|
*/
|
||||||
|
private void createTempResultTable(String code) {
|
||||||
|
tableGenMapper.genAdHarmonicTable("drop table if exists AD_Non_Harmonic_Result_" + code + "_temp,AD_Harmonic_Result_" + code + "_temp");
|
||||||
|
tableGenMapper.genAdNonHarmonicResultTable(code + "_temp");
|
||||||
|
StringBuilder A = new StringBuilder();
|
||||||
|
StringBuilder B = new StringBuilder();
|
||||||
|
StringBuilder C = new StringBuilder();
|
||||||
|
for (int i = 1; i <= 50; i++) {
|
||||||
|
if (i == 1) {
|
||||||
|
A.append("A_Value_").append(i).append(" json NULL COMMENT 'A相基波',");
|
||||||
|
B.append("B_Value_").append(i).append(" json NULL COMMENT 'B相基波',");
|
||||||
|
C.append("C_Value_").append(i).append(" json NULL COMMENT 'C相基波',");
|
||||||
|
} else {
|
||||||
|
A.append("A_Value_").append(i).append(" json NULL COMMENT '").append(i).append("次A相谐波',");
|
||||||
|
B.append("B_Value_").append(i).append(" json NULL COMMENT '").append(i).append("次B相谐波',");
|
||||||
|
C.append("C_Value_").append(i).append(" json NULL COMMENT '").append(i).append("次C相谐波',");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String sql1 = "CREATE TABLE if not exists AD_Harmonic_Result_" + code + "_temp (\n" +
|
||||||
|
" Monitor_Id CHAR(60) NOT NULL COMMENT '监测点Id',\n" +
|
||||||
|
" Time_Id DATETIME NULL COMMENT '时间',\n" +
|
||||||
|
" Script_Id CHAR(32) NOT NULL COMMENT '检测脚本子表Id,字典表',\n" +
|
||||||
|
" Sort int(5) NOT NULL COMMENT '总检测脚本中的测试项序号',\n" +
|
||||||
|
" AD_Type CHAR(32) NOT NULL COMMENT '检测指标,字典表',\n" +
|
||||||
|
" Data_Type CHAR(32) NOT NULL COMMENT '数据指标,只有数据源为分钟统计时候才会使用(最大、最小、平均、CP95,默认平均值),字典表',\n" +
|
||||||
|
" Result_Flag int(1) NOT NULL COMMENT '1合格 2不合格 4无法处理',\n" +
|
||||||
|
A + B + C +
|
||||||
|
" PRIMARY KEY (Monitor_Id, Script_Id, Sort, AD_Type)\n" +
|
||||||
|
") COMMENT='监测数据表';";
|
||||||
|
tableGenMapper.genAdHarmonicTable(sql1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改拷贝后的结果表(根据误差体系修改)
|
||||||
|
*
|
||||||
|
* @param planId
|
||||||
|
* @param code
|
||||||
|
* @param errorSysId
|
||||||
|
* @param devId
|
||||||
|
*/
|
||||||
|
private void insertTempResultTable(String planId, String scriptId, String code, String errorSysId, String devId) {
|
||||||
|
PreDetectionParam param = new PreDetectionParam();
|
||||||
|
param.setCode(code);
|
||||||
|
param.setErrorSysId(errorSysId);
|
||||||
|
param.setDevIds(Arrays.asList(devId));
|
||||||
|
param.setCode(code+"_temp");
|
||||||
|
|
||||||
|
Map<String, String> devIdMapComm = new HashMap<>();
|
||||||
|
PqDev dev = pqDevService.getById(devId);
|
||||||
|
devIdMapComm.put(devId,devId);
|
||||||
|
|
||||||
|
SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
|
||||||
|
DictDataEnum dataRule;
|
||||||
|
if (ObjectUtil.isNotNull(oneConfig)) {
|
||||||
|
dataRule = DictDataEnum.getDictDataEnumByCode(oneConfig.getDataRule());
|
||||||
|
} else {
|
||||||
|
dataRule = DictDataEnum.AT_WILL_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<AdNonHarmonicResult> allNonHarmonicRawData = adNonHarmonicService.listAll(code, devId);
|
||||||
|
LinkedHashMap<Integer, List<AdNonHarmonicResult>> map = allNonHarmonicRawData.stream().sorted(Comparator.comparing(AdNonHarmonicResult::getSort))
|
||||||
|
.collect(Collectors.groupingBy(AdNonHarmonicResult::getSort, LinkedHashMap::new, Collectors.toList()));
|
||||||
|
|
||||||
|
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
||||||
|
issueParam.setPlanId(planId);
|
||||||
|
// issueParam.setSourceId();
|
||||||
|
// issueParam.setScriptType();
|
||||||
|
// issueParam.setScriptSubType();
|
||||||
|
|
||||||
|
issueParam.setDevIds(Arrays.asList(devId));
|
||||||
|
issueParam.setScriptId(scriptId);
|
||||||
|
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.FORMAL_TEST.getValue());
|
||||||
|
List<SourceIssue> sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam);
|
||||||
|
|
||||||
|
sourceIssues.forEach(sourceIssue -> {
|
||||||
|
List<DevData> realDataXiList = MsgUtil.toList(map.get(sourceIssue.getIndex()), null);
|
||||||
|
for (int i = 0; i < realDataXiList.size(); i++) {
|
||||||
|
DevData devData = realDataXiList.get(i);
|
||||||
|
List<DevData.SqlDataDTO> sqlData = devData.getSqlData();
|
||||||
|
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)){
|
||||||
|
DictTree dictTree = dictTreeService.getById(desc);
|
||||||
|
if (ObjectUtil.isNotNull(dictTree)) {
|
||||||
|
sqlDataDTO.setDesc(dictTree.getCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
detectionServiceImpl.processing(realDataXiList, param, devIdMapComm, sourceIssue, dataRule);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,4 @@ public interface TableGenMapper {
|
|||||||
|
|
||||||
|
|
||||||
void genAdNonHarmonicResultTable(@Param("code")String code);
|
void genAdNonHarmonicResultTable(@Param("code")String code);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<update id="genAdNonHarmonicResultTable" parameterType="string">
|
<update id="genAdNonHarmonicResultTable" parameterType="string">
|
||||||
CREATE TABLE ad_non_harmonic_result_${code} (
|
CREATE TABLE if not exists ad_non_harmonic_result_${code} (
|
||||||
Monitor_Id CHAR(60) NOT NULL COMMENT '监测点Id',
|
Monitor_Id CHAR(60) NOT NULL COMMENT '监测点Id',
|
||||||
Time_Id DATETIME NULL COMMENT '时间',
|
Time_Id DATETIME NULL COMMENT '时间',
|
||||||
Script_Id CHAR(32) NOT NULL COMMENT '检测脚本子表Id,字典表',
|
Script_Id CHAR(32) NOT NULL COMMENT '检测脚本子表Id,字典表',
|
||||||
@@ -41,10 +41,5 @@
|
|||||||
PRIMARY KEY (Monitor_Id, Script_Id, Sort, AD_Type,Data_Type)
|
PRIMARY KEY (Monitor_Id, Script_Id, Sort, AD_Type,Data_Type)
|
||||||
) COMMENT='监测数据表';
|
) COMMENT='监测数据表';
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<update id="genAdHarmonicResultTable" parameterType="string">
|
|
||||||
${tableSql}
|
|
||||||
</update>
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
||||||
|
|||||||
@@ -46,4 +46,12 @@ public interface AdNonHarmonicService extends IService<AdNonHarmonicResult> {
|
|||||||
* @param singleNonHarmParam 查询参数
|
* @param singleNonHarmParam 查询参数
|
||||||
*/
|
*/
|
||||||
AdNonHarmonicResult getSingleResult(SingleNonHarmParam singleNonHarmParam);
|
AdNonHarmonicResult getSingleResult(SingleNonHarmParam singleNonHarmParam);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有原始数据
|
||||||
|
* @param code
|
||||||
|
* @param devId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<AdNonHarmonicResult> listAll(String code,String devId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,10 @@ import org.springframework.stereotype.Service;
|
|||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -67,7 +70,7 @@ public class AdNonHarmonicServiceImpl extends ServiceImpl<AdNonHarmonicMapper, A
|
|||||||
Map<String, List<RawDataVO>> info = new LinkedHashMap<>(2);
|
Map<String, List<RawDataVO>> info = new LinkedHashMap<>(2);
|
||||||
Map<String, List<AdNonHarmonicResult>> adTypeMap = adHarmonicResults.stream().collect(Collectors.groupingBy(AdNonHarmonicResult::getAdType));
|
Map<String, List<AdNonHarmonicResult>> adTypeMap = adHarmonicResults.stream().collect(Collectors.groupingBy(AdNonHarmonicResult::getAdType));
|
||||||
List<DictTree> dictTreeById = dictTreeService.getDictTreeById(new ArrayList<>(adTypeMap.keySet()));
|
List<DictTree> dictTreeById = dictTreeService.getDictTreeById(new ArrayList<>(adTypeMap.keySet()));
|
||||||
Map<String, DictTree> dictTreeByName = dictTreeById.stream().collect(Collectors.toMap(DictTree::getId,Function.identity()));
|
Map<String, DictTree> dictTreeByName = dictTreeById.stream().collect(Collectors.toMap(DictTree::getId, Function.identity()));
|
||||||
adTypeMap.forEach((key, value) -> {
|
adTypeMap.forEach((key, value) -> {
|
||||||
if (dictTreeByName.containsKey(key)) {
|
if (dictTreeByName.containsKey(key)) {
|
||||||
DictTree dictTree = dictTreeByName.get(key);
|
DictTree dictTree = dictTreeByName.get(key);
|
||||||
@@ -104,7 +107,7 @@ public class AdNonHarmonicServiceImpl extends ServiceImpl<AdNonHarmonicMapper, A
|
|||||||
Map<String, AdNonHarmonicResult> adTypeMap = adHarmonicResults.stream().collect(Collectors.toMap(AdNonHarmonicResult::getAdType, Function.identity()));
|
Map<String, AdNonHarmonicResult> adTypeMap = adHarmonicResults.stream().collect(Collectors.toMap(AdNonHarmonicResult::getAdType, Function.identity()));
|
||||||
List<DictTree> dictTreeById = dictTreeService.getDictTreeById(new ArrayList<>(adTypeMap.keySet()));
|
List<DictTree> dictTreeById = dictTreeService.getDictTreeById(new ArrayList<>(adTypeMap.keySet()));
|
||||||
|
|
||||||
Map<String, DictTree> dictTreeByName = dictTreeById.stream().collect(Collectors.toMap(DictTree::getId,Function.identity()));
|
Map<String, DictTree> dictTreeByName = dictTreeById.stream().collect(Collectors.toMap(DictTree::getId, Function.identity()));
|
||||||
adTypeMap.forEach((key, result) -> {
|
adTypeMap.forEach((key, result) -> {
|
||||||
if (dictTreeByName.containsKey(key)) {
|
if (dictTreeByName.containsKey(key)) {
|
||||||
DictTree treeName = dictTreeByName.get(key);
|
DictTree treeName = dictTreeByName.get(key);
|
||||||
@@ -119,10 +122,10 @@ public class AdNonHarmonicServiceImpl extends ServiceImpl<AdNonHarmonicMapper, A
|
|||||||
dataVO.setDataB(b);
|
dataVO.setDataB(b);
|
||||||
dataVO.setDataC(c);
|
dataVO.setDataC(c);
|
||||||
dataVO.setDataT(t);
|
dataVO.setDataT(t);
|
||||||
if(ObjectUtil.isNotNull(t)){
|
if (ObjectUtil.isNotNull(t)) {
|
||||||
dataVO.setRadius(t.getRadius());
|
dataVO.setRadius(t.getRadius());
|
||||||
}else{
|
} else {
|
||||||
if(ObjectUtil.isNotNull(b)){
|
if (ObjectUtil.isNotNull(b)) {
|
||||||
dataVO.setRadius(b.getRadius());
|
dataVO.setRadius(b.getRadius());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -135,7 +138,7 @@ public class AdNonHarmonicServiceImpl extends ServiceImpl<AdNonHarmonicMapper, A
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AdNonHarmonicResult getSingleResult(SingleNonHarmParam singleNonHarmParam) {
|
public AdNonHarmonicResult getSingleResult(SingleNonHarmParam singleNonHarmParam) {
|
||||||
if(ObjectUtil.isNotNull(singleNonHarmParam)){
|
if (ObjectUtil.isNotNull(singleNonHarmParam)) {
|
||||||
String prefix = "ad_non_harmonic_result_";
|
String prefix = "ad_non_harmonic_result_";
|
||||||
DynamicTableNameHandler.setTableName(prefix + singleNonHarmParam.getPlanCode());
|
DynamicTableNameHandler.setTableName(prefix + singleNonHarmParam.getPlanCode());
|
||||||
MPJLambdaWrapper<AdNonHarmonicResult> wrapper = new MPJLambdaWrapper<>();
|
MPJLambdaWrapper<AdNonHarmonicResult> wrapper = new MPJLambdaWrapper<>();
|
||||||
@@ -143,71 +146,82 @@ public class AdNonHarmonicServiceImpl extends ServiceImpl<AdNonHarmonicMapper, A
|
|||||||
.eq(AdNonHarmonicResult::getSort, singleNonHarmParam.getSort())
|
.eq(AdNonHarmonicResult::getSort, singleNonHarmParam.getSort())
|
||||||
.eq(AdNonHarmonicResult::getAdType, singleNonHarmParam.getAdType());
|
.eq(AdNonHarmonicResult::getAdType, singleNonHarmParam.getAdType());
|
||||||
List<AdNonHarmonicResult> adHarmonicResults = this.getBaseMapper().selectJoinList(AdNonHarmonicResult.class, wrapper);
|
List<AdNonHarmonicResult> adHarmonicResults = this.getBaseMapper().selectJoinList(AdNonHarmonicResult.class, wrapper);
|
||||||
if (CollectionUtil.isNotEmpty(adHarmonicResults)){
|
if (CollectionUtil.isNotEmpty(adHarmonicResults)) {
|
||||||
return adHarmonicResults.get(0);
|
return adHarmonicResults.get(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String unit(String code){
|
@Override
|
||||||
String unit="";
|
public List<AdNonHarmonicResult> listAll(String code, String devId) {
|
||||||
|
String prefix = "ad_non_harmonic_" + code;
|
||||||
|
DynamicTableNameHandler.setTableName(prefix);
|
||||||
|
MPJLambdaWrapper<AdNonHarmonicResult> wrapper = new MPJLambdaWrapper<>();
|
||||||
|
wrapper.likeRight(AdNonHarmonicResult::getMonitorId, devId);
|
||||||
|
List<AdNonHarmonicResult> adHarmonicResults = this.getBaseMapper().selectJoinList(AdNonHarmonicResult.class, wrapper);
|
||||||
|
DynamicTableNameHandler.remove();
|
||||||
|
return adHarmonicResults;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String unit(String code) {
|
||||||
|
String unit = "";
|
||||||
switch (code) {
|
switch (code) {
|
||||||
/**
|
/**
|
||||||
* 频率
|
* 频率
|
||||||
*/
|
*/
|
||||||
case "FREQ":
|
case "FREQ":
|
||||||
unit="Hz";
|
unit = "Hz";
|
||||||
break;
|
break;
|
||||||
/**
|
/**
|
||||||
* 电压
|
* 电压
|
||||||
*/
|
*/
|
||||||
case "VRMS":
|
case "VRMS":
|
||||||
unit="V";
|
unit = "V";
|
||||||
break;
|
break;
|
||||||
/**
|
/**
|
||||||
* 电流
|
* 电流
|
||||||
*/
|
*/
|
||||||
case "IRMS":
|
case "IRMS":
|
||||||
unit="A";
|
unit = "A";
|
||||||
break;
|
break;
|
||||||
/**
|
/**
|
||||||
* 谐波电压
|
* 谐波电压
|
||||||
*/
|
*/
|
||||||
case "V2-50":
|
case "V2-50":
|
||||||
/**
|
/**
|
||||||
* 谐波电流
|
* 谐波电流
|
||||||
*/
|
*/
|
||||||
case "I2-50":
|
case "I2-50":
|
||||||
/**
|
/**
|
||||||
* 间谐波电压
|
* 间谐波电压
|
||||||
*/
|
*/
|
||||||
case "SV_1-49":
|
case "SV_1-49":
|
||||||
/**
|
/**
|
||||||
* 间谐波电流
|
* 间谐波电流
|
||||||
*/
|
*/
|
||||||
case "SI_1-49":
|
case "SI_1-49":
|
||||||
/**
|
/**
|
||||||
* 三相电压不平衡度
|
* 三相电压不平衡度
|
||||||
*/
|
*/
|
||||||
case "V_UNBAN":
|
case "V_UNBAN":
|
||||||
/**
|
/**
|
||||||
* 三相电流不平衡度
|
* 三相电流不平衡度
|
||||||
*/
|
*/
|
||||||
case "I_UNBAN":
|
case "I_UNBAN":
|
||||||
unit="%";
|
unit = "%";
|
||||||
break;
|
break;
|
||||||
/**
|
/**
|
||||||
* 谐波有功功率
|
* 谐波有功功率
|
||||||
*/
|
*/
|
||||||
case "P2-50":
|
case "P2-50":
|
||||||
unit="W";
|
unit = "W";
|
||||||
break;
|
break;
|
||||||
/**
|
/**
|
||||||
* 功率
|
* 功率
|
||||||
*/
|
*/
|
||||||
case "P":
|
case "P":
|
||||||
unit="P";
|
unit = "P";
|
||||||
break;
|
break;
|
||||||
/**
|
/**
|
||||||
* 闪变
|
* 闪变
|
||||||
@@ -218,28 +232,28 @@ public class AdNonHarmonicServiceImpl extends ServiceImpl<AdNonHarmonicMapper, A
|
|||||||
* 暂态-电压幅值
|
* 暂态-电压幅值
|
||||||
*/
|
*/
|
||||||
case "MAG":
|
case "MAG":
|
||||||
unit="V";
|
unit = "%";
|
||||||
break;
|
break;
|
||||||
/**
|
/**
|
||||||
* 暂态-持续时间
|
* 暂态-持续时间
|
||||||
*/
|
*/
|
||||||
case "DUR":
|
case "DUR":
|
||||||
unit="s";
|
unit = "s";
|
||||||
break;
|
break;
|
||||||
/**
|
/**
|
||||||
* 相角
|
* 相角
|
||||||
*/
|
*/
|
||||||
case "VA":
|
case "VA":
|
||||||
case "IA":
|
case "IA":
|
||||||
unit="°";
|
unit = "°";
|
||||||
break;
|
break;
|
||||||
/**
|
/**
|
||||||
* 电压偏差
|
* 电压偏差
|
||||||
*/
|
*/
|
||||||
case "DELTA_V":
|
case "DELTA_V":
|
||||||
unit="%";
|
unit = "%";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return unit;
|
return unit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user