Merge remote-tracking branch 'origin/master'
# Conflicts: # detection/src/main/java/com/njcn/gather/device/service/impl/PqDevServiceImpl.java
This commit is contained in:
@@ -3,6 +3,7 @@ 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;
|
||||
|
||||
/**
|
||||
@@ -33,4 +34,27 @@ public interface ContrastHarmonicService extends IService<ContrastHarmonicResult
|
||||
* @return
|
||||
*/
|
||||
List<ContrastHarmonicResult> listAllResultData(String code, Integer num, Integer waveNum, Boolean isWave, String devId, List<String> adTypeList);
|
||||
|
||||
|
||||
/**
|
||||
* 获取谐波检测项的比对结果
|
||||
* @param planCode 计划code
|
||||
* @param monitorId 监测点ID
|
||||
* @param scriptId 指标id
|
||||
* @param resultType 结果类型
|
||||
* @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 resultType 结果类型
|
||||
* @param time 第几次检测
|
||||
* @return 数据组数
|
||||
*/
|
||||
int getNumOfData(Integer planCode, String monitorId, List<String> scriptId, String resultType, int time);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ 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;
|
||||
|
||||
/**
|
||||
@@ -39,4 +40,27 @@ public interface ContrastNonHarmonicService extends IService<ContrastNonHarmonic
|
||||
*/
|
||||
|
||||
List<ContrastNonHarmonicResult> listAllResultData(String code, Integer num, Integer waveNum, Boolean isWave, String devId, List<String> adTypeList);
|
||||
|
||||
/**
|
||||
* 获取非谐波检测项的比对结果
|
||||
* @param planCode 计划code
|
||||
* @param monitorId 监测点ID
|
||||
* @param scriptId 指标id
|
||||
* @param resultType 结果类型
|
||||
* @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 resultType 结果类型
|
||||
* @param time 第几次检测
|
||||
* @return 数据组数
|
||||
*/
|
||||
int getNumOfData(Integer planCode, String monitorId, List<String> scriptId, String resultType, int time);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
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 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;
|
||||
@@ -11,6 +13,7 @@ import com.njcn.gather.storage.service.ContrastHarmonicService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -45,6 +48,9 @@ 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) {
|
||||
String prefix = "ad_harmonic_result_" + code;
|
||||
@@ -65,4 +71,72 @@ public class ContrastHarmonicServiceImpl extends ServiceImpl<ContrastHarmonicMap
|
||||
DynamicTableNameHandler.remove();
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param planCode 计划code
|
||||
* @param monitorId 监测点ID
|
||||
* @param scriptId 指标id
|
||||
* @param resultType 结果类型
|
||||
* @param time 第几次检测
|
||||
* @return 检测结果
|
||||
*/
|
||||
@Override
|
||||
public ContrastHarmonicResult getContrastResultHarm(Integer planCode, String monitorId, List<String> scriptId, String resultType, int time) {
|
||||
boolean isWave = resultType.contains("wave_data");
|
||||
int waveTime = 1;
|
||||
if (isWave) {
|
||||
// 说明是要进一步拆解type,查询录波的数据
|
||||
// 从 wave_data_1 格式中提取录波次数
|
||||
String[] parts = resultType.split("_");
|
||||
if (parts.length > 2) {
|
||||
waveTime = Integer.parseInt(parts[parts.length - 1]);
|
||||
}
|
||||
}
|
||||
List<ContrastHarmonicResult> result = this.listAllResultData(String.valueOf(planCode), time, waveTime, isWave, monitorId, scriptId);
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
return result.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 去原始表获取总次数
|
||||
* @param planCode 计划code
|
||||
* @param monitorId 监测点ID
|
||||
* @param scriptId 指标id
|
||||
* @param resultType 结果类型
|
||||
* @param time 第几次检测
|
||||
* @return 数据组数
|
||||
*/
|
||||
@Override
|
||||
public int getNumOfData(Integer planCode, String monitorId, List<String> scriptId, String resultType, int time) {
|
||||
String prefix = "ad_harmonic_" + planCode;
|
||||
DynamicTableNameHandler.setTableName(prefix);
|
||||
boolean isWave = resultType.contains("wave_data");
|
||||
int waveTime = 1;
|
||||
if (isWave) {
|
||||
// 说明是要进一步拆解type,查询录波的数据
|
||||
// 从 wave_data_1 格式中提取录波次数
|
||||
String[] parts = resultType.split("_");
|
||||
if (parts.length > 2) {
|
||||
waveTime = Integer.parseInt(parts[parts.length - 1]);
|
||||
}
|
||||
}
|
||||
LambdaQueryChainWrapper<ContrastHarmonicResult> wrapper = this.lambdaQuery()
|
||||
.eq(ContrastHarmonicResult::getDevMonitorId, monitorId)
|
||||
.in(ContrastHarmonicResult::getAdType, scriptId)
|
||||
.eq(ContrastHarmonicResult::getFlag, 0)
|
||||
.eq(ContrastHarmonicResult::getNum, time);
|
||||
if(isWave){
|
||||
wrapper.eq(ContrastHarmonicResult::getDataType, "wave_data")
|
||||
.eq(ContrastHarmonicResult::getWaveNum, waveTime);
|
||||
}else{
|
||||
wrapper.eq(ContrastHarmonicResult::getDataType, resultType);
|
||||
}
|
||||
// 执行查询并统计满足条件的记录数
|
||||
int count = wrapper.count();
|
||||
DynamicTableNameHandler.remove();
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,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 com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@@ -11,6 +12,7 @@ import com.njcn.gather.storage.service.ContrastNonHarmonicService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -65,4 +67,54 @@ public class ContrastNonHarmonicServiceImpl extends ServiceImpl<ContrastNonHarmo
|
||||
DynamicTableNameHandler.remove();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContrastNonHarmonicResult getContrastResultHarm(Integer planCode, String monitorId, List<String> scriptId, String resultType, int time) {
|
||||
boolean isWave = resultType.contains("wave_data");
|
||||
int waveTime = 1;
|
||||
if (isWave) {
|
||||
// 说明是要进一步拆解type,查询录波的数据
|
||||
// 从 wave_data_1 格式中提取录波次数
|
||||
String[] parts = resultType.split("_");
|
||||
if (parts.length > 2) {
|
||||
waveTime = Integer.parseInt(parts[parts.length - 1]);
|
||||
}
|
||||
}
|
||||
List<ContrastNonHarmonicResult> result = this.listAllResultData(String.valueOf(planCode), time, waveTime, isWave, monitorId, scriptId);
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
return result.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumOfData(Integer planCode, String monitorId, List<String> scriptId, String resultType, int time) {
|
||||
String prefix = "ad_non_harmonic_" + planCode;
|
||||
DynamicTableNameHandler.setTableName(prefix);
|
||||
boolean isWave = resultType.contains("wave_data");
|
||||
int waveTime = 1;
|
||||
if (isWave) {
|
||||
// 说明是要进一步拆解type,查询录波的数据
|
||||
// 从 wave_data_1 格式中提取录波次数
|
||||
String[] parts = resultType.split("_");
|
||||
if (parts.length > 2) {
|
||||
waveTime = Integer.parseInt(parts[parts.length - 1]);
|
||||
}
|
||||
}
|
||||
LambdaQueryChainWrapper<ContrastNonHarmonicResult> wrapper = this.lambdaQuery()
|
||||
.eq(ContrastNonHarmonicResult::getDevMonitorId, monitorId)
|
||||
.in(ContrastNonHarmonicResult::getAdType, scriptId)
|
||||
.eq(ContrastNonHarmonicResult::getFlag, 0)
|
||||
.eq(ContrastNonHarmonicResult::getNum, time);
|
||||
if(isWave){
|
||||
wrapper.eq(ContrastNonHarmonicResult::getDataType, "wave_data")
|
||||
.eq(ContrastNonHarmonicResult::getWaveNum, waveTime);
|
||||
}else{
|
||||
wrapper.eq(ContrastNonHarmonicResult::getDataType, resultType);
|
||||
}
|
||||
// 执行查询并统计满足条件的记录数
|
||||
int count = wrapper.count();
|
||||
DynamicTableNameHandler.remove();
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,11 @@ public class TableGenServiceImpl implements TableGenService {
|
||||
@Override
|
||||
public void genTable(String code, boolean isContrast) {
|
||||
tableGenMapper.genNonHarmonicTable(code, isContrast);
|
||||
// 添加索引
|
||||
tableGenMapper.genAdHarmonicTable("CREATE INDEX idx_ad_non_harmonic_" + code + "_dev_monitor_id" + " ON ad_non_harmonic_" + code + " (Dev_Monitor_Id);");
|
||||
tableGenMapper.genNonHarmonicResultTable(code, isContrast);
|
||||
// 添加索引
|
||||
tableGenMapper.genAdHarmonicTable("CREATE INDEX idx_ad_non_harmonic_result_" + code + "_dev_monitor_id" + " ON ad_non_harmonic_result_" + code + " (Dev_Monitor_Id);");
|
||||
|
||||
StringBuilder A = new StringBuilder();
|
||||
StringBuilder B = new StringBuilder();
|
||||
@@ -57,6 +61,8 @@ public class TableGenServiceImpl implements TableGenService {
|
||||
" PRIMARY KEY (Dev_Monitor_Id, Time_Id, Script_Id, Sort, AD_Type)\n"
|
||||
) + ") COMMENT='谐波类原始数据表';";
|
||||
tableGenMapper.genAdHarmonicTable(sql);
|
||||
// 添加索引
|
||||
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");
|
||||
@@ -84,6 +90,8 @@ public class TableGenServiceImpl implements TableGenService {
|
||||
" PRIMARY KEY (Dev_Monitor_Id,Script_Id, Sort, AD_Type)\n"
|
||||
) + ") COMMENT='谐波类检测结果表';";
|
||||
tableGenMapper.genAdHarmonicTable(sql2);
|
||||
// 添加索引
|
||||
tableGenMapper.genAdHarmonicTable("CREATE INDEX idx_ad_harmonic_result_" + code + "_dev_monitor_id" + " ON ad_harmonic_result_" + code + " (Dev_Monitor_Id);");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user