修改原始数据表结构、监测点检测结果加入统计数据逻辑
This commit is contained in:
@@ -8,10 +8,10 @@
|
||||
Time_Id DATETIME(3) NOT NULL COMMENT '时间',
|
||||
AD_Type CHAR(32) NOT NULL COMMENT '检测指标,字典表',
|
||||
Data_Type CHAR(32) NOT NULL COMMENT '数据指标,只有数据源为分钟统计时候才会使用(最大、最小、平均、CP95,默认平均值),字典表',
|
||||
A_Value float DEFAULT NULL COMMENT 'A相值',
|
||||
B_Value float DEFAULT NULL COMMENT 'B相值',
|
||||
C_Value float DEFAULT NULL COMMENT 'C相值',
|
||||
T_Value float DEFAULT NULL COMMENT 'T相值(没有相别的则存这里)',
|
||||
A_Value float(14,7) DEFAULT NULL COMMENT 'A相值',
|
||||
B_Value float(14,7) DEFAULT NULL COMMENT 'B相值',
|
||||
C_Value float(14,7) DEFAULT NULL COMMENT 'C相值',
|
||||
T_Value float(14,7) DEFAULT NULL COMMENT 'T相值(没有相别的则存这里)',
|
||||
Result_Flag int(1) NULL COMMENT '1合格 2不合格 4无法处理',
|
||||
<choose>
|
||||
<when test="isContrast">
|
||||
@@ -19,9 +19,9 @@
|
||||
Std_Dev_Monitor_Id CHAR(34) NOT NULL COMMENT '标准设备监测点Id',
|
||||
Num tinyint(1) unsigned DEFAULT 0 COMMENT '第几次检测',
|
||||
Flag tinyint(1) unsigned NOT NULL COMMENT '0表示被检设备数据,1表示标准设备数据',
|
||||
A_Value_0 float NULL COMMENT 'A相基波有效值',
|
||||
B_Value_0 float NULL COMMENT 'B相基波有效值',
|
||||
C_Value_0 float NULL COMMENT 'B相基波有效值',
|
||||
A_Value_0 float(14,7) NULL COMMENT 'A相基波有效值',
|
||||
B_Value_0 float(14,7) NULL COMMENT 'B相基波有效值',
|
||||
C_Value_0 float(14,7) NULL COMMENT 'B相基波有效值',
|
||||
Wave_Num tinyint(1) unsigned DEFAULT null COMMENT '录波数据第几组',
|
||||
PRIMARY KEY (Id)
|
||||
</when>
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.njcn.gather.storage.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.storage.pojo.po.ContrastHarmonicResult;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -22,7 +21,7 @@ public interface ContrastHarmonicService extends IService<ContrastHarmonicResult
|
||||
* @param adTypeList
|
||||
* @return
|
||||
*/
|
||||
List<ContrastHarmonicResult> listAllRawData(String code, Integer num, Integer waveNum, Boolean isWave, Integer flag, String devId, List<String> adTypeList);
|
||||
List<ContrastHarmonicResult> listAllRawData(String code, Integer num, Integer waveNum, Boolean isWave, String dataType, Integer flag, String devId, List<String> adTypeList);
|
||||
|
||||
/**
|
||||
* 获取所有谐波结果数据
|
||||
@@ -33,27 +32,29 @@ public interface ContrastHarmonicService extends IService<ContrastHarmonicResult
|
||||
* @param devId 设备ID
|
||||
* @return
|
||||
*/
|
||||
List<ContrastHarmonicResult> listAllResultData(String code, Integer num, Integer waveNum, Boolean isWave, String devId, List<String> adTypeList);
|
||||
List<ContrastHarmonicResult> listAllResultData(String code, Integer num, Integer waveNum, Boolean isWave, String dataType, String devId, List<String> adTypeList);
|
||||
|
||||
|
||||
/**
|
||||
* 获取谐波检测项的比对结果
|
||||
* @param planCode 计划code
|
||||
* @param monitorId 监测点ID
|
||||
* @param scriptId 指标id
|
||||
*
|
||||
* @param planCode 计划code
|
||||
* @param monitorId 监测点ID
|
||||
* @param scriptId 指标id
|
||||
* @param resultType 结果类型
|
||||
* @param time 第几次检测
|
||||
* @param time 第几次检测
|
||||
* @return 检测结果
|
||||
*/
|
||||
ContrastHarmonicResult getContrastResultHarm(Integer planCode, String monitorId, List<String> scriptId, String resultType, int time);
|
||||
|
||||
/**
|
||||
* 去原始表获取总次数
|
||||
* @param planCode 计划code
|
||||
* @param monitorId 监测点ID
|
||||
* @param scriptId 指标id
|
||||
*
|
||||
* @param planCode 计划code
|
||||
* @param monitorId 监测点ID
|
||||
* @param scriptId 指标id
|
||||
* @param resultType 结果类型
|
||||
* @param time 第几次检测
|
||||
* @param time 第几次检测
|
||||
* @return 数据组数
|
||||
*/
|
||||
int getNumOfData(Integer planCode, String monitorId, List<String> scriptId, String resultType, int time);
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.njcn.gather.storage.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.storage.pojo.po.ContrastNonHarmonicResult;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -19,12 +18,13 @@ public interface ContrastNonHarmonicService extends IService<ContrastNonHarmonic
|
||||
* @param num
|
||||
* @param waveNum
|
||||
* @param isWave
|
||||
* @param dataType
|
||||
* @param flag
|
||||
* @param devId
|
||||
* @param adTypeList
|
||||
* @return
|
||||
*/
|
||||
List<ContrastNonHarmonicResult> listAllRawData(String code, Integer num, Integer waveNum, Boolean isWave, Integer flag, String devId, List<String> adTypeList);
|
||||
List<ContrastNonHarmonicResult> listAllRawData(String code, Integer num, Integer waveNum, Boolean isWave, String dataType, Integer flag, String devId, List<String> adTypeList);
|
||||
|
||||
|
||||
/**
|
||||
@@ -34,31 +34,34 @@ public interface ContrastNonHarmonicService extends IService<ContrastNonHarmonic
|
||||
* @param num
|
||||
* @param waveNum
|
||||
* @param isWave
|
||||
* @param dataType
|
||||
* @param devId
|
||||
* @param adTypeList
|
||||
* @return
|
||||
*/
|
||||
|
||||
List<ContrastNonHarmonicResult> listAllResultData(String code, Integer num, Integer waveNum, Boolean isWave, String devId, List<String> adTypeList);
|
||||
List<ContrastNonHarmonicResult> listAllResultData(String code, Integer num, Integer waveNum, Boolean isWave, String dataType, String devId, List<String> adTypeList);
|
||||
|
||||
/**
|
||||
* 获取非谐波检测项的比对结果
|
||||
* @param planCode 计划code
|
||||
* @param monitorId 监测点ID
|
||||
* @param scriptId 指标id
|
||||
*
|
||||
* @param planCode 计划code
|
||||
* @param monitorId 监测点ID
|
||||
* @param scriptId 指标id
|
||||
* @param resultType 结果类型
|
||||
* @param time 第几次检测
|
||||
* @param time 第几次检测
|
||||
* @return 检测结果
|
||||
*/
|
||||
ContrastNonHarmonicResult getContrastResultHarm(Integer planCode, String monitorId, List<String> scriptId, String resultType, int time);
|
||||
|
||||
/**
|
||||
* 去原始表获取总次数
|
||||
* @param planCode 计划code
|
||||
* @param monitorId 监测点ID
|
||||
* @param scriptId 指标id
|
||||
*
|
||||
* @param planCode 计划code
|
||||
* @param monitorId 监测点ID
|
||||
* @param scriptId 指标id
|
||||
* @param resultType 结果类型
|
||||
* @param time 第几次检测
|
||||
* @param time 第几次检测
|
||||
* @return 数据组数
|
||||
*/
|
||||
int getNumOfData(Integer planCode, String monitorId, List<String> scriptId, String resultType, int time);
|
||||
|
||||
@@ -3,9 +3,9 @@ package com.njcn.gather.storage.service.impl;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
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.ContrastHarmonicMappper;
|
||||
import com.njcn.gather.storage.pojo.po.ContrastHarmonicResult;
|
||||
@@ -13,7 +13,6 @@ import com.njcn.gather.storage.service.ContrastHarmonicService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -26,12 +25,13 @@ public class ContrastHarmonicServiceImpl extends ServiceImpl<ContrastHarmonicMap
|
||||
|
||||
|
||||
@Override
|
||||
public List<ContrastHarmonicResult> listAllRawData(String code, Integer num, Integer waveNum, Boolean isWave, Integer flag, String devId, List<String> adTypeList) {
|
||||
public List<ContrastHarmonicResult> listAllRawData(String code, Integer num, Integer waveNum, Boolean isWave, String dataType, Integer flag, String devId, List<String> adTypeList) {
|
||||
String prefix = "ad_harmonic_" + code;
|
||||
DynamicTableNameHandler.setTableName(prefix);
|
||||
LambdaQueryChainWrapper<ContrastHarmonicResult> wrapper = this.lambdaQuery().likeRight(ContrastHarmonicResult::getDevMonitorId, devId)
|
||||
.eq(ObjectUtil.isNotNull(num), ContrastHarmonicResult::getNum, num)
|
||||
.eq(ContrastHarmonicResult::getFlag, flag)
|
||||
.eq(StrUtil.isNotBlank(dataType), ContrastHarmonicResult::getDataType, dataType)
|
||||
.in(CollUtil.isNotEmpty(adTypeList), ContrastHarmonicResult::getAdType, adTypeList)
|
||||
.orderByAsc(ContrastHarmonicResult::getTimeId);
|
||||
if (isWave) {
|
||||
@@ -48,15 +48,14 @@ public class ContrastHarmonicServiceImpl extends ServiceImpl<ContrastHarmonicMap
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* todo... 缺少统计的数据获取逻辑
|
||||
*/
|
||||
|
||||
@Override
|
||||
public List<ContrastHarmonicResult> listAllResultData(String code, Integer num, Integer waveNum, Boolean isWave, String devId, List<String> adTypeList) {
|
||||
public List<ContrastHarmonicResult> listAllResultData(String code, Integer num, Integer waveNum, Boolean isWave, String dataType, String devId, List<String> adTypeList) {
|
||||
String prefix = "ad_harmonic_result_" + code;
|
||||
DynamicTableNameHandler.setTableName(prefix);
|
||||
LambdaQueryChainWrapper<ContrastHarmonicResult> wrapper = this.lambdaQuery().likeRight(ContrastHarmonicResult::getDevMonitorId, devId)
|
||||
.eq(ObjectUtil.isNotNull(num), ContrastHarmonicResult::getNum, num)
|
||||
.eq(StrUtil.isNotBlank(dataType), ContrastHarmonicResult::getDataType, dataType)
|
||||
.in(CollUtil.isNotEmpty(adTypeList), ContrastHarmonicResult::getAdType, adTypeList);
|
||||
if (isWave) {
|
||||
if (ObjectUtil.isNotNull(waveNum)) {
|
||||
@@ -73,12 +72,11 @@ public class ContrastHarmonicServiceImpl extends ServiceImpl<ContrastHarmonicMap
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param planCode 计划code
|
||||
* @param monitorId 监测点ID
|
||||
* @param scriptId 指标id
|
||||
* @param planCode 计划code
|
||||
* @param monitorId 监测点ID
|
||||
* @param scriptId 指标id
|
||||
* @param resultType 结果类型
|
||||
* @param time 第几次检测
|
||||
* @param time 第几次检测
|
||||
* @return 检测结果
|
||||
*/
|
||||
@Override
|
||||
@@ -93,7 +91,7 @@ public class ContrastHarmonicServiceImpl extends ServiceImpl<ContrastHarmonicMap
|
||||
waveTime = Integer.parseInt(parts[parts.length - 1]);
|
||||
}
|
||||
}
|
||||
List<ContrastHarmonicResult> result = this.listAllResultData(String.valueOf(planCode), time, waveTime, isWave, monitorId, scriptId);
|
||||
List<ContrastHarmonicResult> result = this.listAllResultData(String.valueOf(planCode), time, waveTime, isWave, null, monitorId, scriptId);
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
return result.get(0);
|
||||
}
|
||||
@@ -102,11 +100,12 @@ public class ContrastHarmonicServiceImpl extends ServiceImpl<ContrastHarmonicMap
|
||||
|
||||
/**
|
||||
* 去原始表获取总次数
|
||||
* @param planCode 计划code
|
||||
* @param monitorId 监测点ID
|
||||
* @param scriptId 指标id
|
||||
*
|
||||
* @param planCode 计划code
|
||||
* @param monitorId 监测点ID
|
||||
* @param scriptId 指标id
|
||||
* @param resultType 结果类型
|
||||
* @param time 第几次检测
|
||||
* @param time 第几次检测
|
||||
* @return 数据组数
|
||||
*/
|
||||
@Override
|
||||
@@ -128,10 +127,10 @@ public class ContrastHarmonicServiceImpl extends ServiceImpl<ContrastHarmonicMap
|
||||
.in(ContrastHarmonicResult::getAdType, scriptId)
|
||||
.eq(ContrastHarmonicResult::getFlag, 0)
|
||||
.eq(ContrastHarmonicResult::getNum, time);
|
||||
if(isWave){
|
||||
if (isWave) {
|
||||
wrapper.eq(ContrastHarmonicResult::getDataType, "wave_data")
|
||||
.eq(ContrastHarmonicResult::getWaveNum, waveTime);
|
||||
}else{
|
||||
} else {
|
||||
wrapper.eq(ContrastHarmonicResult::getDataType, resultType);
|
||||
}
|
||||
// 执行查询并统计满足条件的记录数
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.njcn.gather.storage.service.impl;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.db.mybatisplus.handler.DynamicTableNameHandler;
|
||||
@@ -12,7 +13,6 @@ import com.njcn.gather.storage.service.ContrastNonHarmonicService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -25,12 +25,13 @@ public class ContrastNonHarmonicServiceImpl extends ServiceImpl<ContrastNonHarmo
|
||||
|
||||
|
||||
@Override
|
||||
public List<ContrastNonHarmonicResult> listAllRawData(String code, Integer num, Integer waveNum, Boolean isWave, Integer flag, String devId, List<String> adTypeList) {
|
||||
public List<ContrastNonHarmonicResult> listAllRawData(String code, Integer num, Integer waveNum, Boolean isWave, String dataType, Integer flag, String devId, List<String> adTypeList) {
|
||||
String prefix = "ad_non_harmonic_" + code;
|
||||
DynamicTableNameHandler.setTableName(prefix);
|
||||
LambdaQueryChainWrapper<ContrastNonHarmonicResult> wrapper = this.lambdaQuery().likeRight(ContrastNonHarmonicResult::getDevMonitorId, devId)
|
||||
.eq(ObjectUtil.isNotNull(num), ContrastNonHarmonicResult::getNum, num)
|
||||
.eq(ContrastNonHarmonicResult::getFlag, flag)
|
||||
.eq(StrUtil.isNotBlank(dataType), ContrastNonHarmonicResult::getDataType, dataType)
|
||||
.in(CollUtil.isNotEmpty(adTypeList), ContrastNonHarmonicResult::getAdType, adTypeList)
|
||||
.orderByAsc(ContrastNonHarmonicResult::getTimeId);
|
||||
if (isWave) {
|
||||
@@ -48,11 +49,12 @@ public class ContrastNonHarmonicServiceImpl extends ServiceImpl<ContrastNonHarmo
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ContrastNonHarmonicResult> listAllResultData(String code, Integer num, Integer waveNum, Boolean isWave, String devId, List<String> adTypeList) {
|
||||
public List<ContrastNonHarmonicResult> listAllResultData(String code, Integer num, Integer waveNum, Boolean isWave, String dataType, String devId, List<String> adTypeList) {
|
||||
String prefix = "ad_non_harmonic_result_" + code;
|
||||
DynamicTableNameHandler.setTableName(prefix);
|
||||
LambdaQueryChainWrapper<ContrastNonHarmonicResult> wrapper = this.lambdaQuery().likeRight(ContrastNonHarmonicResult::getDevMonitorId, devId)
|
||||
.eq(ObjectUtil.isNotNull(num), ContrastNonHarmonicResult::getNum, num)
|
||||
.eq(StrUtil.isNotBlank(dataType), ContrastNonHarmonicResult::getDataType, dataType)
|
||||
.in(CollUtil.isNotEmpty(adTypeList), ContrastNonHarmonicResult::getAdType, adTypeList);
|
||||
if (isWave) {
|
||||
if (ObjectUtil.isNotNull(waveNum)) {
|
||||
@@ -80,7 +82,7 @@ public class ContrastNonHarmonicServiceImpl extends ServiceImpl<ContrastNonHarmo
|
||||
waveTime = Integer.parseInt(parts[parts.length - 1]);
|
||||
}
|
||||
}
|
||||
List<ContrastNonHarmonicResult> result = this.listAllResultData(String.valueOf(planCode), time, waveTime, isWave, monitorId, scriptId);
|
||||
List<ContrastNonHarmonicResult> result = this.listAllResultData(String.valueOf(planCode), time, waveTime, isWave, null, monitorId, scriptId);
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
return result.get(0);
|
||||
}
|
||||
@@ -106,10 +108,10 @@ public class ContrastNonHarmonicServiceImpl extends ServiceImpl<ContrastNonHarmo
|
||||
.in(ContrastNonHarmonicResult::getAdType, scriptId)
|
||||
.eq(ContrastNonHarmonicResult::getFlag, 0)
|
||||
.eq(ContrastNonHarmonicResult::getNum, time);
|
||||
if(isWave){
|
||||
if (isWave) {
|
||||
wrapper.eq(ContrastNonHarmonicResult::getDataType, "wave_data")
|
||||
.eq(ContrastNonHarmonicResult::getWaveNum, waveTime);
|
||||
}else{
|
||||
} else {
|
||||
wrapper.eq(ContrastNonHarmonicResult::getDataType, resultType);
|
||||
}
|
||||
// 执行查询并统计满足条件的记录数
|
||||
|
||||
@@ -28,13 +28,13 @@ public class TableGenServiceImpl implements TableGenService {
|
||||
StringBuilder C = new StringBuilder();
|
||||
for (int i = 1; i <= 50; i++) {
|
||||
if (i == 1) {
|
||||
A.append("A_Value_").append(i).append(" float NULL COMMENT 'A相基波',");
|
||||
B.append("B_Value_").append(i).append(" float NULL COMMENT 'B相基波',");
|
||||
C.append("C_Value_").append(i).append(" float NULL COMMENT 'C相基波',");
|
||||
A.append("A_Value_").append(i).append(" float(14,7) NULL COMMENT 'A相基波',");
|
||||
B.append("B_Value_").append(i).append(" float(14,7) NULL COMMENT 'B相基波',");
|
||||
C.append("C_Value_").append(i).append(" float(14,7) NULL COMMENT 'C相基波',");
|
||||
} else {
|
||||
A.append("A_Value_").append(i).append(" float NULL COMMENT '").append(i).append("次A相谐波',");
|
||||
B.append("B_Value_").append(i).append(" float NULL COMMENT '").append(i).append("次B相谐波',");
|
||||
C.append("C_Value_").append(i).append(" float NULL COMMENT '").append(i).append("次C相谐波',");
|
||||
A.append("A_Value_").append(i).append(" float(14,7) NULL COMMENT '").append(i).append("次A相谐波',");
|
||||
B.append("B_Value_").append(i).append(" float(14,7) NULL COMMENT '").append(i).append("次B相谐波',");
|
||||
C.append("C_Value_").append(i).append(" float(14,7) NULL COMMENT '").append(i).append("次C相谐波',");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,9 +50,9 @@ public class TableGenServiceImpl implements TableGenService {
|
||||
"Std_Dev_Monitor_Id CHAR(34) NOT NULL COMMENT '标准设备监测点Id',\n" +
|
||||
"Num tinyint(1) unsigned DEFAULT 0 COMMENT '第几次检测',\n" +
|
||||
"Flag tinyint(1) unsigned NOT NULL COMMENT '0表示被检设备数据,1表示标准设备数据',\n" +
|
||||
"A_Value_0 float NULL COMMENT 'A相基波有效值',\n" +
|
||||
"C_Value_0 float NULL COMMENT 'B相基波有效值',\n" +
|
||||
"B_Value_0 float NULL COMMENT 'B相基波有效值',\n" +
|
||||
"A_Value_0 float(14,7) NULL COMMENT 'A相基波有效值',\n" +
|
||||
"C_Value_0 float(14,7) NULL COMMENT 'B相基波有效值',\n" +
|
||||
"B_Value_0 float(14,7) NULL COMMENT 'B相基波有效值',\n" +
|
||||
"Wave_Num tinyint(1) unsigned DEFAULT null COMMENT '录波数据第几组',\n" +
|
||||
"PRIMARY KEY (Id)\n"
|
||||
:
|
||||
@@ -64,9 +64,9 @@ public class TableGenServiceImpl implements TableGenService {
|
||||
// 添加索引
|
||||
tableGenMapper.genAdHarmonicTable("CREATE INDEX idx_ad_harmonic_" + code + "_dev_monitor_id" + " ON ad_harmonic_" + code + " (Dev_Monitor_Id);");
|
||||
|
||||
String a = A.toString().replaceAll("float", "json");
|
||||
String b = B.toString().replaceAll("float", "json");
|
||||
String c = C.toString().replaceAll("float", "json");
|
||||
String a = A.toString().replaceAll("float\\(14,7\\)", "json");
|
||||
String b = B.toString().replaceAll("float\\(14,7\\)", "json");
|
||||
String c = C.toString().replaceAll("float\\(14,7\\)", "json");
|
||||
String sql2 = "CREATE TABLE AD_Harmonic_Result_" + code + " (\n" +
|
||||
" Dev_Monitor_Id CHAR(34) NOT NULL COMMENT '监测点Id',\n" +
|
||||
" Time_Id DATETIME(3) NULL COMMENT '时间',\n" +
|
||||
|
||||
Reference in New Issue
Block a user