Compare commits
22 Commits
598fa803a1
...
2026-01
| 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 |
@@ -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";
|
||||
|
||||
|
||||
@@ -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);
|
||||
//标题
|
||||
|
||||
@@ -12,6 +12,8 @@ public interface OssPath {
|
||||
*/
|
||||
String WAVE_DIR="comtrade/";
|
||||
|
||||
String WAVE_FILE="wave/";
|
||||
|
||||
/***
|
||||
* 下载文件
|
||||
*/
|
||||
|
||||
@@ -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,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-------------------------------------------------------
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
@@ -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,7 +510,7 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
|
||||
|
||||
|
||||
private List<PqDataVerifyBak> baseDataVerifyQuery(List<String> monitorIds, MonitorBaseParam monitorBaseParam) {
|
||||
if(Objects.isNull(monitorBaseParam.getErrorTimeCount())){
|
||||
if (Objects.isNull(monitorBaseParam.getErrorTimeCount())) {
|
||||
monitorBaseParam.setErrorTimeCount(720);
|
||||
}
|
||||
LambdaQueryWrapper<PqDataVerifyBak> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
@@ -623,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:
|
||||
@@ -747,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()));
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.springframework.stereotype.Service;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
|
||||
/**
|
||||
@@ -51,11 +52,12 @@ public class AreaAnalysisServiceImpl implements AreaAnalysisService {
|
||||
private final EventDetailService eventDetailService;
|
||||
@Override
|
||||
public AreaAnalysisVO getEventReason(DeviceInfoParam.BusinessParam deviceInfoParam) {
|
||||
//根据单体系统这里只要不为录波的都统计
|
||||
//获取暂降字典信息
|
||||
DictData recordingWaveData = dicDataFeignClient.getDicDataByCode(DicDataEnum.RECORDING_WAVE.getCode()).getData();
|
||||
|
||||
if(ObjectUtil.isNull(recordingWaveData)){
|
||||
//获取暂降字典信息
|
||||
DictData voltageData = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_DIP.getCode()).getData();
|
||||
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();
|
||||
@@ -70,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)
|
||||
.ne("event_type", recordingWaveData.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())))
|
||||
|
||||
@@ -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;
|
||||
@@ -149,7 +150,7 @@ public class AreaInfoServiceImpl implements AreaInfoService {
|
||||
//监测点id
|
||||
eventDetailNew.setLineId(eventDetail.getMeasurementPointId());
|
||||
//特征幅值 需要转成百分比*100
|
||||
eventDetailNew.setFeatureAmplitude(eventDetail.getFeatureAmplitude()*100);
|
||||
eventDetailNew.setFeatureAmplitude(roundHalfUp(eventDetail.getFeatureAmplitude()*100));
|
||||
//持续时间
|
||||
eventDetailNew.setDuration(eventDetail.getDuration());
|
||||
|
||||
@@ -164,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();
|
||||
|
||||
@@ -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;
|
||||
@@ -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())))
|
||||
);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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> {
|
||||
|
||||
}
|
||||
@@ -374,7 +374,11 @@ public class CommMonitorEventReportServiceImpl implements CommMonitorEventReport
|
||||
//6.1整合提出查询语句
|
||||
Boolean fly = exportParam.isYybg() || exportParam.isYytx() || exportParam.isLxbg() || exportParam.isLxtx();
|
||||
if (fly) {
|
||||
StatisticVO statistic = eventReportService.getStatistic(info, reasonData, typeData);
|
||||
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()));
|
||||
@@ -571,14 +575,14 @@ public class CommMonitorEventReportServiceImpl implements CommMonitorEventReport
|
||||
* @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<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)
|
||||
// .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())))
|
||||
);
|
||||
|
||||
@@ -4,6 +4,7 @@ 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;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.config.GeneralInfo;
|
||||
@@ -948,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());
|
||||
}
|
||||
@@ -973,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);
|
||||
}
|
||||
}
|
||||
@@ -993,7 +995,7 @@ public class EventAnalysisServiceImpl implements EventAnalysisService {
|
||||
}
|
||||
result.setTypes(typesVOS);
|
||||
result.setReason(reasonsVOS);
|
||||
//result.setDetail(list);
|
||||
result.setDetail(list);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1326,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())))
|
||||
);
|
||||
|
||||
@@ -191,6 +191,11 @@ public class EventDetailServiceImpl extends ServiceImpl<RmpEventDetailMapper, Rm
|
||||
}
|
||||
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());
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.njcn.harmonic.pojo.param.excel;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*
|
||||
*/
|
||||
@Data
|
||||
public class ExcelParam implements Serializable {
|
||||
|
||||
@ApiModelProperty("模板分类名称")
|
||||
@NotBlank(message = "模板分类名称不可为空")
|
||||
private String modelTypeName;
|
||||
|
||||
@ApiModelProperty("模板分类类型")
|
||||
private String modelType;
|
||||
|
||||
@ApiModelProperty("排序")
|
||||
private Integer sort;
|
||||
|
||||
|
||||
@Data
|
||||
public static class ListExcelParam implements Serializable {
|
||||
|
||||
@ApiModelProperty("模板分类id")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty("模板id")
|
||||
private List<String> modelIds;
|
||||
}
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class UpdateExcelParam extends ExcelParam implements Serializable {
|
||||
|
||||
@ApiModelProperty("模板id")
|
||||
private String id;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -34,4 +34,6 @@ public class ExcelRptTemp extends BaseEntity {
|
||||
|
||||
private Integer sort;
|
||||
|
||||
private String wiringMethod;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.njcn.harmonic.pojo.po.excel;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
import java.io.Serializable;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2026-01-27
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("sys_excel")
|
||||
public class SysExcel extends BaseEntity implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 报表类型名称
|
||||
*/
|
||||
private String excelName;
|
||||
|
||||
private String excelType;
|
||||
|
||||
private Integer sort;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.njcn.harmonic.pojo.po.excel;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2026-01-27
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("sys_excel_relation")
|
||||
public class SysExcelRelation implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* sys_excel的主键id
|
||||
*/
|
||||
private String sysExcelId;
|
||||
|
||||
/**
|
||||
* sys_excel_rpt_temp的主键id
|
||||
*/
|
||||
private String sysExcelRptTempId;
|
||||
|
||||
|
||||
}
|
||||
@@ -862,10 +862,10 @@ public class OracleResultServiceImpl implements OracleResultService {
|
||||
String id = historyParam.getLineId();
|
||||
String starTime = historyParam.getStartTime();
|
||||
String endTime = historyParam.getEndTime();
|
||||
String key = "0e3bac160fd246f181ad4fd47da6929a";
|
||||
String secret = "383b4b2536234d84ac909cd605762061";
|
||||
String url = "http://8d051549520e423ab8dccf8b3d457c74.apigw.he-region-2.sgic.sgcc.com.cn/ast/ydxxcjxt/dws/get_e_mp_TGvol_zl_ds";
|
||||
String apiId = "46e61646481c0146e26ba79bb5c8fa05";
|
||||
String key = "a1a69c93c11e4910aa247087c261bec5";
|
||||
String secret = "038de3c27cc54489862d181470e3ad92";
|
||||
String url = "https://25.37.90.72/ast/ydxxcjxt/dws/get_e_mp_TGvol_zl_ds";
|
||||
String apiId = "0644f1c6abd65d3a3a81eb3314390e14";
|
||||
String apiName = "电能质量谐波监测系统_分布式光伏台区电压日数据_e_mp_TGvol_zl_时间";
|
||||
List<HarmonicHistoryV> harmonicHistory = adsDiList(HarmonicHistoryV.class, id, starTime, endTime, key, secret, url, apiId, apiName);
|
||||
return ztDataV(harmonicHistory);
|
||||
@@ -875,10 +875,10 @@ public class OracleResultServiceImpl implements OracleResultService {
|
||||
String id = historyParam.getLineId();
|
||||
String starTime = historyParam.getStartTime();
|
||||
String endTime = historyParam.getEndTime();
|
||||
String key = "0e3bac160fd246f181ad4fd47da6929a";
|
||||
String secret = "383b4b2536234d84ac909cd605762061";
|
||||
String url = "http://8d051549520e423ab8dccf8b3d457c74.apigw.he-region-2.sgic.sgcc.com.cn/ast/ydxxcjxt/dws/get_e_mp_TGpower_zl_ds";
|
||||
String apiId = "9db49fdc30dbc3bf6fa4f5cce141416c";
|
||||
String key = "a1a69c93c11e4910aa247087c261bec5";
|
||||
String secret = "038de3c27cc54489862d181470e3ad92";
|
||||
String url = "https://25.37.90.72/ast/ydxxcjxt/dws/get_e_mp_TGpower_zl_ds";
|
||||
String apiId = "f9f0eb9627410c0ad4a66ae33a75e2c9";
|
||||
String apiName = "get_电能质量谐波监测系统_分布式光伏台区功率日数据_e_mp_TGpower_zl_时间";
|
||||
List<HarmonicHistoryP> harmonicHistory = adsDiList(HarmonicHistoryP.class, id, starTime, endTime, key, secret, url, apiId, apiName);
|
||||
return ztDataP(harmonicHistory,type);
|
||||
@@ -888,10 +888,10 @@ public class OracleResultServiceImpl implements OracleResultService {
|
||||
String id = historyParam.getLineId();
|
||||
String starTime = historyParam.getStartTime();
|
||||
String endTime = historyParam.getEndTime();
|
||||
String key = "0e3bac160fd246f181ad4fd47da6929a";
|
||||
String secret = "383b4b2536234d84ac909cd605762061";
|
||||
String url = "http://8d051549520e423ab8dccf8b3d457c74.apigw.he-region-2.sgic.sgcc.com.cn/ast/ydxxcjxt/dws/get_e_mp_TGfactor_zl_ds";
|
||||
String apiId = "9c3ebd9c19dc0eb8e24385e40bd50a53";
|
||||
String key = "a1a69c93c11e4910aa247087c261bec5";
|
||||
String secret = "038de3c27cc54489862d181470e3ad92";
|
||||
String url = "https://25.37.90.72/ast/ydxxcjxt/dws/get_e_mp_TGfactor_zl_ds";
|
||||
String apiId = "bf6cc99505f93c355baad9926b61f17e";
|
||||
String apiName = "get_电能质量谐波监测系统_分布式光伏台区功率因数日数据_e_mp_TGfactor_zl_时间";
|
||||
List<HarmonicHistoryC> harmonicHistory = adsDiList(HarmonicHistoryC.class, id, starTime, endTime, key, secret, url, apiId, apiName);
|
||||
return ztDataC(harmonicHistory,type);
|
||||
|
||||
@@ -27,6 +27,7 @@ public interface ExcelRptTempMapper extends BaseMapper<ExcelRptTemp> {
|
||||
|
||||
List<ReportTemplateVO> getReportTemplateByDept(@Param("ids") List<String> ids);
|
||||
|
||||
List<ReportTemplateVO> getReportTemplateByIds(@Param("ids") List<String> ids);
|
||||
|
||||
@Select("${sqlStr}")
|
||||
StatisticalDataDTO dynamicSql(@Param("sqlStr")String sql);
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.harmonic.common.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.harmonic.pojo.po.excel.SysExcel;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2026-01-27
|
||||
*/
|
||||
public interface SysExcelMapper extends BaseMapper<SysExcel> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.harmonic.common.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.harmonic.pojo.po.excel.SysExcelRelation;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2026-01-27
|
||||
*/
|
||||
public interface SysExcelRelationMapper extends BaseMapper<SysExcelRelation> {
|
||||
|
||||
}
|
||||
@@ -8,9 +8,11 @@
|
||||
a.name,
|
||||
a.dept_id,
|
||||
b.name deptName,
|
||||
a.activation,
|
||||
a.activation,,
|
||||
a.wiring_method wiringMethod
|
||||
a.update_time,
|
||||
c.name updateBy
|
||||
c.name updateBy,
|
||||
a.sort sort
|
||||
from sys_excel_rpt_temp a
|
||||
left join sys_dept b on a.dept_id = b.id
|
||||
left join sys_user c on a.update_by = c.id
|
||||
@@ -21,6 +23,7 @@
|
||||
b.name like CONCAT('%', #{baseParam.searchValue},'%')
|
||||
)
|
||||
</if>
|
||||
order by a.sort asc
|
||||
</select>
|
||||
|
||||
<select id="getReportTemplateList" resultType="com.njcn.harmonic.common.pojo.vo.ReportTemplateVO">
|
||||
@@ -32,12 +35,15 @@
|
||||
d.NAME updateBy,
|
||||
a.Activation,
|
||||
a.Report_Type,
|
||||
a.Report_Form
|
||||
a.Report_Form,
|
||||
a.wiring_method wiringMethod,
|
||||
a.sort sort
|
||||
FROM
|
||||
sys_excel_rpt_temp a
|
||||
LEFT JOIN sys_user d ON a.update_by = d.id
|
||||
WHERE
|
||||
a.state = 1
|
||||
order by a.sort asc
|
||||
</select>
|
||||
|
||||
<select id="getReportTemplateByDept" resultType="com.njcn.harmonic.common.pojo.vo.ReportTemplateVO">
|
||||
@@ -47,7 +53,8 @@
|
||||
a.NAME,
|
||||
a.activation,
|
||||
a.report_form,
|
||||
a.sort
|
||||
a.sort,
|
||||
a.wiring_method wiringMethod
|
||||
FROM
|
||||
sys_excel_rpt_temp a
|
||||
LEFT JOIN sys_dept_temp b ON a.Id = b.temp_id
|
||||
@@ -55,4 +62,27 @@
|
||||
a.activation = 1
|
||||
order by a.sort asc
|
||||
</select>
|
||||
|
||||
<select id="getReportTemplateByIds" resultType="com.njcn.harmonic.common.pojo.vo.ReportTemplateVO">
|
||||
SELECT
|
||||
DISTINCT
|
||||
a.id,
|
||||
a.NAME,
|
||||
a.activation,
|
||||
a.report_form,
|
||||
a.sort,
|
||||
a.report_type reportType,
|
||||
a.wiring_method wiringMethod
|
||||
FROM
|
||||
sys_excel_rpt_temp a
|
||||
WHERE
|
||||
a.activation = 1 and a.state = 1
|
||||
<if test="ids!=null and ids.size()!=0">
|
||||
and a.id IN
|
||||
<foreach collection="ids" item="item" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
order by a.sort asc
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -31,4 +31,7 @@ public class ReportTemplateVO extends BaseEntity {
|
||||
|
||||
private String reportForm;
|
||||
|
||||
private String wiringMethod;
|
||||
|
||||
private Integer sort;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.njcn.harmonic.common.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Data
|
||||
public class SysExcelRelationVO implements Serializable {
|
||||
|
||||
private String sysExcelId;
|
||||
|
||||
private List<String> relationIds;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.njcn.harmonic.common.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.harmonic.common.pojo.vo.SysExcelRelationVO;
|
||||
import com.njcn.harmonic.pojo.param.excel.ExcelParam;
|
||||
import com.njcn.harmonic.pojo.po.excel.SysExcelRelation;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2026-01-27
|
||||
*/
|
||||
public interface ISysExcelRelationService extends IService<SysExcelRelation> {
|
||||
|
||||
//查询已绑定的关系
|
||||
SysExcelRelationVO getRelation(String id);
|
||||
|
||||
//重新绑定模板
|
||||
boolean bandRelation(ExcelParam.ListExcelParam param);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.njcn.harmonic.common.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.device.pq.pojo.vo.LineStateVO;
|
||||
import com.njcn.harmonic.pojo.param.excel.ExcelParam;
|
||||
import com.njcn.harmonic.pojo.po.excel.SysExcel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2026-01-27
|
||||
*/
|
||||
public interface ISysExcelService extends IService<SysExcel> {
|
||||
|
||||
//新增
|
||||
boolean addSysExcel(ExcelParam param);
|
||||
|
||||
//删除
|
||||
boolean deleteSysExcel(String id);
|
||||
|
||||
//修改
|
||||
boolean updateSysExcel(ExcelParam.UpdateExcelParam param);
|
||||
|
||||
//查询
|
||||
List<SysExcel> querySysExcel();
|
||||
|
||||
}
|
||||
@@ -19,14 +19,13 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.csdevice.api.CsCommTerminalFeignClient;
|
||||
import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
|
||||
import com.njcn.device.biz.pojo.po.PqsDeviceUnit;
|
||||
import com.njcn.harmonic.common.mapper.ExcelRptTempMapper;
|
||||
import com.njcn.harmonic.common.pojo.dto.DeviceUnitCommDTO;
|
||||
import com.njcn.harmonic.common.service.CustomReportTableService;
|
||||
import com.njcn.harmonic.enums.HarmonicResponseEnum;
|
||||
import com.njcn.harmonic.pojo.dto.ReportTemplateDTO;
|
||||
import com.njcn.harmonic.pojo.param.ReportSearchParam;
|
||||
import com.njcn.harmonic.pojo.po.ExcelRptTemp;
|
||||
import com.njcn.harmonic.common.mapper.ExcelRptTempMapper;
|
||||
import com.njcn.harmonic.common.service.CustomReportTableService;
|
||||
import com.njcn.influx.constant.InfluxDbSqlConstant;
|
||||
import com.njcn.influx.pojo.constant.InfluxDBTableConstant;
|
||||
import com.njcn.oss.enums.OssResponseEnum;
|
||||
@@ -91,6 +90,12 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
private final String STR_FOUR = "%";
|
||||
private final String UVOLTAGE_DEV = "UVOLTAGE_DEV";
|
||||
private final String VOLTAGE_DEV = "VOLTAGE_DEV";
|
||||
private static final Map<String, String> PHASE_MAPPING = new HashMap<String, String>() {{
|
||||
put("AB", "A");
|
||||
put("BC", "B");
|
||||
put("CA", "C");
|
||||
put("M", "T");
|
||||
}};
|
||||
|
||||
@Override
|
||||
public void getCustomReport(ReportSearchParam reportSearchParam,Map<String,String> newMap,DeviceUnitCommDTO deviceUnitCommDTO, HttpServletResponse response) {
|
||||
@@ -141,9 +146,20 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
throw new BusinessException(CommonResponseEnum.FAIL,"字典类型模板缺少!");
|
||||
}
|
||||
|
||||
|
||||
DictData epdDic = dicDataFeignClient.getDicDataByCodeAndType(DicDataEnum.EPD.getCode(),DicDataTypeEnum.CS_DATA_TYPE.getCode()).getData();
|
||||
List<EleEpdPqd> eleEpdPqdList= epdFeignClient.dictMarkByDataType(epdDic.getId()).getData();
|
||||
|
||||
Map<String, String> tMap = new HashMap<>();
|
||||
eleEpdPqdList.forEach(item->{
|
||||
String phase;
|
||||
if (Objects.isNull(PHASE_MAPPING.get(item.getPhase()))) {
|
||||
phase = item.getPhase();
|
||||
} else {
|
||||
phase = PHASE_MAPPING.get(item.getPhase());
|
||||
}
|
||||
tMap.put((item.getOtherName() + phase + item.getResourcesId()).toUpperCase(), item.getPrimaryFormula());
|
||||
});
|
||||
|
||||
eleEpdPqdList = eleEpdPqdList.stream().filter(it->"T".equals(it.getPhase())||"M".equals(it.getPhase())).collect(Collectors.toList());
|
||||
List<String> noPhaseList = eleEpdPqdList.stream().filter(it->StrUtil.isNotBlank(it.getOtherName())).map(it->it.getOtherName().toUpperCase()).collect(Collectors.toList());
|
||||
|
||||
@@ -173,13 +189,13 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
phaseMap.forEach((phaseKey, phaseVal) -> {
|
||||
StringBuilder sql = new StringBuilder(InfluxDbSqlConstant.SELECT);
|
||||
if (InfluxDbSqlConstant.MAX.equalsIgnoreCase(valueTypeKey)) {
|
||||
assSqlByMysql(phaseVal, sql, endList, InfluxDbSqlConstant.MAX, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
|
||||
assSqlByMysql(tMap,newMap.get("LEVEL"),newMap.get("PT"),newMap.get("CT"),phaseVal, sql, endList, InfluxDbSqlConstant.MAX, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
|
||||
} else if (InfluxDbSqlConstant.MIN.equalsIgnoreCase(valueTypeKey)) {
|
||||
assSqlByMysql(phaseVal, sql, endList, InfluxDbSqlConstant.MIN, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
|
||||
assSqlByMysql(tMap,newMap.get("LEVEL"),newMap.get("PT"),newMap.get("CT"),phaseVal, sql, endList, InfluxDbSqlConstant.MIN, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
|
||||
} else if (InfluxDbSqlConstant.AVG_WEB.equalsIgnoreCase(valueTypeKey)) {
|
||||
assSqlByMysql(phaseVal, sql, endList, InfluxDbSqlConstant.AVG_WEB, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
|
||||
assSqlByMysql(tMap,newMap.get("LEVEL"),newMap.get("PT"),newMap.get("CT"),phaseVal, sql, endList, InfluxDbSqlConstant.AVG_WEB, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
|
||||
} else if (InfluxDbSqlConstant.CP95.equalsIgnoreCase(valueTypeKey)) {
|
||||
assSqlByMysql(phaseVal, sql, endList, InfluxDbSqlConstant.CP95, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
|
||||
assSqlByMysql(tMap,newMap.get("LEVEL"),newMap.get("PT"),newMap.get("CT"),phaseVal, sql, endList, InfluxDbSqlConstant.CP95, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
|
||||
}
|
||||
|
||||
});
|
||||
@@ -453,6 +469,37 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
}
|
||||
|
||||
|
||||
public Double getData(String data) {
|
||||
double ratio = 1.0;
|
||||
String[] parts = data.split(":");
|
||||
if (parts.length == 2) {
|
||||
try {
|
||||
int num1 = Integer.parseInt(parts[0]);
|
||||
int num2 = Integer.parseInt(parts[1]);
|
||||
// 如果需要计算比值
|
||||
ratio = (double) num1 / num2;
|
||||
} catch (NumberFormatException e) {
|
||||
System.out.println("字符串格式错误");
|
||||
}
|
||||
}
|
||||
return ratio;
|
||||
}
|
||||
|
||||
public String appendData(Map<String,String> tMap,String name, double pt, double ct) {
|
||||
String result;
|
||||
String format = tMap.get(name);
|
||||
if (Objects.equals(format, "*PT")) {
|
||||
result = "*"+pt+"/1000";
|
||||
} else if (Objects.equals(format, "*CT")) {
|
||||
result = "*"+ct;
|
||||
} else if (Objects.equals(format, "*PT*CT")) {
|
||||
result = "*"+pt+"*"+ct+"/1000";
|
||||
} else {
|
||||
result = "";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param data 同类型的cell模板
|
||||
* @param sql 单个cell模板
|
||||
@@ -461,8 +508,7 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
* @param assNoPassMap 用于存储不合格的指标
|
||||
* @date 2023/10/20
|
||||
*/
|
||||
|
||||
private void assSqlByMysql(List<ReportTemplateDTO> data, StringBuilder sql, List<ReportTemplateDTO> endList, String method, ReportSearchParam reportSearchParam, Map<String, ReportTemplateDTO> limitMap, Map<String, Float> overLimitMap, Map<String, ReportTemplateDTO> assNoPassMap,List<String> noPhaseList) {
|
||||
private void assSqlByMysql(Map<String,String> tMap, String dataLevel, String pt, String ct, List<ReportTemplateDTO> data, StringBuilder sql, List<ReportTemplateDTO> endList, String method, ReportSearchParam reportSearchParam, Map<String, ReportTemplateDTO> limitMap, Map<String, Float> overLimitMap, Map<String, ReportTemplateDTO> assNoPassMap,List<String> noPhaseList) {
|
||||
//sql拼接示例:select MAX(IHA2) as IHA2 from power_quality_data where Phase = 'A' and LineId='1324564568' and Stat_Method='max' tz('Asia/Shanghai')
|
||||
if (InfluxDbSqlConstant.CP95.equals(method)) {
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
@@ -471,6 +517,7 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
.append(InfluxDbSqlConstant.LBK)
|
||||
.append(data.get(i).getTemplateName())
|
||||
.append(InfluxDbSqlConstant.RBK)
|
||||
.append(Objects.equals(dataLevel, "Secondary") ? " " + appendData(tMap, data.get(i).getTemplateName()+data.get(i).getPhase()+data.get(0).getResourceId(), getData(pt), getData(ct)) : "")
|
||||
.append(InfluxDbSqlConstant.AS)
|
||||
.append("\""+data.get(i).getItemName()+"\"");
|
||||
} else {
|
||||
@@ -478,6 +525,7 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
.append(InfluxDbSqlConstant.LBK)
|
||||
.append(data.get(i).getTemplateName())
|
||||
.append(InfluxDbSqlConstant.RBK)
|
||||
.append(Objects.equals(dataLevel, "Secondary") ? " " + appendData(tMap, data.get(i).getTemplateName()+data.get(i).getPhase()+data.get(0).getResourceId(), getData(pt), getData(ct)) : "")
|
||||
.append(InfluxDbSqlConstant.AS)
|
||||
.append("\""+data.get(i).getItemName()+"\"").append(StrUtil.COMMA);
|
||||
}
|
||||
@@ -489,6 +537,7 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
.append(InfluxDbSqlConstant.LBK)
|
||||
.append(data.get(i).getTemplateName())
|
||||
.append(InfluxDbSqlConstant.RBK)
|
||||
.append(Objects.equals(dataLevel, "Secondary") ? " " + appendData(tMap, data.get(i).getTemplateName()+data.get(i).getPhase()+data.get(0).getResourceId(), getData(pt), getData(ct)) : "")
|
||||
.append(InfluxDbSqlConstant.AS)
|
||||
.append("\""+data.get(i).getItemName()+"\"");
|
||||
} else {
|
||||
@@ -496,6 +545,7 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
.append(InfluxDbSqlConstant.LBK)
|
||||
.append(data.get(i).getTemplateName())
|
||||
.append(InfluxDbSqlConstant.RBK)
|
||||
.append(Objects.equals(dataLevel, "Secondary") ? " " + appendData(tMap, data.get(i).getTemplateName()+data.get(i).getPhase()+data.get(0).getResourceId(), getData(pt), getData(ct)) : "")
|
||||
.append(InfluxDbSqlConstant.AS)
|
||||
.append("\""+data.get(i).getItemName()+"\"").append(StrUtil.COMMA);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.njcn.harmonic.common.service.impl;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.harmonic.common.mapper.SysExcelRelationMapper;
|
||||
import com.njcn.harmonic.common.pojo.vo.SysExcelRelationVO;
|
||||
import com.njcn.harmonic.common.service.ISysExcelRelationService;
|
||||
import com.njcn.harmonic.pojo.param.excel.ExcelParam;
|
||||
import com.njcn.harmonic.pojo.po.excel.SysExcelRelation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2026-01-27
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@DS("sjzx")
|
||||
public class SysExcelRelationServiceImpl extends ServiceImpl<SysExcelRelationMapper, SysExcelRelation> implements ISysExcelRelationService {
|
||||
|
||||
@Override
|
||||
public SysExcelRelationVO getRelation(String id) {
|
||||
SysExcelRelationVO vo = new SysExcelRelationVO();
|
||||
LambdaQueryWrapper<SysExcelRelation> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysExcelRelation::getSysExcelId, id);
|
||||
List<SysExcelRelation> list = this.list(queryWrapper);
|
||||
vo.setSysExcelId(id);
|
||||
if (!list.isEmpty()) {
|
||||
vo.setRelationIds(list.stream().map(SysExcelRelation::getSysExcelRptTempId).collect(Collectors.toList()));
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean bandRelation(ExcelParam.ListExcelParam param) {
|
||||
//先删除
|
||||
LambdaQueryWrapper<SysExcelRelation> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysExcelRelation::getSysExcelId, param.getId());
|
||||
this.remove(queryWrapper);
|
||||
//再绑定
|
||||
if (!param.getModelIds().isEmpty()) {
|
||||
List<SysExcelRelation> list = param.getModelIds().stream().map(id -> {
|
||||
SysExcelRelation relation = new SysExcelRelation();
|
||||
relation.setSysExcelId(param.getId());
|
||||
relation.setSysExcelRptTempId(id);
|
||||
return relation;
|
||||
}).collect(Collectors.toList());
|
||||
this.saveBatch(list);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.njcn.harmonic.common.service.impl;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.harmonic.common.mapper.SysExcelMapper;
|
||||
import com.njcn.harmonic.common.mapper.SysExcelRelationMapper;
|
||||
import com.njcn.harmonic.common.service.ISysExcelService;
|
||||
import com.njcn.harmonic.pojo.param.excel.ExcelParam;
|
||||
import com.njcn.harmonic.pojo.po.excel.SysExcel;
|
||||
import com.njcn.harmonic.pojo.po.excel.SysExcelRelation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2026-01-27
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@DS("sjzx")
|
||||
public class SysExcelServiceImpl extends ServiceImpl<SysExcelMapper, SysExcel> implements ISysExcelService {
|
||||
|
||||
private final SysExcelRelationMapper sysExcelRelationMapper;
|
||||
|
||||
@Override
|
||||
public boolean addSysExcel(ExcelParam param) {
|
||||
LambdaQueryWrapper<SysExcel> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysExcel::getExcelName, param.getModelTypeName());
|
||||
if (this.count(queryWrapper) > 0) {
|
||||
throw new BusinessException("名称重复");
|
||||
}
|
||||
|
||||
SysExcel sysExcel = new SysExcel();
|
||||
sysExcel.setExcelName(param.getModelTypeName());
|
||||
sysExcel.setExcelType(param.getModelType());
|
||||
sysExcel.setSort(param.getSort());
|
||||
return this.save(sysExcel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteSysExcel(String id) {
|
||||
LambdaQueryWrapper<SysExcelRelation> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysExcelRelation::getSysExcelId, id);
|
||||
if (sysExcelRelationMapper.selectCount(queryWrapper) > 0) {
|
||||
throw new BusinessException("请先删除关联关系");
|
||||
}
|
||||
return this.removeById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateSysExcel(ExcelParam.UpdateExcelParam param) {
|
||||
LambdaQueryWrapper<SysExcel> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysExcel::getExcelName, param.getModelTypeName()).ne(SysExcel::getId, param.getId());
|
||||
if (this.count(queryWrapper) > 0) {
|
||||
throw new BusinessException("名称重复");
|
||||
}
|
||||
SysExcel sysExcel = new SysExcel();
|
||||
sysExcel.setId(param.getId());
|
||||
sysExcel.setExcelName(param.getModelTypeName());
|
||||
sysExcel.setExcelType(param.getModelType());
|
||||
sysExcel.setSort(param.getSort());
|
||||
return this.updateById(sysExcel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysExcel> querySysExcel() {
|
||||
return this.list().stream().sorted(Comparator.comparing(SysExcel::getSort)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.njcn.user.constant;
|
||||
|
||||
/**
|
||||
* 短信发送的一些常量,微服务添加在nacos中
|
||||
*
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2023年08月24日 18:25
|
||||
*/
|
||||
public interface SmsConstant {
|
||||
|
||||
String DEFAULT_CONNECT_TIME_OUT = "sun.net.client.defaultConnectTimeout";
|
||||
String DEFAULT_READ_TIME_OUT = "sun.net.client.defaultReadTimeout";
|
||||
//短信API产品名称(短信产品名固定,无需修改)
|
||||
String PRODUCT = "Dysmsapi";
|
||||
//短信API产品域名(接口地址固定,无需修改)
|
||||
String DOMAIN = "dysmsapi.aliyuncs.com";
|
||||
//accessKeyId
|
||||
String ACCESS_KEY_ID = "LTAI4FxsR76x2dq3w9c5puUe";
|
||||
//accessKeySecret
|
||||
String ACCESS_KEY_SECRET = "GxkTR8fsrvHtixTlD9UPmOGli35tZs";
|
||||
//短信所属地
|
||||
String LOCATION = "cn-hangzhou";
|
||||
|
||||
/**
|
||||
* 通知签名
|
||||
*/
|
||||
String SGIN = "灿能云";
|
||||
String CNWL = "灿能物联";
|
||||
String NJCNDL = "南京灿能电力";
|
||||
|
||||
/**
|
||||
* 验证码签名
|
||||
*/
|
||||
String VERIFICATION_SIGNATURE = "南京灿能电力自动化股份";
|
||||
|
||||
/**
|
||||
* 短信接口地址
|
||||
*/
|
||||
String SMS_API_URL = "https://sms.ymeeting.cn/smsv2";
|
||||
|
||||
/**
|
||||
* 短信接口内容类型
|
||||
*/
|
||||
String SMS_CONTENT_TYPE = "application/json;charset=utf-8";
|
||||
|
||||
/**
|
||||
* 接口编码方式
|
||||
*/
|
||||
String SMS_CHARSET = "UTF-8";
|
||||
|
||||
/**
|
||||
* 短信接口账号
|
||||
*/
|
||||
String SMS_ACCOUNT = "925631";
|
||||
|
||||
/**
|
||||
* 短信接口密码
|
||||
*/
|
||||
String SMS_PASSWORD = "AMW2pOVrdky";
|
||||
|
||||
/**
|
||||
* 虚拟接入码
|
||||
*/
|
||||
String SMS_ACCESS_CODE = "106905631";
|
||||
}
|
||||
@@ -14,7 +14,7 @@ public interface UserValidMessage {
|
||||
|
||||
String LOGIN_NAME_NOT_BLANK = "登录名不能为空,请检查loginName参数";
|
||||
|
||||
String LOGIN_NAME_FORMAT_ERROR = "登录名格式错误,需3-16位的英文字母或数字,请检查loginName参数";
|
||||
String LOGIN_NAME_FORMAT_ERROR = "登录名格式错误,首字符必须是字母,需3-16位的英文字母或数字,请检查loginName参数";
|
||||
|
||||
String PASSWORD_NOT_BLANK = "密码不能为空,请检查password参数";
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.njcn.user.service.impl;
|
||||
|
||||
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
|
||||
import com.aliyuncs.exceptions.ClientException;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
@@ -22,11 +21,13 @@ import com.njcn.user.pojo.po.UserSet;
|
||||
import com.njcn.user.pojo.po.app.AppInfoSet;
|
||||
import com.njcn.user.pojo.po.app.AppSendMsg;
|
||||
import com.njcn.user.service.*;
|
||||
import com.njcn.user.util.SmsApiUtil;
|
||||
import com.njcn.user.util.SmsUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -63,6 +64,8 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, User> impleme
|
||||
|
||||
private final SmsUtil smsUtil;
|
||||
|
||||
private final SmsApiUtil smsApiUtil;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String setMessage(String phone, String devCode, String type) {
|
||||
@@ -70,6 +73,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, User> impleme
|
||||
throw new BusinessException(UserResponseEnum.REGISTER_PHONE_WRONG);
|
||||
}
|
||||
SendSmsResponse sendSmsResponse = null;
|
||||
ResponseEntity<String> response = null;
|
||||
String msgTemplate = SmsUtil.getMessageTemplate(type);
|
||||
String vcode = null;
|
||||
try {
|
||||
@@ -91,27 +95,75 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, User> impleme
|
||||
}
|
||||
}
|
||||
}
|
||||
//开始执行短信发送
|
||||
vcode = getMessageCode();
|
||||
//获取短信发送结果
|
||||
sendSmsResponse = smsUtil.sendSms(phone,msgTemplate,"code",vcode);
|
||||
//开始执行短信发送
|
||||
String mobiles = phone;
|
||||
String content = SmsUtil.getLianTongMessageTemplate(type, vcode);
|
||||
response = smsApiUtil.sendBatchSms(mobiles, content);
|
||||
String key = RedisKeyEnum.SMS_LOGIN_KEY.getKey() + phone;
|
||||
if (sendSmsResponse.getCode() != null && "OK".equals(sendSmsResponse.getCode())) {
|
||||
//成功发送短信验证码后,保存进redis,验证码失效为5分钟
|
||||
redisUtil.saveByKeyWithExpire(key, vcode,300L);
|
||||
} else {
|
||||
throw new BusinessException(UserResponseEnum.SEND_CODE_FAIL);
|
||||
}
|
||||
//成功发送短信验证码后,保存进redis
|
||||
redisUtil.saveByKeyWithExpire(key, vcode, 300L);
|
||||
//短信入库
|
||||
addSendMessage(phone,vcode,msgTemplate,sendSmsResponse);
|
||||
addZdSendMessage(phone,vcode,msgTemplate,response);
|
||||
} catch (Exception e) {
|
||||
logger.error("发送短信异常,异常为:"+e.getMessage());
|
||||
//短信入库
|
||||
addSendMessage(phone,vcode,msgTemplate,sendSmsResponse);
|
||||
addZdSendMessage(phone,vcode,msgTemplate,response);
|
||||
throw new BusinessException(e.getMessage());
|
||||
}
|
||||
return sendSmsResponse.getCode();
|
||||
return "OK";
|
||||
}
|
||||
|
||||
// @Override
|
||||
// @Transactional(rollbackFor = Exception.class)
|
||||
// public String setMessage(String phone, String devCode, String type) {
|
||||
// if (!PubUtils.match(PatternRegex.PHONE_REGEX, phone)){
|
||||
// throw new BusinessException(UserResponseEnum.REGISTER_PHONE_WRONG);
|
||||
// }
|
||||
// SendSmsResponse sendSmsResponse = null;
|
||||
// String msgTemplate = SmsUtil.getMessageTemplate(type);
|
||||
// String vcode = null;
|
||||
// try {
|
||||
// //type为4,账号替换为新手机号
|
||||
// if (!msgTemplate.equalsIgnoreCase(MessageEnum.REGISTER.getTemplateCode())) {
|
||||
// User user = this.lambdaQuery().eq(User::getPhone,phone).one();
|
||||
// if ("4".equalsIgnoreCase(type)) {
|
||||
// //注册,无需判断手机号与设备的匹配
|
||||
// if (user != null) {
|
||||
// throw new BusinessException(UserResponseEnum.REGISTER_PHONE_FAIL);
|
||||
// }
|
||||
// } else {
|
||||
// if (null == user) {
|
||||
// throw new BusinessException(UserResponseEnum.LOGIN_PHONE_NOT_REGISTER);
|
||||
// } else {
|
||||
// user.setDevCode(devCode);
|
||||
// logger.info("更新手机id:" + devCode);
|
||||
// this.updateById(user);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// vcode = getMessageCode();
|
||||
// //获取短信发送结果
|
||||
// sendSmsResponse = smsUtil.sendSms(phone,msgTemplate,"code",vcode);
|
||||
// String key = RedisKeyEnum.SMS_LOGIN_KEY.getKey() + phone;
|
||||
// if (sendSmsResponse.getCode() != null && "OK".equals(sendSmsResponse.getCode())) {
|
||||
// //成功发送短信验证码后,保存进redis,验证码失效为5分钟
|
||||
// redisUtil.saveByKeyWithExpire(key, vcode,300L);
|
||||
// } else {
|
||||
// throw new BusinessException(UserResponseEnum.SEND_CODE_FAIL);
|
||||
// }
|
||||
// //短信入库
|
||||
// addSendMessage(phone,vcode,msgTemplate,sendSmsResponse);
|
||||
// } catch (Exception e) {
|
||||
// logger.error("发送短信异常,异常为:"+e.getMessage());
|
||||
// //短信入库
|
||||
// addSendMessage(phone,vcode,msgTemplate,sendSmsResponse);
|
||||
// throw new BusinessException(e.getMessage());
|
||||
// }
|
||||
// return sendSmsResponse.getCode();
|
||||
// }
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public void register(String phone, String code, String devCode) {
|
||||
@@ -123,7 +175,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, User> impleme
|
||||
}
|
||||
judgeCode(phone, code);
|
||||
String password = null;
|
||||
SendSmsResponse sendSmsResponse = null;
|
||||
ResponseEntity<String> response = null;
|
||||
//先根据手机号查询是否已被注册
|
||||
User user = this.lambdaQuery().eq(User::getPhone,phone).ne(User::getState,0).one();
|
||||
if (!Objects.isNull(user)){
|
||||
@@ -147,25 +199,75 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, User> impleme
|
||||
appInfoSet.setExFactoryBug(0);
|
||||
appInfoSetService.save(appInfoSet);
|
||||
//发送用户初始密码
|
||||
try {
|
||||
password = redisUtil.getStringByKey(newUser.getId());
|
||||
sendSmsResponse = smsUtil.sendSms(phone,MessageEnum.getTemplateByCode(3),"pwd",password);
|
||||
if (sendSmsResponse.getCode() != null && "OK".equals(sendSmsResponse.getCode())) {
|
||||
//成功发送短信验证码后,删除用户密码信息
|
||||
redisUtil.delete(newUser.getId());
|
||||
} else {
|
||||
throw new BusinessException(UserResponseEnum.SEND_CODE_FAIL);
|
||||
}
|
||||
addSendMessage(phone,password,MessageEnum.getTemplateByCode(3),sendSmsResponse);
|
||||
} catch (ClientException e) {
|
||||
logger.error("发送短信异常,异常为:"+e.getMessage());
|
||||
addSendMessage(phone,password,MessageEnum.getTemplateByCode(3),sendSmsResponse);
|
||||
password = redisUtil.getStringByKey(newUser.getId());
|
||||
String content = SmsUtil.getLianTongMessageTemplate("3", password);
|
||||
response = smsApiUtil.sendBatchSms(phone, content);
|
||||
if (response != null && response.getStatusCodeValue() == 200) {
|
||||
//成功发送短信验证码后,删除用户密码信息
|
||||
redisUtil.delete(newUser.getId());
|
||||
} else {
|
||||
throw new BusinessException(UserResponseEnum.SEND_CODE_FAIL);
|
||||
}
|
||||
addZdSendMessage(phone,password,MessageEnum.getTemplateByCode(3),response);
|
||||
//删除验证码
|
||||
deleteCode(phone);
|
||||
}
|
||||
}
|
||||
|
||||
// @Override
|
||||
// @Transactional(rollbackFor = {Exception.class})
|
||||
// public void register(String phone, String code, String devCode) {
|
||||
// if (!PubUtils.match(PatternRegex.PHONE_REGEX, phone)){
|
||||
// throw new BusinessException(UserResponseEnum.REGISTER_PHONE_WRONG);
|
||||
// }
|
||||
// if (StringUtils.isBlank(devCode)) {
|
||||
// throw new BusinessException(UserResponseEnum.DEV_CODE_WRONG);
|
||||
// }
|
||||
// judgeCode(phone, code);
|
||||
// String password = null;
|
||||
// SendSmsResponse sendSmsResponse = null;
|
||||
// //先根据手机号查询是否已被注册
|
||||
// User user = this.lambdaQuery().eq(User::getPhone,phone).ne(User::getState,0).one();
|
||||
// if (!Objects.isNull(user)){
|
||||
// throw new BusinessException(UserResponseEnum.REGISTER_PHONE_REPEAT);
|
||||
// } else {
|
||||
// //新增用户配置表
|
||||
// UserSet userSet = userSetService.addAppUserSet();
|
||||
// //新增用户表
|
||||
// User newUser = cloneUserBoToUser(phone,devCode,userSet);
|
||||
// //新增用户角色关系表
|
||||
// Role role = roleService.getRoleByCode(AppRoleEnum.TOURIST.getCode());
|
||||
// userRoleService.addUserRole(newUser.getId(), Collections.singletonList(role.getId()));
|
||||
// //消息默认配置
|
||||
// AppInfoSet appInfoSet = new AppInfoSet();
|
||||
// appInfoSet.setUserId(newUser.getId());
|
||||
// appInfoSet.setHarmonicInfo(1);
|
||||
// appInfoSet.setEventInfo(1);
|
||||
// appInfoSet.setRunInfo(1);
|
||||
// appInfoSet.setAlarmInfo(1);
|
||||
// appInfoSet.setFunctionBug(0);
|
||||
// appInfoSet.setExFactoryBug(0);
|
||||
// appInfoSetService.save(appInfoSet);
|
||||
// //发送用户初始密码
|
||||
// try {
|
||||
// password = redisUtil.getStringByKey(newUser.getId());
|
||||
// sendSmsResponse = smsUtil.sendSms(phone,MessageEnum.getTemplateByCode(3),"pwd",password);
|
||||
// if (sendSmsResponse.getCode() != null && "OK".equals(sendSmsResponse.getCode())) {
|
||||
// //成功发送短信验证码后,删除用户密码信息
|
||||
// redisUtil.delete(newUser.getId());
|
||||
// } else {
|
||||
// throw new BusinessException(UserResponseEnum.SEND_CODE_FAIL);
|
||||
// }
|
||||
// addSendMessage(phone,password,MessageEnum.getTemplateByCode(3),sendSmsResponse);
|
||||
// } catch (ClientException e) {
|
||||
// logger.error("发送短信异常,异常为:"+e.getMessage());
|
||||
// addSendMessage(phone,password,MessageEnum.getTemplateByCode(3),sendSmsResponse);
|
||||
// }
|
||||
// //删除验证码
|
||||
// deleteCode(phone);
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void modifyPsd(String userId, String phone, String code, String password, String devCode) {
|
||||
if (!PubUtils.match(PatternRegex.PHONE_REGEX, phone)){
|
||||
@@ -346,4 +448,22 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, User> impleme
|
||||
appSendMsgService.save(appSendMsg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 中国电信验证码入库
|
||||
*/
|
||||
public void addZdSendMessage(String phone, String vcode, String template, ResponseEntity<String> response) {
|
||||
AppSendMsg appSendMsg = new AppSendMsg();
|
||||
appSendMsg.setPhone(phone);
|
||||
appSendMsg.setMessage(vcode);
|
||||
appSendMsg.setSendTime(LocalDateTime.now());
|
||||
if (Objects.isNull(response)){
|
||||
appSendMsg.setSendStatus("无状态");
|
||||
appSendMsg.setRemark(null);
|
||||
} else {
|
||||
appSendMsg.setSendStatus(String.valueOf(response.getStatusCodeValue()));
|
||||
}
|
||||
appSendMsg.setTemplate(template);
|
||||
appSendMsgService.save(appSendMsg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
package com.njcn.user.util;
|
||||
|
||||
import com.njcn.user.constant.SmsConstant;
|
||||
import com.njcn.web.utils.RestTemplateUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 短信接口管理静态工具类
|
||||
* 统一管理各种短信接口操作
|
||||
*
|
||||
* @date 2025-08-25
|
||||
*/
|
||||
@Component
|
||||
public class SmsApiUtil {
|
||||
|
||||
@Resource
|
||||
private RestTemplateUtil restTemplateUtil;
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(SmsApiUtil.class);
|
||||
|
||||
|
||||
/**
|
||||
* 群发短信接口
|
||||
*
|
||||
* @param mobiles 手机号列表,多个手机号用逗号分隔
|
||||
* @param content 短信内容
|
||||
* @return 发送结果
|
||||
*/
|
||||
public ResponseEntity<String> sendBatchSms(String mobiles, String content) {
|
||||
return sendBatchSms(SmsConstant.SMS_ACCOUNT, SmsConstant.SMS_PASSWORD, mobiles, content);
|
||||
}
|
||||
|
||||
/**
|
||||
* 群发短信接口
|
||||
*
|
||||
* @param account 账号
|
||||
* @param password 密码
|
||||
* @param mobiles 手机号列表,多个手机号用逗号分隔
|
||||
* @param content 短信内容
|
||||
* @return 发送结果
|
||||
*/
|
||||
public ResponseEntity<String> sendBatchSms(String account, String password, String mobiles, String content) {
|
||||
try {
|
||||
String[] mobileArray = mobiles.split(",");
|
||||
log.info("开始群发短信,手机号数量: {}, 扩展号码: {}", mobileArray.length, SmsConstant.SMS_ACCESS_CODE);
|
||||
|
||||
// 构建请求参数
|
||||
Map<String, Object> request = new HashMap<>();
|
||||
request.put("action", "send");
|
||||
request.put("account", account);
|
||||
request.put("password", password);
|
||||
request.put("mobile", mobiles);
|
||||
request.put("content", content);
|
||||
request.put("extno", SmsConstant.SMS_ACCESS_CODE);
|
||||
|
||||
// 设置请求头
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Content-Type", SmsConstant.SMS_CONTENT_TYPE);
|
||||
|
||||
// 发送请求
|
||||
ResponseEntity<String> response = restTemplateUtil.post(
|
||||
SmsConstant.SMS_API_URL,
|
||||
request,
|
||||
headers,
|
||||
String.class
|
||||
);
|
||||
|
||||
log.info("群发短信完成,响应状态: {}, 响应内容: {}",
|
||||
response.getStatusCode(), response.getBody());
|
||||
|
||||
return response;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("群发短信失败: {}", e.getMessage(), e);
|
||||
throw new RuntimeException("群发短信失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 消息状态报告查询接口
|
||||
*
|
||||
* @param size 查询数量,建议不超过1000
|
||||
* @return 状态报告查询结果
|
||||
*/
|
||||
public ResponseEntity<String> messageReport(Integer size) {
|
||||
return messageReport(SmsConstant.SMS_ACCOUNT, SmsConstant.SMS_PASSWORD, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* 消息状态报告查询接口
|
||||
*
|
||||
* @param account 账号
|
||||
* @param password 密码
|
||||
* @param size 查询数量,建议不超过1000
|
||||
* @return 状态报告查询结果
|
||||
*/
|
||||
public ResponseEntity<String> messageReport(String account, String password, Integer size) {
|
||||
try {
|
||||
log.info("开始查询消息状态报告,查询数量: {}", size);
|
||||
|
||||
// 构建请求参数
|
||||
Map<String, Object> request = new HashMap<>();
|
||||
request.put("action", "report");
|
||||
request.put("account", account);
|
||||
request.put("password", password);
|
||||
request.put("size", size != null ? size : 1000);
|
||||
|
||||
// 设置请求头
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Content-Type", SmsConstant.SMS_CONTENT_TYPE);
|
||||
|
||||
// 发送请求
|
||||
ResponseEntity<String> response = restTemplateUtil.post(
|
||||
SmsConstant.SMS_API_URL,
|
||||
request,
|
||||
headers,
|
||||
String.class
|
||||
);
|
||||
|
||||
log.info("消息状态报告查询完成,响应状态: {}, 响应内容: {}",
|
||||
response.getStatusCode(), response.getBody());
|
||||
|
||||
return response;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("消息状态报告查询失败: {}", e.getMessage(), e);
|
||||
throw new RuntimeException("消息状态报告查询失败", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import com.aliyuncs.profile.DefaultProfile;
|
||||
import com.aliyuncs.profile.IClientProfile;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.user.config.Message;
|
||||
import com.njcn.user.constant.SmsConstant;
|
||||
import com.njcn.user.enums.MessageEnum;
|
||||
import com.njcn.user.enums.UserResponseEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -92,6 +93,37 @@ public class SmsUtil {
|
||||
return msgTemplate;
|
||||
}
|
||||
|
||||
//验证码类型(0:登录 1:注册 2:修改密码 4:换绑新手机 5.老手机校验 6:忘记密码)
|
||||
public static String getLianTongMessageTemplate(String type, String vcode) {
|
||||
String msgTemplate = null;
|
||||
switch (type) {
|
||||
case "0":
|
||||
msgTemplate = "【" + SmsConstant.NJCNDL + "】" + "验证码为:" + vcode + ",您正在登录,若非本人操作,请勿泄露!";
|
||||
break;
|
||||
case "1":
|
||||
msgTemplate = "【" + SmsConstant.NJCNDL + "】" + "验证码为:" + vcode + ",您正在注册成为平台会员,感谢您的支持!";
|
||||
break;
|
||||
case "2":
|
||||
case "6":
|
||||
msgTemplate = "【" + SmsConstant.NJCNDL + "】" + "验证码为:" + vcode + ",您正在修改密码,如非本人操作,请忽略本短信!";
|
||||
break;
|
||||
case "3":
|
||||
msgTemplate = "【" + SmsConstant.NJCNDL + "】" + "恭喜您注册成功,您的初始密码为:"+vcode+",请及时修改为常用密码,避免遗忘,感谢您的支持!";
|
||||
break;
|
||||
case "7":
|
||||
case "8":
|
||||
msgTemplate = "【" + SmsConstant.NJCNDL + "】" + "验证码为:" + vcode + ",您正在进行敏感操作,如非本人操作,请忽略本短信!";
|
||||
break;
|
||||
case "4":
|
||||
case "5":
|
||||
msgTemplate = "【" + SmsConstant.NJCNDL + "】" + "验证码为:" + vcode + ",您正在尝试重新绑定手机号,请妥善保管账户信息!";
|
||||
break;
|
||||
default:
|
||||
throw new BusinessException(UserResponseEnum.CODE_TYPE_ERROR);
|
||||
}
|
||||
return msgTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
* @param phone 手机号
|
||||
|
||||
Reference in New Issue
Block a user