39 Commits

Author SHA1 Message Date
wr
94037d588b 暂态事件报告功能下载 2026-02-28 15:30:35 +08:00
01a77fa92d 1.暂降事件报告 2026-02-27 09:40:12 +08:00
9d9150e418 Merge remote-tracking branch 'origin/main' 2026-02-27 09:35:44 +08:00
ee1ca85a5d 1.暂降事件报告 2026-02-27 09:35:38 +08:00
wr
2c3c716607 河北算法调整 2026-02-26 15:41:16 +08:00
wr
e1d17c63a2 微调 2026-02-26 08:38:03 +08:00
hzj
6234ac8ce9 系统配置合并 2026-02-11 14:34:33 +08:00
6c91774200 1.报告模板bug 2026-02-11 13:31:06 +08:00
fc951e913c 1.微调 2026-02-10 16:32:34 +08:00
d138d4353f 1.用户对象管理业务迁移 2026-02-10 14:48:04 +08:00
aecee4de49 1.用户对象管理业务迁移 2026-02-10 14:36:12 +08:00
hzj
fd04c21997 修改驾驶舱bug 2026-02-10 09:22:04 +08:00
08d8b5b488 Merge remote-tracking branch 'origin/main' 2026-02-09 16:14:05 +08:00
82457bc9c2 1.解决修改台账bug 2026-02-09 16:13:53 +08:00
hzj
63330a04a6 电能质量污区图bug 2026-02-09 16:11:14 +08:00
hzj
ad45661c3c 稳态合格率报告bug 2026-02-09 14:47:27 +08:00
wr
23de6313a6 Merge remote-tracking branch 'origin/main' 2026-02-06 15:09:30 +08:00
wr
7a5ef040bb 冀北数据周报 2026-02-06 15:09:17 +08:00
xy
140ed85108 报表优化 2026-02-06 09:57:15 +08:00
hzj
99ab77dcf0 暂降原因暂降类型那边没兼容大小写后缀 2026-02-03 13:42:28 +08:00
hzj
c772c9cd81 修改定版bug 2026-02-02 16:36:30 +08:00
cdf
996ec87ea8 适配达梦 2026-02-01 13:53:43 +08:00
hzj
b6eaff3b1e 修改定版bug 2026-01-30 14:58:15 +08:00
hzj
56bf5bb7c9 修改bug 2026-01-30 10:17:13 +08:00
wr
7410d32241 Merge remote-tracking branch 'origin/main' 2026-01-29 14:15:18 +08:00
wr
41ba37b723 河北数据中台业务参数调整 2026-01-29 10:30:13 +08:00
wr
3f77d30cfd 1.监测点异常统计报表调整 2026-01-28 11:26:52 +08:00
cdf
f71f87ced4 一键分配装置前置进程 2026-01-28 10:39:18 +08:00
xy
32295f60c0 报表添加接线方式、一二次值判断 2026-01-28 08:43:04 +08:00
hzj
d2945b0fb2 bug修改 2026-01-27 15:33:15 +08:00
hzj
133766a2c7 bug修改 2026-01-27 13:47:35 +08:00
xy
2a5a5087ad 微调 2026-01-26 19:30:33 +08:00
xy
4edb27d20b Merge remote-tracking branch 'origin/main' 2026-01-26 19:28:47 +08:00
xy
71d6636be0 物联短信发送调整 2026-01-26 19:28:37 +08:00
hzj
8ccdb84ea9 Merge remote-tracking branch 'origin/main' 2026-01-26 15:04:32 +08:00
hzj
5389903ed7 暂态模块bug修改 2026-01-26 15:02:25 +08:00
wr
0684bdf503 Merge remote-tracking branch 'origin/main' 2026-01-26 15:00:34 +08:00
wr
d0b4a1ec71 1.监测点异常统计报表 2026-01-23 10:19:55 +08:00
cdf
764ca4a12a 暂降模块调整 2026-01-22 21:54:52 +08:00
104 changed files with 5645 additions and 2061 deletions

View File

@@ -47,7 +47,7 @@ import java.util.List;
* angle_diff_cn C相相位负跳变
* bph_max_value 不平衡度(单位%
*/
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonIgnoreProperties(ignoreUnknown = true,value = {"pointer"})
public class BackData extends Structure {
public int qvvr_cata_cause[] = new int[256];
public int qvvr_phasetype[] = new int[256];

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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();

View File

@@ -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文件缺失,请联系管理员");
}
}
//读取

View File

@@ -88,7 +88,7 @@ public class BpmSignParam extends BaseEntity implements Serializable {
private String name;
@ApiModelProperty("标识key")
private String key;
private String signKey;
}

View File

@@ -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())) {

View File

@@ -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");

View File

@@ -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";

View File

@@ -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);
//标题

View File

@@ -12,6 +12,8 @@ public interface OssPath {
*/
String WAVE_DIR="comtrade/";
String WAVE_FILE="wave/";
/***
* 下载文件
*/

View File

@@ -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参数";

View File

@@ -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-------------------------------------------------------
/**

View File

@@ -0,0 +1,16 @@
package com.njcn.device.biz.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.device.biz.pojo.po.PqSensitiveUser;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xy
* @since 2025-11-17
*/
public interface PqSensitiveUserMapper extends BaseMapper<PqSensitiveUser> {
}

View File

@@ -0,0 +1,62 @@
package com.njcn.device.biz.pojo.po;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.njcn.db.bo.BaseEntity;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import static com.baomidou.mybatisplus.annotation.IdType.ASSIGN_ID;
/**
* @Author: cdf
* @CreateTime: 2026-02-10
* @Description:
*/
@Getter
@Setter
@TableName("pq_sensitive_user")
public class PqSensitiveUser extends BaseEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
@TableId(value = "id",type = ASSIGN_ID)
private String id;
/**
* 敏感用户名称
*/
private String name;
/**
* 敏感负荷类型
*/
private String loadType;
/**
* 用户协议容量
*/
private Double userAgreementCapacity;
/**
* 装机容量
*/
private Double installedCapacity;
/**
* 所属厂站名称
*/
private String substationName;
/**
* 排序
*/
private Integer sort;
}

View File

@@ -0,0 +1,76 @@
package com.njcn.device.pq.pojo.param;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* @Author: cdf
* @CreateTime: 2025-12-02
* @Description:
*/
@Data
public class PqSensitiveUserParam {
/**
* 敏感用户名称
*/
@NotBlank(message = "用户名称不可为空")
@ApiModelProperty(name = "name",value = "用户名称不可为空")
private String name;
/**
* 敏感负荷类型
*/
@NotBlank(message = "敏感负荷类型不可为空")
@ApiModelProperty(name = "loadType",value = "敏感负荷类型")
private String loadType;
/**
* 用户协议容量
*/
@Range(min = 0,max = 10000000 )
@ApiModelProperty(name = "userAgreementCapacity",value = "用户协议容量")
private Double userAgreementCapacity;
/**
* 装机容量
*/
@Range(min = 0,max = 10000000 )
@ApiModelProperty(name = "installedCapacity",value = "装机容量")
private Double installedCapacity;
/**
* 所属厂站名称
*/
@NotBlank(message = "所属厂站名称不可为空")
@ApiModelProperty(name = "substationName",value = "所属厂站名称")
private String substationName;
/**
* 排序
*/
@NotNull(message = "排序不可为空")
@ApiModelProperty(name = "sort",value = "排序")
private Integer sort;
@Data
@EqualsAndHashCode(callSuper = true)
public static class UpdatePqSensitiveUserParam extends PqSensitiveUserParam{
/**
* id
*/
@NotBlank(message = "id不可为空")
@ApiModelProperty(name = "id",value = "id")
private String id;
}
}

View File

@@ -63,6 +63,9 @@ public class AreaLineInfoVO implements Serializable {
@ApiModelProperty(name = "pt2",value = "pt2")
private Integer pt2;
@ApiModelProperty(name = "ptType",value = "接线类型(0:星型接法;1:三角型接法;2:开口三角型接法)")
private Integer ptType;
@ApiModelProperty(name = "objName",value = "对象名称")
private String objName;
@@ -136,6 +139,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;

View File

@@ -0,0 +1,52 @@
package com.njcn.device.pq.pojo.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author wr
* @description
* @date 2026/2/2 15:16
*/
@Data
public class LineInfoMonitorIdVO {
@ApiModelProperty(name = "lineId",value = "监测点id")
private String lineId;
@ApiModelProperty(name = "gdName",value = "供电公司名称")
private String gdName;
@ApiModelProperty(name = "lineName",value = "监测点名称")
private String lineName;
@ApiModelProperty(name = "loadType",value = "干扰源类型")
private String loadType;
@ApiModelProperty(name = "objName",value = "对象名称")
private String objName;
@ApiModelProperty(name = "subName",value = "变电站名称")
private String subName;
@ApiModelProperty(name = "powerSubstationName", value = "电网侧变电站")
private String powerSubstationName;
@ApiModelProperty(name = "deviceId",value = "装置Id")
private String deviceId;
@ApiModelProperty(name = "deviceName",value = "装置名称")
private String deviceName;
@ApiModelProperty(name = "ip",value = "装置ip")
private String ip;
@ApiModelProperty(name = "manufacturer",value = "供应商名称")
private String manufacturer;
@ApiModelProperty(name = "monitorId",value = "国网ID")
private String monitorId;
@ApiModelProperty(name = "powerFlag",value = "电网标志0-电网侧1-非电网侧)")
private Integer powerFlag;
}

View File

@@ -0,0 +1,64 @@
package com.njcn.device.pq.pojo.vo;
import lombok.Data;
import java.io.Serializable;
/**
* <p>
*
* </p>
*
* @author xy
* @since 2025-11-17
*/
@Data
public class PqSensitiveUserVo implements Serializable{
private static final long serialVersionUID = 1L;
/**
* id
*/
private String id;
/**
* 敏感用户名称
*/
private String name;
/**
* 敏感负荷类型
*/
private String loadType;
/**
* 排序
*/
private Integer sort;
/**
* 是否监测
*/
private String isMonitor;
/**
* 是否治理
*/
private String isGovern;
/**
* 用户协议容量
*/
private Double userAgreementCapacity;
/**
* 装机容量
*/
private Double installedCapacity;
/**
* 所属厂站名称
*/
private String substationName;
}

View File

@@ -0,0 +1,44 @@
package com.njcn.device.pq.pojo.vo.dataClean;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
/**
* @version 1.0.0
* @author: chenchao
* @date: 2022/07/18 11:04
*/
@Getter
@Setter
@EqualsAndHashCode
public class CityDataExcel implements Serializable {
@ExcelProperty(value = "单位")
private String deptName;
@ExcelProperty(value = "监测终端数量")
private BigDecimal deviceNum;
@ExcelProperty(value = "监测点个数")
private BigDecimal lineNum;
@ExcelProperty(value = "在线率(%")
private BigDecimal onlineRate;
@ExcelProperty(value = "完整率(%")
private BigDecimal integrity;
@ExcelProperty(value = "问题监测点")
private BigDecimal abnormalNum;
@ExcelProperty(value = "问题监测点")
private List<String> abnormalList;
}

View File

@@ -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", "电压暂升");
}
}

View File

@@ -0,0 +1,54 @@
package com.njcn.device.pq.pojo.vo.dataClean;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @version 1.0.0
* @author: chenchao
* @date: 2022/07/18 11:04
*/
@Getter
@Setter
@EqualsAndHashCode
public class LineDataExcel implements Serializable {
@ExcelProperty(value = "序号")
private BigDecimal lineNum;
@ExcelProperty(value = "监测点名称")
private String lineName;
@ExcelProperty(value = "所属部门")
private String deptName;
@ExcelProperty(value = "接入电网侧变电站名")
private String powerSubstationName;
@ExcelProperty(value = "监测点对象名称")
private String objName;
@ExcelProperty(value = "装置编号")
private String deviceName;
@ExcelProperty(value = "IP地址")
private String ip;
@ExcelProperty(value = "终端厂家")
private String manufacturer;
@ExcelProperty(value = "在线率")
private BigDecimal onlineRate;
@ExcelProperty(value = "数据完整性")
private BigDecimal integrity;
@ExcelProperty(value = "国网ID")
private BigDecimal monitorId;
}

View File

@@ -0,0 +1,107 @@
package com.njcn.device.pq.utils;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjUtil;
import com.alibaba.nacos.shaded.com.google.common.collect.Lists;
import com.njcn.device.pq.pojo.vo.dataClean.CityDataExcel;
import com.njcn.device.pq.pojo.vo.dataClean.LineDataExcel;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* @author wr
* @description
* @date 2026/2/2 10:13
*/
public class DataLineExcelUtil {
/**
* 创建监测点信息表头
* @param FlyMonitorId
* @return
*/
public static List<List<String>> lineHeader(Boolean FlyMonitorId) {
List<List<String>> header = new ArrayList<>();
header.add(Collections.singletonList("序号"));
header.add(Collections.singletonList("监测点名称"));
header.add(Collections.singletonList("所属部门"));
header.add(Collections.singletonList("接入电网侧变电站名"));
header.add(Collections.singletonList("监测点对象名称"));
header.add(Collections.singletonList("装置编号"));
header.add(Collections.singletonList("IP地址"));
header.add(Collections.singletonList("终端厂家"));
header.add(Collections.singletonList("在线率"));
header.add(Collections.singletonList("数据完整性"));
if(FlyMonitorId){
header.add(Collections.singletonList("国网ID"));
}
return header;
}
/**
* 监测点信息表头数据写入
* @param data
* @return
*/
public static List<List<Object>> lineBody(List<LineDataExcel> data) {
List<List<Object>> result = new ArrayList<>();
if(CollUtil.isNotEmpty(data)){
for (LineDataExcel datum : data) {
ArrayList<Object> row = Lists.newArrayList(datum.getLineNum(),
datum.getLineName(),
datum.getDeptName(),
datum.getPowerSubstationName(),
datum.getObjName(),
datum.getDeviceName(),
datum.getIp(),
datum.getManufacturer(),
datum.getOnlineRate(),
datum.getIntegrity());
if(ObjUtil.isNotNull(datum.getMonitorId())){
row.add(datum.getMonitorId());
}
result.add(row);
}
}
// 插入一个空行
result.add(Collections.emptyList());
return result;
}
/**
* 创建地市信息表头
* @return
*/
public static List<List<String>> cityHeader() {
List<List<String>> header = new ArrayList<>();
header.add(Collections.singletonList("单位"));
header.add(Collections.singletonList("监测终端数量"));
header.add(Collections.singletonList("监测点个数"));
header.add(Collections.singletonList("在线率(%"));
header.add(Collections.singletonList("完整率(%"));
header.add(Collections.singletonList("问题监测点"));
return header;
}
public static List<List<Object>> cityBody(List<CityDataExcel> data) {
List<List<Object>> result = new ArrayList<>();
if(CollUtil.isNotEmpty(data)){
for (CityDataExcel datum : data) {
ArrayList<Object> row = Lists.newArrayList(datum.getDeptName(),
datum.getDeviceNum(),
datum.getLineNum(),
datum.getOnlineRate(),
datum.getIntegrity(),
datum.getAbnormalNum());
result.add(row);
}
}
// 插入一个空行
result.add(Collections.emptyList());
return result;
}
}

View File

@@ -0,0 +1,235 @@
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.metadata.style.WriteCellStyle;
import com.alibaba.excel.write.metadata.style.WriteFont;
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
import com.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy;
import com.njcn.device.pq.pojo.vo.dataClean.DataVerifyExcel;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import java.io.FileOutputStream;
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 Map<String, List> exportExcelByDataSize(List<DataVerifyExcel> dataList) {
Map<String, List> map = new HashMap<>(2);
Map<String, Integer> fieldCount = countValidData(dataList);
List<String> sortedFields = sortFields(fieldCount);
map.put("head", buildCorrectHead(sortedFields));
map.put("data", buildRowData(dataList, sortedFields));
return map;
}
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);
}
}
public static HorizontalCellStyleStrategy writeCenterStyle() {
// 内容的策略
WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
//设置 自动换行
contentWriteCellStyle.setWrapped(true);
//设置 垂直居中
contentWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
//设置 水平居中
contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
//设置边框样式
contentWriteCellStyle.setBorderLeft(BorderStyle.THIN);
contentWriteCellStyle.setBorderTop(BorderStyle.THIN);
contentWriteCellStyle.setBorderRight(BorderStyle.THIN);
contentWriteCellStyle.setBorderBottom(BorderStyle.THIN);
WriteFont bodyWriteFont = new WriteFont();
bodyWriteFont.setFontHeightInPoints((short) 11);
bodyWriteFont.setBold(false);
bodyWriteFont.setFontName("宋体");
contentWriteCellStyle.setWriteFont(bodyWriteFont);
// 头部
WriteCellStyle headWriteCellStyle = new WriteCellStyle();
// 设置字体居中
headWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
WriteFont headWriteFont = new WriteFont();
// 设置字体大小为20
headWriteFont.setFontHeightInPoints((short) 11);
headWriteFont.setBold(false);
headWriteFont.setFontName("宋体");
headWriteCellStyle.setWriteFont(headWriteFont);
return new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle);
}
// ★ 修复点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) {
// 每个列名单独封装成ListEasyExcel才能识别为不同列
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;
}
}

View File

@@ -1,6 +1,7 @@
package com.njcn.device.pq.controller;
import cn.hutool.core.date.DateUtil;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
@@ -16,18 +17,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 +51,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 +60,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 +73,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 +93,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 +108,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 +120,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 +133,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 +149,18 @@ 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");
monitorBaseParam.setSearchBeginTime(DateUtil.beginOfDay(DateUtil.parse(monitorBaseParam.getSearchBeginTime())).toString());
monitorBaseParam.setSearchEndTime(DateUtil.endOfDay(DateUtil.parse(monitorBaseParam.getSearchEndTime())).toString());
iPqDataVerifyBakService.dataVerifyExcel(response, monitorBaseParam);
}
}

View File

@@ -0,0 +1,113 @@
package com.njcn.device.pq.controller;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.device.biz.pojo.po.PqSensitiveUser;
import com.njcn.device.pq.pojo.param.PqSensitiveUserParam;
import com.njcn.device.pq.pojo.vo.PqSensitiveUserVo;
import com.njcn.device.pqUser.service.IPqSensitiveUserService;
import com.njcn.web.controller.BaseController;
import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* <p>
* 前端控制器
* </p>
*
* @author xy
* @since 2025-11-17
*/
@Slf4j
@RestController
@RequestMapping("/pqSensitiveUser")
@Api(tags = "敏感负荷用户管理")
@AllArgsConstructor
public class PqSensitiveUserController extends BaseController {
private final IPqSensitiveUserService pqSensitiveUserService;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getList")
@ApiOperation("获取敏感负荷用户列表")
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
public HttpResult<Page<PqSensitiveUserVo>> getList(@RequestBody BaseParam param) {
String methodDescribe = getMethodDescribe("getList");
Page<PqSensitiveUserVo> page = pqSensitiveUserService.getList(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getListByIds")
@ApiOperation("根据id集合获取敏感负荷用户列表")
@ApiImplicitParam(name = "ids", value = "id集合")
public HttpResult<List<PqSensitiveUser>> getListByIds(@RequestParam(name = "ids", required = false) List<String> ids) {
String methodDescribe = getMethodDescribe("getListByIds");
List<PqSensitiveUser> list;
list = pqSensitiveUserService.list(
new LambdaQueryWrapper<PqSensitiveUser>().in(PqSensitiveUser::getId, ids)
);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
/**
* 新增用户对象
*/
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD)
@PostMapping("/save")
@ApiOperation("新增用户对象")
public HttpResult<Boolean> save(@RequestBody @Validated PqSensitiveUserParam pqSensitiveUserParam) {
String methodDescribe = getMethodDescribe("save");
pqSensitiveUserService.save(pqSensitiveUserParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
}
/**
* 修改用户对象
*/
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.UPDATE)
@PostMapping("/update")
@ApiOperation("修改用户对象")
public HttpResult<Boolean> update(@RequestBody @Validated PqSensitiveUserParam.UpdatePqSensitiveUserParam pqSensitiveUserParam) {
String methodDescribe = getMethodDescribe("update");
pqSensitiveUserService.update(pqSensitiveUserParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
}
/**
* 删除用户对象
*/
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.DELETE)
@PostMapping("/delete")
@ApiOperation("删除用户对象")
@ApiImplicitParam(name = "ids", value = "id集合")
public HttpResult<Boolean> delete(@RequestBody List<String> ids) {
String methodDescribe = getMethodDescribe("delete");
pqSensitiveUserService.removeByIds(ids);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
}
}

View File

@@ -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);
}

View File

@@ -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 &lt;= #{param.searchEndTime}
</if>
</where>
GROUP BY line_id
) a
WHERE
allTime >0
</select>
</mapper>

View File

@@ -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>

View File

@@ -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;
}

View File

@@ -101,12 +101,7 @@ public class LineIntegrityDataServiceImpl extends ServiceImpl<LineIntegrityDataM
if (CollectionUtil.isEmpty(alarmStrategyVos)) {
throw new BusinessException(DeviceResponseEnum.QUERY_ALARMSTRATEGY_DATA_EMPTY);
}
List<AlarmStrategyVO> alarmAlgoDescribe = lineIntegrityDataMapper.getAlarmAlgoDescribe(alarmStrategyVos);
Map<Integer, Integer> mapAlarm = alarmAlgoDescribe.stream().collect(Collectors.toMap(AlarmStrategyVO::getAlgoDescribe, AlarmStrategyVO::getIntegrityValue));
Map<String, Integer> mapA = alarmStrategyVos.stream().collect(Collectors.toMap(AlarmStrategyVO::getId, AlarmStrategyVO::getIntegrityValue));
// 遍历集合
for (GeneralDeviceDTO generalDeviceDTO : generalDeviceDTOList) {

View File

@@ -4,44 +4,58 @@ package com.njcn.device.pq.service.impl;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.*;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
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.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.metadata.WriteTable;
import com.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.dto.SimpleDTO;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.dataProcess.api.PqReasonableRangeFeignClient;
import com.njcn.dataProcess.enums.DataCleanEnum;
import com.njcn.dataProcess.param.DataCleanParam;
import com.njcn.dataProcess.pojo.dto.PqReasonableRangeDto;
import com.njcn.device.common.mapper.onlinerate.OnLineRateMapper;
import com.njcn.device.common.service.GeneralDeviceService;
import com.njcn.device.line.mapper.LineMapper;
import com.njcn.device.line.service.DeptLineService;
import com.njcn.device.pq.constant.Param;
import com.njcn.device.pq.enums.LineBaseEnum;
import com.njcn.device.pq.mapper.PqDataVerifyBakMapper;
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
import com.njcn.device.pq.pojo.param.OnlineRateParam;
import com.njcn.device.pq.pojo.param.dataClean.MonitorBaseParam;
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.*;
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.device.pq.utils.DataLineExcelUtil;
import com.njcn.device.rstatintegrity.mapper.RStatIntegrityDMapper;
import com.njcn.oss.utils.FileStorageUtil;
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 org.springframework.util.CollectionUtils;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
@@ -50,6 +64,9 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static com.njcn.device.pq.utils.FixedDynamicExcelExport.exportExcelByDataSize;
import static com.njcn.device.pq.utils.FixedDynamicExcelExport.writeCenterStyle;
/**
* <p>
* 服务实现类
@@ -72,10 +89,13 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
private final UserLedgerFeignClient userLedgerFeignClient;
private final FileStorageUtil fileStorageUtil;
private final DeptLineService deptLineService;
private final GeneralDeviceService deviceService;
private final RStatIntegrityDMapper integrityDMapper;
private final OnLineRateMapper onLineRateMapper;
@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 +106,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 +172,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());
@@ -177,13 +197,16 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
@Override
public List<PowerQualityIndicatorsVO> getMonitorVerifyDay(MonitorBaseParam monitorBaseParam) {
List<String> monitorIds = commTerminalService.getRunMonitorByDept(monitorBaseParam);
if(CollectionUtils.isEmpty(monitorIds)){
return new ArrayList<>();
}
List<PqDataVerifyBak> dataVerifyList = baseDataVerifyQuery(monitorIds, monitorBaseParam);
return getAbnormalTable(dataVerifyList, monitorBaseParam);
}
@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 +320,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 +354,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 +390,230 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
return info;
}
@Override
public void dataVerifyExcel(HttpServletResponse response, MonitorBaseParam monitorBaseParam) throws IOException {
if (StrUtil.isNotBlank(monitorBaseParam.getDeptId())) {
DeviceInfoParam param = new DeviceInfoParam();
param.setDeptIndex(monitorBaseParam.getDeptId());
param.setStatisticalType(new SimpleDTO());
//获取终端台账类信息
List<GeneralDeviceDTO> deviceInfo = deviceService.getDeviceInfo(param, Arrays.asList(0), Arrays.asList(1));
List<String> lineIds = deviceInfo.stream().flatMap(x -> x.getLineIndexes().stream()).distinct().collect(Collectors.toList());
List<String> devIds = deviceInfo.stream().flatMap(x -> x.getDeviceIndexes().stream()).distinct().collect(Collectors.toList());
List<LineInfoMonitorIdVO> areaLineInfoVOList = lineMapper.getBaseLineInfoMonitorIdInfo(lineIds);
List<LineInfoMonitorIdVO> monitorLine = areaLineInfoVOList.stream().filter(x -> StrUtil.isNotBlank(x.getMonitorId())).collect(Collectors.toList());
List<LineInfoMonitorIdVO> gridSide = areaLineInfoVOList.stream().filter(x -> x.getPowerFlag() == 0).collect(Collectors.toList());
List<LineInfoMonitorIdVO> nonGridSide = areaLineInfoVOList.stream().filter(x -> x.getPowerFlag() == 1).collect(Collectors.toList());
OnlineRateParam onlineRateParam = new OnlineRateParam();
onlineRateParam.setIds(devIds);
onlineRateParam.setStartTime(monitorBaseParam.getSearchBeginTime());
onlineRateParam.setEndTime(monitorBaseParam.getSearchEndTime());
//完整率
List<RStatIntegrityVO> integrityList = integrityDMapper.getLineIntegrityRateInfo(lineIds,
monitorBaseParam.getSearchBeginTime(),
monitorBaseParam.getSearchEndTime());
//获取所有终端在线率
List<RStatOnlineRateVO> onlineRateByDev = onLineRateMapper.getOnlineRateByDevIds(onlineRateParam);
List<CityDataExcel> cityData1 = new ArrayList<>();
List<CityDataExcel> cityData2 = new ArrayList<>();
List<CityDataExcel> cityData3 = new ArrayList<>();
for (GeneralDeviceDTO dto : deviceInfo) {
cityData1.add(addCityDataExcel(dto, monitorLine, onlineRateByDev, integrityList));
cityData2.add(addCityDataExcel(dto, gridSide, onlineRateByDev, integrityList));
cityData3.add(addCityDataExcel(dto, nonGridSide, onlineRateByDev, integrityList));
}
monitorBaseParam.setMonitorIds(lineIds);
List<DataVerifyExcel> dataVerifyExcels = this.baseMapper.selectDataVerifySum(monitorBaseParam);
Map<String, LineInfoMonitorIdVO> lineInfomap = areaLineInfoVOList.stream().collect(Collectors.toMap(LineInfoMonitorIdVO::getLineId, Function.identity()));
for (DataVerifyExcel dataVerifyExcel : dataVerifyExcels) {
if (lineInfomap.containsKey(dataVerifyExcel.getLineId())) {
LineInfoMonitorIdVO areaLineInfoVO = lineInfomap.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())
);
Map<String, List> map = exportExcelByDataSize(dataVerifyExcels);
// 步骤5导出Excel含列宽设置
ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream())
.registerWriteHandler(new SimpleColumnWidthStyleStrategy(20))
.registerWriteHandler(writeCenterStyle()).build();
WriteSheet writeSheet0 = EasyExcel.writerSheet("监测点异常指标统计").build();
WriteTable writeTable0 = EasyExcel.writerTable(0).needHead(Boolean.TRUE).head(map.get("head")).build();
excelWriter.write(map.get("data"), writeSheet0, writeTable0);
Map<Integer, List<CityDataExcel>> cityData = new HashMap<>();
cityData.put(1, cityData1);
cityData.put(2, cityData2);
cityData.put(3, cityData3);
Map<Integer, List<LineDataExcel>> lineData = new HashMap<>();
addLineDataExcel(cityData1, areaLineInfoVOList, onlineRateByDev, integrityList, lineData, 1);
addLineDataExcel(cityData2, areaLineInfoVOList, onlineRateByDev, integrityList, lineData, 2);
addLineDataExcel(cityData3, areaLineInfoVOList, onlineRateByDev, integrityList, lineData, 3);
excelExtracted(excelWriter, "数据质量", new HashMap<>(), cityData, true);
excelExtracted(excelWriter, "数据质量表格", lineData, new HashMap<>(), false);
excelWriter.finish();
}
}
private void addLineDataExcel(List<CityDataExcel> cityData1, List<LineInfoMonitorIdVO> areaLineInfoVOList, List<RStatOnlineRateVO> onlineRateByDev, List<RStatIntegrityVO> integrityList, Map<Integer, List<LineDataExcel>> lineData, Integer num) {
List<LineDataExcel> lineDataExcels1 = new ArrayList<>();
List<String> lineData1 = cityData1.stream().flatMap(x -> x.getAbnormalList().stream()).collect(Collectors.toList());
List<LineInfoMonitorIdVO> lineInfoData1 = areaLineInfoVOList.stream().filter(x -> lineData1.contains(x.getLineId())).collect(Collectors.toList());
LineDataExcel lineDataExcel;
for (int i = 0; i < lineInfoData1.size(); i++) {
LineInfoMonitorIdVO dto = lineInfoData1.get(i);
lineDataExcel = new LineDataExcel();
lineDataExcel.setLineNum(BigDecimal.valueOf((i + 1)));
lineDataExcel.setLineName(dto.getLineName());
lineDataExcel.setDeptName(dto.getDeviceName());
lineDataExcel.setPowerSubstationName(dto.getPowerSubstationName());
lineDataExcel.setObjName(dto.getObjName());
lineDataExcel.setDeviceName(dto.getDeviceName());
lineDataExcel.setIp(dto.getIp());
lineDataExcel.setManufacturer(dto.getManufacturer());
lineDataExcel.setOnlineRate(onLineRate(onlineRateByDev, Arrays.asList(dto.getDeviceId())));
lineDataExcel.setIntegrity(integrity(integrityList, Arrays.asList(dto.getLineId())));
if (num == 1) {
lineDataExcel.setMonitorId(new BigDecimal(dto.getMonitorId()));
}
lineDataExcels1.add(lineDataExcel);
}
lineData.put(num, lineDataExcels1);
}
private CityDataExcel addCityDataExcel(GeneralDeviceDTO dto, List<LineInfoMonitorIdVO> monitorLine, List<RStatOnlineRateVO> onlineRateByDev, List<RStatIntegrityVO> integrityList) {
CityDataExcel data = new CityDataExcel();
List<String> monitorLineList = monitorLine.stream()
.filter(x -> dto.getLineIndexes().contains(x.getLineId()))
.map(LineInfoMonitorIdVO::getLineId)
.distinct()
.collect(Collectors.toList());
List<String> devList = monitorLine.stream()
.filter(x -> dto.getDeviceIndexes().contains(x.getDeviceId()))
.map(LineInfoMonitorIdVO::getDeviceId)
.distinct()
.collect(Collectors.toList());
data.setDeptName(dto.getName());
data.setDeviceNum(BigDecimal.valueOf(devList.size()));
data.setLineNum(BigDecimal.valueOf(monitorLineList.size()));
data.setOnlineRate(onLineRate(onlineRateByDev, devList));
data.setIntegrity(integrity(integrityList, monitorLineList));
List<String> abnormalList = integrityList.stream()
.filter(x -> ObjUtil.isNotNull(x.getIntegrityRate()))
.filter(x -> x.getIntegrityRate().compareTo(BigDecimal.ZERO) == 0)
.filter(x -> monitorLineList.contains(x.getLineIndex()))
.map(RStatIntegrityVO::getLineIndex)
.distinct()
.collect(Collectors.toList());
data.setAbnormalNum(BigDecimal.valueOf(abnormalList.size()));
data.setAbnormalList(abnormalList);
return data;
}
private BigDecimal integrity(List<RStatIntegrityVO> integrityList, List<String> lineIds) {
//监测完整率
List<RStatIntegrityVO> integrityDS = integrityList.stream().filter(x -> lineIds.contains(x.getLineIndex())).collect(Collectors.toList());
if (CollUtil.isNotEmpty(integrityDS)) {
double realTime = integrityDS.stream().mapToDouble(RStatIntegrityVO::getRealTime).sum();
double dueTime = integrityDS.stream().mapToDouble(RStatIntegrityVO::getDueTime).sum();
if (dueTime == 0) {
return new BigDecimal(0);
}
return NumberUtil.round(Math.min(realTime * 100.0 / dueTime, 100), 2);
} else {
return new BigDecimal(0);
}
}
private BigDecimal onLineRate(List<RStatOnlineRateVO> onlineRateByDev, List<String> devIds) {
//终端在线率
List<RStatOnlineRateVO> onlineRateDS = onlineRateByDev.stream().filter(x -> devIds.contains(x.getDevIndex())).collect(Collectors.toList());
if (CollUtil.isNotEmpty(onlineRateDS)) {
double onlineTime = onlineRateDS.stream().mapToDouble(RStatOnlineRateVO::getOnlineMin).sum();
double offlineTime = onlineRateDS.stream().mapToDouble(RStatOnlineRateVO::getOfflineMin).sum();
if ((onlineTime + offlineTime) == 0) {
return new BigDecimal(0);
}
return NumberUtil.round(Math.min(onlineTime * 100.0 / (onlineTime + offlineTime), 100), 2);
} else {
return new BigDecimal(0);
}
}
private void excelExtracted(ExcelWriter excelWriter, String sheetName, Map<Integer, List<LineDataExcel>> lineData, Map<Integer, List<CityDataExcel>> cityData, Boolean fly) {
// 构建sheet页--表示不加表头
WriteSheet writeSheet = EasyExcel.writerSheet(sheetName).needHead(Boolean.FALSE).build();
// 表头的数量
int num = 0;
Boolean first = false;
// 模拟写5张表
for (int i = 1; i < 4; i++) {
String name = "";
if (i == 1) {
if (fly) {
name = "一类监测点";
} else {
name = "冀北公司一类监测点数据质量问题";
}
first = true;
}
if (i == 2) {
if (fly) {
name = "电网侧";
} else {
name = "冀北公司电网侧监测点数据质量问题(不包含一类监测点)";
}
first = false;
}
if (i == 3) {
if (fly) {
name = "非电网侧";
} else {
name = "冀北公司非电网侧问题监测点(不包含一类监测点)";
}
first = false;
}
String finalName = name;
List<List<String>> contentHeader;
if (fly) {
contentHeader = DataLineExcelUtil.cityHeader();
} else {
contentHeader = DataLineExcelUtil.lineHeader(first);
}
List<List<String>> nameHeader = contentHeader.stream().map(item -> Collections.singletonList(finalName)).collect(Collectors.toList());
// 这里必须指定需要头table 会继承sheet的配置sheet配置了不需要table 默认也是不需要
// 创建一个表头
WriteTable writeTable1 = EasyExcel.writerTable(num).needHead(Boolean.TRUE).head(nameHeader).build();
excelWriter.write(new ArrayList<>(), writeSheet, writeTable1);
//创建数据
WriteTable writeTable2 = EasyExcel.writerTable(num + 1).needHead(Boolean.TRUE).head(contentHeader).build();
List<List<Object>> body;
if (fly) {
body = DataLineExcelUtil.cityBody(cityData.get(i));
} else {
body = DataLineExcelUtil.lineBody(lineData.get(i));
}
excelWriter.write(body, writeSheet, writeTable2);
// 插入两次表头加2
num = num + 2;
}
}
private static final Pattern HARMONIC_PATTERN = Pattern.compile("(\\d+)次谐波");
@@ -441,7 +688,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 +718,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 +870,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 +994,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);
}

View File

@@ -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);
}
}
// }
}
}

View File

@@ -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()));

View File

@@ -7,6 +7,7 @@ import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.text.StrBuilder;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
@@ -100,6 +101,7 @@ import java.math.BigDecimal;
import java.net.HttpURLConnection;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -681,6 +683,9 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
BeanUtils.copyProperties(updateDeviceParam, deviceDetail);
deviceDetail.setId(updateDeviceParam.getDevIndex());
coderM3d(deviceDetail, true);
deviceDetail.setLoginTime(LocalDate.parse(updateDeviceParam.getLoginTime(), DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN)));
deviceDetail.setThisTimeCheck(LocalDate.parse(updateDeviceParam.getThisTimeCheck(), DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN)));
deviceDetail.setNextTimeCheck(LocalDate.parse(updateDeviceParam.getNextTimeCheck(), DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN)));
this.updateById(device);
deviceMapper.updateById(deviceDetail);

View File

@@ -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);
}

View File

@@ -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

View File

@@ -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);

View File

@@ -216,6 +216,8 @@ public interface LineMapper extends BaseMapper<Line> {
*/
List<AreaLineInfoVO> getBaseLineAreaInfo(@Param("list") List<String> lineIndex, @Param("searchValue") String searchValue, @Param("comFlag") Integer comFlag);
List<LineInfoMonitorIdVO> getBaseLineInfoMonitorIdInfo(@Param("list") List<String> lineIndex);
/**
* 返回监测点信息及通讯状态
*

View File

@@ -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

View File

@@ -557,12 +557,13 @@
detail.ct2,
detail.pt1,
detail.pt2,
detail.PT_Type as ptType,
detail.obj_name,
detail.Dev_Capacity deviceCapacity,
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 +572,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 +1270,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
@@ -1510,17 +1513,9 @@
<select id="getCustomDetailByLineId" resultType="map">
SELECT
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.pt2 AS CHAR), 'N/A')
) AS pt,
CONCAT(
IFNULL(CAST(detail.ct1 AS CHAR), 'N/A'),
':',
IFNULL(CAST(detail.ct2 AS CHAR), 'N/A')
) AS ct,
CONCAT(CONCAT(CONCAT(sub.NAME, '_'), vo.NAME), CONCAT('_', line.NAME)) AS lineName,
CONCAT(CONCAT(COALESCE(detail.pt1, 'N/A'), ':'), COALESCE(detail.pt2, 'N/A')) AS pt,
CONCAT(CONCAT(COALESCE(detail.ct1, 'N/A'), ':'), COALESCE(detail.ct2, 'N/A')) AS ct,
detail.Dev_Capacity AS Dev_Capacity,
detail.Short_Capacity AS Short_Capacity,
detail.Standard_Capacity AS Standard_Capacity,
@@ -1539,6 +1534,7 @@
WHERE
line.id = #{lineId}
</select>
<select id="selectByIds" resultType="com.njcn.device.pq.pojo.vo.LineDetailVO$Detail">
SELECT DISTINCT
line.id as lineId,
@@ -1947,5 +1943,83 @@
</foreach>
</select>
<select id="getBaseLineInfoMonitorIdInfo" resultType="com.njcn.device.pq.pojo.vo.LineInfoMonitorIdVO">
SELECT
line.Id lineId,
line.Name lineName,
gd.Name gdName,
substation.id subId,
substation.Name subName,
subscale.name subScale,
device.id deviceId,
device.name deviceName,
pqdevice.IP ip,
factory.Name manufacturer,
voltage.id voltageId,
voltage.Name voltageName,
scale.Name voltageScale,
pqdevice.run_flag,
pqdevice.com_flag,
pqsubstation.Lng,
pqsubstation.lat,
detail.num,
detail.ct1,
detail.ct2,
detail.pt1,
detail.pt2,
detail.obj_name,
detail.Dev_Capacity deviceCapacity,
detail.Short_Capacity,
detail.Standard_Capacity,
detail.Deal_Capacity,
detail.Business_Type businessType,
detail.Calssification_Grade,
detail.Superiors_Substation,
detail.Hang_Line,
loadtype.name loadType,
detail.New_Station_Id as newStationId,
detail.obj_id,
detail.big_obj_type,
detail.small_obj_type,
detail.Power_Flag powerFlag,
detail.Power_Substation_Name powerSubstationName,
detail.Monitor_Id monitorId
FROM
pq_line line,
pq_line_detail detail,
pq_line voltage,
pq_voltage pqvoltage,
pq_line device,
pq_device pqdevice,
pq_line substation,
pq_substation pqsubstation,
pq_line gd,
sys_dict_data scale,
sys_dict_data factory,
sys_dict_data loadtype,
sys_dict_data subscale
WHERE
line.id = detail.id
AND line.pid = voltage.id
AND voltage.id = pqvoltage.id
AND pqvoltage.Scale = scale.id
AND voltage.pid = device.id
AND voltage.pid = pqdevice.id
AND pqdevice.Manufacturer = factory.id
AND device.pid = substation.id
AND substation.id = pqsubstation.id
AND pqsubstation.scale = subscale.id
AND substation.pid = gd.id
AND detail.load_type = loadtype.id
<if test="list !=null and list.size() >0">
AND line.Id IN
<foreach item="item" collection="list" separator="," open="(" close=")">
#{item}
</foreach>
</if>
</select>
</mapper>

View File

@@ -0,0 +1,26 @@
package com.njcn.device.pqUser.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.device.biz.pojo.po.PqSensitiveUser;
import com.njcn.device.pq.pojo.param.PqSensitiveUserParam;
import com.njcn.device.pq.pojo.vo.PqSensitiveUserVo;
import com.njcn.web.pojo.param.BaseParam;
/**
* <p>
* 服务类
* </p>
*
* @author xy
* @since 2025-11-17
*/
public interface IPqSensitiveUserService extends IService<PqSensitiveUser> {
Page<PqSensitiveUserVo> getList(BaseParam param);
boolean save(PqSensitiveUserParam pqSensitiveUserParam);
boolean update(PqSensitiveUserParam.UpdatePqSensitiveUserParam pqSensitiveUserParam);
}

View File

@@ -0,0 +1,107 @@
package com.njcn.device.pqUser.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.device.biz.mapper.PqSensitiveUserMapper;
import com.njcn.device.biz.pojo.po.PqSensitiveUser;
import com.njcn.device.pq.pojo.param.PqSensitiveUserParam;
import com.njcn.device.pq.pojo.vo.PqSensitiveUserVo;
import com.njcn.device.pqUser.service.IPqSensitiveUserService;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.pojo.po.DictData;
import com.njcn.web.pojo.param.BaseParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
/**
* <p>
* 服务实现类
* </p>
*
* @author xy
* @since 2025-11-17
*/
@DS("sjzx")
@Slf4j
@Service
@RequiredArgsConstructor
public class PqSensitiveUserServiceImpl extends ServiceImpl<PqSensitiveUserMapper, PqSensitiveUser> implements IPqSensitiveUserService {
private final DicDataFeignClient dicDataFeignClient;
@Override
public Page<PqSensitiveUserVo> getList(BaseParam param) {
Page<PqSensitiveUserVo> result = new Page<>(param.getPageNum(),param.getPageSize());
LambdaQueryWrapper<PqSensitiveUser> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.orderByDesc(PqSensitiveUser::getSort);
if (StrUtil.isNotBlank(param.getSearchValue())) {
lambdaQueryWrapper.like(PqSensitiveUser::getName, param.getSearchValue());
}
Page<PqSensitiveUser> page = this.page(new Page<>(param.getPageNum(),param.getPageSize()),lambdaQueryWrapper);
if(CollUtil.isNotEmpty(page.getRecords())){
List<PqSensitiveUserVo> dataGroupEventVOList = new ArrayList<>();
page.getRecords().forEach(item->{
PqSensitiveUserVo vo = new PqSensitiveUserVo();
BeanUtil.copyProperties(item,vo);
dataGroupEventVOList.add(vo);
});
result.setRecords(dataGroupEventVOList);
result.setTotal(page.getTotal());
result.setSize(page.getSize());
result.setCurrent(page.getCurrent());
result.setPages(page.getPages());
}
return result;
}
@Override
public boolean save(PqSensitiveUserParam pqSensitiveUserParam) {
checkParam(pqSensitiveUserParam,false);
PqSensitiveUser pqSensitiveUser = new PqSensitiveUser();
BeanUtil.copyProperties(pqSensitiveUserParam,pqSensitiveUser);
return this.save(pqSensitiveUser);
}
@Override
public boolean update(PqSensitiveUserParam.UpdatePqSensitiveUserParam pqSensitiveUserParam) {
checkParam(pqSensitiveUserParam,true);
PqSensitiveUser pqSensitiveUser = new PqSensitiveUser();
BeanUtil.copyProperties(pqSensitiveUserParam,pqSensitiveUser);
return this.updateById(pqSensitiveUser);
}
private void checkParam(PqSensitiveUserParam param,boolean update){
DictData data = dicDataFeignClient.getDicDataById(param.getLoadType()).getData();
if(Objects.isNull(data)){
throw new BusinessException(CommonResponseEnum.FAIL,"字典负荷类型缺失!");
}
LambdaQueryWrapper<PqSensitiveUser> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(PqSensitiveUser::getName,param.getName());
if(update){
if(param instanceof PqSensitiveUserParam.UpdatePqSensitiveUserParam){
lambdaQueryWrapper.ne(PqSensitiveUser::getId,((PqSensitiveUserParam.UpdatePqSensitiveUserParam) param).getId());
}
}
int count = this.count(lambdaQueryWrapper);
if(count>0){
throw new BusinessException(CommonResponseEnum.FAIL,"用户名称重复!");
}
}
}

View File

@@ -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">

View File

@@ -234,4 +234,10 @@ public class ReportController extends BaseController {
reportService.getPmsAreaReport(areaReportParam, response);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/createEventReport")
@ApiOperation("暂态事件报告导出")
public void createEventReport(@RequestBody @Validated List<String> index, HttpServletResponse response) throws IOException, InvalidFormatException {
commMonitorEventReportService.createEventReport(index,response);
}
}

View File

@@ -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}

View File

@@ -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())))

View File

@@ -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();

View File

@@ -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())))
);

View File

@@ -1,10 +1,8 @@
package com.njcn.event.common.mapper;
import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.event.pojo.dto.EventCount;
import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.event.pojo.vo.RmpEventDetailVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

View File

@@ -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> {
}

View File

@@ -0,0 +1,69 @@
package com.njcn.event.common.pojo.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @description: 暂降事件特征幅值
* @author: denghuajun
* @time: 2019-10-17 13:59:51
**/
@Data
public class EventEigDetail implements Serializable {
/**
* 输出参数
* 持续时间(单位秒)
* hold_time_rms 有效值算法持续时间
* hold_time_dq dq变换算法持续时间
* 波形起始点(单位度)
* POW_a A相波形起始点
* POW_b B相波形起始点
* POW_c C相波形起始点
* 跳变段电压变化率单位V/S
* Voltagechange_Va A相跳变段电压变化率
* Voltagechange_Vb B相跳变段电压变化率
* Voltagechange_Vc C相跳变段电压变化率
* 分段信息
* SEG_T_num 分段数目
* SEG_T0_idx 原始分段位置
* SEG_T_idx 修正分段位置
* 有效值分段信息
* SEG_RMS_T_num 分段数目
* SEG_RMS_T_idx 分段位置
* 特征幅值单位V
* u_min_num 特征值个数
* ua_min A相电压特征值
* ub_min B相电压特征值
* uc_min C相电压特征值
* u3_min 三相电压特征值
* order_min_idx 最小值位置
* 相位跳变(单位度)
* angle_diff_ap A相相位正跳变
* angle_diff_bp B相相位正跳变
* angle_diff_cp C相相位正跳变
* angle_diff_an A相相位负跳变
* angle_diff_bn B相相位负跳变
* angle_diff_cn C相相位负跳变
* bph_max_value 不平衡度(单位%
*/
public float hold_time_dq;
public float pow_a;
public float pow_b;
public float pow_c;
public float voltagechange_Va;
public float voltagechange_Vb;
public float voltagechange_Vc;
public float ua_min;
public float ub_min;
public float uc_min;
public float angle_diff_ap;
public float angle_diff_bp;
public float angle_diff_cp;
public float bph_max_value;
public String sagReason; // 暂降原因描述,数据库获取
public String sagType; // 暂降类型描述,数据库获取
private Integer pttype;
}

View File

@@ -0,0 +1,63 @@
package com.njcn.event.common.pojo.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @Description:
* @Author: wr
* @Date: 2023/11/1 13:17
*/
@Data
public class EventInfoDetailVO implements Serializable {
@ApiModelProperty("监测点名称")
private String lineName;
@ApiModelProperty("供电公司名称")
private String gdName;
@ApiModelProperty("变电站名称")
private String bdzName;
@ApiModelProperty("终端名称")
private String devName;
@ApiModelProperty("电压等级")
private String scale;
@ApiModelProperty("ip")
private String ip;
@ApiModelProperty("暂降事件id")
private String eventDetailIndex;
@ApiModelProperty("触发时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
private LocalDateTime timeID;
@ApiModelProperty("持续时间")
private Double persistTime;
@ApiModelProperty("处理结果第一条事件发生时间毫秒")
private Double ms;
@ApiModelProperty("特征幅值")
private Double eventValue;
@ApiModelProperty("报告状态")
private int report;
@ApiModelProperty("评价")
private int evaluate;
@ApiModelProperty("报告路径")
private String reportPath;
}

View File

@@ -2,8 +2,11 @@ package com.njcn.event.common.service;
import com.njcn.event.common.pojo.dto.LineDetailDataCommDTO;
import com.njcn.event.pojo.param.ExportParam;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
/**
* pqs
@@ -15,4 +18,10 @@ public interface CommMonitorEventReportService {
void getLineExport(ExportParam exportParam, LineDetailDataCommDTO lineDetailDataCommDTO, HttpServletResponse response);
/**
* 暂态事件报告
* @param index
*/
void createEventReport(List<String> index, HttpServletResponse response) throws IOException, InvalidFormatException;
}

View File

@@ -0,0 +1,28 @@
package com.njcn.event.common.service;
import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
import com.njcn.event.common.pojo.dto.EventEigDetail;
import com.njcn.event.file.pojo.dto.WaveDataDTO;
import com.njcn.event.pojo.po.RmpEventDetailPO;
import java.util.List;
/**
* @Author: cdf
* @CreateTime: 2026-02-26
* @Description:
*/
public interface WaveService {
/**
* 通过优化后的方式获取波形数据
* @param
* @param
* @return
*/
WaveDataDTO getWavedata(RmpEventDetailPO eventDetail, AreaLineInfoVO line);
List<EventEigDetail> eventDetailEigenvalue(String eventDetailIndex,Integer ptType);
}

View File

@@ -1,34 +1,43 @@
package com.njcn.event.common.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.device.pms.api.MonitorClient;
import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
import com.njcn.echarts.pojo.constant.PicCommonData;
import com.njcn.echarts.util.DrawPicUtil;
import com.njcn.event.common.mapper.RmpEventDetailMapper;
import com.njcn.event.common.pojo.dto.EventEigDetail;
import com.njcn.event.common.pojo.dto.LineDetailDataCommDTO;
import com.njcn.event.common.service.CommMonitorEventReportService;
import com.njcn.event.common.service.EventAnalysisService;
import com.njcn.event.common.service.EventReportService;
import com.njcn.event.common.service.CommMonitorEventReportService;
import com.njcn.event.common.service.WaveService;
import com.njcn.event.common.pojo.dto.EventInfoDetailVO;
import com.njcn.event.common.utils.WordUtil;
import com.njcn.event.common.utils.WordUtils;
import com.njcn.event.file.component.WavePicComponent;
import com.njcn.event.file.pojo.bo.WaveDataDetail;
import com.njcn.event.file.pojo.dto.WaveDataDTO;
import com.njcn.event.file.utils.WaveUtil;
import com.njcn.event.pojo.param.ExportParam;
import com.njcn.event.pojo.param.StatisticsParam;
import com.njcn.event.pojo.po.EventDetail;
import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.event.pojo.vo.*;
import com.njcn.oss.utils.FileStorageUtil;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.enums.DicDataTypeEnum;
import com.njcn.system.pojo.po.DictData;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.util.Units;
import org.apache.poi.xwpf.usermodel.*;
@@ -38,9 +47,7 @@ import org.springframework.stereotype.Service;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
@@ -49,6 +56,7 @@ import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
@@ -63,17 +71,16 @@ import java.util.stream.Collectors;
public class CommMonitorEventReportServiceImpl implements CommMonitorEventReportService {
private final DicDataFeignClient dicDataFeignClient;
private final EventReportService eventReportService;
private final EventAnalysisService eventAnalysisService;
private final RmpEventDetailMapper rmpEventDetailMapper;
private final WaveService waveService;
private final DrawPicUtil drawPicUtil;
private final WavePicComponent wavePicComponent;
private final FileStorageUtil fileStorageUtil;
private final LineFeignClient lineFeignClient;
private final DicDataFeignClient dicDataFeignClient;
private final EventReportService eventReportService;
//调用暂降密度接口
private final EventAnalysisService eventAnalysisService;
private final MonitorClient monitorClient;
private final RmpEventDetailMapper rmpEventDetailMapper;
private final DrawPicUtil drawPicUtil;
/**
* 监测点导出word
@@ -218,7 +225,7 @@ public class CommMonitorEventReportServiceImpl implements CommMonitorEventReport
EventDetail eventDetail = plot.get(j);
String s = eventDetail.getStartTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
insertRow(doc, table, centerParagraph, false, j + 1 + "", s, BigDecimal.valueOf(eventDetail.getFeatureAmplitude() * 100).setScale(2, RoundingMode.HALF_UP).toString(), eventDetail.getDuration() + "", eventDetail.getAdvanceType(), eventDetail.getAdvanceReason(), eventDetail.getSeverity() + "");
insertRow(doc, table, centerParagraph, false, j + 1 + "", s, BigDecimal.valueOf(eventDetail.getFeatureAmplitude() * 100).setScale(2, RoundingMode.HALF_UP).toString(), eventDetail.getDuration() + "", Objects.isNull(eventDetail.getAdvanceType()) ? "/" : eventDetail.getAdvanceType(), Objects.isNull(eventDetail.getAdvanceReason()) ? "/" : eventDetail.getAdvanceReason(), Objects.isNull(eventDetail.getSeverity()) ? "/" : eventDetail.getSeverity() + "");
}
i++;
}
@@ -361,7 +368,7 @@ public class CommMonitorEventReportServiceImpl implements CommMonitorEventReport
} else {
for (int j = 0; j < reasonTypeTime.size(); j++) {
TimeVO timeVO = reasonTypeTime.get(j);
insertRow(doc, table1, centerParagraph, false,timeVO.getFulltime(), timeVO.getTimes());
insertRow(doc, table1, centerParagraph, false, timeVO.getFulltime(), timeVO.getTimes());
}
}
two++;
@@ -374,7 +381,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()));
@@ -456,8 +467,8 @@ public class CommMonitorEventReportServiceImpl implements CommMonitorEventReport
response.setContentType("application/octet-stream;charset=UTF-8");
doc.write(outputStream);
outputStream.close();
}catch (Exception e){
throw new BusinessException(CommonResponseEnum.FAIL,"导出监测点暂降报告异常");
} catch (Exception e) {
throw new BusinessException(CommonResponseEnum.FAIL, "导出监测点暂降报告异常");
}
}
@@ -516,14 +527,8 @@ public class CommMonitorEventReportServiceImpl implements CommMonitorEventReport
}
public void setCellStyle(HSSFCell cellname, String value, HSSFCellStyle style) {
cellname.setCellValue(value);
cellname.setCellStyle(style);
}
/**
*
*
* @param document 文档
* @param image 图片base64
* @param name 图片名
@@ -532,16 +537,16 @@ public class CommMonitorEventReportServiceImpl implements CommMonitorEventReport
*/
public void createPic(XWPFDocument document, String image, String name) {
try {
XWPFParagraph picParagraph = WordUtils.getCenterParagraph(document);
XWPFRun createRun = picParagraph.createRun();
if (image.contains(PicCommonData.PNG_PREFIX)) {
image = image.replace(PicCommonData.PNG_PREFIX, "");
}
byte[] bytes = Base64.getDecoder().decode(image);
InputStream in = new ByteArrayInputStream(bytes);
createRun.addPicture(in, 5, name, Units.toEMU(410), Units.toEMU(170));
}catch (Exception e){
log.error("在word中创建图片异常:",e);
XWPFParagraph picParagraph = WordUtils.getCenterParagraph(document);
XWPFRun createRun = picParagraph.createRun();
if (image.contains(PicCommonData.PNG_PREFIX)) {
image = image.replace(PicCommonData.PNG_PREFIX, "");
}
byte[] bytes = Base64.getDecoder().decode(image);
InputStream in = new ByteArrayInputStream(bytes);
createRun.addPicture(in, 5, name, Units.toEMU(410), Units.toEMU(170));
} catch (Exception e) {
log.error("在word中创建图片异常:", e);
}
}
@@ -571,19 +576,78 @@ 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)
.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())))
.eq(RmpEventDetailPO::getMeasurementPointId, statisticsParam.getLineIndex())
// .in(RmpEventDetailPO::getEventType, typeIds)
.ge(StrUtil.isNotBlank(statisticsParam.getStartTime()), RmpEventDetailPO::getStartTime, DateUtil.beginOfDay(DateUtil.parse(statisticsParam.getStartTime())))
.le(StrUtil.isNotBlank(statisticsParam.getEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(statisticsParam.getEndTime())))
.orderByDesc(RmpEventDetailPO::getStartTime)
);
return BeanUtil.copyToList(info, EventDetail.class);
}
/**
* 生成暂降事件报告
*/
public void createEventReport(List<String> eventIndex, HttpServletResponse response) throws IOException, InvalidFormatException {
WordUtil wordUtil = new WordUtil();
for (String index : eventIndex) {
RmpEventDetailPO detail = rmpEventDetailMapper.selectById(index);
List<AreaLineInfoVO> lineDetail = lineFeignClient.getBaseLineAreaInfo(Stream.of(detail.getLineId()).collect(Collectors.toList())).getData();
AreaLineInfoVO line = lineDetail.get(0);
WaveDataDTO waveData = waveService.getWavedata(detail, line);
//数据筛选,如果是双路电压的话会存在2个波形数据
List<WaveDataDetail> waveDataDetails = WaveUtil.filterWaveData(waveData);
if (ObjUtil.isNull(waveData)) {
throw new BusinessException(CommonResponseEnum.FAIL, "没有波形数据");
} else {
//获取瞬时波形
String instantPath = wavePicComponent.generateImageShun(waveData, waveDataDetails);
InputStream instantStream = fileStorageUtil.getFileStream(instantPath);
String imageShun64 = cn.hutool.core.codec.Base64.encode(instantStream);
wordUtil.translateShun(index, imageShun64);
//获取rms波形
String rmsPath = wavePicComponent.generateImageRms(waveData, waveDataDetails);
InputStream rmsStream = fileStorageUtil.getFileStream(rmsPath);
String rmsShun64 = cn.hutool.core.codec.Base64.encode(rmsStream);
wordUtil.translateRms(index, rmsShun64);
EventInfoDetailVO eventInfoList = new EventInfoDetailVO();
eventInfoList.setLineName(line.getLineName());
eventInfoList.setGdName(line.getGdName());
eventInfoList.setBdzName(line.getSubName());
eventInfoList.setDevName(line.getDeviceName());
eventInfoList.setScale(line.getVoltageScale());
eventInfoList.setIp(line.getIp());
eventInfoList.setEventDetailIndex(detail.getEventId());
eventInfoList.setTimeID(detail.getStartTime());
eventInfoList.setPersistTime(detail.getDuration());
eventInfoList.setMs(detail.getFirstMs());
eventInfoList.setEventValue(detail.getFeatureAmplitude());
wordUtil.setEventInfoList(index, eventInfoList);
List<EventEigDetail> eventDetailEigenvalue = waveService.eventDetailEigenvalue(index,line.getPtType());
wordUtil.setEventDetailEigenvalue(index, eventDetailEigenvalue);
}
}
wordUtil.createReport(eventIndex);
try {
ServletOutputStream outputStream = response.getOutputStream();
String fileName = URLEncoder.encode("暂降事件报告_" + DateUtil.format(new Date(),DatePattern.NORM_DATE_PATTERN)+ ".docx", "UTF-8");
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
response.setContentType("application/octet-stream;charset=UTF-8");
wordUtil.getDocument().write(outputStream);
outputStream.close();
} catch (Exception e) {
throw new BusinessException(CommonResponseEnum.FAIL, "导出暂降事件报告异常");
}
}
}

View File

@@ -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())))
);

View File

@@ -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());

View File

@@ -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);

View File

@@ -0,0 +1,125 @@
package com.njcn.event.common.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.njcn.advance.api.EventWaveAnalysisFeignClient;
import com.njcn.advance.pojo.dto.waveAnalysis.EntityAdvancedData;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.utils.PubUtils;
import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
import com.njcn.event.common.pojo.dto.EventEigDetail;
import com.njcn.event.common.service.WaveService;
import com.njcn.event.file.component.WaveFileComponent;
import com.njcn.event.file.pojo.dto.WaveDataDTO;
import com.njcn.event.file.pojo.enums.WaveFileResponseEnum;
import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.oss.constant.GeneralConstant;
import com.njcn.oss.constant.OssPath;
import com.njcn.oss.utils.FileStorageUtil;
import com.njcn.system.api.DicDataFeignClient;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.io.InputStream;
import java.util.*;
/**
* @Author: cdf
* @CreateTime: 2026-02-26
* @Description:
*/
@Service
@RequiredArgsConstructor
@Slf4j
public class WaveServiceImpl implements WaveService {
private final WaveFileComponent waveFileComponent;
private final FileStorageUtil fileStorageUtil;
private final EventWaveAnalysisFeignClient eventWaveAnalysisFeignClient;
/**
* 根据暂降事件索引获取波形数据
* 注:当前只考虑本地的波形文件
*
* @param eventDetail 暂态事件
* @param line 监测点
*/
@Override
public WaveDataDTO getWavedata(RmpEventDetailPO eventDetail, AreaLineInfoVO line) {
WaveDataDTO waveDataDTO = null;
if (ObjectUtil.isNotEmpty(line)) {
String waveName = eventDetail.getWavePath();
if (StrUtil.isBlank(waveName)) {
throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
}
String wavePath = OssPath.WAVE_DIR + line.getIp() + StrUtil.SLASH + waveName;
try (
InputStream cfgStream = fileStorageUtil.getFileStream(wavePath + GeneralConstant.CFG);
InputStream datStream = fileStorageUtil.getFileStream(wavePath + GeneralConstant.DAT)
) {
if (Objects.isNull(cfgStream) || Objects.isNull(datStream)) {
throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
}
waveDataDTO = waveFileComponent.getComtrade(cfgStream, datStream, 1);
} catch (Exception e) {
try {
InputStream cfgStreamLower = fileStorageUtil.getFileStream(wavePath + GeneralConstant.CFG_LOWER);
InputStream datStreamLower = fileStorageUtil.getFileStream(wavePath + GeneralConstant.DAT_LOWER);
if (Objects.isNull(cfgStreamLower) || Objects.isNull(datStreamLower)) {
throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
}
waveDataDTO = waveFileComponent.getComtrade(cfgStreamLower, datStreamLower, 1);
} catch (Exception e1) {
throw new BusinessException(WaveFileResponseEnum.WAVE_DATA_INVALID);
}
}
waveDataDTO = waveFileComponent.getValidData(waveDataDTO);
waveDataDTO.setPtType(line.getPtType());
waveDataDTO.setPt(line.getPt1() * 1.0 / line.getPt2());
waveDataDTO.setCt(line.getCt1() * 1.0 / line.getCt2());
waveDataDTO.setMonitorName(line.getLineName());
}
return waveDataDTO;
}
@Override
public List<EventEigDetail> eventDetailEigenvalue(String eventDetailIndex,Integer ptType) {
List<EventEigDetail> eventInfoDetails = new ArrayList<>();
EntityAdvancedData entityAdvancedData = eventWaveAnalysisFeignClient.analysis(eventDetailIndex).getData() ;
if (entityAdvancedData.backNumber != -1) {
for (int i = 0; i < entityAdvancedData.backNumber; i++) {
EventEigDetail eventEigDetail = new EventEigDetail();
eventEigDetail.setHold_time_dq(entityAdvancedData.evt_buf[i].hold_time_dq * 1000);
eventEigDetail.setPow_a(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].POW_a));
eventEigDetail.setPow_b(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].POW_b));
eventEigDetail.setPow_c(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].POW_c));
eventEigDetail.setVoltagechange_Va(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].Voltagechange_Va / 1000));
eventEigDetail.setVoltagechange_Vb(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].Voltagechange_Vb / 1000));
eventEigDetail.setVoltagechange_Vc(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].Voltagechange_Vc / 1000));
eventEigDetail.setUa_min(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].ua_min[0]));
eventEigDetail.setUb_min(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].ub_min[0]));
eventEigDetail.setUc_min(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].ua_min[0]));
eventEigDetail.setAngle_diff_ap(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].angle_diff_ap[0]));
eventEigDetail.setAngle_diff_bp(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].angle_diff_bp[0]));
eventEigDetail.setAngle_diff_cp(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].angle_diff_cp[0]));
eventEigDetail.setBph_max_value(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].bph_max_value[0]));
eventEigDetail.setSagReason(entityAdvancedData.sagReason[0]);//暂降原因,暂降原因都一样
eventEigDetail.setSagType(entityAdvancedData.sagType[i]);//暂降类型
eventInfoDetails.add(eventEigDetail);
eventEigDetail.setPttype(ptType);
}
} else {
eventInfoDetails = null;
}
return eventInfoDetails;
}
}

View File

@@ -0,0 +1,342 @@
package com.njcn.event.common.utils;
import com.njcn.event.common.pojo.dto.EventEigDetail;
import com.njcn.event.common.pojo.dto.EventInfoDetailVO;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.util.Units;
import org.apache.poi.xwpf.usermodel.*;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
import sun.misc.BASE64Decoder;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.time.format.DateTimeFormatter;
import java.util.*;
public class WordUtil {
private Map<String, List<byte[]>> listShunPic = new HashMap<>();
private Map<String, List<byte[]>> listRmsPic = new HashMap<>();
private XWPFDocument document;
private Map<String, List<EventEigDetail>> eventDetailEigenvalue = new HashMap<>();
private Map<String, EventInfoDetailVO> eventInfoList = new HashMap<>();
public void setEventInfoList(String index, EventInfoDetailVO eventInfoList) {
EventInfoDetailVO tmp = eventInfoList == null ? new EventInfoDetailVO() : eventInfoList;
this.eventInfoList.put(index, tmp);
}
public void setEventDetailEigenvalue(String index, List<EventEigDetail> eventDetailEigenvalue) {
List<EventEigDetail> tmp = eventDetailEigenvalue == null ? new ArrayList<>() : eventDetailEigenvalue;
this.eventDetailEigenvalue.put(index, tmp);
}
public XWPFDocument getDocument() {
return document;
}
public WordUtil() {
this.document = new XWPFDocument();
}
public void translateShun(String index, String strShunPic) {
BASE64Decoder decoder = new BASE64Decoder();
List<byte[]> tmp = new ArrayList<>();
try {
byte[] buffer = decoder.decodeBuffer(strShunPic);
tmp.add(buffer);
} catch (Exception e) {
}
listShunPic.put(index, tmp);
}
public void translateRms(String index, String strRmsPic) {
BASE64Decoder decoder = new BASE64Decoder();
List<byte[]> tmp = new ArrayList<>();
try {
byte[] buffer = decoder.decodeBuffer(strRmsPic);
tmp.add(buffer);
} catch (Exception e) {
}
listRmsPic.put(index, tmp);
}
public void createReport(List<String> eventIndex) throws IOException, InvalidFormatException {
setHeadingStyle(this.document);
// 添加标题
XWPFParagraph titleParagraph = getCenterParagraph(this.document);
addLine(titleParagraph, 11);
// 设置段落居中
XWPFRun titleParagraphBigRun = titleParagraph.createRun();
addParagraph(titleParagraphBigRun, "宋体", 28, "000000", "暂降事件报告", true);
addLine(titleParagraph, 17);
XWPFRun titleParagraphDateRun = titleParagraph.createRun();
addParagraph(titleParagraphDateRun, "宋体", 16, "000000", "南京灿能电力自动化股份有限公司", false);
addLine(titleParagraph, 1);
titleParagraphDateRun = titleParagraph.createRun();
addParagraph(titleParagraphDateRun, "宋体", 14, "000000", "生成时间:" + getRightNow(), false);
addLine(titleParagraph, 8);
titleParagraph = getLeftParagraph(this.document);
titleParagraphDateRun = titleParagraph.createRun();
addParagraph(titleParagraphDateRun, "宋体", 10, "000000", "【申明】本公司保留对报告的修改权,恕不另行通知,敬请关注最新版本。", false);
for (int m = 0; m < eventIndex.size(); m++) {
String eventId = eventIndex.get(m);
List<EventEigDetail> eventDetailEigenvaluetmp = this.eventDetailEigenvalue.get(eventId);
String time = eventInfoList.get(eventId).getTimeID().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
createTitle(document, (m + 1) + ". " + time, "标题 1", 0, 20);
createTitle(document, (m + 1) + "." + "1. 基本信息", "标题 2", 0, 15);
XWPFParagraph introductionContentParagraph = getLeftParagraph(document);
introductionContentParagraph.setIndentationFirstLine(200);
XWPFRun introductionContentRun = introductionContentParagraph.createRun();
addParagraph(introductionContentRun, "宋体", 11, "000000", eventInfoList.get(eventId).getGdName() + "" + eventInfoList.get(eventId).getBdzName() + ",网络参数:" + eventInfoList.get(eventId).getIp() + "" + eventInfoList.get(eventId).getLineName() + "" + time + "发生暂降事件,特征幅值:" + (eventInfoList.get(eventId).getEventValue()) + "%,持续时间:" + eventInfoList.get(eventId).getPersistTime() + "s。", false);
createTitle(document, (m + 1) + "." + "2. 波形图", "标题 2", 0, 15);
createTitle(document, (m + 1) + "." + "2.1 瞬时波形图", "标题 3", 200, 11);
for (int shun = 0; shun < listShunPic.get(eventId).size(); shun++) {
createPic(document, "瞬时波形" + (shun), listShunPic.get(eventId).get(shun));
}
createTitle(document, (m + 1) + "." + "2.2 RMS波形图", "标题 3", 200, 11);
for (int rms = 0; rms < listRmsPic.get(eventId).size(); rms++) {
createPic(document, "RMS波形" + (eventId), listRmsPic.get(eventId).get(rms));
}
createTitle(document, (m + 1) + "." + "3. 多特征值", "标题 2", 0, 15);
XWPFParagraph value = getLeftParagraph(document);
XWPFRun valuex = value.createRun();
addParagraph(valuex, "宋体", 11, "000000", "事件总分段数:" + eventDetailEigenvaluetmp.size(), false);
addLine(value, 1);
if (eventDetailEigenvaluetmp.size() == 0) {
continue;
}
valuex = value.createRun();
addParagraph(valuex, "宋体", 11, "000000", "暂降原因:" + eventDetailEigenvaluetmp.get(0).getSagReason(), false);
addLine(value, 1);
for (int i = 0; i < eventDetailEigenvaluetmp.size(); i++) {
valuex = value.createRun();
addParagraph(valuex, "宋体", 11, "000000", "分段" + (i + 1) + "多特征值", true);
addLine(value, 1);
valuex = value.createRun();
addParagraph(valuex, "宋体", 11, "000000", "波形起始点相位(°)" + (eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "A" : "AB") + "" + eventDetailEigenvaluetmp.get(i).getPow_a() + " " + (eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "B" : "BC") + "" + eventDetailEigenvaluetmp.get(i).getPow_b() + " " + ((eventDetailEigenvaluetmp.get(0).getPttype() == 2) ? "" : ((eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "C" : "CA") + "" + eventDetailEigenvaluetmp.get(i).getPow_c())), false);
addLine(value, 1);
valuex = value.createRun();
addParagraph(valuex, "宋体", 11, "000000", "跳变段电压变化率(V/ms)" + (eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "A" : "AB") + "" + eventDetailEigenvaluetmp.get(i).getVoltagechange_Va() + " " + (eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "B" : "BC") + "" + eventDetailEigenvaluetmp.get(i).getVoltagechange_Vb() + " " + ((eventDetailEigenvaluetmp.get(0).getPttype() == 2) ? "" : ((eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "C" : "CA") + "" + eventDetailEigenvaluetmp.get(i).getVoltagechange_Vc())), false);
addLine(value, 1);
valuex = value.createRun();
addParagraph(valuex, "宋体", 11, "000000", "相位跳变(°)" + (eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "A" : "AB") + "" + eventDetailEigenvaluetmp.get(i).getAngle_diff_ap() + " " + (eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "B" : "BC") + "" + eventDetailEigenvaluetmp.get(i).getAngle_diff_bp() + " " + ((eventDetailEigenvaluetmp.get(0).getPttype() == 2) ? "" : ((eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "C" : "CA") + "" + eventDetailEigenvaluetmp.get(i).getAngle_diff_cp())), false);
/*
* addLine(value, 1); valuex = value.createRun();
* addParagraph(valuex, "宋体", 11, "000000", "特征幅值(V)A相" +
* this.eventDetailEigenvalue.get(i).getUa_min() + " B相" +
* this.eventDetailEigenvalue.get(i).getUb_min() + " C相" +
* this.eventDetailEigenvalue.get(i).getUc_min(), false);
*/
/*
* addLine(value, 1); valuex = value.createRun();
* addParagraph(valuex, "宋体", 11, "000000", "持续时间(ms)" +
* this.eventDetailEigenvalue.get(i).getHold_time_dq(), false);
*/
addLine(value, 1);
valuex = value.createRun();
addParagraph(valuex, "宋体", 11, "000000", "不平衡度(%)" + eventDetailEigenvaluetmp.get(i).getBph_max_value(), false);
addLine(value, 1);
valuex = value.createRun();
addParagraph(valuex, "宋体", 11, "000000", "暂降类型:" + eventDetailEigenvaluetmp.get(i).getSagType(), false);
addLine(value, 1);
}
addLine(value, 1);
}
System.out.println("11");
}
public void createPic(XWPFDocument document, String name, byte[] base64Info) throws IOException, InvalidFormatException {
XWPFParagraph picParagraph = getCenterParagraph(document);
XWPFRun createRun = picParagraph.createRun();
InputStream in = new ByteArrayInputStream(base64Info);
createRun.addPicture(in, 5, name, Units.toEMU(410), Units.toEMU(170));
}
public void createTitle(XWPFDocument document, String message, String style, int line, int fontSize) {
XWPFParagraph summaeTableParagraph = getLeftParagraph(document);
summaeTableParagraph.setStyle(style);
summaeTableParagraph.setIndentationFirstLine(line);
XWPFRun summaeTableRun = summaeTableParagraph.createRun();
addParagraph(summaeTableRun, "宋体", fontSize, "000000", message, false);
}
public void setParagraphStyle(XWPFParagraph paragraph) {
paragraph.setSpacingBefore(100);
paragraph.setSpacingAfter(100);
}
/**
* 返回指定格式的段落 居中型
*
* @param document 文档对象
*/
public XWPFParagraph getCenterParagraph(XWPFDocument document) {
XWPFParagraph paragraph = document.createParagraph();
setParagraphStyle(paragraph);
paragraph.setAlignment(ParagraphAlignment.CENTER);
paragraph.setVerticalAlignment(TextAlignment.CENTER);
return paragraph;
}
/**
* 返回指定格式的段落 居左型
*
* @param document 文档对象
*/
public XWPFParagraph getLeftParagraph(XWPFDocument document) {
XWPFParagraph paragraph = document.createParagraph();
setParagraphStyle(paragraph);
paragraph.setAlignment(ParagraphAlignment.LEFT);
return paragraph;
}
/**
* 添加换行符
*
* @param paragraph 指定段落
* @param amount 行数
*/
public void addLine(XWPFParagraph paragraph, Integer amount) {
XWPFRun run = paragraph.createRun();
run.setFontSize(11);
for (int i = 0; i < amount; i++) {
run.addCarriageReturn();
}
}
/**
* 添加段落文本
*
* @param run 文本执行对象
* @param fontFamily 字体类型
* @param fontSize 字体大小
* @param backgroundColor 字体颜色
* @param bold 是否加粗
*/
public void addParagraph(XWPFRun run, String fontFamily, Integer fontSize, String backgroundColor, String message, boolean bold) {
run.setText(message);
run.setColor(backgroundColor);
run.setFontSize(fontSize);
run.setFontFamily(fontFamily);
run.setBold(bold);
}
/**
* 增加自定义标题样式。这里用的是stackoverflow的源码
*
* @param docxDocument 目标文档
* @param strStyleId 样式名称
* @param headingLevel 样式级别
*/
public void addCustomHeadingStyle(XWPFDocument docxDocument, String strStyleId, int headingLevel) {
CTStyle ctStyle = CTStyle.Factory.newInstance();
ctStyle.setStyleId(strStyleId);
CTString styleName = CTString.Factory.newInstance();
styleName.setVal(strStyleId);
ctStyle.setName(styleName);
CTDecimalNumber indentNumber = CTDecimalNumber.Factory.newInstance();
indentNumber.setVal(BigInteger.valueOf(headingLevel));
// lower number > style is more prominent in the formats bar
ctStyle.setUiPriority(indentNumber);
CTOnOff onoffnull = CTOnOff.Factory.newInstance();
ctStyle.setUnhideWhenUsed(onoffnull);
// style shows up in the formats bar
ctStyle.setQFormat(onoffnull);
// style defines a heading of the given level
CTPPr ppr = CTPPr.Factory.newInstance();
ppr.setOutlineLvl(indentNumber);
ctStyle.setPPr(ppr);
XWPFStyle style = new XWPFStyle(ctStyle);
// is a null op if already defined
XWPFStyles styles = docxDocument.createStyles();
style.setType(STStyleType.PARAGRAPH);
styles.addStyle(style);
}
/**
* 设置文档中标题格式
*/
public void setHeadingStyle(XWPFDocument document) {
addCustomHeadingStyle(document, "标题 1", 1);
addCustomHeadingStyle(document, "标题 2", 2);
addCustomHeadingStyle(document, "标题 3", 3);
addCustomHeadingStyle(document, "标题 4", 4);
addCustomHeadingStyle(document, "标题 5", 5);
addCustomHeadingStyle(document, "标题 6", 6);
addCustomHeadingStyle(document, "标题 7", 7);
}
/**
* 给表格添加一行数据
*
* @param paragraph 段落对象
* @param row 行对象
* @param data 不定长度的数据
*/
public void setExcelContent(XWPFParagraph paragraph, XWPFTableRow row, String... data) {
for (int i = 0; i < data.length; i++) {
XWPFRun run = paragraph.createRun();
run.setFontFamily("宋体");
run.setText(data[i]);
row.getCell(i).setParagraph(paragraph);
paragraph.removeRun(0);
}
}
/**
* 添加表头标题一行数据
*
* @param paragraph 段落对象
* @param row 行对象
* @param data 不定长度的数据
*/
public void setExcelHeadContent(XWPFParagraph paragraph, XWPFTableRow row, String... data) {
XWPFRun run = paragraph.createRun();
run.setFontFamily("宋体");
run.setBold(true);
run.setText(data[0]);
row.getCell(0).setParagraph(paragraph);
paragraph.removeRun(0);
for (int i = 1; i < data.length; i++) {
XWPFRun run1 = paragraph.createRun();
run1.setFontFamily("宋体");
run1.setBold(true);
run1.setText(data[i]);
row.addNewTableCell().setParagraph(paragraph);
paragraph.removeRun(0);
}
}
/**
* 获取当前的日期
*
* @return
*/
public String getRightNow() {
Calendar rightNow = Calendar.getInstance();
Integer year = rightNow.get(Calendar.YEAR);
Integer month = rightNow.get(Calendar.MONTH) + 1;
Integer day = rightNow.get(rightNow.DAY_OF_MONTH);
return year + "" + month + "" + day + "";
}
}

View File

@@ -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;
}
}

View File

@@ -34,4 +34,6 @@ public class ExcelRptTemp extends BaseEntity {
private Integer sort;
private String wiringMethod;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -125,6 +125,6 @@ public class ExportModelController extends BaseController {
monitorHarmonicReportService.exportWorld(response,startTime,endTime,type,lineIndex,name,reportNumber,crmName,isUrl,file, harmLineDetailDataCommDTO,overLimitInfoCommDTO,deviceUnitCommDTO);
monitorHarmonicReportService.exportWorld(response,startTime,endTime,type,lineIndex,name,reportNumber,crmName,isUrl,file, harmLineDetailDataCommDTO,overLimitInfoCommDTO,deviceUnitCommDTO,null);
}
}

View File

@@ -212,7 +212,7 @@ public class GridServiceImpl implements IGridService {
if (param.getAreaType() == 0) {
AssessVo.AssessTrendVo vo = new AssessVo.AssessTrendVo();
vo.setDeptId(param.getDeptIndex());
vo.setDeptName("冀北");
vo.setDeptName(deptFeignClient.getDeptById(param.getDeptIndex()).getData().getName());
List<AssessVo> children = new ArrayList<>();
map.forEach((k1, v1) -> {
AssessVo assessVo = new AssessVo();

View File

@@ -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 = "http://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 = "http://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 = "http://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);

View File

@@ -392,7 +392,7 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
eq("DATE_FORMAT( data_date ,'%Y-%m-%d')", searchBeginTime);
RStatPollutionSubstationYPO rStatPollutionSubstationYPO = pollutionSubstationYPOMapper.selectOne(wrapper);
Optional.ofNullable(rStatPollutionSubstationYPO).ifPresent(t -> pollutionsubVO.setData(t.getValue()));
Optional.ofNullable(rStatPollutionSubstationYPO).ifPresent(a -> pollutionsubVO.setData(BigDecimal.valueOf(a.getValue()).setScale(2, RoundingMode.UP).doubleValue()));
} else if (Objects.equals(harmonicPublicParam.getReportFlag(), BizParamConstant.STAT_BIZ_QUARTER)) {
QueryWrapper<RStatPollutionSubstationQPO> wrapper = new QueryWrapper<>();
wrapper.eq("substation_id", id).
@@ -400,7 +400,7 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
eq("DATE_FORMAT( data_date ,'%Y-%m-%d')", searchBeginTime);
RStatPollutionSubstationQPO rStatPollutionSubstationQPO = pollutionSubstationQPOMapper.selectOne(wrapper);
Optional.ofNullable(rStatPollutionSubstationQPO).ifPresent(t -> pollutionsubVO.setData(t.getValue()));
Optional.ofNullable(rStatPollutionSubstationQPO).ifPresent(a -> pollutionsubVO.setData(BigDecimal.valueOf(a.getValue()).setScale(2, RoundingMode.UP).doubleValue()));
} else if (Objects.equals(harmonicPublicParam.getReportFlag(), BizParamConstant.STAT_BIZ_MONTH)) {
QueryWrapper<RStatPollutionSubstationM> wrapper = new QueryWrapper<>();
wrapper.eq("substation_id", id).
@@ -408,7 +408,7 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
eq("DATE_FORMAT( data_date ,'%Y-%m-%d')", searchBeginTime);
RStatPollutionSubstationM rStatPollutionSubstationM = pollutionSubstationMMapper.selectOne(wrapper);
Optional.ofNullable(rStatPollutionSubstationM).ifPresent(t -> pollutionsubVO.setData(t.getValue()));
Optional.ofNullable(rStatPollutionSubstationM).ifPresent(a -> pollutionsubVO.setData(BigDecimal.valueOf(a.getValue()).setScale(2, RoundingMode.UP).doubleValue()));
} else if (Objects.equals(harmonicPublicParam.getReportFlag(), BizParamConstant.STAT_BIZ_DAY)) {
QueryWrapper<RStatPollutionSubstationDPO> wrapper = new QueryWrapper<>();
@@ -417,7 +417,7 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
eq("DATE_FORMAT( data_date ,'%Y-%m-%d')", searchBeginTime);
RStatPollutionSubstationDPO rStatPollutionSubstationDPO = pollutionSubstationDPOMapper.selectOne(wrapper);
Optional.ofNullable(rStatPollutionSubstationDPO).ifPresent(t -> pollutionsubVO.setData(t.getValue()));
Optional.ofNullable(rStatPollutionSubstationDPO).ifPresent(a -> pollutionsubVO.setData(BigDecimal.valueOf(a.getValue()).setScale(2, RoundingMode.UP).doubleValue()));
} else if (Objects.equals(harmonicPublicParam.getReportFlag(), BizParamConstant.STAT_BIZ_WEEK)) {
QueryWrapper<RStatPollutionSubstationDPO> wrapper = new QueryWrapper<>();
wrapper.eq("substation_id", id).
@@ -425,7 +425,7 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
between("DATE_FORMAT( data_date ,'%Y-%m-%d')", searchBeginTime, searchEndTime)
.orderByDesc("value").last(" limit 1");
RStatPollutionSubstationDPO rStatPollutionSubstationDPO = pollutionSubstationDPOMapper.selectOne(wrapper);
Optional.ofNullable(rStatPollutionSubstationDPO).ifPresent(t -> pollutionsubVO.setData(t.getValue()));
Optional.ofNullable(rStatPollutionSubstationDPO).ifPresent(a -> pollutionsubVO.setData(BigDecimal.valueOf(a.getValue()).setScale(2, RoundingMode.UP).doubleValue()));
}
}

View File

@@ -194,7 +194,7 @@ public class QualifiedReportServiceImpl implements QualifiedReportService {
//计算组装谐波含电压有率
int flagV = 0;
for (int i = HARMONIC_START; i < HARMONIC_END; i++) {
BigDecimal v = new BigDecimal(getUharmOvertime(i));
BigDecimal v = new BigDecimal(getUharmOvertime(i,map));
BigDecimal hegeRate = alltime.subtract(v).divide(alltime, 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
if (hegeRate.floatValue() < 95) {
content.append(String.valueOf(i)).append("次谐波电压含有率合格率").append(String.valueOf(hegeRate.floatValue())).append("%;");
@@ -206,7 +206,7 @@ public class QualifiedReportServiceImpl implements QualifiedReportService {
int flagI = 0;
for (int i = HARMONIC_START; i < HARMONIC_END; i++) {
String key = "IHARM_" + i + "_OVERTIME";
BigDecimal ih = new BigDecimal(getIharmOvertime(i));
BigDecimal ih = new BigDecimal(getIharmOvertime(i,map));
BigDecimal hegeRate = alltime.subtract(ih).divide(alltime, 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
if (hegeRate.floatValue() < 95) {
BigDecimal maxI = (BigDecimal) lineIhMap.get(key);
@@ -239,22 +239,22 @@ public class QualifiedReportServiceImpl implements QualifiedReportService {
}
public Integer getUharmOvertime(int harmonicOrder) {
public Integer getUharmOvertime(int harmonicOrder, RStatLimitTargetDPO map) {
try {
Field field = this.getClass().getDeclaredField("uharm" + harmonicOrder + "Overtime");
Field field = map.getClass().getDeclaredField("uharm" + harmonicOrder + "Overtime");
field.setAccessible(true);
return (Integer) field.get(this);
return (Integer) field.get(map);
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
return 0;
}
}
public Integer getIharmOvertime(int harmonicOrder) {
public Integer getIharmOvertime(int harmonicOrder, RStatLimitTargetDPO map) {
try {
Field field = this.getClass().getDeclaredField("iharm" + harmonicOrder + "Overtime");
Field field = map.getClass().getDeclaredField("iharm" + harmonicOrder + "Overtime");
field.setAccessible(true);
return (Integer) field.get(this);
return (Integer) field.get(map);
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
return 0;

View File

@@ -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);

View File

@@ -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> {
}

View File

@@ -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> {
}

View File

@@ -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>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.harmonic.rstatlimitrate.mapper.RStatDataVDMapper">
<mapper namespace="com.njcn.harmonic.common.mapper.RStatDataVDMapper">
<select id="getFreqDev" resultType="com.njcn.harmonic.pojo.po.RStatDataVD">
select

View File

@@ -31,4 +31,7 @@ public class ReportTemplateVO extends BaseEntity {
private String reportForm;
private String wiringMethod;
private Integer sort;
}

View File

@@ -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;
}

View File

@@ -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);
}

View File

@@ -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();
}

View File

@@ -25,5 +25,5 @@ public interface MonitorHarmonicReportService {
String crmName,
Boolean isUrl,
MultipartFile file,
HarmLineDetailDataCommDTO lineDto, OverLimitInfoCommDTO overLimitData, DeviceUnitCommDTO deviceUnit);
HarmLineDetailDataCommDTO lineDto, OverLimitInfoCommDTO overLimitData, DeviceUnitCommDTO deviceUnit, String dataLevel);
}

View File

@@ -14,19 +14,19 @@ import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONTokener;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.toolkit.SqlRunner;
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 +91,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 +147,26 @@ 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());
}
if (ObjectUtils.isNotNull(item.getHarmStart()) && ObjectUtils.isNotNull(item.getHarmEnd())) {
for (int i = item.getHarmStart(); i <= item.getHarmEnd() + 1; i++) {
tMap.put((item.getOtherName() + "_" + i + phase + item.getResourcesId()).toUpperCase(), item.getPrimaryFormula());
}
} else {
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 +196,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 +476,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 +515,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 +524,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 +532,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 +544,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 +552,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);
}

View File

@@ -14,15 +14,15 @@ import com.njcn.device.pms.api.MonitorClient;
import com.njcn.device.pms.pojo.po.Monitor;
import com.njcn.device.pq.api.DeviceUnitClient;
import com.njcn.harmonic.common.pojo.dto.DeviceUnitCommDTO;
import com.njcn.harmonic.common.pojo.dto.HarmLineDetailDataCommDTO;
import com.njcn.harmonic.common.pojo.dto.OverLimitInfoCommDTO;
import com.njcn.harmonic.common.service.MonitorCommReportService;
import com.njcn.harmonic.common.service.MonitorHarmonicReportService;
import com.njcn.harmonic.pojo.param.ReportQueryParam;
import com.njcn.harmonic.pojo.po.report.EnumPass;
import com.njcn.harmonic.pojo.po.report.Pass;
import com.njcn.harmonic.pojo.po.report.ReportTarget;
import com.njcn.harmonic.pojo.vo.ReportValue;
import com.njcn.harmonic.common.pojo.dto.HarmLineDetailDataCommDTO;
import com.njcn.harmonic.common.pojo.dto.OverLimitInfoCommDTO;
import com.njcn.harmonic.common.service.MonitorCommReportService;
import com.njcn.harmonic.common.service.MonitorHarmonicReportService;
import com.njcn.harmonic.utils.WordUtil2;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.api.ThemeFeignClient;
@@ -114,7 +114,7 @@ public class MonitorHarmonicReportServiceImpl implements MonitorHarmonicReportSe
String crmName,
Boolean isUrl,
MultipartFile file,
HarmLineDetailDataCommDTO lineDto, OverLimitInfoCommDTO overLimit, DeviceUnitCommDTO deviceUnit) {
HarmLineDetailDataCommDTO lineDto, OverLimitInfoCommDTO overLimit, DeviceUnitCommDTO deviceUnit, String dataLevel) {
//获取监测点信息
String bdname;
Integer pttype;
@@ -122,6 +122,12 @@ public class MonitorHarmonicReportServiceImpl implements MonitorHarmonicReportSe
String atype = "";
String btype = "";
String ctype = "";
//pt
Double pt = getData(lineDto.getPt());
//ct
Double ct = getData(lineDto.getCt());
if (type == 0) {
if (ObjectUtil.isNull(lineDto)) {
throw new BusinessException(CommonResponseEnum.NO_DATA);
@@ -263,14 +269,13 @@ public class MonitorHarmonicReportServiceImpl implements MonitorHarmonicReportSe
// 基波电压最大值
reportmap.put("$B" + "V0" + "X" + "_A$", judgeNull(voltage1.getFmaxValue()));
reportmap.put("$B" + "V0" + "X" + "_B$", judgeNull(voltage2.getFmaxValue()));
reportmap.put("$B" + "V0" + "X" + "_C$", judgeNull(voltage3.getFmaxValue()));
// 基波电流最大值
reportmap.put("$B" + "I0" + "X" + "_A$", judgeNull(current1.getFmaxValue()));
reportmap.put("$B" + "I0" + "X" + "_B$", judgeNull(current2.getFmaxValue()));
reportmap.put("$B" + "I0" + "X" + "_C$", judgeNull(current3.getFmaxValue()));
reportmap.put("$B" + "I0" + "X" + "_A$", dataConversion(current1.getFmaxValue(),dataLevel,ct,true));
reportmap.put("$B" + "I0" + "X" + "_B$", dataConversion(current2.getFmaxValue(),dataLevel,ct,true));
reportmap.put("$B" + "I0" + "X" + "_C$", dataConversion(current3.getFmaxValue(),dataLevel,ct,true));
/**************************************************************
**** 三张大表基础数据幅值
@@ -291,9 +296,9 @@ public class MonitorHarmonicReportServiceImpl implements MonitorHarmonicReportSe
reportmap.put("$B" + "V0" + "N" + "_C$", judgeNull(voltage3.getMinValue()));
// 基波电流最小值
reportmap.put("$B" + "I0" + "N" + "_A$", judgeNull(current1.getMinValue()));
reportmap.put("$B" + "I0" + "N" + "_B$", judgeNull(current2.getMinValue()));
reportmap.put("$B" + "I0" + "N" + "_C$", judgeNull(current3.getMinValue()));
reportmap.put("$B" + "I0" + "N" + "_A$", dataConversion(current1.getMinValue(),dataLevel,ct,true));
reportmap.put("$B" + "I0" + "N" + "_B$", dataConversion(current2.getMinValue(),dataLevel,ct,true));
reportmap.put("$B" + "I0" + "N" + "_C$", dataConversion(current3.getMinValue(),dataLevel,ct,true));
/**************************************************************
**** 三张大表基础数据幅值
@@ -314,9 +319,9 @@ public class MonitorHarmonicReportServiceImpl implements MonitorHarmonicReportSe
reportmap.put("$B" + "V0" + "E" + "_C$", judgeNull(voltage3.getMeanValue()));
// 基波电流平均值
reportmap.put("$B" + "I0" + "E" + "_A$", judgeNull(current1.getMeanValue()));
reportmap.put("$B" + "I0" + "E" + "_B$", judgeNull(current2.getMeanValue()));
reportmap.put("$B" + "I0" + "E" + "_C$", judgeNull(current3.getMeanValue()));
reportmap.put("$B" + "I0" + "E" + "_A$", dataConversion(current1.getMeanValue(),dataLevel,ct,true));
reportmap.put("$B" + "I0" + "E" + "_B$", dataConversion(current2.getMeanValue(),dataLevel,ct,true));
reportmap.put("$B" + "I0" + "E" + "_C$", dataConversion(current3.getMeanValue(),dataLevel,ct,true));
/**************************************************************
**** 三张大表基础数据幅值
@@ -337,9 +342,9 @@ public class MonitorHarmonicReportServiceImpl implements MonitorHarmonicReportSe
reportmap.put("$B" + "V0" + "%" + "_C$", judgeNull(voltage3.getCp95Value()));
// 基波电流cp95值
reportmap.put("$B" + "I0" + "%" + "_A$", judgeNull(current1.getCp95Value()));
reportmap.put("$B" + "I0" + "%" + "_B$", judgeNull(current2.getCp95Value()));
reportmap.put("$B" + "I0" + "%" + "_C$", judgeNull(current3.getCp95Value()));
reportmap.put("$B" + "I0" + "%" + "_A$", dataConversion(current1.getCp95Value(),dataLevel,ct,true));
reportmap.put("$B" + "I0" + "%" + "_B$", dataConversion(current2.getCp95Value(),dataLevel,ct,true));
reportmap.put("$B" + "I0" + "%" + "_C$", dataConversion(current3.getCp95Value(),dataLevel,ct,true));
/**************************************************************
**** 三张大表基础数据幅值
@@ -387,10 +392,10 @@ public class MonitorHarmonicReportServiceImpl implements MonitorHarmonicReportSe
Double vaveValue = Double.parseDouble(reportmap.get("$BV0E_" + tmpstrMap + "$").toString());
Double vcp95Value = Double.parseDouble(reportmap.get("$BV0%_" + tmpstrMap + "$").toString());
// 基波电流
Double imaxValue = Double.parseDouble(reportmap.get("$BI0X_" + tmpstrMap + "$").toString());
Double iminValue = Double.parseDouble(reportmap.get("$BI0N_" + tmpstrMap + "$").toString());
Double iaveValue = Double.parseDouble(reportmap.get("$BI0E_" + tmpstrMap + "$").toString());
Double icp95Value = Double.parseDouble(reportmap.get("$BI0%_" + tmpstrMap + "$").toString());
Double imaxValue = !Objects.equals("Secondary",dataLevel) ? Double.parseDouble(reportmap.get("$BI0X_" + tmpstrMap + "$").toString()):Double.parseDouble(reportmap.get("$BI0X_" + tmpstrMap + "$").toString())*ct;
Double iminValue = !Objects.equals("Secondary",dataLevel) ? Double.parseDouble(reportmap.get("$BI0N_" + tmpstrMap + "$").toString()):Double.parseDouble(reportmap.get("$BI0N_" + tmpstrMap + "$").toString())*ct;
Double iaveValue = !Objects.equals("Secondary",dataLevel) ? Double.parseDouble(reportmap.get("$BI0E_" + tmpstrMap + "$").toString()):Double.parseDouble(reportmap.get("$BI0E_" + tmpstrMap + "$").toString())*ct;
Double icp95Value = !Objects.equals("Secondary",dataLevel) ? Double.parseDouble(reportmap.get("$BI0%_" + tmpstrMap + "$").toString()):Double.parseDouble(reportmap.get("$BI0%_" + tmpstrMap + "$").toString())*ct;
if (!(vmaxValue >= vminValue && vmaxValue >= vaveValue && vmaxValue >= vcp95Value)) {
strBaseVIResult += "注意:从上表中可以看出" + strLineBaseName
@@ -1222,9 +1227,12 @@ public class MonitorHarmonicReportServiceImpl implements MonitorHarmonicReportSe
String strCurrent = strMap + (i + 1) + "%";
// 谐波电流幅值
strCurrentA = judgeNull(this.listICurrent.get(i).getList().get(0).getCp95Value());
strCurrentB = judgeNull(this.listICurrent.get(i).getList().get(1).getCp95Value());
strCurrentC = judgeNull(this.listICurrent.get(i).getList().get(2).getCp95Value());
// strCurrentA = judgeNull(this.listICurrent.get(i).getList().get(0).getCp95Value());
// strCurrentB = judgeNull(this.listICurrent.get(i).getList().get(1).getCp95Value());
// strCurrentC = judgeNull(this.listICurrent.get(i).getList().get(2).getCp95Value());
strCurrentA = dataConversion(this.listICurrent.get(i).getList().get(0).getCp95Value(),dataLevel,ct,true);
strCurrentB = dataConversion(this.listICurrent.get(i).getList().get(1).getCp95Value(),dataLevel,ct,true);
strCurrentC = dataConversion(this.listICurrent.get(i).getList().get(2).getCp95Value(),dataLevel,ct,true);
strLimit = judgeNull(this.listICurrent.get(i).getOverLimit());
reportmap.put(strCurrent + "_A$", strCurrentA);
@@ -1253,9 +1261,9 @@ public class MonitorHarmonicReportServiceImpl implements MonitorHarmonicReportSe
reportmap.put("$CI" + (i + 1) + "L$", strLimit);
try {
maxValue = Double.parseDouble(strCurrentA);
minValue = Double.parseDouble(strCurrentB);
aveValue = Double.parseDouble(strCurrentC);
maxValue = Objects.equals("Secondary",dataLevel) ? Double.parseDouble(strCurrentA)*ct : Double.parseDouble(strCurrentA);
minValue = Objects.equals("Secondary",dataLevel) ? Double.parseDouble(strCurrentB)*ct : Double.parseDouble(strCurrentB);
aveValue = Objects.equals("Secondary",dataLevel) ? Double.parseDouble(strCurrentC)*ct : Double.parseDouble(strCurrentC);;
limit = Double.parseDouble(strLimit);
} catch (Exception e) {
strResultCurrentValue += "注意:从上表中可以看出" + strLineBaseName +(i + 1)+ "次谐波电流幅值95%概率值数据存在异常(不是数值类型)。\r\n";
@@ -1380,6 +1388,26 @@ public class MonitorHarmonicReportServiceImpl implements MonitorHarmonicReportSe
}
}
public Double getData(String data) {
double ratio = 1.0;
if (Objects.isNull(data) || data.isEmpty()) {
return ratio;
}
String[] parts = data.split("/");
if (parts.length == 2) {
try {
Double num1 = Double.parseDouble(parts[0]);
Double num2 = Double.parseDouble(parts[1]);
ratio = num1 / num2;
} catch (NumberFormatException var7) {
System.out.println("字符串格式错误");
}
} else {
ratio = Double.parseDouble(parts[0]);
}
return ratio;
}
/**
* 数据单位信息 重组
*
@@ -1722,6 +1750,22 @@ public class MonitorHarmonicReportServiceImpl implements MonitorHarmonicReportSe
return (result == null) ? "/" : result.toString();
}
public String dataConversion(Float result, String dataLevel, Double ratio, Boolean isI) {
if (result == null) {
return "/";
}
if (!"Secondary".equals(dataLevel)) {
return String.valueOf(result);
}
double conversionRatio = (ratio != null) ? ratio : 1.0;
double convertedValue = result * conversionRatio;
if (isI != null && Boolean.TRUE.equals(isI)) {
return String.format("%.2f", convertedValue);
} else {
return String.format("%.2f", convertedValue / 1000.0);
}
}
/**
* 谐波电流限值
*

View File

@@ -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;
}
}

View File

@@ -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());
}
}

View File

@@ -1,5 +1,6 @@
package com.njcn.prepare.harmonic.service.mysql.Impl.line;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
@@ -26,6 +27,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
/**
@@ -1851,10 +1853,12 @@ public class DayDataServiceImpl implements DayDataService {
.groupBy(DataPlt::getLineId, DataPlt::getPhaseType, DataPlt::getQualityFlag, DataPlt::getValueType)
.between(DataPlt::getTime, startTime, endTime);
List<DataPlt> result1 = dataPltMapper.getStatisticsByWraper(influxQueryWrapper);
result1.forEach(item -> {
item.setValueType(InfluxDbSqlConstant.MIN);
});
result.addAll(result1);
if(CollUtil.isNotEmpty(result1)){
result1.sort(Comparator.comparing(DataPlt::getPlt));
DataPlt dataPlt = result1.get(0);
dataPlt.setValueType(InfluxDbSqlConstant.MIN);
result.add(dataPlt);
}
//最大值
InfluxQueryWrapper influxQueryWrapper2 = new InfluxQueryWrapper(DataPlt.class);
influxQueryWrapper2.regular(DataPlt::getLineId, lineIndex)
@@ -1862,10 +1866,13 @@ public class DayDataServiceImpl implements DayDataService {
.groupBy(DataPlt::getLineId, DataPlt::getPhaseType, DataPlt::getQualityFlag, DataPlt::getValueType)
.between(DataPlt::getTime, startTime, endTime);
List<DataPlt> result2 = dataPltMapper.getStatisticsByWraper(influxQueryWrapper2);
result2.forEach(item -> {
item.setValueType(InfluxDbSqlConstant.MAX);
});
result.addAll(result2);
if(CollUtil.isNotEmpty(result2)){
result2.sort(Comparator.comparing(DataPlt::getPlt).reversed());
DataPlt dataPlt = result2.get(0);
dataPlt.setValueType(InfluxDbSqlConstant.MAX);
result.add(dataPlt);
}
//平均值
InfluxQueryWrapper influxQueryWrapper3 = new InfluxQueryWrapper(DataPlt.class);
influxQueryWrapper3.regular(DataPlt::getLineId, lineIndex)
@@ -1873,10 +1880,14 @@ public class DayDataServiceImpl implements DayDataService {
.groupBy(DataPlt::getLineId, DataPlt::getPhaseType, DataPlt::getQualityFlag, DataPlt::getValueType)
.between(DataPlt::getTime, startTime, endTime);
List<DataPlt> result3 = dataPltMapper.getStatisticsByWraper(influxQueryWrapper3);
result3.forEach(item -> {
item.setValueType(InfluxDbSqlConstant.AVG_WEB);
});
result.addAll(result3);
if(CollUtil.isNotEmpty(result3)){
double asDouble = result3.stream().mapToDouble(DataPlt::getPlt).average().getAsDouble();
DataPlt dataPlt = result3.get(0);
dataPlt.setValueType(InfluxDbSqlConstant.AVG_WEB);
dataPlt.setPlt(asDouble);
result.add(dataPlt);
}
//CP95(取平均值的CP95值)
InfluxQueryWrapper influxQueryWrapper4 = new InfluxQueryWrapper(DataPlt.class);
influxQueryWrapper4.regular(DataPlt::getLineId, lineIndex)
@@ -1884,10 +1895,12 @@ public class DayDataServiceImpl implements DayDataService {
.groupBy(DataPlt::getLineId, DataPlt::getPhaseType, DataPlt::getQualityFlag, DataPlt::getValueType)
.between(DataPlt::getTime, startTime, endTime);
List<DataPlt> result4 = dataPltMapper.getStatisticsByWraper(influxQueryWrapper4);
result4.forEach(item -> {
item.setValueType(InfluxDbSqlConstant.CP95);
});
result.addAll(result4);
if(CollUtil.isNotEmpty(result4)){
result4.sort(Comparator.comparing(DataPlt::getPlt).reversed());
DataPlt dataPlt = result4.get(0);
dataPlt.setValueType(InfluxDbSqlConstant.CP95);
result.add(dataPlt);
}
return result;
}

View File

@@ -34,7 +34,7 @@ public class PqFrontLogsChild extends BaseEntity {
@TableField(value = "grade")
private String grade;
@TableField(value = "`state`")
@TableField(value = "state")
private Integer state;
}

View File

@@ -30,5 +30,6 @@
<where>
${ew.sqlSegment}
</where>
order by A.sort asc
</select>
</mapper>

View File

@@ -15,6 +15,6 @@
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, main_id, log, `state`, create_by, create_time, update_by, update_time
id, main_id, log, state, create_by, create_time, update_by, update_time
</sql>
</mapper>

View File

@@ -131,7 +131,8 @@ public class EventDictServiceImpl extends ServiceImpl<EventDictMapper, ReportDic
queryWrapper.eq("report_dict.state", DataStateEnum.ENABLE.getCode()).eq("report_dict.Type",dictQueryParam.getType());
List<ReportDict> reportAllDicts = this.baseMapper.selectList(queryWrapper);
List<ReportDict> reportDicts = new ArrayList<>();
reportAllDicts.stream().filter(reportDict -> reportDict.getId().equals(dictQueryParam.getId())).forEach(reportDict -> {
List<ReportDict> rootList = reportAllDicts.stream().filter(reportDict -> Objects.equals(reportDict.getPid(),"0")).collect(Collectors.toList());
rootList.forEach(reportDict -> {
reportDicts.add(reportDict);
getChild(reportDicts, reportDict, reportAllDicts);
});

View File

@@ -71,10 +71,10 @@ public class PqDashboardPageServiceImpl extends ServiceImpl<PqDashboardPageMappe
if (Objects.nonNull(param.getSearchBeginTime()) && Objects.nonNull(param.getSearchEndTime())) {
queryWrapper.between("A.Create_Time", param.getSearchBeginTime(), param.getSearchEndTime());
}
if(Objects.nonNull(param.getPageName())){
queryWrapper.like("A.page_name",param.getPageName());
if(Objects.nonNull(param.getSearchValue())){
queryWrapper.like("A.page_name",param.getSearchValue());
}
queryWrapper.orderByAsc("A.sort");
// queryWrapper.orderByAsc("A.sort");
return this.baseMapper.page(new Page<>(PageFactory.getPageNum(param), PageFactory.getPageSize(param)), queryWrapper);
}

View File

@@ -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";
}

View File

@@ -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参数";

View File

@@ -0,0 +1,37 @@
package com.njcn.user.pojo.param;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
/**
* Description:
* Date: 2024/7/11 18:04【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Data
@ApiModel
public class AuthClientParam {
@ApiModelProperty(name = "sessionTime",value = "*会话超时时间(分钟)")
@NotNull(message = "会话超时时间(分钟)不可为空")
@Range(min = 1,max = 1440000,message = "会话超时时间(分钟)超范围")
private Integer accessTokenValidity;
@ApiModelProperty(name = "sessionRefreshTime",value = "*会话刷新时间(分钟)")
@NotNull(message = "会话刷新时间(分钟)不可为空")
@Range(min = 1,max = 1440000,message = "会话刷新时间(分钟)超范围")
private Integer refreshTokenValidity;
}

View File

@@ -29,15 +29,15 @@ public class PassWordRuleParam {
@Range(min = 5,max = 60,message = "自动解锁(分钟)超范围")
private Integer releaseTime;
@ApiModelProperty(name = "sessionTime",value = "*会话超时时间(分钟)")
@NotNull(message = "会话超时时间(分钟)不可为空")
@Range(min = 1,max = 1440000,message = "会话超时时间(分钟)超范围")
private Integer sessionTime;
@ApiModelProperty(name = "sessionRefreshTime",value = "*会话刷新时间(分钟)")
@NotNull(message = "会话刷新时间(分钟)不可为空")
@Range(min = 1,max = 1440000,message = "会话刷新时间(分钟)超范围")
private Integer sessionRefreshTime;
// @ApiModelProperty(name = "sessionTime",value = "*会话超时时间(分钟)")
// @NotNull(message = "会话超时时间(分钟)不可为空")
// @Range(min = 1,max = 1440000,message = "会话超时时间(分钟)超范围")
// private Integer sessionTime;
//
// @ApiModelProperty(name = "sessionRefreshTime",value = "*会话刷新时间(分钟)")
// @NotNull(message = "会话刷新时间(分钟)不可为空")
// @Range(min = 1,max = 1440000,message = "会话刷新时间(分钟)超范围")
// private Integer sessionRefreshTime;
@ApiModelProperty(name = "passwordExpirationDays",value = "密码有效期")
@NotNull(message = "密码有效期不可为空")
@@ -57,13 +57,24 @@ public class PassWordRuleParam {
//@NotNull(message = "密码大小写混合校验不可为空")
private Integer mixedCaseCheckFlag;*/
@ApiModelProperty(name = "maxUseUser",value = "大于0" )
@ApiModelProperty(name = "maxUseUser",value = "最大并发用户" )
@NotNull(message = "最大并发用户不可为空")
@Range(min = 10,max = 99,message = "最大并发用户超范围")
private Integer maxUseUser;
@NotNull(message = "账号长时间未登录休眠期(天)")
@ApiModelProperty(name = "maxUseUser",value = "验证密码错误次数" )
@NotNull(message = "验证密码错误次数时间范围不可为空")
@Range(min = 10,max = 99,message = "最大并发用户超范围")
private Integer lockPwdCheck;
@NotNull(message = "账号长时间未登录休眠期(天)不可为空")
@Range(min = 1,max = 180,message = "账号长时间未登录休眠期(天)超范围")
private Integer sleepDay;
@NotNull(message = "用户注销时间(天)不可为空")
@Range(min = 1,max = 360,message = "用户注销(天)超范围")
private Integer logoutDay;
//类型0-临时用户 1-正常用户)
@NotNull(message = "用户类型不可为空")
private Integer type;
}

View File

@@ -9,6 +9,8 @@ import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.common.utils.LogUtil;
import com.njcn.user.enums.UserResponseEnum;
import com.njcn.user.pojo.param.AuthClientParam;
import com.njcn.user.pojo.param.PassWordRuleParam;
import com.njcn.user.pojo.po.AuthClient;
import com.njcn.user.service.IAuthClientService;
import io.swagger.annotations.Api;
@@ -17,11 +19,8 @@ import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;
import com.njcn.web.controller.BaseController;
import java.util.Objects;
@@ -57,5 +56,15 @@ public class AuthClientController extends BaseController {
}
}
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
@ApiOperation("客户端会话配置更新")
@RequestMapping(value = "/sessionConfigUpdate", method = RequestMethod.POST)
public HttpResult<Boolean> sessionConfigUpdate(@RequestBody @Validated AuthClientParam authClientParam) {
String methodDescribe = getMethodDescribe("sessionConfigUpdate");
Boolean flag = authClientService.sessionConfigUpdate(authClientParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
}
}

View File

@@ -19,6 +19,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* Description:
* Date: 2024/7/11 18:01【需求编号】
@@ -34,6 +36,8 @@ import org.springframework.web.bind.annotation.RestController;
@AllArgsConstructor
public class PassWordRuleController extends BaseController {
private final IPassWordRuleService passWordRuleService;
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
@ApiOperation("密码规则修改")
@RequestMapping(value = "/ruleUpdate", method = RequestMethod.POST)
@@ -64,6 +68,16 @@ public class PassWordRuleController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, userStrategy, methodDescribe);
}
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
@ApiOperation("获取用户策略列表")
@RequestMapping(value = "/getUserStrategyList", method = RequestMethod.POST)
public HttpResult<List<PassWordRuleParam>> getUserStrategyList() {
String methodDescribe = getMethodDescribe("getUserStrategyList");
List<PassWordRuleParam> userStrategys = passWordRuleService.getUserStrategyList();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, userStrategys, methodDescribe);
}
@OperateInfo(info = LogEnum.SYSTEM_SERIOUS)
@ApiOperation("解锁超级管理员")

View File

@@ -1,6 +1,7 @@
package com.njcn.user.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.user.pojo.param.AuthClientParam;
import com.njcn.user.pojo.po.AuthClient;
/**
@@ -19,4 +20,6 @@ public interface IAuthClientService extends IService<AuthClient> {
* @return .
*/
AuthClient getAuthClientByName(String clientName);
Boolean sessionConfigUpdate(AuthClientParam authClientParam);
}

View File

@@ -3,6 +3,8 @@ package com.njcn.user.service;
import com.njcn.user.pojo.param.PassWordRuleParam;
import com.njcn.user.pojo.po.UserStrategy;
import java.util.List;
/**
* Description:
* Date: 2024/7/11 18:06【需求编号】
@@ -18,4 +20,6 @@ public interface IPassWordRuleService {
Boolean unlockRoot();
UserStrategy getUserStrategy();
List<PassWordRuleParam> getUserStrategyList();
}

View File

@@ -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);
}
}

Some files were not shown because too many files have changed in this diff Show More