16 Commits

Author SHA1 Message Date
xy
3727b5777e 1.新增工程项目管理接口
2.调整报表数据不对的问题
2026-01-30 15:21:07 +08:00
xy
c3cb9a5f85 报告兼容 2026-01-28 13:26:32 +08:00
xy
05ef7028c4 报表添加接线方式、一二次值判断 2026-01-28 08:44:45 +08:00
xy
736b0a6e60 调整overLimitMapper使用公共文件 2026-01-19 14:01:29 +08:00
cdf
cc63cead04 暂降监测点报告抽取公共方法 2026-01-19 11:29:53 +08:00
cdf
30bc3c7448 暂降监测点报告抽取公共方法 2026-01-17 20:26:28 +08:00
cdf
51a16c5701 监测点报告抽取公共方法 2026-01-17 13:40:29 +08:00
xy
4497699178 1.监测点运行状态数据调整;
2.暂态事件同步
2026-01-16 14:57:44 +08:00
xy
0ac51648f4 bug修复 2026-01-15 14:17:24 +08:00
xy
fb515cca9b bug修复 2026-01-15 13:32:29 +08:00
xy
14d77725aa 微调 2026-01-14 20:32:34 +08:00
xy
ee87ffb0d4 微调 2026-01-12 09:36:47 +08:00
xy
5ff8c946aa 组态新增压缩包文件上传下载功能 2026-01-09 16:57:22 +08:00
xy
cccc73f211 前置日志优化 2026-01-08 20:16:45 +08:00
xy
4882151ccd 台账添加监测位置 2026-01-07 20:53:24 +08:00
xy
b774b7ce91 基于云平台功能调整 2026-01-07 19:20:11 +08:00
105 changed files with 7612 additions and 7473 deletions

View File

@@ -81,4 +81,7 @@ public interface CsLineFeignClient {
@PostMapping("/getLineDetailData") @PostMapping("/getLineDetailData")
HttpResult<LineDetailDataVO> getLineDetailData(@RequestParam("id") String id); HttpResult<LineDetailDataVO> getLineDetailData(@RequestParam("id") String id);
@GetMapping("/getSimpleLine")
HttpResult<List<CsLinePO>> getSimpleLine();
} }

View File

@@ -3,7 +3,7 @@ package com.njcn.csdevice.api;
import com.njcn.common.pojo.constant.ServerInfo; import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csdevice.api.fallback.CsOverLimitFallbackFactory; import com.njcn.csdevice.api.fallback.CsOverLimitFallbackFactory;
import com.njcn.csdevice.pojo.po.Overlimit; import com.njcn.device.biz.pojo.po.Overlimit;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;

View File

@@ -131,6 +131,12 @@ public class CsLineClientFallbackFactory implements FallbackFactory<CsLineFeignC
log.error("{}异常,降级处理,异常为:{}","查询监测点详情异常",cause.toString()); log.error("{}异常,降级处理,异常为:{}","查询监测点详情异常",cause.toString());
throw new BusinessException(finalExceptionEnum); throw new BusinessException(finalExceptionEnum);
} }
@Override
public HttpResult<List<CsLinePO>> getSimpleLine() {
log.error("{}异常,降级处理,异常为:{}","查询登录用户拥有的监测点台账",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
}; };
} }
} }

View File

@@ -4,7 +4,7 @@ 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.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csdevice.api.CsOverLimitClient; import com.njcn.csdevice.api.CsOverLimitClient;
import com.njcn.csdevice.pojo.po.Overlimit; import com.njcn.device.biz.pojo.po.Overlimit;
import com.njcn.device.biz.utils.DeviceEnumUtil; import com.njcn.device.biz.utils.DeviceEnumUtil;
import feign.hystrix.FallbackFactory; import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;

View File

@@ -58,7 +58,7 @@ public interface DataParam {
String GOVERNANCE_SYSTEM = "治理系统"; String GOVERNANCE_SYSTEM = "治理系统";
String cldDev = "在线设备"; String cldDev = "监测设备";
String EvtParamPhase = "Evt_Param_Phase"; String EvtParamPhase = "Evt_Param_Phase";

View File

@@ -55,4 +55,7 @@ public class AppProjectAddParm {
@ApiModelProperty(value="拓扑图模版id集合") @ApiModelProperty(value="拓扑图模版id集合")
private List<String> topoIds; private List<String> topoIds;
@ApiModelProperty(value="排序")
private Integer sort;
} }

View File

@@ -44,4 +44,7 @@ public class AppProjectAuditParm {
private List<String> topoIds; private List<String> topoIds;
private List<String> newTopoIds; private List<String> newTopoIds;
@ApiModelProperty(value="排序")
private Integer sort;
} }

View File

@@ -53,6 +53,10 @@ public class CsEngineeringAddParm {
@ApiModelProperty(value = "描述") @ApiModelProperty(value = "描述")
private String description; private String description;
/**
* 描述
*/
@ApiModelProperty(value = "排序")
private Integer sort;
} }

View File

@@ -54,6 +54,7 @@ public class CsEngineeringAuditParm {
@ApiModelProperty(value="0删除 1正常") @ApiModelProperty(value="0删除 1正常")
private String status; private String status;
@ApiModelProperty(value="排序")
private Integer sort;
} }

View File

@@ -140,6 +140,11 @@ public class CsLineParam extends BaseEntity {
*/ */
private String monitorUser; private String monitorUser;
/**
* 监测位置
*/
private String position;
} }

View File

@@ -23,31 +23,31 @@ public class DeviceExcelTemplete implements Serializable {
/** /**
* 装置名称 * 装置名称
*/ */
@Excel(name = "装置名称", width = 15) @Excel(name = "设备名称", width = 15)
private String name; private String name;
/** /**
* 网关识别码 * 网关识别码
*/ */
@Excel(name = "关识别码", width = 15) @Excel(name = "络设备ID", width = 15)
private String ndid; private String ndid;
/** /**
* 装置类型(直连设备、网关设备、装置) * 装置类型(直连设备、网关设备、装置)
*/ */
@Excel(name = "装置类型(直连设备,网关设备)", width = 30) @Excel(name = "设备类型(直连设备,网关设备、便携式设备", width = 30)
private String devType; private String devType;
/** /**
* 装置型号pqs588、pqs680... * 装置型号pqs588、pqs680...
*/ */
@Excel(name = "装置型号", width = 15) @Excel(name = "设备型号", width = 15)
private String devModel; private String devModel;
/** /**
* 装置接入方式mqtt、cloud * 装置接入方式mqtt、cloud
*/ */
@Excel(name = "装置接入方式mqtt、cloud", width = 25) @Excel(name = "通讯协议MQTT、CLD", width = 25)
private String devAccessMethod; private String devAccessMethod;
/** /**

View File

@@ -57,5 +57,8 @@ public class AppProjectPO extends BaseEntity {
@TableField(value = "description") @TableField(value = "description")
private String description; private String description;
@TableField(value = "sort")
private Integer sort;
} }

View File

@@ -64,5 +64,10 @@ public class CsEngineeringPO extends BaseEntity {
@TableField(value = "status") @TableField(value = "status")
private String status; private String status;
/**
* 排序
*/
@TableField(value = "sort")
private Integer sort;
} }

View File

@@ -0,0 +1,59 @@
package com.njcn.csdevice.pojo.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @author xy
* 日志信息
*/
@Data
public class EngineeringProjectRelationVo implements Serializable {
//工程信息
@ApiModelProperty("工程id")
private String engineeringId;
@ApiModelProperty("工程名称")
private String engineeringName;
@ApiModelProperty("区域")
private String engineeringArea;
@ApiModelProperty("工程备注")
private String engineeringRemark;
@ApiModelProperty("工程排序")
private Integer engineeringSort;
@ApiModelProperty("项目信息")
private List<ProjectInfo> projectInfoList;
//项目信息
@Data
public static class ProjectInfo implements Serializable {
@ApiModelProperty("项目id")
private String projectId;
@ApiModelProperty("项目名称")
private String projectName;
@ApiModelProperty("项目地址")
private String projectArea;
@ApiModelProperty("项目备注")
private String projectRemark;
@ApiModelProperty("项目排序")
private Integer projectSort;
@ApiModelProperty("拓扑图信息")
private String topologyInfo;
}
}

View File

@@ -1,383 +1,383 @@
package com.njcn.csdevice.utils; //package com.njcn.csdevice.utils;
//
import com.njcn.csdevice.pojo.po.Overlimit; //import com.njcn.csdevice.pojo.po.Overlimit;
import com.njcn.device.biz.enums.RunFlagEnum; //import com.njcn.device.biz.enums.RunFlagEnum;
import com.njcn.system.enums.DicDataEnum; //import com.njcn.system.enums.DicDataEnum;
//
import java.math.BigDecimal; //import java.math.BigDecimal;
import java.math.RoundingMode; //import java.math.RoundingMode;
import java.util.Objects; //import java.util.Objects;
//
//
/** ///**
* pqs // * pqs
* 限值计算工具类 // * 限值计算工具类
* // *
* @author cdf // * @author cdf
* @date 2023/5/15 // * @date 2023/5/15
*/ // */
public class COverlimitUtil { //public class COverlimitUtil {
//
//
/** // /**
* 谐波电流系数 // * 谐波电流系数
*/ // */
private static final double[][] ARR = { // private static final double[][] ARR = {
{78, 62, 39, 62, 26, 44, 19, 21, 16, 28, 13, 24, 11, 12, 9.7, 18, 8.6, 16, 7.8, 8.9, 7.1, 14, 6.5, 12, 6.0, 6.9, 5.6, 11, 5.2, 10, 4.9, 5.6, 4.6, 8.9, 4.3, 8.4, 4.1, 4.8, 3.9, 7.6, 3.7, 7.2, 3.5, 4.1, 3.4, 6.6, 3.3, 6.3, 3.1}, // {78, 62, 39, 62, 26, 44, 19, 21, 16, 28, 13, 24, 11, 12, 9.7, 18, 8.6, 16, 7.8, 8.9, 7.1, 14, 6.5, 12, 6.0, 6.9, 5.6, 11, 5.2, 10, 4.9, 5.6, 4.6, 8.9, 4.3, 8.4, 4.1, 4.8, 3.9, 7.6, 3.7, 7.2, 3.5, 4.1, 3.4, 6.6, 3.3, 6.3, 3.1},
{43, 34, 21, 34, 14, 24, 11, 11, 8.5, 16, 7.1, 13, 6.1, 6.8, 5.3, 10, 4.7, 9, 4.3, 4.9, 3.9, 7.4, 3.6, 6.8, 3.3, 3.8, 3.1, 5.9, 2.9, 5.5, 2.7, 3.1, 2.5, 4.9, 2.4, 4.6, 2.3, 2.6, 2.2, 4.1, 2.0, 4.0, 2.0, 2.3, 1.9, 3.6, 1.8, 3.5, 1.7}, // {43, 34, 21, 34, 14, 24, 11, 11, 8.5, 16, 7.1, 13, 6.1, 6.8, 5.3, 10, 4.7, 9, 4.3, 4.9, 3.9, 7.4, 3.6, 6.8, 3.3, 3.8, 3.1, 5.9, 2.9, 5.5, 2.7, 3.1, 2.5, 4.9, 2.4, 4.6, 2.3, 2.6, 2.2, 4.1, 2.0, 4.0, 2.0, 2.3, 1.9, 3.6, 1.8, 3.5, 1.7},
{26, 20, 13, 20, 8.5, 15, 6.4, 6.8, 5.1, 9.3, 4.3, 7.9, 3.7, 4.1, 3.2, 6, 2.8, 5.4, 2.6, 2.9, 2.3, 4.5, 2.1, 4.1, 2.0, 2.2, 1.9, 3.4, 1.7, 3.2, 1.6, 1.8, 1.5, 2.9, 1.4, 2.7, 1.4, 1.5, 1.3, 2.4, 1.2, 2.3, 1.2, 1.3, 1.1, 2.1, 1.1, 2.0, 1.0}, // {26, 20, 13, 20, 8.5, 15, 6.4, 6.8, 5.1, 9.3, 4.3, 7.9, 3.7, 4.1, 3.2, 6, 2.8, 5.4, 2.6, 2.9, 2.3, 4.5, 2.1, 4.1, 2.0, 2.2, 1.9, 3.4, 1.7, 3.2, 1.6, 1.8, 1.5, 2.9, 1.4, 2.7, 1.4, 1.5, 1.3, 2.4, 1.2, 2.3, 1.2, 1.3, 1.1, 2.1, 1.1, 2.0, 1.0},
{15, 12, 7.7, 12, 5.1, 8.8, 3.8, 4.1, 3.1, 5.6, 2.6, 4.7, 2.2, 2.5, 1.9, 3.6, 1.7, 3.2, 1.5, 1.8, 1.4, 2.7, 1.3, 2.5, 1.2, 1.3, 1.1, 2.1, 1.0, 1.9, 0.9, 1.1, 0.9, 1.7, 0.8, 1.6, 0.8, 0.9, 0.8, 1.5, 0.7, 1.4, 0.7, 0.8, 0.7, 1.3, 0.6, 1.2, 0.6}, // {15, 12, 7.7, 12, 5.1, 8.8, 3.8, 4.1, 3.1, 5.6, 2.6, 4.7, 2.2, 2.5, 1.9, 3.6, 1.7, 3.2, 1.5, 1.8, 1.4, 2.7, 1.3, 2.5, 1.2, 1.3, 1.1, 2.1, 1.0, 1.9, 0.9, 1.1, 0.9, 1.7, 0.8, 1.6, 0.8, 0.9, 0.8, 1.5, 0.7, 1.4, 0.7, 0.8, 0.7, 1.3, 0.6, 1.2, 0.6},
{16, 13, 8.1, 13, 5.4, 9.3, 4.1, 4.3, 3.3, 5.9, 2.7, 5, 2.3, 2.6, 2, 3.8, 1.8, 3.4, 1.6, 1.9, 1.5, 2.8, 1.4, 2.6, 1.2, 1.4, 1.1, 2.2, 1.1, 2.1, 1.0, 1.2, 0.9, 1.9, 0.9, 1.8, 0.8, 1.0, 0.8, 1.6, 0.8, 1.5, 0.7, 0.9, 0.7, 1.4, 0.7, 1.3, 0.6}, // {16, 13, 8.1, 13, 5.4, 9.3, 4.1, 4.3, 3.3, 5.9, 2.7, 5, 2.3, 2.6, 2, 3.8, 1.8, 3.4, 1.6, 1.9, 1.5, 2.8, 1.4, 2.6, 1.2, 1.4, 1.1, 2.2, 1.1, 2.1, 1.0, 1.2, 0.9, 1.9, 0.9, 1.8, 0.8, 1.0, 0.8, 1.6, 0.8, 1.5, 0.7, 0.9, 0.7, 1.4, 0.7, 1.3, 0.6},
{12, 9.6, 6, 9.6, 4, 6.8, 3, 3.2, 2.4, 4.3, 2, 3.7, 1.7, 1.9, 1.5, 2.8, 1.3, 2.5, 1.2, 1.4, 1.1, 2.1, 1, 1.9, 0.9, 1.1, 0.9, 1.7, 0.8, 1.5, 0.8, 0.9, 0.7, 1.4, 0.7, 1.3, 0.6, 0.7, 0.6, 1.2, 0.6, 1.1, 0.5, 0.6, 0.5, 1.0, 0.5, 1.0, 0.5} // {12, 9.6, 6, 9.6, 4, 6.8, 3, 3.2, 2.4, 4.3, 2, 3.7, 1.7, 1.9, 1.5, 2.8, 1.3, 2.5, 1.2, 1.4, 1.1, 2.1, 1, 1.9, 0.9, 1.1, 0.9, 1.7, 0.8, 1.5, 0.8, 0.9, 0.7, 1.4, 0.7, 1.3, 0.6, 0.7, 0.6, 1.2, 0.6, 1.1, 0.5, 0.6, 0.5, 1.0, 0.5, 1.0, 0.5}
}; // };
//
//
/** // /**
* 计算监测点限值 // * 计算监测点限值
* @param voltageLevel 电压等级10kV = 10 220kV = 220 // * @param voltageLevel 电压等级10kV = 10 220kV = 220
* @param protocolCapacity 协议容量 // * @param protocolCapacity 协议容量
* @param devCapacity 设备容量 // * @param devCapacity 设备容量
* @param shortCapacity 短路容量 // * @param shortCapacity 短路容量
* @param powerFlag 0.用户侧 1.电网侧 // * @param powerFlag 0.用户侧 1.电网侧
* @param lineType 0.主网 1.配网 需要注意配网目前没有四种容量,谐波电流幅值限值,负序电流限值无法计算默认-3.14159 // * @param lineType 0.主网 1.配网 需要注意配网目前没有四种容量,谐波电流幅值限值,负序电流限值无法计算默认-3.14159
*/ // */
public static Overlimit globalAssemble(Float voltageLevel, Float protocolCapacity, Float devCapacity, // public static Overlimit globalAssemble(Float voltageLevel, Float protocolCapacity, Float devCapacity,
Float shortCapacity, Integer powerFlag, Integer lineType) { // Float shortCapacity, Integer powerFlag, Integer lineType) {
Overlimit overlimit = new Overlimit(); // Overlimit overlimit = new Overlimit();
voltageDeviation(overlimit,voltageLevel); // voltageDeviation(overlimit,voltageLevel);
frequency(overlimit); // frequency(overlimit);
voltageFluctuation(overlimit,voltageLevel); // voltageFluctuation(overlimit,voltageLevel);
voltageFlicker(overlimit,voltageLevel); // voltageFlicker(overlimit,voltageLevel);
totalHarmonicDistortion(overlimit,voltageLevel); // totalHarmonicDistortion(overlimit,voltageLevel);
uHarm(overlimit,voltageLevel); // uHarm(overlimit,voltageLevel);
threeVoltageUnbalance(overlimit); // threeVoltageUnbalance(overlimit);
interharmonicCurrent(overlimit,voltageLevel); // interharmonicCurrent(overlimit,voltageLevel);
//
if(Objects.equals(lineType, RunFlagEnum.PW_FLAG.getStatus())) { // if(Objects.equals(lineType, RunFlagEnum.PW_FLAG.getStatus())) {
//配网 // //配网
Float[] iHarmTem = new Float[49]; // Float[] iHarmTem = new Float[49];
for (int i = 0; i <= 48; i++) { // for (int i = 0; i <= 48; i++) {
//
iHarmTem[i] = -3.14159f; // iHarmTem[i] = -3.14159f;
} // }
overlimit.buildIHarm(iHarmTem); // overlimit.buildIHarm(iHarmTem);
overlimit.setINeg(-3.14159f); // overlimit.setINeg(-3.14159f);
}else { // }else {
//主网 // //主网
iHarm(overlimit, voltageLevel, protocolCapacity, devCapacity, shortCapacity); // iHarm(overlimit, voltageLevel, protocolCapacity, devCapacity, shortCapacity);
negativeSequenceCurrent(overlimit, voltageLevel, shortCapacity); // negativeSequenceCurrent(overlimit, voltageLevel, shortCapacity);
} // }
return overlimit; // return overlimit;
} // }
//
//
/** // /**
* 电压偏差限值 // * 电压偏差限值
* // *
*/ // */
public static void voltageDeviation(Overlimit overlimit,Float voltageLevel) { // public static void voltageDeviation(Overlimit overlimit,Float voltageLevel) {
float voltageDev = 3.14159f,uvoltageDev = 3.14159f; // float voltageDev = 3.14159f,uvoltageDev = 3.14159f;
if(voltageLevel <= Float.parseFloat(DicDataEnum.V220.getCode())){ // if(voltageLevel <= Float.parseFloat(DicDataEnum.V220.getCode())){
voltageDev = 7.0f; // voltageDev = 7.0f;
uvoltageDev=-10.0f; // uvoltageDev=-10.0f;
}else if(voltageLevel>Float.parseFloat(DicDataEnum.V220.getCode())&&voltageLevel<Float.parseFloat(DicDataEnum.KV20.getCode())){ // }else if(voltageLevel>Float.parseFloat(DicDataEnum.V220.getCode())&&voltageLevel<Float.parseFloat(DicDataEnum.KV20.getCode())){
voltageDev = 7.0f; // voltageDev = 7.0f;
uvoltageDev=-7.0f; // uvoltageDev=-7.0f;
}else if(voltageLevel>=Float.parseFloat(DicDataEnum.KV20.getCode())&&voltageLevel<Float.parseFloat(DicDataEnum.KV35.getCode())){ // }else if(voltageLevel>=Float.parseFloat(DicDataEnum.KV20.getCode())&&voltageLevel<Float.parseFloat(DicDataEnum.KV35.getCode())){
voltageDev = 7.0f; // voltageDev = 7.0f;
uvoltageDev=-7.0f; // uvoltageDev=-7.0f;
}else if(voltageLevel>=Float.parseFloat(DicDataEnum.KV35.getCode())&&voltageLevel<Float.parseFloat(DicDataEnum.KV66.getCode())){ // }else if(voltageLevel>=Float.parseFloat(DicDataEnum.KV35.getCode())&&voltageLevel<Float.parseFloat(DicDataEnum.KV66.getCode())){
voltageDev = 10.0f; // voltageDev = 10.0f;
uvoltageDev=-10.0f; // uvoltageDev=-10.0f;
}else if(voltageLevel>=Float.parseFloat(DicDataEnum.KV66.getCode())&&voltageLevel<=Float.parseFloat(DicDataEnum.KV110.getCode())){ // }else if(voltageLevel>=Float.parseFloat(DicDataEnum.KV66.getCode())&&voltageLevel<=Float.parseFloat(DicDataEnum.KV110.getCode())){
voltageDev = 7.0f; // voltageDev = 7.0f;
uvoltageDev=-3.0f; // uvoltageDev=-3.0f;
}else if(voltageLevel>Float.parseFloat(DicDataEnum.KV110.getCode())){ // }else if(voltageLevel>Float.parseFloat(DicDataEnum.KV110.getCode())){
voltageDev = 10.0f; // voltageDev = 10.0f;
uvoltageDev=-10.0f; // uvoltageDev=-10.0f;
} // }
overlimit.setVoltageDev(voltageDev); // overlimit.setVoltageDev(voltageDev);
overlimit.setUvoltageDev(uvoltageDev); // overlimit.setUvoltageDev(uvoltageDev);
} // }
//
//
/** // /**
* 频率偏差 // * 频率偏差
* 默认限值±0.2Hz(即:-0.2 Hz≤限值≤0.2 Hz // * 默认限值±0.2Hz(即:-0.2 Hz≤限值≤0.2 Hz
*/ // */
public static void frequency(Overlimit overlimit) { // public static void frequency(Overlimit overlimit) {
overlimit.setFreqDev(0.2f); // overlimit.setFreqDev(0.2f);
} // }
//
//
/** // /**
* 电压波动 // * 电压波动
* 对LV、MV0≤限值≤3%对HV0≤限值≤2.5%。 // * 对LV、MV0≤限值≤3%对HV0≤限值≤2.5%。
* LV、MV、HV的定义 // * LV、MV、HV的定义
* 低压LV UN≤1kV // * 低压LV UN≤1kV
* 中压MV 1kVUN≤35kV // * 中压MV 1kVUN≤35kV
* 高压HV 35kVUN≤220kV // * 高压HV 35kVUN≤220kV
* 超高压EHV220kVUN参照HV执行 // * 超高压EHV220kVUN参照HV执行
*/ // */
public static void voltageFluctuation(Overlimit overlimit, Float voltageLevel) { // public static void voltageFluctuation(Overlimit overlimit, Float voltageLevel) {
if (voltageLevel < Float.parseFloat(DicDataEnum.KV35.getCode())) { // if (voltageLevel < Float.parseFloat(DicDataEnum.KV35.getCode())) {
overlimit.setVoltageFluctuation(3.0f); // overlimit.setVoltageFluctuation(3.0f);
} else { // } else {
overlimit.setVoltageFluctuation(2.5f); // overlimit.setVoltageFluctuation(2.5f);
} // }
} // }
//
//
//
/** // /**
* 电压闪变 // * 电压闪变
* ≤110kV 1 // * ≤110kV 1
* 110kV 0.8 // * 110kV 0.8
*/ // */
public static void voltageFlicker(Overlimit overlimit, Float voltageLevel) { // public static void voltageFlicker(Overlimit overlimit, Float voltageLevel) {
if (voltageLevel <= Float.parseFloat(DicDataEnum.KV110.getCode())) { // if (voltageLevel <= Float.parseFloat(DicDataEnum.KV110.getCode())) {
overlimit.setFlicker(1.0f); // overlimit.setFlicker(1.0f);
} else { // } else {
overlimit.setFlicker(0.8f); // overlimit.setFlicker(0.8f);
} // }
} // }
//
//
/** // /**
* 总谐波电压畸变率 // * 总谐波电压畸变率
* // *
* // *
*/ // */
public static void totalHarmonicDistortion(Overlimit overlimit, Float voltageLevel) { // public static void totalHarmonicDistortion(Overlimit overlimit, Float voltageLevel) {
float result = 3.14159f; // float result = 3.14159f;
if (voltageLevel < Float.parseFloat(DicDataEnum.KV6.getCode())) { // if (voltageLevel < Float.parseFloat(DicDataEnum.KV6.getCode())) {
result = 5.0f; // result = 5.0f;
} else if(voltageLevel >= Float.parseFloat(DicDataEnum.KV6.getCode()) && voltageLevel <= Float.parseFloat(DicDataEnum.KV20.getCode())){ // } else if(voltageLevel >= Float.parseFloat(DicDataEnum.KV6.getCode()) && voltageLevel <= Float.parseFloat(DicDataEnum.KV20.getCode())){
result = 4.0f; // result = 4.0f;
} else if(voltageLevel >= Float.parseFloat(DicDataEnum.KV35.getCode()) && voltageLevel <= Float.parseFloat(DicDataEnum.KV66.getCode())){ // } else if(voltageLevel >= Float.parseFloat(DicDataEnum.KV35.getCode()) && voltageLevel <= Float.parseFloat(DicDataEnum.KV66.getCode())){
result = 3.0f; // result = 3.0f;
} else if(voltageLevel >= Float.parseFloat(DicDataEnum.KV110.getCode()) && voltageLevel <= Float.parseFloat(DicDataEnum.KV1000.getCode())){ // } else if(voltageLevel >= Float.parseFloat(DicDataEnum.KV110.getCode()) && voltageLevel <= Float.parseFloat(DicDataEnum.KV1000.getCode())){
result = 2.0f; // result = 2.0f;
} // }
overlimit.setUaberrance(result); // overlimit.setUaberrance(result);
} // }
//
//
//
/** // /**
* 谐波电压含有率 // * 谐波电压含有率
*/ // */
public static void uHarm(Overlimit overlimit, Float voltageLevel) { // public static void uHarm(Overlimit overlimit, Float voltageLevel) {
float resultOdd = 3.14159f,resultEven = 3.14159f; // float resultOdd = 3.14159f,resultEven = 3.14159f;
if (voltageLevel < Float.parseFloat(DicDataEnum.KV6.getCode())) { // if (voltageLevel < Float.parseFloat(DicDataEnum.KV6.getCode())) {
resultOdd = 4.0f; // resultOdd = 4.0f;
resultEven = 2.0f; // resultEven = 2.0f;
} else if(voltageLevel >= Float.parseFloat(DicDataEnum.KV6.getCode()) && voltageLevel <= Float.parseFloat(DicDataEnum.KV20.getCode())){ // } else if(voltageLevel >= Float.parseFloat(DicDataEnum.KV6.getCode()) && voltageLevel <= Float.parseFloat(DicDataEnum.KV20.getCode())){
resultOdd = 3.2f; // resultOdd = 3.2f;
resultEven = 1.6f; // resultEven = 1.6f;
} else if(voltageLevel >= Float.parseFloat(DicDataEnum.KV35.getCode()) && voltageLevel <= Float.parseFloat(DicDataEnum.KV66.getCode())){ // } else if(voltageLevel >= Float.parseFloat(DicDataEnum.KV35.getCode()) && voltageLevel <= Float.parseFloat(DicDataEnum.KV66.getCode())){
resultOdd = 2.4f; // resultOdd = 2.4f;
resultEven = 1.2f; // resultEven = 1.2f;
} else if(voltageLevel >= Float.parseFloat(DicDataEnum.KV110.getCode()) && voltageLevel <= Float.parseFloat(DicDataEnum.KV1000.getCode())){ // } else if(voltageLevel >= Float.parseFloat(DicDataEnum.KV110.getCode()) && voltageLevel <= Float.parseFloat(DicDataEnum.KV1000.getCode())){
resultOdd = 1.6f; // resultOdd = 1.6f;
resultEven = 0.8f; // resultEven = 0.8f;
} // }
overlimit.buildUharm(resultEven,resultOdd); // overlimit.buildUharm(resultEven,resultOdd);
} // }
//
//
/** // /**
* 负序电压不平衡(三相电压不平衡度) // * 负序电压不平衡(三相电压不平衡度)
* // *
*/ // */
public static void threeVoltageUnbalance(Overlimit overlimit) { // public static void threeVoltageUnbalance(Overlimit overlimit) {
overlimit.setUbalance(2.0f); // overlimit.setUbalance(2.0f);
overlimit.setShortUbalance(4.0f); // overlimit.setShortUbalance(4.0f);
} // }
//
//
/*---------------------------------谐波电流限值start-----------------------------------*/ // /*---------------------------------谐波电流限值start-----------------------------------*/
//
/** // /**
* 谐波电流限值 // * 谐波电流限值
*/ // */
public static void iHarm(Overlimit overlimit, Float voltageLevel,Float protocolCapacity,Float devCapacity,Float shortCapacity) { // public static void iHarm(Overlimit overlimit, Float voltageLevel,Float protocolCapacity,Float devCapacity,Float shortCapacity) {
float calCap = shortCapacity/getDlCapByVoltageLevel(voltageLevel); // float calCap = shortCapacity/getDlCapByVoltageLevel(voltageLevel);
//24谐波电流幅值 // //24谐波电流幅值
Float[] iHarmTem = new Float[49]; // Float[] iHarmTem = new Float[49];
for (int i = 0; i <= 48; i++) { // for (int i = 0; i <= 48; i++) {
float inHarm = iHarmCalculate(i+2,voltageLevel,protocolCapacity,devCapacity,calCap); // float inHarm = iHarmCalculate(i+2,voltageLevel,protocolCapacity,devCapacity,calCap);
iHarmTem[i] = inHarm; // iHarmTem[i] = inHarm;
} // }
overlimit.buildIHarm(iHarmTem); // overlimit.buildIHarm(iHarmTem);
} // }
/** // /**
* @Description: iHarmCalculate // * @Description: iHarmCalculate
* @Param: protocolCapacity 协议容量 devCapacity设备容量 calCap 短路容量 // * @Param: protocolCapacity 协议容量 devCapacity设备容量 calCap 短路容量
* @return: float // * @return: float
* @Author: clam // * @Author: clam
* @Date: 2024/2/4 // * @Date: 2024/2/4
*/ // */
private static float iHarmCalculate(int nHarm, Float voltageLevel,float protocolCapacity, float devCapacity,float calCap) { // private static float iHarmCalculate(int nHarm, Float voltageLevel,float protocolCapacity, float devCapacity,float calCap) {
double tag = calCap*getHarmTag(nHarm,voltageLevel); // double tag = calCap*getHarmTag(nHarm,voltageLevel);
Double limit = getHarmonicLimit(nHarm,tag,new BigDecimal(String.valueOf(devCapacity)).doubleValue(),new BigDecimal(String.valueOf(protocolCapacity)).doubleValue()); // Double limit = getHarmonicLimit(nHarm,tag,new BigDecimal(String.valueOf(devCapacity)).doubleValue(),new BigDecimal(String.valueOf(protocolCapacity)).doubleValue());
BigDecimal bigDecimal = BigDecimal.valueOf(limit).setScale(4,RoundingMode.HALF_UP); // BigDecimal bigDecimal = BigDecimal.valueOf(limit).setScale(4,RoundingMode.HALF_UP);
return bigDecimal.floatValue(); // return bigDecimal.floatValue();
} // }
//
//
/** // /**
* 电流谐波限值 // * 电流谐波限值
*/ // */
private static Double getHarmTag(Integer iCount, Float voltageLevel) { // private static Double getHarmTag(Integer iCount, Float voltageLevel) {
int x, y; // int x, y;
if (voltageLevel < DicDataEnum.KV6.getValue()) { // if (voltageLevel < DicDataEnum.KV6.getValue()) {
x = 0; // x = 0;
} else if (voltageLevel<DicDataEnum.KV10.getValue()) { // } else if (voltageLevel<DicDataEnum.KV10.getValue()) {
x = 1; // x = 1;
} else if (voltageLevel<DicDataEnum.KV35.getValue()) { // } else if (voltageLevel<DicDataEnum.KV35.getValue()) {
x = 2; // x = 2;
} else if (voltageLevel<DicDataEnum.KV66.getValue()) { // } else if (voltageLevel<DicDataEnum.KV66.getValue()) {
x = 3; // x = 3;
} else if (voltageLevel<DicDataEnum.KV110.getValue()) { // } else if (voltageLevel<DicDataEnum.KV110.getValue()) {
x = 4; // x = 4;
} else { // } else {
x = 5; // x = 5;
} // }
y = iCount - 2; // y = iCount - 2;
return ARR[x][y]; // return ARR[x][y];
} // }
//
/** // /**
* 相位叠加系数的取值 // * 相位叠加系数的取值
*/ // */
public static Double getHarmonicLimit(Integer times, double iTag, double supply, double user) { // public static Double getHarmonicLimit(Integer times, double iTag, double supply, double user) {
if (supply == 0) { // if (supply == 0) {
return 0.0; // return 0.0;
} // }
double coefficient = 2.0; // double coefficient = 2.0;
if (times == 3) { // if (times == 3) {
coefficient = 1.1; // coefficient = 1.1;
} else if (times == 5) { // } else if (times == 5) {
coefficient = 1.2; // coefficient = 1.2;
} else if (times == 7) { // } else if (times == 7) {
coefficient = 1.4; // coefficient = 1.4;
} else if (times == 11) { // } else if (times == 11) {
coefficient = 1.8; // coefficient = 1.8;
} else if (times == 13) { // } else if (times == 13) {
coefficient = 1.9; // coefficient = 1.9;
} // }
BigDecimal bd = new BigDecimal(iTag * Math.pow((user / supply), (1 / coefficient))); // BigDecimal bd = new BigDecimal(iTag * Math.pow((user / supply), (1 / coefficient)));
bd = bd.setScale(6, RoundingMode.HALF_UP); // bd = bd.setScale(6, RoundingMode.HALF_UP);
return Double.parseDouble(bd.toString()); // return Double.parseDouble(bd.toString());
} // }
//
/** // /**
* 根据电压等级获取基准短路容量 // * 根据电压等级获取基准短路容量
*/ // */
public static float getDlCapByVoltageLevel(Float voltageLevel){ // public static float getDlCapByVoltageLevel(Float voltageLevel){
float capValue; // float capValue;
if(voltageLevel< DicDataEnum.KV06.getValue()){ // if(voltageLevel< DicDataEnum.KV06.getValue()){
capValue = 10; // capValue = 10;
}else if(voltageLevel<DicDataEnum.KV20.getValue()){ // }else if(voltageLevel<DicDataEnum.KV20.getValue()){
capValue = 100; // capValue = 100;
}else if(voltageLevel<DicDataEnum.KV35.getValue()){ // }else if(voltageLevel<DicDataEnum.KV35.getValue()){
capValue = 200; // capValue = 200;
}else if(voltageLevel<DicDataEnum.KV66.getValue()){ // }else if(voltageLevel<DicDataEnum.KV66.getValue()){
capValue = 250; // capValue = 250;
}else if(voltageLevel<DicDataEnum.KV110.getValue()){ // }else if(voltageLevel<DicDataEnum.KV110.getValue()){
capValue = 500; // capValue = 500;
}else if(voltageLevel<DicDataEnum.KV220.getValue()){ // }else if(voltageLevel<DicDataEnum.KV220.getValue()){
capValue = 750; // capValue = 750;
}else if(voltageLevel<DicDataEnum.KV330.getValue()){ // }else if(voltageLevel<DicDataEnum.KV330.getValue()){
capValue = 2000; // capValue = 2000;
}else if(voltageLevel<DicDataEnum.KV500.getValue()){ // }else if(voltageLevel<DicDataEnum.KV500.getValue()){
capValue = 3000; // capValue = 3000;
}else if(voltageLevel<DicDataEnum.KV750.getValue()){ // }else if(voltageLevel<DicDataEnum.KV750.getValue()){
capValue = 4500; // capValue = 4500;
}else if(voltageLevel<DicDataEnum.KV1000.getValue()){ // }else if(voltageLevel<DicDataEnum.KV1000.getValue()){
capValue = 7000; // capValue = 7000;
}else { // }else {
capValue = 9000; // capValue = 9000;
} // }
return capValue; // return capValue;
} // }
//
//
/*---------------------------------谐波电流限值end-----------------------------------*/ // /*---------------------------------谐波电流限值end-----------------------------------*/
//
//
/** // /**
* 间谐波电压含有率 // * 间谐波电压含有率
*/ // */
//
public static void interharmonicCurrent(Overlimit overlimit,Float voltageLevel){ // public static void interharmonicCurrent(Overlimit overlimit,Float voltageLevel){
float aValue,bValue; // float aValue,bValue;
if(voltageLevel <= DicDataEnum.KV1.getValue()){ // if(voltageLevel <= DicDataEnum.KV1.getValue()){
aValue = 0.2f;bValue = 0.5f; // aValue = 0.2f;bValue = 0.5f;
}else { // }else {
aValue = 0.16f;bValue = 0.4f; // aValue = 0.16f;bValue = 0.4f;
} // }
overlimit.setInuharm1(aValue); // overlimit.setInuharm1(aValue);
overlimit.setInuharm2(aValue); // overlimit.setInuharm2(aValue);
//
overlimit.setInuharm3(bValue); // overlimit.setInuharm3(bValue);
overlimit.setInuharm4(bValue); // overlimit.setInuharm4(bValue);
overlimit.setInuharm5(bValue); // overlimit.setInuharm5(bValue);
overlimit.setInuharm6(bValue); // overlimit.setInuharm6(bValue);
overlimit.setInuharm7(bValue); // overlimit.setInuharm7(bValue);
overlimit.setInuharm8(bValue); // overlimit.setInuharm8(bValue);
overlimit.setInuharm9(bValue); // overlimit.setInuharm9(bValue);
overlimit.setInuharm10(bValue); // overlimit.setInuharm10(bValue);
overlimit.setInuharm11(bValue); // overlimit.setInuharm11(bValue);
overlimit.setInuharm12(bValue); // overlimit.setInuharm12(bValue);
overlimit.setInuharm13(bValue); // overlimit.setInuharm13(bValue);
overlimit.setInuharm14(bValue); // overlimit.setInuharm14(bValue);
overlimit.setInuharm15(bValue); // overlimit.setInuharm15(bValue);
overlimit.setInuharm16(bValue); // overlimit.setInuharm16(bValue);
} // }
//
//
/** // /**
* 负序电流限值 // * 负序电流限值
*/ // */
public static void negativeSequenceCurrent(Overlimit overlimit,Float voltageLevel,Float shortCapacity){ // public static void negativeSequenceCurrent(Overlimit overlimit,Float voltageLevel,Float shortCapacity){
double v = (0.013*shortCapacity*1000)/(getUl(voltageLevel)*Math.sqrt(3)); // double v = (0.013*shortCapacity*1000)/(getUl(voltageLevel)*Math.sqrt(3));
overlimit.setINeg((float) v); // overlimit.setINeg((float) v);
} // }
//
/** // /**
* 获取额定线电压 // * 获取额定线电压
*/ // */
private static float getUl(Float voltageLevel){ // private static float getUl(Float voltageLevel){
float value; // float value;
if(voltageLevel<DicDataEnum.KV6.getValue()){ // if(voltageLevel<DicDataEnum.KV6.getValue()){
value = 0.4f; // value = 0.4f;
}else if(voltageLevel<DicDataEnum.KV10.getValue()){ // }else if(voltageLevel<DicDataEnum.KV10.getValue()){
value = 6.3f; // value = 6.3f;
}else if(voltageLevel<DicDataEnum.KV20.getValue()){ // }else if(voltageLevel<DicDataEnum.KV20.getValue()){
value = 10.5f; // value = 10.5f;
}else if(voltageLevel<DicDataEnum.KV35.getValue()){ // }else if(voltageLevel<DicDataEnum.KV35.getValue()){
value = 21.0f; // value = 21.0f;
}else if(voltageLevel<DicDataEnum.KV66.getValue()){ // }else if(voltageLevel<DicDataEnum.KV66.getValue()){
value = 36.5f; // value = 36.5f;
}else if(voltageLevel<DicDataEnum.KV110.getValue()){ // }else if(voltageLevel<DicDataEnum.KV110.getValue()){
value = 69.0f; // value = 69.0f;
}else if(voltageLevel<DicDataEnum.KV220.getValue()){ // }else if(voltageLevel<DicDataEnum.KV220.getValue()){
value = 115.5f; // value = 115.5f;
}else if(voltageLevel<DicDataEnum.KV330.getValue()){ // }else if(voltageLevel<DicDataEnum.KV330.getValue()){
value = 230.0f; // value = 230.0f;
}else { // }else {
value = 345.0f; // value = 345.0f;
} // }
return value; // return value;
} // }
//
//
public static void main(String[] args) { // public static void main(String[] args) {
System.out.println("sss"); // System.out.println("sss");
float aa = iHarmCalculate(9,500f,10,10,0.002222222222f); // float aa = iHarmCalculate(9,500f,10,10,0.002222222222f);
//
System.out.println(aa); // System.out.println(aa);
} // }
} //}

View File

@@ -6,9 +6,9 @@ import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil; import com.njcn.common.utils.HttpResultUtil;
import com.njcn.csdevice.pojo.po.Overlimit;
import com.njcn.csdevice.pojo.vo.LineOverLimitVO; import com.njcn.csdevice.pojo.vo.LineOverLimitVO;
import com.njcn.csdevice.service.IOverLimitService; import com.njcn.csdevice.service.IOverLimitService;
import com.njcn.device.biz.pojo.po.Overlimit;
import com.njcn.web.controller.BaseController; import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;

View File

@@ -67,7 +67,7 @@ public class IcdController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/bzFileByEventId") @PostMapping("/bzFileByEventId")
@ApiOperation("指定事件补召波形") @ApiOperation("指定事件补召波形指令下发")
@ApiImplicitParam(name = "eventId", value = "事件id", required = true) @ApiImplicitParam(name = "eventId", value = "事件id", required = true)
public HttpResult<String> bzFileByEventId(@RequestParam String eventId){ public HttpResult<String> bzFileByEventId(@RequestParam String eventId){
String methodDescribe = getMethodDescribe("bzFileByEventId"); String methodDescribe = getMethodDescribe("bzFileByEventId");
@@ -77,7 +77,7 @@ public class IcdController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/bzEvent") @PostMapping("/bzEvent")
@ApiOperation("补召事件") @ApiOperation("补召事件指令下发")
@ApiImplicitParam(name = "param", value = "参数", required = true) @ApiImplicitParam(name = "param", value = "参数", required = true)
public HttpResult<String> bzEvent(@RequestBody @Validated IcdBzParam param){ public HttpResult<String> bzEvent(@RequestBody @Validated IcdBzParam param){
String methodDescribe = getMethodDescribe("bzEvent"); String methodDescribe = getMethodDescribe("bzEvent");
@@ -87,7 +87,7 @@ public class IcdController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/bzFile") @PostMapping("/bzFile")
@ApiOperation("补召波形") @ApiOperation("补召波形指令下发")
@ApiImplicitParam(name = "param", value = "参数", required = true) @ApiImplicitParam(name = "param", value = "参数", required = true)
public HttpResult<String> bzFile(@RequestBody @Validated IcdBzParam param){ public HttpResult<String> bzFile(@RequestBody @Validated IcdBzParam param){
String methodDescribe = getMethodDescribe("bzFile"); String methodDescribe = getMethodDescribe("bzFile");

View File

@@ -1,6 +1,5 @@
package com.njcn.csdevice.controller.line; package com.njcn.csdevice.controller.line;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo; import com.njcn.common.pojo.annotation.OperateInfo;
@@ -8,14 +7,14 @@ import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil; import com.njcn.common.utils.HttpResultUtil;
import com.njcn.csdevice.mapper.OverlimitMapper;
import com.njcn.csdevice.pojo.param.CsLineParam; import com.njcn.csdevice.pojo.param.CsLineParam;
import com.njcn.csdevice.pojo.po.CsLinePO; import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csdevice.pojo.vo.LineDetailDataVO; import com.njcn.csdevice.pojo.vo.LineDetailDataVO;
import com.njcn.csdevice.pojo.po.Overlimit;
import com.njcn.csdevice.pojo.vo.PqSensitiveUserLineVO; import com.njcn.csdevice.pojo.vo.PqSensitiveUserLineVO;
import com.njcn.csdevice.service.CsLinePOService; import com.njcn.csdevice.service.CsLinePOService;
import com.njcn.csdevice.utils.COverlimitUtil; import com.njcn.device.biz.mapper.OverLimitWlMapper;
import com.njcn.device.biz.pojo.po.Overlimit;
import com.njcn.device.biz.utils.COverlimitUtil;
import com.njcn.web.controller.BaseController; import com.njcn.web.controller.BaseController;
import com.njcn.web.pojo.param.BaseParam; import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.*; import io.swagger.annotations.*;
@@ -45,7 +44,7 @@ import java.util.Map;
public class CslineController extends BaseController { public class CslineController extends BaseController {
private final CsLinePOService csLinePOService; private final CsLinePOService csLinePOService;
private final OverlimitMapper overlimitMapper; private final OverLimitWlMapper overLimitWlMapper;
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryLineById") @PostMapping("/queryLineById")
@@ -88,8 +87,8 @@ public class CslineController extends BaseController {
for(CsLinePO csLinePO: list){ for(CsLinePO csLinePO: list){
Overlimit overlimit = COverlimitUtil.globalAssemble(csLinePO.getVolGrade().floatValue(),10f,10f,10f,0,1); Overlimit overlimit = COverlimitUtil.globalAssemble(csLinePO.getVolGrade().floatValue(),10f,10f,10f,0,1);
overlimit.setId(csLinePO.getLineId()); overlimit.setId(csLinePO.getLineId());
overlimitMapper.deleteById(csLinePO.getLineId()); overLimitWlMapper.deleteById(csLinePO.getLineId());
overlimitMapper.insert(overlimit); overLimitWlMapper.insert(overlimit);
} }
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
} }
@@ -156,7 +155,17 @@ public class CslineController extends BaseController {
@ApiImplicitParam(name = "ids", value = "监测点id集合", required = true) @ApiImplicitParam(name = "ids", value = "监测点id集合", required = true)
public HttpResult<List<Overlimit>> getOverLimitData(@RequestBody List<String> ids) { public HttpResult<List<Overlimit>> getOverLimitData(@RequestBody List<String> ids) {
String methodDescribe = getMethodDescribe("getOverLimitDataByIds"); String methodDescribe = getMethodDescribe("getOverLimitDataByIds");
List<Overlimit> result = overlimitMapper.selectBatchIds(ids); List<Overlimit> result = overLimitWlMapper.selectBatchIds(ids);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getOverLimitData")
@ApiOperation("根据监测点id获取国标限值")
@ApiImplicitParam(name = "id", value = "监测点id", required = true)
public HttpResult<Overlimit> getOverLimitData(@RequestParam("id") String id) {
String methodDescribe = getMethodDescribe("getOverLimitData");
Overlimit result = overLimitWlMapper.selectById(id);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
} }
@@ -188,10 +197,10 @@ public class CslineController extends BaseController {
String methodDescribe = getMethodDescribe("addCldLine"); String methodDescribe = getMethodDescribe("addCldLine");
csLinePOService.addCldLine(param); csLinePOService.addCldLine(param);
//新增监测点限值 //新增监测点限值
Overlimit overlimit = COverlimitUtil.globalAssemble(param.getVolGrade().floatValue(),10f,10f,10f,0,1); Overlimit overlimit = COverlimitUtil.globalAssemble(param.getVolGrade().floatValue(),param.getProtocolCapacity().floatValue(),param.getDevCapacity().floatValue(),param.getShortCircuitCapacity().floatValue(),0,0);
overlimit.setId(param.getLineId()); overlimit.setId(param.getLineId());
overlimitMapper.deleteById(param.getLineId()); overLimitWlMapper.deleteById(param.getLineId());
overlimitMapper.insert(overlimit); overLimitWlMapper.insert(overlimit);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
} }
@@ -203,10 +212,10 @@ public class CslineController extends BaseController {
String methodDescribe = getMethodDescribe("updateCldLine"); String methodDescribe = getMethodDescribe("updateCldLine");
csLinePOService.updateCldLine(param); csLinePOService.updateCldLine(param);
//修改监测点限值 //修改监测点限值
Overlimit overlimit = COverlimitUtil.globalAssemble(param.getVolGrade().floatValue(),10f,10f,10f,0,1); Overlimit overlimit = COverlimitUtil.globalAssemble(param.getVolGrade().floatValue(),param.getProtocolCapacity().floatValue(),param.getDevCapacity().floatValue(),param.getShortCircuitCapacity().floatValue(),0,0);
overlimit.setId(param.getLineId()); overlimit.setId(param.getLineId());
overlimitMapper.deleteById(param.getLineId()); overLimitWlMapper.deleteById(param.getLineId());
overlimitMapper.insert(overlimit); overLimitWlMapper.insert(overlimit);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
} }
@@ -217,6 +226,7 @@ public class CslineController extends BaseController {
public HttpResult<List<CsLinePO>> delCldLine(@RequestParam("id") String id) { public HttpResult<List<CsLinePO>> delCldLine(@RequestParam("id") String id) {
String methodDescribe = getMethodDescribe("delCldLine"); String methodDescribe = getMethodDescribe("delCldLine");
csLinePOService.deleteCldLine(id); csLinePOService.deleteCldLine(id);
overLimitWlMapper.deleteById(id);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
} }
@@ -270,10 +280,7 @@ public class CslineController extends BaseController {
@ApiImplicitParam(name = "param", value = "param", required = true) @ApiImplicitParam(name = "param", value = "param", required = true)
public HttpResult<List<CsLinePO>> list(@RequestBody CsLinePO param) { public HttpResult<List<CsLinePO>> list(@RequestBody CsLinePO param) {
String methodDescribe = getMethodDescribe("list"); String methodDescribe = getMethodDescribe("list");
List<CsLinePO> list = csLinePOService.list(new LambdaQueryWrapper<CsLinePO>() List<CsLinePO> list = csLinePOService.getLineList(param);
.eq(CsLinePO::getStatus, 1)
.eq(StrUtil.isNotBlank(param.getPosition()), CsLinePO::getPosition, param.getPosition())
.orderByAsc(CsLinePO::getName));
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
} }
@@ -292,7 +299,7 @@ public class CslineController extends BaseController {
@ApiOperation("获取敏感负荷用户监测点列表") @ApiOperation("获取敏感负荷用户监测点列表")
@ApiImplicitParam(name = "param", value = "查询参数", required = true) @ApiImplicitParam(name = "param", value = "查询参数", required = true)
public HttpResult<Page<PqSensitiveUserLineVO>> getSensitiveUserLineList(@RequestBody BaseParam param) { public HttpResult<Page<PqSensitiveUserLineVO>> getSensitiveUserLineList(@RequestBody BaseParam param) {
String methodDescribe = getMethodDescribe("getList"); String methodDescribe = getMethodDescribe("getSensitiveUserLineList");
Page<PqSensitiveUserLineVO> page = csLinePOService.getSensitiveUserLineList(param); Page<PqSensitiveUserLineVO> page = csLinePOService.getSensitiveUserLineList(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
} }

View File

@@ -11,8 +11,6 @@ import com.njcn.csdevice.pojo.param.CsEngineeringAuditParm;
import com.njcn.csdevice.pojo.param.CsEngineeringQueryPageParm; import com.njcn.csdevice.pojo.param.CsEngineeringQueryPageParm;
import com.njcn.csdevice.pojo.param.CsEngineeringQueryParm; import com.njcn.csdevice.pojo.param.CsEngineeringQueryParm;
import com.njcn.csdevice.pojo.po.CsEngineeringPO; import com.njcn.csdevice.pojo.po.CsEngineeringPO;
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csdevice.pojo.vo.CsEngineeringVO; import com.njcn.csdevice.pojo.vo.CsEngineeringVO;
import com.njcn.csdevice.service.CsEngineeringService; import com.njcn.csdevice.service.CsEngineeringService;
import com.njcn.web.controller.BaseController; import com.njcn.web.controller.BaseController;

View File

@@ -0,0 +1,100 @@
package com.njcn.csdevice.controller.project;
import com.njcn.common.pojo.annotation.OperateInfo;
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.csdevice.pojo.param.AppProjectAddParm;
import com.njcn.csdevice.pojo.param.AppProjectAuditParm;
import com.njcn.csdevice.pojo.param.CsEngineeringAddParm;
import com.njcn.csdevice.pojo.param.CsEngineeringAuditParm;
import com.njcn.csdevice.pojo.vo.EngineeringProjectRelationVo;
import com.njcn.csdevice.service.IEngineeringProjectService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
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.List;
/**
* @author xy
* @date 2026/1/29
*/
@Slf4j
@RestController
@RequestMapping("/engineeringProjectRelation")
@Api(tags = " 工程信息管理(不分权限)")
@AllArgsConstructor
public class EngineeringProjectController extends BaseController {
private final IEngineeringProjectService csEngineeringService;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/addEngineering")
@ApiOperation("新增工程信息")
public HttpResult<Boolean> addEngineering(@Validated @RequestBody CsEngineeringAddParm csEngineeringAddParm){
String methodDescribe = getMethodDescribe("addEngineering");
boolean result = csEngineeringService.addEngineering(csEngineeringAddParm);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/updateEngineering")
@ApiOperation("修改工程信息")
public HttpResult<Boolean> updateEngineering(@Validated @RequestBody CsEngineeringAuditParm csEngineeringAuditParm){
String methodDescribe = getMethodDescribe("updateEngineering");
boolean result = csEngineeringService.updateEngineering(csEngineeringAuditParm);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/deleteEngineering")
@ApiOperation("删除工程信息")
public HttpResult<Boolean> deleteEngineering(@RequestParam("id") String id){
String methodDescribe = getMethodDescribe("deleteEngineering");
boolean result = csEngineeringService.deleteEngineering(id);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/addProject")
@ApiOperation("新增项目信息")
public HttpResult<Boolean> addProject(@Validated @RequestBody AppProjectAddParm param){
String methodDescribe = getMethodDescribe("addProject");
boolean result = csEngineeringService.addProject(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/updateProject")
@ApiOperation("修改项目信息")
public HttpResult<Boolean> updateProject(@Validated @RequestBody AppProjectAuditParm param){
String methodDescribe = getMethodDescribe("updateProject");
boolean result = csEngineeringService.updateProject(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/deleteProject")
@ApiOperation("删除项目信息")
public HttpResult<Boolean> deleteProject(@RequestParam("id") String id){
String methodDescribe = getMethodDescribe("deleteProject");
boolean result = csEngineeringService.deleteProject(id);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/list")
@ApiOperation("查询工程信息列表")
public HttpResult<List<EngineeringProjectRelationVo>> getList(){
String methodDescribe = getMethodDescribe("getList");
List<EngineeringProjectRelationVo> result = csEngineeringService.getList();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
}

View File

@@ -1,22 +0,0 @@
package com.njcn.csdevice.mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.csdevice.pojo.po.Overlimit;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author cdf
* @since 2022-01-04
*/
@DS("sjzx")
@Mapper
public interface OverlimitMapper extends BaseMapper<Overlimit> {
}

View File

@@ -39,15 +39,17 @@
SELECT SELECT
line.line_id as lineId, line.line_id as lineId,
line.name as lineName, line.name as lineName,
concat(round(line.pt_ratio,0),concat(':',round(line.pt2_ratio,0))) as pt, concat(round(line.pt_ratio,0), ':', round(IFNULL(line.pt2_ratio, 1), 0)) as pt,
concat(round(line.ct_ratio,0),concat(':',round(line.ct2_ratio,0))) as ct, concat(round(line.ct_ratio,0), ':', round(IFNULL(line.ct2_ratio, 1), 0)) as ct,
line.dev_capacity as Dev_Capacity, line.dev_capacity as Dev_Capacity,
line.short_circuit_capacity as Short_Capacity, line.short_circuit_capacity as Short_Capacity,
line.basic_capacity as Standard_Capacity, line.basic_capacity as Standard_Capacity,
line.protocol_capacity as Deal_Capacity, line.protocol_capacity as Deal_Capacity,
line.vol_grade AS voltageLevel line.vol_grade AS voltageLevel,
dataSet.data_level AS level
FROM FROM
cs_line line cs_line line
left JOIN cs_data_set dataSet on line.data_set_id = dataSet.id
WHERE WHERE
line.line_id = #{lineId} line.line_id = #{lineId}
</select> </select>

View File

@@ -55,4 +55,11 @@ public interface AppProjectService extends IService<AppProjectPO> {
* @return * @return
*/ */
List<AppProjectPO> getProjectByEngineering(List<String> list); List<AppProjectPO> getProjectByEngineering(List<String> list);
AppProjectPO add(AppProjectAddParm param);
AppProjectPO updateData(AppProjectAuditParm param);
boolean delete(String id);
} }

View File

@@ -59,4 +59,11 @@ public interface CsEngineeringService extends IService<CsEngineeringPO>{
CsEngineeringPO queryEngineeringById(String id); CsEngineeringPO queryEngineeringById(String id);
List<CsEngineeringPO> getUnlinkedEngineering(String userId); List<CsEngineeringPO> getUnlinkedEngineering(String userId);
CsEngineeringPO add(CsEngineeringAddParm csEngineeringAddParm);
CsEngineeringPO updateData(CsEngineeringAuditParm csEngineeringAuditParm);
boolean deleteData(String id);
} }

View File

@@ -95,4 +95,6 @@ public interface CsLinePOService extends IService<CsLinePO>{
* @return 结果 * @return 结果
*/ */
LineDetailDataVO getLineDetailData(String id); LineDetailDataVO getLineDetailData(String id);
List<CsLinePO> getLineList(CsLinePO param);
} }

View File

@@ -0,0 +1,35 @@
package com.njcn.csdevice.service;
import com.njcn.csdevice.pojo.param.AppProjectAddParm;
import com.njcn.csdevice.pojo.param.AppProjectAuditParm;
import com.njcn.csdevice.pojo.param.CsEngineeringAddParm;
import com.njcn.csdevice.pojo.param.CsEngineeringAuditParm;
import com.njcn.csdevice.pojo.vo.EngineeringProjectRelationVo;
import java.util.List;
/**
* <p>
* 组和指标关系表 服务类
* </p>
*
* @author xuyang
* @since 2023-06-19
*/
public interface IEngineeringProjectService {
boolean addEngineering(CsEngineeringAddParm csEngineeringAddParm);
boolean updateEngineering(CsEngineeringAuditParm csEngineeringAuditParm);
boolean deleteEngineering(String id);
boolean addProject(AppProjectAddParm param);
boolean updateProject(AppProjectAuditParm param);
boolean deleteProject(String id);
List<EngineeringProjectRelationVo> getList();
}

View File

@@ -2,8 +2,8 @@ package com.njcn.csdevice.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.csdevice.pojo.po.Overlimit;
import com.njcn.csdevice.pojo.vo.LineOverLimitVO; import com.njcn.csdevice.pojo.vo.LineOverLimitVO;
import com.njcn.device.biz.pojo.po.Overlimit;
/** /**
* <p> * <p>

View File

@@ -1,9 +1,9 @@
package com.njcn.csdevice.service.impl; package com.njcn.csdevice.service.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.stream.CollectorUtil;
import com.alibaba.cloud.commons.lang.StringUtils; import com.alibaba.cloud.commons.lang.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -17,7 +17,6 @@ import com.njcn.csdevice.pojo.param.*;
import com.njcn.csdevice.pojo.po.*; import com.njcn.csdevice.pojo.po.*;
import com.njcn.csdevice.pojo.vo.AppProjectVO; import com.njcn.csdevice.pojo.vo.AppProjectVO;
import com.njcn.csdevice.pojo.vo.AppTopologyDiagramVO; import com.njcn.csdevice.pojo.vo.AppTopologyDiagramVO;
import com.njcn.csdevice.pojo.vo.CsLineTopologyTemplateVO;
import com.njcn.csdevice.service.AppProjectService; import com.njcn.csdevice.service.AppProjectService;
import com.njcn.csdevice.service.AppTopologyDiagramService; import com.njcn.csdevice.service.AppTopologyDiagramService;
import com.njcn.csdevice.service.CsLineTopologyTemplateService; import com.njcn.csdevice.service.CsLineTopologyTemplateService;
@@ -367,4 +366,42 @@ class AppProjectServiceImpl extends ServiceImpl<AppProjectMapper, AppProjectPO>
} }
return result; return result;
} }
@Override
public AppProjectPO add(AppProjectAddParm param) {
AppProjectPO po = new AppProjectPO ( );
List<AppProjectPO> list = this.lambdaQuery().eq(AppProjectPO::getName, param.getName()).eq(AppProjectPO::getStatus, "1").list();
if(!list.isEmpty()){
throw new BusinessException("新增失败,项目名重复");
}
BeanUtils.copyProperties (param, po);
po.setStatus ("1");
this.save(po);
return po;
}
@Override
public AppProjectPO updateData(AppProjectAuditParm param) {
List<AppProjectPO> list = this.lambdaQuery()
.eq(AppProjectPO::getName, param.getName())
.eq(AppProjectPO::getStatus, "1")
.ne(AppProjectPO::getId, param.getId())
.list();
if(!list.isEmpty()){
throw new BusinessException("修改失败,项目名重复");
}
AppProjectPO po = new AppProjectPO ();
BeanUtils.copyProperties (param, po);
this.updateById(po);
return po;
}
@Override
public boolean delete(String id) {
LambdaUpdateWrapper<AppProjectPO> queryWrapper = new LambdaUpdateWrapper<>();
queryWrapper.eq(AppProjectPO::getId,id).set(AppProjectPO::getStatus,"0");
return this.update(queryWrapper);
}
} }

View File

@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
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.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
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;
@@ -259,6 +260,43 @@ public class CsEngineeringServiceImpl extends ServiceImpl<CsEngineeringMapper, C
return result; return result;
} }
@Override
public CsEngineeringPO add(CsEngineeringAddParm csEngineeringAddParm) {
List<CsEngineeringPO> list = this.lambdaQuery().eq(CsEngineeringPO::getName, csEngineeringAddParm.getName()).eq(CsEngineeringPO::getStatus, "1").list();
if(!list.isEmpty()){
throw new BusinessException("新增失败,工程名重复");
}
//新增工程
CsEngineeringPO po = new CsEngineeringPO ();
BeanUtils.copyProperties (csEngineeringAddParm, po);
po.setStatus ("1");
this.save(po);
return po;
}
@Override
public CsEngineeringPO updateData(CsEngineeringAuditParm csEngineeringAuditParm) {
List<CsEngineeringPO> list = this.lambdaQuery()
.eq(CsEngineeringPO::getName, csEngineeringAuditParm.getName())
.eq(CsEngineeringPO::getStatus, "1")
.ne(CsEngineeringPO::getId, csEngineeringAuditParm.getId())
.list();
if(!list.isEmpty()){
throw new BusinessException("修改失败,工程名重复");
}
CsEngineeringPO po = new CsEngineeringPO();
BeanUtils.copyProperties(csEngineeringAuditParm, po);
this.updateById(po);
return po;
}
@Override
public boolean deleteData(String id) {
LambdaUpdateWrapper<CsEngineeringPO> queryWrapper = new LambdaUpdateWrapper<>();
queryWrapper.eq(CsEngineeringPO::getId,id).set(CsEngineeringPO::getStatus,"0");
return this.update(queryWrapper);
}
public String getAreaById(String id){ public String getAreaById(String id){

View File

@@ -117,8 +117,12 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
@Transactional(rollbackFor = {Exception.class}) @Transactional(rollbackFor = {Exception.class})
public CsEquipmentDeliveryPO save(CsEquipmentDeliveryAddParm csEquipmentDeliveryAddParm) { public CsEquipmentDeliveryPO save(CsEquipmentDeliveryAddParm csEquipmentDeliveryAddParm) {
boolean result; boolean result;
CsEquipmentDeliveryPO one = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getName, csEquipmentDeliveryAddParm.getName()).ne(CsEquipmentDeliveryPO::getRunStatus, 0).one(); List<CsEquipmentDeliveryPO> one = this.lambdaQuery()
if(Objects.nonNull (one)){ .eq(CsEquipmentDeliveryPO::getName, csEquipmentDeliveryAddParm.getName())
.ne(CsEquipmentDeliveryPO::getRunStatus, 0)
.eq(CsEquipmentDeliveryPO::getDevAccessMethod, "MQTT")
.list();
if(CollUtil.isNotEmpty(one)){
throw new BusinessException ("设备名称不能重复"); throw new BusinessException ("设备名称不能重复");
} }
StringUtil.containsSpecialCharacters(csEquipmentDeliveryAddParm.getNdid()); StringUtil.containsSpecialCharacters(csEquipmentDeliveryAddParm.getNdid());
@@ -259,12 +263,14 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
CsEquipmentDeliveryPO csEquipmentDeliveryPo = new CsEquipmentDeliveryPO(); CsEquipmentDeliveryPO csEquipmentDeliveryPo = new CsEquipmentDeliveryPO();
BeanUtils.copyProperties (csEquipmentDeliveryAuditParm, csEquipmentDeliveryPo); BeanUtils.copyProperties (csEquipmentDeliveryAuditParm, csEquipmentDeliveryPo);
result = this.updateById(csEquipmentDeliveryPo); result = this.updateById(csEquipmentDeliveryPo);
//修改台账树中的设备名称 //如果是已经接入的设备需要修改台账树中的设备名称
CsLedger csLedger = csLedgerService.findDataById(csEquipmentDeliveryAuditParm.getId()); CsLedger csLedger = csLedgerService.findDataById(csEquipmentDeliveryAuditParm.getId());
CsLedgerParam.Update csLedgerParam = new CsLedgerParam.Update(); if (ObjectUtil.isNotNull(csLedger)) {
BeanUtils.copyProperties (csLedger, csLedgerParam); CsLedgerParam.Update csLedgerParam = new CsLedgerParam.Update();
csLedgerParam.setName(csEquipmentDeliveryAuditParm.getName()); BeanUtils.copyProperties (csLedger, csLedgerParam);
csLedgerService.updateLedgerTree(csLedgerParam); csLedgerParam.setName(csEquipmentDeliveryAuditParm.getName());
csLedgerService.updateLedgerTree(csLedgerParam);
}
if (result) { if (result) {
refreshDeviceDataCache(); refreshDeviceDataCache();
if (!Objects.equals(po.getUsageStatus(),csEquipmentDeliveryAuditParm.getUsageStatus())) { if (!Objects.equals(po.getUsageStatus(),csEquipmentDeliveryAuditParm.getUsageStatus())) {
@@ -435,8 +441,9 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
} }
deviceManagerVo.setDataSetList(dataSetList); deviceManagerVo.setDataSetList(dataSetList);
List<CsLinePO> csLinePOS = csLinePOService.findByNdid(csEquipmentDeliveryPo.getNdid()); List<CsLinePO> csLinePOS = csLinePOService.findByNdid(csEquipmentDeliveryPo.getNdid());
if(!csLinePOS.isEmpty() && csLinePOS.get(0)!=null){ if(!csLinePOS.isEmpty()){
deviceManagerVo.setTime(csLinePOService.findByNdid(csEquipmentDeliveryPo.getNdid()).get(0).getCreateTime()); Optional<CsLinePO> earliest = csLinePOS.stream().min(Comparator.comparing(CsLinePO::getCreateTime));
deviceManagerVo.setTime(earliest.map(CsLinePO::getCreateTime).orElse(null));
} }
} }
} }
@@ -935,9 +942,9 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
devList.forEach(item->{item.setRunStatus(1);}); devList.forEach(item->{item.setRunStatus(1);});
this.updateBatchById(devList); this.updateBatchById(devList);
//修改监测点运行状态 //修改监测点运行状态
List<String> devIdList = devList.stream().map(CsEquipmentDeliveryPO::getId).collect(Collectors.toList()); //List<String> devIdList = devList.stream().map(CsEquipmentDeliveryPO::getId).collect(Collectors.toList());
List<CsLinePO> lineList = csLinePOService.getLinesByDevList(devIdList); //List<CsLinePO> lineList = csLinePOService.getLinesByDevList(devIdList);
csLinePOService.updateCldLineStatus(lineList,2); //csLinePOService.updateCldLineStatus(lineList,2);
} }
} }
@@ -951,9 +958,10 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
if (ObjectUtil.isNotNull(po)) { if (ObjectUtil.isNotNull(po)) {
po.setRunStatus(status); po.setRunStatus(status);
this.updateById(po); this.updateById(po);
//这边是监测点的运行状态 不是通讯状态,所以不要修改,通讯状态跟着设备的通讯状态来
//修改监测点运行状态 //修改监测点运行状态
List<CsLinePO> lineList = csLinePOService.getLinesByDevList(Collections.singletonList(po.getId())); //List<CsLinePO> lineList = csLinePOService.getLinesByDevList(Collections.singletonList(po.getId()));
csLinePOService.updateCldLineStatus(lineList,status==1?2:0); //csLinePOService.updateCldLineStatus(lineList,status==1?2:0);
} }
} }
@@ -990,17 +998,33 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
public List<CsEquipmentDeliveryPO> getRunPortableDev(String userId) { public List<CsEquipmentDeliveryPO> getRunPortableDev(String userId) {
List<CsEquipmentDeliveryPO> result = new ArrayList<>(); List<CsEquipmentDeliveryPO> result = new ArrayList<>();
DictTreeVO vo = dictTreeFeignClient.queryByCode(DicDataEnum.PORTABLE.getCode()).getData(); DictTreeVO vo = dictTreeFeignClient.queryByCode(DicDataEnum.PORTABLE.getCode()).getData();
if (ObjectUtil.isNotNull(vo)) { if (ObjectUtil.isNull(vo)) {
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>(); throw new BusinessException("便携式设备类型字典缺失");
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getDevType,vo.getId()) }
.ne(CsEquipmentDeliveryPO::getRunStatus,0) LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
.eq(CsEquipmentDeliveryPO::getUsageStatus,1); lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getDevType,vo.getId())
//获取用户已经绑定的便携式设备 .ne(CsEquipmentDeliveryPO::getRunStatus,0)
List<String> devList = csDeviceUserPOService.findDevByUserId(userId); .eq(CsEquipmentDeliveryPO::getUsageStatus,1);
if (CollectionUtil.isNotEmpty(devList)) { //获取用户已经绑定的便携式设备
lambdaQueryWrapper.notIn(CsEquipmentDeliveryPO::getId,devList); List<String> devList = csDeviceUserPOService.findDevByUserId(userId);
if (CollectionUtil.isNotEmpty(devList)) {
lambdaQueryWrapper.notIn(CsEquipmentDeliveryPO::getId,devList);
}
result = this.list(lambdaQueryWrapper);
if (CollectionUtil.isNotEmpty(result)) {
//获取已经接入过系统的设备,未接入的不给分配
LambdaQueryWrapper<CsLedger> queryWrapper = new LambdaQueryWrapper<>();
List<String> ids = result.stream().map(CsEquipmentDeliveryPO::getId).collect(Collectors.toList());
queryWrapper.in(CsLedger::getId,ids);
List<CsLedger> list = csLedgerService.list(queryWrapper);
if (CollectionUtil.isNotEmpty(list)) {
Set<String> idSet = list.stream()
.map(CsLedger::getId)
.collect(Collectors.toSet());
return result.stream()
.filter(data -> idSet.contains(data.getId()))
.collect(Collectors.toList());
} }
result = this.list(lambdaQueryWrapper);
} }
return result; return result;
} }

View File

@@ -20,7 +20,10 @@ import com.njcn.csdevice.api.EquipmentFeignClient;
import com.njcn.csdevice.constant.DataParam; import com.njcn.csdevice.constant.DataParam;
import com.njcn.csdevice.enums.AlgorithmResponseEnum; import com.njcn.csdevice.enums.AlgorithmResponseEnum;
import com.njcn.csdevice.enums.LineBaseEnum; import com.njcn.csdevice.enums.LineBaseEnum;
import com.njcn.csdevice.mapper.*; import com.njcn.csdevice.mapper.CsDataArrayMapper;
import com.njcn.csdevice.mapper.CsDataSetMapper;
import com.njcn.csdevice.mapper.CsGroArrMapper;
import com.njcn.csdevice.mapper.CsGroupMapper;
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO; import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
import com.njcn.csdevice.pojo.param.EnergyBaseParam; import com.njcn.csdevice.pojo.param.EnergyBaseParam;
import com.njcn.csdevice.pojo.po.*; import com.njcn.csdevice.pojo.po.*;
@@ -38,6 +41,8 @@ import com.njcn.csharmonic.constant.HarmonicConstant;
import com.njcn.csharmonic.param.*; import com.njcn.csharmonic.param.*;
import com.njcn.csharmonic.pojo.vo.ThdDataTdVO; import com.njcn.csharmonic.pojo.vo.ThdDataTdVO;
import com.njcn.csharmonic.pojo.vo.ThdDataVO; import com.njcn.csharmonic.pojo.vo.ThdDataVO;
import com.njcn.device.biz.mapper.OverLimitWlMapper;
import com.njcn.device.biz.pojo.po.Overlimit;
import com.njcn.influx.pojo.bo.CommonQueryParam; import com.njcn.influx.pojo.bo.CommonQueryParam;
import com.njcn.influx.pojo.dto.EventDataSetDTO; import com.njcn.influx.pojo.dto.EventDataSetDTO;
import com.njcn.influx.pojo.dto.StatisticalDataDTO; import com.njcn.influx.pojo.dto.StatisticalDataDTO;
@@ -91,7 +96,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
private final EvtDataService evtDataService; private final EvtDataService evtDataService;
private final DecimalFormat df = new DecimalFormat("#0.00"); private final DecimalFormat df = new DecimalFormat("#0.00");
private final EleEvtFeignClient eleEvtFeignClient; private final EleEvtFeignClient eleEvtFeignClient;
private final OverlimitMapper overlimitMapper; private final OverLimitWlMapper overLimitWlMapper;
private final CsDataSetMapper csDataSetMapper; private final CsDataSetMapper csDataSetMapper;
private final EventFeignClient eventFeignClient; private final EventFeignClient eventFeignClient;
private final InfluxDbParamUtil influxDbParamUtil; private final InfluxDbParamUtil influxDbParamUtil;
@@ -580,7 +585,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
@Override @Override
public List<ThdDataTdVO> getDeviceTrendData(String devId, String lineId,String groupId) { public List<ThdDataTdVO> getDeviceTrendData(String devId, String lineId,String groupId) {
List<ThdDataTdVO> data = new ArrayList(); List<ThdDataTdVO> data = new ArrayList();
List<Overlimit> overlimits = overlimitMapper.selectBatchIds(Arrays.asList(lineId)); List<Overlimit> overlimits = overLimitWlMapper.selectBatchIds(Arrays.asList(lineId));
List<CsLinePO> finalCsLinePOList = csLineFeignClient.queryLineById(Arrays.asList(lineId)).getData(); List<CsLinePO> finalCsLinePOList = csLineFeignClient.queryLineById(Arrays.asList(lineId)).getData();
List<CsEquipmentDeliveryDTO> data1 = equipmentFeignClient.queryDeviceById(Stream.of(devId).collect(Collectors.toList())).getData(); List<CsEquipmentDeliveryDTO> data1 = equipmentFeignClient.queryDeviceById(Stream.of(devId).collect(Collectors.toList())).getData();
//便携式设备-稳态指标-实时数据-指标 //便携式设备-稳态指标-实时数据-指标
@@ -794,7 +799,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
List<ThdDataVO> result = new ArrayList<>(); List<ThdDataVO> result = new ArrayList<>();
CsLinePO finalCsLinePO = csLineFeignClient.getById(trendDataQueryParam.getLineId()).getData(); CsLinePO finalCsLinePO = csLineFeignClient.getById(trendDataQueryParam.getLineId()).getData();
CsDataSet csDataSet = csDataSetMapper.selectOne(new LambdaQueryWrapper<CsDataSet>().eq(CsDataSet::getId,finalCsLinePO.getDataSetId())); CsDataSet csDataSet = csDataSetMapper.selectOne(new LambdaQueryWrapper<CsDataSet>().eq(CsDataSet::getId,finalCsLinePO.getDataSetId()));
if(Objects.isNull(csDataSet) || StrUtil.isBlank(csDataSet.getDataLevel())){ if(Objects.isNull(csDataSet) || StrUtil.isBlank(csDataSet.getDataLevel())) {
throw new BusinessException("当前测点数据集主要信息缺失,请联系管理员排查(测点表里面数据集id缺失)"); throw new BusinessException("当前测点数据集主要信息缺失,请联系管理员排查(测点表里面数据集id缺失)");
} }
Double ct = finalCsLinePO.getCtRatio(); Double ct = finalCsLinePO.getCtRatio();
@@ -947,7 +952,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
Double ct = finalCsLinePO.getCtRatio(); Double ct = finalCsLinePO.getCtRatio();
Double pt = finalCsLinePO.getPtRatio(); Double pt = finalCsLinePO.getPtRatio();
// String position = finalCsLinePO.getPosition(); // String position = finalCsLinePO.getPosition();
Overlimit overlimit = overlimitMapper.selectById(finalCsLinePO.getLineId()); Overlimit overlimit = overLimitWlMapper.selectById(finalCsLinePO.getLineId());
if (Objects.isNull(overlimit)) { if (Objects.isNull(overlimit)) {
throw new BusinessException("当前测点限值信息缺失,请联系管理员排查"); throw new BusinessException("当前测点限值信息缺失,请联系管理员排查");
} }
@@ -1126,7 +1131,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
} else { } else {
result.addAll(dataList); result.addAll(dataList);
} }
} }
} }
return result; return result;
@@ -1135,6 +1140,9 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
@Override @Override
public Map<String, List<ThdDataVO>> sensitiveUserTrendData(SensitiveUserTrendDataQueryParam param) { public Map<String, List<ThdDataVO>> sensitiveUserTrendData(SensitiveUserTrendDataQueryParam param) {
Map<String, List<ThdDataVO>> result = new HashMap<>(); Map<String, List<ThdDataVO>> result = new HashMap<>();
if (Objects.isNull(param.getSensitiveUserId())) {
return result;
}
result.put("before", new ArrayList<>()); result.put("before", new ArrayList<>());
result.put("after", new ArrayList<>()); result.put("after", new ArrayList<>());
String sensitiveUserId = param.getSensitiveUserId(); String sensitiveUserId = param.getSensitiveUserId();
@@ -1154,7 +1162,9 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
List<SensitiveUserTrendDataQueryParam> paramList = param.getList(); List<SensitiveUserTrendDataQueryParam> paramList = param.getList();
List<TrendDataQueryParam> indexList = paramList.stream().map(item -> { List<TrendDataQueryParam> indexList = paramList.stream().map(item -> {
TrendDataQueryParam queryParam = new TrendDataQueryParam(); TrendDataQueryParam queryParam = new TrendDataQueryParam();
queryParam.setFrequency(item.getFrequency()); if (ObjectUtil.isNotNull(param.getHarmonicCount())) {
queryParam.setFrequency(String.valueOf(param.getHarmonicCount()));
}
queryParam.setStatisticalId(item.getStatisticalId()); queryParam.setStatisticalId(item.getStatisticalId());
return queryParam; return queryParam;
}).collect(Collectors.toList()); }).collect(Collectors.toList());

View File

@@ -596,7 +596,6 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
return device; return device;
} }
@Override @Override
public List<CsLedgerVO> getztProjectTree() { public List<CsLedgerVO> getztProjectTree() {
List<CsLedgerVO> engineeringList; List<CsLedgerVO> engineeringList;
@@ -604,76 +603,264 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
/*获取用户工程,设备信息过滤*/ /*获取用户工程,设备信息过滤*/
List<String> roleengineer = roleEngineerDevService.getRoleengineer(); List<String> roleengineer = roleEngineerDevService.getRoleengineer();
List<String> device = roleEngineerDevService.getDevice(); List<String> device = roleEngineerDevService.getDevice();
List<String> zhiLianDevice = new ArrayList<>();
List<String> cldDevice = new ArrayList<>();
if (CollectionUtil.isNotEmpty(device)) {
List<CsEquipmentDeliveryPO> csEquipmentDeliveryPOS = csEquipmentDeliveryMapper.selectBatchIds(device);
DictTreeVO vo1 = dictTreeFeignClient.queryByCode(DicDataEnum.DEV_CLD.getCode()).getData();
Optional.ofNullable(vo1)
.map(DictTreeVO::getId)
.ifPresent(id -> csEquipmentDeliveryPOS.stream()
.filter(item -> Objects.equals(item.getDevType(), id))
.map(CsEquipmentDeliveryPO::getId)
.forEach(cldDevice::add)
);
DictTreeVO vo2 = dictTreeFeignClient.queryByCode(DicDataEnum.CONNECT_DEV.getCode()).getData();
Optional.ofNullable(vo2)
.map(DictTreeVO::getId)
.ifPresent(id -> csEquipmentDeliveryPOS.stream()
.filter(item -> Objects.equals(item.getDevType(), id))
.map(CsEquipmentDeliveryPO::getId)
.forEach(zhiLianDevice::add)
);
}
engineeringList = allList.stream().filter(item -> roleengineer.contains(item.getId())).collect(Collectors.toList()); engineeringList = allList.stream().filter(item -> roleengineer.contains(item.getId())).collect(Collectors.toList());
List<CsLedgerVO> projectList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList()); List<CsLedgerVO> projectList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
List<CsLedgerVO> deviceList = allList.stream().filter(item -> device.contains(item.getId()) && !Objects.equals(item.getPid(), "0")). Map<String, CsEquipmentDeliveryPO> poMap = allList.stream()
peek( .filter(item -> device.contains(item.getId()) && !Objects.equals(item.getPid(), "0"))
temp -> { .map(CsLedgerVO::getId)
CsEquipmentDeliveryPO po = csEquipmentDeliveryMapper.selectById(temp.getId()); .distinct()
temp.setComFlag(po.getRunStatus()); .collect(Collectors.toMap(
temp.setNDId(po.getNdid()); Function.identity(),
temp.setType("device"); csEquipmentDeliveryMapper::selectById
} ));
).
sorted(Comparator.comparing(CsLedgerVO::getSort))
.collect(Collectors.toList());
checkDevSetData(deviceList);
projectList.forEach(pro -> pro.setChildren(getChildren(pro, deviceList)));
engineeringList.forEach(eng -> eng.setChildren(getChildren(eng, projectList)));
//获取便携式项目数 //获取治理设备
List<CsLedgerVO> deviceList = allList.stream()
.filter(item -> zhiLianDevice.contains(item.getId()) && !Objects.equals(item.getPid(), "0"))
.peek(item -> {
CsEquipmentDeliveryPO po = poMap.get(item.getId());
item.setComFlag(po.getRunStatus());
item.setNDId(po.getNdid());
item.setType("device");
item.setProcess(po.getProcess());
})
.filter(item -> Objects.equals(poMap.get(item.getId()).getUsageStatus(), 1))
.sorted(Comparator.comparing(CsLedgerVO::getSort))
.collect(Collectors.toList());
List<CsLedgerVO> engineeringList1 = new ArrayList<>();
List<CsLedgerVO> projectList1 = new ArrayList<>();
checkDevSetData(deviceList);
List<String> dev = deviceList.stream().map(CsLedgerVO::getId).collect(Collectors.toList());
List<CsLedgerVO> ledger1 = getProAndEngineer(dev);
if (CollectionUtil.isNotEmpty(ledger1)) {
engineeringList1 = ledger1.stream().filter(item -> item.getLevel().equals(LineBaseEnum.ENGINEERING_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
projectList1 = ledger1.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
projectList1.forEach(pro -> pro.setChildren(getChildren(pro, deviceList)));
List<CsLedgerVO> finalProjectList = projectList1;
engineeringList1.forEach(eng -> eng.setChildren(getChildren(eng, finalProjectList)));
}
//获取云前置设备
List<CsLedgerVO> cldDevList = allList.stream()
.filter(item -> cldDevice.contains(item.getId()) && !Objects.equals(item.getPid(), "0"))
.peek(item -> {
CsEquipmentDeliveryPO po = poMap.get(item.getId());
item.setComFlag(po.getRunStatus());
item.setNDId(po.getNdid());
item.setType("device");
item.setProcess(po.getProcess());
})
.filter(item -> Objects.equals(poMap.get(item.getId()).getUsageStatus(), 1))
.sorted(Comparator.comparing(CsLedgerVO::getSort))
.collect(Collectors.toList());
checkDevSetData(cldDevList);
List<CsLedgerVO> engineeringList2 = new ArrayList<>();
List<CsLedgerVO> projectList2 = new ArrayList<>();
List<String> dev2 = cldDevList.stream().map(CsLedgerVO::getId).collect(Collectors.toList());
List<CsLedgerVO> ledger2 = getProAndEngineer(dev2);
if (CollectionUtil.isNotEmpty(ledger2)) {
engineeringList2 = ledger2.stream().filter(item -> item.getLevel().equals(LineBaseEnum.ENGINEERING_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
projectList2 = ledger2.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
projectList2.forEach(pro -> pro.setChildren(getChildren(pro, cldDevList)));
List<CsLedgerVO> finalProjectList = projectList2;
engineeringList2.forEach(eng -> eng.setChildren(getChildren(eng, finalProjectList)));
}
//获取便携式设备树
CsLedgerVO portable = new CsLedgerVO(); CsLedgerVO portable = new CsLedgerVO();
portable.setLevel(0); portable.setLevel(0);
portable.setName(DataParam.PORTABLE_SYSTEM); portable.setName(DataParam.portableDev);
portable.setPid("0"); portable.setPid("0");
portable.setId(IdUtil.simpleUUID()); portable.setId(IdUtil.simpleUUID());
CsLedgerVO project = new CsLedgerVO(); List<CsLedgerVO> ledger;
project.setLevel(1); String role = RequestUtil.getUserRole();
project.setName(DataParam.WIRELESS_PROJECT); List<String> roles = JSONArray.parseArray(role, String.class);
project.setPid("0"); if(roles.contains(AppRoleEnum.ROOT.getCode()) || roles.contains(AppRoleEnum.OPERATION_MANAGER.getCode()) || roles.contains(AppRoleEnum.REGULAR_USER.getCode())){
project.setId(DataParam.WIRELESS_PROJECT_ID); ledger = allList.stream()
.filter(item -> Objects.equals(item.getLevel(), 2) && Objects.equals(item.getPid(), "0"))
List<CsLedgerVO> portables = allList.stream().filter(item -> Objects.equals(item.getLevel(), 2) && Objects.equals(item.getPid(), "0")).collect(Collectors.toList()); .collect(Collectors.toList());
checkDevSetData(portables); } else {
for (CsLedgerVO c : portables) { LambdaQueryWrapper<CsDeviceUserPO> queryWrapper = new LambdaQueryWrapper<>();
c.setPid(project.getId()); queryWrapper.eq(CsDeviceUserPO::getPrimaryUserId, RequestUtil.getUserIndex());
CsEquipmentDeliveryPO po = csEquipmentDeliveryMapper.selectById(c.getId()); List<CsDeviceUserPO> list1 = csDeviceUserPOMapper.selectList(queryWrapper);
c.setComFlag(po.getRunStatus()); List<String> result = new ArrayList<>();
c.setNDId(po.getNdid()); if (CollectionUtil.isNotEmpty(list1)) {
c.setType("device"); result = list1.stream().map(CsDeviceUserPO::getDeviceId).collect(Collectors.toList());
}
//针对未启用的装置判断
List<String> finalResult = result;
ledger = allList.stream()
.filter(item -> Objects.equals(item.getLevel(), 2) && Objects.equals(item.getPid(), "0") && finalResult.contains(item.getId()))
.collect(Collectors.toList());
} }
project.setChildren(portables);
List<CsLedgerVO> wxProjectList = new ArrayList<>(); Map<String, CsEquipmentDeliveryPO> poMap2 = ledger.stream()
wxProjectList.add(project); .collect(Collectors.toMap(
CsLedgerVO::getId,
portable.setChildren(wxProjectList); csEquipmentDeliveryMapper::selectById,
(existing, replacement) -> existing
));
List<CsLedgerVO> portables = ledger.stream()
.peek(c -> {
CsEquipmentDeliveryPO po = poMap2.get(c.getId());
c.setPid(portable.getId());
c.setComFlag(po.getRunStatus());
c.setNDId(po.getNdid());
c.setType("device");
c.setName(po.getName());
c.setSort(po.getSort());
})
.filter(c -> poMap2.get(c.getId()).getUsageStatus() == 1)
.collect(Collectors.toList());
portables = portables.stream().sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
portable.setChildren(portables);
CsLedgerVO government = new CsLedgerVO(); CsLedgerVO government = new CsLedgerVO();
government.setLevel(0); government.setLevel(0);
government.setName(DataParam.GOVERNANCE_SYSTEM); government.setName(DataParam.governmentDev);
government.setPid("0"); government.setPid("0");
government.setId(IdUtil.simpleUUID()); government.setId(IdUtil.simpleUUID());
government.setChildren(engineeringList); government.setChildren(engineeringList1);
List<CsLedgerVO> tree = new ArrayList<>();
//获取云前置设备树
CsLedgerVO cld = new CsLedgerVO();
cld.setLevel(0);
cld.setName(DataParam.cldDev);
cld.setPid("0");
cld.setId(IdUtil.simpleUUID());
cld.setChildren(engineeringList2);
List<CsLedgerVO> tree = new ArrayList<>();
if (CollUtil.isNotEmpty(portables)) { if (CollUtil.isNotEmpty(portables)) {
tree.add(portable); CsLedgerVO vo1 = new CsLedgerVO();
vo1.setLevel(0);
vo1.setName(DataParam.PORTABLE_SYSTEM);
vo1.setPid("0");
vo1.setId(IdUtil.simpleUUID());
CsLedgerVO vo2 = new CsLedgerVO();
vo2.setLevel(1);
vo2.setName(DataParam.WIRELESS_PROJECT);
vo2.setPid("0");
vo2.setId(DataParam.WIRELESS_PROJECT_ID);
vo2.setChildren(portables);
vo1.setChildren(Collections.singletonList(vo2));
tree.add(vo1);
} }
if (CollUtil.isNotEmpty(deviceList)) { if (CollUtil.isNotEmpty(deviceList)) {
tree.add(government); tree.add(government);
} }
if (CollUtil.isNotEmpty(cldDevList)) {
tree.add(cld);
}
return tree; return tree;
} }
// @Override
// public List<CsLedgerVO> getztProjectTree() {
// List<CsLedgerVO> engineeringList;
// List<CsLedgerVO> allList = this.baseMapper.getAll();
// /*获取用户工程,设备信息过滤*/
// List<String> roleengineer = roleEngineerDevService.getRoleengineer();
// List<String> device = roleEngineerDevService.getDevice();
// engineeringList = allList.stream().filter(item -> roleengineer.contains(item.getId())).collect(Collectors.toList());
// List<CsLedgerVO> projectList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
//
// List<CsLedgerVO> deviceList = allList.stream().filter(item -> device.contains(item.getId()) && !Objects.equals(item.getPid(), "0")).
// peek(
// temp -> {
// CsEquipmentDeliveryPO po = csEquipmentDeliveryMapper.selectById(temp.getId());
// temp.setComFlag(po.getRunStatus());
// temp.setNDId(po.getNdid());
// temp.setType("device");
// }
// ).
// sorted(Comparator.comparing(CsLedgerVO::getSort))
// .collect(Collectors.toList());
// checkDevSetData(deviceList);
// projectList.forEach(pro -> pro.setChildren(getChildren(pro, deviceList)));
// engineeringList.forEach(eng -> eng.setChildren(getChildren(eng, projectList)));
//
// //获取便携式项目数
// CsLedgerVO portable = new CsLedgerVO();
// portable.setLevel(0);
// portable.setName(DataParam.PORTABLE_SYSTEM);
// portable.setPid("0");
// portable.setId(IdUtil.simpleUUID());
//
// CsLedgerVO project = new CsLedgerVO();
// project.setLevel(1);
// project.setName(DataParam.WIRELESS_PROJECT);
// project.setPid("0");
// project.setId(DataParam.WIRELESS_PROJECT_ID);
//
// List<CsLedgerVO> portables = allList.stream().filter(item -> Objects.equals(item.getLevel(), 2) && Objects.equals(item.getPid(), "0")).collect(Collectors.toList());
// checkDevSetData(portables);
// for (CsLedgerVO c : portables) {
// c.setPid(project.getId());
// CsEquipmentDeliveryPO po = csEquipmentDeliveryMapper.selectById(c.getId());
// c.setComFlag(po.getRunStatus());
// c.setNDId(po.getNdid());
// c.setType("device");
// }
// project.setChildren(portables);
//
// List<CsLedgerVO> wxProjectList = new ArrayList<>();
// wxProjectList.add(project);
//
// portable.setChildren(wxProjectList);
//
//
// CsLedgerVO government = new CsLedgerVO();
// government.setLevel(0);
// government.setName(DataParam.GOVERNANCE_SYSTEM);
// government.setPid("0");
// government.setId(IdUtil.simpleUUID());
// government.setChildren(engineeringList);
// List<CsLedgerVO> tree = new ArrayList<>();
//
// if (CollUtil.isNotEmpty(portables)) {
// tree.add(portable);
// }
// if (CollUtil.isNotEmpty(deviceList)) {
// tree.add(government);
// }
//
// return tree;
// }
@Override @Override
public List<CsLedgerVO> objTree() { public List<CsLedgerVO> objTree() {
List<CsLedgerVO> result = new ArrayList<>(); List<CsLedgerVO> result = new ArrayList<>();
String userId = "fa37b93cc90d4c1784ca8f6debddee1a"; String userId = RequestUtil.getUserIndex();
UserVO userVO = userFeignClient.getUserById(userId).getData(); UserVO userVO = userFeignClient.getUserById(userId).getData();
List<String> devIds; List<String> devIds;
if (userVO.getType().equals(UserType.SUPER_ADMINISTRATOR) || userVO.getType().equals(UserType.ADMINISTRATOR)) { if (userVO.getType().equals(UserType.SUPER_ADMINISTRATOR) || userVO.getType().equals(UserType.ADMINISTRATOR)) {
@@ -698,6 +885,9 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
List<String> lineIds = poList.stream().map(CsLinePO::getLineId).distinct().collect(Collectors.toList()); List<String> lineIds = poList.stream().map(CsLinePO::getLineId).distinct().collect(Collectors.toList());
List<PqSensitiveUser> pqSensitiveUserList = pqSensitiveUserFeignClient.getListByIds(objIds).getData(); List<PqSensitiveUser> pqSensitiveUserList = pqSensitiveUserFeignClient.getListByIds(objIds).getData();
if (CollUtil.isEmpty(pqSensitiveUserList)) {
return result;
}
Map<String,String> objMap = pqSensitiveUserList.stream().collect(Collectors.toMap(PqSensitiveUser::getId, PqSensitiveUser::getName)); Map<String,String> objMap = pqSensitiveUserList.stream().collect(Collectors.toMap(PqSensitiveUser::getId, PqSensitiveUser::getName));
List<CsLedger> csLineList = this.baseMapper.selectList(new LambdaQueryWrapper<CsLedger>().in(CsLedger::getId, lineIds)); List<CsLedger> csLineList = this.baseMapper.selectList(new LambdaQueryWrapper<CsLedger>().in(CsLedger::getId, lineIds));

View File

@@ -29,6 +29,7 @@ import com.njcn.csharmonic.pojo.po.PqSensitiveUser;
import com.njcn.oss.constant.OssPath; import com.njcn.oss.constant.OssPath;
import com.njcn.oss.utils.FileStorageUtil; import com.njcn.oss.utils.FileStorageUtil;
import com.njcn.system.api.DicDataFeignClient; import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.api.DictTreeFeignClient;
import com.njcn.system.enums.DicDataEnum; import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.pojo.po.DictData; import com.njcn.system.pojo.po.DictData;
import com.njcn.user.api.UserFeignClient; import com.njcn.user.api.UserFeignClient;
@@ -44,10 +45,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.*;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@@ -74,7 +72,7 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
private final UserFeignClient userFeignClient; private final UserFeignClient userFeignClient;
private final CsEquipmentDeliveryMapper csEquipmentDeliveryMapper; private final CsEquipmentDeliveryMapper csEquipmentDeliveryMapper;
private final CsDeviceUserPOMapper csDeviceUserPOMapper; private final CsDeviceUserPOMapper csDeviceUserPOMapper;
private final DictTreeFeignClient dictTreeFeignClient;
@Override @Override
@@ -146,7 +144,7 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
//1.新增监测点信息 //1.新增监测点信息
BeanUtils.copyProperties(param,po); BeanUtils.copyProperties(param,po);
po.setStatus(1); po.setStatus(1);
po.setRunStatus(2); po.setRunStatus(param.getRunStatus());
po.setLineId(param.getDevMac().replace(":","") + param.getLineNo()); po.setLineId(param.getDevMac().replace(":","") + param.getLineNo());
//模板id //模板id
CsDevModelPO po1 = csDevModelService.getCldModel(); CsDevModelPO po1 = csDevModelService.getCldModel();
@@ -160,8 +158,8 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
po.setClDid(list.get(0).getClDev()); po.setClDid(list.get(0).getClDev());
} }
//监测位置 //监测位置
DictData data = dicDataFeignClient.getDicDataByCode(DicDataEnum.GRID_SIDE.getCode()).getData(); //DictData data = dicDataFeignClient.getDicDataByCode(DicDataEnum.GRID_SIDE.getCode()).getData();
po.setPosition(data.getId()); po.setPosition(param.getPosition());
this.save(po); this.save(po);
//2.新增台账树信息 //2.新增台账树信息
@@ -209,6 +207,7 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
.set(CsLinePO::getMonitorObj,param.getMonitorObj()) .set(CsLinePO::getMonitorObj,param.getMonitorObj())
.set(CsLinePO::getMonitorObj,param.getMonitorObj()) .set(CsLinePO::getMonitorObj,param.getMonitorObj())
.set(CsLinePO::getGovern,param.getGovern()) .set(CsLinePO::getGovern,param.getGovern())
.set(CsLinePO::getPosition,param.getPosition())
.set(CsLinePO::getMonitorUser,param.getMonitorUser()); .set(CsLinePO::getMonitorUser,param.getMonitorUser());
this.update(lambdaUpdateWrapper); this.update(lambdaUpdateWrapper);
@@ -275,7 +274,7 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
public List<CsLinePO> getSimpleLine() { public List<CsLinePO> getSimpleLine() {
List<String> devIds = commGetDevIds(RequestUtil.getUserIndex()); List<String> devIds = commGetDevIds(RequestUtil.getUserIndex());
if(CollUtil.isNotEmpty(devIds)){ if(CollUtil.isNotEmpty(devIds)){
List<CsLinePO> poList = this.lambdaQuery().select(CsLinePO::getLineId,CsLinePO::getName).in(CsLinePO::getDeviceId,devIds) List<CsLinePO> poList = this.lambdaQuery().select(CsLinePO::getLineId,CsLinePO::getName,CsLinePO::getMonitorUser).in(CsLinePO::getDeviceId,devIds)
.eq(CsLinePO::getStatus, DataStateEnum.ENABLE.getCode()).list(); .eq(CsLinePO::getStatus, DataStateEnum.ENABLE.getCode()).list();
return poList; return poList;
}else { }else {
@@ -287,8 +286,8 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
UserVO userVO = userFeignClient.getUserById(userId).getData(); UserVO userVO = userFeignClient.getUserById(userId).getData();
List<String> devIds; List<String> devIds;
if(userVO.getType().equals(UserType.SUPER_ADMINISTRATOR ) || userVO.getType().equals(UserType.ADMINISTRATOR )){ if(userVO.getType().equals(UserType.SUPER_ADMINISTRATOR ) || userVO.getType().equals(UserType.ADMINISTRATOR )){
devIds = csEquipmentDeliveryMapper.selectList(new LambdaQueryWrapper<CsEquipmentDeliveryPO>().eq(CsEquipmentDeliveryPO::getStatus,DataStateEnum.ENABLE)).stream().map(CsEquipmentDeliveryPO::getId).collect(Collectors.toList()); devIds = csEquipmentDeliveryMapper.selectList(new LambdaQueryWrapper<CsEquipmentDeliveryPO>().ne(CsEquipmentDeliveryPO::getRunStatus,DataStateEnum.DELETED.getCode())).stream().map(CsEquipmentDeliveryPO::getId).collect(Collectors.toList());
}else { } else {
LambdaQueryWrapper<CsDeviceUserPO> lambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsDeviceUserPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.select(CsDeviceUserPO::getDeviceId) lambdaQueryWrapper.select(CsDeviceUserPO::getDeviceId)
.and(w->w.eq(CsDeviceUserPO::getPrimaryUserId,userId).or().eq(CsDeviceUserPO::getSubUserId,userId)) .and(w->w.eq(CsDeviceUserPO::getPrimaryUserId,userId).or().eq(CsDeviceUserPO::getSubUserId,userId))
@@ -313,24 +312,34 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
result.setCurrent(param.getPageNum()); result.setCurrent(param.getPageNum());
result.setSize(param.getPageSize()); result.setSize(param.getPageSize());
// 查询登录用户拥有的监测点台账
Page<CsLinePO> linePage = this.page(new Page<>(param.getPageNum(), param.getPageSize()), List<CsLinePO> poList = getSimpleLine();
new LambdaQueryWrapper<CsLinePO>() // 构建基础查询条件
.eq(CsLinePO::getStatus, 1) LambdaQueryWrapper<CsLinePO> lambdaQueryWrapper = new LambdaQueryWrapper<CsLinePO>()
// 关联敏感用户 .eq(CsLinePO::getStatus, 1)
.isNotNull(CsLinePO::getMonitorUser) // 关联敏感用户
.orderByAsc(CsLinePO::getMonitorUser) //.isNotNull(CsLinePO::getMonitorUser)
); .orderByAsc(CsLinePO::getMonitorUser);
// 只有当lineList不为空时才添加in条件
if (CollUtil.isNotEmpty(poList)) {
List<String> lineList = poList.stream().map(CsLinePO::getLineId).collect(Collectors.toList());
lambdaQueryWrapper.in(CsLinePO::getLineId, lineList);
}
Page<CsLinePO> linePage = this.page(new Page<>(param.getPageNum(), param.getPageSize()), lambdaQueryWrapper);
BeanUtil.copyProperties(linePage, result); BeanUtil.copyProperties(linePage, result);
List<CsLinePO> records = linePage.getRecords(); List<CsLinePO> records = linePage.getRecords();
if (CollUtil.isEmpty(records)) { if (CollUtil.isEmpty(records)) {
return result; return result;
} }
List<PqSensitiveUserLineVO> list = new ArrayList<>(); List<PqSensitiveUserLineVO> list = new ArrayList<>();
List<String> sensitiveUserIds = list.stream().map(PqSensitiveUserLineVO::getSensitiveUser).distinct().collect(Collectors.toList()); List<String> sensitiveUserIds = list.stream().map(PqSensitiveUserLineVO::getSensitiveUser).distinct().collect(Collectors.toList());
Map<String, String> sensitiveUserNameMap = pqSensitiveUserFeignClient.getListByIds(sensitiveUserIds).getData() Map<String, String> sensitiveUserNameMap = new HashMap<>();
.stream().collect(Collectors.toMap(PqSensitiveUser::getId, PqSensitiveUser::getName)); List<PqSensitiveUser> pqSensitiveUserList = pqSensitiveUserFeignClient.getListByIds(sensitiveUserIds).getData();
if (CollUtil.isNotEmpty(pqSensitiveUserList)) {
sensitiveUserNameMap = pqSensitiveUserList.stream().collect(Collectors.toMap(PqSensitiveUser::getId, PqSensitiveUser::getName));
}
PqSensitiveUserLineVO sensitiveUserLineVO; PqSensitiveUserLineVO sensitiveUserLineVO;
for (CsLinePO record : records) { for (CsLinePO record : records) {
sensitiveUserLineVO = new PqSensitiveUserLineVO(); sensitiveUserLineVO = new PqSensitiveUserLineVO();
@@ -349,26 +358,34 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
} }
} }
// 监测类型 // 监测类型
sensitiveUserLineVO.setPosition(record.getPosition()); if (ObjectUtil.isNotNull(record.getPosition())) {
DictData positionDictData = dicDataFeignClient.getDicDataById(record.getPosition()).getData(); sensitiveUserLineVO.setPosition(record.getPosition());
if (positionDictData != null) { DictData positionDictData = dicDataFeignClient.getDicDataById(record.getPosition()).getData();
sensitiveUserLineVO.setPosition(positionDictData.getName()); if (positionDictData != null) {
sensitiveUserLineVO.setPosition(positionDictData.getName());
}
} }
// 电压等级 // 电压等级
sensitiveUserLineVO.setVolGrade(record.getVolGrade()); if (ObjectUtil.isNotNull(record.getVolGrade())) {
sensitiveUserLineVO.setVolGrade(record.getVolGrade());
}
// 运行状态 // 运行状态
sensitiveUserLineVO.setRunStatus(getRunStatusDescription(record.getRunStatus())); if (ObjectUtil.isNotNull(record.getRunStatus())) {
//获取设备状态
int devRunStatus = csEquipmentDeliveryMapper.selectById(record.getDeviceId()).getRunStatus();
sensitiveUserLineVO.setRunStatus(getRunStatusDescription(devRunStatus));
}
// 报告文件 // 报告文件
sensitiveUserLineVO.setReportFilePath(record.getReportFilePath()); sensitiveUserLineVO.setReportFilePath(record.getReportFilePath());
// 最新数据时间 // 最新数据时间
List<CsLineLatestData> lineLatestDataList = csLineLatestDataFeignClient.listData().getData(); // List<CsLineLatestData> lineLatestDataList = csLineLatestDataFeignClient.listData().getData();
if (CollUtil.isNotEmpty(lineLatestDataList)) { // if (CollUtil.isNotEmpty(lineLatestDataList)) {
sensitiveUserLineVO.setLatestTime(lineLatestDataList.stream() // sensitiveUserLineVO.setLatestTime(lineLatestDataList.stream()
.filter(item -> item.getLineId().equals(record.getLineId())) // .filter(item -> item.getLineId().equals(record.getLineId()))
.map(CsLineLatestData::getTimeId) // .map(CsLineLatestData::getTimeId)
.max(LocalDateTime::compareTo) // .max(LocalDateTime::compareTo)
.orElse(null)); // .orElse(null));
} // }
list.add(sensitiveUserLineVO); list.add(sensitiveUserLineVO);
} }
result.setRecords(list); result.setRecords(list);
@@ -377,7 +394,7 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
@Override @Override
public boolean uploadReport(MultipartFile file, String lineId) { public boolean uploadReport(MultipartFile file, String lineId) {
String filePath = fileStorageUtil.uploadMultipart(file, OssPath.GOVERN_HARMONIC_FILE); String filePath = fileStorageUtil.uploadMultipart(file, OssPath.GOVERN_HARMONIC_FILE, true);
return this.update(new LambdaUpdateWrapper<CsLinePO>().eq(CsLinePO::getLineId, lineId).set(CsLinePO::getReportFilePath, filePath)); return this.update(new LambdaUpdateWrapper<CsLinePO>().eq(CsLinePO::getLineId, lineId).set(CsLinePO::getReportFilePath, filePath));
} }
@@ -400,15 +417,22 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
return new LineDetailDataVO(); return new LineDetailDataVO();
} else { } else {
CsLinePO csLinePO = this.baseMapper.selectOne(new LambdaQueryWrapper<CsLinePO>().eq(CsLinePO::getLineId,id)); CsLinePO csLinePO = this.baseMapper.selectOne(new LambdaQueryWrapper<CsLinePO>().eq(CsLinePO::getLineId,id));
//获取设备信息
CsEquipmentDeliveryPO csEquipmentDelivery = csEquipmentDeliveryMapper.selectById(csLinePO.getDeviceId());
String code = dictTreeFeignClient.queryById(csEquipmentDelivery.getDevType()).getData().getCode();
CsLedger csLedger = csLedgerMapper.selectById(csLinePO.getLineId()); CsLedger csLedger = csLedgerMapper.selectById(csLinePO.getLineId());
LineDetailDataVO lineDetailDataVO = new LineDetailDataVO(); LineDetailDataVO lineDetailDataVO = new LineDetailDataVO();
lineDetailDataVO.setScale(csLinePO.getVolGrade()+"kV"); lineDetailDataVO.setScale(csLinePO.getVolGrade()+"kV");
lineDetailDataVO.setAreaName(csLedgerMapper.selectById(csLedger.getPids().split(StrUtil.COMMA)[LineBaseEnum.ENGINEERING_LEVEL.getCode()+1]).getName()); if (Objects.equals(DicDataEnum.PORTABLE.getCode(),code)) {
lineDetailDataVO.setBdName(csLedgerMapper.selectById(csLedger.getPids().split(StrUtil.COMMA)[LineBaseEnum.PROJECT_LEVEL.getCode()+1]).getName()); lineDetailDataVO.setAreaName("便携式工程");
lineDetailDataVO.setBdName("便携式项目");
} else {
lineDetailDataVO.setAreaName(csLedgerMapper.selectById(csLedger.getPids().split(StrUtil.COMMA)[LineBaseEnum.ENGINEERING_LEVEL.getCode()+1]).getName());
lineDetailDataVO.setBdName(csLedgerMapper.selectById(csLedger.getPids().split(StrUtil.COMMA)[LineBaseEnum.PROJECT_LEVEL.getCode()+1]).getName());
}
lineDetailDataVO.setLineName(csLinePO.getName());
//Device device = deviceMapper.selectById(devId); //Device device = deviceMapper.selectById(devId);
//lineDetailDataVO.setComFlag(PubUtils.comFlag(device.getComFlag())); //lineDetailDataVO.setComFlag(PubUtils.comFlag(device.getComFlag()));
//lineDetailDataVO.setRunFlag(PubUtils.lineRunFlag(lineDetail.getRunFlag())); //lineDetailDataVO.setRunFlag(PubUtils.lineRunFlag(lineDetail.getRunFlag()));
@@ -420,33 +444,50 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
lineDetailDataVO.setObjName(csLinePO.getMonitorUser()); lineDetailDataVO.setObjName(csLinePO.getMonitorUser());
lineDetailDataVO.setLineId(csLinePO.getLineId()); lineDetailDataVO.setLineId(csLinePO.getLineId());
lineDetailDataVO.setPtType(PubUtils.ptType(csLinePO.getConType())); lineDetailDataVO.setPtType(PubUtils.ptType(csLinePO.getConType()));
lineDetailDataVO.setPt(csLinePO.getPtRatio() + "/" + csLinePO.getPt2Ratio()); lineDetailDataVO.setPt(csLinePO.getPtRatio() + "/" + (Objects.isNull(csLinePO.getPt2Ratio())?1.0:csLinePO.getPt2Ratio()));
lineDetailDataVO.setCt(csLinePO.getCtRatio() + "/" + csLinePO.getCt2Ratio()); lineDetailDataVO.setCt(csLinePO.getCtRatio() + "/" + (Objects.isNull(csLinePO.getCt2Ratio())?1.0:csLinePO.getCt2Ratio()));
lineDetailDataVO.setDealCapacity(csLinePO.getProtocolCapacity().floatValue()); lineDetailDataVO.setDealCapacity(Objects.isNull(csLinePO.getProtocolCapacity())?0.0f:csLinePO.getProtocolCapacity().floatValue());
lineDetailDataVO.setDevCapacity(csLinePO.getDevCapacity().floatValue()); lineDetailDataVO.setDevCapacity(Objects.isNull(csLinePO.getDevCapacity())?0.0f:csLinePO.getDevCapacity().floatValue());
lineDetailDataVO.setShortCapacity(csLinePO.getShortCircuitCapacity().floatValue()); lineDetailDataVO.setShortCapacity(Objects.isNull(csLinePO.getShortCircuitCapacity())?0.0f:csLinePO.getShortCircuitCapacity().floatValue());
lineDetailDataVO.setStandardCapacity(csLinePO.getBasicCapacity().floatValue()); lineDetailDataVO.setStandardCapacity(Objects.isNull(csLinePO.getBasicCapacity())?0.0f:csLinePO.getBasicCapacity().floatValue());
lineDetailDataVO.setTimeInterval(csLinePO.getLineInterval()); lineDetailDataVO.setTimeInterval(csLinePO.getLineInterval());
return lineDetailDataVO; return lineDetailDataVO;
} }
}
@Override
public List<CsLinePO> getLineList(CsLinePO param) {
List<String> keywordsLineIds = new ArrayList<>();
List<CsLinePO> poList = getSimpleLine();
if (CollUtil.isNotEmpty(poList)) {
keywordsLineIds = poList.stream().map(CsLinePO::getLineId).collect(Collectors.toList());
}
List<CsLinePO> result = this.list(new LambdaQueryWrapper<CsLinePO>()
.eq(CsLinePO::getStatus, 1)
.eq(StrUtil.isNotBlank(param.getPosition()), CsLinePO::getPosition, param.getPosition())
.in(CsLinePO::getLineId, keywordsLineIds)
.orderByAsc(CsLinePO::getName));
//根据监测点id查询设备信息
if (CollectionUtil.isNotEmpty(result)) {
//获取设备信息集合
List<String> devList = result.stream().map(CsLinePO::getDeviceId).collect(Collectors.toList());
List<CsEquipmentDeliveryPO> equipmentDeliveryList = csEquipmentDeliveryMapper.selectBatchIds(devList);
Map<String,Integer> runStatusMap = equipmentDeliveryList.stream().collect(Collectors.toMap(CsEquipmentDeliveryPO::getId,CsEquipmentDeliveryPO::getRunStatus));
result.forEach(item->{
item.setRunStatus(runStatusMap.get(item.getDeviceId()));
});
}
return result;
} }
private String getRunStatusDescription(Integer runStatus) { private String getRunStatusDescription(Integer runStatus) {
// 0运行1检修2停运3调试4退运
switch (runStatus) { switch (runStatus) {
case 0:
return "运行";
case 1: case 1:
return "检修"; return "离线";
case 2: case 2:
return "停运"; return "在线";
case 3:
return "调试";
case 4:
return "退运";
default: default:
return "未知"; return "未知";
} }

View File

@@ -0,0 +1,191 @@
package com.njcn.csdevice.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.csdevice.mapper.CsLedgerMapper;
import com.njcn.csdevice.pojo.param.*;
import com.njcn.csdevice.pojo.po.AppProjectPO;
import com.njcn.csdevice.pojo.po.AppTopologyDiagramPO;
import com.njcn.csdevice.pojo.po.CsEngineeringPO;
import com.njcn.csdevice.pojo.po.CsLedger;
import com.njcn.csdevice.pojo.vo.CsLedgerVO;
import com.njcn.csdevice.pojo.vo.EngineeringProjectRelationVo;
import com.njcn.csdevice.service.*;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* <p>
* 数据集表 服务实现类
* </p>
*
* @author xuyang
* @since 2026-01-29
*/
@Service
@RequiredArgsConstructor
public class EngineeringProjectServiceImpl implements IEngineeringProjectService {
private final CsEngineeringService csEngineeringService;
private final AppProjectService appProjectService;
private final ICsLedgerService csLedgerService;
private final CsLedgerMapper csLedgerMapper;
private final AppTopologyDiagramService appTopologyDiagramService;
@Override
@Transactional(rollbackFor = Exception.class)
public boolean addEngineering(CsEngineeringAddParm csEngineeringAddParm) {
boolean result = false;
//新增工程信息
CsEngineeringPO po1 = csEngineeringService.add(csEngineeringAddParm);
//新增cs_ledger数据
CsLedgerParam csLedgerParam = new CsLedgerParam();
csLedgerParam.setId(po1.getId());
csLedgerParam.setPid("9999999");
csLedgerParam.setName(csEngineeringAddParm.getName());
csLedgerParam.setLevel(0);
csLedgerParam.setRemark(csEngineeringAddParm.getDescription());
csLedgerParam.setSort(csEngineeringAddParm.getSort());
CsLedger po2 = csLedgerService.addLedgerTree(csLedgerParam);
if (ObjectUtil.isNotNull(po1) && ObjectUtil.isNotNull(po2)) {
result = true;
}
return result;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean updateEngineering(CsEngineeringAuditParm csEngineeringAuditParm) {
//修改工程信息
CsEngineeringPO po1 = csEngineeringService.updateData(csEngineeringAuditParm);
//修改cs_ledger数据
CsLedgerParam.Update csLedgerParam = new CsLedgerParam.Update();
csLedgerParam.setId(po1.getId());
csLedgerParam.setName(csEngineeringAuditParm.getName());
csLedgerParam.setSort(csEngineeringAuditParm.getSort());
csLedgerService.updateLedgerTree(csLedgerParam);
return true;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean deleteEngineering(String id) {
//查询csledger数据
List<CsLedgerVO> allList = csLedgerMapper.getAll();
allList.forEach(item->{
if (Objects.equals(item.getPid(),id)) {
throw new BusinessException("请先删除该工程下的所有项目");
}
});
//删除工程信息
csEngineeringService.deleteData(id);
//删除台账信息
csLedgerService.deleteLedgerTree(id);
return true;
}
@Override
public boolean addProject(AppProjectAddParm param) {
boolean result = false;
//新增项目信息
AppProjectPO po1 = appProjectService.add(param);
//新增cs_ledger数据
CsLedgerParam csLedgerParam = new CsLedgerParam();
csLedgerParam.setId(po1.getId());
csLedgerParam.setPid(param.getEngineeringId());
csLedgerParam.setName(param.getName());
csLedgerParam.setLevel(1);
csLedgerParam.setSort(param.getSort());
CsLedger po2 = csLedgerService.addLedgerTree(csLedgerParam);
if (ObjectUtil.isNotNull(po1) && ObjectUtil.isNotNull(po2)) {
result = true;
}
return result;
}
@Override
public boolean updateProject(AppProjectAuditParm param) {
//修改工程信息
AppProjectPO po1 = appProjectService.updateData(param);
//修改cs_ledger数据
CsLedgerParam.Update csLedgerParam = new CsLedgerParam.Update();
csLedgerParam.setId(po1.getId());
csLedgerParam.setName(param.getName());
csLedgerParam.setSort(param.getSort());
csLedgerParam.setRemark(param.getDescription());
csLedgerService.updateLedgerTree(csLedgerParam);
return true;
}
@Override
public boolean deleteProject(String id) {
//删除项目信息
appProjectService.delete(id);
//删除台账信息
csLedgerService.deleteLedgerTree(id);
return true;
}
@Override
public List<EngineeringProjectRelationVo> getList() {
List<EngineeringProjectRelationVo> result = new ArrayList<>();
//查询所有工程
LambdaQueryWrapper<CsEngineeringPO> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.eq(CsEngineeringPO::getStatus,"1").orderByAsc(CsEngineeringPO::getSort);
List<CsEngineeringPO> list1 = csEngineeringService.list(queryWrapper1);
//查询所有项目
LambdaQueryWrapper<AppProjectPO> queryWrapper2 = new LambdaQueryWrapper<>();
queryWrapper2.eq(AppProjectPO::getStatus,"1").orderByAsc(AppProjectPO::getSort);
List<AppProjectPO> list2 = appProjectService.list(queryWrapper2);
Map<String,AppProjectPO> map = list2.stream().collect(Collectors.toMap(AppProjectPO::getId, item->item));
//查询所有拓扑图
LambdaQueryWrapper<AppTopologyDiagramPO> queryWrapper3 = new LambdaQueryWrapper<>();
queryWrapper3.eq(AppTopologyDiagramPO::getStatus,"1");
List<AppTopologyDiagramPO> list3 = appTopologyDiagramService.list(queryWrapper3);
Map<String,AppTopologyDiagramPO> map3 = list3.stream().collect(Collectors.toMap(AppTopologyDiagramPO::getProjectId, item->item));
//查询台账信息
List<CsLedgerVO> allList = csLedgerMapper.getAll();
if (CollectionUtil.isNotEmpty(list1)) {
list1.forEach(item->{
EngineeringProjectRelationVo temp = new EngineeringProjectRelationVo();
temp.setEngineeringId(item.getId());
temp.setEngineeringName(item.getName());
temp.setEngineeringArea(item.getProvince()+item.getCity());
temp.setEngineeringRemark(item.getDescription());
temp.setEngineeringSort(item.getSort());
List<CsLedgerVO> projectList = allList.stream().filter(item2->item2.getPid().equals(item.getId())).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(projectList)) {
List<EngineeringProjectRelationVo.ProjectInfo> projectInfoList = new ArrayList<>();
projectList.forEach(item2->{
AppProjectPO po = map.get(item2.getId());
EngineeringProjectRelationVo.ProjectInfo projectInfo = new EngineeringProjectRelationVo.ProjectInfo();
projectInfo.setProjectId(po.getId());
projectInfo.setProjectName(po.getName());
projectInfo.setProjectArea(po.getArea());
projectInfo.setProjectRemark(po.getDescription());
projectInfo.setProjectSort(po.getSort());
projectInfo.setTopologyInfo(Objects.isNull(map3.get(po.getId()))?null:map3.get(po.getId()).getFilePath());
projectInfoList.add(projectInfo);
});
temp.setProjectInfoList(projectInfoList);
}
result.add(temp);
});
}
return result;
}
}

View File

@@ -8,10 +8,10 @@ import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.csp.sentinel.util.StringUtil; import com.alibaba.csp.sentinel.util.StringUtil;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.njcn.access.utils.ChannelObjectUtil; import com.njcn.access.utils.ChannelObjectUtil;
import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.csdevice.mapper.OverlimitMapper;
import com.njcn.csdevice.param.IcdBzParam; import com.njcn.csdevice.param.IcdBzParam;
import com.njcn.csdevice.param.IcdLedgerParam; import com.njcn.csdevice.param.IcdLedgerParam;
import com.njcn.csdevice.param.IcdParam; import com.njcn.csdevice.param.IcdParam;
@@ -22,9 +22,11 @@ import com.njcn.csdevice.pojo.po.*;
import com.njcn.csdevice.pojo.vo.CldLedgerVo; import com.njcn.csdevice.pojo.vo.CldLedgerVo;
import com.njcn.csdevice.pojo.vo.DeviceInfo; import com.njcn.csdevice.pojo.vo.DeviceInfo;
import com.njcn.csdevice.service.*; import com.njcn.csdevice.service.*;
import com.njcn.csdevice.utils.COverlimitUtil;
import com.njcn.csharmonic.api.EventFeignClient; import com.njcn.csharmonic.api.EventFeignClient;
import com.njcn.csharmonic.pojo.po.CsEventPO; import com.njcn.csharmonic.pojo.po.CsEventPO;
import com.njcn.device.biz.mapper.OverLimitWlMapper;
import com.njcn.device.biz.pojo.po.Overlimit;
import com.njcn.device.biz.utils.COverlimitUtil;
import com.njcn.mq.message.BZEventMessage; import com.njcn.mq.message.BZEventMessage;
import com.njcn.mq.template.BZEventMessageTemplate; import com.njcn.mq.template.BZEventMessageTemplate;
import com.njcn.redis.pojo.enums.AppRedisKey; import com.njcn.redis.pojo.enums.AppRedisKey;
@@ -60,7 +62,7 @@ class IcdServiceImpl implements IcdService {
private final EventFeignClient eventFeignClient; private final EventFeignClient eventFeignClient;
private final ICsTerminalLogsService csTerminalLogsService; private final ICsTerminalLogsService csTerminalLogsService;
private final ICsTerminalReplyService csTerminalReplyService; private final ICsTerminalReplyService csTerminalReplyService;
private final OverlimitMapper overlimitMapper; private final OverLimitWlMapper overLimitWlMapper;
private final DateTimeFormatter microsecondFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSS"); private final DateTimeFormatter microsecondFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSS");
@Override @Override
@@ -126,6 +128,7 @@ class IcdServiceImpl implements IcdService {
} }
@Override @Override
@DSTransactional
public void addLedgerInfo(IcdLedgerParam param) { public void addLedgerInfo(IcdLedgerParam param) {
// 第一种:全流程创建 // 第一种:全流程创建
if (isAllIndicesNull(param)) { if (isAllIndicesNull(param)) {
@@ -581,7 +584,6 @@ class IcdServiceImpl implements IcdService {
&& ObjectUtil.isNull(param.getDevIndex()); && ObjectUtil.isNull(param.getDevIndex());
} }
@Transactional(rollbackFor = Exception.class)
public void handleFullProcessCreation(@NotNull IcdLedgerParam param) { public void handleFullProcessCreation(@NotNull IcdLedgerParam param) {
if (ObjectUtil.isNotNull(param.getEngineering())) { if (ObjectUtil.isNotNull(param.getEngineering())) {
CsEngineeringPO po1 = csEngineeringService.addEngineering(param.getEngineering()); CsEngineeringPO po1 = csEngineeringService.addEngineering(param.getEngineering());
@@ -590,17 +592,14 @@ class IcdServiceImpl implements IcdService {
} }
} }
@Transactional(rollbackFor = Exception.class)
public void handleFromEngineeringCreation(IcdLedgerParam param) { public void handleFromEngineeringCreation(IcdLedgerParam param) {
createProjectAndDevices(param); createProjectAndDevices(param);
} }
@Transactional(rollbackFor = Exception.class)
public void handleFromProjectCreation(IcdLedgerParam param) { public void handleFromProjectCreation(IcdLedgerParam param) {
saveDevicesAndLines(param); saveDevicesAndLines(param);
} }
@Transactional(rollbackFor = Exception.class)
public void handleFromDeviceCreation(IcdLedgerParam param) { public void handleFromDeviceCreation(IcdLedgerParam param) {
saveLines(param); saveLines(param);
} }
@@ -634,7 +633,6 @@ class IcdServiceImpl implements IcdService {
saveLines(param); saveLines(param);
} }
@Transactional(rollbackFor = Exception.class)
public void saveLines(IcdLedgerParam param) { public void saveLines(IcdLedgerParam param) {
List<CsLineParam> lineList = param.getLine(); List<CsLineParam> lineList = param.getLine();
if (CollectionUtil.isNotEmpty(lineList)) { if (CollectionUtil.isNotEmpty(lineList)) {
@@ -660,7 +658,7 @@ class IcdServiceImpl implements IcdService {
//新增监测点限值 //新增监测点限值
Overlimit overlimit = COverlimitUtil.globalAssemble(line.getVolGrade().floatValue(), line.getProtocolCapacity().floatValue(),line.getDevCapacity().floatValue(),line.getShortCircuitCapacity().floatValue(),0,0); Overlimit overlimit = COverlimitUtil.globalAssemble(line.getVolGrade().floatValue(), line.getProtocolCapacity().floatValue(),line.getDevCapacity().floatValue(),line.getShortCircuitCapacity().floatValue(),0,0);
overlimit.setId(po.getLineId()); overlimit.setId(po.getLineId());
overlimitMapper.insert(overlimit); overLimitWlMapper.insert(overlimit);
} }
//新增台账日志 //新增台账日志

View File

@@ -1,11 +1,12 @@
package com.njcn.csdevice.service.impl; package com.njcn.csdevice.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.csdevice.mapper.OverlimitMapper;
import com.njcn.csdevice.pojo.po.Overlimit;
import com.njcn.csdevice.pojo.vo.LineOverLimitVO; import com.njcn.csdevice.pojo.vo.LineOverLimitVO;
import com.njcn.csdevice.service.IOverLimitService; import com.njcn.csdevice.service.IOverLimitService;
import com.njcn.device.biz.mapper.OverLimitWlMapper;
import com.njcn.device.biz.pojo.po.Overlimit;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -15,9 +16,10 @@ import org.springframework.stereotype.Service;
* @author cdf * @author cdf
* @date 2023/6/7 * @date 2023/6/7
*/ */
@DS("sjzx")
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class OverLimitServiceImpl extends ServiceImpl<OverlimitMapper, Overlimit> implements IOverLimitService { public class OverLimitServiceImpl extends ServiceImpl<OverLimitWlMapper, Overlimit> implements IOverLimitService {
@Override @Override

View File

@@ -24,7 +24,6 @@ import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
import com.njcn.csdevice.pojo.param.WlRecordParam; import com.njcn.csdevice.pojo.param.WlRecordParam;
import com.njcn.csdevice.pojo.po.CsDataSet; import com.njcn.csdevice.pojo.po.CsDataSet;
import com.njcn.csdevice.pojo.po.CsLinePO; import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csdevice.pojo.po.Overlimit;
import com.njcn.csdevice.pojo.po.WlRecord; import com.njcn.csdevice.pojo.po.WlRecord;
import com.njcn.csdevice.pojo.vo.RecordAllDevTreeVo; import com.njcn.csdevice.pojo.vo.RecordAllDevTreeVo;
import com.njcn.csdevice.pojo.vo.RecordTreeVo; import com.njcn.csdevice.pojo.vo.RecordTreeVo;
@@ -32,10 +31,11 @@ import com.njcn.csdevice.pojo.vo.RecordVo;
import com.njcn.csdevice.service.IOverLimitService; import com.njcn.csdevice.service.IOverLimitService;
import com.njcn.csdevice.service.IWlRecordService; import com.njcn.csdevice.service.IWlRecordService;
import com.njcn.csdevice.util.InfluxDbParamUtil; import com.njcn.csdevice.util.InfluxDbParamUtil;
import com.njcn.csdevice.utils.COverlimitUtil;
import com.njcn.csdevice.utils.StringUtil; import com.njcn.csdevice.utils.StringUtil;
import com.njcn.csharmonic.param.CommonStatisticalQueryParam; import com.njcn.csharmonic.param.CommonStatisticalQueryParam;
import com.njcn.csharmonic.pojo.vo.ThdDataVO; import com.njcn.csharmonic.pojo.vo.ThdDataVO;
import com.njcn.device.biz.pojo.po.Overlimit;
import com.njcn.device.biz.utils.COverlimitUtil;
import com.njcn.influx.imapper.CommonMapper; import com.njcn.influx.imapper.CommonMapper;
import com.njcn.influx.pojo.bo.CommonQueryParam; import com.njcn.influx.pojo.bo.CommonQueryParam;
import com.njcn.influx.pojo.constant.InfluxDBTableConstant; import com.njcn.influx.pojo.constant.InfluxDBTableConstant;

View File

@@ -0,0 +1,20 @@
package com.njcn.csharmonic.param;
import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
* @author xy
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class CldWarnParam extends BaseParam implements Serializable {
@ApiModelProperty("告警等级")
private String level;
}

View File

@@ -12,7 +12,6 @@ import java.util.List;
public class SensitiveUserTrendDataQueryParam { public class SensitiveUserTrendDataQueryParam {
@ApiModelProperty(value = "检测对象ID") @ApiModelProperty(value = "检测对象ID")
@NotBlank(message = "检测对象ID不可为空")
private String sensitiveUserId; private String sensitiveUserId;
@ApiModelProperty(name = "searchBeginTime", value = "开始时间") @ApiModelProperty(name = "searchBeginTime", value = "开始时间")
@@ -37,4 +36,8 @@ public class SensitiveUserTrendDataQueryParam {
@ApiModelProperty(value = "频次2-50") @ApiModelProperty(value = "频次2-50")
private String frequency; private String frequency;
//采用这个频次,上面那个频次用于多指标筛选
@ApiModelProperty(value = "频次2-50")
private Integer harmonicCount;
} }

View File

@@ -56,4 +56,6 @@ public class ReportTemplateDTO {
*/ */
private String value; private String value;
private String lowValue;
} }

View File

@@ -1,42 +1,42 @@
package com.njcn.csharmonic.pojo.param; //package com.njcn.csharmonic.pojo.param;
//
import io.swagger.annotations.ApiModelProperty; //import io.swagger.annotations.ApiModelProperty;
import lombok.Data; //import lombok.Data;
//
/** ///**
* 模板动态更新数据 // * 模板动态更新数据
* // *
* @author qijian // * @author qijian
* @date 2022/10/11 // * @date 2022/10/11
*/ // */
@Data //@Data
public class ReportSearchParam { //public class ReportSearchParam {
//
@ApiModelProperty(name = "lineId",value = "监测点id") // @ApiModelProperty(name = "lineId",value = "监测点id")
private String lineId; // private String lineId;
//
@ApiModelProperty(name = "tempId",value = "模板ID") // @ApiModelProperty(name = "tempId",value = "模板ID")
private String tempId; // private String tempId;
//
@ApiModelProperty(name = "activation",value = "激活状态") // @ApiModelProperty(name = "activation",value = "激活状态")
private Integer activation; // private Integer activation;
//
@ApiModelProperty(name = "type",value = "报表类型") // @ApiModelProperty(name = "type",value = "报表类型")
private Integer type; // private Integer type;
//
@ApiModelProperty(name = "startTime",value = "开始时间") // @ApiModelProperty(name = "startTime",value = "开始时间")
private String startTime; // private String startTime;
//
@ApiModelProperty(name = "endTime",value = "结束时间") // @ApiModelProperty(name = "endTime",value = "结束时间")
private String endTime; // private String endTime;
//
@ApiModelProperty(name = "deptId",value = "部门ID") // @ApiModelProperty(name = "deptId",value = "部门ID")
private String deptId; // private String deptId;
//
//目前用于区分不同系统资源null默认 1.无线系统配合cs-device // //目前用于区分不同系统资源null默认 1.无线系统配合cs-device
private Integer resourceType; // private Integer resourceType;
//
//浙江无线报表特殊标识 null为通用报表 1.浙江无线报表 // //浙江无线报表特殊标识 null为通用报表 1.浙江无线报表
private Integer customType; // private Integer customType;
//
} //}

View File

@@ -45,6 +45,12 @@ public class ReportTemplateParam {
@ApiModelProperty(name = "reportForm",value = "报表类型",required = true) @ApiModelProperty(name = "reportForm",value = "报表类型",required = true)
private String reportForm; private String reportForm;
@ApiModelProperty(name = "wiringMethod",value = "接线方式",required = true)
private String wiringMethod;
@ApiModelProperty(name = "sort",value = "排序",required = true)
private Integer sort;
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)

View File

@@ -1,75 +1,75 @@
package com.njcn.csharmonic.pojo.param.eventReport; //package com.njcn.csharmonic.pojo.param.eventReport;
//
import io.swagger.annotations.ApiModelProperty; //import io.swagger.annotations.ApiModelProperty;
import lombok.Data; //import lombok.Data;
//
import java.io.Serializable; //import java.io.Serializable;
//
/** ///**
* @author xxy // * @author xxy
* @version 1.0.0 // * @version 1.0.0
* @date 2022年08月16日 19:37 // * @date 2022年08月16日 19:37
*/ // */
@Data //@Data
public class ExportParam implements Serializable { //public class ExportParam implements Serializable {
//
@ApiModelProperty(name = "lineId",value = "监测点ID") // @ApiModelProperty(name = "lineId",value = "监测点ID")
private String lineId; // private String lineId;
//
@ApiModelProperty(name = "searchBeginTime",value = "开始时间") // @ApiModelProperty(name = "searchBeginTime",value = "开始时间")
private String searchBeginTime; // private String searchBeginTime;
//
@ApiModelProperty(name = "searchEndTime",value = "结束时间") // @ApiModelProperty(name = "searchEndTime",value = "结束时间")
private String searchEndTime; // private String searchEndTime;
//
@ApiModelProperty(name = "lineName",value = "监测点名称") // @ApiModelProperty(name = "lineName",value = "监测点名称")
private String lineName; // private String lineName;
//
@ApiModelProperty(name = "xq",value = "监测点详情",example = "true") // @ApiModelProperty(name = "xq",value = "监测点详情",example = "true")
private boolean xq; // private boolean xq;
//
@ApiModelProperty(name = "lb",value = "暂降事件列表",example = "true") // @ApiModelProperty(name = "lb",value = "暂降事件列表",example = "true")
private boolean lb; // private boolean lb;
//
@ApiModelProperty(name = "mdbg",value = "暂降密度表格",example = "false") // @ApiModelProperty(name = "mdbg",value = "暂降密度表格",example = "false")
private boolean mdbg; // private boolean mdbg;
//
@ApiModelProperty(name = "mdtx",value = "暂降密度图形",example = "false") // @ApiModelProperty(name = "mdtx",value = "暂降密度图形",example = "false")
private boolean mdtx; // private boolean mdtx;
//
@ApiModelProperty(name = "sjdITIC",value = "暂降时间点ITIC",example = "false") // @ApiModelProperty(name = "sjdITIC",value = "暂降时间点ITIC",example = "false")
private boolean sjdITIC; // private boolean sjdITIC;
//
@ApiModelProperty(name = "sjdF47",value = "暂降时间点F47",example = "false") // @ApiModelProperty(name = "sjdF47",value = "暂降时间点F47",example = "false")
private boolean sjdF47; // private boolean sjdF47;
//
@ApiModelProperty(name = "glfbfz",value = "概率分布暂降赋值",example = "false") // @ApiModelProperty(name = "glfbfz",value = "概率分布暂降赋值",example = "false")
private boolean glfbfz; // private boolean glfbfz;
//
@ApiModelProperty(name = "glfbsj",value = "概率分布持续时间",example = "false") // @ApiModelProperty(name = "glfbsj",value = "概率分布持续时间",example = "false")
private boolean glfbsj; // private boolean glfbsj;
//
@ApiModelProperty(name = "tjbg",value = "月份统计表格",example = "false") // @ApiModelProperty(name = "tjbg",value = "月份统计表格",example = "false")
private boolean tjbg; // private boolean tjbg;
//
@ApiModelProperty(name = "tjtx",value = "月份统计图形",example = "false") // @ApiModelProperty(name = "tjtx",value = "月份统计图形",example = "false")
private boolean tjtx; // private boolean tjtx;
//
@ApiModelProperty(name = "yybg",value = "暂降原因表格",example = "false") // @ApiModelProperty(name = "yybg",value = "暂降原因表格",example = "false")
private boolean yybg; // private boolean yybg;
//
@ApiModelProperty(name = "yytx",value = "暂降原因图形",example = "false") // @ApiModelProperty(name = "yytx",value = "暂降原因图形",example = "false")
private boolean yytx; // private boolean yytx;
//
@ApiModelProperty(name = "lxbg",value = "暂降类型表格",example = "false") // @ApiModelProperty(name = "lxbg",value = "暂降类型表格",example = "false")
private boolean lxbg; // private boolean lxbg;
//
@ApiModelProperty(name = "lxtx",value = "暂降类型图形",example = "false") // @ApiModelProperty(name = "lxtx",value = "暂降类型图形",example = "false")
private boolean lxtx; // private boolean lxtx;
//
@ApiModelProperty(name = "flag",value = "标识") // @ApiModelProperty(name = "flag",value = "标识")
private Integer flag; // private Integer flag;
//
@ApiModelProperty(name = "type",value = "系统区分(0:pq 1:pms)") // @ApiModelProperty(name = "type",value = "系统区分(0:pq 1:pms)")
private Integer type; // private Integer type;
} //}

View File

@@ -1,37 +1,37 @@
package com.njcn.csharmonic.pojo.po; //package com.njcn.csharmonic.pojo.po;
//
import com.baomidou.mybatisplus.annotation.TableName; //import com.baomidou.mybatisplus.annotation.TableName;
import com.njcn.db.bo.BaseEntity; //import com.njcn.db.bo.BaseEntity;
import lombok.Data; //import lombok.Data;
import lombok.EqualsAndHashCode; //import lombok.EqualsAndHashCode;
//
//
/** ///**
* pqs // * pqs
* 自定义报表 // * 自定义报表
* @author cdf // * @author cdf
* @date 2022/8/16 // * @date 2022/8/16
*/ // */
@Data //@Data
@EqualsAndHashCode(callSuper = true) //@EqualsAndHashCode(callSuper = true)
@TableName(value = "sys_excel_rpt_temp") //@TableName(value = "sys_excel_rpt_temp")
public class ExcelRptTemp extends BaseEntity { //public class ExcelRptTemp extends BaseEntity {
private String id; // private String id;
//
private String name; // private String name;
//
private String content; // private String content;
//
private Integer activation; // private Integer activation;
//
private Integer state; // private Integer state;
//
private String valueTitle; // private String valueTitle;
//
private String reportType; // private String reportType;
//
private String reportForm; // private String reportForm;
//
private Integer sort; // private Integer sort;
//
} //}

View File

@@ -0,0 +1,127 @@
//package com.njcn.csharmonic.pojo.po;
//
//import com.baomidou.mybatisplus.annotation.IdType;
//import com.baomidou.mybatisplus.annotation.TableField;
//import com.baomidou.mybatisplus.annotation.TableId;
//import com.baomidou.mybatisplus.annotation.TableName;
//import com.fasterxml.jackson.annotation.JsonFormat;
//import io.swagger.annotations.ApiModel;
//import io.swagger.annotations.ApiModelProperty;
//import lombok.Data;
//
//import java.io.Serializable;
//import java.time.LocalDateTime;
//
///**
// * 暂降明细实体类
// *
// * @author yzh
// * @since 2022-10-12 18:34:55
// */
//@Data
//@TableName("r_mp_event_detail")
//@ApiModel(value="RmpEventDetail对象")
//public class RmpEventDetailPO implements Serializable {
// private static final long serialVersionUID = 1L;
//
// @ApiModelProperty(value = "暂时事件ID")
// @TableId(value = "event_id", type = IdType.ASSIGN_ID)
// private String eventId;
//
// @ApiModelProperty(value = "监测点ID")
// private String measurementPointId;
//
// @ApiModelProperty(value = "监测点ID(复制)")
// @TableField("measurement_point_id")
// private String lineId;
//
// @ApiModelProperty(value = "统计类型")
// private String eventType;
//
// @ApiModelProperty(value = "暂降原因Event_Reason")
// @TableField("advance_reason")
// private String advanceReason;
//
// @ApiModelProperty(value = "暂降类型Event_Type")
// @TableField("advance_type")
// private String advanceType;
//
// @ApiModelProperty(value = "事件关联分析表Guid")
// private String eventassIndex;
//
// @ApiModelProperty(value = "dq计算持续时间 ")
// private Double dqTime;
//
// @ApiModelProperty(value = "特征值计算更新时间外键PQS_Relevance的Time字段")
// private LocalDateTime dealTime;
//
// @ApiModelProperty(value = "默认事件个数为0")
// private Integer num;
//
// @ApiModelProperty(value = "波形文件是否从装置招到本地(0未招1已招)默认值为0")
// private Integer fileFlag;
//
// @ApiModelProperty(value = "特征值计算标志0未处理1已处理; 2已处理无结果;3计算失败默认值为0")
// private Integer dealFlag;
//
// @ApiModelProperty(value = "处理结果第一条事件发生时间(读comtra文件获取)")
// private LocalDateTime firstTime;
//
// @ApiModelProperty(value = "处理结果第一条事件暂降类型字典表PQS_Dicdata")
// private String firstType;
//
// @ApiModelProperty(value = "处理结果第一条事件发生时间毫秒(读comtra文件获取)")
// private Double firstMs;
//
// @ApiModelProperty(value = "暂降能量")
// private Double energy;
//
// @ApiModelProperty(value = "暂降严重度")
// private Double severity;
//
// @ApiModelProperty(value = "暂降源与监测位置关系 Upper:上游Lower :下游Unknown :未知;为空则是未计算")
// private String sagsource;
//
// @ApiModelProperty(value = "开始时间")
// @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
// private LocalDateTime startTime;
//
// @ApiModelProperty(value = "格式化开始时间")
// @TableField(exist = false)
// private String formatTime;
//
//
// @ApiModelProperty(value = "持续时间,单位秒")
// private Double duration;
//
// @ApiModelProperty(value = "特征幅值")
// private Double featureAmplitude;
//
// @ApiModelProperty(value = "相别")
// private String phase;
//
// @ApiModelProperty(value = "事件描述")
// private String eventDescribe;
//
// @ApiModelProperty(value = "波形路径")
// private String wavePath;
//
// @ApiModelProperty(value = "暂降核实原因")
// @TableField("verify_reason")
// private String verifyReason;
//
// @ApiModelProperty(value = "暂降核实原因详情")
// @TableField("verify_reason_detail")
// private String verifyReasonDetail;
//
// private Double transientValue;
//
// @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
// private LocalDateTime createTime;
//
// @ApiModelProperty(value = "用于计算数量")
// @TableField(exist = false)
// private Integer count;
//
//}
//

View File

@@ -1,34 +1,34 @@
package com.njcn.csharmonic.pojo.vo; //package com.njcn.csharmonic.pojo.vo;
//
import com.njcn.db.bo.BaseEntity; //import com.njcn.db.bo.BaseEntity;
import lombok.Data; //import lombok.Data;
import lombok.EqualsAndHashCode; //import lombok.EqualsAndHashCode;
//
/** ///**
* pqs // * pqs
* 自定义报表 // * 自定义报表
* @author cdf // * @author cdf
* @date 2022/8/16 // * @date 2022/8/16
*/ // */
@Data //@Data
@EqualsAndHashCode(callSuper = true) //@EqualsAndHashCode(callSuper = true)
public class ReportTemplateVO extends BaseEntity { //public class ReportTemplateVO extends BaseEntity {
private String id; // private String id;
//
private String name; // private String name;
//
private String content; // private String content;
//
private String deptId; // private String deptId;
//
private Integer activation; // private Integer activation;
//
private Integer state; // private Integer state;
//
private String deptName; // private String deptName;
//
private String reportType; // private String reportType;
//
private String reportForm; // private String reportForm;
//
} //}

View File

@@ -22,8 +22,10 @@ public class TotalLimitStatisticsDetailsVO {
private Integer allTime; private Integer allTime;
@ApiModelProperty(value = "闪变越限次数") @ApiModelProperty(value = "闪变越限次数")
private Integer flickerOvertime; private Integer flickerAllTime;
@ApiModelProperty(value = "闪变越限")
private double flickerOvertime;
@ApiModelProperty(value = "频率偏差越限") @ApiModelProperty(value = "频率偏差越限")
private double freqDevOvertime; private double freqDevOvertime;

View File

@@ -1,142 +1,142 @@
package com.njcn.csharmonic.utils.report; //package com.njcn.csharmonic.utils.report;
//
/** ///**
* @author hongawen // * @author hongawen
* @date: 2020/8/20 13:36 // * @date: 2020/8/20 13:36
*/ // */
public class ClearPathUtil { //public class ClearPathUtil {
//
/** // /**
* 针对漏洞,新增的特殊字符替换的扫描方法 // * 针对漏洞,新增的特殊字符替换的扫描方法
*/ // */
public static String cleanString(String str) { // public static String cleanString(String str) {
if (str == null) { // if (str == null) {
return null; // return null;
} // }
StringBuilder sb = new StringBuilder(); // StringBuilder sb = new StringBuilder();
for (int i = 0; i < str.length(); ++i) { // for (int i = 0; i < str.length(); ++i) {
sb.append(cleanChar(str.charAt(i))); // sb.append(cleanChar(str.charAt(i)));
} // }
return sb.toString(); // return sb.toString();
} // }
//
private static char cleanChar(char ch) { // private static char cleanChar(char ch) {
//
// 0 - 9 // // 0 - 9
for (int i = 48; i < 58; ++i) { // for (int i = 48; i < 58; ++i) {
if (ch == i) { // if (ch == i) {
return (char) i; // return (char) i;
} // }
} // }
//
// 'A' - 'Z' // // 'A' - 'Z'
for (int i = 65; i < 91; ++i) { // for (int i = 65; i < 91; ++i) {
if (ch == i) { // if (ch == i) {
return (char) i; // return (char) i;
} // }
} // }
//
// 'a' - 'z' // // 'a' - 'z'
for (int i = 97; i < 123; ++i) { // for (int i = 97; i < 123; ++i) {
if (ch == i) { // if (ch == i) {
return (char) i; // return (char) i;
} // }
} // }
//
// other valid characters // // other valid characters
switch (ch) { // switch (ch) {
case '/': // case '/':
return '/'; // return '/';
case '.': // case '.':
return '.'; // return '.';
case '-': // case '-':
return '-'; // return '-';
case '_': // case '_':
return '_'; // return '_';
case ',': // case ',':
return ','; // return ',';
case ' ': // case ' ':
return ' '; // return ' ';
case '!': // case '!':
return '!'; // return '!';
case '@': // case '@':
return '@'; // return '@';
case '#': // case '#':
return '#'; // return '#';
case '$': // case '$':
return '$'; // return '$';
case '%': // case '%':
return '%'; // return '%';
case '^': // case '^':
return '^'; // return '^';
case '&': // case '&':
return '&'; // return '&';
case '*': // case '*':
return '*'; // return '*';
case '(': // case '(':
return '('; // return '(';
case ')': // case ')':
return ')'; // return ')';
case '+': // case '+':
return '+'; // return '+';
case '=': // case '=':
return '='; // return '=';
case ':': // case ':':
return ':'; // return ':';
case ';': // case ';':
return ';'; // return ';';
case '?': // case '?':
return '?'; // return '?';
case '"': // case '"':
return '"'; // return '"';
case '<': // case '<':
return '<'; // return '<';
case '>': // case '>':
return '>'; // return '>';
case '`': // case '`':
return '`'; // return '`';
case '\\': // case '\\':
return '/'; // return '/';
case 'I': // case 'I':
return 'I'; // return 'I';
case 'Ⅱ': // case 'Ⅱ':
return 'Ⅱ'; // return 'Ⅱ';
case 'Ⅲ': // case 'Ⅲ':
return 'Ⅲ'; // return 'Ⅲ';
case 'Ⅳ': // case 'Ⅳ':
return 'Ⅳ'; // return 'Ⅳ';
case '': // case '':
return ''; // return '';
case 'Ⅵ': // case 'Ⅵ':
return 'Ⅵ'; // return 'Ⅵ';
case 'Ⅶ': // case 'Ⅶ':
return 'Ⅶ'; // return 'Ⅶ';
case 'Ⅷ': // case 'Ⅷ':
return 'Ⅷ'; // return 'Ⅷ';
case 'Ⅸ': // case 'Ⅸ':
return 'Ⅸ'; // return 'Ⅸ';
//
case 'V': // case 'V':
return 'V'; // return 'V';
case 'X': // case 'X':
return 'X'; // return 'X';
case '': // case '':
return ''; // return '';
default: // default:
if (isChineseChar(ch)) { // if (isChineseChar(ch)) {
return ch; // return ch;
} // }
return '%'; // return '%';
} // }
} // }
//
// 根据Unicode编码判断中文汉字和符号 // // 根据Unicode编码判断中文汉字和符号
private static boolean isChineseChar(char c) { // private static boolean isChineseChar(char c) {
Character.UnicodeBlock ub = Character.UnicodeBlock.of(c); // Character.UnicodeBlock ub = Character.UnicodeBlock.of(c);
return ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS || ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS // return ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS || ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS
|| ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B // || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B
|| ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION || ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS // || ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION || ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS
|| ub == Character.UnicodeBlock.GENERAL_PUNCTUATION; // || ub == Character.UnicodeBlock.GENERAL_PUNCTUATION;
} // }
//
} //}

View File

@@ -1,83 +1,83 @@
package com.njcn.csharmonic.utils.report; //package com.njcn.csharmonic.utils.report;
//
import lombok.extern.slf4j.Slf4j; //import lombok.extern.slf4j.Slf4j;
import org.apache.poi.openxml4j.opc.OPCPackage; //import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.xwpf.usermodel.XWPFDocument; //import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph; //import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.apache.xmlbeans.XmlException; //import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlToken; //import org.apache.xmlbeans.XmlToken;
import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps; //import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps;
import org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D; //import org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D;
import org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.CTInline; //import org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.CTInline;
//
import java.io.IOException; //import java.io.IOException;
import java.io.InputStream; //import java.io.InputStream;
//
@Slf4j //@Slf4j
public class CustomXWPFDocument extends XWPFDocument { //public class CustomXWPFDocument extends XWPFDocument {
// 日志记录 // // 日志记录
public CustomXWPFDocument(InputStream in) throws IOException { // public CustomXWPFDocument(InputStream in) throws IOException {
super(in); // super(in);
} // }
//
public CustomXWPFDocument() { // public CustomXWPFDocument() {
super(); // super();
} // }
//
public CustomXWPFDocument(OPCPackage pkg) throws IOException { // public CustomXWPFDocument(OPCPackage pkg) throws IOException {
super(pkg); // super(pkg);
} // }
//
/** // /**
* @param id // * @param id
* @param width // * @param width
* 宽 // * 宽
* @param height // * @param height
* 高 // * 高
* @param paragraph // * @param paragraph
* 段落 // * 段落
*/ // */
public void createPicture(int id, int width, int height,String blipId, XWPFParagraph paragraph) { // public void createPicture(int id, int width, int height,String blipId, XWPFParagraph paragraph) {
final int EMU = 9525; // final int EMU = 9525;
width *= EMU; // width *= EMU;
height *= EMU; // height *= EMU;
// String blipId = getAllPictures().get(id).getPackageRelationship().getId(); //// String blipId = getAllPictures().get(id).getPackageRelationship().getId();
CTInline inline = paragraph.createRun().getCTR().addNewDrawing().addNewInline(); // CTInline inline = paragraph.createRun().getCTR().addNewDrawing().addNewInline();
String picXml = "" + "<a:graphic xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\">" // String picXml = "" + "<a:graphic xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\">"
+ " <a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/picture\">" // + " <a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/picture\">"
+ " <pic:pic xmlns:pic=\"http://schemas.openxmlformats.org/drawingml/2006/picture\">" // + " <pic:pic xmlns:pic=\"http://schemas.openxmlformats.org/drawingml/2006/picture\">"
+ " <pic:nvPicPr>" + " <pic:cNvPr id=\"" + id + "\" name=\"Generated\"/>" // + " <pic:nvPicPr>" + " <pic:cNvPr id=\"" + id + "\" name=\"Generated\"/>"
+ " <pic:cNvPicPr/>" + " </pic:nvPicPr>" + " <pic:blipFill>" // + " <pic:cNvPicPr/>" + " </pic:nvPicPr>" + " <pic:blipFill>"
+ " <a:blip r:embed=\"" + blipId // + " <a:blip r:embed=\"" + blipId
+ "\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"/>" // + "\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"/>"
+ " <a:stretch>" + " <a:fillRect/>" + " </a:stretch>" // + " <a:stretch>" + " <a:fillRect/>" + " </a:stretch>"
+ " </pic:blipFill>" + " <pic:spPr>" + " <a:xfrm>" // + " </pic:blipFill>" + " <pic:spPr>" + " <a:xfrm>"
+ " <a:off x=\"0\" y=\"0\"/>" + " <a:ext cx=\"" + width + "\" cy=\"" // + " <a:off x=\"0\" y=\"0\"/>" + " <a:ext cx=\"" + width + "\" cy=\""
+ height + "\"/>" + " </a:xfrm>" + " <a:prstGeom prst=\"rect\">" // + height + "\"/>" + " </a:xfrm>" + " <a:prstGeom prst=\"rect\">"
+ " <a:avLst/>" + " </a:prstGeom>" + " </pic:spPr>" // + " <a:avLst/>" + " </a:prstGeom>" + " </pic:spPr>"
+ " </pic:pic>" + " </a:graphicData>" + "</a:graphic>"; // + " </pic:pic>" + " </a:graphicData>" + "</a:graphic>";
//
inline.addNewGraphic().addNewGraphicData(); // inline.addNewGraphic().addNewGraphicData();
XmlToken xmlToken = null; // XmlToken xmlToken = null;
try { // try {
xmlToken = XmlToken.Factory.parse(picXml); // xmlToken = XmlToken.Factory.parse(picXml);
} catch (XmlException xe) { // } catch (XmlException xe) {
log.error("生成报表发生异常,异常是"+xe.getMessage()); // log.error("生成报表发生异常,异常是"+xe.getMessage());
} // }
inline.set(xmlToken); // inline.set(xmlToken);
//
inline.setDistT(0); // inline.setDistT(0);
inline.setDistB(0); // inline.setDistB(0);
inline.setDistL(0); // inline.setDistL(0);
inline.setDistR(0); // inline.setDistR(0);
//
CTPositiveSize2D extent = inline.addNewExtent(); // CTPositiveSize2D extent = inline.addNewExtent();
extent.setCx(width); // extent.setCx(width);
extent.setCy(height); // extent.setCy(height);
//
CTNonVisualDrawingProps docPr = inline.addNewDocPr(); // CTNonVisualDrawingProps docPr = inline.addNewDocPr();
docPr.setId(id); // docPr.setId(id);
docPr.setName("图片" + id); // docPr.setName("图片" + id);
docPr.setDescr("测试"); // docPr.setDescr("测试");
} // }
} //}

View File

@@ -1,28 +1,28 @@
package com.njcn.csharmonic.utils.report; //package com.njcn.csharmonic.utils.report;
//
import java.math.BigDecimal; //import java.math.BigDecimal;
//
/** ///**
* @author hongawen(创建) -----denghuajun移植使用 // * @author hongawen(创建) -----denghuajun移植使用
* @Date: 2018/8/27 11:29 // * @Date: 2018/8/27 11:29
*/ // */
public class FloatUtils { //public class FloatUtils {
//
//
/** // /**
* 保留传入进来的float的两位小数四舍五入的方式 // * 保留传入进来的float的两位小数四舍五入的方式
* // *
* @param data Float参数 // * @param data Float参数
*/ // */
public static float get2Float(Float data) { // public static float get2Float(Float data) {
if (data == null || data.isNaN() || data.isInfinite()) { // if (data == null || data.isNaN() || data.isInfinite()) {
return 0f; // return 0f;
} // }
int scale = 2;//设置位数 // int scale = 2;//设置位数
int roundingMode = 4;//表示四舍五入,可以选择其他舍值方式,例如去尾,等等. // int roundingMode = 4;//表示四舍五入,可以选择其他舍值方式,例如去尾,等等.
BigDecimal bd = new BigDecimal(data); // BigDecimal bd = new BigDecimal(data);
bd = bd.setScale(scale, roundingMode); // bd = bd.setScale(scale, roundingMode);
data = bd.floatValue(); // data = bd.floatValue();
return data; // return data;
} // }
} //}

View File

@@ -1,224 +1,224 @@
package com.njcn.csharmonic.utils.report; //package com.njcn.csharmonic.utils.report;
//
import cn.hutool.core.util.ObjectUtil; //import cn.hutool.core.util.ObjectUtil;
import lombok.SneakyThrows; //import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j; //import lombok.extern.slf4j.Slf4j;
//
import java.io.File; //import java.io.File;
import java.io.IOException; //import java.io.IOException;
import java.io.InputStream; //import java.io.InputStream;
import java.text.SimpleDateFormat; //import java.text.SimpleDateFormat;
import java.util.*; //import java.util.*;
//
/** ///**
* @author wr // * @author wr
* @description // * @description
* @date 2023/4/10 17:39 // * @date 2023/4/10 17:39
*/ // */
@Slf4j //@Slf4j
public class PubUtils { //public class PubUtils {
public static boolean createFile(String destFileName) { // public static boolean createFile(String destFileName) {
File file = new File(destFileName); // File file = new File(destFileName);
if (file.exists()) { // if (file.exists()) {
log.warn("创建单个文件" + destFileName + "失败,目标文件已存在!"); // log.warn("创建单个文件" + destFileName + "失败,目标文件已存在!");
return false; // return false;
} // }
if (destFileName.endsWith(File.separator)) { // if (destFileName.endsWith(File.separator)) {
log.warn("创建单个文件" + destFileName + "失败,目标文件不能为目录!"); // log.warn("创建单个文件" + destFileName + "失败,目标文件不能为目录!");
return false; // return false;
} // }
//判断目标文件所在的目录是否存在 // //判断目标文件所在的目录是否存在
if (!file.getParentFile().exists()) { // if (!file.getParentFile().exists()) {
//如果目标文件所在的目录不存在,则创建父目录 // //如果目标文件所在的目录不存在,则创建父目录
log.warn("目标文件所在目录不存在,准备创建它!"); // log.warn("目标文件所在目录不存在,准备创建它!");
if (!file.getParentFile().mkdirs()) { // if (!file.getParentFile().mkdirs()) {
log.warn("创建目标文件所在目录失败!"); // log.warn("创建目标文件所在目录失败!");
return false; // return false;
} // }
} // }
//创建目标文件 // //创建目标文件
try { // try {
if (file.createNewFile()) { // if (file.createNewFile()) {
log.warn("创建单个文件" + destFileName + "成功!"); // log.warn("创建单个文件" + destFileName + "成功!");
return true; // return true;
} else { // } else {
log.warn("创建单个文件" + destFileName + "失败!"); // log.warn("创建单个文件" + destFileName + "失败!");
return false; // return false;
} // }
} catch (IOException e) { // } catch (IOException e) {
log.warn("创建单个文件" + destFileName + "失败!" + e.getMessage()); // log.warn("创建单个文件" + destFileName + "失败!" + e.getMessage());
return false; // return false;
} // }
} // }
//
/** // /**
* 读取配置文件 // * 读取配置文件
* // *
* @param cl 类名字 // * @param cl 类名字
* @param strPropertiesName 配置文件名称 // * @param strPropertiesName 配置文件名称
*/ // */
public static Properties readProperties(ClassLoader cl, String strPropertiesName) { // public static Properties readProperties(ClassLoader cl, String strPropertiesName) {
Properties pros = new Properties(); // Properties pros = new Properties();
InputStream in = null; // InputStream in = null;
try { // try {
in = cl.getResourceAsStream(strPropertiesName); // in = cl.getResourceAsStream(strPropertiesName);
pros.load(in); // pros.load(in);
} catch (Exception e) { // } catch (Exception e) {
log.error("读取配置文件失败失败:" + e.getMessage()); // log.error("读取配置文件失败失败:" + e.getMessage());
} finally { // } finally {
if (in != null) { // if (in != null) {
PubUtils.safeClose(in, "安全关闭读取配置文件失败,异常为:"); // PubUtils.safeClose(in, "安全关闭读取配置文件失败,异常为:");
} // }
} // }
return pros; // return pros;
} // }
//
/** // /**
* 安全关闭InputStream // * 安全关闭InputStream
* // *
* @param s // * @param s
*/ // */
public static void safeClose(InputStream s, String strError) { // public static void safeClose(InputStream s, String strError) {
if (s != null) { // if (s != null) {
try { // try {
s.close(); // s.close();
} catch (IOException e) { // } catch (IOException e) {
log.error(strError + e.toString()); // log.error(strError + e.toString());
} // }
} // }
} // }
//
public static Double dataLimits(Double data) { // public static Double dataLimits(Double data) {
if (ObjectUtil.isNotNull(data)) { // if (ObjectUtil.isNotNull(data)) {
return data > 100 ? 100 : data; // return data > 100 ? 100 : data;
} // }
return data; // return data;
} // }
//
@SneakyThrows // @SneakyThrows
public static List<String> getIntervalTime(String startTime, String endTime) { // public static List<String> getIntervalTime(String startTime, String endTime) {
List<String> times = new ArrayList<>(); // List<String> times = new ArrayList<>();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM"); // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
Date start = sdf.parse(startTime); // Date start = sdf.parse(startTime);
Date end = sdf.parse(endTime); // Date end = sdf.parse(endTime);
// 同月 // // 同月
if (start.getTime() == end.getTime()) { // if (start.getTime() == end.getTime()) {
String time = startTime.substring(0, 7); // String time = startTime.substring(0, 7);
times.add(time); // times.add(time);
} else if (start.getYear() == end.getYear()) { // } else if (start.getYear() == end.getYear()) {
// 同年 // // 同年
int startM = start.getMonth() + 1; // int startM = start.getMonth() + 1;
int endM = end.getMonth() + 1; // int endM = end.getMonth() + 1;
int temp = endM - startM; // int temp = endM - startM;
for (int i = 0; i <= temp; i++) { // for (int i = 0; i <= temp; i++) {
String time = start.getYear() + 1900 + ""; // String time = start.getYear() + 1900 + "";
int month = startM + i; // int month = startM + i;
if (month < 10) { // if (month < 10) {
time = time + "-0" + month; // time = time + "-0" + month;
} else { // } else {
time = time + "-" + month; // time = time + "-" + month;
} // }
times.add(time); // times.add(time);
} // }
} else { // } else {
// 不同年!!!!这里忽略了年份之间跨年的情况 // // 不同年!!!!这里忽略了年份之间跨年的情况
int startY = start.getYear() + 1900; // int startY = start.getYear() + 1900;
int startM = start.getMonth() + 1; // int startM = start.getMonth() + 1;
int endY = end.getYear() + 1900; // int endY = end.getYear() + 1900;
int endM = end.getMonth() + 1; // int endM = end.getMonth() + 1;
int tempS = 12 - startM; // int tempS = 12 - startM;
// 连续的年份 // // 连续的年份
if (endY - startY == 1) { // if (endY - startY == 1) {
// 第一年的时间获取 // // 第一年的时间获取
for (int i = 0; i <= tempS; i++) { // for (int i = 0; i <= tempS; i++) {
int month = startM + i; // int month = startM + i;
String time = startY + "-"; // String time = startY + "-";
if (month < 10) { // if (month < 10) {
time = time + "0" + month; // time = time + "0" + month;
} else { // } else {
time = time + month; // time = time + month;
} // }
times.add(time); // times.add(time);
} // }
// 第二年的时间获取 // // 第二年的时间获取
//
for (int i = 1; i <= endM; i++) { // for (int i = 1; i <= endM; i++) {
String time = endY + "-"; // String time = endY + "-";
if (i < 10) { // if (i < 10) {
time = time + "0" + i; // time = time + "0" + i;
} else { // } else {
time = time + i; // time = time + i;
} // }
times.add(time); // times.add(time);
} // }
} else { // } else {
// 不连续的年份 // // 不连续的年份
// 第一年的时间获取 // // 第一年的时间获取
for (int i = 0; i <= tempS; i++) { // for (int i = 0; i <= tempS; i++) {
int month = startM + i; // int month = startM + i;
String time = startY + "-"; // String time = startY + "-";
if (month < 10) { // if (month < 10) {
time = time + "0" + month; // time = time + "0" + month;
} else { // } else {
time = time + month; // time = time + month;
} // }
times.add(time); // times.add(time);
} // }
int tempY = endY - startY; // int tempY = endY - startY;
// 中间年份的时间 // // 中间年份的时间
for (int i = 1; i < tempY; i++) { // for (int i = 1; i < tempY; i++) {
for (int j = 1; j <= 12; j++) { // for (int j = 1; j <= 12; j++) {
String time = startY + i + "-"; // String time = startY + i + "-";
if (j < 10) { // if (j < 10) {
time = time + "0" + j; // time = time + "0" + j;
} else { // } else {
time = time + j; // time = time + j;
} // }
times.add(time); // times.add(time);
} // }
} // }
// 最后一年的时间获取 // // 最后一年的时间获取
for (int i = 1; i <= endM; i++) { // for (int i = 1; i <= endM; i++) {
String time = endY + "-"; // String time = endY + "-";
if (i < 10) { // if (i < 10) {
time = time + "0" + i; // time = time + "0" + i;
} else { // } else {
time = time + i; // time = time + i;
} // }
times.add(time); // times.add(time);
} // }
} // }
//
} // }
return times; // return times;
} // }
//
@SneakyThrows // @SneakyThrows
public static List<String> getIntervalDateTime(Integer startTime, int beginDay, Integer endTime, Integer dd) { // public static List<String> getIntervalDateTime(Integer startTime, int beginDay, Integer endTime, Integer dd) {
List<String> list = new ArrayList<>(); // List<String> list = new ArrayList<>();
Calendar calendar = Calendar.getInstance(Locale.CHINA); // Calendar calendar = Calendar.getInstance(Locale.CHINA);
calendar.set(startTime, endTime - 1, 1); // calendar.set(startTime, endTime - 1, 1);
//年份 // //年份
int year = calendar.get(Calendar.YEAR); // int year = calendar.get(Calendar.YEAR);
//月份 // //月份
int month = calendar.get(Calendar.MONTH) + 1; // int month = calendar.get(Calendar.MONTH) + 1;
for (int i = beginDay; i <= dd; i++) { // for (int i = beginDay; i <= dd; i++) {
String date = null; // String date = null;
if (month < 10 && i < 10) { // if (month < 10 && i < 10) {
date = year + "-0" + month + "-0" + i; // date = year + "-0" + month + "-0" + i;
} // }
if (month < 10 && i >= 10) { // if (month < 10 && i >= 10) {
date = year + "-0" + month + "-" + i; // date = year + "-0" + month + "-" + i;
} // }
if (month >= 10 && i < 10) { // if (month >= 10 && i < 10) {
date = year + "-" + month + "-0" + i; // date = year + "-" + month + "-0" + i;
} // }
if (month >= 10 && i >= 10) { // if (month >= 10 && i >= 10) {
date = year + "-" + month + "-" + i; // date = year + "-" + month + "-" + i;
} // }
//
list.add(date); // list.add(date);
} // }
return list; // return list;
} // }
} //}

View File

@@ -1,30 +1,30 @@
package com.njcn.csharmonic.utils.report; //package com.njcn.csharmonic.utils.report;
//
/** ///**
* 数据公共工具类 // * 数据公共工具类
* // *
* @author qijian // * @author qijian
* @version 1.0.0 // * @version 1.0.0
* @createTime 2022/10/14 - 10:07 // * @createTime 2022/10/14 - 10:07
*/ // */
public class PublicDataUtils { //public class PublicDataUtils {
/** // /**
* 功能:下划线命名转驼峰命名 // * 功能:下划线命名转驼峰命名
* 将下划线替换为空格,将字符串根据空格分割成数组,再将每个单词首字母大写 // * 将下划线替换为空格,将字符串根据空格分割成数组,再将每个单词首字母大写
* @param s // * @param s
* @return // * @return
*/ // */
public static String underCamel(String s) // public static String underCamel(String s)
{ // {
String separator = "_"; // String separator = "_";
String under=""; // String under="";
s = s.toLowerCase().replace(separator, " "); // s = s.toLowerCase().replace(separator, " ");
String sarr[]=s.split(" "); // String sarr[]=s.split(" ");
for(int i=0;i<sarr.length;i++) // for(int i=0;i<sarr.length;i++)
{ // {
String w=sarr[i].substring(0,1).toUpperCase()+sarr[i].substring(1); // String w=sarr[i].substring(0,1).toUpperCase()+sarr[i].substring(1);
under +=w; // under +=w;
} // }
return under; // return under;
} // }
} //}

View File

@@ -1,25 +1,25 @@
package com.njcn.csharmonic.utils.report; //package com.njcn.csharmonic.utils.report;
//
import com.alibaba.fastjson.serializer.JSONSerializer; //import com.alibaba.fastjson.serializer.JSONSerializer;
import com.alibaba.fastjson.serializer.ObjectSerializer; //import com.alibaba.fastjson.serializer.ObjectSerializer;
import org.springframework.stereotype.Component; //import org.springframework.stereotype.Component;
//
import java.io.IOException; //import java.io.IOException;
import java.lang.reflect.Type; //import java.lang.reflect.Type;
import java.sql.Timestamp; //import java.sql.Timestamp;
//
@Component //@Component
public class TimestampAsLongSerializer implements ObjectSerializer { //public class TimestampAsLongSerializer implements ObjectSerializer {
//
@Override // @Override
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException { // public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
if (object instanceof Timestamp) { // if (object instanceof Timestamp) {
Timestamp timestamp = (Timestamp) object; // Timestamp timestamp = (Timestamp) object;
// 将Timestamp转换为时间戳毫秒数 // // 将Timestamp转换为时间戳毫秒数
long time = timestamp.getTime(); // long time = timestamp.getTime();
serializer.write(time); // serializer.write(time);
} else { // } else {
serializer.write(object); // serializer.write(object);
} // }
} // }
} //}

View File

@@ -1,427 +1,427 @@
package com.njcn.csharmonic.utils.report; //package com.njcn.csharmonic.utils.report;
//
import cn.hutool.core.collection.CollUtil; //import cn.hutool.core.collection.CollUtil;
import com.njcn.oss.constant.OssPath; //import com.njcn.oss.constant.OssPath;
import com.njcn.oss.utils.FileStorageUtil; //import com.njcn.oss.utils.FileStorageUtil;
import lombok.RequiredArgsConstructor; //import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; //import lombok.extern.slf4j.Slf4j;
import org.apache.poi.xwpf.usermodel.*; //import org.apache.poi.xwpf.usermodel.*;
import org.apache.tomcat.util.http.fileupload.IOUtils; //import org.apache.tomcat.util.http.fileupload.IOUtils;
import org.springframework.core.io.ClassPathResource; //import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource; //import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader; //import org.springframework.core.io.ResourceLoader;
import org.springframework.stereotype.Component; //import org.springframework.stereotype.Component;
import org.springframework.util.FileCopyUtils; //import org.springframework.util.FileCopyUtils;
//
import javax.servlet.ServletOutputStream; //import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse; //import javax.servlet.http.HttpServletResponse;
import java.io.*; //import java.io.*;
import java.util.*; //import java.util.*;
import java.util.Map.Entry; //import java.util.Map.Entry;
import java.util.regex.Matcher; //import java.util.regex.Matcher;
import java.util.regex.Pattern; //import java.util.regex.Pattern;
//
@Slf4j //@Slf4j
@Component //@Component
@RequiredArgsConstructor //@RequiredArgsConstructor
public class WordUtil2 { //public class WordUtil2 {
//
//
private final ResourceLoader resourceLoader; // private final ResourceLoader resourceLoader;
private final FileStorageUtil fileStorageUtil; // private final FileStorageUtil fileStorageUtil;
//
//
public void getWord(String path, Map<String, Object> params, String fileName,List<List<String[]>> tableList, HttpServletResponse response) // public void getWord(String path, Map<String, Object> params, String fileName,List<List<String[]>> tableList, HttpServletResponse response)
throws Exception { // throws Exception {
byte[] docBytes = null; // byte[] docBytes = null;
//
path = ClearPathUtil.cleanString(path); // path = ClearPathUtil.cleanString(path);
InputStream is = null; // InputStream is = null;
CustomXWPFDocument doc = null; // CustomXWPFDocument doc = null;
//读取报告模板 // //读取报告模板
try { // try {
Resource resource = resourceLoader.getResource("classpath:" + path); // Resource resource = resourceLoader.getResource("classpath:" + path);
if (!resource.exists()) { // if (!resource.exists()) {
throw new FileNotFoundException("模板文件未找到: " + path); // throw new FileNotFoundException("模板文件未找到: " + path);
} // }
is = resource.getInputStream(); // is = resource.getInputStream();
doc = new CustomXWPFDocument(is); // doc = new CustomXWPFDocument(is);
if(CollUtil.isNotEmpty(tableList)){ // if(CollUtil.isNotEmpty(tableList)){
this.replaceInTable(doc, params,tableList); // this.replaceInTable(doc, params,tableList);
}else{ // }else{
this.replaceInTable(doc, params); // this.replaceInTable(doc, params);
} // }
// 替换表格里面的变量 // // 替换表格里面的变量
this.replaceInPara(doc, params); // 替换文本里面的变量 // this.replaceInPara(doc, params); // 替换文本里面的变量
} catch (IOException e) { // } catch (IOException e) {
getError("获取报告模板异常,原因为:" + e); // getError("获取报告模板异常,原因为:" + e);
} finally { // } finally {
if (null != is) { // if (null != is) {
is.close(); // is.close();
} // }
} // }
try { // try {
ServletOutputStream outputStream = response.getOutputStream(); // ServletOutputStream outputStream = response.getOutputStream();
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\""); // response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
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) {
getError("输出稳态报告异常,原因为:" + e); // getError("输出稳态报告异常,原因为:" + e);
} finally { // } finally {
if (doc != null) { // if (doc != null) {
doc.close(); // doc.close();
} // }
} // }
} // }
//
//
//
//
// 辅助方法:字节数组转十六进制(便于打印排查) // // 辅助方法:字节数组转十六进制(便于打印排查)
private static String bytesToHex(byte[] bytes) { // private static String bytesToHex(byte[] bytes) {
StringBuilder sb = new StringBuilder(); // StringBuilder sb = new StringBuilder();
for (byte b : bytes) { // for (byte b : bytes) {
sb.append(String.format("%02X ", b)); // sb.append(String.format("%02X ", b));
} // }
return sb.toString().trim(); // return sb.toString().trim();
} // }
//
//
//
//
public InputStream getReportFile(String path, Map<String, Object> params, List<List<String[]>> tableList) // public InputStream getReportFile(String path, Map<String, Object> params, List<List<String[]>> tableList)
throws Exception { // throws Exception {
path = ClearPathUtil.cleanString(path); // path = ClearPathUtil.cleanString(path);
InputStream inStream = null,in = null; // InputStream inStream = null,in = null;
CustomXWPFDocument doc = null; // CustomXWPFDocument doc = null;
//读取报告模板 // //读取报告模板
try { // try {
inStream = new ClassPathResource(path).getInputStream(); // inStream = new ClassPathResource(path).getInputStream();
doc = new CustomXWPFDocument(inStream); // doc = new CustomXWPFDocument(inStream);
this.replaceInTable(doc,params,tableList); // this.replaceInTable(doc,params,tableList);
this.replaceInPara(doc, params); // this.replaceInPara(doc, params);
} catch (IOException e) { // } catch (IOException e) {
getError("获取报告模板异常,原因为:" + e); // getError("获取报告模板异常,原因为:" + e);
} finally { // } finally {
if (null != inStream) { // if (null != inStream) {
inStream.close(); // inStream.close();
} // }
} // }
try { // try {
//临时缓冲区 // //临时缓冲区
ByteArrayOutputStream out = new ByteArrayOutputStream(); // ByteArrayOutputStream out = new ByteArrayOutputStream();
doc.write(out); // doc.write(out);
byte[] docByteAry = out.toByteArray(); // byte[] docByteAry = out.toByteArray();
in = new ByteArrayInputStream(docByteAry); // in = new ByteArrayInputStream(docByteAry);
out.close(); // out.close();
} catch (Exception e) { // } catch (Exception e) {
getError("输出稳态报告异常,原因为:" + e); // getError("输出稳态报告异常,原因为:" + e);
} finally { // } finally {
if (doc != null) { // if (doc != null) {
doc.close(); // doc.close();
} // }
} // }
return in; // return in;
} // }
//
//
//
public String getReportFileUrl(String path,String fileName,List<List<String[]>> tableList, Map<String, Object> params) // public String getReportFileUrl(String path,String fileName,List<List<String[]>> tableList, Map<String, Object> params)
throws Exception { // throws Exception {
path = ClearPathUtil.cleanString(path); // path = ClearPathUtil.cleanString(path);
InputStream inStream = null,in = null; // InputStream inStream = null,in = null;
CustomXWPFDocument doc = null; // CustomXWPFDocument doc = null;
//读取报告模板 // //读取报告模板
try { // try {
inStream = new ClassPathResource(path).getInputStream();; // inStream = new ClassPathResource(path).getInputStream();;
doc = new CustomXWPFDocument(inStream); // doc = new CustomXWPFDocument(inStream);
if(CollUtil.isNotEmpty(tableList)){ // if(CollUtil.isNotEmpty(tableList)){
this.replaceInTable(doc, params,tableList); // this.replaceInTable(doc, params,tableList);
}else{ // }else{
this.replaceInTable(doc, params); // this.replaceInTable(doc, params);
} // }
this.replaceInPara(doc, params); // 替换文本里面的变量 // this.replaceInPara(doc, params); // 替换文本里面的变量
//临时缓冲区 // //临时缓冲区
ByteArrayOutputStream out = new ByteArrayOutputStream(); // ByteArrayOutputStream out = new ByteArrayOutputStream();
doc.write(out); // doc.write(out);
byte[] docByteAry = out.toByteArray(); // byte[] docByteAry = out.toByteArray();
in = new ByteArrayInputStream(docByteAry); // in = new ByteArrayInputStream(docByteAry);
out.close(); // out.close();
} catch (IOException e) { // } catch (IOException e) {
getError("获取报告模板异常,原因为:" + e); // getError("获取报告模板异常,原因为:" + e);
} finally { // } finally {
if (null != inStream) { // if (null != inStream) {
inStream.close(); // inStream.close();
} // }
if (doc != null) { // if (doc != null) {
doc.close(); // doc.close();
} // }
} // }
//上传文件服务器 // //上传文件服务器
return fileStorageUtil.uploadStreamSpecifyName(in, OssPath.ONLINE_REPORT, fileName); // return fileStorageUtil.uploadStreamSpecifyName(in, OssPath.ONLINE_REPORT, fileName);
} // }
//
//
private static void getError(String e) { // private static void getError(String e) {
log.error(e); // log.error(e);
} // }
/** // /**
* 替换段落里面的变量 // * 替换段落里面的变量
* // *
* @param doc 要替换的文档 // * @param doc 要替换的文档
* @param params 参数 // * @param params 参数
*/ // */
private void replaceInPara(CustomXWPFDocument doc, Map<String, Object> params) { // private void replaceInPara(CustomXWPFDocument doc, Map<String, Object> params) {
Iterator<XWPFParagraph> iterator = doc.getParagraphsIterator(); // Iterator<XWPFParagraph> iterator = doc.getParagraphsIterator();
List<XWPFParagraph> paragraphList = new ArrayList<>(); // List<XWPFParagraph> paragraphList = new ArrayList<>();
XWPFParagraph para; // XWPFParagraph para;
while (iterator.hasNext()) { // while (iterator.hasNext()) {
para = iterator.next(); // para = iterator.next();
paragraphList.add(para); // paragraphList.add(para);
} // }
processParagraphs(paragraphList, params, doc); // processParagraphs(paragraphList, params, doc);
} // }
//
private void replaceInTable(CustomXWPFDocument doc, Map<String, Object> params) { // private void replaceInTable(CustomXWPFDocument doc, Map<String, Object> params) {
Iterator<XWPFTable> it = doc.getTablesIterator(); // Iterator<XWPFTable> it = doc.getTablesIterator();
while (it.hasNext()) { // while (it.hasNext()) {
XWPFTable table = it.next(); // XWPFTable table = it.next();
List<XWPFTableRow> rows = table.getRows(); // List<XWPFTableRow> rows = table.getRows();
for (XWPFTableRow row : rows) { // for (XWPFTableRow row : rows) {
List<XWPFTableCell> cells = row.getTableCells(); // List<XWPFTableCell> cells = row.getTableCells();
for (XWPFTableCell cell : cells) { // for (XWPFTableCell cell : cells) {
List<XWPFParagraph> paragraphListTable = cell.getParagraphs(); // List<XWPFParagraph> paragraphListTable = cell.getParagraphs();
processParagraphs(paragraphListTable, params, doc); // processParagraphs(paragraphListTable, params, doc);
} // }
} // }
} // }
} // }
//
public static void processParagraphs(List<XWPFParagraph> paragraphList, Map<String, Object> param, // public static void processParagraphs(List<XWPFParagraph> paragraphList, Map<String, Object> param,
CustomXWPFDocument doc) { // CustomXWPFDocument doc) {
if (paragraphList != null && paragraphList.size() > 0) { // if (paragraphList != null && paragraphList.size() > 0) {
for (XWPFParagraph paragraph : paragraphList) { // for (XWPFParagraph paragraph : paragraphList) {
List<XWPFRun> runs = paragraph.getRuns(); // List<XWPFRun> runs = paragraph.getRuns();
if (runs.size() > 0) { // if (runs.size() > 0) {
for (XWPFRun run : runs) { // for (XWPFRun run : runs) {
String bflag = ""; // String bflag = "";
String text = run.getText(0); // String text = run.getText(0);
if (text != null) { // if (text != null) {
boolean isSetText = false; // boolean isSetText = false;
for (Entry<String, Object> entry : param.entrySet()) { // for (Entry<String, Object> entry : param.entrySet()) {
String key = entry.getKey(); // String key = entry.getKey();
if (text.indexOf(key) != -1) { // if (text.indexOf(key) != -1) {
isSetText = true; // isSetText = true;
Object value = entry.getValue(); // Object value = entry.getValue();
if (value instanceof String) {// 文本替换 // if (value instanceof String) {// 文本替换
text = text.replace(key, value.toString()); // text = text.replace(key, value.toString());
} else if (value instanceof Map) {// 图片替换 // } else if (value instanceof Map) {// 图片替换
text = text.replace(key, ""); // text = text.replace(key, "");
Map pic = (Map) value; // Map pic = (Map) value;
int width = Integer.parseInt(pic.get("width").toString()); // int width = Integer.parseInt(pic.get("width").toString());
int height = Integer.parseInt(pic.get("height").toString()); // int height = Integer.parseInt(pic.get("height").toString());
int picType = getPictureType(pic.get("type").toString()); // int picType = getPictureType(pic.get("type").toString());
byte[] byteArray = (byte[]) pic.get("content"); // byte[] byteArray = (byte[]) pic.get("content");
ByteArrayInputStream byteInputStream = new ByteArrayInputStream(byteArray); // ByteArrayInputStream byteInputStream = new ByteArrayInputStream(byteArray);
try { // try {
String s = doc.addPictureData(byteInputStream, picType); // String s = doc.addPictureData(byteInputStream, picType);
//
doc.createPicture(doc.getAllPictures().size() - 1, width, height, // doc.createPicture(doc.getAllPictures().size() - 1, width, height,
s,paragraph); // s,paragraph);
bflag = "break"; // bflag = "break";
} catch (Exception e) { // } catch (Exception e) {
getError("文本替换发生异常,异常是" + e.getMessage()); // getError("文本替换发生异常,异常是" + e.getMessage());
} // }
} // }
} // }
} // }
if (isSetText) { // if (isSetText) {
run.setText(text, 0); // run.setText(text, 0);
} // }
} // }
if (bflag == "break") { // if (bflag == "break") {
break; // break;
} // }
} // }
} // }
} // }
} // }
} // }
//
/** // /**
* 替换段落里面的变量 // * 替换段落里面的变量
* // *
* @param para 要替换的段落 // * @param para 要替换的段落
* @param params 参数 // * @param params 参数
*/ // */
private void replaceInPara(XWPFParagraph para, Map<String, Object> params, CustomXWPFDocument doc) { // private void replaceInPara(XWPFParagraph para, Map<String, Object> params, CustomXWPFDocument doc) {
List<XWPFRun> runs; // List<XWPFRun> runs;
Matcher matcher; // Matcher matcher;
// if (this.matcher(para.getParagraphText()).find()) { // // if (this.matcher(para.getParagraphText()).find()) {
runs = para.getRuns(); // runs = para.getRuns();
int start = -1; // int start = -1;
int end = -1; // int end = -1;
String str = ""; // String str = "";
for (int i = 0; i < runs.size(); i++) { // for (int i = 0; i < runs.size(); i++) {
XWPFRun run = runs.get(i); // XWPFRun run = runs.get(i);
String runText = run.toString(); // String runText = run.toString();
if ('$' == runText.charAt(0) && '{' == runText.charAt(1)) { // if ('$' == runText.charAt(0) && '{' == runText.charAt(1)) {
start = i; // start = i;
} // }
if ((start != -1)) { // if ((start != -1)) {
str += runText; // str += runText;
} // }
if ('}' == runText.charAt(runText.length() - 1)) { // if ('}' == runText.charAt(runText.length() - 1)) {
if (start != -1) { // if (start != -1) {
end = i; // end = i;
break; // break;
} // }
} // }
} // }
//
for (int i = start; i <= end; i++) { // for (int i = start; i <= end; i++) {
para.removeRun(i); // para.removeRun(i);
i--; // i--;
end--; // end--;
} // }
//
for (Entry<String, Object> entry : params.entrySet()) { // for (Entry<String, Object> entry : params.entrySet()) {
String key = entry.getKey(); // String key = entry.getKey();
if (str.indexOf(key) != -1) { // if (str.indexOf(key) != -1) {
Object value = entry.getValue(); // Object value = entry.getValue();
if (value instanceof String) { // if (value instanceof String) {
str = str.replace(key, value.toString()); // str = str.replace(key, value.toString());
para.createRun().setText(str, 0); // para.createRun().setText(str, 0);
break; // break;
} else if (value instanceof Map) { // } else if (value instanceof Map) {
str = str.replace(key, ""); // str = str.replace(key, "");
Map pic = (Map) value; // Map pic = (Map) value;
int width = Integer.parseInt(pic.get("width").toString()); // int width = Integer.parseInt(pic.get("width").toString());
int height = Integer.parseInt(pic.get("height").toString()); // int height = Integer.parseInt(pic.get("height").toString());
int picType = getPictureType(pic.get("type").toString()); // int picType = getPictureType(pic.get("type").toString());
byte[] byteArray = (byte[]) pic.get("content"); // byte[] byteArray = (byte[]) pic.get("content");
ByteArrayInputStream byteInputStream = new ByteArrayInputStream(byteArray); // ByteArrayInputStream byteInputStream = new ByteArrayInputStream(byteArray);
try { // try {
// int ind = doc.addPicture(byteInputStream,picType); // // int ind = doc.addPicture(byteInputStream,picType);
// doc.createPicture(ind, width , height,para); // // doc.createPicture(ind, width , height,para);
String s = doc.addPictureData(byteInputStream, picType); // String s = doc.addPictureData(byteInputStream, picType);
doc.createPicture(doc.getAllPictures().size() - 1, width, height,s, para); // doc.createPicture(doc.getAllPictures().size() - 1, width, height,s, para);
para.createRun().setText(str, 0); // para.createRun().setText(str, 0);
break; // break;
} catch (Exception e) { // } catch (Exception e) {
getError("文件替换发生异常,异常是" + e.getMessage()); // getError("文件替换发生异常,异常是" + e.getMessage());
} // }
} // }
} // }
} // }
// } // // }
} // }
//
/** // /**
* 为表格插入数据,行数不够添加新行 // * 为表格插入数据,行数不够添加新行
* // *
* @param table 需要插入数据的表格 // * @param table 需要插入数据的表格
* @param tableList 插入数据集合 // * @param tableList 插入数据集合
*/ // */
private static void insertTable(XWPFTable table, List<String[]> tableList) { // private static void insertTable(XWPFTable table, List<String[]> tableList) {
//删除占位符行数 // //删除占位符行数
table.removeRow(1); // table.removeRow(1);
if (CollUtil.isNotEmpty(tableList)) { // if (CollUtil.isNotEmpty(tableList)) {
// 创建行,根据需要插入的数据添加新行,不处理表头 // // 创建行,根据需要插入的数据添加新行,不处理表头
for (int i = 0; i < tableList.size(); i++) { // for (int i = 0; i < tableList.size(); i++) {
XWPFTableRow row = table.createRow(); // XWPFTableRow row = table.createRow();
List<XWPFTableCell> cells = row.getTableCells(); // List<XWPFTableCell> cells = row.getTableCells();
for (int j = 0; j < cells.size(); j++) { // for (int j = 0; j < cells.size(); j++) {
String s = tableList.get(i)[j]; // String s = tableList.get(i)[j];
XWPFTableCell cell = cells.get(j); // XWPFTableCell cell = cells.get(j);
cell.removeParagraph(0); // cell.removeParagraph(0);
XWPFParagraph paragraph = cell.addParagraph(); // XWPFParagraph paragraph = cell.addParagraph();
paragraph.setAlignment(ParagraphAlignment.CENTER); // paragraph.setAlignment(ParagraphAlignment.CENTER);
// 在段落中添加文本 // // 在段落中添加文本
XWPFRun run = paragraph.createRun(); // XWPFRun run = paragraph.createRun();
run.setText(s); // run.setText(s);
} // }
} // }
} // }
} // }
//
/** // /**
* 替换表格里面的变量 // * 替换表格里面的变量
* // *
* @param doc 要替换的文档 // * @param doc 要替换的文档
* @param tableList 存放数据顺序要与表格一致 // * @param tableList 存放数据顺序要与表格一致
* @param params 参数 // * @param params 参数
*/ // */
private void replaceInTable(CustomXWPFDocument doc, Map<String, Object> params, List<List<String[]>> tableList) { // private void replaceInTable(CustomXWPFDocument doc, Map<String, Object> params, List<List<String[]>> tableList) {
Iterator<XWPFTable> iterator = doc.getTablesIterator(); // Iterator<XWPFTable> iterator = doc.getTablesIterator();
XWPFTable table; // XWPFTable table;
List<XWPFTableRow> rows; // List<XWPFTableRow> rows;
List<XWPFTableCell> cells; // List<XWPFTableCell> cells;
List<XWPFParagraph> paras; // List<XWPFParagraph> paras;
Integer num=0; // Integer num=0;
while (iterator.hasNext()) { // while (iterator.hasNext()) {
table = iterator.next(); // table = iterator.next();
if (table.getRows().size() > 1) { // if (table.getRows().size() > 1) {
// 判断表格是需要替换还是需要插入,判断逻辑有$为替换,表格无$为插入 // // 判断表格是需要替换还是需要插入,判断逻辑有$为替换,表格无$为插入
if (this.matcher(table.getText()).find()||this.matcherS(table.getText()).find()) { // if (this.matcher(table.getText()).find()||this.matcherS(table.getText()).find()) {
rows = table.getRows(); // rows = table.getRows();
for (XWPFTableRow row : rows) { // for (XWPFTableRow row : rows) {
cells = row.getTableCells(); // cells = row.getTableCells();
for (XWPFTableCell cell : cells) { // for (XWPFTableCell cell : cells) {
List<XWPFParagraph> paragraphListTable = cell.getParagraphs(); // List<XWPFParagraph> paragraphListTable = cell.getParagraphs();
processParagraphs(paragraphListTable, params, doc); // processParagraphs(paragraphListTable, params, doc);
} // }
} // }
}else { // }else {
if (CollUtil.isNotEmpty(tableList.get(num))){ // if (CollUtil.isNotEmpty(tableList.get(num))){
insertTable(table, tableList.get(num)); // 插入数据 // insertTable(table, tableList.get(num)); // 插入数据
} // }
num++; // num++;
} // }
} // }
} // }
} // }
//
/** // /**
* 正则匹配字符串 // * 正则匹配字符串
* // *
* @param str // * @param str
* @return // * @return
*/ // */
private Matcher matcher(String str) { // private Matcher matcher(String str) {
Pattern pattern = Pattern.compile("\\$\\{(.+?)\\}", Pattern.CASE_INSENSITIVE); // Pattern pattern = Pattern.compile("\\$\\{(.+?)\\}", Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(str); // Matcher matcher = pattern.matcher(str);
return matcher; // return matcher;
} // }
private Matcher matcherS(String str) { // private Matcher matcherS(String str) {
Pattern pattern = Pattern.compile("\\$(.*?)\\$"); // Pattern pattern = Pattern.compile("\\$(.*?)\\$");
Matcher matcher = pattern.matcher(str); // Matcher matcher = pattern.matcher(str);
return matcher; // return matcher;
} // }
//
/** // /**
* 根据图片类型,取得对应的图片类型代码 // * 根据图片类型,取得对应的图片类型代码
* // *
* @param picType // * @param picType
* @return int // * @return int
*/ // */
private static int getPictureType(String picType) { // private static int getPictureType(String picType) {
int res = CustomXWPFDocument.PICTURE_TYPE_PICT; // int res = CustomXWPFDocument.PICTURE_TYPE_PICT;
if (picType != null) { // if (picType != null) {
if (picType.equalsIgnoreCase("image/png")) { // if (picType.equalsIgnoreCase("image/png")) {
res = CustomXWPFDocument.PICTURE_TYPE_PNG; // res = CustomXWPFDocument.PICTURE_TYPE_PNG;
} else if (picType.equalsIgnoreCase("image/dib")) { // } else if (picType.equalsIgnoreCase("image/dib")) {
res = CustomXWPFDocument.PICTURE_TYPE_DIB; // res = CustomXWPFDocument.PICTURE_TYPE_DIB;
} else if (picType.equalsIgnoreCase("image/emf")) { // } else if (picType.equalsIgnoreCase("image/emf")) {
res = CustomXWPFDocument.PICTURE_TYPE_EMF; // res = CustomXWPFDocument.PICTURE_TYPE_EMF;
} else if (picType.equalsIgnoreCase("image/jpg") || picType.equalsIgnoreCase("image/jpeg")) { // } else if (picType.equalsIgnoreCase("image/jpg") || picType.equalsIgnoreCase("image/jpeg")) {
res = CustomXWPFDocument.PICTURE_TYPE_JPEG; // res = CustomXWPFDocument.PICTURE_TYPE_JPEG;
} else if (picType.equalsIgnoreCase("image/wmf")) { // } else if (picType.equalsIgnoreCase("image/wmf")) {
res = CustomXWPFDocument.PICTURE_TYPE_WMF; // res = CustomXWPFDocument.PICTURE_TYPE_WMF;
} // }
} // }
return res; // return res;
} // }
//
} //}

View File

@@ -141,6 +141,18 @@
<version>1.0.0</version> <version>1.0.0</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>harmonic-common</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>event-common</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@@ -1,10 +1,16 @@
package com.njcn.csharmonic.controller; package com.njcn.csharmonic.controller;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.extra.template.TemplateException; import cn.hutool.extra.template.TemplateException;
import com.baomidou.dynamic.datasource.annotation.DS;
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.csharmonic.pojo.param.eventReport.ExportParam; import com.njcn.csdevice.api.CsLineFeignClient;
import com.njcn.csharmonic.service.event.EventMonitorReportService; import com.njcn.csdevice.pojo.vo.LineDetailDataVO;
import com.njcn.csharmonic.service.event.CsEventMonitorReportService;
import com.njcn.event.common.pojo.dto.LineDetailDataCommDTO;
import com.njcn.event.common.service.EventMonitorReportService;
import com.njcn.event.pojo.param.ExportParam;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@@ -32,16 +38,17 @@ import java.text.ParseException;
@RestController @RestController
@RequestMapping("/eventReport") @RequestMapping("/eventReport")
@RequiredArgsConstructor @RequiredArgsConstructor
public class EventMonitorReportController { public class CsEventMonitorReportController {
private final EventMonitorReportService eventMonitorReportService; private final CsEventMonitorReportService monitorEventReportService;
private final CsLineFeignClient csLineFeignClient;
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getLineExport") @PostMapping("/getLineExport")
@ApiOperation("监测点报告导出") @ApiOperation("监测点报告导出")
@ApiImplicitParam(name = "exportParam", value = "监测点报告导出参数", required = true) @ApiImplicitParam(name = "exportParam", value = "监测点报告导出参数", required = true)
public void getLineExport(@RequestBody @Validated ExportParam exportParam, HttpServletResponse response) throws IOException, InvalidFormatException, TemplateException, ParseException { public void getLineExport(@RequestBody @Validated ExportParam exportParam, HttpServletResponse response) throws IOException, InvalidFormatException, TemplateException, ParseException {
eventMonitorReportService.getLineExport(exportParam, response); monitorEventReportService.getLineExport(exportParam, response);
} }
} }

View File

@@ -8,13 +8,14 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil; import com.njcn.common.utils.HttpResultUtil;
import com.njcn.csharmonic.param.SensitiveUserReportQueryParam; import com.njcn.csharmonic.param.SensitiveUserReportQueryParam;
import com.njcn.csharmonic.pojo.param.ReportSearchParam;
import com.njcn.csharmonic.pojo.param.ReportTemplateParam; import com.njcn.csharmonic.pojo.param.ReportTemplateParam;
import com.njcn.csharmonic.pojo.po.ExcelRptTemp;
import com.njcn.csharmonic.pojo.vo.ReportTemplateVO;
import com.njcn.csharmonic.pojo.vo.ReportTreeVO; import com.njcn.csharmonic.pojo.vo.ReportTreeVO;
import com.njcn.csharmonic.pojo.vo.SysDeptTempVO; import com.njcn.csharmonic.pojo.vo.SysDeptTempVO;
import com.njcn.csharmonic.service.CustomReportService; import com.njcn.csharmonic.service.CustomReportService;
import com.njcn.harmonic.common.pojo.vo.ReportTemplateVO;
import com.njcn.harmonic.common.service.CustomReportTableService;
import com.njcn.harmonic.pojo.param.ReportSearchParam;
import com.njcn.harmonic.pojo.po.ExcelRptTemp;
import com.njcn.web.controller.BaseController; import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
@@ -44,6 +45,8 @@ public class CustomReportController extends BaseController {
private final CustomReportService customReportService; private final CustomReportService customReportService;
/** /**
* 替换报表数据并返回 * 替换报表数据并返回
* @author qijian * @author qijian

View File

@@ -1,6 +1,5 @@
package com.njcn.csharmonic.controller; package com.njcn.csharmonic.controller;
import cn.hutool.core.collection.CollUtil;
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;
@@ -21,7 +20,6 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -92,13 +90,7 @@ public class EventOverviewController extends BaseController {
@ApiOperation("获取暂降方向统计数据") @ApiOperation("获取暂降方向统计数据")
public HttpResult<List<Map<String,Object>>> getEventDirectionData(@RequestBody EventStatisticParam baseParam){ public HttpResult<List<Map<String,Object>>> getEventDirectionData(@RequestBody EventStatisticParam baseParam){
String methodDescribe = getMethodDescribe("getEventDirectionData"); String methodDescribe = getMethodDescribe("getEventDirectionData");
Map<String,Object> load = new HashMap<>(); List<Map<String,Object>> list = eventOverviewService.getEventDirectionData(baseParam);
load.put("source", "load");
load.put("times", 41);
Map<String,Object> grid = new HashMap<>();
grid.put("source", "grid");
grid.put("times", 4);
List<Map<String,Object>> list = CollUtil.newArrayList(load, grid);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,list,methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,list,methodDescribe);
} }

View File

@@ -6,13 +6,13 @@ import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil; import com.njcn.common.utils.HttpResultUtil;
import com.njcn.csharmonic.param.CldWarnParam;
import com.njcn.csharmonic.param.CsEventUserQueryPage; import com.njcn.csharmonic.param.CsEventUserQueryPage;
import com.njcn.csharmonic.param.CsEventUserQueryParam; import com.njcn.csharmonic.param.CsEventUserQueryParam;
import com.njcn.csharmonic.pojo.po.CsEventPO; import com.njcn.csharmonic.pojo.po.CsEventPO;
import com.njcn.csharmonic.pojo.vo.EventDetailVO; import com.njcn.csharmonic.pojo.vo.EventDetailVO;
import com.njcn.csharmonic.service.CsEventUserPOService; import com.njcn.csharmonic.service.CsEventUserPOService;
import com.njcn.web.controller.BaseController; import com.njcn.web.controller.BaseController;
import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@@ -82,7 +82,7 @@ public class EventUserController extends BaseController {
@PostMapping("/frontWarnInfo") @PostMapping("/frontWarnInfo")
@ApiOperation("前置告警信息") @ApiOperation("前置告警信息")
@ApiImplicitParam(name = "baseParam", value = "基础查询数据", required = true) @ApiImplicitParam(name = "baseParam", value = "基础查询数据", required = true)
public HttpResult<Page<CsEventPO>> frontWarnInfo(@RequestBody BaseParam baseParam) { public HttpResult<Page<CsEventPO>> frontWarnInfo(@RequestBody CldWarnParam baseParam) {
String methodDescribe = getMethodDescribe("frontWarnInfo"); String methodDescribe = getMethodDescribe("frontWarnInfo");
Page<CsEventPO> list = csEventUserPOService.getFrontWarnInfo(baseParam); Page<CsEventPO> list = csEventUserPOService.getFrontWarnInfo(baseParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);

View File

@@ -10,6 +10,8 @@ import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil; import com.njcn.common.utils.HttpResultUtil;
import com.njcn.csdevice.api.CsLineFeignClient;
import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csharmonic.pojo.param.PqSensitiveUserParam; import com.njcn.csharmonic.pojo.param.PqSensitiveUserParam;
import com.njcn.csharmonic.pojo.po.PqSensitiveUser; import com.njcn.csharmonic.pojo.po.PqSensitiveUser;
import com.njcn.csharmonic.pojo.vo.PqSensitiveUserVo; import com.njcn.csharmonic.pojo.vo.PqSensitiveUserVo;
@@ -24,7 +26,10 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/** /**
* <p> * <p>
@@ -42,6 +47,7 @@ import java.util.List;
public class PqSensitiveUserController extends BaseController { public class PqSensitiveUserController extends BaseController {
private final IPqSensitiveUserService pqSensitiveUserService; private final IPqSensitiveUserService pqSensitiveUserService;
private final CsLineFeignClient csLineFeignClient;
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getList") @PostMapping("/getList")
@@ -59,11 +65,26 @@ public class PqSensitiveUserController extends BaseController {
@ApiImplicitParam(name = "ids", value = "id集合") @ApiImplicitParam(name = "ids", value = "id集合")
public HttpResult<List<PqSensitiveUser>> getListByIds(@RequestParam(name = "ids", required = false) List<String> ids) { public HttpResult<List<PqSensitiveUser>> getListByIds(@RequestParam(name = "ids", required = false) List<String> ids) {
String methodDescribe = getMethodDescribe("getListByIds"); String methodDescribe = getMethodDescribe("getListByIds");
List<PqSensitiveUser> list = pqSensitiveUserService.list( List<PqSensitiveUser> list;
new LambdaQueryWrapper<PqSensitiveUser>() //获取用户监测点
.in(CollUtil.isNotEmpty(ids),PqSensitiveUser::getId, ids) List<String> keywordsLineIds = new ArrayList<>();
List<CsLinePO> poList = csLineFeignClient.getSimpleLine().getData();
if (CollUtil.isNotEmpty(poList)) {
keywordsLineIds = poList.stream().map(CsLinePO::getMonitorUser).filter(Objects::nonNull).distinct().collect(Collectors.toList());
}
if (CollUtil.isEmpty(keywordsLineIds)) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
} else {
if (CollUtil.isNotEmpty(ids)) {
keywordsLineIds = ids;
}
}
list = pqSensitiveUserService.list(
new LambdaQueryWrapper<PqSensitiveUser>().in(PqSensitiveUser::getId, keywordsLineIds)
); );
if (CollUtil.isEmpty(list)) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
} }

View File

@@ -112,7 +112,6 @@ public class RStatLimitRateDController extends BaseController {
public HttpResult<TotalLimitTotalStatisticsVO> totalLimitTotalStatisticsData(@RequestBody TotalLimitStatisticsParam mainLineQueryParam) { public HttpResult<TotalLimitTotalStatisticsVO> totalLimitTotalStatisticsData(@RequestBody TotalLimitStatisticsParam mainLineQueryParam) {
String methodDescribe = getMethodDescribe("totalLimitStatisticsList"); String methodDescribe = getMethodDescribe("totalLimitStatisticsList");
TotalLimitTotalStatisticsVO data = limitRateDService.totalLimitTotalStatisticsData(mainLineQueryParam); TotalLimitTotalStatisticsVO data = limitRateDService.totalLimitTotalStatisticsData(mainLineQueryParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, data, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, data, methodDescribe);
} }
@@ -122,7 +121,6 @@ public class RStatLimitRateDController extends BaseController {
public HttpResult<List<TotalLimitStatisticsVO>> totalLimitStatisticsList(@RequestBody TotalLimitStatisticsParam mainLineQueryParam) { public HttpResult<List<TotalLimitStatisticsVO>> totalLimitStatisticsList(@RequestBody TotalLimitStatisticsParam mainLineQueryParam) {
String methodDescribe = getMethodDescribe("totalLimitStatisticsList"); String methodDescribe = getMethodDescribe("totalLimitStatisticsList");
List<TotalLimitStatisticsVO> list = limitRateDService.totalLimitStatisticsList(mainLineQueryParam); List<TotalLimitStatisticsVO> list = limitRateDService.totalLimitStatisticsList(mainLineQueryParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
} }

View File

@@ -0,0 +1,77 @@
package com.njcn.csharmonic.controller;
import com.njcn.common.pojo.annotation.OperateInfo;
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.harmonic.common.service.ISysExcelService;
import com.njcn.harmonic.pojo.param.excel.ExcelParam;
import com.njcn.harmonic.pojo.po.excel.SysExcel;
import com.njcn.web.controller.BaseController;
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.web.bind.annotation.*;
import java.util.List;
/**
* <p>
* 前端控制器
* </p>
*
* @author xy
* @since 2026-01-27
*/
@Slf4j
@RestController
@RequestMapping("/sysExcel")
@Api(tags = "模板类型配置")
@AllArgsConstructor
public class SysExcelController extends BaseController {
private final ISysExcelService sysExcelService;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/addSysExcel")
@ApiOperation("新增")
@ApiImplicitParam(name = "param", value = "设备数据趋势参数", required = true)
public HttpResult<Boolean> addSysExcel(@RequestBody ExcelParam param) {
String methodDescribe = getMethodDescribe("addSysExcel");
Boolean result = sysExcelService.addSysExcel(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/updateSysExcel")
@ApiOperation("修改")
public HttpResult<Boolean> updateSysExcel(@RequestBody ExcelParam.UpdateExcelParam param) {
String methodDescribe = getMethodDescribe("updateSysExcel");
Boolean result = sysExcelService.updateSysExcel(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/deleteSysExcel")
@ApiOperation("删除")
public HttpResult<Boolean> deleteSysExcel(@RequestParam("id") String id) {
String methodDescribe = getMethodDescribe("deleteSysExcel");
Boolean result = sysExcelService.deleteSysExcel(id);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/querySysExcel")
@ApiOperation("查询")
public HttpResult<List<SysExcel>> querySysExcel() {
String methodDescribe = getMethodDescribe("querySysExcel");
List<SysExcel> result = sysExcelService.querySysExcel();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
}

View File

@@ -0,0 +1,60 @@
package com.njcn.csharmonic.controller;
import com.njcn.common.pojo.annotation.OperateInfo;
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.csharmonic.service.ICsSysExcelRelationService;
import com.njcn.harmonic.common.pojo.vo.ReportTemplateVO;
import com.njcn.harmonic.pojo.param.excel.ExcelParam;
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.web.bind.annotation.*;
import com.njcn.web.controller.BaseController;
import java.util.List;
/**
* <p>
* 前端控制器
* </p>
*
* @author xy
* @since 2026-01-27
*/
@RequestMapping("/sysExcelRelation")
@Slf4j
@RestController
@Api(tags = "模板关系配置")
@AllArgsConstructor
public class SysExcelRelationController extends BaseController {
private final ICsSysExcelRelationService sysExcelService;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryList")
@ApiOperation("查询")
public HttpResult<List<ReportTemplateVO>> queryList(@RequestParam("id") String id) {
String methodDescribe = getMethodDescribe("queryList");
List<ReportTemplateVO> result = sysExcelService.queryList(id);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/bandRelation")
@ApiOperation("绑定关系")
public HttpResult<Boolean> bandRelation(@RequestBody ExcelParam.ListExcelParam param) {
String methodDescribe = getMethodDescribe("bandRelation");
Boolean result = sysExcelService.bandRelation(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
}

View File

@@ -1,36 +0,0 @@
package com.njcn.csharmonic.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.csharmonic.pojo.param.ReportSearchParam;
import com.njcn.csharmonic.pojo.po.ExcelRptTemp;
import com.njcn.csharmonic.pojo.vo.ReportTemplateVO;
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
import com.njcn.web.pojo.param.BaseParam;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
import java.util.Map;
/**
* pqs
*
* @author cdf
* @date 2022/8/16
*/
public interface ExcelRptTempMapper extends BaseMapper<ExcelRptTemp> {
Page<ReportTemplateVO> getReportTemplateListPage(Page<BaseParam> page, @Param("baseParam")BaseParam baseParam);
List<ReportTemplateVO> getReportTemplateList(@Param("reportSearchParam")ReportSearchParam reportSearchParam);
List<ReportTemplateVO> getReportTemplateByDept(@Param("ids") List<String> ids);
@Select("${sqlStr}")
StatisticalDataDTO dynamicSql(@Param("sqlStr")String sql);
@Select("${sqlStr}")
Map<String, Float> dynamicSqlMap(@Param("sqlStr")String sql);
}

View File

@@ -0,0 +1,18 @@
//package com.njcn.csharmonic.mapper;
//
//import com.baomidou.dynamic.datasource.annotation.DS;
//import com.baomidou.mybatisplus.core.mapper.BaseMapper;
//import com.njcn.csharmonic.pojo.po.RmpEventDetailPO;
//import org.apache.ibatis.annotations.Mapper;
//
///**
// * 暂态事件明细
// *
// * @author yzh
// * @date 2022/10/12
// */
//@Mapper
//@DS("sjzx")
//public interface RmpEventDetailMapper extends BaseMapper<RmpEventDetailPO> {
//
//}

View File

@@ -21,7 +21,11 @@
SELECT SELECT
t1.line_id id, t1.line_id id,
t2.NAME, t2.NAME,
t1.start_time timeId, CONCAT(
DATE_FORMAT( t1.start_time, '%Y-%m-%d %H:%i:%s' ),
'.',
LPAD( FLOOR( MICROSECOND( t1.start_time ) / 1000 ), 3, '0' )
) AS timeId,
t1.amplitude, t1.amplitude,
t1.persist_time t1.persist_time
FROM FROM
@@ -34,6 +38,7 @@
#{lineId} #{lineId}
</foreach> </foreach>
and t1.type = 0 and t1.type = 0
order by t1.start_time DESC
LIMIT 60 LIMIT 60
</select> </select>

View File

@@ -107,7 +107,10 @@
AND b.type =#{ csEventUserQueryPage.type} AND b.type =#{ csEventUserQueryPage.type}
</if> </if>
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.level != null and csEventUserQueryPage.level !=''"> <if test="csEventUserQueryPage!=null and csEventUserQueryPage.level != null and csEventUserQueryPage.level !=''">
AND b.level =#{ csEventUserQueryPage.level} AND b.level IN
<foreach collection="csEventUserQueryPage.level.split(',')" item="level" open="(" separator="," close=")">
#{level}
</foreach>
</if> </if>
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.status != null and csEventUserQueryPage.status !=''"> <if test="csEventUserQueryPage!=null and csEventUserQueryPage.status != null and csEventUserQueryPage.status !=''">
AND a.status =#{ csEventUserQueryPage.status} AND a.status =#{ csEventUserQueryPage.status}
@@ -157,9 +160,11 @@
</if> </if>
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.level != null and csEventUserQueryPage.level !=''"> <if test="csEventUserQueryPage!=null and csEventUserQueryPage.level != null and csEventUserQueryPage.level !=''">
AND b.level = #{ csEventUserQueryPage.level} AND b.level IN
<foreach collection="csEventUserQueryPage.level.split(',')" item="level" open="(" separator="," close=")">
#{level}
</foreach>
</if> </if>
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.eventType != null and csEventUserQueryPage.eventType !=''"> <if test="csEventUserQueryPage!=null and csEventUserQueryPage.eventType != null and csEventUserQueryPage.eventType !=''">
AND b.tag = #{csEventUserQueryPage.eventType} AND b.tag = #{csEventUserQueryPage.eventType}
</if> </if>

View File

@@ -1,58 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.csharmonic.mapper.ExcelRptTempMapper">
<select id="getReportTemplateListPage" resultType="com.njcn.csharmonic.pojo.vo.ReportTemplateVO">
select
a.id,
a.name,
a.dept_id,
b.name deptName,
a.activation,
a.update_time,
c.name updateBy
from sys_excel_rpt_temp a
left join sys_dept b on a.dept_id = b.id
left join sys_user c on a.update_by = c.id
where a.state = 1
<if test="baseParam.searchValue!=null and baseParam.searchValue!=''">
and (
a.name like CONCAT('%', #{baseParam.searchValue},'%') or
b.name like CONCAT('%', #{baseParam.searchValue},'%')
)
</if>
</select>
<select id="getReportTemplateList" resultType="com.njcn.csharmonic.pojo.vo.ReportTemplateVO">
SELECT
a.id,
a.NAME,
a.update_time,
a.create_time,
a.update_by,
a.Activation,
a.Report_Type,
a.Report_Form
FROM
sys_excel_rpt_temp a
WHERE
a.state = 1
order by a.create_time desc
</select>
<select id="getReportTemplateByDept" resultType="com.njcn.csharmonic.pojo.vo.ReportTemplateVO">
SELECT
DISTINCT
a.id,
a.NAME,
a.activation,
a.report_form,
a.sort
FROM
sys_excel_rpt_temp a
LEFT JOIN sys_dept_temp b ON a.Id = b.temp_id
WHERE
a.activation = 1
order by a.sort asc
</select>
</mapper>

View File

@@ -0,0 +1,36 @@
//package com.njcn.csharmonic.mapper.report;
//
//import com.baomidou.mybatisplus.core.mapper.BaseMapper;
//import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
//import com.njcn.csharmonic.pojo.param.ReportSearchParam;
//import com.njcn.csharmonic.pojo.po.ExcelRptTemp;
//import com.njcn.csharmonic.pojo.vo.ReportTemplateVO;
//import com.njcn.influx.pojo.dto.StatisticalDataDTO;
//import com.njcn.web.pojo.param.BaseParam;
//import org.apache.ibatis.annotations.Param;
//import org.apache.ibatis.annotations.Select;
//
//import java.util.List;
//import java.util.Map;
//
///**
// * pqs
// *
// * @author cdf
// * @date 2022/8/16
// */
//public interface ExcelRptTempMapper extends BaseMapper<ExcelRptTemp> {
//
// Page<ReportTemplateVO> getReportTemplateListPage(Page<BaseParam> page, @Param("baseParam")BaseParam baseParam);
//
// List<ReportTemplateVO> getReportTemplateList(@Param("reportSearchParam")ReportSearchParam reportSearchParam);
//
// List<ReportTemplateVO> getReportTemplateByDept(@Param("ids") List<String> ids);
//
//
// @Select("${sqlStr}")
// StatisticalDataDTO dynamicSql(@Param("sqlStr")String sql);
//
// @Select("${sqlStr}")
// Map<String, Float> dynamicSqlMap(@Param("sqlStr")String sql);
//}

View File

@@ -0,0 +1,16 @@
//package com.njcn.csharmonic.mapper.report;
//
//import com.baomidou.mybatisplus.core.mapper.BaseMapper;
//import com.njcn.csharmonic.pojo.po.day.RStatDataHarmrateVDPO;
//
///**
// * <p>
// * Mapper 接口
// * </p>
// *
// * @author wr
// * @since 2023-04-17
// */
//public interface RStatDataHarmRateVDMapper extends BaseMapper<RStatDataHarmrateVDPO> {
//
//}

View File

@@ -1,29 +1,29 @@
package com.njcn.csharmonic.mapper.report; //package com.njcn.csharmonic.mapper.report;
//
import com.baomidou.mybatisplus.core.mapper.BaseMapper; //import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.csharmonic.pojo.po.day.RStatDataIDPO; //import com.njcn.csharmonic.pojo.po.day.RStatDataIDPO;
import org.apache.ibatis.annotations.Param; //import org.apache.ibatis.annotations.Param;
//
import java.util.List; //import java.util.List;
//
/** ///**
* <p> // * <p>
* Mapper 接口 // * Mapper 接口
* </p> // * </p>
* // *
* @author wr // * @author wr
* @since 2023-04-17 // * @since 2023-04-17
*/ // */
public interface RStatDataIDMapper extends BaseMapper<RStatDataIDPO> { //public interface RStatDataIDMapper extends BaseMapper<RStatDataIDPO> {
//
/** // /**
* 获取监测点负序电流 // * 获取监测点负序电流
* @return // * @return
*/ // */
List<RStatDataIDPO> getINeg(@Param("list") List<String> lineList, @Param("startTime") String startTime, @Param("endTime") String endTime); // List<RStatDataIDPO> getINeg(@Param("list") List<String> lineList, @Param("startTime") String startTime, @Param("endTime") String endTime);
//
/** // /**
* 谐波电流 // * 谐波电流
*/ // */
List<RStatDataIDPO> getI(@Param("list") List<String> lineList, @Param("startTime") String startTime, @Param("endTime") String endTime); // List<RStatDataIDPO> getI(@Param("list") List<String> lineList, @Param("startTime") String startTime, @Param("endTime") String endTime);
} //}

View File

@@ -1,17 +1,17 @@
package com.njcn.csharmonic.mapper.report; //package com.njcn.csharmonic.mapper.report;
//
import com.baomidou.mybatisplus.core.mapper.BaseMapper; //import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.csharmonic.pojo.po.day.RStatDataInharmVDPO; //import com.njcn.csharmonic.pojo.po.day.RStatDataInharmVDPO;
import org.apache.ibatis.annotations.Param; //import org.apache.ibatis.annotations.Param;
//
import java.util.List; //import java.util.List;
//
/** ///**
* @Description: // * @Description:
* @Author: wr // * @Author: wr
* @Date: 2024/7/31 9:24 // * @Date: 2024/7/31 9:24
*/ // */
public interface RStatDataInharmVDMapper extends BaseMapper<RStatDataInharmVDPO> { //public interface RStatDataInharmVDMapper extends BaseMapper<RStatDataInharmVDPO> {
//
//List<RStatDataInharmVDPO> getV(@Param("list") List<String> lineList, @Param("startTime") String startTime, @Param("endTime") String endTime); // //List<RStatDataInharmVDPO> getV(@Param("list") List<String> lineList, @Param("startTime") String startTime, @Param("endTime") String endTime);
} //}

View File

@@ -1,43 +1,43 @@
package com.njcn.csharmonic.mapper.report; //package com.njcn.csharmonic.mapper.report;
//
import com.baomidou.mybatisplus.core.mapper.BaseMapper; //import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.csharmonic.pojo.po.day.RStatDataVDPO; //import com.njcn.csharmonic.pojo.po.day.RStatDataVDPO;
import org.apache.ibatis.annotations.Param; //import org.apache.ibatis.annotations.Param;
//
import java.util.List; //import java.util.List;
//
/** ///**
* <p> // * <p>
* Mapper 接口 // * Mapper 接口
* </p> // * </p>
* // *
* @author wr // * @author wr
* @since 2023-03-31 // * @since 2023-03-31
*/ // */
public interface RStatDataVDPOMapper extends BaseMapper<RStatDataVDPO> { //public interface RStatDataVDPOMapper extends BaseMapper<RStatDataVDPO> {
//
/** // /**
* 获取频率偏差、三相电压不平衡度 // * 获取频率偏差、三相电压不平衡度
*/ // */
List<RStatDataVDPO> getFreqDev(@Param("list") List<String> lineList, @Param("startTime") String startTime, @Param("endTime") String endTime); // List<RStatDataVDPO> getFreqDev(@Param("list") List<String> lineList, @Param("startTime") String startTime, @Param("endTime") String endTime);
//
/** // /**
* 获取电压偏差 // * 获取电压偏差
*/ // */
List<RStatDataVDPO> getVuDev(@Param("list") List<String> lineList, @Param("startTime") String startTime, @Param("endTime") String endTime); // List<RStatDataVDPO> getVuDev(@Param("list") List<String> lineList, @Param("startTime") String startTime, @Param("endTime") String endTime);
//
/** // /**
* 获取电压总谐波畸变率 // * 获取电压总谐波畸变率
*/ // */
List<RStatDataVDPO> getVthd(@Param("list") List<String> lineList, @Param("startTime") String startTime, @Param("endTime") String endTime); // List<RStatDataVDPO> getVthd(@Param("list") List<String> lineList, @Param("startTime") String startTime, @Param("endTime") String endTime);
//
/** // /**
* 获取三相电压不平衡度 // * 获取三相电压不平衡度
*/ // */
List<RStatDataVDPO> getUnbalance(@Param("list") List<String> lineList, @Param("startTime") String startTime, @Param("endTime") String endTime); // List<RStatDataVDPO> getUnbalance(@Param("list") List<String> lineList, @Param("startTime") String startTime, @Param("endTime") String endTime);
//
/** // /**
* 获取谐波电压 // * 获取谐波电压
*/ // */
List<RStatDataVDPO> getV(@Param("list") List<String> lineList, @Param("startTime") String startTime, @Param("endTime") String endTime); // List<RStatDataVDPO> getV(@Param("list") List<String> lineList, @Param("startTime") String startTime, @Param("endTime") String endTime);
} //}

View File

@@ -1,138 +1,138 @@
package com.njcn.csharmonic.mapper.report; //package com.njcn.csharmonic.mapper.report;
//
//
import com.njcn.csharmonic.pojo.param.report.ReportQueryParam; //import com.njcn.csharmonic.pojo.param.report.ReportQueryParam;
import com.njcn.csharmonic.pojo.vo.report.ReportValue; //import com.njcn.csharmonic.pojo.vo.report.ReportValue;
import org.apache.ibatis.annotations.Param; //import org.apache.ibatis.annotations.Param;
//
import java.util.List; //import java.util.List;
//
/** ///**
* 谐波报告查询 // * 谐波报告查询
*/ // */
public interface ReportMapper { //public interface ReportMapper {
/** // /**
* 获取电流有效值 // * 获取电流有效值
* @return // * @return
*/ // */
List<ReportValue> getVirtualDataI(@Param("param") ReportQueryParam param); // List<ReportValue> getVirtualDataI(@Param("param") ReportQueryParam param);
//
/** // /**
* 获取电压有效值 // * 获取电压有效值
* @return // * @return
*/ // */
List<ReportValue> getVirtualDataV(@Param("param") ReportQueryParam param); // List<ReportValue> getVirtualDataV(@Param("param") ReportQueryParam param);
//
/** // /**
* CP95条数 // * CP95条数
* @param param // * @param param
* @return // * @return
*/ // */
Integer getTotalCP95Day(@Param("param")ReportQueryParam param); // Integer getTotalCP95Day(@Param("param")ReportQueryParam param);
/** // /**
* CP95条数 // * CP95条数
* @param param // * @param param
* @return // * @return
*/ // */
Integer getTotalPltCP95Day(@Param("param")ReportQueryParam param); // Integer getTotalPltCP95Day(@Param("param")ReportQueryParam param);
/** // /**
* CP95条数 // * CP95条数
* @param param // * @param param
* @return // * @return
*/ // */
Integer getTotalPstCP95Day(@Param("param")ReportQueryParam param); // Integer getTotalPstCP95Day(@Param("param")ReportQueryParam param);
//
//
List<ReportValue> getVVirtualData(@Param("param")ReportQueryParam param); // List<ReportValue> getVVirtualData(@Param("param")ReportQueryParam param);
//
/** // /**
* 获取有功功率 // * 获取有功功率
* @param param // * @param param
* @return // * @return
*/ // */
List<ReportValue> getPowerP(@Param("param")ReportQueryParam param); // List<ReportValue> getPowerP(@Param("param")ReportQueryParam param);
//
/** // /**
* 无功功率 // * 无功功率
* @param param // * @param param
* @return // * @return
*/ // */
List<ReportValue> getPowerQ(@Param("param")ReportQueryParam param); // List<ReportValue> getPowerQ(@Param("param")ReportQueryParam param);
//
/** // /**
* 视在功率 // * 视在功率
* @param param // * @param param
* @return // * @return
*/ // */
List<ReportValue> getPowerS(@Param("param")ReportQueryParam param); // List<ReportValue> getPowerS(@Param("param")ReportQueryParam param);
//
/** // /**
* 功率因数 // * 功率因数
* @param param // * @param param
* @return // * @return
*/ // */
List<ReportValue> getPF(@Param("param")ReportQueryParam param); // List<ReportValue> getPF(@Param("param")ReportQueryParam param);
//
/** // /**
* 短时闪变 // * 短时闪变
* @param param // * @param param
* @return // * @return
*/ // */
List<ReportValue> getFlickerData(@Param("param")ReportQueryParam param); // List<ReportValue> getFlickerData(@Param("param")ReportQueryParam param);
//
/** // /**
* 长时闪变 // * 长时闪变
* @param param // * @param param
* @return // * @return
*/ // */
List<ReportValue> getLFlickerData(@Param("param")ReportQueryParam param); // List<ReportValue> getLFlickerData(@Param("param")ReportQueryParam param);
//
/** // /**
* 电压负偏差 // * 电压负偏差
* @param param // * @param param
* @return // * @return
*/ // */
List<ReportValue> getUVdeviationData(@Param("param")ReportQueryParam param); // List<ReportValue> getUVdeviationData(@Param("param")ReportQueryParam param);
//
/** // /**
* 电压正偏差 // * 电压正偏差
* @param param // * @param param
* @return // * @return
*/ // */
List<ReportValue> getLVdeviationData(@Param("param")ReportQueryParam param); // List<ReportValue> getLVdeviationData(@Param("param")ReportQueryParam param);
//
/** // /**
* 获取电压畸变率 // * 获取电压畸变率
* @param param // * @param param
* @return // * @return
*/ // */
List<ReportValue> getDistortionDataV(@Param("param")ReportQueryParam param); // List<ReportValue> getDistortionDataV(@Param("param")ReportQueryParam param);
//
/** // /**
* 获取电流畸变率 // * 获取电流畸变率
* @param param // * @param param
* @return // * @return
*/ // */
List<ReportValue> getDistortionDataI(@Param("param")ReportQueryParam param); // List<ReportValue> getDistortionDataI(@Param("param")ReportQueryParam param);
//
/** // /**
*频率 // *频率
* @param param // * @param param
* @return // * @return
*/ // */
List<ReportValue> getFrequencyData(@Param("param")ReportQueryParam param); // List<ReportValue> getFrequencyData(@Param("param")ReportQueryParam param);
//
/** // /**
*频率 // *频率
* @param param // * @param param
* @return // * @return
*/ // */
List<ReportValue> getDEVFrequencyData(@Param("param")ReportQueryParam param); // List<ReportValue> getDEVFrequencyData(@Param("param")ReportQueryParam param);
//
/** // /**
* 负序电流 // * 负序电流
* @param param // * @param param
* @return // * @return
*/ // */
List<ReportValue> getINegData(@Param("param")ReportQueryParam param); // List<ReportValue> getINegData(@Param("param")ReportQueryParam param);
} //}

View File

@@ -2,6 +2,7 @@ package com.njcn.csharmonic.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.csharmonic.param.CldWarnParam;
import com.njcn.csharmonic.param.CsEventUserQueryPage; import com.njcn.csharmonic.param.CsEventUserQueryPage;
import com.njcn.csharmonic.param.CsEventUserQueryParam; import com.njcn.csharmonic.param.CsEventUserQueryParam;
import com.njcn.csharmonic.pojo.po.CsEventPO; import com.njcn.csharmonic.pojo.po.CsEventPO;
@@ -32,5 +33,5 @@ public interface CsEventUserPOService extends IService<CsEventUserPO>{
Page<EventDetailVO> queryEventPageWeb(CsEventUserQueryPage csEventUserQueryPage); Page<EventDetailVO> queryEventPageWeb(CsEventUserQueryPage csEventUserQueryPage);
Page<CsEventPO> getFrontWarnInfo(BaseParam baseParam); Page<CsEventPO> getFrontWarnInfo(CldWarnParam baseParam);
} }

View File

@@ -1,12 +1,12 @@
package com.njcn.csharmonic.service; package com.njcn.csharmonic.service;
import com.njcn.csharmonic.param.SensitiveUserReportQueryParam; import com.njcn.csharmonic.param.SensitiveUserReportQueryParam;
import com.njcn.csharmonic.pojo.param.ReportSearchParam;
import com.njcn.csharmonic.pojo.param.ReportTemplateParam; import com.njcn.csharmonic.pojo.param.ReportTemplateParam;
import com.njcn.csharmonic.pojo.po.ExcelRptTemp;
import com.njcn.csharmonic.pojo.vo.ReportTemplateVO;
import com.njcn.csharmonic.pojo.vo.ReportTreeVO; import com.njcn.csharmonic.pojo.vo.ReportTreeVO;
import com.njcn.csharmonic.pojo.vo.SysDeptTempVO; import com.njcn.csharmonic.pojo.vo.SysDeptTempVO;
import com.njcn.harmonic.common.pojo.vo.ReportTemplateVO;
import com.njcn.harmonic.pojo.param.ReportSearchParam;
import com.njcn.harmonic.pojo.po.ExcelRptTemp;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;

View File

@@ -0,0 +1,24 @@
package com.njcn.csharmonic.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.harmonic.common.pojo.vo.ReportTemplateVO;
import com.njcn.harmonic.pojo.param.excel.ExcelParam;
import com.njcn.harmonic.pojo.po.excel.SysExcelRelation;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author xy
* @since 2026-01-27
*/
public interface ICsSysExcelRelationService extends IService<SysExcelRelation> {
List<ReportTemplateVO> queryList(String id);
Boolean bandRelation(ExcelParam.ListExcelParam param);
}

View File

@@ -1,7 +1,8 @@
package com.njcn.csharmonic.service.event; package com.njcn.csharmonic.service.event;
import cn.hutool.extra.template.TemplateException; import cn.hutool.extra.template.TemplateException;
import com.njcn.csharmonic.pojo.param.eventReport.ExportParam; import com.njcn.event.common.pojo.dto.LineDetailDataCommDTO;
import com.njcn.event.pojo.param.ExportParam;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@@ -14,7 +15,7 @@ import java.text.ParseException;
* @author cdf * @author cdf
* @date 2025/12/6 * @date 2025/12/6
*/ */
public interface EventMonitorReportService { public interface CsEventMonitorReportService {
void getLineExport(ExportParam exportParam, HttpServletResponse response) throws InvalidFormatException, IOException, TemplateException, ParseException; void getLineExport(ExportParam exportParam, HttpServletResponse response) throws InvalidFormatException, IOException, TemplateException, ParseException;

View File

@@ -1,15 +1,12 @@
package com.njcn.csharmonic.service.event; package com.njcn.csharmonic.service.event;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csharmonic.pojo.param.EventStatisticParam; import com.njcn.csharmonic.pojo.param.EventStatisticParam;
import com.njcn.csharmonic.pojo.vo.event.EventCoordsVO; import com.njcn.csharmonic.pojo.vo.event.EventCoordsVO;
import com.njcn.csharmonic.pojo.vo.event.EventStatisticVO; import com.njcn.csharmonic.pojo.vo.event.EventStatisticVO;
import com.njcn.csharmonic.pojo.vo.event.F47Curve; import com.njcn.csharmonic.pojo.vo.event.F47Curve;
import com.njcn.web.pojo.param.BaseParam;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @Author: cdf * @Author: cdf
@@ -28,4 +25,6 @@ public interface EventOverviewService {
List<EventStatisticVO> getEventDate(EventStatisticParam baseParam); List<EventStatisticVO> getEventDate(EventStatisticParam baseParam);
EventCoordsVO getEventCoords(EventStatisticParam baseParam); EventCoordsVO getEventCoords(EventStatisticParam baseParam);
List<Map<String,Object>> getEventDirectionData(EventStatisticParam baseParam);
} }

View File

@@ -1,80 +1,80 @@
package com.njcn.csharmonic.service.event; //package com.njcn.csharmonic.service.event;
//
import com.njcn.csharmonic.pojo.dto.eventReport.EventDetail; //import com.njcn.csharmonic.pojo.dto.eventReport.EventDetail;
import com.njcn.csharmonic.pojo.param.eventReport.StatisticsParam; //import com.njcn.csharmonic.pojo.param.eventReport.StatisticsParam;
import com.njcn.csharmonic.pojo.vo.eventReport.*; //import com.njcn.csharmonic.pojo.vo.eventReport.*;
//
import com.njcn.system.pojo.po.DictData; //import com.njcn.system.pojo.po.DictData;
//
import java.text.ParseException; //import java.text.ParseException;
import java.util.List; //import java.util.List;
//
/** ///**
* <监测点报表> // * <监测点报表>
* // *
* @author wr // * @author wr
* @createTime: 2023-02-10 // * @createTime: 2023-02-10
*/ // */
public interface EventReportService { //public interface EventReportService {
//
/** // /**
*获取Disdip表格监测点报表专用 // *获取Disdip表格监测点报表专用
* @param info influxdb查询结果pqs_eventdetail表 // * @param info influxdb查询结果pqs_eventdetail表
* @return // * @return
*/ // */
List<DISDIPVO> eventDisdip(List<EventDetail> info); // List<DISDIPVO> eventDisdip(List<EventDetail> info);
//
/** // /**
* 获取IEC411数据 // * 获取IEC411数据
* @param info influxdb查询结果pqs_eventdetail表 // * @param info influxdb查询结果pqs_eventdetail表
* @return // * @return
*/ // */
List<IEC411VO> IEC411(List<EventDetail> info); // List<IEC411VO> IEC411(List<EventDetail> info);
//
/** // /**
* 获取IEC28数据 // * 获取IEC28数据
* @param info influxdb查询结果pqs_eventdetail表 // * @param info influxdb查询结果pqs_eventdetail表
* @return // * @return
*/ // */
List<IEC28VO> IEC28(List<EventDetail> info); // List<IEC28VO> IEC28(List<EventDetail> info);
//
/** // /**
*暂降幅值概率分布 // *暂降幅值概率分布
* @param info2 influxdb查询结果pqs_eventdetail表 // * @param info2 influxdb查询结果pqs_eventdetail表
* @return // * @return
*/ // */
ProbabilityVO getProbabilityDistribution(List<EventDetail> info2); // ProbabilityVO getProbabilityDistribution(List<EventDetail> info2);
//
//
/** // /**
* 获取点状表格数据2.1 // * 获取点状表格数据2.1
* @param info 结果集 // * @param info 结果集
* @param reasonData 暂降原因 // * @param reasonData 暂降原因
* @param typeData 暂降类型 // * @param typeData 暂降类型
* @return // * @return
*/ // */
List<EventDetail> getPlot(List<EventDetail> info, List<DictData> reasonData, List<DictData> typeData); // List<EventDetail> getPlot(List<EventDetail> info, List<DictData> reasonData, List<DictData> typeData);
//
/** // /**
* 获取详细数据对象 // * 获取详细数据对象
* @param info // * @param info
* @param reasonData // * @param reasonData
* @param typeData // * @param typeData
* @return // * @return
*/ // */
StatisticVO getStatistic(List<EventDetail> info,List<DictData> reasonData,List<DictData>typeData); // StatisticVO getStatistic(List<EventDetail> info,List<DictData> reasonData,List<DictData>typeData);
//
/** // /**
* 获取密度点图 // * 获取密度点图
* @param info // * @param info
* @return // * @return
*/ // */
Integer[][] getCoords(List<EventDetail> info); // Integer[][] getCoords(List<EventDetail> info);
//
/** // /**
* 获取时间列表 // * 获取时间列表
* @param statisticsParam // * @param statisticsParam
* @return // * @return
*/ // */
List<TimeVO> getReasonTypeTime(StatisticsParam statisticsParam) throws ParseException; // List<TimeVO> getReasonTypeTime(StatisticsParam statisticsParam) throws ParseException;
} //}

View File

@@ -0,0 +1,15 @@
//package com.njcn.csharmonic.service.event;
//
//import com.baomidou.mybatisplus.extension.service.IService;
//import com.njcn.csharmonic.pojo.po.RmpEventDetailPO;
//
///**
// * 暂态事件明细
// *
// * @author yzh
// * @date 2022/10/12
// */
//
//public interface RmpEventDetailService extends IService<RmpEventDetailPO> {
//
//}

View File

@@ -9,12 +9,14 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.ZipUtil; import cn.hutool.core.util.ZipUtil;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.common.pojo.exception.BusinessException; import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.csdevice.api.CsLedgerFeignClient; import com.njcn.csdevice.api.CsLedgerFeignClient;
import com.njcn.csdevice.api.CsLineFeignClient; import com.njcn.csdevice.api.CsLineFeignClient;
import com.njcn.csdevice.api.EquipmentFeignClient;
import com.njcn.csdevice.enums.AlgorithmResponseEnum; import com.njcn.csdevice.enums.AlgorithmResponseEnum;
import com.njcn.csdevice.pojo.dto.DevDetailDTO; import com.njcn.csdevice.pojo.dto.DevDetailDTO;
import com.njcn.csdevice.pojo.po.CsLinePO; import com.njcn.csdevice.pojo.po.CsLinePO;
@@ -34,12 +36,14 @@ import com.njcn.csharmonic.pojo.vo.EventDetailVO;
import com.njcn.csharmonic.pojo.vo.EventStatisticsVo; import com.njcn.csharmonic.pojo.vo.EventStatisticsVo;
import com.njcn.csharmonic.service.CsEventPOService; import com.njcn.csharmonic.service.CsEventPOService;
import com.njcn.csharmonic.service.CsEventUserPOService; import com.njcn.csharmonic.service.CsEventUserPOService;
import com.njcn.event.common.mapper.WlRmpEventDetailMapper;
import com.njcn.event.file.component.WaveFileComponent; import com.njcn.event.file.component.WaveFileComponent;
import com.njcn.event.file.component.WavePicComponent; import com.njcn.event.file.component.WavePicComponent;
import com.njcn.event.file.pojo.bo.WaveDataDetail; import com.njcn.event.file.pojo.bo.WaveDataDetail;
import com.njcn.event.file.pojo.dto.WaveDataDTO; import com.njcn.event.file.pojo.dto.WaveDataDTO;
import com.njcn.event.file.pojo.enums.WaveFileResponseEnum; import com.njcn.event.file.pojo.enums.WaveFileResponseEnum;
import com.njcn.event.file.utils.WaveUtil; import com.njcn.event.file.utils.WaveUtil;
import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.influx.pojo.constant.InfluxDBTableConstant; import com.njcn.influx.pojo.constant.InfluxDBTableConstant;
import com.njcn.influx.pojo.dto.EventDataSetDTO; import com.njcn.influx.pojo.dto.EventDataSetDTO;
import com.njcn.influx.service.EvtDataService; import com.njcn.influx.service.EvtDataService;
@@ -48,8 +52,11 @@ import com.njcn.minioss.config.MinIossProperties;
import com.njcn.minioss.util.MinIoUtils; import com.njcn.minioss.util.MinIoUtils;
import com.njcn.oss.constant.GeneralConstant; import com.njcn.oss.constant.GeneralConstant;
import com.njcn.oss.utils.FileStorageUtil; import com.njcn.oss.utils.FileStorageUtil;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.api.EleEvtFeignClient; import com.njcn.system.api.EleEvtFeignClient;
import com.njcn.system.api.EpdFeignClient; import com.njcn.system.api.EpdFeignClient;
import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.pojo.po.DictData;
import com.njcn.system.pojo.po.EleEpdPqd; import com.njcn.system.pojo.po.EleEpdPqd;
import com.njcn.system.pojo.po.EleEvtParm; import com.njcn.system.pojo.po.EleEvtParm;
import com.njcn.web.factory.PageFactory; import com.njcn.web.factory.PageFactory;
@@ -107,6 +114,10 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
private final MinIossProperties minIossProperties; private final MinIossProperties minIossProperties;
private final InfluxDbUtils influxDbUtils; private final InfluxDbUtils influxDbUtils;
private final MinIoUtils minIoUtils; private final MinIoUtils minIoUtils;
private final DicDataFeignClient dicDataFeignClient;
private final WlRmpEventDetailMapper wlRmpEventDetailMapper;
//private final CommonEventWaveAnalysisService commonEventWaveAnalysisService;
private final EquipmentFeignClient equipmentFeignClient;
@Override @Override
public List<EventDetailVO> queryEventList(CsEventUserQueryParam csEventUserQueryParam) { public List<EventDetailVO> queryEventList(CsEventUserQueryParam csEventUserQueryParam) {
@@ -328,7 +339,7 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
} }
@Override @Override
@Transactional(rollbackFor = Exception.class) @DSTransactional
public void addCldEvent(CldEventParam param) { public void addCldEvent(CldEventParam param) {
//校验是新增时间还是更新文件信息 //校验是新增时间还是更新文件信息
LambdaQueryWrapper<CsEventPO> lambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsEventPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
@@ -368,6 +379,8 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
if (CollectionUtil.isNotEmpty(records)) { if (CollectionUtil.isNotEmpty(records)) {
influxDbUtils.batchInsert(influxDbUtils.getDbName(), "", InfluxDB.ConsistencyLevel.ALL, TimeUnit.MILLISECONDS, records); influxDbUtils.batchInsert(influxDbUtils.getDbName(), "", InfluxDB.ConsistencyLevel.ALL, TimeUnit.MILLISECONDS, records);
} }
//同步数据到 r_mp_event_detail
insertEvent(uuid, param, time);
} else { } else {
if (StrUtil.isNotBlank(param.getWavePath())) { if (StrUtil.isNotBlank(param.getWavePath())) {
//更新文件信息 //更新文件信息
@@ -377,10 +390,43 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
.eq(CsEventPO::getStartTime,param.getStartTime()) .eq(CsEventPO::getStartTime,param.getStartTime())
.set(CsEventPO::getWavePath,param.getWavePath()) .set(CsEventPO::getWavePath,param.getWavePath())
.update(); .update();
//更新文件信息
updateEvent(param);
} }
} }
} }
public void insertEvent(String uuid, CldEventParam param, LocalDateTime time) {
RmpEventDetailPO rmpEventDetailPO = new RmpEventDetailPO();
rmpEventDetailPO.setEventId(uuid);
rmpEventDetailPO.setMeasurementPointId(param.getMonitorId());
rmpEventDetailPO.setStartTime(time);
rmpEventDetailPO.setEventType(getEventType(param.getEventType()));
rmpEventDetailPO.setFeatureAmplitude(param.getAmplitude() * 100);
rmpEventDetailPO.setDuration(param.getDuration());
rmpEventDetailPO.setEventDescribe(getTag(param.getEventType()));
rmpEventDetailPO.setPhase(param.getPhase());
rmpEventDetailPO.setDealFlag(0);
wlRmpEventDetailMapper.insert(rmpEventDetailPO);
}
public void updateEvent(CldEventParam param) {
LambdaQueryWrapper<RmpEventDetailPO> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(RmpEventDetailPO::getMeasurementPointId,param.getMonitorId()).eq(RmpEventDetailPO::getStartTime,param.getStartTime());
RmpEventDetailPO po = wlRmpEventDetailMapper.selectOne(wrapper);
po.setWavePath(param.getWavePath());
po.setFileFlag(1);
//根据事件获取暂态类型、暂态原因、暂态发生位置
//String ip = equipmentFeignClient.getDevByLineId(param.getMonitorId()).getData().getMac();
//EntityAdvancedData advancedData = commonEventWaveAnalysisService.analysis(po,ip);
//po.setAdvanceReason(advancedData.getSagReason()[0]);
//po.setAdvanceType(advancedData.getSagType()[0]);
wlRmpEventDetailMapper.updateById(po);
}
@Override @Override
public List<CsEventPO> getEventByTime(List<String> lineList, String startTime, String endTime) { public List<CsEventPO> getEventByTime(List<String> lineList, String startTime, String endTime) {
LambdaQueryWrapper<CsEventPO> lambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsEventPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
@@ -414,7 +460,15 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
csWarnDescVOList = this.baseMapper.getEventDesc(lineIdList,60); csWarnDescVOList = this.baseMapper.getEventDesc(lineIdList,60);
// 处理下描述 // 处理下描述
for (CsWarnDescVO csWarnDescVO : csWarnDescVOList) { for (CsWarnDescVO csWarnDescVO : csWarnDescVOList) {
csWarnDescVO.setEventDesc("电压暂态事件,持续时间"+csWarnDescVO.getPersistTime()+"秒,电压降至"+csWarnDescVO.getAmplitude()+"%。"); String desc;
if(csWarnDescVO.getAmplitude() <= 90) {
desc = "降至";
} else if (csWarnDescVO.getAmplitude() >= 110) {
desc = "升至";
} else {
desc = "维持";
}
csWarnDescVO.setEventDesc("电压暂态事件,持续时间"+csWarnDescVO.getPersistTime()+"秒,电压"+desc+csWarnDescVO.getAmplitude()+"%。");
} }
return csWarnDescVOList; return csWarnDescVOList;
} }
@@ -441,7 +495,27 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
return tag; return tag;
} }
public String getEventType(Integer type) {
String tag;
switch (type) {
case 1:
DictData dip = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_DIP.getCode()).getData();
tag = dip.getId();
break;
case 2:
DictData rise = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_RISE.getCode()).getData();
tag = rise.getId();
break;
case 3:
DictData interruptions = dicDataFeignClient.getDicDataByCode(DicDataEnum.SHORT_INTERRUPTIONS.getCode()).getData();
tag = interruptions.getId();
break;
default:
tag = "Un_Know";
break;
}
return tag;
}
/** /**

View File

@@ -18,6 +18,7 @@ import com.njcn.csdevice.pojo.po.Node;
import com.njcn.csdevice.pojo.vo.CsLedgerVO; import com.njcn.csdevice.pojo.vo.CsLedgerVO;
import com.njcn.csharmonic.mapper.CsEventPOMapper; import com.njcn.csharmonic.mapper.CsEventPOMapper;
import com.njcn.csharmonic.mapper.CsEventUserPOMapper; import com.njcn.csharmonic.mapper.CsEventUserPOMapper;
import com.njcn.csharmonic.param.CldWarnParam;
import com.njcn.csharmonic.param.CsEventUserQueryPage; import com.njcn.csharmonic.param.CsEventUserQueryPage;
import com.njcn.csharmonic.param.CsEventUserQueryParam; import com.njcn.csharmonic.param.CsEventUserQueryParam;
import com.njcn.csharmonic.pojo.po.CsEventPO; import com.njcn.csharmonic.pojo.po.CsEventPO;
@@ -32,7 +33,6 @@ import com.njcn.system.api.EpdFeignClient;
import com.njcn.system.pojo.po.EleEpdPqd; import com.njcn.system.pojo.po.EleEpdPqd;
import com.njcn.system.pojo.po.EleEvtParm; import com.njcn.system.pojo.po.EleEvtParm;
import com.njcn.user.enums.AppRoleEnum; import com.njcn.user.enums.AppRoleEnum;
import com.njcn.web.pojo.param.BaseParam;
import com.njcn.web.utils.RequestUtil; import com.njcn.web.utils.RequestUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
@@ -392,40 +392,43 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
if(!CollectionUtils.isEmpty(cldDevTree)){ if(!CollectionUtils.isEmpty(cldDevTree)){
cldDevTree = cldDevTree.get(0).getChildren(); cldDevTree = cldDevTree.get(0).getChildren();
} }
if (ObjectUtil.isNull(csEventUserQueryPage.getDeviceId()) || StringUtils.isEmpty(csEventUserQueryPage.getDeviceId())) {
//便携式就1层下边就是设备
List<String> portableDevIds = portableDevTree.stream().filter(
temp -> StringUtils.isEmpty(csEventUserQueryPage.getDeviceId()) ||
Objects.equals(temp.getId(), csEventUserQueryPage.getDeviceId())
).map(CsLedgerVO::getId).collect(Collectors.toList());
List<String> governmentDevIds = governmentDevTree.stream().filter(temp->StringUtils.isEmpty(csEventUserQueryPage.getEngineeringid())||
Objects.equals(temp.getId(), csEventUserQueryPage.getEngineeringid()))
.map(CsLedgerVO::getChildren).flatMap(Collection::stream).filter(
temp->StringUtils.isEmpty(csEventUserQueryPage.getProjectId())||
Objects.equals(temp.getId(), csEventUserQueryPage.getProjectId())
).
map(CsLedgerVO::getChildren).flatMap(Collection::stream).filter(
temp->StringUtils.isEmpty(csEventUserQueryPage.getDeviceId())||
Objects.equals(temp.getId(), csEventUserQueryPage.getDeviceId())
).
map(CsLedgerVO::getId).
collect(Collectors.toList());
List<String> cldDevIds = cldDevTree.stream().filter(temp->StringUtils.isEmpty(csEventUserQueryPage.getEngineeringid())||
Objects.equals(temp.getId(), csEventUserQueryPage.getEngineeringid()))
.map(CsLedgerVO::getChildren).flatMap(Collection::stream).filter(
temp->StringUtils.isEmpty(csEventUserQueryPage.getProjectId())||
Objects.equals(temp.getId(), csEventUserQueryPage.getProjectId())
).
map(CsLedgerVO::getChildren).flatMap(Collection::stream).filter(
temp->StringUtils.isEmpty(csEventUserQueryPage.getDeviceId())||
Objects.equals(temp.getId(), csEventUserQueryPage.getDeviceId())
).
map(CsLedgerVO::getId).
collect(Collectors.toList());
//便携式就1层下边就是设备 devIds.addAll(portableDevIds);
List<String> portableDevIds = portableDevTree.stream().filter( devIds.addAll(governmentDevIds);
temp -> StringUtils.isEmpty(csEventUserQueryPage.getDeviceId()) || devIds.addAll(cldDevIds);
Objects.equals(temp.getId(), csEventUserQueryPage.getDeviceId()) } else {
).map(CsLedgerVO::getId).collect(Collectors.toList()); devIds.add(csEventUserQueryPage.getDeviceId());
List<String> governmentDevIds = governmentDevTree.stream().filter(temp->StringUtils.isEmpty(csEventUserQueryPage.getEngineeringid())|| }
Objects.equals(temp.getId(), csEventUserQueryPage.getEngineeringid()))
.map(CsLedgerVO::getChildren).flatMap(Collection::stream).filter(
temp->StringUtils.isEmpty(csEventUserQueryPage.getProjectId())||
Objects.equals(temp.getId(), csEventUserQueryPage.getProjectId())
).
map(CsLedgerVO::getChildren).flatMap(Collection::stream).filter(
temp->StringUtils.isEmpty(csEventUserQueryPage.getDeviceId())||
Objects.equals(temp.getId(), csEventUserQueryPage.getDeviceId())
).
map(CsLedgerVO::getId).
collect(Collectors.toList());
List<String> cldDevIds = cldDevTree.stream().filter(temp->StringUtils.isEmpty(csEventUserQueryPage.getEngineeringid())||
Objects.equals(temp.getId(), csEventUserQueryPage.getEngineeringid()))
.map(CsLedgerVO::getChildren).flatMap(Collection::stream).filter(
temp->StringUtils.isEmpty(csEventUserQueryPage.getProjectId())||
Objects.equals(temp.getId(), csEventUserQueryPage.getProjectId())
).
map(CsLedgerVO::getChildren).flatMap(Collection::stream).filter(
temp->StringUtils.isEmpty(csEventUserQueryPage.getDeviceId())||
Objects.equals(temp.getId(), csEventUserQueryPage.getDeviceId())
).
map(CsLedgerVO::getId).
collect(Collectors.toList());
devIds.addAll(portableDevIds);
devIds.addAll(governmentDevIds);
devIds.addAll(cldDevIds);
if (CollectionUtils.isEmpty(devIds)){ if (CollectionUtils.isEmpty(devIds)){
return returnpage; return returnpage;
@@ -515,7 +518,7 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
} }
@Override @Override
public Page<CsEventPO> getFrontWarnInfo(BaseParam baseParam) { public Page<CsEventPO> getFrontWarnInfo(CldWarnParam baseParam) {
Page<CsEventPO> page = new Page<>(baseParam.getPageNum(), baseParam.getPageSize()); Page<CsEventPO> page = new Page<>(baseParam.getPageNum(), baseParam.getPageSize());
List<Node> nodeList = nodeFeignClient.nodeAllList().getData(); List<Node> nodeList = nodeFeignClient.nodeAllList().getData();
Map<String, Node> nodeMap = nodeList.stream().collect(Collectors.toMap(Node::getId, Function.identity())); Map<String, Node> nodeMap = nodeList.stream().collect(Collectors.toMap(Node::getId, Function.identity()));
@@ -533,6 +536,14 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
DateUtil.endOfDay(DateUtil.parse(baseParam.getSearchEndTime())).toString()) DateUtil.endOfDay(DateUtil.parse(baseParam.getSearchEndTime())).toString())
.eq(CsEventPO::getType, 4) .eq(CsEventPO::getType, 4)
.orderByDesc(CsEventPO::getStartTime); .orderByDesc(CsEventPO::getStartTime);
if (ObjectUtil.isNotNull(baseParam.getLevel()) && StringUtil.isNotBlank(baseParam.getLevel())) {
List<Integer> levelList = Arrays.stream(baseParam.getLevel().split(","))
.map(String::trim)
.filter(s -> !s.isEmpty())
.map(Integer::parseInt)
.collect(Collectors.toList());
queryWrapper.in(CsEventPO::getLevel, levelList);
}
page = csEventPOMapper.selectPage(page, queryWrapper); page = csEventPOMapper.selectPage(page, queryWrapper);
} }
} }

View File

@@ -0,0 +1,50 @@
package com.njcn.csharmonic.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.csharmonic.service.ICsSysExcelRelationService;
import com.njcn.harmonic.common.mapper.ExcelRptTempMapper;
import com.njcn.harmonic.common.mapper.SysExcelRelationMapper;
import com.njcn.harmonic.common.pojo.vo.ReportTemplateVO;
import com.njcn.harmonic.common.pojo.vo.SysExcelRelationVO;
import com.njcn.harmonic.common.service.ISysExcelRelationService;
import com.njcn.harmonic.pojo.param.excel.ExcelParam;
import com.njcn.harmonic.pojo.po.excel.SysExcelRelation;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author xy
* @since 2026-01-27
*/
@Service
@RequiredArgsConstructor
@DS("sjzx")
public class CsSysExcelRelationServiceImpl extends ServiceImpl<SysExcelRelationMapper, SysExcelRelation> implements ICsSysExcelRelationService {
private final ISysExcelRelationService sysExcelRelationService;
private final ExcelRptTempMapper excelRptTempMapper;
@Override
public List<ReportTemplateVO> queryList(String id) {
List<ReportTemplateVO> result = new ArrayList<>();
SysExcelRelationVO sysExcelRelationVO = sysExcelRelationService.getRelation(id);
if (CollectionUtil.isNotEmpty(sysExcelRelationVO.getRelationIds())) {
result = excelRptTempMapper.getReportTemplateByIds(sysExcelRelationVO.getRelationIds());
}
return result;
}
@Override
public Boolean bandRelation(ExcelParam.ListExcelParam param) {
return sysExcelRelationService.bandRelation(param);
}
}

View File

@@ -1,5 +1,6 @@
package com.njcn.csharmonic.service.impl; package com.njcn.csharmonic.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.LocalDateTimeUtil; import cn.hutool.core.date.LocalDateTimeUtil;
@@ -15,6 +16,7 @@ import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.toolkit.SqlRunner; import com.baomidou.mybatisplus.extension.toolkit.SqlRunner;
import com.njcn.common.pojo.enums.common.DataStateEnum; import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.utils.FileUtil; import com.njcn.common.utils.FileUtil;
import com.njcn.csdevice.api.CsCommTerminalFeignClient; import com.njcn.csdevice.api.CsCommTerminalFeignClient;
@@ -23,20 +25,23 @@ import com.njcn.csdevice.api.WlRecordFeignClient;
import com.njcn.csdevice.pojo.po.CsLinePO; import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csdevice.pojo.po.WlRecord; import com.njcn.csdevice.pojo.po.WlRecord;
import com.njcn.csharmonic.enums.CsHarmonicResponseEnum; import com.njcn.csharmonic.enums.CsHarmonicResponseEnum;
import com.njcn.csharmonic.mapper.ExcelRptTempMapper;
import com.njcn.csharmonic.param.SensitiveUserReportQueryParam; import com.njcn.csharmonic.param.SensitiveUserReportQueryParam;
import com.njcn.csharmonic.pojo.dto.ReportTemplateDTO; import com.njcn.csharmonic.pojo.dto.ReportTemplateDTO;
import com.njcn.csharmonic.pojo.param.ReportSearchParam;
import com.njcn.csharmonic.pojo.param.ReportTemplateParam; import com.njcn.csharmonic.pojo.param.ReportTemplateParam;
import com.njcn.csharmonic.pojo.po.ExcelRptTemp;
import com.njcn.csharmonic.pojo.vo.ReportTemplateDataVO; import com.njcn.csharmonic.pojo.vo.ReportTemplateDataVO;
import com.njcn.csharmonic.pojo.vo.ReportTemplateVO;
import com.njcn.csharmonic.pojo.vo.ReportTreeVO; import com.njcn.csharmonic.pojo.vo.ReportTreeVO;
import com.njcn.csharmonic.pojo.vo.SysDeptTempVO; import com.njcn.csharmonic.pojo.vo.SysDeptTempVO;
import com.njcn.csharmonic.service.CustomReportService; import com.njcn.csharmonic.service.CustomReportService;
import com.njcn.csharmonic.service.ICsSysExcelRelationService;
import com.njcn.csharmonic.utils.DataChangeUtil; import com.njcn.csharmonic.utils.DataChangeUtil;
import com.njcn.device.biz.commApi.CommTerminalGeneralClient; import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
import com.njcn.device.biz.pojo.po.PqsDeviceUnit; import com.njcn.device.biz.pojo.po.PqsDeviceUnit;
import com.njcn.harmonic.common.mapper.ExcelRptTempMapper;
import com.njcn.harmonic.common.pojo.dto.DeviceUnitCommDTO;
import com.njcn.harmonic.common.pojo.vo.ReportTemplateVO;
import com.njcn.harmonic.common.service.CustomReportTableService;
import com.njcn.harmonic.pojo.param.ReportSearchParam;
import com.njcn.harmonic.pojo.po.ExcelRptTemp;
import com.njcn.influx.constant.InfluxDbSqlConstant; import com.njcn.influx.constant.InfluxDbSqlConstant;
import com.njcn.influx.pojo.constant.InfluxDBTableConstant; import com.njcn.influx.pojo.constant.InfluxDBTableConstant;
import com.njcn.influx.utils.InfluxDbUtils; import com.njcn.influx.utils.InfluxDbUtils;
@@ -103,9 +108,12 @@ public class CustomReportServiceImpl implements CustomReportService {
private final CsCommTerminalFeignClient csCommTerminalFeignClient; private final CsCommTerminalFeignClient csCommTerminalFeignClient;
private final CustomReportTableService customReportTableService;
private final WlRecordFeignClient wlRecordFeignClient; private final WlRecordFeignClient wlRecordFeignClient;
private final UserFeignClient userFeignClient; private final UserFeignClient userFeignClient;
private final CsLineFeignClient csLineFeignClient; private final CsLineFeignClient csLineFeignClient;
private final ICsSysExcelRelationService sysExcelService;
private final ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() + 1); private final ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() + 1);
private final JdbcTemplate jdbcTemplate; private final JdbcTemplate jdbcTemplate;
@@ -118,14 +126,24 @@ public class CustomReportServiceImpl implements CustomReportService {
private final String STR_FIVE = "~"; private final String STR_FIVE = "~";
private final String limitTable = "pq_overlimit"; private final String limitTable = "pq_overlimit";
private final String UVOLTAGE_DEV = "UVOLTAGE_DEV";
private final String VOLTAGE_DEV = "VOLTAGE_DEV";
private final String GRID_SIDE_DICT_CODE = "Grid_Side"; private final String GRID_SIDE_DICT_CODE = "Grid_Side";
private final String LOAD_SIDE_DICT_CODE = "Load_Side"; private final String LOAD_SIDE_DICT_CODE = "Load_Side";
private static final Map<String, String> PHASE_MAPPING = new HashMap<String, String>() {{
put("AB", "A");
put("BC", "B");
put("CA", "C");
put("M", "T");
}};
/** /**
* map key转大写 * map key转大写
*/ */
public static <V> Map<String, V> convertKeysToUpperCase(Map<String, V> originalMap) { public <V> Map<String, V> convertKeysToUpperCase(Map<String, V> originalMap) {
Map<String, V> newMap = new HashMap<>(); Map<String, V> newMap = new HashMap<>();
if (CollUtil.isNotEmpty(originalMap)) { if (CollUtil.isNotEmpty(originalMap)) {
for (Map.Entry<String, V> entry : originalMap.entrySet()) { for (Map.Entry<String, V> entry : originalMap.entrySet()) {
@@ -147,14 +165,27 @@ public class CustomReportServiceImpl implements CustomReportService {
@Override @Override
public void getCustomReport(ReportSearchParam reportSearchParam, HttpServletResponse response) { public void getCustomReport(ReportSearchParam reportSearchParam, HttpServletResponse response) {
//获取模板id
String tempId = getTempId(reportSearchParam.getTempId(), reportSearchParam.getLineId());
//修改模板id
reportSearchParam.setTempId(tempId);
//原代码
TimeInterval timeInterval = new TimeInterval(); TimeInterval timeInterval = new TimeInterval();
ExcelRptTemp excelRptTemp = excelRptTempMapper.selectById(reportSearchParam.getTempId()); //ExcelRptTemp excelRptTemp = excelRptTempMapper.selectById(reportSearchParam.getTempId());
ExcelRptTemp excelRptTemp = excelRptTempMapper.selectById(tempId);
if (Objects.isNull(excelRptTemp)) { if (Objects.isNull(excelRptTemp)) {
throw new BusinessException(CsHarmonicResponseEnum.CUSTOM_REPORT_ACTIVE); throw new BusinessException(CsHarmonicResponseEnum.CUSTOM_REPORT_ACTIVE);
} }
if (Objects.isNull(reportSearchParam.getCustomType())) { if (Objects.isNull(reportSearchParam.getCustomType())) {
//通用报表 //通用报表
analyzeReport(reportSearchParam, excelRptTemp, response); Map<String,String> map = csLineFeignClient.getCustomDetailByLineId(reportSearchParam.getLineId()).getData();
Map<String,String> newMap = convertKeysToUpperCase(map);
PqsDeviceUnit deviceUnit = csCommTerminalFeignClient.lineUnitDetail(reportSearchParam.getLineId()).getData();
DeviceUnitCommDTO deviceUnitCommDTO = BeanUtil.copyProperties(deviceUnit, DeviceUnitCommDTO.class);
customReportTableService.getCustomReport(reportSearchParam,newMap,deviceUnitCommDTO,response);
} else { } else {
//浙江无线报表 //浙江无线报表
analyzeReportZhejiang(reportSearchParam, excelRptTemp, response); analyzeReportZhejiang(reportSearchParam, excelRptTemp, response);
@@ -247,18 +278,31 @@ public class CustomReportServiceImpl implements CustomReportService {
@Override @Override
public void getSensitiveUserReport(SensitiveUserReportQueryParam queryParam, HttpServletResponse response) { public void getSensitiveUserReport(SensitiveUserReportQueryParam queryParam, HttpServletResponse response) {
TimeInterval timeInterval = new TimeInterval();
ExcelRptTemp excelRptTemp = excelRptTempMapper.selectById(queryParam.getTempId());
if (Objects.isNull(excelRptTemp)) {
throw new BusinessException(CsHarmonicResponseEnum.CUSTOM_REPORT_ACTIVE);
}
String sensitiveUserId = queryParam.getSensitiveUserId(); String sensitiveUserId = queryParam.getSensitiveUserId();
List<CsLinePO> linePOList = csLineFeignClient.getLineBySensitiveUser(Collections.singletonList(sensitiveUserId)).getData(); List<CsLinePO> linePOList = csLineFeignClient.getLineBySensitiveUser(Collections.singletonList(sensitiveUserId)).getData();
DictData loadSideDictData = dicDataFeignClient.getDicDataByCode(LOAD_SIDE_DICT_CODE).getData(); DictData loadSideDictData = dicDataFeignClient.getDicDataByCode(LOAD_SIDE_DICT_CODE).getData();
DictData gridSideDictData = dicDataFeignClient.getDicDataByCode(GRID_SIDE_DICT_CODE).getData(); DictData gridSideDictData = dicDataFeignClient.getDicDataByCode(GRID_SIDE_DICT_CODE).getData();
CsLinePO gridSideLine = linePOList.stream().filter(linePO -> linePO.getPosition().equals(gridSideDictData.getId())).findFirst().orElse(null); CsLinePO gridSideLine = linePOList.stream().filter(linePO -> linePO.getPosition().equals(gridSideDictData.getId())).findFirst().orElse(null);
CsLinePO loadSideLine = linePOList.stream().filter(linePO -> linePO.getPosition().equals(loadSideDictData.getId())).findFirst().orElse(null); CsLinePO loadSideLine = linePOList.stream().filter(linePO -> linePO.getPosition().equals(loadSideDictData.getId())).findFirst().orElse(null);
String lineName = "";
String tempId = getTempId(queryParam.getTempId(), Objects.isNull(gridSideLine)? loadSideLine.getLineId():gridSideLine.getLineId());
queryParam.setTempId(tempId);
TimeInterval timeInterval = new TimeInterval();
// ExcelRptTemp excelRptTemp = excelRptTempMapper.selectById(queryParam.getTempId());
ExcelRptTemp excelRptTemp = excelRptTempMapper.selectById(tempId);
if (Objects.isNull(excelRptTemp)) {
throw new BusinessException(CsHarmonicResponseEnum.CUSTOM_REPORT_ACTIVE);
}
// String sensitiveUserId = queryParam.getSensitiveUserId();
// List<CsLinePO> linePOList = csLineFeignClient.getLineBySensitiveUser(Collections.singletonList(sensitiveUserId)).getData();
// DictData loadSideDictData = dicDataFeignClient.getDicDataByCode(LOAD_SIDE_DICT_CODE).getData();
// DictData gridSideDictData = dicDataFeignClient.getDicDataByCode(GRID_SIDE_DICT_CODE).getData();
// CsLinePO gridSideLine = linePOList.stream().filter(linePO -> linePO.getPosition().equals(gridSideDictData.getId())).findFirst().orElse(null);
// CsLinePO loadSideLine = linePOList.stream().filter(linePO -> linePO.getPosition().equals(loadSideDictData.getId())).findFirst().orElse(null);
String lineName1 = "";
String lineName2 = "";
// 模版内容数据 // 模版内容数据
JSONArray templateData; JSONArray templateData;
@@ -285,13 +329,13 @@ public class CustomReportServiceImpl implements CustomReportService {
Map<String, List<ReportTemplateDataVO>> classMap = indexDataList.stream().collect(Collectors.groupingBy(ReportTemplateDataVO::getResourceId)); Map<String, List<ReportTemplateDataVO>> classMap = indexDataList.stream().collect(Collectors.groupingBy(ReportTemplateDataVO::getResourceId));
//定义存放指标的map //定义存放指标的map
if (gridSideLine != null) { if (gridSideLine != null) {
lineName = gridSideLine.getName(); lineName2 = gridSideLine.getName();
List<ReportTemplateDataVO> afterDataList = fetchDataList(gridSideLine, classMap, queryParam); List<ReportTemplateDataVO> afterDataList = fetchDataList(gridSideLine, classMap, queryParam);
afterFinalDataList.addAll(afterDataList); afterFinalDataList.addAll(afterDataList);
} }
if (loadSideLine != null) { if (loadSideLine != null) {
lineName = loadSideLine.getName(); lineName1 = loadSideLine.getName();
List<ReportTemplateDataVO> beforeDataList = fetchDataList(loadSideLine, classMap, queryParam); List<ReportTemplateDataVO> beforeDataList = fetchDataList(loadSideLine, classMap, queryParam);
beforeFinalDataList.addAll(beforeDataList); beforeFinalDataList.addAll(beforeDataList);
} }
@@ -369,9 +413,13 @@ public class CustomReportServiceImpl implements CustomReportService {
} else if (v.charAt(0) == '&') { } else if (v.charAt(0) == '&') {
// 基础数据 // 基础数据
String baseItem = v.replace(STR_THREE, "").toUpperCase(); String baseItem = v.replace(STR_THREE, "").toUpperCase();
if (baseItem.startsWith("LINENAME")) { if (baseItem.startsWith("LINENAME1")) {
//台账信息 //台账信息
son.putOpt(V, baseItem.replace("LINENAME", lineName)); son.putOpt(V, baseItem.replace("LINENAME1", lineName1));
}
if (baseItem.startsWith("LINENAME2")) {
//台账信息
son.putOpt(V, baseItem.replace("LINENAME2", lineName2));
} }
} else if (v.contains("start_time") && v.contains("end_time")){ } else if (v.contains("start_time") && v.contains("end_time")){
//如时间是大于当前时间则用当前时间 //如时间是大于当前时间则用当前时间
@@ -839,7 +887,7 @@ public class CustomReportServiceImpl implements CustomReportService {
* @date 2023/10/20 * @date 2023/10/20
*/ */
private void assSqlByMysql(List<ReportTemplateDTO> data, StringBuilder sql, List<ReportTemplateDTO> endList, String method, ReportSearchParam reportSearchParam, Map<String, ReportTemplateDTO> limitMap, Map<String, Float> overLimitMap, Map<String, ReportTemplateDTO> assNoPassMap) { private void assSqlByMysql(List<ReportTemplateDTO> data, StringBuilder sql, List<ReportTemplateDTO> endList, String method, ReportSearchParam reportSearchParam, Map<String, ReportTemplateDTO> limitMap, Map<String, Float> overLimitMap, Map<String, ReportTemplateDTO> assNoPassMap,List<String> noPhaseList) {
//sql拼接示例select MAX(IHA2) as IHA2 from power_quality_data where Phase = 'A' and LineId='1324564568' and Stat_Method='max' tz('Asia/Shanghai') //sql拼接示例select MAX(IHA2) as IHA2 from power_quality_data where Phase = 'A' and LineId='1324564568' and Stat_Method='max' tz('Asia/Shanghai')
if (InfluxDbSqlConstant.CP95.equals(method)) { if (InfluxDbSqlConstant.CP95.equals(method)) {
for (int i = 0; i < data.size(); i++) { for (int i = 0; i < data.size(); i++) {
@@ -849,14 +897,14 @@ public class CustomReportServiceImpl implements CustomReportService {
.append(data.get(i).getTemplateName()) .append(data.get(i).getTemplateName())
.append(InfluxDbSqlConstant.RBK) .append(InfluxDbSqlConstant.RBK)
.append(InfluxDbSqlConstant.AS) .append(InfluxDbSqlConstant.AS)
.append("\"" + data.get(i).getItemName() + "\""); .append("\""+data.get(i).getItemName()+"\"");
} else { } else {
sql.append(InfluxDbSqlConstant.MAX) sql.append(InfluxDbSqlConstant.MAX)
.append(InfluxDbSqlConstant.LBK) .append(InfluxDbSqlConstant.LBK)
.append(data.get(i).getTemplateName()) .append(data.get(i).getTemplateName())
.append(InfluxDbSqlConstant.RBK) .append(InfluxDbSqlConstant.RBK)
.append(InfluxDbSqlConstant.AS) .append(InfluxDbSqlConstant.AS)
.append("\"" + data.get(i).getItemName() + "\"").append(StrUtil.COMMA); .append("\""+data.get(i).getItemName()+"\"").append(StrUtil.COMMA);
} }
} }
} else { } else {
@@ -867,14 +915,14 @@ public class CustomReportServiceImpl implements CustomReportService {
.append(data.get(i).getTemplateName()) .append(data.get(i).getTemplateName())
.append(InfluxDbSqlConstant.RBK) .append(InfluxDbSqlConstant.RBK)
.append(InfluxDbSqlConstant.AS) .append(InfluxDbSqlConstant.AS)
.append("\"" + data.get(i).getItemName() + "\""); .append("\""+data.get(i).getItemName()+"\"");
} else { } else {
sql.append(method) sql.append(method)
.append(InfluxDbSqlConstant.LBK) .append(InfluxDbSqlConstant.LBK)
.append(data.get(i).getTemplateName()) .append(data.get(i).getTemplateName())
.append(InfluxDbSqlConstant.RBK) .append(InfluxDbSqlConstant.RBK)
.append(InfluxDbSqlConstant.AS) .append(InfluxDbSqlConstant.AS)
.append("\"" + data.get(i).getItemName() + "\"").append(StrUtil.COMMA); .append("\""+data.get(i).getItemName()+"\"").append(StrUtil.COMMA);
} }
} }
@@ -911,7 +959,10 @@ public class CustomReportServiceImpl implements CustomReportService {
//频率和频率偏差仅统计T相 //频率和频率偏差仅统计T相
if (data.get(0).getTemplateName().equals("freq_dev") || data.get(0).getTemplateName().equals("freq")) { if (noPhaseList.contains(data.get(0).getTemplateName())) {
if(data.get(0).getTemplateName().equalsIgnoreCase("v_unbalance")){
System.out.println(44);
}
sql.append(InfluxDbSqlConstant.AND) sql.append(InfluxDbSqlConstant.AND)
.append(InfluxDBTableConstant.PHASIC_TYPE) .append(InfluxDBTableConstant.PHASIC_TYPE)
.append(InfluxDbSqlConstant.EQ) .append(InfluxDbSqlConstant.EQ)
@@ -931,6 +982,7 @@ public class CustomReportServiceImpl implements CustomReportService {
if (CollUtil.isEmpty(mapList) || Objects.isNull(mapList.get(0))) { if (CollUtil.isEmpty(mapList) || Objects.isNull(mapList.get(0))) {
data = data.stream().peek(item -> item.setValue("/")).collect(Collectors.toList()); data = data.stream().peek(item -> item.setValue("/")).collect(Collectors.toList());
} else { } else {
//兼容达梦数据库方法
Map<String, Object> map = convertKeysToUpperCase(mapList.get(0)); Map<String, Object> map = convertKeysToUpperCase(mapList.get(0));
for (ReportTemplateDTO item : data) { for (ReportTemplateDTO item : data) {
if (map.containsKey(item.getItemName())) { if (map.containsKey(item.getItemName())) {
@@ -938,10 +990,22 @@ public class CustomReportServiceImpl implements CustomReportService {
item.setValue(String.format("%.3f", v)); item.setValue(String.format("%.3f", v));
if (overLimitMap.containsKey(item.getLimitName())) { if (overLimitMap.containsKey(item.getLimitName())) {
Float tagVal = overLimitMap.get(item.getLimitName()); Float tagVal = overLimitMap.get(item.getLimitName());
if (v > tagVal) {
item.setOverLimitFlag(1); if(item.getLimitName().equalsIgnoreCase(UVOLTAGE_DEV)){
} else { //对电压偏差特殊处理
item.setOverLimitFlag(0); Float tagVal_U = overLimitMap.get(UVOLTAGE_DEV);
if (v > tagVal || v<tagVal_U) {
item.setOverLimitFlag(1);
} else {
item.setOverLimitFlag(0);
}
}else {
if (v > tagVal) {
item.setOverLimitFlag(1);
} else {
item.setOverLimitFlag(0);
}
} }
} }
@@ -951,12 +1015,27 @@ public class CustomReportServiceImpl implements CustomReportService {
if (limitMap.containsKey(key)) { if (limitMap.containsKey(key)) {
ReportTemplateDTO tem = limitMap.get(key); ReportTemplateDTO tem = limitMap.get(key);
double limitVal = Double.parseDouble(tem.getValue()); double limitVal = Double.parseDouble(tem.getValue());
if (v > limitVal) {
tem.setOverLimitFlag(1); if(VOLTAGE_DEV.equalsIgnoreCase(tem.getLimitName())){
assNoPassMap.put(key, tem); //针对电压偏差特殊处理
} else if (!assNoPassMap.containsKey(key)) { double limitLowVal = Double.parseDouble(tem.getLowValue());
tem.setOverLimitFlag(0);
assNoPassMap.put(key, tem); if (v > limitVal || v<limitLowVal) {
tem.setOverLimitFlag(1);
assNoPassMap.put(key, tem);
} else if (!assNoPassMap.containsKey(key)) {
tem.setOverLimitFlag(0);
assNoPassMap.put(key, tem);
}
}else {
//其他指标
if (v > limitVal) {
tem.setOverLimitFlag(1);
assNoPassMap.put(key, tem);
} else if (!assNoPassMap.containsKey(key)) {
tem.setOverLimitFlag(0);
assNoPassMap.put(key, tem);
}
} }
} }
} }
@@ -967,8 +1046,7 @@ public class CustomReportServiceImpl implements CustomReportService {
} }
endList.addAll(data); endList.addAll(data);
} }
private void assSqlByMysqlNew(Map<String,String> tMap, String dataLevel, Double pt, Double ct, List<ReportTemplateDataVO> data, StringBuilder sql, List<ReportTemplateDataVO> finalDataList, String method, SensitiveUserReportQueryParam queryParam, String lineId) {
private void assSqlByMysqlNew(List<ReportTemplateDataVO> data, StringBuilder sql, List<ReportTemplateDataVO> finalDataList, String method, SensitiveUserReportQueryParam queryParam, String lineId) {
//sql拼接示例select MAX(IHA2) as IHA2 from power_quality_data where Phase = 'A' and LineId='1324564568' and Stat_Method='max' tz('Asia/Shanghai') //sql拼接示例select MAX(IHA2) as IHA2 from power_quality_data where Phase = 'A' and LineId='1324564568' and Stat_Method='max' tz('Asia/Shanghai')
if (InfluxDbSqlConstant.CP95.equals(method)) { if (InfluxDbSqlConstant.CP95.equals(method)) {
for (int i = 0; i < data.size(); i++) { for (int i = 0; i < data.size(); i++) {
@@ -977,6 +1055,7 @@ public class CustomReportServiceImpl implements CustomReportService {
.append(InfluxDbSqlConstant.LBK) .append(InfluxDbSqlConstant.LBK)
.append(data.get(i).getTemplateName()) .append(data.get(i).getTemplateName())
.append(InfluxDbSqlConstant.RBK) .append(InfluxDbSqlConstant.RBK)
.append(Objects.equals(dataLevel, "Secondary") ? " " + appendData(tMap, data.get(i).getTemplateName()+data.get(i).getPhase()+data.get(0).getResourceId(), pt, ct) : "")
.append(InfluxDbSqlConstant.AS) .append(InfluxDbSqlConstant.AS)
.append("\"" + data.get(i).getItemName() + "\""); .append("\"" + data.get(i).getItemName() + "\"");
} else { } else {
@@ -984,6 +1063,7 @@ public class CustomReportServiceImpl implements CustomReportService {
.append(InfluxDbSqlConstant.LBK) .append(InfluxDbSqlConstant.LBK)
.append(data.get(i).getTemplateName()) .append(data.get(i).getTemplateName())
.append(InfluxDbSqlConstant.RBK) .append(InfluxDbSqlConstant.RBK)
.append(Objects.equals(dataLevel, "Secondary") ? " " + appendData(tMap, data.get(i).getTemplateName()+data.get(i).getPhase()+data.get(0).getResourceId(), pt, ct) : "")
.append(InfluxDbSqlConstant.AS) .append(InfluxDbSqlConstant.AS)
.append("\"" + data.get(i).getItemName() + "\"").append(StrUtil.COMMA); .append("\"" + data.get(i).getItemName() + "\"").append(StrUtil.COMMA);
} }
@@ -995,6 +1075,7 @@ public class CustomReportServiceImpl implements CustomReportService {
.append(InfluxDbSqlConstant.LBK) .append(InfluxDbSqlConstant.LBK)
.append(data.get(i).getTemplateName()) .append(data.get(i).getTemplateName())
.append(InfluxDbSqlConstant.RBK) .append(InfluxDbSqlConstant.RBK)
.append(Objects.equals(dataLevel, "Secondary") ? " " + appendData(tMap, data.get(i).getTemplateName()+data.get(i).getPhase()+data.get(0).getResourceId(), pt, ct) : "")
.append(InfluxDbSqlConstant.AS) .append(InfluxDbSqlConstant.AS)
.append("\"" + data.get(i).getItemName() + "\""); .append("\"" + data.get(i).getItemName() + "\"");
} else { } else {
@@ -1002,6 +1083,7 @@ public class CustomReportServiceImpl implements CustomReportService {
.append(InfluxDbSqlConstant.LBK) .append(InfluxDbSqlConstant.LBK)
.append(data.get(i).getTemplateName()) .append(data.get(i).getTemplateName())
.append(InfluxDbSqlConstant.RBK) .append(InfluxDbSqlConstant.RBK)
.append(Objects.equals(dataLevel, "Secondary") ? " " + appendData(tMap, data.get(i).getTemplateName()+data.get(i).getPhase()+data.get(0).getResourceId(), pt, ct) : "")
.append(InfluxDbSqlConstant.AS) .append(InfluxDbSqlConstant.AS)
.append("\"" + data.get(i).getItemName() + "\"").append(StrUtil.COMMA); .append("\"" + data.get(i).getItemName() + "\"").append(StrUtil.COMMA);
} }
@@ -1086,6 +1168,21 @@ public class CustomReportServiceImpl implements CustomReportService {
} }
public String appendData(Map<String,String> tMap,String name, double pt, double ct) {
String result;
String format = tMap.get(name);
if (Objects.equals(format, "*PT")) {
result = "*"+pt+"/1000";
} else if (Objects.equals(format, "*CT")) {
result = "*"+ct;
} else if (Objects.equals(format, "*PT*CT")) {
result = "*"+pt+"*"+ct+"/1000";
} else {
result = "";
}
return result;
}
/** /**
* 处理 * 处理
* *
@@ -1113,9 +1210,23 @@ public class CustomReportServiceImpl implements CustomReportService {
throw new BusinessException(CsHarmonicResponseEnum.CUSTOM_REPORT_JSON); throw new BusinessException(CsHarmonicResponseEnum.CUSTOM_REPORT_JSON);
} }
} }
//查询不分相别的指标
DictData dictData = dicDataFeignClient.getDicDataByCodeAndType(DicDataEnum.EPD.getCode(), DicDataTypeEnum.CS_DATA_TYPE.getCode()).getData();
if(Objects.isNull(dictData)){
throw new BusinessException(CommonResponseEnum.FAIL,"字典类型模板缺少!");
}
//List<EleEpdPqd> temTargetList = eleEpdMapper.selectList(new LambdaQueryWrapper<EleEpdPqd>().eq(EleEpdPqd::getDataType,dictData.getId()).in(EleEpdPqd::getPhase,Arrays.asList("T", "M")));
DictData epdDic = dicDataFeignClient.getDicDataByCodeAndType(DicDataEnum.EPD.getCode(),DicDataTypeEnum.CS_DATA_TYPE.getCode()).getData();
List<EleEpdPqd> eleEpdPqdList= epdFeignClient.dictMarkByDataType(epdDic.getId()).getData();
eleEpdPqdList = eleEpdPqdList.stream().filter(it->"T".equals(it.getPhase())||"M".equals(it.getPhase())).collect(Collectors.toList());
List<String> noPhaseList = eleEpdPqdList.stream().filter(it->StrUtil.isNotBlank(it.getOtherName())).map(it->it.getOtherName().toUpperCase()).collect(Collectors.toList());
//处理指标是否合格 //处理指标是否合格
reportLimitList = new LinkedHashSet<>(reportLimitList).stream().sorted(Comparator.comparing(ReportTemplateDTO::getItemName)).collect(Collectors.toList()); reportLimitList = new LinkedHashSet<>(reportLimitList).stream().sorted(Comparator.comparing(ReportTemplateDTO::getItemName)).collect(Collectors.toList());
Map<String, Float> limitMap = overLimitDeal(reportLimitList, reportSearchParam.getLineId()); Map<String, Float> limitMap = overLimitDeal(reportLimitList, reportSearchParam);
//存放限值指标的map //存放限值指标的map
Map<String, ReportTemplateDTO> limitTargetMapX = reportLimitList.stream().collect(Collectors.toMap(ReportTemplateDTO::getItemName, Function.identity())); Map<String, ReportTemplateDTO> limitTargetMapX = reportLimitList.stream().collect(Collectors.toMap(ReportTemplateDTO::getItemName, Function.identity()));
@@ -1141,13 +1252,13 @@ public class CustomReportServiceImpl implements CustomReportService {
phaseMap.forEach((phaseKey, phaseVal) -> { phaseMap.forEach((phaseKey, phaseVal) -> {
StringBuilder sql = new StringBuilder(InfluxDbSqlConstant.SELECT); StringBuilder sql = new StringBuilder(InfluxDbSqlConstant.SELECT);
if (InfluxDbSqlConstant.MAX.equalsIgnoreCase(valueTypeKey)) { if (InfluxDbSqlConstant.MAX.equalsIgnoreCase(valueTypeKey)) {
assSqlByMysql(phaseVal, sql, endList, InfluxDbSqlConstant.MAX, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap); assSqlByMysql(phaseVal, sql, endList, InfluxDbSqlConstant.MAX, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
} else if (InfluxDbSqlConstant.MIN.equalsIgnoreCase(valueTypeKey)) { } else if (InfluxDbSqlConstant.MIN.equalsIgnoreCase(valueTypeKey)) {
assSqlByMysql(phaseVal, sql, endList, InfluxDbSqlConstant.MIN, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap); assSqlByMysql(phaseVal, sql, endList, InfluxDbSqlConstant.MIN, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
} else if (InfluxDbSqlConstant.AVG_WEB.equalsIgnoreCase(valueTypeKey)) { } else if (InfluxDbSqlConstant.AVG_WEB.equalsIgnoreCase(valueTypeKey)) {
assSqlByMysql(phaseVal, sql, endList, InfluxDbSqlConstant.AVG_WEB, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap); assSqlByMysql(phaseVal, sql, endList, InfluxDbSqlConstant.AVG_WEB, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
} else if (InfluxDbSqlConstant.CP95.equalsIgnoreCase(valueTypeKey)) { } else if (InfluxDbSqlConstant.CP95.equalsIgnoreCase(valueTypeKey)) {
assSqlByMysql(phaseVal, sql, endList, InfluxDbSqlConstant.CP95, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap); assSqlByMysql(phaseVal, sql, endList, InfluxDbSqlConstant.CP95, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
} }
}); });
@@ -1300,7 +1411,7 @@ public class CustomReportServiceImpl implements CustomReportService {
} else if (vItem.length == 4) { } else if (vItem.length == 4) {
//$HA[_25]#max#classId$ //$HA[_25]#max#classId$
reportTemplateDTO.setTemplateName(vItem[0].toUpperCase()); reportTemplateDTO.setTemplateName(vItem[0].toUpperCase());
reportTemplateDTO.setPhase("M"); reportTemplateDTO.setPhase("T");
reportTemplateDTO.setStatMethod(vItem[1].toUpperCase()); reportTemplateDTO.setStatMethod(vItem[1].toUpperCase());
reportTemplateDTO.setResourceId(vItem[2].toUpperCase()); reportTemplateDTO.setResourceId(vItem[2].toUpperCase());
reportTemplateDTO.setLimitName(vItem[3].toUpperCase()); reportTemplateDTO.setLimitName(vItem[3].toUpperCase());
@@ -1373,7 +1484,7 @@ public class CustomReportServiceImpl implements CustomReportService {
} else if (vItem.length == 4) { } else if (vItem.length == 4) {
//$HA[_25]#max#classId#no$ //$HA[_25]#max#classId#no$
indexDataVO.setTemplateName(vItem[0].toUpperCase()); indexDataVO.setTemplateName(vItem[0].toUpperCase());
indexDataVO.setPhase("M"); indexDataVO.setPhase("T");
indexDataVO.setStatMethod(vItem[1].toUpperCase()); indexDataVO.setStatMethod(vItem[1].toUpperCase());
indexDataVO.setResourceId(vItem[2].toUpperCase()); indexDataVO.setResourceId(vItem[2].toUpperCase());
} }
@@ -1417,7 +1528,7 @@ public class CustomReportServiceImpl implements CustomReportService {
} else if (vItem.length == 4) { } else if (vItem.length == 4) {
//$HA[_25]#max#classId#no$ //$HA[_25]#max#classId#no$
indexDataVO.setTemplateName(vItem[0].toUpperCase()); indexDataVO.setTemplateName(vItem[0].toUpperCase());
indexDataVO.setPhase("M"); indexDataVO.setPhase("T");
indexDataVO.setStatMethod(vItem[1].toUpperCase()); indexDataVO.setStatMethod(vItem[1].toUpperCase());
indexDataVO.setResourceId(vItem[2].toUpperCase()); indexDataVO.setResourceId(vItem[2].toUpperCase());
} }
@@ -1440,18 +1551,21 @@ public class CustomReportServiceImpl implements CustomReportService {
* @author cdf * @author cdf
* @date 2023/10/23 * @date 2023/10/23
*/ */
private Map<String, Float> overLimitDeal(List<ReportTemplateDTO> reportLimitList, String lineId) { private Map<String, Float> overLimitDeal(List<ReportTemplateDTO> reportLimitList, ReportSearchParam
reportSearchParam) {
Map<String, Float> limitMap = new HashMap<>(); Map<String, Float> limitMap = new HashMap<>();
if (CollUtil.isNotEmpty(reportLimitList)) { if (CollUtil.isNotEmpty(reportLimitList)) {
StringBuilder sql = new StringBuilder(InfluxDbSqlConstant.SELECT); StringBuilder sql = new StringBuilder(InfluxDbSqlConstant.SELECT);
for (int i = 0; i < reportLimitList.size(); i++) { for (int i = 0; i < reportLimitList.size(); i++) {
if (i == reportLimitList.size() - 1) { if (i == reportLimitList.size() - 1) {
sql.append(UVOLTAGE_DEV).append(StrUtil.COMMA);
sql.append(reportLimitList.get(i).getTemplateName()).append(StrUtil.C_SPACE); sql.append(reportLimitList.get(i).getTemplateName()).append(StrUtil.C_SPACE);
} else { } else {
sql.append(reportLimitList.get(i).getTemplateName()).append(StrUtil.COMMA); sql.append(reportLimitList.get(i).getTemplateName()).append(StrUtil.COMMA);
} }
} }
sql.append(InfluxDbSqlConstant.FROM).append(reportLimitList.get(0).getResourceId()).append(InfluxDbSqlConstant.WHERE).append("id ='").append(lineId).append("'");
sql.append(InfluxDbSqlConstant.FROM).append(reportLimitList.get(0).getResourceId()).append(InfluxDbSqlConstant.WHERE).append("id ='").append(reportSearchParam.getLineId()).append("'");
limitMap = excelRptTempMapper.dynamicSqlMap(sql.toString()); limitMap = excelRptTempMapper.dynamicSqlMap(sql.toString());
if (Objects.isNull(limitMap)) { if (Objects.isNull(limitMap)) {
throw new BusinessException("当前报表测点限值缺失!"); throw new BusinessException("当前报表测点限值缺失!");
@@ -1459,6 +1573,10 @@ public class CustomReportServiceImpl implements CustomReportService {
for (ReportTemplateDTO item : reportLimitList) { for (ReportTemplateDTO item : reportLimitList) {
if (limitMap.containsKey(item.getTemplateName())) { if (limitMap.containsKey(item.getTemplateName())) {
if(item.getTemplateName().equalsIgnoreCase(VOLTAGE_DEV)){
item.setLowValue(limitMap.get(UVOLTAGE_DEV).toString());
}
item.setValue(limitMap.get(item.getTemplateName()).toString()); item.setValue(limitMap.get(item.getTemplateName()).toString());
} }
} }
@@ -1515,7 +1633,7 @@ public class CustomReportServiceImpl implements CustomReportService {
.sorted(Comparator.comparing(ReportTemplateDTO::getItemName)) .sorted(Comparator.comparing(ReportTemplateDTO::getItemName))
.collect(Collectors.toList()); .collect(Collectors.toList());
Map<String, Float> limitMap = overLimitDeal(reportLimitList, reportSearchParam.getLineId()); Map<String, Float> limitMap = overLimitDeal(reportLimitList, reportSearchParam);
//存放限值指标的map //存放限值指标的map
Map<String, ReportTemplateDTO> limitTargetMapX = reportLimitList.stream().collect(Collectors.toMap(ReportTemplateDTO::getItemName, Function.identity())); Map<String, ReportTemplateDTO> limitTargetMapX = reportLimitList.stream().collect(Collectors.toMap(ReportTemplateDTO::getItemName, Function.identity()));
@@ -1903,13 +2021,18 @@ public class CustomReportServiceImpl implements CustomReportService {
(Map<String, ReportTemplateDTO> assNoPassMap, Map<String, ReportTemplateDTO> limitTargetMapX, List<ReportTemplateDTO> endList) { (Map<String, ReportTemplateDTO> assNoPassMap, Map<String, ReportTemplateDTO> limitTargetMapX, List<ReportTemplateDTO> endList) {
assNoPassMap.forEach((key, val) -> { assNoPassMap.forEach((key, val) -> {
limitTargetMapX.remove(key); limitTargetMapX.remove(key);
if ("Voltage_Dev".toUpperCase().equals(val.getTemplateName()) || "Freq_Dev".toUpperCase().equals(val.getTemplateName())) { if ("Freq_Dev".toUpperCase().equals(val.getTemplateName())) {
val.setValue("±" + val.getValue()); val.setValue("±" + val.getValue());
} }
String expend = "";
if(Objects.nonNull(val.getLowValue())){
expend = val.getLowValue()+",";
}
if (val.getOverLimitFlag() == 1) { if (val.getOverLimitFlag() == 1) {
val.setValue("不合格 (" + val.getValue() + ")"); val.setValue("不合格 (" + expend+val.getValue() + ")");
} else { } else {
val.setValue("合格 (" + val.getValue() + ")"); val.setValue("合格 (" + expend+val.getValue() + ")");
} }
endList.add(val); endList.add(val);
}); });
@@ -1924,6 +2047,7 @@ public class CustomReportServiceImpl implements CustomReportService {
}); });
} }
/** /**
* 解析模板 * 解析模板
* *
@@ -1964,7 +2088,7 @@ public class CustomReportServiceImpl implements CustomReportService {
} else if (vItem.length == 4) { } else if (vItem.length == 4) {
//$HA[_25]#max#classId$ //$HA[_25]#max#classId$
reportTemplateDTO.setTemplateName(vItem[0]); reportTemplateDTO.setTemplateName(vItem[0]);
reportTemplateDTO.setPhase("M"); reportTemplateDTO.setPhase("T");
reportTemplateDTO.setStatMethod(vItem[1]); reportTemplateDTO.setStatMethod(vItem[1]);
reportTemplateDTO.setResourceId(vItem[2]); reportTemplateDTO.setResourceId(vItem[2]);
reportTemplateDTO.setLimitName(vItem[3]); reportTemplateDTO.setLimitName(vItem[3]);
@@ -2006,6 +2130,27 @@ public class CustomReportServiceImpl implements CustomReportService {
private List<ReportTemplateDataVO> fetchDataList(CsLinePO linePO, private List<ReportTemplateDataVO> fetchDataList(CsLinePO linePO,
Map<String, List<ReportTemplateDataVO>> classMap, Map<String, List<ReportTemplateDataVO>> classMap,
SensitiveUserReportQueryParam queryParam) { SensitiveUserReportQueryParam queryParam) {
//获取指标一二次值转换关系
DictData epdDic = dicDataFeignClient.getDicDataByCodeAndType(DicDataEnum.EPD.getCode(),DicDataTypeEnum.CS_DATA_TYPE.getCode()).getData();
List<EleEpdPqd> eleEpdPqdList= epdFeignClient.dictMarkByDataType(epdDic.getId()).getData();
Map<String, String> tMap = new HashMap<>();
eleEpdPqdList.forEach(item->{
String phase;
if (Objects.isNull(PHASE_MAPPING.get(item.getPhase()))) {
phase = item.getPhase();
} else {
phase = PHASE_MAPPING.get(item.getPhase());
}
tMap.put((item.getOtherName() + phase + item.getResourcesId()).toUpperCase(), item.getPrimaryFormula());
});
//pt
double pt = safeDivide(linePO.getPtRatio(), linePO.getPt2Ratio());
//ct
double ct = safeDivide(linePO.getCtRatio(), linePO.getCt2Ratio());
//获取当前监测点是一次值还是二次值
Map<String,String> map = csLineFeignClient.getCustomDetailByLineId(linePO.getLineId()).getData();
String dataLevel = map.get("level");
String lineId = linePO.getLineId(); String lineId = linePO.getLineId();
List<Future<List<ReportTemplateDataVO>>> futures = new ArrayList<>(); List<Future<List<ReportTemplateDataVO>>> futures = new ArrayList<>();
@@ -2038,13 +2183,13 @@ public class CustomReportServiceImpl implements CustomReportService {
StringBuilder sql = new StringBuilder(InfluxDbSqlConstant.SELECT); StringBuilder sql = new StringBuilder(InfluxDbSqlConstant.SELECT);
if (InfluxDbSqlConstant.MAX.equalsIgnoreCase(valueTypeKey)) { if (InfluxDbSqlConstant.MAX.equalsIgnoreCase(valueTypeKey)) {
assSqlByMysqlNew(newDataList, sql, threadDataList, InfluxDbSqlConstant.MAX, queryParam, lineId); assSqlByMysqlNew(tMap,dataLevel,pt,ct,newDataList, sql, threadDataList, InfluxDbSqlConstant.MAX, queryParam, lineId);
} else if (InfluxDbSqlConstant.MIN.equalsIgnoreCase(valueTypeKey)) { } else if (InfluxDbSqlConstant.MIN.equalsIgnoreCase(valueTypeKey)) {
assSqlByMysqlNew(newDataList, sql, threadDataList, InfluxDbSqlConstant.MIN, queryParam, lineId); assSqlByMysqlNew(tMap,dataLevel,pt,ct,newDataList, sql, threadDataList, InfluxDbSqlConstant.MIN, queryParam, lineId);
} else if (InfluxDbSqlConstant.AVG_WEB.equalsIgnoreCase(valueTypeKey)) { } else if (InfluxDbSqlConstant.AVG_WEB.equalsIgnoreCase(valueTypeKey)) {
assSqlByMysqlNew(newDataList, sql, threadDataList, InfluxDbSqlConstant.AVG_WEB, queryParam, lineId); assSqlByMysqlNew(tMap,dataLevel,pt,ct,newDataList, sql, threadDataList, InfluxDbSqlConstant.AVG_WEB, queryParam, lineId);
} else if (InfluxDbSqlConstant.CP95.equalsIgnoreCase(valueTypeKey)) { } else if (InfluxDbSqlConstant.CP95.equalsIgnoreCase(valueTypeKey)) {
assSqlByMysqlNew(newDataList, sql, threadDataList, InfluxDbSqlConstant.CP95, queryParam, lineId); assSqlByMysqlNew(tMap,dataLevel,pt,ct,newDataList, sql, threadDataList, InfluxDbSqlConstant.CP95, queryParam, lineId);
} }
}); });
}); });
@@ -2063,35 +2208,47 @@ public class CustomReportServiceImpl implements CustomReportService {
return dataList; return dataList;
} }
private double safeDivide(Double dividend, Double divisor) {
if (divisor == null || divisor == 0.0) {
divisor = 1.0;
}
double dividendValue = dividend != null ? dividend : 0.0;
return dividendValue / divisor;
}
} //获取模板id
public String getTempId(String oldTempId, String lineId) {
//根据模板类型的id获取模板
List<ReportTemplateVO> result = sysExcelService.queryList(oldTempId);
if (CollUtil.isEmpty(result)) {
throw new BusinessException("未配置相关模板");
}
//根据监测点获取接线方式
CsLinePO po = csLineFeignClient.getById(lineId).getData();
//根据接线方式获取模板id
int conType = po.getConType();
DictData dicData;
//角型
if (conType == 1) {
dicData = dicDataFeignClient.getDicDataByCode(DicDataEnum.STAR_TRIANGLE.getCode()).getData();
}
//v型
else if (conType == 2){
dicData = dicDataFeignClient.getDicDataByCode(DicDataEnum.OPEN_DELTA.getCode()).getData();
}
//星型 或 其他
else {
dicData = dicDataFeignClient.getDicDataByCode(DicDataEnum.STAR.getCode()).getData();
}
String tempId;
Optional<ReportTemplateVO> vo = result.stream().filter(item -> Objects.equals(dicData.getId(),item.getWiringMethod())).findFirst();
if (vo.isPresent()) {
tempId = vo.get().getId();
} else {
throw new BusinessException("未找到此接线方式的模板");
}
return tempId;
}
}

View File

@@ -667,19 +667,19 @@ public class DataServiceImpl implements IDataService {
BeanUtils.copyProperties(vo1,vo); BeanUtils.copyProperties(vo1,vo);
RealTimeDataVo phaseA = v.stream().filter(s->Objects.equals(s.getPhase(),"A") || Objects.equals(s.getPhase(),"AB")).findFirst().orElse(null); RealTimeDataVo phaseA = v.stream().filter(s->Objects.equals(s.getPhase(),"A") || Objects.equals(s.getPhase(),"AB")).findFirst().orElse(null);
if (Objects.nonNull(phaseA)) { if (Objects.nonNull(phaseA)) {
vo.setValueA(phaseA.getAvgValue()); vo.setValueA(Objects.isNull(phaseA.getAvgValue()) ? 3.14159 : phaseA.getAvgValue());
} }
RealTimeDataVo phaseB = v.stream().filter(s->Objects.equals(s.getPhase(),"B") || Objects.equals(s.getPhase(),"BC")).findFirst().orElse(null); RealTimeDataVo phaseB = v.stream().filter(s->Objects.equals(s.getPhase(),"B") || Objects.equals(s.getPhase(),"BC")).findFirst().orElse(null);
if (Objects.nonNull(phaseB)) { if (Objects.nonNull(phaseB)) {
vo.setValueB(phaseB.getAvgValue()); vo.setValueB(Objects.isNull(phaseB.getAvgValue()) ? 3.14159 : phaseB.getAvgValue());
} }
RealTimeDataVo phaseC = v.stream().filter(s->Objects.equals(s.getPhase(),"C") || Objects.equals(s.getPhase(),"CA")).findFirst().orElse(null); RealTimeDataVo phaseC = v.stream().filter(s->Objects.equals(s.getPhase(),"C") || Objects.equals(s.getPhase(),"CA")).findFirst().orElse(null);
if (Objects.nonNull(phaseC)) { if (Objects.nonNull(phaseC)) {
vo.setValueC(phaseC.getAvgValue()); vo.setValueC(Objects.isNull(phaseC.getAvgValue()) ? 3.14159 : phaseC.getAvgValue());
} }
RealTimeDataVo phaseM = v.stream().filter(s->Objects.equals(s.getPhase(),"M")).findFirst().orElse(null); RealTimeDataVo phaseM = v.stream().filter(s->Objects.equals(s.getPhase(),"M")).findFirst().orElse(null);
if (Objects.nonNull(phaseM)) { if (Objects.nonNull(phaseM)) {
vo.setValueM(phaseM.getAvgValue()); vo.setValueM(Objects.isNull(phaseM.getAvgValue()) ? 3.14159 : phaseM.getAvgValue());
} }
vo.setPhase("/"); vo.setPhase("/");
vo.setAvgValue(null); vo.setAvgValue(null);

View File

@@ -2,6 +2,7 @@ package com.njcn.csharmonic.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
@@ -29,10 +30,7 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.ArrayList; import java.util.*;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@@ -162,13 +160,21 @@ public class RStatLimitRateDServiceImpl extends ServiceImpl<RStatLimitRateDMappe
return result; return result;
} }
keywordsLineIds = lineList.stream().map(CsLinePO::getLineId).collect(Collectors.toList()); keywordsLineIds = lineList.stream().map(CsLinePO::getLineId).collect(Collectors.toList());
} else {
List<CsLinePO> poList = csLineFeignClient.getSimpleLine().getData();
if (CollUtil.isNotEmpty(poList)) {
keywordsLineIds = poList.stream().map(CsLinePO::getLineId).collect(Collectors.toList());
}
}
if (CollUtil.isEmpty(keywordsLineIds)) {
return result;
} }
// 根据监测点Id分组再分页 // 根据监测点Id分组再分页
Page<RStatLimitRateDPO> ratePage = this.page(new Page<RStatLimitRateDPO>(param.getPageNum(), param.getPageSize()), new LambdaQueryWrapper<RStatLimitRateDPO>() Page<RStatLimitRateDPO> ratePage = this.page(new Page<RStatLimitRateDPO>(param.getPageNum(), param.getPageSize()), new LambdaQueryWrapper<RStatLimitRateDPO>()
.eq(RStatLimitRateDPO::getPhasicType, "T") .eq(RStatLimitRateDPO::getPhasicType, "T")
.ge(StrUtil.isNotBlank(param.getSearchBeginTime()), RStatLimitRateDPO::getTime, param.getSearchBeginTime()) .ge(StrUtil.isNotBlank(param.getSearchBeginTime()), RStatLimitRateDPO::getTime, param.getSearchBeginTime())
.le(StrUtil.isNotBlank(param.getSearchEndTime()), RStatLimitRateDPO::getTime, param.getSearchEndTime()) .le(StrUtil.isNotBlank(param.getSearchEndTime()), RStatLimitRateDPO::getTime, param.getSearchEndTime())
.in(CollUtil.isNotEmpty(keywordsLineIds), RStatLimitRateDPO::getLineId, keywordsLineIds) .in(RStatLimitRateDPO::getLineId, keywordsLineIds)
.groupBy(RStatLimitRateDPO::getLineId) .groupBy(RStatLimitRateDPO::getLineId)
.select(RStatLimitRateDPO::getLineId) .select(RStatLimitRateDPO::getLineId)
); );
@@ -186,16 +192,20 @@ public class RStatLimitRateDServiceImpl extends ServiceImpl<RStatLimitRateDMappe
mainLineVO.setLineId(lineId); mainLineVO.setLineId(lineId);
if (linePO != null) { if (linePO != null) {
mainLineVO.setLineName(linePO.getName()); mainLineVO.setLineName(linePO.getName());
if (linePO.getGovern().equals(0)) { if (ObjectUtil.isNotNull(linePO.getGovern())) {
mainLineVO.setGovern("未治理"); if (linePO.getGovern().equals(0)) {
} mainLineVO.setGovern("未治理");
if (linePO.getGovern().equals(1)) { }
mainLineVO.setGovern("已治理"); if (linePO.getGovern().equals(1)) {
mainLineVO.setGovern("已治理");
}
} }
mainLineVO.setObjType(linePO.getMonitorObj()); mainLineVO.setObjType(linePO.getMonitorObj());
DictData dictData = dicDataFeignClient.getDicDataById(linePO.getMonitorObj()).getData(); if (ObjectUtil.isNotNull(linePO.getMonitorObj())) {
if (dictData != null) { DictData dictData = dicDataFeignClient.getDicDataById(linePO.getMonitorObj()).getData();
mainLineVO.setObjType(dictData.getName()); if (dictData != null) {
mainLineVO.setObjType(dictData.getName());
}
} }
} }
MainLineStatLimitRateDetailsQueryParam detailsQueryParam = new MainLineStatLimitRateDetailsQueryParam(); MainLineStatLimitRateDetailsQueryParam detailsQueryParam = new MainLineStatLimitRateDetailsQueryParam();
@@ -237,19 +247,19 @@ public class RStatLimitRateDServiceImpl extends ServiceImpl<RStatLimitRateDMappe
@Override @Override
public List<MainLineStatLimitRateDetailsVO> mainLineStatLimitRateDetails(MainLineStatLimitRateDetailsQueryParam param) { public List<MainLineStatLimitRateDetailsVO> mainLineStatLimitRateDetails(MainLineStatLimitRateDetailsQueryParam param) {
HttpResult<CsLinePO> lineResult = csLineFeignClient.getById(param.getLineId()); HttpResult<CsLinePO> lineResult = csLineFeignClient.getById(param.getLineId());
CsLinePO linePO = lineResult.getData(); CsLinePO linePO = lineResult.getData();
if (linePO == null) { if (linePO == null) {
return Collections.emptyList(); return Collections.emptyList();
} }
List<RStatLimitRateDPO> list = this.list(new LambdaQueryWrapper<RStatLimitRateDPO>() List<RStatLimitRateDPO> list = this.list(new LambdaQueryWrapper<RStatLimitRateDPO>()
.eq(RStatLimitRateDPO::getLineId, param.getLineId())
.eq(RStatLimitRateDPO::getPhasicType, "T") .eq(RStatLimitRateDPO::getPhasicType, "T")
.eq(RStatLimitRateDPO::getLineId, param.getLineId())
.ge(StrUtil.isNotBlank(param.getSearchBeginTime()), RStatLimitRateDPO::getTime, param.getSearchBeginTime()) .ge(StrUtil.isNotBlank(param.getSearchBeginTime()), RStatLimitRateDPO::getTime, param.getSearchBeginTime())
.le(StrUtil.isNotBlank(param.getSearchEndTime()), RStatLimitRateDPO::getTime, param.getSearchEndTime()) .le(StrUtil.isNotBlank(param.getSearchEndTime()), RStatLimitRateDPO::getTime, param.getSearchEndTime())
.orderByAsc(RStatLimitRateDPO::getTime) .orderByAsc(RStatLimitRateDPO::getTime)
); );
return list.stream().map(item -> { return list.stream().map(item -> {
MainLineStatLimitRateDetailsVO vo = BeanUtil.copyProperties(item, MainLineStatLimitRateDetailsVO.class); MainLineStatLimitRateDetailsVO vo = BeanUtil.copyProperties(item, MainLineStatLimitRateDetailsVO.class);
vo.setLineName(linePO.getName()); vo.setLineName(linePO.getName());
@@ -269,16 +279,28 @@ public class RStatLimitRateDServiceImpl extends ServiceImpl<RStatLimitRateDMappe
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }
@Override @Override
public TotalLimitTotalStatisticsVO totalLimitTotalStatisticsData(TotalLimitStatisticsParam param) { public TotalLimitTotalStatisticsVO totalLimitTotalStatisticsData(TotalLimitStatisticsParam param) {
TotalLimitTotalStatisticsVO statisticsVO = new TotalLimitTotalStatisticsVO();
//获取用户监测点
List<String> keywordsLineIds = new ArrayList<>();
List<CsLinePO> poList = csLineFeignClient.getSimpleLine().getData();
if (CollUtil.isNotEmpty(poList)) {
keywordsLineIds = poList.stream().map(CsLinePO::getLineId).collect(Collectors.toList());
}
if (CollUtil.isEmpty(keywordsLineIds)) {
return statisticsVO;
}
List<RStatLimitRateDPO> rateList = this.list(new LambdaQueryWrapper<RStatLimitRateDPO>() List<RStatLimitRateDPO> rateList = this.list(new LambdaQueryWrapper<RStatLimitRateDPO>()
.eq(RStatLimitRateDPO::getPhasicType, "T") .eq(RStatLimitRateDPO::getPhasicType, "T")
.ge(StrUtil.isNotBlank(param.getSearchBeginTime()), RStatLimitRateDPO::getTime, param.getSearchBeginTime()) .ge(StrUtil.isNotBlank(param.getSearchBeginTime()), RStatLimitRateDPO::getTime, param.getSearchBeginTime())
.le(StrUtil.isNotBlank(param.getSearchEndTime()), RStatLimitRateDPO::getTime, param.getSearchEndTime()) .le(StrUtil.isNotBlank(param.getSearchEndTime()), RStatLimitRateDPO::getTime, param.getSearchEndTime())
.in(RStatLimitRateDPO::getLineId, keywordsLineIds)
.orderByAsc(RStatLimitRateDPO::getTime) .orderByAsc(RStatLimitRateDPO::getTime)
); );
TotalLimitTotalStatisticsVO statisticsVO = new TotalLimitTotalStatisticsVO();
int flickerTotalTime = rateList.stream().mapToInt(RStatLimitRateDPO::getFlickerOvertime).sum(); int flickerTotalTime = rateList.stream().mapToInt(RStatLimitRateDPO::getFlickerOvertime).sum();
int voltageDevTotalTime = rateList.stream().mapToInt(RStatLimitRateDPO::getVoltageDevOvertime).sum(); int voltageDevTotalTime = rateList.stream().mapToInt(RStatLimitRateDPO::getVoltageDevOvertime).sum();
int ubalanceTotalTime = rateList.stream().mapToInt(RStatLimitRateDPO::getUbalanceOvertime).sum(); int ubalanceTotalTime = rateList.stream().mapToInt(RStatLimitRateDPO::getUbalanceOvertime).sum();
@@ -316,11 +338,20 @@ public class RStatLimitRateDServiceImpl extends ServiceImpl<RStatLimitRateDMappe
@Override @Override
public List<TotalLimitStatisticsVO> totalLimitStatisticsList(TotalLimitStatisticsParam param) { public List<TotalLimitStatisticsVO> totalLimitStatisticsList(TotalLimitStatisticsParam param) {
List<TotalLimitStatisticsVO> result = new ArrayList<>(); List<TotalLimitStatisticsVO> result = new ArrayList<>();
//获取用户监测点
List<String> keywordsLineIds = new ArrayList<>();
List<CsLinePO> poList = csLineFeignClient.getSimpleLine().getData();
if (CollUtil.isNotEmpty(poList)) {
keywordsLineIds = poList.stream().map(CsLinePO::getLineId).collect(Collectors.toList());
}
if (CollUtil.isEmpty(keywordsLineIds)) {
return result;
}
List<RStatLimitRateDPO> rateList = this.list(new LambdaQueryWrapper<RStatLimitRateDPO>() List<RStatLimitRateDPO> rateList = this.list(new LambdaQueryWrapper<RStatLimitRateDPO>()
.eq(RStatLimitRateDPO::getPhasicType, "T") .eq(RStatLimitRateDPO::getPhasicType, "T")
.ge(StrUtil.isNotBlank(param.getSearchBeginTime()), RStatLimitRateDPO::getTime, param.getSearchBeginTime()) .ge(StrUtil.isNotBlank(param.getSearchBeginTime()), RStatLimitRateDPO::getTime, param.getSearchBeginTime())
.le(StrUtil.isNotBlank(param.getSearchEndTime()), RStatLimitRateDPO::getTime, param.getSearchEndTime()) .le(StrUtil.isNotBlank(param.getSearchEndTime()), RStatLimitRateDPO::getTime, param.getSearchEndTime())
.in(RStatLimitRateDPO::getLineId, keywordsLineIds)
.orderByAsc(RStatLimitRateDPO::getTime) .orderByAsc(RStatLimitRateDPO::getTime)
); );
if (CollUtil.isEmpty(rateList)) { if (CollUtil.isEmpty(rateList)) {
@@ -339,6 +370,7 @@ public class RStatLimitRateDServiceImpl extends ServiceImpl<RStatLimitRateDMappe
statisticsVO.setLineName(linePO.getName()); statisticsVO.setLineName(linePO.getName());
List<RStatLimitRateDPO> lineRateList = lineMap.get(linePO.getLineId()); List<RStatLimitRateDPO> lineRateList = lineMap.get(linePO.getLineId());
int totalTime = lineRateList.stream().mapToInt(RStatLimitRateDPO::getAllTime).sum(); int totalTime = lineRateList.stream().mapToInt(RStatLimitRateDPO::getAllTime).sum();
int flickerTime = lineRateList.stream().mapToInt(RStatLimitRateDPO::getFlickerAllTime).sum();
int flickerTotalTime = lineRateList.stream().mapToInt(RStatLimitRateDPO::getFlickerOvertime).sum(); int flickerTotalTime = lineRateList.stream().mapToInt(RStatLimitRateDPO::getFlickerOvertime).sum();
int voltageDevTotalTime = lineRateList.stream().mapToInt(RStatLimitRateDPO::getVoltageDevOvertime).sum(); int voltageDevTotalTime = lineRateList.stream().mapToInt(RStatLimitRateDPO::getVoltageDevOvertime).sum();
int ubalanceTotalTime = lineRateList.stream().mapToInt(RStatLimitRateDPO::getUbalanceOvertime).sum(); int ubalanceTotalTime = lineRateList.stream().mapToInt(RStatLimitRateDPO::getUbalanceOvertime).sum();
@@ -374,7 +406,7 @@ public class RStatLimitRateDServiceImpl extends ServiceImpl<RStatLimitRateDMappe
statisticsVO.setUharm(0.0); statisticsVO.setUharm(0.0);
statisticsVO.setIharm(0.0); statisticsVO.setIharm(0.0);
} else { } else {
statisticsVO.setFlicker(calculatePercentage(flickerTotalTime, totalTime)); statisticsVO.setFlicker(calculatePercentage(flickerTotalTime, flickerTime));
statisticsVO.setVoltageDev(calculatePercentage(voltageDevTotalTime, totalTime)); statisticsVO.setVoltageDev(calculatePercentage(voltageDevTotalTime, totalTime));
statisticsVO.setUbalance(calculatePercentage(ubalanceTotalTime, totalTime)); statisticsVO.setUbalance(calculatePercentage(ubalanceTotalTime, totalTime));
statisticsVO.setUharm(calculatePercentage(uharm, totalTime)); statisticsVO.setUharm(calculatePercentage(uharm, totalTime));
@@ -405,15 +437,22 @@ public class RStatLimitRateDServiceImpl extends ServiceImpl<RStatLimitRateDMappe
MainLineStatLimitRateDetailsVO vo = BeanUtil.copyProperties(item, MainLineStatLimitRateDetailsVO.class); MainLineStatLimitRateDetailsVO vo = BeanUtil.copyProperties(item, MainLineStatLimitRateDetailsVO.class);
vo.setLineName(linePO.getName()); vo.setLineName(linePO.getName());
Integer allTime = item.getAllTime(); Integer allTime = item.getAllTime();
Integer flickerTime = item.getFlickerAllTime();
JSONObject entries = JSONUtil.parseObj(vo); JSONObject entries = JSONUtil.parseObj(vo);
for (Map.Entry<String, Object> entry : entries.entrySet()) { for (Map.Entry<String, Object> entry : entries.entrySet()) {
String key = entry.getKey(); String key = entry.getKey();
if (key.endsWith("Overtime") && allTime != 0) { if (key.endsWith("Overtime") && allTime != 0 && !Objects.equals("flickerOvertime", key)) {
String value = entry.getValue().toString(); String value = entry.getValue().toString();
int intValue = new Integer(value); int intValue = new Integer(value);
// 占比 = 越限次数 / 总次数 * 100 // 占比 = 越限次数 / 总次数 * 100
double proportion = calculatePercentage(intValue, allTime); double proportion = calculatePercentage(intValue, allTime);
entries.putOpt(key, proportion); entries.putOpt(key, proportion);
} else if (Objects.equals("flickerOvertime", key)) {
String value = entry.getValue().toString();
int intValue = new Integer(value);
// 占比 = 越限次数 / 总次数 * 100
double proportion = calculatePercentage(intValue, flickerTime);
entries.putOpt(key, proportion);
} }
} }
return BeanUtil.copyProperties(entries, TotalLimitStatisticsDetailsVO.class); return BeanUtil.copyProperties(entries, TotalLimitStatisticsDetailsVO.class);
@@ -593,6 +632,9 @@ public class RStatLimitRateDServiceImpl extends ServiceImpl<RStatLimitRateDMappe
private double calculatePercentage(double part, double total) { private double calculatePercentage(double part, double total) {
if (total == 0) {
return 0.0;
}
return Double.parseDouble(df.format(BigDecimal.valueOf(part / total * 100.0) return Double.parseDouble(df.format(BigDecimal.valueOf(part / total * 100.0)
.setScale(2, RoundingMode.HALF_UP).doubleValue())); .setScale(2, RoundingMode.HALF_UP).doubleValue()));
} }

View File

@@ -14,7 +14,6 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.csdevice.api.CsLineFeignClient; import com.njcn.csdevice.api.CsLineFeignClient;
import com.njcn.csdevice.api.CsOverLimitClient; import com.njcn.csdevice.api.CsOverLimitClient;
import com.njcn.csdevice.pojo.po.CsLinePO; import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csdevice.pojo.po.Overlimit;
import com.njcn.csharmonic.mapper.RStatLimitRateDetailDMapper; import com.njcn.csharmonic.mapper.RStatLimitRateDetailDMapper;
import com.njcn.csharmonic.pojo.param.LimitCalendarQueryParam; import com.njcn.csharmonic.pojo.param.LimitCalendarQueryParam;
import com.njcn.csharmonic.pojo.param.LimitExtentDayQueryParam; import com.njcn.csharmonic.pojo.param.LimitExtentDayQueryParam;
@@ -26,6 +25,7 @@ import com.njcn.csharmonic.pojo.vo.LimitExtentVO;
import com.njcn.csharmonic.pojo.vo.LimitProbabilityVO; import com.njcn.csharmonic.pojo.vo.LimitProbabilityVO;
import com.njcn.csharmonic.pojo.vo.LimitTimeProbabilityVO; import com.njcn.csharmonic.pojo.vo.LimitTimeProbabilityVO;
import com.njcn.csharmonic.service.IRStatLimitRateDetailDService; import com.njcn.csharmonic.service.IRStatLimitRateDetailDService;
import com.njcn.device.biz.pojo.po.Overlimit;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -89,9 +89,19 @@ public class RStatLimitRateDetailDServiceImpl extends ServiceImpl<RStatLimitRate
LimitExtentVO ubalance = new LimitExtentVO(); LimitExtentVO ubalance = new LimitExtentVO();
ubalance.setCode("ubalance"); ubalance.setCode("ubalance");
ubalance.setName(indexMap.get(ubalance.getCode())); ubalance.setName(indexMap.get(ubalance.getCode()));
//获取用户监测点
List<String> keywordsLineIds = new ArrayList<>();
List<CsLinePO> poList = csLineFeignClient.getSimpleLine().getData();
if (CollUtil.isNotEmpty(poList)) {
keywordsLineIds = poList.stream().map(CsLinePO::getLineId).collect(Collectors.toList());
}
if (CollUtil.isEmpty(keywordsLineIds)) {
return result;
}
List<RStatLimitRateDetailDPO> detailList = this.list(new LambdaQueryWrapper<RStatLimitRateDetailDPO>() List<RStatLimitRateDetailDPO> detailList = this.list(new LambdaQueryWrapper<RStatLimitRateDetailDPO>()
.ge(StrUtil.isNotBlank(param.getSearchBeginTime()), RStatLimitRateDetailDPO::getTime, param.getSearchBeginTime()) .ge(StrUtil.isNotBlank(param.getSearchBeginTime()), RStatLimitRateDetailDPO::getTime, param.getSearchBeginTime())
.le(StrUtil.isNotBlank(param.getSearchEndTime()), RStatLimitRateDetailDPO::getTime, param.getSearchEndTime()) .le(StrUtil.isNotBlank(param.getSearchEndTime()), RStatLimitRateDetailDPO::getTime, param.getSearchEndTime())
.in(RStatLimitRateDetailDPO::getLineId, keywordsLineIds)
.orderByAsc(RStatLimitRateDetailDPO::getTime) .orderByAsc(RStatLimitRateDetailDPO::getTime)
); );
if (CollUtil.isNotEmpty(detailList)) { if (CollUtil.isNotEmpty(detailList)) {
@@ -190,9 +200,19 @@ public class RStatLimitRateDetailDServiceImpl extends ServiceImpl<RStatLimitRate
@Override @Override
public List<LimitCalendarVO> limitCalendarData(LimitCalendarQueryParam param) { public List<LimitCalendarVO> limitCalendarData(LimitCalendarQueryParam param) {
List<LimitCalendarVO> result = new ArrayList<>(); List<LimitCalendarVO> result = new ArrayList<>();
//获取用户监测点
List<String> keywordsLineIds = new ArrayList<>();
List<CsLinePO> poList = csLineFeignClient.getSimpleLine().getData();
if (CollUtil.isNotEmpty(poList)) {
keywordsLineIds = poList.stream().map(CsLinePO::getLineId).collect(Collectors.toList());
}
if (CollUtil.isEmpty(keywordsLineIds)) {
return result;
}
List<RStatLimitRateDetailDPO> detailList = this.list(new LambdaQueryWrapper<RStatLimitRateDetailDPO>() List<RStatLimitRateDetailDPO> detailList = this.list(new LambdaQueryWrapper<RStatLimitRateDetailDPO>()
.ge(StrUtil.isNotBlank(param.getSearchBeginTime()), RStatLimitRateDetailDPO::getTime, param.getSearchBeginTime()) .ge(StrUtil.isNotBlank(param.getSearchBeginTime()), RStatLimitRateDetailDPO::getTime, param.getSearchBeginTime())
.le(StrUtil.isNotBlank(param.getSearchEndTime()), RStatLimitRateDetailDPO::getTime, param.getSearchEndTime()) .le(StrUtil.isNotBlank(param.getSearchEndTime()), RStatLimitRateDetailDPO::getTime, param.getSearchEndTime())
.in(RStatLimitRateDetailDPO::getLineId, keywordsLineIds)
.orderByAsc(RStatLimitRateDetailDPO::getTime) .orderByAsc(RStatLimitRateDetailDPO::getTime)
); );
if (CollUtil.isEmpty(detailList)) { if (CollUtil.isEmpty(detailList)) {

View File

@@ -0,0 +1,48 @@
package com.njcn.csharmonic.service.impl.event;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.extra.template.TemplateException;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.njcn.csdevice.api.CsLineFeignClient;
import com.njcn.csdevice.pojo.vo.LineDetailDataVO;
import com.njcn.csharmonic.service.event.CsEventMonitorReportService;
import com.njcn.echarts.util.DrawPicUtil;
import com.njcn.event.common.pojo.dto.LineDetailDataCommDTO;
import com.njcn.event.common.service.CommMonitorEventReportService;
import com.njcn.event.pojo.param.ExportParam;
import com.njcn.system.api.DicDataFeignClient;
import lombok.RequiredArgsConstructor;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.ParseException;
/**
* govern
*
* @author cdf
* @date 2025/12/6
*/
@Service
@RequiredArgsConstructor
@DS("sjzx")
public class CsEventMonitorReportServiceImpl implements CsEventMonitorReportService {
private final CommMonitorEventReportService monitorEventReportService;
private final CsLineFeignClient csLineFeignClient;
@Override
public void getLineExport(ExportParam exportParam,HttpServletResponse response) throws InvalidFormatException, IOException, TemplateException, ParseException {
LineDetailDataCommDTO lineDetailDataCommDTO = new LineDetailDataCommDTO();
LineDetailDataVO lineDetailDataVO = csLineFeignClient.getLineDetailData(exportParam.getLineId()).getData();
BeanUtil.copyProperties(lineDetailDataVO,lineDetailDataCommDTO);
monitorEventReportService.getLineExport(exportParam,lineDetailDataCommDTO, response);
}
}

View File

@@ -1,592 +0,0 @@
package com.njcn.csharmonic.service.impl.event;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.extra.template.TemplateException;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csdevice.api.CsLineFeignClient;
import com.njcn.csdevice.pojo.vo.LineDetailDataVO;
import com.njcn.csharmonic.pojo.dto.eventReport.EventDetail;
import com.njcn.csharmonic.pojo.param.eventReport.ExportParam;
import com.njcn.csharmonic.pojo.param.eventReport.StatisticsParam;
import com.njcn.csharmonic.pojo.vo.eventReport.*;
import com.njcn.csharmonic.service.event.EventMonitorReportService;
import com.njcn.csharmonic.service.event.EventReportService;
import com.njcn.csharmonic.utils.eventReport.WordUtils;
import com.njcn.echarts.pojo.constant.PicCommonData;
import com.njcn.echarts.util.DrawPicUtil;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.enums.DicDataTypeEnum;
import com.njcn.system.enums.EventResponseEnum;
import com.njcn.system.pojo.po.DictData;
import lombok.RequiredArgsConstructor;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.util.Units;
import org.apache.poi.xwpf.usermodel.*;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblWidth;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTblWidth;
import org.springframework.stereotype.Service;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.net.URLEncoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
/**
* govern
*
* @author cdf
* @date 2025/12/6
*/
@Service
@RequiredArgsConstructor
public class EventMonitorReportServiceImpl implements EventMonitorReportService {
private final DicDataFeignClient dicDataFeignClient;
private final DrawPicUtil drawPicUtil;
private final EventReportService eventReportService;
private final CsLineFeignClient csLineFeignClient;
/**
* 监测点导出word
*
* @param exportParam .
* @param response .
* @throws InvalidFormatException .
* @throws IOException .
*/
@Override
public void getLineExport(ExportParam exportParam, HttpServletResponse response) throws IOException, InvalidFormatException, TemplateException, ParseException {
//创建word文档(poi生成word)
XWPFDocument doc = new XWPFDocument(); //创建Word文件
//设置标题样式
WordUtils.setHeadingStyle(doc);
XWPFParagraph p = doc.createParagraph(); //新建一个段落
//设置对齐
p.setAlignment(ParagraphAlignment.CENTER);
p.setVerticalAlignment(TextAlignment.CENTER);
XWPFRun r = p.createRun();//创建段落文本
r.addBreak();
r.addBreak();
r.addBreak();
r.addBreak();
r.addBreak();
r.addBreak();
r.setText("中国");
r.setBold(true);//设置为粗体
r.setFontSize(14);//字体大小
r.addBreak();
p = doc.createParagraph(); //新建一个段落
p.setAlignment(ParagraphAlignment.CENTER);
XWPFRun r1 = p.createRun();//创建段落文本
r1.setText("电压暂降事件分析报告");
r1.setBold(true);//设置为粗体
r1.setFontSize(36);//字体大小
r1.addBreak();
r1.addBreak();
r1.addBreak();
r1.addBreak();
r1.addBreak();
r1.addBreak();
r1.addBreak();
p = doc.createParagraph(); //新建一个段落
p.setAlignment(ParagraphAlignment.CENTER);
XWPFRun r2 = p.createRun();//创建段落文本
//获取当前时间
Date date = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy 年 MM 月 dd 日");
String time = dateFormat.format(date);
r2.setText("日期: " + time);
r2.setBold(true);//设置为粗体
r2.setFontSize(14);//字体大小
r2.addBreak();
r2.addBreak();
r2.addBreak();
p = doc.createParagraph(); //新建一个段落
p.setAlignment(ParagraphAlignment.CENTER);
XWPFRun r3 = p.createRun();//创建段落文本
r3.setText("电压暂降事件区域报告");
r3.setFontSize(24);//字体大小
p = doc.createParagraph(); //新建一个段落
p.setAlignment(ParagraphAlignment.LEFT);
createTitle(doc, "1. 引言", "标题 1", 0, 15);
p = doc.createParagraph(); //新建一个段落
p.setAlignment(ParagraphAlignment.BOTH);
XWPFRun r5 = p.createRun();//创建段落文本
r5.setText("对所选中区间内电压暂降事件进行分析,能够直观清晰查看响应的暂降事件信息。");
r5.setFontSize(11);//字体大小
p = doc.createParagraph(); //新建一个段落
p.setAlignment(ParagraphAlignment.LEFT);
createTitle(doc, "2. 报告分析对象", "标题 1", 0, 15);
p = doc.createParagraph(); //新建一个段落
p.setAlignment(ParagraphAlignment.BOTH);
XWPFRun r7 = p.createRun();//创建段落文本
r7.setText(exportParam.getLineName());
r7.setFontSize(11);//字体大小
p = doc.createParagraph(); //新建一个段落
p.setAlignment(ParagraphAlignment.LEFT);
createTitle(doc, "3. 报告分析时间", "标题 1", 0, 15);
p = doc.createParagraph(); //新建一个段落
p.setAlignment(ParagraphAlignment.BOTH);
XWPFRun r9 = p.createRun();//创建段落文本
r9.setText(exportParam.getSearchBeginTime() + "" + exportParam.getSearchEndTime());
r9.setFontSize(11);//字体大小
p = doc.createParagraph(); //新建一个段落
p.setAlignment(ParagraphAlignment.LEFT);
createTitle(doc, "4. 总汇信息", "标题 1", 0, 15);
//查询参数
StatisticsParam param = new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(), exportParam.getFlag());
//获取暂降原因字典
List<DictData> reasonData = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_REASON.getName()).getData();
//获取暂降类型字典
List<DictData> typeData = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName()).getData();
//influxdb查询结果pqs_eventdetail表
List<EventDetail> info = info(param);
//记录数
int i = 1;
//1.监测点信息
if (exportParam.isXq()) {
createTitle(doc, "4." + i + " 监测点信息", "标题 2", 200, 15);
XWPFTable table = createTable(doc);
XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc);
if (exportParam.getType() == 0) {
HttpResult<LineDetailDataVO> lineDetailData = csLineFeignClient.getLineDetailData(exportParam.getLineId());
if (ObjectUtil.isNull(lineDetailData)) {
throw new BusinessException(CommonResponseEnum.NO_DATA);
}
insertRow(doc, table, centerParagraph, true, "项目", "描述");
insertRow(doc, table, centerParagraph, false, "监测点名称", lineDetailData.getData().getLineName());
insertRow(doc, table, centerParagraph, false, "电压等级", lineDetailData.getData().getScale());
insertRow(doc, table, centerParagraph, false, "PT变比", lineDetailData.getData().getPt());
insertRow(doc, table, centerParagraph, false, "CT变比", lineDetailData.getData().getCt());
insertRow(doc, table, centerParagraph, false, "协议容量", lineDetailData.getData().getDealCapacity() + "");
insertRow(doc, table, centerParagraph, false, "基准容量", lineDetailData.getData().getStandardCapacity() + "");
insertRow(doc, table, centerParagraph, false, "设备容量", lineDetailData.getData().getDevCapacity() + "");
insertRow(doc, table, centerParagraph, false, "最小短路容量", lineDetailData.getData().getShortCapacity() + "");
insertRow(doc, table, centerParagraph, false, "接线方式", lineDetailData.getData().getPtType());
} else {
/* HttpResult<List<Monitor>> monitorList = monitorClient.getMonitorList(Arrays.asList(exportParam.getLineId()));
if (ObjectUtil.isNull(monitorList)) {
throw new BusinessException(EventResponseEnum.NOT_FOUND);
}
insertRow(doc, table, centerParagraph, true, "项目", "描述");
insertRow(doc, table, centerParagraph, false, "监测点名称", monitorList.getData().get(0).getName());
insertRow(doc, table, centerParagraph, false, "电压等级", dicDataFeignClient.getDicDataById(monitorList.getData().get(0).getVoltageLevel()).getData().getName());
insertRow(doc, table, centerParagraph, false, "PT变比", monitorList.getData().get(0).getPt1() + "/" + monitorList.getData().get(0).getPt2());
insertRow(doc, table, centerParagraph, false, "CT变比", monitorList.getData().get(0).getCt1() + "/" + monitorList.getData().get(0).getCt2());
insertRow(doc, table, centerParagraph, false, "协议容量", monitorList.getData().get(0).getUserAgreementCapacity() + "");
// insertRow(doc, table, centerParagraph, false, "基准容量", monitorList.getData().get(0).getMinShortCircuitCapacity() + "");
insertRow(doc, table, centerParagraph, false, "设备容量", monitorList.getData().get(0).getPowerSupplyEqCapacity() + "");
insertRow(doc, table, centerParagraph, false, "最小短路容量", monitorList.getData().get(0).getMinShortCircuitCapacity() + "");
insertRow(doc, table, centerParagraph, false, "接线方式", dicDataFeignClient.getDicDataById(monitorList.getData().get(0).getTerminalWiringMethod()).getData().getName());
*/
}
i++;
}
//2.暂降事件暂降事件列表和暂降点图
//2.1.判断列表和点图是否是要导出
if (exportParam.isLb() || exportParam.isSjdF47() || exportParam.isSjdITIC()) {
// List<EventDetail> plot = eventAnalysisService.getPlot(param);
List<EventDetail> plot = eventReportService.getPlot(info, reasonData, typeData);
//暂降事件列表
if (exportParam.isLb()) {
createTitle(doc, "4." + i + " 暂降事件列表", "标题 2", 200, 15);
XWPFTable table = createTable(doc);
XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc);
insertRow(doc, table, centerParagraph, true, "序号", "暂降发生时刻", "暂降幅值(%)", "持续时间(s)", "暂降类型", "暂降原因", "严重度");
for (int j = 0; j < plot.size(); j++) {
EventDetail eventDetail = plot.get(j);
String s = eventDetail.getStartTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
insertRow(doc, table, centerParagraph, false, j + 1 + "", s, BigDecimal.valueOf(eventDetail.getFeatureAmplitude() * 100).setScale(2, RoundingMode.HALF_UP).toString(), eventDetail.getDuration() + "", eventDetail.getAdvanceType(), eventDetail.getAdvanceReason(), eventDetail.getSeverity() + "");
}
i++;
}
//暂降事件点图
if (exportParam.isSjdF47() || exportParam.isSjdITIC()) {
ArrayList<List<Double>> ass = getAss(plot);
createTitle(doc, "4." + i + " 暂降事件点图", "标题 2", 200, 15);
int two = 1;
if (exportParam.isSjdITIC()) {
createTitle(doc, "4." + i + "." + two + " ITIC 曲线", "标题 3", 400, 15);
String itic = drawPicUtil.drawItic(ass);
createPic(doc, itic, "ITIC曲线");
two++;
}
if (exportParam.isSjdF47()) {
createTitle(doc, "4." + i + "." + two + " F47 曲线", "标题 3", 400, 15);
String f47 = drawPicUtil.drawF47(ass);
createPic(doc, f47, "SEMI F47曲线");
two++;
}
i++;
}
}
//3.暂降密度
if (exportParam.isMdbg() || exportParam.isMdtx()) {
createTitle(doc, "4." + i + " 暂降密度", "标题 2", 200, 15);
int two = 1;
if (exportParam.isMdtx()) {
createTitle(doc, "4." + i + "." + two + " 暂降密度点图", "标题 3", 400, 15);
Integer[][] eventDensityData = eventReportService.getCoords(info);
String str = drawPicUtil.drawEventDensity(eventDensityData);
createPic(doc, str, "暂降密度图");
two++;
}
if (exportParam.isMdbg()) {
XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc);
createTitle(doc, "4." + i + "." + two + " DISDIP 表格:国际发配电联盟(UNIPEDE)", "标题 3", 400, 15);
// List<DISDIPVO> eventDisdip = eventAnalysisService.eventDisdip(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag()));
List<DISDIPVO> eventDisdip = eventReportService.eventDisdip(info);
XWPFTable table1 = createTable(doc);
insertRow(doc, table1, centerParagraph, true, "剩余电压", "20ms", "100ms", "500ms", "1s", "3s", "20s", "60s", "180s");
for (int j = 0; j < eventDisdip.size(); j++) {
DISDIPVO disdipvo = eventDisdip.get(j);
insertRow(doc, table1, centerParagraph, false, disdipvo.getName(), disdipvo.getTwentyMs(), disdipvo.getOneHundredMs(), disdipvo.getFiveHundredMs(), disdipvo.getOneS(), disdipvo.getThreeS(), disdipvo.getTwentyS(), disdipvo.getSixtyS(), disdipvo.getOneEightyS());
}
two++;
createTitle(doc, "4." + i + "." + two + " IEC 61000-4-11:(用电终端的电压暂降抗度)", "标题 3", 400, 15);
// List<IEC411VO> iec411VOS = eventAnalysisService.IEC411(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag()));
List<IEC411VO> iec411VOS = eventReportService.IEC411(info);
XWPFTable table2 = createTable(doc);
insertRow(doc, table2, centerParagraph, true, "剩余电压", "10~20ms", "20~100ms", "0.1~0.2s", "0.2~0.5s", "0.5~1s", ">1s");
for (int j = 0; j < iec411VOS.size(); j++) {
IEC411VO iec411VO = iec411VOS.get(j);
insertRow(doc, table2, centerParagraph, false, iec411VO.getName(), iec411VO.getTenTwentyMs(), iec411VO.getTwentyOneHundredMs(), iec411VO.getZeroPiontOneTwoS(), iec411VO.getZeroPiontTwoFiveS(), iec411VO.getZeroPiontFive1S(), iec411VO.getGreater1S());
}
two++;
createTitle(doc, "4." + i + "." + two + " IEC 61000-2-8:(公共电网电压暂降测量统计)", "标题 3", 400, 15);
// List<IEC28VO> iec28VOS = eventAnalysisService.IEC28(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag()));
List<IEC28VO> iec28VOS = eventReportService.IEC28(info);
XWPFTable table3 = createTable(doc);
insertRow(doc, table3, centerParagraph, true, "剩余电压", "0.02~0.1s", "0.1~0.25s", "0.25~0.5s", "0.5s~1s", "1~3s", "3~20s", "20~60s", "60~180s");
for (int j = 0; j < iec28VOS.size(); j++) {
IEC28VO iec28VO = iec28VOS.get(j);
insertRow(doc, table3, centerParagraph, false, iec28VO.getName(), iec28VO.getQ(), iec28VO.getW(), iec28VO.getE(), iec28VO.getR(), iec28VO.getT(), iec28VO.getY(), iec28VO.getU(), iec28VO.getI());
}
two++;
}
i++;
}
//4.暂降幅值概率分布
if (exportParam.isGlfbfz() || exportParam.isGlfbsj()) {
createTitle(doc, "4." + i + " 暂降幅值概率分布图", "标题 2", 200, 15);
// ProbabilityVO probabilityVO = eventAnalysisService.getProbabilityDistribution(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag()));
ProbabilityVO probabilityVO = eventReportService.getProbabilityDistribution(info);
int two = 1;
if (exportParam.isGlfbfz()) {
createTitle(doc, "4." + i + "." + two + " 暂降幅值的概率分函数", "标题 3", 400, 15);
List<String> ybardata = probabilityVO.getPereventvalue();
List<String> ylinedata = probabilityVO.getEventvalue();
String fz = drawPicUtil.drawEventAmplitude(ylinedata, ybardata);
createPic(doc, fz, "暂降幅值的概率分布函数");
two++;
}
if (exportParam.isGlfbsj()) {
createTitle(doc, "4." + i + "." + two + " 持续时间的概率分函数", "标题 3", 400, 15);
List<String> ybardata = probabilityVO.getPersisttime();
List<String> ylinedata = probabilityVO.getSisttime();
String sj = drawPicUtil.drawPersistentTime(ylinedata, ybardata);
createPic(doc, sj, "持续时间的概率分布函数");
two++;
}
i++;
}
//5.月份统计
if (exportParam.isTjbg() || exportParam.isTjtx()) {
createTitle(doc, "4." + i + " 月份统计", "标题 2", 200, 15);
int two = 1;
List<TimeVO> reasonTypeTime = eventReportService.getReasonTypeTime(param);
//暂时时间端按月查询不能查询
// List<TimeVO> reasonTypeTime = eventReportService.getReasonTypeTime(param,null);
if (exportParam.isTjtx()) {
createTitle(doc, "4." + i + "." + two + " 月份统计图", "标题 3", 400, 15);
List<Integer> count = new ArrayList<>();
List<String> name = new ArrayList<>();
if (exportParam.getFlag() == 0) {
for (TimeVO timeVO : reasonTypeTime) {
name.add(timeVO.getMonth() + "");
count.add(Integer.parseInt(timeVO.getTimes()));
}
} else {
for (TimeVO timeVO : reasonTypeTime) {
name.add(timeVO.getDay() + "");
count.add(Integer.parseInt(timeVO.getTimes()));
}
}
String yftj = drawPicUtil.drawMonth(name, count, reasonTypeTime.get(0).getYear(), exportParam.getFlag());
createPic(doc, yftj, "月份统计图");
two++;
}
if (exportParam.isTjbg()) {
XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc);
createTitle(doc, "4." + i + "." + two + " 时间统计表格", "标题 3", 400, 15);
XWPFTable table1 = createTable(doc);
if (exportParam.getFlag() == 0) {
insertRow(doc, table1, centerParagraph, true, "时间(月)", "电压暂降次数");
} else {
insertRow(doc, table1, centerParagraph, true, "时间(天)", "电压暂降次数");
}
if (exportParam.getFlag() == 0) {
for (int j = 0; j < reasonTypeTime.size(); j++) {
TimeVO timeVO = reasonTypeTime.get(j);
insertRow(doc, table1, centerParagraph, false, timeVO.getMonth(), timeVO.getTimes());
}
} else {
for (int j = 0; j < reasonTypeTime.size(); j++) {
TimeVO timeVO = reasonTypeTime.get(j);
insertRow(doc, table1, centerParagraph, false,timeVO.getFulltime(), timeVO.getTimes());
}
}
two++;
}
i++;
}
//6.原因统计
//6.1整合提出查询语句
Boolean fly = exportParam.isYybg() || exportParam.isYytx() || exportParam.isLxbg() || exportParam.isLxtx();
if (fly) {
StatisticVO statistic = eventReportService.getStatistic(info, reasonData, typeData);
if (exportParam.isYybg() || exportParam.isYytx()) {
createTitle(doc, "4." + i + " 原因统计", "标题 2", 200, 15);
// StatisticVO statistic = eventAnalysisService.getStatistic(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag()));
int two = 1;
if (exportParam.isYytx()) {
createTitle(doc, "4." + i + "." + two + " 原因统计图", "标题 3", 400, 15);
List<String> xdata = new ArrayList<>();
List<Map<String, Object>> reasonList = new ArrayList<>();
List<ReasonsVO> reason = statistic.getReason();
for (ReasonsVO reasonsVO : reason) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("value", reasonsVO.getTimes());
map.put("name", reasonsVO.getReason());
reasonList.add(map);
xdata.add(reasonsVO.getReason());
}
String tr = drawPicUtil.drawReason(xdata, reasonList);
createPic(doc, tr, "暂降原因图");
two++;
}
if (exportParam.isYybg()) {
XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc);
createTitle(doc, "4." + i + "." + two + " 原因统计表格", "标题 3", 400, 15);
XWPFTable table1 = createTable(doc);
insertRow(doc, table1, centerParagraph, true, "暂降原因", "电压暂降次数");
List<ReasonsVO> reason = statistic.getReason();
for (int j = 0; j < reason.size(); j++) {
ReasonsVO reasonsVO = reason.get(j);
insertRow(doc, table1, centerParagraph, false, reasonsVO.getReason(), reasonsVO.getTimes() + "");
}
two++;
}
i++;
}
//7.类型统计
if (exportParam.isLxbg() || exportParam.isLxtx()) {
createTitle(doc, "4." + i + " 类型统计", "标题 2", 200, 15);
// StatisticVO statistic = eventAnalysisService.getStatistic(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag()));
int two = 1;
if (exportParam.isLxtx()) {
createTitle(doc, "4." + i + "." + two + " 类型统计图", "标题 3", 400, 15);
List<String> xdata = new ArrayList<>();
List<TypesVO> types = statistic.getTypes();
List<Map<String, Object>> reasonList = new ArrayList<>();
for (TypesVO type : types) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("value", type.getTimes());
map.put("name", type.getType());
reasonList.add(map);
xdata.add(type.getType());
}
String tr = drawPicUtil.drawType(xdata, reasonList);
createPic(doc, tr, "暂降类型图");
two++;
}
if (exportParam.isLxbg()) {
createTitle(doc, "4." + i + "." + two + " 类型统计表格", "标题 3", 400, 15);
XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc);
XWPFTable table1 = createTable(doc);
insertRow(doc, table1, centerParagraph, true, "暂降原因", "电压暂降次数");
List<TypesVO> types = statistic.getTypes();
for (int j = 0; j < types.size(); j++) {
TypesVO typesVO = types.get(j);
insertRow(doc, table1, centerParagraph, false, typesVO.getType(), typesVO.getTimes() + "");
}
two++;
}
i++;
}
}
ServletOutputStream outputStream = response.getOutputStream();
String fileName = URLEncoder.encode(exportParam.getLineName() + ".docx", "UTF-8");
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
response.setContentType("application/octet-stream;charset=UTF-8");
doc.write(outputStream);
outputStream.close();
}
/**
* 创建标题
*
* @param document 文档
* @param message 标题内容
* @param style 标题等级
* @param line 缩进
* @param fontSize 字体大小
*/
public void createTitle(XWPFDocument document, String message, String style, int line, int fontSize) {
XWPFParagraph summaeTableParagraph = WordUtils.getLeftParagraph(document);
summaeTableParagraph.setStyle(style);
summaeTableParagraph.setIndentationFirstLine(line);
XWPFRun summaeTableRun = summaeTableParagraph.createRun();
WordUtils.addParagraph(summaeTableRun, "宋体", fontSize, "000000", message, false);
}
/**
* 表格插入行数据
*
* @param document 文档
* @param table 表格
* @param head 是否是表头
* @param values 数据内容
*/
public static void insertRow(XWPFDocument document, XWPFTable table, XWPFParagraph excelParagraph, boolean head,
String... values) {
if (head) {
XWPFTableRow summaTableRowOne = table.getRow(0);
WordUtils.setExcelHeadContent(excelParagraph, summaTableRowOne, values);
} else {
XWPFTableRow summaTableRowOne = table.createRow();
WordUtils.setExcelContent(excelParagraph, summaTableRowOne, values);
}
}
/**
* 创建图片在word中
*
* @param document 文档
* @param image 图片base64
* @param name 图片名
* @throws IOException
* @throws InvalidFormatException
*/
public void createPic(XWPFDocument document, String image, String name) throws IOException, InvalidFormatException, InvalidFormatException {
XWPFParagraph picParagraph = WordUtils.getCenterParagraph(document);
XWPFRun createRun = picParagraph.createRun();
if (image.contains(PicCommonData.PNG_PREFIX)) {
image = image.replace(PicCommonData.PNG_PREFIX, "");
}
byte[] bytes = Base64.getDecoder().decode(image);
InputStream in = new ByteArrayInputStream(bytes);
createRun.addPicture(in, 5, name, Units.toEMU(410), Units.toEMU(170));
}
/**
* 创建表格
*
* @param document
* @return
*/
public XWPFTable createTable(XWPFDocument document) {
XWPFTable summaTable = document.createTable();
// 列宽自动分割
CTTblWidth summaTableWidth = summaTable.getCTTbl().addNewTblPr().addNewTblW();
summaTableWidth.setType(STTblWidth.DXA);
summaTableWidth.setW(BigInteger.valueOf(8160));
return summaTable;
}
public void setCellStyle(HSSFCell cellname, String value, HSSFCellStyle style) {
cellname.setCellValue(value);
cellname.setCellStyle(style);
}
/**
* 监测点暂降事件点图赋值
*
* @param plot
* @return
*/
private ArrayList<List<Double>> getAss(List<EventDetail> plot) {
//TODO 666
ArrayList<List<Double>> list = new ArrayList<>();
for (EventDetail eventDetail : plot) {
ArrayList<Double> doubles = new ArrayList<>();
doubles.add(eventDetail.getDuration());
doubles.add(Double.parseDouble(String.valueOf(eventDetail.getFeatureAmplitude() * 100)));
list.add(doubles);
}
return list;
}
/**
* influxdb查询结果集
*
* @param statisticsParam
* @return
*/
private List<EventDetail> info(StatisticsParam statisticsParam) {
//获取事件类型
List<DictData> dictType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_STATIS.getCode()).getData();
List<String> typeIds = dictType.stream().filter(x -> DicDataEnum.VOLTAGE_DIP.getCode().equals(x.getCode()) || DicDataEnum.SHORT_INTERRUPTIONS.getCode().equals(x.getCode()))
.map(DictData::getId).collect(Collectors.toList());
//数据暂降查询
/* List<RmpEventDetailPO> info = eventDetailService.list(new LambdaQueryWrapper<RmpEventDetailPO>()
.eq(RmpEventDetailPO::getMeasurementPointId, statisticsParam.getLineIndex())
.in(RmpEventDetailPO::getEventType, typeIds)
.ge(StrUtil.isNotBlank(statisticsParam.getStartTime()), RmpEventDetailPO::getStartTime, DateUtil.beginOfDay(DateUtil.parse(statisticsParam.getStartTime())))
.le(StrUtil.isNotBlank(statisticsParam.getEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(statisticsParam.getEndTime())))
);*/
return new ArrayList<>();
}
}

View File

@@ -1,11 +1,12 @@
package com.njcn.csharmonic.service.impl.event; package com.njcn.csharmonic.service.impl.event;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.*; import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.C;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
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;
@@ -13,7 +14,6 @@ import com.njcn.csdevice.api.CsCommTerminalFeignClient;
import com.njcn.csdevice.api.CsLineFeignClient; import com.njcn.csdevice.api.CsLineFeignClient;
import com.njcn.csdevice.pojo.po.CsLinePO; import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csharmonic.enums.CsEventEnum; import com.njcn.csharmonic.enums.CsEventEnum;
import com.njcn.csharmonic.enums.CsTransientEnum;
import com.njcn.csharmonic.pojo.param.EventStatisticParam; import com.njcn.csharmonic.pojo.param.EventStatisticParam;
import com.njcn.csharmonic.pojo.po.CsEventPO; import com.njcn.csharmonic.pojo.po.CsEventPO;
import com.njcn.csharmonic.pojo.vo.event.EventCoordsVO; import com.njcn.csharmonic.pojo.vo.event.EventCoordsVO;
@@ -21,12 +21,14 @@ import com.njcn.csharmonic.pojo.vo.event.EventStatisticVO;
import com.njcn.csharmonic.pojo.vo.event.F47Curve; import com.njcn.csharmonic.pojo.vo.event.F47Curve;
import com.njcn.csharmonic.service.CsEventPOService; import com.njcn.csharmonic.service.CsEventPOService;
import com.njcn.csharmonic.service.event.EventOverviewService; import com.njcn.csharmonic.service.event.EventOverviewService;
import com.njcn.event.common.mapper.WlRmpEventDetailMapper;
import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.web.utils.RequestUtil; import com.njcn.web.utils.RequestUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
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.IntStream; import java.util.stream.IntStream;
@@ -51,6 +53,7 @@ public class EventOverviewServiceImpl implements EventOverviewService {
private final CsEventPOService csEventPOService; private final CsEventPOService csEventPOService;
private final CsLineFeignClient csLineFeignClient; private final CsLineFeignClient csLineFeignClient;
private final CsCommTerminalFeignClient csCommTerminalFeignClient; private final CsCommTerminalFeignClient csCommTerminalFeignClient;
private final WlRmpEventDetailMapper wlRmpEventDetailMapper;
@Override @Override
public EventStatisticVO netEventEcharts(EventStatisticParam baseParam) { public EventStatisticVO netEventEcharts(EventStatisticParam baseParam) {
@@ -295,7 +298,13 @@ public class EventOverviewServiceImpl implements EventOverviewService {
// 0:down, 1:off, 2:up // 0:down, 1:off, 2:up
List<Integer>[] timeSegmentStats = new List[3]; List<Integer>[] timeSegmentStats = new List[3];
for (int i = 0; i < timeSegmentStats.length; i++) { for (int i = 0; i < timeSegmentStats.length; i++) {
timeSegmentStats[i] = IntStream.range(0, 5).boxed().collect(Collectors.toList()); // 创建独立的 ArrayList每个都有初始值 0
timeSegmentStats[i] = new ArrayList<>();
// 5个时间段
for (int j = 0; j < 5; j++) {
timeSegmentStats[i].add(0);
}
// timeSegmentStats[i] = IntStream.range(0, 5).boxed().collect(Collectors.toList());
} }
for (CsEventPO event : events) { for (CsEventPO event : events) {
double amplitude = event.getAmplitude(); double amplitude = event.getAmplitude();
@@ -317,7 +326,7 @@ public class EventOverviewServiceImpl implements EventOverviewService {
inner.setZ(inner.getZ() + 1); inner.setZ(inner.getZ() + 1);
} }
int hour = event.getStartTime().getHour(); int hour = event.getStartTime().getHour() + 1;
int startTimeGroup = getRangeGroup(startTimeRanges, hour); int startTimeGroup = getRangeGroup(startTimeRanges, hour);
String tag = event.getTag(); String tag = event.getTag();
@@ -345,6 +354,49 @@ public class EventOverviewServiceImpl implements EventOverviewService {
return eventCoordsVO; return eventCoordsVO;
} }
@Override
public List<Map<String, Object>> getEventDirectionData(EventStatisticParam baseParam) {
List<Map<String,Object>> list = new ArrayList<>();
Map<String,Object> load = new HashMap<>();
load.put("source", "load");
Map<String,Object> grid = new HashMap<>();
grid.put("source", "grid");
//获取当前用户拥有的监测点
List<CsLinePO> poList = csLineFeignClient.getSimpleLine().getData();
if (CollUtil.isEmpty(poList)) {
load.put("times", 0);
grid.put("times", 0);
} else {
List<String> ids = poList.stream().map(CsLinePO::getLineId).collect(Collectors.toList());
//根据监测点获取暂态事件
//安全处理空列表
List<RmpEventDetailPO> events = Optional.ofNullable(selectEventByIds(baseParam, ids))
.orElse(Collections.emptyList());
long lowerCount = events.stream()
.filter(event -> event != null && "Lower".equalsIgnoreCase(event.getSagsource()))
.count();
long upperCount = events.stream()
.filter(event -> event != null && "Upper".equalsIgnoreCase(event.getSagsource()))
.count();
load.put("times", (int) lowerCount);
grid.put("times", (int) upperCount);
}
list.add(load);
list.add(grid);
return list;
}
//根据监测点获取暂态事件
public List<RmpEventDetailPO> selectEventByIds(EventStatisticParam param, List<String> ids) {
LambdaQueryWrapper<RmpEventDetailPO> wrapper = new LambdaQueryWrapper<>();
wrapper.in(RmpEventDetailPO::getMeasurementPointId,ids)
.between(RmpEventDetailPO::getStartTime,param.getSearchBeginTime(),param.getSearchEndTime());
return wlRmpEventDetailMapper.selectList(wrapper);
}
/** /**
* 根据范围映射表获取分组 * 根据范围映射表获取分组
*/ */

View File

@@ -0,0 +1,28 @@
//package com.njcn.csharmonic.service.impl.event;
//
//import com.baomidou.dynamic.datasource.annotation.DS;
//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
//import com.njcn.csharmonic.mapper.RmpEventDetailMapper;
//import com.njcn.csharmonic.pojo.po.RmpEventDetailPO;
//import com.njcn.csharmonic.service.event.RmpEventDetailService;
//import lombok.RequiredArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.stereotype.Service;
//
//
///**
// * 暂态事件明细
// *
// * @author yzh
// * @date 2022/10/12
// */
//@Service
//@Slf4j
//@RequiredArgsConstructor
//@DS("sjzx")
//public class RmpEventDetailServiceImpl extends ServiceImpl<RmpEventDetailMapper, RmpEventDetailPO> implements RmpEventDetailService {
//
//
//}
//
//

View File

@@ -1,45 +1,45 @@
package com.njcn.csharmonic.util; //package com.njcn.csharmonic.util;
//
//
import com.njcn.csharmonic.pojo.vo.report.ReportValue; //import com.njcn.csharmonic.pojo.vo.report.ReportValue;
//
import java.util.List; //import java.util.List;
//
public class RegroupData { //public class RegroupData {
public static void regroupData(List<ReportValue> list, boolean... b) { // public static void regroupData(List<ReportValue> list, boolean... b) {
if (1 == b.length || (2 == b.length && b[1] == false)) { // if (1 == b.length || (2 == b.length && b[1] == false)) {
if (0 < list.size()) { // if (0 < list.size()) {
return; // return;
} // }
} // }
//
Float value = null; // Float value = null;
int length = b[0] ? 3 : 1; // int length = b[0] ? 3 : 1;
//
length = (b.length == 2 && !b[1]) ? 4 : length; // length = (b.length == 2 && !b[1]) ? 4 : length;
//
for (int i = 0; i < length; i++) { // for (int i = 0; i < length; i++) {
String str = null; // String str = null;
//
if (b[0]) { // if (b[0]) {
switch (i) { // switch (i) {
case 0: // case 0:
str = "A"; // str = "A";
break; // break;
case 1: // case 1:
str = "B"; // str = "B";
break; // break;
case 2: // case 2:
str = "C"; // str = "C";
break; // break;
case 3: // case 3:
str = "T"; // str = "T";
break; // break;
} // }
} // }
//
ReportValue reportValue = new ReportValue(str, value, value, value, value); // ReportValue reportValue = new ReportValue(str, value, value, value, value);
list.add(reportValue); // list.add(reportValue);
} // }
} // }
} //}

View File

@@ -5,7 +5,7 @@ import lombok.Data;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import java.io.File;
/** /**
* 类的介绍: * 类的介绍:
@@ -35,11 +35,13 @@ public class ElementParam {
private String elementMark; private String elementMark;
@ApiModelProperty(value = "图元文件") @ApiModelProperty(value = "图元文件")
@NotNull(message="图元文件不能为空!")
private MultipartFile multipartFile; private MultipartFile multipartFile;
@ApiModelProperty(value = "图元类型") @ApiModelProperty(value = "图元类型")
@NotBlank(message="图元类型不能为空!") @NotBlank(message="图元类型不能为空!")
private String elementForm; private String elementForm;
@ApiModelProperty(value = "压缩包文件")
private MultipartFile zipFile;
} }

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