监测点报告抽取公共方法

This commit is contained in:
cdf
2026-01-17 13:40:29 +08:00
parent 4497699178
commit 51a16c5701
40 changed files with 3585 additions and 5233 deletions

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

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

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

@@ -7,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.po.Overlimit;
import com.njcn.csdevice.pojo.vo.LineDetailDataVO; import com.njcn.csdevice.pojo.vo.LineDetailDataVO;
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.OverlimitMapper;
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.*;

View File

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

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

@@ -38,6 +38,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.OverlimitMapper;
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;
@@ -1126,7 +1128,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
} else { } else {
result.addAll(dataList); result.addAll(dataList);
} }
} }
} }
return result; return result;

View File

@@ -860,7 +860,7 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
@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)) {

View File

@@ -11,7 +11,6 @@ import com.alibaba.csp.sentinel.util.StringUtil;
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 +21,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.OverlimitMapper;
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;

View File

@@ -3,10 +3,10 @@ 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.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.OverlimitMapper;
import com.njcn.device.biz.pojo.po.Overlimit;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;

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

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

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

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

@@ -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,14 @@
<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>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@@ -8,13 +8,13 @@ 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.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;

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

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

@@ -1,16 +1,16 @@
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.RStatDataHarmrateVDPO; //import com.njcn.csharmonic.pojo.po.day.RStatDataHarmrateVDPO;
//
/** ///**
* <p> // * <p>
* Mapper 接口 // * Mapper 接口
* </p> // * </p>
* // *
* @author wr // * @author wr
* @since 2023-04-17 // * @since 2023-04-17
*/ // */
public interface RStatDataHarmRateVDMapper extends BaseMapper<RStatDataHarmrateVDPO> { //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

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

@@ -15,6 +15,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 +24,20 @@ 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.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.vo.ReportTemplateVO;
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;
@@ -118,6 +119,9 @@ 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";
@@ -839,7 +843,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 +853,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 +871,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 +915,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 +938,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 +946,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 +971,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,7 +1002,6 @@ public class CustomReportServiceImpl implements CustomReportService {
} }
endList.addAll(data); endList.addAll(data);
} }
private void assSqlByMysqlNew(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)) {
@@ -1113,9 +1147,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 +1189,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 +1348,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 +1421,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 +1465,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 +1488,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 +1510,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 +1570,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 +1958,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 +1984,7 @@ public class CustomReportServiceImpl implements CustomReportService {
}); });
} }
/** /**
* 解析模板 * 解析模板
* *
@@ -1964,7 +2025,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]);

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;

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