19 Commits

Author SHA1 Message Date
wr
94037d588b 暂态事件报告功能下载 2026-02-28 15:30:35 +08:00
01a77fa92d 1.暂降事件报告 2026-02-27 09:40:12 +08:00
9d9150e418 Merge remote-tracking branch 'origin/main' 2026-02-27 09:35:44 +08:00
ee1ca85a5d 1.暂降事件报告 2026-02-27 09:35:38 +08:00
wr
2c3c716607 河北算法调整 2026-02-26 15:41:16 +08:00
wr
e1d17c63a2 微调 2026-02-26 08:38:03 +08:00
hzj
6234ac8ce9 系统配置合并 2026-02-11 14:34:33 +08:00
6c91774200 1.报告模板bug 2026-02-11 13:31:06 +08:00
fc951e913c 1.微调 2026-02-10 16:32:34 +08:00
d138d4353f 1.用户对象管理业务迁移 2026-02-10 14:48:04 +08:00
aecee4de49 1.用户对象管理业务迁移 2026-02-10 14:36:12 +08:00
hzj
fd04c21997 修改驾驶舱bug 2026-02-10 09:22:04 +08:00
08d8b5b488 Merge remote-tracking branch 'origin/main' 2026-02-09 16:14:05 +08:00
82457bc9c2 1.解决修改台账bug 2026-02-09 16:13:53 +08:00
hzj
63330a04a6 电能质量污区图bug 2026-02-09 16:11:14 +08:00
hzj
ad45661c3c 稳态合格率报告bug 2026-02-09 14:47:27 +08:00
wr
23de6313a6 Merge remote-tracking branch 'origin/main' 2026-02-06 15:09:30 +08:00
wr
7a5ef040bb 冀北数据周报 2026-02-06 15:09:17 +08:00
xy
140ed85108 报表优化 2026-02-06 09:57:15 +08:00
53 changed files with 2121 additions and 204 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -4,12 +4,17 @@ import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.write.handler.SheetWriteHandler; import com.alibaba.excel.write.handler.SheetWriteHandler;
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder; 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.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy;
import com.njcn.device.pq.pojo.vo.dataClean.DataVerifyExcel; 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.Sheet;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.OutputStream;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.*; import java.util.*;
@@ -57,23 +62,13 @@ public class FixedDynamicExcelExport {
} }
} }
public static void exportExcelByDataSize(List<DataVerifyExcel> dataList, OutputStream outputStream) { public static Map<String, List> exportExcelByDataSize(List<DataVerifyExcel> dataList) {
// 步骤1统计每个字段的有效数据量 Map<String, List> map = new HashMap<>(2);
Map<String, Integer> fieldCount = countValidData(dataList); Map<String, Integer> fieldCount = countValidData(dataList);
// 步骤2按数据量降序排序字段名
List<String> sortedFields = sortFields(fieldCount); List<String> sortedFields = sortFields(fieldCount);
// 步骤3构建正确的动态表头 map.put("head", buildCorrectHead(sortedFields));
List<List<String>> head = buildCorrectHead(sortedFields); map.put("data", buildRowData(dataList, sortedFields));
// 步骤4构建对应顺序的行数据 return map;
List<List<Object>> data = buildRowData(dataList, sortedFields);
// 步骤5导出Excel含列宽设置
EasyExcel.write(outputStream)
.head(head)
.registerWriteHandler(new SimpleColumnWidthStyleStrategy(20))
.registerWriteHandler(new FreezeHeaderHandler()) // 用修复后的表头
.sheet("数据统计")
.doWrite(data);
} }
public static class FreezeHeaderHandler implements SheetWriteHandler { 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 // ★ 修复点1构建正确的表头每个列名独立成List
private static List<List<String>> buildCorrectHead(List<String> allFields) { private static List<List<String>> buildCorrectHead(List<String> allFields) {
List<List<String>> head = new ArrayList<>(); List<List<String>> head = new ArrayList<>();

View File

@@ -1,6 +1,7 @@
package com.njcn.device.pq.controller; package com.njcn.device.pq.controller;
import cn.hutool.core.date.DateUtil;
import com.njcn.common.pojo.annotation.OperateInfo; import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum; import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum; 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 { public void dataVerifyExcel(HttpServletResponse response, MonitorBaseParam monitorBaseParam) throws IOException {
response.setContentType("application/vnd.ms-excel"); response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("utf-8"); 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); iPqDataVerifyBakService.dataVerifyExcel(response, monitorBaseParam);
} }

View File

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

View File

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

View File

@@ -4,6 +4,7 @@ package com.njcn.device.pq.service.impl;
import cn.hutool.core.codec.Base64; import cn.hutool.core.codec.Base64;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.*; import cn.hutool.core.date.*;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjUtil; import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONArray; import cn.hutool.json.JSONArray;
@@ -11,38 +12,50 @@ import cn.hutool.json.JSONConfig;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONTokener; import cn.hutool.json.JSONTokener;
import com.alibaba.excel.EasyExcel; 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.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 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.common.pojo.exception.BusinessException;
import com.njcn.dataProcess.api.PqReasonableRangeFeignClient; import com.njcn.dataProcess.api.PqReasonableRangeFeignClient;
import com.njcn.dataProcess.enums.DataCleanEnum; import com.njcn.dataProcess.enums.DataCleanEnum;
import com.njcn.dataProcess.param.DataCleanParam; import com.njcn.dataProcess.param.DataCleanParam;
import com.njcn.dataProcess.pojo.dto.PqReasonableRangeDto; 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.mapper.LineMapper;
import com.njcn.device.line.service.DeptLineService; import com.njcn.device.line.service.DeptLineService;
import com.njcn.device.pq.constant.Param; import com.njcn.device.pq.constant.Param;
import com.njcn.device.pq.enums.LineBaseEnum; import com.njcn.device.pq.enums.LineBaseEnum;
import com.njcn.device.pq.mapper.PqDataVerifyBakMapper; 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.param.dataClean.MonitorBaseParam;
import com.njcn.device.pq.pojo.po.DeptLine; import com.njcn.device.pq.pojo.po.DeptLine;
import com.njcn.device.pq.pojo.po.PqDataVerifyBak; import com.njcn.device.pq.pojo.po.PqDataVerifyBak;
import com.njcn.device.pq.pojo.vo.AreaLineInfoVO; import com.njcn.device.pq.pojo.vo.*;
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
import com.njcn.device.pq.pojo.vo.dataClean.*; import com.njcn.device.pq.pojo.vo.dataClean.*;
import com.njcn.device.pq.service.CommTerminalService; import com.njcn.device.pq.service.CommTerminalService;
import com.njcn.device.pq.service.IPqDataVerifyBakService; 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.oss.utils.FileStorageUtil;
import com.njcn.poi.excel.ExcelUtil;
import com.njcn.supervision.api.UserLedgerFeignClient; import com.njcn.supervision.api.UserLedgerFeignClient;
import com.njcn.system.api.DictTreeFeignClient; import com.njcn.system.api.DictTreeFeignClient;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
@@ -52,6 +65,7 @@ import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.njcn.device.pq.utils.FixedDynamicExcelExport.exportExcelByDataSize; import static com.njcn.device.pq.utils.FixedDynamicExcelExport.exportExcelByDataSize;
import static com.njcn.device.pq.utils.FixedDynamicExcelExport.writeCenterStyle;
/** /**
* <p> * <p>
@@ -75,6 +89,9 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
private final UserLedgerFeignClient userLedgerFeignClient; private final UserLedgerFeignClient userLedgerFeignClient;
private final FileStorageUtil fileStorageUtil; private final FileStorageUtil fileStorageUtil;
private final DeptLineService deptLineService; private final DeptLineService deptLineService;
private final GeneralDeviceService deviceService;
private final RStatIntegrityDMapper integrityDMapper;
private final OnLineRateMapper onLineRateMapper;
@Override @Override
public VerifyMonitorVO getMonitorVerifyData(MonitorBaseParam monitorBaseParam) { public VerifyMonitorVO getMonitorVerifyData(MonitorBaseParam monitorBaseParam) {
@@ -180,6 +197,9 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
@Override @Override
public List<PowerQualityIndicatorsVO> getMonitorVerifyDay(MonitorBaseParam monitorBaseParam) { public List<PowerQualityIndicatorsVO> getMonitorVerifyDay(MonitorBaseParam monitorBaseParam) {
List<String> monitorIds = commTerminalService.getRunMonitorByDept(monitorBaseParam); List<String> monitorIds = commTerminalService.getRunMonitorByDept(monitorBaseParam);
if(CollectionUtils.isEmpty(monitorIds)){
return new ArrayList<>();
}
List<PqDataVerifyBak> dataVerifyList = baseDataVerifyQuery(monitorIds, monitorBaseParam); List<PqDataVerifyBak> dataVerifyList = baseDataVerifyQuery(monitorIds, monitorBaseParam);
return getAbnormalTable(dataVerifyList, monitorBaseParam); return getAbnormalTable(dataVerifyList, monitorBaseParam);
} }
@@ -373,37 +393,225 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
@Override @Override
public void dataVerifyExcel(HttpServletResponse response, MonitorBaseParam monitorBaseParam) throws IOException { public void dataVerifyExcel(HttpServletResponse response, MonitorBaseParam monitorBaseParam) throws IOException {
if (StrUtil.isNotBlank(monitorBaseParam.getDeptId())) { if (StrUtil.isNotBlank(monitorBaseParam.getDeptId())) {
List<String> monitorIds = commTerminalService.getRunMonitorByDept(monitorBaseParam); DeviceInfoParam param = new DeviceInfoParam();
monitorBaseParam.setMonitorIds(monitorIds); param.setDeptIndex(monitorBaseParam.getDeptId());
} param.setStatisticalType(new SimpleDTO());
List<DataVerifyExcel> dataVerifyExcels = this.baseMapper.selectDataVerifySum(monitorBaseParam); //获取终端台账类信息
List<String> ids = dataVerifyExcels.stream().map(DataVerifyExcel::getLineId).collect(Collectors.toList()); List<GeneralDeviceDTO> deviceInfo = deviceService.getDeviceInfo(param, Arrays.asList(0), Arrays.asList(1));
List<AreaLineInfoVO> areaLineInfoVOList = lineMapper.getBaseLineAreaInfo(ids, null, null); List<String> lineIds = deviceInfo.stream().flatMap(x -> x.getLineIndexes().stream()).distinct().collect(Collectors.toList());
Map<String, AreaLineInfoVO> map = areaLineInfoVOList.stream().collect(Collectors.toMap(AreaLineInfoVO::getLineId, Function.identity())); List<String> devIds = deviceInfo.stream().flatMap(x -> x.getDeviceIndexes().stream()).distinct().collect(Collectors.toList());
for (DataVerifyExcel dataVerifyExcel : dataVerifyExcels) { List<LineInfoMonitorIdVO> areaLineInfoVOList = lineMapper.getBaseLineInfoMonitorIdInfo(lineIds);
if (map.containsKey(dataVerifyExcel.getLineId())) { List<LineInfoMonitorIdVO> monitorLine = areaLineInfoVOList.stream().filter(x -> StrUtil.isNotBlank(x.getMonitorId())).collect(Collectors.toList());
AreaLineInfoVO areaLineInfoVO = map.get(dataVerifyExcel.getLineId()); List<LineInfoMonitorIdVO> gridSide = areaLineInfoVOList.stream().filter(x -> x.getPowerFlag() == 0).collect(Collectors.toList());
dataVerifyExcel.setCity(areaLineInfoVO.getGdName()); List<LineInfoMonitorIdVO> nonGridSide = areaLineInfoVOList.stream().filter(x -> x.getPowerFlag() == 1).collect(Collectors.toList());
dataVerifyExcel.setLineName(areaLineInfoVO.getLineName());
dataVerifyExcel.setLoadType(areaLineInfoVO.getLoadType()); OnlineRateParam onlineRateParam = new OnlineRateParam();
dataVerifyExcel.setObjName(areaLineInfoVO.getObjName()); onlineRateParam.setIds(devIds);
dataVerifyExcel.setStationName(areaLineInfoVO.getSubName()); onlineRateParam.setStartTime(monitorBaseParam.getSearchBeginTime());
dataVerifyExcel.setPowerSubstationName(areaLineInfoVO.getPowerSubstationName()); onlineRateParam.setEndTime(monitorBaseParam.getSearchEndTime());
dataVerifyExcel.setDevName(areaLineInfoVO.getDeviceName()); //完整率
dataVerifyExcel.setIp(areaLineInfoVO.getIp()); List<RStatIntegrityVO> integrityList = integrityDMapper.getLineIntegrityRateInfo(lineIds,
dataVerifyExcel.setManufacturer(areaLineInfoVO.getManufacturer()); 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);
} }

View File

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

View File

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

View File

@@ -557,6 +557,7 @@
detail.ct2, detail.ct2,
detail.pt1, detail.pt1,
detail.pt2, detail.pt2,
detail.PT_Type as ptType,
detail.obj_name, detail.obj_name,
detail.Dev_Capacity deviceCapacity, detail.Dev_Capacity deviceCapacity,
detail.Short_Capacity, detail.Short_Capacity,
@@ -1512,17 +1513,9 @@
<select id="getCustomDetailByLineId" resultType="map"> <select id="getCustomDetailByLineId" resultType="map">
SELECT SELECT
line.id AS lineId, line.id AS lineId,
CONCAT(sub.NAME, '_', vo.NAME, '_', line.NAME) AS lineName, CONCAT(CONCAT(CONCAT(sub.NAME, '_'), vo.NAME), CONCAT('_', line.NAME)) AS lineName,
CONCAT( CONCAT(CONCAT(COALESCE(detail.pt1, 'N/A'), ':'), COALESCE(detail.pt2, 'N/A')) AS pt,
IFNULL(CAST(detail.pt1 AS VARCHAR), 'N/A'), CONCAT(CONCAT(COALESCE(detail.ct1, 'N/A'), ':'), COALESCE(detail.ct2, 'N/A')) AS ct,
':',
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,
detail.Dev_Capacity AS Dev_Capacity, detail.Dev_Capacity AS Dev_Capacity,
detail.Short_Capacity AS Short_Capacity, detail.Short_Capacity AS Short_Capacity,
detail.Standard_Capacity AS Standard_Capacity, detail.Standard_Capacity AS Standard_Capacity,
@@ -1541,6 +1534,7 @@
WHERE WHERE
line.id = #{lineId} line.id = #{lineId}
</select> </select>
<select id="selectByIds" resultType="com.njcn.device.pq.pojo.vo.LineDetailVO$Detail"> <select id="selectByIds" resultType="com.njcn.device.pq.pojo.vo.LineDetailVO$Detail">
SELECT DISTINCT SELECT DISTINCT
line.id as lineId, line.id as lineId,
@@ -1949,5 +1943,83 @@
</foreach> </foreach>
</select> </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> </mapper>

View File

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

View File

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

View File

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

View File

@@ -2021,7 +2021,7 @@ public class ReportServiceImpl implements ReportService {
@Override @Override
public Page<WaveTypeVO> getEventReport(WaveTypeParam deviceInfoParam) { public Page<WaveTypeVO> getEventReport(WaveTypeParam deviceInfoParam) {
Page<WaveTypeVO> page = new Page<>(deviceInfoParam.getPageNum(), deviceInfoParam.getPageSize()); 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()); List<String> lineIds = generalDeviceDTOList.stream().flatMap(dto -> dto.getLineIndexes().stream()).collect(Collectors.toList());
if (CollUtil.isEmpty(lineIds)) { if (CollUtil.isEmpty(lineIds)) {
return page; return page;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -864,7 +864,7 @@ public class OracleResultServiceImpl implements OracleResultService {
String endTime = historyParam.getEndTime(); String endTime = historyParam.getEndTime();
String key = "a1a69c93c11e4910aa247087c261bec5"; String key = "a1a69c93c11e4910aa247087c261bec5";
String secret = "038de3c27cc54489862d181470e3ad92"; 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 apiId = "0644f1c6abd65d3a3a81eb3314390e14";
String apiName = "电能质量谐波监测系统_分布式光伏台区电压日数据_e_mp_TGvol_zl_时间"; String apiName = "电能质量谐波监测系统_分布式光伏台区电压日数据_e_mp_TGvol_zl_时间";
List<HarmonicHistoryV> harmonicHistory = adsDiList(HarmonicHistoryV.class, id, starTime, endTime, key, secret, url, apiId, apiName); 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 endTime = historyParam.getEndTime();
String key = "a1a69c93c11e4910aa247087c261bec5"; String key = "a1a69c93c11e4910aa247087c261bec5";
String secret = "038de3c27cc54489862d181470e3ad92"; 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 apiId = "f9f0eb9627410c0ad4a66ae33a75e2c9";
String apiName = "get_电能质量谐波监测系统_分布式光伏台区功率日数据_e_mp_TGpower_zl_时间"; String apiName = "get_电能质量谐波监测系统_分布式光伏台区功率日数据_e_mp_TGpower_zl_时间";
List<HarmonicHistoryP> harmonicHistory = adsDiList(HarmonicHistoryP.class, id, starTime, endTime, key, secret, url, apiId, apiName); 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 endTime = historyParam.getEndTime();
String key = "a1a69c93c11e4910aa247087c261bec5"; String key = "a1a69c93c11e4910aa247087c261bec5";
String secret = "038de3c27cc54489862d181470e3ad92"; 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 apiId = "bf6cc99505f93c355baad9926b61f17e";
String apiName = "get_电能质量谐波监测系统_分布式光伏台区功率因数日数据_e_mp_TGfactor_zl_时间"; String apiName = "get_电能质量谐波监测系统_分布式光伏台区功率因数日数据_e_mp_TGfactor_zl_时间";
List<HarmonicHistoryC> harmonicHistory = adsDiList(HarmonicHistoryC.class, id, starTime, endTime, key, secret, url, apiId, apiName); List<HarmonicHistoryC> harmonicHistory = adsDiList(HarmonicHistoryC.class, id, starTime, endTime, key, secret, url, apiId, apiName);

View File

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

View File

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

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?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"> <!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 id="getFreqDev" resultType="com.njcn.harmonic.pojo.po.RStatDataVD">
select select

View File

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

View File

@@ -14,6 +14,7 @@ import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONTokener; import cn.hutool.json.JSONTokener;
import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.toolkit.SqlRunner; import com.baomidou.mybatisplus.extension.toolkit.SqlRunner;
import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.pojo.exception.BusinessException;
@@ -157,7 +158,13 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
} else { } else {
phase = PHASE_MAPPING.get(item.getPhase()); 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()); eleEpdPqdList = eleEpdPqdList.stream().filter(it->"T".equals(it.getPhase())||"M".equals(it.getPhase())).collect(Collectors.toList());

View File

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

View File

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

View File

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

View File

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

View File

@@ -15,6 +15,6 @@
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
<!--@mbg.generated--> <!--@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> </sql>
</mapper> </mapper>

View File

@@ -131,7 +131,8 @@ public class EventDictServiceImpl extends ServiceImpl<EventDictMapper, ReportDic
queryWrapper.eq("report_dict.state", DataStateEnum.ENABLE.getCode()).eq("report_dict.Type",dictQueryParam.getType()); queryWrapper.eq("report_dict.state", DataStateEnum.ENABLE.getCode()).eq("report_dict.Type",dictQueryParam.getType());
List<ReportDict> reportAllDicts = this.baseMapper.selectList(queryWrapper); List<ReportDict> reportAllDicts = this.baseMapper.selectList(queryWrapper);
List<ReportDict> reportDicts = new ArrayList<>(); 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); reportDicts.add(reportDict);
getChild(reportDicts, reportDict, reportAllDicts); getChild(reportDicts, reportDict, reportAllDicts);
}); });

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -5,6 +5,7 @@ import com.njcn.common.pojo.response.HttpResult;
import com.njcn.system.api.AreaFeignClient; import com.njcn.system.api.AreaFeignClient;
import com.njcn.system.pojo.po.Area; import com.njcn.system.pojo.po.Area;
import com.njcn.user.mapper.AuthClientMapper; import com.njcn.user.mapper.AuthClientMapper;
import com.njcn.user.pojo.param.AuthClientParam;
import com.njcn.user.pojo.po.AuthClient; import com.njcn.user.pojo.po.AuthClient;
import com.njcn.user.service.IAuthClientService; import com.njcn.user.service.IAuthClientService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 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()) .eq(AuthClient::getState,DataStateEnum.ENABLE.getCode())
.one(); .one();
} }
@Override
public Boolean sessionConfigUpdate(AuthClientParam authClientParam) {
return lambdaUpdate().set(AuthClient::getRefreshTokenValidity,authClientParam.getRefreshTokenValidity())
.set(AuthClient::getAccessTokenValidity,authClientParam.getAccessTokenValidity())
.update();
}
} }

View File

@@ -2,7 +2,6 @@ package com.njcn.user.service.impl;
import com.njcn.common.pojo.enums.common.DataStateEnum; import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.user.pojo.param.PassWordRuleParam; 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.User;
import com.njcn.user.pojo.po.UserStrategy; import com.njcn.user.pojo.po.UserStrategy;
import com.njcn.user.service.IAuthClientService; import com.njcn.user.service.IAuthClientService;
@@ -13,6 +12,9 @@ import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.stream.Collectors;
/** /**
* Description: * Description:
* Date: 2024/7/11 18:06【需求编号】 * Date: 2024/7/11 18:06【需求编号】
@@ -33,19 +35,21 @@ public class PassWordRuleServiceImpl implements IPassWordRuleService {
@Transactional(rollbackFor = {Exception.class}) @Transactional(rollbackFor = {Exception.class})
public Boolean ruleUpdate(PassWordRuleParam passWordRuleParam) { public Boolean ruleUpdate(PassWordRuleParam passWordRuleParam) {
iUserStrategyService.lambdaUpdate().eq(UserStrategy::getType,"1") iUserStrategyService.lambdaUpdate().eq(UserStrategy::getType,passWordRuleParam.getType())
.eq(UserStrategy::getState, DataStateEnum.ENABLE.getCode()) .eq(UserStrategy::getState, DataStateEnum.ENABLE.getCode())
.set(UserStrategy::getLimitPwdTimes,passWordRuleParam.getErrorsCount()) .set(UserStrategy::getLimitPwdTimes,passWordRuleParam.getErrorsCount())
.set(UserStrategy::getLimitPwdDate,passWordRuleParam.getPasswordExpirationMonth()) .set(UserStrategy::getLimitPwdDate,passWordRuleParam.getPasswordExpirationMonth())
.set(UserStrategy::getLockPwdTime,passWordRuleParam.getReleaseTime()) .set(UserStrategy::getLockPwdTime,passWordRuleParam.getReleaseTime())
.set(UserStrategy::getMaxNum,passWordRuleParam.getMaxUseUser()) .set(UserStrategy::getMaxNum,passWordRuleParam.getMaxUseUser())
.set(UserStrategy::getSleep,passWordRuleParam.getSleepDay()) .set(UserStrategy::getSleep,passWordRuleParam.getSleepDay())
.set(UserStrategy::getLockPwdCheck,passWordRuleParam.getLockPwdCheck())
.set(UserStrategy::getLogout,passWordRuleParam.getLogoutDay())
.update(); .update();
iAuthClientService.lambdaUpdate() // iAuthClientService.lambdaUpdate()
.set(AuthClient::getRefreshTokenValidity,passWordRuleParam.getSessionRefreshTime()) // .set(AuthClient::getRefreshTokenValidity,passWordRuleParam.getSessionRefreshTime())
.set(AuthClient::getAccessTokenValidity,passWordRuleParam.getSessionTime()) // .set(AuthClient::getAccessTokenValidity,passWordRuleParam.getSessionTime())
.update(); // .update();
return true; return true;
} }
@@ -59,10 +63,11 @@ public class PassWordRuleServiceImpl implements IPassWordRuleService {
passWordRuleParam.setPasswordExpirationMonth(userStrategy.getLimitPwdDate()); passWordRuleParam.setPasswordExpirationMonth(userStrategy.getLimitPwdDate());
passWordRuleParam.setMaxUseUser(userStrategy.getMaxNum()); passWordRuleParam.setMaxUseUser(userStrategy.getMaxNum());
passWordRuleParam.setSleepDay(userStrategy.getSleep()); passWordRuleParam.setSleepDay(userStrategy.getSleep());
passWordRuleParam.setLockPwdCheck(userStrategy.getLockPwdCheck());
AuthClient authClient = iAuthClientService.lambdaQuery().last(" limit 1").one(); passWordRuleParam.setLogoutDay(userStrategy.getLogout());
passWordRuleParam.setSessionTime(authClient.getAccessTokenValidity()); // AuthClient authClient = iAuthClientService.lambdaQuery().last(" limit 1").one();
passWordRuleParam.setSessionRefreshTime(authClient.getRefreshTokenValidity()); // passWordRuleParam.setSessionTime(authClient.getAccessTokenValidity());
// passWordRuleParam.setSessionRefreshTime(authClient.getRefreshTokenValidity());
return passWordRuleParam; return passWordRuleParam;
} }
@@ -79,4 +84,26 @@ public class PassWordRuleServiceImpl implements IPassWordRuleService {
.eq(UserStrategy::getState, DataStateEnum.ENABLE.getCode()) .eq(UserStrategy::getState, DataStateEnum.ENABLE.getCode())
.one(); .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;
}
} }