diff --git a/pqs-common/common-echarts/src/main/java/com/njcn/echarts/util/DrawPicUtil.java b/pqs-common/common-echarts/src/main/java/com/njcn/echarts/util/DrawPicUtil.java index ba66c83b8..af69d986b 100644 --- a/pqs-common/common-echarts/src/main/java/com/njcn/echarts/util/DrawPicUtil.java +++ b/pqs-common/common-echarts/src/main/java/com/njcn/echarts/util/DrawPicUtil.java @@ -24,7 +24,7 @@ import java.util.*; public class DrawPicUtil { //目前写死,后续作为配置 - @Value("${DrawPicUtil.URL:http://192.168.1.24:5174/picture}") + @Value("${DrawPicUtil.URL:http://127.0.0.1:3008/generate-chart}") private String URL; diff --git a/pqs-common/common-web/src/main/java/com/njcn/web/advice/ResponseAdvice.java b/pqs-common/common-web/src/main/java/com/njcn/web/advice/ResponseAdvice.java index 8f196cf66..c3c67afa6 100644 --- a/pqs-common/common-web/src/main/java/com/njcn/web/advice/ResponseAdvice.java +++ b/pqs-common/common-web/src/main/java/com/njcn/web/advice/ResponseAdvice.java @@ -1,17 +1,13 @@ package com.njcn.web.advice; import com.njcn.common.config.GeneralInfo; -import com.njcn.common.pojo.constant.SecurityConstants; import com.njcn.common.pojo.response.HttpResult; -import com.njcn.common.pojo.constant.LogInfo; import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.utils.ReflectCommonUtil; -import com.njcn.web.utils.RequestUtil; import com.njcn.web.service.ILogService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.MethodParameter; -import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.http.server.ServerHttpRequest; import org.springframework.http.server.ServerHttpResponse; @@ -19,7 +15,6 @@ import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice; import javax.annotation.Nonnull; -import javax.servlet.http.HttpServletRequest; import java.util.Arrays; import java.util.List; diff --git a/pqs-common/common-web/src/main/java/com/njcn/web/constant/ValidMessage.java b/pqs-common/common-web/src/main/java/com/njcn/web/constant/ValidMessage.java index 4491b9526..65f811f8c 100644 --- a/pqs-common/common-web/src/main/java/com/njcn/web/constant/ValidMessage.java +++ b/pqs-common/common-web/src/main/java/com/njcn/web/constant/ValidMessage.java @@ -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参数"; diff --git a/pqs-common/common-web/src/main/java/com/njcn/web/service/impl/LogServiceImpl.java b/pqs-common/common-web/src/main/java/com/njcn/web/service/impl/LogServiceImpl.java index 3c8b94bd8..c1b697e26 100644 --- a/pqs-common/common-web/src/main/java/com/njcn/web/service/impl/LogServiceImpl.java +++ b/pqs-common/common-web/src/main/java/com/njcn/web/service/impl/LogServiceImpl.java @@ -84,19 +84,19 @@ public class LogServiceImpl implements ILogService { LogInfoDTO logInfoDTO = new LogInfoDTO(loginName, userName, ip, methodDescribe, operateType, result.equalsIgnoreCase("失败") ? 0 : 1, "", severity, type.equalsIgnoreCase("业务事件") ? 0 : 1, generalInfo.getMicroServiceName(), userIndex, LocalDateTime.now()); publisher.send("/userLog", PubUtils.obj2json(logInfoDTO), 2, false); //推送审计消息功能 - if(severity!=0){ - if(!logInfoDTO.getLoginName().equals(LogInfo.UNKNOWN_USER)){ + if (severity != 0) { + if (!logInfoDTO.getLoginName().equals(LogInfo.UNKNOWN_USER)) { publisher.send("/userLogPush", PubUtils.obj2json(logInfoDTO), 2, false); //发送邮箱功能 - if(severity==2&&logInfoDTO.getResult()==0){ + if (severity == 2 && logInfoDTO.getResult() == 0) { //publisher.send("/userLogEmailPush", PubUtils.obj2json(logInfoDTO), 2, false); } } } //如果存在设备日志注解,则记录设备日志 - if(Objects.nonNull((returnType.getMethod()))&& (returnType.getMethod()).isAnnotationPresent(DeviceLog.class)){ - String deviceOperate = returnType.getMethod().getAnnotation(DeviceLog.class).operateType(); - DeviceLogDTO deviceLogDTO = new DeviceLogDTO(userName,deviceOperate,result.equalsIgnoreCase("失败") ? 0 : 1,"",loginName,userIndex); + if (Objects.nonNull((returnType.getMethod())) && (returnType.getMethod()).isAnnotationPresent(DeviceLog.class)) { + String deviceOperate = returnType.getMethod().getAnnotation(DeviceLog.class).operateType(); + DeviceLogDTO deviceLogDTO = new DeviceLogDTO(userName, deviceOperate, result.equalsIgnoreCase("失败") ? 0 : 1, "", loginName, userIndex); publisher.send("/deviceLog", PubUtils.obj2json(deviceLogDTO), 2, false); } @@ -169,8 +169,8 @@ public class LogServiceImpl implements ILogService { private void auditPush(Integer severity, LogInfoDTO logInfoDTO) { //推送审计消息功能 - if(severity !=0){ - if(!logInfoDTO.getLoginName().equals(LogInfo.UNKNOWN_USER)) { + if (severity != 0) { + if (!logInfoDTO.getLoginName().equals(LogInfo.UNKNOWN_USER)) { publisher.send("/userLogPush", PubUtils.obj2json(logInfoDTO), 2, false); //发送邮箱功能 if (severity == 2 && logInfoDTO.getResult() == 0) { diff --git a/pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/api/LineFeignClient.java b/pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/api/LineFeignClient.java index e7e2b2377..f33a10df8 100644 --- a/pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/api/LineFeignClient.java +++ b/pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/api/LineFeignClient.java @@ -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> getPowerStationByMonitorIds(@RequestBody List ids); + + @PostMapping("/getDevListByLineIdList") + HttpResult> getDevListByLineIdList(@RequestBody List list); } diff --git a/pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/api/fallback/LineFeignClientFallbackFactory.java b/pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/api/fallback/LineFeignClientFallbackFactory.java index 7d28a0e97..0aca96294 100644 --- a/pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/api/fallback/LineFeignClientFallbackFactory.java +++ b/pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/api/fallback/LineFeignClientFallbackFactory.java @@ -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> getDevListByLineIdList(List list) { + log.error("{}异常,降级处理,异常为:{}", "根据监测点id集合获取装置id集合: ", throwable.toString()); + throw new BusinessException(finalExceptionEnum); + } }; } } diff --git a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/controller/LineController.java b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/controller/LineController.java index fbcd93215..a15b342da 100644 --- a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/controller/LineController.java +++ b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/controller/LineController.java @@ -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> getDevListByLineIdList(@RequestBody List list) { + String methodDescribe = getMethodDescribe("getDevListByLineIdList"); + Set result = lineService.getDevListByLineIdList(list); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); + } + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) @PostMapping("/getOverLimitData") @ApiOperation("根据监测点id获取越限数值") diff --git a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/LineDetailMapper.java b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/LineDetailMapper.java index a9372847b..313ff3379 100644 --- a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/LineDetailMapper.java +++ b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/LineDetailMapper.java @@ -56,6 +56,7 @@ public interface LineDetailMapper extends BaseMapper { void updateLineRunFlag(@Param("id")String lineId, @Param("runFlag")Integer status); + void updateLineRunFlagBatch(@Param("lineIds") List lineIds, @Param("runFlag") Integer status); /** * 根据监测点信息获取监测点详情(关联终端和母线) @@ -69,4 +70,6 @@ public interface LineDetailMapper extends BaseMapper { * 判断该新能源场站信息是否绑定了测点ID */ Integer checkExistsLineByNewStationId(@Param("newStationId") String newStationId); + + } diff --git a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/LineMapper.java b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/LineMapper.java index 05c15ff0f..bcc95fc48 100644 --- a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/LineMapper.java +++ b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/LineMapper.java @@ -581,4 +581,9 @@ public interface LineMapper extends BaseMapper { List getLineDeviceByDevIds(@Param("powerFlag") Integer powerFlag, @Param("lineIds") List lineIds, @Param("devIds") List devIds); + + /** + * 根据Pid获取所有子节点 + */ + List getSubIdByPid(@Param("pid") String pid); } diff --git a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/mapping/LineDetailMapper.xml b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/mapping/LineDetailMapper.xml index 5e5bc06da..236608a74 100644 --- a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/mapping/LineDetailMapper.xml +++ b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/mapping/LineDetailMapper.xml @@ -58,7 +58,7 @@ select count(1) from pq_line pl inner join pq_line_detail pld on pl.id = pld.id and pl.State = 1 and pld.New_Station_Id = #{newStationId} diff --git a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/mapping/LineIntegrityDataMapper.xml b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/mapping/LineIntegrityDataMapper.xml index 814b7201a..d8d1b1cf4 100644 --- a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/mapping/LineIntegrityDataMapper.xml +++ b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/mapping/LineIntegrityDataMapper.xml @@ -104,6 +104,7 @@ and pld.Line_Grade = #{lineGrade} + order by line.sort + + + diff --git a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/LineService.java b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/LineService.java index d60c4f4b8..02f4bfb29 100644 --- a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/LineService.java +++ b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/LineService.java @@ -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 { */ String getLineIdByDevId(String id); + Set getDevListByLineIdList(List list); + /** * 获取限值表信息 * @param id 监测点id @@ -246,4 +249,13 @@ public interface LineService extends IService { */ List getPollutionLineInfo(List id); + /** + * 根据pid获取所有子节点的ID + */ + List getSubIdByPid(String pid); + + /** + * 终端运行状态修改时,同时调整监测点的运行状态 + */ + void updateLineRunFlag(String id, Integer status); } diff --git a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/LineServiceImpl.java b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/LineServiceImpl.java index eee7f0bbf..e23e45afb 100644 --- a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/LineServiceImpl.java +++ b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/LineServiceImpl.java @@ -293,6 +293,24 @@ public class LineServiceImpl extends ServiceImpl implements Li return devId; } + @Override + public Set getDevListByLineIdList(List list) { + Set set = new HashSet<>(); + list.forEach(item->{ + String devId = ""; + //根据id查询当前信息的pids + List pids = Arrays.asList(this.baseMapper.selectById(item).getPids().split(",")); + List 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); @@ -847,6 +865,30 @@ public class LineServiceImpl extends ServiceImpl implements Li return pollutionLineInfoDTOList; } + @Override + public List getSubIdByPid(String pid) { + List subIdList = lineMapper.getSubIdByPid(pid); + if(CollUtil.isNotEmpty(subIdList)){ + return subIdList; + } + return Collections.emptyList(); + } + + @Override + public void updateLineRunFlag(String devId, Integer status) { + List lineIds = new ArrayList<>(); + // 获取母线 + List subLineIds = lineMapper.getSubIdByPid(devId); + // 母线再获取所有监测点id + for (String subLineId : subLineIds) { + List lineIdsTemp = lineMapper.getSubIdByPid(subLineId); + lineIds.addAll(lineIdsTemp); + } + if(CollUtil.isNotEmpty(lineIds)){ + lineDetailMapper.updateLineRunFlagBatch(lineIds, status); + } + } + @Override public List getOverLimitByList(PollutionParamDTO pollutionParamDTO) { diff --git a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/TerminalMaintainServiceImpl.java b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/TerminalMaintainServiceImpl.java index 4a4da5fd3..73c3368c0 100644 --- a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/TerminalMaintainServiceImpl.java +++ b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/TerminalMaintainServiceImpl.java @@ -77,6 +77,7 @@ public class TerminalMaintainServiceImpl implements TerminalMaintainService { private final DevFuctionMapper devFuctionMapper; private final CldStatisticsFlowMapper cldStatisticsFlowMapper; + private final LineService lineService; @Override public List getTerminalMainList(TerminalMainQueryParam terminalMainQueryParam) { @@ -139,12 +140,17 @@ public class TerminalMaintainServiceImpl implements TerminalMaintainService { @Override public boolean updateRunFlagManage(TerminalParam terminalParam) { + List devIds = terminalParam.getIds(); + if(CollectionUtils.isEmpty(devIds)){ + return true; + } QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.in("id", terminalParam.getIds()); + wrapper.in("id", devIds); List newList = iDeviceService.listByIds(terminalParam.getIds()); boolean b = iDeviceService.update(new LambdaUpdateWrapper() .set(Device::getRunFlag,terminalParam.getRunFlag()) .in(Device::getId,terminalParam.getIds())); + devIds.forEach(id -> {lineService.updateLineRunFlag(id,terminalParam.getRunFlag());}); //添加日志信息 if (b) { List oldList = iDeviceService.list(wrapper); diff --git a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/TerminalOnlineRateDataServiceImpl.java b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/TerminalOnlineRateDataServiceImpl.java index b3d3454f7..296e54a42 100644 --- a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/TerminalOnlineRateDataServiceImpl.java +++ b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/TerminalOnlineRateDataServiceImpl.java @@ -299,8 +299,6 @@ public class TerminalOnlineRateDataServiceImpl implements TerminalOnlineRateData mapAlarm.put(0,0); } - - for (TerminalOnlineRateDataVO proItem : terminalOnlineRateData) { List gds = proItem.getChildren(); if (CollectionUtil.isNotEmpty(gds)) { diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/RmpEventDetailPO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/RmpEventDetailPO.java index ccdeb52b7..cc0c712cb 100644 --- a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/RmpEventDetailPO.java +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/RmpEventDetailPO.java @@ -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 = "用于计算数量") diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/SendEventVO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/SendEventVO.java new file mode 100644 index 000000000..e382ff9f8 --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/SendEventVO.java @@ -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 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; +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/WaveTypeVO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/WaveTypeVO.java index 02c9fc797..a96b9b573 100644 --- a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/WaveTypeVO.java +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/WaveTypeVO.java @@ -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; } diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/EventAnalysisServiceImpl.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/EventAnalysisServiceImpl.java index 131f1cfff..ef9147505 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/EventAnalysisServiceImpl.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/EventAnalysisServiceImpl.java @@ -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()); diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/EventDetailServiceImpl.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/EventDetailServiceImpl.java index 51fa9ef24..8197ef0d0 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/EventDetailServiceImpl.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/EventDetailServiceImpl.java @@ -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 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 dept = new HashSet<>(); + dept.add(deptIndex); + DeptGetLineParam deptGetLineParam = new DeptGetLineParam(); + deptGetLineParam.setDeptId(deptIndex); + List 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 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) { diff --git a/pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/pojo/vo/HistoryDataResultVO.java b/pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/pojo/vo/HistoryDataResultVO.java index 70792f4f6..f12bff899 100644 --- a/pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/pojo/vo/HistoryDataResultVO.java +++ b/pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/pojo/vo/HistoryDataResultVO.java @@ -45,6 +45,9 @@ public class HistoryDataResultVO implements Serializable { @ApiModelProperty("下限") private Float lowerLimit; + @ApiModelProperty("接线方式 0.星型 1.星三角 2.三角") + private String wiringMethod; + @ApiModelProperty("暂降事件详情") private List eventDetail; diff --git a/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/pojo/QueryResultLimitVO.java b/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/pojo/QueryResultLimitVO.java index b64ead263..65eb4cea2 100644 --- a/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/pojo/QueryResultLimitVO.java +++ b/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/pojo/QueryResultLimitVO.java @@ -23,4 +23,8 @@ public class QueryResultLimitVO implements Serializable { private List phaiscType; private List unit; private Integer harmNum; + /** + * 接线方式 0.星型 1.星三角 2.三角 + */ + private String wiringMethod; } diff --git a/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/HistoryResultServiceImpl.java b/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/HistoryResultServiceImpl.java index 01c286eed..857efbf2e 100644 --- a/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/HistoryResultServiceImpl.java +++ b/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/HistoryResultServiceImpl.java @@ -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; } diff --git a/pqs-harmonic/harmonic-boot/src/main/resources/bootstrap.yml b/pqs-harmonic/harmonic-boot/src/main/resources/bootstrap.yml index 19cb511ff..db9f602b3 100644 --- a/pqs-harmonic/harmonic-boot/src/main/resources/bootstrap.yml +++ b/pqs-harmonic/harmonic-boot/src/main/resources/bootstrap.yml @@ -35,8 +35,8 @@ spring: - data-id: share-config.yaml refresh: true #数据中心使用 - #- data-Id: share-config-datasource-db.yaml - # refresh: true +# - data-Id: share-config-datasource-db.yaml +# refresh: true #PMS使用 - data-Id: share-config-harmonic-db.yaml refresh: true diff --git a/pqs-prepare/prepare-api/src/main/java/com/njcn/prepare/harmonic/pojo/bo/excel/DataVDetail.java b/pqs-prepare/prepare-api/src/main/java/com/njcn/prepare/harmonic/pojo/bo/excel/DataVDetail.java new file mode 100644 index 000000000..ecd26a0e7 --- /dev/null +++ b/pqs-prepare/prepare-api/src/main/java/com/njcn/prepare/harmonic/pojo/bo/excel/DataVDetail.java @@ -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; + +} diff --git a/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/executor/MeasurementExecutor.java b/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/executor/MeasurementExecutor.java index c754beac6..c0bad6fc0 100644 --- a/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/executor/MeasurementExecutor.java +++ b/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/executor/MeasurementExecutor.java @@ -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());} diff --git a/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/harmonic/service/influxdb/IPollutionCalc.java b/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/harmonic/service/influxdb/IPollutionCalc.java index 19a030402..76d439eab 100644 --- a/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/harmonic/service/influxdb/IPollutionCalc.java +++ b/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/harmonic/service/influxdb/IPollutionCalc.java @@ -3,4 +3,9 @@ package com.njcn.prepare.harmonic.service.influxdb; public interface IPollutionCalc { void calcAllLineValue(); + + //按监测点获取各地市谐波电压原始数据 + void getDataVByLineId(); + + } diff --git a/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/harmonic/service/influxdb/impl/PollutionCalcImpl.java b/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/harmonic/service/influxdb/impl/PollutionCalcImpl.java index d84b3abfc..c2edf9448 100644 --- a/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/harmonic/service/influxdb/impl/PollutionCalcImpl.java +++ b/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/harmonic/service/influxdb/impl/PollutionCalcImpl.java @@ -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 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 lineIdList = Arrays.asList("123","456","789"); + List 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 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 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 getData(DataVDetail linePollution, String startTime, String endTime) { + List 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 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 vthResultList2 = dataHarmRateVMapper.getStatisticsByWraper(dataVQueryWrapper2); + + if (CollUtil.isNotEmpty(vthResultList) && CollUtil.isNotEmpty(vthResultList2)) { + Map> map1 = vthResultList.stream().collect(Collectors.groupingBy(DataV::getTime)); + Map> map1ByPhase = map1.entrySet().stream() + .collect(Collectors.toMap( + Map.Entry::getKey, + entry -> entry.getValue().stream() + .collect(Collectors.toMap(DataV::getPhaseType, dataV -> dataV)) + )); + Map> map2 = vthResultList2.stream().collect(Collectors.groupingBy(DataHarmRateV::getTime)); + Map> map2ByPhase = map2.entrySet().stream() + .collect(Collectors.toMap( + Map.Entry::getKey, + entry -> entry.getValue().stream() + .collect(Collectors.toMap(DataHarmRateV::getPhaseType, dataHarmRateV -> dataHarmRateV)) + )); + // 获取两个 Map 的时间交集 + Set commonTimes = new HashSet<>(map1.keySet()); + commonTimes.retainAll(map2.keySet()); + for (Instant time : commonTimes) { + Map phaseData1 = map1ByPhase.get(time); + Map 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) { //最大值 diff --git a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/user/impl/UserReportPOServiceImpl.java b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/user/impl/UserReportPOServiceImpl.java index 4a5751410..8048651e7 100644 --- a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/user/impl/UserReportPOServiceImpl.java +++ b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/user/impl/UserReportPOServiceImpl.java @@ -1324,7 +1324,7 @@ public class UserReportPOServiceImpl extends ServiceImpl 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) { diff --git a/pqs-system/system-api/src/main/java/com/njcn/system/pojo/param/ThemeParam.java b/pqs-system/system-api/src/main/java/com/njcn/system/pojo/param/ThemeParam.java index 7599a1f6a..1d1c9646e 100644 --- a/pqs-system/system-api/src/main/java/com/njcn/system/pojo/param/ThemeParam.java +++ b/pqs-system/system-api/src/main/java/com/njcn/system/pojo/param/ThemeParam.java @@ -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 { /** * 用户更新操作实体 - * + *

* 需要填写的参数:用户的id */ @Data diff --git a/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/SysDicTreePOServiceImpl.java b/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/SysDicTreePOServiceImpl.java index 701c08e40..2c80e034f 100644 --- a/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/SysDicTreePOServiceImpl.java +++ b/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/SysDicTreePOServiceImpl.java @@ -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 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 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> queryCustomizer, + UserResponseEnum errorEnum) { + LambdaQueryWrapper 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); + } + } + } diff --git a/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/ThemeServiceImpl.java b/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/ThemeServiceImpl.java index e4a2cb815..be09b353c 100644 --- a/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/ThemeServiceImpl.java +++ b/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/ThemeServiceImpl.java @@ -134,21 +134,21 @@ public class ThemeServiceImpl extends ServiceImpl implements if (themeParam.getFaviconFile().isEmpty()) { throw new BusinessException(ThemeEnum.FAVICON_FILE_BLANK); } - LambdaQueryWrapper 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 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); +// } } /** diff --git a/pqs-user/user-api/src/main/java/com/njcn/user/enums/UserResponseEnum.java b/pqs-user/user-api/src/main/java/com/njcn/user/enums/UserResponseEnum.java index 6cb71daf8..3c2e83b06 100644 --- a/pqs-user/user-api/src/main/java/com/njcn/user/enums/UserResponseEnum.java +++ b/pqs-user/user-api/src/main/java/com/njcn/user/enums/UserResponseEnum.java @@ -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字段"), diff --git a/pqs-user/user-boot/src/main/java/com/njcn/user/service/impl/FunctionServiceImpl.java b/pqs-user/user-boot/src/main/java/com/njcn/user/service/impl/FunctionServiceImpl.java index 22beafc17..3867464bf 100644 --- a/pqs-user/user-boot/src/main/java/com/njcn/user/service/impl/FunctionServiceImpl.java +++ b/pqs-user/user-boot/src/main/java/com/njcn/user/service/impl/FunctionServiceImpl.java @@ -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 i * 名称 && 路径做唯一判断 */ private void checkFunctionParam(FunctionParam functionParam, boolean isExcludeSelf) { - LambdaQueryWrapper 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> queryCustomizer, + UserResponseEnum errorEnum) { + LambdaQueryWrapper 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); } }