间谐波电压取基波有效值、角型接线时若不存在线电压指标则使用相电压指标、表结构调整以记录配对关系

This commit is contained in:
caozehui
2025-08-21 10:13:16 +08:00
parent ddf6da0855
commit b4bd2e6d1d
30 changed files with 815 additions and 552 deletions

View File

@@ -38,7 +38,7 @@ public class DataDealController extends BaseController {
SimAndDigHarmonicResult.setDataType("aa");
SimAndDigHarmonicResult.setAdType("aaaa");
SimAndDigHarmonicResult.setMonitorId("ss");
SimAndDigHarmonicResult.setDevMonitorId("ss");
SimAndDigHarmonicResult.setScriptId("ddd");
SimAndDigHarmonicResult.setTimeId(LocalDateTime.now());
@@ -47,12 +47,12 @@ public class DataDealController extends BaseController {
SimAndDigHarmonicResult2.setDataType("aabb");
SimAndDigHarmonicResult2.setAdType("aaaabb");
SimAndDigHarmonicResult2.setMonitorId("ssbb");
SimAndDigHarmonicResult2.setDevMonitorId("ssbb");
SimAndDigHarmonicResult2.setScriptId("dddbb");
SimAndDigHarmonicResult2.setTimeId(LocalDateTime.now());
list2.add(SimAndDigHarmonicResult2);
detectionDataDealService.acceptAd(list2,"1");
detectionDataDealService.acceptHarmonic(list2,"1");
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);

View File

@@ -4,26 +4,31 @@
<update id="genNonHarmonicTable">
CREATE TABLE ad_non_harmonic_${code}
(
Monitor_Id CHAR(34) NOT NULL COMMENT '监测点Id',
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相值(没有相别的则存这里)',
Result_Flag int(1) NULL COMMENT '1合格 2不合格 4无法处理',
<choose>
<when test="isContrast">
Num tinyint(1) unsigned DEFAULT 0 COMMENT '第几次检测',
PRIMARY KEY (Monitor_Id, Time_Id, AD_Type, Num)
</when>
<otherwise>
Script_Id CHAR(32) NOT NULL COMMENT '检测脚本表Id',
Sort int(4) NOT NULL COMMENT '总检测脚本中的测试项序号',
PRIMARY KEY (Monitor_Id, Time_Id, Script_Id, Sort, AD_Type)
</otherwise>
</choose>
Dev_Monitor_Id CHAR(34) NOT NULL COMMENT '监测点Id',
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相值(没有相别的则存这里)',
Result_Flag int(1) NULL COMMENT '1合格 2不合格 4无法处理',
<choose>
<when test="isContrast">
Id char(32) COLLATE utf8mb4_bin NOT NULL COMMENT '主键Id',
Std_Dev_Monitor_Id CHAR(34) NOT NULL COMMENT '标准设备监测点Id',
Num tinyint(1) unsigned DEFAULT 0 COMMENT '第几次检测',
A_Value_0 float NULL COMMENT 'A相基波有效值',
B_Value_0 float NULL COMMENT 'B相基波有效值',
C_Value_0 float NULL COMMENT 'B相基波有效值',
PRIMARY KEY (Id)
</when>
<otherwise>
Script_Id CHAR(32) NOT NULL COMMENT '检测脚本表Id',
Sort int(4) NOT NULL COMMENT '总检测脚本中的测试项序号',
PRIMARY KEY (Monitor_Id, Time_Id, Script_Id, Sort, AD_Type)
</otherwise>
</choose>
) COMMENT='非谐波类原始数据表';
</update>
@@ -35,27 +40,32 @@
<update id="genNonHarmonicResultTable">
CREATE TABLE if not exists ad_non_harmonic_result_${code} (
Monitor_Id CHAR(34) NOT NULL COMMENT '监测点Id',
Time_Id DATETIME NULL COMMENT '时间',
AD_Type CHAR(32) NOT NULL COMMENT '检测指标,字典表',
Data_Type CHAR(32) NOT NULL COMMENT '数据指标只有数据源为分钟统计时候才会使用最大、最小、平均、CP95默认平均值字典表',
A_Value json NULL COMMENT 'A相值',
B_Value json NULL COMMENT 'B相值',
C_Value json NULL COMMENT 'C相值',
T_Value json NULL COMMENT 'T相值(没有相别的则存这里)',
Result_Flag int(1) NOT NULL COMMENT '1合格 2不合格 4无法处理',
<choose>
<when test="isContrast">
Num tinyint(1) unsigned DEFAULT 0 COMMENT '第几次检测',
PRIMARY KEY (Monitor_Id, AD_Type, Num)
</when>
<otherwise>
Script_Id CHAR(32) NOT NULL COMMENT '检测脚本表Id',
Sort int(4) NOT NULL COMMENT '总检测脚本中的测试项序号',
PRIMARY KEY (Monitor_Id, Script_Id, Sort, AD_Type)
</otherwise>
</choose>
) COMMENT='非谐波类检测结果表';
Dev_Monitor_Id CHAR(34) NOT NULL COMMENT '监测点Id',
Time_Id DATETIME NULL COMMENT '时间',
AD_Type CHAR(32) NOT NULL COMMENT '检测指标,字典表',
Data_Type CHAR(32) NOT NULL COMMENT '数据指标只有数据源为分钟统计时候才会使用最大、最小、平均、CP95默认平均值字典表',
A_Value json NULL COMMENT 'A相值',
B_Value json NULL COMMENT 'B相值',
C_Value json NULL COMMENT 'C相值',
T_Value json NULL COMMENT 'T相值(没有相别的则存这里)',
Result_Flag int(1) NOT NULL COMMENT '1合格 2不合格 4无法处理',
<choose>
<when test="isContrast">
Id char(32) COLLATE utf8mb4_bin NOT NULL COMMENT '主键Id',
Std_Dev_Monitor_Id CHAR(34) NOT NULL COMMENT '标准设备监测点Id',
Num tinyint(1) unsigned DEFAULT 0 COMMENT '第几次检测',
A_Value_0 json NULL COMMENT 'A相基波有效值',
B_Value_0 json NULL COMMENT 'B相基波有效值',
C_Value_0 json NULL COMMENT 'B相基波有效值',
PRIMARY KEY (Id)
</when>
<otherwise>
Script_Id CHAR(32) NOT NULL COMMENT '检测脚本表Id',
Sort int(4) NOT NULL COMMENT '总检测脚本中的测试项序号',
PRIMARY KEY (Monitor_Id, Script_Id, Sort, AD_Type)
</otherwise>
</choose>
) COMMENT='非谐波类检测结果表';
</update>

View File

@@ -13,7 +13,7 @@ public class BaseResult {
/**
* 监测点Id
*/
private String monitorId;
private String devMonitorId;
/**
* 时间

View File

@@ -10,8 +10,15 @@ import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = true)
public class ContrastBaseResult extends BaseResult {
private String id;
/**
* 第几次检测
*/
private Integer num;
/**
* 标准设备监测点id
*/
private String stdDevMonitorId;
}

View File

@@ -15,6 +15,15 @@ import lombok.EqualsAndHashCode;
public class ContrastHarmonicResult extends ContrastBaseResult {
private static final long serialVersionUID = 1L;
@TableField(value = "A_Value_0")
private String aValue0;
@TableField(value = "B_Value_0")
private String bValue0;
@TableField(value = "C_Value_0")
private String cValue0;
/**
* A相基波
*/

View File

@@ -13,9 +13,9 @@ public interface DetectionDataDealService extends IReplenishMybatisService<SimAn
Boolean acceptAdNon(List<? extends BaseResult> nonHarmonicResultList,String code);
Boolean acceptNonHarmonic(List<? extends BaseResult> nonHarmonicResultList,String code);
Boolean acceptAd(List<? extends BaseResult> harmonicResultList,String code);
Boolean acceptHarmonic(List<? extends BaseResult> harmonicResultList,String code);
Boolean acceptNonHarmonicResult(List<? extends BaseResult> nonHarmonicResultList, String code);
@@ -23,10 +23,12 @@ public interface DetectionDataDealService extends IReplenishMybatisService<SimAn
/**
* 根据终端id查询终端所有监测项目是否合格
*
* @param isContrast
* @param ids
* @param valueType
* @param adType
* @param code
* @return
*/
Map<String,Integer> devResult(List<String> ids,List<String> valueType,String code);
Map<String,Integer> devResult(boolean isContrast,List<String> ids,List<String> adType,String code);
}

View File

@@ -36,16 +36,16 @@ public class DetectionDataServiceImpl extends ReplenishMybatisServiceImpl<Detect
@Override
@Transactional
public Boolean acceptAdNon(List<? extends BaseResult> nonHarmonicResultList, String code) {
public Boolean acceptNonHarmonic(List<? extends BaseResult> nonHarmonicResultList, String code) {
if (CollUtil.isNotEmpty(nonHarmonicResultList)) {
String adNonTable = "ad_non_harmonic_";
DynamicTableNameHandler.setTableName(adNonTable + code);
if (nonHarmonicResultList.get(0) instanceof SimAndDigNonHarmonicResult) {
List<SimAndDigNonHarmonicResult> simAndDigNonHarmonicResults = BeanUtil.copyToList(nonHarmonicResultList, SimAndDigNonHarmonicResult.class);
List<String> monitorIds = simAndDigNonHarmonicResults.stream().map(SimAndDigNonHarmonicResult::getMonitorId).distinct().collect(Collectors.toList());
List<String> monitorIds = simAndDigNonHarmonicResults.stream().map(SimAndDigNonHarmonicResult::getDevMonitorId).distinct().collect(Collectors.toList());
if (CollUtil.isNotEmpty(monitorIds)) {
simAndDigNonHarmonicService.remove(new LambdaQueryWrapper<SimAndDigNonHarmonicResult>().in(SimAndDigNonHarmonicResult::getMonitorId, monitorIds)
simAndDigNonHarmonicService.remove(new LambdaQueryWrapper<SimAndDigNonHarmonicResult>().in(SimAndDigNonHarmonicResult::getDevMonitorId, monitorIds)
.eq(SimAndDigNonHarmonicResult::getScriptId, simAndDigNonHarmonicResults.get(0).getScriptId())
.eq(SimAndDigNonHarmonicResult::getSort, simAndDigNonHarmonicResults.get(0).getSort()));
simAndDigNonHarmonicService.saveBatch(simAndDigNonHarmonicResults, 100);
@@ -54,12 +54,7 @@ public class DetectionDataServiceImpl extends ReplenishMybatisServiceImpl<Detect
if (nonHarmonicResultList.get(0) instanceof ContrastNonHarmonicResult) {
List<ContrastNonHarmonicResult> contrastNonHarmonicResults = BeanUtil.copyToList(nonHarmonicResultList, ContrastNonHarmonicResult.class);
List<String> monitorIds = contrastNonHarmonicResults.stream().map(ContrastNonHarmonicResult::getMonitorId).distinct().collect(Collectors.toList());
if (CollUtil.isNotEmpty(monitorIds)) {
contrastNonHarmonicService.remove(new LambdaQueryWrapper<ContrastNonHarmonicResult>().in(ContrastNonHarmonicResult::getMonitorId, monitorIds)
.eq(ContrastNonHarmonicResult::getNum, contrastNonHarmonicResults.get(0).getNum()));
contrastNonHarmonicService.saveBatch(contrastNonHarmonicResults, 100);
}
contrastNonHarmonicService.saveBatch(contrastNonHarmonicResults);
}
DynamicTableNameHandler.remove();
@@ -70,30 +65,25 @@ public class DetectionDataServiceImpl extends ReplenishMybatisServiceImpl<Detect
@Override
@Transactional
public Boolean acceptAd(List<? extends BaseResult> harmonicResultList, String code) {
public Boolean acceptHarmonic(List<? extends BaseResult> harmonicResultList, String code) {
if (CollUtil.isNotEmpty(harmonicResultList)) {
String adTable = "ad_harmonic_";
DynamicTableNameHandler.setTableName(adTable + code);
if (harmonicResultList.get(0) instanceof SimAndDigHarmonicResult) {
List<SimAndDigHarmonicResult> simAndDigHarmonicResultList = BeanUtil.copyToList(harmonicResultList, SimAndDigHarmonicResult.class);
List<String> monitorIds = simAndDigHarmonicResultList.stream().map(SimAndDigHarmonicResult::getMonitorId).distinct().collect(Collectors.toList());
List<String> monitorIds = simAndDigHarmonicResultList.stream().map(SimAndDigHarmonicResult::getDevMonitorId).distinct().collect(Collectors.toList());
if (CollUtil.isNotEmpty(monitorIds)) {
simAndDigHarmonicService.remove(new LambdaQueryWrapper<SimAndDigHarmonicResult>().in(SimAndDigHarmonicResult::getMonitorId, monitorIds)
simAndDigHarmonicService.remove(new LambdaQueryWrapper<SimAndDigHarmonicResult>().in(SimAndDigHarmonicResult::getDevMonitorId, monitorIds)
.eq(SimAndDigHarmonicResult::getScriptId, simAndDigHarmonicResultList.get(0).getScriptId())
.eq(SimAndDigHarmonicResult::getSort, simAndDigHarmonicResultList.get(0).getSort()));
simAndDigHarmonicService.saveBatch(simAndDigHarmonicResultList, 100);
simAndDigHarmonicService.saveBatch(simAndDigHarmonicResultList);
}
}
if (harmonicResultList.get(0) instanceof ContrastHarmonicResult) {
List<ContrastHarmonicResult> contrastHarmonicResultList = BeanUtil.copyToList(harmonicResultList, ContrastHarmonicResult.class);
List<String> monitorIds = contrastHarmonicResultList.stream().map(ContrastHarmonicResult::getMonitorId).distinct().collect(Collectors.toList());
if (CollUtil.isNotEmpty(monitorIds)) {
contrastHarmonicService.remove(new LambdaQueryWrapper<ContrastHarmonicResult>().in(ContrastHarmonicResult::getMonitorId, monitorIds)
.eq(ContrastHarmonicResult::getNum, contrastHarmonicResultList.get(0).getNum()));
contrastHarmonicService.saveBatch(contrastHarmonicResultList, 100);
}
contrastHarmonicService.saveBatch(contrastHarmonicResultList);
}
DynamicTableNameHandler.remove();
@@ -110,9 +100,9 @@ public class DetectionDataServiceImpl extends ReplenishMybatisServiceImpl<Detect
DynamicTableNameHandler.setTableName(adNonTableResult + code);
if (nonHarmonicResultList.get(0) instanceof SimAndDigNonHarmonicResult) {
List<SimAndDigNonHarmonicResult> simAndDigNonHarmonicResultList = BeanUtil.copyToList(nonHarmonicResultList, SimAndDigNonHarmonicResult.class);
List<String> monitorIds = simAndDigNonHarmonicResultList.stream().map(SimAndDigNonHarmonicResult::getMonitorId).distinct().collect(Collectors.toList());
List<String> monitorIds = simAndDigNonHarmonicResultList.stream().map(SimAndDigNonHarmonicResult::getDevMonitorId).distinct().collect(Collectors.toList());
if (CollUtil.isNotEmpty(monitorIds)) {
simAndDigNonHarmonicService.remove(new LambdaQueryWrapper<SimAndDigNonHarmonicResult>().in(SimAndDigNonHarmonicResult::getMonitorId, monitorIds)
simAndDigNonHarmonicService.remove(new LambdaQueryWrapper<SimAndDigNonHarmonicResult>().in(SimAndDigNonHarmonicResult::getDevMonitorId, monitorIds)
.eq(SimAndDigNonHarmonicResult::getScriptId, simAndDigNonHarmonicResultList.get(0).getScriptId())
.eq(SimAndDigNonHarmonicResult::getSort, simAndDigNonHarmonicResultList.get(0).getSort()));
simAndDigNonHarmonicService.saveBatch(simAndDigNonHarmonicResultList, 100);
@@ -120,13 +110,8 @@ public class DetectionDataServiceImpl extends ReplenishMybatisServiceImpl<Detect
}
if (nonHarmonicResultList.get(0) instanceof ContrastNonHarmonicResult) {
List<ContrastNonHarmonicResult> contrastNonHarmonicResultList = BeanUtil.copyToList(nonHarmonicResultList, ContrastNonHarmonicResult.class);
List<String> monitorIds = contrastNonHarmonicResultList.stream().map(ContrastNonHarmonicResult::getMonitorId).distinct().collect(Collectors.toList());
if (CollUtil.isNotEmpty(monitorIds)) {
contrastNonHarmonicService.remove(new LambdaQueryWrapper<ContrastNonHarmonicResult>().in(ContrastNonHarmonicResult::getMonitorId, monitorIds)
.eq(ContrastNonHarmonicResult::getAdType, contrastNonHarmonicResultList.get(0).getAdType())
.eq(ContrastNonHarmonicResult::getNum, contrastNonHarmonicResultList.get(0).getNum()));
contrastNonHarmonicService.saveBatch(contrastNonHarmonicResultList, 100);
}
contrastNonHarmonicService.saveBatch(contrastNonHarmonicResultList);
}
DynamicTableNameHandler.remove();
}
@@ -141,9 +126,9 @@ public class DetectionDataServiceImpl extends ReplenishMybatisServiceImpl<Detect
DynamicTableNameHandler.setTableName(adTableResult + code);
if (harmonicResultList.get(0) instanceof SimAndDigHarmonicResult) {
List<SimAndDigHarmonicResult> simAndDigHarmonicResultList = BeanUtil.copyToList(harmonicResultList, SimAndDigHarmonicResult.class);
List<String> monitorIds = simAndDigHarmonicResultList.stream().map(SimAndDigHarmonicResult::getMonitorId).distinct().collect(Collectors.toList());
List<String> monitorIds = simAndDigHarmonicResultList.stream().map(SimAndDigHarmonicResult::getDevMonitorId).distinct().collect(Collectors.toList());
if (CollUtil.isNotEmpty(monitorIds)) {
simAndDigHarmonicService.remove(new LambdaQueryWrapper<SimAndDigHarmonicResult>().in(SimAndDigHarmonicResult::getMonitorId, monitorIds)
simAndDigHarmonicService.remove(new LambdaQueryWrapper<SimAndDigHarmonicResult>().in(SimAndDigHarmonicResult::getDevMonitorId, monitorIds)
.eq(SimAndDigHarmonicResult::getScriptId, simAndDigHarmonicResultList.get(0).getScriptId())
.eq(SimAndDigHarmonicResult::getSort, simAndDigHarmonicResultList.get(0).getSort()));
simAndDigHarmonicService.saveBatch(simAndDigHarmonicResultList, 100);
@@ -152,13 +137,7 @@ public class DetectionDataServiceImpl extends ReplenishMybatisServiceImpl<Detect
if (harmonicResultList.get(0) instanceof ContrastHarmonicResult) {
List<ContrastHarmonicResult> contrastHarmonicResultList = BeanUtil.copyToList(harmonicResultList, ContrastHarmonicResult.class);
List<String> monitorIds = contrastHarmonicResultList.stream().map(ContrastHarmonicResult::getMonitorId).distinct().collect(Collectors.toList());
if (CollUtil.isNotEmpty(monitorIds)) {
contrastHarmonicService.remove(new LambdaQueryWrapper<ContrastHarmonicResult>().in(ContrastHarmonicResult::getMonitorId, monitorIds)
.eq(ContrastHarmonicResult::getAdType, contrastHarmonicResultList.get(0).getAdType())
.eq(ContrastHarmonicResult::getNum, contrastHarmonicResultList.get(0).getNum()));
contrastHarmonicService.saveBatch(contrastHarmonicResultList, 100);
}
contrastHarmonicService.saveBatch(contrastHarmonicResultList);
}
DynamicTableNameHandler.remove();
return true;
@@ -167,33 +146,56 @@ public class DetectionDataServiceImpl extends ReplenishMybatisServiceImpl<Detect
}
@Override
public Map<String, Integer> devResult(List<String> ids, List<String> valueType, String code) {
List<Integer> disabledScriptDtlIndexs = detectionDataDealMapper.listDisabledScriptDtlIndexs(ids.get(0));
List<SimAndDigNonHarmonicResult> noHarm = new ArrayList<>();
for (String id : ids) {
DynamicTableNameHandler.setTableName("ad_non_harmonic_result_" + code);
noHarm.addAll(simAndDigNonHarmonicService.list(new LambdaQueryWrapper<SimAndDigNonHarmonicResult>()
.like(SimAndDigNonHarmonicResult::getMonitorId, id)
.notIn(CollUtil.isNotEmpty(disabledScriptDtlIndexs), SimAndDigNonHarmonicResult::getSort, disabledScriptDtlIndexs)
.in(CollUtil.isNotEmpty(valueType), SimAndDigNonHarmonicResult::getAdType, valueType)
));
}
DynamicTableNameHandler.remove();
List<SimAndDigHarmonicResult> harm = new ArrayList<>();
for (String id : ids) {
DynamicTableNameHandler.setTableName("ad_harmonic_result_" + code);
harm.addAll(this.list(new LambdaQueryWrapper<SimAndDigHarmonicResult>()
.like(SimAndDigHarmonicResult::getMonitorId, id)
.notIn(CollUtil.isNotEmpty(disabledScriptDtlIndexs), SimAndDigHarmonicResult::getSort, disabledScriptDtlIndexs)
.in(CollUtil.isNotEmpty(valueType), SimAndDigHarmonicResult::getAdType, valueType)
));
}
DynamicTableNameHandler.remove();
Map<String, List<Integer>> noHarmMap = noHarm.stream().collect(Collectors.groupingBy(x -> x.getMonitorId().split("_")[0],
Collectors.mapping(SimAndDigNonHarmonicResult::getResultFlag, Collectors.toList())));
Map<String, List<Integer>> harmMap = harm.stream().collect(Collectors.groupingBy(x -> x.getMonitorId().split("_")[0],
Collectors.mapping(SimAndDigHarmonicResult::getResultFlag, Collectors.toList())));
public Map<String, Integer> devResult(boolean isContrast, List<String> ids, List<String> adType, String code) {
Map<String, Integer> map = new HashMap<>(2);
List<BaseResult> noHarm = new ArrayList<>();
List<BaseResult> harm = new ArrayList<>();
if (isContrast) {
DynamicTableNameHandler.setTableName("ad_non_harmonic_result_" + code);
LambdaQueryWrapper<ContrastNonHarmonicResult> wrapper1 = new LambdaQueryWrapper<ContrastNonHarmonicResult>()
.in(CollUtil.isNotEmpty(adType), ContrastNonHarmonicResult::getAdType, adType);
for (String id : ids) {
wrapper1.like(ContrastNonHarmonicResult::getDevMonitorId, id);
}
noHarm.addAll(contrastNonHarmonicService.list(wrapper1));
DynamicTableNameHandler.remove();
DynamicTableNameHandler.setTableName("ad_harmonic_result_" + code);
LambdaQueryWrapper<ContrastHarmonicResult> wrapper2 = new LambdaQueryWrapper<ContrastHarmonicResult>()
.in(CollUtil.isNotEmpty(adType), ContrastHarmonicResult::getAdType, adType);
for (String id : ids) {
wrapper2.like(ContrastHarmonicResult::getDevMonitorId, id);
}
harm.addAll(contrastHarmonicService.list(wrapper2));
DynamicTableNameHandler.remove();
} else {
List<Integer> disabledScriptDtlIndexs = detectionDataDealMapper.listDisabledScriptDtlIndexs(ids.get(0));
DynamicTableNameHandler.setTableName("ad_non_harmonic_result_" + code);
LambdaQueryWrapper<SimAndDigNonHarmonicResult> wrapper1 = new LambdaQueryWrapper<SimAndDigNonHarmonicResult>()
.notIn(CollUtil.isNotEmpty(disabledScriptDtlIndexs), SimAndDigNonHarmonicResult::getSort, disabledScriptDtlIndexs)
.in(CollUtil.isNotEmpty(adType), SimAndDigNonHarmonicResult::getAdType, adType);
for (String id : ids) {
wrapper1.like(SimAndDigNonHarmonicResult::getDevMonitorId, id);
}
noHarm.addAll(simAndDigNonHarmonicService.list(wrapper1));
DynamicTableNameHandler.remove();
DynamicTableNameHandler.setTableName("ad_harmonic_result_" + code);
LambdaQueryWrapper<SimAndDigHarmonicResult> wrapper2 = new LambdaQueryWrapper<SimAndDigHarmonicResult>()
.notIn(CollUtil.isNotEmpty(disabledScriptDtlIndexs), SimAndDigHarmonicResult::getSort, disabledScriptDtlIndexs)
.in(CollUtil.isNotEmpty(adType), SimAndDigHarmonicResult::getAdType, adType);
for (String id : ids) {
wrapper2.like(SimAndDigHarmonicResult::getDevMonitorId, id);
}
harm.addAll(this.list(wrapper2));
DynamicTableNameHandler.remove();
}
Map<String, List<Integer>> noHarmMap = noHarm.stream().collect(Collectors.groupingBy(x -> x.getDevMonitorId().split("_")[0],
Collectors.mapping(BaseResult::getResultFlag, Collectors.toList())));
Map<String, List<Integer>> harmMap = harm.stream().collect(Collectors.groupingBy(x -> x.getDevMonitorId().split("_")[0],
Collectors.mapping(BaseResult::getResultFlag, Collectors.toList())));
for (String id : ids) {
List<Integer> resultFlags = new ArrayList<>();
if (noHarmMap.containsKey(id)) {

View File

@@ -57,7 +57,7 @@ public class SimAndDigHarmonicServiceImpl extends ServiceImpl<SimAndDigHarmonicM
if ("-1".equals(chnNum)) {
monitorId = deviceId;
}
wrapper.like(SimAndDigHarmonicResult::getMonitorId, monitorId)
wrapper.like(SimAndDigHarmonicResult::getDevMonitorId, monitorId)
.eq(ObjectUtil.isNotNull(scriptId), SimAndDigHarmonicResult::getScriptId, scriptId)
.in(CollUtil.isNotEmpty(sort), SimAndDigHarmonicResult::getSort, sort);
List<SimAndDigHarmonicResult> list = this.getBaseMapper().selectJoinList(SimAndDigHarmonicResult.class, wrapper);
@@ -70,7 +70,7 @@ public class SimAndDigHarmonicServiceImpl extends ServiceImpl<SimAndDigHarmonicM
String prefix = "ad_harmonic_";
DynamicTableNameHandler.setTableName(prefix + param.getCode());
MPJLambdaWrapper<SimAndDigHarmonicResult> wrapper = new MPJLambdaWrapper<>();
wrapper.like(SimAndDigHarmonicResult::getMonitorId, param.getDevId() + "_" + param.getDevNum())
wrapper.like(SimAndDigHarmonicResult::getDevMonitorId, param.getDevId() + "_" + param.getDevNum())
.eq(ObjectUtil.isNotNull(param.getScriptId()), SimAndDigHarmonicResult::getScriptId, param.getScriptId())
.in(ObjectUtil.isNotEmpty(param.getIndex()), SimAndDigHarmonicResult::getSort, param.getIndex())
.orderByAsc(SimAndDigHarmonicResult::getTimeId)
@@ -137,7 +137,7 @@ public class SimAndDigHarmonicServiceImpl extends ServiceImpl<SimAndDigHarmonicM
String prefix = "ad_harmonic_result_";
DynamicTableNameHandler.setTableName(prefix + param.getCode());
MPJLambdaWrapper<SimAndDigHarmonicResult> wrapper = new MPJLambdaWrapper<>();
wrapper.like(SimAndDigHarmonicResult::getMonitorId, param.getDevId() + "_" + param.getDevNum())
wrapper.like(SimAndDigHarmonicResult::getDevMonitorId, param.getDevId() + "_" + param.getDevNum())
.eq(ObjectUtil.isNotNull(param.getScriptId()), SimAndDigHarmonicResult::getScriptId, param.getScriptId())
.in(ObjectUtil.isNotEmpty(param.getIndex()), SimAndDigHarmonicResult::getSort, param.getIndex())
.orderByAsc(SimAndDigHarmonicResult::getTimeId);
@@ -207,7 +207,7 @@ public class SimAndDigHarmonicServiceImpl extends ServiceImpl<SimAndDigHarmonicM
DynamicTableNameHandler.setTableName(prefix + param.getCode());
LambdaQueryWrapper<SimAndDigHarmonicResult> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.select(SimAndDigHarmonicResult::getSort)
.likeRight(StrUtil.isNotBlank(param.getDevId()), SimAndDigHarmonicResult::getMonitorId, param.getDevId())
.likeRight(StrUtil.isNotBlank(param.getDevId()), SimAndDigHarmonicResult::getDevMonitorId, param.getDevId())
.ne(SimAndDigHarmonicResult::getResultFlag, 1)
.ne(SimAndDigHarmonicResult::getResultFlag, 4)
.ne(SimAndDigHarmonicResult::getResultFlag, 5)
@@ -218,7 +218,7 @@ public class SimAndDigHarmonicServiceImpl extends ServiceImpl<SimAndDigHarmonicM
DynamicTableNameHandler.setTableName(prefixNon + param.getCode());
LambdaQueryWrapper<SimAndDigNonHarmonicResult> resultLambdaQueryWrapper = new LambdaQueryWrapper<>();
resultLambdaQueryWrapper.select(SimAndDigNonHarmonicResult::getSort)
.likeRight(StrUtil.isNotBlank(param.getDevId()), SimAndDigNonHarmonicResult::getMonitorId, param.getDevId())
.likeRight(StrUtil.isNotBlank(param.getDevId()), SimAndDigNonHarmonicResult::getDevMonitorId, param.getDevId())
.ne(SimAndDigNonHarmonicResult::getResultFlag, 1)
.ne(SimAndDigNonHarmonicResult::getResultFlag, 4)
.ne(SimAndDigNonHarmonicResult::getResultFlag, 5)
@@ -235,7 +235,7 @@ public class SimAndDigHarmonicServiceImpl extends ServiceImpl<SimAndDigHarmonicM
String prefix = "ad_harmonic_result_";
DynamicTableNameHandler.setTableName(prefix + singleNonHarmParam.getPlanCode());
MPJLambdaWrapper<SimAndDigHarmonicResult> wrapper = new MPJLambdaWrapper<>();
wrapper.like(SimAndDigHarmonicResult::getMonitorId, singleNonHarmParam.getDevId() + "_" + singleNonHarmParam.getChannelNo())
wrapper.like(SimAndDigHarmonicResult::getDevMonitorId, singleNonHarmParam.getDevId() + "_" + singleNonHarmParam.getChannelNo())
.eq(SimAndDigHarmonicResult::getSort, singleNonHarmParam.getSort())
.eq(SimAndDigHarmonicResult::getAdType, singleNonHarmParam.getAdType());
List<SimAndDigHarmonicResult> adHarmonicResults = this.getBaseMapper().selectJoinList(SimAndDigHarmonicResult.class, wrapper);
@@ -255,7 +255,7 @@ public class SimAndDigHarmonicServiceImpl extends ServiceImpl<SimAndDigHarmonicM
wrapper.selectAll(SimAndDigHarmonicResult.class)
.selectAs(DictTree::getCode, SimAndDigHarmonicResult::getAdType)
.leftJoin(DictTree.class, DictTree::getId, SimAndDigHarmonicResult::getAdType).eq(SimAndDigHarmonicResult::getScriptId, scriptId)
.likeRight(SimAndDigHarmonicResult::getMonitorId, devId);
.likeRight(SimAndDigHarmonicResult::getDevMonitorId, devId);
List<SimAndDigHarmonicResult> results = this.getBaseMapper().selectJoinList(SimAndDigHarmonicResult.class, wrapper);
DynamicTableNameHandler.remove();
return results;
@@ -269,7 +269,7 @@ public class SimAndDigHarmonicServiceImpl extends ServiceImpl<SimAndDigHarmonicM
wrapper.selectAll(SimAndDigHarmonicResult.class)
.selectAs(DictTree::getCode, SimAndDigHarmonicResult::getAdType)
.leftJoin(DictTree.class, DictTree::getId, SimAndDigHarmonicResult::getAdType).eq(SimAndDigHarmonicResult::getScriptId, scriptId)
.likeRight(SimAndDigHarmonicResult::getMonitorId, devId);
.likeRight(SimAndDigHarmonicResult::getDevMonitorId, devId);
List<SimAndDigHarmonicResult> results = this.getBaseMapper().selectJoinList(SimAndDigHarmonicResult.class, wrapper);
DynamicTableNameHandler.remove();
return results;

View File

@@ -48,7 +48,7 @@ public class SimAndDigNonHarmonicServiceImpl extends ServiceImpl<SimAndDigNonHar
if ("-1".equals(chnNum)) {
monitorId = deviceId;
}
wrapper.like(SimAndDigNonHarmonicResult::getMonitorId, monitorId)
wrapper.like(SimAndDigNonHarmonicResult::getDevMonitorId, monitorId)
.eq(ObjectUtil.isNotNull(scriptId), SimAndDigNonHarmonicResult::getScriptId, scriptId)
.in(CollUtil.isNotEmpty(sort), SimAndDigNonHarmonicResult::getSort, sort);
List<SimAndDigNonHarmonicResult> list = this.getBaseMapper().selectJoinList(SimAndDigNonHarmonicResult.class, wrapper);
@@ -61,7 +61,7 @@ public class SimAndDigNonHarmonicServiceImpl extends ServiceImpl<SimAndDigNonHar
String prefix = "ad_non_harmonic_";
DynamicTableNameHandler.setTableName(prefix + param.getCode());
MPJLambdaWrapper<SimAndDigNonHarmonicResult> wrapper = new MPJLambdaWrapper<>();
wrapper.like(SimAndDigNonHarmonicResult::getMonitorId, param.getDevId() + "_" + param.getDevNum())
wrapper.like(SimAndDigNonHarmonicResult::getDevMonitorId, param.getDevId() + "_" + param.getDevNum())
.eq(ObjectUtil.isNotNull(param.getScriptId()), SimAndDigNonHarmonicResult::getScriptId, param.getScriptId())
.in(ObjectUtil.isNotEmpty(param.getIndex()), SimAndDigNonHarmonicResult::getSort, param.getIndex());
List<SimAndDigNonHarmonicResult> SimAndDigHarmonicResults = this.getBaseMapper().selectJoinList(SimAndDigNonHarmonicResult.class, wrapper);
@@ -95,7 +95,7 @@ public class SimAndDigNonHarmonicServiceImpl extends ServiceImpl<SimAndDigNonHar
String prefix = "ad_non_harmonic_result_";
DynamicTableNameHandler.setTableName(prefix + param.getCode());
MPJLambdaWrapper<SimAndDigNonHarmonicResult> wrapper = new MPJLambdaWrapper<>();
wrapper.like(SimAndDigNonHarmonicResult::getMonitorId, param.getDevId() + "_" + param.getDevNum())
wrapper.like(SimAndDigNonHarmonicResult::getDevMonitorId, param.getDevId() + "_" + param.getDevNum())
.eq(ObjectUtil.isNotNull(param.getScriptId()), SimAndDigNonHarmonicResult::getScriptId, param.getScriptId())
.in(ObjectUtil.isNotEmpty(param.getIndex()), SimAndDigNonHarmonicResult::getSort, param.getIndex());
@@ -141,7 +141,7 @@ public class SimAndDigNonHarmonicServiceImpl extends ServiceImpl<SimAndDigNonHar
String prefix = "ad_non_harmonic_result_";
DynamicTableNameHandler.setTableName(prefix + singleNonHarmParam.getPlanCode());
MPJLambdaWrapper<SimAndDigNonHarmonicResult> wrapper = new MPJLambdaWrapper<>();
wrapper.like(SimAndDigNonHarmonicResult::getMonitorId, singleNonHarmParam.getDevId() + "_" + singleNonHarmParam.getChannelNo())
wrapper.like(SimAndDigNonHarmonicResult::getDevMonitorId, singleNonHarmParam.getDevId() + "_" + singleNonHarmParam.getChannelNo())
.eq(SimAndDigNonHarmonicResult::getSort, singleNonHarmParam.getSort())
.eq(SimAndDigNonHarmonicResult::getAdType, singleNonHarmParam.getAdType());
List<SimAndDigNonHarmonicResult> SimAndDigHarmonicResults = this.getBaseMapper().selectJoinList(SimAndDigNonHarmonicResult.class, wrapper);
@@ -161,7 +161,7 @@ public class SimAndDigNonHarmonicServiceImpl extends ServiceImpl<SimAndDigNonHar
.selectAs(DictTree::getCode, SimAndDigNonHarmonicResult::getAdType)
.leftJoin(DictTree.class, DictTree::getId, SimAndDigNonHarmonicResult::getAdType)
.eq(SimAndDigNonHarmonicResult::getScriptId, scriptId)
.likeRight(SimAndDigNonHarmonicResult::getMonitorId, devId);
.likeRight(SimAndDigNonHarmonicResult::getDevMonitorId, devId);
List<SimAndDigNonHarmonicResult> results = this.getBaseMapper().selectJoinList(SimAndDigNonHarmonicResult.class, wrapper);
DynamicTableNameHandler.remove();
return results;
@@ -172,7 +172,7 @@ public class SimAndDigNonHarmonicServiceImpl extends ServiceImpl<SimAndDigNonHar
String prefix = "ad_non_harmonic_result_";
DynamicTableNameHandler.setTableName(prefix + param.getPlanCode());
MPJLambdaWrapper<SimAndDigNonHarmonicResult> wrapper = new MPJLambdaWrapper<>();
wrapper.like(SimAndDigNonHarmonicResult::getMonitorId, param.getDevId() + "_" + param.getChannelNo())
wrapper.like(SimAndDigNonHarmonicResult::getDevMonitorId, param.getDevId() + "_" + param.getChannelNo())
.in(SimAndDigNonHarmonicResult::getSort, param.getSortList())
.in(SimAndDigNonHarmonicResult::getAdType, param.getValueTypeList());
List<SimAndDigNonHarmonicResult> adNonHarmonicResults = this.getBaseMapper().selectJoinList(SimAndDigNonHarmonicResult.class, wrapper);
@@ -190,7 +190,7 @@ public class SimAndDigNonHarmonicServiceImpl extends ServiceImpl<SimAndDigNonHar
.selectAs(DictTree::getCode, SimAndDigNonHarmonicResult::getAdType)
.leftJoin(DictTree.class, DictTree::getId, SimAndDigNonHarmonicResult::getAdType)
.eq(SimAndDigNonHarmonicResult::getScriptId, scriptId)
.likeRight(SimAndDigNonHarmonicResult::getMonitorId, devId);
.likeRight(SimAndDigNonHarmonicResult::getDevMonitorId, devId);
List<SimAndDigNonHarmonicResult> results = this.getBaseMapper().selectJoinList(SimAndDigNonHarmonicResult.class, wrapper);
DynamicTableNameHandler.remove();
return results;

View File

@@ -35,15 +35,20 @@ public class TableGenServiceImpl implements TableGenService {
}
String sql = "CREATE TABLE AD_Harmonic_" + code + " (\n" +
" Monitor_Id CHAR(34) NOT NULL COMMENT '监测点Id',\n" +
" Dev_Monitor_Id CHAR(34) NOT NULL COMMENT '监测点Id',\n" +
" Time_Id DATETIME(3) 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) NULL COMMENT '0不合格 1合格 4无法处理',\n" +
A + B + C +
(isContrast ?
" Num tinyint(1) unsigned DEFAULT 0 COMMENT '第几次检测',\n" +
" PRIMARY KEY (Monitor_Id,Time_Id, AD_Type, Num)\n"
"Id char(32) COLLATE utf8mb4_bin NOT NULL COMMENT '主键Id',\n" +
"Std_Dev_Monitor_Id CHAR(34) NOT NULL COMMENT '标准设备监测点Id',\n" +
"Num tinyint(1) unsigned DEFAULT 0 COMMENT '第几次检测',\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" +
"PRIMARY KEY (Id)\n"
:
" Script_Id CHAR(32) NOT NULL COMMENT '检测脚本表Id',\n" +
" Sort int(4) NOT NULL COMMENT '总检测脚本中的测试项序号',\n" +
@@ -55,15 +60,20 @@ public class TableGenServiceImpl implements TableGenService {
String b = B.toString().replaceAll("float", "json");
String c = C.toString().replaceAll("float", "json");
String sql2 = "CREATE TABLE AD_Harmonic_Result_" + code + " (\n" +
" Monitor_Id CHAR(34) NOT NULL COMMENT '监测点Id',\n" +
" Dev_Monitor_Id CHAR(34) NOT NULL COMMENT '监测点Id',\n" +
" Time_Id DATETIME(3) 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 +
(isContrast ?
" Num tinyint(1) unsigned DEFAULT 0 COMMENT '第几次检测',\n" +
" PRIMARY KEY (Monitor_Id, AD_Type, Num)\n"
"Id char(32) COLLATE utf8mb4_bin NOT NULL COMMENT '主键Id',\n" +
"Std_Dev_Monitor_Id CHAR(34) NOT NULL COMMENT '标准设备监测点Id',\n" +
"Num tinyint(1) unsigned DEFAULT 0 COMMENT '第几次检测',\n" +
"A_Value_0 json NULL COMMENT 'A相基波有效值',\n" +
"B_Value_0 json NULL COMMENT 'B相基波有效值',\n" +
"C_Value_0 json NULL COMMENT 'B相基波有效值',\n" +
"PRIMARY KEY (Id)\n"
:
" Script_Id CHAR(32) NOT NULL COMMENT '检测脚本表Id',\n" +
" Sort int(4) NOT NULL COMMENT '总检测脚本中的测试项序号',\n" +