测试文档bug调整

This commit is contained in:
xy
2025-07-28 21:02:50 +08:00
parent 2009009296
commit 67680628a1
25 changed files with 638 additions and 66 deletions

View File

@@ -19,7 +19,7 @@ public interface ValidMessage {
String NAME_NOT_BLANK = "名称不能为空请检查name参数";
String NAME_FORMAT_ERROR = "名称格式错误请检查name参数";
String NAME_FORMAT_ERROR = "名称格式错误,存在特殊符号或超过20字符请检查name参数";
String INDUSTRY_NOT_BLANK = "行业不能为空请检查industry参数";
String INDUSTRY_FORMAT_ERROR = "行业格式错误请检查industry参数";

View File

@@ -1,7 +1,11 @@
package com.njcn.device.pq.api;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.ServerInfo;
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.device.biz.pojo.dto.PollutionLineDTO;
import com.njcn.device.pq.api.fallback.LineFeignClientFallbackFactory;
import com.njcn.device.pq.pojo.dto.*;
@@ -13,6 +17,8 @@ import com.njcn.device.pq.pojo.po.LineDetail;
import com.njcn.device.biz.pojo.po.Overlimit;
import com.njcn.device.pq.pojo.po.line.LineInfoVO;
import com.njcn.device.pq.pojo.vo.*;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@@ -21,6 +27,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @author denghuajun
@@ -366,4 +373,7 @@ import java.util.Map;
@PostMapping("/getPowerStationByMonitorIds")
HttpResult<List<PollutionSubstationDTO>> getPowerStationByMonitorIds(@RequestBody List<String> ids);
@PostMapping("/getDevListByLineIdList")
HttpResult<Set<String>> getDevListByLineIdList(@RequestBody List<String> list);
}

View File

@@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @author denghuajun
@@ -306,6 +307,12 @@ public class LineFeignClientFallbackFactory implements FallbackFactory<LineFeign
log.error("{}异常,降级处理,异常为:{}", "根据监测id集合查询场站用户信息: ", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<Set<String>> getDevListByLineIdList(List<String> list) {
log.error("{}异常,降级处理,异常为:{}", "根据监测点id集合获取装置id集合: ", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -33,6 +33,7 @@ import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
/**
* @author denghuajun
@@ -138,6 +139,17 @@ public class LineController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getDevListByLineIdList")
@ApiOperation("根据监测点id集合获取装置id集合")
@ApiImplicitParam(name = "list", value = "监测点id集合", required = true)
public HttpResult<Set<String>> getDevListByLineIdList(@RequestBody List<String> list) {
String methodDescribe = getMethodDescribe("getDevListByLineIdList");
Set<String> result = lineService.getDevListByLineIdList(list);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getOverLimitData")
@ApiOperation("根据监测点id获取越限数值")

View File

@@ -58,7 +58,7 @@
<select id="getMonitorDetail" resultType="com.njcn.device.biz.pojo.dto.LineDevGetDTO">
select a.id pointId,a.name pointName,b.Time_Interval timeInterval,bus.pid devId
select a.id pointId,a.name pointName,b.Time_Interval timeInterval,bus.pid devId,b.PT_Type wiringMethod
from pq_line a
inner join pq_line_detail b on a.id=b.id
inner join pq_line bus on a.pid =bus.id

View File

@@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* 监测点类
@@ -63,6 +64,8 @@ public interface LineService extends IService<Line> {
*/
String getLineIdByDevId(String id);
Set<String> getDevListByLineIdList(List<String> list);
/**
* 获取限值表信息
* @param id 监测点id

View File

@@ -293,6 +293,24 @@ public class LineServiceImpl extends ServiceImpl<LineMapper, Line> implements Li
return devId;
}
@Override
public Set<String> getDevListByLineIdList(List<String> list) {
Set<String> set = new HashSet<>();
list.forEach(item->{
String devId = "";
//根据id查询当前信息的pids
List<String> pids = Arrays.asList(this.baseMapper.selectById(item).getPids().split(","));
List<LineDataVO> lineDataVOList = this.baseMapper.getLineDetail(pids);
for (LineDataVO lineDataVO : lineDataVOList) {
if (lineDataVO.getLevel() == 4) {
devId = lineDataVO.getId();
}
}
set.add(devId);
});
return set;
}
@Override
public Overlimit getOverLimitData(String id) {
return overlimitMapper.selectById(id);

View File

@@ -118,6 +118,7 @@ public class RmpEventDetailPO implements Serializable {
private Double transientValue;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
@ApiModelProperty(value = "用于计算数量")

View File

@@ -0,0 +1,50 @@
package com.njcn.event.pojo.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.influxdb.annotation.Column;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Set;
/**
* @author xy
*/
@Data
public class SendEventVO implements Serializable {
@ApiModelProperty("部门集合")
private Set<String> deptList;
@ApiModelProperty(name = "time",value = "暂降发生时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime time;
@ApiModelProperty(name = "eventValue",value = "特征幅值")
@Column(name = "event_value")
private Double eventValue;
@ApiModelProperty(name = "persistTime",value = "持续时间ms")
@Column(name = "persist_time")
private Double persistTime;
@ApiModelProperty(name = "eventType",value = "暂降类型")
@Column(name = "event_type")
private String eventType;
@ApiModelProperty(name = "eventReason",value = "暂降原因")
@Column(name = "event_reason")
private String eventReason;
@ApiModelProperty("监测点名称")
private String lineName;
@ApiModelProperty("供电公司")
private String powerCompany;
@ApiModelProperty("变电站")
private String substation;
}

View File

@@ -1,14 +1,13 @@
package com.njcn.event.pojo.vo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.influxdb.annotation.Column;
import org.influxdb.annotation.Measurement;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
*获取事件报告
* @author zbj
@@ -84,7 +83,8 @@ public class WaveTypeVO{
private String lineId;
@Column(name = "time")
private String startTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime startTime;
@Column(name = "event_describe")
private String eventDescribe;
@@ -147,7 +147,8 @@ public class WaveTypeVO{
private String sagSource;
@Column(name = "create_time")
private String createTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
}

View File

@@ -15,8 +15,8 @@ import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
import com.njcn.event.enums.EventResponseEnum;
import com.njcn.event.file.pojo.enums.WaveFileResponseEnum;
import com.njcn.event.pojo.constant.Param;
import com.njcn.event.pojo.param.*;
import com.njcn.event.pojo.param.EventBaseParam;
import com.njcn.event.pojo.param.StatisticsParam;
import com.njcn.event.pojo.po.EventDetail;
import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.event.pojo.vo.*;
@@ -30,11 +30,9 @@ import com.njcn.system.pojo.po.DictData;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils;
import org.influxdb.dto.QueryResult;
import org.influxdb.impl.InfluxDBResultMapper;
import org.springframework.stereotype.Service;
import java.io.*;
import java.math.BigDecimal;
import java.text.ParseException;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
@@ -1428,7 +1426,8 @@ public class EventAnalysisServiceImpl implements EventAnalysisService {
if (waveTypeVO.getLineId() != null) {
for (AreaLineInfoVO lineInfoVO : areaLineList) {
if (waveTypeVO.getLineId().equals(lineInfoVO.getLineId())) {
waveTypeVO.setStartTime(record.getStartTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS")));
// waveTypeVO.setStartTime(record.getStartTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS")));
waveTypeVO.setStartTime(record.getStartTime());
waveTypeVO.setSubName(lineInfoVO.getSubName());
waveTypeVO.setLineId(lineInfoVO.getLineId());
waveTypeVO.setLineName(lineInfoVO.getLineName());

View File

@@ -1,11 +1,22 @@
package com.njcn.event.service.majornetwork.Impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
import com.njcn.common.pojo.constant.LogInfo;
import com.njcn.common.pojo.dto.LogInfoDTO;
import com.njcn.common.utils.PubUtils;
import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
import com.njcn.device.biz.pojo.dto.DeptGetBase;
import com.njcn.device.biz.pojo.param.DeptGetLineParam;
import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
import com.njcn.event.pojo.vo.SendEventVO;
import com.njcn.event.utils.EventUtil;
import com.njcn.event.mapper.majornetwork.EventDetailMapper;
import com.njcn.event.pojo.dto.EventDeatilDTO;
@@ -16,6 +27,7 @@ import com.njcn.influx.utils.InfluxDbUtils;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.pojo.po.DictData;
import com.njcn.web.utils.RequestUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.influxdb.dto.QueryResult;
@@ -26,8 +38,7 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;
import java.util.*;
/**
* @author denghuajun
@@ -40,8 +51,10 @@ import java.util.Objects;
public class EventDetailServiceImpl extends ServiceImpl<EventDetailMapper, RmpEventDetailPO> implements EventDetailService {
private final InfluxDbUtils influxDbUtils;
private final DicDataFeignClient dicDataFeignClient;
private final MqttPublisher publisher;
private final CommTerminalGeneralClient commTerminalGeneralClient;
private final LineFeignClient lineFeignClient;
@Override
@@ -159,14 +172,41 @@ public class EventDetailServiceImpl extends ServiceImpl<EventDetailMapper, RmpEv
if(Objects.nonNull(one)){
rmpEventDetailPO.setEventId(one.getEventId());
this.updateById(rmpEventDetailPO);
}else {
} else {
this.save(rmpEventDetailPO);
//推送MQTT消息给前端用于展示告警消息和弹窗
pushEvent(rmpEventDetailPO);
}
return true;
}
private void pushEvent(RmpEventDetailPO po) {
//获取部门
String deptIndex = RequestUtil.getDeptIndex();
Set<String> dept = new HashSet<>();
dept.add(deptIndex);
DeptGetLineParam deptGetLineParam = new DeptGetLineParam();
deptGetLineParam.setDeptId(deptIndex);
List<DeptGetBase> deptList = commTerminalGeneralClient.getDeptChildrenByParent(deptGetLineParam).getData();
if (CollectionUtil.isNotEmpty(deptList)) {
deptList.forEach(item->{
dept.addAll(item.getUnitChildrenList());
});
}
SendEventVO vo = new SendEventVO();
vo.setDeptList(dept);
vo.setTime(po.getStartTime());
vo.setEventValue(po.getFeatureAmplitude());
vo.setPersistTime(po.getDuration());
vo.setEventType(po.getEventType());
vo.setEventReason(po.getAdvanceReason());
List<AreaLineInfoVO> lineInfoVOList = lineFeignClient.getBaseLineAreaInfo(Collections.singletonList(po.getLineId())).getData();
vo.setLineName(lineInfoVOList.get(0).getLineName());
vo.setPowerCompany(lineInfoVOList.get(0).getGdName());
vo.setSubstation(lineInfoVOList.get(0).getSubName());
publisher.send("/sendEvent", PubUtils.obj2json(vo), 1, false);
}
public String eventTypeReflection(Integer eventType){
String result ="";
switch (eventType) {

View File

@@ -45,6 +45,9 @@ public class HistoryDataResultVO implements Serializable {
@ApiModelProperty("下限")
private Float lowerLimit;
@ApiModelProperty("接线方式 0.星型 1.星三角 2.三角")
private String wiringMethod;
@ApiModelProperty("暂降事件详情")
private List<EventDetailVO> eventDetail;

View File

@@ -23,4 +23,8 @@ public class QueryResultLimitVO implements Serializable {
private List<String> phaiscType;
private List<String> unit;
private Integer harmNum;
/**
* 接线方式 0.星型 1.星三角 2.三角
*/
private String wiringMethod;
}

View File

@@ -827,6 +827,7 @@ public class HistoryResultServiceImpl implements HistoryResultService {
queryResultLimitVO.setLineName(lineDetailDataVO.getPointName());
queryResultLimitVO.setHarmNum(number);
queryResultLimitVO.setTargetName(targetName);
queryResultLimitVO.setWiringMethod(lineDetailDataVO.getWiringMethod());
} else {
return queryResultLimitVO;
}

View File

@@ -0,0 +1,207 @@
package com.njcn.prepare.harmonic.pojo.bo.excel;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
import java.io.Serializable;
/**
* @author xy
*/
@Data
public class DataVDetail implements Serializable {
/**
* 供电公司名称
*/
@Excel(name = "时间", width = 30)
private String time;
/**
* 所属变电站
*/
@Excel(name = "变电站", width = 30)
private String subStationName;
/**
* 终端名称
*/
@Excel(name = "终端名称", width = 30)
private String devName;
/**
* 监测点索引
*/
private String lineId;
/**
* 监测点名称
*/
@Excel(name = "监测点名称", width = 30)
private String lineName;
/**
* 相别
*/
@Excel(name = "相别", width = 30)
private String phaseType;
/**
* 新增
* 监测点电压等级
*/
@Excel(name = "监测点电压等级", width = 30)
private String lineVoltage;
@Excel(name = "电压总谐波畸变率", width = 10)
private Double vThd;
@Excel(name = "2次谐波电压含有率", width = 10)
private Double v2;
@Excel(name = "3次谐波电压含有率", width = 10)
private Double v3;
@Excel(name = "4次谐波电压含有率", width = 10)
private Double v4;
@Excel(name = "5次谐波电压含有率", width = 10)
private Double v5;
@Excel(name = "6次谐波电压含有率", width = 10)
private Double v6;
@Excel(name = "7次谐波电压含有率", width = 10)
private Double v7;
@Excel(name = "8次谐波电压含有率", width = 10)
private Double v8;
@Excel(name = "9次谐波电压含有率", width = 10)
private Double v9;
@Excel(name = "10次谐波电压含有率", width = 10)
private Double v10;
@Excel(name = "11次谐波电压含有率", width = 10)
private Double v11;
@Excel(name = "12次谐波电压含有率", width = 10)
private Double v12;
@Excel(name = "13次谐波电压含有率", width = 10)
private Double v13;
@Excel(name = "14次谐波电压含有率", width = 10)
private Double v14;
@Excel(name = "15次谐波电压含有率", width = 10)
private Double v15;
@Excel(name = "16次谐波电压含有率", width = 10)
private Double v16;
@Excel(name = "17次谐波电压含有率", width = 10)
private Double v17;
@Excel(name = "18次谐波电压含有率", width = 10)
private Double v18;
@Excel(name = "19次谐波电压含有率", width = 10)
private Double v19;
@Excel(name = "20次谐波电压含有率", width = 10)
private Double v20;
@Excel(name = "21次谐波电压含有率", width = 10)
private Double v21;
@Excel(name = "22次谐波电压含有率", width = 10)
private Double v22;
@Excel(name = "23次谐波电压含有率", width = 10)
private Double v23;
@Excel(name = "24次谐波电压含有率", width = 10)
private Double v24;
@Excel(name = "25次谐波电压含有率", width = 10)
private Double v25;
@Excel(name = "26次谐波电压含有率", width = 10)
private Double v26;
@Excel(name = "27次谐波电压含有率", width = 10)
private Double v27;
@Excel(name = "28次谐波电压含有率", width = 10)
private Double v28;
@Excel(name = "29次谐波电压含有率", width = 10)
private Double v29;
@Excel(name = "30次谐波电压含有率", width = 10)
private Double v30;
@Excel(name = "31次谐波电压含有率", width = 10)
private Double v31;
@Excel(name = "32次谐波电压含有率", width = 10)
private Double v32;
@Excel(name = "33次谐波电压含有率", width = 10)
private Double v33;
@Excel(name = "34次谐波电压含有率", width = 10)
private Double v34;
@Excel(name = "35次谐波电压含有率", width = 10)
private Double v35;
@Excel(name = "36次谐波电压含有率", width = 10)
private Double v36;
@Excel(name = "37次谐波电压含有率", width = 10)
private Double v37;
@Excel(name = "38次谐波电压含有率", width = 10)
private Double v38;
@Excel(name = "39次谐波电压含有率", width = 10)
private Double v39;
@Excel(name = "40次谐波电压含有率", width = 10)
private Double v40;
@Excel(name = "41次谐波电压含有率", width = 10)
private Double v41;
@Excel(name = "42次谐波电压含有率", width = 10)
private Double v42;
@Excel(name = "43次谐波电压含有率", width = 10)
private Double v43;
@Excel(name = "44次谐波电压含有率", width = 10)
private Double v44;
@Excel(name = "45次谐波电压含有率", width = 10)
private Double v45;
@Excel(name = "46次谐波电压含有率", width = 10)
private Double v46;
@Excel(name = "47次谐波电压含有率", width = 10)
private Double v47;
@Excel(name = "48次谐波电压含有率", width = 10)
private Double v48;
@Excel(name = "49次谐波电压含有率", width = 10)
private Double v49;
@Excel(name = "50次谐波电压含有率", width = 10)
private Double v50;
}

View File

@@ -277,7 +277,6 @@ public class MeasurementExecutor extends BaseExecutor {
@LiteflowMethod(value = LiteFlowMethodEnum.IS_ACCESS, nodeId = "dataHarmPowerP", nodeType = NodeTypeEnum.COMMON)
public boolean dataToDayAccess7(NodeComponent bindCmp) {return isAccess(bindCmp);}
@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "dataHarmPowerP", nodeType = NodeTypeEnum.COMMON)
public void dataToDayProcess7(NodeComponent bindCmp) {dayDataService.dataHarmPowerPHardler(bindCmp.getRequestData());}

View File

@@ -3,4 +3,9 @@ package com.njcn.prepare.harmonic.service.influxdb;
public interface IPollutionCalc {
void calcAllLineValue();
//按监测点获取各地市谐波电压原始数据
void getDataVByLineId();
}

View File

@@ -35,6 +35,8 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.reflect.Field;
import java.time.Instant;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -299,6 +301,55 @@ public class PollutionCalcImpl implements IPollutionCalc {
System.out.println("程序执行完毕,总耗时:" + time + "");
}
@Override
public void getDataVByLineId() {
List<DataVDetail> linePollutionList = new ArrayList<>();
String yesterdayDate = "2025-03-10";
String beginDay = "2025-02-10 00:00:00";
String endDay = "2025-03-10 23:59:59";
List<String> lineIdList = Arrays.asList("123","456","789");
List<PollutionLineInfoDTO> lineInfoDTOList = commLineClient.getPollutionLineInfo(lineIdList).getData();
if (CollUtil.isNotEmpty(lineIdList)) {
// 获取谐波电压数据 电压总谐波畸变率 + 2—50次谐波电压含有率
for (int i = 0; i < lineIdList.size(); i++) {
String lineId = lineIdList.get(i);
DataVDetail linePollution = new DataVDetail();
linePollution.setLineId(lineId);
//获取监测点限值
//Overlimit overlimit = commTerminalGeneralClient.getOverLimitData(lineId).getData();
LineDevGetDTO lineDetailData = commTerminalGeneralClient.getMonitorDetail(lineId).getData();
linePollution.setLineName(lineDetailData.getPointName());
//获取该监测点其他元信息
Optional<PollutionLineInfoDTO> any = lineInfoDTOList.stream().filter(item -> item.getLineId().equals(lineId)).findAny();
if (any.isPresent()) {
PollutionLineInfoDTO data = any.get();
BeanUtil.copyProperties(data, linePollution, true);
}
linePollutionList = getData(linePollution,beginDay,endDay);
}
}
List<DataVDetail> finalLinePollutionList = new ArrayList<>(linePollutionList);
// 全部监测点计算完毕后按时间排序
finalLinePollutionList.sort(Comparator.comparing(DataVDetail::getTime).thenComparing(DataVDetail::getPhaseType));
Collections.reverse(finalLinePollutionList);
// 监测点的污染值计算完毕后输出到指定目录。目前目录是写死的待后期调整成配置可供用户选择下载。todo...
// 导出监测点污染值
String folder = "c:\\njcn";
File file = new File(folder);
if (!file.exists()) {
boolean mkdirs = file.mkdirs();
if (!mkdirs) {
System.out.println("无法创建文件夹");
return;
}
}
String fileName = folder + "\\各地市谐波电压数据详情" + yesterdayDate + ".xlsx";
ExportParams exportParams = new ExportParams();
exportLinePollution(exportParams, LinePollution.class, finalLinePollutionList, fileName);
}
/**
* 输出下载文件
@@ -325,11 +376,122 @@ public class PollutionCalcImpl implements IPollutionCalc {
}
}
/**
* 获取规定时间内谐波电压数据
* 谐波电压包含 电压总谐波畸变率 + 2~50次谐波电压含有率
* @param linePollution 监测点信息
*/
private List<DataVDetail> getData(DataVDetail linePollution, String startTime, String endTime) {
List<DataVDetail> linePollutionList = new ArrayList<>();
InfluxQueryWrapper dataVQueryWrapper = new InfluxQueryWrapper(DataV.class);
dataVQueryWrapper.select(DataV::getVThd)
.select(DataV::getPhaseType)
.eq(DataV::getLineId, linePollution.getLineId())
.eq(DataV::getValueType, InfluxDbSqlConstant.CP95)
.ne(DataV::getPhaseType, InfluxDBTableConstant.PHASE_TYPE_T)
.between(DataV::getTime, startTime, endTime);
List<DataV> vthResultList = dataVMapper.getStatisticsByWraper(dataVQueryWrapper);
InfluxQueryWrapper dataVQueryWrapper2 = new InfluxQueryWrapper(DataHarmRateV.class);
dataVQueryWrapper2.samePrefixAndSuffix(InfluxDbSqlConstant.V, "", HarmonicTimesUtil.harmonicTimesList(2, 50, 1));
dataVQueryWrapper2.eq(DataHarmRateV::getLineId, linePollution.getLineId())
.eq(DataHarmRateV::getValueType, InfluxDbSqlConstant.CP95)
.ne(DataHarmRateV::getPhaseType, InfluxDBTableConstant.PHASE_TYPE_T)
.between(DataHarmRateV::getTime, startTime, endTime);
List<DataHarmRateV> vthResultList2 = dataHarmRateVMapper.getStatisticsByWraper(dataVQueryWrapper2);
if (CollUtil.isNotEmpty(vthResultList) && CollUtil.isNotEmpty(vthResultList2)) {
Map<Instant,List<DataV>> map1 = vthResultList.stream().collect(Collectors.groupingBy(DataV::getTime));
Map<Instant, Map<String, DataV>> map1ByPhase = map1.entrySet().stream()
.collect(Collectors.toMap(
Map.Entry::getKey,
entry -> entry.getValue().stream()
.collect(Collectors.toMap(DataV::getPhaseType, dataV -> dataV))
));
Map<Instant,List<DataHarmRateV>> map2 = vthResultList2.stream().collect(Collectors.groupingBy(DataHarmRateV::getTime));
Map<Instant, Map<String, DataHarmRateV>> map2ByPhase = map2.entrySet().stream()
.collect(Collectors.toMap(
Map.Entry::getKey,
entry -> entry.getValue().stream()
.collect(Collectors.toMap(DataHarmRateV::getPhaseType, dataHarmRateV -> dataHarmRateV))
));
// 获取两个 Map 的时间交集
Set<Instant> commonTimes = new HashSet<>(map1.keySet());
commonTimes.retainAll(map2.keySet());
for (Instant time : commonTimes) {
Map<String, DataV> phaseData1 = map1ByPhase.get(time);
Map<String, DataHarmRateV> phaseData2 = map2ByPhase.get(time);
// 遍历 phaseData1 的所有 phaseType
phaseData1.forEach((phaseType, dataV) -> {
// 在 phaseData2 中查找匹配的 phaseType
DataHarmRateV harmRateV = phaseData2.get(phaseType);
if (harmRateV != null) {
DataVDetail detail = new DataVDetail();
BeanUtil.copyProperties(linePollution,detail);
detail.setTime(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(time));
detail.setPhaseType(phaseType); // 设置相别
detail.setVThd(dataV.getVThd()); // 设置 DataV 的值
detail.setV2(harmRateV.getV2());
detail.setV3(harmRateV.getV3());
detail.setV4(harmRateV.getV4());
detail.setV5(harmRateV.getV5());
detail.setV6(harmRateV.getV6());
detail.setV7(harmRateV.getV7());
detail.setV8(harmRateV.getV8());
detail.setV9(harmRateV.getV9());
detail.setV10(harmRateV.getV10());
detail.setV11(harmRateV.getV11());
detail.setV12(harmRateV.getV12());
detail.setV13(harmRateV.getV13());
detail.setV14(harmRateV.getV14());
detail.setV15(harmRateV.getV15());
detail.setV16(harmRateV.getV16());
detail.setV17(harmRateV.getV17());
detail.setV18(harmRateV.getV18());
detail.setV19(harmRateV.getV19());
detail.setV20(harmRateV.getV20());
detail.setV21(harmRateV.getV21());
detail.setV22(harmRateV.getV22());
detail.setV23(harmRateV.getV23());
detail.setV24(harmRateV.getV24());
detail.setV25(harmRateV.getV25());
detail.setV26(harmRateV.getV26());
detail.setV27(harmRateV.getV27());
detail.setV28(harmRateV.getV28());
detail.setV29(harmRateV.getV29());
detail.setV30(harmRateV.getV30());
detail.setV31(harmRateV.getV31());
detail.setV32(harmRateV.getV32());
detail.setV33(harmRateV.getV33());
detail.setV34(harmRateV.getV34());
detail.setV35(harmRateV.getV35());
detail.setV36(harmRateV.getV36());
detail.setV37(harmRateV.getV37());
detail.setV38(harmRateV.getV38());
detail.setV39(harmRateV.getV39());
detail.setV40(harmRateV.getV40());
detail.setV41(harmRateV.getV41());
detail.setV42(harmRateV.getV42());
detail.setV43(harmRateV.getV43());
detail.setV44(harmRateV.getV44());
detail.setV45(harmRateV.getV45());
detail.setV46(harmRateV.getV46());
detail.setV47(harmRateV.getV47());
detail.setV48(harmRateV.getV48());
detail.setV49(harmRateV.getV49());
detail.setV50(harmRateV.getV50());
linePollutionList.add(detail);
}
});
}
}
return linePollutionList;
}
/**
* 计算谐波电压的污染值包含了电压总畸变率和谐波电压2~25次
*
* @param linePollution 监测点信息
* @param overlimit 当前监测点限值
*/
private double calcVAllPollutionValue(LinePollution linePollution, Overlimit overlimit, String startTime, String endTime) {
//最大值

View File

@@ -1324,7 +1324,7 @@ public class UserReportPOServiceImpl extends ServiceImpl<UserReportPOMapper, Use
LambdaQueryWrapper<UserReportPO> userReportPOLambdaQueryWrapper = new LambdaQueryWrapper<>();
userReportPOLambdaQueryWrapper
.eq(UserReportPO::getProjectName, userReportParam.getProjectName())
.in(UserReportPO::getStatus, CollectionUtil.newArrayList(BpmProcessInstanceStatusEnum.RUNNING.getStatus(), BpmProcessInstanceStatusEnum.APPROVE.getStatus()))
.in(UserReportPO::getStatus, CollectionUtil.newArrayList(BpmProcessInstanceStatusEnum.AWAIT.getStatus(),BpmProcessInstanceStatusEnum.RUNNING.getStatus(), BpmProcessInstanceStatusEnum.APPROVE.getStatus()))
.eq(UserReportPO::getState, DataStateEnum.ENABLE.getCode());
//更新的时候,需排除当前记录
if (isExcludeSelf) {

View File

@@ -8,9 +8,8 @@ import lombok.EqualsAndHashCode;
import org.springframework.web.multipart.MultipartFile;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.util.List;
/**
@@ -21,7 +20,7 @@ import java.util.List;
* @createTime 2022/1/12 13:45
*/
@Data
public class ThemeParam {
public class ThemeParam implements Serializable {
@ApiModelProperty("主题名称")
@NotBlank(message = ValidMessage.NAME_NOT_BLANK)
@@ -29,7 +28,6 @@ public class ThemeParam {
private String name;
@ApiModelProperty("主题描述")
@NotBlank(message = ValidMessage.REMARK_NOT_BLANK)
@Pattern(regexp = PatternRegex.NORMAL, message = ValidMessage.REMARK_FORMAT_ERROR)
private String remark;
@@ -39,11 +37,11 @@ public class ThemeParam {
private String color;
@ApiModelProperty("logo图片")
@NotNull(message = ValidMessage.LOGO_NOT_BLANK)
@NotBlank(message = ValidMessage.LOGO_NOT_BLANK)
private MultipartFile logoFile;
@ApiModelProperty("favicon图标")
@NotNull(message = ValidMessage.FAVICON_NOT_BLANK)
@NotBlank(message = ValidMessage.FAVICON_NOT_BLANK)
private MultipartFile faviconFile;
@ApiModelProperty("切换栏位置")
@@ -84,7 +82,7 @@ public class ThemeParam {
/**
* 用户更新操作实体
*
* <p>
* 需要填写的参数用户的id
*/
@Data

View File

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.constant.BizParamConstant;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.redis.pojo.enums.AppRedisKey;
import com.njcn.redis.utils.RedisUtil;
import com.njcn.system.enums.DicDataTypeEnum;
@@ -15,12 +16,18 @@ import com.njcn.system.pojo.param.DictTreeParam;
import com.njcn.system.pojo.po.SysDicTreePO;
import com.njcn.system.pojo.vo.DictTreeVO;
import com.njcn.system.service.SysDicTreePOService;
import com.njcn.user.enums.UserResponseEnum;
import com.njcn.user.pojo.constant.FunctionState;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.function.Consumer;
import java.util.stream.Collectors;
/**
@@ -47,18 +54,15 @@ public class SysDicTreePOServiceImpl extends ServiceImpl<SysDicTreePOMapper, Sys
@Override
@Transactional(rollbackFor = {Exception.class})
public boolean addDictTree(DictTreeParam dictTreeParam) {
checkFunctionParam(dictTreeParam,false);
boolean result;
SysDicTreePO sysDicTreePO = new SysDicTreePO();
BeanUtils.copyProperties(dictTreeParam, sysDicTreePO);
if (!Objects.equals(sysDicTreePO.getPid(), BizParamConstant.PARENT_ID)) {
QueryWrapper<SysDicTreePO> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("id", sysDicTreePO.getPid());
SysDicTreePO instance = this.baseMapper.selectOne(queryWrapper);
sysDicTreePO.setPids(instance.getPids() + StrPool.COMMA + instance.getId());
} else {
sysDicTreePO.setPids(BizParamConstant.PARENT_ID);
}
@@ -75,6 +79,7 @@ public class SysDicTreePOServiceImpl extends ServiceImpl<SysDicTreePOMapper, Sys
@Override
public boolean updateDictTree(DictTreeParam dictTreeParam) {
checkFunctionParam(dictTreeParam,true);
boolean result;
SysDicTreePO sysDicTreePO = new SysDicTreePO();
BeanUtils.copyProperties(dictTreeParam, sysDicTreePO);
@@ -219,4 +224,36 @@ public class SysDicTreePOServiceImpl extends ServiceImpl<SysDicTreePOMapper, Sys
}).collect(Collectors.toList());
}
private void checkFunctionParam(DictTreeParam dictTreeParam, boolean isExcludeSelf) {
// 检查同名同父级的功能是否存在
checkFunctionDuplicate(dictTreeParam, isExcludeSelf,
wrapper -> wrapper.eq(SysDicTreePO::getName, dictTreeParam.getName())
.eq(SysDicTreePO::getPid, dictTreeParam.getPid()),
UserResponseEnum.FUNCTION_NAME_EXIST);
// 检查同路径同父级的功能是否存在
checkFunctionDuplicate(dictTreeParam, isExcludeSelf,
wrapper -> wrapper.eq(SysDicTreePO::getCode, dictTreeParam.getCode())
.eq(SysDicTreePO::getPid, dictTreeParam.getPid()),
UserResponseEnum.FUNCTION_CODE_EXIST);
}
private void checkFunctionDuplicate(DictTreeParam dictTreeParam,
boolean isExcludeSelf,
Consumer<LambdaQueryWrapper<SysDicTreePO>> queryCustomizer,
UserResponseEnum errorEnum) {
LambdaQueryWrapper<SysDicTreePO> wrapper = new LambdaQueryWrapper<>();
// 应用公共条件
wrapper.eq(SysDicTreePO::getStatus, FunctionState.DELETE);
// 应用自定义条件
queryCustomizer.accept(wrapper);
// 排除自身条件
if (isExcludeSelf && dictTreeParam instanceof DictTreeParam.DictTreeUpdateParam) {
wrapper.ne(SysDicTreePO::getId, ((DictTreeParam.DictTreeUpdateParam) dictTreeParam).getId());
}
// 检查是否存在重复记录
if (this.count(wrapper) >= 1) {
throw new BusinessException(errorEnum);
}
}
}

View File

@@ -134,21 +134,21 @@ public class ThemeServiceImpl extends ServiceImpl<ThemeMapper, Theme> implements
if (themeParam.getFaviconFile().isEmpty()) {
throw new BusinessException(ThemeEnum.FAVICON_FILE_BLANK);
}
LambdaQueryWrapper<Theme> themeLambdaQueryWrapper = new LambdaQueryWrapper<>();
themeLambdaQueryWrapper
.eq(Theme::getName, themeParam.getName())
.eq(Theme::getState, ThemeState.NORMAL);
//更新的时候,需排除当前记录
if (isExcludeSelf) {
if (themeParam instanceof ThemeParam.ThemeUpdateParam) {
themeLambdaQueryWrapper.ne(Theme::getId, ((ThemeParam.ThemeUpdateParam) themeParam).getId());
}
}
int countByAccount = this.count(themeLambdaQueryWrapper);
//大于等于1个则表示重复
if (countByAccount >= 1) {
throw new BusinessException(ThemeEnum.SAME_THEME_NAME);
}
// LambdaQueryWrapper<Theme> themeLambdaQueryWrapper = new LambdaQueryWrapper<>();
// themeLambdaQueryWrapper
// .eq(Theme::getName, themeParam.getName())
// .eq(Theme::getState, ThemeState.NORMAL);
// //更新的时候,需排除当前记录
// if (isExcludeSelf) {
// if (themeParam instanceof ThemeParam.ThemeUpdateParam) {
// themeLambdaQueryWrapper.ne(Theme::getId, ((ThemeParam.ThemeUpdateParam) themeParam).getId());
// }
// }
// int countByAccount = this.count(themeLambdaQueryWrapper);
// //大于等于1个则表示重复
// if (countByAccount >= 1) {
// throw new BusinessException(ThemeEnum.SAME_THEME_NAME);
// }
}
/**

View File

@@ -63,6 +63,8 @@ public enum UserResponseEnum {
REGISTER_LOGIN_NAME_EXIST("A0102", "该登录名已存在,请检查loginName字段"),
REGISTER_HOMEPAGE_NAME_EXIST("A0102", "该驾驶舱名已存在,请检查name字段"),
FUNCTION_PATH_EXIST("A0102", "菜单路径已存在,请检查path字段"),
FUNCTION_CODE_EXIST("A0102", "菜单code已存在,请检查code字段"),
FUNCTION_NAME_EXIST("A0102", "菜单名称已存在,请检查name字段"),
COMPONENT_NAME_EXIST("A0102", "组件名已存在,请检查name字段"),

View File

@@ -27,6 +27,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.*;
import java.util.function.Consumer;
import java.util.stream.Collectors;
/**
@@ -324,22 +325,34 @@ public class FunctionServiceImpl extends ServiceImpl<FunctionMapper, Function> i
* 名称 && 路径做唯一判断
*/
private void checkFunctionParam(FunctionParam functionParam, boolean isExcludeSelf) {
LambdaQueryWrapper<Function> functionLambdaQueryWrapper = new LambdaQueryWrapper<>();
functionLambdaQueryWrapper
.eq(Function::getName, functionParam.getName())
.eq(Function::getPath, functionParam.getPath())
.eq(Function::getPid, functionParam.getPid())
.eq(Function::getState, FunctionState.ENABLE);
//更新的时候,需排除当前记录
if (isExcludeSelf) {
if (functionParam instanceof FunctionParam.FunctionUpdateParam) {
functionLambdaQueryWrapper.ne(Function::getId, ((FunctionParam.FunctionUpdateParam) functionParam).getId());
}
// 检查同名同父级的功能是否存在
checkFunctionDuplicate(functionParam, isExcludeSelf,
wrapper -> wrapper.eq(Function::getName, functionParam.getName())
.eq(Function::getPid, functionParam.getPid()),
UserResponseEnum.FUNCTION_NAME_EXIST);
// 检查同路径同父级的功能是否存在
checkFunctionDuplicate(functionParam, isExcludeSelf,
wrapper -> wrapper.eq(Function::getPath, functionParam.getPath())
.eq(Function::getPid, functionParam.getPid()),
UserResponseEnum.FUNCTION_PATH_EXIST);
}
private void checkFunctionDuplicate(FunctionParam functionParam,
boolean isExcludeSelf,
Consumer<LambdaQueryWrapper<Function>> queryCustomizer,
UserResponseEnum errorEnum) {
LambdaQueryWrapper<Function> wrapper = new LambdaQueryWrapper<>();
// 应用公共条件
wrapper.eq(Function::getState, FunctionState.ENABLE);
// 应用自定义条件
queryCustomizer.accept(wrapper);
// 排除自身条件
if (isExcludeSelf && functionParam instanceof FunctionParam.FunctionUpdateParam) {
wrapper.ne(Function::getId, ((FunctionParam.FunctionUpdateParam) functionParam).getId());
}
int countByAccount = this.count(functionLambdaQueryWrapper);
//大于等于1个则表示重复
if (countByAccount >= 1) {
throw new BusinessException(UserResponseEnum.FUNCTION_PATH_EXIST);
// 检查是否存在重复记录
if (this.count(wrapper) >= 1) {
throw new BusinessException(errorEnum);
}
}