Merge remote-tracking branch 'origin/master'

This commit is contained in:
xy
2024-09-18 20:19:24 +08:00
47 changed files with 2078 additions and 1089 deletions

View File

@@ -1,9 +1,6 @@
package com.njcn.device.pq.constant;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@@ -41,24 +38,19 @@ public interface Param {
* put(name:表ele_epd_pqd中的名称,value:页面展示的指标名称)
*/
Map<String,String> DATABSEMAP = new HashMap(){{
put("频率偏差","频率偏差");
put("线电压偏差","电压偏差");
put("电压负序不平衡度","三相电压不平衡度");
put("相电压电压变动幅度","电压波动");
put("相电压长时闪变","长时闪变");
//put("线电压总有效值","谐波电压");
//put("电流总有效值","谐波电流");
//put("相电压总有效值","间谐波电压");
put("电压负序不平衡度","负序电压不平衡度");
put("电流负序不平衡度","负序电流");
put("总稳态指标","三相总有功功率");
put("相电压谐波总畸变率","电压总谐波畸变率");
put("电流负序不平衡度","电流不平衡度");
}};
Map<String,String> UHARMMAP = new HashMap(){{
put("相电压谐波含有率序列","电压");
put("相电压谐波含有率序列","谐波电压");
}};
Map<String,String> IHARMMAP = new HashMap(){{
put("谐波电流有效值","电流");
put("谐波电流有效值","谐波电流");
}};
Map<String,String> INTERHARMONICMAP = new HashMap(){{

View File

@@ -28,4 +28,21 @@ public interface Param {
String END =" 23:59:59";
String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
String voltageOffset = "电压偏差";
String vTimes = "谐波电压";
String iTimes = "谐波电流";
String ubalance = "三相电压不平衡度";
String voltageFluctuation = "电压波动";
String flicker = "闪变";
String interHarmonic = "间谐波电压含有率";
String sequenceCurrentUnbalance = "电流不平衡度";
}

View File

@@ -71,19 +71,4 @@ public interface Param {
String DECIMAL_FORMATTWOSTR = "#.##";
String voltageOffset = "电压偏差";
String vTimes = "谐波电压";
String iTimes = "谐波电流";
String ubalance = "三相电压不平衡度";
String voltageFluctuation = "电压波动";
String flicker = "闪变";
String interHarmonic = "间谐波电压含有率";
String sequenceCurrentUnbalance = "电流不平衡度";
}

View File

@@ -1,7 +1,5 @@
package com.njcn.harmonic.pojo.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.ArrayList;
@@ -16,19 +14,15 @@ import java.util.List;
public class PowerStatisticsTargetVO {
@ApiModelProperty("时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private String time;
@ApiModelProperty("电压偏差")
@ExcelProperty(index =2,value = {"电压","B"})
private Integer voltageOffset = 0;
@ApiModelProperty("谐波电压")
@ExcelProperty(index =3,value = {"电压","C"})
private Integer vTimes = 0;
@ApiModelProperty("谐波电流")
@ExcelProperty(index =4,value = {"电流","A"})
private Integer iTimes = 0;
@ApiModelProperty("三相电压不平衡度")
@@ -46,9 +40,6 @@ public class PowerStatisticsTargetVO {
@ApiModelProperty("电流不平衡度")
private Integer sequenceCurrentUnbalance = 0;
@ApiModelProperty("区间字段(标识是哪个区间:10%~20%、20%~30%....)用于后端辅助计算")
private String field;
@ApiModelProperty("电压偏差详情")
private List<ThdDataVO> voltageOffsetList = new ArrayList<>();
@@ -73,58 +64,4 @@ public class PowerStatisticsTargetVO {
@ApiModelProperty("电流不平衡度详情")
private List<ThdDataVO> sequenceCurrentUnbalanceList = new ArrayList<>();
@ApiModelProperty("相别(用于后端辅助计算)")
private String phasicType;
@ApiModelProperty("统计方式(用于后端辅助计算)")
private String valueType;;
@ApiModelProperty("电压偏差国标限值(用于后端辅助计算)")
private Float voltageOffsetLimit;
@ApiModelProperty("谐波电压国标限值(用于后端辅助计算)")
private List<Float> vTimesLimit = new ArrayList<>();;
@ApiModelProperty("谐波电流国标限值(用于后端辅助计算)")
private List<Float> iTimesLimit = new ArrayList<>();;
@ApiModelProperty("三相电压不平衡度国标限值(用于后端辅助计算)")
private Float ubalanceLimit;
@ApiModelProperty("电压波动国标限值(用于后端辅助计算)")
private Float voltageFluctuationLimit;
@ApiModelProperty("闪变国标限值(用于后端辅助计算)")
private Float flickerLimit;
@ApiModelProperty("间谐波电压含有率国标限值(用于后端辅助计算)")
private List<Float> interHarmonicLimit = new ArrayList<>();;
@ApiModelProperty("电流不平衡度国标限值(用于后端辅助计算)")
private Float sequenceCurrentUnbalanceLimit;
@ApiModelProperty("电压偏差具体值(用于后端辅助计算)")
private Double voltageOffsetData;
@ApiModelProperty("谐波电压具体值(用于后端辅助计算)")
private List<Double> vTimesData = new ArrayList<>();;
@ApiModelProperty("谐波电流具体值(用于后端辅助计算)")
private List<Double> iTimesData = new ArrayList<>();;
@ApiModelProperty("三相电压不平衡度具体值(用于后端辅助计算)")
private Double ubalanceData;
@ApiModelProperty("电压波动具体值(用于后端辅助计算)")
private Double voltageFluctuationData;
@ApiModelProperty("闪变具体值(用于后端辅助计算)")
private Double flickerData;
@ApiModelProperty("间谐波电压含有率具体值(用于后端辅助计算)")
private List<Double> interHarmonicData = new ArrayList<>();
@ApiModelProperty("电流不平衡度具体值(用于后端辅助计算)")
private Double sequenceCurrentUnbalanceData;
}

View File

@@ -1,5 +1,6 @@
package com.njcn.harmonic.pojo.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -56,6 +57,9 @@ public class ThdDataVO {
@ApiModelProperty("国标限值")
private Float limit;
@ApiModelProperty("谐波次数")
private Integer frequency;
@ApiModelProperty("时间")
private String time;

View File

@@ -29,6 +29,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.lang.reflect.Field;
import java.text.DecimalFormat;
import java.util.*;
import java.util.stream.Collectors;
@@ -71,6 +72,7 @@ public class PowerStatisticsServiceImpl implements PowerStatisticsService {
//执行完就可以获取到区间数据了
RActivePowerRangePO rActivePowerRangePO = rActivePowerRangeFeignClient.getDataByLineId(powerStatisticsParam.getLineId(),
powerStatisticsParam.getSearchBeginTime(),powerStatisticsParam.getSearchEndTime()).getData();
//如果的确没有统计到数据则默认
if(rActivePowerRangePO == null){
rActivePowerRangePO = new RActivePowerRangePO();
}
@@ -98,253 +100,40 @@ public class PowerStatisticsServiceImpl implements PowerStatisticsService {
@Override
public List<PowerStatisticsTargetVO> getTargetLimitById(PowerStatisticsParam powerStatisticsParam) {
List<PowerStatisticsTargetVO> data = new ArrayList<>();
List<PowerStatisticsTargetVO> record = new ArrayList<>();
RActivePowerRangeParam rActivePowerRangeParam = new RActivePowerRangeParam();
BeanUtil.copyProperties(powerStatisticsParam, rActivePowerRangeParam);
rActivePowerRangeParam.setSearch(true);
//重点说明:powerStatisticsTargetVO结构(维度)为:time可能多组相同,取决于功率表data_harmpower_p中的相别及统计方式,标识每个指标是否越限,总之一句话:每条数据当前时间中八个指标是否越限及他们的相别和统计方式是什么
//基于record结构需要做维度的转换
List<PowerStatisticsTargetVO> record = rActivePowerRangeFeignClient.record(rActivePowerRangeParam).getData();
//根据时间分组:
Map<String,List<PowerStatisticsTargetVO>> map = record.stream().collect(Collectors.groupingBy(PowerStatisticsTargetVO::getTime));
map.forEach((key, value) ->{
PowerStatisticsTargetVO powerStatisticsTargetVO = new PowerStatisticsTargetVO();
powerStatisticsTargetVO.setTime(key);
powerStatisticsTargetVO.setField(powerStatisticsParam.getField());
//各指标越限的相别及统计方式集合
List<Map<String,String>> pvs = new ArrayList<>();
//遍历当前时间下的区间指标(注意:可能多组只是说统计方式和相别不同)
for(PowerStatisticsTargetVO vo : value){
//以下这些判断只要有一个指标越限了(不管是什么统计方式和相别)直接标识该指标越限(这些字段用于前端展示)
if(vo.getVoltageOffset().intValue() == 1) powerStatisticsTargetVO.setVoltageOffset(1);
if(vo.getVTimes().intValue() == 1) powerStatisticsTargetVO.setVTimes(1);
if(vo.getITimes().intValue() == 1) powerStatisticsTargetVO.setITimes(1);
if(vo.getUbalance().intValue() == 1) powerStatisticsTargetVO.setUbalance(1);
if(vo.getVoltageFluctuation().intValue() == 1) powerStatisticsTargetVO.setVoltageFluctuation(1);
if(vo.getFlicker().intValue() == 1) powerStatisticsTargetVO.setFlicker(1);
if(vo.getInterHarmonic().intValue() == 1) powerStatisticsTargetVO.setInterHarmonic(1);
if(vo.getSequenceCurrentUnbalance().intValue() == 1) powerStatisticsTargetVO.setSequenceCurrentUnbalance(1);
//以下逻辑用于前端点击指标时能看到指标具体的越限情况(比方说A相AVG越限了)
Map<String,String> pv = new HashMap<>();
pv.put(vo.getPhasicType(),vo.getValueType());
//除了带有谐波次数的指标需要特殊处理其他正常添加到pvs中
if(vo.getVoltageOffsetData()!=null) pv.put(Param.voltageOffset,df.format(vo.getVoltageOffsetData()));
if(vo.getUbalanceData()!=null) pv.put(Param.ubalance,df.format(vo.getUbalanceData()));
if(vo.getVoltageFluctuationData()!=null) pv.put(Param.voltageFluctuation,df.format(vo.getVoltageFluctuationData()));
if(vo.getFlickerData()!=null) pv.put(Param.flicker,df.format(vo.getFlickerData()));
if(vo.getSequenceCurrentUnbalanceData()!=null) pv.put(Param.sequenceCurrentUnbalance,df.format(vo.getSequenceCurrentUnbalanceData()));
pvs.add(pv);
}
powerStatisticsTargetVO.setVoltageOffsetList(initPV(pvs,Param.voltageOffset,value.get(0).getVoltageOffsetLimit()));
//谐波电压带有谐波次数需要特殊处理
powerStatisticsTargetVO.setVTimesList(initFrequencyPV(value,Param.vTimes,value.get(0).getVTimesLimit()));
//谐波电流带有谐波次数需要特殊处理
powerStatisticsTargetVO.setITimestList(initFrequencyPV(value,Param.iTimes,value.get(0).getITimesLimit()));
powerStatisticsTargetVO.setUbalanceList(initPV(pvs,Param.ubalance,value.get(0).getUbalanceLimit()));
powerStatisticsTargetVO.setVoltageFluctuationList(initPV(pvs,Param.voltageFluctuation,value.get(0).getVoltageFluctuationLimit()));
powerStatisticsTargetVO.setFlickerList(initPV(pvs,Param.flicker,value.get(0).getFlickerLimit()));
//间谐波电压含有率带有谐波次数需要特殊处理
powerStatisticsTargetVO.setInterHarmonicList(initFrequencyPV(value,Param.interHarmonic,value.get(0).getInterHarmonicLimit()));
powerStatisticsTargetVO.setSequenceCurrentUnbalanceList(initPV(pvs,Param.sequenceCurrentUnbalance,value.get(0).getSequenceCurrentUnbalanceLimit()));
powerStatisticsTargetVO.setVTimesList(formatFrequency(powerStatisticsTargetVO.getVTimesList()));
powerStatisticsTargetVO.setITimestList(formatFrequency(powerStatisticsTargetVO.getITimestList()));
powerStatisticsTargetVO.setInterHarmonicList(formatFrequency(powerStatisticsTargetVO.getInterHarmonicList()));
data.add(powerStatisticsTargetVO);
});
return data.stream().sorted(Comparator.comparing(PowerStatisticsTargetVO::getTime)).collect(Collectors.toList());
}
private List<ThdDataVO> formatFrequency(List<ThdDataVO> thdDataVOS){
List<ThdDataVO> data = new ArrayList<>();
for(ThdDataVO thdDataVO : thdDataVOS){
boolean isOk = false;
if(thdDataVO.getMINPhaseA()!= null && Float.parseFloat(thdDataVO.getMINPhaseA())>thdDataVO.getLimit()) isOk = true;
if(thdDataVO.getMINPhaseB()!= null && Float.parseFloat(thdDataVO.getMINPhaseB())>thdDataVO.getLimit()) isOk = true;
if(thdDataVO.getMINPhaseC()!= null && Float.parseFloat(thdDataVO.getMINPhaseC())>thdDataVO.getLimit()) isOk = true;
if(thdDataVO.getMAXPhaseA()!= null && Float.parseFloat(thdDataVO.getMAXPhaseA())>thdDataVO.getLimit()) isOk = true;
if(thdDataVO.getMAXPhaseB()!= null && Float.parseFloat(thdDataVO.getMAXPhaseB())>thdDataVO.getLimit()) isOk = true;
if(thdDataVO.getMAXPhaseC()!= null && Float.parseFloat(thdDataVO.getMAXPhaseC())>thdDataVO.getLimit()) isOk = true;
if(thdDataVO.getAVGPhaseA()!= null && Float.parseFloat(thdDataVO.getAVGPhaseA())>thdDataVO.getLimit()) isOk = true;
if(thdDataVO.getAVGPhaseB()!= null && Float.parseFloat(thdDataVO.getAVGPhaseB())>thdDataVO.getLimit()) isOk = true;
if(thdDataVO.getAVGPhaseC()!= null && Float.parseFloat(thdDataVO.getAVGPhaseC())>thdDataVO.getLimit()) isOk = true;
if(thdDataVO.getCP95PhaseA()!= null && Float.parseFloat(thdDataVO.getCP95PhaseA())>thdDataVO.getLimit()) isOk = true;
if(thdDataVO.getCP95PhaseB()!= null && Float.parseFloat(thdDataVO.getCP95PhaseB())>thdDataVO.getLimit()) isOk = true;
if(thdDataVO.getCP95PhaseC()!= null && Float.parseFloat(thdDataVO.getCP95PhaseC())>thdDataVO.getLimit()) isOk = true;
if(isOk){
data.add(thdDataVO);
RActivePowerRangePO rActivePowerRangePO = rActivePowerRangeFeignClient.getDataByLineId(powerStatisticsParam.getLineId(),
powerStatisticsParam.getSearchBeginTime(),powerStatisticsParam.getSearchEndTime()).getData();
if(rActivePowerRangePO != null){
String times = reflexObjValue(rActivePowerRangePO,"minsTime"+powerStatisticsParam.getField()).toString().replace("null","");
rActivePowerRangeParam.setSearchTimeFort(false);
for(String se : times.split("&")){
String startTime = se.split(",")[0];
String endTime = se.split(",")[1];
rActivePowerRangeParam.setSearchBeginTime(startTime);
rActivePowerRangeParam.setSearchEndTime(endTime);
record.addAll(rActivePowerRangeFeignClient.record(rActivePowerRangeParam).getData());
}
}
return data;
return record.stream().sorted(Comparator.comparing(PowerStatisticsTargetVO::getTime)).collect(Collectors.toList());
}
private List<ThdDataVO> initPV(List<Map<String,String>> pv, String name, Float limit){
List<ThdDataVO> thdDataVOS = new ArrayList<>();
ThdDataVO tdv = new ThdDataVO();
tdv.setAnotherName(name);
tdv.setLimit(limit);
//便利统计方式和相别集合渲染对应字段
for(Map<String,String> arr :pv){
arr.forEach((phasicType, valueType) ->{
switch (valueType){
case InfluxDBTableConstant.AVG:
switch (phasicType){
case InfluxDBTableConstant.PHASE_TYPE_A:
tdv.setAVGPhaseA(arr.get(name));
break;
case InfluxDBTableConstant.PHASE_TYPE_B:
tdv.setAVGPhaseB(arr.get(name));
break;
case InfluxDBTableConstant.PHASE_TYPE_C:
tdv.setAVGPhaseC(arr.get(name));
break;
}
break;
case InfluxDBTableConstant.CP95:
switch (phasicType){
case InfluxDBTableConstant.PHASE_TYPE_A:
tdv.setCP95PhaseA(arr.get(name));
break;
case InfluxDBTableConstant.PHASE_TYPE_B:
tdv.setCP95PhaseB(arr.get(name));
break;
case InfluxDBTableConstant.PHASE_TYPE_C:
tdv.setCP95PhaseC(arr.get(name));
break;
}
break;
case InfluxDBTableConstant.MIN:
switch (phasicType){
case InfluxDBTableConstant.PHASE_TYPE_A:
tdv.setMINPhaseA(arr.get(name));
break;
case InfluxDBTableConstant.PHASE_TYPE_B:
tdv.setMINPhaseB(arr.get(name));
break;
case InfluxDBTableConstant.PHASE_TYPE_C:
tdv.setMINPhaseC(arr.get(name));
break;
}
break;
case InfluxDBTableConstant.MAX:
switch (phasicType){
case InfluxDBTableConstant.PHASE_TYPE_A:
tdv.setMAXPhaseA(arr.get(name));
break;
case InfluxDBTableConstant.PHASE_TYPE_B:
tdv.setMAXPhaseB(arr.get(name));
break;
case InfluxDBTableConstant.PHASE_TYPE_C:
tdv.setMAXPhaseC(arr.get(name));
break;
}
break;
}
});
}
//如果所有的相别和统计方式都没有值则可直接忽略该条数据
if(tdv.getAVGPhaseA() != null || tdv.getAVGPhaseB() != null
|| tdv.getAVGPhaseC() != null || tdv.getCP95PhaseA() != null
|| tdv.getCP95PhaseB() != null || tdv.getCP95PhaseC() != null
|| tdv.getMINPhaseA() != null || tdv.getMINPhaseB() != null
|| tdv.getMINPhaseC() != null || tdv.getMAXPhaseA() != null
|| tdv.getMAXPhaseB() != null || tdv.getMAXPhaseC() != null){
thdDataVOS.add(tdv);
}
return thdDataVOS;
}
private List<Double> getFrequencyData(List<PowerStatisticsTargetVO> pv,String valueType,String phasicType,String name){
//根据不同的相别及统计方式分别获取该时间组下区间指标集合的具体值
List<PowerStatisticsTargetVO> data = pv.stream().filter(param->phasicType.equals(param.getPhasicType()) && valueType.equals(param.getValueType())).collect(Collectors.toList());
if(!data.isEmpty()){
switch (name){
case Param.vTimes:
return data.get(0).getVTimesData();
case Param.iTimes:
return data.get(0).getITimesData();
case Param.interHarmonic:
return data.get(0).getInterHarmonicData();
}
//反射获取值
private Object reflexObjValue(Object obj, String fieldName) {
try {
Class clazz = obj.getClass();
Field field = clazz.getDeclaredField(fieldName);
field.setAccessible(true);
return field.get(obj);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
private String frequencyPVList(List<Double> data,int index){
try {
return df.format(data.get(index));
} catch (Exception e) {
return null;
}
}
private List<ThdDataVO> initFrequencyPV(List<PowerStatisticsTargetVO> pv, String name, List<Float> limit){
List<ThdDataVO> thdDataVOS = new ArrayList<>();
if(!limit.isEmpty()){
//根据不同的相别及统计方式分别获取该时间组下区间指标集合的具体值
List<Double> avgA = getFrequencyData(pv,InfluxDBTableConstant.AVG,InfluxDBTableConstant.PHASE_TYPE_A,name);
List<Double> avgB = getFrequencyData(pv,InfluxDBTableConstant.AVG,InfluxDBTableConstant.PHASE_TYPE_B,name);
List<Double> avgC = getFrequencyData(pv,InfluxDBTableConstant.AVG,InfluxDBTableConstant.PHASE_TYPE_C,name);
List<Double> cp94A = getFrequencyData(pv,InfluxDBTableConstant.CP95,InfluxDBTableConstant.PHASE_TYPE_A,name);
List<Double> cp94B = getFrequencyData(pv,InfluxDBTableConstant.CP95,InfluxDBTableConstant.PHASE_TYPE_B,name);
List<Double> cp94C = getFrequencyData(pv,InfluxDBTableConstant.CP95,InfluxDBTableConstant.PHASE_TYPE_C,name);
List<Double> minA = getFrequencyData(pv,InfluxDBTableConstant.MIN,InfluxDBTableConstant.PHASE_TYPE_A,name);
List<Double> minB = getFrequencyData(pv,InfluxDBTableConstant.MIN,InfluxDBTableConstant.PHASE_TYPE_B,name);
List<Double> minC = getFrequencyData(pv,InfluxDBTableConstant.MIN,InfluxDBTableConstant.PHASE_TYPE_C,name);
List<Double> maxA = getFrequencyData(pv,InfluxDBTableConstant.MAX,InfluxDBTableConstant.PHASE_TYPE_A,name);
List<Double> maxB = getFrequencyData(pv,InfluxDBTableConstant.MAX,InfluxDBTableConstant.PHASE_TYPE_B,name);
List<Double> maxC = getFrequencyData(pv,InfluxDBTableConstant.MAX,InfluxDBTableConstant.PHASE_TYPE_C,name);
int k = 0,j = 0;
double c = 0;
switch (name){
//谐波电压和电流默认谐波次数2-25
case Param.vTimes:
case Param.iTimes:
k = 2;
j = 25;
break;
//间谐波电压含有率默认谐波次数1-16
case Param.interHarmonic:
k = 1;
j = 16;
c = 0.5;
break;
}
for (int i = k; i <= j; i++) {
ThdDataVO tdv = new ThdDataVO();
tdv.setAnotherName(name +(((i-c)+"").replace(".0",""))+"");
try {
tdv.setLimit(limit.get(i-k));
//frequencyPVList次方法提提高容灾,如果真的出现数组越界只有一种情况:有些有功功率查不到对应的某些指标数据
tdv.setAVGPhaseA(frequencyPVList(avgA,i-k));
tdv.setAVGPhaseB(frequencyPVList(avgB,i-k));
tdv.setAVGPhaseC(frequencyPVList(avgC,i-k));
tdv.setCP95PhaseA(frequencyPVList(cp94A,i-k));
tdv.setCP95PhaseB(frequencyPVList(cp94B,i-k));
tdv.setCP95PhaseC(frequencyPVList(cp94C,i-k));
tdv.setMINPhaseA(frequencyPVList(minA,i-k));
tdv.setMINPhaseB(frequencyPVList(minB,i-k));
tdv.setMINPhaseC(frequencyPVList(minC,i-k));
tdv.setMAXPhaseA(frequencyPVList(maxA,i-k));
tdv.setMAXPhaseB(frequencyPVList(maxB,i-k));
tdv.setMAXPhaseC(frequencyPVList(maxC,i-k));
} catch (Exception e) {
e.printStackTrace();
}
//如果所有的相别和统计方式都没有值则可直接忽略该条数据
if(tdv.getAVGPhaseA() != null || tdv.getAVGPhaseB() != null
|| tdv.getAVGPhaseC() != null || tdv.getCP95PhaseA() != null
|| tdv.getCP95PhaseB() != null || tdv.getCP95PhaseC() != null
|| tdv.getMINPhaseA() != null || tdv.getMINPhaseB() != null
|| tdv.getMINPhaseC() != null || tdv.getMAXPhaseA() != null
|| tdv.getMAXPhaseB() != null || tdv.getMAXPhaseC() != null){
thdDataVOS.add(tdv);
}
}
}
return thdDataVOS;
}
@Override
public List<ThdDataVO> getTargetByTime(PowerStatisticsParam powerStatisticsParam) {
List<ThdDataVO> result = new ArrayList();

View File

@@ -53,4 +53,11 @@ public class RActivePowerRangeParam extends BaseParam {
@ApiModelProperty("查询时是否统计数据(默认不统计)")
private boolean searchForAdd = false;
/**
* search = true 该参数才有效
* 查询时是否格式化时间
*/
@ApiModelProperty("查询时是否格式化时间(默认需要格式化)")
private boolean searchTimeFort = true;
}

View File

@@ -34,7 +34,7 @@ public class RActivePowerRangePO extends BaseEntity {
/**
* 0%~10%区间时间Json
*/
private String minsTime0 = "{}";
private String minsTime0;
/**
* 0%~10%区间个数
@@ -49,7 +49,7 @@ public class RActivePowerRangePO extends BaseEntity {
/**
* 10%~20%区间时间Json
*/
private String minsTime1 = "{}";;
private String minsTime1;
/**
* 10%~20%区间个数
@@ -64,7 +64,7 @@ public class RActivePowerRangePO extends BaseEntity {
/**
* 20%~30%区间时间Json
*/
private String minsTime2 = "{}";;
private String minsTime2;
/**
* 20%~30%区间个数
@@ -79,7 +79,7 @@ public class RActivePowerRangePO extends BaseEntity {
/**
* 30%~40%区间时间Json
*/
private String minsTime3 = "{}";;
private String minsTime3;
/**
* 30%~40%区间个数
@@ -94,7 +94,7 @@ public class RActivePowerRangePO extends BaseEntity {
/**
* 40%~50%区间时间Json
*/
private String minsTime4 = "{}";;
private String minsTime4;
/**
* 40%~50%区间个数
@@ -109,7 +109,7 @@ public class RActivePowerRangePO extends BaseEntity {
/**
* 50%~60%区间时间Json
*/
private String minsTime5 = "{}";;
private String minsTime5;
/**
* 50%~60%区间个数
@@ -124,7 +124,7 @@ public class RActivePowerRangePO extends BaseEntity {
/**
* 60%~70%区间时间Json
*/
private String minsTime6 = "{}";;
private String minsTime6;
/**
* 60%~70%区间个数
@@ -139,7 +139,7 @@ public class RActivePowerRangePO extends BaseEntity {
/**
* 70%~80%区间时间Json
*/
private String minsTime7 = "{}";;
private String minsTime7;
/**
* 70%~80%区间个数
@@ -154,7 +154,7 @@ public class RActivePowerRangePO extends BaseEntity {
/**
* 80%~90%区间时间Json
*/
private String minsTime8 = "{}";;
private String minsTime8;
/**
* 80%~90%区间个数
@@ -169,7 +169,7 @@ public class RActivePowerRangePO extends BaseEntity {
/**
* 90%~100%区间时间Json
*/
private String minsTime9 = "{}";;
private String minsTime9;
/**
* 90%~100%区间个数

View File

@@ -12,6 +12,7 @@ import com.njcn.device.pq.api.OverLimitClient;
import com.njcn.device.pq.pojo.po.NewStation;
import com.njcn.event.pojo.constant.Param;
import com.njcn.harmonic.pojo.vo.PowerStatisticsTargetVO;
import com.njcn.harmonic.pojo.vo.ThdDataVO;
import com.njcn.influx.pojo.bo.CommonQueryParam;
import com.njcn.influx.pojo.constant.InfluxDBTableConstant;
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
@@ -25,15 +26,19 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.lang.reflect.Field;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
/**
* 有功功率趋势 服务实现类
*
* @author guofeihu
* @since 2024-08-22
*/
@@ -44,6 +49,18 @@ public class RActivePowerRangeServiceImpl extends MppServiceImpl<RActivePowerRan
private final CommonService commonService;
private final IDataVService iDataVService;
private final IDataIService iDataIService;
private final DataPltService dataPltService;
private final DataInHarmVService dataInHarmVService;
private final DataHarmRateVService dataHarmRateVService;
private final DataFlucService dataFlucService;
private final CommLineClient commLineClient;
private final NewStationClient newStationClient;
@@ -52,9 +69,11 @@ public class RActivePowerRangeServiceImpl extends MppServiceImpl<RActivePowerRan
private DateTimeFormatter formatter = DateTimeFormatter.ofPattern(Param.DATE_FORMAT);
private final DecimalFormat df = new DecimalFormat(com.njcn.harmonic.constant.Param.DECIMAL_FORMATSTR);
private SimpleDateFormat sdf = new SimpleDateFormat(Param.DATE_FORMAT);
private List<String> PHASE = Arrays.asList(InfluxDBTableConstant.PHASE_TYPE_A,InfluxDBTableConstant.PHASE_TYPE_B,InfluxDBTableConstant.PHASE_TYPE_C);
private List<String> PHASE = Arrays.asList(InfluxDBTableConstant.PHASE_TYPE_A, InfluxDBTableConstant.PHASE_TYPE_B, InfluxDBTableConstant.PHASE_TYPE_C);
/**
* 整个算法的业务逻辑:
@@ -64,398 +83,560 @@ public class RActivePowerRangeServiceImpl extends MppServiceImpl<RActivePowerRan
* --------------------------------指标---------------------------------
* 电压偏差 data_v vu_dev 电压偏差 如果vu_dev>0,使用上偏差限值对比如果vu_dev<0,使用下偏差限值对比
* 谐波电压 data_v v_thd 电压总谐波总谐波畸变率 有一个指标超标,则谐波电压超标
* data_harmrate_v v2-v25 2-25次谐波电压含有率
* data_harmrate_v v2-v25 2-25次谐波电压含有率
* 谐波电流 data_i i2-i25 2-25次谐波电流幅值 有一个指标超标,则谐波电压超标
* 三相电压不平衡度 data_v v_unbalance
* 电压波动 data_fluc fluc
* 长时闪变 data_plt plt
* 间谐波电压含有率 data_inharm_v v1-v16 0.5-15.5次间谐波电压含有率 有一个指标超标,则谐波电压超标
* 电流不平衡度 data_i i_unbalance 这个不确定,找宝哥确认下
*
* @param rActivePowerRangeParam
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public List<PowerStatisticsTargetVO> record(RActivePowerRangeParam rActivePowerRangeParam) {
if(rActivePowerRangeParam == null){
if (rActivePowerRangeParam == null) {
rActivePowerRangeParam = new RActivePowerRangeParam();
}
//返回的最终结果
List<PowerStatisticsTargetVO> powerStatisticsTargetVOS = new ArrayList<>();
//默认初始化开始和结束时间
String startTime = getTime(rActivePowerRangeParam.getInterval(),0);
String endTime = getTime(rActivePowerRangeParam.getInterval(),1);
String startTime = getTime(rActivePowerRangeParam.getInterval(), 0);
String endTime = getTime(rActivePowerRangeParam.getInterval(), 1);
//获取时间段内的有功功率集合
List<CommonQueryParam> commonQueryParams = new ArrayList<>();
CommonQueryParam commonQueryParam = new CommonQueryParam();
//控制参数中如果search为true,则获取有功功率集合的时间段内为BaseParam中的searchBeginTime和searchEndTime(用于前端有功功率查询页面相关接口)
if(rActivePowerRangeParam.isSearch()){
startTime = rActivePowerRangeParam.getSearchBeginTime()+Param.BEGIN;
endTime = rActivePowerRangeParam.getSearchEndTime()+Param.END;
if (rActivePowerRangeParam.isSearch()) {
if(rActivePowerRangeParam.isSearchTimeFort()){
startTime = rActivePowerRangeParam.getSearchBeginTime() + Param.BEGIN;
endTime = rActivePowerRangeParam.getSearchEndTime() + Param.END;
}else{
startTime = rActivePowerRangeParam.getSearchBeginTime();
endTime = rActivePowerRangeParam.getSearchEndTime();
}
commonQueryParam.setLineId(rActivePowerRangeParam.getLineId());
}
//时间段
commonQueryParam.setStartTime(startTime);
commonQueryParam.setEndTime(endTime);
//临时模拟增加的条件(用于调试主要是数据量太大非常消耗时间) 2024-09-01 00:00:00
// commonQueryParam.setDataType("AVG");
// commonQueryParam.setPhasic("A");
commonQueryParam.setStartTime("2024-08-10 00:00:00");
commonQueryParam.setEndTime("2024-08-10 00:00:00");
//模拟增加的条件结束
//功率表data_harmpower_p及字段p
commonQueryParam.setTableName(InfluxDBTableConstant.DATA_HARM_POWER_P);
commonQueryParam.setColumnName("p");
commonQueryParams.add(commonQueryParam);
//这边没有设置他的统计方式和相别是因为根据有功功率查询各个指标的时候要把所有的指标和统计方式都查出来一一比较
//查询功率表(多个统计方式及相别)
List<StatisticalDataDTO> dataHarmPowerPS = commonService.getNewDeviceRtDataByTime(commonQueryParams);
//由于前端写死了各个指标的相别(只有A、B、C所以这边直接限制死了)
dataHarmPowerPS = dataHarmPowerPS.stream().filter(param->PHASE.contains(param.getPhaseType())).collect(Collectors.toList());
dataHarmPowerPS = dataHarmPowerPS.stream().filter(param -> PHASE.contains(param.getPhaseType())).collect(Collectors.toList());
//有功功率趋势表是按照监测点来划分的 所以这边需要根据监测点来分组
Map<String,List<StatisticalDataDTO>> map = dataHarmPowerPS.stream().collect(Collectors.groupingBy(StatisticalDataDTO::getLineId));
Map<String, List<StatisticalDataDTO>> lineMap = dataHarmPowerPS.stream().collect(Collectors.groupingBy(StatisticalDataDTO::getLineId));
RActivePowerRangeParam finalRActivePowerRangeParam = rActivePowerRangeParam;
//以下这段逻辑较耗时(主要是for循环),主要是要遍历所有的有功功率,在根据有功功率查询各个指标进行比较(最耗时的是有功功率查询各个指标,所以一但有功功率很多则遍历较慢)
log.info("当前遍历的功率根据监测点分组后长度为:{},集合总长为:{},现在开始遍历,{}",map.size(),dataHarmPowerPS.size(),sdf.format(new Date()));
map.forEach((key, value) ->{
log.info("当前遍历的功率根据监测点分组后长度为:{},集合总长为:{},现在开始遍历,{}", lineMap.size(), dataHarmPowerPS.size(), sdf.format(new Date()));
lineMap.forEach((lineId, lineGroupList) -> {
log.info("当前遍历的监测点ID为:{},监测点集合长为:{},现在开始遍历,{}", lineId, lineGroupList.size(), sdf.format(new Date()));
//获取监测点的国标限值
List<Overlimit> overlimits = overLimitClient.getOverLimitByLineIds(Arrays.asList(key)).getData();
List<Overlimit> overlimits = overLimitClient.getOverLimitByLineIds(Arrays.asList(lineId)).getData();
//该监测点必须要有国标限值
if(overlimits != null && !overlimits.isEmpty()){
if (overlimits != null && !overlimits.isEmpty()) {
Overlimit overlimit = overlimits.get(0);
//获取监测点
LineDTO lineDTO = commLineClient.getLineDetail(key).getData();
LineDTO lineDTO = commLineClient.getLineDetail(lineId).getData();
//监测点必须绑定新能源站
if(lineDTO != null && lineDTO.getNewStationId() != null){
if (lineDTO != null && lineDTO.getNewStationId() != null) {
//获取监测点的新能源站
NewStation newStation = newStationClient.selectById(lineDTO.getNewStationId()).getData();
//新能源站有些切必须是风电场
if(newStation != null && com.njcn.device.pq.constant.Param.WINDFARM.equals(newStation.getStationType())){
if (newStation != null && com.njcn.device.pq.constant.Param.WINDFARM.equals(newStation.getStationType())) {
RActivePowerRangePO rActivePowerRangePO = new RActivePowerRangePO();
rActivePowerRangePO.setLineId(key);
rActivePowerRangePO.setLineId(lineId);
rActivePowerRangePO.setTimeId(LocalDate.now());
rActivePowerRangePO.setId(IdUtil.simpleUUID());
LambdaQueryWrapper<RActivePowerRangePO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(RActivePowerRangePO::getLineId,key).eq(RActivePowerRangePO::getTimeId,LocalDate.now());
lambdaQueryWrapper.eq(RActivePowerRangePO::getLineId, lineId).eq(RActivePowerRangePO::getTimeId, LocalDate.now());
//控制参数-强制刷新
if(finalRActivePowerRangeParam.isRefresh()){
if (finalRActivePowerRangeParam.isRefresh()) {
this.baseMapper.delete(lambdaQueryWrapper);
}
//控制参数-是否查询及查询新增(主要用于harmonic-boot-getDataByLineId方法,避免每次执行都会执行for循环,也即当日执行完一次即可)
if(!this.baseMapper.selectList(lambdaQueryWrapper).isEmpty() && (finalRActivePowerRangeParam.isSearch() && finalRActivePowerRangeParam.isSearchForAdd())){
//控制参数-是否查询及查询新增(主要用于harmonic-boot-getDataByLineId方法,避免每次执行都会执行循环,也即当日执行完一次即可)
if (!this.baseMapper.selectList(lambdaQueryWrapper).isEmpty() && (finalRActivePowerRangeParam.isSearch() && finalRActivePowerRangeParam.isSearchForAdd())) {
return;
}
int index = 1;
//耗时开始-计算各个区间个数及是否越限
for(StatisticalDataDTO statisticalDataDTO : value){
log.info("前监测点为:{},遍历第{}条...,现在开始遍历,{}",key,index,sdf.format(new Date()));
//当前监测点的功率数据在根据时间分组然后取出一个时间分组内最大的值
Map<Instant, List<StatisticalDataDTO>> timeMap = lineGroupList.stream().collect(Collectors.groupingBy(StatisticalDataDTO::getTime));
timeMap.forEach((time, timeGroupList) -> {
//取出当前时间分组内最大的一个值来判断是否越界
Optional<StatisticalDataDTO> optional = timeGroupList.stream().max(Comparator.comparingDouble(StatisticalDataDTO::getValue));
StatisticalDataDTO statisticalDataDTO = optional.get();
PowerStatisticsTargetVO powerStatisticsTargetVO = new PowerStatisticsTargetVO();
//设置时间为当前功率的时间
powerStatisticsTargetVO.setTime(statisticalDataDTO.getTime().atZone(ZoneId.systemDefault()).format(formatter));
powerStatisticsTargetVO.setTime("2024-08-10 00:00:00");
//当前功率的p字段 / 风电场额定功率
double temp = statisticalDataDTO.getValue() / Double.parseDouble(newStation.getRatedPower());
//区间过滤下(用于前端查询)
if(finalRActivePowerRangeParam.isSearch() && finalRActivePowerRangeParam.getField() != null){
if(Double.parseDouble(finalRActivePowerRangeParam.getField()) < temp * 10 && temp * 10 <= Double.parseDouble(finalRActivePowerRangeParam.getField())+1){
//指标越限列表区间区分字段(用于前端查询)
powerStatisticsTargetVO.setField(finalRActivePowerRangeParam.getField());
//判断每个指标是否越限(根据type来区分设置到哪个区间对应的是否越限字段)
installLimit(rActivePowerRangePO,statisticalDataDTO,overlimit,Integer.parseInt(finalRActivePowerRangeParam.getField()),powerStatisticsTargetVO);
//区间过滤下(如果进去此判断 那么只能是查询某个区间下的指标越限列表)
if (finalRActivePowerRangeParam.isSearch() && finalRActivePowerRangeParam.getField() != null) {
if (Double.parseDouble(finalRActivePowerRangeParam.getField()) < temp * 10 && temp * 10 <= Double.parseDouble(finalRActivePowerRangeParam.getField()) + 1) {
//判断当前区间每个指标是否越限(根据type来区分设置到哪个区间对应的是否越限字段)
installLimit(rActivePowerRangePO, statisticalDataDTO, overlimit, Integer.parseInt(finalRActivePowerRangeParam.getField()), powerStatisticsTargetVO);
powerStatisticsTargetVOS.add(powerStatisticsTargetVO);
}
continue;
} else {
//否则是正常的定时任务插入,或者前端搜索插入
//设置每个区间的统计时间
rActivePowerRangePO.setMinsTime0(commonQueryParam.getStartTime()+","+commonQueryParam.getEndTime());
rActivePowerRangePO.setMinsTime1(commonQueryParam.getStartTime()+","+commonQueryParam.getEndTime());
rActivePowerRangePO.setMinsTime2(commonQueryParam.getStartTime()+","+commonQueryParam.getEndTime());
rActivePowerRangePO.setMinsTime3(commonQueryParam.getStartTime()+","+commonQueryParam.getEndTime());
rActivePowerRangePO.setMinsTime4(commonQueryParam.getStartTime()+","+commonQueryParam.getEndTime());
rActivePowerRangePO.setMinsTime5(commonQueryParam.getStartTime()+","+commonQueryParam.getEndTime());
rActivePowerRangePO.setMinsTime6(commonQueryParam.getStartTime()+","+commonQueryParam.getEndTime());
rActivePowerRangePO.setMinsTime7(commonQueryParam.getStartTime()+","+commonQueryParam.getEndTime());
rActivePowerRangePO.setMinsTime8(commonQueryParam.getStartTime()+","+commonQueryParam.getEndTime());
rActivePowerRangePO.setMinsTime9(commonQueryParam.getStartTime()+","+commonQueryParam.getEndTime());
if (temp <= 0.1) {
//占有率区间个数+1
rActivePowerRangePO.setMinsNum0(rActivePowerRangePO.getMinsNum0() + 1);
//判断当前区间每个指标是否越限
installLimit(rActivePowerRangePO, statisticalDataDTO, overlimit, 0, powerStatisticsTargetVO);
} else if (0.1 < temp && temp <= 0.2) {
rActivePowerRangePO.setMinsNum1(rActivePowerRangePO.getMinsNum1() + 1);
installLimit(rActivePowerRangePO, statisticalDataDTO, overlimit, 1, powerStatisticsTargetVO);
} else if (0.2 < temp && temp <= 0.3) {
rActivePowerRangePO.setMinsNum2(rActivePowerRangePO.getMinsNum2() + 1);
installLimit(rActivePowerRangePO, statisticalDataDTO, overlimit, 2, powerStatisticsTargetVO);
} else if (0.3 < temp && temp <= 0.4) {
rActivePowerRangePO.setMinsNum3(rActivePowerRangePO.getMinsNum3() + 1);
installLimit(rActivePowerRangePO, statisticalDataDTO, overlimit, 3, powerStatisticsTargetVO);
} else if (0.4 < temp && temp <= 0.5) {
rActivePowerRangePO.setMinsNum4(rActivePowerRangePO.getMinsNum4() + 1);
installLimit(rActivePowerRangePO, statisticalDataDTO, overlimit, 4, powerStatisticsTargetVO);
} else if (0.5 < temp && temp <= 0.6) {
rActivePowerRangePO.setMinsNum5(rActivePowerRangePO.getMinsNum5() + 1);
installLimit(rActivePowerRangePO, statisticalDataDTO, overlimit, 5, powerStatisticsTargetVO);
} else if (0.6 < temp && temp <= 0.7) {
rActivePowerRangePO.setMinsNum6(rActivePowerRangePO.getMinsNum6() + 1);
installLimit(rActivePowerRangePO, statisticalDataDTO, overlimit, 6, powerStatisticsTargetVO);
} else if (0.7 < temp && temp <= 0.8) {
rActivePowerRangePO.setMinsNum7(rActivePowerRangePO.getMinsNum7() + 1);
installLimit(rActivePowerRangePO, statisticalDataDTO, overlimit, 7, powerStatisticsTargetVO);
} else if (0.8 < temp && temp <= 0.9) {
rActivePowerRangePO.setMinsNum8(rActivePowerRangePO.getMinsNum8() + 1);
installLimit(rActivePowerRangePO, statisticalDataDTO, overlimit, 8, powerStatisticsTargetVO);
} else if (temp > 0.9) {
rActivePowerRangePO.setMinsNum9(rActivePowerRangePO.getMinsNum9() + 1);
installLimit(rActivePowerRangePO, statisticalDataDTO, overlimit, 9, powerStatisticsTargetVO);
}
powerStatisticsTargetVOS.add(powerStatisticsTargetVO);
}
if(temp <= 0.1){
//占有率区间个数+1
rActivePowerRangePO.setMinsNum0(rActivePowerRangePO.getMinsNum0() + 1);
//指标越限列表区间区分字段(用于前端查询)
powerStatisticsTargetVO.setField("0");
//判断每个指标是否越限(根据type来区分设置到哪个区间对应的是否越限字段)
installLimit(rActivePowerRangePO,statisticalDataDTO,overlimit,0,powerStatisticsTargetVO);
}else if(0.1 < temp && temp <= 0.2){
rActivePowerRangePO.setMinsNum1(rActivePowerRangePO.getMinsNum1() + 1);
powerStatisticsTargetVO.setField("1");
installLimit(rActivePowerRangePO,statisticalDataDTO,overlimit,1,powerStatisticsTargetVO);
}else if(0.2 < temp && temp <= 0.3){
rActivePowerRangePO.setMinsNum2(rActivePowerRangePO.getMinsNum2() + 1);
powerStatisticsTargetVO.setField("2");
installLimit(rActivePowerRangePO,statisticalDataDTO,overlimit,2,powerStatisticsTargetVO);
}else if(0.3 < temp && temp <= 0.4){
rActivePowerRangePO.setMinsNum3(rActivePowerRangePO.getMinsNum3() + 1);
powerStatisticsTargetVO.setField("3");
installLimit(rActivePowerRangePO,statisticalDataDTO,overlimit,3,powerStatisticsTargetVO);
}else if(0.4 < temp && temp <= 0.5){
rActivePowerRangePO.setMinsNum4(rActivePowerRangePO.getMinsNum4() + 1);
powerStatisticsTargetVO.setField("4");
installLimit(rActivePowerRangePO,statisticalDataDTO,overlimit,4,powerStatisticsTargetVO);
}else if(0.5 < temp && temp <= 0.6){
rActivePowerRangePO.setMinsNum5(rActivePowerRangePO.getMinsNum5() + 1);
powerStatisticsTargetVO.setField("5");
installLimit(rActivePowerRangePO,statisticalDataDTO,overlimit,5,powerStatisticsTargetVO);
}else if(0.6 < temp && temp <= 0.7){
rActivePowerRangePO.setMinsNum6(rActivePowerRangePO.getMinsNum6() + 1);
powerStatisticsTargetVO.setField("6");
installLimit(rActivePowerRangePO,statisticalDataDTO,overlimit,6,powerStatisticsTargetVO);
}else if(0.7 < temp && temp <= 0.8){
rActivePowerRangePO.setMinsNum7(rActivePowerRangePO.getMinsNum7() + 1);
powerStatisticsTargetVO.setField("7");
installLimit(rActivePowerRangePO,statisticalDataDTO,overlimit,7,powerStatisticsTargetVO);
}else if(0.8 < temp && temp <= 0.9){
rActivePowerRangePO.setMinsNum8(rActivePowerRangePO.getMinsNum8() + 1);
powerStatisticsTargetVO.setField("8");
installLimit(rActivePowerRangePO,statisticalDataDTO,overlimit,8,powerStatisticsTargetVO);
}else if(temp > 0.9){
rActivePowerRangePO.setMinsNum9(rActivePowerRangePO.getMinsNum9() + 1);
powerStatisticsTargetVO.setField("9");
installLimit(rActivePowerRangePO,statisticalDataDTO,overlimit,9,powerStatisticsTargetVO);
}
powerStatisticsTargetVOS.add(powerStatisticsTargetVO);
log.info("前监测点为:{},遍历第{}条...,遍历结束,{}",key,index,sdf.format(new Date()));
index++;
}
});
//根据日期及lineId当天不能重复执行
if(this.baseMapper.selectList(lambdaQueryWrapper).isEmpty() && (finalRActivePowerRangeParam.isSearch() && finalRActivePowerRangeParam.isSearchForAdd() || !finalRActivePowerRangeParam.isSearch())){
if (this.baseMapper.selectList(lambdaQueryWrapper).isEmpty() && (finalRActivePowerRangeParam.isSearch() && finalRActivePowerRangeParam.isSearchForAdd() || !finalRActivePowerRangeParam.isSearch())) {
this.baseMapper.insert(rActivePowerRangePO);
}
}
}
}
});
log.info("当前遍历的功率根据监测点分组后长度为:{},集合总长为:{},遍历结束,{}",map.size(),dataHarmPowerPS.size(),sdf.format(new Date()));
if(rActivePowerRangeParam.isSearch()){
//重点说明:powerStatisticsTargetVO结构(维度)为:time可能多组相同,取决于功率表data_harmpower_p中的相别及统计方式,标识每个指标是否越限,总之一句话:每条数据当前时间中八个指标是否越限及他们的相别和统计方式是什么
log.info("当前遍历的功率根据监测点分组后长度为:{},集合总长为:{},遍历结束,{}", lineMap.size(), dataHarmPowerPS.size(), sdf.format(new Date()));
if (rActivePowerRangeParam.isSearch()) {
return powerStatisticsTargetVOS;
}
return null;
}
private void installLimit(RActivePowerRangePO rActivePowerRangePO,StatisticalDataDTO statisticalDataDTO,Overlimit overlimit,int type,PowerStatisticsTargetVO powerStatisticsTargetVO){
//记录统计方式
powerStatisticsTargetVO.setValueType(statisticalDataDTO.getValueType());
//记录相别
powerStatisticsTargetVO.setPhasicType(statisticalDataDTO.getPhaseType());
//以下的结果集按道理最多只有一条(因为确定的相别统计方式及开始和结束时间都一致,除了有谐波次数的指标)
private void installLimit(RActivePowerRangePO rActivePowerRangePO, StatisticalDataDTO statisticalDataDTO, Overlimit overlimit, int type, PowerStatisticsTargetVO powerStatisticsTargetVO) {
//根据当前最大值的功率查询各个指标信息
//电压偏差
List<StatisticalDataDTO> vu_dev = commonQuery(InfluxDBTableConstant.DATA_V,"vu_dev",statisticalDataDTO,null,null);
List<StatisticalDataDTO> vu_dev = commonQuery(InfluxDBTableConstant.DATA_V, "vuDev", statisticalDataDTO, null, null);
//谐波电压
List<StatisticalDataDTO> v_thd = commonQuery(InfluxDBTableConstant.DATA_V,"v_thd",statisticalDataDTO,null,null);
List<StatisticalDataDTO> v = commonQuery(InfluxDBTableConstant.DATA_HARM_RATE_V,"v",statisticalDataDTO,2,25);
List<StatisticalDataDTO> v_thd = commonQuery(InfluxDBTableConstant.DATA_V, "vThd", statisticalDataDTO, null, null);
List<StatisticalDataDTO> v = commonQuery(InfluxDBTableConstant.DATA_HARM_RATE_V, "v", statisticalDataDTO, 2, 25);
//谐波电流
List<StatisticalDataDTO> i = commonQuery(InfluxDBTableConstant.DATA_I,"i",statisticalDataDTO,2,25);
List<StatisticalDataDTO> i = commonQuery(InfluxDBTableConstant.DATA_I, "i", statisticalDataDTO, 2, 25);
//三相电压不平衡度
List<StatisticalDataDTO> v_unbalance = commonQuery(InfluxDBTableConstant.DATA_V,"v_unbalance",statisticalDataDTO,null,null);
List<StatisticalDataDTO> v_unbalance = commonQuery(InfluxDBTableConstant.DATA_V, "vUnbalance", statisticalDataDTO, null, null);
//电压波动
List<StatisticalDataDTO> fluc = commonQuery(InfluxDBTableConstant.DATA_FLUC,"fluc",statisticalDataDTO,null,null);
List<StatisticalDataDTO> fluc = commonQuery(InfluxDBTableConstant.DATA_FLUC, "fluc", statisticalDataDTO, null, null);
//长时闪变
List<StatisticalDataDTO> plt = commonQuery(InfluxDBTableConstant.DATA_PLT,"plt",statisticalDataDTO,null,null);
List<StatisticalDataDTO> plt = commonQuery(InfluxDBTableConstant.DATA_PLT, "plt", statisticalDataDTO, null, null);
//间谐波电压含有率
List<StatisticalDataDTO> v1 = commonQuery(InfluxDBTableConstant.DATA_IN_HARM_V,"v",statisticalDataDTO,1,16);
List<StatisticalDataDTO> v1 = commonQuery(InfluxDBTableConstant.DATA_IN_HARM_V, "v", statisticalDataDTO, 1, 16);
//电流不平衡度
List<StatisticalDataDTO> i_unbalance = commonQuery(InfluxDBTableConstant.DATA_I,"i_unbalance",statisticalDataDTO,null,null);
//此标识用来记录当前区间下指标是否越限(0%~10%是否越限,10%~20%是否越限.....)
List<StatisticalDataDTO> i_unbalance = commonQuery(InfluxDBTableConstant.DATA_I, "iUnbalance", statisticalDataDTO, null, null);
//此标识用来记录当前区间下指标是否越限
boolean isLimit = false;
//电压偏差国标限值
powerStatisticsTargetVO.setVoltageOffsetLimit(overlimit.getVoltageDev());
//电压偏差是否越限比较
for(StatisticalDataDTO dto : vu_dev){
//电压偏差具体值
powerStatisticsTargetVO.setVoltageOffsetData(dto.getValue());
//电压偏差国标限值有额外的判断
if(dto.getValue()>0){
powerStatisticsTargetVO.setVoltageOffsetLimit(overlimit.getVoltageDev());
}else{
powerStatisticsTargetVO.setVoltageOffsetLimit(overlimit.getUvoltageDev());
}
//如果vu_dev>0,使用上偏差限值对比如果vu_dev<0,使用下偏差限值对比
if((dto.getValue()>0 && Double.compare(dto.getValue(),overlimit.getVoltageDev())>0)
|| (dto.getValue()<0 && Double.compare(dto.getValue(),overlimit.getUvoltageDev())>0)){
isLimit = true;
//标志电压偏差越限
powerStatisticsTargetVO.setVoltageOffset(1);
}
//电压偏差是否越限比较(此指标比较较为特殊所以单独一个重载的判断方法)
Float isVoltageOffsetLimit = isLimit(vu_dev, overlimit);
//电压偏差指标详细数据
powerStatisticsTargetVO.setVoltageOffsetList(toThdDataVO(vu_dev, Param.voltageOffset, null, isVoltageOffsetLimit));
if (isVoltageOffsetLimit != null) {
isLimit = true;
//电压偏差越限
powerStatisticsTargetVO.setVoltageOffset(1);
}
//谐波电压比较较为特殊需要比较两个点(以v为主)
//谐波电压是否越限比较
for(StatisticalDataDTO dto : v_thd){
if(Double.compare(dto.getValue(),overlimit.getUaberrance())>0){
isLimit = true;
powerStatisticsTargetVO.setVTimes(1);
}
//谐波电压比较较为特殊需要比较两个点
//谐波电压指标详细数据
powerStatisticsTargetVO.setVTimesList(toThdDataVO(v, Param.vTimes, overlimit, null));
//谐波电压是否越限比较(不过指标详细数据还是取data_harmrate_v表里的数据)
if (isLimit(v, Param.vTimes, InfluxDBTableConstant.CP95, overlimit, null)) {
isLimit = true;
//谐波电流越限
powerStatisticsTargetVO.setVTimes(1);
}
int num = 2;
for(StatisticalDataDTO dto : v){
Float value = frequencyValue(overlimit,num,"uharm");
if(value != null){
//记录谐波电压2到25次国标限值(当然这里还是要以influxDb里为主,虽然当前遍历的集合明确查询2-25次但是为了防止influxDb可能缺失一些次数的数据,所以国标限值次数跟着influxDb走)
powerStatisticsTargetVO.getVTimesLimit().add(value);
//谐波电压具体值
powerStatisticsTargetVO.getVTimesData().add(dto.getValue());
if(Double.compare(dto.getValue(),value)>0){
isLimit = true;
//标志谐波电压越限
powerStatisticsTargetVO.setVTimes(1);
}
}
num++;
if (isLimit(v_thd, Param.vTimes, InfluxDBTableConstant.CP95, null, overlimit.getUaberrance())) {
isLimit = true;
//谐波电流越限
powerStatisticsTargetVO.setVTimes(1);
}
num = 2;
//谐波电流指标详细数据
powerStatisticsTargetVO.setITimestList(toThdDataVO(i, Param.iTimes, overlimit, null));
//谐波电流是否越限比较
for(StatisticalDataDTO dto : i){
Float value = frequencyValue(overlimit,num,"iharm");
if(value != null){
//记录谐波电流2到25次国标限值(当然这里还是要以influxDb里为主,虽然当前遍历的集合明确查询2-25次但是为了防止influxDb可能缺失一些次数的数据,所以国标限值次数跟着influxDb走)
powerStatisticsTargetVO.getITimesLimit().add(value);
//谐波电流具体值
powerStatisticsTargetVO.getITimesData().add(dto.getValue());
if(Double.compare(dto.getValue(),value)>0){
isLimit = true;
//标志谐波电流越限
powerStatisticsTargetVO.setITimes(1);
}
}
num++;
if (isLimit(i, Param.vTimes, InfluxDBTableConstant.CP95, overlimit, null)) {
isLimit = true;
//谐波电流越限
powerStatisticsTargetVO.setITimes(1);
}
//三相电压不平衡度国标限值
powerStatisticsTargetVO.setUbalanceLimit(overlimit.getUbalance());
//三相电压不平衡度指标详细数据
powerStatisticsTargetVO.setUbalanceList(toThdDataVO(v_unbalance, Param.ubalance, null, overlimit.getUbalance()));
//三相电压不平衡度是否越限比较
for(StatisticalDataDTO dto : v_unbalance){
//三相电压不平衡度具体值
powerStatisticsTargetVO.setUbalanceData(dto.getValue());
if(Double.compare(dto.getValue(),overlimit.getUbalance())>0){
isLimit = true;
//标志三相电压不平衡度越限
powerStatisticsTargetVO.setUbalance(1);
}
if (isLimit(v_unbalance, Param.ubalance, InfluxDBTableConstant.CP95, null, overlimit.getUbalance())) {
isLimit = true;
//三相电压不平衡度越限
powerStatisticsTargetVO.setUbalance(1);
}
//电压波动国标限值
powerStatisticsTargetVO.setVoltageFluctuationLimit(overlimit.getVoltageFluctuation());
//电压波动指标详细数据
powerStatisticsTargetVO.setVoltageFluctuationList(toThdDataVO(fluc, Param.voltageFluctuation, null, overlimit.getVoltageFluctuation()));
//电压波动是否越限比较
for(StatisticalDataDTO dto : fluc){
//电压波动具体值
powerStatisticsTargetVO.setVoltageFluctuationData(dto.getValue());
if(Double.compare(dto.getValue(),overlimit.getVoltageFluctuation())>0){
isLimit = true;
//标志电压波动越限
powerStatisticsTargetVO.setVoltageFluctuation(1);
}
if (isLimit(fluc, Param.voltageFluctuation, InfluxDBTableConstant.MAX, null, overlimit.getVoltageFluctuation())) {
isLimit = true;
//电压波动变越限
powerStatisticsTargetVO.setVoltageFluctuation(1);
}
//长时闪变国标限值
powerStatisticsTargetVO.setFlickerLimit(overlimit.getFlicker());
//长时闪变指标详细数据
powerStatisticsTargetVO.setFlickerList(toThdDataVO(plt, Param.flicker, null, overlimit.getFlicker()));
//长时闪变是否越限比较
for(StatisticalDataDTO dto : plt){
//长时闪变具体值
powerStatisticsTargetVO.setFlickerData(dto.getValue());
if(Double.compare(dto.getValue(),overlimit.getFlicker())>0){
isLimit = true;
//标志长时闪变越限
powerStatisticsTargetVO.setFlicker(1);
}
if (isLimit(plt, Param.flicker, InfluxDBTableConstant.MAX, null, overlimit.getFlicker())) {
isLimit = true;
//长时闪变越限
powerStatisticsTargetVO.setFlicker(1);
}
num = 1;
//间谐波电压含有率指标详细数据
powerStatisticsTargetVO.setInterHarmonicList(toThdDataVO(v1, Param.interHarmonic, overlimit, null));
//间谐波电压含有率是否越限比较
for(StatisticalDataDTO dto : v1){
Float value = frequencyValue(overlimit,num,"inuharm");
if(value != null){
//记录间谐波电压含有率1到16次国标限值(当然这里还是要以influxDb里为主,虽然当前遍历的集合明确查询1-16次但是为了防止influxDb可能缺失一些次数的数据,所以国标限值次数跟着influxDb走)
powerStatisticsTargetVO.getInterHarmonicLimit().add(value);
//间谐波电压含有率具体值
powerStatisticsTargetVO.getInterHarmonicData().add(dto.getValue());
if(Double.compare(dto.getValue(),value)>0){
isLimit = true;
//标志间谐波电压含有率越限
powerStatisticsTargetVO.setInterHarmonic(1);
}
}
num++;
if (isLimit(v1, Param.interHarmonic, InfluxDBTableConstant.CP95, overlimit, null)) {
isLimit = true;
//间谐波电压含有率越限
powerStatisticsTargetVO.setInterHarmonic(1);
}
//电流不平衡度国标限值
powerStatisticsTargetVO.setSequenceCurrentUnbalanceLimit(overlimit.getINeg());
//电流不平衡度指标详细数据
powerStatisticsTargetVO.setSequenceCurrentUnbalanceList(toThdDataVO(i_unbalance, Param.sequenceCurrentUnbalance, null, overlimit.getINeg()));
//电流不平衡度是否越限比较
for(StatisticalDataDTO dto : i_unbalance){
//电流不平衡度具体值
powerStatisticsTargetVO.setSequenceCurrentUnbalanceData(dto.getValue());
if(Double.compare(dto.getValue(),overlimit.getINeg())>0){
isLimit = true;
//标志电流不平衡度越限
powerStatisticsTargetVO.setSequenceCurrentUnbalance(1);
}
if (isLimit(i_unbalance, Param.sequenceCurrentUnbalance, null, null, overlimit.getINeg())) {
isLimit = true;
//电流不平衡度越限
powerStatisticsTargetVO.setSequenceCurrentUnbalance(1);
}
//区间是否越限标识
switch (type){
switch (type) {
case 0:
if(isLimit) rActivePowerRangePO.setIsOrNot0(1);
if (isLimit) rActivePowerRangePO.setIsOrNot0(1);
break;
case 1:
if(isLimit) rActivePowerRangePO.setIsOrNot1(1);
if (isLimit) rActivePowerRangePO.setIsOrNot1(1);
break;
case 2:
if(isLimit) rActivePowerRangePO.setIsOrNot2(1);
if (isLimit) rActivePowerRangePO.setIsOrNot2(1);
break;
case 3:
if(isLimit) rActivePowerRangePO.setIsOrNot3(1);
if (isLimit) rActivePowerRangePO.setIsOrNot3(1);
break;
case 4:
if(isLimit) rActivePowerRangePO.setIsOrNot4(1);
if (isLimit) rActivePowerRangePO.setIsOrNot4(1);
break;
case 5:
if(isLimit) rActivePowerRangePO.setIsOrNot5(1);
if (isLimit) rActivePowerRangePO.setIsOrNot5(1);
break;
case 6:
if(isLimit) rActivePowerRangePO.setIsOrNot6(1);
if (isLimit) rActivePowerRangePO.setIsOrNot6(1);
break;
case 7:
if(isLimit) rActivePowerRangePO.setIsOrNot7(1);
if (isLimit) rActivePowerRangePO.setIsOrNot7(1);
break;
case 8:
if(isLimit) rActivePowerRangePO.setIsOrNot8(1);
if (isLimit) rActivePowerRangePO.setIsOrNot8(1);
break;
case 9:
if(isLimit) rActivePowerRangePO.setIsOrNot9(1);
if (isLimit) rActivePowerRangePO.setIsOrNot9(1);
break;
}
}
private Float isLimit(List<StatisticalDataDTO> list, Overlimit overlimit) {
List<StatisticalDataDTO> maxList = list.stream().filter(dto -> dto.equals(InfluxDBTableConstant.MAX)).collect(Collectors.toList());
List<StatisticalDataDTO> minList = list.stream().filter(dto -> dto.equals(InfluxDBTableConstant.MIN)).collect(Collectors.toList());
StatisticalDataDTO maxDto = maxList.stream().max(Comparator.comparingDouble(StatisticalDataDTO::getValue)).orElse(null);
StatisticalDataDTO minDto = minList.stream().min(Comparator.comparingDouble(StatisticalDataDTO::getValue)).orElse(null);
if (!maxList.isEmpty()) {
if (Double.compare(maxDto.getValue(), 0) > 0 && Double.compare(maxDto.getValue(), overlimit.getVoltageDev()) > 0) {
return overlimit.getVoltageDev();
}
}
if (!minList.isEmpty()) {
if (Double.compare(minDto.getValue(), 0) < 0 && Double.compare(maxDto.getValue(), overlimit.getUvoltageDev()) > 0) {
return overlimit.getUvoltageDev();
}
}
return null;
}
private boolean isLimit(List<StatisticalDataDTO> list, String name, String valueType, Overlimit overlimit, Float limit) {
AtomicBoolean ist = new AtomicBoolean(false);
if (valueType != null) {
list = list.stream().filter(dto -> dto.getValueType().equals(valueType)).collect(Collectors.toList());
}
if (overlimit != null) {
String field = "";
switch (name) {
case Param.vTimes:
field = "uharm";
break;
case Param.iTimes:
field = "iharm";
break;
case Param.interHarmonic:
field = "inuharm";
break;
}
Map<String, List<StatisticalDataDTO>> frequencyMap = list.stream().collect(Collectors.groupingBy(StatisticalDataDTO::getFrequency));
String finalField = field;
frequencyMap.forEach((frequency, frequencyGroupList) -> {
StatisticalDataDTO statisticalDataDTO = frequencyGroupList.stream().max(Comparator.comparingDouble(StatisticalDataDTO::getValue)).orElse(null);
Float value = (Float) reflexObjValue(overlimit, finalField + Integer.parseInt(frequency));
if (value != null) {
if (statisticalDataDTO.getValue() != null && Double.compare(statisticalDataDTO.getValue(), value) > 0) {
ist.set(true);
return;
}
}
});
} else {
StatisticalDataDTO statisticalDataDTO = list.stream().max(Comparator.comparingDouble(StatisticalDataDTO::getValue)).orElse(null);
if (statisticalDataDTO != null && statisticalDataDTO.getValue() != null && Double.compare(statisticalDataDTO.getValue(), limit) > 0) {
return true;
}
}
return ist.get();
}
//根据各个指标数组信息组装成前端需要的格式
private List<ThdDataVO> toThdDataVO(List<StatisticalDataDTO> list, String name, Overlimit overlimit, Float limit) {
List<ThdDataVO> thdDataVOS = new ArrayList<>();
//带有谐波次数的指标
if (overlimit != null) {
String field = "";
double c = 0;
switch (name) {
//谐波电压和电流默认谐波次数2-25
case Param.vTimes:
field = "uharm";
break;
case Param.iTimes:
field = "iharm";
break;
//间谐波电压含有率默认谐波次数1-16
case Param.interHarmonic:
field = "inuharm";
c = 0.5;
break;
}
//根据谐波次数分组,分组完则frequencyMap数据维度:当前谐波次数下的各个统计方式和相别他们的值是多少
Map<String, List<StatisticalDataDTO>> frequencyMap = list.stream().collect(Collectors.groupingBy(StatisticalDataDTO::getFrequency));
double finalC = c;
String finalField = field;
frequencyMap.forEach((frequency, frequencyGroupList) -> {
Integer frequencyNum = Integer.parseInt(frequency);
//反射获取当前谐波次数对应的国标限值
Float frequencyLimit = (Float) reflexObjValue(overlimit, finalField + frequencyNum);
//相别和统计方式的值和ThdDataVO字段相对于
ThdDataVO tdv = initThdDataVO(frequencyGroupList,frequencyLimit);
if (tdv != null) {
tdv.setAnotherName(name + (((frequencyNum - finalC) + "").replace(".0", "")) + "");
tdv.setLimit((Float) reflexObjValue(overlimit, finalField + frequencyNum));
tdv.setFrequency(frequencyNum);
thdDataVOS.add(tdv);
}
});
} else {
//无谐波次数
ThdDataVO tdv = initThdDataVO(list,limit);
if (tdv != null) {
tdv.setAnotherName(name);
tdv.setLimit(limit);
thdDataVOS.add(tdv);
}
}
return thdDataVOS.stream().sorted(Comparator.comparing(ThdDataVO::getFrequency)).collect(Collectors.toList());
}
private ThdDataVO initThdDataVO(List<StatisticalDataDTO> list,Float limit) {
ThdDataVO tdv = new ThdDataVO();
boolean isF = false;
//list包含了一组不同相别不同统计方式的数据(最多12条,因为统计方式和相别自由组合最多12条)
for (StatisticalDataDTO statisticalDataDTO : list) {
String valueType = statisticalDataDTO.getValueType();
String phasicType = statisticalDataDTO.getPhaseType();
String value = null;
if (statisticalDataDTO.getValue() != null) {
value = df.format(statisticalDataDTO.getValue());
//判断是否有指标越界(不管哪一个相别及统计方式的指标,)
if(Double.compare(statisticalDataDTO.getValue(), limit) > 0){
isF = true;
}
}
//统计方式和相别渲染ThdDataVO
switch (valueType) {
case InfluxDBTableConstant.AVG:
switch (phasicType) {
case InfluxDBTableConstant.PHASE_TYPE_A:
tdv.setAVGPhaseA(value);
break;
case InfluxDBTableConstant.PHASE_TYPE_B:
tdv.setAVGPhaseB(value);
break;
case InfluxDBTableConstant.PHASE_TYPE_C:
tdv.setAVGPhaseC(value);
break;
}
break;
case InfluxDBTableConstant.CP95:
switch (phasicType) {
case InfluxDBTableConstant.PHASE_TYPE_A:
tdv.setCP95PhaseA(value);
break;
case InfluxDBTableConstant.PHASE_TYPE_B:
tdv.setCP95PhaseB(value);
break;
case InfluxDBTableConstant.PHASE_TYPE_C:
tdv.setCP95PhaseC(value);
break;
}
break;
case InfluxDBTableConstant.MIN:
switch (phasicType) {
case InfluxDBTableConstant.PHASE_TYPE_A:
tdv.setMINPhaseA(value);
break;
case InfluxDBTableConstant.PHASE_TYPE_B:
tdv.setMINPhaseB(value);
break;
case InfluxDBTableConstant.PHASE_TYPE_C:
tdv.setMINPhaseC(value);
break;
}
break;
case InfluxDBTableConstant.MAX:
switch (phasicType) {
case InfluxDBTableConstant.PHASE_TYPE_A:
tdv.setMAXPhaseA(value);
break;
case InfluxDBTableConstant.PHASE_TYPE_B:
tdv.setMAXPhaseB(value);
break;
case InfluxDBTableConstant.PHASE_TYPE_C:
tdv.setMAXPhaseC(value);
break;
}
break;
}
}
//如果所有的相别和统计方式都没有值则可直接忽略该条数据或者没有一个相别及统计方式的指标越界也可以忽略
if (tdv.getAVGPhaseA() != null || tdv.getAVGPhaseB() != null
|| tdv.getAVGPhaseC() != null || tdv.getCP95PhaseA() != null
|| tdv.getCP95PhaseB() != null || tdv.getCP95PhaseC() != null
|| tdv.getMINPhaseA() != null || tdv.getMINPhaseB() != null
|| tdv.getMINPhaseC() != null || tdv.getMAXPhaseA() != null
|| tdv.getMAXPhaseB() != null || tdv.getMAXPhaseC() != null) {
if(isF){
return tdv;
}
}
return null;
}
//组装公共查询(有谐波次数指标查询和没有谐波次数指标查询)
private List<StatisticalDataDTO> commonQuery(String tableName,String columnName,StatisticalDataDTO statisticalDataDTO,Integer start,Integer end){
List<CommonQueryParam> commonQueryParams = new ArrayList<>();
//不管哪种时间是固定的
private List<StatisticalDataDTO> commonQuery(String tableName, String columnName, StatisticalDataDTO statisticalDataDTO, Integer start, Integer end) {
String time = statisticalDataDTO.getTime().atZone(ZoneId.systemDefault()).format(formatter);
time = "2024-08-10 00:00:00";
CommonQueryParam commonQueryParam = new CommonQueryParam();
//无谐波次数指标查询
if(start == null){
commonQueryParam.setStartTime(time);
commonQueryParam.setEndTime(time);
commonQueryParam.setLineId(statisticalDataDTO.getLineId());
commonQueryParam.setPhasic(statisticalDataDTO.getPhaseType());
commonQueryParam.setDataType(statisticalDataDTO.getValueType());
commonQueryParam.setTableName(tableName);
commonQueryParam.setColumnName(columnName);
commonQueryParams.add(commonQueryParam);
}else{
//有谐波次数指标查询
for (int i = start; i <= end; i++) {
commonQueryParam = new CommonQueryParam();
commonQueryParam.setStartTime(time);
commonQueryParam.setEndTime(time);
commonQueryParam.setLineId(statisticalDataDTO.getLineId());
commonQueryParam.setPhasic(statisticalDataDTO.getPhaseType());
commonQueryParam.setDataType(statisticalDataDTO.getValueType());
commonQueryParam.setTableName(tableName);
commonQueryParam.setColumnName(columnName+"_"+i);
commonQueryParams.add(commonQueryParam);
List<Object> data = null;
switch (tableName) {
case InfluxDBTableConstant.DATA_V:
data = Collections.singletonList(iDataVService.getNewDataV(statisticalDataDTO.getLineId(), time, time));
break;
case InfluxDBTableConstant.DATA_HARM_RATE_V:
data = Collections.singletonList(dataHarmRateVService.getNewDataHarmRateV(statisticalDataDTO.getLineId(), time, time));
break;
case InfluxDBTableConstant.DATA_I:
data = Collections.singletonList(iDataIService.getNewDataI(statisticalDataDTO.getLineId(), time, time));
break;
case InfluxDBTableConstant.DATA_FLUC:
data = Collections.singletonList(dataFlucService.getNewDataFluc(statisticalDataDTO.getLineId(), time, time));
break;
case InfluxDBTableConstant.DATA_PLT:
data = Collections.singletonList(dataPltService.getNewDataPlt(statisticalDataDTO.getLineId(), time, time));
break;
case InfluxDBTableConstant.DATA_IN_HARM_V:
data = Collections.singletonList(dataInHarmVService.getNewDataInHarmV(statisticalDataDTO.getLineId(), time, time));
break;
}
List<StatisticalDataDTO> list = new ArrayList<>();
if (!data.isEmpty()) {
data = (List<Object>) data.get(0);
for (Object item : data) {
String phaseType = (reflexObjValue(item, "phaseType").toString());
if (PHASE.contains(phaseType)) {
if (start != null) {
for (int i = start; i <= end; i++) {
StatisticalDataDTO dto = new StatisticalDataDTO();
dto.setPhaseType(phaseType);
dto.setValueType((reflexObjValue(item, "valueType").toString()));
dto.setTime((Instant) reflexObjValue(item, "time"));
dto.setLineId(reflexObjValue(item, "lineId").toString());
dto.setValue((Double) reflexObjValue(item, columnName + i));
dto.setFrequency(i + "");
list.add(dto);
}
} else {
StatisticalDataDTO dto = new StatisticalDataDTO();
dto.setPhaseType(phaseType);
dto.setValueType((reflexObjValue(item, "valueType").toString()));
dto.setTime((Instant) reflexObjValue(item, "time"));
dto.setLineId(reflexObjValue(item, "lineId").toString());
dto.setValue((Double) reflexObjValue(item, columnName));
list.add(dto);
}
}
}
}
return commonService.getNewDeviceRtDataByTime(commonQueryParams);
return list;
}
//反射获取国标限值对应的字段
private Float frequencyValue(Overlimit overlimit,int num,String flag){
//反射获取值
private Object reflexObjValue(Object obj, String fieldName) {
try {
Class clazz = overlimit.getClass();
Field field = clazz.getDeclaredField(flag+num);
Class clazz = obj.getClass();
Field field = clazz.getDeclaredField(fieldName);
field.setAccessible(true);
return Float.parseFloat(field.get(overlimit).toString());
return field.get(obj);
} catch (Exception e) {
e.printStackTrace();
}
@@ -463,49 +644,59 @@ public class RActivePowerRangeServiceImpl extends MppServiceImpl<RActivePowerRan
}
//根据时间间隔获取间隔前时间或获取昨晚最晚时间
private String getTime(long interval,int type){
private String getTime(long interval, int type) {
DateTimeFormatter sdf = DateTimeFormatter.ofPattern(DateUtils.DATE_FORMAT_10);
LocalDate yesterday;
if(type == 0){
if (type == 0) {
yesterday = LocalDate.now().minusDays(interval);
return yesterday.format(sdf)+Param.BEGIN;
}else{
return yesterday.format(sdf) + Param.BEGIN;
} else {
yesterday = LocalDate.now().minusDays(1);
return yesterday.format(sdf)+Param.END;
return yesterday.format(sdf) + Param.END;
}
}
@Override
public RActivePowerRangePO getDataByLineId(String lineId,String startTime,String endTime) {
public RActivePowerRangePO getDataByLineId(String lineId, String startTime, String endTime) {
LambdaQueryWrapper<RActivePowerRangePO> lambdaQueryWrapper = new LambdaQueryWrapper();
lambdaQueryWrapper.eq(RActivePowerRangePO::getLineId,lineId).eq(RActivePowerRangePO::getState,"1")
.between(RActivePowerRangePO::getTimeId,startTime,endTime);
lambdaQueryWrapper.eq(RActivePowerRangePO::getLineId, lineId).eq(RActivePowerRangePO::getState, "1")
.between(RActivePowerRangePO::getTimeId, startTime, endTime);
List<RActivePowerRangePO> rActivePowerRangePOS = this.baseMapper.selectList(lambdaQueryWrapper);
if(!rActivePowerRangePOS.isEmpty()){
if (!rActivePowerRangePOS.isEmpty()) {
RActivePowerRangePO rActivePowerRangePO = new RActivePowerRangePO();
rActivePowerRangePO.setLineId(lineId);
//多条记录则次数累加,是否越限只要有一个区间越限则统一视为该区间越限
for(RActivePowerRangePO rangePO : rActivePowerRangePOS){
rActivePowerRangePO.setMinsNum0(rangePO.getMinsNum0()+rActivePowerRangePO.getMinsNum0());
rActivePowerRangePO.setMinsNum1(rangePO.getMinsNum1()+rActivePowerRangePO.getMinsNum1());
rActivePowerRangePO.setMinsNum2(rangePO.getMinsNum2()+rActivePowerRangePO.getMinsNum2());
rActivePowerRangePO.setMinsNum3(rangePO.getMinsNum3()+rActivePowerRangePO.getMinsNum3());
rActivePowerRangePO.setMinsNum4(rangePO.getMinsNum4()+rActivePowerRangePO.getMinsNum4());
rActivePowerRangePO.setMinsNum5(rangePO.getMinsNum5()+rActivePowerRangePO.getMinsNum5());
rActivePowerRangePO.setMinsNum6(rangePO.getMinsNum6()+rActivePowerRangePO.getMinsNum6());
rActivePowerRangePO.setMinsNum7(rangePO.getMinsNum7()+rActivePowerRangePO.getMinsNum7());
rActivePowerRangePO.setMinsNum8(rangePO.getMinsNum8()+rActivePowerRangePO.getMinsNum8());
rActivePowerRangePO.setMinsNum9(rangePO.getMinsNum9()+rActivePowerRangePO.getMinsNum9());
rActivePowerRangePO.setIsOrNot0(rangePO.getIsOrNot0()+rActivePowerRangePO.getIsOrNot0());
rActivePowerRangePO.setIsOrNot1(rangePO.getIsOrNot1()+rActivePowerRangePO.getIsOrNot1());
rActivePowerRangePO.setIsOrNot2(rangePO.getIsOrNot2()+rActivePowerRangePO.getIsOrNot2());
rActivePowerRangePO.setIsOrNot3(rangePO.getIsOrNot3()+rActivePowerRangePO.getIsOrNot3());
rActivePowerRangePO.setIsOrNot4(rangePO.getIsOrNot4()+rActivePowerRangePO.getIsOrNot4());
rActivePowerRangePO.setIsOrNot5(rangePO.getIsOrNot5()+rActivePowerRangePO.getIsOrNot5());
rActivePowerRangePO.setIsOrNot6(rangePO.getIsOrNot6()+rActivePowerRangePO.getIsOrNot6());
rActivePowerRangePO.setIsOrNot7(rangePO.getIsOrNot7()+rActivePowerRangePO.getIsOrNot7());
rActivePowerRangePO.setIsOrNot8(rangePO.getIsOrNot8()+rActivePowerRangePO.getIsOrNot8());
rActivePowerRangePO.setIsOrNot9(rangePO.getIsOrNot9()+rActivePowerRangePO.getIsOrNot9());
for (RActivePowerRangePO rangePO : rActivePowerRangePOS) {
rActivePowerRangePO.setMinsNum0(rangePO.getMinsNum0() + rActivePowerRangePO.getMinsNum0());
rActivePowerRangePO.setMinsNum1(rangePO.getMinsNum1() + rActivePowerRangePO.getMinsNum1());
rActivePowerRangePO.setMinsNum2(rangePO.getMinsNum2() + rActivePowerRangePO.getMinsNum2());
rActivePowerRangePO.setMinsNum3(rangePO.getMinsNum3() + rActivePowerRangePO.getMinsNum3());
rActivePowerRangePO.setMinsNum4(rangePO.getMinsNum4() + rActivePowerRangePO.getMinsNum4());
rActivePowerRangePO.setMinsNum5(rangePO.getMinsNum5() + rActivePowerRangePO.getMinsNum5());
rActivePowerRangePO.setMinsNum6(rangePO.getMinsNum6() + rActivePowerRangePO.getMinsNum6());
rActivePowerRangePO.setMinsNum7(rangePO.getMinsNum7() + rActivePowerRangePO.getMinsNum7());
rActivePowerRangePO.setMinsNum8(rangePO.getMinsNum8() + rActivePowerRangePO.getMinsNum8());
rActivePowerRangePO.setMinsNum9(rangePO.getMinsNum9() + rActivePowerRangePO.getMinsNum9());
rActivePowerRangePO.setIsOrNot0(rangePO.getIsOrNot0() + rActivePowerRangePO.getIsOrNot0());
rActivePowerRangePO.setIsOrNot1(rangePO.getIsOrNot1() + rActivePowerRangePO.getIsOrNot1());
rActivePowerRangePO.setIsOrNot2(rangePO.getIsOrNot2() + rActivePowerRangePO.getIsOrNot2());
rActivePowerRangePO.setIsOrNot3(rangePO.getIsOrNot3() + rActivePowerRangePO.getIsOrNot3());
rActivePowerRangePO.setIsOrNot4(rangePO.getIsOrNot4() + rActivePowerRangePO.getIsOrNot4());
rActivePowerRangePO.setIsOrNot5(rangePO.getIsOrNot5() + rActivePowerRangePO.getIsOrNot5());
rActivePowerRangePO.setIsOrNot6(rangePO.getIsOrNot6() + rActivePowerRangePO.getIsOrNot6());
rActivePowerRangePO.setIsOrNot7(rangePO.getIsOrNot7() + rActivePowerRangePO.getIsOrNot7());
rActivePowerRangePO.setIsOrNot8(rangePO.getIsOrNot8() + rActivePowerRangePO.getIsOrNot8());
rActivePowerRangePO.setIsOrNot9(rangePO.getIsOrNot9() + rActivePowerRangePO.getIsOrNot9());
rActivePowerRangePO.setMinsTime0(rangePO.getMinsTime0() + "&" + rActivePowerRangePO.getMinsTime0());
rActivePowerRangePO.setMinsTime1(rangePO.getMinsTime1() + "&" + rActivePowerRangePO.getMinsTime1());
rActivePowerRangePO.setMinsTime2(rangePO.getMinsTime2() + "&" + rActivePowerRangePO.getMinsTime2());
rActivePowerRangePO.setMinsTime3(rangePO.getMinsTime3() + "&" + rActivePowerRangePO.getMinsTime3());
rActivePowerRangePO.setMinsTime4(rangePO.getMinsTime4() + "&" + rActivePowerRangePO.getMinsTime4());
rActivePowerRangePO.setMinsTime5(rangePO.getMinsTime5() + "&" + rActivePowerRangePO.getMinsTime5());
rActivePowerRangePO.setMinsTime6(rangePO.getMinsTime6() + "&" + rActivePowerRangePO.getMinsTime6());
rActivePowerRangePO.setMinsTime7(rangePO.getMinsTime7() + "&" + rActivePowerRangePO.getMinsTime7());
rActivePowerRangePO.setMinsTime8(rangePO.getMinsTime8() + "&" + rActivePowerRangePO.getMinsTime8());
rActivePowerRangePO.setMinsTime9(rangePO.getMinsTime9() + "&" + rActivePowerRangePO.getMinsTime9());
}
return rActivePowerRangePO;
}

View File

@@ -26,6 +26,7 @@ public enum SupervisionResponseEnum {
IMPORT_DEV_ERROR("A00550","导入终端检测失败"),
DELETE_TO_BE_SUBMITTED("A00550","流程删除失败,只有待提交信息可删除!"),
EXISTENCE_OR_NOT("A00550","信息查询为空,请检查信息是否存在!"),
NAME_EXISTS("A00550","名称重复"),
;
private final String code;

View File

@@ -0,0 +1,75 @@
package com.njcn.supervision.pojo.param.databank;
import com.njcn.db.bo.BaseEntity;
import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
import java.util.List;
/**
*
* Description:
* Date: 2024/9/10 14:16【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class LibAlgorithmParam extends BaseEntity {
/**
* 上级id
*/
@ApiModelProperty(value="上级id")
private String pid;
/**
* 算法名称
*/
@NotBlank(message ="名称不能为空")
@ApiModelProperty(value="算法名称")
private String name;
/**
* 定义
*/
@ApiModelProperty(value="定义")
private String definition;
/**
* 计算周期0日1月2季3年
*/
@ApiModelProperty(value="计算周期0日1月2季3年")
private String period;
/**
* 数据来源(单体,数据中台....
*/
@ApiModelProperty(value="数据来源(单体,数据中台....")
private String source;
private Integer useFLag;
@Data
@EqualsAndHashCode(callSuper = true)
public static class LibAlgorithmParamUpdate extends LibAlgorithmParam {
@ApiModelProperty("id")
private String id;
}
}

View File

@@ -0,0 +1,95 @@
package com.njcn.supervision.pojo.param.databank;
import com.njcn.db.bo.BaseEntity;
import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
*
* Description:
* Date: 2024/9/10 14:17【需求编号】
*
* @author clam
* @version V1.0.0
*/
@ApiModel(description="")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class LibCaseParam extends BaseEntity {
/**
* 事件名称
*/
@ApiModelProperty(value="事件名称")
private String name;
/**
* 发生事件类型
*/
@ApiModelProperty(value="发生事件类型")
private String type;
/**
* 发生地点
*/
@ApiModelProperty(value="发生地点")
private String location;
/**
* 事件简介
*/
@ApiModelProperty(value="事件简介")
private String summary;
/**
* 事件经过
*/
@ApiModelProperty(value="事件经过")
private String process;
/**
* 处理措施
*/
@ApiModelProperty(value="处理措施")
private String measures;
/**
* 治理效果
*/
@ApiModelProperty(value="治理效果")
private String effect;
/**
* 附件地址
*/
@ApiModelProperty(value="附件地址")
private String url;
/**
* 示范案例地址
*/
@ApiModelProperty(value="示范案例地址")
private String caseUrl;
@Data
@EqualsAndHashCode(callSuper = true)
public static class LibCaseParamUpdate extends LibCaseParam {
@ApiModelProperty("id")
private String id;
}
@Data
@EqualsAndHashCode(callSuper = true)
public static class LibCaseParamQuery extends BaseParam {
}
}

View File

@@ -0,0 +1,58 @@
package com.njcn.supervision.pojo.param.databank;
import com.njcn.db.bo.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
/**
*
* Description:
* Date: 2024/9/10 14:17【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class LibStandardParam extends BaseEntity {
/**
* 上级id
*/
@ApiModelProperty(value="上级id")
private String pid;
/**
* 名称
*/
@NotBlank(message ="名称不能为空")
@ApiModelProperty(value="名称")
private String name;
/**
* 文件地址
*/
@ApiModelProperty(value="文件地址")
private String url;
@Data
@EqualsAndHashCode(callSuper = true)
public static class LibStandardParamUpdate extends LibStandardParam {
@ApiModelProperty("id")
private String id;
}
}

View File

@@ -0,0 +1,53 @@
package com.njcn.supervision.pojo.param.databank;
import com.njcn.db.bo.BaseEntity;
import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
*
* Description:
* Date: 2024/9/10 14:17【需求编号】
*
* @author clam
* @version V1.0.0
*/
@ApiModel(description="")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class LibTemplateParam extends BaseEntity {
/**
* 模板名称
*/
@ApiModelProperty(value="模板名称")
private String name;
/**
* 文件地址
*/
@ApiModelProperty(value="文件地址")
private String url;
@Data
@EqualsAndHashCode(callSuper = true)
public static class LibTemplateParamUpdate extends LibTemplateParam {
@ApiModelProperty("id")
private String id;
}
@Data
@EqualsAndHashCode(callSuper = true)
public static class LibTemplateParamQuery extends BaseParam {
}
}

View File

@@ -0,0 +1,90 @@
package com.njcn.supervision.pojo.po.databank;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.njcn.db.bo.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
*
* Description:
* Date: 2024/9/10 14:16【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "lib_algorithm")
public class LibAlgorithm extends BaseEntity {
@TableId(value = "id", type = IdType.ASSIGN_ID)
private String id;
/**
* 上级id
*/
@TableField(value = "pid")
private String pid;
/**
* 父级id集合
*/
@TableField(value = "pids")
private String pids;
/**
* 算法名称
*/
@TableField(value = "name")
private String name;
/**
* 定义
*/
@TableField(value = "`definition`")
private String definition;
/**
* 计算周期0日1月2季3年
*/
@TableField(value = "period")
private String period;
/**
* 数据来源(单体,数据中台....
*/
@TableField(value = "source")
private String source;
/**
* 状态(字典 1正常 0停用
*/
@TableField(value = "use_flag")
private Integer useFLag;
/**
* 状态(字典 1正常 0删除
*/
@TableField(value = "`status`")
private Integer status;
/**
* 子类
*/
@TableField(exist = false)
private List<LibAlgorithm> children;
@TableField(exist = false)
private Integer level;
}

View File

@@ -0,0 +1,89 @@
package com.njcn.supervision.pojo.po.databank;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.njcn.db.bo.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
*
* Description:
* Date: 2024/9/10 14:17【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "lib_case")
public class LibCase extends BaseEntity {
@TableId(value = "id", type = IdType.ASSIGN_UUID)
private String id;
/**
* 事件名称
*/
@TableField(value = "name")
private String name;
/**
* 发生事件类型
*/
@TableField(value = "type")
private String type;
/**
* 发生地点
*/
@TableField(value = "location")
private String location;
/**
* 事件简介
*/
@TableField(value = "summary")
private String summary;
/**
* 事件经过
*/
@TableField(value = "process")
private String process;
/**
* 处理措施
*/
@TableField(value = "measures")
private String measures;
/**
* 治理效果
*/
@TableField(value = "effect")
private String effect;
/**
* 附件地址
*/
@TableField(value = "url")
private String url;
/**
* 示范案例地址
*/
@TableField(value = "case_url")
private String caseUrl;
/**
* 状态(字典 1正常 删除)
*/
@TableField(value = "`status`")
private Integer status;
}

View File

@@ -0,0 +1,63 @@
package com.njcn.supervision.pojo.po.databank;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.njcn.db.bo.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
*
* Description:
* Date: 2024/9/10 14:17【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "lib_standard")
public class LibStandard extends BaseEntity {
@TableId(value = "id", type = IdType.ASSIGN_UUID)
private String id;
/**
* 上级id
*/
@TableField(value = "pid")
private String pid;
/**
* 父级id集合
*/
@TableField(value = "pids")
private String pids;
/**
* 名称
*/
@TableField(value = "name")
private String name;
/**
* 文件地址
*/
@TableField(value = "url")
private String url;
/**
* 状态(字典 1正常 删除)
*/
@TableField(value = "`status`")
private Integer status;
@TableField(exist = false)
private List<LibStandard> children;
}

View File

@@ -0,0 +1,49 @@
package com.njcn.supervision.pojo.po.databank;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.njcn.db.bo.BaseEntity;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
*
* Description:
* Date: 2024/9/10 14:17【需求编号】
*
* @author clam
* @version V1.0.0
*/
@ApiModel(description="")
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "lib_template")
public class LibTemplate extends BaseEntity {
@TableId(value = "id", type = IdType.ASSIGN_ID)
private String id;
/**
* 模板名称
*/
@TableField(value = "name")
private String name;
/**
* 文件地址
*/
@TableField(value = "url")
private String url;
/**
* 状态(字典 1正常 删除)
*/
@TableField(value = "`status`")
private Integer status;
}

View File

@@ -0,0 +1,83 @@
package com.njcn.supervision.controller.databank;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.supervision.pojo.param.databank.LibAlgorithmParam;
import com.njcn.supervision.pojo.po.databank.LibAlgorithm;
import com.njcn.supervision.service.databank.LibAlgorithmService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* Description:
* Date: 2024/9/10 14:26【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Slf4j
@RestController
@RequestMapping("/libalgorithm")
@Api(tags = "算法库")
@AllArgsConstructor
public class LibAlgorithmController extends BaseController {
private final LibAlgorithmService libAlgorithmService;
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
@PostMapping("/add")
@ApiOperation("新增")
@ApiImplicitParam(name = "libAlgorithmParam", value = "实体参数", required = true)
public HttpResult<LibAlgorithm> add(@RequestBody @Validated LibAlgorithmParam libAlgorithmParam) {
String methodDescribe = getMethodDescribe("add");
LibAlgorithm add = libAlgorithmService.add(libAlgorithmParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, add, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
@PostMapping("/updateAlgorithmLibrary")
@ApiOperation("更新")
@ApiImplicitParam(name = "paramUpdate", value = "实体参数", required = true)
public HttpResult<String> updateAlgorithmLibrary(@RequestBody @Validated LibAlgorithmParam.LibAlgorithmParamUpdate paramUpdate) {
String methodDescribe = getMethodDescribe("updateAlgorithmLibrary");
String id = libAlgorithmService.updateAlgorithmLibrary(paramUpdate);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, id, methodDescribe);
}
@OperateInfo(info = LogEnum.SYSTEM_COMMON,operateType = OperateType.QUERY)
@GetMapping("/queryAllAlgorithmLibrary")
@ApiOperation("查询所有算法库树结构")
public HttpResult<List<LibAlgorithm>> queryAllAlgorithmLibrary() {
String methodDescribe = getMethodDescribe("queryAll");
List<LibAlgorithm> result = libAlgorithmService.queryAll();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.SYSTEM_COMMON,operateType = OperateType.QUERY)
@GetMapping("/queryById")
@ApiOperation("根据id查询")
public HttpResult<LibAlgorithm> queryById(@RequestParam("id") String id) {
String methodDescribe = getMethodDescribe("queryById");
LibAlgorithm result = libAlgorithmService.lambdaQuery().eq(LibAlgorithm::getId,id).one();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.SYSTEM_COMMON,operateType = OperateType.DELETE)
@GetMapping("/deleteyById")
@ApiOperation("通过id删除")
public HttpResult<Boolean> deleteyById(@RequestParam("id") String id) {
String methodDescribe = getMethodDescribe("deleteyById");
boolean update = libAlgorithmService.lambdaUpdate().set(LibAlgorithm::getStatus, 0).eq(LibAlgorithm::getId, id).update();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, update, methodDescribe);
}
}

View File

@@ -0,0 +1,109 @@
package com.njcn.supervision.controller.databank;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.oss.utils.FileStorageUtil;
import com.njcn.redis.utils.RedisUtil;
import com.njcn.supervision.pojo.param.databank.LibCaseParam;
import com.njcn.supervision.pojo.po.databank.LibCase;
import com.njcn.supervision.service.databank.LibCaseService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
* Description:
* Date: 2024/9/10 16:49【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Slf4j
@RestController
@RequestMapping("/libcase")
@Api(tags = "案例库")
@AllArgsConstructor
public class LibCaseController extends BaseController {
private final LibCaseService libCaseService;
private final RedisUtil redisUtil;
private final FileStorageUtil fileStorageUtil;
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
@PostMapping("/add")
@ApiOperation("新增")
@ApiImplicitParam(name = "libCaseParam", value = "实体参数", required = true)
public HttpResult<LibCase> add(@RequestBody @Validated LibCaseParam libCaseParam) {
String methodDescribe = getMethodDescribe("add");
LibCase add = libCaseService.add(libCaseParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, add, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
@PostMapping("/addStandardCase")
@ApiOperation("新增标准案例")
public HttpResult<String> addStandardCase(@RequestParam String caseUrl) {
String methodDescribe = getMethodDescribe("addStandardCase");
redisUtil.saveByKey("StandardCase",caseUrl);
String fileUrl = fileStorageUtil.getFileUrl(caseUrl);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, fileUrl, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.QUERY)
@PostMapping("/queryStandardCase")
@ApiOperation("获取标准案例")
public HttpResult<String> queryStandardCase() {
String methodDescribe = getMethodDescribe("queryStandardCase");
String standardCase = redisUtil.getStringByKey("StandardCase");
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, standardCase, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
@PostMapping("/updateCaseLibrary")
@ApiOperation("更新")
@ApiImplicitParam(name = "paramUpdate", value = "实体参数", required = true)
public HttpResult<String> updateCaseLibrary(@RequestBody @Validated LibCaseParam.LibCaseParamUpdate paramUpdate) {
String methodDescribe = getMethodDescribe("updateCaseLibrary");
String id = libCaseService.updateCaseLibrary(paramUpdate);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, id, methodDescribe);
}
@OperateInfo(info = LogEnum.SYSTEM_COMMON,operateType = OperateType.DELETE)
@GetMapping("/deleteyById")
@ApiOperation("通过id删除")
public HttpResult<Boolean> deleteyById(@RequestParam("id") String id) {
String methodDescribe = getMethodDescribe("deleteyById");
boolean update = libCaseService.lambdaUpdate().set(LibCase::getStatus, 0).eq(LibCase::getId, id).update();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, update, methodDescribe);
}
@OperateInfo(info = LogEnum.SYSTEM_COMMON,operateType = OperateType.QUERY)
@GetMapping("/queryById")
@ApiOperation("根据id查询")
public HttpResult<LibCase> queryById(@RequestParam("id") String id) {
String methodDescribe = getMethodDescribe("queryById");
LibCase result = libCaseService.lambdaQuery().eq(LibCase::getId,id).one();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/pageQuery")
@ApiOperation("分页查询案例库")
@ApiImplicitParam(name = "param", value = "参数", required = true)
public HttpResult<Page<LibCase>> pageQuery(@RequestBody @Validated LibCaseParam.LibCaseParamQuery param) {
String methodDescribe = getMethodDescribe("pageQuery");
Page<LibCase> list = libCaseService.pageQuery(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
}

View File

@@ -0,0 +1,83 @@
package com.njcn.supervision.controller.databank;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.supervision.pojo.param.databank.LibStandardParam;
import com.njcn.supervision.pojo.po.databank.LibStandard;
import com.njcn.supervision.service.databank.LibStandardService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* Description:
* Date: 2024/9/10 16:26【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Slf4j
@RestController
@RequestMapping("/libstandard")
@Api(tags = "标准库")
@AllArgsConstructor
public class LibStandardController extends BaseController {
private final LibStandardService libStandardService;
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
@PostMapping("/add")
@ApiOperation("新增")
@ApiImplicitParam(name = "libStandardParam", value = "实体参数", required = true)
public HttpResult<LibStandard> add(@RequestBody @Validated LibStandardParam libStandardParam) {
String methodDescribe = getMethodDescribe("add");
LibStandard add = libStandardService.add(libStandardParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, add, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
@PostMapping("/updateStandardLibrary")
@ApiOperation("更新")
@ApiImplicitParam(name = "paramUpdate", value = "实体参数", required = true)
public HttpResult<String> updateStandardLibrary(@RequestBody @Validated LibStandardParam.LibStandardParamUpdate paramUpdate) {
String methodDescribe = getMethodDescribe("updateStandardLibrary");
String id = libStandardService.updateStandardLibrary(paramUpdate);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, id, methodDescribe);
}
@OperateInfo(info = LogEnum.SYSTEM_COMMON,operateType = OperateType.DELETE)
@GetMapping("/deleteyById")
@ApiOperation("通过id删除")
public HttpResult<Boolean> deleteyById(@RequestParam("id") String id) {
String methodDescribe = getMethodDescribe("deleteyById");
boolean update = libStandardService.lambdaUpdate().set(LibStandard::getStatus, 0).eq(LibStandard::getId, id).update();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, update, methodDescribe);
}
@OperateInfo(info = LogEnum.SYSTEM_COMMON,operateType = OperateType.QUERY)
@GetMapping("/queryById")
@ApiOperation("根据id查询")
public HttpResult<LibStandard> queryById(@RequestParam("id") String id) {
String methodDescribe = getMethodDescribe("queryById");
LibStandard result = libStandardService.lambdaQuery().eq(LibStandard::getId,id).one();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.SYSTEM_COMMON,operateType = OperateType.QUERY)
@GetMapping("/queryAll")
@ApiOperation("查询所有标准库树结构")
public HttpResult<List<LibStandard>> queryAll() {
String methodDescribe = getMethodDescribe("queryAll");
List<LibStandard> result = libStandardService.queryAll();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
}

View File

@@ -0,0 +1,84 @@
package com.njcn.supervision.controller.databank;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.supervision.pojo.param.databank.LibTemplateParam;
import com.njcn.supervision.pojo.po.databank.LibTemplate;
import com.njcn.supervision.service.databank.LibTemplateService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
* Description:
* Date: 2024/9/10 16:49【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Slf4j
@RestController
@RequestMapping("/libtemplate")
@Api(tags = "模版库")
@AllArgsConstructor
public class LibTemplateController extends BaseController {
private final LibTemplateService libTemplateService;
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
@PostMapping("/add")
@ApiOperation("新增")
@ApiImplicitParam(name = "libTemplateParam", value = "实体参数", required = true)
public HttpResult<LibTemplate> add(@RequestBody @Validated LibTemplateParam libTemplateParam) {
String methodDescribe = getMethodDescribe("add");
LibTemplate add = libTemplateService.add(libTemplateParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, add, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
@PostMapping("/updateTemplate")
@ApiOperation("更新")
@ApiImplicitParam(name = "paramUpdate", value = "实体参数", required = true)
public HttpResult<String> updateTemplate(@RequestBody @Validated LibTemplateParam.LibTemplateParamUpdate paramUpdate) {
String methodDescribe = getMethodDescribe("updateTemplate");
String id = libTemplateService.updateTemplate(paramUpdate);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, id, methodDescribe);
}
@OperateInfo(info = LogEnum.SYSTEM_COMMON,operateType = OperateType.DELETE)
@GetMapping("/deleteyById")
@ApiOperation("通过id删除")
public HttpResult<Boolean> deleteyById(@RequestParam("id") String id) {
String methodDescribe = getMethodDescribe("deleteyById");
boolean update = libTemplateService.lambdaUpdate().set(LibTemplate::getStatus, 0).eq(LibTemplate::getId, id).update();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, update, methodDescribe);
}
@OperateInfo(info = LogEnum.SYSTEM_COMMON,operateType = OperateType.QUERY)
@GetMapping("/queryById")
@ApiOperation("根据id查询")
public HttpResult<LibTemplate> queryById(@RequestParam("id") String id) {
String methodDescribe = getMethodDescribe("queryById");
LibTemplate result = libTemplateService.lambdaQuery().eq(LibTemplate::getId,id).one();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/pageQuery")
@ApiOperation("分页查询案例库")
@ApiImplicitParam(name = "param", value = "参数", required = true)
public HttpResult<Page<LibTemplate>> pageQuery(@RequestBody @Validated LibTemplateParam.LibTemplateParamQuery param) {
String methodDescribe = getMethodDescribe("pageQuery");
Page<LibTemplate> list = libTemplateService.pageQuery(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
}

View File

@@ -0,0 +1,15 @@
package com.njcn.supervision.mapper.databank;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.supervision.pojo.po.databank.LibAlgorithm;
/**
*
* Description:
* Date: 2024/9/10 14:16【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface LibAlgorithmMapper extends BaseMapper<LibAlgorithm> {
}

View File

@@ -0,0 +1,19 @@
package com.njcn.supervision.mapper.databank;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.supervision.pojo.po.databank.LibCase;
import org.apache.ibatis.annotations.Param;
/**
*
* Description:
* Date: 2024/9/10 14:17【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface LibCaseMapper extends BaseMapper<LibCase> {
Page<LibCase> page(Page<Object> objectPage, @Param("ew") QueryWrapper<LibCase> queryWrapper);
}

View File

@@ -0,0 +1,15 @@
package com.njcn.supervision.mapper.databank;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.supervision.pojo.po.databank.LibStandard;
/**
*
* Description:
* Date: 2024/9/10 14:17【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface LibStandardMapper extends BaseMapper<LibStandard> {
}

View File

@@ -0,0 +1,19 @@
package com.njcn.supervision.mapper.databank;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.supervision.pojo.po.databank.LibTemplate;
import org.apache.ibatis.annotations.Param;
/**
*
* Description:
* Date: 2024/9/10 14:17【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface LibTemplateMapper extends BaseMapper<LibTemplate> {
Page<LibTemplate> page(Page<Object> objectPage,@Param("ew") QueryWrapper<LibTemplate> queryWrapper);
}

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.supervision.mapper.databank.LibAlgorithmMapper">
</mapper>

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.supervision.mapper.databank.LibCaseMapper">
<select id="page"
resultType="com.njcn.supervision.pojo.po.databank.LibCase">
SELECT
*
FROM lib_case lib_case
WHERE ${ew.sqlSegment}
</select>
</mapper>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.supervision.mapper.databank.LibStandardMapper">
</mapper>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.supervision.mapper.databank.LibTemplateMapper">
<select id="page" resultType="com.njcn.supervision.pojo.po.databank.LibTemplate">
SELECT
*
FROM lib_template lib_template
WHERE ${ew.sqlSegment}
</select>
</mapper>

View File

@@ -0,0 +1,25 @@
package com.njcn.supervision.service.databank;
import com.njcn.supervision.pojo.param.databank.LibAlgorithmParam;
import com.njcn.supervision.pojo.po.databank.LibAlgorithm;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
*
* Description:
* Date: 2024/9/10 14:16【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface LibAlgorithmService extends IService<LibAlgorithm>{
LibAlgorithm add(LibAlgorithmParam libAlgorithmParam);
String updateAlgorithmLibrary(LibAlgorithmParam.LibAlgorithmParamUpdate paramUpdate);
List<LibAlgorithm> queryAll();
}

View File

@@ -0,0 +1,23 @@
package com.njcn.supervision.service.databank;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.supervision.pojo.param.databank.LibCaseParam;
import com.njcn.supervision.pojo.po.databank.LibCase;
import com.baomidou.mybatisplus.extension.service.IService;
/**
*
* Description:
* Date: 2024/9/10 14:17【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface LibCaseService extends IService<LibCase>{
LibCase add(LibCaseParam libCaseParam);
String updateCaseLibrary(LibCaseParam.LibCaseParamUpdate paramUpdate);
Page<LibCase> pageQuery(LibCaseParam.LibCaseParamQuery param);
}

View File

@@ -0,0 +1,25 @@
package com.njcn.supervision.service.databank;
import com.njcn.supervision.pojo.param.databank.LibStandardParam;
import com.njcn.supervision.pojo.po.databank.LibStandard;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
*
* Description:
* Date: 2024/9/10 14:17【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface LibStandardService extends IService<LibStandard>{
LibStandard add(LibStandardParam libStandardParam);
String updateStandardLibrary(LibStandardParam.LibStandardParamUpdate paramUpdate);
List<LibStandard> queryAll();
}

View File

@@ -0,0 +1,23 @@
package com.njcn.supervision.service.databank;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.supervision.pojo.param.databank.LibTemplateParam;
import com.njcn.supervision.pojo.po.databank.LibTemplate;
import com.baomidou.mybatisplus.extension.service.IService;
/**
*
* Description:
* Date: 2024/9/10 14:17【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface LibTemplateService extends IService<LibTemplate>{
LibTemplate add(LibTemplateParam libTemplateParam);
String updateTemplate(LibTemplateParam.LibTemplateParamUpdate paramUpdate);
Page<LibTemplate> pageQuery(LibTemplateParam.LibTemplateParamQuery param);
}

View File

@@ -0,0 +1,107 @@
package com.njcn.supervision.service.databank.impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.supervision.enums.SupervisionResponseEnum;
import com.njcn.supervision.mapper.databank.LibAlgorithmMapper;
import com.njcn.supervision.pojo.param.databank.LibAlgorithmParam;
import com.njcn.supervision.pojo.po.databank.LibAlgorithm;
import com.njcn.supervision.service.databank.LibAlgorithmService;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.stream.Collectors;
/**
*
* Description:
* Date: 2024/9/10 14:16【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Service
@RequiredArgsConstructor
public class LibAlgorithmServiceImpl extends ServiceImpl<LibAlgorithmMapper, LibAlgorithm> implements LibAlgorithmService {
@Override
@Transactional(rollbackFor = Exception.class)
public LibAlgorithm add(LibAlgorithmParam libAlgorithmParam) {
checkName(libAlgorithmParam,false);
LibAlgorithm libAlgorithm = new LibAlgorithm();
BeanUtils.copyProperties(libAlgorithmParam, libAlgorithm);
libAlgorithm.setStatus(1);
if(StringUtils.isEmpty(libAlgorithmParam.getPid())){
libAlgorithm.setPid("0");
libAlgorithm.setPids("0");
}else {
LibAlgorithm fatherLibAlgorithm = this.lambdaQuery().eq(LibAlgorithm::getId, libAlgorithmParam.getPid()).one();
libAlgorithm.setPids(fatherLibAlgorithm.getPids() + "," + libAlgorithm.getPid());
}
this.save(libAlgorithm);
return libAlgorithm;
}
private void checkName(LibAlgorithmParam libAlgorithmParam, boolean isExcludeSelf) {
String pid =StringUtils.isEmpty(libAlgorithmParam.getPid())?"0":libAlgorithmParam.getPid();
LambdaQueryWrapper<LibAlgorithm> sgUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
sgUserLambdaQueryWrapper
.eq(LibAlgorithm::getName, libAlgorithmParam.getName())
.eq(LibAlgorithm::getPid,pid)
.eq(LibAlgorithm::getStatus, DataStateEnum.ENABLE.getCode());
//更新的时候,需排除当前记录
if (isExcludeSelf) {
if (libAlgorithmParam instanceof LibAlgorithmParam.LibAlgorithmParamUpdate) {
sgUserLambdaQueryWrapper.ne(LibAlgorithm::getId, (( LibAlgorithmParam.LibAlgorithmParamUpdate) libAlgorithmParam).getId());
}
}
int countByAccount = this.count(sgUserLambdaQueryWrapper);
//大于等于1个则表示重复
if (countByAccount >= 1) {
throw new BusinessException(SupervisionResponseEnum.NAME_EXISTS);
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public String updateAlgorithmLibrary(LibAlgorithmParam.LibAlgorithmParamUpdate paramUpdate) {
checkName(paramUpdate,true);
LibAlgorithm libAlgorithm = new LibAlgorithm();
BeanUtil.copyProperties(paramUpdate, libAlgorithm);
this.updateById(libAlgorithm);
return libAlgorithm.getId();
}
@Override
public List<LibAlgorithm> queryAll() {
List<LibAlgorithm> libAlgorithmList = this.lambdaQuery().eq(LibAlgorithm::getStatus,1).list();
List<LibAlgorithm> tree = libAlgorithmList.stream().filter(item -> item.getPid().equals("0")).peek(item -> {
item.setLevel(1);
item.setChildren(getChildren(item, libAlgorithmList));
}).collect(Collectors.toList());
return tree;
}
private List<LibAlgorithm> getChildren(LibAlgorithm libAlgorithm, List<LibAlgorithm> all) {
return all.stream().filter(item -> item.getPid().equals(libAlgorithm.getId())).peek(item -> {
item.setLevel(libAlgorithm.getLevel()+1);
item.setChildren(getChildren(item, all));
}).collect(Collectors.toList());
}
}

View File

@@ -0,0 +1,89 @@
package com.njcn.supervision.service.databank.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.supervision.enums.SupervisionResponseEnum;
import com.njcn.supervision.mapper.databank.LibCaseMapper;
import com.njcn.supervision.pojo.param.databank.LibCaseParam;
import com.njcn.supervision.pojo.po.databank.LibCase;
import com.njcn.supervision.service.databank.LibCaseService;
import com.njcn.web.factory.PageFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
*
* Description:
* Date: 2024/9/10 14:17【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Service
public class LibCaseServiceImpl extends ServiceImpl<LibCaseMapper, LibCase> implements LibCaseService {
@Override
@Transactional(rollbackFor = Exception.class)
public LibCase add(LibCaseParam libCaseParam) {
checkName(libCaseParam,false);
LibCase libCase = new LibCase();
BeanUtils.copyProperties(libCaseParam, libCase);
libCase.setStatus(1);
this.save(libCase);
return libCase;
}
private void checkName(LibCaseParam libCaseParam, boolean isExcludeSelf) {
LambdaQueryWrapper<LibCase> sgUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
sgUserLambdaQueryWrapper
.eq(LibCase::getName, libCaseParam.getName())
.eq(LibCase::getStatus, DataStateEnum.ENABLE.getCode());
//更新的时候,需排除当前记录
if (isExcludeSelf) {
if (libCaseParam instanceof LibCaseParam.LibCaseParamUpdate) {
sgUserLambdaQueryWrapper.ne(LibCase::getId, (( LibCaseParam.LibCaseParamUpdate) libCaseParam).getId());
}
}
int countByAccount = this.count(sgUserLambdaQueryWrapper);
//大于等于1个则表示重复
if (countByAccount >= 1) {
throw new BusinessException(SupervisionResponseEnum.NAME_EXISTS);
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public String updateCaseLibrary(LibCaseParam.LibCaseParamUpdate paramUpdate) {
checkName(paramUpdate,true);
LibCase libCase = new LibCase();
BeanUtil.copyProperties(paramUpdate, libCase);
this.updateById(libCase);
return libCase.getId();
}
@Override
public Page<LibCase> pageQuery(LibCaseParam.LibCaseParamQuery param) {
QueryWrapper<LibCase> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("lib_case.status",1);
//添加上时间范围
queryWrapper.between("lib_case.Create_Time",
DateUtil.beginOfDay(DateUtil.parse(param.getSearchBeginTime())),
DateUtil.endOfDay(DateUtil.parse(param.getSearchEndTime())));
queryWrapper.orderByDesc("lib_case.Update_Time");
Page<LibCase> page = this.baseMapper.page(new Page<>(PageFactory.getPageNum(param), PageFactory.getPageSize(param)), queryWrapper);
return page;
}
}

View File

@@ -0,0 +1,101 @@
package com.njcn.supervision.service.databank.impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.supervision.enums.SupervisionResponseEnum;
import com.njcn.supervision.mapper.databank.LibStandardMapper;
import com.njcn.supervision.pojo.param.databank.LibStandardParam;
import com.njcn.supervision.pojo.po.databank.LibStandard;
import com.njcn.supervision.service.databank.LibStandardService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.stream.Collectors;
/**
*
* Description:
* Date: 2024/9/10 14:17【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Service
public class LibStandardServiceImpl extends ServiceImpl<LibStandardMapper, LibStandard> implements LibStandardService {
@Override
@Transactional(rollbackFor = Exception.class)
public LibStandard add(LibStandardParam libStandardParam) {
checkName(libStandardParam,false);
LibStandard libStandard = new LibStandard();
BeanUtils.copyProperties(libStandardParam, libStandard);
libStandard.setStatus(1);
if(StringUtils.isEmpty(libStandardParam.getPid())){
libStandard.setPid("0");
libStandard.setPids("0");
}else {
LibStandard fatherLibStandard = this.lambdaQuery().eq(LibStandard::getId, libStandardParam.getPid()).one();
libStandard.setPids(fatherLibStandard.getPids() + "," + libStandardParam.getPid());
}
this.save(libStandard);
return libStandard;
}
private void checkName(LibStandardParam libStandardParam, boolean isExcludeSelf) {
String pid =StringUtils.isEmpty(libStandardParam.getPid())?"0":libStandardParam.getPid();
LambdaQueryWrapper<LibStandard> sgUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
sgUserLambdaQueryWrapper
.eq(LibStandard::getName, libStandardParam.getName())
.eq(LibStandard::getPid,pid)
.eq(LibStandard::getStatus, DataStateEnum.ENABLE.getCode());
//更新的时候,需排除当前记录
if (isExcludeSelf) {
if (libStandardParam instanceof LibStandardParam.LibStandardParamUpdate) {
sgUserLambdaQueryWrapper.ne(LibStandard::getId, (( LibStandardParam.LibStandardParamUpdate) libStandardParam).getId());
}
}
int countByAccount = this.count(sgUserLambdaQueryWrapper);
//大于等于1个则表示重复
if (countByAccount >= 1) {
throw new BusinessException(SupervisionResponseEnum.NAME_EXISTS);
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public String updateStandardLibrary(LibStandardParam.LibStandardParamUpdate paramUpdate) {
checkName(paramUpdate,true);
LibStandard libStandard = new LibStandard();
BeanUtil.copyProperties(paramUpdate, libStandard);
this.updateById(libStandard);
return libStandard.getId();
}
@Override
public List<LibStandard> queryAll() {
List<LibStandard> libStandardList = this.lambdaQuery().eq(LibStandard::getStatus,1).list();
List<LibStandard> tree = libStandardList.stream().filter(item -> item.getPid().equals("0")).peek(item -> {
item.setChildren(getChildren(item, libStandardList));
}).collect(Collectors.toList());
return tree;
}
private List<LibStandard> getChildren(LibStandard libStandard, List<LibStandard> all) {
return all.stream().filter(item -> item.getPid().equals(libStandard.getId())).peek(item -> {
item.setChildren(getChildren(item, all));
}).collect(Collectors.toList());
}
}

View File

@@ -0,0 +1,87 @@
package com.njcn.supervision.service.databank.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.supervision.enums.SupervisionResponseEnum;
import com.njcn.supervision.mapper.databank.LibTemplateMapper;
import com.njcn.supervision.pojo.param.databank.LibTemplateParam;
import com.njcn.supervision.pojo.po.databank.LibTemplate;
import com.njcn.supervision.service.databank.LibTemplateService;
import com.njcn.web.factory.PageFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
*
* Description:
* Date: 2024/9/10 14:17【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Service
public class LibTemplateServiceImpl extends ServiceImpl<LibTemplateMapper, LibTemplate> implements LibTemplateService {
@Override
@Transactional(rollbackFor = Exception.class)
public LibTemplate add(LibTemplateParam libTemplateParam) {
checkName(libTemplateParam,false);
LibTemplate libTemplate = new LibTemplate();
BeanUtils.copyProperties(libTemplateParam, libTemplate);
libTemplate.setStatus(1);
this.save(libTemplate);
return libTemplate;
}
private void checkName(LibTemplateParam libTemplateParam, boolean isExcludeSelf) {
LambdaQueryWrapper<LibTemplate> sgUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
sgUserLambdaQueryWrapper
.eq(LibTemplate::getName, libTemplateParam.getName())
.eq(LibTemplate::getStatus, DataStateEnum.ENABLE.getCode());
//更新的时候,需排除当前记录
if (isExcludeSelf) {
if (libTemplateParam instanceof LibTemplateParam.LibTemplateParamUpdate) {
sgUserLambdaQueryWrapper.ne(LibTemplate::getId, (( LibTemplateParam.LibTemplateParamUpdate) libTemplateParam).getId());
}
}
int countByAccount = this.count(sgUserLambdaQueryWrapper);
//大于等于1个则表示重复
if (countByAccount >= 1) {
throw new BusinessException(SupervisionResponseEnum.NAME_EXISTS);
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public String updateTemplate(LibTemplateParam.LibTemplateParamUpdate paramUpdate) {
checkName(paramUpdate,true);
LibTemplate libTemplate = new LibTemplate();
BeanUtil.copyProperties(paramUpdate, libTemplate);
this.updateById(libTemplate);
return libTemplate.getId();
}
@Override
public Page<LibTemplate> pageQuery(LibTemplateParam.LibTemplateParamQuery param) {
QueryWrapper<LibTemplate> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("lib_template.status",1);
//添加上时间范围
queryWrapper.between("lib_template.Create_Time",
DateUtil.beginOfDay(DateUtil.parse(param.getSearchBeginTime())),
DateUtil.endOfDay(DateUtil.parse(param.getSearchEndTime())));
queryWrapper.orderByDesc("lib_template.Update_Time");
Page<LibTemplate> page = this.baseMapper.page(new Page<>(PageFactory.getPageNum(param), PageFactory.getPageSize(param)), queryWrapper);
return page;
}
}

View File

@@ -1,52 +0,0 @@
//package com.njcn.system.pojo.param;
//
//import com.njcn.common.pojo.constant.PatternRegex;
//import com.njcn.web.constant.ValidMessage;
//import io.swagger.annotations.ApiModelProperty;
//import lombok.Data;
//import lombok.EqualsAndHashCode;
//import org.hibernate.validator.constraints.Range;
//
//import javax.validation.constraints.NotBlank;
//import javax.validation.constraints.NotNull;
//import javax.validation.constraints.Pattern;
//
//@Data
//public class DicParam {
//
// @ApiModelProperty("节点")
// @NotBlank(message = ValidMessage.PID_NOT_BLANK)
// private String pid;
//
// @ApiModelProperty("名称")
// @NotBlank(message = ValidMessage.NAME_NOT_BLANK)
// @Pattern(regexp = PatternRegex.DIC_REGEX, message = ValidMessage.NAME_FORMAT_ERROR)
// private String name;
//
// @ApiModelProperty("编号")
// @NotBlank(message = ValidMessage.CODE_NOT_BLANK)
// private String code;
//
// @ApiModelProperty("排序")
// @NotNull(message = ValidMessage.SORT_NOT_NULL)
// @Range(min = 0, max = 999, message = ValidMessage.PARAM_FORMAT_ERROR)
// private Integer sort;
//
// @ApiModelProperty("描述")
// private String remark;
//
//
// /**
// * 更新操作实体
// * 需要填写的参数id
// */
// @Data
// @EqualsAndHashCode(callSuper = true)
// public static class UpdateParam extends DicParam {
//
// @ApiModelProperty("Id")
// @NotBlank(message = ValidMessage.ID_NOT_BLANK)
// @Pattern(regexp = PatternRegex.SYSTEM_ID, message = ValidMessage.ID_FORMAT_ERROR)
// private String id;
// }
//}

View File

@@ -1,30 +0,0 @@
//package com.njcn.system.pojo.po;
//
//import com.baomidou.mybatisplus.annotation.TableName;
//import com.njcn.db.bo.BaseEntity;
//import lombok.Data;
//import lombok.EqualsAndHashCode;
//
//@Data
//@EqualsAndHashCode(callSuper = true)
//@TableName("sys_dic_tree")
//public class Dic extends BaseEntity {
//
// private static final long serialVersionUID = 1L;
//
// private String id;
//
// private String pid;
//
// private String pids;
//
// private String name;
//
// private String code;
//
// private Integer sort;
//
// private String remark;
//
// private Integer status;
//}

View File

@@ -1,35 +0,0 @@
//package com.njcn.system.pojo.vo;
//
//import io.swagger.annotations.ApiModelProperty;
//import lombok.Data;
//
//import java.io.Serializable;
//import java.util.List;
//
//@Data
//public class DicVO implements Serializable {
//
// @ApiModelProperty("Id")
// private String id;
//
// @ApiModelProperty("父节点")
// private String pid;
//
// @ApiModelProperty("名称")
// private String name;
//
// @ApiModelProperty("编码")
// private String code;
//
// @ApiModelProperty("排序")
// private Integer sort;
//
// @ApiModelProperty("描述")
// private String remark;
//
// @ApiModelProperty("状态")
// private Integer status;
//
// @ApiModelProperty("子级")
// List<DicVO> children;
//}

View File

@@ -1,137 +0,0 @@
//package com.njcn.system.controller;
//
//
//import com.njcn.common.pojo.annotation.OperateInfo;
//import com.njcn.common.pojo.constant.OperateType;
//import com.njcn.common.pojo.enums.common.LogEnum;
//import com.njcn.common.pojo.enums.response.CommonResponseEnum;
//import com.njcn.common.pojo.response.HttpResult;
//import com.njcn.common.utils.HttpResultUtil;
//import com.njcn.common.utils.LogUtil;
//import com.njcn.system.pojo.param.DicParam;
//import com.njcn.system.pojo.po.Dic;
//import com.njcn.system.pojo.vo.DicVO;
//import com.njcn.system.service.IDicService;
//import com.njcn.user.pojo.param.FunctionParam;
//import com.njcn.user.pojo.po.Function;
//import com.njcn.web.controller.BaseController;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiImplicitParam;
//import io.swagger.annotations.ApiOperation;
//import lombok.AllArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.validation.annotation.Validated;
//import org.springframework.web.bind.annotation.*;
//
//import java.util.List;
//
///**
// * @author hany
// * @date 2022/10/18
// */
//@Validated
//@Slf4j
//@RestController
//@RequestMapping("/dic")
//@Api(tags = "树型字典管理")
//@AllArgsConstructor
//public class DicController extends BaseController {
//
// private final IDicService dicService;
//
// /**
// * 获取树
// * @return
// */
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
// @GetMapping("/dicTree")
// @ApiOperation("获取字典树")
// public HttpResult<List<DicVO>> getDicTree(){
// String methodDescribe = getMethodDescribe("getDicTree");
// List<DicVO> list = dicService.getDicTree(null);
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,list,methodDescribe);
// }
//
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
// @GetMapping("/codeDicTree")
// @ApiOperation("根据code获取字典树")
// public HttpResult<List<DicVO>> getCodeDicTree(String code){
// String methodDescribe = getMethodDescribe("getCodeDicTree");
// List<DicVO> list = dicService.getDicTree(code);
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,list,methodDescribe);
// }
// /**
// * 新增
// * @param dicParam
// */
// @OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD)
// @PostMapping("/add")
// @ApiOperation("新增")
// @ApiImplicitParam(name = "dicParam", value = "新增数据", required = true)
// public HttpResult<Boolean> add(@RequestBody @Validated DicParam dicParam) {
// String methodDescribe = getMethodDescribe("add");
// LogUtil.njcnDebug(log, "{},数据为:{}", methodDescribe, dicParam);
// boolean result = dicService.addDic(dicParam);
// if (result) {
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
// } else {
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
// }
// }
//
// /**
// * 修改
// * @param dicParam
// * @return
// */
// @OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
// @PutMapping("/update")
// @ApiOperation("修改")
// @ApiImplicitParam(name = "dicParam", value = "数据", required = true)
// public HttpResult<Boolean> update(@RequestBody @Validated DicParam.UpdateParam dicParam) {
// String methodDescribe = getMethodDescribe("update");
// LogUtil.njcnDebug(log, "{},更新的信息为:{}", methodDescribe,dicParam);
// boolean result = dicService.updateDic(dicParam);
// if (result){
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
// } else {
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
// }
// }
//
// /**
// * 删除
// * @param id
// * @return
// */
// @OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.DELETE)
// @DeleteMapping("/delete")
// @ApiOperation("删除")
// @ApiImplicitParam(name = "id", value = "id", required = true)
// public HttpResult<Boolean> delete(@RequestParam @Validated String id) {
// String methodDescribe = getMethodDescribe("delete");
// LogUtil.njcnDebug(log, "{},删除的id为{}", methodDescribe,id);
// boolean result = dicService.deleteDic(id);
// if (result){
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
// } else {
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
// }
// }
//
// /**
// * 查询
// * @param id
// * @return
// */
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
// @GetMapping("/getDicById")
// @ApiOperation("查看详情")
// @ApiImplicitParam(name = "id", value = "id", required = true)
// public HttpResult<Dic> getDicById(String id){
// String methodDescribe = getMethodDescribe("getDicById");
// LogUtil.njcnDebug(log, "{},id为{}", methodDescribe,id);
// Dic dic = dicService.getDicById(id);
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,dic,methodDescribe);
// }
//}

View File

@@ -1,12 +0,0 @@
//package com.njcn.system.mapper;
//
//import com.baomidou.mybatisplus.core.mapper.BaseMapper;
//import com.njcn.system.pojo.po.Dic;
//import com.njcn.system.pojo.vo.DicVO;
//
//import java.util.List;
//
//public interface DicMapper extends BaseMapper<Dic> {
//
// List<DicVO> getAllDic();
//}

View File

@@ -1,52 +0,0 @@
//package com.njcn.system.service;
//
//
//import com.njcn.system.pojo.param.DicParam;
//import com.njcn.system.pojo.po.Dic;
//import com.njcn.system.pojo.vo.DicVO;
//import com.njcn.user.pojo.param.FunctionParam;
//import com.njcn.user.pojo.po.Function;
//
//import java.util.List;
//
///**
// * @author hany
// * @date 2022/10/18
// */
//public interface IDicService {
//
// /**
// * 获取树
// * @return
// */
// List<DicVO> getDicTree(String code);
//
// /**
// * 功能描述:新增
// *
// * @param dicParam 资源参数
// */
// boolean addDic(DicParam dicParam);
//
// /**
// * 功能描述: 修改
// *
// * @param dicParam
// */
// boolean updateDic(DicParam.UpdateParam dicParam);
//
// /**
// * 功能描述:删除
// *
// * @param id
// * @return boolean
// */
// boolean deleteDic(String id);
//
// /**
// * 功能描述: 根据id获取菜单详情
// *
// * @param id
// */
// Dic getDicById(String id);
//}

View File

@@ -1,130 +0,0 @@
//package com.njcn.system.service.impl;
//
//import cn.hutool.core.bean.BeanUtil;
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
//import com.njcn.common.pojo.exception.BusinessException;
//import com.njcn.system.enums.EventResponseEnum;
//import com.njcn.system.enums.TemplateTreeEnum;
//import com.njcn.system.mapper.DicMapper;
//import com.njcn.system.pojo.constant.DicState;
//import com.njcn.system.pojo.param.DicParam;
//import com.njcn.system.pojo.po.Dic;
//import com.njcn.system.pojo.vo.DicVO;
//import com.njcn.system.service.IDicService;
//import lombok.RequiredArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.lang.StringUtils;
//import org.springframework.stereotype.Service;
//
//import java.util.Comparator;
//import java.util.List;
//import java.util.Objects;
//import java.util.stream.Collectors;
//
///**
// * @author hany
// * @date 2022/10/18
// */
//@Slf4j
//@Service
//@RequiredArgsConstructor
//public class DicServiceImpl extends ServiceImpl<DicMapper, Dic> implements IDicService {
//
// private final DicMapper dicMapper;
//
// @Override
// public boolean addDic(DicParam dicParam) {
// checkDicParam(dicParam,false);
// Dic dic = new Dic();
// BeanUtil.copyProperties(dicParam, dic);
// dic.setStatus(DicState.ENABLE);
// if (Objects.equals(dicParam.getPid(),DicState.FATHER_PID)){
// dic.setPids(DicState.FATHER_PID);
// } else {
// Dic fatherFaction = this.lambdaQuery().eq(Dic::getId,dicParam.getPid()).one();
// if (Objects.equals(fatherFaction.getPid(),DicState.FATHER_PID)){
// dic.setPids(dicParam.getPid());
// } else {
// String pidS = fatherFaction.getPids();
// dic.setPids(pidS+","+dicParam.getPid());
// }
// }
// return this.save(dic);
// }
//
// @Override
// public boolean updateDic(DicParam.UpdateParam dicParam) {
// checkDicParam(dicParam,true);
// Dic dic = new Dic();
// BeanUtil.copyProperties(dicParam, dic);
// return this.updateById(dic);
// }
//
// @Override
// public boolean deleteDic(String id) {
// return this.lambdaUpdate().set(Dic::getStatus, DicState.DELETE).in(Dic::getId, id).update();
// }
//
// @Override
// public Dic getDicById(String id) {
// return this.lambdaQuery().eq(Dic::getId,id).one();
// }
//
// /**
// * 获取树
// * @return
// */
// @Override
// public List<DicVO> getDicTree(String code) {
// List<DicVO> list = dicMapper.getAllDic();
// return list.stream()
// .filter(fun -> {
// boolean flag =true;
// boolean flag1 =true;
// flag = Objects.equals(TemplateTreeEnum.FATHER_PID,fun.getPid());
// if(!StringUtils.isEmpty(code)){
// flag1 = fun.getCode().equals(code);
// }
//
// return flag&&flag1;
//
// })
// .peek(funS -> funS.setChildren(getChildList(funS, list)))
// .sorted(Comparator.comparingInt(DicVO::getSort))
// .collect(Collectors.toList());
// }
//
// /**
// * 递归组装
// */
// private List<DicVO> getChildList(DicVO dictMenu, List<DicVO> categories) {
// return categories.stream().filter(o -> Objects.equals(o.getPid(),dictMenu.getId()))
// .peek(o -> o.setChildren(getChildList(o, categories)))
// .sorted(Comparator.comparingInt(DicVO::getSort))
// .collect(Collectors.toList());
// }
//
// /**
// * 校验参数,
// * 1.检查是否存在相同名称的菜单
// */
// private void checkDicParam(DicParam dicParam, boolean isExcludeSelf) {
// LambdaQueryWrapper<Dic> lambdaQueryWrapper = new LambdaQueryWrapper<>();
// lambdaQueryWrapper
// .eq(Dic::getName,dicParam.getName())
// .eq(Dic::getStatus, DicState.ENABLE);
// //更新的时候,需排除当前记录
// if (isExcludeSelf) {
// if (dicParam instanceof DicParam.UpdateParam) {
// lambdaQueryWrapper.ne(Dic::getId, ((DicParam.UpdateParam) dicParam).getId());
// }
// }
// int countByAccount = this.count(lambdaQueryWrapper);
// //大于等于1个则表示重复
// if (countByAccount >= 1) {
// throw new BusinessException(EventResponseEnum.NAME_REPEAT);
// }
// }
//
//}

View File

@@ -5,8 +5,8 @@
<select id="getAllFunctions" resultType="FunctionVO">
SELECT
Id,Pid,
`Name` title,
`Code`,
Name title,
Code,
Path routePath,
Icon,Sort,
Type,
@@ -21,8 +21,8 @@
<select id="getFunctionsByList" resultType="FunctionVO">
SELECT
Id,Pid,
`Name` title,
`Code`,
Name title,
Code,
Path routePath,
Icon,Sort,
Type,
@@ -42,8 +42,8 @@
<select id="getUserFunctionsByList" resultType="FunctionVO">
SELECT
Id,Pid,
`Name` title,
`Code`,
Name title,
Code,
Path routePath,
Icon,Sort,
Type,
@@ -63,8 +63,8 @@
<select id="getByList" resultType="FunctionVO">
SELECT
Id,Pid,
`Name` title,
`Code`,
Name title,
Code,
Path routePath,
Icon,Sort,
Type,

View File

@@ -190,7 +190,7 @@ public class FunctionServiceImpl extends ServiceImpl<FunctionMapper, Function> i
}
List<FunctionVO> functionVOList = functionMapper.getFunctionsByList(functionList);
result = functionVOList.stream()
.filter(fun -> Objects.equals(FunctionState.FATHER_PID,fun.getPid()))
.filter(fun -> Objects.equals(FunctionState.FATHER_PID,fun.getPid().trim()))
.peek(funS -> funS.setChildren(getChildCategoryList(funS, functionVOList)))
.sorted(Comparator.comparingInt(FunctionVO::getSort))
.collect(Collectors.toList());