8 Commits

Author SHA1 Message Date
hzj
99ab77dcf0 暂降原因暂降类型那边没兼容大小写后缀 2026-02-03 13:42:28 +08:00
hzj
c772c9cd81 修改定版bug 2026-02-02 16:36:30 +08:00
cdf
996ec87ea8 适配达梦 2026-02-01 13:53:43 +08:00
hzj
b6eaff3b1e 修改定版bug 2026-01-30 14:58:15 +08:00
hzj
56bf5bb7c9 修改bug 2026-01-30 10:17:13 +08:00
wr
7410d32241 Merge remote-tracking branch 'origin/main' 2026-01-29 14:15:18 +08:00
wr
41ba37b723 河北数据中台业务参数调整 2026-01-29 10:30:13 +08:00
wr
3f77d30cfd 1.监测点异常统计报表调整 2026-01-28 11:26:52 +08:00
21 changed files with 356 additions and 50 deletions

View File

@@ -9,8 +9,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.advance.enums.AdvanceResponseEnum; import com.njcn.advance.enums.AdvanceResponseEnum;
import com.njcn.advance.mapper.govern.voltage.SgMachineMapper; import com.njcn.advance.mapper.govern.voltage.SgMachineMapper;
import com.njcn.advance.pojo.param.govern.voltage.SgMachineParam; import com.njcn.advance.pojo.param.govern.voltage.SgMachineParam;
import com.njcn.advance.pojo.param.govern.voltage.SgUserParam;
import com.njcn.advance.pojo.po.govern.voltage.SgMachine; import com.njcn.advance.pojo.po.govern.voltage.SgMachine;
import com.njcn.advance.pojo.po.govern.voltage.SgSensitiveUnit; import com.njcn.advance.pojo.po.govern.voltage.SgSensitiveUnit;
import com.njcn.advance.pojo.po.govern.voltage.SgUser;
import com.njcn.advance.pojo.vo.govern.voltage.SgMachineVO; import com.njcn.advance.pojo.vo.govern.voltage.SgMachineVO;
import com.njcn.advance.service.govern.voltage.ISgMachineService; import com.njcn.advance.service.govern.voltage.ISgMachineService;
import com.njcn.advance.service.govern.voltage.ISgSensitiveUnitService; import com.njcn.advance.service.govern.voltage.ISgSensitiveUnitService;
@@ -56,12 +58,34 @@ public class SgMachineServiceImpl extends ServiceImpl<SgMachineMapper, SgMachine
@Override @Override
public String addMachine(SgMachineParam sgMachineParam) { public String addMachine(SgMachineParam sgMachineParam) {
SgMachine sgMachine = new SgMachine(); SgMachine sgMachine = new SgMachine();
checkMachineName(sgMachineParam, false);
BeanUtil.copyProperties(sgMachineParam, sgMachine); BeanUtil.copyProperties(sgMachineParam, sgMachine);
//默认为正常状态 //默认为正常状态
sgMachine.setState(DataStateEnum.ENABLE.getCode()); sgMachine.setState(DataStateEnum.ENABLE.getCode());
this.save(sgMachine); this.save(sgMachine);
return sgMachine.getId(); return sgMachine.getId();
} }
/**
* 校验参数,检查是否存在相同名称的业务用户
*/
private void checkMachineName(SgMachineParam sgMachineParam, boolean isExcludeSelf) {
LambdaQueryWrapper<SgMachine> sgUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
sgUserLambdaQueryWrapper
.eq(SgMachine::getName, sgMachineParam.getName())
.eq(SgMachine::getState, DataStateEnum.ENABLE.getCode());
//更新的时候,需排除当前记录
if (isExcludeSelf) {
if (sgMachineParam instanceof SgMachineParam.SgMachineUpdateParam) {
sgUserLambdaQueryWrapper.ne(SgMachine::getId, ((SgMachineParam.SgMachineUpdateParam) sgMachineParam).getId());
}
}
int countByAccount = this.count(sgUserLambdaQueryWrapper);
//大于等于1个则表示重复
if (countByAccount >= 1) {
throw new BusinessException(AdvanceResponseEnum.SG_USER_NAME_REPEAT);
}
}
/** /**
* 更新设备 * 更新设备
@@ -70,6 +94,8 @@ public class SgMachineServiceImpl extends ServiceImpl<SgMachineMapper, SgMachine
@Override @Override
public boolean updateSgMachine(SgMachineParam.SgMachineUpdateParam updateParam) { public boolean updateSgMachine(SgMachineParam.SgMachineUpdateParam updateParam) {
SgMachine sgMachine = new SgMachine(); SgMachine sgMachine = new SgMachine();
checkMachineName(updateParam, true);
BeanUtil.copyProperties(updateParam, sgMachine); BeanUtil.copyProperties(updateParam, sgMachine);
return this.updateById(sgMachine); return this.updateById(sgMachine);
} }

View File

@@ -2,12 +2,15 @@ package com.njcn.advance.service.govern.voltage.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
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.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.advance.enums.AdvanceResponseEnum; import com.njcn.advance.enums.AdvanceResponseEnum;
import com.njcn.advance.mapper.govern.voltage.SgSensitiveUnitMapper; import com.njcn.advance.mapper.govern.voltage.SgSensitiveUnitMapper;
import com.njcn.advance.pojo.param.govern.voltage.SgMachineParam;
import com.njcn.advance.pojo.param.govern.voltage.SgSensitiveUnitParam; import com.njcn.advance.pojo.param.govern.voltage.SgSensitiveUnitParam;
import com.njcn.advance.pojo.po.govern.voltage.SgMachine;
import com.njcn.advance.pojo.po.govern.voltage.SgSensitiveUnit; import com.njcn.advance.pojo.po.govern.voltage.SgSensitiveUnit;
import com.njcn.advance.pojo.vo.govern.voltage.SgSensitiveUnitVO; import com.njcn.advance.pojo.vo.govern.voltage.SgSensitiveUnitVO;
import com.njcn.advance.service.govern.voltage.ISgSensitiveUnitService; import com.njcn.advance.service.govern.voltage.ISgSensitiveUnitService;
@@ -54,12 +57,34 @@ public class SgSensitiveUnitServiceImpl extends ServiceImpl<SgSensitiveUnitMappe
@Override @Override
public String addSensitiveUnit(SgSensitiveUnitParam sgSensitiveUnitParam) { public String addSensitiveUnit(SgSensitiveUnitParam sgSensitiveUnitParam) {
SgSensitiveUnit sgSensitiveUnit = new SgSensitiveUnit(); SgSensitiveUnit sgSensitiveUnit = new SgSensitiveUnit();
checkSensitiveUnitName(sgSensitiveUnitParam, false);
BeanUtil.copyProperties(sgSensitiveUnitParam, sgSensitiveUnit); BeanUtil.copyProperties(sgSensitiveUnitParam, sgSensitiveUnit);
//默认为正常状态 //默认为正常状态
sgSensitiveUnit.setState(DataStateEnum.ENABLE.getCode()); sgSensitiveUnit.setState(DataStateEnum.ENABLE.getCode());
this.save(sgSensitiveUnit); this.save(sgSensitiveUnit);
return sgSensitiveUnit.getId(); return sgSensitiveUnit.getId();
} }
/**
* 校验参数,检查是否存在相同名称的业务用户
*/
private void checkSensitiveUnitName(SgSensitiveUnitParam sgSensitiveUnitParam, boolean isExcludeSelf) {
LambdaQueryWrapper<SgSensitiveUnit> sgUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
sgUserLambdaQueryWrapper
.eq(SgSensitiveUnit::getName, sgSensitiveUnitParam.getName())
.eq(SgSensitiveUnit::getState, DataStateEnum.ENABLE.getCode());
//更新的时候,需排除当前记录
if (isExcludeSelf) {
if (sgSensitiveUnitParam instanceof SgSensitiveUnitParam.SgSensitiveUnitUpdateParam) {
sgUserLambdaQueryWrapper.ne(SgSensitiveUnit::getId, ((SgSensitiveUnitParam.SgSensitiveUnitUpdateParam) sgSensitiveUnitParam).getId());
}
}
int countByAccount = this.count(sgUserLambdaQueryWrapper);
//大于等于1个则表示重复
if (countByAccount >= 1) {
throw new BusinessException(AdvanceResponseEnum.SG_USER_NAME_REPEAT);
}
}
/** /**
* 更新元器件 * 更新元器件
@@ -69,6 +94,8 @@ public class SgSensitiveUnitServiceImpl extends ServiceImpl<SgSensitiveUnitMappe
@Override @Override
public boolean updateSgSensitiveUnit(SgSensitiveUnitParam.SgSensitiveUnitUpdateParam updateParam) { public boolean updateSgSensitiveUnit(SgSensitiveUnitParam.SgSensitiveUnitUpdateParam updateParam) {
SgSensitiveUnit sgSensitiveUnit = new SgSensitiveUnit(); SgSensitiveUnit sgSensitiveUnit = new SgSensitiveUnit();
checkSensitiveUnitName(updateParam, true);
BeanUtil.copyProperties(updateParam, sgSensitiveUnit); BeanUtil.copyProperties(updateParam, sgSensitiveUnit);
return this.updateById(sgSensitiveUnit); return this.updateById(sgSensitiveUnit);
} }

View File

@@ -512,7 +512,7 @@ public class EventRelevantAnalysisServiceImpl extends ServiceImpl<RmpEventAdvanc
lambdaQueryWrapper.like(RmpEventDetailAssPO::getContentDes, baseParam.getSearchValue()); lambdaQueryWrapper.like(RmpEventDetailAssPO::getContentDes, baseParam.getSearchValue());
} }
lambdaQueryWrapper.between(RmpEventDetailAssPO::getTimeId, timeV.get(0), timeV.get(1)) lambdaQueryWrapper.between(RmpEventDetailAssPO::getTimeId, timeV.get(0), timeV.get(1))
.orderByAsc(RmpEventDetailAssPO::getTimeId); .orderByDesc(RmpEventDetailAssPO::getTimeId);
return rmpEventDetailAssMapper.selectPage(new Page<>(PageFactory.getPageNum(baseParam), PageFactory.getPageSize(baseParam)), lambdaQueryWrapper); return rmpEventDetailAssMapper.selectPage(new Page<>(PageFactory.getPageNum(baseParam), PageFactory.getPageSize(baseParam)), lambdaQueryWrapper);
} }

View File

@@ -81,7 +81,13 @@ public class EventWaveAnalysisServiceImpl implements EventWaveAnalysisService {
inputStreamCfg = fileStorageUtil.getFileStream(OssPath.WAVE_DIR + lineDetailDataVO.getIp() + StrUtil.SLASH + rmpEventDetailPO.getWavePath() + GeneralConstant.CFG); inputStreamCfg = fileStorageUtil.getFileStream(OssPath.WAVE_DIR + lineDetailDataVO.getIp() + StrUtil.SLASH + rmpEventDetailPO.getWavePath() + GeneralConstant.CFG);
inputStreamDat = fileStorageUtil.getFileStream(OssPath.WAVE_DIR + lineDetailDataVO.getIp() + StrUtil.SLASH + rmpEventDetailPO.getWavePath() + GeneralConstant.DAT); inputStreamDat = fileStorageUtil.getFileStream(OssPath.WAVE_DIR + lineDetailDataVO.getIp() + StrUtil.SLASH + rmpEventDetailPO.getWavePath() + GeneralConstant.DAT);
} catch (Exception e) { } catch (Exception e) {
throw new BusinessException("暂降cfg,dat文件缺失,请联系管理员"); try {
inputStreamCfg = fileStorageUtil.getFileStream(OssPath.WAVE_DIR + lineDetailDataVO.getIp() + StrUtil.SLASH + rmpEventDetailPO.getWavePath() + GeneralConstant.CFG.toLowerCase());
inputStreamDat = fileStorageUtil.getFileStream(OssPath.WAVE_DIR + lineDetailDataVO.getIp() + StrUtil.SLASH + rmpEventDetailPO.getWavePath() + GeneralConstant.DAT.toLowerCase());
} catch (Exception e1) {
throw new BusinessException("暂降cfg,dat文件缺失,请联系管理员");
}
} }
//读取 //读取

View File

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

View File

@@ -67,8 +67,8 @@ public class BpmCategoryServiceImpl extends ServiceImpl<BpmCategoryMapper, BpmCa
@Override @Override
public Page<BpmCategoryVO> getCategoryPage(BpmCategoryParam.BpmCategoryQueryParam bpmCategoryQueryParam) { public Page<BpmCategoryVO> getCategoryPage(BpmCategoryParam.BpmCategoryQueryParam bpmCategoryQueryParam) {
QueryWrapper<BpmCategoryVO> categoryVOQueryWrapper = new QueryWrapper<>(); QueryWrapper<BpmCategoryVO> categoryVOQueryWrapper = new QueryWrapper<>();
if (StrUtil.isNotBlank(bpmCategoryQueryParam.getName())) { if (StrUtil.isNotBlank(bpmCategoryQueryParam.getSearchValue())) {
categoryVOQueryWrapper.like("bpm_category.name", bpmCategoryQueryParam.getName()); categoryVOQueryWrapper.like("bpm_category.name", bpmCategoryQueryParam.getSearchValue());
} }
if (StrUtil.isNotBlank(bpmCategoryQueryParam.getCode())) { if (StrUtil.isNotBlank(bpmCategoryQueryParam.getCode())) {

View File

@@ -106,8 +106,8 @@ public class BpmSignServiceImpl extends ServiceImpl<BpmSignMapper, BpmSign> impl
bpmSignVOQueryWrapper.like("bpm_sign.name", bpmSignQueryParam.getName()); bpmSignVOQueryWrapper.like("bpm_sign.name", bpmSignQueryParam.getName());
} }
if (StrUtil.isNotBlank(bpmSignQueryParam.getKey())) { if (StrUtil.isNotBlank(bpmSignQueryParam.getSignKey())) {
bpmSignVOQueryWrapper.like("bpm_sign.signKey", bpmSignQueryParam.getKey()); bpmSignVOQueryWrapper.like("bpm_sign.sign_key", bpmSignQueryParam.getSignKey());
} }
bpmSignVOQueryWrapper.eq("bpm_sign.state", DataStateEnum.ENABLE.getCode()); bpmSignVOQueryWrapper.eq("bpm_sign.state", DataStateEnum.ENABLE.getCode());
bpmSignVOQueryWrapper.orderByAsc("bpm_sign.sort"); bpmSignVOQueryWrapper.orderByAsc("bpm_sign.sort");

View File

@@ -258,7 +258,7 @@ public interface PatternRegex {
/** /**
* 任意字符长度在1-20位常用于名称、编码等常规录入 * 任意字符长度在1-20位常用于名称、编码等常规录入
*/ */
String ALL_CHAR_1_20 = "^[-_A-Za-z0-9\\u4e00-\\u9fa5]{1,20}$"; String ALL_CHAR_1_20 = "^[-_A-Za-z0-9\\u4e00-\\u9fa5]{1,32}$";
String SPECIALCHARACTER ="[<>%'%;()&+/\\\\-\\\\\\\\_|@*?#$!,.]|html"; String SPECIALCHARACTER ="[<>%'%;()&+/\\\\-\\\\\\\\_|@*?#$!,.]|html";

View File

@@ -33,6 +33,8 @@ public class PieGenerator {
Option reasonOption = new Option(); Option reasonOption = new Option();
//取消渲染动画 //取消渲染动画
reasonOption.setAnimation(false); reasonOption.setAnimation(false);
String[] colorArr = {"#526ADE", "#00BFF5","#FFBF00","#77DA63","#D5FF6B"};
reasonOption.setColor(colorArr);
//背景色 //背景色
reasonOption.setBackgroundColor(PicCommonData.PIC_BACK_COLOR); reasonOption.setBackgroundColor(PicCommonData.PIC_BACK_COLOR);
//标题 //标题

View File

@@ -8,6 +8,8 @@ import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.io.Serializable; import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
/** /**
* @version 1.0.0 * @version 1.0.0
@@ -72,7 +74,7 @@ public class DataVerifyExcel implements Serializable {
@ColumnWidth(20) @ColumnWidth(20)
@ExcelProperty(value = "总指标异常时间") @ExcelProperty(value = "总指标异常时间")
@Excel(name = "") @Excel(name = "指标异常时间")
private Integer allTime; private Integer allTime;
@ColumnWidth(20) @ColumnWidth(20)
@@ -191,4 +193,33 @@ public class DataVerifyExcel implements Serializable {
private Integer riseTime; private Integer riseTime;
// 字段名 ↔ Excel列名 映射
public static final Map<String, String> FIELD_COLUMN_MAP = new HashMap<>();
static {
// 按代码中字段顺序整理,确保一一对应
FIELD_COLUMN_MAP.put("freqTime", "频率");
FIELD_COLUMN_MAP.put("freqDevTime", "频率偏差");
FIELD_COLUMN_MAP.put("vRmsTime", "相电压有效值");
FIELD_COLUMN_MAP.put("vPosTime", "正序电压");
FIELD_COLUMN_MAP.put("vNegTime", "负序电压");
FIELD_COLUMN_MAP.put("vZeroTime", "零序电压");
FIELD_COLUMN_MAP.put("vUnbalanceTime", "电压不平衡度");
FIELD_COLUMN_MAP.put("rmsLvrTime", "线电压有效值");
FIELD_COLUMN_MAP.put("vuDevTime", "电压正偏差");
FIELD_COLUMN_MAP.put("vlDevTime", "电压负偏差");
FIELD_COLUMN_MAP.put("vThdTime", "电压总谐波畸变率");
FIELD_COLUMN_MAP.put("vTime", "相电压基波有效值");
FIELD_COLUMN_MAP.put("iRmsTime", "电流有效值");
FIELD_COLUMN_MAP.put("pltTime", "长时闪变");
FIELD_COLUMN_MAP.put("vInharmTime", "间谐波电压含有率");
FIELD_COLUMN_MAP.put("vHarmTime", "谐波电压含有率");
FIELD_COLUMN_MAP.put("pfTime", "功率因数");
FIELD_COLUMN_MAP.put("vPhasicTime", "谐波电压相角");
FIELD_COLUMN_MAP.put("v1PhasicTime", "谐波电压基波相角");
FIELD_COLUMN_MAP.put("flucTime", "电压波动");
FIELD_COLUMN_MAP.put("pstTime", "短时闪变");
FIELD_COLUMN_MAP.put("dipTime", "电压暂降");
FIELD_COLUMN_MAP.put("riseTime", "电压暂升");
}
} }

View File

@@ -0,0 +1,206 @@
package com.njcn.device.pq.utils;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.write.handler.SheetWriteHandler;
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder;
import com.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy;
import com.njcn.device.pq.pojo.vo.dataClean.DataVerifyExcel;
import org.apache.poi.ss.usermodel.Sheet;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.lang.reflect.Field;
import java.util.*;
/**
* 修复版按数据量动态排序Excel列解决列挤在一行的问题
* 关键改动:表头构建方式 + 列宽匹配逻辑
*/
public class FixedDynamicExcelExport {
public static void main(String[] args) throws Exception {
// 1. 模拟测试数据(相电压数据量最多,频率次之,频率偏差最少)
List<DataVerifyExcel> dataList = EasyExcel.read("F:\\usr\\response.xlsx")
.head(DataVerifyExcel.class)
.doReadAllSync();
// 2. 导出Excel替换为你的本地路径比如桌面
dataList.sort(Comparator.comparing((DataVerifyExcel item) -> item.getCity() + "_" + item.getStationName()+"_"+item.getDevName())
.thenComparing(DataVerifyExcel::getAllTime, Comparator.reverseOrder())
);
exportExcelByDataSize(dataList, "D:/dynamic_excel_fixed.xlsx");
System.out.println("导出完成!打开桌面的「测试导出.xlsx」查看效果");
}
/**
* 核心方法按数据量排序导出Excel
*/
public static void exportExcelByDataSize(List<DataVerifyExcel> dataList, String outputPath) throws Exception {
// 步骤1统计每个字段的有效数据量
Map<String, Integer> fieldCount = countValidData(dataList);
// 步骤2按数据量降序排序字段名
List<String> sortedFields = sortFields(fieldCount);
// 步骤3构建正确的动态表头
List<List<String>> head = buildCorrectHead(sortedFields);
// 步骤4构建对应顺序的行数据
List<List<Object>> data = buildRowData(dataList, sortedFields);
// 步骤5导出Excel含列宽设置
try (FileOutputStream out = new FileOutputStream(outputPath)) {
EasyExcel.write(out)
.head(head)
.registerWriteHandler(new SimpleColumnWidthStyleStrategy(20))
.registerWriteHandler(new FreezeHeaderHandler()) // 用修复后的表头
.sheet("数据统计")
.doWrite(data);
}
}
public static void exportExcelByDataSize(List<DataVerifyExcel> dataList, OutputStream outputStream) {
// 步骤1统计每个字段的有效数据量
Map<String, Integer> fieldCount = countValidData(dataList);
// 步骤2按数据量降序排序字段名
List<String> sortedFields = sortFields(fieldCount);
// 步骤3构建正确的动态表头
List<List<String>> head = buildCorrectHead(sortedFields);
// 步骤4构建对应顺序的行数据
List<List<Object>> data = buildRowData(dataList, sortedFields);
// 步骤5导出Excel含列宽设置
EasyExcel.write(outputStream)
.head(head)
.registerWriteHandler(new SimpleColumnWidthStyleStrategy(20))
.registerWriteHandler(new FreezeHeaderHandler()) // 用修复后的表头
.sheet("数据统计")
.doWrite(data);
}
public static class FreezeHeaderHandler implements SheetWriteHandler {
@Override
public void beforeSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) {
// 表格创建前无需操作
}
@Override
public void afterSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) {
Sheet sheet = writeSheetHolder.getSheet();
// freezePane(c, r)c=冻结列数r=冻结行数这里r=1表示冻结第1行表头c=0表示不冻结列
// 比如 freezePane(1, 1) 表示冻结第一列+第一行
sheet.createFreezePane(0, 1);
}
}
// ★ 修复点1构建正确的表头每个列名独立成List
private static List<List<String>> buildCorrectHead(List<String> allFields) {
List<List<String>> head = new ArrayList<>();
head.add(Collections.singletonList("供电公司"));
head.add(Collections.singletonList("所属变电站"));
head.add(Collections.singletonList("终端名称"));
head.add(Collections.singletonList("监测点名称"));
head.add(Collections.singletonList("IP"));
head.add(Collections.singletonList("干扰源类型"));
head.add(Collections.singletonList("监测对象名称"));
head.add(Collections.singletonList("电网侧变电站"));
head.add(Collections.singletonList("厂商"));
head.add(Collections.singletonList("总指标异常时间"));
List<String> sortedFields = allFields.subList(10, allFields.size());
for (String field : sortedFields) {
// 每个列名单独封装成ListEasyExcel才能识别为不同列
head.add(Collections.singletonList(DataVerifyExcel.FIELD_COLUMN_MAP.get(field)));
}
return head;
}
// 统计有效数据量(无改动,保留)
private static Map<String, Integer> countValidData(List<DataVerifyExcel> dataList) {
// 1. 初始化计数字典反射自动提取所有Time结尾的Integer字段初始值0
Map<String, Integer> countMap = initCountMap();
// 2. 判空,避免空指针异常
if (dataList == null || dataList.isEmpty()) {
return countMap;
}
// 3. 获取DataStatistic类的所有字段
Field[] fields = DataVerifyExcel.class.getDeclaredFields();
try {
// 4. 遍历每个数据对象
for (DataVerifyExcel data : dataList) {
// 5. 遍历每个字段,累加数值
for (Field field : fields) {
// 过滤条件Integer类型 + 以Time结尾
if (field.getType() == Integer.class && field.getName().endsWith("Time") ) {
if(!field.getName().equals("allTime")){
// 设置可访问私有字段
field.setAccessible(true);
// 获取当前对象的该字段值
Integer value = (Integer) field.get(data);
// 非空则累加
if (value != null) {
String fieldName = field.getName();
countMap.put(fieldName, countMap.get(fieldName) + value);
}
}
}
}
}
} catch (IllegalAccessException e) {
// 捕获反射访问异常,便于排查问题
throw new RuntimeException("统计字段时反射访问失败", e);
}
return countMap;
}
// 反射初始化计数字典(复用之前的逻辑)
private static Map<String, Integer> initCountMap() {
Map<String, Integer> countMap = new HashMap<>();
Field[] fields = DataVerifyExcel.class.getDeclaredFields();
for (Field field : fields) {
if (field.getType() == Integer.class && field.getName().endsWith("Time")) {
if(!field.getName().equals("allTime")){
countMap.put(field.getName(), 0);
}
}
}
return countMap;
}
// 按数据量排序字段(无改动,保留)
private static List<String> sortFields(Map<String, Integer> fieldCount) {
List<String> fields = new ArrayList<>(fieldCount.keySet());
fields.sort((f1, f2) -> fieldCount.get(f2) - fieldCount.get(f1)); // 降序
List<String> fieldAlls=new ArrayList<>();
fieldAlls.add("city");
fieldAlls.add("stationName");
fieldAlls.add("devName");
fieldAlls.add("lineName");
fieldAlls.add("ip");
fieldAlls.add("loadType");
fieldAlls.add("objName");
fieldAlls.add("powerSubstationName");
fieldAlls.add("manufacturer");
fieldAlls.add("allTime");
fieldAlls.addAll(fields);
return fieldAlls;
}
// 构建行数据(无改动,保留)
private static List<List<Object>> buildRowData(List<DataVerifyExcel> dataList, List<String> sortedFields) {
List<List<Object>> rows = new ArrayList<>();
for (DataVerifyExcel data : dataList) {
List<Object> row = new ArrayList<>();
for (String field : sortedFields) {
try {
Field f = DataVerifyExcel.class.getDeclaredField(field);
f.setAccessible(true);
row.add(f.get(data));
} catch (Exception e) {
throw new RuntimeException("导出异常数据转换异常:"+e);
}
}
rows.add(row);
}
return rows;
}
}

View File

@@ -15,6 +15,7 @@
STATUS = 1 STATUS = 1
</select> </select>
<select id="sortTransformer" resultType="java.lang.Integer"> <select id="sortTransformer" resultType="java.lang.Integer">
select IFNULL(max(pqs_transformer.sort),0) from pqs_transformer order by update_time desc select IFNULL(max(pqs_transformer.sort),0) from pqs_transformer
<!-- order by update_time desc-->
</select> </select>
</mapper> </mapper>

View File

@@ -51,6 +51,8 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.njcn.device.pq.utils.FixedDynamicExcelExport.exportExcelByDataSize;
/** /**
* <p> * <p>
* 服务实现类 * 服务实现类
@@ -392,14 +394,16 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
dataVerifyExcel.setManufacturer(areaLineInfoVO.getManufacturer()); dataVerifyExcel.setManufacturer(areaLineInfoVO.getManufacturer());
} }
} }
Set<String> excludeColumnFiledNames = new HashSet<>(1); dataVerifyExcels.sort(Comparator
excludeColumnFiledNames.add("lineId"); .comparing(DataVerifyExcel::getAllTime, Comparator.reverseOrder())
dataVerifyExcels.sort(Comparator.comparing((DataVerifyExcel item) -> item.getCity() + "_" + item.getStationName()+"_"+item.getDevName()) .thenComparing((DataVerifyExcel item) -> item.getCity() + "_" + item.getStationName()+"_"+item.getDevName())
.thenComparing(DataVerifyExcel::getAllTime, Comparator.reverseOrder())
); );
EasyExcel.write(response.getOutputStream(), DataVerifyExcel.class) exportExcelByDataSize(dataVerifyExcels,response.getOutputStream());
.excludeColumnFiledNames(excludeColumnFiledNames).sheet("sheet") // Set<String> excludeColumnFiledNames = new HashSet<>(1);
.doWrite(dataVerifyExcels); // excludeColumnFiledNames.add("lineId");
// EasyExcel.write(response.getOutputStream(), DataVerifyExcel.class)
// .excludeColumnFiledNames(excludeColumnFiledNames).sheet("sheet")
// .doWrite(dataVerifyExcels);
} }

View File

@@ -119,7 +119,7 @@ public class PqsTflgployServiceImpl extends ServiceImpl<PqsTflgployMapper, PqsTf
} }
private void addList(TflgployParam param, PqsTflgploy tflgploy, boolean save, List<PqsTflgployass> info) { private void addList(TflgployParam param, PqsTflgploy tflgploy, boolean save, List<PqsTflgployass> info) {
if(save){ // if(save){
List<String> tfIndexs = param.getTfIndexs(); List<String> tfIndexs = param.getTfIndexs();
if(CollUtil.isNotEmpty(tfIndexs)){ if(CollUtil.isNotEmpty(tfIndexs)){
PqsTflgployass ass; PqsTflgployass ass;
@@ -129,7 +129,7 @@ public class PqsTflgployServiceImpl extends ServiceImpl<PqsTflgployMapper, PqsTf
ass.setTfIndex(tfIndex); ass.setTfIndex(tfIndex);
info.add(ass); info.add(ass);
} }
} // }
} }
} }

View File

@@ -198,7 +198,7 @@ public class DeviceController extends BaseController {
@ApiOperation("修改装置通讯状态及时间") @ApiOperation("修改装置通讯状态及时间")
public HttpResult<Boolean> updateDevComFlag(@RequestBody DevComFlagDTO devComFlagDTO) { public HttpResult<Boolean> updateDevComFlag(@RequestBody DevComFlagDTO devComFlagDTO) {
String methodDescribe = getMethodDescribe("updateDevComFlag"); String methodDescribe = getMethodDescribe("updateDevComFlag");
boolean update = iDeviceService.lambdaUpdate().set(Objects.nonNull(devComFlagDTO.getStatus()),Device::getComFlag,devComFlagDTO.getStatus() ).set(Device::getUpdateTime, devComFlagDTO.getDate()).eq(Device::getId, devComFlagDTO.getId()).update(); boolean update = iDeviceService.lambdaUpdate().set(Objects.nonNull(devComFlagDTO.getStatus()),Device::getComFlag,devComFlagDTO.getStatus() ).set(Objects.nonNull(devComFlagDTO.getDate()),Device::getUpdateTime, devComFlagDTO.getDate()).eq(Device::getId, devComFlagDTO.getId()).update();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, update, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, update, methodDescribe);
} }

View File

@@ -38,7 +38,7 @@ public class TerminalVersionServiceImpl implements TerminalVersionService {
List<TerminalVersionVO> devList = terminalVersionMapper.getTerminalVersionInfo(terminalMainQueryParam); List<TerminalVersionVO> devList = terminalVersionMapper.getTerminalVersionInfo(terminalMainQueryParam);
if(CollectionUtil.isEmpty(devList)){ if(CollectionUtil.isEmpty(devList)){
throw new BusinessException(DeviceResponseEnum.DEVICE_EMPTY); return devList;
} }
List<String> subIndexes = devList.stream().map(TerminalVersionVO::getPid).collect(Collectors.toList()); List<String> subIndexes = devList.stream().map(TerminalVersionVO::getPid).collect(Collectors.toList());
List<TerminalVersionVO> subList =terminalVersionMapper.getPqLineGdAndSubList(subIndexes); List<TerminalVersionVO> subList =terminalVersionMapper.getPqLineGdAndSubList(subIndexes);

View File

@@ -43,7 +43,7 @@
a.name lineName, a.name lineName,
c.Time_Interval, c.Time_Interval,
d.Scale AS scale, d.Scale AS scale,
c.Obj_Id obyId, c.Obj_Id objId,
c.Big_Obj_Type bigObjType c.Big_Obj_Type bigObjType
from pq_line a from pq_line a
inner join pq_line b on a.pid = b.id inner join pq_line b on a.pid = b.id

View File

@@ -1269,7 +1269,8 @@
SELECT SELECT
voltage.id as id, voltage.id as id,
sub.id as pid, sub.id as pid,
concat( sub.NAME, " ", voltage.NAME ) as name, <!-- 兼容国产数据库-->
concat( sub.NAME, ' ', voltage.NAME ) as name,
voltage.Sort as sort voltage.Sort as sort
FROM FROM
pq_line voltage pq_line voltage
@@ -1513,14 +1514,14 @@
line.id AS lineId, line.id AS lineId,
CONCAT(sub.NAME, '_', vo.NAME, '_', line.NAME) AS lineName, CONCAT(sub.NAME, '_', vo.NAME, '_', line.NAME) AS lineName,
CONCAT( CONCAT(
IFNULL(CAST(detail.pt1 AS CHAR), 'N/A'), IFNULL(CAST(detail.pt1 AS VARCHAR), 'N/A'),
':', ':',
IFNULL(CAST(detail.pt2 AS CHAR), 'N/A') IFNULL(CAST(detail.pt2 AS VARCHAR), 'N/A')
) AS pt, ) AS pt,
CONCAT( CONCAT(
IFNULL(CAST(detail.ct1 AS CHAR), 'N/A'), IFNULL(CAST(detail.ct1 AS VARCHAR), 'N/A'),
':', ':',
IFNULL(CAST(detail.ct2 AS CHAR), 'N/A') IFNULL(CAST(detail.ct2 AS VARCHAR), 'N/A')
) AS ct, ) 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,

View File

@@ -148,7 +148,7 @@
<select id="getMonthFlow" resultType="com.njcn.device.pq.pojo.vo.LineFlowMealDetailVO"> <select id="getMonthFlow" resultType="com.njcn.device.pq.pojo.vo.LineFlowMealDetailVO">
select t.*, select t.*,
(t.statisValue)/t.flowMeal flowProportion (t.statisValue / t.flowMeal) as flowProportion
from ( from (
SELECT SELECT
a.id id, a.id id,
@@ -158,8 +158,6 @@
gd.name electricPowerCompany, gd.name electricPowerCompany,
b.IP DeviceIP, b.IP DeviceIP,
b.id deviceId, b.id deviceId,
-- ifnull(d.flow, (select flow from cld_flow_meal where type = 0 and flag = 1)) + ifnull(d1.flow, 0) flowMeal,
-- ifnull(convert(m.Actual_Value/1024/1024,decimal(7,2)),0) statisValue
COALESCE(d.flow, (SELECT flow FROM cld_flow_meal WHERE type = 0 AND flag = 1)) + COALESCE(d1.flow, 0) AS flowMeal, COALESCE(d.flow, (SELECT flow FROM cld_flow_meal WHERE type = 0 AND flag = 1)) + COALESCE(d1.flow, 0) AS flowMeal,
COALESCE(CAST(m.Actual_Value / 1024 / 1024 AS DECIMAL(7, 2)), 0) AS statisValue COALESCE(CAST(m.Actual_Value / 1024 / 1024 AS DECIMAL(7, 2)), 0) AS statisValue
FROM pq_line a FROM pq_line a
@@ -170,16 +168,20 @@
LEFT JOIN cld_dev_meal c ON b.id = c.line_id LEFT JOIN cld_dev_meal c ON b.id = c.line_id
LEFT JOIN cld_flow_meal d ON c.Base_Meal_Id = d.id LEFT JOIN cld_flow_meal d ON c.Base_Meal_Id = d.id
LEFT JOIN cld_flow_meal d1 ON c.Ream_Meal_Id = d1.id LEFT JOIN cld_flow_meal d1 ON c.Ream_Meal_Id = d1.id
WHERE a.id IN <where>
a.id IN
<foreach item="item" collection="devs" separator="," open="(" close=")"> <foreach item="item" collection="devs" separator="," open="(" close=")">
#{item} #{item}
</foreach> </foreach>
AND <if test="startTime != null and endTime != null">
m.Time_Id between #{startTime} and #{endTime} AND
AND m.Time_Id between #{startTime} and #{endTime}
</if>
AND
b.Run_Flag != 2 b.Run_Flag != 2
</where>
) t ) t
ORDER BY flowProportion DESC ORDER BY flowProportion DESC ;
</select> </select>
<select id="getMonthFlowNew" resultType="com.njcn.device.pq.pojo.vo.LineFlowMealDetailVO"> <select id="getMonthFlowNew" resultType="com.njcn.device.pq.pojo.vo.LineFlowMealDetailVO">

View File

@@ -747,8 +747,8 @@ public class ReportServiceImpl implements ReportService {
bodyFont.setFontHeightInPoints((short) 9); bodyFont.setFontHeightInPoints((short) 9);
bodyStyle.setFont(bodyFont); bodyStyle.setFont(bodyFont);
sheet2(sheets, cellStyle, bodyStyle, businessParam);
sheet3(sheets, cellStyle, bodyStyle, businessParam); sheet3(sheets, cellStyle, bodyStyle, businessParam);
sheet2(sheets, cellStyle, bodyStyle, businessParam);
sheet4(sheets, cellStyle, bodyStyle, businessParam); sheet4(sheets, cellStyle, bodyStyle, businessParam);
sheet5(sheets, cellStyle, bodyStyle, businessParam); sheet5(sheets, cellStyle, bodyStyle, businessParam);
sheet6(sheets, cellStyle, bodyStyle, businessParam); sheet6(sheets, cellStyle, bodyStyle, businessParam);
@@ -909,7 +909,7 @@ public class ReportServiceImpl implements ReportService {
public void sheet2(HSSFWorkbook sheets, HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle, DeviceInfoParam.BusinessParam businessParam) { public void sheet2(HSSFWorkbook sheets, HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle, DeviceInfoParam.BusinessParam businessParam) {
sheets.createSheet("暂态严重度统计"); sheets.createSheet("暂态严重度统计");
HSSFSheet sheetAt = sheets.getSheetAt(1); HSSFSheet sheetAt = sheets.getSheetAt(2);
sheetAt.setColumnWidth(0, 24 * 256); sheetAt.setColumnWidth(0, 24 * 256);
sheetAt.setColumnWidth(1, 24 * 256); sheetAt.setColumnWidth(1, 24 * 256);
sheetAt.setColumnWidth(2, 24 * 256); sheetAt.setColumnWidth(2, 24 * 256);
@@ -1001,7 +1001,7 @@ public class ReportServiceImpl implements ReportService {
public void sheet3(HSSFWorkbook sheets, HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle, DeviceInfoParam.BusinessParam businessParam) throws TemplateException, IOException { public void sheet3(HSSFWorkbook sheets, HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle, DeviceInfoParam.BusinessParam businessParam) throws TemplateException, IOException {
sheets.createSheet("暂态原因统计"); sheets.createSheet("暂态原因统计");
HSSFSheet sheetAt = sheets.getSheetAt(2); HSSFSheet sheetAt = sheets.getSheetAt(1);
sheetAt.setColumnWidth(0, 40 * 256); sheetAt.setColumnWidth(0, 40 * 256);
sheetAt.setColumnWidth(1, 40 * 256); sheetAt.setColumnWidth(1, 40 * 256);
sheetAt.setColumnWidth(2, 40 * 256); sheetAt.setColumnWidth(2, 40 * 256);

View File

@@ -862,10 +862,10 @@ public class OracleResultServiceImpl implements OracleResultService {
String id = historyParam.getLineId(); String id = historyParam.getLineId();
String starTime = historyParam.getStartTime(); String starTime = historyParam.getStartTime();
String endTime = historyParam.getEndTime(); String endTime = historyParam.getEndTime();
String key = "0e3bac160fd246f181ad4fd47da6929a"; String key = "a1a69c93c11e4910aa247087c261bec5";
String secret = "383b4b2536234d84ac909cd605762061"; String secret = "038de3c27cc54489862d181470e3ad92";
String url = "http://8d051549520e423ab8dccf8b3d457c74.apigw.he-region-2.sgic.sgcc.com.cn/ast/ydxxcjxt/dws/get_e_mp_TGvol_zl_ds"; String url = "https://25.37.90.72/ast/ydxxcjxt/dws/get_e_mp_TGvol_zl_ds";
String apiId = "46e61646481c0146e26ba79bb5c8fa05"; 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);
return ztDataV(harmonicHistory); return ztDataV(harmonicHistory);
@@ -875,10 +875,10 @@ public class OracleResultServiceImpl implements OracleResultService {
String id = historyParam.getLineId(); String id = historyParam.getLineId();
String starTime = historyParam.getStartTime(); String starTime = historyParam.getStartTime();
String endTime = historyParam.getEndTime(); String endTime = historyParam.getEndTime();
String key = "0e3bac160fd246f181ad4fd47da6929a"; String key = "a1a69c93c11e4910aa247087c261bec5";
String secret = "383b4b2536234d84ac909cd605762061"; String secret = "038de3c27cc54489862d181470e3ad92";
String url = "http://8d051549520e423ab8dccf8b3d457c74.apigw.he-region-2.sgic.sgcc.com.cn/ast/ydxxcjxt/dws/get_e_mp_TGpower_zl_ds"; String url = "https://25.37.90.72/ast/ydxxcjxt/dws/get_e_mp_TGpower_zl_ds";
String apiId = "9db49fdc30dbc3bf6fa4f5cce141416c"; 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);
return ztDataP(harmonicHistory,type); return ztDataP(harmonicHistory,type);
@@ -888,10 +888,10 @@ public class OracleResultServiceImpl implements OracleResultService {
String id = historyParam.getLineId(); String id = historyParam.getLineId();
String starTime = historyParam.getStartTime(); String starTime = historyParam.getStartTime();
String endTime = historyParam.getEndTime(); String endTime = historyParam.getEndTime();
String key = "0e3bac160fd246f181ad4fd47da6929a"; String key = "a1a69c93c11e4910aa247087c261bec5";
String secret = "383b4b2536234d84ac909cd605762061"; String secret = "038de3c27cc54489862d181470e3ad92";
String url = "http://8d051549520e423ab8dccf8b3d457c74.apigw.he-region-2.sgic.sgcc.com.cn/ast/ydxxcjxt/dws/get_e_mp_TGfactor_zl_ds"; String url = "https://25.37.90.72/ast/ydxxcjxt/dws/get_e_mp_TGfactor_zl_ds";
String apiId = "9c3ebd9c19dc0eb8e24385e40bd50a53"; 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);
return ztDataC(harmonicHistory,type); return ztDataC(harmonicHistory,type);