切换误差体系-未做完

This commit is contained in:
caozehui
2025-03-07 10:31:32 +08:00
parent 08be6c15fb
commit 6968bf437d
10 changed files with 237 additions and 61 deletions

View File

@@ -13,7 +13,4 @@ public interface TableGenMapper {
void genAdNonHarmonicResultTable(@Param("code")String code);
}

View File

@@ -26,7 +26,7 @@
<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',
Time_Id DATETIME NULL COMMENT '时间',
Script_Id CHAR(32) NOT NULL COMMENT '检测脚本子表Id字典表',
@@ -41,10 +41,5 @@
PRIMARY KEY (Monitor_Id, Script_Id, Sort, AD_Type,Data_Type)
) COMMENT='监测数据表';
</update>
<update id="genAdHarmonicResultTable" parameterType="string">
${tableSql}
</update>
</mapper>

View File

@@ -46,4 +46,12 @@ public interface AdNonHarmonicService extends IService<AdNonHarmonicResult> {
* @param singleNonHarmParam 查询参数
*/
AdNonHarmonicResult getSingleResult(SingleNonHarmParam singleNonHarmParam);
/**
* 获取所有原始数据
* @param code
* @param devId
* @return
*/
List<AdNonHarmonicResult> listAll(String code,String devId);
}

View File

@@ -24,7 +24,10 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal;
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.stream.Collectors;
@@ -67,7 +70,7 @@ public class AdNonHarmonicServiceImpl extends ServiceImpl<AdNonHarmonicMapper, A
Map<String, List<RawDataVO>> info = new LinkedHashMap<>(2);
Map<String, List<AdNonHarmonicResult>> adTypeMap = adHarmonicResults.stream().collect(Collectors.groupingBy(AdNonHarmonicResult::getAdType));
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) -> {
if (dictTreeByName.containsKey(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()));
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) -> {
if (dictTreeByName.containsKey(key)) {
DictTree treeName = dictTreeByName.get(key);
@@ -119,10 +122,10 @@ public class AdNonHarmonicServiceImpl extends ServiceImpl<AdNonHarmonicMapper, A
dataVO.setDataB(b);
dataVO.setDataC(c);
dataVO.setDataT(t);
if(ObjectUtil.isNotNull(t)){
if (ObjectUtil.isNotNull(t)) {
dataVO.setRadius(t.getRadius());
}else{
if(ObjectUtil.isNotNull(b)){
} else {
if (ObjectUtil.isNotNull(b)) {
dataVO.setRadius(b.getRadius());
}
}
@@ -135,7 +138,7 @@ public class AdNonHarmonicServiceImpl extends ServiceImpl<AdNonHarmonicMapper, A
@Override
public AdNonHarmonicResult getSingleResult(SingleNonHarmParam singleNonHarmParam) {
if(ObjectUtil.isNotNull(singleNonHarmParam)){
if (ObjectUtil.isNotNull(singleNonHarmParam)) {
String prefix = "ad_non_harmonic_result_";
DynamicTableNameHandler.setTableName(prefix + singleNonHarmParam.getPlanCode());
MPJLambdaWrapper<AdNonHarmonicResult> wrapper = new MPJLambdaWrapper<>();
@@ -143,71 +146,82 @@ public class AdNonHarmonicServiceImpl extends ServiceImpl<AdNonHarmonicMapper, A
.eq(AdNonHarmonicResult::getSort, singleNonHarmParam.getSort())
.eq(AdNonHarmonicResult::getAdType, singleNonHarmParam.getAdType());
List<AdNonHarmonicResult> adHarmonicResults = this.getBaseMapper().selectJoinList(AdNonHarmonicResult.class, wrapper);
if (CollectionUtil.isNotEmpty(adHarmonicResults)){
if (CollectionUtil.isNotEmpty(adHarmonicResults)) {
return adHarmonicResults.get(0);
}
}
return null;
}
private String unit(String code){
String unit="";
@Override
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) {
/**
* 频率
*/
case "FREQ":
unit="Hz";
unit = "Hz";
break;
/**
* 电压
*/
case "VRMS":
unit="V";
unit = "V";
break;
/**
* 电流
*/
case "IRMS":
unit="A";
unit = "A";
break;
/**
* 谐波电压
*/
case "V2-50":
/**
* 谐波电流
*/
/**
* 谐波电流
*/
case "I2-50":
/**
* 间谐波电压
*/
/**
* 间谐波电压
*/
case "SV_1-49":
/**
* 间谐波电流
*/
/**
* 间谐波电流
*/
case "SI_1-49":
/**
* 三相电压不平衡度
*/
/**
* 三相电压不平衡度
*/
case "V_UNBAN":
/**
* 三相电流不平衡度
*/
/**
* 三相电流不平衡度
*/
case "I_UNBAN":
unit="%";
unit = "%";
break;
/**
* 谐波有功功率
*/
case "P2-50":
unit="W";
unit = "W";
break;
/**
* 功率
*/
case "P":
unit="P";
unit = "P";
break;
/**
* 闪变
@@ -218,28 +232,28 @@ public class AdNonHarmonicServiceImpl extends ServiceImpl<AdNonHarmonicMapper, A
* 暂态-电压幅值
*/
case "MAG":
unit="V";
unit = "%";
break;
/**
* 暂态-持续时间
*/
case "DUR":
unit="s";
unit = "s";
break;
/**
* 相角
*/
case "VA":
case "IA":
unit="°";
unit = "°";
break;
/**
* 电压偏差
*/
case "DELTA_V":
unit="%";
unit = "%";
break;
}
return unit;
return unit;
}
}