47 Commits

Author SHA1 Message Date
d5c18198b9 稳态趋势图调整 2025-01-03 08:58:36 +08:00
4a38148d7a pms上送报错问题解决 2024-12-30 08:56:07 +08:00
ab68a98999 pmsbug修改 2024-12-27 15:58:07 +08:00
xy
d435398c64 河北新增在线监测功能 2024-12-25 11:09:38 +08:00
1acba83ff2 浙江无线报表调整 2024-12-24 15:27:26 +08:00
43af977942 浙江无线报表调整 2024-12-24 15:01:37 +08:00
xy
f0ffb63cff 微调 2024-12-23 10:50:01 +08:00
xy
ac24724ee8 limitRate算法添加空数据判断 2024-12-19 10:28:02 +08:00
8f4949af80 sm4解密优化 2024-12-16 10:12:59 +08:00
f1d0e7df42 处理间谐波含有率17至50次无法展示问题 2024-12-13 14:02:35 +08:00
265eeb7bdd 1.暂降事件调整 2024-12-12 15:20:01 +08:00
hzj
78524de495 修改bug 2024-12-12 13:39:22 +08:00
hzj
5125ef738a 修改bug 2024-12-12 13:35:43 +08:00
hzj
721aa81c36 修改bug 2024-12-12 13:00:36 +08:00
hzj
eb54a13226 修改bug 2024-12-11 15:05:09 +08:00
9bc072ec8b 1.浙江无线报表修改 2024-12-11 09:36:45 +08:00
hzj
f380c51a89 修改bug 2024-12-10 15:47:07 +08:00
hzj
386e4cb647 修改bug 2024-12-10 15:02:28 +08:00
46f54685b1 1.添加5层树排序 2024-12-10 14:58:09 +08:00
hzj
55f04541bd 修改 2024-12-10 13:41:02 +08:00
hzj
840c48e136 修改 2024-12-10 13:31:28 +08:00
a122df4763 1.添加装置加密解密配置 2024-12-09 11:47:06 +08:00
f656c15dc5 1.配置回退 2024-12-09 11:24:37 +08:00
e47584a118 1.暂降事件归集功能调整 2024-12-09 11:22:01 +08:00
63617c92c0 Merge remote-tracking branch 'origin/master' 2024-12-09 08:49:14 +08:00
efc075b4a9 代码调整 2024-12-07 15:26:19 +08:00
3e3165bed8 代码调整 2024-12-07 14:02:33 +08:00
xy
ea70f0fc2c 安徽测试报告整改 2024-12-07 13:42:39 +08:00
7e130e9eb0 1.暂降事件归集功能调整 2024-12-06 16:40:24 +08:00
da3e897fc2 1.校验修改 2024-12-06 16:37:48 +08:00
hzj
932ab2d6f5 修改 2024-12-06 09:57:18 +08:00
hanyong
f3223bd680 波形文件恢复读取/usr/local/comtrade路径 2024-12-05 15:41:01 +08:00
hanyong
9bee2386bf 海南波形文件读取路径修改 2024-12-05 15:34:00 +08:00
hzj
3f56fa0de9 删除校验 2024-12-05 15:19:24 +08:00
hzj
62db637bdd 添加条件 2024-12-05 14:52:13 +08:00
hzj
39c9d1f54e 添加条件 2024-12-05 13:04:59 +08:00
hzj
0c9a93f600 添加时间格式 2024-12-05 12:53:33 +08:00
xy
fad2279980 安徽测试报告整改 2024-12-05 11:50:43 +08:00
99d8e89bec 代码调整 2024-12-05 11:42:56 +08:00
hzj
8a5fec58d1 修改报表时间 2024-12-05 11:22:01 +08:00
f603794110 Merge remote-tracking branch 'origin/master' 2024-12-05 11:17:23 +08:00
7d727088c2 代码调整 2024-12-05 11:17:15 +08:00
hzj
2a703a8c30 修改报表时间 2024-12-05 11:12:06 +08:00
1ff860bda9 代码调整 2024-12-05 10:51:01 +08:00
xy
fe756e0f87 算法调整 2024-12-04 10:33:23 +08:00
xy
373cd71b02 Merge remote-tracking branch 'origin/master' 2024-12-03 16:25:31 +08:00
xy
49a3afb505 根据接线方式取指标调整 2024-12-03 16:25:15 +08:00
76 changed files with 2332 additions and 396 deletions

View File

@@ -3,6 +3,7 @@ package com.njcn.advance.pojo.carrycapacity.excel;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.converters.localdatetime.LocalDateTimeStringConverter;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import java.time.LocalDateTime;
@@ -19,7 +20,8 @@ import java.util.List;
@Data
public class CarryCapcityDataEexcel {
@ExcelProperty(index = 0,value = "时间",converter = LocalDateTimeStringConverter.class)
@ExcelProperty(index = 0,value = "时间(格式为yyyy-MM-dd hh:mm:ss)",converter = LocalDateTimeStringConverter.class)
@JSONField(format = "yyyy-MM-dd hh:mm:ss")
private LocalDateTime time;
@ExcelProperty(index =1,value = {"电压","A"})

View File

@@ -331,7 +331,7 @@ public class CarryCapcityDataIEexcel {
DataI dataI = new DataI();
BeanUtils.copyProperties(carryCapcityDataIEexcel,dataI);
dataI.setPhaseType(phase);
dataI.setTime(carryCapcityDataIEexcel.getTime().plusSeconds(8*60*60));
dataI.setTime(carryCapcityDataIEexcel.getTime());
if (phase.equals("A")) {

View File

@@ -47,7 +47,7 @@ public class CarryCapcityDataPEexcel {
CarryCapcityData carryCapcityData = new CarryCapcityData();
BeanUtils.copyProperties(carryCapcityDataPEexcel,carryCapcityData);
carryCapcityData.setPhaseType(phase);
carryCapcityData.setTime(carryCapcityDataPEexcel.getTime().plusSeconds(8*60*60));
carryCapcityData.setTime(carryCapcityDataPEexcel.getTime());
if (phase.equals("A")) {
carryCapcityData.setValue(carryCapcityDataPEexcel.getValue_a());

View File

@@ -49,7 +49,7 @@ public class CarryCapcityDataQEexcel {
CarryCapcityData carryCapcityData = new CarryCapcityData();
BeanUtils.copyProperties(carryCapcityDataQEexcel,carryCapcityData);
carryCapcityData.setPhaseType(phase);
carryCapcityData.setTime(carryCapcityDataQEexcel.getTime().plusSeconds(8*60*60));
carryCapcityData.setTime(carryCapcityDataQEexcel.getTime());
if (phase.equals("A")) {
carryCapcityData.setValue(carryCapcityDataQEexcel.getValue_a());

View File

@@ -48,7 +48,7 @@ public class CarryCapcityDataVEexcel {
CarryCapcityData carryCapcityData = new CarryCapcityData();
BeanUtils.copyProperties(carryCapcityDataVEexcel,carryCapcityData);
carryCapcityData.setPhaseType(phase);
carryCapcityData.setTime(carryCapcityDataVEexcel.getTime().plusSeconds(8*60*60));
carryCapcityData.setTime(carryCapcityDataVEexcel.getTime());
if (phase.equals("A")) {
carryCapcityData.setValue(carryCapcityDataVEexcel.getValue_a());

View File

@@ -23,7 +23,6 @@ public class CarryCapacityDeviceParam {
/**
* 设备名称
*/
@Pattern(regexp = PatternRegex.DES32_REGEX, message = ValidMessage.DATA_TOO_LONG)
private String devName;
private String devScale;

View File

@@ -31,7 +31,6 @@ public class CarryCapacityUserParam {
/**
* 用户名称
*/
@Pattern(regexp = PatternRegex.DES32_REGEX, message = ValidMessage.DATA_TOO_LONG)
private String userName;
/**

View File

@@ -1,35 +1,16 @@
package com.njcn.advance.pojo.dto.relevent;
import com.njcn.advance.pojo.dto.SagEvent;
import lombok.Data;
@Data
public class EntityGroupEvtData implements Cloneable,Comparable<EntityGroupEvtData> {
//逻辑节点序号
private int node;
//事件开始时间时标
private int start_time;
//类别
private int cata;
//标注类别
private int cata2;
//物理节点
private String nodePhysics;
private int node;//逻辑节点序号
private int start_time;//事件开始时间时标
private int cata;//类别
private int cata2;//标注类别
private String nodePhysics; //物理节点
private SagEvent sagEvent;
private String sagReason;
public Object objClone() {
try {
return clone();
} catch (CloneNotSupportedException e) {
return new EntityGroupEvtData(null, -1, -1, -1,null,null);
}
}
public EntityGroupEvtData(String nodePhysics, int start_time, int cata, int cata2,SagEvent sagEvent,String sagReason) {
this.nodePhysics = nodePhysics;
this.start_time = start_time;
@@ -39,6 +20,144 @@ public class EntityGroupEvtData implements Cloneable,Comparable<EntityGroupEvtDa
this.sagReason = sagReason;
}
public SagEvent getSagEvent() {
return sagEvent;
}
public void setSagEvent(SagEvent sagEvent) {
this.sagEvent = sagEvent;
}
public String getNodePhysics() {
return nodePhysics;
}
public void setNodePhysics(String nodePhysics) {
this.nodePhysics = nodePhysics;
}
public int getNode() {
return node;
}
public void setNode(int node) {
this.node = node;
}
public int getStart_time() {
return start_time;
}
public void setStart_time(int start_time) {
this.start_time = start_time;
}
public int getCata() {
return cata;
}
public void setCata(int cata) {
this.cata = cata;
}
public int getCata2() {
return cata2;
}
public void setCata2(int cata2) {
this.cata2 = cata2;
}
public String getSagReason() {
return sagReason;
}
public void setSagReason(String sagReason) {
this.sagReason = sagReason;
}
/**
* Creates and returns a copy of this object. The precise meaning
* of "copy" may depend on the class of the object. The general
* intent is that, for any object {@code x}, the expression:
* <blockquote>
* <pre>
* x.clone() != x</pre></blockquote>
* will be true, and that the expression:
* <blockquote>
* <pre>
* x.clone().getClass() == x.getClass()</pre></blockquote>
* will be {@code true}, but these are not absolute requirements.
* While it is typically the case that:
* <blockquote>
* <pre>
* x.clone().equals(x)</pre></blockquote>
* will be {@code true}, this is not an absolute requirement.
*
* By convention, the returned object should be obtained by calling
* {@code super.clone}. If a class and all of its superclasses (except
* {@code Object}) obey this convention, it will be the case that
* {@code x.clone().getClass() == x.getClass()}.
*
* By convention, the object returned by this method should be independent
* of this object (which is being cloned). To achieve this independence,
* it may be necessary to modify one or more fields of the object returned
* by {@code super.clone} before returning it. Typically, this means
* copying any mutable objects that comprise the internal "deep structure"
* of the object being cloned and replacing the references to these
* objects with references to the copies. If a class contains only
* primitive fields or references to immutable objects, then it is usually
* the case that no fields in the object returned by {@code super.clone}
* need to be modified.
*
* The method {@code clone} for class {@code Object} performs a
* specific cloning operation. First, if the class of this object does
* not implement the interface {@code Cloneable}, then a
* {@code CloneNotSupportedException} is thrown. Note that all arrays
* are considered to implement the interface {@code Cloneable} and that
* the return type of the {@code clone} method of an array type {@code T[]}
* is {@code T[]} where T is any reference or primitive type.
* Otherwise, this method creates a new instance of the class of this
* object and initializes all its fields with exactly the contents of
* the corresponding fields of this object, as if by assignment; the
* contents of the fields are not themselves cloned. Thus, this method
* performs a "shallow copy" of this object, not a "deep copy" operation.
*
* The class {@code Object} does not itself implement the interface
* {@code Cloneable}, so calling the {@code clone} method on an object
* whose class is {@code Object} will result in throwing an
* exception at run time.
*
* @return a clone of this instance.
* @throws CloneNotSupportedException if the object's class does not
* support the {@code Cloneable} interface. Subclasses
* that override the {@code clone} method can also
* throw this exception to indicate that an instance cannot
* be cloned.
* @see Cloneable
*/
@Override
protected Object clone() throws CloneNotSupportedException {
return super.clone();
}
public Object objClone() {
try {
return clone();
} catch (CloneNotSupportedException e) {
return new EntityGroupEvtData("-1", -1, -1, -1,null,null);
}
}
@Override
public String toString() {
return "EntityGroupEvtData{" +
"node=" + node +
", start_time=" + start_time +
", cata=" + cata +
", cata2=" + cata2 +
'}';
}
@Override
public int compareTo(EntityGroupEvtData obj) {

View File

@@ -8,9 +8,9 @@ public class EntityLogic {
//物理隔绝变压器策略GUID
private String tPIndex;
//变压器逻辑上节点
private String node_h;
private Integer node_h;
//变压器逻辑下节点
private String node_l;
private Integer node_l;
// 变压器连接方式
private Integer type;
//变压器物理上节点

View File

@@ -69,3 +69,4 @@ public class EntityMtrans implements Serializable {
+ Arrays.toString(possiable_path) + ", path_num=" + path_num + "]";
}
}

View File

@@ -1,6 +1,6 @@
package com.njcn.advance.pojo.dto.relevent;
import com.njcn.advance.pojo.dto.SagEvent;
import lombok.Data;
import java.io.Serializable;

View File

@@ -1,4 +1,4 @@
package com.njcn.advance.pojo.dto;
package com.njcn.advance.pojo.dto.relevent;
import com.njcn.advance.pojo.dto.relevent.PlantInfo;

View File

@@ -0,0 +1,29 @@
package com.njcn.advance.utils;
import cn.hutool.core.codec.Base64;
import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.web.constant.ValidMessage;
import java.util.regex.Pattern;
/**
* Description:
* Date: 2024/12/10 14:51【需求编号】
*
* @author clam
* @version V1.0.0
*/
public class CheckStringUtil {
public static void checkName(String name) {
Pattern pattern = Pattern.compile(PatternRegex.SPECIALCHARACTER);
if(pattern.matcher(name).find()){
throw new BusinessException(ValidMessage.NAME_SPECIAL_REGEX);
}
}
// public static void main(String[] args) {
// checkName("100迈岭站2djvjva13ad");
// }
}

View File

@@ -0,0 +1,71 @@
package com.njcn.advance.utils;
import cn.hutool.core.codec.Base64;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.io.*;
@Component
public class InstantiateUtil<E> {
private static final Logger logger= LoggerFactory.getLogger(InstantiateUtil.class);
public byte[] instantiate(E e) {
if (e == null) {
return null;
}
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
try {
ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
objectOutputStream.writeObject(e);
objectOutputStream.close();
return byteArrayOutputStream.toByteArray();
} catch (IOException e1) {
logger.error("发生异常,"+e1.getMessage());
}
return null;
}
public <E> E deInstantiate(byte[] bytes) {
if (bytes == null) {
return null;
}
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes);
try {
ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream);
try {
return (E) objectInputStream.readObject();
} catch (ClassNotFoundException e) {
logger.error("发生异常,"+e.getMessage());
}
} catch (IOException e) {
logger.error("发生异常,"+e.getMessage());
}
return null;
}
public String stringInstantiate(E e) { //序列化对象的byte[]数组转为字符串(包装类可不调用)
byte[] bytes = instantiate(e);
if (bytes != null && bytes.length>0 ) {
return Base64.encode(bytes);
}
return "";
}
public byte[] stringDeInstantiate(String str) { //stringInstantiate方法还原为byte[]数组
if (!StringUtils.isEmpty(str)) {
return Base64.decode(str);
}
return null;
}
}

View File

@@ -6,6 +6,7 @@ import com.njcn.advance.pojo.po.PqsRelevanceLog;
import com.njcn.advance.service.EventRelevantAnalysisService;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType;
import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
@@ -14,17 +15,20 @@ import com.njcn.common.utils.HttpResultUtil;
import com.njcn.common.utils.PubUtils;
import com.njcn.event.pojo.po.RmpEventDetailAssPO;
import com.njcn.event.pojo.vo.AdvanceEventDetailVO;
import com.njcn.web.constant.ValidMessage;
import com.njcn.web.controller.BaseController;
import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
/**
* pqs
@@ -33,11 +37,11 @@ import java.util.Map;
* @author cdf
* @date 2023/6/30
*/
@Slf4j
@RestController
@RequestMapping("process")
@Api(tags = "暂降事件关联分析")
@RequiredArgsConstructor
@Slf4j
public class EventRelevantAnalysisController extends BaseController {
private final EventRelevantAnalysisService eventRelevantAnalysisService;
@@ -78,6 +82,11 @@ public class EventRelevantAnalysisController extends BaseController {
@ApiOperation("事件波形分析主列表")
public HttpResult<Page<RmpEventDetailAssPO>> queryEventsAssPage(@RequestBody BaseParam baseParam){
String methodDescribe = getMethodDescribe("queryEventsAssPage");
String searchValue = baseParam.getSearchValue();
Pattern pattern = Pattern.compile(PatternRegex.SPECIAL_REGEX);
if(pattern.matcher(searchValue).find()){
throw new BusinessException(ValidMessage.SPECIAL_REGEX);
}
Page<RmpEventDetailAssPO> page = eventRelevantAnalysisService.queryEventsAssPage(baseParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
}
@@ -188,4 +197,12 @@ public class EventRelevantAnalysisController extends BaseController {
boolean flag = eventRelevantAnalysisService.delRelevantLog(id);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
}
}

View File

@@ -0,0 +1,25 @@
package com.njcn.advance.controller.eventGui;
import com.njcn.common.utils.PubUtils;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.io.DataInputStream;
import java.net.URLDecoder;
import java.time.LocalDateTime;
import java.util.List;
@RestController
@RequestMapping("process")
@Api(tags = "暂降事件关联分析")
@RequiredArgsConstructor
@Slf4j
public class EventGuiController {
}

View File

@@ -0,0 +1,9 @@
package com.njcn.advance.mapper;
public interface RelevanceMapper {
// 查询监测点的线路ID
String queryLineIdbyPointId(String pointId);
}

View File

@@ -1,7 +1,7 @@
package com.njcn.advance.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.advance.pojo.dto.SagEvent;
import com.njcn.event.pojo.po.RmpEventDetailPO;
import org.apache.ibatis.annotations.Param;

View File

@@ -1,7 +1,7 @@
package com.njcn.advance.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.advance.pojo.dto.SagEvent;
import com.njcn.advance.pojo.dto.relevent.EventAssObj;
import com.njcn.event.pojo.po.RmpEventDetailAssPO;
import org.apache.ibatis.annotations.Param;

View File

@@ -0,0 +1,14 @@
<?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.advance.mapper.RelevanceMapper">
<select id="queryLineIdbyPointId" resultType="string" parameterType="string">
select pid from pq_line where id = #{pointId}
</select>
<select id="queryCodebyGuid" resultType="java.lang.Integer" parameterType="java.lang.String">
select triphase from sys_dict_data where id = #{guid}
</select>
</mapper>

View File

@@ -2,14 +2,11 @@ package com.njcn.advance.service.carrycapacity.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.advance.enums.AdvanceResponseEnum;
import com.njcn.advance.mapper.carrycapacity.CarryCapacityDevicePOMapper;
import com.njcn.advance.pojo.carrycapacity.param.CarryCapacityDeviceParam;
import com.njcn.advance.pojo.carrycapacity.param.CarryCapacityUserParam;
import com.njcn.advance.pojo.carrycapacity.po.CarryCapacityDevicePO;
import com.njcn.advance.pojo.carrycapacity.po.CarryCapacityUserPO;
import com.njcn.advance.service.carrycapacity.CarryCapacityDevicePOService;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.advance.utils.CheckStringUtil;
import com.njcn.common.pojo.exception.BusinessException;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
@@ -36,6 +33,7 @@ public class CarryCapacityDevicePOServiceImpl extends ServiceImpl<CarryCapacityD
checkName(deviceParam,true);
return this.lambdaUpdate().eq(CarryCapacityDevicePO::getDevId, deviceParam.getDevId())
.set(CarryCapacityDevicePO::getDevName, deviceParam.getDevName())
.set(CarryCapacityDevicePO::getDevScale, deviceParam.getDevScale())
.set(CarryCapacityDevicePO::getProtocolCapacity, deviceParam.getProtocolCapacity())
.update();
}
@@ -59,6 +57,12 @@ public class CarryCapacityDevicePOServiceImpl extends ServiceImpl<CarryCapacityD
* @return 结果
*/
private void checkName(CarryCapacityDeviceParam carryCapacityDeviceParam, boolean isUpdate) {
if(carryCapacityDeviceParam.getDevName().length()>32){
throw new BusinessException("超过最大长度");
}
CheckStringUtil.checkName(carryCapacityDeviceParam.getDevName());
LambdaQueryWrapper<CarryCapacityDevicePO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
//条件组合where state = 1 and name = ?
lambdaQueryWrapper.eq(CarryCapacityDevicePO::getUserId,carryCapacityDeviceParam.getUserId()).eq(CarryCapacityDevicePO::getDevName, carryCapacityDeviceParam.getDevName());

View File

@@ -48,12 +48,14 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.InputStream;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -131,8 +133,8 @@ public class CarryCapacityServiceImpl implements CarryCapacityService {
CollectionUtil.isEmpty(dataHarmPowerQ2List) ||
CollectionUtil.isEmpty(dataHarmPowerU2List)) {
CarryCapacityDataPO one = carryCapacityDataPOService.lambdaQuery().eq(CarryCapacityDataPO::getLineId, lineId)
.eq(CarryCapacityDataPO::getStartTime, startTime)
.eq(CarryCapacityDataPO::getEndTime, endTime).one();
.eq(CarryCapacityDataPO::getStartTime, queryParam.getStartTime())
.eq(CarryCapacityDataPO::getEndTime, queryParam.getEndTime()).one();
if (Objects.nonNull(one)) {
//todo 调用查询文件
InputStream fileStream = fileStorageUtil.getFileStream(one.getDateList());
@@ -264,6 +266,10 @@ public class CarryCapacityServiceImpl implements CarryCapacityService {
}
// dataHarmPowerpList = dataHarmPowerpList.stream().map(temp -> {
// temp.setTime(temp.getTime().plusMillis(TimeUnit.HOURS.toMillis(8)));
// return temp;
// }).collect(Collectors.toList());
carryCapacityDataVO.setData(dataHarmPowerpList);
@@ -330,6 +336,11 @@ public class CarryCapacityServiceImpl implements CarryCapacityService {
redisUtil.saveByKey(lineId + "#" + LocalDateTimeUtil.format(startDate, formatter) + "#" + LocalDateTimeUtil.format(endDate, formatter) + "#" + "Q",
dataHarmPowerqList);
}
// dataHarmPowerqList = dataHarmPowerqList.stream().map(temp -> {
// temp.setTime(temp.getTime().plusMillis(TimeUnit.HOURS.toMillis(8)));
// return temp;
// }).collect(Collectors.toList());
carryCapacityDataqVO.setData(dataHarmPowerqList);
@@ -383,6 +394,11 @@ public class CarryCapacityServiceImpl implements CarryCapacityService {
stringBuilder2.append("line_id='").append(lineId).append("' and ").append(InfluxDbSqlConstant.TIME + " >= '").append(startTime).append("' and ").append(InfluxDbSqlConstant.TIME).append(" <= '").append(endTime).append("' group by time(").append(timeInterval).append("m),* fill(3.1415926) ").append(InfluxDbSqlConstant.TZ);
String sqlI1 = "select " + stringBuilder1 + " from " + InfluxDBTableConstant.DATA_I + " where value_type='CP95' and phasic_type!='T' and " + stringBuilder2;
dataI = dataiMapper.getSqlResult(sqlI1);
//此处查询influxdb少8个小时
dataI = dataI.stream().map(temp -> {
temp.setTime(temp.getTime().plusMillis(TimeUnit.HOURS.toMillis(8)));
return temp;
}).collect(Collectors.toList());
if (CollectionUtil.isEmpty(dataI)) {
throw new BusinessException(AdvanceResponseEnum.DATA_NOT_FOUND);
} else {
@@ -613,66 +629,66 @@ public class CarryCapacityServiceImpl implements CarryCapacityService {
//数据校验
if (CollectionUtil.isEmpty(dataHarmPowerpList)) {
throw new BusinessException(AdvanceResponseEnum.DATA_NOT_FOUND);
throw new BusinessException("数据量过少,请查看上传数据集的数据集时间与页面选择时间"+startDate+"-"+endDate+"的本周数据及其上周是否充足");
} else {
if (checkData(dataHarmPowerpList, startDate, endDate, timeInterval)) {
throw new BusinessException(AdvanceResponseEnum.DATA_NOT_FOUND);
throw new BusinessException("数据量过少,请查看上传数据集的数据集时间与页面选择时间"+startDate+"-"+endDate+"的本周数据是否充足");
}
}
linearInterpolation(dataHarmPowerpList);
//数据校验
if (CollectionUtil.isEmpty(dataHarmPowerp2List)) {
throw new BusinessException(AdvanceResponseEnum.DATA_NOT_FOUND);
throw new BusinessException("数据量过少,请查看上传数据集的数据集时间与页面选择时间"+startDate+"-"+endDate+"的本周数据及其上周是否充足");
} else {
if (checkData(dataHarmPowerp2List, startDate2, endDate2, timeInterval)) {
throw new BusinessException(AdvanceResponseEnum.DATA_NOT_FOUND);
throw new BusinessException("数据量过少,请查看上传数据集的数据集时间与页面选择时间"+startDate+"-"+endDate+"的前一周数据量是否充足");
}
}
linearInterpolation(dataHarmPowerp2List);
//数据校验
if (CollectionUtil.isEmpty(dataHarmPowerqList)) {
throw new BusinessException(AdvanceResponseEnum.DATA_NOT_FOUND);
throw new BusinessException("数据量过少,请查看上传数据集的数据集时间与页面选择时间"+startDate+"-"+endDate+"的本周数据及其上周是否充足");
} else {
if (checkData(dataHarmPowerqList, startDate, endDate, timeInterval)) {
throw new BusinessException(AdvanceResponseEnum.DATA_NOT_FOUND);
throw new BusinessException("数据量过少,请查看上传数据集的数据集时间与页面选择时间"+startDate+"-"+endDate+"的本周数据是否充足");
}
}
linearInterpolation(dataHarmPowerqList);
//数据校验
if (CollectionUtil.isEmpty(dataHarmPowerq2List)) {
throw new BusinessException(AdvanceResponseEnum.DATA_NOT_FOUND);
throw new BusinessException("数据量过少,请查看上传数据集的数据集时间与页面选择时间"+startDate+"-"+endDate+"的本周数据及其上周是否充足");
} else {
if (checkData(dataHarmPowerq2List, startDate2, endDate2, timeInterval)) {
throw new BusinessException(AdvanceResponseEnum.DATA_NOT_FOUND);
throw new BusinessException("数据量过少,请查看上传数据集的数据集时间与页面选择时间"+startDate+"-"+endDate+"的前一周数据量是否充足");
}
}
linearInterpolation(dataHarmPowerq2List);
//数据校验
if (CollectionUtil.isEmpty(dataHarmPoweruList)) {
throw new BusinessException(AdvanceResponseEnum.DATA_NOT_FOUND);
throw new BusinessException("数据量过少,请查看上传数据集的数据集时间与页面选择时间"+startDate+"-"+endDate+"的本周数据及其上周是否充足");
} else {
if (checkData(dataHarmPoweruList, startDate2, endDate2, timeInterval)) {
throw new BusinessException(AdvanceResponseEnum.DATA_NOT_FOUND);
throw new BusinessException("数据量过少,请查看上传数据集的数据集时间与页面选择时间"+startDate+"-"+endDate+"的前一周数据量是否充足");
}
}
linearInterpolation(dataHarmPoweruList);
if (CollectionUtil.isEmpty(dataiList)) {
throw new BusinessException(AdvanceResponseEnum.DATA_NOT_FOUND);
throw new BusinessException("数据量过少,请查看上传数据集的数据集时间与页面选择时间"+startDate+"-"+endDate+"的本周数据及其上周是否充足");
} else {
List<CarryCapcityData> iList = dataiList.stream().map(temp -> {
CarryCapcityData carryCapcityData = new CarryCapcityData();
@@ -682,7 +698,7 @@ public class CarryCapacityServiceImpl implements CarryCapacityService {
}).collect(Collectors.toList());
if (checkData(iList, startDate, endDate, timeInterval)) {
throw new BusinessException(AdvanceResponseEnum.DATA_NOT_FOUND);
throw new BusinessException("数据量过少,请查看上传数据集的数据集时间与页面选择时间"+startDate+"-"+endDate+"的本周数据量是否充足");
}
}
linearInterpolationI(dataiList);
@@ -711,7 +727,6 @@ public class CarryCapacityServiceImpl implements CarryCapacityService {
}
@Override
public CarryCapacityDResultVO carryCapacityEvaluate(CarryCapacityEvaluateParam calParam) {
CarryCapacityDResultVO vo = new CarryCapacityDResultVO();
@@ -933,6 +948,7 @@ public class CarryCapacityServiceImpl implements CarryCapacityService {
try {
List<CarryCapcityDataEexcel> objects = EasyExcelUtil.syncReadModel(is, CarryCapcityDataEexcel.class, 0, 3);
objects = objects.stream().filter(temp -> Objects.nonNull(temp.getTime())).collect(Collectors.toList());
List<CarryCapcityDataIEexcel> iEexcelList = new ArrayList<>();
List<CarryCapcityDataVEexcel> vEexcelList = new ArrayList<>();
List<CarryCapcityDataPEexcel> pEexcelList = new ArrayList<>();

View File

@@ -5,6 +5,7 @@ import com.njcn.advance.mapper.carrycapacity.CarryCapacityStrategyDhlPOMapper;
import com.njcn.advance.pojo.carrycapacity.po.CarryCapacityStrategyDhlPO;
import com.njcn.advance.pojo.carrycapacity.vo.CarryCapacityStrategyDhlVO;
import com.njcn.advance.service.carrycapacity.CarryCapacityStrategyDhlPOService;
import com.njcn.advance.utils.CheckStringUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

View File

@@ -11,6 +11,7 @@ import com.njcn.advance.pojo.carrycapacity.po.CarryCapacityStrategyDhlPO;
import com.njcn.advance.pojo.carrycapacity.po.CarryCapacityStrategyPO;
import com.njcn.advance.pojo.carrycapacity.vo.CarryCapacityStrategyVO;
import com.njcn.advance.service.carrycapacity.CarryCapacityStrategyPOService;
import com.njcn.advance.utils.CheckStringUtil;
import com.njcn.common.pojo.exception.BusinessException;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
@@ -38,6 +39,7 @@ public class CarryCapacityStrategyPOServiceImpl extends ServiceImpl<CarryCapacit
@Override
@Transactional(rollbackFor = {Exception.class})
public Boolean add(CarryCapacityStrategyParam carryCapacityStrategyParam) {
CarryCapacityStrategyPO carryCapacityStrategy = new CarryCapacityStrategyPO();
BeanUtils.copyProperties(carryCapacityStrategyParam, carryCapacityStrategy);
//将原始策略处理为不启用

View File

@@ -11,7 +11,9 @@ import com.njcn.advance.mapper.carrycapacity.CarryCapacityUserPOMapper;
import com.njcn.advance.pojo.carrycapacity.param.CarryCapacityUserParam;
import com.njcn.advance.pojo.carrycapacity.po.CarryCapacityUserPO;
import com.njcn.advance.service.carrycapacity.CarryCapacityUserPOService;
import com.njcn.advance.utils.CheckStringUtil;
import com.njcn.common.pojo.constant.LogInfo;
import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.harmonic.enums.HarmonicResponseEnum;
@@ -19,6 +21,7 @@ import com.njcn.harmonic.pojo.param.ReportTemplateParam;
import com.njcn.harmonic.pojo.po.ExcelRptTemp;
import com.njcn.user.api.UserFeignClient;
import com.njcn.user.pojo.vo.UserVO;
import com.njcn.web.constant.ValidMessage;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
@@ -26,6 +29,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Objects;
import java.util.regex.Pattern;
/**
*
@@ -57,6 +61,11 @@ public class CarryCapacityUserPOServiceImpl extends ServiceImpl<CarryCapacityUse
* @return 结果
*/
private void checkName(CarryCapacityUserParam carryCapacityUserParam, boolean isUpdate) {
if(carryCapacityUserParam.getUserName().length()>32){
throw new BusinessException("超过最大长度");
}
CheckStringUtil.checkName(carryCapacityUserParam.getUserName());
LambdaQueryWrapper<CarryCapacityUserPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
//条件组合where state = 1 and name = ?
lambdaQueryWrapper.eq(CarryCapacityUserPO::getStatus, DataStateEnum.ENABLE.getCode()).eq(CarryCapacityUserPO::getUserName, carryCapacityUserParam.getUserName());
@@ -82,7 +91,7 @@ public class CarryCapacityUserPOServiceImpl extends ServiceImpl<CarryCapacityUse
if(StringUtils.isBlank(userUpdateParam.getUserName())){
throw new BusinessException("用户称不能为空");
}
checkName(userUpdateParam,false);
checkName(userUpdateParam,true);
CarryCapacityUserPO carryCapacityUser = new CarryCapacityUserPO();
BeanUtils.copyProperties(userUpdateParam, carryCapacityUser);

View File

@@ -118,7 +118,7 @@ public class SgEventServiceImpl extends ServiceImpl<SgEventMapper, SgEvent> impl
@Override
public void downloadTemplate() {
ExcelUtil.exportExcel("暂降事件模板.xls", "暂降数据", SgEventExcel.class, new ArrayList<>());
ExcelUtil.exportExcel("暂降事件模板.csv", "暂降数据", SgEventExcel.class, new ArrayList<>());
}
/**

View File

@@ -5,7 +5,9 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.date.TimeInterval;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.SerializeUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@@ -15,7 +17,7 @@ import com.njcn.advance.enums.AdvanceResponseEnum;
import com.njcn.advance.mapper.RelevantLogMapper;
import com.njcn.advance.mapper.RmpEventAdvanceMapper;
import com.njcn.advance.mapper.RmpEventDetailAssMapper;
import com.njcn.advance.pojo.dto.SagEvent;
import com.njcn.advance.pojo.dto.relevent.*;
import com.njcn.advance.pojo.po.PqsRelevanceLog;
import com.njcn.advance.service.EventRelevantAnalysisService;
@@ -26,10 +28,12 @@ import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.utils.PubUtils;
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.device.pq.pojo.po.PqsTflgployass;
import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
import com.njcn.event.pojo.po.RmpEventDetailAssPO;
import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.event.pojo.vo.AdvanceEventDetailVO;
import com.njcn.redis.utils.RedisUtil;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.enums.DicDataTypeEnum;
@@ -40,8 +44,10 @@ import com.njcn.user.pojo.po.User;
import com.njcn.web.factory.PageFactory;
import com.njcn.web.pojo.param.BaseParam;
import com.njcn.web.utils.RequestUtil;
import io.swagger.models.auth.In;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -63,6 +69,8 @@ import java.util.stream.Collectors;
@Slf4j
public class EventRelevantAnalysisServiceImpl extends ServiceImpl<RmpEventAdvanceMapper, RmpEventDetailPO> implements EventRelevantAnalysisService {
private final String redisSortKey = "NODESORT";
private final DicDataFeignClient dicDataFeignClient;
@@ -78,6 +86,8 @@ public class EventRelevantAnalysisServiceImpl extends ServiceImpl<RmpEventAdvanc
private final UserFeignClient userFeignClient;
private final RedisUtil redisUtil;
@Override
@Transactional(rollbackFor = Exception.class)
@@ -85,11 +95,6 @@ public class EventRelevantAnalysisServiceImpl extends ServiceImpl<RmpEventAdvanc
TimeInterval timeInterval = new TimeInterval();
DictData dictData = dicDataFeignClient.getDicDataByNameAndTypeName(DicDataTypeEnum.EVENT_REASON.getName(), DicDataEnum.SHORT_TROUBLE.getName()).getData();
if (Objects.isNull(dictData)) {
throw new BusinessException(SystemResponseEnum.ADVANCE_REASON);
}
LocalDateTime date = LocalDateTime.now();
HandleEvent handleEvent = new HandleEvent();
@@ -98,62 +103,58 @@ public class EventRelevantAnalysisServiceImpl extends ServiceImpl<RmpEventAdvanc
if (CollectionUtil.isEmpty(baseList)) {
throw new BusinessException("当前时间段暂无可分析事件");
}
List<EntityGroupEvtData> list3 = new ArrayList<>(baseList);
// 传入的处理事件根据物理隔绝进行分组
List<EntityLogic> strategyList = relevantLogMapper.getLogic();
if (CollectionUtil.isNotEmpty(strategyList)) {
Map<String, EntityMtrans> entityMtransMap = getNodeInfo();
Set<Map.Entry<String, EntityMtrans>> setMtrans = entityMtransMap.entrySet();
List<SagEvent> listSagEvent = new ArrayList<>();
List<EventAssObj> listEventAssObj = new ArrayList<>();
Map<String, List<String>> strategyToBusBarMap = new HashMap<>(32);
Map<String, Map<String, Integer>> nodeMap = (Map<String, Map<String, Integer>>)redisUtil.getObjectByKey(redisSortKey);
Set<Map.Entry<String, Map<String, Integer>>> nodeSort = nodeMap.entrySet();
Map<String, EntityMtrans> mapRedis = new HashMap<>(32);
Map<String, List<EntityLogic>> strategyMap = strategyList.stream().collect(Collectors.groupingBy(EntityLogic::getTPIndex));
strategyMap.forEach((key, list) -> {
List<String> before = list.stream().map(EntityLogic::getNodeBefore).distinct().collect(Collectors.toList());
List<String> after = list.stream().map(EntityLogic::getNodeNext).distinct().collect(Collectors.toList());
before.addAll(after);
before = before.stream().distinct().collect(Collectors.toList());
strategyToBusBarMap.put(key, before);
DictData dictData = dicDataFeignClient.getDicDataByNameAndTypeName(DicDataTypeEnum.EVENT_REASON.getName(), DicDataEnum.SHORT_TROUBLE.getName()).getData();
if (Objects.isNull(dictData)) {
throw new BusinessException(SystemResponseEnum.ADVANCE_REASON);
}
FinalData.NODE_NUM = before.size();
EntityMtrans entityMtrans = new EntityMtrans();
handleEvent.create_matrixcata(list, entityMtrans);
for (Map.Entry<String, Map<String, Integer>> m : nodeSort) {
List<EntityGroupEvtData> list = new ArrayList<EntityGroupEvtData>();
Set<Map.Entry<String, Integer>> mapValue = m.getValue().entrySet();
FinalData.NODE_NUM = m.getValue().size();
mapRedis.put(key, entityMtrans);
});
strategyToBusBarMap.forEach((lastKey, lastVal) -> {
int index = 1;
List<EntityGroupEvtData> list = new ArrayList<>();
for (EntityGroupEvtData entityGroupEvtData : baseList) {
if (lastVal.contains(entityGroupEvtData.getNodePhysics()) && dictData.getId().equals(entityGroupEvtData.getSagReason())) {
entityGroupEvtData.setNode(index++);
list.add(entityGroupEvtData);
for (Map.Entry<String, Integer> mm : mapValue) {
for (EntityGroupEvtData groupEvtData : baseList) {
if (groupEvtData.getNodePhysics().equals(mm.getKey()) && dictData.getId().equals(groupEvtData.getSagReason())) {
groupEvtData.setNode(mm.getValue());
list.add(groupEvtData);
}
}
baseList.removeIf(entityGroupEvtData -> lastVal.contains(entityGroupEvtData.getNodePhysics()) && dictData.getId().equals(entityGroupEvtData.getSagReason()));
// 筛选不在矩阵中的事件id
list3.removeIf(entityGroupEvtData -> entityGroupEvtData.getNodePhysics().equals(mm.getKey()) && dictData.getId().equals(entityGroupEvtData.getSagReason()));
}
EntityGroupEvtData[] entityGroupEvtData = new EntityGroupEvtData[list.size()];
Collections.sort(list);
list.toArray(entityGroupEvtData);
mapRedis.forEach((mKey, mVal) -> {
if (mKey.equals(lastKey)) {
/********************************************************************
* 算法最多处理1000条数据超过限制需分批处理 先将数据根据某种方式进行升序/降序排序,然后分段处理 加入循环处理
*********************************************************************/
for (Map.Entry<String, EntityMtrans> mEntry : setMtrans) {
if (mEntry.getKey().equals(m.getKey())) {
//算法最多处理1000条数据超过限制需分批处理 先将数据根据某种方式进行升序/降序排序,然后分段处理 加入循环处理
int circulation = entityGroupEvtData.length % FinalData.MAX_EVT_NUM == 0
? entityGroupEvtData.length / FinalData.MAX_EVT_NUM
: entityGroupEvtData.length / FinalData.MAX_EVT_NUM + 1;
for (int i = 0; i < circulation; i++) {
int to;
int to = 0;
if (i == circulation - 1) {
to = entityGroupEvtData.length % FinalData.MAX_EVT_NUM > 0
? entityGroupEvtData.length
@@ -164,19 +165,22 @@ public class EventRelevantAnalysisServiceImpl extends ServiceImpl<RmpEventAdvanc
EntityGroupEvtData[] arrayObj = Arrays.copyOfRange(entityGroupEvtData,
i * FinalData.MAX_EVT_NUM, to);
EntityGroupData entityGroupData = handleEvent.translate(arrayObj, mVal);
EntityMtrans entityMtrans = mEntry.getValue();
EntityGroupData entityGroupData = handleEvent.translate(arrayObj,entityMtrans);
// 处理分析结果
handleEvent.show_group_info(entityGroupData, listSagEvent, listEventAssObj, date);
}
}
});
});
}
}
/******************************************************************************
* 事件ID不在矩阵中结果集为基础以时标为标准进行归集处理 注意:三相与(单相/两相)互斥
*****************************************************************************/
disposeNonStandardData(handleEvent, baseList, listEventAssObj, listSagEvent, date);
@@ -216,13 +220,232 @@ public class EventRelevantAnalysisServiceImpl extends ServiceImpl<RmpEventAdvanc
entityPqsRelevance.setTimeId(date);
relevantLogMapper.insert(entityPqsRelevance);
} else {
throw new BusinessException("当前无变压器策略,请先配置策略");
}
log.info("事件关联分析用时:" + timeInterval.interval() / 1000 + "");
}
// @Override
// @Transactional(rollbackFor = Exception.class)
// public void processEvents(LocalDateTime startTime, LocalDateTime endTime) {
//
// TimeInterval timeInterval = new TimeInterval();
//
//
// Map<String, Map<String, Integer>> nodeSort = new HashMap<>();
// Map<String, EntityMtrans> entityMtransMap = getNodeInfo();
//
//
//
//
//
// for (Map.Entry<String, Map<String, Integer>> m : nodeSort) {
// List<EntityGroupEvtData> list = new ArrayList<EntityGroupEvtData>();
// Set<Map.Entry<String, Integer>> mapValue = m.getValue().entrySet();
// FinalData.NODE_NUM = m.getValue().size();
//
// for (Map.Entry<String, Integer> mm : mapValue) {
// for (int i = 0; i < entityGroupEvtDatas.length; i++) {
// if (entityGroupEvtDatas[i].getNodePhysics() == mm.getKey().intValue() && "短路故障".equals(entityGroupEvtDatas[i].getSagReason())) {
// entityGroupEvtDatas[i].setNode(mm.getValue());
// list.add(entityGroupEvtDatas[i]);
// }
// }
//
// // 筛选不在矩阵中的事件id
// Iterator<EntityGroupEvtData> iterator = list3.iterator();
// while (iterator.hasNext()) {
// EntityGroupEvtData entityGroupEvtData = iterator.next();
//
// if (entityGroupEvtData.getNodePhysics() == mm.getKey().intValue() && "短路故障".equals(entityGroupEvtData.getSagReason())) {
// iterator.remove();
// }
// }
// }
//
// EntityGroupEvtData[] entityGroupEvtData = new EntityGroupEvtData[list.size()];
// Collections.sort(list);
// list.toArray(entityGroupEvtData);
//
// for (Map.Entry<String, JSONObject> mEntry : setMtrans) {
// if (mEntry.getKey().equals(m.getKey())) {
// *//**//********************************************************************
// * 算法最多处理1000条数据超过限制需分批处理 先将数据根据某种方式进行升序/降序排序,然后分段处理 加入循环处理
// *********************************************************************//**//*
// int circulation = entityGroupEvtData.length % FinalData.MAX_EVT_NUM == 0
// ? entityGroupEvtData.length / FinalData.MAX_EVT_NUM
// : entityGroupEvtData.length / FinalData.MAX_EVT_NUM + 1;
//
// for (int i = 0; i < circulation; i++) {
// int to = 0;
//
// if (i == circulation - 1) {
// to = entityGroupEvtData.length % FinalData.MAX_EVT_NUM > 0
// ? entityGroupEvtData.length
// : (i + 1) * FinalData.MAX_EVT_NUM - 1;
// } else {
// to = (i + 1) * FinalData.MAX_EVT_NUM - 1;
// }
//
// EntityGroupEvtData[] arrayObj = Arrays.copyOfRange(entityGroupEvtData,
// i * FinalData.MAX_EVT_NUM, to);
// JSONObject entityMtrans = mEntry.getValue();
// EntityGroupData entityGroupData = handleEvent.translate(arrayObj, (EntityMtrans) JSONObject.toBean(entityMtrans, EntityMtrans.class));
// // 处理分析结果
// handleEvent.show_group_info(entityGroupData, listSagEvent, listEventAssObj, date);
// }
// }
// }
// }
//
//
// DictData dictData = dicDataFeignClient.getDicDataByNameAndTypeName(DicDataTypeEnum.EVENT_REASON.getName(), DicDataEnum.SHORT_TROUBLE.getName()).getData();
// if (Objects.isNull(dictData)) {
// throw new BusinessException(SystemResponseEnum.ADVANCE_REASON);
// }
//
//
// LocalDateTime date = LocalDateTime.now();
// HandleEvent handleEvent = new HandleEvent();
// // 分析的事件进行处理
// List<EntityGroupEvtData> baseList = handleEvent.getData(startTime, endTime);
// if (CollectionUtil.isEmpty(baseList)) {
// throw new BusinessException("当前时间段暂无可分析事件");
// }
//
// // 传入的处理事件根据物理隔绝进行分组
//
// List<EntityLogic> strategyList = relevantLogMapper.getLogic();
//
// if (CollectionUtil.isNotEmpty(strategyList)) {
// List<SagEvent> listSagEvent = new ArrayList<>();
// List<EventAssObj> listEventAssObj = new ArrayList<>();
//
// Map<String, List<String>> strategyToBusBarMap = new HashMap<>(32);
//
// Map<String, EntityMtrans> mapRedis = new HashMap<>(32);
//
// Map<String, List<EntityLogic>> strategyMap = strategyList.stream().collect(Collectors.groupingBy(EntityLogic::getTPIndex));
// strategyMap.forEach((key, list) -> {
// List<String> before = list.stream().map(EntityLogic::getNodeBefore).distinct().collect(Collectors.toList());
// List<String> after = list.stream().map(EntityLogic::getNodeNext).distinct().collect(Collectors.toList());
// before.addAll(after);
// before = before.stream().distinct().collect(Collectors.toList());
// strategyToBusBarMap.put(key, before);
//
// FinalData.NODE_NUM = before.size();
// EntityMtrans entityMtrans = new EntityMtrans();
// handleEvent.create_matrixcata(list, entityMtrans);
//
// mapRedis.put(key, entityMtrans);
// });
//
// strategyToBusBarMap.forEach((lastKey, lastVal) -> {
// int index = 1;
// List<EntityGroupEvtData> list = new ArrayList<>();
// for (EntityGroupEvtData entityGroupEvtData : baseList) {
// if (lastVal.contains(entityGroupEvtData.getNodePhysics()) && dictData.getId().equals(entityGroupEvtData.getSagReason())) {
// entityGroupEvtData.setNode(index++);
// list.add(entityGroupEvtData);
// }
// }
//
// baseList.removeIf(entityGroupEvtData -> lastVal.contains(entityGroupEvtData.getNodePhysics()) && dictData.getId().equals(entityGroupEvtData.getSagReason()));
//
//
// EntityGroupEvtData[] entityGroupEvtData = new EntityGroupEvtData[list.size()];
// Collections.sort(list);
// list.toArray(entityGroupEvtData);
//
// mapRedis.forEach((mKey, mVal) -> {
// if (mKey.equals(lastKey)) {
// //算法最多处理1000条数据超过限制需分批处理 先将数据根据某种方式进行升序/降序排序,然后分段处理 加入循环处理
// int circulation = entityGroupEvtData.length % FinalData.MAX_EVT_NUM == 0
// ? entityGroupEvtData.length / FinalData.MAX_EVT_NUM
// : entityGroupEvtData.length / FinalData.MAX_EVT_NUM + 1;
//
// for (int i = 0; i < circulation; i++) {
// int to;
// if (i == circulation - 1) {
// to = entityGroupEvtData.length % FinalData.MAX_EVT_NUM > 0
// ? entityGroupEvtData.length
// : (i + 1) * FinalData.MAX_EVT_NUM - 1;
// } else {
// to = (i + 1) * FinalData.MAX_EVT_NUM - 1;
// }
//
// EntityGroupEvtData[] arrayObj = Arrays.copyOfRange(entityGroupEvtData,
// i * FinalData.MAX_EVT_NUM, to);
// EntityGroupData entityGroupData = handleEvent.translate(arrayObj, mVal);
// // 处理分析结果
// handleEvent.show_group_info(entityGroupData, listSagEvent, listEventAssObj, date);
// }
// }
// });
//
// });
//
//
//
// //事件ID不在矩阵中结果集为基础以时标为标准进行归集处理 注意:三相与(单相/两相)互斥
//
// disposeNonStandardData(handleEvent, baseList, listEventAssObj, listSagEvent, date);
//
//
// int listSize = listEventAssObj.size();
// int toIndex = 1000;
// for (int i = 0; i < listSize; i += 1000) {
// //作用为toIndex最后没有toIndex条数据则剩余几条newList中就装几条
// if (i + 1000 > listSize) {
// toIndex = listSize - i;
// }
// //分割lst
// List<EventAssObj> newList = listEventAssObj.subList(i, i + toIndex);
// //写入添加方法,需要写你的新增方法把newList分切后的数据新增进入数据库。
// rmpEventDetailAssMapper.insertEventAssData(newList);
// }
//
// List<RmpEventDetailPO> eventUpdateList = new ArrayList<>();
// for (int i = 0; i < listSagEvent.size(); i++) {
// RmpEventDetailPO rmp = new RmpEventDetailPO();
// rmp.setEventId(listSagEvent.get(i).getIndexEventDetail());
// rmp.setEventassIndex(listSagEvent.get(i).getIndexEventAss());
// rmp.setDealTime(listSagEvent.get(i).getDealTime());
// eventUpdateList.add(rmp);
// if ((i + 1) % 1000 == 0) {
// this.updateBatchById(eventUpdateList);
// eventUpdateList.clear();
// } else if (i == listSagEvent.size() - 1) {
// this.updateBatchById(eventUpdateList);
// }
// }
//
// // 增加策略记录
// String describe = "用户" + RequestUtil.getUserNickname() + "进行了关联分析";
// PqsRelevanceLog entityPqsRelevance = new PqsRelevanceLog();
// entityPqsRelevance.setContentDes(describe);
// entityPqsRelevance.setState(DataStateEnum.ENABLE.getCode());
// entityPqsRelevance.setTimeId(date);
// relevantLogMapper.insert(entityPqsRelevance);
//
// } else {
// throw new BusinessException("当前无变压器策略,请先配置策略");
// }
//
// log.info("事件关联分析用时:" + timeInterval.interval() / 1000 + "秒");
// }
@Override
public Page<AdvanceEventDetailVO> querySagEventsPage(BaseParam baseParam) {
List<String> lineIds = generalDeviceInfoClient.deptGetRunLineEvent(RequestUtil.getDeptIndex()).getData();
@@ -635,31 +858,116 @@ public class EventRelevantAnalysisServiceImpl extends ServiceImpl<RmpEventAdvanc
/*************************************************************************************
* 获取变压器信息并生成矩阵
*************************************************************************************/
@Deprecated
public void getNodeInfo(HandleEvent handleEvent) {
public Map<String, EntityMtrans> getNodeInfo( ) {
Map<String, EntityMtrans> entityMtranMap = new HashMap<>(32);
HandleEvent handleEvent = new HandleEvent();
List<EntityLogic> list = relevantLogMapper.getLogic();
if (CollectionUtil.isNotEmpty(list)) {
Map<String, List<EntityLogic>> tfMap = list.stream().collect(Collectors.groupingBy(EntityLogic::getTPIndex));
Map<String, List<String>> tfBusBarMap = new HashMap<>(32);
Map<String, EntityMtrans> entityMtranMap = new HashMap<>(32);
Map<String, List<String>> map = getLogicInfo(list);
Map<String, Map<String, Integer>> setNodeSort = nodeSort(map);
redisUtil.saveByKeyWithExpire(redisSortKey,setNodeSort,-1L);
tfMap.forEach((key, val) -> {
List<String> tem = new ArrayList<>();
val.forEach(it -> {
tem.add(it.getNodeBefore());
tem.add(it.getNodeNext());
});
tfBusBarMap.put(key, tem);
setNodeSort.forEach((key, val) -> {
FinalData.NODE_NUM = val.size();
List<EntityLogic> listNew = new ArrayList<>();
for (EntityLogic entityLogic : list) {
if (entityLogic.getTPIndex().equals(key)) {
entityLogic.setNode_h(val.get(entityLogic.getNodeBefore()));
entityLogic.setNode_l(val.get(entityLogic.getNodeNext()));
listNew.add(entityLogic);
}
}
EntityMtrans entityMtrans = new EntityMtrans();
handleEvent.create_matrixcata(val, entityMtrans);
handleEvent.create_matrixcata(listNew, entityMtrans);
entityMtranMap.put(key, entityMtrans);
});
}
return entityMtranMap;
}
/*******************************************
* 增加排序功能并缓存进redis
*******************************************/
public Map<String, Map<String, Integer>> nodeSort(Map<String, List<String>> mapList) {
Set<Map.Entry<String, List<String>>> sets = mapList.entrySet();
Map<String, Map<String, Integer>> map = new HashMap<>();
for (Map.Entry<String, List<String>> m : sets) {
int index = 1;
Map<String, Integer> map2 = new HashMap<>();
for (String item : m.getValue()) {
map2.put(item, index++);
}
map.put(m.getKey(), map2);
}
return map;
}
/**
* 抽取物理隔绝信息与母线的关系并放入map集合中
* 与getTflgPloyInfo()方法功能类似
*/
public Map<String, List<String>> getLogicInfo(List<EntityLogic> list) {
if (list.size() > 0) {
Iterator<String> iterator = getAreaInfo(list).iterator();
Map<String, List<String>> map = new HashMap<>();
while (iterator.hasNext()) {
List<String> listLogic = new ArrayList<>();
String areaString = iterator.next();
for (EntityLogic entityLogic : list) {
if (entityLogic.getTPIndex().equals(areaString)) {
listLogic.add(entityLogic.getNodeBefore());
listLogic.add(entityLogic.getNodeNext());
}
}
//去除list中重复数据
Set<String> set = new TreeSet<>(listLogic);
map.put(areaString, new ArrayList<>(set));
}
return map;
}
return null;
}
/**
* 获取物理隔绝编码信息
* 供getInfo()、getLogicInfo()方法使用
* 先从list数组中去重然后获取物理隔绝编码
*/
public <T> Set<String> getAreaInfo(List<T> list) {
Set<T> set = new HashSet<T>(list);
Iterator<T> iterator = set.iterator();
Set<String> setReturn = new HashSet<String>();
while (iterator.hasNext()) {
Object object = iterator.next();
if (object instanceof PqsTflgployass) {
setReturn.add(((PqsTflgployass) object).getTpIndex());
continue;
}
setReturn.add(((EntityLogic) object).getTPIndex());
}
return setReturn;
}
@@ -697,3 +1005,4 @@ public class EventRelevantAnalysisServiceImpl extends ServiceImpl<RmpEventAdvanc
return new ArrayList<>();
}
}

View File

@@ -1,5 +1,7 @@
package com.njcn.advance.utils;
import com.njcn.advance.enums.AdvanceResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import org.apache.commons.math3.linear.DecompositionSolver;
import org.apache.commons.math3.linear.LUDecomposition;
import org.apache.commons.math3.linear.MatrixUtils;
@@ -102,10 +104,16 @@ public class CZNLPG {
//矩阵求逆
public static RealMatrix inverseMatrix(RealMatrix matrix) {
try {
LUDecomposition LUDe = new LUDecomposition(matrix);
DecompositionSolver solver = LUDe.getSolver();
RealMatrix result = solver.getInverse();
return result;
}catch (Exception e){
throw new BusinessException("数据存在问题无法进行矩阵求逆");
}
}
/**

View File

@@ -5,90 +5,87 @@ import com.njcn.advance.pojo.dto.relevent.*;
public class UtilNormalization {
public static void matrixcata_pro(EntityLogic[] transformer,EntityMtrans entityMtrans, int len) {
int i, j, k, con;
String node1, node2;
int i, j, k;
int node1, node2, con;
int src_node[] = new int[] { 0 };
// 连接方式转化为矩阵形式,行、列表示所有节点
// inf表示两个节点不相连0表示与自身相连其他数值表示变压器连接类型
// 将初始矩阵的元素设为inf,对角线元素设为0
for (i = 0; i < FinalData.NODE_NUM; i++) {
for (j = 0; j < FinalData.NODE_NUM; j++) {
for (j = 0; j < FinalData.NODE_NUM; j++)
entityMtrans.getMtrans()[i][j] = FinalData.DATA_INF;
}
entityMtrans.getMtrans()[i][i] = 0;
}
// 根据transformer设置元素
for (i = 0; i < len; i++) {
node1 = transformer[i].getNode_h();
node2 = transformer[i].getNode_l();
con = transformer[i].getType();
entityMtrans.getMtrans()[node1 - 1][node2 - 1] = con;
entityMtrans.getMtrans()[node2 - 1][node1 - 1] = con;
}
StringBuilder str = new StringBuilder();
for (i = 0; i < FinalData.NODE_NUM; i++) {
for (j = 0; j < FinalData.NODE_NUM; j++) {
str.append(entityMtrans.getMtrans()[i][j]).append(" ");
if (j == (FinalData.NODE_NUM - 1)) {
if (j == (FinalData.NODE_NUM - 1))
str.append("\r\n");
}
}
}
// 类型匹配矩阵Matrixcata
// Matrixcata模式匹配矩阵列为节点数行为总类别数元素为第一个节点分别是1-6类别情况下其他节点类别情况。
// 元素1,2,34,5,6 分别对应 Dc,Cb,Da,Cc,Db,Ca
// 设置矩阵第一行元素
for (i = 0; i < FinalData.NODE_NUM; i++) {
for (i = 0; i < FinalData.NODE_NUM; i++)
entityMtrans.getMatrixcata0()[0][i] = 0;
}
for (i = 1; i < FinalData.NODE_NUM; i++) {
// 路径缓存清空
for (j = 0; j < FinalData.MAX_PATH_NUM; j++) {
for (k = 0; k < (FinalData.NODE_NUM + 1); k++) {
for (k = 0; k < (FinalData.NODE_NUM + 1); k++)
entityMtrans.getPossiable_path()[j][k] = 0;
}
}
entityMtrans.setPath_num(0);
// 寻找路径
src_node[0] = 0;
findPath(entityMtrans, src_node, i, 0, 1, FinalData.NODE_NUM);
if (entityMtrans.getPath_num() != 0) {
if (entityMtrans.getPath_num() != 0)
entityMtrans.getMatrixcata0()[0][i] = entityMtrans.getPossiable_path()[0][FinalData.NODE_NUM]; // 采用第一条路径
} else {
else
entityMtrans.getMatrixcata0()[0][i] = FinalData.DATA_INF; // 找不到路径填大值表示不通
}
}
// 构造矩阵其他行元素
for (i = 1; i < FinalData.EVT_TYPE_NUM; i++) {
for (j = 0; j < FinalData.NODE_NUM; j++)
// EntityGroupData.Matrixcata0[i][j] =
// EntityGroupData.Matrixcata0[0][j] + i;
{
if (entityMtrans.getMatrixcata0()[0][j] == FinalData.DATA_INF) {
entityMtrans.getMatrixcata0()[i][j] = FinalData.DATA_INF;
} else {
entityMtrans.getMatrixcata0()[i][j] = entityMtrans.getMatrixcata0()[0][j] + i;
}
}
}
// 将数据归类到0-5
for (i = 0; i < FinalData.EVT_TYPE_NUM; i++) {
for (j = 0; j < FinalData.NODE_NUM; j++) {
for (j = 0; j < FinalData.NODE_NUM; j++)
entityMtrans.getMatrixcata1()[i][j] = entityMtrans.getMatrixcata0()[i][j] % 6;
}
}
// 0换成6将数据归类到1-6
for (i = 0; i < FinalData.EVT_TYPE_NUM; i++) {
for (j = 0; j < FinalData.NODE_NUM; j++) {
if (entityMtrans.getMatrixcata1()[i][j] == 0) {
if (entityMtrans.getMatrixcata1()[i][j] == 0)
entityMtrans.getMatrixcata1()[i][j] = 6;
}
}
}
str.delete(0, str.length());
for (i = 0; i < FinalData.EVT_TYPE_NUM; i++) {
for (j = 0; j < FinalData.NODE_NUM; j++) {
str.append(entityMtrans.getMatrixcata1()[i][j]).append(" ");
if (j == (FinalData.NODE_NUM - 1)) {
if (j == (FinalData.NODE_NUM - 1))
str.append("\r\n");
}
}
}
}

View File

@@ -15,6 +15,7 @@ import java.time.*;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
/*****************************************************************
* 字符串转基础类型,可能转换不成功,封装该方法
@@ -113,16 +114,16 @@ public class Utils {
public static boolean isTimeInRange(Instant instant, LocalDate startTime, LocalDate endTime) {
// 将Instant对象转换为LocalDateTime对象
LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
Instant instant1 = startTime.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant().plusMillis(TimeUnit.HOURS.toMillis(8));
Instant instant2 = endTime.plusDays(1).atStartOfDay(ZoneId.systemDefault()).toInstant().plusMillis(TimeUnit.HOURS.toMillis(8));
// 检查LocalDateTime对象是否在startTime和endTime之间
boolean isInRange = !localDateTime.toLocalDate().isBefore(startTime) && !localDateTime.toLocalDate().isAfter(endTime.plus(1, ChronoUnit.DAYS));
boolean isInRange = instant1.isBefore(instant) && instant2.isAfter(instant);
// 返回结果
return isInRange;
}
public static <T> List<Double> getAttributeValueByPropertyName(List<T> list, String propertyName) {
List<Double> resultList = new ArrayList<>();
for (T item : list) {

View File

@@ -65,7 +65,7 @@ public class RMpMonitorEvaluateDServiceImpl extends MppServiceImpl<RMpMonitorEva
// Integer statisticalInterval = lineDTO.getTimeInterval();
// /*电压等级*/
// Double voltage = Double.parseDouble(lineDTO.getVoltageLevel());
// List<DataVFiveItemDTO> fiveItems = dataVInfluxdbService.getFiveItems(lineDTO.getLineId(), beginDay, endDay, statisticalInterval);
// List<DataVFiveItemDTO> fiveItems = dataVInfluxdbService.getFiveItems(lineDTO.getL@ineId(), beginDay, endDay, statisticalInterval);
// RMpMonitorEvaluateD rMpMonitorEvaluateD = new RMpMonitorEvaluateD();
// rMpMonitorEvaluateD = calculateRMpMonitorEvaluateDPO(rMpMonitorEvaluateD, fiveItems, pmsAbnormalRules, voltage, lineDTO);
// Date date = DateUtil.parse(beginDay);

View File

@@ -169,6 +169,11 @@ public interface PatternRegex {
*/
String TF_NAME_REGEX = "^[0-9a-zA-Z\\u0391-\\uFFE5]{1,16}$";
/**
* 特殊字符正则
*/
String SPECIAL_REGEX = "[<>%'%;()&+/-\\\\_|@*?#$!,.]|html";
/**
* 字典类型名称
*/
@@ -177,7 +182,7 @@ public interface PatternRegex {
/**
* 描述32
*/
String DES32_REGEX = "^.{0,32}$";
String DES32_REGEX = "^.{0,10}$";
/**
* 描述64
@@ -229,6 +234,11 @@ public interface PatternRegex {
*/
String POSITIVE = "^[0-9].*$";
/**
* 大于0的数字整数以及小数
*/
String POSITIVEALL_NUM = "^(?:[1-9]\\d*(\\.\\d+)?)$";
/**
* 资源名称
*/
@@ -250,6 +260,8 @@ public interface PatternRegex {
*/
String ALL_CHAR_1_20 = "^[-_A-Za-z0-9\\u4e00-\\u9fa5]{1,20}$";
String SPECIALCHARACTER ="[<>%'%;()&+/\\\\-\\\\\\\\_|@*?#$!,.]|html";
/**
* uuid 32位正则数字 、 字母
*/

View File

@@ -10,8 +10,7 @@ import java.util.regex.Pattern;
/**
* @author yexibao
*/
public class Sm4Utils
{
public class Sm4Utils {
//全局秘钥
public final static String globalSecretKey = "11HDESaAhiHHug2z";
@@ -37,26 +36,20 @@ public class Sm4Utils
this.iv = iv;
}
public Sm4Utils(String secretKey)
{
public Sm4Utils(String secretKey) {
this.secretKey = secretKey;
}
public String encryptData_ECB(String plainText)
{
try
{
public String encryptData_ECB(String plainText) {
try {
Sm4Context ctx = new Sm4Context();
ctx.isPadding = true;
ctx.mode = Sm4.SM4_ENCRYPT;
byte[] keyBytes;
if (HEX_STRING)
{
if (HEX_STRING) {
keyBytes = util.hexStringToBytes(secretKey);
}
else
{
} else {
keyBytes = secretKey.getBytes();
}
@@ -64,66 +57,59 @@ public class Sm4Utils
sm4.sm4_setkey_enc(ctx, keyBytes);
byte[] encrypted = sm4.sm4_crypt_ecb(ctx, plainText.getBytes("GBK"));
String cipherText = new BASE64Encoder().encode(encrypted);
if (cipherText != null && cipherText.trim().length() > 0)
{
if (cipherText != null && cipherText.trim().length() > 0) {
Pattern p = Pattern.compile("\\s*|\t|\r|\n");
Matcher m = p.matcher(cipherText);
cipherText = m.replaceAll("");
}
return cipherText;
}
catch (Exception e)
{
} catch (Exception e) {
return null;
}
}
public String decryptData_ECB(String cipherText)
{
try
{
public String decryptData_ECB(String cipherText) {
try {
Sm4Context ctx = new Sm4Context();
ctx.isPadding = true;
ctx.mode = Sm4.SM4_DECRYPT;
byte[] keyBytes;
if (HEX_STRING)
{
if (HEX_STRING) {
keyBytes = util.hexStringToBytes(secretKey);
}
else
{
} else {
keyBytes = secretKey.getBytes();
}
Sm4 sm4 = new Sm4();
sm4.sm4_setkey_dec(ctx, keyBytes);
byte[] decrypted = sm4.sm4_crypt_ecb(ctx, new BASE64Decoder().decodeBuffer(cipherText));
return new String(decrypted, "GBK");
String tempText = new String(decrypted, "GBK");
String finalText = "";
for (int i = 0; i < tempText.length(); i++) {
char c = tempText.charAt(i);
if ((int) c != 0) {
finalText += c;
}
catch (Exception e)
{
}
return finalText;
} catch (Exception e) {
return null;
}
}
public String encryptData_CBC(String plainText)
{
try
{
public String encryptData_CBC(String plainText) {
try {
Sm4Context ctx = new Sm4Context();
ctx.isPadding = true;
ctx.mode = Sm4.SM4_ENCRYPT;
byte[] keyBytes;
byte[] ivBytes;
if (HEX_STRING)
{
if (HEX_STRING) {
keyBytes = util.hexStringToBytes(secretKey);
ivBytes = util.hexStringToBytes(iv);
}
else
{
} else {
keyBytes = secretKey.getBytes();
ivBytes = iv.getBytes();
}
@@ -132,37 +118,29 @@ public class Sm4Utils
sm4.sm4_setkey_enc(ctx, keyBytes);
byte[] encrypted = sm4.sm4_crypt_cbc(ctx, ivBytes, plainText.getBytes("GBK"));
String cipherText = new BASE64Encoder().encode(encrypted);
if (cipherText != null && cipherText.trim().length() > 0)
{
if (cipherText != null && cipherText.trim().length() > 0) {
Pattern p = Pattern.compile("\\s*|\t|\r|\n");
Matcher m = p.matcher(cipherText);
cipherText = m.replaceAll("");
}
return cipherText;
}
catch (Exception e)
{
} catch (Exception e) {
return null;
}
}
public String decryptData_CBC(String cipherText)
{
try
{
public String decryptData_CBC(String cipherText) {
try {
Sm4Context ctx = new Sm4Context();
ctx.isPadding = true;
ctx.mode = Sm4.SM4_DECRYPT;
byte[] keyBytes;
byte[] ivBytes;
if (HEX_STRING)
{
if (HEX_STRING) {
keyBytes = util.hexStringToBytes(secretKey);
ivBytes = util.hexStringToBytes(iv);
}
else
{
} else {
keyBytes = secretKey.getBytes();
ivBytes = iv.getBytes();
}
@@ -171,22 +149,22 @@ public class Sm4Utils
sm4.sm4_setkey_dec(ctx, keyBytes);
byte[] decrypted = sm4.sm4_crypt_cbc(ctx, ivBytes, new BASE64Decoder().decodeBuffer(cipherText));
return new String(decrypted, "GBK");
}
catch (Exception e)
{
} catch (Exception e) {
return null;
}
}
public static void main(String[] args) throws IOException
{
public static void main(String[] args) throws IOException {
String plainText = "@#001njcnpqs";
//11HDESaAhiHHugDz
String secretKey = "11HDESaAhiHHug2z";
Sm4Utils sm4 = new Sm4Utils(secretKey);
String cipherText = sm4.encryptData_ECB(plainText);
System.out.println("加密后:" + cipherText);
String cipherText1 = sm4.decryptData_ECB(cipherText);
System.out.println("解密后:" + cipherText1);
cipherText = cipherText + "11HDESaAhiHHug2z";
sm4.setSecretKey("11HDESaAhiHHug2z");
cipherText = sm4.encryptData_ECB(cipherText);

View File

@@ -68,6 +68,9 @@ public interface ValidMessage {
String DEVICE_VERSION_NOT_BLANK = "装置版本json文件不能为空请检查deviceVersionFile参数";
String SEARCH_DATA_ERROR = "搜索值过长,请检查搜索参数";
String SPECIAL_REGEX = "搜索值包含特殊字符";
String NAME_SPECIAL_REGEX = "包含特殊字符";
String DATA_TOO_LONG = "参数过长,请检查参数";

View File

@@ -632,5 +632,42 @@ public class RestTemplateUtil {
return restTemplate;
}
public static void main(String[] args) {
String s1 = "runoob";
String s2 = "runoob";
System.out.println(s1 == s2);
String body ="[\n" +
" {\n" +
" \"monitorId\": [\n" +
" \"id1\",\n" +
" \"id2\",\n" +
" \"id3\"\n" +
" ],\n" +
" \"dataType\": \"1\",\n" +
" \"timeInterval\": [\n" +
" \"2024-01-01 12:52:51~2024-01-01 13:53:00\",\n" +
" \"2024-01-02 12:52:51~2024-01-02 13:53:00\",\n" +
" \"2024-01-03 12:52:51~2024-01-03 13:53:00\",\n" +
" \"2024-01-04 12:52:51~2024-01-04 13:53:00\"\n" +
" ]\n" +
" },\n" +
" {\n" +
" \"monitorId\": [\n" +
" \"id4\"\n" +
" ],\n" +
" \"dataType\": \"0\",\n" +
" \"timeInterval\": [\n" +
" \"2024-01-01 12:40:00~2024-01-01 23:59:59\"\n" +
" ]\n" +
" }\n" +
"]";
ResponseEntity<Object> post = RestTemplateUtil.post("http://192.168.1.105:10004/powerQuality/recall", body, Object.class);
System.out.println(post);
}
}

View File

@@ -6,10 +6,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.*;
/**
* 线路信息表
@@ -68,7 +65,7 @@ public class LineParam {
*/
@ApiModelProperty(name = "devCapacity",value = "设备容量",required = true)
@NotNull(message = "设备容量不可为空")
@Min(value = 1,message = "设备容量格式有误")
@Min(value=0,message = "设备容量格式有误")
private Float devCapacity;
/**
@@ -76,7 +73,7 @@ public class LineParam {
*/
@ApiModelProperty(name = "shortCapacity",value = "短路容量",required = true)
@NotNull(message = "短路容量不可为空")
@Min(value = 1,message = "设备容量格式有误")
@Min(value=0,message = "设备容量格式有误")
private Float shortCapacity;
/**
@@ -84,7 +81,7 @@ public class LineParam {
*/
@ApiModelProperty(name = "dealCapacity",value = "协议容量",required = true)
@NotNull(message = "协议容量不可为空")
@Min(value = 1,message = "设备容量格式有误")
@Min(value=0,message = "设备容量格式有误")
private Float dealCapacity;
/**
@@ -92,7 +89,7 @@ public class LineParam {
*/
@ApiModelProperty(name = "standardCapacity",value = "基准容量新增时候可为空",required = true)
@NotNull(message = "基准容量不可为空")
@Min(value = 1,message = "设备容量格式有误")
@Min(value=0,message = "设备容量格式有误")
private Float standardCapacity;

View File

@@ -31,10 +31,10 @@ public class PqIcdPath {
/**
* 装置类型名称
*/
@TableField(value = "`Name`")
@TableField(value = "Name")
private String name;
@TableField(value = "`Path`")
@TableField(value = "Path")
private String path;

View File

@@ -1799,9 +1799,9 @@
<select id="getLineByDeviceId" resultType="com.njcn.device.pq.pojo.dto.MonitorInfo">
SELECT
pq_line_detail.id id,
line.`Name` name,
line.Name name,
pq_line_detail.Num lineNo,
s1.`Name` voltageLevel,
s1.Name voltageLevel,
pq_line_detail.PT_Phase_Type ptType,
pq_line_detail.Run_Flag status
FROM

View File

@@ -7,11 +7,11 @@
SELECT
pq_device.Id id,
pq_device.IP ip,
s1.`Name` devType,
pq_device.`Port` port,
pq_line.`Name` name,
s1.Name devType,
pq_device.Port port,
pq_line.Name name,
pq_device.Update_Time updateTime,
s2.`Name` manufacturer,
s2.Name manufacturer,
pq_device.Com_Flag status,
pq_device.Series series,
pq_device.Dev_Key devKey

View File

@@ -11,6 +11,6 @@
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
ID, `Name`, `Path`, Update_Time
ID, Name, Pat`, Update_Time
</sql>
</mapper>

View File

@@ -121,6 +121,11 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
@Value("${oracle.syncLedgerDeleteLine}")
private String urlDelete;
@Value("${devCD:0}")
private Integer devCD;
/**
* 终端新增操作
*
@@ -810,18 +815,18 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
private void coderM3d(Device deviceDetail){
if(StrUtil.isNotBlank(deviceDetail.getDevKey())){
deviceDetail.setDevKey(DeviceUtil.encodeString(1,deviceDetail.getDevKey()));
deviceDetail.setDevKey(DeviceUtil.encodeString(devCD,deviceDetail.getDevKey()));
}
if(StrUtil.isNotBlank(deviceDetail.getSeries())){
deviceDetail.setSeries(DeviceUtil.encodeString(1,deviceDetail.getSeries()));
deviceDetail.setSeries(DeviceUtil.encodeString(devCD,deviceDetail.getSeries()));
}
}
private void decoderM3d(Device deviceDetail){
if(StrUtil.isNotBlank(deviceDetail.getDevKey())){
deviceDetail.setDevKey(DeviceUtil.decoderString(1,deviceDetail.getDevKey()));
deviceDetail.setDevKey(DeviceUtil.decoderString(devCD,deviceDetail.getDevKey()));
}
if(StrUtil.isNotBlank(deviceDetail.getSeries())){
deviceDetail.setSeries(DeviceUtil.decoderString(1,deviceDetail.getSeries()));
deviceDetail.setSeries(DeviceUtil.decoderString(devCD,deviceDetail.getSeries()));
}
}

View File

@@ -180,10 +180,11 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
}
//变电站
targetData = targetData.stream().peek(terminalTree -> {
System.out.println(groupLine.get(terminalTree.getId()));
System.out.println(terminalTree.getId());
List<TerminalTree> terminalTrees = groupLine.get(terminalTree.getId()).stream().sorted(Comparator.comparing(TerminalTree::getSort)).collect(Collectors.toList());
if (isLine) {
//变电站集合
List<TerminalTree> terminalTrees = groupLine.get(terminalTree.getId());
int size = terminalTrees.stream().map(x -> {
// 获取父id字符串通过 逗号 分割 成一个数组
String[] pid = x.getPids().split(",");
@@ -192,7 +193,7 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
terminalTree.setName(terminalTree.getName() + "" + size + "台装置)");
terminalTree.setChildren(groupLine.get(terminalTree.getId()));
terminalTree.setChildren(terminalTrees);
} else {
terminalTree.setChildren(groupLine.get(terminalTree.getId()));
}

View File

@@ -1551,6 +1551,7 @@ public class EventAnalysisServiceImpl implements EventAnalysisService {
.eq(RmpEventDetailPO::getMeasurementPointId, eventBaseParam.getLineId())
.ge(StringUtils.isNotBlank(eventBaseParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime, DateUtil.beginOfDay(DateUtil.parse(eventBaseParam.getSearchBeginTime())))
.le(StringUtils.isNotBlank(eventBaseParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(eventBaseParam.getSearchEndTime())))
.orderByDesc(RmpEventDetailPO::getStartTime)
);
//获取关于监测点发电站相关信息

View File

@@ -231,6 +231,7 @@ whitelist:
- /bpm-boot/**
- /harmonic-boot/comAccess/getComAccessData
- /harmonic-boot/harmonic/getHistoryResult
- /event-boot/transient/getTransientAnalyseWave
#开始
# - /advance-boot/**
# - /device-boot/**

View File

@@ -0,0 +1,20 @@
package com.njcn.harmonic.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.harmonic.api.fallback.PmsLineWarningFeignClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
/**
* 流程实例 Api 接口
* @author xy
*/
@FeignClient(value = ServerInfo.HARMONIC, path = "/onlineMonitor", fallbackFactory = PmsLineWarningFeignClientFallbackFactory.class)
public interface PmsLineWarningFeignClient {
@PostMapping("/heBeiNorthAdd")
HttpResult<String> heBeiNorthAdd();
}

View File

@@ -1,23 +1,12 @@
package com.njcn.harmonic.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.harmonic.api.fallback.HarmDataFeignClientFallbackFactory;
import com.njcn.harmonic.api.fallback.RStatLimitRateDFeignClientFallbackFactory;
import com.njcn.harmonic.pojo.param.HistoryHarmParam;
import com.njcn.harmonic.pojo.param.RStatLimitQueryParam;
import com.njcn.harmonic.pojo.param.StatSubstationBizBaseParam;
import com.njcn.harmonic.pojo.po.day.RStatLimitRateDPO;
import com.njcn.harmonic.pojo.po.day.RStatLimitTargetDPO;
import com.njcn.harmonic.pojo.vo.RStatLimitTargetVO;
import com.njcn.influx.pojo.dto.HarmHistoryDataDTO;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

View File

@@ -0,0 +1,35 @@
package com.njcn.harmonic.api.fallback;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.harmonic.api.PmsLineWarningFeignClient;
import com.njcn.harmonic.utils.HarmonicEnumUtil;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* @author xy
*/
@Slf4j
@Component
public class PmsLineWarningFeignClientFallbackFactory implements FallbackFactory<PmsLineWarningFeignClient> {
@Override
public PmsLineWarningFeignClient create(Throwable throwable) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (throwable.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException) throwable.getCause();
exceptionEnum = HarmonicEnumUtil.getExceptionEnum(businessException.getResult());
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new PmsLineWarningFeignClient() {
@Override
public HttpResult<String> heBeiNorthAdd() {
log.error("{}异常,降级处理,异常为:{}", "新增在线监测数据(冀北-按月统计累计超标天数)", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -46,6 +46,9 @@ public class ReportTemplateDTO {
*/
private String resourceId;
/**
* 标识指标是否越限 0.否 1.是
*/
private Integer overLimitFlag;
/**

View File

@@ -0,0 +1,86 @@
package com.njcn.harmonic.pojo.param;
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 java.io.Serializable;
import java.util.List;
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2024/6/18 15:53
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class OnlineParam extends BaseParam implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "id")
private String id;
@ApiModelProperty(value = "部门id")
private String deptId;
@ApiModelProperty(value = "部门名称")
private String deptName;
@ApiModelProperty(value = "指标id")
private String targetId;
@ApiModelProperty(value = "指标集合")
private List<String> targetList;
@ApiModelProperty(value = "预警阈值")
private Integer alertThreshold;
@ApiModelProperty(value = "告警阈值")
private Integer alarmThreshold;
@ApiModelProperty(value = "数据类型")
private Integer dataType;
@ApiModelProperty(value = "监测点类型 0:电网侧 1:非电网侧")
private String lineType;
@Data
@EqualsAndHashCode(callSuper = true)
public static class ReportParam extends OnlineParam {
@ApiModelProperty(name = "type", value = "1:预警单 2:告警单")
private Integer type;
@ApiModelProperty(name = "issueDetail", value = "问题描述")
private String issueDetail;
@ApiModelProperty(name = "reformAdvice", value = "整改意见")
private String reformAdvice;
@ApiModelProperty(name = "year", value = "")
private String year;
@ApiModelProperty(name = "number", value = "编号")
private String number;
@ApiModelProperty(name = "idList", value = "问题id集合")
private List<String> idList;
}
@Data
@EqualsAndHashCode(callSuper = true)
public static class DetailParam extends OnlineParam {
@ApiModelProperty(name = "lineId", value = "监测点id")
private String lineId;
}
}

View File

@@ -0,0 +1,89 @@
package com.njcn.harmonic.pojo.po;
import com.baomidou.mybatisplus.annotation.TableName;
import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
import com.njcn.db.bo.BaseEntity;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.time.LocalDate;
/**
* <p>
* 监测点每日稳态指标超标天数统计表
* </p>
*
* @author xy
* @since 2024-06-17
*/
@Getter
@Setter
@TableName("supervision_line_warning")
public class PmsLineWarning extends BaseEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
private String id;
/**
* 告警时间
*/
@MppMultiId(value = "alarm_time")
private LocalDate alarmTime;
/**
* 责任部门id
*/
private String deptId;
/**
* 监测点id
*/
@MppMultiId(value = "line_id")
private String lineId;
/**
* 指标类型(字典id)
*/
@MppMultiId(value = "target_type")
private String targetType;
/**
* 越限天数
*/
private Integer overLimitDay;
/**
* 是否发送单子0:未发 1:已发)
*/
private Integer initiateWarningFlag;
/**
* 当前流程(0:无告警 1:预警 2:告警)
*/
private Integer step;
/**
* 预警阈值
*/
private Integer alertThreshold;
/**
* 告警阈值
*/
private Integer alarmThreshold;
/**
* 阈值来源(0:系统生成 1:界面)
*/
private Integer thresholdResource;
/**
* 预告警单id
*/
private String leafletId;
}

View File

@@ -0,0 +1,27 @@
package com.njcn.harmonic.pojo.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDate;
/**
* <p>
* 在线监测监测点越限详情
* </p>
*
* @author xy
* @since 2024-07-05
*/
@Data
public class LineLimitDetailVo implements Serializable {
@ApiModelProperty("日期")
@JsonFormat(pattern="yyyy-MM-dd")
private LocalDate time;
@ApiModelProperty("越限详情")
private String overLimitInfo;
}

View File

@@ -0,0 +1,85 @@
package com.njcn.harmonic.pojo.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2024/6/18 16:44
*/
@Data
public class PmsOnlineVo implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("id")
private String id;
@ApiModelProperty("责任单位")
private String dept;
@ApiModelProperty("变电站")
private String substation;
@ApiModelProperty("装置名称")
private String deviceName;
@ApiModelProperty("监测点id")
private String lineId;
@ApiModelProperty("监测点名称")
private String lineName;
@ApiModelProperty("监测对象类型")
private String businessType;
@ApiModelProperty("监测对象名称")
private String objectName;
@ApiModelProperty("指标id")
private String targetType;
@ApiModelProperty("超标天数")
private Integer overLimitDay;
@ApiModelProperty("频率偏差")
private Integer freq;
@ApiModelProperty("电压偏差")
private Integer voltage;
@ApiModelProperty("闪变")
private Integer flicker;
@ApiModelProperty("三相电压不平衡度")
private Integer ubalance;
@ApiModelProperty("负序电流")
private Integer iNeg;
@ApiModelProperty("谐波电压")
private Integer harmonicV;
@ApiModelProperty("谐波电流")
private Integer harmonicI;
@ApiModelProperty("间谐波电压")
private Integer inuharmV;
@ApiModelProperty("数据来源 0:系统默认 1:自定义")
private Integer dataResource;
@ApiModelProperty("当前流程(null:无流程 1:预警 2:告警)")
private Integer step;
@ApiModelProperty("最新数据时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
private LocalDateTime updateTime;
}

View File

@@ -6,6 +6,7 @@ import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.ObjectUtil;
import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
@@ -33,6 +34,7 @@ import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.enums.DicDataTypeEnum;
import com.njcn.system.pojo.po.DictData;
import com.njcn.system.pojo.po.Theme;
import com.njcn.web.constant.ValidMessage;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -48,6 +50,7 @@ import java.io.*;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.*;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@@ -182,7 +185,10 @@ public class ExportModelController extends BaseController {
param.setStartTime(DateUtil.format(startDate, "yyyy-MM-dd HH:mm:ss"));
LocalDateTime parse = LocalDateTimeUtil.parse(DateUtil.format(endDate, "yyyy-MM-dd HH:mm:ss"), DatePattern.NORM_DATETIME_PATTERN);
if(LocalDateTime.now().isBefore(parse)){
param.setEndTime(LocalDateTimeUtil.format(LocalDateTime.now(),DatePattern.NORM_DATETIME_PATTERN));
endDate = DateUtil.parse(LocalDateTimeUtil.format(LocalDateTime.now(),DatePattern.NORM_DATETIME_PATTERN));
}else {
param.setEndTime(DateUtil.format(endDate, "yyyy-MM-dd HH:mm:ss"));
}

View File

@@ -0,0 +1,77 @@
package com.njcn.harmonic.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo;
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.harmonic.pojo.param.OnlineParam;
import com.njcn.harmonic.pojo.vo.LineLimitDetailVo;
import com.njcn.harmonic.pojo.vo.PmsOnlineVo;
import com.njcn.harmonic.service.IPmsLineWarningService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
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;
/**
* <p>
* 监测点每日稳态指标超标天数统计表 前端控制器
* </p>
*
* @author xy
* @since 2024-06-17
*/
@Slf4j
@RestController
@RequestMapping("/onlineMonitor")
@Api(tags = "在线监测")
@AllArgsConstructor
public class PmsLineWarningController extends BaseController {
private final IPmsLineWarningService iPmsLineWarningService;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/heBeiNorthAdd")
@ApiOperation("新增在线监测数据(按月统计累计超标天数)")
@ApiImplicitParams({
@ApiImplicitParam(name = "startTime", value = "开始时间"),
@ApiImplicitParam(name = "endTime", value = "结束时间")
})
public HttpResult<String> heBeiNorthAdd(@RequestParam(value = "startTime",required = false) String startTime, @RequestParam(value = "endTime",required = false) String endTime) {
String methodDescribe = getMethodDescribe("heBeiNorthAdd");
iPmsLineWarningService.addHeBeiNorthLineWarning(startTime,endTime);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/list")
@ApiOperation("分页查询在线监测数据")
@ApiImplicitParam(name = "param", value = "参数", required = true)
public HttpResult<Page<PmsOnlineVo>> lineWarningList(@RequestBody @Validated OnlineParam param) {
String methodDescribe = getMethodDescribe("lineWarningList");
Page<PmsOnlineVo> list = iPmsLineWarningService.getLineWarningList(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/overLimitDetail")
@ApiOperation("查看越限详情")
@ApiImplicitParam(name = "param", value = "参数", required = true)
public HttpResult<List<LineLimitDetailVo>> getOverLimitDetail(@RequestBody @Validated OnlineParam.DetailParam param) {
String methodDescribe = getMethodDescribe("getOverLimitDetail");
List<LineLimitDetailVo> result = iPmsLineWarningService.getOverLimitDetail(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
}

View File

@@ -3,13 +3,16 @@ package com.njcn.harmonic.controller.report;
import cn.hutool.core.date.TimeInterval;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.harmonic.pojo.dto.FpyReportDTO;
import com.njcn.harmonic.pojo.param.QualifiedReportParam;
import com.njcn.harmonic.service.majornetwork.QualifiedReportService;
import com.njcn.web.constant.ValidMessage;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
@@ -22,6 +25,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.regex.Pattern;
/**
* pqs
@@ -49,6 +54,11 @@ public class QualifiedReport extends BaseController {
@ApiImplicitParam(name = "qualifiedReportParam", value = "合格率报告参数", required = true)
public HttpResult<Page<FpyReportDTO>> pageTable(@RequestBody @Validated QualifiedReportParam qualifiedReportParam) {
TimeInterval timeInterval = new TimeInterval();
String searchValue = qualifiedReportParam.getSearchValue();
Pattern pattern = Pattern.compile(PatternRegex.SPECIAL_REGEX);
if(pattern.matcher(searchValue).find()){
throw new BusinessException(ValidMessage.SPECIAL_REGEX);
}
String methodDescribe = getMethodDescribe("pageTable");
Page<FpyReportDTO> result = qualifiedReportService.pageTable(qualifiedReportParam);
log.info("合格率报告执行时长:"+timeInterval.interval());

View File

@@ -0,0 +1,21 @@
package com.njcn.harmonic.mapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
import com.njcn.harmonic.pojo.po.PmsLineWarning;
import com.njcn.harmonic.pojo.vo.PmsOnlineVo;
import org.apache.ibatis.annotations.Param;
/**
* <p>
* 监测点每日稳态指标超标天数统计表 Mapper 接口
* </p>
*
* @author xy
* @since 2024-06-17
*/
public interface PmsLineWarningMapper extends MppBaseMapper<PmsLineWarning> {
Page<PmsOnlineVo> page(@Param("page") Page<PmsLineWarning> page, @Param("ew") QueryWrapper<PmsLineWarning> queryWrapper);
}

View File

@@ -0,0 +1,27 @@
<?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.harmonic.mapper.PmsLineWarningMapper">
<select id="page" resultType="PmsOnlineVo">
SELECT
p1.id id,
p2.Org_Name dept,
p2.Powerr_Name substation,
p3.`Name` deviceName,
p2.`Name` lineName,
p1.line_id lineId,
p4.`Name` businessType,
p2.Monitor_Object_Name objectName,
p1.target_type targetType,
p1.over_limit_day overLimitDay,
p3.Update_Time updateTime
FROM
supervision_line_warning p1
LEFT JOIN pms_monitor p2 ON p1.line_id = p2.Id
LEFT JOIN pms_terminal p3 ON p2.Terminal_Id = p3.Id
LEFT JOIN sys_dict_data p4 ON p2.Monitor_Type = p4.Id
<where>
and ${ew.sqlSegment}
</where>
</select>
</mapper>

View File

@@ -0,0 +1,41 @@
package com.njcn.harmonic.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.harmonic.pojo.param.OnlineParam;
import com.njcn.harmonic.pojo.po.PmsLineWarning;
import com.njcn.harmonic.pojo.vo.LineLimitDetailVo;
import com.njcn.harmonic.pojo.vo.PmsOnlineVo;
import java.util.List;
/**
* <p>
* 监测点每日稳态指标超标天数统计表 服务类
* </p>
*
* @author xy
* @since 2024-06-17
*/
public interface IPmsLineWarningService extends IService<PmsLineWarning> {
/**
* 每日统计当前月各监测点各指标累计超标天数
*/
void addHeBeiNorthLineWarning(String startTime, String endTime);
/**
* 获取在线监测的数据列表
* @param param
* @return
*/
Page<PmsOnlineVo> getLineWarningList(OnlineParam param);
/**
* 按监测点id指标id查看越限详情具体展示每日超标的
* @param param
* @return
*/
List<LineLimitDetailVo> getOverLimitDetail(OnlineParam.DetailParam param);
}

View File

@@ -31,6 +31,7 @@ import com.njcn.harmonic.mapper.ExcelRptTempMapper;
import com.njcn.harmonic.pojo.dto.ReportTemplateDTO;
import com.njcn.harmonic.pojo.param.ReportSearchParam;
import com.njcn.harmonic.pojo.param.ReportTemplateParam;
import com.njcn.harmonic.utils.DataChangeUtil;
import com.njcn.influx.constant.InfluxDbSqlConstant;
import com.njcn.influx.pojo.constant.InfluxDBTableConstant;
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
@@ -103,11 +104,8 @@ public class CustomReportServiceImpl implements CustomReportService {
private final FileStorageUtil fileStorageUtil;
private final CommonService commonService;
private final DeviceUnitClient deviceUnitClient;
private final DicDataFeignClient dicDataFeignClient;
private final DeptFeignClient deptFeignClient;
private final InfluxDbUtils influxDbUtils;
@@ -819,11 +817,10 @@ public class CustomReportServiceImpl implements CustomReportService {
*/
private void analyzeReport(ReportSearchParam reportSearchParam, ExcelRptTemp excelRptTemp, HttpServletResponse response) {
//定义一个线程集合
List<Future<?>> futures = new ArrayList<>();
long begin = System.currentTimeMillis();
//根据content获取v值并进行处理
//指标
List<ReportTemplateDTO> reportTemplateDTOList = new ArrayList<>();
//限值
@@ -838,10 +835,8 @@ public class CustomReportServiceImpl implements CustomReportService {
throw new BusinessException(HarmonicResponseEnum.CUSTOM_REPORT_JSON);
}
long temEnd = System.currentTimeMillis();
//处理指标是否合格
reportLimitList = new LinkedHashSet<>(reportLimitList).stream().sorted(Comparator.comparing(ReportTemplateDTO::getItemName)).collect(Collectors.toList());
Map<String, Float> limitMap = overLimitDeal(reportLimitList, reportSearchParam);
@@ -860,6 +855,7 @@ public class CustomReportServiceImpl implements CustomReportService {
classMap.forEach((classKey, templateValue) -> {
Map<String, List<ReportTemplateDTO>> valueTypeMap = templateValue.stream().collect(Collectors.groupingBy(ReportTemplateDTO::getStatMethod));
//每张表开启一个独立线程查询
futures.add(executorService.submit(() -> {
//avg.max,min,cp95
valueTypeMap.forEach((valueTypeKey, valueTypeVal) -> {
@@ -884,7 +880,6 @@ public class CustomReportServiceImpl implements CustomReportService {
});
// 等待所有任务完成
for (Future<?> future : futures) {
try {
@@ -894,7 +889,6 @@ public class CustomReportServiceImpl implements CustomReportService {
}
}
//处理指标最终判定合格还是不合格
dealTargetResult(assNoPassMap, limitTargetMapX, endList);
@@ -912,11 +906,12 @@ public class CustomReportServiceImpl implements CustomReportService {
//1、根据itemName分组
Map<String, List<ReportTemplateDTO>> assMap = endList.stream().collect(Collectors.groupingBy(ReportTemplateDTO::getItemName));
//处理台账信息
Map<String, String> terminalMap = null;
Map<String, String> finalTerminalMap;
if (CollUtil.isNotEmpty(terminalList)) {
terminalMap = commTerminalGeneralClient.getCustomDetailByLineId(reportSearchParam.getLineId()).getData();
finalTerminalMap = commTerminalGeneralClient.getCustomDetailByLineId(reportSearchParam.getLineId()).getData();
}else {
finalTerminalMap = new HashMap<>();
}
Map<String, String> finalTerminalMap = terminalMap;
//2、把itemName的value赋给v和m
@@ -966,12 +961,21 @@ public class CustomReportServiceImpl implements CustomReportService {
if (Objects.nonNull(finalTerminalMap)) {
if ("statis_time".equals(tem)) {
//如何时间是大于当前时间则用当前时间
// String localTime = InfluxDbSqlConstant.END_TIME;
// LocalDate localDate = LocalDateTimeUtil.parseDate(reportSearchParam.getEndTime(), DatePattern.NORM_DATE_PATTERN);
// if(LocalDate.now().isEqual(localDate)){
// localTime =" "+ LocalTime.now().format(DatePattern.NORM_TIME_FORMATTER);
// }
// son.set("v", reportSearchParam.getStartTime() + InfluxDbSqlConstant.START_TIME + "_" + reportSearchParam.getEndTime() + localTime);
String localTime = InfluxDbSqlConstant.END_TIME;
LocalDate localDate = LocalDateTimeUtil.parseDate(reportSearchParam.getEndTime(), DatePattern.NORM_DATE_PATTERN);
if(LocalDate.now().isEqual(localDate)){
localTime =" "+ LocalTime.now().format(DatePattern.NORM_TIME_FORMATTER);
}
LocalDate nowDate = LocalDate.now();
if (nowDate.isAfter(localDate)) {
son.set("v", reportSearchParam.getStartTime() + InfluxDbSqlConstant.START_TIME + "_" + reportSearchParam.getEndTime() + localTime);
} else {
localTime = " " + LocalTime.now().format(DatePattern.NORM_TIME_FORMATTER);
son.set("v", reportSearchParam.getStartTime() + InfluxDbSqlConstant.START_TIME + "_" + nowDate + localTime);
}
} else {
//台账信息
son.set("v", finalTerminalMap.getOrDefault(tem, "/"));
@@ -1159,6 +1163,11 @@ public class CustomReportServiceImpl implements CustomReportService {
throw new BusinessException(HarmonicResponseEnum.CUSTOM_REPORT_JSON);
}
DictData pqdDic = dicDataFeignClient.getDicDataByCodeAndType(DicDataEnum.PQD.getCode(), DicDataTypeEnum.CS_DATA_TYPE.getCode()).getData();
List<EleEpdPqd> eleEpdPqdList = eleEpdMapper.selectList(new LambdaQueryWrapper<EleEpdPqd>().eq(EleEpdPqd::getDataType, pqdDic.getId()).isNotNull(EleEpdPqd::getPrimaryFormula));
Map<String, List<EleEpdPqd>> pqdMap = eleEpdPqdList.stream().filter(item -> StrUtil.isNotBlank(item.getPrimaryFormula())).collect(Collectors.groupingBy(EleEpdPqd::getName));
//处理指标是否合格
reportLimitList = new LinkedHashSet<>(reportLimitList)
.stream()
@@ -1169,15 +1178,16 @@ public class CustomReportServiceImpl implements CustomReportService {
//存放限值指标的map
Map<String, ReportTemplateDTO> limitTargetMapX = reportLimitList.stream().collect(Collectors.toMap(ReportTemplateDTO::getItemName, Function.identity()));
List<ReportTemplateDTO> endList = new ArrayList<>();
if (CollUtil.isNotEmpty(reportTemplateDTOList)) {
//组装最后监测点条件
List<WlRecord> wlRecordList = wlRecordFeignClient.getWlAssByWlId(reportSearchParam.getLineId()).getData();
if (CollUtil.isEmpty(wlRecordList)) {
List<WlRecord> temList = wlRecordFeignClient.getWlAssByWlId(reportSearchParam.getLineId()).getData();
//List<WlRecord> wlRecordList = temList.stream().filter(it -> it.getType() == 1).collect(Collectors.toList());
if (CollUtil.isEmpty(temList) && temList.size()==1) {
throw new BusinessException("当前测试项无测试数据");
}
List<ReportTemplateDTO> endList = new ArrayList<>();
if (CollUtil.isNotEmpty(reportTemplateDTOList)) {
//开始组织sql
reportTemplateDTOList = new LinkedHashSet<>(reportTemplateDTOList)
.stream()
@@ -1199,13 +1209,13 @@ public class CustomReportServiceImpl implements CustomReportService {
phaseMap.forEach((phaseKey, phaseVal) -> {
StringBuilder sql = new StringBuilder(InfluxDbSqlConstant.SELECT);
if (InfluxDbSqlConstant.MAX.equalsIgnoreCase(valueTypeKey)) {
assSqlZhejiang(phaseVal, sql, endList, InfluxDbSqlConstant.MAX, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap, wlRecordList);
assSqlZhejiang(phaseVal, sql, endList, InfluxDbSqlConstant.MAX, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap, temList, pqdMap);
} else if (InfluxDbSqlConstant.MIN.equalsIgnoreCase(valueTypeKey)) {
assSqlZhejiang(phaseVal, sql, endList, InfluxDbSqlConstant.MIN, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap, wlRecordList);
assSqlZhejiang(phaseVal, sql, endList, InfluxDbSqlConstant.MIN, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap, temList, pqdMap);
} else if (InfluxDbSqlConstant.AVG_WEB.equalsIgnoreCase(valueTypeKey)) {
assSqlZhejiang(phaseVal, sql, endList, InfluxDbSqlConstant.AVG, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap, wlRecordList);
assSqlZhejiang(phaseVal, sql, endList, InfluxDbSqlConstant.AVG, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap, temList, pqdMap);
} else if (InfluxDbSqlConstant.CP95.equalsIgnoreCase(valueTypeKey)) {
assSqlZhejiang(phaseVal, sql, endList, InfluxDbSqlConstant.PERCENTILE, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap, wlRecordList);
assSqlZhejiang(phaseVal, sql, endList, InfluxDbSqlConstant.PERCENTILE, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap, temList, pqdMap);
}
});
});
@@ -1219,7 +1229,6 @@ public class CustomReportServiceImpl implements CustomReportService {
System.out.println("查询数据库花费时间" + (dealEnd - deal) / 1000 + "S");
}
if (CollUtil.isNotEmpty(endList)) {
long jie = System.currentTimeMillis();
//数据单位信息
@@ -1228,33 +1237,46 @@ public class CustomReportServiceImpl implements CustomReportService {
//1、根据itemName分组
Map<String, List<ReportTemplateDTO>> assMap = endList.stream().collect(Collectors.groupingBy(ReportTemplateDTO::getItemName));
//处理台账信息
/*Map<String, String> terminalMap = null;
Map<String, String> finalTerminalMap;
if (CollUtil.isNotEmpty(terminalList)) {
terminalMap = commTerminalGeneralClient.getCustomDetailByLineId(reportSearchParam.getLineId()).getData();
}
Map<String, String> finalTerminalMap = terminalMap;*/
if(Objects.nonNull(reportSearchParam.getCustomType()) && reportSearchParam.getCustomType() == 1){
WlRecord wlRecordMain = temList.stream().filter(it -> it.getType() == 0).collect(Collectors.toList()).get(0);
finalTerminalMap = new HashMap<>();
finalTerminalMap.put("lineName",wlRecordMain.getItemName());
//finalTerminalMap.put("statis_time",wlRecordMain.getStartTime()+"_"+wlRecordMain.getEndTime());
finalTerminalMap.put("pt",wlRecordMain.getCt().toString());
finalTerminalMap.put("ct",wlRecordMain.getPt().toString());
finalTerminalMap.put("Standard_Capacity",wlRecordMain.getCapacitySscb().toString());
finalTerminalMap.put("Short_Capacity",wlRecordMain.getCapacitySscmin().toString());
finalTerminalMap.put("Deal_Capacity",wlRecordMain.getCapacitySi().toString());
finalTerminalMap.put("Dev_Capacity",wlRecordMain.getCapacitySt().toString());
}else {
finalTerminalMap = commTerminalGeneralClient.getCustomDetailByLineId(reportSearchParam.getLineId()).getData();
}
}else {
finalTerminalMap = new HashMap<>();
}
//2、把itemName的value赋给v和m
dealExcelResult(jsonArray, assMap, unit);
dealExcelResult(jsonArray, assMap, unit,finalTerminalMap);
long jieEnd = System.currentTimeMillis();
System.out.println("组装信息耗时 " + (jieEnd - jie) / 1000 + "S");
}
long daochu = System.currentTimeMillis();
//导出自定义报表
downReport(jsonArray, response);
long daochuEnd = System.currentTimeMillis();
System.out.println("导出耗时 " + (daochuEnd - daochu) / 1000 + "S");
}
private void assSqlZhejiang(List<ReportTemplateDTO> data, StringBuilder
sql, List<ReportTemplateDTO> endList, String method, ReportSearchParam
reportSearchParam, Map<String, ReportTemplateDTO> limitMap, Map<String, Float> overLimitMap, Map<String, ReportTemplateDTO> assNoPassMap, List<WlRecord> wlRecordList) {
sql, List<ReportTemplateDTO> endList, String method, ReportSearchParam reportSearchParam, Map<String, ReportTemplateDTO> limitMap, Map<String, Float> overLimitMap, Map<String,
ReportTemplateDTO> assNoPassMap, List<WlRecord> wlRecordList, Map<String, List<EleEpdPqd>> pqdMap) {
//sql拼接示例select MAX(IHA2) as IHA2 from power_quality_data where Phase = 'A' and LineId='1324564568' and Stat_Method='max' tz('Asia/Shanghai')
//cp95函数特殊处理 PERCENTILE(field_key, N)
if (InfluxDbSqlConstant.PERCENTILE.equals(method)) {
@@ -1314,7 +1336,10 @@ public class CustomReportServiceImpl implements CustomReportService {
.append(InfluxDbSqlConstant.QM);
List<Map<String, Object>> allList = new ArrayList<>();
WlRecord ceShiItem = wlRecordList.stream().filter(it->it.getType()==0).collect(Collectors.toList()).get(0);
for (WlRecord wlRecord : wlRecordList) {
if(wlRecord.getType().equals(1)) {
StringBuilder temSql = new StringBuilder(sql);
String start = LocalDateTimeUtil.format(wlRecord.getStartTime(), DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN));
String end = LocalDateTimeUtil.format(wlRecord.getEndTime(), DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN));
@@ -1327,20 +1352,46 @@ public class CustomReportServiceImpl implements CustomReportService {
List<Map<String, Object>> temMapList = influxDbUtils.getMapResult(temSql.toString());
if (CollUtil.isNotEmpty(temMapList)) {
Map<String, Object> tem = temMapList.get(0);
//需要吧测点为二次值的转换为一次值
if (wlRecord.getDataLevel().equals("Secondary")) {
for (Map.Entry<String, Object> entry : tem.entrySet()) {
if (Objects.nonNull(entry.getValue()) && !entry.getKey().equals("time")) {
String key = entry.getKey();
double val = (double) entry.getValue();
String zi = key.substring(0, key.indexOf("#"));
String[] temStrArr = zi.split("_");
boolean flag = isInteger(temStrArr[temStrArr.length-1]);
if(flag){
zi = zi.substring(0,zi.lastIndexOf("_"));
}
if (pqdMap.containsKey(zi)) {
EleEpdPqd eleEpdPqd = pqdMap.get(zi).get(0);
if(!eleEpdPqd.getPrimaryFormula().equals("*CT")){
val = val / 1000;
}
double vRes = DataChangeUtil.secondaryToPrimary(eleEpdPqd.getPrimaryFormula(),val, (double) ceShiItem.getPt(), (double) ceShiItem.getCt());
entry.setValue(vRes);
}
}
}
}
allList.add(temMapList.get(0));
}
}
}
Map<String, Object> resultMap = dealResultMap(method, allList);
if (resultMap.isEmpty()) {
data = data.stream().peek(item -> item.setValue("/")).collect(Collectors.toList());
} else {
//遍历模板对查询出来的数据进行赋值
for (ReportTemplateDTO item : data) {
if (resultMap.containsKey(item.getItemName())) {
double v = (Double) resultMap.get(item.getItemName());
item.setValue(String.format("%.3f", v));
if (overLimitMap.containsKey(item.getLimitName())) {
Float tagVal = overLimitMap.get(item.getLimitName());
if (v > tagVal) {
@@ -1375,6 +1426,12 @@ public class CustomReportServiceImpl implements CustomReportService {
}
/**
* 对多测点数据进行计算求出一组数据
* @param method
* @param allList
* @return
*/
private Map<String, Object> dealResultMap(String method, List<Map<String, Object>> allList) {
Map<String, Object> resultMap = new HashMap<>();
// 遍历列表中的每个Map
@@ -1383,7 +1440,7 @@ public class CustomReportServiceImpl implements CustomReportService {
// 遍历当前Map的键值对
for (Map.Entry<String, Object> entry : map.entrySet()) {
String key = entry.getKey();
if (!key.equals("time")) {
if (Objects.nonNull(entry.getValue()) && !key.equals("time")) {
double value = (double) entry.getValue();
// 检查结果Map中是否已包含该键
if (!resultMap.containsKey(key) || (double) resultMap.get(key) > value) {
@@ -1398,7 +1455,7 @@ public class CustomReportServiceImpl implements CustomReportService {
// 遍历当前Map的键值对
for (Map.Entry<String, Object> entry : map.entrySet()) {
String key = entry.getKey();
if (!key.equals("time")) {
if (Objects.nonNull(entry.getValue()) && !key.equals("time")) {
double value = (double) entry.getValue();
// 检查结果Map中是否已包含该键
if (!resultMap.containsKey(key) || (double) resultMap.get(key) < value) {
@@ -1416,7 +1473,7 @@ public class CustomReportServiceImpl implements CustomReportService {
// 遍历当前Map的键值对
for (Map.Entry<String, Object> entry : map.entrySet()) {
String key = entry.getKey();
if (!key.equals("time")) {
if (Objects.nonNull(entry.getValue()) && !key.equals("time")) {
double value = (double) entry.getValue();
// 更新累计和
@@ -1441,7 +1498,7 @@ public class CustomReportServiceImpl implements CustomReportService {
private void dealExcelResult(JSONArray
jsonArray, Map<String, List<ReportTemplateDTO>> assMap, Map<String, String> unit) {
jsonArray, Map<String, List<ReportTemplateDTO>> assMap, Map<String, String> unit,Map<String,String> finalTerminalMap) {
jsonArray.forEach(item -> {
JSONObject jsonObject = (JSONObject) item;
JSONArray itemArr = (JSONArray) jsonObject.get("celldata");
@@ -1482,18 +1539,18 @@ public class CustomReportServiceImpl implements CustomReportService {
son.set("fc", "#990000");
}
}
} /*else if (v.charAt(0) == '&') {
} else if (v.charAt(0) == '&') {
//结论
String tem = v.replace("&", "");
if (Objects.nonNull(finalTerminalMap)) {
if ("statis_time".equals(tem)) {
son.set("v", reportSearchParam.getStartTime() + InfluxDbSqlConstant.START_TIME + "_" + reportSearchParam.getEndTime() + InfluxDbSqlConstant.END_TIME);
// son.set("v", reportSearchParam.getStartTime() + InfluxDbSqlConstant.START_TIME + "_" + reportSearchParam.getEndTime() + InfluxDbSqlConstant.END_TIME);
} else {
//台账信息
son.set("v", finalTerminalMap.getOrDefault(tem, "/"));
}
}
}*/ else if (v.charAt(0) == '@' && v.contains("#")) {
} else if (v.charAt(0) == '@' && v.contains("#")) {
//解决数据单位问题 @指标#类型@
String replace = v.replace("@", "");
son.set("v", unit.getOrDefault(replace, "/"));
@@ -1614,6 +1671,14 @@ public class CustomReportServiceImpl implements CustomReportService {
}
}
public static boolean isInteger(String str) {
try {
Integer.parseInt(str);
return true;
} catch (NumberFormatException e) {
return false;
}
}
}

View File

@@ -507,7 +507,7 @@ public class HistoryResultServiceImpl implements HistoryResultService {
case 22:
//负序电流
sql = "SELECT time as time, i_neg as aValue ," + InfluxDBTableConstant.PHASIC_TYPE + " FROM data_i WHERE " + stringBuilder +
" and (phasic_type ='A' or phasic_type ='B' or phasic_type ='C') order by time asc tz('Asia/Shanghai');";
" and phasic_type ='T' order by time asc tz('Asia/Shanghai');";
topLimit = overlimit.getINeg();
phasicType.add("负序电流");
unit.add("A");
@@ -526,7 +526,7 @@ public class HistoryResultServiceImpl implements HistoryResultService {
case 40:
//谐波电压含有率
if (number == 1) {
sql = "SELECT time as time, v as aValue ," + InfluxDBTableConstant.PHASIC_TYPE + " FROM data_harmrate_v WHERE " + stringBuilder +
sql = "SELECT time as time, v_1 as aValue ," + InfluxDBTableConstant.PHASIC_TYPE + " FROM data_harmrate_v WHERE " + stringBuilder +
" and (phasic_type ='A' or phasic_type ='B' or phasic_type ='C') order by time asc tz('Asia/Shanghai');";
} else {
sql = "SELECT time as time, v_" + number + " as aValue ," + InfluxDBTableConstant.PHASIC_TYPE + " FROM data_harmrate_v WHERE " + stringBuilder +
@@ -550,7 +550,7 @@ public class HistoryResultServiceImpl implements HistoryResultService {
case 41:
//谐波电流含有率
if (number == 1) {
sql = "SELECT time as time, i as aValue ," + InfluxDBTableConstant.PHASIC_TYPE + " FROM data_harmrate_i WHERE " + stringBuilder +
sql = "SELECT time as time, i_1 as aValue ," + InfluxDBTableConstant.PHASIC_TYPE + " FROM data_harmrate_i WHERE " + stringBuilder +
" and (phasic_type ='A' or phasic_type ='B' or phasic_type ='C') order by time asc tz('Asia/Shanghai');";
} else {
sql = "SELECT time as time, i_" + number + " as aValue ," + InfluxDBTableConstant.PHASIC_TYPE + " FROM data_harmrate_i WHERE " + stringBuilder +
@@ -565,7 +565,7 @@ public class HistoryResultServiceImpl implements HistoryResultService {
case 42:
//谐波电压幅值
if (number == 1) {
sql = "SELECT time as time, v as aValue ," + InfluxDBTableConstant.PHASIC_TYPE + " FROM data_v WHERE " + stringBuilder +
sql = "SELECT time as time, v_1 as aValue ," + InfluxDBTableConstant.PHASIC_TYPE + " FROM data_v WHERE " + stringBuilder +
" and (phasic_type ='A' or phasic_type ='B' or phasic_type ='C') order by time asc tz('Asia/Shanghai');";
} else {
sql = "SELECT time as time, v_" + number + " as aValue ," + InfluxDBTableConstant.PHASIC_TYPE + " FROM data_v WHERE " + stringBuilder +
@@ -590,7 +590,7 @@ public class HistoryResultServiceImpl implements HistoryResultService {
case 43:
//谐波电流幅值
if (number == 1) {
sql = "SELECT time as time, i as aValue ," + InfluxDBTableConstant.PHASIC_TYPE + " FROM data_i WHERE " + stringBuilder +
sql = "SELECT time as time, i_1 as aValue ," + InfluxDBTableConstant.PHASIC_TYPE + " FROM data_i WHERE " + stringBuilder +
" and (phasic_type ='A' or phasic_type ='B' or phasic_type ='C') order by time asc tz('Asia/Shanghai');";
} else {
sql = "SELECT time as time, i_" + number + " as aValue ," + InfluxDBTableConstant.PHASIC_TYPE + " FROM data_i WHERE " + stringBuilder +
@@ -608,7 +608,7 @@ public class HistoryResultServiceImpl implements HistoryResultService {
case 44:
//谐波电压相角
if (number == 1) {
sql = "SELECT time as time, v as aValue ," + InfluxDBTableConstant.PHASIC_TYPE + " FROM data_harmphasic_v WHERE " + stringBuilder +
sql = "SELECT time as time, v_1 as aValue ," + InfluxDBTableConstant.PHASIC_TYPE + " FROM data_harmphasic_v WHERE " + stringBuilder +
" and (phasic_type ='A' or phasic_type ='B' or phasic_type ='C') order by time asc tz('Asia/Shanghai');";
} else {
sql = "SELECT time as time, v_" + number + " as aValue ," + InfluxDBTableConstant.PHASIC_TYPE + " FROM data_harmphasic_v WHERE " + stringBuilder +
@@ -629,7 +629,7 @@ public class HistoryResultServiceImpl implements HistoryResultService {
case 45:
//谐波电流相角
if (number == 1) {
sql = "SELECT time as time, i as aValue ," + InfluxDBTableConstant.PHASIC_TYPE + " FROM data_harmphasic_i WHERE " + stringBuilder +
sql = "SELECT time as time, i_1 as aValue ," + InfluxDBTableConstant.PHASIC_TYPE + " FROM data_harmphasic_i WHERE " + stringBuilder +
" and (phasic_type ='A' or phasic_type ='B' or phasic_type ='C') order by time asc tz('Asia/Shanghai');";
} else {
sql = "SELECT time as time, i_" + number + " as aValue ," + InfluxDBTableConstant.PHASIC_TYPE + " FROM data_harmphasic_i WHERE " + stringBuilder +
@@ -643,9 +643,13 @@ public class HistoryResultServiceImpl implements HistoryResultService {
break;
case 46:
//间谐波电压含有率
sql = "SELECT time as time, v_" + number + " as aValue ," + InfluxDBTableConstant.PHASIC_TYPE + " FROM data_inharmrate_v WHERE " + stringBuilder +
sql = "SELECT time as time, v_" + number + " as aValue ," + InfluxDBTableConstant.PHASIC_TYPE + " FROM data_inharm_v WHERE " + stringBuilder +
" and (phasic_type ='A' or phasic_type ='B' or phasic_type ='C') order by time asc tz('Asia/Shanghai');";
if(number<17){
topLimit = PubUtils.getValueByMethod(overlimit, "getInuharm", number);
}else {
topLimit = 0.0f;
}
if (ptType == 0) {
phasicType.add("A相");
phasicType.add("B相");
@@ -660,7 +664,7 @@ public class HistoryResultServiceImpl implements HistoryResultService {
break;
case 47:
//间谐波电流含有率
sql = "SELECT time as time, i_" + number + " as aValue ," + InfluxDBTableConstant.PHASIC_TYPE + " FROM data_inharmrate_i WHERE " + stringBuilder +
sql = "SELECT time as time, i_" + number + " as aValue ," + InfluxDBTableConstant.PHASIC_TYPE + " FROM data_inharm_i WHERE " + stringBuilder +
" and (phasic_type ='A' or phasic_type ='B' or phasic_type ='C') order by time asc tz('Asia/Shanghai');";
phasicType.add("A相");
phasicType.add("B相");
@@ -868,6 +872,7 @@ public class HistoryResultServiceImpl implements HistoryResultService {
phasicType.add("CA相");
}
targetName = "电压波动";
unit.add("%");
break;
default:
break;
@@ -1016,7 +1021,7 @@ public class HistoryResultServiceImpl implements HistoryResultService {
case 46:
//间谐波电压含有率
sql = "SELECT time as time, v_" + number + " as aValue FROM data_inharmrate_v WHERE " + stringBuilder +
sql = "SELECT time as time, v_" + number + " as aValue FROM data_inharm_v WHERE " + stringBuilder +
" order by time asc tz('Asia/Shanghai');";
topLimit = PubUtils.getValueByMethod(overlimit, "getInuharm", number);
unit.add("%");

View File

@@ -0,0 +1,572 @@
package com.njcn.harmonic.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
import com.njcn.common.pojo.enums.common.ServerEnum;
import com.njcn.common.utils.HarmonicTimesUtil;
import com.njcn.common.utils.PubUtils;
import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
import com.njcn.device.biz.pojo.dto.DeptGetChildrenMoreDTO;
import com.njcn.device.biz.pojo.dto.LineDevGetDTO;
import com.njcn.device.biz.pojo.param.DeptGetLineParam;
import com.njcn.device.biz.pojo.po.Overlimit;
import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.harmonic.api.RStatLimitRateDClient;
import com.njcn.harmonic.mapper.PmsLineWarningMapper;
import com.njcn.harmonic.pojo.param.OnlineParam;
import com.njcn.harmonic.pojo.param.RStatLimitQueryParam;
import com.njcn.harmonic.pojo.po.PmsLineWarning;
import com.njcn.harmonic.pojo.po.day.RStatLimitRateDPO;
import com.njcn.harmonic.pojo.vo.LineLimitDetailVo;
import com.njcn.harmonic.pojo.vo.PmsOnlineVo;
import com.njcn.harmonic.pojo.vo.RStatLimitTargetVO;
import com.njcn.harmonic.service.IPmsLineWarningService;
import com.njcn.influx.constant.InfluxDbSqlConstant;
import com.njcn.influx.imapper.*;
import com.njcn.influx.pojo.po.*;
import com.njcn.influx.query.InfluxQueryWrapper;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.enums.DicDataTypeEnum;
import com.njcn.system.pojo.po.DictData;
import com.njcn.user.api.DeptFeignClient;
import com.njcn.user.pojo.po.Dept;
import com.njcn.web.factory.PageFactory;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.lang.reflect.Method;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* <p>
* 监测点每日稳态指标超标天数统计表 服务实现类
* </p>
*
* @author xy
* @since 2024-06-17
*/
@Service
@RequiredArgsConstructor
public class PmsLineWarningServiceImpl extends MppServiceImpl<PmsLineWarningMapper, PmsLineWarning> implements IPmsLineWarningService {
private final DicDataFeignClient dicDataFeignClient;
private final RStatLimitRateDClient limitRateDClient;
private final CommTerminalGeneralClient commTerminalGeneralClient;
private final LineFeignClient lineFeignClient;
private final DeptFeignClient deptFeignClient;
private final DataVMapper dataVMapper;
private final DataIMapper dataIMapper;
private final DataHarmRateVMapper dataHarmRateVMapper;
private final DataInHarmVMapper dataInHarmVMapper;
private final DataPltMapper dataPltMapper;
@Override
@Transactional(rollbackFor = Exception.class)
public void addHeBeiNorthLineWarning(String startTime, String endTime) {
List<PmsLineWarning> result = new ArrayList<>();
//获取指标集合(10个指标)
List<DictData> dataList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.STEADY_STATIS.getCode()).getData();
Map<String, DictData> targetMap = dataList.stream().collect(Collectors.toMap(DictData::getCode, Function.identity()));
//获取监测点和部门表关系
Dept data = deptFeignClient.getRootDept().getData();
DeptGetLineParam deptGetLineParam = new DeptGetLineParam();
deptGetLineParam.setDeptId(data.getId());
List<DeptGetChildrenMoreDTO> list = commTerminalGeneralClient.deptGetLine(deptGetLineParam).getData();
List<LineDevGetDTO> dtoList = new ArrayList<>();
for (DeptGetChildrenMoreDTO dto : list) {
if (!CollectionUtils.isEmpty(dto.getLineBaseList())) {
dtoList = Stream.concat(dtoList.stream(), dto.getLineBaseList().stream())
.collect(Collectors.collectingAndThen(Collectors.toSet(), ArrayList::new));
}
}
if (!CollectionUtils.isEmpty(dtoList)) {
//获取监测点按时间统计越限天数
LocalDate firstDayOfMonth = Objects.isNull(startTime) ? LocalDate.now().minusDays(1).with(TemporalAdjusters.firstDayOfMonth()) : LocalDate.parse(startTime);
String date = Objects.isNull(startTime) ? DateUtil.format(firstDayOfMonth.atStartOfDay(), DatePattern.NORM_DATE_PATTERN) : startTime;
String endDate = Objects.isNull(endTime) ? DateUtil.format(LocalDateTime.now().minusDays(1), DatePattern.NORM_DATE_PATTERN) : endTime;
RStatLimitQueryParam rStatLimitQueryParam = new RStatLimitQueryParam(null, date, endDate);
List<RStatLimitTargetVO> limitTarget = limitRateDClient.monitorOverLimitDays(rStatLimitQueryParam).getData();
Map<String, RStatLimitTargetVO> limitMap = limitTarget.stream().collect(Collectors.toMap(RStatLimitTargetVO::getLineId, Function.identity()));
for (LineDevGetDTO item : dtoList) {
if (Objects.isNull(limitMap.get(item.getPointId()))) {
continue;
}
//频率偏差
PmsLineWarning l1 = overData(firstDayOfMonth, item.getPointId(), item.getUnitId(), targetMap.get(DicDataEnum.FREQUENCY_DEV.getCode()).getId(), limitMap.get(item.getPointId()).getFreqDevOvertime());
//电压偏差
PmsLineWarning l2 = overData(firstDayOfMonth, item.getPointId(), item.getUnitId(), targetMap.get(DicDataEnum.VOLTAGE_DEV.getCode()).getId(), limitMap.get(item.getPointId()).getVoltageDevOvertime());
//长时闪变
PmsLineWarning l3 = overData(firstDayOfMonth, item.getPointId(), item.getUnitId(), targetMap.get(DicDataEnum.FLICKER.getCode()).getId(), limitMap.get(item.getPointId()).getFlickerOvertime());
//谐波电压
PmsLineWarning l4 = overData(firstDayOfMonth, item.getPointId(), item.getUnitId(), targetMap.get(DicDataEnum.HARMONIC_VOLTAGE.getCode()).getId(), limitMap.get(item.getPointId()).getUharmOvertime());
//谐波电流
PmsLineWarning l5 = overData(firstDayOfMonth, item.getPointId(), item.getUnitId(), targetMap.get(DicDataEnum.HARMONIC_CURRENT.getCode()).getId(), limitMap.get(item.getPointId()).getIharmOvertime());
//间谐波电压
PmsLineWarning l6 = overData(firstDayOfMonth, item.getPointId(), item.getUnitId(), targetMap.get(DicDataEnum.INTERHARMONIC_VOLTAGE.getCode()).getId(), limitMap.get(item.getPointId()).getInuharmOvertime());
//负序电压不平衡度
PmsLineWarning l7 = overData(firstDayOfMonth, item.getPointId(), item.getUnitId(), targetMap.get(DicDataEnum.PHASE_VOLTAGE.getCode()).getId(), limitMap.get(item.getPointId()).getUbalanceOvertime());
//负序电流
PmsLineWarning l8 = overData(firstDayOfMonth, item.getPointId(), item.getUnitId(), targetMap.get(DicDataEnum.NEG_CURRENT.getCode()).getId(), limitMap.get(item.getPointId()).getINegOvertime());
//电压总谐波畸变率
PmsLineWarning l9 = overData(firstDayOfMonth, item.getPointId(), item.getUnitId(), targetMap.get(DicDataEnum.THD_V.getCode()).getId(), limitMap.get(item.getPointId()).getUaberranceOvertime());
//总稳态指标
PmsLineWarning l10 = overData(firstDayOfMonth, item.getPointId(), item.getUnitId(), targetMap.get(DicDataEnum.TOTAL_INDICATOR.getCode()).getId(), limitMap.get(item.getPointId()).getAllOvertime());
result.addAll(Arrays.asList(l1, l2, l3, l4, l5, l6, l7, l8, l9, l10));
}
this.saveOrUpdateBatchByMultiId(result);
}
}
@Override
public Page<PmsOnlineVo> getLineWarningList(OnlineParam param) {
DeptGetLineParam deptGetLineParam = new DeptGetLineParam();
deptGetLineParam.setDeptId(param.getDeptId());
deptGetLineParam.setServerName(ServerEnum.HARMONIC.getName());
List<DeptGetChildrenMoreDTO> list = commTerminalGeneralClient.deptGetLine(deptGetLineParam).getData();
List<String> lineList = list.stream()
.flatMap(dto -> dto.getLineBaseList().stream().map(LineDevGetDTO::getPointId))
.distinct()
.collect(Collectors.toList());
QueryWrapper<PmsLineWarning> queryWrapper = new QueryWrapper<>();
queryWrapper.between("p1.alarm_time", param.getSearchBeginTime(), param.getSearchEndTime());
//监测点id
if (CollUtil.isNotEmpty(lineList)) {
queryWrapper.in("p1.line_id", lineList);
}
//监测点类型
if (StringUtils.isNotBlank(param.getLineType())) {
if (Objects.equals(param.getLineType(),"0")) {
queryWrapper.eq("p2.Power_Flag", "101");
} else {
queryWrapper.eq("p2.Power_Flag", "102");
}
}
//指标判断
if (CollUtil.isNotEmpty(param.getTargetList())) {
queryWrapper.in("p1.target_type", param.getTargetList());
}
if (Objects.nonNull(param.getAlarmThreshold())) {
queryWrapper.ge("p1.over_limit_day", param.getAlarmThreshold());
}
queryWrapper.orderBy(true, true, "p2.Org_Name", "p2.Powerr_Name", "p3.`Name`");
return this.baseMapper.page(new Page<>(PageFactory.getPageNum(param), PageFactory.getPageSize(param)), queryWrapper);
}
@Override
public List<LineLimitDetailVo> getOverLimitDetail(OnlineParam.DetailParam param) {
List<LineLimitDetailVo> result = new ArrayList<>();
String targetCode = dicDataFeignClient.getDicDataById(param.getTargetId()).getData().getCode();
//获取监测点统计间隔
Integer timeInterval = commTerminalGeneralClient.getMonitorDetail(param.getLineId()).getData().getInterval();
//获取限值
Overlimit overlimit = commTerminalGeneralClient.getOverLimitData(param.getLineId()).getData();
//处理数据
List<LineLimitDetailVo> data = chanelTarget(param, overlimit, timeInterval, targetCode);
if (CollUtil.isNotEmpty(data)) {
result = data.stream().sorted(Comparator.comparing(LineLimitDetailVo::getTime)).collect(Collectors.toList());
}
return result;
}
//指标数据处理
public List<LineLimitDetailVo> chanelTarget(OnlineParam.DetailParam param, Overlimit overlimit, Integer timeInterval, String targetCode) {
List<LineLimitDetailVo> result = new ArrayList<>(), finalList = new ArrayList<>();
//频率偏差
if (Objects.equals(targetCode, DicDataEnum.FREQUENCY_DEV.getCode()) || Objects.equals(targetCode, DicDataEnum.TOTAL_INDICATOR.getCode())) {
List<RStatLimitRateDPO> list = limitRateDClient.getOverData(param.getLineId(), param.getSearchBeginTime(), param.getSearchEndTime(), 1).getData();
if (CollUtil.isNotEmpty(list)) {
list.forEach(item -> {
String time = item.getTime().format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN));
double maxData = getFreqDev(param.getLineId()
, time + " 00:00:00"
, time + " 23:59:59"
).get(0).getFreqDev();
channelEachData(item, maxData > 0 ? overlimit.getFreqDev() : -overlimit.getFreqDev(), "getFreqDev", result, DicDataEnum.FREQUENCY_DEV.getName(), timeInterval, maxData);
});
}
}
//电压偏差
if (Objects.equals(targetCode, DicDataEnum.VOLTAGE_DEV.getCode()) || Objects.equals(targetCode, DicDataEnum.TOTAL_INDICATOR.getCode())) {
List<RStatLimitRateDPO> list = limitRateDClient.getOverData(param.getLineId(), param.getSearchBeginTime(), param.getSearchEndTime(), 2).getData();
if (CollUtil.isNotEmpty(list)) {
list.forEach(item -> {
Float overLimit;
Double maxData;
String time = item.getTime().format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN));
List<DataV> voltageList = getVoltageDev(param.getLineId()
, time + " 00:00:00"
, time + " 23:59:59"
);
List<Double> voltage = voltageList.stream().map(DataV::getVuDev).collect(Collectors.toList());
if (Math.abs(voltage.get(0)) >= Math.abs(voltage.get(1))) {
overLimit = overlimit.getUvoltageDev();
maxData = voltage.get(0);
} else {
overLimit = overlimit.getVoltageDev();
maxData = voltage.get(1);
}
channelEachData(item, overLimit, "getVoltageDev", result, DicDataEnum.VOLTAGE_DEV.getName(), timeInterval, maxData);
});
}
}
//长时闪变
if (Objects.equals(targetCode, DicDataEnum.FLICKER.getCode()) || Objects.equals(targetCode, DicDataEnum.TOTAL_INDICATOR.getCode())) {
List<RStatLimitRateDPO> list = limitRateDClient.getOverData(param.getLineId(), param.getSearchBeginTime(), param.getSearchEndTime(), 3).getData();
if (CollUtil.isNotEmpty(list)) {
list.forEach(item -> {
String time = item.getTime().format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN));
double maxData = getFlicker(param.getLineId()
, time + " 00:00:00"
, time + " 23:59:59"
).get(0).getPlt();
channelEachData(item, overlimit.getFlicker(), "getFlicker", result, DicDataEnum.FLICKER.getName(), timeInterval, maxData);
});
}
}
//电压总谐波畸变率
if (Objects.equals(targetCode, DicDataEnum.THD_V.getCode())) {
List<RStatLimitRateDPO> list = limitRateDClient.getOverData(param.getLineId(), param.getSearchBeginTime(), param.getSearchEndTime(), 4).getData();
if (CollUtil.isNotEmpty(list)) {
list.forEach(item -> {
String time = item.getTime().format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN));
double maxData = getVThd(param.getLineId()
, time + " 00:00:00"
, time + " 23:59:59"
).get(0).getVThd();
channelEachData(item, overlimit.getUaberrance(), "getUaberrance", result, DicDataEnum.THD_V.getName(), timeInterval, maxData);
});
}
}
//谐波电压
if (Objects.equals(targetCode, DicDataEnum.HARMONIC_VOLTAGE.getCode()) || Objects.equals(targetCode, DicDataEnum.TOTAL_INDICATOR.getCode())) {
//电压总谐波畸变率
List<RStatLimitRateDPO> list = limitRateDClient.getOverData(param.getLineId(), param.getSearchBeginTime(), param.getSearchEndTime(), 4).getData();
if (CollUtil.isNotEmpty(list)) {
list.forEach(item -> {
String time = item.getTime().format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN));
double maxData = getVThd(param.getLineId()
, time + " 00:00:00"
, time + " 23:59:59"
).get(0).getVThd();
channelEachData(item, overlimit.getUaberrance(), "getUaberrance", result, DicDataEnum.THD_V.getName(), timeInterval, maxData);
});
}
//谐波电压含有率2~25次
List<RStatLimitRateDPO> list2 = limitRateDClient.getOverData(param.getLineId(), param.getSearchBeginTime(), param.getSearchEndTime(), 7).getData();
if (CollUtil.isNotEmpty(list2)) {
list2.forEach(item -> {
String time = item.getTime().format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN));
DataHarmRateV dataHarmRateV = getDataHarmRateV(param.getLineId()
, time + " 00:00:00"
, time + " 23:59:59").get(0);
channelHarmonicData(dataHarmRateV, null, null, item, overlimit, result, "getUharm", DicDataEnum.HARMONIC_VOLTAGE.getName(), timeInterval, 2, 25);
});
}
}
//谐波电流
if (Objects.equals(targetCode, DicDataEnum.HARMONIC_CURRENT.getCode()) || Objects.equals(targetCode, DicDataEnum.TOTAL_INDICATOR.getCode())) {
List<RStatLimitRateDPO> list = limitRateDClient.getOverData(param.getLineId(), param.getSearchBeginTime(), param.getSearchEndTime(), 8).getData();
if (CollUtil.isNotEmpty(list)) {
list.forEach(item -> {
String time = item.getTime().format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN));
DataI dataI = getDataI(param.getLineId()
, time + " 00:00:00"
, time + " 23:59:59").get(0);
channelHarmonicData(null, dataI, null, item, overlimit, result, "getIharm", DicDataEnum.HARMONIC_CURRENT.getName(), timeInterval, 2, 25);
});
}
}
//间谐波电压
if (Objects.equals(targetCode, DicDataEnum.INTERHARMONIC_VOLTAGE.getCode()) || Objects.equals(targetCode, DicDataEnum.TOTAL_INDICATOR.getCode())) {
List<RStatLimitRateDPO> list = limitRateDClient.getOverData(param.getLineId(), param.getSearchBeginTime(), param.getSearchEndTime(), 9).getData();
if (CollUtil.isNotEmpty(list)) {
list.forEach(item -> {
String time = item.getTime().format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN));
DataInHarmV dataInHarmV = getDataInHarmV(param.getLineId()
, time + " 00:00:00"
, time + " 23:59:59").get(0);
channelHarmonicData(null, null, dataInHarmV, item, overlimit, result, "getInuharm", DicDataEnum.INTERHARMONIC_VOLTAGE.getName(), timeInterval, 1, 16);
});
}
}
//负序电压不平衡度
if (Objects.equals(targetCode, DicDataEnum.PHASE_VOLTAGE.getCode()) || Objects.equals(targetCode, DicDataEnum.TOTAL_INDICATOR.getCode())) {
List<RStatLimitRateDPO> list = limitRateDClient.getOverData(param.getLineId(), param.getSearchBeginTime(), param.getSearchEndTime(), 5).getData();
if (CollUtil.isNotEmpty(list)) {
list.forEach(item -> {
String time = item.getTime().format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN));
double maxData = getUnbalance(param.getLineId()
, time + " 00:00:00"
, time + " 23:59:59"
).get(0).getVUnbalance();
channelEachData(item, overlimit.getUbalance(), "getUbalance", result, DicDataEnum.PHASE_VOLTAGE.getName(), timeInterval, maxData);
});
}
}
//负序电流
if (Objects.equals(targetCode, DicDataEnum.NEG_CURRENT.getCode()) || Objects.equals(targetCode, DicDataEnum.TOTAL_INDICATOR.getCode())) {
List<RStatLimitRateDPO> list = limitRateDClient.getOverData(param.getLineId(), param.getSearchBeginTime(), param.getSearchEndTime(), 6).getData();
if (CollUtil.isNotEmpty(list)) {
list.forEach(item -> {
String time = item.getTime().format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN));
double maxData = getINeg(param.getLineId()
, time + " 00:00:00"
, time + " 23:59:59"
).get(0).getINeg();
channelEachData(item, overlimit.getINeg(), "getINeg", result, DicDataEnum.NEG_CURRENT.getName(), timeInterval, maxData);
});
}
}
if (CollUtil.isNotEmpty(result)) {
Map<LocalDate, List<LineLimitDetailVo>> map = result.stream().collect(Collectors.groupingBy(LineLimitDetailVo::getTime, LinkedHashMap::new, Collectors.toList()));
map.forEach((k, v) -> {
StringBuilder describe = new StringBuilder();
LineLimitDetailVo lineLimitDetailVo = new LineLimitDetailVo();
lineLimitDetailVo.setTime(k);
v.forEach(item -> {
describe.append(item.getOverLimitInfo());
});
lineLimitDetailVo.setOverLimitInfo(describe.toString());
finalList.add(lineLimitDetailVo);
});
}
return finalList;
}
//处理单指标
public void channelEachData(RStatLimitRateDPO dpo, float limit, String getColum, List<LineLimitDetailVo> result, String targetName, Integer timeInterval, double maxData) {
try {
Class<?> clazz = dpo.getClass();
String methodName = getColum + "Overtime";
Method method;
method = clazz.getMethod(methodName);
int value = (int) method.invoke(dpo);
LineLimitDetailVo vo = new LineLimitDetailVo();
vo.setTime(dpo.getTime());
vo.setOverLimitInfo(targetName + "最大幅值:" + PubUtils.doubleRound(2, maxData) + ",限值:" + limit + ",超标时间:" + value * timeInterval + "分钟;");
result.add(vo);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
//处理谐波数据 谐波电压、谐波电流、间谐波电压
public void channelHarmonicData(DataHarmRateV dataHarmRateV, DataI dataI, DataInHarmV dataInHarmV, RStatLimitRateDPO dpo, Overlimit overlimit, List<LineLimitDetailVo> result, String getColum, String targetName, Integer timeInterval, Integer startTimes, Integer endTimes) {
LinkedHashMap<Integer, Integer> overMap = new LinkedHashMap<>();
StringBuilder describe = new StringBuilder();
LineLimitDetailVo vo = new LineLimitDetailVo();
vo.setTime(dpo.getTime());
//查看具体哪几次超标
Class<?> clazz = dpo.getClass();
for (int i = startTimes; i <= endTimes; i++) {
String methodName = getColum + i + "Overtime";
try {
Method method = clazz.getMethod(methodName);
int value = (int) method.invoke(dpo);
if (value > 0) {
overMap.put(i, value);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Class<?> clazz2 = null;
String targetName2 = null;
double value2;
if (Objects.nonNull(dataHarmRateV)) {
clazz2 = dataHarmRateV.getClass();
targetName2 = "getV";
} else if (Objects.nonNull(dataI)) {
clazz2 = dataI.getClass();
targetName2 = "getI";
} else if (Objects.nonNull(dataInHarmV)) {
clazz2 = dataInHarmV.getClass();
targetName2 = "getV";
}
for (Integer key : overMap.keySet()) {
int value = overMap.get(key);
String methodName = targetName2 + key;
Method method;
try {
method = clazz2.getMethod(methodName);
if (Objects.nonNull(dataHarmRateV)) {
value2 = (double) method.invoke(dataHarmRateV);
describe.append(key).append("").append(targetName).append("CP95值最大幅值:").append(PubUtils.doubleRound(2, value2)).append("%,限值:").append(getOverLimitData(overlimit, getColum, key)).append("%,超标时间:").append(value * timeInterval).append("分钟;");
} else if (Objects.nonNull(dataI)) {
value2 = (double) method.invoke(dataI);
describe.append(key).append("").append(targetName).append("CP95值最大幅值:").append(PubUtils.doubleRound(2, value2)).append("%,限值:").append(getOverLimitData(overlimit, getColum, key)).append("%,超标时间:").append(value * timeInterval).append("分钟;");
} else if (Objects.nonNull(dataInHarmV)) {
value2 = (double) method.invoke(dataInHarmV);
describe.append((key - 0.5)).append("").append(targetName).append("CP95值最大幅值:").append(PubUtils.doubleRound(2, value2)).append("%,限值:").append(getOverLimitData(overlimit, getColum, key)).append("%,超标时间:").append(value * timeInterval).append("分钟;");
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
vo.setOverLimitInfo(describe.toString().trim());
result.add(vo);
}
public PmsLineWarning overData(LocalDate date, String lineId, String deptId, String codeId, Integer overDays) {
PmsLineWarning lineWarning = new PmsLineWarning();
lineWarning.setAlarmTime(date);
lineWarning.setDeptId(deptId);
lineWarning.setLineId(lineId);
lineWarning.setTargetType(codeId);
lineWarning.setOverLimitDay(overDays);
return lineWarning;
}
private float getOverLimitData(Overlimit overlimit, String targetName, Integer times) {
float result;
Class<?> clazz = overlimit.getClass();
String methodName = targetName + times;
try {
Method method = clazz.getMethod(methodName);
result = (float) method.invoke(overlimit);
} catch (Exception e) {
throw new RuntimeException(e);
}
return result;
}
/**
* 获取频率偏差-日最大值-最大值
*/
public List<DataV> getFreqDev(String lineIndex, String startTime, String endTime) {
InfluxQueryWrapper influxQueryWrapper2 = new InfluxQueryWrapper(DataV.class);
influxQueryWrapper2.eq(DataV::getLineId, lineIndex)
.eq(DataV::getValueType, InfluxDbSqlConstant.MAX)
.eq(DataV::getPhaseType, "T")
.max(DataV::getFreqDev)
.between(DataV::getTime, startTime, endTime);
return dataVMapper.getStatisticsByWraper(influxQueryWrapper2);
}
/**
* 获取电压偏差-日最大值&&日最小值 日最大值的最大值 日最小值的最小值
*/
public List<DataV> getVoltageDev(String lineIndex, String startTime, String endTime) {
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataV.class);
influxQueryWrapper.eq(DataV::getLineId, lineIndex)
.eq(DataV::getValueType, InfluxDbSqlConstant.MIN)
.regular(DataV::getPhaseType, Arrays.asList("A", "B", "C"))
.min(DataV::getVuDev)
.between(DataV::getTime, startTime, endTime);
List<DataV> result = new ArrayList<>(dataVMapper.getStatisticsByWraper(influxQueryWrapper));
InfluxQueryWrapper influxQueryWrapper2 = new InfluxQueryWrapper(DataV.class);
influxQueryWrapper2.eq(DataV::getLineId, lineIndex)
.eq(DataV::getValueType, InfluxDbSqlConstant.MAX)
.regular(DataV::getPhaseType, Arrays.asList("A", "B", "C"))
.max(DataV::getVuDev)
.between(DataV::getTime, startTime, endTime);
result.addAll(dataVMapper.getStatisticsByWraper(influxQueryWrapper2));
return result;
}
/**
* 获取长时闪变-日最大值-最大值
*/
public List<DataPlt> getFlicker(String lineIndex, String startTime, String endTime) {
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataPlt.class);
influxQueryWrapper.eq(DataPlt::getLineId, lineIndex)
.regular(DataPlt::getPhaseType, Arrays.asList("A", "B", "C"))
.max(DataPlt::getPlt)
.between(DataPlt::getTime, startTime, endTime);
return dataPltMapper.getStatisticsByWraper(influxQueryWrapper);
}
/**
* 获取电压总谐波畸变率-日CP95-最大值
*/
public List<DataV> getVThd(String lineIndex, String startTime, String endTime) {
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataV.class);
influxQueryWrapper.eq(DataV::getLineId, lineIndex)
.eq(DataV::getValueType, InfluxDbSqlConstant.CP95)
.regular(DataV::getPhaseType, Arrays.asList("A", "B", "C"))
.max(DataV::getVThd)
.between(DataV::getTime, startTime, endTime);
return dataVMapper.getStatisticsByWraper(influxQueryWrapper);
}
/**
* 获取负序电压不平衡度-日最大值-最大值
*/
public List<DataV> getUnbalance(String lineIndex, String startTime, String endTime) {
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataV.class);
influxQueryWrapper.eq(DataV::getLineId, lineIndex)
.eq(DataV::getValueType, InfluxDbSqlConstant.MAX)
.eq(DataV::getPhaseType, "T")
.max(DataV::getVUnbalance)
.between(DataV::getTime, startTime, endTime);
return dataVMapper.getStatisticsByWraper(influxQueryWrapper);
}
/**
* 获取负序电流-日最大值-最大值
*/
public List<DataI> getINeg(String lineIndex, String startTime, String endTime) {
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataI.class);
influxQueryWrapper.eq(DataI::getLineId, lineIndex)
.eq(DataI::getValueType, InfluxDbSqlConstant.MAX)
.eq(DataI::getPhaseType, "T")
.max(DataI::getINeg)
.between(DataI::getTime, startTime, endTime);
return dataIMapper.getStatisticsByWraper(influxQueryWrapper);
}
/**
* 获取谐波电压含有率 2~25次数据
*/
public List<DataHarmRateV> getDataHarmRateV(String lineIndex, String startTime, String endTime) {
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmRateV.class);
influxQueryWrapper.maxSamePrefixAndSuffix(InfluxDbSqlConstant.V, "", HarmonicTimesUtil.harmonicTimesList(2, 25, 1));
influxQueryWrapper.eq(DataHarmRateV::getLineId, lineIndex)
.eq(DataHarmRateV::getValueType, InfluxDbSqlConstant.CP95)
.regular(DataHarmRateV::getPhaseType, Arrays.asList("A", "B", "C"))
.between(DataHarmRateV::getTime, startTime, endTime);
return dataHarmRateVMapper.getStatisticsByWraper(influxQueryWrapper);
}
/**
* 获取谐波电流含有率 2~25次数据
*/
public List<DataI> getDataI(String lineIndex, String startTime, String endTime) {
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataI.class);
influxQueryWrapper.maxSamePrefixAndSuffix(InfluxDbSqlConstant.I, "", HarmonicTimesUtil.harmonicTimesList(2, 25, 1));
influxQueryWrapper.eq(DataI::getLineId, lineIndex)
.eq(DataI::getValueType, InfluxDbSqlConstant.CP95)
.regular(DataI::getPhaseType, Arrays.asList("A", "B", "C"))
.between(DataI::getTime, startTime, endTime);
return dataIMapper.getStatisticsByWraper(influxQueryWrapper);
}
/**
* 获取间谐波电压含有率 2~25次数据
*/
public List<DataInHarmV> getDataInHarmV(String lineIndex, String startTime, String endTime) {
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataInHarmV.class);
influxQueryWrapper.maxSamePrefixAndSuffix(InfluxDbSqlConstant.V, "", HarmonicTimesUtil.harmonicTimesList(1, 16, 1));
influxQueryWrapper.eq(DataInHarmV::getLineId, lineIndex)
.eq(DataInHarmV::getValueType, InfluxDbSqlConstant.CP95)
.regular(DataInHarmV::getPhaseType, Arrays.asList("A", "B", "C"))
.between(DataInHarmV::getTime, startTime, endTime);
return dataInHarmVMapper.getStatisticsByWraper(influxQueryWrapper);
}
}

View File

@@ -73,7 +73,7 @@ public class PmsTemProcessTrackServiceImpl extends ServiceImpl<PmsTemProcessTrac
PmsTemUserPO pmsTemUserPO = iPmsTemUserService.getById(updatePmsTemProcessTrackParam.getTempUserDossierId());
pmsTemProcessTrackPO.setTempUserDossierName(pmsTemUserPO.getConsName());
PmsTemProcessTrackPO tem = this.getById(updatePmsTemProcessTrackParam.getObjId());
PmsTemProcessTrackPO tem = this.getById(updatePmsTemProcessTrackParam.getTempUserDossierId());
if(Integer.valueOf(DicDataEnum.Has_Upload.getCode()).equals(tem.getUploadStatus())){
pmsTemProcessTrackPO.setUploadStatus(Integer.valueOf(DicDataEnum.Return_Upload.getCode()));
}

View File

@@ -103,7 +103,7 @@ public class PointStatisticalDataServiceImpl extends ServiceImpl<RUploadPointSta
}
list = list.stream().peek(item->item.setStationType(dictDataMap.get(item.getStationType()).getValue())).collect(Collectors.toList());
List<List<RUploadPointStatisticalDataD>> partition = ListUtils.partition(list, 100);
List<List<RUploadPointStatisticalDataD>> partition = ListUtils.partition(list, 50);
StrBuilder resultLog = new StrBuilder();
AtomicBoolean resultFlag = new AtomicBoolean(true);
//分片上传

View File

@@ -5,6 +5,7 @@ import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.LocalDateTimeUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.utils.NjcnBeanUtil;
import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
import com.njcn.device.biz.pojo.po.Overlimit;
@@ -95,6 +96,43 @@ public class LimitRateServiceImpl extends MppServiceImpl<LimitRatePOMapper, Limi
list11.addAll(getDataPlt(pendingId, startTime, endTime));
}
if (CollectionUtils.isEmpty(overLimitList)) {
throw new BusinessException("限值表数据缺失");
}
if (CollectionUtils.isEmpty(list1)) {
throw new BusinessException("data_v allTime数据缺失");
}
if (CollectionUtils.isEmpty(list2)) {
throw new BusinessException("data_plt flickerAllTime数据缺失");
}
if (CollectionUtils.isEmpty(list3)) {
throw new BusinessException("data_harmrate_v 谐波数据缺失");
}
if (CollectionUtils.isEmpty(list4)) {
throw new BusinessException("data_I 谐波数据缺失");
}
if (CollectionUtils.isEmpty(list5)) {
throw new BusinessException("data_inharm_v 间谐波数据缺失");
}
if (CollectionUtils.isEmpty(list6)) {
throw new BusinessException("data_v 电压总谐波畸变率数据缺失");
}
if (CollectionUtils.isEmpty(list7)) {
throw new BusinessException("data_v 三相电压不平衡度数据缺失");
}
if (CollectionUtils.isEmpty(list8)) {
throw new BusinessException("data_I 负序电流数据缺失");
}
if (CollectionUtils.isEmpty(list9)) {
throw new BusinessException("data_v 频率偏差数据缺失");
}
if (CollectionUtils.isEmpty(list10)) {
throw new BusinessException("data_v 电压偏差数据缺失");
}
if (CollectionUtils.isEmpty(list11)) {
throw new BusinessException("data_plt 闪变数据缺失");
}
//数据处理,按监测点分组
Map<String,List<DataV>> map1 = list1.stream().collect(Collectors.groupingBy(DataV::getLineId));
Map<String,List<DataPlt>> map2 = list2.stream().collect(Collectors.groupingBy(DataPlt::getLineId));
@@ -909,7 +947,7 @@ public class LimitRateServiceImpl extends MppServiceImpl<LimitRatePOMapper, Limi
limitRate.setPhasicType (phasicType);
limitRate.setAllTime (allTime);
limitRate.setFlickerAllTime (flickerAllTime);
limitRate.setUAberranceOverTime (0);
limitRate.setUAberranceOverTime (thd);
limitRate.setINegOverTime (0);
limitRate.setFreqDevOverTime (0);
limitRate.setUHarm2OverTime (v2);
@@ -976,7 +1014,7 @@ public class LimitRateServiceImpl extends MppServiceImpl<LimitRatePOMapper, Limi
limitRate.setInuHarm14OverTime (uHarm14);
limitRate.setInuHarm15OverTime (uHarm15);
limitRate.setInuHarm16OverTime (uHarm16);
limitRate.setUBalanceOverTime (thd);
limitRate.setUBalanceOverTime (0);
limitRate.setVoltageDevOverTime (uDev);
limitRate.setFlickerOverTime (flicker);
return limitRate;
@@ -1310,7 +1348,7 @@ public class LimitRateServiceImpl extends MppServiceImpl<LimitRatePOMapper, Limi
limitRate.setPhasicType("T");
limitRate.setAllTime(allTime);
limitRate.setFlickerAllTime(flickerAllTime);
limitRate.setUAberranceOverTime(uAberrance);
limitRate.setUAberranceOverTime(thd);
limitRate.setINegOverTime(iNeg);
limitRate.setFreqDevOverTime(freqDev);
limitRate.setUHarm2OverTime(v2);
@@ -1377,7 +1415,7 @@ public class LimitRateServiceImpl extends MppServiceImpl<LimitRatePOMapper, Limi
limitRate.setInuHarm14OverTime(uHarm14);
limitRate.setInuHarm15OverTime(uHarm15);
limitRate.setInuHarm16OverTime(uHarm16);
limitRate.setUBalanceOverTime(thd);
limitRate.setUBalanceOverTime(uAberrance);
limitRate.setVoltageDevOverTime(uDev);
limitRate.setFlickerOverTime(flicker);
return limitRate;

View File

@@ -154,6 +154,19 @@ public class ProblemVO extends BaseEntity {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime discoveryTime;
@ApiModelProperty("告预警单id,当ifReleaseWarning为是时必填")
private String workAlarmId;
public String getWorkAlarmId() {
return workAlarmId;
}
public void setWorkAlarmId(String workAlarmId) {
this.workAlarmId = workAlarmId;
}
public void setProblemId(String problemId) {
if (StrUtil.isNotBlank(problemId)) {
this.problemId = problemId;

View File

@@ -17,6 +17,7 @@ public enum SupervisionResponseEnum {
*/
SUPERVISION_COMMON_ERROR("A00550","监督管理模块异常"),
IMPORT_SENSITIVE_USER_ERROR("A00550","导入敏感及重要用户失败"),
IMPORT_SENSITIVE_USER_DATA_ERROR("A00550","敏感及重要用户数据为空"),
IMPORT_SENSITIVE_REPORT_ERROR("A00550","导入干扰源用户失败"),
SUPERVISION_SERVICE_NOT_FOUND("A00550","业务实现类丢失,清查看类路径配置"),
DATA_NOT_EXISTS("A00550","数据不存在"),
@@ -24,6 +25,7 @@ public enum SupervisionResponseEnum {
NO_USER_REPORT_UPDATE("A00550","常态化干扰源用户管理信息更新失败,不存在该条信息"),
NO_DEPT_POWER("A00550","不能操作非自己部门创建的任务"),
IMPORT_DEV_ERROR("A00550","导入终端检测失败"),
IMPORT_DEV_DATA_ERROR("A00550","终端数据为空"),
DELETE_TO_BE_SUBMITTED("A00550","流程删除失败,只有待提交信息可删除!"),
EXISTENCE_OR_NOT("A00550","信息查询为空,请检查信息是否存在!"),
NAME_EXISTS("A00550","名称重复"),

View File

@@ -58,7 +58,7 @@ public class SensitiveUserSExcel implements Serializable {
@Excel(name = "工程预期投产日期(yyyy-MM-dd)", width = 30)
//@NotBlank(message = "工程预期投产日期不能为空")
@NotBlank(message = "工程预期投产日期不能为空")
private String expectedProductionDate;
@Excel(name = "电压等级", width = 30)

View File

@@ -58,7 +58,7 @@ public class UserReportManageController extends BaseController {
@PostMapping("/update")
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
@Operation(summary = "重新发起")
@ApiOperation("重新发起")
@ApiImplicitParam(name = "userReportParam", value = "实体参数", required = true)
public HttpResult<Object> updateUserReport(@RequestBody @Validated UserReportParam.UserReportUpdate userReportParam) {
String methodDescribe = getMethodDescribe("updateUserReport");

View File

@@ -52,6 +52,7 @@
left join supervision_temp_line_run_test
on supervision_temp_line_debug.id = supervision_temp_line_run_test.id
where supervision_temp_line_debug.status = 5
and (supervision_temp_line_run_test.state = 1 OR supervision_temp_line_run_test.state IS NULL)
and ${ew.sqlSegment}
</select>

View File

@@ -57,6 +57,7 @@ import com.njcn.web.utils.RequestUtil;
import com.njcn.web.utils.WebUtil;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -152,6 +153,10 @@ public class SupervisionDevMainReportPOServiceImpl extends ServiceImpl<Supervisi
@Override
public String updateDevReport(SupervisionDevMainReportParam.SupervisionDevMainReportParamUpdate supervisionDevMainReportParam) {
//校验ip
if (Objects.equals(supervisionDevMainReportParam.getSaveOrCheckflag(), "2")) {
checkIp(supervisionDevMainReportParam, !StringUtils.isEmpty(supervisionDevMainReportParam.getId()));
}
SupervisionDevMainReportPO supervisionDevMainReportPO = this.baseMapper.selectById(supervisionDevMainReportParam.getId());
//判断是否有权限操作
InstanceUtil.judgeUserPower(RequestUtil.getUserIndex(), supervisionDevMainReportPO.getCreateBy());
@@ -503,15 +508,20 @@ public class SupervisionDevMainReportPOServiceImpl extends ServiceImpl<Supervisi
params.setNeedVerify(true);
params.setStartSheetIndex(0);
params.setSheetNum(1);
List<SupervisionDevMainReportExcel> devExcels = new ArrayList<>();
List<SupervisionDevMainReportExcel> devExcels;
try {
ExcelImportResult<SupervisionDevMainReportExcel> sensitiveUserExcelExcelImportResult = ExcelImportUtil.importExcelMore(file.getInputStream(), SupervisionDevMainReportExcel.class, params);
//如果存在非法数据,将不合格的数据导出
if (sensitiveUserExcelExcelImportResult.isVerifyFail()) {
PoiUtil.exportFileByWorkbook(sensitiveUserExcelExcelImportResult.getFailWorkbook(), "非法数据.xlsx", response);
} else {
devExcels = sensitiveUserExcelExcelImportResult.getList();
List<SupervisionDevMainReportExcel> sensitiveUserExcelExcelImportResult = ExcelImportUtil.importExcel(file.getInputStream(), SupervisionDevMainReportExcel.class, params);
// 过滤掉空的数据
devExcels = sensitiveUserExcelExcelImportResult.stream().filter(x -> StringUtils.isNotBlank(x.getCity())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(devExcels)){
throw new BusinessException(SupervisionResponseEnum.IMPORT_DEV_DATA_ERROR);
}
//如果存在非法数据,将不合格的数据导出
// if (sensitiveUserExcelExcelImportResult.isVerifyFail()) {
// PoiUtil.exportFileByWorkbook(sensitiveUserExcelExcelImportResult.getFailWorkbook(), "非法数据.xlsx", response);
// } else {
// devExcels = sensitiveUserExcelExcelImportResult.getList();
// }
} catch (Exception e) {
throw new BusinessException(SupervisionResponseEnum.IMPORT_DEV_ERROR);
}

View File

@@ -110,6 +110,9 @@ public class SupervisionTempLineReportServiceImpl extends ServiceImpl<Supervisio
@Override
public String updateLineReport(SupervisionTempLineReportParam.SupervisionTempLineReportUpdate supervisionTempLineReportParam) {
if (Objects.equals(supervisionTempLineReportParam.getSaveOrCheckflag(), "2")) {
checkLineId(supervisionTempLineReportParam, !StringUtils.isEmpty(supervisionTempLineReportParam.getId()));
}
SupervisionTempLineReport supervisionTempLineReport = this.baseMapper.selectById(supervisionTempLineReportParam.getId());
//判断是否有权限操作
InstanceUtil.judgeUserPower(RequestUtil.getUserIndex(), supervisionTempLineReport.getCreateBy());

View File

@@ -51,8 +51,15 @@ import com.njcn.supervision.service.device.ISupervisionTempLineRunTestService;
import com.njcn.supervision.service.device.TempLineRunTestWarningService;
import com.njcn.supervision.service.user.*;
import com.njcn.supervision.utils.InstanceUtil;
import com.njcn.system.enums.DicDataEnum;
import com.njcn.web.utils.RequestUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.time.LocalDate;
@@ -62,14 +69,6 @@ import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
/**
* <p>

View File

@@ -129,7 +129,7 @@ public class WarningLeafletServiceImpl extends ServiceImpl<WarningLeafletMapper,
@Override
public Page<WarningLeafletVO> warningPageData(WarningLeafletParam.WarningLeafletQueryParam warningLeafletQueryParam) {
QueryWrapper<WarningLeafletVO> warningLeafletVOQueryWrapper = new QueryWrapper<>();
if (Objects.nonNull(warningLeafletQueryParam) && StringUtils.equals(warningLeafletQueryParam.getDealState(), "1")) {
if (Objects.nonNull(warningLeafletQueryParam)) {
//添加上时间范围
warningLeafletVOQueryWrapper.between("supervision_warning_leaflet.Create_Time",
DateUtil.beginOfDay(DateUtil.parse(warningLeafletQueryParam.getSearchBeginTime())),
@@ -142,7 +142,6 @@ public class WarningLeafletServiceImpl extends ServiceImpl<WarningLeafletMapper,
warningLeafletVOQueryWrapper.in("supervision_warning_leaflet.dept_id", deptIds);
}
warningLeafletVOQueryWrapper
.eq(StringUtils.equals(warningLeafletQueryParam.getDealState(), "0"), "supervision_temp_line_run_test_warning.deal_state", 0)
.eq("supervision_warning_leaflet.state", DataStateEnum.ENABLE.getCode())
.eq("supervision_warning_leaflet.leaflet_type", LeafletTypeEnum.WARNING.getCode())
.orderByDesc("supervision_warning_leaflet.Update_Time");
@@ -358,6 +357,7 @@ public class WarningLeafletServiceImpl extends ServiceImpl<WarningLeafletMapper,
warningLeafletVOQueryWrapper
.eq("supervision_warning_leaflet.state", DataStateEnum.ENABLE.getCode())
.eq("supervision_warning_leaflet.leaflet_type", LeafletTypeEnum.ALARM.getCode())
.eq(StringUtils.equals(warningLeafletQueryParam.getDealState(), "0"), "supervision_warning_leaflet.deal_state", 0)
.eq(Objects.nonNull(warningLeafletQueryParam.getStatus()), "supervision_warning_leaflet.status", warningLeafletQueryParam.getStatus())
.orderByDesc("supervision_warning_leaflet.Update_Time");
Page<WarningLeafletVO> warningLeafletVOPage = this.baseMapper.alarmPageData(new Page<>(PageFactory.getPageNum(warningLeafletQueryParam), PageFactory.getPageSize(warningLeafletQueryParam)), warningLeafletVOQueryWrapper);

View File

@@ -23,7 +23,9 @@ import com.njcn.bpm.pojo.dto.BpmProcessInstanceCreateReqDTO;
import com.njcn.bpm.pojo.param.instance.BpmProcessInstanceCancelParam;
import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.utils.FileUtil;
import com.njcn.device.pms.utils.PubUtil;
import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.device.pq.pojo.po.LineDetail;
@@ -112,6 +114,7 @@ public class UserReportPOServiceImpl extends ServiceImpl<UserReportPOMapper, Use
//判断工程名称是否有重复的
if (Objects.equals(userReportParam.getSaveOrCheckflag(), "1")) {
userReportPO.setStatus(BpmTaskStatusEnum.WAIT.getStatus());
checkProjectName(userReportParam, !StringUtils.isEmpty(userReportParam.getId()));
} else {
//常态化干扰源用户信息更新的用的
if (!Objects.equals(userReportParam.getSaveOrCheckflag(), "0")) {
@@ -186,6 +189,11 @@ public class UserReportPOServiceImpl extends ServiceImpl<UserReportPOMapper, Use
@Override
@Transactional(rollbackFor = Exception.class)
public String updateUserReport(UserReportParam.UserReportUpdate userReportParam) {
//判断工程名称是否有重复的
if (Objects.equals(userReportParam.getSaveOrCheckflag(), "2")) {
checkProjectName(userReportParam, !StringUtils.isEmpty(userReportParam.getId()));
}
UserReportPO userReportPO = this.baseMapper.selectById(userReportParam.getId());
//判断是否有权限操作
InstanceUtil.judgeUserPower(RequestUtil.getUserIndex(), userReportPO.getCreateBy());
@@ -771,6 +779,10 @@ public class UserReportPOServiceImpl extends ServiceImpl<UserReportPOMapper, Use
@Override
@Transactional(rollbackFor = Exception.class)
public void importSensitiveUserData(MultipartFile file, HttpServletResponse response) {
boolean fileType = FileUtil.judgeFileIsExcel(file.getOriginalFilename());
if (!fileType) {
throw new BusinessException(CommonResponseEnum.FILE_XLSX_ERROR);
}
ImportParams params = new ImportParams();
//表头
params.setHeadRows(1);
@@ -779,15 +791,19 @@ public class UserReportPOServiceImpl extends ServiceImpl<UserReportPOMapper, Use
params.setNeedVerify(true);
params.setStartSheetIndex(0);
params.setSheetNum(1);
List<SensitiveUserSExcel> sensitiveUserExcels = new ArrayList<>();
List<SensitiveUserSExcel> sensitiveUserExcels;
try {
ExcelImportResult<SensitiveUserSExcel> sensitiveUserExcelExcelImportResult = ExcelImportUtil.importExcelMore(file.getInputStream(), SensitiveUserSExcel.class, params);
//如果存在非法数据,将不合格的数据导出
if (sensitiveUserExcelExcelImportResult.isVerifyFail()) {
PoiUtil.exportFileByWorkbook(sensitiveUserExcelExcelImportResult.getFailWorkbook(), "非法用户数据.xlsx", response);
} else {
sensitiveUserExcels = sensitiveUserExcelExcelImportResult.getList();
List<SensitiveUserSExcel> sensitiveUserExcelExcelImportResult = ExcelImportUtil.importExcel(file.getInputStream(), SensitiveUserSExcel.class, params);
sensitiveUserExcels = sensitiveUserExcelExcelImportResult.stream().filter(x -> StringUtils.isNotBlank(x.getCity())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(sensitiveUserExcels)){
throw new BusinessException(SupervisionResponseEnum.IMPORT_DEV_DATA_ERROR);
}
//如果存在非法数据,将不合格的数据导出
// if (sensitiveUserExcelExcelImportResult.isVerifyFail()) {
// PoiUtil.exportFileByWorkbook(sensitiveUserExcelExcelImportResult.getFailWorkbook(), "非法用户数据.xlsx", response);
// } else {
// sensitiveUserExcels = sensitiveUserExcelExcelImportResult.getList();
// }
} catch (Exception e) {
throw new BusinessException(SupervisionResponseEnum.IMPORT_SENSITIVE_USER_ERROR);
}
@@ -807,7 +823,7 @@ public class UserReportPOServiceImpl extends ServiceImpl<UserReportPOMapper, Use
List<DictData> supplyCondition = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.SUPPLY_CONDITION.getCode()).getData();
//解决填报部门问题
List<DeptDTO> data = deptFeignClient.getDeptDescendantIndexes(RequestUtil.getUserIndex(), WebUtil.filterDeptType()).getData();
List<DeptDTO> data = deptFeignClient.getDeptDescendantIndexes(RequestUtil.getDeptIndex(), WebUtil.filterDeptType()).getData();
//执行批量导入敏感及重要用户,入库过程中会进行数据校验
@@ -986,6 +1002,10 @@ public class UserReportPOServiceImpl extends ServiceImpl<UserReportPOMapper, Use
@Override
@Transactional(rollbackFor = Exception.class)
public void importSensitiveReportData(MultipartFile file, HttpServletResponse response) {
boolean fileType = FileUtil.judgeFileIsExcel(file.getOriginalFilename());
if (!fileType) {
throw new BusinessException(CommonResponseEnum.FILE_XLSX_ERROR);
}
ImportParams params = new ImportParams();
//表头
params.setHeadRows(1);

View File

@@ -191,14 +191,18 @@ public class SysDicTreePOServiceImpl extends ServiceImpl<SysDicTreePOMapper, Sys
}
//通用指标
else {
//型接线
if (Objects.equals(conType,1)) {
//0-星型接线
if (Objects.equals(conType,0)) {
queryWrapper.in(SysDicTreePO::getType, Arrays.asList(2,4));
}
//其他接线方式
else {
//1-角型接线
else if (Objects.equals(conType,1)) {
queryWrapper.in(SysDicTreePO::getType,Arrays.asList(2,5));
}
//2-V型接线
else if (Objects.equals(conType,2)) {
queryWrapper.in(SysDicTreePO::getType,Arrays.asList(2,5,6));
}
}
return this.list(queryWrapper);
}

View File

@@ -0,0 +1,21 @@
package com.njcn.system.timer.tasks;
import com.njcn.harmonic.api.PmsLineWarningFeignClient;
import com.njcn.system.timer.TimerTaskRunner;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
/**
* @author xy
*/
@Component
@RequiredArgsConstructor
public class PmsLineWarningTaskRunner implements TimerTaskRunner {
private final PmsLineWarningFeignClient pmsLineWarningFeignClient;
@Override
public void action(String date) {
pmsLineWarningFeignClient.heBeiNorthAdd();
}
}