Compare commits
17 Commits
2026-01
...
9d9150e418
| Author | SHA1 | Date | |
|---|---|---|---|
| 9d9150e418 | |||
| ee1ca85a5d | |||
|
|
2c3c716607 | ||
|
|
e1d17c63a2 | ||
|
|
6234ac8ce9 | ||
| 6c91774200 | |||
| fc951e913c | |||
| d138d4353f | |||
| aecee4de49 | |||
|
|
fd04c21997 | ||
| 08d8b5b488 | |||
| 82457bc9c2 | |||
|
|
63330a04a6 | ||
|
|
ad45661c3c | ||
|
|
23de6313a6 | ||
|
|
7a5ef040bb | ||
| 140ed85108 |
@@ -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> {
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -4,12 +4,17 @@ 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.io.OutputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
|
||||
@@ -57,23 +62,13 @@ public class FixedDynamicExcelExport {
|
||||
}
|
||||
}
|
||||
|
||||
public static void exportExcelByDataSize(List<DataVerifyExcel> dataList, OutputStream outputStream) {
|
||||
// 步骤1:统计每个字段的有效数据量
|
||||
public static Map<String, List> exportExcelByDataSize(List<DataVerifyExcel> dataList) {
|
||||
Map<String, List> map = new HashMap<>(2);
|
||||
Map<String, Integer> fieldCount = countValidData(dataList);
|
||||
// 步骤2:按数据量降序排序字段名
|
||||
List<String> sortedFields = sortFields(fieldCount);
|
||||
// 步骤3:构建正确的动态表头
|
||||
List<List<String>> head = buildCorrectHead(sortedFields);
|
||||
// 步骤4:构建对应顺序的行数据
|
||||
List<List<Object>> data = buildRowData(dataList, sortedFields);
|
||||
|
||||
// 步骤5:导出Excel(含列宽设置)
|
||||
EasyExcel.write(outputStream)
|
||||
.head(head)
|
||||
.registerWriteHandler(new SimpleColumnWidthStyleStrategy(20))
|
||||
.registerWriteHandler(new FreezeHeaderHandler()) // 用修复后的表头
|
||||
.sheet("数据统计")
|
||||
.doWrite(data);
|
||||
map.put("head", buildCorrectHead(sortedFields));
|
||||
map.put("data", buildRowData(dataList, sortedFields));
|
||||
return map;
|
||||
}
|
||||
|
||||
public static class FreezeHeaderHandler implements SheetWriteHandler {
|
||||
@@ -91,6 +86,40 @@ public class FixedDynamicExcelExport {
|
||||
}
|
||||
}
|
||||
|
||||
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<>();
|
||||
|
||||
@@ -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;
|
||||
@@ -155,6 +156,8 @@ public class DataVerifyController extends BaseController {
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ 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;
|
||||
@@ -11,38 +12,50 @@ 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.*;
|
||||
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.poi.excel.ExcelUtil;
|
||||
import com.njcn.supervision.api.UserLedgerFeignClient;
|
||||
import com.njcn.system.api.DictTreeFeignClient;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import 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.*;
|
||||
@@ -52,6 +65,7 @@ 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>
|
||||
@@ -75,6 +89,9 @@ 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) {
|
||||
@@ -180,6 +197,9 @@ 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);
|
||||
}
|
||||
@@ -373,37 +393,225 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
|
||||
@Override
|
||||
public void dataVerifyExcel(HttpServletResponse response, MonitorBaseParam monitorBaseParam) throws IOException {
|
||||
if (StrUtil.isNotBlank(monitorBaseParam.getDeptId())) {
|
||||
List<String> monitorIds = commTerminalService.getRunMonitorByDept(monitorBaseParam);
|
||||
monitorBaseParam.setMonitorIds(monitorIds);
|
||||
}
|
||||
List<DataVerifyExcel> dataVerifyExcels = this.baseMapper.selectDataVerifySum(monitorBaseParam);
|
||||
List<String> ids = dataVerifyExcels.stream().map(DataVerifyExcel::getLineId).collect(Collectors.toList());
|
||||
List<AreaLineInfoVO> areaLineInfoVOList = lineMapper.getBaseLineAreaInfo(ids, null, null);
|
||||
Map<String, AreaLineInfoVO> map = areaLineInfoVOList.stream().collect(Collectors.toMap(AreaLineInfoVO::getLineId, Function.identity()));
|
||||
for (DataVerifyExcel dataVerifyExcel : dataVerifyExcels) {
|
||||
if (map.containsKey(dataVerifyExcel.getLineId())) {
|
||||
AreaLineInfoVO areaLineInfoVO = map.get(dataVerifyExcel.getLineId());
|
||||
dataVerifyExcel.setCity(areaLineInfoVO.getGdName());
|
||||
dataVerifyExcel.setLineName(areaLineInfoVO.getLineName());
|
||||
dataVerifyExcel.setLoadType(areaLineInfoVO.getLoadType());
|
||||
dataVerifyExcel.setObjName(areaLineInfoVO.getObjName());
|
||||
dataVerifyExcel.setStationName(areaLineInfoVO.getSubName());
|
||||
dataVerifyExcel.setPowerSubstationName(areaLineInfoVO.getPowerSubstationName());
|
||||
dataVerifyExcel.setDevName(areaLineInfoVO.getDeviceName());
|
||||
dataVerifyExcel.setIp(areaLineInfoVO.getIp());
|
||||
dataVerifyExcel.setManufacturer(areaLineInfoVO.getManufacturer());
|
||||
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;
|
||||
}
|
||||
dataVerifyExcels.sort(Comparator
|
||||
.comparing(DataVerifyExcel::getAllTime, Comparator.reverseOrder())
|
||||
.thenComparing((DataVerifyExcel item) -> item.getCity() + "_" + item.getStationName()+"_"+item.getDevName())
|
||||
);
|
||||
exportExcelByDataSize(dataVerifyExcels,response.getOutputStream());
|
||||
// Set<String> excludeColumnFiledNames = new HashSet<>(1);
|
||||
// excludeColumnFiledNames.add("lineId");
|
||||
// EasyExcel.write(response.getOutputStream(), DataVerifyExcel.class)
|
||||
// .excludeColumnFiledNames(excludeColumnFiledNames).sheet("sheet")
|
||||
// .doWrite(dataVerifyExcels);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
/**
|
||||
* 返回监测点信息及通讯状态
|
||||
*
|
||||
|
||||
@@ -1512,17 +1512,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 VARCHAR), 'N/A'),
|
||||
':',
|
||||
IFNULL(CAST(detail.pt2 AS VARCHAR), 'N/A')
|
||||
) AS pt,
|
||||
CONCAT(
|
||||
IFNULL(CAST(detail.ct1 AS VARCHAR), 'N/A'),
|
||||
':',
|
||||
IFNULL(CAST(detail.ct2 AS VARCHAR), '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,
|
||||
@@ -1541,6 +1533,7 @@
|
||||
WHERE
|
||||
line.id = #{lineId}
|
||||
</select>
|
||||
|
||||
<select id="selectByIds" resultType="com.njcn.device.pq.pojo.vo.LineDetailVO$Detail">
|
||||
SELECT DISTINCT
|
||||
line.id as lineId,
|
||||
@@ -1949,5 +1942,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>
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
@@ -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,"用户名称重复!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2021,7 +2021,7 @@ public class ReportServiceImpl implements ReportService {
|
||||
@Override
|
||||
public Page<WaveTypeVO> getEventReport(WaveTypeParam deviceInfoParam) {
|
||||
Page<WaveTypeVO> page = new Page<>(deviceInfoParam.getPageNum(), deviceInfoParam.getPageSize());
|
||||
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(deviceInfoParam).getData();
|
||||
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceInfoClient.getPracticalRunDeviceInfo(deviceInfoParam).getData();
|
||||
List<String> lineIds = generalDeviceDTOList.stream().flatMap(dto -> dto.getLineIndexes().stream()).collect(Collectors.toList());
|
||||
if (CollUtil.isEmpty(lineIds)) {
|
||||
return page;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
}
|
||||
@@ -15,4 +15,7 @@ public interface CommMonitorEventReportService {
|
||||
|
||||
void getLineExport(ExportParam exportParam, LineDetailDataCommDTO lineDetailDataCommDTO, HttpServletResponse response);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.njcn.event.common.service;
|
||||
|
||||
import com.njcn.advance.pojo.dto.waveAnalysis.WaveData;
|
||||
|
||||
/**
|
||||
* @Author: cdf
|
||||
* @CreateTime: 2026-02-26
|
||||
* @Description:
|
||||
*/
|
||||
public interface WaveService {
|
||||
|
||||
//通过优化后的方式获取波形数据
|
||||
WaveData getWavedata(String eventIndex, int flag);
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.njcn.advance.pojo.dto.waveAnalysis.WaveData;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.device.pms.api.MonitorClient;
|
||||
@@ -11,11 +12,15 @@ import com.njcn.device.pq.api.LineFeignClient;
|
||||
import com.njcn.echarts.pojo.constant.PicCommonData;
|
||||
import com.njcn.echarts.util.DrawPicUtil;
|
||||
import com.njcn.event.common.mapper.RmpEventDetailMapper;
|
||||
import com.njcn.event.common.pojo.dto.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.utils.WordUtil;
|
||||
import com.njcn.event.common.utils.WordUtils;
|
||||
import com.njcn.event.file.pojo.bo.WaveDataDetail;
|
||||
import com.njcn.event.pojo.param.ExportParam;
|
||||
import com.njcn.event.pojo.param.StatisticsParam;
|
||||
import com.njcn.event.pojo.po.EventDetail;
|
||||
@@ -35,12 +40,15 @@ import org.apache.poi.xwpf.usermodel.*;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblWidth;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTblWidth;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.math.RoundingMode;
|
||||
@@ -63,16 +71,16 @@ import java.util.stream.Collectors;
|
||||
public class CommMonitorEventReportServiceImpl implements CommMonitorEventReportService {
|
||||
|
||||
|
||||
private final LineFeignClient lineFeignClient;
|
||||
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
|
||||
private final EventReportService eventReportService;
|
||||
//调用暂降密度接口
|
||||
private final EventAnalysisService eventAnalysisService;
|
||||
private final MonitorClient monitorClient;
|
||||
|
||||
private final RmpEventDetailMapper rmpEventDetailMapper;
|
||||
|
||||
private final WaveService waveService;
|
||||
|
||||
private final DrawPicUtil drawPicUtil;
|
||||
|
||||
/**
|
||||
@@ -218,7 +226,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++;
|
||||
}
|
||||
@@ -585,9 +593,99 @@ public class CommMonitorEventReportServiceImpl implements CommMonitorEventReport
|
||||
// .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> index) {
|
||||
try {
|
||||
WordUtil wordUtil = new WordUtil();
|
||||
for (int i = 0; i < index.size(); i++) {
|
||||
WaveData waveData = waveService.getWavedata(index.get(i), 1);
|
||||
//数据筛选,如果是双路电压的话,会存在2个波形数据
|
||||
List<WaveDataDetail> waveDataDetails = waveService.filteWaveData(waveData);
|
||||
if (waveData.getSunData().isEmpty()) {
|
||||
throw new BusinessException(CommonResponseEnum.FAIL,"没有波形数据");
|
||||
} else {
|
||||
String time = waveData.getTime();
|
||||
time = time.replace(" ", "%20");
|
||||
String title = "监测点名称:" + waveData.getLineName() + "%20发生时刻:" + time + "%20特征幅值:" + waveData.getEventValue() + "%25%20持续时间:" + waveData.getPersistTime() + "s";
|
||||
|
||||
List<String> shun = new ArrayList<>();
|
||||
List<String> rms = new ArrayList<>();
|
||||
if (waveDataDetails.size() == 1) {
|
||||
shun.add(waveService.createShunTitle(title, waveDataDetails.get(0)));
|
||||
rms.add(waveService.createRMSTitle(title, waveDataDetails.get(0)));
|
||||
} else {
|
||||
shun.add(waveService.createShunTitle(title, waveDataDetails.get(0)));
|
||||
rms.add(waveService.createRMSTitle(title, waveDataDetails.get(0)));
|
||||
for (int n = 1; n < waveDataDetails.size(); n++) {
|
||||
shun.add(waveService.createShun(waveDataDetails.get(n)));
|
||||
rms.add(waveService.createRMS(waveDataDetails.get(n)));
|
||||
}
|
||||
}
|
||||
wordUtil.translateShun(i, shun);
|
||||
wordUtil.translateRms(i, rms);
|
||||
List<EventEigDetail> eventDetailEigenvalue = eventDetailService.eventDetailEigenvalue(index.get(i));
|
||||
wordUtil.setEventDetailEigenvalue(i, eventDetailEigenvalue);
|
||||
EventInfoDetail eventInfoList = .eventDetailBaseInfoByIndex(index.get(i));
|
||||
wordUtil.setEventInfoList(i, eventInfoList);
|
||||
}
|
||||
}
|
||||
wordUtil.createReport(index.size());
|
||||
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmm");// 报告时分秒格式
|
||||
String fileName = "暂降事件报告_" + formatter.format(new Date()) + ".docx";
|
||||
//读取配置文件
|
||||
Properties pros = PubUtils.readProperties(getClass().getClassLoader(), "java.properties");
|
||||
String tmpPath = pros.get("TMP_PATH").toString() + File.separator + "eventreoprt";
|
||||
tmpPath = ClearPathUtil.cleanString(tmpPath);
|
||||
OutputStream os = null;
|
||||
File tmpfile = new File(tmpPath);
|
||||
if (!tmpfile.exists()) {
|
||||
tmpfile.mkdir();
|
||||
}
|
||||
tmpPath = tmpPath + File.separator + fileName;
|
||||
tmpPath = ClearPathUtil.cleanString(tmpPath);
|
||||
File tmp = new File(tmpPath);
|
||||
if (tmp.exists()) {
|
||||
tmp.delete();
|
||||
}
|
||||
PubUtils.createFile(tmpPath);
|
||||
try {
|
||||
os = new FileOutputStream(tmpPath);
|
||||
if (null != wordUtil.getDocument()) {
|
||||
wordUtil.getDocument().write(os);
|
||||
session.setAttribute("eventFilePath", tmpPath);
|
||||
session.setAttribute("eventFileName", fileName);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
session.setAttribute("eventFilePath", "");
|
||||
session.setAttribute("eventFileName", "");
|
||||
logger.error("输出暂态事件报告异常,原因为:" + e.toString());
|
||||
} finally {
|
||||
try {
|
||||
if (os != null) {
|
||||
os.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("关闭流异常,原因为:" + e.toString());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("生成事件报告失败,方法名为:getEventReport,异常为:" + e.toString());
|
||||
result = PubUtils.assignmentResult(null, 500, "生成事件报告出错,请联系管理员");
|
||||
}
|
||||
|
||||
return result;
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,213 @@
|
||||
//package com.njcn.event.common.service.impl;
|
||||
//
|
||||
//import cn.hutool.core.util.StrUtil;
|
||||
//import com.njcn.advance.pojo.dto.waveAnalysis.AnalyWave;
|
||||
//import com.njcn.advance.pojo.dto.waveAnalysis.WaveData;
|
||||
//import com.njcn.common.config.GeneralInfo;
|
||||
//import com.njcn.common.pojo.exception.BusinessException;
|
||||
//import com.njcn.device.pq.api.LineFeignClient;
|
||||
//import com.njcn.device.pq.pojo.po.line.LineInfoVO;
|
||||
//import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
|
||||
//import com.njcn.event.common.mapper.RmpEventDetailMapper;
|
||||
//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.file.utils.WaveUtil;
|
||||
//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 lombok.RequiredArgsConstructor;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.apache.commons.lang3.StringUtils;
|
||||
//import org.springframework.stereotype.Service;
|
||||
//
|
||||
//import java.io.File;
|
||||
//import java.io.InputStream;
|
||||
//import java.math.BigDecimal;
|
||||
//import java.math.RoundingMode;
|
||||
//import java.text.SimpleDateFormat;
|
||||
//import java.util.List;
|
||||
//import java.util.Objects;
|
||||
//import java.util.stream.Collectors;
|
||||
//import java.util.stream.Stream;
|
||||
//
|
||||
///**
|
||||
// * @Author: cdf
|
||||
// * @CreateTime: 2026-02-26
|
||||
// * @Description:
|
||||
// */
|
||||
//@Service
|
||||
//@RequiredArgsConstructor
|
||||
//@Slf4j
|
||||
//public class WaveServiceImpl implements WaveService {
|
||||
//
|
||||
// private final RmpEventDetailMapper rmpEventDetailMapper;
|
||||
//
|
||||
// private final WaveFileComponent waveFileComponent;
|
||||
//
|
||||
// private final GeneralInfo generalInfo;
|
||||
//
|
||||
// private final FileStorageUtil fileStorageUtil;
|
||||
// private final LineFeignClient lineFeignClient;
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 根据暂降事件索引获取波形数据
|
||||
// * 注:当前只考虑本地的波形文件
|
||||
// *
|
||||
// * @param eventIndex 事件索引
|
||||
// * @param flag 抽点方式
|
||||
// */
|
||||
// @Override
|
||||
// public WaveData getWavedata(String eventIndex, int flag) {
|
||||
// WaveData waveData = new WaveData();
|
||||
// RmpEventDetailPO eventDetail = rmpEventDetailMapper.selectById(eventIndex);
|
||||
// if (Objects.nonNull(eventDetail)) {
|
||||
// //获取PT变比
|
||||
// List<AreaLineInfoVO> lineInfoVOList = lineFeignClient.getBaseLineAreaInfo(Stream.of(eventDetail.getLineId()).collect(Collectors.toList())).getData();
|
||||
// AreaLineInfoVO line = lineInfoVOList.get(0);
|
||||
// waveData.setLineName(line.getLineName());
|
||||
// /*********** Modify by xuyang 添加变电站名称---Start **************/
|
||||
// waveData.setSubName(line.getSubName());
|
||||
// /*********** Modify by xuyang ---End **************/
|
||||
// waveData.setEventValue(BigDecimal.valueOf(eventDetail.getFeatureAmplitude()*100).setScale(2, RoundingMode.HALF_UP).floatValue());
|
||||
// waveData.setPersistTime(BigDecimal.valueOf(eventDetail.getDuration()*100).setScale(3, RoundingMode.HALF_UP).floatValue());
|
||||
// waveData.setTrigeTime(AnalyWave.getTimeWave());
|
||||
// if (Objects.nonNull(line)) {
|
||||
// float pt1 = line.getPt1();
|
||||
// float pt2 = line.getPt2();
|
||||
// float pt = (pt1) / (pt2);
|
||||
// waveData.setPt(pt);
|
||||
// float ct1 = line.getCt1();
|
||||
// float ct2 = line.getCt2();
|
||||
// float ct = (ct1) / (ct2);
|
||||
// waveData.setCt(ct);
|
||||
// //获取接线方式
|
||||
// if (line.getVHarmonicValue() != 0) {
|
||||
// //赋值abc三相名称
|
||||
// if (lineDetail.getPtType() == 2) {
|
||||
// waveData.setOpen(true);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// //严重度
|
||||
// Float yzd = eventDetail.getSeverity();
|
||||
// if (null == yzd || yzd == 0.0) {
|
||||
// // 前去计算严重度
|
||||
// yzd = Float.parseFloat(getYzd(eventDetail.getPersistTime(), eventDetail.getEventValue()));
|
||||
// eventDetail.setSeverity(yzd);
|
||||
// //回填严重度到数据库中
|
||||
// updateEventDeatilYzd(eventDetail);
|
||||
// }
|
||||
// waveData.setYzd(yzd);
|
||||
// //暂降发生时间
|
||||
// String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(eventDetail.getTimeId()) + "." + PubUtils.getMs(eventDetail.getMs());
|
||||
// waveData.setTime(time);
|
||||
// //暂降类型
|
||||
// // 获取暂降类型的数据字典 暂降类型
|
||||
// List<DicData> voltageType = redisCacheUtil.getVoltageType();
|
||||
// for (DicData dicData : voltageType) {
|
||||
// if (dicData.getDicIndex().equals(eventDetail.getEventType())) {
|
||||
// waveData.setWaveType(dicData.getDicName());
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if (Integer.parseInt(eventDetail.getFileFlag()) == 1) {
|
||||
// //根据暂降事件,返回波形文件名
|
||||
// LineInfoVO ip = lineFeignClient.getLineInfoVO(eventIndex);
|
||||
// if (StringUtils.isBlank(ip)) {
|
||||
// return waveData;
|
||||
// }
|
||||
// String path = appConfig.getWavePath();
|
||||
// path = path + File.separator + ip;
|
||||
// String waveName = getWaveName(eventDetail, path);
|
||||
// String pathTemp = path + File.separator + waveName;
|
||||
// File file = new File(pathTemp);
|
||||
// // 判断文件是否存在
|
||||
// if (file.isFile() && file.exists()) {
|
||||
// System.out.println(pathTemp + "路径下,文件找到了");
|
||||
// //CFG文件路径 pathTemp
|
||||
// //获取波形的瞬时值、RMS值数据
|
||||
// AnalyWave analyWave = new AnalyWave();
|
||||
// WaveDataDTO tagDataValue = waveRead(eventDetail.getWavePath(),ip);
|
||||
// List<List<Float>> shunWave = tagDataValue.getListWaveData();//获取瞬时波形值
|
||||
// List<List<Float>> rmsWave = tagDataValue.getListRmsData();//RMS值波形
|
||||
// waveData.setnOneWaveNum(analyWave.getnOneWaveNum());
|
||||
// waveData.setSunData(shunWave);
|
||||
// waveData.setTmpWaveTitle(tagDataValue.getWaveTitle());
|
||||
// waveData.setFirstMs(analyWave.getFirstMs());
|
||||
// waveData.setFirstTime(analyWave.getFirstTime());
|
||||
// waveData.setRmsData(rmsWave);
|
||||
// waveData.setRatesCfg(analyWave.getRatesCfg());
|
||||
// /*********** Modify by yexibao ---Start **************/
|
||||
// waveData.setiPhasic(tagDataValue.getIPhasic());
|
||||
// /*********** Modify by yexibao ---End **************/
|
||||
// List<String> tmpWaveTitle = tagDataValue.getWaveTitle();
|
||||
// /*********** Modify by yexibao ---Start **************/
|
||||
// for (int i = 0; i < tagDataValue.getIPhasic(); i++) {
|
||||
// if (tmpWaveTitle.get(i + 1).substring(1).indexOf("A") > -1)
|
||||
// waveData.setA(tmpWaveTitle.get(i + 1).substring(1));
|
||||
// if (tmpWaveTitle.get(i + 1).substring(1).indexOf("B") > -1)
|
||||
// waveData.setB(tmpWaveTitle.get(i + 1).substring(1));
|
||||
// if (tmpWaveTitle.get(i + 1).substring(1).indexOf("C") > -1)
|
||||
// waveData.setC(tmpWaveTitle.get(i + 1).substring(1));
|
||||
// }
|
||||
// /*********** Modify by yexibao ---End **************/
|
||||
//
|
||||
// } else {
|
||||
// System.out.println(pathTemp + "路径下,文件找不到了");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return waveData;
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// public WaveDataDTO waveRead(String waveName,String ip){
|
||||
// WaveDataDTO waveDataDTO;
|
||||
// String cfgPath, datPath, cfgPath2, datPath2;
|
||||
// if (generalInfo.getBusinessWaveFileStorage() == GeneralConstant.LOCAL_DISK) {
|
||||
// cfgPath = generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + GeneralConstant.CFG;
|
||||
// datPath = generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + GeneralConstant.DAT;
|
||||
// log.info("本地磁盘波形文件路径----" + cfgPath);
|
||||
// InputStream cfgStream = waveFileComponent.getFileInputStreamByFilePath(cfgPath);
|
||||
// InputStream datStream = waveFileComponent.getFileInputStreamByFilePath(datPath);
|
||||
// if (Objects.isNull(cfgStream) || Objects.isNull(datStream)) {
|
||||
// throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
|
||||
// }
|
||||
// waveDataDTO = waveFileComponent.getComtrade(cfgStream, datStream, 1);
|
||||
// } else {
|
||||
// cfgPath = OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.CFG;
|
||||
// datPath = OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.DAT;
|
||||
// //适配文件后缀小写
|
||||
// cfgPath2 = OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.CFG.toLowerCase();
|
||||
// datPath2 = OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.DAT.toLowerCase();
|
||||
// log.info("文件服务器波形文件路径----" + cfgPath);
|
||||
// try (
|
||||
// InputStream cfgStream = fileStorageUtil.getFileStream(cfgPath);
|
||||
// InputStream datStream = fileStorageUtil.getFileStream(datPath)
|
||||
// ) {
|
||||
// if (Objects.isNull(cfgStream) || Objects.isNull(datStream)) {
|
||||
// throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
|
||||
// }
|
||||
// waveDataDTO = waveFileComponent.getComtrade(cfgStream, datStream, 0);
|
||||
// } catch (Exception e) {
|
||||
// try {
|
||||
// InputStream cfgStream = fileStorageUtil.getFileStream(cfgPath2);
|
||||
// InputStream datStream = fileStorageUtil.getFileStream(datPath2);
|
||||
// if (Objects.isNull(cfgStream) || Objects.isNull(datStream)) {
|
||||
// throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
|
||||
// }
|
||||
// waveDataDTO = waveFileComponent.getComtrade(cfgStream, datStream, 0);
|
||||
// } catch (Exception e1) {
|
||||
// throw new BusinessException(WaveFileResponseEnum.WAVE_DATA_INVALID);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// return waveDataDTO;
|
||||
// }
|
||||
//}
|
||||
@@ -0,0 +1,684 @@
|
||||
package com.njcn.event.common.utils;
|
||||
|
||||
|
||||
import com.njcn.event.common.pojo.dto.EventEigDetail;
|
||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||
import net.sf.json.JSONArray;
|
||||
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.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
public class WordUtil {
|
||||
private Map<Integer, List<byte[]>> listShunPic = new HashMap<>();
|
||||
private Map<Integer, List<byte[]>> listRmsPic = new HashMap<>();
|
||||
private XWPFDocument document;
|
||||
private Map<Integer, List<EventEigDetail>> eventDetailEigenvalue = new HashMap<>();
|
||||
private Map<Integer, RmpEventDetailPO> eventInfoList = new HashMap<>();
|
||||
|
||||
public void setEventInfoList(Integer index, RmpEventDetailPO eventInfoList) {
|
||||
RmpEventDetailPO tmp = eventInfoList == null ? new RmpEventDetailPO() : eventInfoList;
|
||||
this.eventInfoList.put(index, tmp);
|
||||
}
|
||||
|
||||
public void setEventDetailEigenvalue(Integer 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(Integer index, List<String> strPic) {
|
||||
BASE64Decoder decoder = new BASE64Decoder();
|
||||
List<byte[]> tmp = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < strPic.size(); i++) {
|
||||
try {
|
||||
byte[] buffer = decoder.decodeBuffer(strPic.get(i));
|
||||
tmp.add(buffer);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
listShunPic.put(index, tmp);
|
||||
}
|
||||
|
||||
public void translateRms(Integer index, List<String> strPic) {
|
||||
BASE64Decoder decoder = new BASE64Decoder();
|
||||
List<byte[]> tmp = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < strPic.size(); i++) {
|
||||
try {
|
||||
byte[] buffer = decoder.decodeBuffer(strPic.get(i));
|
||||
tmp.add(buffer);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
listRmsPic.put(index, tmp);
|
||||
}
|
||||
|
||||
public void createReport(Integer length) 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 < length; m++) {
|
||||
List<EventEigDetail> eventDetailEigenvaluetmp = this.eventDetailEigenvalue.get(m);
|
||||
|
||||
SimpleDateFormat sdfs = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
|
||||
String time = sdfs.format(eventInfoList.get(m).getStartTime());
|
||||
createTitle(document, String.valueOf(m+1) + ". " +time, "标题 1", 0, 20);
|
||||
createTitle(document, String.valueOf(m+1) + "." +"1. 基本信息", "标题 2", 0, 15);
|
||||
XWPFParagraph introductionContentParagraph = getLeftParagraph(document);
|
||||
introductionContentParagraph.setIndentationFirstLine(200);
|
||||
XWPFRun introductionContentRun = introductionContentParagraph.createRun();
|
||||
addParagraph(introductionContentRun, "宋体", 11, "000000",
|
||||
eventInfoList.get(m).getGdName() + "," + eventInfoList.get(m).getBdzName() + ",网络参数:" + eventInfoList.get(m).getIp()
|
||||
+ "," + eventInfoList.get(m).getLineName() + "于" + time + "发生暂降事件,特征幅值:"
|
||||
+ String.valueOf(eventInfoList.get(m).getEventValue()) + "%,持续时间:" + eventInfoList.get(m).getPersistTime()
|
||||
+ "s。",
|
||||
false);
|
||||
createTitle(document, String.valueOf(m+1) + "." +"2. 波形图", "标题 2", 0, 15);
|
||||
createTitle(document, String.valueOf(m+1) + "." +"2.1 瞬时波形图", "标题 3", 200, 11);
|
||||
for(int shun = 0;shun< listShunPic.get(m).size();shun++){
|
||||
createPic(document, "瞬时波形"+String.valueOf(shun), listShunPic.get(m).get(shun));
|
||||
}
|
||||
createTitle(document, String.valueOf(m+1) + "." +"2.2 RMS波形图", "标题 3", 200, 11);
|
||||
for(int rms = 0;rms< listRmsPic.get(m).size();rms++){
|
||||
createPic(document, "RMS波形"+String.valueOf(rms), listRmsPic.get(m).get(rms));
|
||||
}
|
||||
createTitle(document, String.valueOf(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 + "日";
|
||||
}
|
||||
|
||||
public String createWave(WaveData waveData) throws Exception {
|
||||
HashMap<String, Object> datas = new HashMap<>();
|
||||
List<List<Float>> sunData = waveData.getSunData();
|
||||
int iphasic =waveData.getiPhasic();
|
||||
float pt = waveData.getPt() / 1000;
|
||||
float ifmax = 0f, ifmin = 0f;
|
||||
List<List<Float>> adata = new ArrayList<>();
|
||||
List<List<Float>> bdata = new ArrayList<>();
|
||||
List<List<Float>> cdata = new ArrayList<>();
|
||||
|
||||
if (sunData.size() > 0) {
|
||||
ifmax = sunData.get(0).get(1) * pt;
|
||||
ifmin = sunData.get(0).get(1) * pt;
|
||||
}
|
||||
List<String> colors =new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < sunData.size(); i++) {
|
||||
float x = sunData.get(i).get(0);
|
||||
if(iphasic==1){
|
||||
float shunFirstA = sunData.get(i).get(1) * pt;
|
||||
List<Float> a = new ArrayList() {
|
||||
{
|
||||
add(x);
|
||||
add(shunFirstA);
|
||||
}
|
||||
};
|
||||
adata.add(a);
|
||||
ifmax = ifmax > shunFirstA ? ifmax : shunFirstA;
|
||||
ifmin = ifmin < shunFirstA ? ifmin : shunFirstA;
|
||||
colors.add("#DAA520");
|
||||
colors.add("#fff");
|
||||
colors.add("#fff");
|
||||
|
||||
datas.put("a", waveData.getA());
|
||||
datas.put("b", "");
|
||||
datas.put("c", "");
|
||||
}else if(iphasic==2){
|
||||
float shunFirstA = sunData.get(i).get(1) * pt;
|
||||
float shunFirstB = sunData.get(i).get(2) * pt;
|
||||
List<Float> a = new ArrayList() {
|
||||
{
|
||||
add(x);
|
||||
add(shunFirstA);
|
||||
}
|
||||
};
|
||||
adata.add(a);
|
||||
|
||||
List<Float> b = new ArrayList() {
|
||||
{
|
||||
add(x);
|
||||
add(shunFirstB);
|
||||
}
|
||||
};
|
||||
bdata.add(b);
|
||||
|
||||
ifmax = getMaxTwo(ifmax, shunFirstA, shunFirstB);
|
||||
ifmin = getMinTwo(ifmin, shunFirstA, shunFirstB);
|
||||
|
||||
colors.add("#DAA520");
|
||||
colors.add("#2E8B57");
|
||||
colors.add("#fff");
|
||||
|
||||
datas.put("a", waveData.getA());
|
||||
datas.put("b", waveData.getB());
|
||||
datas.put("c", "");
|
||||
|
||||
}else if(iphasic==3){
|
||||
float shunFirstA = sunData.get(i).get(1) * pt;
|
||||
float shunFirstB = sunData.get(i).get(2) * pt;
|
||||
float shunFirstC = sunData.get(i).get(3) * pt;
|
||||
List<Float> a = new ArrayList() {
|
||||
{
|
||||
add(x);
|
||||
add(shunFirstA);
|
||||
}
|
||||
};
|
||||
adata.add(a);
|
||||
|
||||
List<Float> b = new ArrayList() {
|
||||
{
|
||||
add(x);
|
||||
add(shunFirstB);
|
||||
}
|
||||
};
|
||||
bdata.add(b);
|
||||
|
||||
List<Float> c = new ArrayList() {
|
||||
{
|
||||
add(x);
|
||||
add(shunFirstC);
|
||||
}
|
||||
};
|
||||
cdata.add(c);
|
||||
ifmax = getMax(ifmax, shunFirstA, shunFirstB, shunFirstC);
|
||||
ifmin = getMin(ifmin, shunFirstA, shunFirstB, shunFirstC);
|
||||
|
||||
colors.add("#DAA520");
|
||||
colors.add("#2E8B57");
|
||||
colors.add("#A52a2a");
|
||||
|
||||
datas.put("a", waveData.getA());
|
||||
datas.put("b", waveData.getB());
|
||||
datas.put("c", waveData.getC());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
String time = waveData.getTime();
|
||||
time = time.replace(" ", "%20");
|
||||
float severity = waveData.getYzd();
|
||||
String strSeverity = String.valueOf(severity);
|
||||
String type = waveData.getWaveType();
|
||||
|
||||
if (severity < 0) {
|
||||
strSeverity = "/";
|
||||
type = "/";
|
||||
}
|
||||
|
||||
String title = "监测点名称:" + waveData.getLineName() + "%20发生时刻:" + time + "%20特征幅值:" + waveData.getEventValue()
|
||||
+ "%25%20持续时间:" + waveData.getPersistTime() + "s";
|
||||
|
||||
|
||||
datas.put("title", title);
|
||||
datas.put("adata", JSONArray.fromObject(adata).toString());
|
||||
datas.put("bdata", JSONArray.fromObject(bdata).toString());
|
||||
datas.put("cdata", JSONArray.fromObject(cdata).toString());
|
||||
datas.put("unit", "kV");
|
||||
datas.put("max", String.valueOf(ifmax));
|
||||
datas.put("min", String.valueOf(ifmin));
|
||||
datas.put("colors", JSONArray.fromObject(colors).toString());
|
||||
datas.put("cshow", Boolean.toString(!waveData.getOpenTri()));
|
||||
|
||||
|
||||
String option = FreemarkerUtil.generateString("wave.ftl", "com/pqs9200/template", datas);
|
||||
return EchartsUtil.generateEchartsBase64(option, "3003");
|
||||
}
|
||||
|
||||
public String createRms(WaveData waveData) throws IOException, TemplateException {
|
||||
List<List<Float>> rmsData = waveData.getRmsData();
|
||||
HashMap<String, Object> datas = new HashMap<>();
|
||||
int iphasic =waveData.getiPhasic();
|
||||
float pt = waveData.getPt() / 1000;
|
||||
List<List<Float>> adata = new ArrayList<>();
|
||||
List<List<Float>> bdata = new ArrayList<>();
|
||||
List<List<Float>> cdata = new ArrayList<>();
|
||||
|
||||
List<String> colors =new ArrayList<>();
|
||||
for (int i = 0; i < rmsData.size(); i++) {
|
||||
float x = rmsData.get(i).get(0);
|
||||
if(iphasic==1){
|
||||
float rmsFirstA = rmsData.get(i).get(1) * pt;
|
||||
List<Float> a = new ArrayList() {
|
||||
{
|
||||
add(x);
|
||||
add(rmsFirstA);
|
||||
}
|
||||
};
|
||||
adata.add(a);
|
||||
|
||||
colors.add("#DAA520");
|
||||
colors.add("#fff");
|
||||
colors.add("#fff");
|
||||
|
||||
datas.put("a", waveData.getA());
|
||||
datas.put("b", "");
|
||||
datas.put("c", "");
|
||||
}else if(iphasic==2){
|
||||
float rmsFirstA = rmsData.get(i).get(1) * pt;
|
||||
float rmsFirstB = rmsData.get(i).get(2) * pt;
|
||||
List<Float> a = new ArrayList() {
|
||||
{
|
||||
add(x);
|
||||
add(rmsFirstA);
|
||||
}
|
||||
};
|
||||
adata.add(a);
|
||||
|
||||
List<Float> b = new ArrayList() {
|
||||
{
|
||||
add(x);
|
||||
add(rmsFirstB);
|
||||
}
|
||||
};
|
||||
bdata.add(b);
|
||||
|
||||
colors.add("#DAA520");
|
||||
colors.add("#2E8B57");
|
||||
colors.add("#fff");
|
||||
|
||||
datas.put("a", waveData.getA());
|
||||
datas.put("b", waveData.getB());
|
||||
datas.put("c", "");
|
||||
}else if(iphasic==3){
|
||||
float rmsFirstA = rmsData.get(i).get(1) * pt;
|
||||
float rmsFirstB = rmsData.get(i).get(2) * pt;
|
||||
float rmsFirstC = rmsData.get(i).get(3) * pt;
|
||||
|
||||
List<Float> a = new ArrayList() {
|
||||
{
|
||||
add(x);
|
||||
add(rmsFirstA);
|
||||
}
|
||||
};
|
||||
adata.add(a);
|
||||
|
||||
List<Float> b = new ArrayList() {
|
||||
{
|
||||
add(x);
|
||||
add(rmsFirstB);
|
||||
}
|
||||
};
|
||||
bdata.add(b);
|
||||
|
||||
List<Float> c = new ArrayList() {
|
||||
{
|
||||
add(x);
|
||||
add(rmsFirstC);
|
||||
}
|
||||
};
|
||||
cdata.add(c);
|
||||
|
||||
colors.add("#DAA520");
|
||||
colors.add("#2E8B57");
|
||||
colors.add("#A52a2a");
|
||||
|
||||
datas.put("a", waveData.getA());
|
||||
datas.put("b", waveData.getB());
|
||||
datas.put("c", waveData.getC());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
String time = waveData.getTime();
|
||||
time = time.replace(" ", "%20"); // 时分秒
|
||||
float severity = waveData.getYzd();
|
||||
String strSeverity = String.valueOf(severity);
|
||||
String type = waveData.getWaveType();
|
||||
|
||||
if (severity < 0) {
|
||||
strSeverity = "/";
|
||||
type = "/";
|
||||
}
|
||||
|
||||
String title = "监测点名称:" + waveData.getLineName() + "%20发生时刻:" + time + "%20特征幅值:" + waveData.getEventValue()
|
||||
+ "%25%20持续时间:" + waveData.getPersistTime() + "s";
|
||||
|
||||
|
||||
datas.put("title", title);
|
||||
datas.put("adata", JSONArray.fromObject(adata).toString());
|
||||
datas.put("bdata", JSONArray.fromObject(bdata).toString());
|
||||
datas.put("cdata", JSONArray.fromObject(cdata).toString());
|
||||
datas.put("unit", "kV");
|
||||
datas.put("colors", JSONArray.fromObject(colors).toString());
|
||||
datas.put("cshow", Boolean.toString(!waveData.getOpenTri()));
|
||||
|
||||
String option = FreemarkerUtil.generateString("rms.ftl", "com/pqs9200/template", datas);
|
||||
return EchartsUtil.generateEchartsBase64(option, "3003");
|
||||
}
|
||||
|
||||
private float getMin(float temp, float tempA, float tempB, float tempC) {
|
||||
temp = temp < tempA ? temp : tempA;
|
||||
temp = temp < tempB ? temp : tempB;
|
||||
temp = temp < tempC ? temp : tempC;
|
||||
return temp;
|
||||
}
|
||||
|
||||
private float getMinTwo(float temp, float tempA, float tempB) {
|
||||
temp = temp < tempA ? temp : tempA;
|
||||
temp = temp < tempB ? temp : tempB;
|
||||
return temp;
|
||||
}
|
||||
|
||||
private float getMax(float temp, float tempA, float tempB, float tempC) {
|
||||
temp = temp > tempA ? temp : tempA;
|
||||
temp = temp > tempB ? temp : tempB;
|
||||
temp = temp > tempC ? temp : tempC;
|
||||
return temp;
|
||||
}
|
||||
|
||||
private float getMaxTwo(float temp, float tempA, float tempB) {
|
||||
temp = temp > tempA ? temp : tempA;
|
||||
temp = temp > tempB ? temp : tempB;
|
||||
return temp;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -864,7 +864,7 @@ public class OracleResultServiceImpl implements OracleResultService {
|
||||
String endTime = historyParam.getEndTime();
|
||||
String key = "a1a69c93c11e4910aa247087c261bec5";
|
||||
String secret = "038de3c27cc54489862d181470e3ad92";
|
||||
String url = "https://25.37.90.72/ast/ydxxcjxt/dws/get_e_mp_TGvol_zl_ds";
|
||||
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);
|
||||
@@ -877,7 +877,7 @@ public class OracleResultServiceImpl implements OracleResultService {
|
||||
String endTime = historyParam.getEndTime();
|
||||
String key = "a1a69c93c11e4910aa247087c261bec5";
|
||||
String secret = "038de3c27cc54489862d181470e3ad92";
|
||||
String url = "https://25.37.90.72/ast/ydxxcjxt/dws/get_e_mp_TGpower_zl_ds";
|
||||
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);
|
||||
@@ -890,7 +890,7 @@ public class OracleResultServiceImpl implements OracleResultService {
|
||||
String endTime = historyParam.getEndTime();
|
||||
String key = "a1a69c93c11e4910aa247087c261bec5";
|
||||
String secret = "038de3c27cc54489862d181470e3ad92";
|
||||
String url = "https://25.37.90.72/ast/ydxxcjxt/dws/get_e_mp_TGfactor_zl_ds";
|
||||
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);
|
||||
|
||||
@@ -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()));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ 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;
|
||||
@@ -157,7 +158,13 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
} else {
|
||||
phase = PHASE_MAPPING.get(item.getPhase());
|
||||
}
|
||||
tMap.put((item.getOtherName() + phase + item.getResourcesId()).toUpperCase(), item.getPrimaryFormula());
|
||||
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());
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 谐波电流限值
|
||||
*
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ public class PqFrontLogsChild extends BaseEntity {
|
||||
@TableField(value = "grade")
|
||||
private String grade;
|
||||
|
||||
@TableField(value = "`state`")
|
||||
@TableField(value = "state")
|
||||
private Integer state;
|
||||
|
||||
}
|
||||
@@ -30,5 +30,6 @@
|
||||
<where>
|
||||
${ew.sqlSegment}
|
||||
</where>
|
||||
order by A.sort asc
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -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>
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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("解锁超级管理员")
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.system.api.AreaFeignClient;
|
||||
import com.njcn.system.pojo.po.Area;
|
||||
import com.njcn.user.mapper.AuthClientMapper;
|
||||
import com.njcn.user.pojo.param.AuthClientParam;
|
||||
import com.njcn.user.pojo.po.AuthClient;
|
||||
import com.njcn.user.service.IAuthClientService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@@ -31,4 +32,11 @@ public class AuthClientServiceImpl extends ServiceImpl<AuthClientMapper, AuthCli
|
||||
.eq(AuthClient::getState,DataStateEnum.ENABLE.getCode())
|
||||
.one();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean sessionConfigUpdate(AuthClientParam authClientParam) {
|
||||
return lambdaUpdate().set(AuthClient::getRefreshTokenValidity,authClientParam.getRefreshTokenValidity())
|
||||
.set(AuthClient::getAccessTokenValidity,authClientParam.getAccessTokenValidity())
|
||||
.update();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.njcn.user.service.impl;
|
||||
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.user.pojo.param.PassWordRuleParam;
|
||||
import com.njcn.user.pojo.po.AuthClient;
|
||||
import com.njcn.user.pojo.po.User;
|
||||
import com.njcn.user.pojo.po.UserStrategy;
|
||||
import com.njcn.user.service.IAuthClientService;
|
||||
@@ -13,6 +12,9 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2024/7/11 18:06【需求编号】
|
||||
@@ -33,19 +35,21 @@ public class PassWordRuleServiceImpl implements IPassWordRuleService {
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public Boolean ruleUpdate(PassWordRuleParam passWordRuleParam) {
|
||||
|
||||
iUserStrategyService.lambdaUpdate().eq(UserStrategy::getType,"1")
|
||||
iUserStrategyService.lambdaUpdate().eq(UserStrategy::getType,passWordRuleParam.getType())
|
||||
.eq(UserStrategy::getState, DataStateEnum.ENABLE.getCode())
|
||||
.set(UserStrategy::getLimitPwdTimes,passWordRuleParam.getErrorsCount())
|
||||
.set(UserStrategy::getLimitPwdDate,passWordRuleParam.getPasswordExpirationMonth())
|
||||
.set(UserStrategy::getLockPwdTime,passWordRuleParam.getReleaseTime())
|
||||
.set(UserStrategy::getMaxNum,passWordRuleParam.getMaxUseUser())
|
||||
.set(UserStrategy::getSleep,passWordRuleParam.getSleepDay())
|
||||
.set(UserStrategy::getLockPwdCheck,passWordRuleParam.getLockPwdCheck())
|
||||
.set(UserStrategy::getLogout,passWordRuleParam.getLogoutDay())
|
||||
.update();
|
||||
|
||||
iAuthClientService.lambdaUpdate()
|
||||
.set(AuthClient::getRefreshTokenValidity,passWordRuleParam.getSessionRefreshTime())
|
||||
.set(AuthClient::getAccessTokenValidity,passWordRuleParam.getSessionTime())
|
||||
.update();
|
||||
// iAuthClientService.lambdaUpdate()
|
||||
// .set(AuthClient::getRefreshTokenValidity,passWordRuleParam.getSessionRefreshTime())
|
||||
// .set(AuthClient::getAccessTokenValidity,passWordRuleParam.getSessionTime())
|
||||
// .update();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -59,10 +63,11 @@ public class PassWordRuleServiceImpl implements IPassWordRuleService {
|
||||
passWordRuleParam.setPasswordExpirationMonth(userStrategy.getLimitPwdDate());
|
||||
passWordRuleParam.setMaxUseUser(userStrategy.getMaxNum());
|
||||
passWordRuleParam.setSleepDay(userStrategy.getSleep());
|
||||
|
||||
AuthClient authClient = iAuthClientService.lambdaQuery().last(" limit 1").one();
|
||||
passWordRuleParam.setSessionTime(authClient.getAccessTokenValidity());
|
||||
passWordRuleParam.setSessionRefreshTime(authClient.getRefreshTokenValidity());
|
||||
passWordRuleParam.setLockPwdCheck(userStrategy.getLockPwdCheck());
|
||||
passWordRuleParam.setLogoutDay(userStrategy.getLogout());
|
||||
// AuthClient authClient = iAuthClientService.lambdaQuery().last(" limit 1").one();
|
||||
// passWordRuleParam.setSessionTime(authClient.getAccessTokenValidity());
|
||||
// passWordRuleParam.setSessionRefreshTime(authClient.getRefreshTokenValidity());
|
||||
return passWordRuleParam;
|
||||
}
|
||||
|
||||
@@ -79,4 +84,26 @@ public class PassWordRuleServiceImpl implements IPassWordRuleService {
|
||||
.eq(UserStrategy::getState, DataStateEnum.ENABLE.getCode())
|
||||
.one();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PassWordRuleParam> getUserStrategyList() {
|
||||
List<UserStrategy> list = iUserStrategyService.list();
|
||||
List<PassWordRuleParam> collect = list.stream().map(temp -> {
|
||||
PassWordRuleParam passWordRuleParam = new PassWordRuleParam();
|
||||
|
||||
passWordRuleParam.setErrorsCount(temp.getLimitPwdTimes());
|
||||
passWordRuleParam.setReleaseTime(temp.getLockPwdTime());
|
||||
passWordRuleParam.setPasswordExpirationMonth(temp.getLimitPwdDate());
|
||||
passWordRuleParam.setMaxUseUser(temp.getMaxNum());
|
||||
passWordRuleParam.setSleepDay(temp.getSleep());
|
||||
passWordRuleParam.setLockPwdCheck(temp.getLockPwdCheck());
|
||||
passWordRuleParam.setLogoutDay(temp.getLogout());
|
||||
passWordRuleParam.setType(temp.getType());
|
||||
// AuthClient authClient = iAuthClientService.lambdaQuery().last(" limit 1").one();
|
||||
// passWordRuleParam.setSessionTime(authClient.getAccessTokenValidity());
|
||||
// passWordRuleParam.setSessionRefreshTime(authClient.getRefreshTokenValidity());
|
||||
return passWordRuleParam;
|
||||
}).collect(Collectors.toList());
|
||||
return collect;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user