Compare commits
64 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
99ab77dcf0 | ||
|
|
c772c9cd81 | ||
| 996ec87ea8 | |||
|
|
b6eaff3b1e | ||
|
|
56bf5bb7c9 | ||
|
|
7410d32241 | ||
|
|
41ba37b723 | ||
|
|
3f77d30cfd | ||
| f71f87ced4 | |||
| 32295f60c0 | |||
|
|
d2945b0fb2 | ||
|
|
133766a2c7 | ||
| 2a5a5087ad | |||
| 4edb27d20b | |||
| 71d6636be0 | |||
|
|
8ccdb84ea9 | ||
|
|
5389903ed7 | ||
|
|
0684bdf503 | ||
|
|
d0b4a1ec71 | ||
| 764ca4a12a | |||
|
|
ca992cadbc | ||
|
|
ed166cf1e0 | ||
| 598fa803a1 | |||
| 10050ce418 | |||
| cb688ad7ad | |||
| f6c4d050da | |||
|
|
fd6ec7bdf2 | ||
|
|
ca7f1010b0 | ||
| 97ddd133f0 | |||
| 735c99e8ac | |||
| 9a53399ec9 | |||
| f27276624a | |||
| df149a3cc2 | |||
| 7ca23b9431 | |||
| b27f049c9f | |||
| 23c4a78383 | |||
|
|
c9301d1f8f | ||
|
|
977a0e7a35 | ||
|
|
9143ff5b80 | ||
| 0502dc7508 | |||
| eb689c9852 | |||
|
|
c576bd3bf7 | ||
| 27bac7288c | |||
| a7c69f7c43 | |||
| 33ab825497 | |||
| 22c8ff3b22 | |||
|
|
875d114733 | ||
|
|
bd1fe68060 | ||
| c1d933467e | |||
|
|
e7daf05670 | ||
|
|
e251fc6a1a | ||
| 0e7cc360f7 | |||
| e2d3394669 | |||
| b3ab5d2587 | |||
|
|
ed029139d3 | ||
| 02578546f2 | |||
|
|
09e2f329b7 | ||
|
|
ee2fae105b | ||
| 82efce189a | |||
|
|
be8c14625f | ||
| 95a571d3c3 | |||
| 322001150a | |||
|
|
b805bda25b | ||
| f592f2b580 |
12
pom.xml
12
pom.xml
@@ -43,7 +43,7 @@
|
||||
<!-- <middle.server.url>10.95.53.49</middle.server.url>-->
|
||||
<middle.server.url>192.168.1.103</middle.server.url>
|
||||
<!--微服务模块发布地址-->
|
||||
<service.server.url>127.0.0.1</service.server.url>
|
||||
<service.server.url>192.168.2.130</service.server.url>
|
||||
<!--docker仓库地址-->
|
||||
<docker.server.url>192.168.1.22</docker.server.url>
|
||||
<!--nacos的ip:port-->
|
||||
@@ -53,9 +53,9 @@
|
||||
<!--nacos的ip:port-->
|
||||
<nacos.password>nacos</nacos.password>
|
||||
<!--服务器发布内容为空-->
|
||||
<!-- <nacos.namespace></nacos.namespace>-->
|
||||
<nacos.namespace>hswbpm</nacos.namespace>
|
||||
<!-- <nacos.namespace>30c701c4-2a94-49d9-82e1-76aa9456573f</nacos.namespace>-->
|
||||
<nacos.namespace>6fd2d036-f390-46ee-9c9d-d5a5c00e3314</nacos.namespace>
|
||||
<!-- <nacos.namespace>12b467cc-a7e6-411d-8944-090cbfa09dde</nacos.namespace>-->
|
||||
<!-- <nacos.namespace>910d0d69-2254-481b-b9f7-7ecf9cb881b0</nacos.namespace>-->
|
||||
<!-- sentinel:port-->
|
||||
<sentinel.url>${middle.server.url}:8080</sentinel.url>
|
||||
@@ -81,6 +81,7 @@
|
||||
<springcloud.alibaba.version>2.2.7.RELEASE</springcloud.alibaba.version>
|
||||
<hutool.version>5.8.11</hutool.version>
|
||||
<knife4j.version>3.0.2</knife4j.version>
|
||||
<postgresql.version>42.3.8</postgresql.version>
|
||||
<knife4j.aggregation.version>2.0.8</knife4j.aggregation.version>
|
||||
<lombok.version>1.18.18</lombok.version>
|
||||
<mybatis.version>2.1.3</mybatis.version>
|
||||
@@ -171,6 +172,11 @@
|
||||
<artifactId>knife4j-spring-ui</artifactId>
|
||||
<version>${knife4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>${postgresql.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-aggregation-spring-boot-starter</artifactId>
|
||||
|
||||
@@ -9,8 +9,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.advance.enums.AdvanceResponseEnum;
|
||||
import com.njcn.advance.mapper.govern.voltage.SgMachineMapper;
|
||||
import com.njcn.advance.pojo.param.govern.voltage.SgMachineParam;
|
||||
import com.njcn.advance.pojo.param.govern.voltage.SgUserParam;
|
||||
import com.njcn.advance.pojo.po.govern.voltage.SgMachine;
|
||||
import com.njcn.advance.pojo.po.govern.voltage.SgSensitiveUnit;
|
||||
import com.njcn.advance.pojo.po.govern.voltage.SgUser;
|
||||
import com.njcn.advance.pojo.vo.govern.voltage.SgMachineVO;
|
||||
import com.njcn.advance.service.govern.voltage.ISgMachineService;
|
||||
import com.njcn.advance.service.govern.voltage.ISgSensitiveUnitService;
|
||||
@@ -56,12 +58,34 @@ public class SgMachineServiceImpl extends ServiceImpl<SgMachineMapper, SgMachine
|
||||
@Override
|
||||
public String addMachine(SgMachineParam sgMachineParam) {
|
||||
SgMachine sgMachine = new SgMachine();
|
||||
checkMachineName(sgMachineParam, false);
|
||||
|
||||
BeanUtil.copyProperties(sgMachineParam, sgMachine);
|
||||
//默认为正常状态
|
||||
sgMachine.setState(DataStateEnum.ENABLE.getCode());
|
||||
this.save(sgMachine);
|
||||
return sgMachine.getId();
|
||||
}
|
||||
/**
|
||||
* 校验参数,检查是否存在相同名称的业务用户
|
||||
*/
|
||||
private void checkMachineName(SgMachineParam sgMachineParam, boolean isExcludeSelf) {
|
||||
LambdaQueryWrapper<SgMachine> sgUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
sgUserLambdaQueryWrapper
|
||||
.eq(SgMachine::getName, sgMachineParam.getName())
|
||||
.eq(SgMachine::getState, DataStateEnum.ENABLE.getCode());
|
||||
//更新的时候,需排除当前记录
|
||||
if (isExcludeSelf) {
|
||||
if (sgMachineParam instanceof SgMachineParam.SgMachineUpdateParam) {
|
||||
sgUserLambdaQueryWrapper.ne(SgMachine::getId, ((SgMachineParam.SgMachineUpdateParam) sgMachineParam).getId());
|
||||
}
|
||||
}
|
||||
int countByAccount = this.count(sgUserLambdaQueryWrapper);
|
||||
//大于等于1个则表示重复
|
||||
if (countByAccount >= 1) {
|
||||
throw new BusinessException(AdvanceResponseEnum.SG_USER_NAME_REPEAT);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新设备
|
||||
@@ -70,6 +94,8 @@ public class SgMachineServiceImpl extends ServiceImpl<SgMachineMapper, SgMachine
|
||||
@Override
|
||||
public boolean updateSgMachine(SgMachineParam.SgMachineUpdateParam updateParam) {
|
||||
SgMachine sgMachine = new SgMachine();
|
||||
checkMachineName(updateParam, true);
|
||||
|
||||
BeanUtil.copyProperties(updateParam, sgMachine);
|
||||
return this.updateById(sgMachine);
|
||||
}
|
||||
|
||||
@@ -2,12 +2,15 @@ package com.njcn.advance.service.govern.voltage.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.advance.enums.AdvanceResponseEnum;
|
||||
import com.njcn.advance.mapper.govern.voltage.SgSensitiveUnitMapper;
|
||||
import com.njcn.advance.pojo.param.govern.voltage.SgMachineParam;
|
||||
import com.njcn.advance.pojo.param.govern.voltage.SgSensitiveUnitParam;
|
||||
import com.njcn.advance.pojo.po.govern.voltage.SgMachine;
|
||||
import com.njcn.advance.pojo.po.govern.voltage.SgSensitiveUnit;
|
||||
import com.njcn.advance.pojo.vo.govern.voltage.SgSensitiveUnitVO;
|
||||
import com.njcn.advance.service.govern.voltage.ISgSensitiveUnitService;
|
||||
@@ -54,12 +57,34 @@ public class SgSensitiveUnitServiceImpl extends ServiceImpl<SgSensitiveUnitMappe
|
||||
@Override
|
||||
public String addSensitiveUnit(SgSensitiveUnitParam sgSensitiveUnitParam) {
|
||||
SgSensitiveUnit sgSensitiveUnit = new SgSensitiveUnit();
|
||||
checkSensitiveUnitName(sgSensitiveUnitParam, false);
|
||||
|
||||
BeanUtil.copyProperties(sgSensitiveUnitParam, sgSensitiveUnit);
|
||||
//默认为正常状态
|
||||
sgSensitiveUnit.setState(DataStateEnum.ENABLE.getCode());
|
||||
this.save(sgSensitiveUnit);
|
||||
return sgSensitiveUnit.getId();
|
||||
}
|
||||
/**
|
||||
* 校验参数,检查是否存在相同名称的业务用户
|
||||
*/
|
||||
private void checkSensitiveUnitName(SgSensitiveUnitParam sgSensitiveUnitParam, boolean isExcludeSelf) {
|
||||
LambdaQueryWrapper<SgSensitiveUnit> sgUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
sgUserLambdaQueryWrapper
|
||||
.eq(SgSensitiveUnit::getName, sgSensitiveUnitParam.getName())
|
||||
.eq(SgSensitiveUnit::getState, DataStateEnum.ENABLE.getCode());
|
||||
//更新的时候,需排除当前记录
|
||||
if (isExcludeSelf) {
|
||||
if (sgSensitiveUnitParam instanceof SgSensitiveUnitParam.SgSensitiveUnitUpdateParam) {
|
||||
sgUserLambdaQueryWrapper.ne(SgSensitiveUnit::getId, ((SgSensitiveUnitParam.SgSensitiveUnitUpdateParam) sgSensitiveUnitParam).getId());
|
||||
}
|
||||
}
|
||||
int countByAccount = this.count(sgUserLambdaQueryWrapper);
|
||||
//大于等于1个则表示重复
|
||||
if (countByAccount >= 1) {
|
||||
throw new BusinessException(AdvanceResponseEnum.SG_USER_NAME_REPEAT);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新元器件
|
||||
@@ -69,6 +94,8 @@ public class SgSensitiveUnitServiceImpl extends ServiceImpl<SgSensitiveUnitMappe
|
||||
@Override
|
||||
public boolean updateSgSensitiveUnit(SgSensitiveUnitParam.SgSensitiveUnitUpdateParam updateParam) {
|
||||
SgSensitiveUnit sgSensitiveUnit = new SgSensitiveUnit();
|
||||
checkSensitiveUnitName(updateParam, true);
|
||||
|
||||
BeanUtil.copyProperties(updateParam, sgSensitiveUnit);
|
||||
return this.updateById(sgSensitiveUnit);
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ import io.swagger.models.auth.In;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -511,7 +512,7 @@ public class EventRelevantAnalysisServiceImpl extends ServiceImpl<RmpEventAdvanc
|
||||
lambdaQueryWrapper.like(RmpEventDetailAssPO::getContentDes, baseParam.getSearchValue());
|
||||
}
|
||||
lambdaQueryWrapper.between(RmpEventDetailAssPO::getTimeId, timeV.get(0), timeV.get(1))
|
||||
.orderByAsc(RmpEventDetailAssPO::getTimeId);
|
||||
.orderByDesc(RmpEventDetailAssPO::getTimeId);
|
||||
return rmpEventDetailAssMapper.selectPage(new Page<>(PageFactory.getPageNum(baseParam), PageFactory.getPageSize(baseParam)), lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
@@ -733,7 +734,7 @@ public class EventRelevantAnalysisServiceImpl extends ServiceImpl<RmpEventAdvanc
|
||||
|
||||
List<AdvanceEventDetailVO> advanceEventDetailVOLsit = querySagEventsAll(startTime, endTime);
|
||||
|
||||
|
||||
advanceEventDetailVOLsit = advanceEventDetailVOLsit.stream().filter(temp-> StringUtils.isNotEmpty(temp.getAdvanceType())).collect(Collectors.toList());
|
||||
for (AdvanceEventDetailVO advanceEventDetailVO : advanceEventDetailVOLsit) { // 获取监测点线路序号
|
||||
//母线id
|
||||
String nodePhysics = advanceEventDetailVO.getVoltageId();
|
||||
|
||||
@@ -81,7 +81,13 @@ public class EventWaveAnalysisServiceImpl implements EventWaveAnalysisService {
|
||||
inputStreamCfg = fileStorageUtil.getFileStream(OssPath.WAVE_DIR + lineDetailDataVO.getIp() + StrUtil.SLASH + rmpEventDetailPO.getWavePath() + GeneralConstant.CFG);
|
||||
inputStreamDat = fileStorageUtil.getFileStream(OssPath.WAVE_DIR + lineDetailDataVO.getIp() + StrUtil.SLASH + rmpEventDetailPO.getWavePath() + GeneralConstant.DAT);
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException("暂降cfg,dat文件缺失,请联系管理员");
|
||||
try {
|
||||
inputStreamCfg = fileStorageUtil.getFileStream(OssPath.WAVE_DIR + lineDetailDataVO.getIp() + StrUtil.SLASH + rmpEventDetailPO.getWavePath() + GeneralConstant.CFG.toLowerCase());
|
||||
inputStreamDat = fileStorageUtil.getFileStream(OssPath.WAVE_DIR + lineDetailDataVO.getIp() + StrUtil.SLASH + rmpEventDetailPO.getWavePath() + GeneralConstant.DAT.toLowerCase());
|
||||
} catch (Exception e1) {
|
||||
|
||||
throw new BusinessException("暂降cfg,dat文件缺失,请联系管理员");
|
||||
}
|
||||
}
|
||||
|
||||
//读取
|
||||
|
||||
@@ -88,7 +88,7 @@ public class BpmSignParam extends BaseEntity implements Serializable {
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("标识key")
|
||||
private String key;
|
||||
private String signKey;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -67,8 +67,8 @@ public class BpmCategoryServiceImpl extends ServiceImpl<BpmCategoryMapper, BpmCa
|
||||
@Override
|
||||
public Page<BpmCategoryVO> getCategoryPage(BpmCategoryParam.BpmCategoryQueryParam bpmCategoryQueryParam) {
|
||||
QueryWrapper<BpmCategoryVO> categoryVOQueryWrapper = new QueryWrapper<>();
|
||||
if (StrUtil.isNotBlank(bpmCategoryQueryParam.getName())) {
|
||||
categoryVOQueryWrapper.like("bpm_category.name", bpmCategoryQueryParam.getName());
|
||||
if (StrUtil.isNotBlank(bpmCategoryQueryParam.getSearchValue())) {
|
||||
categoryVOQueryWrapper.like("bpm_category.name", bpmCategoryQueryParam.getSearchValue());
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(bpmCategoryQueryParam.getCode())) {
|
||||
|
||||
@@ -106,8 +106,8 @@ public class BpmSignServiceImpl extends ServiceImpl<BpmSignMapper, BpmSign> impl
|
||||
bpmSignVOQueryWrapper.like("bpm_sign.name", bpmSignQueryParam.getName());
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(bpmSignQueryParam.getKey())) {
|
||||
bpmSignVOQueryWrapper.like("bpm_sign.signKey", bpmSignQueryParam.getKey());
|
||||
if (StrUtil.isNotBlank(bpmSignQueryParam.getSignKey())) {
|
||||
bpmSignVOQueryWrapper.like("bpm_sign.sign_key", bpmSignQueryParam.getSignKey());
|
||||
}
|
||||
bpmSignVOQueryWrapper.eq("bpm_sign.state", DataStateEnum.ENABLE.getCode());
|
||||
bpmSignVOQueryWrapper.orderByAsc("bpm_sign.sort");
|
||||
|
||||
@@ -75,9 +75,9 @@ public interface PatternRegex {
|
||||
String ROLE_REGEX = "^[a-zA-Z][a-zA-Z0-9]{2,50}$";
|
||||
|
||||
/**
|
||||
* 部门名称由汉字组成,长度为0-20
|
||||
* 部门名称由汉字组成,长度为0-32 (前端统一32了这边改下长度)
|
||||
*/
|
||||
String DEPT_NAME_REGEX = "^[\\u4e00-\\u9fa5]{1,20}$";
|
||||
String DEPT_NAME_REGEX = "^[\\u4e00-\\u9fa5]{1,32}$";
|
||||
|
||||
/**
|
||||
* 字典名称包括中文、数字、字母、罗马数字、括号以及点号
|
||||
@@ -258,7 +258,7 @@ public interface PatternRegex {
|
||||
/**
|
||||
* 任意字符,长度在1-20位,常用于名称、编码等常规录入
|
||||
*/
|
||||
String ALL_CHAR_1_20 = "^[-_A-Za-z0-9\\u4e00-\\u9fa5]{1,20}$";
|
||||
String ALL_CHAR_1_20 = "^[-_A-Za-z0-9\\u4e00-\\u9fa5]{1,32}$";
|
||||
|
||||
String SPECIALCHARACTER ="[<>%'%;()&+/\\\\-\\\\\\\\_|@*?#$!,.]|html";
|
||||
|
||||
|
||||
@@ -25,6 +25,12 @@ public class SimpleDTO implements Serializable {
|
||||
@ApiModelProperty(name = "value", value = "数值")
|
||||
private String value;
|
||||
|
||||
/**
|
||||
* 针对云南曲靖特殊处理的五层树标识符
|
||||
* 特殊在不显示供电公司,显示(变电站、线路)这两个是部门的名称+母线_监测点的名称
|
||||
*/
|
||||
private String deptName;
|
||||
|
||||
private Integer sort;
|
||||
|
||||
private Integer algoDescribe;
|
||||
|
||||
@@ -74,6 +74,12 @@
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
|
||||
<version>3.5.1</version>
|
||||
</dependency>
|
||||
|
||||
<!--数据库相关********end-->
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@ public class PieGenerator {
|
||||
Option reasonOption = new Option();
|
||||
//取消渲染动画
|
||||
reasonOption.setAnimation(false);
|
||||
String[] colorArr = {"#526ADE", "#00BFF5","#FFBF00","#77DA63","#D5FF6B"};
|
||||
reasonOption.setColor(colorArr);
|
||||
//背景色
|
||||
reasonOption.setBackgroundColor(PicCommonData.PIC_BACK_COLOR);
|
||||
//标题
|
||||
|
||||
@@ -25,7 +25,7 @@ public class BusinessDataUtil {
|
||||
List<List<Double>> unTolerateData = new ArrayList<>();
|
||||
for (List<Double> list : originData) {
|
||||
//是否超过上限
|
||||
if (list.get(0) <= 0.03) {
|
||||
if (list.get(0) <= 0.003) {
|
||||
int line = 230 - 30000 * list.get(0).intValue();
|
||||
if (list.get(1) > line) {
|
||||
unTolerateData.add(list);
|
||||
|
||||
@@ -34,24 +34,24 @@ public class NacosLogbackConfigLoader implements SpringApplicationRunListener, A
|
||||
|
||||
@Override
|
||||
public void environmentPrepared(ConfigurableEnvironment environment) {
|
||||
// String serverAddr = environment.getProperty("spring.cloud.nacos.config.server-addr");
|
||||
// String namespace = environment.getProperty("spring.cloud.nacos.config.namespace");
|
||||
// String projectName = environment.getProperty("microservice.ename");
|
||||
// String logLevel = environment.getProperty("logging.level.root");
|
||||
// String url = String.format("http://%s/nacos/v1/cs/configs?tenant=%s&group=DEFAULT_GROUP&dataId=logback.xml", serverAddr, namespace);
|
||||
// HttpHeaders headers = new HttpHeaders();
|
||||
// headers.set("cndl408125hawen", "lanxia201");
|
||||
// HttpEntity<String> entity = new HttpEntity<>(headers);
|
||||
// RestTemplate restTemplate = new RestTemplate();
|
||||
// ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, entity, String.class);
|
||||
// if (response.getStatusCode().is2xxSuccessful()) {
|
||||
// String logbackConfigContent = response.getBody();
|
||||
// //替换项目名称
|
||||
// logbackConfigContent = logbackConfigContent.replace("projectDefaultName",projectName);
|
||||
// logbackConfigContent = logbackConfigContent.replace("logDefaultLevel",logLevel);
|
||||
// // 应用获取到的Logback配置
|
||||
// applyLogbackConfig(logbackConfigContent);
|
||||
// }
|
||||
/* String serverAddr = environment.getProperty("spring.cloud.nacos.config.server-addr");
|
||||
String namespace = environment.getProperty("spring.cloud.nacos.config.namespace");
|
||||
String projectName = environment.getProperty("microservice.ename");
|
||||
String logLevel = environment.getProperty("logging.level.root");
|
||||
String url = String.format("http://%s/nacos/v1/cs/configs?tenant=%s&group=DEFAULT_GROUP&dataId=logback.xml", serverAddr, namespace);
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("cndl408125hawen", "lanxia201");
|
||||
HttpEntity<String> entity = new HttpEntity<>(headers);
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, entity, String.class);
|
||||
if (response.getStatusCode().is2xxSuccessful()) {
|
||||
String logbackConfigContent = response.getBody();
|
||||
//替换项目名称
|
||||
logbackConfigContent = logbackConfigContent.replace("projectDefaultName",projectName);
|
||||
logbackConfigContent = logbackConfigContent.replace("logDefaultLevel",logLevel);
|
||||
// 应用获取到的Logback配置
|
||||
applyLogbackConfig(logbackConfigContent);
|
||||
}*/
|
||||
}
|
||||
|
||||
private void applyLogbackConfig(String logbackConfigContent) {
|
||||
|
||||
@@ -48,6 +48,28 @@
|
||||
<artifactId>minioss-springboot-starter</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>aliyun-oss-springboot-starter</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-api</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.aliyun.oss</groupId>
|
||||
<artifactId>aliyun-sdk-oss</artifactId>
|
||||
<version>3.18.0</version>
|
||||
<optional>false</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -13,6 +13,7 @@ public interface GeneralConstant {
|
||||
Integer LOCAL_DISK = 1;
|
||||
Integer HUAWEI_OBS = 2;
|
||||
Integer MINIO_OSS = 3;
|
||||
Integer AliYUN_OSS = 4;
|
||||
|
||||
/***
|
||||
* 波形文件的3种后缀
|
||||
|
||||
@@ -12,6 +12,8 @@ public interface OssPath {
|
||||
*/
|
||||
String WAVE_DIR="comtrade/";
|
||||
|
||||
String WAVE_FILE="wave/";
|
||||
|
||||
/***
|
||||
* 下载文件
|
||||
*/
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.njcn.oss.utils;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.lang.UUID;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.njcn.ali.oss.util.AliYunOssUtils;
|
||||
import com.njcn.common.config.GeneralInfo;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.huawei.obs.util.OBSUtil;
|
||||
@@ -13,7 +13,6 @@ import com.njcn.oss.constant.GeneralConstant;
|
||||
import com.njcn.oss.constant.OssPath;
|
||||
import com.njcn.oss.enums.OssResponseEnum;
|
||||
import io.minio.*;
|
||||
import io.minio.errors.*;
|
||||
import io.minio.messages.Item;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -66,6 +65,11 @@ public class FileStorageUtil {
|
||||
|
||||
private final MinIossProperties minIossProperties;
|
||||
|
||||
/**
|
||||
* 阿里云文件服务器
|
||||
*/
|
||||
private final AliYunOssUtils aliYunOssUtils;
|
||||
|
||||
|
||||
/***
|
||||
* 上传MultipartFile文件,
|
||||
@@ -79,7 +83,7 @@ public class FileStorageUtil {
|
||||
if (generalInfo.getBusinessFileStorage() == GeneralConstant.HUAWEI_OBS) {
|
||||
filePath = dir + minIoUtils.minFileName(multipartFile.getOriginalFilename());
|
||||
obsUtil.uploadMultipart(multipartFile, filePath);
|
||||
} else if(generalInfo.getBusinessFileStorage() == GeneralConstant.MINIO_OSS){
|
||||
} else if (generalInfo.getBusinessFileStorage() == GeneralConstant.MINIO_OSS) {
|
||||
try {
|
||||
//把名称存入数据
|
||||
MinIoUploadResDTO minIoUploadResDTO = minIoUtils.upload(multipartFile, minIossProperties.getBucket(), dir);
|
||||
@@ -87,11 +91,15 @@ public class FileStorageUtil {
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(OssResponseEnum.UPLOAD_FILE_ERROR);
|
||||
}
|
||||
}else {
|
||||
} else if (generalInfo.getBusinessFileStorage() == GeneralConstant.AliYUN_OSS) {
|
||||
filePath = dir;
|
||||
aliYunOssUtils.uploadFile(dir, multipartFile);
|
||||
} else {
|
||||
try {
|
||||
// 构建完整目录:基准目录 + dir子目录
|
||||
Path basePath = Paths.get(generalInfo.getLocalStorePath());
|
||||
Path uploadPath = basePath.resolve(dir); // 将dir作为子目录添加
|
||||
// 将dir作为子目录添加
|
||||
Path uploadPath = basePath.resolve(dir);
|
||||
|
||||
// 确保完整目录存在(包括dir子目录)
|
||||
if (!Files.exists(uploadPath)) {
|
||||
@@ -135,6 +143,9 @@ public class FileStorageUtil {
|
||||
if (generalInfo.getBusinessFileStorage() == GeneralConstant.HUAWEI_OBS) {
|
||||
filePath = dir + minIoUtils.minFileName(multipartFile.getOriginalFilename());
|
||||
obsUtil.uploadMultipart(multipartFile, filePath);
|
||||
} else if (generalInfo.getBusinessFileStorage() == GeneralConstant.AliYUN_OSS) {
|
||||
filePath = dir;
|
||||
aliYunOssUtils.uploadFile(dir, multipartFile);
|
||||
} else {
|
||||
try {
|
||||
//把名称存入数据
|
||||
@@ -160,7 +171,7 @@ public class FileStorageUtil {
|
||||
if (generalInfo.getBusinessFileStorage() == GeneralConstant.HUAWEI_OBS) {
|
||||
filePath = dir + minIoUtils.minFileName(fileName);
|
||||
obsUtil.uploadStream(inputStream, filePath);
|
||||
} else if (generalInfo.getBusinessFileStorage() == GeneralConstant.MINIO_OSS){
|
||||
} else if (generalInfo.getBusinessFileStorage() == GeneralConstant.MINIO_OSS) {
|
||||
try {
|
||||
//把名称存入数据
|
||||
MinIoUploadResDTO minIoUploadResDTO = minIoUtils.uploadStream(inputStream, minIossProperties.getBucket(), dir, minIoUtils.minFileName(fileName));
|
||||
@@ -168,14 +179,17 @@ public class FileStorageUtil {
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(OssResponseEnum.UPLOAD_FILE_ERROR);
|
||||
}
|
||||
}else {
|
||||
} else if (generalInfo.getBusinessFileStorage() == GeneralConstant.AliYUN_OSS) {
|
||||
filePath = dir + fileName;
|
||||
aliYunOssUtils.uploadFile(filePath, inputStream);
|
||||
} else {
|
||||
// 本地存储逻辑
|
||||
try {
|
||||
// 1. 获取本地存储路径
|
||||
String localStoragePath = generalInfo.getLocalStorePath();
|
||||
|
||||
// 2. 确保目录存在(如果不存在则创建)
|
||||
File targetDir = new File(localStoragePath +File.separator+ dir);
|
||||
File targetDir = new File(localStoragePath + File.separator + dir);
|
||||
if (!targetDir.exists()) {
|
||||
boolean created = targetDir.mkdirs();
|
||||
if (!created) {
|
||||
@@ -193,7 +207,7 @@ public class FileStorageUtil {
|
||||
// 5. 返回相对路径
|
||||
filePath = dir + finalFileName;
|
||||
} catch (IOException e) {
|
||||
throw new BusinessException(OssResponseEnum.UPLOAD_FILE_ERROR,e.getMessage());
|
||||
throw new BusinessException(OssResponseEnum.UPLOAD_FILE_ERROR, e.getMessage());
|
||||
}
|
||||
}
|
||||
return filePath;
|
||||
@@ -209,6 +223,9 @@ public class FileStorageUtil {
|
||||
if (generalInfo.getBusinessFileStorage() == GeneralConstant.HUAWEI_OBS) {
|
||||
filePath = dir + minIoUtils.minFileName(fileName);
|
||||
obsUtil.uploadStream(inputStream, filePath);
|
||||
} else if (generalInfo.getBusinessFileStorage() == GeneralConstant.AliYUN_OSS) {
|
||||
filePath = dir + fileName;
|
||||
aliYunOssUtils.uploadFile(filePath, inputStream);
|
||||
} else {
|
||||
try {
|
||||
//把名称存入数据
|
||||
@@ -232,6 +249,8 @@ public class FileStorageUtil {
|
||||
String url;
|
||||
if (generalInfo.getBusinessFileStorage() == GeneralConstant.HUAWEI_OBS) {
|
||||
url = obsUtil.getFileUrl(filePath);
|
||||
} else if (generalInfo.getBusinessFileStorage() == GeneralConstant.AliYUN_OSS) {
|
||||
url = aliYunOssUtils.generatePresignedUrl(filePath, 3600);
|
||||
} else {
|
||||
url = minIoUtils.getObjectUrl(minIossProperties.getBucket(), filePath, 7 * 24 * 60 * 60);
|
||||
}
|
||||
@@ -250,10 +269,12 @@ public class FileStorageUtil {
|
||||
try {
|
||||
if (generalInfo.getBusinessFileStorage() == GeneralConstant.HUAWEI_OBS) {
|
||||
inputStream = obsUtil.downloadStream(filePath);
|
||||
} else if(generalInfo.getBusinessFileStorage() == GeneralConstant.MINIO_OSS) {
|
||||
} else if (generalInfo.getBusinessFileStorage() == GeneralConstant.MINIO_OSS) {
|
||||
inputStream = minIoUtils.downloadStream(minIossProperties.getBucket(), filePath);
|
||||
}else {
|
||||
Path path = Paths.get(generalInfo.getLocalStorePath()+File.separator+filePath);
|
||||
} else if (generalInfo.getBusinessFileStorage() == GeneralConstant.AliYUN_OSS) {
|
||||
inputStream = aliYunOssUtils.downloadStream(filePath);
|
||||
} else {
|
||||
Path path = Paths.get(generalInfo.getLocalStorePath() + File.separator + filePath);
|
||||
inputStream = Files.newInputStream(path);
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
@@ -274,11 +295,13 @@ public class FileStorageUtil {
|
||||
try {
|
||||
if (generalInfo.getBusinessFileStorage() == GeneralConstant.HUAWEI_OBS) {
|
||||
inputStream = obsUtil.downloadStream(filePath);
|
||||
} else if(generalInfo.getBusinessFileStorage() == GeneralConstant.MINIO_OSS){
|
||||
} else if (generalInfo.getBusinessFileStorage() == GeneralConstant.MINIO_OSS) {
|
||||
inputStream = minIoUtils.downloadStream(minIossProperties.getBucket(), filePath);
|
||||
}else {
|
||||
} else if (generalInfo.getBusinessFileStorage() == GeneralConstant.AliYUN_OSS) {
|
||||
inputStream = aliYunOssUtils.downloadStream(filePath);
|
||||
} else {
|
||||
// 本地存储处理
|
||||
Path path = Paths.get(generalInfo.getLocalStorePath()+File.separator+filePath);
|
||||
Path path = Paths.get(generalInfo.getLocalStorePath() + File.separator + filePath);
|
||||
inputStream = Files.newInputStream(path);
|
||||
|
||||
// 设置下载文件名(从路径中提取)
|
||||
@@ -331,14 +354,16 @@ public class FileStorageUtil {
|
||||
public void deleteFile(String fileName) {
|
||||
if (generalInfo.getBusinessFileStorage() == GeneralConstant.HUAWEI_OBS) {
|
||||
obsUtil.delete(fileName);
|
||||
} else if(generalInfo.getBusinessFileStorage() == GeneralConstant.MINIO_OSS){
|
||||
} else if (generalInfo.getBusinessFileStorage() == GeneralConstant.MINIO_OSS) {
|
||||
minIoUtils.removeObject(minIossProperties.getBucket(), fileName);
|
||||
} else if(generalInfo.getBusinessFileStorage() == GeneralConstant.LOCAL_DISK){
|
||||
Path path = Paths.get(generalInfo.getLocalStorePath()+File.separator+fileName);
|
||||
} else if (generalInfo.getBusinessFileStorage() == GeneralConstant.AliYUN_OSS) {
|
||||
aliYunOssUtils.deleteFile(fileName);
|
||||
} else if (generalInfo.getBusinessFileStorage() == GeneralConstant.LOCAL_DISK) {
|
||||
Path path = Paths.get(generalInfo.getLocalStorePath() + File.separator + fileName);
|
||||
try {
|
||||
Files.delete(path);
|
||||
} catch (IOException e) {
|
||||
log.info("删除本地文件{}失败失败原因{}", path,e.getMessage());
|
||||
log.info("删除本地文件{}失败失败原因{}", path, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -409,9 +434,10 @@ public class FileStorageUtil {
|
||||
|
||||
file = File.createTempFile(lastItem.objectName(), "xlsx");
|
||||
FileUtil.writeFromStream(stream, file);
|
||||
}else if(generalInfo.getBusinessFileStorage() == GeneralConstant.HUAWEI_OBS){
|
||||
} else if (generalInfo.getBusinessFileStorage() == GeneralConstant.HUAWEI_OBS) {
|
||||
file = obsUtil.getLastFile(OssPath.LOGBAK);
|
||||
|
||||
} else if (generalInfo.getBusinessFileStorage() == GeneralConstant.AliYUN_OSS) {
|
||||
file = aliYunOssUtils.getLastFile(directory);
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,22 @@ public enum RedisKeyEnum {
|
||||
/**
|
||||
* 云前置心跳
|
||||
*/
|
||||
CLD_HEART_BEAT_KEY("CLD_HEART_BEAT:", 180L);
|
||||
CLD_HEART_BEAT_KEY("CLD_HEART_BEAT:", 180L),
|
||||
|
||||
/**
|
||||
* 用户日志队列
|
||||
*/
|
||||
USER_LOG_QUEUE("USER_LOG_QUEUE", -1L),
|
||||
|
||||
/**
|
||||
* 用户日志邮件推送队列
|
||||
*/
|
||||
USER_LOG_EMAIL_QUEUE("USER_LOG_EMAIL_QUEUE", -1L),
|
||||
|
||||
/**
|
||||
* 终端日志
|
||||
*/
|
||||
DEVICE_LOG_QUEUE("DEVICE_LOG_QUEUE", -1L);
|
||||
|
||||
|
||||
private final String key;
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.njcn.redis.utils;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Redis 消息队列工具类
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class RedisMessageQueueUtil {
|
||||
|
||||
private final RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
/**
|
||||
* 推送消息到队列(左推)
|
||||
*
|
||||
* @param queueKey 队列Key
|
||||
* @param message 消息内容(JSON字符串)
|
||||
*/
|
||||
public void pushMessage(String queueKey, String message) {
|
||||
try {
|
||||
redisTemplate.opsForList().leftPush(queueKey, message);
|
||||
} catch (Exception e) {
|
||||
log.error("推送消息到队列失败,queueKey={}", queueKey, e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 阻塞式弹出消息(右弹)
|
||||
*
|
||||
* @param queueKey 队列Key
|
||||
* @param timeout 超时时间(秒)
|
||||
* @return 消息内容,超时返回null
|
||||
*/
|
||||
public String popMessage(String queueKey, long timeout) {
|
||||
try {
|
||||
Object result = redisTemplate.opsForList().rightPop(queueKey, timeout, TimeUnit.SECONDS);
|
||||
return result != null ? result.toString() : null;
|
||||
} catch (Exception e) {
|
||||
log.error("弹出消息失败,queueKey={}", queueKey, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取队列长度(用于监控)
|
||||
*
|
||||
* @param queueKey 队列Key
|
||||
* @return 队列长度
|
||||
*/
|
||||
public Long getQueueSize(String queueKey) {
|
||||
try {
|
||||
return redisTemplate.opsForList().size(queueKey);
|
||||
} catch (Exception e) {
|
||||
log.error("获取队列长度失败,queueKey={}", queueKey, e);
|
||||
return 0L;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -47,6 +47,7 @@ public class FeignConfig {
|
||||
@Bean
|
||||
public Decoder feignDecoder() {
|
||||
return (response, type) -> {
|
||||
|
||||
String bodyStr = Util.toString(response.body().asReader(Util.UTF_8));
|
||||
//对结果进行转换
|
||||
HttpResult<Object> result = PubUtils.json2obj(bodyStr, type);
|
||||
@@ -60,6 +61,8 @@ public class FeignConfig {
|
||||
}
|
||||
switch (commonResponseEnum) {
|
||||
case SUCCESS:
|
||||
// case NO_DATA:
|
||||
// case FAIL:
|
||||
return result;
|
||||
default:
|
||||
throw new BusinessException(result);
|
||||
|
||||
@@ -19,7 +19,7 @@ public interface ValidMessage {
|
||||
|
||||
String NAME_NOT_BLANK = "名称不能为空,请检查name参数";
|
||||
|
||||
String NAME_FORMAT_ERROR = "名称格式错误,存在特殊符号或超过20字符,请检查name参数";
|
||||
String NAME_FORMAT_ERROR = "名称格式错误,存在特殊符号或超过32字符,请检查name参数";
|
||||
|
||||
String INDUSTRY_NOT_BLANK = "行业不能为空,请检查industry参数";
|
||||
String INDUSTRY_FORMAT_ERROR = "行业格式错误,请检查industry参数";
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package com.njcn.web.service.impl;
|
||||
|
||||
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
||||
import com.njcn.common.config.GeneralInfo;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.LogInfo;
|
||||
import com.njcn.common.pojo.dto.DeviceLogDTO;
|
||||
import com.njcn.common.pojo.dto.LogInfoDTO;
|
||||
@@ -10,6 +8,8 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.common.utils.ReflectCommonUtil;
|
||||
import com.njcn.redis.pojo.enums.RedisKeyEnum;
|
||||
import com.njcn.redis.utils.RedisMessageQueueUtil;
|
||||
import com.njcn.web.advice.DeviceLog;
|
||||
import com.njcn.web.service.ILogService;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
@@ -46,8 +46,15 @@ public class LogServiceImpl implements ILogService {
|
||||
|
||||
|
||||
private final GeneralInfo generalInfo;
|
||||
/**
|
||||
* mqtt处理日志异步发布
|
||||
*/
|
||||
// private final MqttPublisher publisher;
|
||||
|
||||
private final MqttPublisher publisher;
|
||||
/**
|
||||
* redis队列处理日志异步发布
|
||||
*/
|
||||
private final RedisMessageQueueUtil redisMessageQueueUtil;
|
||||
|
||||
|
||||
/**
|
||||
@@ -82,14 +89,27 @@ public class LogServiceImpl implements ILogService {
|
||||
String operateType = ReflectCommonUtil.getOperateTypeByMethod(returnType.getMethod());
|
||||
Integer severity = levelStringToNumber(level);
|
||||
LogInfoDTO logInfoDTO = new LogInfoDTO(loginName, userName, ip, methodDescribe, operateType, result.equalsIgnoreCase("失败") ? 0 : 1, "", severity, type.equalsIgnoreCase("业务事件") ? 0 : 1, generalInfo.getMicroServiceName(), userIndex, LocalDateTime.now());
|
||||
publisher.send("/userLog", PubUtils.obj2json(logInfoDTO), 2, false);
|
||||
// publisher.send("/userLog", PubUtils.obj2json(logInfoDTO), 2, false);
|
||||
|
||||
redisMessageQueueUtil.pushMessage(
|
||||
RedisKeyEnum.USER_LOG_QUEUE.getKey(),
|
||||
PubUtils.obj2json(logInfoDTO)
|
||||
);
|
||||
|
||||
//推送审计消息功能
|
||||
if (severity != 0) {
|
||||
if (!logInfoDTO.getLoginName().equals(LogInfo.UNKNOWN_USER)) {
|
||||
publisher.send("/userLogPush", PubUtils.obj2json(logInfoDTO), 2, false);
|
||||
/**注意,此处是给前端推送的,如果没有了mqtt协议,此处前端就无消息可消费了*/
|
||||
// publisher.send("/userLogPush", PubUtils.obj2json(logInfoDTO), 2, false);
|
||||
|
||||
//发送邮箱功能
|
||||
if (severity == 2 && logInfoDTO.getResult() == 0) {
|
||||
//publisher.send("/userLogEmailPush", PubUtils.obj2json(logInfoDTO), 2, false);
|
||||
|
||||
// redisMessageQueueUtil.pushMessage(
|
||||
// RedisKeyEnum.USER_LOG_EMAIL_QUEUE.getKey(),
|
||||
// PubUtils.obj2json(logInfoDTO)
|
||||
// );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -97,8 +117,11 @@ public class LogServiceImpl implements ILogService {
|
||||
if (Objects.nonNull((returnType.getMethod())) && (returnType.getMethod()).isAnnotationPresent(DeviceLog.class)) {
|
||||
String deviceOperate = returnType.getMethod().getAnnotation(DeviceLog.class).operateType();
|
||||
DeviceLogDTO deviceLogDTO = new DeviceLogDTO(userName, deviceOperate, result.equalsIgnoreCase("失败") ? 0 : 1, "", loginName, userIndex);
|
||||
publisher.send("/deviceLog", PubUtils.obj2json(deviceLogDTO), 2, false);
|
||||
|
||||
// publisher.send("/deviceLog", PubUtils.obj2json(deviceLogDTO), 2, false);
|
||||
redisMessageQueueUtil.pushMessage(
|
||||
RedisKeyEnum.DEVICE_LOG_QUEUE.getKey(),
|
||||
PubUtils.obj2json(deviceLogDTO)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,7 +158,11 @@ public class LogServiceImpl implements ILogService {
|
||||
String operateType = ReflectCommonUtil.getOperateTypeByMethod(method);
|
||||
Integer severity = levelStringToNumber(level);
|
||||
LogInfoDTO logInfoDTO = new LogInfoDTO(tempLogInfo.getLoginName(), tempLogInfo.getUserName(), tempLogInfo.getIp(), ReflectCommonUtil.getMethodDescribeByMethod(method), operateType, result.equalsIgnoreCase("失败") ? 0 : 1, message, severity, type.equalsIgnoreCase("业务事件") ? 0 : 1, generalInfo.getMicroServiceName(), userIndex, LocalDateTime.now());
|
||||
publisher.send("/userLog", PubUtils.obj2json(logInfoDTO), 1, false);
|
||||
// publisher.send("/userLog", PubUtils.obj2json(logInfoDTO), 1, false);
|
||||
redisMessageQueueUtil.pushMessage(
|
||||
RedisKeyEnum.USER_LOG_QUEUE.getKey(),
|
||||
PubUtils.obj2json(logInfoDTO)
|
||||
);
|
||||
auditPush(severity, logInfoDTO);
|
||||
}
|
||||
|
||||
@@ -163,7 +190,11 @@ public class LogServiceImpl implements ILogService {
|
||||
Integer severity = levelStringToNumber(level);
|
||||
String operateType = ReflectCommonUtil.getOperateTypeByMethod(method);
|
||||
LogInfoDTO logInfoDTO = new LogInfoDTO(loginName, "", ip, ReflectCommonUtil.getMethodDescribeByMethod(method), operateType, result.equalsIgnoreCase("失败") ? 0 : 1, message, severity, type.equalsIgnoreCase("业务事件") ? 0 : 1, generalInfo.getMicroServiceName(), loginName, LocalDateTime.now());
|
||||
publisher.send("/userLog", PubUtils.obj2json(logInfoDTO), 1, false);
|
||||
// publisher.send("/userLog", PubUtils.obj2json(logInfoDTO), 1, false);
|
||||
redisMessageQueueUtil.pushMessage(
|
||||
RedisKeyEnum.USER_LOG_QUEUE.getKey(),
|
||||
PubUtils.obj2json(logInfoDTO)
|
||||
);
|
||||
auditPush(severity, logInfoDTO);
|
||||
}
|
||||
|
||||
@@ -171,7 +202,12 @@ public class LogServiceImpl implements ILogService {
|
||||
//推送审计消息功能
|
||||
if (severity != 0) {
|
||||
if (!logInfoDTO.getLoginName().equals(LogInfo.UNKNOWN_USER)) {
|
||||
publisher.send("/userLogPush", PubUtils.obj2json(logInfoDTO), 2, false);
|
||||
/**注意,此处是给前端推送的,如果没有了mqtt协议,此处前端就无消息可消费了*/
|
||||
// publisher.send("/userLogPush", PubUtils.obj2json(logInfoDTO), 2, false);
|
||||
// redisMessageQueueUtil.pushMessage(
|
||||
// RedisKeyEnum.USER_LOG_QUEUE.getKey(),
|
||||
// PubUtils.obj2json(logInfoDTO)
|
||||
// );
|
||||
//发送邮箱功能
|
||||
if (severity == 2 && logInfoDTO.getResult() == 0) {
|
||||
//publisher.send("/userLogEmailPush", PubUtils.obj2json(logInfoDTO), 2, false);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.njcn.web.utils;
|
||||
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.net.URI;
|
||||
@@ -15,8 +15,11 @@ import java.util.Map;
|
||||
* @createDate 2019-02-08
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
public class RestTemplateUtil {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(RestTemplateUtil.class);
|
||||
|
||||
private static final RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
// ----------------------------------GET-------------------------------------------------------
|
||||
@@ -263,6 +266,24 @@ public class RestTemplateUtil {
|
||||
return restTemplate.exchange(url, HttpMethod.POST, requestEntity, responseType, uriVariables);
|
||||
}
|
||||
|
||||
public <T> ResponseEntity<T> post(String url, Object requestBody, HttpHeaders headers, Class<T> responseType) {
|
||||
try {
|
||||
if (headers == null) {
|
||||
headers = new HttpHeaders();
|
||||
}
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
|
||||
HttpEntity<Object> entity = new HttpEntity<>(requestBody, headers);
|
||||
log.info("发送POST请求到: {}", url);
|
||||
ResponseEntity<T> response = restTemplate.postForEntity(url, entity, responseType);
|
||||
log.info("POST请求响应状态: {}", response.getStatusCode());
|
||||
return response;
|
||||
} catch (Exception e) {
|
||||
log.error("POST请求异常: {}", e.getMessage(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------PUT-------------------------------------------------------
|
||||
|
||||
/**
|
||||
|
||||
@@ -60,6 +60,7 @@
|
||||
<artifactId>pqs-influx</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -51,6 +51,10 @@ public interface CommTerminalGeneralClient {
|
||||
@PostMapping("deptGetLine")
|
||||
HttpResult<List<DeptGetChildrenMoreDTO>> deptGetLine(@RequestBody @Validated DeptGetLineParam deptGetLineParam);
|
||||
|
||||
@PostMapping("deptGetLineInfo")
|
||||
HttpResult<List<MonitorCommLedgerInfoDTO>> deptGetLineInfo(@RequestBody @Validated DeptGetLineParam deptGetLineParam);
|
||||
|
||||
|
||||
@PostMapping("deptGetAllLine")
|
||||
HttpResult<List<DeptGetChildrenMoreDTO>> deptGetAllLine(@RequestBody @Validated DeptGetLineParam deptGetLineParam);
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.njcn.device.biz.utils.DeviceEnumUtil;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
@@ -50,6 +51,13 @@ public class CommTerminalGeneralClientFallbackFactory implements FallbackFactory
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public HttpResult<List<MonitorCommLedgerInfoDTO>> deptGetLineInfo(DeptGetLineParam deptGetLineParam) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "根据部门获取监测点信息", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<DeptGetChildrenMoreDTO>> deptGetAllLine(DeptGetLineParam deptGetLineParam) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "根据单位获取all监测点信息", throwable.toString());
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.njcn.device.biz.mapper;
|
||||
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.device.biz.pojo.po.Overlimit;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2022-01-04
|
||||
*/
|
||||
@DS("sjzx")
|
||||
@Mapper
|
||||
public interface OverLimitWlMapper extends BaseMapper<Overlimit> {
|
||||
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.njcn.device.overlimit.mapper;
|
||||
package com.njcn.device.biz.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
@@ -1,6 +1,6 @@
|
||||
<?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.device.overlimit.mapper.OverlimitMapper">
|
||||
<mapper namespace="com.njcn.device.biz.mapper.OverlimitMapper">
|
||||
|
||||
<select id="getAllLineOverLimit" resultType="com.njcn.device.biz.pojo.po.Overlimit">
|
||||
select f.* from pq_line a
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.njcn.device.biz.pojo.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @Author: cdf
|
||||
* @CreateTime: 2026-01-06
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
public class MonitorCommLedgerInfoDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
private String monitorId;
|
||||
|
||||
private String monitorName;
|
||||
|
||||
private String gdName;
|
||||
|
||||
private String bdName;
|
||||
|
||||
private String busBarName;
|
||||
|
||||
private String voltageLevel;
|
||||
|
||||
private String shortCapacity;
|
||||
|
||||
private String devCapacity;
|
||||
|
||||
private String dealCapacity;
|
||||
|
||||
private String standardCapacity;
|
||||
|
||||
private Integer timeInterval;
|
||||
|
||||
}
|
||||
@@ -762,81 +762,6 @@ public class Overlimit implements Serializable {
|
||||
public Overlimit(){}
|
||||
|
||||
|
||||
public Overlimit(String lineId, String scaTmp, float fDLRL, float fJZRL, float fXYRL, float fSBRL){
|
||||
float[] fLimit = COverlimit.GetOverLimit(scaTmp, fDLRL, fJZRL, fXYRL, fSBRL);
|
||||
this.id=lineId;
|
||||
this.freqDev=fLimit[0];
|
||||
this.voltageDev=fLimit[1];
|
||||
this.ubalance=fLimit[2];
|
||||
this.flicker=fLimit[3];
|
||||
this.uaberrance=fLimit[4];
|
||||
this.uharm2=fLimit[5];
|
||||
this.uharm3=fLimit[6];
|
||||
this.uharm4=fLimit[7];
|
||||
this.uharm5=fLimit[8];
|
||||
this.uharm6=fLimit[9];
|
||||
this.uharm7=fLimit[10];
|
||||
this.uharm8=fLimit[11];
|
||||
this.uharm9=fLimit[12];
|
||||
this.uharm10=fLimit[13];
|
||||
this.uharm11=fLimit[14];
|
||||
this.uharm12=fLimit[15];
|
||||
this.uharm13=fLimit[16];
|
||||
this.uharm14=fLimit[17];
|
||||
this.uharm15=fLimit[18];
|
||||
this.uharm16=fLimit[19];
|
||||
this.uharm17=fLimit[20];
|
||||
this.uharm18=fLimit[21];
|
||||
this.uharm19=fLimit[22];
|
||||
this.uharm20=fLimit[23];
|
||||
this.uharm21=fLimit[24];
|
||||
this.uharm22=fLimit[25];
|
||||
this.uharm23=fLimit[26];
|
||||
this.uharm24=fLimit[27];
|
||||
this.uharm25=fLimit[28];
|
||||
this.iharm2=fLimit[29];
|
||||
this.iharm3=fLimit[30];
|
||||
this.iharm4=fLimit[31];
|
||||
this.iharm5=fLimit[32];
|
||||
this.iharm6=fLimit[33];
|
||||
this.iharm7=fLimit[34];
|
||||
this.iharm8=fLimit[35];
|
||||
this.iharm9=fLimit[36];
|
||||
this.iharm10=fLimit[37];
|
||||
this.iharm11=fLimit[38];
|
||||
this.iharm12=fLimit[39];
|
||||
this.iharm13=fLimit[40];
|
||||
this.iharm14=fLimit[41];
|
||||
this.iharm15=fLimit[42];
|
||||
this.iharm16=fLimit[43];
|
||||
this.iharm17=fLimit[44];
|
||||
this.iharm18=fLimit[45];
|
||||
this.iharm19=fLimit[46];
|
||||
this.iharm20=fLimit[47];
|
||||
this.iharm21=fLimit[48];
|
||||
this.iharm22=fLimit[49];
|
||||
this.iharm23=fLimit[50];
|
||||
this.iharm24=fLimit[51];
|
||||
this.iharm25=fLimit[52];
|
||||
this.uvoltageDev=fLimit[53];
|
||||
this.iNeg=fLimit[54];
|
||||
this.inuharm1=fLimit[55];
|
||||
this.inuharm2=fLimit[56];
|
||||
this.inuharm3=fLimit[57];
|
||||
this.inuharm4=fLimit[58];
|
||||
this.inuharm5=fLimit[59];
|
||||
this.inuharm6=fLimit[60];
|
||||
this.inuharm7=fLimit[61];
|
||||
this.inuharm8=fLimit[62];
|
||||
this.inuharm9=fLimit[63];
|
||||
this.inuharm10=fLimit[64];
|
||||
this.inuharm11=fLimit[65];
|
||||
this.inuharm12=fLimit[66];
|
||||
this.inuharm13=fLimit[67];
|
||||
this.inuharm14=fLimit[68];
|
||||
this.inuharm15=fLimit[69];
|
||||
this.inuharm16=fLimit[70];
|
||||
}
|
||||
|
||||
public void buildIHarm(Float[] iHarmTem){
|
||||
this.iharm2= iHarmTem[0];
|
||||
|
||||
@@ -57,8 +57,8 @@ public class COverlimitUtil {
|
||||
//配网
|
||||
Float[] iHarmTem = new Float[49];
|
||||
for (int i = 0; i <= 48; i++) {
|
||||
|
||||
iHarmTem[i] = -3.14159f;
|
||||
//目前只处理了配网II类测点,III类测点暂未处理,III类测点参考主网
|
||||
iHarmTem[i] = getHarmTag(i+2,voltageLevel).floatValue();
|
||||
}
|
||||
overlimit.buildIHarm(iHarmTem);
|
||||
overlimit.setINeg(-3.14159f);
|
||||
|
||||
@@ -42,6 +42,13 @@ public enum LineBaseEnum {
|
||||
POWER_FLAG_NOT(1,"非电网侧"),
|
||||
|
||||
|
||||
/**
|
||||
* 装置系统类型
|
||||
*/
|
||||
DEV_DATA_TYPE_ZT(0,"暂态系统装置"),
|
||||
DEV_DATA_TYPE_WT(1,"稳态系统装置"),
|
||||
DEV_DATA_TYPE_ALL(2,"全部系统装置")
|
||||
|
||||
|
||||
;
|
||||
|
||||
|
||||
@@ -136,6 +136,9 @@ public class AreaLineInfoVO implements Serializable {
|
||||
@ApiModelProperty(name = "objId",value = "对象id")
|
||||
private String objId;
|
||||
|
||||
@ApiModelProperty(name = "powerSubstationName", value = "电网侧变电站")
|
||||
private String powerSubstationName;
|
||||
|
||||
@ApiModelProperty(name = "vHarmonicValue",value = "污染值")
|
||||
private Double vHarmonicValue;
|
||||
|
||||
|
||||
@@ -0,0 +1,225 @@
|
||||
package com.njcn.device.pq.pojo.vo.dataClean;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @version 1.0.0
|
||||
* @author: chenchao
|
||||
* @date: 2022/07/18 11:04
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@EqualsAndHashCode
|
||||
public class DataVerifyExcel implements Serializable {
|
||||
|
||||
private String lineId;
|
||||
|
||||
@ColumnWidth(20)
|
||||
@ExcelProperty(value = "供电公司")
|
||||
@Excel(name = "供电公司")
|
||||
private String city;
|
||||
|
||||
@ColumnWidth(20)
|
||||
@ExcelProperty(value = "所属变电站")
|
||||
@Excel(name = "所属变电站")
|
||||
private String stationName;
|
||||
|
||||
|
||||
@ColumnWidth(20)
|
||||
@ExcelProperty(value = "终端名称")
|
||||
@Excel(name = "终端名称")
|
||||
private String devName;
|
||||
|
||||
@ColumnWidth(20)
|
||||
@ExcelProperty(value = "监测点名称")
|
||||
@Excel(name = "监测点名称")
|
||||
private String lineName;
|
||||
|
||||
|
||||
@ColumnWidth(20)
|
||||
@ExcelProperty(value = "IP")
|
||||
@Excel(name = "IP")
|
||||
private String ip;
|
||||
|
||||
@ColumnWidth(20)
|
||||
@ExcelProperty(value = "干扰源类型")
|
||||
@Excel(name = "干扰源类型")
|
||||
private String loadType;
|
||||
|
||||
|
||||
@ColumnWidth(20)
|
||||
@ExcelProperty(value = "监测对象名称")
|
||||
@Excel(name = "监测对象名称")
|
||||
private String objName;
|
||||
|
||||
|
||||
@ColumnWidth(20)
|
||||
@ExcelProperty(value = "电网侧变电站")
|
||||
@Excel(name = "电网侧变电站")
|
||||
private String powerSubstationName;
|
||||
|
||||
@ColumnWidth(20)
|
||||
@ExcelProperty(value = "厂商")
|
||||
@Excel(name = "厂商")
|
||||
private String manufacturer;
|
||||
|
||||
@ColumnWidth(20)
|
||||
@ExcelProperty(value = "总指标异常时间")
|
||||
@Excel(name = "总指标异常时间")
|
||||
private Integer allTime;
|
||||
|
||||
@ColumnWidth(20)
|
||||
@ExcelProperty(value = "频率")
|
||||
@Excel(name = "频率")
|
||||
private Integer freqTime;
|
||||
|
||||
@ColumnWidth(20)
|
||||
@ExcelProperty(value = "频率偏差")
|
||||
@Excel(name = "频率偏差")
|
||||
private Integer freqDevTime;
|
||||
|
||||
@ColumnWidth(20)
|
||||
@ExcelProperty(value = "相电压有效值")
|
||||
@Excel(name = "相电压有效值")
|
||||
private Integer vRmsTime;
|
||||
|
||||
@ColumnWidth(20)
|
||||
@ExcelProperty(value = "正序电压")
|
||||
@Excel(name = "正序电压")
|
||||
private Integer vPosTime;
|
||||
|
||||
@ColumnWidth(20)
|
||||
@ExcelProperty(value = "负序电压")
|
||||
@Excel(name = "负序电压")
|
||||
private Integer vNegTime;
|
||||
|
||||
@ColumnWidth(20)
|
||||
@ExcelProperty(value = "零序电压")
|
||||
@Excel(name = "零序电压")
|
||||
private Integer vZeroTime;
|
||||
|
||||
@ColumnWidth(20)
|
||||
@ExcelProperty(value = "电压不平衡度")
|
||||
@Excel(name = "电压不平衡度")
|
||||
private Integer vUnbalanceTime;
|
||||
|
||||
@ColumnWidth(20)
|
||||
@ExcelProperty(value = "线电压有效值")
|
||||
@Excel(name = "线电压有效值")
|
||||
private Integer rmsLvrTime;
|
||||
|
||||
@ColumnWidth(20)
|
||||
@ExcelProperty(value = "电压正偏差")
|
||||
@Excel(name = "电压正偏差")
|
||||
private Integer vuDevTime;
|
||||
|
||||
@ColumnWidth(20)
|
||||
@ExcelProperty(value = "电压负偏差")
|
||||
@Excel(name = "电压负偏差")
|
||||
private Integer vlDevTime;
|
||||
|
||||
@ColumnWidth(25)
|
||||
@ExcelProperty(value = "电压总谐波畸变率")
|
||||
@Excel(name = "电压总谐波畸变率")
|
||||
private Integer vThdTime;
|
||||
|
||||
@ColumnWidth(25)
|
||||
@ExcelProperty(value = "相电压基波有效值")
|
||||
@Excel(name = "相电压基波有效值")
|
||||
private Integer vTime;
|
||||
|
||||
@ColumnWidth(20)
|
||||
@ExcelProperty(value = "电流有效值")
|
||||
@Excel(name = "电流有效值")
|
||||
private Integer iRmsTime;
|
||||
|
||||
@ColumnWidth(20)
|
||||
@ExcelProperty(value = "长时闪变")
|
||||
@Excel(name = "长时闪变")
|
||||
private Integer pltTime;
|
||||
|
||||
@ColumnWidth(25)
|
||||
@ExcelProperty(value = "间谐波电压含有率")
|
||||
@Excel(name = "间谐波电压含有率")
|
||||
private Integer vInharmTime;
|
||||
|
||||
@ColumnWidth(25)
|
||||
@ExcelProperty(value = "谐波电压含有率")
|
||||
@Excel(name = "谐波电压含有率")
|
||||
private Integer vHarmTime;
|
||||
|
||||
@ColumnWidth(20)
|
||||
@ExcelProperty(value = "功率因数")
|
||||
@Excel(name = "功率因数")
|
||||
private Integer pfTime;
|
||||
|
||||
@ColumnWidth(20)
|
||||
@ExcelProperty(value = "谐波电压相角")
|
||||
@Excel(name = "谐波电压相角")
|
||||
private Integer vPhasicTime;
|
||||
|
||||
@ColumnWidth(20)
|
||||
@ExcelProperty(value = "谐波电压基波相角")
|
||||
@Excel(name = "谐波电压基波相角")
|
||||
private Integer v1PhasicTime;
|
||||
|
||||
@ColumnWidth(20)
|
||||
@ExcelProperty(value = "电压波动")
|
||||
@Excel(name = "电压波动")
|
||||
private Integer flucTime;
|
||||
|
||||
@ColumnWidth(20)
|
||||
@ExcelProperty(value = "短时闪变")
|
||||
@Excel(name = "短时闪变")
|
||||
private Integer pstTime;
|
||||
|
||||
@ColumnWidth(20)
|
||||
@ExcelProperty(value = "电压暂降")
|
||||
@Excel(name = "电压暂降")
|
||||
private Integer dipTime;
|
||||
|
||||
@ColumnWidth(20)
|
||||
@ExcelProperty(value = "电压暂升")
|
||||
@Excel(name = "电压暂升")
|
||||
private Integer riseTime;
|
||||
|
||||
|
||||
// 字段名 ↔ Excel列名 映射
|
||||
public static final Map<String, String> FIELD_COLUMN_MAP = new HashMap<>();
|
||||
static {
|
||||
// 按代码中字段顺序整理,确保一一对应
|
||||
FIELD_COLUMN_MAP.put("freqTime", "频率");
|
||||
FIELD_COLUMN_MAP.put("freqDevTime", "频率偏差");
|
||||
FIELD_COLUMN_MAP.put("vRmsTime", "相电压有效值");
|
||||
FIELD_COLUMN_MAP.put("vPosTime", "正序电压");
|
||||
FIELD_COLUMN_MAP.put("vNegTime", "负序电压");
|
||||
FIELD_COLUMN_MAP.put("vZeroTime", "零序电压");
|
||||
FIELD_COLUMN_MAP.put("vUnbalanceTime", "电压不平衡度");
|
||||
FIELD_COLUMN_MAP.put("rmsLvrTime", "线电压有效值");
|
||||
FIELD_COLUMN_MAP.put("vuDevTime", "电压正偏差");
|
||||
FIELD_COLUMN_MAP.put("vlDevTime", "电压负偏差");
|
||||
FIELD_COLUMN_MAP.put("vThdTime", "电压总谐波畸变率");
|
||||
FIELD_COLUMN_MAP.put("vTime", "相电压基波有效值");
|
||||
FIELD_COLUMN_MAP.put("iRmsTime", "电流有效值");
|
||||
FIELD_COLUMN_MAP.put("pltTime", "长时闪变");
|
||||
FIELD_COLUMN_MAP.put("vInharmTime", "间谐波电压含有率");
|
||||
FIELD_COLUMN_MAP.put("vHarmTime", "谐波电压含有率");
|
||||
FIELD_COLUMN_MAP.put("pfTime", "功率因数");
|
||||
FIELD_COLUMN_MAP.put("vPhasicTime", "谐波电压相角");
|
||||
FIELD_COLUMN_MAP.put("v1PhasicTime", "谐波电压基波相角");
|
||||
FIELD_COLUMN_MAP.put("flucTime", "电压波动");
|
||||
FIELD_COLUMN_MAP.put("pstTime", "短时闪变");
|
||||
FIELD_COLUMN_MAP.put("dipTime", "电压暂降");
|
||||
FIELD_COLUMN_MAP.put("riseTime", "电压暂升");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
package com.njcn.device.pq.utils;
|
||||
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.write.handler.SheetWriteHandler;
|
||||
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
|
||||
import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder;
|
||||
import com.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy;
|
||||
import com.njcn.device.pq.pojo.vo.dataClean.DataVerifyExcel;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 修复版:按数据量动态排序Excel列,解决列挤在一行的问题
|
||||
* 关键改动:表头构建方式 + 列宽匹配逻辑
|
||||
*/
|
||||
public class FixedDynamicExcelExport {
|
||||
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
// 1. 模拟测试数据(相电压数据量最多,频率次之,频率偏差最少)
|
||||
List<DataVerifyExcel> dataList = EasyExcel.read("F:\\usr\\response.xlsx")
|
||||
.head(DataVerifyExcel.class)
|
||||
.doReadAllSync();
|
||||
// 2. 导出Excel(替换为你的本地路径,比如桌面)
|
||||
dataList.sort(Comparator.comparing((DataVerifyExcel item) -> item.getCity() + "_" + item.getStationName()+"_"+item.getDevName())
|
||||
.thenComparing(DataVerifyExcel::getAllTime, Comparator.reverseOrder())
|
||||
);
|
||||
exportExcelByDataSize(dataList, "D:/dynamic_excel_fixed.xlsx");
|
||||
System.out.println("导出完成!打开桌面的「测试导出.xlsx」查看效果");
|
||||
}
|
||||
|
||||
/**
|
||||
* 核心方法:按数据量排序导出Excel
|
||||
*/
|
||||
public static void exportExcelByDataSize(List<DataVerifyExcel> dataList, String outputPath) throws Exception {
|
||||
// 步骤1:统计每个字段的有效数据量
|
||||
Map<String, Integer> fieldCount = countValidData(dataList);
|
||||
// 步骤2:按数据量降序排序字段名
|
||||
List<String> sortedFields = sortFields(fieldCount);
|
||||
// 步骤3:构建正确的动态表头
|
||||
List<List<String>> head = buildCorrectHead(sortedFields);
|
||||
// 步骤4:构建对应顺序的行数据
|
||||
List<List<Object>> data = buildRowData(dataList, sortedFields);
|
||||
|
||||
// 步骤5:导出Excel(含列宽设置)
|
||||
try (FileOutputStream out = new FileOutputStream(outputPath)) {
|
||||
EasyExcel.write(out)
|
||||
.head(head)
|
||||
.registerWriteHandler(new SimpleColumnWidthStyleStrategy(20))
|
||||
.registerWriteHandler(new FreezeHeaderHandler()) // 用修复后的表头
|
||||
.sheet("数据统计")
|
||||
.doWrite(data);
|
||||
}
|
||||
}
|
||||
|
||||
public static void exportExcelByDataSize(List<DataVerifyExcel> dataList, OutputStream outputStream) {
|
||||
// 步骤1:统计每个字段的有效数据量
|
||||
Map<String, Integer> fieldCount = countValidData(dataList);
|
||||
// 步骤2:按数据量降序排序字段名
|
||||
List<String> sortedFields = sortFields(fieldCount);
|
||||
// 步骤3:构建正确的动态表头
|
||||
List<List<String>> head = buildCorrectHead(sortedFields);
|
||||
// 步骤4:构建对应顺序的行数据
|
||||
List<List<Object>> data = buildRowData(dataList, sortedFields);
|
||||
|
||||
// 步骤5:导出Excel(含列宽设置)
|
||||
EasyExcel.write(outputStream)
|
||||
.head(head)
|
||||
.registerWriteHandler(new SimpleColumnWidthStyleStrategy(20))
|
||||
.registerWriteHandler(new FreezeHeaderHandler()) // 用修复后的表头
|
||||
.sheet("数据统计")
|
||||
.doWrite(data);
|
||||
}
|
||||
|
||||
public static class FreezeHeaderHandler implements SheetWriteHandler {
|
||||
@Override
|
||||
public void beforeSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) {
|
||||
// 表格创建前无需操作
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) {
|
||||
Sheet sheet = writeSheetHolder.getSheet();
|
||||
// freezePane(c, r):c=冻结列数,r=冻结行数;这里r=1表示冻结第1行(表头),c=0表示不冻结列
|
||||
// 比如 freezePane(1, 1) 表示冻结第一列+第一行
|
||||
sheet.createFreezePane(0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// ★ 修复点1:构建正确的表头(每个列名独立成List)
|
||||
private static List<List<String>> buildCorrectHead(List<String> allFields) {
|
||||
List<List<String>> head = new ArrayList<>();
|
||||
head.add(Collections.singletonList("供电公司"));
|
||||
head.add(Collections.singletonList("所属变电站"));
|
||||
head.add(Collections.singletonList("终端名称"));
|
||||
head.add(Collections.singletonList("监测点名称"));
|
||||
head.add(Collections.singletonList("IP"));
|
||||
head.add(Collections.singletonList("干扰源类型"));
|
||||
head.add(Collections.singletonList("监测对象名称"));
|
||||
head.add(Collections.singletonList("电网侧变电站"));
|
||||
head.add(Collections.singletonList("厂商"));
|
||||
head.add(Collections.singletonList("总指标异常时间"));
|
||||
List<String> sortedFields = allFields.subList(10, allFields.size());
|
||||
for (String field : sortedFields) {
|
||||
// 每个列名单独封装成List,EasyExcel才能识别为不同列
|
||||
head.add(Collections.singletonList(DataVerifyExcel.FIELD_COLUMN_MAP.get(field)));
|
||||
}
|
||||
return head;
|
||||
}
|
||||
|
||||
|
||||
// 统计有效数据量(无改动,保留)
|
||||
private static Map<String, Integer> countValidData(List<DataVerifyExcel> dataList) {
|
||||
// 1. 初始化计数字典(反射自动提取所有Time结尾的Integer字段,初始值0)
|
||||
Map<String, Integer> countMap = initCountMap();
|
||||
// 2. 判空,避免空指针异常
|
||||
if (dataList == null || dataList.isEmpty()) {
|
||||
return countMap;
|
||||
}
|
||||
// 3. 获取DataStatistic类的所有字段
|
||||
Field[] fields = DataVerifyExcel.class.getDeclaredFields();
|
||||
try {
|
||||
// 4. 遍历每个数据对象
|
||||
for (DataVerifyExcel data : dataList) {
|
||||
// 5. 遍历每个字段,累加数值
|
||||
for (Field field : fields) {
|
||||
// 过滤条件:Integer类型 + 以Time结尾
|
||||
if (field.getType() == Integer.class && field.getName().endsWith("Time") ) {
|
||||
if(!field.getName().equals("allTime")){
|
||||
// 设置可访问私有字段
|
||||
field.setAccessible(true);
|
||||
// 获取当前对象的该字段值
|
||||
Integer value = (Integer) field.get(data);
|
||||
// 非空则累加
|
||||
if (value != null) {
|
||||
String fieldName = field.getName();
|
||||
countMap.put(fieldName, countMap.get(fieldName) + value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
// 捕获反射访问异常,便于排查问题
|
||||
throw new RuntimeException("统计字段时反射访问失败", e);
|
||||
}
|
||||
return countMap;
|
||||
}
|
||||
|
||||
// 反射初始化计数字典(复用之前的逻辑)
|
||||
private static Map<String, Integer> initCountMap() {
|
||||
Map<String, Integer> countMap = new HashMap<>();
|
||||
Field[] fields = DataVerifyExcel.class.getDeclaredFields();
|
||||
for (Field field : fields) {
|
||||
if (field.getType() == Integer.class && field.getName().endsWith("Time")) {
|
||||
if(!field.getName().equals("allTime")){
|
||||
countMap.put(field.getName(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
return countMap;
|
||||
}
|
||||
|
||||
|
||||
// 按数据量排序字段(无改动,保留)
|
||||
private static List<String> sortFields(Map<String, Integer> fieldCount) {
|
||||
List<String> fields = new ArrayList<>(fieldCount.keySet());
|
||||
fields.sort((f1, f2) -> fieldCount.get(f2) - fieldCount.get(f1)); // 降序
|
||||
List<String> fieldAlls=new ArrayList<>();
|
||||
fieldAlls.add("city");
|
||||
fieldAlls.add("stationName");
|
||||
fieldAlls.add("devName");
|
||||
fieldAlls.add("lineName");
|
||||
fieldAlls.add("ip");
|
||||
fieldAlls.add("loadType");
|
||||
fieldAlls.add("objName");
|
||||
fieldAlls.add("powerSubstationName");
|
||||
fieldAlls.add("manufacturer");
|
||||
fieldAlls.add("allTime");
|
||||
fieldAlls.addAll(fields);
|
||||
return fieldAlls;
|
||||
}
|
||||
|
||||
// 构建行数据(无改动,保留)
|
||||
private static List<List<Object>> buildRowData(List<DataVerifyExcel> dataList, List<String> sortedFields) {
|
||||
List<List<Object>> rows = new ArrayList<>();
|
||||
for (DataVerifyExcel data : dataList) {
|
||||
List<Object> row = new ArrayList<>();
|
||||
for (String field : sortedFields) {
|
||||
try {
|
||||
Field f = DataVerifyExcel.class.getDeclaredField(field);
|
||||
f.setAccessible(true);
|
||||
row.add(f.get(data));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("导出异常数据转换异常:"+e);
|
||||
}
|
||||
}
|
||||
rows.add(row);
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import com.njcn.device.biz.pojo.po.PqsDeviceUnit;
|
||||
import com.njcn.device.line.mapper.LineMapper;
|
||||
import com.njcn.device.line.service.LineService;
|
||||
import com.njcn.device.line.mapper.LineDetailMapper;
|
||||
import com.njcn.device.biz.pojo.dto.MonitorCommLedgerInfoDTO;
|
||||
import com.njcn.device.pq.service.CommTerminalService;
|
||||
import com.njcn.device.pq.service.IPqsDeviceUnitService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
@@ -108,6 +109,23 @@ public class CommTerminalController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据部门id获取部门监测点台账信息
|
||||
* @param deptGetLineParam
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("deptGetLineInfo")
|
||||
@ApiOperation("根据部门id获取部门监测点台账信息")
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@ApiImplicitParam(name = "deptGetLineParam", value = "请求体", required = true)
|
||||
public HttpResult<List<MonitorCommLedgerInfoDTO>> deptGetLineInfo(@RequestBody @Validated DeptGetLineParam deptGetLineParam) {
|
||||
String methodDescribe = getMethodDescribe("deptGetLineInfo");
|
||||
List<MonitorCommLedgerInfoDTO> result = commTerminalService.deptGetLineInfo(deptGetLineParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("deptGetAllLine")
|
||||
@ApiOperation("根据单位获取监测点信息(all line)")
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
|
||||
@@ -16,18 +16,18 @@ import com.njcn.device.pq.service.IPqDataVerifyBakService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 异常数据功能
|
||||
* 异常数据功能
|
||||
* </p>
|
||||
*
|
||||
* @author cdf
|
||||
@@ -50,7 +50,7 @@ public class DataVerifyController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getMonitorVerifyData")
|
||||
@ApiOperation("异常-获取异常数据主页面")
|
||||
public HttpResult<VerifyMonitorVO> getMonitorVerifyData(@RequestBody MonitorBaseParam monitorBaseParam){
|
||||
public HttpResult<VerifyMonitorVO> getMonitorVerifyData(@RequestBody MonitorBaseParam monitorBaseParam) {
|
||||
String methodDescribe = getMethodDescribe("getMonitorVerifyData");
|
||||
VerifyMonitorVO verifyMonitorVO = iPqDataVerifyBakService.getMonitorVerifyData(monitorBaseParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, verifyMonitorVO, methodDescribe);
|
||||
@@ -59,7 +59,7 @@ public class DataVerifyController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getMonitorVerifyDay")
|
||||
@ApiOperation("异常-更新按钮-获取异常数据列表")
|
||||
public HttpResult<List<PowerQualityIndicatorsVO>> getMonitorVerifyDay(@RequestBody MonitorBaseParam monitorBaseParam){
|
||||
public HttpResult<List<PowerQualityIndicatorsVO>> getMonitorVerifyDay(@RequestBody MonitorBaseParam monitorBaseParam) {
|
||||
String methodDescribe = getMethodDescribe("getMonitorVerifyDay");
|
||||
List<PowerQualityIndicatorsVO> list = iPqDataVerifyBakService.getMonitorVerifyDay(monitorBaseParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
@@ -72,14 +72,13 @@ public class DataVerifyController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/monitorAbnormalTable")
|
||||
@ApiOperation("异常-弹框-获取异常监测点列表")
|
||||
public HttpResult<List<DetailAbnormalVO>> monitorAbnormalTable(@RequestBody MonitorBaseParam monitorBaseParam){
|
||||
public HttpResult<List<DetailAbnormalVO>> monitorAbnormalTable(@RequestBody MonitorBaseParam monitorBaseParam) {
|
||||
String methodDescribe = getMethodDescribe("monitorAbnormalDetail");
|
||||
List<DetailAbnormalVO> page = iPqDataVerifyBakService.monitorAbnormalTable(monitorBaseParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取稳态告警监测点相关信息
|
||||
*/
|
||||
@@ -93,14 +92,13 @@ public class DataVerifyController extends BaseController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取稳态告警数据
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getMonitorLimitData")
|
||||
@ApiOperation("获取稳态告警数据")
|
||||
public HttpResult<VerifyMonitorVO> getMonitorLimitData(@RequestBody MonitorBaseParam monitorBaseParam){
|
||||
public HttpResult<VerifyMonitorVO> getMonitorLimitData(@RequestBody MonitorBaseParam monitorBaseParam) {
|
||||
String methodDescribe = getMethodDescribe("getMonitorLimitData");
|
||||
VerifyMonitorVO verifyMonitorVO = iDataVerifyService.getMonitorLimitData(monitorBaseParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, verifyMonitorVO, methodDescribe);
|
||||
@@ -109,7 +107,7 @@ public class DataVerifyController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getMonitorLimitDataDay")
|
||||
@ApiOperation("更新按钮-获取稳态告警数据")
|
||||
public HttpResult<List<PowerQualityIndicatorsVO>> getMonitorLimitDataDay(@RequestBody MonitorBaseParam monitorBaseParam){
|
||||
public HttpResult<List<PowerQualityIndicatorsVO>> getMonitorLimitDataDay(@RequestBody MonitorBaseParam monitorBaseParam) {
|
||||
String methodDescribe = getMethodDescribe("getMonitorLimitDataDay");
|
||||
List<PowerQualityIndicatorsVO> verifyMonitorVO = iDataVerifyService.getMonitorLimitDataDay(monitorBaseParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, verifyMonitorVO, methodDescribe);
|
||||
@@ -121,7 +119,7 @@ public class DataVerifyController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/monitorLimitTable")
|
||||
@ApiOperation("弹框-获取稳态告警监测点列表")
|
||||
public HttpResult<List<DetailAbnormalVO>> monitorLimitTable(@RequestBody MonitorBaseParam monitorBaseParam){
|
||||
public HttpResult<List<DetailAbnormalVO>> monitorLimitTable(@RequestBody MonitorBaseParam monitorBaseParam) {
|
||||
String methodDescribe = getMethodDescribe("monitorLimitTable");
|
||||
List<DetailAbnormalVO> list = iDataVerifyService.monitorLimitTable(monitorBaseParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
@@ -134,7 +132,7 @@ public class DataVerifyController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/monitorLimitTableDetail")
|
||||
@ApiOperation("弹框-获取稳态告警监测点列表详情")
|
||||
public HttpResult<DetailAbnormalVO.DetailLimitCountVO> monitorLimitTableDetail(@RequestBody MonitorBaseParam monitorBaseParam){
|
||||
public HttpResult<DetailAbnormalVO.DetailLimitCountVO> monitorLimitTableDetail(@RequestBody MonitorBaseParam monitorBaseParam) {
|
||||
String methodDescribe = getMethodDescribe("monitorLimitTableDetail");
|
||||
DetailAbnormalVO.DetailLimitCountVO list = iDataVerifyService.monitorLimitTableDetail(monitorBaseParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
@@ -150,5 +148,16 @@ public class DataVerifyController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/dataVerifyExcel")
|
||||
@ApiOperation(value = "导出异常监测点列表", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||
public void dataVerifyExcel(HttpServletResponse response, MonitorBaseParam monitorBaseParam) throws IOException {
|
||||
response.setContentType("application/vnd.ms-excel");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
iPqDataVerifyBakService.dataVerifyExcel(response, monitorBaseParam);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
package com.njcn.device.pq.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.device.pq.pojo.param.dataClean.MonitorBaseParam;
|
||||
import com.njcn.device.pq.pojo.po.PqDataVerifyBak;
|
||||
import com.njcn.device.pq.pojo.vo.dataClean.DataVerifyExcel;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -13,4 +18,5 @@ import com.njcn.device.pq.pojo.po.PqDataVerifyBak;
|
||||
*/
|
||||
public interface PqDataVerifyBakMapper extends BaseMapper<PqDataVerifyBak> {
|
||||
|
||||
List<DataVerifyExcel> selectDataVerifySum(@Param("param") MonitorBaseParam monitorBaseParam);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
<?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.device.pq.mapper.PqDataVerifyBakMapper">
|
||||
|
||||
<select id="selectDataVerifySum" resultType="com.njcn.device.pq.pojo.vo.dataClean.DataVerifyExcel">
|
||||
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
(select
|
||||
line_id AS lineId,
|
||||
(
|
||||
sum( freq_time ) +
|
||||
sum( freq_Dev_time ) +
|
||||
sum( v_Rms_time )+
|
||||
sum( v_Pos_time ) +
|
||||
sum( v_Neg_time )+
|
||||
sum( v_Zero_time )+
|
||||
sum( v_Unbalance_time )+
|
||||
sum( rms_Lvr_time ) +
|
||||
sum( vu_Dev_time ) +
|
||||
sum( vl_Dev_time ) +
|
||||
sum( v_Thd_time ) +
|
||||
sum( v_time ) +
|
||||
sum( i_Rms_time ) +
|
||||
sum( plt_time ) +
|
||||
sum( v_Inharm_time ) +
|
||||
sum( v_Harm_time )+
|
||||
sum( pf_time ) +
|
||||
sum( v_Phasic_time ) +
|
||||
sum( v1_Phasic_time ) +
|
||||
sum( fluc_time )+
|
||||
sum( pst_time ) +
|
||||
sum( dip_time ) +
|
||||
sum( rise_time )
|
||||
) allTime,
|
||||
sum( freq_time ) AS freqTime,
|
||||
sum( freq_Dev_time ) AS freqDevTime,
|
||||
sum( v_Rms_time ) AS vRmsTime,
|
||||
sum( v_Pos_time ) AS vPosTime,
|
||||
sum( v_Neg_time ) AS vNegTime,
|
||||
sum( v_Zero_time ) AS vZeroTime,
|
||||
sum( v_Unbalance_time ) AS vUnbalanceTime,
|
||||
sum( rms_Lvr_time ) AS rmsLvrTime,
|
||||
sum( vu_Dev_time ) AS vuDevTime,
|
||||
sum( vl_Dev_time ) AS vlDevTime,
|
||||
sum( v_Thd_time ) AS vThdTime,
|
||||
sum( v_time ) AS vTime,
|
||||
sum( i_Rms_time ) AS iRmsTime,
|
||||
sum( plt_time ) AS pltTime,
|
||||
sum( v_Inharm_time ) AS vInharmTime,
|
||||
sum( v_Harm_time ) AS vHarmTime,
|
||||
sum( pf_time ) AS pfTime,
|
||||
sum( v_Phasic_time ) AS vPhasicTime,
|
||||
sum( v1_Phasic_time ) AS v1PhasicTime,
|
||||
sum( fluc_time ) AS flucTime,
|
||||
sum( pst_time ) AS pstTime,
|
||||
sum( dip_time ) AS dipTime,
|
||||
sum( rise_time ) AS riseTime
|
||||
from
|
||||
pq_data_verify_bak
|
||||
<where>
|
||||
state = 1
|
||||
<if test="param.monitorIds != null and param.monitorIds.size > 0">
|
||||
AND line_id IN
|
||||
<foreach collection='param.monitorIds' item='item' index="index" open='(' separator=',' close=')'>
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="param.searchBeginTime != null and param.searchBeginTime !=''">
|
||||
AND time_id >= #{param.searchBeginTime}
|
||||
</if>
|
||||
<if test="param.searchEndTime != null and param.searchEndTime != ''">
|
||||
AND time_id <= #{param.searchEndTime}
|
||||
</if>
|
||||
|
||||
</where>
|
||||
GROUP BY line_id
|
||||
) a
|
||||
WHERE
|
||||
allTime >0
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -15,6 +15,7 @@
|
||||
STATUS = 1
|
||||
</select>
|
||||
<select id="sortTransformer" resultType="java.lang.Integer">
|
||||
select IFNULL(max(pqs_transformer.sort),0) from pqs_transformer order by update_time desc
|
||||
select IFNULL(max(pqs_transformer.sort),0) from pqs_transformer
|
||||
<!-- order by update_time desc-->
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -3,8 +3,8 @@ package com.njcn.device.pq.service;
|
||||
import com.njcn.device.biz.pojo.dto.*;
|
||||
import com.njcn.device.biz.pojo.param.DeptGetLineParam;
|
||||
import com.njcn.device.biz.pojo.param.SubstationParam;
|
||||
import com.njcn.device.biz.pojo.dto.MonitorCommLedgerInfoDTO;
|
||||
import com.njcn.device.pq.pojo.param.dataClean.MonitorBaseParam;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -40,6 +40,9 @@ public interface CommTerminalService {
|
||||
*/
|
||||
List<DeptGetChildrenMoreDTO> deptGetLine(DeptGetLineParam deptGetLineParam);
|
||||
|
||||
|
||||
List<MonitorCommLedgerInfoDTO> deptGetLineInfo(DeptGetLineParam deptGetLineParam);
|
||||
|
||||
List<DeptGetChildrenMoreDTO> deptGetAllLine(DeptGetLineParam deptGetLineParam);
|
||||
|
||||
List<LineDevGetDTO> deptGetLineByIdList(List<String> monitorIds);
|
||||
|
||||
@@ -7,6 +7,8 @@ import com.njcn.device.pq.pojo.vo.dataClean.DetailAbnormalVO;
|
||||
import com.njcn.device.pq.pojo.vo.dataClean.PowerQualityIndicatorsVO;
|
||||
import com.njcn.device.pq.pojo.vo.dataClean.VerifyMonitorVO;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -30,6 +32,6 @@ public interface IPqDataVerifyBakService extends IService<PqDataVerifyBak> {
|
||||
DetailAbnormalVO.DetailAbnormalCountVO monitorAbnormalTableDetail(MonitorBaseParam monitorBaseParam);
|
||||
|
||||
|
||||
|
||||
void dataVerifyExcel(HttpServletResponse response, MonitorBaseParam monitorBaseParam) throws IOException;
|
||||
|
||||
}
|
||||
|
||||
@@ -11,9 +11,10 @@ import com.njcn.common.utils.EnumUtils;
|
||||
import com.njcn.device.biz.pojo.dto.*;
|
||||
import com.njcn.device.biz.pojo.param.DeptGetLineParam;
|
||||
import com.njcn.device.biz.pojo.param.SubstationParam;
|
||||
import com.njcn.device.line.mapper.DeptLineMapper;
|
||||
import com.njcn.device.line.mapper.LineMapper;
|
||||
import com.njcn.device.line.service.DeptLineService;
|
||||
import com.njcn.device.pq.enums.RunFlagEnum;
|
||||
import com.njcn.device.biz.pojo.dto.MonitorCommLedgerInfoDTO;
|
||||
import com.njcn.device.pq.pojo.param.dataClean.MonitorBaseParam;
|
||||
import com.njcn.device.pq.service.CommTerminalService;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
@@ -28,6 +29,8 @@ import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static com.njcn.device.pq.enums.LineBaseEnum.DEV_DATA_TYPE_ALL;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
*
|
||||
@@ -49,6 +52,7 @@ public class CommTerminalServiceImpl implements CommTerminalService {
|
||||
private final RedisUtil redisUtil;
|
||||
|
||||
private final LineMapper lineMapper;
|
||||
private final DeptLineMapper deptLineMapper;
|
||||
|
||||
|
||||
/**
|
||||
@@ -59,10 +63,6 @@ public class CommTerminalServiceImpl implements CommTerminalService {
|
||||
*/
|
||||
@Override
|
||||
public List<DeptGetBase> getDeptChildrenByParent(DeptGetLineParam deptGetLineParam) {
|
||||
/*List<DeptGetBase> redisResult = (List<DeptGetBase>) redisUtil.getObjectByKey(commTerminal + deptGetLineParam.getDeptId());
|
||||
if (CollectionUtil.isNotEmpty(redisResult)) {
|
||||
return redisResult;
|
||||
}*/
|
||||
List<DeptGetBase> result = new ArrayList<>();
|
||||
List<DeptDTO> deptDTOList = deptFeignClient.getDeptDescendantIndexes(deptGetLineParam.getDeptId(), Stream.of(0, 1).collect(Collectors.toList())).getData();
|
||||
deptDTOList.forEach(it -> {
|
||||
@@ -119,6 +119,13 @@ public class CommTerminalServiceImpl implements CommTerminalService {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MonitorCommLedgerInfoDTO> deptGetLineInfo(DeptGetLineParam deptGetLineParam) {
|
||||
List<String> deptIds = deptFeignClient.getDepSonIdtByDeptId(deptGetLineParam.getDeptId()).getData();
|
||||
List<MonitorCommLedgerInfoDTO> ledgerList = deptLineMapper.getMonitorByDeptIds(Stream.of(DEV_DATA_TYPE_ALL.getCode()).collect(Collectors.toList()),deptIds);
|
||||
return ledgerList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeptGetChildrenMoreDTO> deptGetAllLine(DeptGetLineParam deptGetLineParam) {
|
||||
List<DeptGetChildrenMoreDTO> result = new ArrayList<>();
|
||||
|
||||
@@ -10,6 +10,7 @@ import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONConfig;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONTokener;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@@ -28,19 +29,19 @@ import com.njcn.device.pq.pojo.po.DeptLine;
|
||||
import com.njcn.device.pq.pojo.po.PqDataVerifyBak;
|
||||
import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
|
||||
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
|
||||
import com.njcn.device.pq.pojo.vo.dataClean.DetailAbnormalVO;
|
||||
import com.njcn.device.pq.pojo.vo.dataClean.PowerQualityIndicatorsVO;
|
||||
import com.njcn.device.pq.pojo.vo.dataClean.VerifyMonitorVO;
|
||||
import com.njcn.device.pq.pojo.vo.dataClean.VerifyTargetVO;
|
||||
import com.njcn.device.pq.pojo.vo.dataClean.*;
|
||||
import com.njcn.device.pq.service.CommTerminalService;
|
||||
import com.njcn.device.pq.service.IPqDataVerifyBakService;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import com.njcn.poi.excel.ExcelUtil;
|
||||
import com.njcn.supervision.api.UserLedgerFeignClient;
|
||||
import com.njcn.system.api.DictTreeFeignClient;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
@@ -50,6 +51,8 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.njcn.device.pq.utils.FixedDynamicExcelExport.exportExcelByDataSize;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
@@ -75,7 +78,7 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
|
||||
|
||||
@Override
|
||||
public VerifyMonitorVO getMonitorVerifyData(MonitorBaseParam monitorBaseParam) {
|
||||
if(Objects.isNull(monitorBaseParam.getErrorTimeCount())){
|
||||
if (Objects.isNull(monitorBaseParam.getErrorTimeCount())) {
|
||||
monitorBaseParam.setErrorTimeCount(720);
|
||||
}
|
||||
List<String> monitorIds = commTerminalService.getRunMonitorByDept(monitorBaseParam);
|
||||
@@ -86,13 +89,13 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
|
||||
verifyMonitorVO.setAbnormalNum(dataVerifyList.stream().collect(Collectors.groupingBy(PqDataVerifyBak::getLineId)).size());
|
||||
// List<PqDataVerifyBak> dataSumVerifyList = baseDataSumVerifyQuery(monitorIds, monitorBaseParam);
|
||||
verifyMonitorVO.setMapList(getRangeAbnormalMonitor(monitorBaseParam, dataVerifyList));
|
||||
verifyMonitorVO.setTargetList(getAbnormalTarget(dataVerifyList,monitorBaseParam.getErrorTimeCount()));
|
||||
verifyMonitorVO.setTargetList(getAbnormalTarget(dataVerifyList, monitorBaseParam.getErrorTimeCount()));
|
||||
verifyMonitorVO.setMonitorAlarmInfo(getAbnormalTable(dataVerifyList, monitorBaseParam));
|
||||
} else {
|
||||
verifyMonitorVO.setRunNum(0);
|
||||
verifyMonitorVO.setAbnormalNum(0);
|
||||
verifyMonitorVO.setMapList(getRangeAbnormalMonitor(monitorBaseParam, new ArrayList<>()));
|
||||
verifyMonitorVO.setTargetList(getAbnormalTarget(new ArrayList<>(),monitorBaseParam.getErrorTimeCount()));
|
||||
verifyMonitorVO.setTargetList(getAbnormalTarget(new ArrayList<>(), monitorBaseParam.getErrorTimeCount()));
|
||||
verifyMonitorVO.setMonitorAlarmInfo(getAbnormalTable(new ArrayList<>(), monitorBaseParam));
|
||||
}
|
||||
|
||||
@@ -152,7 +155,7 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
|
||||
it.setMonitorName(lineDetail.getLineName());
|
||||
it.setStationName(lineDetail.getSubName());
|
||||
it.setDevName(lineDetail.getDeviceName());
|
||||
if(deptName.containsKey(lineDetail.getLineId())){
|
||||
if (deptName.containsKey(lineDetail.getLineId())) {
|
||||
it.setCity(deptName.get(lineDetail.getLineId()));
|
||||
}
|
||||
it.setVoltageLevel(lineDetail.getVoltageScale());
|
||||
@@ -183,7 +186,7 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
|
||||
|
||||
@Override
|
||||
public List<DetailAbnormalVO> monitorAbnormalTable(MonitorBaseParam monitorBaseParam) {
|
||||
if(Objects.isNull(monitorBaseParam.getErrorTimeCount())){
|
||||
if (Objects.isNull(monitorBaseParam.getErrorTimeCount())) {
|
||||
monitorBaseParam.setErrorTimeCount(720);
|
||||
}
|
||||
List<DetailAbnormalVO> result = new ArrayList<>();
|
||||
@@ -297,7 +300,7 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
|
||||
for (PqDataVerifyBak pqDataVerifyBak : value) {
|
||||
targetKey = new DetailAbnormalVO.TimeAndTargetKey();
|
||||
targetKey.setDate(pqDataVerifyBak.getTimeId().format(DatePattern.NORM_DATE_FORMATTER));
|
||||
targetKey.setTargetKeys(getAbnormalTarget(Arrays.asList(pqDataVerifyBak),monitorBaseParam.getErrorTimeCount()).stream().filter(x->x.getIds().size()>0).collect(Collectors.toList()));
|
||||
targetKey.setTargetKeys(getAbnormalTarget(Arrays.asList(pqDataVerifyBak), monitorBaseParam.getErrorTimeCount()).stream().filter(x -> x.getIds().size() > 0).collect(Collectors.toList()));
|
||||
targetKeyList.add(targetKey);
|
||||
}
|
||||
detailAbnormalVO.setDateTargetList(targetKeyList);
|
||||
@@ -331,11 +334,11 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
|
||||
for (PqDataVerifyBak dataVerifyBak : pqDataVerifyBak) {
|
||||
try (InputStream fileStream = fileStorageUtil.getFileStream(dataVerifyBak.getPath())) {
|
||||
JSONArray jsonArray = new JSONArray(new JSONTokener(fileStream, new JSONConfig()));
|
||||
jsonArray.forEach(it->{
|
||||
jsonArray.forEach(it -> {
|
||||
JSONObject targetJson = (JSONObject) it;
|
||||
if (targetJson.containsKey("lineErrorTimes")) {
|
||||
errorTimeCount[0] += Integer.valueOf(targetJson.get("lineErrorTimes").toString());
|
||||
}else{
|
||||
} else {
|
||||
if (StrUtil.isNotBlank(monitorBaseParam.getTargetKey())) {
|
||||
if (targetJson.containsKey(monitorBaseParam.getTargetKey())) {
|
||||
resultDeal(dtoMap, monitorBaseParam.getTargetKey(), targetJson, result, dataVerifyBak.getTimeId().toString(), errorTimeCount, errAllCount);
|
||||
@@ -367,6 +370,42 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
|
||||
return info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dataVerifyExcel(HttpServletResponse response, MonitorBaseParam monitorBaseParam) throws IOException {
|
||||
if (StrUtil.isNotBlank(monitorBaseParam.getDeptId())) {
|
||||
List<String> monitorIds = commTerminalService.getRunMonitorByDept(monitorBaseParam);
|
||||
monitorBaseParam.setMonitorIds(monitorIds);
|
||||
}
|
||||
List<DataVerifyExcel> dataVerifyExcels = this.baseMapper.selectDataVerifySum(monitorBaseParam);
|
||||
List<String> ids = dataVerifyExcels.stream().map(DataVerifyExcel::getLineId).collect(Collectors.toList());
|
||||
List<AreaLineInfoVO> areaLineInfoVOList = lineMapper.getBaseLineAreaInfo(ids, null, null);
|
||||
Map<String, AreaLineInfoVO> map = areaLineInfoVOList.stream().collect(Collectors.toMap(AreaLineInfoVO::getLineId, Function.identity()));
|
||||
for (DataVerifyExcel dataVerifyExcel : dataVerifyExcels) {
|
||||
if (map.containsKey(dataVerifyExcel.getLineId())) {
|
||||
AreaLineInfoVO areaLineInfoVO = map.get(dataVerifyExcel.getLineId());
|
||||
dataVerifyExcel.setCity(areaLineInfoVO.getGdName());
|
||||
dataVerifyExcel.setLineName(areaLineInfoVO.getLineName());
|
||||
dataVerifyExcel.setLoadType(areaLineInfoVO.getLoadType());
|
||||
dataVerifyExcel.setObjName(areaLineInfoVO.getObjName());
|
||||
dataVerifyExcel.setStationName(areaLineInfoVO.getSubName());
|
||||
dataVerifyExcel.setPowerSubstationName(areaLineInfoVO.getPowerSubstationName());
|
||||
dataVerifyExcel.setDevName(areaLineInfoVO.getDeviceName());
|
||||
dataVerifyExcel.setIp(areaLineInfoVO.getIp());
|
||||
dataVerifyExcel.setManufacturer(areaLineInfoVO.getManufacturer());
|
||||
}
|
||||
}
|
||||
dataVerifyExcels.sort(Comparator
|
||||
.comparing(DataVerifyExcel::getAllTime, Comparator.reverseOrder())
|
||||
.thenComparing((DataVerifyExcel item) -> item.getCity() + "_" + item.getStationName()+"_"+item.getDevName())
|
||||
);
|
||||
exportExcelByDataSize(dataVerifyExcels,response.getOutputStream());
|
||||
// Set<String> excludeColumnFiledNames = new HashSet<>(1);
|
||||
// excludeColumnFiledNames.add("lineId");
|
||||
// EasyExcel.write(response.getOutputStream(), DataVerifyExcel.class)
|
||||
// .excludeColumnFiledNames(excludeColumnFiledNames).sheet("sheet")
|
||||
// .doWrite(dataVerifyExcels);
|
||||
}
|
||||
|
||||
|
||||
private static final Pattern HARMONIC_PATTERN = Pattern.compile("(\\d+)次谐波");
|
||||
|
||||
@@ -441,7 +480,7 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
|
||||
// if ((DataCleanEnum.DataI.getCode() + SEPARATOR + DataCleanEnum.RmsI.getCode() ).equals(targetKey)) {
|
||||
// vo.setRangeDesc(pqReasonableRangeDto.getMinValue() + unit + " ~ " + pqReasonableRangeDto.getMaxValue() + "*CT1" + unit);
|
||||
// } else {
|
||||
vo.setRangeDesc(pqReasonableRangeDto.getMinValue() + unit + " ~ " + pqReasonableRangeDto.getMaxValue() + unit);
|
||||
vo.setRangeDesc(pqReasonableRangeDto.getMinValue() + unit + " ~ " + pqReasonableRangeDto.getMaxValue() + unit);
|
||||
// }
|
||||
valueList.forEach(ites -> {
|
||||
switch (ites.getType()) {
|
||||
@@ -471,6 +510,9 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
|
||||
|
||||
|
||||
private List<PqDataVerifyBak> baseDataVerifyQuery(List<String> monitorIds, MonitorBaseParam monitorBaseParam) {
|
||||
if (Objects.isNull(monitorBaseParam.getErrorTimeCount())) {
|
||||
monitorBaseParam.setErrorTimeCount(720);
|
||||
}
|
||||
LambdaQueryWrapper<PqDataVerifyBak> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.between(PqDataVerifyBak::getTimeId, DateUtil.beginOfDay(DateUtil.parse(monitorBaseParam.getSearchBeginTime())), DateUtil.endOfDay(DateUtil.parse(monitorBaseParam.getSearchEndTime())))
|
||||
.in(PqDataVerifyBak::getLineId, monitorIds)
|
||||
@@ -620,102 +662,102 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
|
||||
/**
|
||||
* 指标异常测点数量
|
||||
*/
|
||||
public List<VerifyTargetVO> getAbnormalTarget(List<PqDataVerifyBak> dataVerifyList,Integer errorTimeCount) {
|
||||
public List<VerifyTargetVO> getAbnormalTarget(List<PqDataVerifyBak> dataVerifyList, Integer errorTimeCount) {
|
||||
List<VerifyTargetVO> result = new ArrayList<>();
|
||||
Map<String, PqReasonableRangeDto> rangeMap = getStandRange();
|
||||
rangeMap.forEach((key, dto) -> {
|
||||
Set<String> ids;
|
||||
switch (key) {
|
||||
case Param.freq:
|
||||
ids = dataVerifyList.stream().filter(x-> ObjUtil.isNotNull(x.getFreqTime())).filter(it -> it.getFreqTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
ids = dataVerifyList.stream().filter(x -> ObjUtil.isNotNull(x.getFreqTime())).filter(it -> it.getFreqTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
assembleEntity(ids, dto, result);
|
||||
break;
|
||||
case Param.freq_dev:
|
||||
ids = dataVerifyList.stream().filter(x-> ObjUtil.isNotNull(x.getFreqDevTime())).filter(it -> it.getFreqDevTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
ids = dataVerifyList.stream().filter(x -> ObjUtil.isNotNull(x.getFreqDevTime())).filter(it -> it.getFreqDevTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
assembleEntity(ids, dto, result);
|
||||
break;
|
||||
case Param.rms_v:
|
||||
ids = dataVerifyList.stream().filter(x-> ObjUtil.isNotNull(x.getVRmsTime())).filter(it -> it.getVRmsTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
ids = dataVerifyList.stream().filter(x -> ObjUtil.isNotNull(x.getVRmsTime())).filter(it -> it.getVRmsTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
assembleEntity(ids, dto, result);
|
||||
break;
|
||||
case Param.rms_lvr:
|
||||
ids = dataVerifyList.stream().filter(x-> ObjUtil.isNotNull(x.getRmsLvrTime())).filter(it -> it.getRmsLvrTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
ids = dataVerifyList.stream().filter(x -> ObjUtil.isNotNull(x.getRmsLvrTime())).filter(it -> it.getRmsLvrTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
assembleEntity(ids, dto, result);
|
||||
break;
|
||||
case Param.vu_dev:
|
||||
ids = dataVerifyList.stream().filter(x-> ObjUtil.isNotNull(x.getVuDevTime())).filter(it -> it.getVuDevTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
ids = dataVerifyList.stream().filter(x -> ObjUtil.isNotNull(x.getVuDevTime())).filter(it -> it.getVuDevTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
assembleEntity(ids, dto, result);
|
||||
break;
|
||||
case Param.vl_dev:
|
||||
ids = dataVerifyList.stream().filter(x-> ObjUtil.isNotNull(x.getVlDevTime())).filter(it -> it.getVlDevTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
ids = dataVerifyList.stream().filter(x -> ObjUtil.isNotNull(x.getVlDevTime())).filter(it -> it.getVlDevTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
assembleEntity(ids, dto, result);
|
||||
break;
|
||||
case Param.rms_i:
|
||||
ids = dataVerifyList.stream().filter(x-> ObjUtil.isNotNull(x.getIRmsTime())).filter(it -> it.getIRmsTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
ids = dataVerifyList.stream().filter(x -> ObjUtil.isNotNull(x.getIRmsTime())).filter(it -> it.getIRmsTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
assembleEntity(ids, dto, result);
|
||||
break;
|
||||
case Param.v_thd:
|
||||
ids = dataVerifyList.stream().filter(x-> ObjUtil.isNotNull(x.getVThdTime())).filter(it -> it.getVThdTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
ids = dataVerifyList.stream().filter(x -> ObjUtil.isNotNull(x.getVThdTime())).filter(it -> it.getVThdTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
assembleEntity(ids, dto, result);
|
||||
break;
|
||||
case Param.v_1_v:
|
||||
ids = dataVerifyList.stream().filter(x-> ObjUtil.isNotNull(x.getVTime())).filter(it -> it.getVTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
ids = dataVerifyList.stream().filter(x -> ObjUtil.isNotNull(x.getVTime())).filter(it -> it.getVTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
assembleEntity(ids, dto, result);
|
||||
break;
|
||||
case Param.phasic_v_1:
|
||||
ids = dataVerifyList.stream().filter(x-> ObjUtil.isNotNull(x.getV1PhasicTime())).filter(it -> it.getV1PhasicTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
ids = dataVerifyList.stream().filter(x -> ObjUtil.isNotNull(x.getV1PhasicTime())).filter(it -> it.getV1PhasicTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
assembleEntity(ids, dto, result);
|
||||
break;
|
||||
case Param.phasic_rate_x:
|
||||
ids = dataVerifyList.stream().filter(x-> ObjUtil.isNotNull(x.getVPhasicTime())).filter(it -> it.getVPhasicTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
ids = dataVerifyList.stream().filter(x -> ObjUtil.isNotNull(x.getVPhasicTime())).filter(it -> it.getVPhasicTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
assembleEntity(ids, dto, result);
|
||||
break;
|
||||
case Param.v_rate:
|
||||
ids = dataVerifyList.stream().filter(x-> ObjUtil.isNotNull(x.getVHarmTime())).filter(it -> it.getVHarmTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
ids = dataVerifyList.stream().filter(x -> ObjUtil.isNotNull(x.getVHarmTime())).filter(it -> it.getVHarmTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
assembleEntity(ids, dto, result);
|
||||
break;
|
||||
case Param.in_v_rate:
|
||||
ids = dataVerifyList.stream().filter(x-> ObjUtil.isNotNull(x.getVInharmTime())).filter(it -> it.getVInharmTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
ids = dataVerifyList.stream().filter(x -> ObjUtil.isNotNull(x.getVInharmTime())).filter(it -> it.getVInharmTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
assembleEntity(ids, dto, result);
|
||||
break;
|
||||
case Param.v_zero:
|
||||
ids = dataVerifyList.stream().filter(x-> ObjUtil.isNotNull(x.getVZeroTime())).filter(it -> it.getVZeroTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
ids = dataVerifyList.stream().filter(x -> ObjUtil.isNotNull(x.getVZeroTime())).filter(it -> it.getVZeroTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
assembleEntity(ids, dto, result);
|
||||
break;
|
||||
case Param.v_neg:
|
||||
ids = dataVerifyList.stream().filter(x-> ObjUtil.isNotNull(x.getVNegTime())).filter(it -> it.getVNegTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
ids = dataVerifyList.stream().filter(x -> ObjUtil.isNotNull(x.getVNegTime())).filter(it -> it.getVNegTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
assembleEntity(ids, dto, result);
|
||||
break;
|
||||
case Param.v_pos:
|
||||
ids = dataVerifyList.stream().filter(x-> ObjUtil.isNotNull(x.getVPosTime())).filter(it -> it.getVPosTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
ids = dataVerifyList.stream().filter(x -> ObjUtil.isNotNull(x.getVPosTime())).filter(it -> it.getVPosTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
assembleEntity(ids, dto, result);
|
||||
break;
|
||||
case Param.v_unbalance:
|
||||
ids = dataVerifyList.stream().filter(x-> ObjUtil.isNotNull(x.getVUnbalanceTime())).filter(it -> it.getVUnbalanceTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
ids = dataVerifyList.stream().filter(x -> ObjUtil.isNotNull(x.getVUnbalanceTime())).filter(it -> it.getVUnbalanceTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
assembleEntity(ids, dto, result);
|
||||
break;
|
||||
case Param.fluc:
|
||||
ids = dataVerifyList.stream().filter(x-> ObjUtil.isNotNull(x.getFlucTime())).filter(it -> it.getFlucTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
ids = dataVerifyList.stream().filter(x -> ObjUtil.isNotNull(x.getFlucTime())).filter(it -> it.getFlucTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
assembleEntity(ids, dto, result);
|
||||
break;
|
||||
case Param.pst:
|
||||
ids = dataVerifyList.stream().filter(x-> ObjUtil.isNotNull(x.getPstTime())).filter(it -> it.getPstTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
ids = dataVerifyList.stream().filter(x -> ObjUtil.isNotNull(x.getPstTime())).filter(it -> it.getPstTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
assembleEntity(ids, dto, result);
|
||||
break;
|
||||
case Param.plt:
|
||||
ids = dataVerifyList.stream().filter(x-> ObjUtil.isNotNull(x.getPltTime())).filter(it -> it.getPltTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
ids = dataVerifyList.stream().filter(x -> ObjUtil.isNotNull(x.getPltTime())).filter(it -> it.getPltTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
assembleEntity(ids, dto, result);
|
||||
break;
|
||||
case Param.pf:
|
||||
ids = dataVerifyList.stream().filter(x-> ObjUtil.isNotNull(x.getPfTime())).filter(it -> it.getPfTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
ids = dataVerifyList.stream().filter(x -> ObjUtil.isNotNull(x.getPfTime())).filter(it -> it.getPfTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
assembleEntity(ids, dto, result);
|
||||
break;
|
||||
case Param.Voltage_Dip:
|
||||
ids = dataVerifyList.stream().filter(x-> ObjUtil.isNotNull(x.getDipTime())).filter(it -> it.getDipTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
ids = dataVerifyList.stream().filter(x -> ObjUtil.isNotNull(x.getDipTime())).filter(it -> it.getDipTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
assembleEntity(ids, dto, result);
|
||||
break;
|
||||
case Param.Voltage_Rise:
|
||||
ids = dataVerifyList.stream().filter(x-> ObjUtil.isNotNull(x.getRiseTime())).filter(it -> it.getRiseTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
ids = dataVerifyList.stream().filter(x -> ObjUtil.isNotNull(x.getRiseTime())).filter(it -> it.getRiseTime() > errorTimeCount).map(PqDataVerifyBak::getLineId).collect(Collectors.toSet());
|
||||
assembleEntity(ids, dto, result);
|
||||
break;
|
||||
default:
|
||||
@@ -744,7 +786,7 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
|
||||
// if (temStr.equals(Param.rms_i)) {
|
||||
// verifyTargetVO.setRangeDesc(dto.getMinValue() + unit + " ~ " + dto.getMaxValue() + "*CT1" + unit);
|
||||
// } else {
|
||||
verifyTargetVO.setRangeDesc(dto.getMinValue() + unit + " ~ " + dto.getMaxValue() + unit);
|
||||
verifyTargetVO.setRangeDesc(dto.getMinValue() + unit + " ~ " + dto.getMaxValue() + unit);
|
||||
// }
|
||||
result.add(verifyTargetVO);
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ public class PqsTflgployServiceImpl extends ServiceImpl<PqsTflgployMapper, PqsTf
|
||||
}
|
||||
|
||||
private void addList(TflgployParam param, PqsTflgploy tflgploy, boolean save, List<PqsTflgployass> info) {
|
||||
if(save){
|
||||
// if(save){
|
||||
List<String> tfIndexs = param.getTfIndexs();
|
||||
if(CollUtil.isNotEmpty(tfIndexs)){
|
||||
PqsTflgployass ass;
|
||||
@@ -129,7 +129,7 @@ public class PqsTflgployServiceImpl extends ServiceImpl<PqsTflgployMapper, PqsTf
|
||||
ass.setTfIndex(tfIndex);
|
||||
info.add(ass);
|
||||
}
|
||||
}
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ public class RunManageServiceImpl implements RunManageService {
|
||||
lineIndexes = generalDeviceDTOList.stream().flatMap(list -> list.getLineIndexes().stream()).collect(Collectors.toList());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(lineIndexes)) {
|
||||
resultList = deviceMapper.getRunManageList(lineIndexes, runManageParam.getComFlag(),runManageParam.getRunFlag(), Objects.isNull(runManageParam.getSearchValue())?null:runManageParam.getSearchValue());
|
||||
resultList = deviceMapper.getRunManageList(lineIndexes, runManageParam.getComFlag(),Objects.isNull(runManageParam.getRunFlag())?new ArrayList<>():runManageParam.getRunFlag(), Objects.isNull(runManageParam.getSearchValue())?null:runManageParam.getSearchValue());
|
||||
if(CollUtil.isNotEmpty(resultList)){
|
||||
List<String> objIds = resultList.stream().map(RunManageVO::getObjId).collect(Collectors.toList());
|
||||
Map<String,NewUserReportVO> runManageVOMap = userLedgerFeignClient.getUserReportByIds(objIds).getData().stream().collect(Collectors.toMap(NewUserReportVO::getId,Function.identity()));
|
||||
|
||||
@@ -29,6 +29,8 @@ import com.njcn.supervision.pojo.vo.user.UserLedgerVO;
|
||||
import com.njcn.system.api.AreaFeignClient;
|
||||
import com.njcn.system.pojo.enums.StatisticsEnum;
|
||||
import com.njcn.system.pojo.po.Area;
|
||||
import com.njcn.user.api.DeptFeignClient;
|
||||
import com.njcn.user.pojo.po.Dept;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -52,6 +54,8 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
|
||||
|
||||
private final LineMapper lineMapper;
|
||||
|
||||
private final DeptFeignClient deptFeignClient;
|
||||
|
||||
private final LineDetailMapper lineDetailMapper;
|
||||
|
||||
private final AreaFeignClient areaFeignClient;
|
||||
@@ -84,40 +88,40 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
|
||||
//处理存在用户的台账
|
||||
List<TerminalTree> newLineList = lineMapper.getLineAndLineDetail();
|
||||
//用户侧测点
|
||||
List<TerminalTree> userLineList = newLineList.stream().filter(it->StrUtil.isNotBlank(it.getObjId())).collect(Collectors.toList());
|
||||
List<TerminalTree> userLineList = newLineList.stream().filter(it -> StrUtil.isNotBlank(it.getObjId())).collect(Collectors.toList());
|
||||
|
||||
//用户侧装置
|
||||
List<String> devIds = userLineList.stream().map(it->it.getPids().split(StrUtil.COMMA)[LineBaseEnum.DEVICE_LEVEL.getCode()]).distinct().collect(Collectors.toList());
|
||||
List<TerminalTree> devUserList = devList.stream().filter(it->devIds.contains(it.getId())).collect(Collectors.toList());
|
||||
List<String> devIds = userLineList.stream().map(it -> it.getPids().split(StrUtil.COMMA)[LineBaseEnum.DEVICE_LEVEL.getCode()]).distinct().collect(Collectors.toList());
|
||||
List<TerminalTree> devUserList = devList.stream().filter(it -> devIds.contains(it.getId())).collect(Collectors.toList());
|
||||
|
||||
//用户侧线路
|
||||
List<TerminalTree> subvUserList = subvList.stream().filter(it->devIds.contains(it.getPid())).collect(Collectors.toList());
|
||||
List<TerminalTree> subvUserList = subvList.stream().filter(it -> devIds.contains(it.getPid())).collect(Collectors.toList());
|
||||
List<String> subvUserIds = subvUserList.stream().map(TerminalTree::getId).distinct().collect(Collectors.toList());
|
||||
|
||||
//电网侧测点
|
||||
List<TerminalTree> otherLineList = newLineList.stream().filter(it->StrUtil.isBlank(it.getObjId())).collect(Collectors.toList());
|
||||
List<String> devOtherIds = otherLineList.stream().map(it->it.getPids().split(StrUtil.COMMA)[LineBaseEnum.DEVICE_LEVEL.getCode()]).distinct().collect(Collectors.toList());
|
||||
List<TerminalTree> otherLineList = newLineList.stream().filter(it -> StrUtil.isBlank(it.getObjId())).collect(Collectors.toList());
|
||||
List<String> devOtherIds = otherLineList.stream().map(it -> it.getPids().split(StrUtil.COMMA)[LineBaseEnum.DEVICE_LEVEL.getCode()]).distinct().collect(Collectors.toList());
|
||||
|
||||
//电网侧装置
|
||||
List<TerminalTree> devOtherList = devList.stream().filter(it->devOtherIds.contains(it.getId())).collect(Collectors.toList());
|
||||
List<TerminalTree> noBindDevList = devList.stream().filter(it->!devOtherIds.contains(it.getId()) && !devIds.contains(it.getId())).collect(Collectors.toList());
|
||||
List<TerminalTree> devOtherList = devList.stream().filter(it -> devOtherIds.contains(it.getId())).collect(Collectors.toList());
|
||||
List<TerminalTree> noBindDevList = devList.stream().filter(it -> !devOtherIds.contains(it.getId()) && !devIds.contains(it.getId())).collect(Collectors.toList());
|
||||
devOtherList.addAll(noBindDevList);
|
||||
//电网侧线路
|
||||
List<TerminalTree> subvOtherList = subvList.stream().filter(it->devOtherIds.contains(it.getPid())).collect(Collectors.toList());
|
||||
List<TerminalTree> subvOtherList = subvList.stream().filter(it -> devOtherIds.contains(it.getPid())).collect(Collectors.toList());
|
||||
List<String> otherBusBarIds = subvOtherList.stream().map(TerminalTree::getId).distinct().collect(Collectors.toList());
|
||||
List<TerminalTree> noBindList = subvList.stream().filter(it->!subvUserIds.contains(it.getId()) && !otherBusBarIds.contains(it.getId())).collect(Collectors.toList());
|
||||
List<TerminalTree> noBindList = subvList.stream().filter(it -> !subvUserIds.contains(it.getId()) && !otherBusBarIds.contains(it.getId())).collect(Collectors.toList());
|
||||
subvOtherList.addAll(noBindList);
|
||||
|
||||
|
||||
UserReportParam userReportParam = new UserReportParam();
|
||||
List<UserLedgerVO> userReportPOList = userLedgerFeignClient.selectUserList(userReportParam).getData();
|
||||
userReportPOList = userReportPOList.stream().filter(it->StrUtil.isNotBlank(it.getStationId())).collect(Collectors.toList());
|
||||
Map<String,List<UserLedgerVO>> userMap = userReportPOList.stream().collect(Collectors.groupingBy(UserLedgerVO::getStationId));
|
||||
userReportPOList = userReportPOList.stream().filter(it -> StrUtil.isNotBlank(it.getStationId())).collect(Collectors.toList());
|
||||
Map<String, List<UserLedgerVO>> userMap = userReportPOList.stream().collect(Collectors.groupingBy(UserLedgerVO::getStationId));
|
||||
|
||||
subvOtherList.forEach(subv -> subv.setChildren(getChildren(subv, otherLineList)));
|
||||
devOtherList.forEach(dev -> dev.setChildren(getChildren(dev, subvOtherList)));
|
||||
|
||||
subList.forEach(sub -> sub.setChildren(specialDealSubChildren(sub, userLineList,devOtherList,subvUserList,devUserList,userMap.get(sub.getId()))));
|
||||
subList.forEach(sub -> sub.setChildren(specialDealSubChildren(sub, userLineList, devOtherList, subvUserList, devUserList, userMap.get(sub.getId()))));
|
||||
//subList.forEach(sub -> sub.setChildren(getChildren(sub, devList)));
|
||||
gdList.forEach(gd -> gd.setChildren(getChildren(gd, subList)));
|
||||
provinceList.forEach(province -> province.setChildren(getChildren(province, gdList)));
|
||||
@@ -137,15 +141,15 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
|
||||
}
|
||||
|
||||
|
||||
private List<TerminalTree> specialDealSubChildren(TerminalTree sub,List<TerminalTree> lineUserList,List<TerminalTree> devOtherList,List<TerminalTree> busBarList,List<TerminalTree> devAllList,List<UserLedgerVO> userReportPOList){
|
||||
private List<TerminalTree> specialDealSubChildren(TerminalTree sub, List<TerminalTree> lineUserList, List<TerminalTree> devOtherList, List<TerminalTree> busBarList, List<TerminalTree> devAllList, List<UserLedgerVO> userReportPOList) {
|
||||
List<TerminalTree> list = new ArrayList<>();
|
||||
//电网侧
|
||||
List<TerminalTree> devTree = devOtherList.stream().filter(it->it.getPid().equals(sub.getId())).collect(Collectors.toList());
|
||||
if(CollectionUtil.isNotEmpty(devTree)){
|
||||
List<TerminalTree> devTree = devOtherList.stream().filter(it -> it.getPid().equals(sub.getId())).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(devTree)) {
|
||||
list.addAll(devTree);
|
||||
}
|
||||
//非电网侧
|
||||
if(CollUtil.isNotEmpty(userReportPOList)) {
|
||||
if (CollUtil.isNotEmpty(userReportPOList)) {
|
||||
Map<String, UserLedgerVO> userLedgerVOMap = userReportPOList.stream().collect(Collectors.toMap(UserLedgerVO::getId, Function.identity()));
|
||||
|
||||
List<TerminalTree> userLineList = lineUserList.stream().filter(it -> it.getPids().split(StrUtil.COMMA)[LineBaseEnum.SUB_LEVEL.getCode()].equals(sub.getId())).collect(Collectors.toList());
|
||||
@@ -190,7 +194,7 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
|
||||
});
|
||||
|
||||
UserLedgerVO userReportPO = userLedgerVOMap.get(objId);
|
||||
if(Objects.isNull(userReportPO)){
|
||||
if (Objects.isNull(userReportPO)) {
|
||||
System.out.println(map);
|
||||
}
|
||||
TerminalTree terminalTree = new TerminalTree();
|
||||
@@ -209,8 +213,6 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 5层树排除设备 母线监测点合并
|
||||
*
|
||||
@@ -226,78 +228,122 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
|
||||
if (CollectionUtil.isNotEmpty(generalDeviceDTOList)) {
|
||||
// 创建集合
|
||||
List<TerminalTree> taiZhang = new ArrayList<>();
|
||||
// 获取用户
|
||||
UserReportParam userReportParam = new UserReportParam();
|
||||
List<UserLedgerVO> userReportPOList = userLedgerFeignClient.selectUserList(userReportParam).getData();
|
||||
userReportPOList = userReportPOList.stream().filter(it -> StrUtil.isNotBlank(it.getStationId())).collect(Collectors.toList());
|
||||
Map<String, UserLedgerVO> userMap = userReportPOList.stream().collect(Collectors.toMap(UserLedgerVO::getId, Function.identity()));
|
||||
|
||||
// 遍历集合
|
||||
for (GeneralDeviceDTO generalDeviceDTO : generalDeviceDTOList) {
|
||||
// 创建实体类
|
||||
TerminalTree terminalTree = new TerminalTree();
|
||||
// 判断监测点索引集合状态
|
||||
if (CollectionUtils.isEmpty(generalDeviceDTO.getLineIndexes())) {
|
||||
continue;
|
||||
}
|
||||
// 通过供电公司索引查询省会
|
||||
List<TerminalTree> proList = treeMapper.getProvinceList(generalDeviceDTO.getGdIndexes());
|
||||
// 通过供电公司索引查询供电公司信息
|
||||
List<TerminalTree> gdList = treeMapper.getGdList(generalDeviceDTO.getGdIndexes());
|
||||
// 通过供电站索引查询供电站信息
|
||||
List<TerminalTree> subList = treeMapper.getSubList(generalDeviceDTO.getSubIndexes());
|
||||
// 通过监测点索引查询监测点信息
|
||||
List<TerminalTree> lineList = treeMapper.getLineList(generalDeviceDTO.getLineIndexes());
|
||||
|
||||
List<TerminalTree> userLineList = lineList.stream().filter(it->StrUtil.isNotBlank(it.getObjId())).collect(Collectors.toList());
|
||||
List<TerminalTree> otherLineList = lineList.stream().filter(it->StrUtil.isBlank(it.getObjId())).collect(Collectors.toList());
|
||||
|
||||
Map<String,List<TerminalTree>> temMap = new HashMap<>();
|
||||
if(CollUtil.isNotEmpty(userLineList)) {
|
||||
Map<String, List<TerminalTree>> objMap = userLineList.stream().collect(Collectors.groupingBy(TerminalTree::getObjId));
|
||||
List<TerminalTree> temList = new ArrayList<>();
|
||||
objMap.forEach((objId, monitorList) -> {
|
||||
UserLedgerVO userLedgerVO = userMap.get(objId);
|
||||
TerminalTree tree = new TerminalTree();
|
||||
tree.setLevel(LineBaseEnum.USER_LEVEL.getCode());
|
||||
tree.setPid(userLedgerVO.getStationId());
|
||||
tree.setId(userLedgerVO.getId());
|
||||
tree.setChildren(monitorList);
|
||||
int devSize = (int) monitorList.stream().map(x -> {
|
||||
// 获取父id字符串,通过 逗号 分割 成一个数组
|
||||
String[] pid = x.getPids().split(StrUtil.COMMA);
|
||||
return pid[LineBaseEnum.DEVICE_LEVEL.getCode()];
|
||||
}).distinct().count();
|
||||
tree.setName(userLedgerVO.getProjectName());
|
||||
//特殊处理,用户层级下面的装置数量临时存到pids字段。
|
||||
tree.setPids(String.valueOf(devSize));
|
||||
temList.add(tree);
|
||||
});
|
||||
temMap = temList.stream().collect(Collectors.groupingBy(TerminalTree::getPid));
|
||||
if (StrUtil.isNotBlank(deviceInfoParam.getStatisticalType().getDeptName())) {
|
||||
// 遍历集合
|
||||
for (GeneralDeviceDTO generalDeviceDTO : generalDeviceDTOList) {
|
||||
// 创建实体类
|
||||
TerminalTree terminalTree = new TerminalTree();
|
||||
terminalTree.setName(generalDeviceDTO.getName());
|
||||
terminalTree.setId(generalDeviceDTO.getIndex());
|
||||
terminalTree.setLevel(0);
|
||||
// 处理子部门
|
||||
deviceInfoParam.setDeptIndex(generalDeviceDTO.getIndex());
|
||||
List<GeneralDeviceDTO> generalDeviceDTOsubList = generalDeviceService.getDeviceInfo(deviceInfoParam, Stream.of(0).collect(Collectors.toList()), Stream.of(1).collect(Collectors.toList()));
|
||||
if (CollectionUtil.isNotEmpty(generalDeviceDTOsubList)) {
|
||||
List<TerminalTree> terminalTreeList = new ArrayList<>();
|
||||
for (int i = 0; i < generalDeviceDTOsubList.size(); i++) {
|
||||
GeneralDeviceDTO deviceDTO = generalDeviceDTOsubList.get(i);
|
||||
TerminalTree terminalSubTree = new TerminalTree();
|
||||
terminalSubTree.setName(deviceDTO.getName());
|
||||
terminalSubTree.setId(deviceDTO.getIndex());
|
||||
terminalSubTree.setPid(generalDeviceDTO.getIndex());
|
||||
terminalSubTree.setLevel(2);
|
||||
terminalSubTree.setSort(i);
|
||||
if(CollectionUtil.isNotEmpty(deviceDTO.getLineIndexes())){
|
||||
// 处理该部门下的检测点显示
|
||||
// 通过监测点索引查询监测点信息
|
||||
List<TerminalTree> lineList = treeMapper.getLineList(deviceDTO.getLineIndexes());
|
||||
terminalSubTree.setChildren(lineList);
|
||||
terminalTreeList.add(terminalSubTree);
|
||||
}
|
||||
}
|
||||
terminalTree.setChildren(terminalTreeList);
|
||||
} else {
|
||||
if(CollectionUtil.isNotEmpty(generalDeviceDTO.getLineIndexes())){
|
||||
// 处理该部门下的检测点显示
|
||||
// 通过监测点索引查询监测点信息
|
||||
List<TerminalTree> lineList = treeMapper.getLineList(generalDeviceDTO.getLineIndexes());
|
||||
terminalTree.setChildren(lineList);
|
||||
}
|
||||
}
|
||||
taiZhang.add(terminalTree);
|
||||
}
|
||||
|
||||
} else {
|
||||
// 获取用户
|
||||
UserReportParam userReportParam = new UserReportParam();
|
||||
List<UserLedgerVO> userReportPOList = userLedgerFeignClient.selectUserList(userReportParam).getData();
|
||||
userReportPOList = userReportPOList.stream().filter(it -> StrUtil.isNotBlank(it.getStationId())).collect(Collectors.toList());
|
||||
Map<String, UserLedgerVO> userMap = userReportPOList.stream().collect(Collectors.toMap(UserLedgerVO::getId, Function.identity()));
|
||||
|
||||
// 遍历集合
|
||||
for (GeneralDeviceDTO generalDeviceDTO : generalDeviceDTOList) {
|
||||
// 创建实体类
|
||||
TerminalTree terminalTree = new TerminalTree();
|
||||
|
||||
// 判断监测点索引集合状态
|
||||
if (CollectionUtils.isEmpty(generalDeviceDTO.getLineIndexes())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 通过供电公司索引查询省会
|
||||
List<TerminalTree> proList = treeMapper.getProvinceList(generalDeviceDTO.getGdIndexes());
|
||||
// 通过供电公司索引查询供电公司信息
|
||||
List<TerminalTree> gdList = treeMapper.getGdList(generalDeviceDTO.getGdIndexes());
|
||||
// 通过供电站索引查询供电站信息
|
||||
List<TerminalTree> subList = treeMapper.getSubList(generalDeviceDTO.getSubIndexes());
|
||||
// 通过监测点索引查询监测点信息
|
||||
List<TerminalTree> lineList = treeMapper.getLineList(generalDeviceDTO.getLineIndexes());
|
||||
|
||||
List<TerminalTree> userLineList = lineList.stream().filter(it -> StrUtil.isNotBlank(it.getObjId())).collect(Collectors.toList());
|
||||
List<TerminalTree> otherLineList = lineList.stream().filter(it -> StrUtil.isBlank(it.getObjId())).collect(Collectors.toList());
|
||||
|
||||
Map<String, List<TerminalTree>> temMap = new HashMap<>();
|
||||
if (CollUtil.isNotEmpty(userLineList)) {
|
||||
Map<String, List<TerminalTree>> objMap = userLineList.stream().collect(Collectors.groupingBy(TerminalTree::getObjId));
|
||||
List<TerminalTree> temList = new ArrayList<>();
|
||||
objMap.forEach((objId, monitorList) -> {
|
||||
UserLedgerVO userLedgerVO = userMap.get(objId);
|
||||
TerminalTree tree = new TerminalTree();
|
||||
tree.setLevel(LineBaseEnum.USER_LEVEL.getCode());
|
||||
tree.setPid(userLedgerVO.getStationId());
|
||||
tree.setId(userLedgerVO.getId());
|
||||
tree.setChildren(monitorList);
|
||||
int devSize = (int) monitorList.stream().map(x -> {
|
||||
// 获取父id字符串,通过 逗号 分割 成一个数组
|
||||
String[] pid = x.getPids().split(StrUtil.COMMA);
|
||||
return pid[LineBaseEnum.DEVICE_LEVEL.getCode()];
|
||||
}).distinct().count();
|
||||
tree.setName(userLedgerVO.getProjectName());
|
||||
//特殊处理,用户层级下面的装置数量临时存到pids字段。
|
||||
tree.setPids(String.valueOf(devSize));
|
||||
temList.add(tree);
|
||||
});
|
||||
temMap = temList.stream().collect(Collectors.groupingBy(TerminalTree::getPid));
|
||||
}
|
||||
|
||||
|
||||
//处理变电站
|
||||
dealChildrenData(subList, otherLineList, temMap,true);
|
||||
//处理变电站
|
||||
dealChildrenData(subList, otherLineList, temMap, true);
|
||||
|
||||
//监测点前面加序号,后面不需要删除下面两行就行
|
||||
//Integer[] arr = {1};
|
||||
//subList.forEach(item->item.getChildren().forEach(it->it.setName((arr[0]++ +"_"+it.getName()))));
|
||||
//处理供电公司
|
||||
dealChildrenData(gdList, subList, null,false);
|
||||
//监测点前面加序号,后面不需要删除下面两行就行
|
||||
//Integer[] arr = {1};
|
||||
//subList.forEach(item->item.getChildren().forEach(it->it.setName((arr[0]++ +"_"+it.getName()))));
|
||||
//处理供电公司
|
||||
dealChildrenData(gdList, subList, null, false);
|
||||
|
||||
if (deviceInfoParam.getStatisticalType().getCode().equalsIgnoreCase(StatisticsEnum.POWER_NETWORK.getCode())) {
|
||||
terminalTree.setChildren(gdList);
|
||||
} else {
|
||||
//还需要额外处理省会
|
||||
dealChildrenData(proList, gdList, null,false);
|
||||
terminalTree.setChildren(proList);
|
||||
if (deviceInfoParam.getStatisticalType().getCode().equalsIgnoreCase(StatisticsEnum.POWER_NETWORK.getCode())) {
|
||||
terminalTree.setChildren(gdList);
|
||||
} else {
|
||||
//还需要额外处理省会
|
||||
dealChildrenData(proList, gdList, null, false);
|
||||
terminalTree.setChildren(proList);
|
||||
}
|
||||
terminalTree.setId(generalDeviceDTO.getIndex());
|
||||
terminalTree.setName(generalDeviceDTO.getName());
|
||||
terminalTree.setLevel(0);
|
||||
taiZhang.add(terminalTree);
|
||||
}
|
||||
terminalTree.setId(generalDeviceDTO.getIndex());
|
||||
terminalTree.setName(generalDeviceDTO.getName());
|
||||
terminalTree.setLevel(0);
|
||||
taiZhang.add(terminalTree);
|
||||
}
|
||||
return taiZhang;
|
||||
} else {
|
||||
@@ -312,7 +358,7 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
|
||||
* @param childrenData
|
||||
* @param isLine
|
||||
*/
|
||||
private void dealChildrenData(List<TerminalTree> targetData, List<TerminalTree> childrenData,Map<String,List<TerminalTree>> userLineMap, boolean isLine) {
|
||||
private void dealChildrenData(List<TerminalTree> targetData, List<TerminalTree> childrenData, Map<String, List<TerminalTree>> userLineMap, boolean isLine) {
|
||||
// 创建一个map集合,用于封装对象
|
||||
Map<String, List<TerminalTree>> groupLine;
|
||||
if (isLine) {
|
||||
@@ -328,7 +374,7 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
|
||||
//变电站
|
||||
targetData.forEach(terminalTree -> {
|
||||
List<TerminalTree> terminalTrees = new ArrayList<>();
|
||||
if(groupLine.containsKey(terminalTree.getId())) {
|
||||
if (groupLine.containsKey(terminalTree.getId())) {
|
||||
terminalTrees.addAll(groupLine.get(terminalTree.getId()).stream().sorted(Comparator.comparing(TerminalTree::getSort)).collect(Collectors.toList()));
|
||||
}
|
||||
if (isLine) {
|
||||
@@ -340,13 +386,13 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
|
||||
}).distinct().count();
|
||||
|
||||
int devSize = 0;
|
||||
if(userLineMap.containsKey(terminalTree.getId())){
|
||||
if (userLineMap.containsKey(terminalTree.getId())) {
|
||||
List<TerminalTree> userList = userLineMap.get(terminalTree.getId());
|
||||
devSize= (int) userList.stream().mapToDouble(it->Integer.parseInt(it.getPids())).sum();
|
||||
devSize = (int) userList.stream().mapToDouble(it -> Integer.parseInt(it.getPids())).sum();
|
||||
terminalTrees.addAll(userList);
|
||||
}
|
||||
int sumDev = size+devSize;
|
||||
terminalTree.setName(terminalTree.getName() + "(" +sumDev+ "台装置)");
|
||||
int sumDev = size + devSize;
|
||||
terminalTree.setName(terminalTree.getName() + "(" + sumDev + "台装置)");
|
||||
terminalTree.setChildren(terminalTrees);
|
||||
} else {
|
||||
terminalTree.setChildren(terminalTrees);
|
||||
@@ -392,7 +438,7 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
|
||||
DeviceInfoParam deviceInfoParam = new DeviceInfoParam();
|
||||
deviceInfoParam.setDeptIndex(RequestUtil.getDeptIndex());
|
||||
deviceInfoParam.setServerName(ServerEnum.HARMONIC.getName());
|
||||
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceService.getDeviceInfo(deviceInfoParam, Stream.of(0,1).collect(Collectors.toList()), Stream.of(1).collect(Collectors.toList()));
|
||||
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceService.getDeviceInfo(deviceInfoParam, Stream.of(0, 1).collect(Collectors.toList()), Stream.of(1).collect(Collectors.toList()));
|
||||
|
||||
for (GeneralDeviceDTO generalDeviceDTO : generalDeviceDTOList) {
|
||||
if (CollectionUtil.isEmpty(generalDeviceDTO.getLineIndexes())) {
|
||||
@@ -472,89 +518,89 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
|
||||
List<LineDetail> list = lineDetailMapper.selectList(new LambdaQueryWrapper<LineDetail>().in(CollUtil.isNotEmpty(lineIds), LineDetail::getId, lineIds));
|
||||
Map<String, LineDetail> powerFlagMap = list.stream().collect(Collectors.toMap(LineDetail::getId, Function.identity()));
|
||||
for (TerminalTree x : lineList) {
|
||||
if(powerFlagMap.containsKey(x.getId())){
|
||||
if (powerFlagMap.containsKey(x.getId())) {
|
||||
x.setPowerFlag(powerFlagMap.get(x.getId()).getPowerFlag());
|
||||
x.setPowerSubstationName(powerFlagMap.get(x.getId()).getPowerSubstationName());
|
||||
x.setObjName(powerFlagMap.get(x.getId()).getObjName());
|
||||
}else{
|
||||
} else {
|
||||
x.setPowerFlag(LineBaseEnum.POWER_FLAG.getCode());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Map<String, List<TerminalTree>> lineObjNameMap = lineList.stream().filter(x -> StrUtil.isNotBlank(x.getPowerSubstationName())).collect(Collectors.groupingBy(TerminalTree::getPowerSubstationName));
|
||||
Map<String, List<TerminalTree>> lineObjNameMap = lineList.stream().filter(x -> StrUtil.isNotBlank(x.getPowerSubstationName())).collect(Collectors.groupingBy(TerminalTree::getPowerSubstationName));
|
||||
//组织变电站信息
|
||||
List<TerminalTree> subInfoList = new ArrayList<>();
|
||||
List<TerminalTree> subInfoList = new ArrayList<>();
|
||||
|
||||
lineObjNameMap.forEach((key, value)->{
|
||||
lineObjNameMap.forEach((key, value) -> {
|
||||
List<TerminalTree> terminalTrees = Collections.unmodifiableList(collect1);
|
||||
//获取变电信息
|
||||
List<TerminalTree> collect = subList.stream().filter(x -> x.getName().equals(key.replace("±",""))).collect(Collectors.toList());
|
||||
List<TerminalTree> collect = subList.stream().filter(x -> x.getName().equals(key.replace("±", ""))).collect(Collectors.toList());
|
||||
//电网侧监测点
|
||||
List<TerminalTree> powerFlag = value.stream().filter(x -> x.getPowerFlag().equals(LineBaseEnum.POWER_FLAG.getCode())).collect(Collectors.toList());
|
||||
if(CollUtil.isEmpty(powerFlag)){
|
||||
if (CollUtil.isEmpty(powerFlag)) {
|
||||
//解决变电站下没有监测点显示问题(变电站-》终端-》母线)
|
||||
powerFlag.addAll(collect);
|
||||
}
|
||||
List<TerminalTree> subChildren = new ArrayList<>();
|
||||
TerminalTree recursion = getRecursionChildren(powerFlag, terminalTrees);
|
||||
if(ObjectUtil.isNotNull(recursion)){
|
||||
if (ObjectUtil.isNotNull(recursion)) {
|
||||
subChildren.add(recursion);
|
||||
}
|
||||
//非电网侧监测点
|
||||
List<TerminalTree> powerFlagNot = value.stream().filter(x -> x.getPowerFlag().equals(LineBaseEnum.POWER_FLAG_NOT.getCode())).collect(Collectors.toList());
|
||||
List<TerminalTree> notSubChildren = new ArrayList<>();
|
||||
if(CollUtil.isNotEmpty(powerFlagNot)){
|
||||
if (CollUtil.isNotEmpty(powerFlagNot)) {
|
||||
Map<String, List<TerminalTree>> objNameMap = powerFlagNot.stream().collect(Collectors.groupingBy(TerminalTree::getObjName));
|
||||
objNameMap.forEach((objNameKey,objNameValue)->{
|
||||
objNameMap.forEach((objNameKey, objNameValue) -> {
|
||||
TerminalTree recursionChildren = getRecursionChildren(objNameValue, terminalTrees);
|
||||
if(ObjectUtil.isNotNull(recursionChildren)){
|
||||
if (ObjectUtil.isNotNull(recursionChildren)) {
|
||||
recursionChildren.setName(objNameKey);
|
||||
notSubChildren.add(recursionChildren);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
if(CollUtil.isNotEmpty(collect)){
|
||||
if (CollUtil.isNotEmpty(collect)) {
|
||||
List<TerminalTree> valueList = new ArrayList<>();
|
||||
TerminalTree sub=new TerminalTree();
|
||||
TerminalTree sub = new TerminalTree();
|
||||
sub.setId(collect.get(0).getId());
|
||||
sub.setName(collect.get(0).getName());
|
||||
sub.setPid(collect.get(0).getPid());
|
||||
sub.setSort(0);
|
||||
sub.setChildren(valueList);
|
||||
|
||||
TerminalTree powerTree=new TerminalTree();
|
||||
TerminalTree powerTree = new TerminalTree();
|
||||
powerTree.setName("电网侧");
|
||||
powerTree.setId(collect.get(0).getId());
|
||||
powerTree.setChildren(subChildren);
|
||||
valueList.add(powerTree);
|
||||
|
||||
|
||||
TerminalTree notPowerTree=new TerminalTree();
|
||||
TerminalTree notPowerTree = new TerminalTree();
|
||||
notPowerTree.setName("非电网侧");
|
||||
notPowerTree.setChildren(notSubChildren);
|
||||
valueList.add(notPowerTree);
|
||||
subInfoList.add(sub);
|
||||
}else{
|
||||
} else {
|
||||
//电网侧变电站能否找到
|
||||
for (TerminalTree child : subChildren) {
|
||||
List<TerminalTree> valueList = new ArrayList<>();
|
||||
List<TerminalTree> exist = subInfoList.stream().filter(x -> x.getId().equals(child.getId())).collect(Collectors.toList());
|
||||
if(CollUtil.isNotEmpty(exist)){
|
||||
if (CollUtil.isNotEmpty(exist)) {
|
||||
//电网侧
|
||||
List<TerminalTree> children =new ArrayList<>();
|
||||
List<TerminalTree> children = new ArrayList<>();
|
||||
children.addAll(exist.get(0).getChildren().get(0).getChildren());
|
||||
children.add(child);
|
||||
exist.get(0).getChildren().get(0).setChildren(children);
|
||||
}else{
|
||||
TerminalTree sub=new TerminalTree();
|
||||
} else {
|
||||
TerminalTree sub = new TerminalTree();
|
||||
sub.setId(child.getId());
|
||||
sub.setName(child.getName());
|
||||
sub.setPid(child.getPid());
|
||||
sub.setSort(0);
|
||||
TerminalTree powerTree=new TerminalTree();
|
||||
TerminalTree powerTree = new TerminalTree();
|
||||
powerTree.setName("电网侧");
|
||||
powerTree.setId(child.getId());
|
||||
powerTree.setChildren(Arrays.asList(child));
|
||||
@@ -574,7 +620,7 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
|
||||
List<TerminalTree> exist = subInfoList.stream().filter(x -> x.getId().equals(child.getId())).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(exist)) {
|
||||
//非电网侧
|
||||
List<TerminalTree> children =new ArrayList<>();
|
||||
List<TerminalTree> children = new ArrayList<>();
|
||||
children.addAll(exist.get(0).getChildren().get(1).getChildren());
|
||||
children.add(child);
|
||||
exist.get(0).getChildren().get(1).setChildren(children);
|
||||
@@ -615,7 +661,7 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
|
||||
for (TerminalTree notSub : collect) {
|
||||
//只显示变电站下有装置的
|
||||
TerminalTree notSub1 = findParents(collect1, notSub);
|
||||
if(CollUtil.isNotEmpty(notSub1.getChildren())){
|
||||
if (CollUtil.isNotEmpty(notSub1.getChildren())) {
|
||||
List<TerminalTree> valueList = new ArrayList<>();
|
||||
|
||||
TerminalTree sub = new TerminalTree();
|
||||
@@ -638,7 +684,7 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
|
||||
subInfoList.add(sub);
|
||||
dw.add(sub);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gdList.forEach(gd -> gd.setChildren(getChildren(gd, subInfoList)));
|
||||
provinceList.forEach(province -> province.setChildren(getChildren(province, gdList)));
|
||||
@@ -668,28 +714,26 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
|
||||
List<TerminalTree> devList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.DEVICE_LEVEL.getCode())).sorted(Comparator.comparing(TerminalTree::getSort)).collect(Collectors.toList());
|
||||
List<TerminalTree> subvList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.SUB_V_LEVEL.getCode())).sorted(Comparator.comparing(TerminalTree::getSort)).collect(Collectors.toList());
|
||||
|
||||
List<TerminalTree> linepowerList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.LINE_LEVEL.getCode())&&item.getPowerFlag() != 1).sorted(Comparator.comparing(TerminalTree::getSort)).collect(Collectors.toList());
|
||||
List<TerminalTree> lineNotPowerList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.LINE_LEVEL.getCode())&&item.getPowerFlag() == 1).sorted(Comparator.comparing(TerminalTree::getSort)).collect(Collectors.toList());
|
||||
List<TerminalTree> linepowerList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.LINE_LEVEL.getCode()) && item.getPowerFlag() != 1).sorted(Comparator.comparing(TerminalTree::getSort)).collect(Collectors.toList());
|
||||
List<TerminalTree> lineNotPowerList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.LINE_LEVEL.getCode()) && item.getPowerFlag() == 1).sorted(Comparator.comparing(TerminalTree::getSort)).collect(Collectors.toList());
|
||||
|
||||
|
||||
|
||||
subvList.forEach(subv ->{
|
||||
if(CollUtil.isEmpty(subv.getChildren())){
|
||||
subvList.forEach(subv -> {
|
||||
if (CollUtil.isEmpty(subv.getChildren())) {
|
||||
subv.setChildren(getRecursionChildren(subv, linepowerList));
|
||||
}
|
||||
}
|
||||
);
|
||||
);
|
||||
|
||||
subvList.forEach(subv -> {
|
||||
if(CollUtil.isEmpty(subv.getChildren())){
|
||||
if (CollUtil.isEmpty(subv.getChildren())) {
|
||||
subv.setChildren(getRecursionChildren(subv, lineNotPowerList));
|
||||
}
|
||||
}
|
||||
);
|
||||
subvList.stream().filter(x-> ObjUtil.isNull(x.getPowerFlag())).forEach(x->x.setPowerFlag(0));
|
||||
subvList.stream().filter(x -> ObjUtil.isNull(x.getPowerFlag())).forEach(x -> x.setPowerFlag(0));
|
||||
devList.forEach(dev -> dev.setChildren(getRecursionChildren(dev, subvList)));
|
||||
devList.stream().filter(x-> ObjUtil.isNull(x.getPowerFlag())).forEach(x->x.setPowerFlag(0));
|
||||
|
||||
devList.stream().filter(x -> ObjUtil.isNull(x.getPowerFlag())).forEach(x -> x.setPowerFlag(0));
|
||||
|
||||
|
||||
subList.forEach(sub -> sub.setChildren(getRecursionChildrenCs(sub, devList)));
|
||||
@@ -709,36 +753,36 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
|
||||
*/
|
||||
public List<TerminalTree> getChildren(TerminalTree item, List<TerminalTree> all) {
|
||||
List<TerminalTree> collect = all.stream().filter(allItem -> allItem.getPid().equals(item.getId())).sorted(Comparator.comparing(TerminalTree::getSort)).collect(Collectors.toList());
|
||||
if(CollUtil.isNotEmpty(collect)){
|
||||
long sortSize = collect.stream().filter(x->ObjUtil.isNotNull(x.getSort())).filter(x -> x.getSort() == 0).count();
|
||||
if(collect.size()-sortSize/collect.size()>50){
|
||||
collect.sort(Comparator.comparing(x->x.getName()));
|
||||
if (CollUtil.isNotEmpty(collect)) {
|
||||
long sortSize = collect.stream().filter(x -> ObjUtil.isNotNull(x.getSort())).filter(x -> x.getSort() == 0).count();
|
||||
if (collect.size() - sortSize / collect.size() > 50) {
|
||||
collect.sort(Comparator.comparing(x -> x.getName()));
|
||||
}
|
||||
}
|
||||
return collect;
|
||||
}
|
||||
|
||||
public List<TerminalTree> getRecursionChildrenCs(TerminalTree item, List<TerminalTree> all){
|
||||
public List<TerminalTree> getRecursionChildrenCs(TerminalTree item, List<TerminalTree> all) {
|
||||
List<TerminalTree> collect = all.stream().filter(allItem -> allItem.getPid().equals(item.getId())).sorted(Comparator.comparing(TerminalTree::getSort)).collect(Collectors.toList());
|
||||
List<TerminalTree> list=new ArrayList<>();
|
||||
TerminalTree power=new TerminalTree();
|
||||
List<TerminalTree> list = new ArrayList<>();
|
||||
TerminalTree power = new TerminalTree();
|
||||
power.setName("电网侧");
|
||||
power.setSort(0);
|
||||
power.setChildren(collect.stream().filter(x -> 1 != x.getPowerFlag()).collect(Collectors.toList()));
|
||||
list.add(power);
|
||||
|
||||
|
||||
|
||||
TerminalTree notPower=new TerminalTree();
|
||||
TerminalTree notPower = new TerminalTree();
|
||||
notPower.setName("非电网侧");
|
||||
notPower.setSort(1);
|
||||
notPower.setChildren(collect.stream().filter(x -> 1 == x.getPowerFlag()).collect(Collectors.toList()));
|
||||
list.add(notPower);
|
||||
return list;
|
||||
}
|
||||
public List<TerminalTree> getRecursionChildren(TerminalTree item, List<TerminalTree> all){
|
||||
|
||||
public List<TerminalTree> getRecursionChildren(TerminalTree item, List<TerminalTree> all) {
|
||||
List<TerminalTree> list = all.stream().filter(allItem -> allItem.getPid().equals(item.getId())).sorted(Comparator.comparing(TerminalTree::getSort)).collect(Collectors.toList());
|
||||
if(CollUtil.isNotEmpty(list)){
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
item.setPowerFlag(list.get(0).getPowerFlag());
|
||||
}
|
||||
return list;
|
||||
@@ -746,31 +790,32 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
|
||||
|
||||
/**
|
||||
* 变电站层级增加电网侧和非电网侧电站
|
||||
*
|
||||
* @param line 变电站对象
|
||||
* @param all 检测对象
|
||||
* @param all 检测对象
|
||||
* @return
|
||||
*/
|
||||
public TerminalTree getRecursionChildren(List<TerminalTree> line, List<TerminalTree> all) {
|
||||
List<TerminalTree> aa=new ArrayList<>();
|
||||
List<TerminalTree> aa = new ArrayList<>();
|
||||
for (TerminalTree lineTree : line) {
|
||||
findParentsRecursive(lineTree, all,aa);
|
||||
findParentsRecursive(lineTree, all, aa);
|
||||
aa.add(lineTree);
|
||||
}
|
||||
List<TerminalTree> distinctList =new ArrayList<>(aa.stream().distinct().collect(Collectors.toList()));
|
||||
List<TerminalTree> distinctList = new ArrayList<>(aa.stream().distinct().collect(Collectors.toList()));
|
||||
long count = line.stream().filter(x -> !x.getLevel().equals(LineBaseEnum.LINE_LEVEL.getCode())).count();
|
||||
if(count>0){
|
||||
if (count > 0) {
|
||||
aa.addAll(all);
|
||||
}
|
||||
List<TerminalTree> lines = aa.stream().distinct().sorted(Comparator.comparing(TerminalTree::getSort)).collect(Collectors.toList());
|
||||
List<TerminalTree> collect = distinctList.stream().filter(x -> x.getLevel() == LineBaseEnum.SUB_LEVEL.getCode()).collect(Collectors.toList());
|
||||
if(CollUtil.isNotEmpty(collect)){
|
||||
if (CollUtil.isNotEmpty(collect)) {
|
||||
TerminalTree terminalTree = BeanUtil.copyProperties(collect.get(0), TerminalTree.class);
|
||||
return findParents(lines,terminalTree);
|
||||
return findParents(lines, terminalTree);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void findParentsRecursive(TerminalTree tree, List<TerminalTree> all,List<TerminalTree> newParents) {
|
||||
private static void findParentsRecursive(TerminalTree tree, List<TerminalTree> all, List<TerminalTree> newParents) {
|
||||
if (tree.getLevel() == LineBaseEnum.SUB_LEVEL.getCode()) {
|
||||
return;
|
||||
}
|
||||
@@ -783,12 +828,12 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
|
||||
}
|
||||
}
|
||||
|
||||
private TerminalTree findParents(List<TerminalTree> all,TerminalTree subTree) {
|
||||
private TerminalTree findParents(List<TerminalTree> all, TerminalTree subTree) {
|
||||
List<TerminalTree> collect = all.stream().filter(allItem -> allItem.getPid().equals(subTree.getId())).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(collect)) {
|
||||
collect.forEach(treeMap -> {
|
||||
subTree.setChildren(collect);
|
||||
findParents( all,treeMap);
|
||||
findParents(all, treeMap);
|
||||
});
|
||||
}
|
||||
return subTree;
|
||||
|
||||
@@ -369,7 +369,7 @@ public class GeneralDeviceService {
|
||||
StatisticsEnum statisticsEnum = StatisticsEnum.getStatisticsEnumByCode(deviceInfoParam.getStatisticalType().getCode());
|
||||
switch (statisticsEnum) {
|
||||
case VOLTAGE_LEVEL:
|
||||
return filterDataByScale(deviceInfos, deviceInfoParam.getScale());
|
||||
return filterDataByScale(deviceInfos, deviceInfoParam.getScale(),deviceInfoParam.getLineOrDevice());
|
||||
case LOAD_TYPE:
|
||||
return filterDataByLoadType(deviceInfos, deviceInfoParam.getLoadType());
|
||||
case MANUFACTURER:
|
||||
@@ -474,11 +474,12 @@ public class GeneralDeviceService {
|
||||
generalDeviceDTO.setLineIndexes(lineIndexes.stream().distinct().collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
private List<GeneralDeviceDTO> filterDataByScale(List<GeneralDeviceDTO> deviceInfos, List<SimpleDTO> scales) {
|
||||
private List<GeneralDeviceDTO> filterDataByScale(List<GeneralDeviceDTO> deviceInfos, List<SimpleDTO> scales,Integer type) {
|
||||
List<GeneralDeviceDTO> generalDeviceDTOS = new ArrayList<>();
|
||||
List<String> subIds = new ArrayList<>(), lineIds = new ArrayList<>();
|
||||
List<String> subIds = new ArrayList<>(), subVIds = new ArrayList<>(),lineIds = new ArrayList<>();
|
||||
for (GeneralDeviceDTO generalDeviceDTO : deviceInfos) {
|
||||
subIds.addAll(generalDeviceDTO.getSubIndexes());
|
||||
subVIds.addAll(generalDeviceDTO.getVoltageIndexes());
|
||||
lineIds.addAll(generalDeviceDTO.getLineIndexes());
|
||||
}
|
||||
//如果电压等级集合为空,则查询所有的电压等级
|
||||
@@ -496,8 +497,13 @@ public class GeneralDeviceService {
|
||||
}
|
||||
List<Line> lines = terminalBaseService.getLineById(lineIds);
|
||||
for (SimpleDTO simpleDTO : scales) {
|
||||
List<String> voltageScaleIds = terminalBaseService.getSubIdByScale(subIds, simpleDTO.getId());
|
||||
generalDeviceDTOS.add(assembleDataByLine(simpleDTO, lines, voltageScaleIds, LineBaseEnum.SUB_LEVEL.getCode()));
|
||||
if(ObjectUtil.isNull(type)){
|
||||
List<String> voltageScaleIds = terminalBaseService.getSubIdByScale(subIds, simpleDTO.getId());
|
||||
generalDeviceDTOS.add(assembleDataByLine(simpleDTO, lines, voltageScaleIds, LineBaseEnum.SUB_LEVEL.getCode()));
|
||||
}else{
|
||||
List<String> voltageScaleIds = terminalBaseService.getVoltageIdByScale(subVIds, simpleDTO.getId());
|
||||
generalDeviceDTOS.add(assembleDataByLine(simpleDTO, lines, voltageScaleIds, LineBaseEnum.SUB_V_LEVEL.getCode()));
|
||||
}
|
||||
}
|
||||
return generalDeviceDTOS;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ import com.njcn.device.line.mapper.LineDetailMapper;
|
||||
import com.njcn.device.line.mapper.LineMapper;
|
||||
import com.njcn.device.line.service.LineBakService;
|
||||
import com.njcn.device.node.service.INodeService;
|
||||
import com.njcn.device.overlimit.mapper.OverlimitMapper;
|
||||
import com.njcn.device.biz.mapper.OverlimitMapper;
|
||||
import com.njcn.device.pq.constant.Param;
|
||||
import com.njcn.device.pq.enums.LineBaseEnum;
|
||||
import com.njcn.device.pq.enums.PvDeviceResponseEnum;
|
||||
@@ -96,6 +96,7 @@ import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
@@ -3698,305 +3699,339 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
||||
|
||||
List<PqsTerminalPushLogDTO> pqsTerminalPushLogDTOList = new ArrayList<>();
|
||||
List<String> addAndDelteId = new ArrayList<>();
|
||||
//异常标志
|
||||
Boolean exFlag= false;
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
//前置层修改
|
||||
List<PqsTerminalLogs> list1 = list.stream().filter(temp -> temp.getTerminalDescribe().contains("终端所属前置机由")).collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(list1)) {
|
||||
for (PqsTerminalLogs temp : list1) {
|
||||
String temLos = "%s终端所属前置机由 %s 改为> %s;";
|
||||
List<String> strings = this.parseTemplateValues(temLos, temp.getTerminalDescribe());
|
||||
String node1 = strings.get(1); // 第一个前置
|
||||
String node2 = strings.get(2); // 第二个前置
|
||||
if (deviceProcesseMap.containsKey(temp.getObjIndex())) {
|
||||
Integer processNum = deviceProcesseMap.get(temp.getObjIndex());
|
||||
PqsTerminalPushLogDTO pqsTerminalPushLogDTO = new PqsTerminalPushLogDTO();
|
||||
pqsTerminalPushLogDTO.setId(temp.getId());
|
||||
String deviceId = temp.getObjIndex();
|
||||
pqsTerminalPushLogDTO.setDevId(deviceId);
|
||||
pqsTerminalPushLogDTO.setDevName(lineMap.containsKey(deviceId) ? lineMap.get(deviceId).getName() : "删除设备");
|
||||
pqsTerminalPushLogDTO.setNodeId(node1);
|
||||
pqsTerminalPushLogDTO.setNodeName(nodeMap.get(node1).getName());
|
||||
pqsTerminalPushLogDTO.setProcessUpdateFlag(true);
|
||||
pqsTerminalPushLogDTO.setProcessNum(processNum);
|
||||
pqsTerminalPushLogDTOList.add(pqsTerminalPushLogDTO);
|
||||
|
||||
PqsTerminalPushLogDTO pqsTerminalPushLogDTO2 = new PqsTerminalPushLogDTO();
|
||||
pqsTerminalPushLogDTO2.setId(temp.getId());
|
||||
pqsTerminalPushLogDTO2.setDevId(deviceId);
|
||||
pqsTerminalPushLogDTO2.setDevName(lineMap.containsKey(deviceId) ? lineMap.get(deviceId).getName() : "删除设备");
|
||||
pqsTerminalPushLogDTO2.setNodeId(node2);
|
||||
pqsTerminalPushLogDTO2.setNodeName(nodeMap.get(node2).getName());
|
||||
pqsTerminalPushLogDTO2.setProcessUpdateFlag(true);
|
||||
pqsTerminalPushLogDTO2.setProcessNum(processNum);
|
||||
pqsTerminalPushLogDTOList.add(pqsTerminalPushLogDTO2);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
list.removeAll(list1);
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
//终端层面和检测点层面修改
|
||||
list.forEach(temp -> {
|
||||
PqsTerminalPushLogDTO pqsTerminalPushLogDTO = new PqsTerminalPushLogDTO();
|
||||
if (Objects.equals(temp.getTerminalType(), 6)) {
|
||||
pqsTerminalPushLogDTO.setId(temp.getId());
|
||||
String deviceId;
|
||||
//如果不存在该设备id,说明监测点删除
|
||||
if (!lineDeviceMap.containsKey(temp.getObjIndex())) {
|
||||
String temLos = "%s监测点名称: %s";
|
||||
List<String> strings = this.parseTemplateValues(temLos, temp.getTerminalDescribe());
|
||||
String[] lineName = strings.get(1).split("->");
|
||||
List<Line> devList = lineById.stream().filter(line -> Objects.equals(line.getName(), lineName[1])).collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(devList)) {
|
||||
//如果不存在该设备说明设备也被删除,直接走下边删除设备逻辑;
|
||||
return;
|
||||
} else {
|
||||
Line sub = lineById.stream().filter(line -> Objects.equals(line.getName(), lineName[0])).collect(Collectors.toList()).get(0);
|
||||
Line tempDev = devList.stream().filter(dev -> dev.getPid().equals(sub.getId())).collect(Collectors.toList()).get(0);
|
||||
deviceId = tempDev.getId();
|
||||
}
|
||||
|
||||
} else {
|
||||
deviceId = lineDeviceMap.get(temp.getObjIndex());
|
||||
|
||||
}
|
||||
|
||||
pqsTerminalPushLogDTO.setDevId(deviceId);
|
||||
pqsTerminalPushLogDTO.setDevName(lineMap.get(deviceId).getName());
|
||||
String nodeId = deviceMap.get(deviceId).getNodeId();
|
||||
pqsTerminalPushLogDTO.setNodeId(nodeId);
|
||||
//如果前置删了直接返回
|
||||
if (!nodeMap.containsKey(nodeId)) {
|
||||
return;
|
||||
}
|
||||
pqsTerminalPushLogDTO.setNodeName(nodeMap.get(nodeId).getName());
|
||||
pqsTerminalPushLogDTO.setProcessUpdateFlag(false);
|
||||
if (deviceProcesseMap.containsKey(deviceId)) {
|
||||
pqsTerminalPushLogDTO.setProcessNum(deviceProcesseMap.get(deviceId));
|
||||
} else {
|
||||
throw new BusinessException("存在终端未设置进程号,请在前置管理页面设置进程号在进行此操作");
|
||||
}
|
||||
pqsTerminalPushLogDTO.setOperateType(DeviceRebootType.LEDGER_MODIFY);
|
||||
pqsTerminalPushLogDTOList.add(pqsTerminalPushLogDTO);
|
||||
|
||||
} else if (Objects.equals(temp.getTerminalType(), 4)) {
|
||||
//如果是修改进程操作记录2个进程日志;
|
||||
if (temp.getLogsType().equals(dataDic.getId())) {
|
||||
String temLos = "%s进行更新终端进程操作;终端名称 :%s,由进程%s修改成进程%s";
|
||||
List<String> strings = this.parseTemplateValues(temLos, temp.getTerminalDescribe());
|
||||
String num1 = strings.get(2); // 第一个进程
|
||||
String num2 = strings.get(3); // 第二个进程
|
||||
int processId1 = Integer.parseInt(num1);
|
||||
int processId2 = Integer.parseInt(num2);
|
||||
List<PqsTerminalLogs> list1 = new ArrayList<>();
|
||||
try {
|
||||
//前置层修改
|
||||
list1 = list.stream().filter(temp -> temp.getTerminalDescribe().contains("终端所属前置机由")).collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(list1)) {
|
||||
for (PqsTerminalLogs temp : list1) {
|
||||
String temLos = "%s终端所属前置机由 %s 改为> %s;";
|
||||
List<String> strings = this.parseTemplateValues(temLos, temp.getTerminalDescribe());
|
||||
String node1 = strings.get(1); // 第一个前置
|
||||
String node2 = strings.get(2); // 第二个前置
|
||||
if (deviceProcesseMap.containsKey(temp.getObjIndex())) {
|
||||
Integer processNum = deviceProcesseMap.get(temp.getObjIndex());
|
||||
PqsTerminalPushLogDTO pqsTerminalPushLogDTO = new PqsTerminalPushLogDTO();
|
||||
pqsTerminalPushLogDTO.setId(temp.getId());
|
||||
String deviceId = temp.getObjIndex();
|
||||
pqsTerminalPushLogDTO.setDevId(deviceId);
|
||||
pqsTerminalPushLogDTO.setDevName(lineMap.containsKey(deviceId) ? lineMap.get(deviceId).getName() : "删除设备");
|
||||
pqsTerminalPushLogDTO.setNodeId(node1);
|
||||
pqsTerminalPushLogDTO.setNodeName(nodeMap.get(node1).getName());
|
||||
pqsTerminalPushLogDTO.setProcessUpdateFlag(true);
|
||||
pqsTerminalPushLogDTO.setProcessNum(processNum);
|
||||
pqsTerminalPushLogDTOList.add(pqsTerminalPushLogDTO);
|
||||
|
||||
PqsTerminalPushLogDTO pqsTerminalPushLogDTO2 = new PqsTerminalPushLogDTO();
|
||||
pqsTerminalPushLogDTO2.setId(temp.getId());
|
||||
pqsTerminalPushLogDTO2.setDevId(deviceId);
|
||||
pqsTerminalPushLogDTO2.setDevName(lineMap.containsKey(deviceId) ? lineMap.get(deviceId).getName() : "删除设备");
|
||||
pqsTerminalPushLogDTO2.setNodeId(node2);
|
||||
pqsTerminalPushLogDTO2.setNodeName(nodeMap.get(node2).getName());
|
||||
pqsTerminalPushLogDTO2.setProcessUpdateFlag(true);
|
||||
pqsTerminalPushLogDTO2.setProcessNum(processNum);
|
||||
pqsTerminalPushLogDTOList.add(pqsTerminalPushLogDTO2);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
list.removeAll(list1);
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
//终端层面和检测点层面修改
|
||||
list.forEach(temp -> {
|
||||
PqsTerminalPushLogDTO pqsTerminalPushLogDTO = new PqsTerminalPushLogDTO();
|
||||
if (Objects.equals(temp.getTerminalType(), 6)) {
|
||||
pqsTerminalPushLogDTO.setId(temp.getId());
|
||||
String deviceId;
|
||||
//如果不存在该设备id,说明监测点删除
|
||||
if (!lineDeviceMap.containsKey(temp.getObjIndex())) {
|
||||
String temLos = "%s监测点名称: %s";
|
||||
List<String> strings = this.parseTemplateValues(temLos, temp.getTerminalDescribe());
|
||||
String[] lineName = strings.get(1).split("->");
|
||||
List<Line> devList = lineById.stream().filter(line -> Objects.equals(line.getName(), lineName[1])).collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(devList)) {
|
||||
//如果不存在该设备说明设备也被删除,直接走下边删除设备逻辑;
|
||||
return;
|
||||
} else {
|
||||
Line sub = lineById.stream().filter(line -> Objects.equals(line.getName(), lineName[0])).collect(Collectors.toList()).get(0);
|
||||
Line tempDev = devList.stream().filter(dev -> dev.getPid().equals(sub.getId())).collect(Collectors.toList()).get(0);
|
||||
deviceId = tempDev.getId();
|
||||
}
|
||||
|
||||
} else {
|
||||
deviceId = lineDeviceMap.get(temp.getObjIndex());
|
||||
|
||||
}
|
||||
|
||||
pqsTerminalPushLogDTO.setDevId(deviceId);
|
||||
pqsTerminalPushLogDTO.setDevName(lineMap.get(deviceId).getName());
|
||||
String nodeId = deviceMap.get(deviceId).getNodeId();
|
||||
pqsTerminalPushLogDTO.setNodeId(nodeId);
|
||||
//如果前置删了直接返回
|
||||
if (!nodeMap.containsKey(nodeId)) {
|
||||
return;
|
||||
}
|
||||
pqsTerminalPushLogDTO.setNodeName(nodeMap.get(nodeId).getName());
|
||||
pqsTerminalPushLogDTO.setProcessUpdateFlag(true);
|
||||
pqsTerminalPushLogDTO.setProcessNum(processId1);
|
||||
pqsTerminalPushLogDTOList.add(pqsTerminalPushLogDTO);
|
||||
PqsTerminalPushLogDTO pqsTerminalPushLogDTO1 = new PqsTerminalPushLogDTO();
|
||||
|
||||
pqsTerminalPushLogDTO1.setId(temp.getId());
|
||||
pqsTerminalPushLogDTO1.setDevId(deviceId);
|
||||
pqsTerminalPushLogDTO1.setDevName(lineMap.get(deviceId).getName());
|
||||
pqsTerminalPushLogDTO1.setNodeId(nodeId);
|
||||
pqsTerminalPushLogDTO1.setNodeName(nodeMap.get(nodeId).getName());
|
||||
pqsTerminalPushLogDTO1.setProcessUpdateFlag(true);
|
||||
pqsTerminalPushLogDTO1.setProcessNum(processId2);
|
||||
pqsTerminalPushLogDTOList.add(pqsTerminalPushLogDTO1);
|
||||
|
||||
} else {
|
||||
pqsTerminalPushLogDTO.setId(temp.getId());
|
||||
String deviceId = temp.getObjIndex();
|
||||
pqsTerminalPushLogDTO.setDevId(deviceId);
|
||||
//区分删除操作,新增和其他操作
|
||||
String operate = DeviceRebootType.LEDGER_MODIFY;
|
||||
|
||||
if (Objects.equals(temp.getOperateType(), Param.DEL)) {
|
||||
operate = DeviceRebootType.DELETE_TERMINAL;
|
||||
|
||||
|
||||
} else if (Objects.equals(temp.getOperateType(), Param.ADD)) {
|
||||
operate = DeviceRebootType.ADD_TERMINAL;
|
||||
|
||||
}
|
||||
//设备删除找不到设备名称,重日志截取
|
||||
if (Objects.equals(temp.getOperateType(), Param.DEL)) {
|
||||
String temLos = "%s名称:%s;前置信息:%s";
|
||||
List<String> strings = this.parseTemplateValues(temLos, temp.getTerminalDescribe());
|
||||
String devName = strings.get(1); // 设备名称
|
||||
String nodeName = strings.get(2); // 进程名称
|
||||
pqsTerminalPushLogDTO.setDevName(devName);
|
||||
String nodeId = nodeNameMap.get(nodeName).getId();
|
||||
pqsTerminalPushLogDTO.setNodeId(nodeId);
|
||||
pqsTerminalPushLogDTO.setNodeName(nodeName);
|
||||
} else {
|
||||
//如果存在说明设备未被删除,不存在说明有一条删除日志,直接return;
|
||||
if (lineMap.containsKey(deviceId)) {
|
||||
pqsTerminalPushLogDTO.setDevName(lineMap.get(deviceId).getName());
|
||||
} else {
|
||||
pqsTerminalPushLogDTO.setDevName("删除设备");
|
||||
|
||||
}
|
||||
//如果新增的没有,说明该新增设备在本次也删除了,
|
||||
if (deviceMap.containsKey(deviceId)) {
|
||||
String nodeId = deviceMap.get(deviceId).getNodeId();
|
||||
pqsTerminalPushLogDTO.setNodeId(nodeId);
|
||||
pqsTerminalPushLogDTO.setNodeName(nodeMap.get(nodeId).getName());
|
||||
} else {
|
||||
addAndDelteId.add(deviceId);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
pqsTerminalPushLogDTO.setProcessUpdateFlag(false);
|
||||
if (deviceProcesseMap.containsKey(deviceId)) {
|
||||
pqsTerminalPushLogDTO.setProcessNum(deviceProcesseMap.get(deviceId));
|
||||
} else {
|
||||
throw new BusinessException("存在终端未设置进程号,请在前置管理页面设置进程号在进行此操作");
|
||||
}
|
||||
|
||||
pqsTerminalPushLogDTO.setOperateType(operate);
|
||||
pqsTerminalPushLogDTO.setOperateType(DeviceRebootType.LEDGER_MODIFY);
|
||||
pqsTerminalPushLogDTOList.add(pqsTerminalPushLogDTO);
|
||||
|
||||
} else if (Objects.equals(temp.getTerminalType(), 4)) {
|
||||
String deviceId = temp.getObjIndex();
|
||||
if(!deviceMap.containsKey(deviceId)){
|
||||
//说明设备被删除
|
||||
String temLos = "%s名称:%s;前置信息:%s";
|
||||
List<String> strings = this.parseTemplateValues(temLos, temp.getTerminalDescribe());
|
||||
String devName = strings.get(1); // 设备名称
|
||||
String nodeName = strings.get(2); // 进程名称
|
||||
pqsTerminalPushLogDTO.setDevName(devName);
|
||||
//如果前置删了直接返回
|
||||
if(!nodeNameMap.containsKey(nodeName)){
|
||||
return;
|
||||
}
|
||||
String nodeId = nodeNameMap.get(nodeName).getId();
|
||||
pqsTerminalPushLogDTO.setNodeId(nodeId);
|
||||
pqsTerminalPushLogDTO.setNodeName(nodeName);
|
||||
}
|
||||
|
||||
//如果是修改进程操作记录2个进程日志;
|
||||
if (temp.getLogsType().equals(dataDic.getId())) {
|
||||
String temLos = "%s进行更新终端进程操作;终端名称 :%s,由进程%s修改成进程%s";
|
||||
List<String> strings = this.parseTemplateValues(temLos, temp.getTerminalDescribe());
|
||||
String num1 = strings.get(2); // 第一个进程
|
||||
String num2 = strings.get(3); // 第二个进程
|
||||
int processId1 = Integer.parseInt(num1);
|
||||
int processId2 = Integer.parseInt(num2);
|
||||
pqsTerminalPushLogDTO.setId(temp.getId());
|
||||
// String deviceId = temp.getObjIndex();
|
||||
pqsTerminalPushLogDTO.setDevId(deviceId);
|
||||
pqsTerminalPushLogDTO.setDevName(lineMap.containsKey(deviceId) ? lineMap.get(deviceId).getName() : "删除设备");
|
||||
String nodeId = deviceMap.get(deviceId).getNodeId();
|
||||
pqsTerminalPushLogDTO.setNodeId(nodeId);
|
||||
pqsTerminalPushLogDTO.setNodeName(nodeMap.get(nodeId).getName());
|
||||
pqsTerminalPushLogDTO.setProcessUpdateFlag(true);
|
||||
pqsTerminalPushLogDTO.setProcessNum(processId1);
|
||||
pqsTerminalPushLogDTOList.add(pqsTerminalPushLogDTO);
|
||||
PqsTerminalPushLogDTO pqsTerminalPushLogDTO1 = new PqsTerminalPushLogDTO();
|
||||
|
||||
pqsTerminalPushLogDTO1.setId(temp.getId());
|
||||
pqsTerminalPushLogDTO1.setDevId(deviceId);
|
||||
pqsTerminalPushLogDTO1.setDevName(lineMap.get(deviceId).getName());
|
||||
pqsTerminalPushLogDTO1.setNodeId(nodeId);
|
||||
pqsTerminalPushLogDTO1.setNodeName(nodeMap.get(nodeId).getName());
|
||||
pqsTerminalPushLogDTO1.setProcessUpdateFlag(true);
|
||||
pqsTerminalPushLogDTO1.setProcessNum(processId2);
|
||||
pqsTerminalPushLogDTOList.add(pqsTerminalPushLogDTO1);
|
||||
|
||||
} else {
|
||||
pqsTerminalPushLogDTO.setId(temp.getId());
|
||||
// String deviceId = temp.getObjIndex();
|
||||
pqsTerminalPushLogDTO.setDevId(deviceId);
|
||||
//区分删除操作,新增和其他操作
|
||||
String operate = DeviceRebootType.LEDGER_MODIFY;
|
||||
|
||||
if (Objects.equals(temp.getOperateType(), Param.DEL)) {
|
||||
operate = DeviceRebootType.DELETE_TERMINAL;
|
||||
|
||||
|
||||
} else if (Objects.equals(temp.getOperateType(), Param.ADD)) {
|
||||
operate = DeviceRebootType.ADD_TERMINAL;
|
||||
|
||||
}
|
||||
//设备删除找不到设备名称,重日志截取
|
||||
if (Objects.equals(temp.getOperateType(), Param.DEL)) {
|
||||
String temLos = "%s名称:%s;前置信息:%s";
|
||||
List<String> strings = this.parseTemplateValues(temLos, temp.getTerminalDescribe());
|
||||
String devName = strings.get(1); // 设备名称
|
||||
String nodeName = strings.get(2); // 进程名称
|
||||
pqsTerminalPushLogDTO.setDevName(devName);
|
||||
String nodeId = nodeNameMap.get(nodeName).getId();
|
||||
pqsTerminalPushLogDTO.setNodeId(nodeId);
|
||||
pqsTerminalPushLogDTO.setNodeName(nodeName);
|
||||
} else {
|
||||
//如果存在说明设备未被删除,不存在说明有一条删除日志,直接return;
|
||||
if (lineMap.containsKey(deviceId)) {
|
||||
pqsTerminalPushLogDTO.setDevName(lineMap.get(deviceId).getName());
|
||||
} else {
|
||||
pqsTerminalPushLogDTO.setDevName("删除设备");
|
||||
|
||||
}
|
||||
//如果新增的没有,说明该新增设备在本次也删除了,
|
||||
if (deviceMap.containsKey(deviceId)) {
|
||||
String nodeId = deviceMap.get(deviceId).getNodeId();
|
||||
pqsTerminalPushLogDTO.setNodeId(nodeId);
|
||||
pqsTerminalPushLogDTO.setNodeName(nodeMap.containsKey(nodeId)?nodeMap.get(nodeId).getName():"删除前置");
|
||||
} else {
|
||||
addAndDelteId.add(deviceId);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
pqsTerminalPushLogDTO.setProcessUpdateFlag(false);
|
||||
if (deviceProcesseMap.containsKey(deviceId)) {
|
||||
pqsTerminalPushLogDTO.setProcessNum(deviceProcesseMap.get(deviceId));
|
||||
} else {
|
||||
throw new BusinessException("存在终端未设置进程号,请在前置管理页面设置进程号在进行此操作");
|
||||
}
|
||||
|
||||
pqsTerminalPushLogDTO.setOperateType(operate);
|
||||
pqsTerminalPushLogDTOList.add(pqsTerminalPushLogDTO);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Map<String, Map<Integer, List<PqsTerminalPushLogDTO>>> collect2 = pqsTerminalPushLogDTOList.stream().filter(temp -> !addAndDelteId.contains(temp.getDevId())).collect(Collectors.groupingBy(PqsTerminalPushLogDTO::getNodeId, Collectors.groupingBy(PqsTerminalPushLogDTO::getProcessNum)));
|
||||
collect2.forEach((nodeId, pqsTerminalPushLogDTOMap) -> {
|
||||
pqsTerminalPushLogDTOMap.forEach((processId, tempPqsTerminalPushLogDTOList) -> {
|
||||
Map<String, Map<Integer, List<PqsTerminalPushLogDTO>>> collect2 = pqsTerminalPushLogDTOList.stream().filter(temp -> !addAndDelteId.contains(temp.getDevId())).collect(Collectors.groupingBy(PqsTerminalPushLogDTO::getNodeId, Collectors.groupingBy(PqsTerminalPushLogDTO::getProcessNum)));
|
||||
collect2.forEach((nodeId, pqsTerminalPushLogDTOMap) -> {
|
||||
pqsTerminalPushLogDTOMap.forEach((processId, tempPqsTerminalPushLogDTOList) -> {
|
||||
|
||||
PqsTerminalPushLogDTO pqsTerminalPushLogDTO = tempPqsTerminalPushLogDTOList.get(0);
|
||||
//如果存在终端变更进程的记录直接重启进程
|
||||
boolean processUpdateFlag = tempPqsTerminalPushLogDTOList.stream().map(PqsTerminalPushLogDTO::getProcessUpdateFlag).anyMatch(b -> b != null && b);
|
||||
if (processUpdateFlag) {
|
||||
PreCommandDTO preCommandDTO = new PreCommandDTO();
|
||||
String guid = IdUtil.simpleUUID();
|
||||
String command = "重启前置机:" + pqsTerminalPushLogDTO.getNodeName() + "下进程:" + processId;
|
||||
preCommandDTO.setGuid(guid);
|
||||
preCommandDTO.setCommand(command);
|
||||
preCommandDTO.setResult("2");
|
||||
//调用重启进程接口
|
||||
this.askRestartProcess(guid, pqsTerminalPushLogDTO.getNodeId(), processId, "delete", "all");
|
||||
preCommandDTOList.add(preCommandDTO);
|
||||
} else {
|
||||
List<String> deviceIds = tempPqsTerminalPushLogDTOList.stream().map(PqsTerminalPushLogDTO::getDevId).distinct().collect(Collectors.toList());
|
||||
//如果一个进程上涉及10个以上的设备修改,直接重启进程,否则重启设备
|
||||
if (CollectionUtil.isNotEmpty(deviceIds) && deviceIds.size() > 10) {
|
||||
PqsTerminalPushLogDTO pqsTerminalPushLogDTO = tempPqsTerminalPushLogDTOList.get(0);
|
||||
//如果存在终端变更进程的记录直接重启进程
|
||||
boolean processUpdateFlag = tempPqsTerminalPushLogDTOList.stream().map(PqsTerminalPushLogDTO::getProcessUpdateFlag).anyMatch(b -> b != null && b);
|
||||
if (processUpdateFlag) {
|
||||
PreCommandDTO preCommandDTO = new PreCommandDTO();
|
||||
String guid = IdUtil.simpleUUID();
|
||||
String command = "重启前置机:" + pqsTerminalPushLogDTO.getNodeName() + "下进程:" + processId;
|
||||
preCommandDTO.setGuid(guid);
|
||||
preCommandDTO.setCommand(command);
|
||||
preCommandDTO.setResult("2");
|
||||
|
||||
//调用重启进程接口
|
||||
this.askRestartProcess(guid, pqsTerminalPushLogDTO.getNodeId(), processId, "delete", "all");
|
||||
preCommandDTOList.add(preCommandDTO);
|
||||
|
||||
} else {
|
||||
//调用重启设备接口先删除设备,在新增,在修改在重启设备
|
||||
List<String> deleteDevIds = new ArrayList<>();
|
||||
List<String> addDevIds = new ArrayList<>();
|
||||
List<String> modifyDevIds = new ArrayList<>();
|
||||
Map<String, List<PqsTerminalPushLogDTO>> collect = tempPqsTerminalPushLogDTOList.stream().collect(Collectors.groupingBy(PqsTerminalPushLogDTO::getOperateType));
|
||||
if (collect.containsKey(DeviceRebootType.DELETE_TERMINAL)) {
|
||||
List<PqsTerminalPushLogDTO> pqsTerminalPushLogDTOList1 = collect.get(DeviceRebootType.DELETE_TERMINAL);
|
||||
deleteDevIds = pqsTerminalPushLogDTOList1.stream().map(PqsTerminalPushLogDTO::getDevId).distinct().collect(Collectors.toList());
|
||||
}
|
||||
if (collect.containsKey(DeviceRebootType.ADD_TERMINAL)) {
|
||||
List<PqsTerminalPushLogDTO> pqsTerminalPushLogDTOList1 = collect.get(DeviceRebootType.ADD_TERMINAL);
|
||||
addDevIds = pqsTerminalPushLogDTOList1.stream().map(PqsTerminalPushLogDTO::getDevId).distinct().collect(Collectors.toList());
|
||||
}
|
||||
if (collect.containsKey(DeviceRebootType.LEDGER_MODIFY)) {
|
||||
List<PqsTerminalPushLogDTO> pqsTerminalPushLogDTOList1 = collect.get(DeviceRebootType.LEDGER_MODIFY);
|
||||
modifyDevIds = pqsTerminalPushLogDTOList1.stream().map(PqsTerminalPushLogDTO::getDevId).distinct().collect(Collectors.toList());
|
||||
}
|
||||
if (collect.containsKey(DeviceRebootType.DELETE_TERMINAL)) {
|
||||
List<PqsTerminalPushLogDTO> pqsTerminalPushLogDTOList1 = collect.get(DeviceRebootType.DELETE_TERMINAL);
|
||||
List<String> finalAddDevIds = addDevIds;
|
||||
//过滤本次新增的设备,因为前置那边还没有新增该装备
|
||||
pqsTerminalPushLogDTOList1 = pqsTerminalPushLogDTOList1.stream().filter(temp -> !finalAddDevIds.contains(temp.getDevId())).distinct().collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(pqsTerminalPushLogDTOList1)) {
|
||||
String devNameString = pqsTerminalPushLogDTOList1.stream().map(PqsTerminalPushLogDTO::getDevName).distinct().collect(Collectors.joining(","));
|
||||
List<String> resultDevIds = pqsTerminalPushLogDTOList1.stream().map(PqsTerminalPushLogDTO::getDevId).distinct().collect(Collectors.toList());
|
||||
PreCommandDTO preCommandDTO = new PreCommandDTO();
|
||||
String guid = IdUtil.simpleUUID();
|
||||
List<String> deviceIds = tempPqsTerminalPushLogDTOList.stream().map(PqsTerminalPushLogDTO::getDevId).distinct().collect(Collectors.toList());
|
||||
//如果一个进程上涉及10个以上的设备修改,直接重启进程,否则重启设备
|
||||
if (CollectionUtil.isNotEmpty(deviceIds) && deviceIds.size() > 10) {
|
||||
PreCommandDTO preCommandDTO = new PreCommandDTO();
|
||||
String guid = IdUtil.simpleUUID();
|
||||
String command = "重启前置机:" + pqsTerminalPushLogDTO.getNodeName() + "下进程:" + processId;
|
||||
preCommandDTO.setGuid(guid);
|
||||
preCommandDTO.setCommand(command);
|
||||
preCommandDTO.setResult("2");
|
||||
|
||||
String command = "删除前置机:" + pqsTerminalPushLogDTO.getNodeName() + "下进程:" + processId + "下终端" + devNameString;
|
||||
preCommandDTO.setGuid(guid);
|
||||
preCommandDTO.setCommand(command);
|
||||
preCommandDTO.setResult("2");
|
||||
//调用重启进程接口
|
||||
this.askRestartProcess(guid, pqsTerminalPushLogDTO.getNodeId(), processId, "delete", "all");
|
||||
preCommandDTOList.add(preCommandDTO);
|
||||
|
||||
} else {
|
||||
//调用重启设备接口先删除设备,在新增,在修改在重启设备
|
||||
List<String> deleteDevIds = new ArrayList<>();
|
||||
List<String> addDevIds = new ArrayList<>();
|
||||
List<String> modifyDevIds = new ArrayList<>();
|
||||
Map<String, List<PqsTerminalPushLogDTO>> collect = tempPqsTerminalPushLogDTOList.stream().collect(Collectors.groupingBy(PqsTerminalPushLogDTO::getOperateType));
|
||||
if (collect.containsKey(DeviceRebootType.DELETE_TERMINAL)) {
|
||||
List<PqsTerminalPushLogDTO> pqsTerminalPushLogDTOList1 = collect.get(DeviceRebootType.DELETE_TERMINAL);
|
||||
deleteDevIds = pqsTerminalPushLogDTOList1.stream().map(PqsTerminalPushLogDTO::getDevId).distinct().collect(Collectors.toList());
|
||||
}
|
||||
if (collect.containsKey(DeviceRebootType.ADD_TERMINAL)) {
|
||||
List<PqsTerminalPushLogDTO> pqsTerminalPushLogDTOList1 = collect.get(DeviceRebootType.ADD_TERMINAL);
|
||||
addDevIds = pqsTerminalPushLogDTOList1.stream().map(PqsTerminalPushLogDTO::getDevId).distinct().collect(Collectors.toList());
|
||||
}
|
||||
if (collect.containsKey(DeviceRebootType.LEDGER_MODIFY)) {
|
||||
List<PqsTerminalPushLogDTO> pqsTerminalPushLogDTOList1 = collect.get(DeviceRebootType.LEDGER_MODIFY);
|
||||
modifyDevIds = pqsTerminalPushLogDTOList1.stream().map(PqsTerminalPushLogDTO::getDevId).distinct().collect(Collectors.toList());
|
||||
}
|
||||
if (collect.containsKey(DeviceRebootType.DELETE_TERMINAL)) {
|
||||
List<PqsTerminalPushLogDTO> pqsTerminalPushLogDTOList1 = collect.get(DeviceRebootType.DELETE_TERMINAL);
|
||||
List<String> finalAddDevIds = addDevIds;
|
||||
//过滤本次新增的设备,因为前置那边还没有新增该装备
|
||||
pqsTerminalPushLogDTOList1 = pqsTerminalPushLogDTOList1.stream().filter(temp -> !finalAddDevIds.contains(temp.getDevId())).distinct().collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(pqsTerminalPushLogDTOList1)) {
|
||||
String devNameString = pqsTerminalPushLogDTOList1.stream().map(PqsTerminalPushLogDTO::getDevName).distinct().collect(Collectors.joining(","));
|
||||
List<String> resultDevIds = pqsTerminalPushLogDTOList1.stream().map(PqsTerminalPushLogDTO::getDevId).distinct().collect(Collectors.toList());
|
||||
PreCommandDTO preCommandDTO = new PreCommandDTO();
|
||||
String guid = IdUtil.simpleUUID();
|
||||
|
||||
String command = "删除前置机:" + pqsTerminalPushLogDTO.getNodeName() + "下进程:" + processId + "下终端" + devNameString;
|
||||
preCommandDTO.setGuid(guid);
|
||||
preCommandDTO.setCommand(command);
|
||||
preCommandDTO.setResult("2");
|
||||
|
||||
//调用重启设备接口
|
||||
this.askRestartDevice(guid, pqsTerminalPushLogDTO.getNodeId(), resultDevIds, DeviceRebootType.DELETE_TERMINAL, processId);
|
||||
preCommandDTOList.add(preCommandDTO);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (collect.containsKey(DeviceRebootType.ADD_TERMINAL)) {
|
||||
List<PqsTerminalPushLogDTO> pqsTerminalPushLogDTOList1 = collect.get(DeviceRebootType.ADD_TERMINAL);
|
||||
List<String> finalDeleteDevIds = deleteDevIds;
|
||||
pqsTerminalPushLogDTOList1 = pqsTerminalPushLogDTOList1.stream().filter(temp -> !finalDeleteDevIds.contains(temp.getDevId())).distinct().collect(Collectors.toList());
|
||||
|
||||
if (!CollectionUtils.isEmpty(pqsTerminalPushLogDTOList1)) {
|
||||
String devNameString = pqsTerminalPushLogDTOList1.stream().map(PqsTerminalPushLogDTO::getDevName).distinct().collect(Collectors.joining(","));
|
||||
List<String> resultDevIds = pqsTerminalPushLogDTOList1.stream().map(PqsTerminalPushLogDTO::getDevId).distinct().collect(Collectors.toList());
|
||||
PreCommandDTO preCommandDTO = new PreCommandDTO();
|
||||
String guid = IdUtil.simpleUUID();
|
||||
String command = "新增前置机:" + pqsTerminalPushLogDTO.getNodeName() + "下进程:" + processId + "下终端" + devNameString;
|
||||
preCommandDTO.setGuid(guid);
|
||||
preCommandDTO.setCommand(command);
|
||||
preCommandDTO.setResult("2");
|
||||
|
||||
//调用重启进程接口
|
||||
this.askRestartDevice(guid, pqsTerminalPushLogDTO.getNodeId(), resultDevIds, DeviceRebootType.ADD_TERMINAL, processId);
|
||||
|
||||
preCommandDTOList.add(preCommandDTO);
|
||||
}
|
||||
|
||||
}
|
||||
if (collect.containsKey(DeviceRebootType.LEDGER_MODIFY)) {
|
||||
List<PqsTerminalPushLogDTO> pqsTerminalPushLogDTOList1 = collect.get(DeviceRebootType.LEDGER_MODIFY);
|
||||
List<String> finalDeleteDevIds1 = deleteDevIds;
|
||||
List<String> finalAddDevIds1 = addDevIds;
|
||||
pqsTerminalPushLogDTOList1 = pqsTerminalPushLogDTOList1.stream().filter(temp -> !finalDeleteDevIds1.contains(temp.getDevId()) && !finalAddDevIds1.contains(temp.getDevId())).distinct().collect(Collectors.toList());
|
||||
|
||||
if (!CollectionUtils.isEmpty(pqsTerminalPushLogDTOList1)) {
|
||||
String devNameString = pqsTerminalPushLogDTOList1.stream().map(PqsTerminalPushLogDTO::getDevName).distinct().collect(Collectors.joining(","));
|
||||
List<String> resultDevIds = pqsTerminalPushLogDTOList1.stream().map(PqsTerminalPushLogDTO::getDevId).distinct().collect(Collectors.toList());
|
||||
PreCommandDTO preCommandDTO = new PreCommandDTO();
|
||||
String guid = IdUtil.simpleUUID();
|
||||
String command = "修改前置机:" + pqsTerminalPushLogDTO.getNodeName() + "下进程:" + processId + "下终端" + devNameString;
|
||||
preCommandDTO.setGuid(guid);
|
||||
preCommandDTO.setCommand(command);
|
||||
preCommandDTO.setResult("2");
|
||||
//调用重启进程接口
|
||||
this.askRestartDevice(guid, pqsTerminalPushLogDTO.getNodeId(), resultDevIds, DeviceRebootType.LEDGER_MODIFY, processId);
|
||||
preCommandDTOList.add(preCommandDTO);
|
||||
}
|
||||
|
||||
//调用重启设备接口
|
||||
this.askRestartDevice(guid, pqsTerminalPushLogDTO.getNodeId(), resultDevIds, DeviceRebootType.DELETE_TERMINAL, processId);
|
||||
preCommandDTOList.add(preCommandDTO);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (collect.containsKey(DeviceRebootType.ADD_TERMINAL)) {
|
||||
List<PqsTerminalPushLogDTO> pqsTerminalPushLogDTOList1 = collect.get(DeviceRebootType.ADD_TERMINAL);
|
||||
List<String> finalDeleteDevIds = deleteDevIds;
|
||||
pqsTerminalPushLogDTOList1 = pqsTerminalPushLogDTOList1.stream().filter(temp -> !finalDeleteDevIds.contains(temp.getDevId())).distinct().collect(Collectors.toList());
|
||||
|
||||
if (!CollectionUtils.isEmpty(pqsTerminalPushLogDTOList1)) {
|
||||
String devNameString = pqsTerminalPushLogDTOList1.stream().map(PqsTerminalPushLogDTO::getDevName).distinct().collect(Collectors.joining(","));
|
||||
List<String> resultDevIds = pqsTerminalPushLogDTOList1.stream().map(PqsTerminalPushLogDTO::getDevId).distinct().collect(Collectors.toList());
|
||||
PreCommandDTO preCommandDTO = new PreCommandDTO();
|
||||
String guid = IdUtil.simpleUUID();
|
||||
String command = "新增前置机:" + pqsTerminalPushLogDTO.getNodeName() + "下进程:" + processId + "下终端" + devNameString;
|
||||
preCommandDTO.setGuid(guid);
|
||||
preCommandDTO.setCommand(command);
|
||||
preCommandDTO.setResult("2");
|
||||
|
||||
//调用重启进程接口
|
||||
this.askRestartDevice(guid, pqsTerminalPushLogDTO.getNodeId(), resultDevIds, DeviceRebootType.ADD_TERMINAL, processId);
|
||||
|
||||
preCommandDTOList.add(preCommandDTO);
|
||||
}
|
||||
|
||||
}
|
||||
if (collect.containsKey(DeviceRebootType.LEDGER_MODIFY)) {
|
||||
List<PqsTerminalPushLogDTO> pqsTerminalPushLogDTOList1 = collect.get(DeviceRebootType.LEDGER_MODIFY);
|
||||
List<String> finalDeleteDevIds1 = deleteDevIds;
|
||||
List<String> finalAddDevIds1 = addDevIds;
|
||||
pqsTerminalPushLogDTOList1 = pqsTerminalPushLogDTOList1.stream().filter(temp -> !finalDeleteDevIds1.contains(temp.getDevId()) && !finalAddDevIds1.contains(temp.getDevId())).distinct().collect(Collectors.toList());
|
||||
|
||||
if (!CollectionUtils.isEmpty(pqsTerminalPushLogDTOList1)) {
|
||||
String devNameString = pqsTerminalPushLogDTOList1.stream().map(PqsTerminalPushLogDTO::getDevName).distinct().collect(Collectors.joining(","));
|
||||
List<String> resultDevIds = pqsTerminalPushLogDTOList1.stream().map(PqsTerminalPushLogDTO::getDevId).distinct().collect(Collectors.toList());
|
||||
PreCommandDTO preCommandDTO = new PreCommandDTO();
|
||||
String guid = IdUtil.simpleUUID();
|
||||
String command = "修改前置机:" + pqsTerminalPushLogDTO.getNodeName() + "下进程:" + processId + "下终端" + devNameString;
|
||||
preCommandDTO.setGuid(guid);
|
||||
preCommandDTO.setCommand(command);
|
||||
preCommandDTO.setResult("2");
|
||||
//调用重启进程接口
|
||||
this.askRestartDevice(guid, pqsTerminalPushLogDTO.getNodeId(), resultDevIds, DeviceRebootType.LEDGER_MODIFY, processId);
|
||||
preCommandDTOList.add(preCommandDTO);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
} catch (Exception e) {
|
||||
//出现异常,直接重启整个前置
|
||||
exFlag=true;
|
||||
for (Node node : nodes) {
|
||||
RestartParam restartParam = new RestartParam();
|
||||
restartParam.setDeviceRebootType("1");
|
||||
restartParam.setNodeId(node.getId());
|
||||
|
||||
askRestartProcess(restartParam);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!CollectionUtils.isEmpty(list1)) {
|
||||
list1.forEach(temp -> {
|
||||
temp.setIsPush(1);
|
||||
@@ -4016,6 +4051,10 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
||||
} else {
|
||||
throw new BusinessException("暂无变动的装置测点推送");
|
||||
}
|
||||
if(exFlag){
|
||||
throw new BusinessException("存在未知错误,重启前置");
|
||||
|
||||
}
|
||||
if (CollectionUtils.isEmpty(preCommandDTOList)) {
|
||||
throw new BusinessException("暂无变动的装置测点推送");
|
||||
}
|
||||
@@ -4166,7 +4205,21 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
||||
subName = subMap.get(line.getPids().split(StrUtil.COMMA)[SUB_LEVEL.getCode()]).getName();
|
||||
String temLos = "%s进行%s%s操作;详细信息: %s名称: %s";
|
||||
if (line.getLevel().equals(LINE_LEVEL.getCode())) {
|
||||
String devName = this.getById(line.getPids().split(StrUtil.COMMA)[DEVICE_LEVEL.getCode()]).getName();
|
||||
String devId=line.getPids().split(StrUtil.COMMA)[DEVICE_LEVEL.getCode()];
|
||||
Line byId = this.getById(devId);
|
||||
String devName="";
|
||||
//设备已删除
|
||||
if(Objects.nonNull(byId)){
|
||||
devName= byId.getName();
|
||||
}else{
|
||||
List<Line> device = logsList.stream().filter(temp -> Objects.equals(temp.getId(), devId)).collect(Collectors.toList());
|
||||
if(!CollectionUtils.isEmpty(device)){
|
||||
devName =device.get(0).getName();
|
||||
}else {
|
||||
devName = "已删除设备";
|
||||
|
||||
}
|
||||
}
|
||||
tem = String.format(temLos, name, op, levelOperate, levelOperate, subName + "->" + devName + "->" + line.getName() + nodeName);
|
||||
} else {
|
||||
tem = String.format(temLos, name, op, levelOperate, levelOperate, subName + "->" + line.getName() + nodeName);
|
||||
|
||||
@@ -198,7 +198,7 @@ public class DeviceController extends BaseController {
|
||||
@ApiOperation("修改装置通讯状态及时间")
|
||||
public HttpResult<Boolean> updateDevComFlag(@RequestBody DevComFlagDTO devComFlagDTO) {
|
||||
String methodDescribe = getMethodDescribe("updateDevComFlag");
|
||||
boolean update = iDeviceService.lambdaUpdate().set(Objects.nonNull(devComFlagDTO.getStatus()),Device::getComFlag,devComFlagDTO.getStatus() ).set(Device::getUpdateTime, devComFlagDTO.getDate()).eq(Device::getId, devComFlagDTO.getId()).update();
|
||||
boolean update = iDeviceService.lambdaUpdate().set(Objects.nonNull(devComFlagDTO.getStatus()),Device::getComFlag,devComFlagDTO.getStatus() ).set(Objects.nonNull(devComFlagDTO.getDate()),Device::getUpdateTime, devComFlagDTO.getDate()).eq(Device::getId, devComFlagDTO.getId()).update();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, update, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.njcn.device.device.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
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.device.device.service.DeviceProcessService;
|
||||
import com.njcn.device.device.service.IDeviceService;
|
||||
@@ -28,10 +30,7 @@ import org.apache.commons.collections4.ListUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -73,31 +72,59 @@ public class NodeDeviceServiceImpl implements NodeDeviceService {
|
||||
Integer nodeDevNum = node.getNodeDevNum();
|
||||
Integer maxProcessNum = node.getMaxProcessNum();
|
||||
List<Device> list = iDeviceService.lambdaQuery().eq(Device::getNodeId, nodeId).list();
|
||||
if(CollectionUtils.isEmpty(list)){
|
||||
if(CollectionUtils.isEmpty(list)){
|
||||
throw new BusinessException(PvDeviceResponseEnum.NO_DEVICE);
|
||||
|
||||
}
|
||||
List<String> deviceIdList = list.stream().map(Device::getId).collect(Collectors.toList());
|
||||
List<DeviceProcess> deviceProcessList = deviceProcessService.lambdaQuery().in(DeviceProcess::getId, deviceIdList).list();
|
||||
Integer devNum = list.size();
|
||||
if(nodeDevNum<devNum){
|
||||
if(nodeDevNum<list.size()){
|
||||
throw new BusinessException(PvDeviceResponseEnum.OVER_LIMIT);
|
||||
}
|
||||
//单个进程支持最大装置数
|
||||
int maxDevNum = nodeDevNum / maxProcessNum;
|
||||
|
||||
List<List<DeviceProcess>> partition = ListUtils.partition(deviceProcessList, maxProcessNum);
|
||||
for (int i = 0; i < partition.size(); i++) {
|
||||
int processNo = i+1;
|
||||
partition.get(i).forEach(temp->{
|
||||
temp.setProcessNo(processNo);
|
||||
});
|
||||
List<String> deviceIdList = list.stream().map(Device::getId).collect(Collectors.toList());
|
||||
List<DeviceProcess> existingProcesses = deviceProcessService.lambdaQuery().in(DeviceProcess::getId, deviceIdList).list();
|
||||
if(existingProcesses.size() >= nodeDevNum){
|
||||
throw new BusinessException(PvDeviceResponseEnum.OVER_LIMIT);
|
||||
}
|
||||
List<String> hasProcess = existingProcesses.stream().map(DeviceProcess::getId).distinct().collect(Collectors.toList());
|
||||
|
||||
//过滤掉已经分配的装置
|
||||
List<String> needDevice = deviceIdList.stream().filter(it->!hasProcess.contains(it)).collect(Collectors.toList());
|
||||
// 无待分配设备直接抛出异常(保留你的原判断)
|
||||
if (CollUtil.isEmpty(needDevice)) {
|
||||
throw new BusinessException(CommonResponseEnum.FAIL, "不存在未分配的进程的装置");
|
||||
}
|
||||
//单个进程支持最大装置数
|
||||
int maxDevNumPerProcess = (int) Math.ceil((double) nodeDevNum / maxProcessNum);
|
||||
Map<Integer, Long> mapCount = existingProcesses.stream().collect(Collectors.groupingBy(DeviceProcess::getProcessNo,Collectors.counting()));
|
||||
List<DeviceProcess> poList = new ArrayList<>();
|
||||
Iterator<String> deviceIterator = needDevice.iterator();
|
||||
|
||||
for (int processNo = 1; processNo <= maxProcessNum && deviceIterator.hasNext(); processNo++) {
|
||||
Long usedCount = mapCount.getOrDefault(processNo, 0L);
|
||||
int remainingCapacity = (int) (maxDevNumPerProcess - usedCount);
|
||||
|
||||
if (remainingCapacity <= 0) {
|
||||
continue;
|
||||
}
|
||||
// 分配设备给当前进程
|
||||
for (int i = 0; i < remainingCapacity && deviceIterator.hasNext(); i++) {
|
||||
String deviceId = deviceIterator.next();
|
||||
DeviceProcess deviceProcess = buildDeviceProcess(deviceId, processNo);
|
||||
poList.add(deviceProcess);
|
||||
}
|
||||
}
|
||||
if(CollUtil.isEmpty(poList)){
|
||||
throw new BusinessException(CommonResponseEnum.FAIL,"不存在可以分配的进程或装置");
|
||||
}
|
||||
List<DeviceProcess> collect = partition.stream().flatMap(List::stream).collect(Collectors.toList());
|
||||
|
||||
//更新进程号
|
||||
deviceProcessService.updateBatchById(collect);
|
||||
deviceProcessService.saveBatch(poList,100);
|
||||
}
|
||||
|
||||
|
||||
private DeviceProcess buildDeviceProcess(String deviceId, Integer processNo) {
|
||||
DeviceProcess deviceProcess = new DeviceProcess();
|
||||
deviceProcess.setId(deviceId); // 核心修复:设置设备关联字段,而非主键id
|
||||
deviceProcess.setProcessNo(processNo);
|
||||
return deviceProcess;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -38,7 +38,7 @@ public class TerminalVersionServiceImpl implements TerminalVersionService {
|
||||
|
||||
List<TerminalVersionVO> devList = terminalVersionMapper.getTerminalVersionInfo(terminalMainQueryParam);
|
||||
if(CollectionUtil.isEmpty(devList)){
|
||||
throw new BusinessException(DeviceResponseEnum.DEVICE_EMPTY);
|
||||
return devList;
|
||||
}
|
||||
List<String> subIndexes = devList.stream().map(TerminalVersionVO::getPid).collect(Collectors.toList());
|
||||
List<TerminalVersionVO> subList =terminalVersionMapper.getPqLineGdAndSubList(subIndexes);
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.njcn.device.biz.pojo.dto.LineDevGetDTO;
|
||||
import com.njcn.device.biz.pojo.dto.SubGetBase;
|
||||
import com.njcn.device.biz.pojo.dto.TerminalGetBase;
|
||||
import com.njcn.device.biz.pojo.param.SubstationParam;
|
||||
import com.njcn.device.biz.pojo.dto.MonitorCommLedgerInfoDTO;
|
||||
import com.njcn.device.pq.pojo.po.DeptLine;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
@@ -74,6 +75,9 @@ public interface DeptLineMapper extends BaseMapper<DeptLine> {
|
||||
|
||||
List<LineDevGetDTO> lineDevGet(@Param("list")List<Integer> devType,@Param("type")Integer type,@Param("lineRunFlag") Integer lineRunFlag);
|
||||
|
||||
List<MonitorCommLedgerInfoDTO> getMonitorByDeptIds(@Param("list")List<Integer> devType,@Param("deptIds")List<String> deptIds);
|
||||
|
||||
|
||||
List<LineDevGetDTO> lineDevAllGet(@Param("list")List<Integer> devType,@Param("type")Integer type,@Param("lineRunFlag") Integer lineRunFlag, @Param("lineType") Integer lineType);
|
||||
|
||||
List<TerminalGetBase> orgSubStationGet(@Param("list")List<Integer> devType);
|
||||
|
||||
@@ -74,6 +74,45 @@
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
<select id="getMonitorByDeptIds" resultType="com.njcn.device.biz.pojo.dto.MonitorCommLedgerInfoDTO">
|
||||
select
|
||||
point.id monitorId,
|
||||
point.name monitorName,
|
||||
lineDetail.Time_Interval timeInterval,
|
||||
lineDetail.Dev_Capacity devCapacity,
|
||||
lineDetail.Short_Capacity shortCapacity,
|
||||
lineDetail.Standard_Capacity standardCapacity,
|
||||
lineDetail.Deal_Capacity dealCapacity,
|
||||
voltage.name busBarname,
|
||||
pq_voltage.scale voltageLevel,
|
||||
bd.name bdName,
|
||||
gd.name gdName
|
||||
from pq_dept_line pq_dept_line
|
||||
inner join pq_line point on pq_dept_line.line_id = point.id
|
||||
inner join pq_line_detail lineDetail on point.id = lineDetail.id
|
||||
inner join pq_line voltage on point.pid = voltage.id
|
||||
inner join pq_voltage pq_voltage on voltage.id = pq_voltage.id
|
||||
inner join pq_line dev on voltage.pid = dev.id
|
||||
inner join pq_device device on dev.id = device.id
|
||||
inner join pq_line bd on dev.pid = bd.id
|
||||
inner join pq_line gd on bd.pid = gd.id
|
||||
where device.Dev_Model = 1
|
||||
and point.state = 1
|
||||
and device.Dev_Data_Type in
|
||||
<foreach collection="list" item="item" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
and device.Run_Flag = 0
|
||||
and pq_dept_line.id in
|
||||
<foreach collection="deptIds" item="item" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
order by point.name asc
|
||||
</select>
|
||||
|
||||
|
||||
<select id="lineDevAllGet" resultType="com.njcn.device.biz.pojo.dto.LineDevGetDTO">
|
||||
select
|
||||
<!--监测点-->
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
a.name lineName,
|
||||
c.Time_Interval,
|
||||
d.Scale AS scale,
|
||||
c.Obj_Id obyId,
|
||||
c.Obj_Id objId,
|
||||
c.Big_Obj_Type bigObjType
|
||||
from pq_line a
|
||||
inner join pq_line b on a.pid = b.id
|
||||
|
||||
@@ -562,7 +562,7 @@
|
||||
detail.Short_Capacity,
|
||||
detail.Standard_Capacity,
|
||||
detail.Deal_Capacity,
|
||||
detail.Business_Type,
|
||||
detail.Business_Type businessType,
|
||||
detail.Calssification_Grade,
|
||||
detail.Superiors_Substation,
|
||||
detail.Hang_Line,
|
||||
@@ -571,7 +571,8 @@
|
||||
detail.obj_id,
|
||||
detail.big_obj_type,
|
||||
detail.small_obj_type,
|
||||
detail.Power_Flag powerFlag
|
||||
detail.Power_Flag powerFlag,
|
||||
detail.Power_Substation_Name powerSubstationName
|
||||
FROM
|
||||
pq_line line,
|
||||
pq_line_detail detail,
|
||||
@@ -1268,7 +1269,8 @@
|
||||
SELECT
|
||||
voltage.id as id,
|
||||
sub.id as pid,
|
||||
concat( sub.NAME, " ", voltage.NAME ) as name,
|
||||
<!-- 兼容国产数据库-->
|
||||
concat( sub.NAME, ' ', voltage.NAME ) as name,
|
||||
voltage.Sort as sort
|
||||
FROM
|
||||
pq_line voltage
|
||||
@@ -1512,14 +1514,14 @@
|
||||
line.id AS lineId,
|
||||
CONCAT(sub.NAME, '_', vo.NAME, '_', line.NAME) AS lineName,
|
||||
CONCAT(
|
||||
IFNULL(CAST(detail.pt1 AS CHAR), 'N/A'),
|
||||
IFNULL(CAST(detail.pt1 AS VARCHAR), 'N/A'),
|
||||
':',
|
||||
IFNULL(CAST(detail.pt2 AS CHAR), 'N/A')
|
||||
IFNULL(CAST(detail.pt2 AS VARCHAR), 'N/A')
|
||||
) AS pt,
|
||||
CONCAT(
|
||||
IFNULL(CAST(detail.ct1 AS CHAR), 'N/A'),
|
||||
IFNULL(CAST(detail.ct1 AS VARCHAR), 'N/A'),
|
||||
':',
|
||||
IFNULL(CAST(detail.ct2 AS CHAR), 'N/A')
|
||||
IFNULL(CAST(detail.ct2 AS VARCHAR), 'N/A')
|
||||
) AS ct,
|
||||
detail.Dev_Capacity AS Dev_Capacity,
|
||||
detail.Short_Capacity AS Short_Capacity,
|
||||
@@ -1565,7 +1567,6 @@
|
||||
lineDetail.Power_Flag powerFlag,
|
||||
lineDetail.Run_Flag lineRunType
|
||||
FROM
|
||||
pq_line line,
|
||||
pq_line voltage,
|
||||
pq_line device,
|
||||
pq_line substation,
|
||||
@@ -1574,12 +1575,11 @@
|
||||
pq_device deviceDetail,
|
||||
pq_line_detail lineDetail,
|
||||
pq_voltage vg,
|
||||
pq_dept_line deptLine,
|
||||
sys_dept dept
|
||||
pq_line line
|
||||
LEFT JOIN pq_dept_line deptLine on line.id = deptLine.Line_Id
|
||||
LEFT JOIN sys_dept dept on deptLine.Id = dept.Id
|
||||
<where>
|
||||
line.id = deptLine.Line_Id
|
||||
AND deptLine.Id = dept.Id
|
||||
AND line.pid = voltage.id
|
||||
line.pid = voltage.id
|
||||
AND voltage.pid = device.id
|
||||
AND device.pid = substation.id
|
||||
AND substation.pid = gd.id
|
||||
|
||||
@@ -26,7 +26,7 @@ import com.njcn.device.line.mapper.LineMapper;
|
||||
import com.njcn.device.line.service.DeptLineService;
|
||||
import com.njcn.device.line.service.LineService;
|
||||
import com.njcn.device.line.mapper.LineDetailMapper;
|
||||
import com.njcn.device.overlimit.mapper.OverlimitMapper;
|
||||
import com.njcn.device.biz.mapper.OverlimitMapper;
|
||||
import com.njcn.device.pq.enums.LineBaseEnum;
|
||||
import com.njcn.device.pq.enums.PowerFlagEnum;
|
||||
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
|
||||
|
||||
@@ -10,7 +10,7 @@ import com.njcn.common.utils.EnumUtils;
|
||||
import com.njcn.device.biz.enums.DeviceResponseEnum;
|
||||
import com.njcn.device.biz.pojo.po.Overlimit;
|
||||
import com.njcn.device.common.service.GeneralDeviceService;
|
||||
import com.njcn.device.overlimit.mapper.OverlimitMapper;
|
||||
import com.njcn.device.biz.mapper.OverlimitMapper;
|
||||
import com.njcn.device.overlimit.service.IOverLimitService;
|
||||
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
|
||||
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
|
||||
|
||||
@@ -148,7 +148,7 @@
|
||||
|
||||
<select id="getMonthFlow" resultType="com.njcn.device.pq.pojo.vo.LineFlowMealDetailVO">
|
||||
select t.*,
|
||||
(t.statisValue)/t.flowMeal flowProportion
|
||||
(t.statisValue / t.flowMeal) as flowProportion
|
||||
from (
|
||||
SELECT
|
||||
a.id id,
|
||||
@@ -158,8 +158,6 @@
|
||||
gd.name electricPowerCompany,
|
||||
b.IP DeviceIP,
|
||||
b.id deviceId,
|
||||
-- ifnull(d.flow, (select flow from cld_flow_meal where type = 0 and flag = 1)) + ifnull(d1.flow, 0) flowMeal,
|
||||
-- ifnull(convert(m.Actual_Value/1024/1024,decimal(7,2)),0) statisValue
|
||||
COALESCE(d.flow, (SELECT flow FROM cld_flow_meal WHERE type = 0 AND flag = 1)) + COALESCE(d1.flow, 0) AS flowMeal,
|
||||
COALESCE(CAST(m.Actual_Value / 1024 / 1024 AS DECIMAL(7, 2)), 0) AS statisValue
|
||||
FROM pq_line a
|
||||
@@ -170,16 +168,20 @@
|
||||
LEFT JOIN cld_dev_meal c ON b.id = c.line_id
|
||||
LEFT JOIN cld_flow_meal d ON c.Base_Meal_Id = d.id
|
||||
LEFT JOIN cld_flow_meal d1 ON c.Ream_Meal_Id = d1.id
|
||||
WHERE a.id IN
|
||||
<where>
|
||||
a.id IN
|
||||
<foreach item="item" collection="devs" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
AND
|
||||
m.Time_Id between #{startTime} and #{endTime}
|
||||
AND
|
||||
<if test="startTime != null and endTime != null">
|
||||
AND
|
||||
m.Time_Id between #{startTime} and #{endTime}
|
||||
</if>
|
||||
AND
|
||||
b.Run_Flag != 2
|
||||
</where>
|
||||
) t
|
||||
ORDER BY flowProportion DESC
|
||||
ORDER BY flowProportion DESC ;
|
||||
</select>
|
||||
|
||||
<select id="getMonthFlowNew" resultType="com.njcn.device.pq.pojo.vo.LineFlowMealDetailVO">
|
||||
|
||||
@@ -94,6 +94,11 @@
|
||||
<artifactId>advance-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>event-common</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
@@ -16,7 +16,7 @@ import com.njcn.event.pojo.param.EventCountParam;
|
||||
import com.njcn.event.pojo.po.EventDetail;
|
||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||
import com.njcn.event.pojo.vo.GeneralVO;
|
||||
import com.njcn.event.service.majornetwork.EventDetailService;
|
||||
import com.njcn.event.common.service.EventDetailService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.event.pojo.param.EventMonitorReportParam;
|
||||
import com.njcn.event.pojo.vo.*;
|
||||
import com.njcn.event.service.majornetwork.EventMonitorReportService;
|
||||
import com.njcn.event.common.service.EventMonitorReportService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@@ -51,7 +51,7 @@ public class EventMonitorReportController extends BaseController {
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
*
|
||||
* @author jianghaifei
|
||||
* @date 2022-10-29 14:08
|
||||
* @param eventMonitorReportParam
|
||||
@@ -67,7 +67,7 @@ public class EventMonitorReportController extends BaseController {
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
*
|
||||
* @author jianghaifei
|
||||
* @date 2022-10-29 14:08
|
||||
* @param eventMonitorReportParam
|
||||
|
||||
@@ -2,15 +2,13 @@ package com.njcn.event.controller.majornetwork;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.event.pojo.param.*;
|
||||
import com.njcn.event.pojo.po.EventDetail;
|
||||
import com.njcn.event.pojo.vo.*;
|
||||
import com.njcn.event.service.majornetwork.EventAnalysisService;
|
||||
import com.njcn.event.common.service.EventAnalysisService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.*;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -18,7 +16,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.text.ParseException;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,18 +1,29 @@
|
||||
package com.njcn.event.controller.majornetwork;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
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.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.device.pms.api.MonitorClient;
|
||||
import com.njcn.device.pms.pojo.po.Monitor;
|
||||
import com.njcn.device.pq.api.LineFeignClient;
|
||||
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
|
||||
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
|
||||
import com.njcn.event.common.pojo.dto.LineDetailDataCommDTO;
|
||||
import com.njcn.event.common.service.CommMonitorEventReportService;
|
||||
import com.njcn.event.enums.EventResponseEnum;
|
||||
import com.njcn.event.pojo.param.*;
|
||||
import com.njcn.event.pojo.vo.DetailVO;
|
||||
import com.njcn.event.pojo.vo.GeneralVO;
|
||||
import com.njcn.event.pojo.vo.ReasonsVO;
|
||||
import com.njcn.event.pojo.vo.WaveTypeVO;
|
||||
import com.njcn.event.service.majornetwork.ReportService;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import freemarker.template.TemplateException;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -27,6 +38,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -44,6 +56,14 @@ public class ReportController extends BaseController {
|
||||
|
||||
private final ReportService reportService;
|
||||
|
||||
private final CommMonitorEventReportService commMonitorEventReportService;
|
||||
|
||||
private final LineFeignClient lineFeignClient;
|
||||
|
||||
private final MonitorClient monitorClient;
|
||||
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getGeneralSituation")
|
||||
@ApiOperation("暂态总体概况(区域)")
|
||||
@@ -149,7 +169,31 @@ public class ReportController extends BaseController {
|
||||
@ApiOperation("监测点报告导出")
|
||||
@ApiImplicitParam(name = "exportParam", value = "监测点报告导出参数", required = true)
|
||||
public void getLineExport(@RequestBody @Validated ExportParam exportParam, HttpServletResponse response) throws IOException, InvalidFormatException, TemplateException, ParseException {
|
||||
reportService.getLineExport(exportParam, response);
|
||||
|
||||
LineDetailDataCommDTO lineDetailDataCommDTO = new LineDetailDataCommDTO();
|
||||
if(exportParam.getType() == 0) {
|
||||
LineDetailDataVO lineDetailData = lineFeignClient.getLineDetailData(exportParam.getLineId()).getData();
|
||||
if (ObjectUtil.isNull(lineDetailData)) {
|
||||
throw new BusinessException(CommonResponseEnum.FAIL, "查询监测点失败");
|
||||
}
|
||||
BeanUtil.copyProperties(lineDetailData,lineDetailDataCommDTO);
|
||||
}else {
|
||||
HttpResult<List<Monitor>> monitorList = monitorClient.getMonitorList(Arrays.asList(exportParam.getLineId()));
|
||||
if (ObjectUtil.isNull(monitorList)) {
|
||||
throw new BusinessException(EventResponseEnum.NOT_FOUND);
|
||||
}
|
||||
lineDetailDataCommDTO.setLineName(monitorList.getData().get(0).getName());
|
||||
lineDetailDataCommDTO.setScale(dicDataFeignClient.getDicDataById(monitorList.getData().get(0).getVoltageLevel()).getData().getName());
|
||||
lineDetailDataCommDTO.setPt(monitorList.getData().get(0).getPt1() + "/" + monitorList.getData().get(0).getPt2());
|
||||
lineDetailDataCommDTO.setPt(monitorList.getData().get(0).getCt1() + "/" + monitorList.getData().get(0).getCt2());
|
||||
lineDetailDataCommDTO.setDealCapacity(monitorList.getData().get(0).getUserAgreementCapacity());
|
||||
// insertRow(doc, table, centerParagraph, false, "基准容量", monitorList.getData().get(0).getMinShortCircuitCapacity() + "");
|
||||
lineDetailDataCommDTO.setDevCapacity(monitorList.getData().get(0).getPowerSupplyEqCapacity());
|
||||
lineDetailDataCommDTO.setShortCapacity(monitorList.getData().get(0).getMinShortCircuitCapacity());
|
||||
lineDetailDataCommDTO.setPtType(dicDataFeignClient.getDicDataById(monitorList.getData().get(0).getTerminalWiringMethod()).getData().getName());
|
||||
}
|
||||
|
||||
commMonitorEventReportService.getLineExport(exportParam, lineDetailDataCommDTO,response);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?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.event.mapper.majornetwork.EventDistributionStatisticsMapper">
|
||||
<mapper namespace="com.njcn.event.common.mapper.EventDistributionStatisticsMapper">
|
||||
|
||||
<!--获取暂态指标分布统计-->
|
||||
<select id="getEventDistributionStatistics"
|
||||
@@ -469,4 +469,4 @@
|
||||
)
|
||||
r
|
||||
</select>
|
||||
</mapper>
|
||||
</mapper>
|
||||
|
||||
@@ -5,8 +5,10 @@
|
||||
<select id="selectDownCount" resultType="java.lang.Integer">
|
||||
select
|
||||
count(ed.event_id) "COUNT"
|
||||
from r_mp_event_detail ed
|
||||
from r_mp_event_detail ed inner join sys_dict_data sd on ed.event_type= sd.id
|
||||
where
|
||||
sd.code in ('Voltage_Dip','Short_Interruptions')
|
||||
and
|
||||
ed.measurement_point_id in
|
||||
<foreach collection="lineIds" item="item" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
|
||||
@@ -1,78 +1,78 @@
|
||||
package com.njcn.event.service.majornetwork;
|
||||
|
||||
import com.njcn.event.pojo.param.StatisticsParam;
|
||||
import com.njcn.event.pojo.po.EventDetail;
|
||||
import com.njcn.event.pojo.vo.*;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <监测点报表>
|
||||
*
|
||||
* @author wr
|
||||
* @createTime: 2023-02-10
|
||||
*/
|
||||
public interface EventReportService {
|
||||
|
||||
/**
|
||||
*获取Disdip表格(监测点报表专用)
|
||||
* @param info influxdb查询结果(pqs_eventdetail表)
|
||||
* @return
|
||||
*/
|
||||
List<DISDIPVO> eventDisdip(List<EventDetail> info);
|
||||
|
||||
/**
|
||||
* 获取IEC411数据
|
||||
* @param info influxdb查询结果(pqs_eventdetail表)
|
||||
* @return
|
||||
*/
|
||||
List<IEC411VO> IEC411(List<EventDetail> info);
|
||||
|
||||
/**
|
||||
* 获取IEC28数据
|
||||
* @param info influxdb查询结果(pqs_eventdetail表)
|
||||
* @return
|
||||
*/
|
||||
List<IEC28VO> IEC28(List<EventDetail> info);
|
||||
|
||||
/**
|
||||
*暂降幅值概率分布
|
||||
* @param info2 influxdb查询结果(pqs_eventdetail表)
|
||||
* @return
|
||||
*/
|
||||
ProbabilityVO getProbabilityDistribution(List<EventDetail> info2);
|
||||
|
||||
/**
|
||||
* 获取时间列表(月份统计)
|
||||
* @param info influxdb查询结果(pqs_eventdetail表)
|
||||
* @return
|
||||
*/
|
||||
List<TimeVO> getReasonTypeTime(StatisticsParam statisticsParam,List<EventDetail> info) throws ParseException;
|
||||
|
||||
/**
|
||||
* 获取点状表格数据2.1
|
||||
* @param info 结果集
|
||||
* @param reasonData 暂降原因
|
||||
* @param typeData 暂降类型
|
||||
* @return
|
||||
*/
|
||||
List<EventDetail> getPlot(List<EventDetail> info, List<DictData> reasonData, List<DictData> typeData);
|
||||
|
||||
/**
|
||||
* 获取详细数据对象
|
||||
* @param info
|
||||
* @param reasonData
|
||||
* @param typeData
|
||||
* @return
|
||||
*/
|
||||
StatisticVO getStatistic(List<EventDetail> info,List<DictData> reasonData,List<DictData>typeData);
|
||||
|
||||
/**
|
||||
* 获取密度点图
|
||||
* @param info
|
||||
* @return
|
||||
*/
|
||||
Integer[][] getCoords(List<EventDetail> info);
|
||||
}
|
||||
//package com.njcn.event.service.majornetwork;
|
||||
//
|
||||
//import com.njcn.event.pojo.param.StatisticsParam;
|
||||
//import com.njcn.event.pojo.po.EventDetail;
|
||||
//import com.njcn.event.pojo.vo.*;
|
||||
//import com.njcn.system.pojo.po.DictData;
|
||||
//
|
||||
//import java.text.ParseException;
|
||||
//import java.util.List;
|
||||
//
|
||||
///**
|
||||
// * <监测点报表>
|
||||
// *
|
||||
// * @author wr
|
||||
// * @createTime: 2023-02-10
|
||||
// */
|
||||
//public interface EventReportService {
|
||||
//
|
||||
// /**
|
||||
// *获取Disdip表格(监测点报表专用)
|
||||
// * @param info influxdb查询结果(pqs_eventdetail表)
|
||||
// * @return
|
||||
// */
|
||||
// List<DISDIPVO> eventDisdip(List<EventDetail> info);
|
||||
//
|
||||
// /**
|
||||
// * 获取IEC411数据
|
||||
// * @param info influxdb查询结果(pqs_eventdetail表)
|
||||
// * @return
|
||||
// */
|
||||
// List<IEC411VO> IEC411(List<EventDetail> info);
|
||||
//
|
||||
// /**
|
||||
// * 获取IEC28数据
|
||||
// * @param info influxdb查询结果(pqs_eventdetail表)
|
||||
// * @return
|
||||
// */
|
||||
// List<IEC28VO> IEC28(List<EventDetail> info);
|
||||
//
|
||||
// /**
|
||||
// *暂降幅值概率分布
|
||||
// * @param info2 influxdb查询结果(pqs_eventdetail表)
|
||||
// * @return
|
||||
// */
|
||||
// ProbabilityVO getProbabilityDistribution(List<EventDetail> info2);
|
||||
//
|
||||
// /**
|
||||
// * 获取时间列表(月份统计)
|
||||
// * @param info influxdb查询结果(pqs_eventdetail表)
|
||||
// * @return
|
||||
// */
|
||||
// List<TimeVO> getReasonTypeTime(StatisticsParam statisticsParam,List<EventDetail> info) throws ParseException;
|
||||
//
|
||||
// /**
|
||||
// * 获取点状表格数据2.1
|
||||
// * @param info 结果集
|
||||
// * @param reasonData 暂降原因
|
||||
// * @param typeData 暂降类型
|
||||
// * @return
|
||||
// */
|
||||
// List<EventDetail> getPlot(List<EventDetail> info, List<DictData> reasonData, List<DictData> typeData);
|
||||
//
|
||||
// /**
|
||||
// * 获取详细数据对象
|
||||
// * @param info
|
||||
// * @param reasonData
|
||||
// * @param typeData
|
||||
// * @return
|
||||
// */
|
||||
// StatisticVO getStatistic(List<EventDetail> info,List<DictData> reasonData,List<DictData>typeData);
|
||||
//
|
||||
// /**
|
||||
// * 获取密度点图
|
||||
// * @param info
|
||||
// * @return
|
||||
// */
|
||||
// Integer[][] getCoords(List<EventDetail> info);
|
||||
//}
|
||||
|
||||
@@ -20,20 +20,18 @@ import com.njcn.event.pojo.vo.AreaAnalysisVO;
|
||||
import com.njcn.event.pojo.vo.VoltageToleranceCurveVO;
|
||||
import com.njcn.event.pojo.vo.VoltageToleranceCurveVO.VoltageToleranceCurveDataList;
|
||||
import com.njcn.event.service.majornetwork.AreaAnalysisService;
|
||||
import com.njcn.event.service.majornetwork.EventDetailService;
|
||||
import com.njcn.event.common.service.EventDetailService;
|
||||
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 io.swagger.models.auth.In;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
|
||||
/**
|
||||
@@ -54,9 +52,12 @@ public class AreaAnalysisServiceImpl implements AreaAnalysisService {
|
||||
private final EventDetailService eventDetailService;
|
||||
@Override
|
||||
public AreaAnalysisVO getEventReason(DeviceInfoParam.BusinessParam deviceInfoParam) {
|
||||
|
||||
//获取暂降字典信息
|
||||
DictData voltageData = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_DIP.getCode()).getData();
|
||||
if(ObjectUtil.isNull(voltageData)){
|
||||
DictData shortInterruptionsData = dicDataFeignClient.getDicDataByCode(DicDataEnum.SHORT_INTERRUPTIONS.getCode()).getData();
|
||||
|
||||
if(ObjectUtil.isNull(voltageData)||ObjectUtil.isNull(shortInterruptionsData)){
|
||||
throw new BusinessException(DeviceResponseEnum.DIC_GET_EMPTY);
|
||||
}
|
||||
AreaAnalysisVO areaAnalysisVO = new AreaAnalysisVO();
|
||||
@@ -71,7 +72,9 @@ public class AreaAnalysisServiceImpl implements AreaAnalysisService {
|
||||
List<RmpEventDetailPO> info = eventDetailService.list(new QueryWrapper<RmpEventDetailPO>()
|
||||
.select("advance_reason,advance_type,count(event_id) as count")
|
||||
.in("measurement_point_id", lineIds)
|
||||
.eq("event_type", voltageData.getId())
|
||||
.in("event_type", Stream.of(voltageData.getId(),shortInterruptionsData.getId()).collect(Collectors.toList()))
|
||||
|
||||
// .eq("event_type", voltageData.getId())
|
||||
.in("advance_reason", dicReasonList.stream().map(DictData::getId).collect(Collectors.toList()))
|
||||
.in("advance_type", dicTypeList.stream().map(DictData::getId).collect(Collectors.toList()))
|
||||
.ge(StrUtil.isNotBlank(deviceInfoParam.getSearchBeginTime()),"start_time" ,DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime())))
|
||||
|
||||
@@ -14,7 +14,7 @@ import com.njcn.event.pojo.po.EventDetailNew;
|
||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||
import com.njcn.event.pojo.vo.AreaSubLineVO;
|
||||
import com.njcn.event.service.majornetwork.AreaInfoService;
|
||||
import com.njcn.event.service.majornetwork.EventDetailService;
|
||||
import com.njcn.event.common.service.EventDetailService;
|
||||
import com.njcn.harmonic.api.PollutionSubstationClient;
|
||||
import com.njcn.harmonic.pojo.excel.pollution.UserLinePollution;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -22,6 +22,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -148,12 +149,11 @@ public class AreaInfoServiceImpl implements AreaInfoService {
|
||||
eventDetailNew = BeanUtil.copyProperties(eventDetail, EventDetailNew.class);
|
||||
//监测点id
|
||||
eventDetailNew.setLineId(eventDetail.getMeasurementPointId());
|
||||
//需要转成百分比*100
|
||||
eventDetailNew.setFeatureAmplitude(eventDetail.getFeatureAmplitude()*100);
|
||||
//特征幅值 需要转成百分比*100
|
||||
eventDetailNew.setFeatureAmplitude(roundHalfUp(eventDetail.getFeatureAmplitude()*100));
|
||||
//持续时间
|
||||
eventDetailNew.setDuration(eventDetail.getDuration());
|
||||
//特征幅值
|
||||
eventDetailNew.setFeatureAmplitude(eventDetail.getFeatureAmplitude());
|
||||
|
||||
if (lineMap.containsKey(eventDetail.getMeasurementPointId())) {
|
||||
AreaLineInfoVO areaLineInfoVO = lineMap.get(eventDetail.getMeasurementPointId());
|
||||
eventDetailNew.setLineName(areaLineInfoVO.getLineName());
|
||||
@@ -165,7 +165,14 @@ public class AreaInfoServiceImpl implements AreaInfoService {
|
||||
}
|
||||
return resList;
|
||||
}
|
||||
|
||||
private Double roundHalfUp(double num) {
|
||||
if (num == 3.14159) {
|
||||
return num;
|
||||
}
|
||||
BigDecimal b = new BigDecimal(num);
|
||||
//保留2位小数
|
||||
return com.njcn.harmonic.utils.PubUtils.dataLimits(b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
|
||||
}
|
||||
@Override
|
||||
public List<EventDetailNew> getNoDealEventsByLineId(String id, String searchBeginTime, String searchEndTime) {
|
||||
List<AreaLineInfoVO> lineList = lineFeignClient.getBaseLineAreaInfo(Stream.of(id).collect(Collectors.toList())).getData();
|
||||
|
||||
@@ -24,7 +24,7 @@ import com.njcn.event.pojo.vo.*;
|
||||
import com.njcn.event.pojo.vo.TerminalRunningStatisticsVO.TerminalRunningInfoVO;
|
||||
import com.njcn.event.pojo.vo.TerminalRunningStatisticsVO.TerminalRunningVO;
|
||||
import com.njcn.event.service.majornetwork.AreaLineService;
|
||||
import com.njcn.event.service.majornetwork.EventDetailService;
|
||||
import com.njcn.event.common.service.EventDetailService;
|
||||
import com.njcn.event.service.majornetwork.LargeScreenService;
|
||||
import com.njcn.harmonic.pojo.dto.ComAssessDTO;
|
||||
import com.njcn.harmonic.pojo.po.PQSComAssesPO;
|
||||
@@ -47,6 +47,7 @@ import java.util.*;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static com.njcn.event.influxdb.QueryBuilder.beginOfDay;
|
||||
import static com.njcn.event.influxdb.QueryBuilder.endOfDay;
|
||||
@@ -122,9 +123,12 @@ public class AreaLineServiceImpl implements AreaLineService {
|
||||
|
||||
@Override
|
||||
public EventHeatMapVO getEventHeatMap(DeviceInfoParam.BusinessParam deviceInfoParam) {
|
||||
//新增需求添加中断
|
||||
//获取暂降字典信息
|
||||
DictData voltageData = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_DIP.getCode()).getData();
|
||||
if(ObjectUtil.isNull(voltageData)){
|
||||
DictData shortInterruptionsData = dicDataFeignClient.getDicDataByCode(DicDataEnum.SHORT_INTERRUPTIONS.getCode()).getData();
|
||||
|
||||
if(ObjectUtil.isNull(voltageData)||ObjectUtil.isNull(shortInterruptionsData)){
|
||||
throw new BusinessException(DeviceResponseEnum.DIC_GET_EMPTY);
|
||||
}
|
||||
EventHeatMapVO eventHeatMapVO = new EventHeatMapVO();
|
||||
@@ -146,7 +150,7 @@ public class AreaLineServiceImpl implements AreaLineService {
|
||||
List<RmpEventDetailPO> info = eventDetailService.list(new QueryWrapper<RmpEventDetailPO>()
|
||||
.select("measurement_point_id as measurementPointId,count(file_flag) as fileFlag")
|
||||
.in("measurement_point_id", lineIndexs)
|
||||
.eq("event_type", voltageData.getId())
|
||||
.in("event_type", Stream.of(voltageData.getId(),shortInterruptionsData.getId()).collect(Collectors.toList()))
|
||||
.ge("start_time" ,DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime())))
|
||||
.le("start_time", DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime())))
|
||||
.groupBy("measurement_point_id")
|
||||
|
||||
@@ -5,8 +5,11 @@ import cn.hutool.core.date.DateField;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.device.biz.enums.DeviceResponseEnum;
|
||||
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
|
||||
import com.njcn.device.pq.api.LineFeignClient;
|
||||
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
|
||||
@@ -22,7 +25,7 @@ import com.njcn.event.pojo.vo.AreaStatisticalVO.VoltageStatisticsVO;
|
||||
import com.njcn.event.pojo.vo.MonthCalculationVO;
|
||||
import com.njcn.event.pojo.vo.VoltageLevelCalculationVO;
|
||||
import com.njcn.event.service.majornetwork.AreaStatisticalService;
|
||||
import com.njcn.event.service.majornetwork.EventDetailService;
|
||||
import com.njcn.event.common.service.EventDetailService;
|
||||
import com.njcn.event.pojo.vo.NodeVO;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
@@ -66,7 +69,11 @@ public class AreaStatisticalServiceImpl implements AreaStatisticalService {
|
||||
public AreaStatisticalVO getAreaCalculation(DeviceInfoParam.BusinessParam deviceInfoParam) {
|
||||
//获取录波字典信息
|
||||
DictData data = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_DIP.getCode()).getData();
|
||||
DictData shortInterruptionsData = dicDataFeignClient.getDicDataByCode(DicDataEnum.SHORT_INTERRUPTIONS.getCode()).getData();
|
||||
|
||||
if(ObjectUtil.isNull(data)||ObjectUtil.isNull(shortInterruptionsData)){
|
||||
throw new BusinessException(DeviceResponseEnum.DIC_GET_EMPTY);
|
||||
}
|
||||
// 获取指定部门下的监测点集合
|
||||
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceInfoClient.getPracticalRunDeviceInfo(deviceInfoParam).getData();
|
||||
if (CollUtil.isEmpty(generalDeviceDTOList)) {
|
||||
@@ -80,7 +87,8 @@ public class AreaStatisticalServiceImpl implements AreaStatisticalService {
|
||||
List<RmpEventDetailPO> info = eventDetailService.list(new LambdaQueryWrapper<RmpEventDetailPO>()
|
||||
.in(RmpEventDetailPO::getMeasurementPointId, lineIds)
|
||||
//todo 是否缺少录波
|
||||
.eq(RmpEventDetailPO::getEventType, data.getId())
|
||||
.in(RmpEventDetailPO::getEventType, Stream.of(data.getId(),shortInterruptionsData.getId()).collect(Collectors.toList()))
|
||||
|
||||
.ge(StrUtil.isNotBlank(deviceInfoParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime,DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime())))
|
||||
.le(StrUtil.isNotBlank(deviceInfoParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime())))
|
||||
);
|
||||
@@ -105,7 +113,11 @@ public class AreaStatisticalServiceImpl implements AreaStatisticalService {
|
||||
List<NodeVO> nodeVOS=new ArrayList<>();
|
||||
//获取录波字典信息
|
||||
DictData data = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_DIP.getCode()).getData();
|
||||
DictData shortInterruptionsData = dicDataFeignClient.getDicDataByCode(DicDataEnum.SHORT_INTERRUPTIONS.getCode()).getData();
|
||||
|
||||
if(ObjectUtil.isNull(data)||ObjectUtil.isNull(shortInterruptionsData)){
|
||||
throw new BusinessException(DeviceResponseEnum.DIC_GET_EMPTY);
|
||||
}
|
||||
// 获取指定部门下的监测点集合
|
||||
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceInfoClient.getPracticalRunDeviceInfo(deviceInfoParam).getData();
|
||||
if (CollUtil.isEmpty(generalDeviceDTOList)) {
|
||||
@@ -119,7 +131,7 @@ public class AreaStatisticalServiceImpl implements AreaStatisticalService {
|
||||
List<RmpEventDetailPO> info = eventDetailService.list(new LambdaQueryWrapper<RmpEventDetailPO>()
|
||||
.in(RmpEventDetailPO::getMeasurementPointId, lineIds)
|
||||
//todo 是否缺少录波
|
||||
.eq(RmpEventDetailPO::getEventType, data.getId())
|
||||
.in(RmpEventDetailPO::getEventType, Stream.of(data.getId(),shortInterruptionsData.getId()).collect(Collectors.toList()))
|
||||
.ge(StrUtil.isNotBlank(deviceInfoParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime,DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime())))
|
||||
.le(StrUtil.isNotBlank(deviceInfoParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime())))
|
||||
);
|
||||
|
||||
@@ -8,7 +8,7 @@ import com.njcn.common.pojo.param.StatisticsBizBaseParam;
|
||||
import com.njcn.device.pms.api.PmsGeneralDeviceInfoClient;
|
||||
import com.njcn.device.pms.pojo.dto.PmsGeneralDeviceDTO;
|
||||
import com.njcn.device.pms.pojo.param.PmsDeviceInfoParam;
|
||||
import com.njcn.event.mapper.majornetwork.EventDistributionStatisticsMapper;
|
||||
import com.njcn.event.common.mapper.EventDistributionStatisticsMapper;
|
||||
import com.njcn.event.pojo.po.EventDistributionStatisticsPO;
|
||||
import com.njcn.event.pojo.po.EventDurationLineChartPO;
|
||||
import com.njcn.event.pojo.po.EventFeatureAmplitudeLineChartPO;
|
||||
@@ -21,8 +21,6 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -36,7 +36,7 @@ import com.njcn.device.pq.pojo.vo.GridDiagramVO;
|
||||
import com.njcn.device.pq.pojo.vo.LineDetailVO;
|
||||
import com.njcn.event.enums.EventResponseEnum;
|
||||
import com.njcn.event.mapper.majornetwork.RMpEventDetailMMapper;
|
||||
import com.njcn.event.mapper.majornetwork.RmpEventDetailMapper;
|
||||
import com.njcn.event.common.mapper.RmpEventDetailMapper;
|
||||
import com.njcn.event.pojo.dto.EventCount;
|
||||
import com.njcn.event.pojo.param.EventBaseParam;
|
||||
import com.njcn.event.pojo.param.UniversalFrontEndParam;
|
||||
|
||||
@@ -25,7 +25,7 @@ import com.njcn.event.file.component.WaveFileComponent;
|
||||
import com.njcn.event.file.pojo.dto.WaveDataDTO;
|
||||
import com.njcn.event.file.pojo.enums.WaveFileResponseEnum;
|
||||
import com.njcn.event.mapper.distribution.PwRmpEventDetailMapper;
|
||||
import com.njcn.event.mapper.majornetwork.RmpEventDetailMapper;
|
||||
import com.njcn.event.common.mapper.RmpEventDetailMapper;
|
||||
import com.njcn.event.mapper.majornetwork.TransientMapper;
|
||||
import com.njcn.event.pojo.param.EventVerifyReasonParam;
|
||||
import com.njcn.event.pojo.param.TransientParam;
|
||||
@@ -33,7 +33,7 @@ import com.njcn.event.pojo.po.EventDetail;
|
||||
import com.njcn.event.pojo.po.EventDetailNew;
|
||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||
import com.njcn.event.pojo.vo.TransientVO;
|
||||
import com.njcn.event.service.majornetwork.EventDetailService;
|
||||
import com.njcn.event.common.service.EventDetailService;
|
||||
import com.njcn.event.service.majornetwork.TransientService;
|
||||
import com.njcn.minioss.config.MinIossProperties;
|
||||
import com.njcn.minioss.util.MinIoUtils;
|
||||
@@ -56,7 +56,6 @@ import java.text.DecimalFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -340,30 +339,30 @@ public class TransientServiceImpl implements TransientService {
|
||||
// 获取按终端分类的监测点索引集合
|
||||
List<String> lineList = generalDeviceDTOList.stream().flatMap(dto -> dto.getLineIndexes().stream()).collect(Collectors.toList());
|
||||
List<TerminalTree> data = deviceTreeClient.getTerminalTree().getData();
|
||||
if (!CollectionUtils.isEmpty(transientParam.getSubstationIds())) {
|
||||
List<String> collect = data.stream().map(TerminalTree::getChildren).flatMap(Collection::stream)
|
||||
.map(TerminalTree::getChildren).flatMap(Collection::stream)
|
||||
.map(TerminalTree::getChildren).flatMap(Collection::stream)
|
||||
.map(TerminalTree::getChildren).flatMap(Collection::stream)
|
||||
.filter(temp -> transientParam.getSubstationIds().contains(temp.getId()))
|
||||
.map(TerminalTree::getChildren).flatMap(Collection::stream)
|
||||
.map(TerminalTree::getChildren).flatMap(Collection::stream)
|
||||
.map(TerminalTree::getChildren).flatMap(Collection::stream)
|
||||
.map(TerminalTree::getId).collect(Collectors.toList());
|
||||
lineList.retainAll(collect);
|
||||
}
|
||||
// if (!CollectionUtils.isEmpty(transientParam.getSubstationIds())) {
|
||||
// List<String> collect = data.stream().map(TerminalTree::getChildren).flatMap(Collection::stream)
|
||||
// .map(TerminalTree::getChildren).flatMap(Collection::stream)
|
||||
// .map(TerminalTree::getChildren).flatMap(Collection::stream)
|
||||
// .map(TerminalTree::getChildren).flatMap(Collection::stream)
|
||||
// .filter(temp -> transientParam.getSubstationIds().contains(temp.getId()))
|
||||
// .map(TerminalTree::getChildren).flatMap(Collection::stream)
|
||||
// .map(TerminalTree::getChildren).flatMap(Collection::stream)
|
||||
// .map(TerminalTree::getChildren).flatMap(Collection::stream)
|
||||
// .map(TerminalTree::getId).collect(Collectors.toList());
|
||||
// lineList.retainAll(collect);
|
||||
// }
|
||||
|
||||
if (!CollectionUtils.isEmpty(transientParam.getLineIds())) {
|
||||
List<String> collect1 = data.stream().map(TerminalTree::getChildren).flatMap(Collection::stream)
|
||||
.map(TerminalTree::getChildren).flatMap(Collection::stream)
|
||||
.map(TerminalTree::getChildren).flatMap(Collection::stream)
|
||||
.map(TerminalTree::getChildren).flatMap(Collection::stream)
|
||||
.map(TerminalTree::getChildren).flatMap(Collection::stream)
|
||||
.map(TerminalTree::getChildren).flatMap(Collection::stream)
|
||||
.map(TerminalTree::getChildren).flatMap(Collection::stream)
|
||||
.filter(temp -> transientParam.getLineIds().contains(temp.getId()))
|
||||
.map(TerminalTree::getId).collect(Collectors.toList());
|
||||
lineList.retainAll(collect1);
|
||||
// List<String> collect1 = data.stream().map(TerminalTree::getChildren).flatMap(Collection::stream)
|
||||
// .map(TerminalTree::getChildren).flatMap(Collection::stream)
|
||||
// .map(TerminalTree::getChildren).flatMap(Collection::stream)
|
||||
// .map(TerminalTree::getChildren).flatMap(Collection::stream)
|
||||
// .map(TerminalTree::getChildren).flatMap(Collection::stream)
|
||||
// .map(TerminalTree::getChildren).flatMap(Collection::stream)
|
||||
// .map(TerminalTree::getChildren).flatMap(Collection::stream)
|
||||
// .filter(temp -> transientParam.getLineIds().contains(temp.getId()))
|
||||
// .map(TerminalTree::getId).collect(Collectors.toList());
|
||||
lineList.retainAll(transientParam.getLineIds());
|
||||
}
|
||||
if (CollUtil.isEmpty(lineList)) {
|
||||
return new Page<>();
|
||||
|
||||
@@ -10,7 +10,7 @@ import com.njcn.event.pojo.param.VoltageRideThroughQueryParam;
|
||||
import com.njcn.event.pojo.po.EventDetail;
|
||||
import com.njcn.event.pojo.vo.EventNewStationVo;
|
||||
import com.njcn.event.pojo.vo.VoltageRideThroughVo;
|
||||
import com.njcn.event.service.majornetwork.EventDetailService;
|
||||
import com.njcn.event.common.service.EventDetailService;
|
||||
import com.njcn.event.service.majornetwork.SpThroughService;
|
||||
import com.njcn.event.service.majornetwork.VoltageRideThroughEventService;
|
||||
import com.njcn.event.pojo.param.SpThroughParam;
|
||||
|
||||
43
pqs-event/event-common/pom.xml
Normal file
43
pqs-event/event-common/pom.xml
Normal file
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>pqs-event</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
|
||||
|
||||
<artifactId>event-common</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<name>event-common</name>
|
||||
<description>event-common</description>
|
||||
|
||||
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>event-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>advance-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
</project>
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.njcn.event.mapper.majornetwork;
|
||||
package com.njcn.event.common.mapper;
|
||||
|
||||
import com.njcn.event.pojo.po.EventDistributionStatisticsPO;
|
||||
import com.njcn.event.pojo.po.EventDurationLineChartPO;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.njcn.event.mapper.majornetwork;
|
||||
package com.njcn.event.common.mapper;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.njcn.event.common.mapper;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 暂态事件明细
|
||||
*
|
||||
* @author yzh
|
||||
* @date 2022/10/12
|
||||
*/
|
||||
@Mapper
|
||||
@DS("sjzx")
|
||||
public interface WlRmpEventDetailMapper extends BaseMapper<RmpEventDetailPO> {
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.event.mapper.majornetwork.RmpEventDetailMapper">
|
||||
<mapper namespace="com.njcn.event.common.mapper.RmpEventDetailMapper">
|
||||
|
||||
<select id="getDetailsOfTransientEvents" resultType="com.njcn.event.pojo.po.RmpEventDetailPO">
|
||||
SELECT
|
||||
@@ -0,0 +1,133 @@
|
||||
package com.njcn.event.common.pojo.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2026/1/17
|
||||
*/
|
||||
@Data
|
||||
public class LineDetailDataCommDTO {
|
||||
private String lineId;
|
||||
|
||||
@ApiModelProperty(name = "id",value = "监测点序号")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(name = "lineName",value = "监测点名称")
|
||||
private String lineName;
|
||||
|
||||
@ApiModelProperty(name = "areaName",value = "工程名称")
|
||||
private String areaName;
|
||||
|
||||
@ApiModelProperty(name = "gdName",value = "单位")
|
||||
private String gdName;
|
||||
|
||||
@ApiModelProperty(name = "bdName",value = "部门")
|
||||
private String bdName;
|
||||
|
||||
@ApiModelProperty(name = "scale",value = "电压等级")
|
||||
private String scale;
|
||||
|
||||
@ApiModelProperty(name = "manufacturer",value = "厂家")
|
||||
private String manufacturer;
|
||||
|
||||
@ApiModelProperty(name = "devId",value = "终端Id")
|
||||
private String devId;
|
||||
|
||||
@ApiModelProperty(name = "devName",value = "终端名称")
|
||||
private String devName;
|
||||
|
||||
@ApiModelProperty(name = "ip",value = "网络参数")
|
||||
private String ip;
|
||||
|
||||
@ApiModelProperty(name = "runFlag",value = "终端运行状态")
|
||||
private String runFlag;
|
||||
|
||||
@ApiModelProperty(name = "comFlag",value = "通讯状态")
|
||||
private String comFlag;
|
||||
|
||||
@ApiModelProperty(name = "loadType",value = "干扰源类型")
|
||||
private String loadType;
|
||||
|
||||
@ApiModelProperty(name = "businessType",value = "行业类型")
|
||||
private String businessType;
|
||||
|
||||
@ApiModelProperty(name = "objName",value = "监测点对象名称")
|
||||
private String objName;
|
||||
|
||||
@ApiModelProperty(name = "ptType",value = "接线方式")
|
||||
private String ptType;
|
||||
|
||||
@ApiModelProperty(name = "pt",value = "PT变比")
|
||||
private String pt;
|
||||
|
||||
@ApiModelProperty(name = "ct",value = "CT变比")
|
||||
private String ct;
|
||||
|
||||
@ApiModelProperty(name = "standardCapacity",value = "基准容量(MVA)")
|
||||
private Float standardCapacity;
|
||||
|
||||
@ApiModelProperty(name = "shortCapacity",value = "最小短路容量(MVA)")
|
||||
private Float shortCapacity;
|
||||
|
||||
@ApiModelProperty(name = "devCapacity",value = "供电设备容量(MVA)")
|
||||
private Float devCapacity;
|
||||
|
||||
@ApiModelProperty(name = "dealCapacity",value = "用户协议容量(MVA)")
|
||||
private Float dealCapacity;
|
||||
|
||||
@ApiModelProperty(name = "powerFlag",value = "电网标志(0-电网侧;1-非电网侧)")
|
||||
private Integer powerFlag;
|
||||
|
||||
/**
|
||||
* 测量间隔(1-10分钟)
|
||||
*/
|
||||
@ApiModelProperty(name = "timeInterval",value = "测量间隔(1-10分钟)")
|
||||
private Integer timeInterval;
|
||||
|
||||
/**
|
||||
* 监测点拥有者
|
||||
*/
|
||||
@ApiModelProperty(name = "owner",value = "监测点拥有者")
|
||||
private String owner;
|
||||
|
||||
/**
|
||||
* 拥有者职务
|
||||
*/
|
||||
@ApiModelProperty(name = "ownerDuty",value = "拥有者职务")
|
||||
private String ownerDuty;
|
||||
|
||||
/**
|
||||
* 拥有者联系方式
|
||||
*/
|
||||
@ApiModelProperty(name = "ownerTel",value = "拥有者联系方式")
|
||||
private String ownerTel;
|
||||
|
||||
/**
|
||||
* 接线图
|
||||
*/
|
||||
@ApiModelProperty(name = "wiringDiagram",value = "接线图")
|
||||
private String wiringDiagram;
|
||||
@ApiModelProperty(name = "ptPhaseType",value = "监测点接线相别(0,单相,1,三相,默认三相)")
|
||||
private Integer ptPhaseType;
|
||||
|
||||
@ApiModelProperty(name = "投运日期")
|
||||
private LocalDate loginTime;
|
||||
|
||||
@ApiModelProperty(name = "最新数据时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@ApiModelProperty(name = "监测对象信息ID")
|
||||
private String objId;
|
||||
|
||||
@ApiModelProperty(name = "对象类型大类")
|
||||
private String bigObjType;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.njcn.event.common.service;
|
||||
|
||||
import com.njcn.event.common.pojo.dto.LineDetailDataCommDTO;
|
||||
import com.njcn.event.pojo.param.ExportParam;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2026/1/17
|
||||
*/
|
||||
public interface CommMonitorEventReportService {
|
||||
|
||||
void getLineExport(ExportParam exportParam, LineDetailDataCommDTO lineDetailDataCommDTO, HttpServletResponse response);
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.njcn.event.service.majornetwork;
|
||||
package com.njcn.event.common.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.event.pojo.param.*;
|
||||
@@ -55,7 +55,7 @@ public interface EventAnalysisService {
|
||||
* @param statisticsParam
|
||||
* @return
|
||||
*/
|
||||
List<TimeVO> getReasonTypeTime(StatisticsParam statisticsParam) throws ParseException;
|
||||
List<TimeVO> getReasonTypeTime(StatisticsParam statisticsParam);
|
||||
|
||||
/**
|
||||
* 获取详细数据对象
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.njcn.event.service.majornetwork;
|
||||
package com.njcn.event.common.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.event.pojo.dto.EventDeatilDTO;
|
||||
@@ -41,4 +41,4 @@ public interface EventDetailService extends IService<RmpEventDetailPO> {
|
||||
List<EventDetail> getEventDetailLimit(List<String> lineIndexes, String startTime, String endTime, Integer pageSize, Integer pageNum, List<String> waveType);
|
||||
|
||||
Boolean addEventDetail(EventDeatilDTO deatilDTO);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.njcn.event.service.majornetwork;
|
||||
package com.njcn.event.common.service;
|
||||
|
||||
import com.njcn.event.pojo.param.EventMonitorReportParam;
|
||||
import com.njcn.event.pojo.vo.*;
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.njcn.event.common.service;
|
||||
|
||||
import com.njcn.event.pojo.param.StatisticsParam;
|
||||
import com.njcn.event.pojo.po.EventDetail;
|
||||
import com.njcn.event.pojo.vo.*;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <监测点报表>
|
||||
*
|
||||
* @author wr
|
||||
* @createTime: 2023-02-10
|
||||
*/
|
||||
public interface EventReportService {
|
||||
|
||||
/**
|
||||
*获取Disdip表格(监测点报表专用)
|
||||
* @param info influxdb查询结果(pqs_eventdetail表)
|
||||
* @return
|
||||
*/
|
||||
List<DISDIPVO> eventDisdip(List<EventDetail> info);
|
||||
|
||||
/**
|
||||
* 获取IEC411数据
|
||||
* @param info influxdb查询结果(pqs_eventdetail表)
|
||||
* @return
|
||||
*/
|
||||
List<IEC411VO> IEC411(List<EventDetail> info);
|
||||
|
||||
/**
|
||||
* 获取IEC28数据
|
||||
* @param info influxdb查询结果(pqs_eventdetail表)
|
||||
* @return
|
||||
*/
|
||||
List<IEC28VO> IEC28(List<EventDetail> info);
|
||||
|
||||
/**
|
||||
*暂降幅值概率分布
|
||||
* @param info2 influxdb查询结果(pqs_eventdetail表)
|
||||
* @return
|
||||
*/
|
||||
ProbabilityVO getProbabilityDistribution(List<EventDetail> info2);
|
||||
|
||||
/**
|
||||
* 获取时间列表(月份统计)
|
||||
* @param info influxdb查询结果(pqs_eventdetail表)
|
||||
* @return
|
||||
*/
|
||||
List<TimeVO> getReasonTypeTime(StatisticsParam statisticsParam,List<EventDetail> info) throws ParseException;
|
||||
|
||||
/**
|
||||
* 获取点状表格数据2.1
|
||||
* @param info 结果集
|
||||
* @param reasonData 暂降原因
|
||||
* @param typeData 暂降类型
|
||||
* @return
|
||||
*/
|
||||
List<EventDetail> getPlot(List<EventDetail> info, List<DictData> reasonData, List<DictData> typeData);
|
||||
|
||||
/**
|
||||
* 获取详细数据对象
|
||||
* @param info
|
||||
* @param reasonData
|
||||
* @param typeData
|
||||
* @return
|
||||
*/
|
||||
StatisticVO getStatistic(List<EventDetail> info,List<DictData> reasonData,List<DictData>typeData);
|
||||
|
||||
/**
|
||||
* 获取密度点图
|
||||
* @param info
|
||||
* @return
|
||||
*/
|
||||
Integer[][] getCoords(List<EventDetail> info);
|
||||
}
|
||||
@@ -0,0 +1,593 @@
|
||||
package com.njcn.event.common.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.device.pms.api.MonitorClient;
|
||||
import com.njcn.device.pq.api.LineFeignClient;
|
||||
import com.njcn.echarts.pojo.constant.PicCommonData;
|
||||
import com.njcn.echarts.util.DrawPicUtil;
|
||||
import com.njcn.event.common.mapper.RmpEventDetailMapper;
|
||||
import com.njcn.event.common.pojo.dto.LineDetailDataCommDTO;
|
||||
import com.njcn.event.common.service.EventAnalysisService;
|
||||
import com.njcn.event.common.service.EventReportService;
|
||||
import com.njcn.event.common.service.CommMonitorEventReportService;
|
||||
import com.njcn.event.common.utils.WordUtils;
|
||||
import com.njcn.event.pojo.param.ExportParam;
|
||||
import com.njcn.event.pojo.param.StatisticsParam;
|
||||
import com.njcn.event.pojo.po.EventDetail;
|
||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||
import com.njcn.event.pojo.vo.*;
|
||||
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 lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.hssf.usermodel.HSSFCell;
|
||||
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||
import org.apache.poi.util.Units;
|
||||
import org.apache.poi.xwpf.usermodel.*;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblWidth;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTblWidth;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.math.RoundingMode;
|
||||
import java.net.URLEncoder;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* pqs
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2026/1/17
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class CommMonitorEventReportServiceImpl implements CommMonitorEventReportService {
|
||||
|
||||
|
||||
private final LineFeignClient lineFeignClient;
|
||||
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
|
||||
private final EventReportService eventReportService;
|
||||
//调用暂降密度接口
|
||||
private final EventAnalysisService eventAnalysisService;
|
||||
private final MonitorClient monitorClient;
|
||||
private final RmpEventDetailMapper rmpEventDetailMapper;
|
||||
|
||||
private final DrawPicUtil drawPicUtil;
|
||||
|
||||
/**
|
||||
* 监测点导出word
|
||||
*
|
||||
* @param exportParam .
|
||||
* @param response .
|
||||
*/
|
||||
@Override
|
||||
public void getLineExport(ExportParam exportParam, LineDetailDataCommDTO lineDetailData, HttpServletResponse response) {
|
||||
//创建word文档(poi生成word)
|
||||
XWPFDocument doc = new XWPFDocument(); //创建Word文件
|
||||
//设置标题样式
|
||||
WordUtils.setHeadingStyle(doc);
|
||||
XWPFParagraph p = doc.createParagraph(); //新建一个段落
|
||||
//设置对齐
|
||||
p.setAlignment(ParagraphAlignment.CENTER);
|
||||
p.setVerticalAlignment(TextAlignment.CENTER);
|
||||
XWPFRun r = p.createRun();//创建段落文本
|
||||
r.addBreak();
|
||||
r.addBreak();
|
||||
r.addBreak();
|
||||
r.addBreak();
|
||||
r.addBreak();
|
||||
r.addBreak();
|
||||
r.setText("");
|
||||
r.setBold(true);//设置为粗体
|
||||
r.setFontSize(14);//字体大小
|
||||
r.addBreak();
|
||||
|
||||
p = doc.createParagraph(); //新建一个段落
|
||||
p.setAlignment(ParagraphAlignment.CENTER);
|
||||
XWPFRun r1 = p.createRun();//创建段落文本
|
||||
r1.setText("电压暂降事件分析报告");
|
||||
r1.setBold(true);//设置为粗体
|
||||
r1.setFontSize(36);//字体大小
|
||||
r1.addBreak();
|
||||
r1.addBreak();
|
||||
r1.addBreak();
|
||||
r1.addBreak();
|
||||
r1.addBreak();
|
||||
r1.addBreak();
|
||||
r1.addBreak();
|
||||
|
||||
p = doc.createParagraph(); //新建一个段落
|
||||
p.setAlignment(ParagraphAlignment.CENTER);
|
||||
XWPFRun r2 = p.createRun();//创建段落文本
|
||||
//获取当前时间
|
||||
Date date = new Date();
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy 年 MM 月 dd 日");
|
||||
String time = dateFormat.format(date);
|
||||
|
||||
r2.setText("日期: " + time);
|
||||
r2.setBold(true);//设置为粗体
|
||||
r2.setFontSize(14);//字体大小
|
||||
|
||||
r2.addBreak();
|
||||
r2.addBreak();
|
||||
r2.addBreak();
|
||||
|
||||
p = doc.createParagraph(); //新建一个段落
|
||||
p.setAlignment(ParagraphAlignment.CENTER);
|
||||
XWPFRun r3 = p.createRun();//创建段落文本
|
||||
r3.setText("电压暂降事件区域报告");
|
||||
r3.setFontSize(24);//字体大小
|
||||
|
||||
p = doc.createParagraph(); //新建一个段落
|
||||
p.setAlignment(ParagraphAlignment.LEFT);
|
||||
createTitle(doc, "1. 引言", "标题 1", 0, 15);
|
||||
|
||||
p = doc.createParagraph(); //新建一个段落
|
||||
p.setAlignment(ParagraphAlignment.BOTH);
|
||||
XWPFRun r5 = p.createRun();//创建段落文本
|
||||
r5.setText("对所选中区间内电压暂降事件进行分析,能够直观清晰查看响应的暂降事件信息。");
|
||||
r5.setFontSize(11);//字体大小
|
||||
|
||||
p = doc.createParagraph(); //新建一个段落
|
||||
p.setAlignment(ParagraphAlignment.LEFT);
|
||||
createTitle(doc, "2. 报告分析对象", "标题 1", 0, 15);
|
||||
|
||||
p = doc.createParagraph(); //新建一个段落
|
||||
p.setAlignment(ParagraphAlignment.BOTH);
|
||||
XWPFRun r7 = p.createRun();//创建段落文本
|
||||
r7.setText(exportParam.getLineName());
|
||||
r7.setFontSize(11);//字体大小
|
||||
|
||||
p = doc.createParagraph(); //新建一个段落
|
||||
p.setAlignment(ParagraphAlignment.LEFT);
|
||||
createTitle(doc, "3. 报告分析时间", "标题 1", 0, 15);
|
||||
|
||||
p = doc.createParagraph(); //新建一个段落
|
||||
p.setAlignment(ParagraphAlignment.BOTH);
|
||||
XWPFRun r9 = p.createRun();//创建段落文本
|
||||
r9.setText(exportParam.getSearchBeginTime() + " 至 " + exportParam.getSearchEndTime());
|
||||
r9.setFontSize(11);//字体大小
|
||||
|
||||
p = doc.createParagraph(); //新建一个段落
|
||||
p.setAlignment(ParagraphAlignment.LEFT);
|
||||
createTitle(doc, "4. 总汇信息", "标题 1", 0, 15);
|
||||
|
||||
//查询参数
|
||||
StatisticsParam param = new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(), exportParam.getFlag());
|
||||
//获取暂降原因字典
|
||||
List<DictData> reasonData = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_REASON.getName()).getData();
|
||||
//获取暂降类型字典
|
||||
List<DictData> typeData = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName()).getData();
|
||||
//influxdb查询结果(pqs_eventdetail表)
|
||||
List<EventDetail> info = info(param);
|
||||
|
||||
//记录数
|
||||
int i = 1;
|
||||
//1.监测点信息
|
||||
if (exportParam.isXq()) {
|
||||
createTitle(doc, "4." + i + " 监测点信息", "标题 2", 200, 15);
|
||||
XWPFTable table = createTable(doc);
|
||||
XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc);
|
||||
insertRow(doc, table, centerParagraph, true, "项目", "描述");
|
||||
insertRow(doc, table, centerParagraph, false, "监测点名称", lineDetailData.getLineName());
|
||||
insertRow(doc, table, centerParagraph, false, "电压等级", lineDetailData.getScale());
|
||||
insertRow(doc, table, centerParagraph, false, "PT变比", lineDetailData.getPt());
|
||||
insertRow(doc, table, centerParagraph, false, "CT变比", lineDetailData.getCt());
|
||||
insertRow(doc, table, centerParagraph, false, "协议容量", lineDetailData.getDealCapacity() + "");
|
||||
insertRow(doc, table, centerParagraph, false, "设备容量", lineDetailData.getDevCapacity() + "");
|
||||
insertRow(doc, table, centerParagraph, false, "最小短路容量", lineDetailData.getShortCapacity() + "");
|
||||
insertRow(doc, table, centerParagraph, false, "接线方式", lineDetailData.getPtType());
|
||||
if (exportParam.getType() == 0) {
|
||||
insertRow(doc, table, centerParagraph, false, "基准容量", lineDetailData.getStandardCapacity() + "");
|
||||
}
|
||||
i++;
|
||||
}
|
||||
//2.暂降事件暂降事件列表和暂降点图
|
||||
//2.1.判断列表和点图是否是要导出
|
||||
if (exportParam.isLb() || exportParam.isSjdF47() || exportParam.isSjdITIC()) {
|
||||
// List<EventDetail> plot = eventAnalysisService.getPlot(param);
|
||||
List<EventDetail> plot = eventReportService.getPlot(info, reasonData, typeData);
|
||||
//暂降事件列表
|
||||
if (exportParam.isLb()) {
|
||||
createTitle(doc, "4." + i + " 暂降事件列表", "标题 2", 200, 15);
|
||||
XWPFTable table = createTable(doc);
|
||||
XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc);
|
||||
insertRow(doc, table, centerParagraph, true, "序号", "暂降发生时刻", "暂降幅值(%)", "持续时间(s)", "暂降类型", "暂降原因", "严重度");
|
||||
for (int j = 0; j < plot.size(); j++) {
|
||||
EventDetail eventDetail = plot.get(j);
|
||||
String s = eventDetail.getStartTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
|
||||
|
||||
insertRow(doc, table, centerParagraph, false, j + 1 + "", s, BigDecimal.valueOf(eventDetail.getFeatureAmplitude() * 100).setScale(2, RoundingMode.HALF_UP).toString(), eventDetail.getDuration() + "", eventDetail.getAdvanceType(), eventDetail.getAdvanceReason(), eventDetail.getSeverity() + "");
|
||||
}
|
||||
i++;
|
||||
}
|
||||
//暂降事件点图
|
||||
if (exportParam.isSjdF47() || exportParam.isSjdITIC()) {
|
||||
ArrayList<List<Double>> ass = getAss(plot);
|
||||
createTitle(doc, "4." + i + " 暂降事件点图", "标题 2", 200, 15);
|
||||
int two = 1;
|
||||
if (exportParam.isSjdITIC()) {
|
||||
createTitle(doc, "4." + i + "." + two + " ITIC 曲线", "标题 3", 400, 15);
|
||||
String itic = drawPicUtil.drawItic(ass);
|
||||
createPic(doc, itic, "ITIC曲线");
|
||||
two++;
|
||||
}
|
||||
if (exportParam.isSjdF47()) {
|
||||
createTitle(doc, "4." + i + "." + two + " F47 曲线", "标题 3", 400, 15);
|
||||
String f47 = drawPicUtil.drawF47(ass);
|
||||
createPic(doc, f47, "SEMI F47曲线");
|
||||
two++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//3.暂降密度
|
||||
if (exportParam.isMdbg() || exportParam.isMdtx()) {
|
||||
createTitle(doc, "4." + i + " 暂降密度", "标题 2", 200, 15);
|
||||
int two = 1;
|
||||
if (exportParam.isMdtx()) {
|
||||
createTitle(doc, "4." + i + "." + two + " 暂降密度点图", "标题 3", 400, 15);
|
||||
Integer[][] eventDensityData = eventReportService.getCoords(info);
|
||||
String str = drawPicUtil.drawEventDensity(eventDensityData);
|
||||
createPic(doc, str, "暂降密度图");
|
||||
two++;
|
||||
}
|
||||
if (exportParam.isMdbg()) {
|
||||
XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc);
|
||||
createTitle(doc, "4." + i + "." + two + " DISDIP 表格:国际发配电联盟(UNIPEDE)", "标题 3", 400, 15);
|
||||
// List<DISDIPVO> eventDisdip = eventAnalysisService.eventDisdip(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag()));
|
||||
List<DISDIPVO> eventDisdip = eventReportService.eventDisdip(info);
|
||||
|
||||
XWPFTable table1 = createTable(doc);
|
||||
insertRow(doc, table1, centerParagraph, true, "剩余电压", "20ms", "100ms", "500ms", "1s", "3s", "20s", "60s", "180s");
|
||||
for (int j = 0; j < eventDisdip.size(); j++) {
|
||||
DISDIPVO disdipvo = eventDisdip.get(j);
|
||||
insertRow(doc, table1, centerParagraph, false, disdipvo.getName(), disdipvo.getTwentyMs(), disdipvo.getOneHundredMs(), disdipvo.getFiveHundredMs(), disdipvo.getOneS(), disdipvo.getThreeS(), disdipvo.getTwentyS(), disdipvo.getSixtyS(), disdipvo.getOneEightyS());
|
||||
}
|
||||
two++;
|
||||
createTitle(doc, "4." + i + "." + two + " IEC 61000-4-11:(用电终端的电压暂降抗度)", "标题 3", 400, 15);
|
||||
// List<IEC411VO> iec411VOS = eventAnalysisService.IEC411(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag()));
|
||||
List<IEC411VO> iec411VOS = eventReportService.IEC411(info);
|
||||
XWPFTable table2 = createTable(doc);
|
||||
insertRow(doc, table2, centerParagraph, true, "剩余电压", "10~20ms", "20~100ms", "0.1~0.2s", "0.2~0.5s", "0.5~1s", ">1s");
|
||||
for (int j = 0; j < iec411VOS.size(); j++) {
|
||||
IEC411VO iec411VO = iec411VOS.get(j);
|
||||
insertRow(doc, table2, centerParagraph, false, iec411VO.getName(), iec411VO.getTenTwentyMs(), iec411VO.getTwentyOneHundredMs(), iec411VO.getZeroPiontOneTwoS(), iec411VO.getZeroPiontTwoFiveS(), iec411VO.getZeroPiontFive1S(), iec411VO.getGreater1S());
|
||||
}
|
||||
two++;
|
||||
createTitle(doc, "4." + i + "." + two + " IEC 61000-2-8:(公共电网电压暂降测量统计)", "标题 3", 400, 15);
|
||||
// List<IEC28VO> iec28VOS = eventAnalysisService.IEC28(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag()));
|
||||
List<IEC28VO> iec28VOS = eventReportService.IEC28(info);
|
||||
XWPFTable table3 = createTable(doc);
|
||||
insertRow(doc, table3, centerParagraph, true, "剩余电压", "0.02~0.1s", "0.1~0.25s", "0.25~0.5s", "0.5s~1s", "1~3s", "3~20s", "20~60s", "60~180s");
|
||||
for (int j = 0; j < iec28VOS.size(); j++) {
|
||||
IEC28VO iec28VO = iec28VOS.get(j);
|
||||
insertRow(doc, table3, centerParagraph, false, iec28VO.getName(), iec28VO.getQ(), iec28VO.getW(), iec28VO.getE(), iec28VO.getR(), iec28VO.getT(), iec28VO.getY(), iec28VO.getU(), iec28VO.getI());
|
||||
}
|
||||
two++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
//4.暂降幅值概率分布
|
||||
if (exportParam.isGlfbfz() || exportParam.isGlfbsj()) {
|
||||
createTitle(doc, "4." + i + " 暂降幅值概率分布图", "标题 2", 200, 15);
|
||||
// ProbabilityVO probabilityVO = eventAnalysisService.getProbabilityDistribution(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag()));
|
||||
ProbabilityVO probabilityVO = eventReportService.getProbabilityDistribution(info);
|
||||
int two = 1;
|
||||
if (exportParam.isGlfbfz()) {
|
||||
createTitle(doc, "4." + i + "." + two + " 暂降幅值的概率分函数", "标题 3", 400, 15);
|
||||
List<String> ybardata = probabilityVO.getPereventvalue();
|
||||
List<String> ylinedata = probabilityVO.getEventvalue();
|
||||
String fz = drawPicUtil.drawEventAmplitude(ylinedata, ybardata);
|
||||
createPic(doc, fz, "暂降幅值的概率分布函数");
|
||||
two++;
|
||||
}
|
||||
if (exportParam.isGlfbsj()) {
|
||||
createTitle(doc, "4." + i + "." + two + " 持续时间的概率分函数", "标题 3", 400, 15);
|
||||
List<String> ybardata = probabilityVO.getPersisttime();
|
||||
List<String> ylinedata = probabilityVO.getSisttime();
|
||||
String sj = drawPicUtil.drawPersistentTime(ylinedata, ybardata);
|
||||
createPic(doc, sj, "持续时间的概率分布函数");
|
||||
two++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
//5.月份统计
|
||||
if (exportParam.isTjbg() || exportParam.isTjtx()) {
|
||||
createTitle(doc, "4." + i + " 月份统计", "标题 2", 200, 15);
|
||||
int two = 1;
|
||||
List<TimeVO> reasonTypeTime = eventAnalysisService.getReasonTypeTime(param);
|
||||
//暂时时间端按月查询不能查询
|
||||
// List<TimeVO> reasonTypeTime = eventReportService.getReasonTypeTime(param,null);
|
||||
if (exportParam.isTjtx()) {
|
||||
createTitle(doc, "4." + i + "." + two + " 月份统计图", "标题 3", 400, 15);
|
||||
List<Integer> count = new ArrayList<>();
|
||||
List<String> name = new ArrayList<>();
|
||||
if (exportParam.getFlag() == 0) {
|
||||
for (TimeVO timeVO : reasonTypeTime) {
|
||||
name.add(timeVO.getMonth() + "");
|
||||
count.add(Integer.parseInt(timeVO.getTimes()));
|
||||
}
|
||||
} else {
|
||||
for (TimeVO timeVO : reasonTypeTime) {
|
||||
name.add(timeVO.getDay() + "");
|
||||
count.add(Integer.parseInt(timeVO.getTimes()));
|
||||
}
|
||||
}
|
||||
String yftj = drawPicUtil.drawMonth(name, count, reasonTypeTime.get(0).getYear(), exportParam.getFlag());
|
||||
createPic(doc, yftj, "月份统计图");
|
||||
two++;
|
||||
}
|
||||
if (exportParam.isTjbg()) {
|
||||
XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc);
|
||||
createTitle(doc, "4." + i + "." + two + " 时间统计表格", "标题 3", 400, 15);
|
||||
|
||||
XWPFTable table1 = createTable(doc);
|
||||
if (exportParam.getFlag() == 0) {
|
||||
insertRow(doc, table1, centerParagraph, true, "时间(月)", "电压暂降次数");
|
||||
} else {
|
||||
insertRow(doc, table1, centerParagraph, true, "时间(天)", "电压暂降次数");
|
||||
}
|
||||
if (exportParam.getFlag() == 0) {
|
||||
for (int j = 0; j < reasonTypeTime.size(); j++) {
|
||||
TimeVO timeVO = reasonTypeTime.get(j);
|
||||
insertRow(doc, table1, centerParagraph, false, timeVO.getMonth(), timeVO.getTimes());
|
||||
}
|
||||
} else {
|
||||
for (int j = 0; j < reasonTypeTime.size(); j++) {
|
||||
TimeVO timeVO = reasonTypeTime.get(j);
|
||||
insertRow(doc, table1, centerParagraph, false,timeVO.getFulltime(), timeVO.getTimes());
|
||||
}
|
||||
}
|
||||
two++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
//6.原因统计
|
||||
//6.1整合提出查询语句
|
||||
Boolean fly = exportParam.isYybg() || exportParam.isYytx() || exportParam.isLxbg() || exportParam.isLxtx();
|
||||
if (fly) {
|
||||
List<DictData> tempDictType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_STATIS.getCode()).getData();
|
||||
List<String> typeIds = tempDictType.stream().filter(x -> DicDataEnum.VOLTAGE_DIP.getCode().equals(x.getCode()) || DicDataEnum.SHORT_INTERRUPTIONS.getCode().equals(x.getCode()))
|
||||
.map(DictData::getId).collect(Collectors.toList());
|
||||
List<EventDetail> tempInfo = info.stream().filter(temp -> typeIds.contains(temp.getEventType())).collect(Collectors.toList());
|
||||
StatisticVO statistic = eventReportService.getStatistic(tempInfo, reasonData, typeData);
|
||||
if (exportParam.isYybg() || exportParam.isYytx()) {
|
||||
createTitle(doc, "4." + i + " 原因统计", "标题 2", 200, 15);
|
||||
// StatisticVO statistic = eventAnalysisService.getStatistic(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag()));
|
||||
int two = 1;
|
||||
if (exportParam.isYytx()) {
|
||||
createTitle(doc, "4." + i + "." + two + " 原因统计图", "标题 3", 400, 15);
|
||||
List<String> xdata = new ArrayList<>();
|
||||
List<Map<String, Object>> reasonList = new ArrayList<>();
|
||||
|
||||
List<ReasonsVO> reason = statistic.getReason();
|
||||
for (ReasonsVO reasonsVO : reason) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("value", reasonsVO.getTimes());
|
||||
map.put("name", reasonsVO.getReason());
|
||||
reasonList.add(map);
|
||||
xdata.add(reasonsVO.getReason());
|
||||
}
|
||||
String tr = drawPicUtil.drawReason(xdata, reasonList);
|
||||
createPic(doc, tr, "暂降原因图");
|
||||
two++;
|
||||
}
|
||||
if (exportParam.isYybg()) {
|
||||
XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc);
|
||||
createTitle(doc, "4." + i + "." + two + " 原因统计表格", "标题 3", 400, 15);
|
||||
XWPFTable table1 = createTable(doc);
|
||||
insertRow(doc, table1, centerParagraph, true, "暂降原因", "电压暂降次数");
|
||||
List<ReasonsVO> reason = statistic.getReason();
|
||||
for (int j = 0; j < reason.size(); j++) {
|
||||
ReasonsVO reasonsVO = reason.get(j);
|
||||
insertRow(doc, table1, centerParagraph, false, reasonsVO.getReason(), reasonsVO.getTimes() + "");
|
||||
}
|
||||
two++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
//7.类型统计
|
||||
if (exportParam.isLxbg() || exportParam.isLxtx()) {
|
||||
createTitle(doc, "4." + i + " 类型统计", "标题 2", 200, 15);
|
||||
// StatisticVO statistic = eventAnalysisService.getStatistic(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag()));
|
||||
int two = 1;
|
||||
if (exportParam.isLxtx()) {
|
||||
createTitle(doc, "4." + i + "." + two + " 类型统计图", "标题 3", 400, 15);
|
||||
List<String> xdata = new ArrayList<>();
|
||||
List<TypesVO> types = statistic.getTypes();
|
||||
|
||||
List<Map<String, Object>> reasonList = new ArrayList<>();
|
||||
for (TypesVO type : types) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("value", type.getTimes());
|
||||
map.put("name", type.getType());
|
||||
reasonList.add(map);
|
||||
xdata.add(type.getType());
|
||||
}
|
||||
String tr = drawPicUtil.drawType(xdata, reasonList);
|
||||
createPic(doc, tr, "暂降类型图");
|
||||
two++;
|
||||
}
|
||||
if (exportParam.isLxbg()) {
|
||||
createTitle(doc, "4." + i + "." + two + " 类型统计表格", "标题 3", 400, 15);
|
||||
XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc);
|
||||
XWPFTable table1 = createTable(doc);
|
||||
insertRow(doc, table1, centerParagraph, true, "暂降原因", "电压暂降次数");
|
||||
List<TypesVO> types = statistic.getTypes();
|
||||
for (int j = 0; j < types.size(); j++) {
|
||||
TypesVO typesVO = types.get(j);
|
||||
insertRow(doc, table1, centerParagraph, false, typesVO.getType(), typesVO.getTimes() + "");
|
||||
}
|
||||
two++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
ServletOutputStream outputStream = response.getOutputStream();
|
||||
String fileName = URLEncoder.encode(exportParam.getLineName() + ".docx", "UTF-8");
|
||||
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
|
||||
response.setContentType("application/octet-stream;charset=UTF-8");
|
||||
doc.write(outputStream);
|
||||
outputStream.close();
|
||||
}catch (Exception e){
|
||||
throw new BusinessException(CommonResponseEnum.FAIL,"导出监测点暂降报告异常");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建标题
|
||||
*
|
||||
* @param document 文档
|
||||
* @param message 标题内容
|
||||
* @param style 标题等级
|
||||
* @param line 缩进
|
||||
* @param fontSize 字体大小
|
||||
*/
|
||||
public void createTitle(XWPFDocument document, String message, String style, int line, int fontSize) {
|
||||
XWPFParagraph summaeTableParagraph = WordUtils.getLeftParagraph(document);
|
||||
summaeTableParagraph.setStyle(style);
|
||||
summaeTableParagraph.setIndentationFirstLine(line);
|
||||
XWPFRun summaeTableRun = summaeTableParagraph.createRun();
|
||||
WordUtils.addParagraph(summaeTableRun, "宋体", fontSize, "000000", message, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 表格插入行数据
|
||||
*
|
||||
* @param document 文档
|
||||
* @param table 表格
|
||||
* @param head 是否是表头
|
||||
* @param values 数据内容
|
||||
*/
|
||||
public static void insertRow(XWPFDocument document, XWPFTable table, XWPFParagraph excelParagraph, boolean head,
|
||||
String... values) {
|
||||
if (head) {
|
||||
XWPFTableRow summaTableRowOne = table.getRow(0);
|
||||
WordUtils.setExcelHeadContent(excelParagraph, summaTableRowOne, values);
|
||||
} else {
|
||||
XWPFTableRow summaTableRowOne = table.createRow();
|
||||
WordUtils.setExcelContent(excelParagraph, summaTableRowOne, values);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建表格
|
||||
*
|
||||
* @param document
|
||||
* @return
|
||||
*/
|
||||
public XWPFTable createTable(XWPFDocument document) {
|
||||
XWPFTable summaTable = document.createTable();
|
||||
// 列宽自动分割
|
||||
CTTblWidth summaTableWidth = summaTable.getCTTbl().addNewTblPr().addNewTblW();
|
||||
summaTableWidth.setType(STTblWidth.DXA);
|
||||
summaTableWidth.setW(BigInteger.valueOf(8160));
|
||||
return summaTable;
|
||||
}
|
||||
|
||||
|
||||
public void setCellStyle(HSSFCell cellname, String value, HSSFCellStyle style) {
|
||||
cellname.setCellValue(value);
|
||||
cellname.setCellStyle(style);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param document 文档
|
||||
* @param image 图片base64
|
||||
* @param name 图片名
|
||||
* @throws IOException
|
||||
* @throws InvalidFormatException
|
||||
*/
|
||||
public void createPic(XWPFDocument document, String image, String name) {
|
||||
try {
|
||||
XWPFParagraph picParagraph = WordUtils.getCenterParagraph(document);
|
||||
XWPFRun createRun = picParagraph.createRun();
|
||||
if (image.contains(PicCommonData.PNG_PREFIX)) {
|
||||
image = image.replace(PicCommonData.PNG_PREFIX, "");
|
||||
}
|
||||
byte[] bytes = Base64.getDecoder().decode(image);
|
||||
InputStream in = new ByteArrayInputStream(bytes);
|
||||
createRun.addPicture(in, 5, name, Units.toEMU(410), Units.toEMU(170));
|
||||
}catch (Exception e){
|
||||
log.error("在word中创建图片异常:",e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 监测点暂降事件点图赋值
|
||||
*
|
||||
* @param plot
|
||||
* @return
|
||||
*/
|
||||
private ArrayList<List<Double>> getAss(List<EventDetail> plot) {
|
||||
ArrayList<List<Double>> list = new ArrayList<>();
|
||||
for (EventDetail eventDetail : plot) {
|
||||
ArrayList<Double> doubles = new ArrayList<>();
|
||||
doubles.add(eventDetail.getDuration());
|
||||
doubles.add(Double.parseDouble(String.valueOf(eventDetail.getFeatureAmplitude() * 100)));
|
||||
list.add(doubles);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* influxdb查询结果集
|
||||
*
|
||||
* @param statisticsParam
|
||||
* @return
|
||||
*/
|
||||
private List<EventDetail> info(StatisticsParam statisticsParam) {
|
||||
// //获取事件类型
|
||||
// List<DictData> dictType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_STATIS.getCode()).getData();
|
||||
// List<String> typeIds = dictType.stream().filter(x -> DicDataEnum.VOLTAGE_DIP.getCode().equals(x.getCode()) || DicDataEnum.SHORT_INTERRUPTIONS.getCode().equals(x.getCode()))
|
||||
// .map(DictData::getId).collect(Collectors.toList());
|
||||
//数据暂降查询
|
||||
List<RmpEventDetailPO> info = rmpEventDetailMapper.selectList(new LambdaQueryWrapper<RmpEventDetailPO>()
|
||||
.eq(RmpEventDetailPO::getMeasurementPointId, statisticsParam.getLineIndex())
|
||||
// .in(RmpEventDetailPO::getEventType, typeIds)
|
||||
.ge(StrUtil.isNotBlank(statisticsParam.getStartTime()), RmpEventDetailPO::getStartTime, DateUtil.beginOfDay(DateUtil.parse(statisticsParam.getStartTime())))
|
||||
.le(StrUtil.isNotBlank(statisticsParam.getEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(statisticsParam.getEndTime())))
|
||||
);
|
||||
|
||||
return BeanUtil.copyToList(info, EventDetail.class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.njcn.event.service.majornetwork.Impl;
|
||||
package com.njcn.event.common.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
@@ -13,6 +13,7 @@ import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.device.pq.api.LineFeignClient;
|
||||
import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
|
||||
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
|
||||
import com.njcn.event.common.service.EventDetailService;
|
||||
import com.njcn.event.enums.EventResponseEnum;
|
||||
import com.njcn.event.file.pojo.enums.WaveFileResponseEnum;
|
||||
import com.njcn.event.pojo.param.EventBaseParam;
|
||||
@@ -20,8 +21,7 @@ import com.njcn.event.pojo.param.StatisticsParam;
|
||||
import com.njcn.event.pojo.po.EventDetail;
|
||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||
import com.njcn.event.pojo.vo.*;
|
||||
import com.njcn.event.service.majornetwork.EventAnalysisService;
|
||||
import com.njcn.event.service.majornetwork.EventDetailService;
|
||||
import com.njcn.event.common.service.EventAnalysisService;
|
||||
import com.njcn.influx.utils.InfluxDbUtils;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
@@ -792,7 +792,7 @@ public class EventAnalysisServiceImpl implements EventAnalysisService {
|
||||
* @author xxy
|
||||
*/
|
||||
@Override
|
||||
public List<TimeVO> getReasonTypeTime(StatisticsParam statisticsParam) throws ParseException {
|
||||
public List<TimeVO> getReasonTypeTime(StatisticsParam statisticsParam) {
|
||||
//获取暂降字典信息
|
||||
List<DictData> data = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_STATIS.getCode()).getData();
|
||||
List<String> typeList = data.stream().filter(it->it.getCode().equals(DicDataEnum.VOLTAGE_DIP.getCode()) || it.getCode().equals(DicDataEnum.SHORT_INTERRUPTIONS.getCode())).map(DictData::getId).collect(Collectors.toList()); List<TimeVO> list = new ArrayList<>();
|
||||
@@ -949,21 +949,22 @@ public class EventAnalysisServiceImpl implements EventAnalysisService {
|
||||
Map<String, Integer> reasonMap = new LinkedHashMap<>();
|
||||
Map<String, Integer> typeMap = new LinkedHashMap<>();
|
||||
|
||||
|
||||
info = info.stream().filter(temp->StringUtils.isNotEmpty(temp.getAdvanceReason())||StringUtils.isNotEmpty(temp.getAdvanceType())).collect(Collectors.toList());
|
||||
//添加detail
|
||||
for (RmpEventDetailPO detail : info) {
|
||||
EventDetail details = null;
|
||||
if (typeList.contains(detail.getEventType())) {
|
||||
for (DictData data : reasonData) {
|
||||
reasonMap.put(data.getName(), 0);
|
||||
if (detail.getAdvanceReason().equals(data.getId())) {
|
||||
//此处写法会报空指针异常修改写法
|
||||
if (Objects.equals(detail.getAdvanceReason(),data.getId())) {
|
||||
details = BeanUtil.copyProperties(detail, EventDetail.class);
|
||||
details.setAdvanceReason(data.getName());
|
||||
}
|
||||
}
|
||||
for (DictData data : typeData) {
|
||||
typeMap.put(data.getName(), 0);
|
||||
if (detail.getAdvanceType().equals(data.getId())) {
|
||||
if (Objects.equals(detail.getAdvanceType(),data.getId())) {
|
||||
// details = BeanUtil.copyProperties(detail, EventDetail.class);
|
||||
details.setAdvanceType(data.getName());
|
||||
}
|
||||
@@ -974,13 +975,13 @@ public class EventAnalysisServiceImpl implements EventAnalysisService {
|
||||
|
||||
//添加reason到map
|
||||
for (EventDetail data : list) {
|
||||
if (reasonMap.get(data.getAdvanceReason()) != null) {
|
||||
if (StringUtils.isNotEmpty(data.getAdvanceReason())&&reasonMap.get(data.getAdvanceReason()) != null) {
|
||||
reasonMap.put(data.getAdvanceReason(), reasonMap.get(data.getAdvanceReason()) + 1);
|
||||
}
|
||||
}
|
||||
//添加type到map
|
||||
for (EventDetail data : list) {
|
||||
if (typeMap.get(data.getAdvanceType()) != null) {
|
||||
if (StringUtils.isNotEmpty(data.getAdvanceType())&&typeMap.get(data.getAdvanceType()) != null) {
|
||||
typeMap.put(data.getAdvanceType(), typeMap.get(data.getAdvanceType()) + 1);
|
||||
}
|
||||
}
|
||||
@@ -994,7 +995,7 @@ public class EventAnalysisServiceImpl implements EventAnalysisService {
|
||||
}
|
||||
result.setTypes(typesVOS);
|
||||
result.setReason(reasonsVOS);
|
||||
//result.setDetail(list);
|
||||
result.setDetail(list);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1327,12 +1328,12 @@ public class EventAnalysisServiceImpl implements EventAnalysisService {
|
||||
// }
|
||||
// }
|
||||
//获取电压暂降信息
|
||||
List<DictData> data = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_STATIS.getCode()).getData();
|
||||
List<String> typeList = data.stream().filter(it->it.getCode().equals(DicDataEnum.VOLTAGE_DIP.getCode()) || it.getCode().equals(DicDataEnum.SHORT_INTERRUPTIONS.getCode())).map(DictData::getId).collect(Collectors.toList());
|
||||
// List<DictData> data = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_STATIS.getCode()).getData();
|
||||
// List<String> typeList = data.stream().filter(it->it.getCode().equals(DicDataEnum.VOLTAGE_DIP.getCode()) || it.getCode().equals(DicDataEnum.SHORT_INTERRUPTIONS.getCode())).map(DictData::getId).collect(Collectors.toList());
|
||||
//查询监测点未处理暂态事件
|
||||
List<RmpEventDetailPO> eventDetails = eventDetailService.list(new LambdaQueryWrapper<RmpEventDetailPO>()
|
||||
.eq(RmpEventDetailPO::getMeasurementPointId, statisticsParam.getLineIndex())
|
||||
.in(RmpEventDetailPO::getEventType,typeList)
|
||||
// .in(RmpEventDetailPO::getEventType,typeList)
|
||||
.ge(StringUtils.isNotBlank(statisticsParam.getStartTime()), RmpEventDetailPO::getStartTime, DateUtil.beginOfDay(DateUtil.parse(statisticsParam.getStartTime())))
|
||||
.le(StringUtils.isNotBlank(statisticsParam.getEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(statisticsParam.getEndTime())))
|
||||
);
|
||||
@@ -1464,9 +1465,6 @@ public class EventAnalysisServiceImpl implements EventAnalysisService {
|
||||
waveTypeVO.setAdvanceReason(dictData.getName());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//抛出异常,当前暂态原因为空
|
||||
throw new BusinessException(EventResponseEnum.EVENT_REASON_NOT_FOUND);
|
||||
}
|
||||
|
||||
if (waveTypeVO.getAdvanceType() != null) {
|
||||
@@ -1476,9 +1474,6 @@ public class EventAnalysisServiceImpl implements EventAnalysisService {
|
||||
waveTypeVO.setAdvanceType(dictData.getName());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//抛出异常,当前暂态类型为空
|
||||
throw new BusinessException(EventResponseEnum.EVENT_TYPE_NOT_FOUND);
|
||||
}
|
||||
waveTypeVOS.add(waveTypeVO);
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
package com.njcn.event.service.majornetwork.Impl;
|
||||
package com.njcn.event.common.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@@ -10,33 +9,27 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
||||
import com.njcn.advance.api.EventCauseFeignClient;
|
||||
import com.njcn.advance.api.EventWaveAnalysisFeignClient;
|
||||
import com.njcn.advance.pojo.dto.EventAnalysisDTO;
|
||||
import com.njcn.common.pojo.constant.LogInfo;
|
||||
import com.njcn.common.pojo.dto.LogInfoDTO;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
|
||||
import com.njcn.device.biz.pojo.dto.DeptGetBase;
|
||||
import com.njcn.device.biz.pojo.param.DeptGetLineParam;
|
||||
import com.njcn.device.pq.api.DeptLineFeignClient;
|
||||
import com.njcn.device.pq.api.LineFeignClient;
|
||||
import com.njcn.device.pq.pojo.po.DeptLine;
|
||||
import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
|
||||
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
|
||||
import com.njcn.event.common.mapper.RmpEventDetailMapper;
|
||||
import com.njcn.event.pojo.vo.SendEventVO;
|
||||
import com.njcn.event.utils.EventUtil;
|
||||
import com.njcn.event.mapper.majornetwork.EventDetailMapper;
|
||||
import com.njcn.event.pojo.dto.EventDeatilDTO;
|
||||
import com.njcn.event.pojo.po.EventDetail;
|
||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||
import com.njcn.event.service.majornetwork.EventDetailService;
|
||||
import com.njcn.event.common.service.EventDetailService;
|
||||
import com.njcn.influx.utils.InfluxDbUtils;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import com.njcn.user.api.DeptFeignClient;
|
||||
import com.njcn.user.pojo.po.Dept;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.influxdb.dto.QueryResult;
|
||||
@@ -60,7 +53,7 @@ import java.util.*;
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class EventDetailServiceImpl extends ServiceImpl<EventDetailMapper, RmpEventDetailPO> implements EventDetailService {
|
||||
public class EventDetailServiceImpl extends ServiceImpl<RmpEventDetailMapper, RmpEventDetailPO> implements EventDetailService {
|
||||
|
||||
private final InfluxDbUtils influxDbUtils;
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
@@ -198,6 +191,11 @@ public class EventDetailServiceImpl extends ServiceImpl<EventDetailMapper, RmpEv
|
||||
}
|
||||
DictData advancereason = dicDataFeignClient.getDicDataByCode(reason).getData();
|
||||
DictData advanceType = dicDataFeignClient.getDicDataByCode(type).getData();
|
||||
if(Objects.equals(result.getCauseFlag(),1)&&Objects.equals(result.getTypeFlag(),1)){
|
||||
rmpEventDetailPO.setDealFlag(1);
|
||||
}else {
|
||||
rmpEventDetailPO.setDealFlag(0);
|
||||
}
|
||||
rmpEventDetailPO.setAdvanceReason(advancereason.getId());
|
||||
rmpEventDetailPO.setAdvanceType(advanceType.getId());
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.njcn.event.service.majornetwork.Impl;
|
||||
package com.njcn.event.common.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.njcn.common.pojo.constant.BizParamConstant;
|
||||
@@ -7,12 +7,12 @@ import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.device.pms.api.MonitorClient;
|
||||
import com.njcn.device.pms.pojo.dto.PmsMonitorDTO;
|
||||
import com.njcn.device.pms.pojo.param.PmsMonitorParam;
|
||||
import com.njcn.event.mapper.majornetwork.EventDistributionStatisticsMapper;
|
||||
import com.njcn.event.mapper.majornetwork.RmpEventDetailMapper;
|
||||
import com.njcn.event.common.mapper.EventDistributionStatisticsMapper;
|
||||
import com.njcn.event.common.service.EventMonitorReportService;
|
||||
import com.njcn.event.common.mapper.RmpEventDetailMapper;
|
||||
import com.njcn.event.pojo.param.EventMonitorReportParam;
|
||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||
import com.njcn.event.pojo.vo.*;
|
||||
import com.njcn.event.service.majornetwork.EventMonitorReportService;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.enums.DicDataTypeEnum;
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.njcn.event.service.majornetwork.Impl;
|
||||
package com.njcn.event.common.service.impl;
|
||||
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.njcn.event.common.service.EventReportService;
|
||||
import com.njcn.event.pojo.constant.Param;
|
||||
import com.njcn.event.pojo.param.StatisticsParam;
|
||||
import com.njcn.event.pojo.po.EventDetail;
|
||||
import com.njcn.event.pojo.po.EventDetailNew;
|
||||
import com.njcn.event.pojo.vo.*;
|
||||
import com.njcn.event.service.majornetwork.EventReportService;
|
||||
import com.njcn.influx.utils.InfluxDbUtils;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -44,7 +44,8 @@ public class EventReportServiceImpl implements EventReportService {
|
||||
}
|
||||
for (int i = 0; i < info.size(); i++) {
|
||||
Double eventvalue = info.get(i).getFeatureAmplitude();
|
||||
double persisttime = info.get(i).getDuration();
|
||||
//mysql存的S要转换成ms
|
||||
double persisttime = info.get(i).getDuration()*1000;
|
||||
if (eventvalue * 100 < 10) {
|
||||
if (persisttime < 20) {
|
||||
arr[4][0]++;
|
||||
@@ -156,7 +157,8 @@ public class EventReportServiceImpl implements EventReportService {
|
||||
}
|
||||
for (int i = 0; i < info.size(); i++) {
|
||||
Double eventvalue = info.get(i).getFeatureAmplitude();
|
||||
double persisttime = info.get(i).getDuration();
|
||||
//mysql存的S要转换成ms
|
||||
double persisttime = info.get(i).getDuration()*1000;
|
||||
if (eventvalue * 100 < 1) {
|
||||
if (persisttime < 20 && persisttime >= 10) {
|
||||
arr[2][0]++;
|
||||
@@ -218,7 +220,9 @@ public class EventReportServiceImpl implements EventReportService {
|
||||
}
|
||||
for (int i = 0; i < info.size(); i++) {
|
||||
Double eventvalue = info.get(i).getFeatureAmplitude();
|
||||
double persisttime = info.get(i).getDuration();
|
||||
//mysql存的S要转换成ms
|
||||
double persisttime = info.get(i).getDuration()*1000;
|
||||
|
||||
if (eventvalue * 100 < 1 && eventvalue * 100 >= 0) {
|
||||
if (persisttime > 10 && persisttime <= 100) {
|
||||
arr[16][0]++;
|
||||
@@ -709,7 +713,8 @@ public class EventReportServiceImpl implements EventReportService {
|
||||
timeMap.put("<180", 0);
|
||||
//求不同时间段的总数
|
||||
for (EventDetail eventDetail : info) {
|
||||
Double persistTime = eventDetail.getDuration();
|
||||
//转换成ms
|
||||
Double persistTime = eventDetail.getDuration()*1000;
|
||||
if (persistTime / 1000 < 0.1) {
|
||||
timeMap.put("<0.1", timeMap.get("<0.1") + 1);
|
||||
} else if (persistTime / 1000 > 0.1 && persistTime / 1000 < 0.25) {
|
||||
@@ -770,7 +775,7 @@ public class EventReportServiceImpl implements EventReportService {
|
||||
//求sisttime
|
||||
List<String> sisttime = new ArrayList<>();
|
||||
for (EventDetail eventDetail : info) {
|
||||
Double persistTime = eventDetail.getDuration();
|
||||
Double persistTime = eventDetail.getDuration()*1000;
|
||||
if (persistTime / 1000 < 0.1) {
|
||||
timeMap2.put("<0.1", timeMap2.get("<0.1") + 1);
|
||||
}
|
||||
@@ -878,7 +883,7 @@ public class EventReportServiceImpl implements EventReportService {
|
||||
InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
|
||||
List<EventDetailNew> eventDetailList = influxDBResultMapper.toPOJO(monitorQuery, EventDetailNew.class);
|
||||
|
||||
Map<String, List<EventDetailNew>> map = eventDetailList.stream().filter(x -> x.getEventType() == "1").collect(Collectors.groupingBy(s -> s.getStartTime().substring(0, 10)));
|
||||
Map<String, List<EventDetailNew>> map = eventDetailList.stream().filter(x -> x.getEventType() == "1").collect(Collectors.groupingBy(s ->s.getStartTime().substring(0, 10)));
|
||||
Set<String> keySet = map.keySet();
|
||||
|
||||
LocalDate parse1 = LocalDate.parse(startTime);
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.njcn.event.utils;
|
||||
package com.njcn.event.common.utils;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.math.BigInteger;
|
||||
@@ -28,7 +28,7 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.STStyleType;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTblWidth;
|
||||
|
||||
public class WordUtils {
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args)throws Exception {
|
||||
|
||||
@@ -200,7 +200,7 @@ public class WordUtils {
|
||||
paragraph.setSpacingAfter(100);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* 返回指定格式的段落 居中型
|
||||
* @param document 文档对象
|
||||
*/
|
||||
@@ -211,8 +211,8 @@ public class WordUtils {
|
||||
paragraph.setVerticalAlignment(TextAlignment.CENTER);
|
||||
return paragraph;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* 返回指定格式的段落 居左型
|
||||
* @param document 文档对象
|
||||
*/
|
||||
@@ -223,7 +223,7 @@ public class WordUtils {
|
||||
return paragraph;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 添加换行符
|
||||
@@ -13,10 +13,11 @@
|
||||
<modules>
|
||||
<module>event-api</module>
|
||||
<module>event-boot</module>
|
||||
<module>event-common</module>
|
||||
</modules>
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
<packaging>pom</packaging>
|
||||
</project>
|
||||
</project>
|
||||
|
||||
@@ -4,9 +4,6 @@ import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.alibaba.nacos.shaded.com.google.gson.JsonObject;
|
||||
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
||||
import com.njcn.common.pojo.constant.LogInfo;
|
||||
import com.njcn.common.pojo.constant.SecurityConstants;
|
||||
import com.njcn.common.pojo.dto.LogInfoDTO;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
@@ -14,6 +11,8 @@ import com.njcn.gateway.enums.GateWayEnum;
|
||||
import com.njcn.gateway.security.AuthorizationManager;
|
||||
import com.njcn.gateway.utils.ResponseUtils;
|
||||
import com.njcn.gateway.utils.WebFluxRequestUtil;
|
||||
import com.njcn.redis.pojo.enums.RedisKeyEnum;
|
||||
import com.njcn.redis.utils.RedisMessageQueueUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -39,7 +38,6 @@ import java.security.KeyFactory;
|
||||
import java.security.interfaces.RSAPublicKey;
|
||||
import java.security.spec.X509EncodedKeySpec;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
@@ -54,7 +52,16 @@ public class ResourceServerConfig {
|
||||
|
||||
private final WhiteListConfig whiteListConfig;
|
||||
|
||||
private final MqttPublisher publisher;
|
||||
/**
|
||||
* mqtt处理日志异步发布
|
||||
*/
|
||||
// private final MqttPublisher publisher;
|
||||
|
||||
/**
|
||||
* redis队列处理日志异步发布
|
||||
*/
|
||||
private final RedisMessageQueueUtil redisMessageQueueUtil;
|
||||
|
||||
|
||||
@Bean
|
||||
public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) {
|
||||
@@ -108,8 +115,12 @@ public class ResourceServerConfig {
|
||||
userIndex,
|
||||
LocalDateTime.now()
|
||||
);
|
||||
publisher.send("/userLog", PubUtils.obj2json(logInfoDTO), 2, false);
|
||||
publisher.send("/userLogPush", PubUtils.obj2json(logInfoDTO), 2, false);
|
||||
// publisher.send("/userLog", PubUtils.obj2json(logInfoDTO), 2, false);
|
||||
redisMessageQueueUtil.pushMessage(
|
||||
RedisKeyEnum.USER_LOG_QUEUE.getKey(),
|
||||
PubUtils.obj2json(logInfoDTO)
|
||||
);
|
||||
// publisher.send("/userLogPush", PubUtils.obj2json(logInfoDTO), 2, false);
|
||||
return ResponseUtils.writeErrorInfo(response, GateWayEnum.NO_AUTHORIZATION);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -48,13 +48,6 @@ public class IpUtils {
|
||||
public static String getRealIpAddress(ServerHttpRequest request) {
|
||||
HttpHeaders headers = request.getHeaders();
|
||||
String ipAddress = headers.getFirst(HEADER_X_FORWARDED_FOR);
|
||||
log.info("X-Forwarded-For:"+ipAddress);
|
||||
ipAddress = headers.getFirst("X-Real-IP");
|
||||
log.error("X-Real-IP:"+ipAddress);
|
||||
ipAddress = headers.getFirst("Proxy-Client-IP");
|
||||
log.error("Proxy-Client-IP:"+ipAddress);
|
||||
ipAddress = headers.getFirst("REMOTE-HOST");
|
||||
log.error("REMOTE-HOST:"+ipAddress);
|
||||
if (StrUtil.isBlankIfStr(ipAddress) || UNKNOWN.equalsIgnoreCase(ipAddress)) {
|
||||
ipAddress = headers.getFirst(HEADER_PROXY_CLIENT_IP);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.njcn.harmonic.pojo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class THDistortionDetailVO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@ApiModelProperty("地市")
|
||||
private String city;
|
||||
|
||||
@ApiModelProperty("供电公司")
|
||||
private String company;
|
||||
|
||||
@ApiModelProperty("变电站")
|
||||
private String subStation;
|
||||
|
||||
@ApiModelProperty("终端ID")
|
||||
private String deviceId;
|
||||
|
||||
@ApiModelProperty("终端名称")
|
||||
private String deviceName;
|
||||
|
||||
@ApiModelProperty("终端厂家")
|
||||
private String manufacturer;
|
||||
|
||||
@ApiModelProperty("终端IP")
|
||||
private String ip;
|
||||
|
||||
/**
|
||||
* 监测点名称
|
||||
*/
|
||||
@ApiModelProperty("监测点名称")
|
||||
private String lineName;
|
||||
|
||||
|
||||
/**
|
||||
* 总畸变率
|
||||
*/
|
||||
@ApiModelProperty("总畸变率")
|
||||
private Double distortion = 3.14159;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user