diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/api/CsOverLimitClient.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/api/CsOverLimitClient.java index a47e73b..f8707e4 100644 --- a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/api/CsOverLimitClient.java +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/api/CsOverLimitClient.java @@ -3,7 +3,7 @@ package com.njcn.csdevice.api; import com.njcn.common.pojo.constant.ServerInfo; import com.njcn.common.pojo.response.HttpResult; 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.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/api/fallback/CsOverLimitFallbackFactory.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/api/fallback/CsOverLimitFallbackFactory.java index 2beabdb..b1142c3 100644 --- a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/api/fallback/CsOverLimitFallbackFactory.java +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/api/fallback/CsOverLimitFallbackFactory.java @@ -4,7 +4,7 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.pojo.response.HttpResult; import com.njcn.csdevice.api.CsOverLimitClient; -import com.njcn.csdevice.pojo.po.Overlimit; +import com.njcn.device.biz.pojo.po.Overlimit; import com.njcn.device.biz.utils.DeviceEnumUtil; import feign.hystrix.FallbackFactory; import lombok.extern.slf4j.Slf4j; diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/po/Overlimit.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/po/Overlimit.java index 30aab32..5d00e57 100644 --- a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/po/Overlimit.java +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/po/Overlimit.java @@ -1,953 +1,953 @@ -package com.njcn.csdevice.pojo.po; - -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import com.njcn.device.biz.utils.COverlimit; -import lombok.Data; - -import java.io.Serializable; - -/** - *

- * - *

- * - * @author cdf - * @since 2022-01-04 - */ -@Data -@TableName("pq_overlimit") -public class Overlimit implements Serializable { - - private static final long serialVersionUID = 1L; - - /** - * 监测点序号 - */ - private String id; - - /** - * 频率限值 - */ - private Float freqDev; - - /** - * 电压波动 - */ - private Float voltageFluctuation; - - /** - * 电压上偏差限值 - */ - private Float voltageDev; - - /** - * 电压下偏差限值 - */ - private Float uvoltageDev; - - /** - * 三相电压不平衡度限值 - */ - private Float ubalance; - - /** - * 短时电压不平衡度限值 - */ - private Float shortUbalance; - - /** - * 闪变限值 - */ - private Float flicker; - - /** - * 电压总谐波畸变率限值 - */ - private Float uaberrance; - - /** - * 负序电流限值 - */ - private Float iNeg; - - /** - * 2次谐波电压限值 - */ - @TableField("uharm_2") - private Float uharm2; - - /** - * 3次谐波电压限值 - */ - @TableField("uharm_3") - private Float uharm3; - - /** - * 4次谐波电压限值 - */ - @TableField("uharm_4") - private Float uharm4; - - /** - * 5次谐波电压限值 - */ - @TableField("uharm_5") - private Float uharm5; - - /** - * 6次谐波电压限值 - */ - @TableField("uharm_6") - private Float uharm6; - - /** - * 7次谐波电压限值 - */ - @TableField("uharm_7") - private Float uharm7; - - /** - * 8次谐波电压限值 - */ - @TableField("uharm_8") - private Float uharm8; - - /** - * 9次谐波电压限值 - */ - @TableField("uharm_9") - private Float uharm9; - - /** - * 10次谐波电压限值 - */ - @TableField("uharm_10") - private Float uharm10; - - /** - * 11次谐波电压限值 - */ - @TableField("uharm_11") - private Float uharm11; - - /** - * 12次谐波电压限值 - */ - @TableField("uharm_12") - private Float uharm12; - - /** - * 13次谐波电压限值 - */ - @TableField("uharm_13") - private Float uharm13; - - /** - * 14次谐波电压限值 - */ - @TableField("uharm_14") - private Float uharm14; - - /** - * 15次谐波电压限值 - */ - @TableField("uharm_15") - private Float uharm15; - - /** - * 16次谐波电压限值 - */ - @TableField("uharm_16") - private Float uharm16; - - /** - * 17次谐波电压限值 - */ - @TableField("uharm_17") - private Float uharm17; - - /** - * 18次谐波电压限值 - */ - @TableField("uharm_18") - private Float uharm18; - - /** - * 19次谐波电压限值 - */ - @TableField("uharm_19") - private Float uharm19; - - /** - * 20次谐波电压限值 - */ - @TableField("uharm_20") - private Float uharm20; - - /** - * 21次谐波电压限值 - */ - @TableField("uharm_21") - private Float uharm21; - - /** - * 22次谐波电压限值 - */ - @TableField("uharm_22") - private Float uharm22; - - /** - * 23次谐波电压限值 - */ - @TableField("uharm_23") - private Float uharm23; - - /** - * 24次谐波电压限值 - */ - @TableField("uharm_24") - private Float uharm24; - - /** - * 25次谐波电压限值 - */ - @TableField("uharm_25") - private Float uharm25; - - /** - * 2次谐波电压限值 - */ - @TableField("uharm_26") - private Float uharm26; - - /** - * 3次谐波电压限值 - */ - @TableField("uharm_27") - private Float uharm27; - - /** - * 4次谐波电压限值 - */ - @TableField("uharm_28") - private Float uharm28; - - /** - * 5次谐波电压限值 - */ - @TableField("uharm_29") - private Float uharm29; - - /** - * 6次谐波电压限值 - */ - @TableField("uharm_30") - private Float uharm30; - - /** - * 7次谐波电压限值 - */ - @TableField("uharm_31") - private Float uharm31; - - /** - * 8次谐波电压限值 - */ - @TableField("uharm_32") - private Float uharm32; - - /** - * 9次谐波电压限值 - */ - @TableField("uharm_33") - private Float uharm33; - - /** - * 10次谐波电压限值 - */ - @TableField("uharm_34") - private Float uharm34; - - /** - * 11次谐波电压限值 - */ - @TableField("uharm_35") - private Float uharm35; - - /** - * 12次谐波电压限值 - */ - @TableField("uharm_36") - private Float uharm36; - - /** - * 13次谐波电压限值 - */ - @TableField("uharm_37") - private Float uharm37; - - /** - * 14次谐波电压限值 - */ - @TableField("uharm_38") - private Float uharm38; - - /** - * 15次谐波电压限值 - */ - @TableField("uharm_39") - private Float uharm39; - - /** - * 16次谐波电压限值 - */ - @TableField("uharm_40") - private Float uharm40; - - /** - * 17次谐波电压限值 - */ - @TableField("uharm_41") - private Float uharm41; - - /** - * 18次谐波电压限值 - */ - @TableField("uharm_42") - private Float uharm42; - - /** - * 19次谐波电压限值 - */ - @TableField("uharm_43") - private Float uharm43; - - /** - * 20次谐波电压限值 - */ - @TableField("uharm_44") - private Float uharm44; - - /** - * 21次谐波电压限值 - */ - @TableField("uharm_45") - private Float uharm45; - - /** - * 22次谐波电压限值 - */ - @TableField("uharm_46") - private Float uharm46; - - /** - * 23次谐波电压限值 - */ - @TableField("uharm_47") - private Float uharm47; - - /** - * 24次谐波电压限值 - */ - @TableField("uharm_48") - private Float uharm48; - - /** - * 25次谐波电压限值 - */ - @TableField("uharm_49") - private Float uharm49; - - /** - * 50次谐波电压限值 - */ - @TableField("uharm_50") - private Float uharm50; - - - - /** - * 2次谐波电流限值 - */ - @TableField("iharm_2") - private Float iharm2; - - /** - * 3次谐波电流限值 - */ - @TableField("iharm_3") - private Float iharm3; - - /** - * 4次谐波电流限值 - */ - @TableField("iharm_4") - private Float iharm4; - - /** - * 5次谐波电流限值 - */ - @TableField("iharm_5") - private Float iharm5; - - /** - * 6次谐波电流限值 - */ - @TableField("iharm_6") - private Float iharm6; - - /** - * 7次谐波电流限值 - */ - @TableField("iharm_7") - private Float iharm7; - - /** - * 8次谐波电流限值 - */ - @TableField("iharm_8") - private Float iharm8; - - /** - * 9次谐波电流限值 - */ - @TableField("iharm_9") - private Float iharm9; - - /** - * 10次谐波电流限值 - */ - @TableField("iharm_10") - private Float iharm10; - - /** - * 11次谐波电流限值 - */ - @TableField("iharm_11") - private Float iharm11; - - /** - * 12次谐波电流限值 - */ - @TableField("iharm_12") - private Float iharm12; - - /** - * 13次谐波电流限值 - */ - @TableField("iharm_13") - private Float iharm13; - - /** - * 14次谐波电流限值 - */ - @TableField("iharm_14") - private Float iharm14; - - /** - * 15次谐波电流限值 - */ - @TableField("iharm_15") - private Float iharm15; - - /** - * 16次谐波电流限值 - */ - @TableField("iharm_16") - private Float iharm16; - - /** - * 17次谐波电流限值 - */ - @TableField("iharm_17") - private Float iharm17; - - /** - * 18次谐波电流限值 - */ - @TableField("iharm_18") - private Float iharm18; - - /** - * 19次谐波电流限值 - */ - @TableField("iharm_19") - private Float iharm19; - - /** - * 20次谐波电流限值 - */ - @TableField("iharm_20") - private Float iharm20; - - /** - * 21次谐波电流限值 - */ - @TableField("iharm_21") - private Float iharm21; - - /** - * 22次谐波电流限值 - */ - @TableField("iharm_22") - private Float iharm22; - - /** - * 23次谐波电流限值 - */ - @TableField("iharm_23") - private Float iharm23; - - /** - * 24次谐波电流限值 - */ - @TableField("iharm_24") - private Float iharm24; - - /** - * 25次谐波电流限值 - */ - @TableField("iharm_25") - private Float iharm25; - - /** - * 2次谐波电压限值 - */ - @TableField("iharm_26") - private Float iharm26; - - /** - * 3次谐波电压限值 - */ - @TableField("iharm_27") - private Float iharm27; - - /** - * 4次谐波电压限值 - */ - @TableField("iharm_28") - private Float iharm28; - - /** - * 5次谐波电压限值 - */ - @TableField("iharm_29") - private Float iharm29; - - /** - * 6次谐波电压限值 - */ - @TableField("iharm_30") - private Float iharm30; - - /** - * 7次谐波电压限值 - */ - @TableField("iharm_31") - private Float iharm31; - - /** - * 8次谐波电压限值 - */ - @TableField("iharm_32") - private Float iharm32; - - /** - * 9次谐波电压限值 - */ - @TableField("iharm_33") - private Float iharm33; - - /** - * 10次谐波电压限值 - */ - @TableField("iharm_34") - private Float iharm34; - - /** - * 11次谐波电压限值 - */ - @TableField("iharm_35") - private Float iharm35; - - /** - * 12次谐波电压限值 - */ - @TableField("iharm_36") - private Float iharm36; - - /** - * 13次谐波电压限值 - */ - @TableField("iharm_37") - private Float iharm37; - - /** - * 14次谐波电压限值 - */ - @TableField("iharm_38") - private Float iharm38; - - /** - * 15次谐波电压限值 - */ - @TableField("iharm_39") - private Float iharm39; - - /** - * 16次谐波电压限值 - */ - @TableField("iharm_40") - private Float iharm40; - - /** - * 17次谐波电压限值 - */ - @TableField("iharm_41") - private Float iharm41; - - /** - * 18次谐波电压限值 - */ - @TableField("iharm_42") - private Float iharm42; - - /** - * 19次谐波电压限值 - */ - @TableField("iharm_43") - private Float iharm43; - - /** - * 20次谐波电压限值 - */ - @TableField("iharm_44") - private Float iharm44; - - /** - * 21次谐波电压限值 - */ - @TableField("iharm_45") - private Float iharm45; - - /** - * 22次谐波电压限值 - */ - @TableField("iharm_46") - private Float iharm46; - - /** - * 23次谐波电压限值 - */ - @TableField("iharm_47") - private Float iharm47; - - /** - * 24次谐波电压限值 - */ - @TableField("iharm_48") - private Float iharm48; - - /** - * 25次谐波电压限值 - */ - @TableField("iharm_49") - private Float iharm49; - - /** - * 50次谐波电压限值 - */ - @TableField("iharm_50") - private Float iharm50; - - - - /** - * 0.5次间谐波电压限值 - */ - @TableField("inuharm_1") - private Float inuharm1; - - /** - * 1.5次间谐波电压限值 - */ - @TableField("inuharm_2") - private Float inuharm2; - - /** - * 2.5次间谐波电压限值 - */ - @TableField("inuharm_3") - private Float inuharm3; - - /** - * 3.5次间谐波电压限值 - */ - @TableField("inuharm_4") - private Float inuharm4; - - /** - * 4.5次间谐波电压限值 - */ - @TableField("inuharm_5") - private Float inuharm5; - - /** - * 5.5次间谐波电压限值 - */ - @TableField("inuharm_6") - private Float inuharm6; - - /** - * 6.5次间谐波电压限值 - */ - @TableField("inuharm_7") - private Float inuharm7; - - /** - * 7.5次间谐波电压限值 - */ - @TableField("inuharm_8") - private Float inuharm8; - - /** - * 8.5次间谐波电压限值 - */ - @TableField("inuharm_9") - private Float inuharm9; - - /** - * 9.5次间谐波电压限值 - */ - @TableField("inuharm_10") - private Float inuharm10; - - /** - * 10.5次间谐波电压限值 - */ - @TableField("inuharm_11") - private Float inuharm11; - - /** - * 11.5次间谐波电压限值 - */ - @TableField("inuharm_12") - private Float inuharm12; - - /** - * 12.5次间谐波电压限值 - */ - @TableField("inuharm_13") - private Float inuharm13; - - /** - * 13.5次间谐波电压限值 - */ - @TableField("inuharm_14") - private Float inuharm14; - - /** - * 14.5次间谐波电压限值 - */ - @TableField("inuharm_15") - private Float inuharm15; - - /** - * 15.5次间谐波电压限值 - */ - @TableField("inuharm_16") - private Float inuharm16; - - public Overlimit(){} - - - public Overlimit(String lineId, String scaTmp, float fDLRL, float fJZRL, float fXYRL, float fSBRL){ - float[] fLimit = COverlimit.GetOverLimit(scaTmp, fDLRL, fJZRL, fXYRL, fSBRL); - this.id=lineId; - this.freqDev=fLimit[0]; - this.voltageDev=fLimit[1]; - this.ubalance=fLimit[2]; - this.flicker=fLimit[3]; - this.uaberrance=fLimit[4]; - this.uharm2=fLimit[5]; - this.uharm3=fLimit[6]; - this.uharm4=fLimit[7]; - this.uharm5=fLimit[8]; - this.uharm6=fLimit[9]; - this.uharm7=fLimit[10]; - this.uharm8=fLimit[11]; - this.uharm9=fLimit[12]; - this.uharm10=fLimit[13]; - this.uharm11=fLimit[14]; - this.uharm12=fLimit[15]; - this.uharm13=fLimit[16]; - this.uharm14=fLimit[17]; - this.uharm15=fLimit[18]; - this.uharm16=fLimit[19]; - this.uharm17=fLimit[20]; - this.uharm18=fLimit[21]; - this.uharm19=fLimit[22]; - this.uharm20=fLimit[23]; - this.uharm21=fLimit[24]; - this.uharm22=fLimit[25]; - this.uharm23=fLimit[26]; - this.uharm24=fLimit[27]; - this.uharm25=fLimit[28]; - this.iharm2=fLimit[29]; - this.iharm3=fLimit[30]; - this.iharm4=fLimit[31]; - this.iharm5=fLimit[32]; - this.iharm6=fLimit[33]; - this.iharm7=fLimit[34]; - this.iharm8=fLimit[35]; - this.iharm9=fLimit[36]; - this.iharm10=fLimit[37]; - this.iharm11=fLimit[38]; - this.iharm12=fLimit[39]; - this.iharm13=fLimit[40]; - this.iharm14=fLimit[41]; - this.iharm15=fLimit[42]; - this.iharm16=fLimit[43]; - this.iharm17=fLimit[44]; - this.iharm18=fLimit[45]; - this.iharm19=fLimit[46]; - this.iharm20=fLimit[47]; - this.iharm21=fLimit[48]; - this.iharm22=fLimit[49]; - this.iharm23=fLimit[50]; - this.iharm24=fLimit[51]; - this.iharm25=fLimit[52]; - this.uvoltageDev=fLimit[53]; - this.iNeg=fLimit[54]; - this.inuharm1=fLimit[55]; - this.inuharm2=fLimit[56]; - this.inuharm3=fLimit[57]; - this.inuharm4=fLimit[58]; - this.inuharm5=fLimit[59]; - this.inuharm6=fLimit[60]; - this.inuharm7=fLimit[61]; - this.inuharm8=fLimit[62]; - this.inuharm9=fLimit[63]; - this.inuharm10=fLimit[64]; - this.inuharm11=fLimit[65]; - this.inuharm12=fLimit[66]; - this.inuharm13=fLimit[67]; - this.inuharm14=fLimit[68]; - this.inuharm15=fLimit[69]; - this.inuharm16=fLimit[70]; - } - - public void buildIHarm(Float[] iHarmTem){ - this.iharm2= iHarmTem[0]; - this.iharm4= iHarmTem[2]; - this.iharm6= iHarmTem[4]; - this.iharm8= iHarmTem[6]; - this.iharm10= iHarmTem[8]; - this.iharm12= iHarmTem[10]; - this.iharm14= iHarmTem[12]; - this.iharm16= iHarmTem[14]; - this.iharm18= iHarmTem[16]; - this.iharm20= iHarmTem[18]; - this.iharm22= iHarmTem[20]; - this.iharm24= iHarmTem[22]; - this.iharm26= iHarmTem[24]; - this.iharm28= iHarmTem[26]; - this.iharm30= iHarmTem[28]; - this.iharm32= iHarmTem[30]; - this.iharm34= iHarmTem[32]; - this.iharm36= iHarmTem[34]; - this.iharm38= iHarmTem[36]; - this.iharm40= iHarmTem[38]; - this.iharm42= iHarmTem[40]; - this.iharm44= iHarmTem[42]; - this.iharm46= iHarmTem[44]; - this.iharm48= iHarmTem[46]; - this.iharm50= iHarmTem[48]; - - - - this.iharm3= iHarmTem[1]; - this.iharm5= iHarmTem[3]; - this.iharm7= iHarmTem[5]; - this.iharm9= iHarmTem[7]; - this.iharm11= iHarmTem[9]; - this.iharm13= iHarmTem[11]; - this.iharm15= iHarmTem[13]; - this.iharm17= iHarmTem[15]; - this.iharm19= iHarmTem[17]; - this.iharm21= iHarmTem[19]; - this.iharm23= iHarmTem[21]; - this.iharm25= iHarmTem[23]; - this.iharm27= iHarmTem[25]; - this.iharm29= iHarmTem[27]; - this.iharm31= iHarmTem[29]; - this.iharm33= iHarmTem[31]; - this.iharm35= iHarmTem[33]; - this.iharm37= iHarmTem[35]; - this.iharm39= iHarmTem[37]; - this.iharm41= iHarmTem[39]; - this.iharm43= iHarmTem[41]; - this.iharm45= iHarmTem[43]; - this.iharm47= iHarmTem[45]; - this.iharm49= iHarmTem[47]; - } - - public void buildUharm(Float resultEven,Float resultOdd){ - this.uharm2=resultEven; - this.uharm4=resultEven; - this.uharm6=resultEven; - this.uharm8=resultEven; - this.uharm10=resultEven; - this.uharm12=resultEven; - this.uharm14=resultEven; - this.uharm16=resultEven; - this.uharm18=resultEven; - this.uharm20=resultEven; - this.uharm22=resultEven; - this.uharm24=resultEven; - this.uharm26=resultEven; - this.uharm28=resultEven; - this.uharm30=resultEven; - this.uharm32=resultEven; - this.uharm34=resultEven; - this.uharm36=resultEven; - this.uharm38=resultEven; - this.uharm40=resultEven; - this.uharm42=resultEven; - this.uharm44=resultEven; - this.uharm46=resultEven; - this.uharm48=resultEven; - this.uharm50=resultEven; - - - this.uharm3=resultOdd; - this.uharm5=resultOdd; - this.uharm7=resultOdd; - this.uharm9=resultOdd; - this.uharm11=resultOdd; - this.uharm13=resultOdd; - this.uharm15=resultOdd; - this.uharm17=resultOdd; - this.uharm19=resultOdd; - this.uharm21=resultOdd; - this.uharm23=resultOdd; - this.uharm25=resultOdd; - this.uharm27=resultOdd; - this.uharm29=resultOdd; - this.uharm31=resultOdd; - this.uharm33=resultOdd; - this.uharm35=resultOdd; - this.uharm37=resultOdd; - this.uharm39=resultOdd; - this.uharm41=resultOdd; - this.uharm43=resultOdd; - this.uharm45=resultOdd; - this.uharm47=resultOdd; - this.uharm49=resultOdd; - } - - - - -} +//package com.njcn.csdevice.pojo.po; +// +//import com.baomidou.mybatisplus.annotation.TableField; +//import com.baomidou.mybatisplus.annotation.TableName; +//import com.njcn.device.biz.utils.COverlimit; +//import lombok.Data; +// +//import java.io.Serializable; +// +///** +// *

+// * +// *

+// * +// * @author cdf +// * @since 2022-01-04 +// */ +//@Data +//@TableName("pq_overlimit") +//public class Overlimit implements Serializable { +// +// private static final long serialVersionUID = 1L; +// +// /** +// * 监测点序号 +// */ +// private String id; +// +// /** +// * 频率限值 +// */ +// private Float freqDev; +// +// /** +// * 电压波动 +// */ +// private Float voltageFluctuation; +// +// /** +// * 电压上偏差限值 +// */ +// private Float voltageDev; +// +// /** +// * 电压下偏差限值 +// */ +// private Float uvoltageDev; +// +// /** +// * 三相电压不平衡度限值 +// */ +// private Float ubalance; +// +// /** +// * 短时电压不平衡度限值 +// */ +// private Float shortUbalance; +// +// /** +// * 闪变限值 +// */ +// private Float flicker; +// +// /** +// * 电压总谐波畸变率限值 +// */ +// private Float uaberrance; +// +// /** +// * 负序电流限值 +// */ +// private Float iNeg; +// +// /** +// * 2次谐波电压限值 +// */ +// @TableField("uharm_2") +// private Float uharm2; +// +// /** +// * 3次谐波电压限值 +// */ +// @TableField("uharm_3") +// private Float uharm3; +// +// /** +// * 4次谐波电压限值 +// */ +// @TableField("uharm_4") +// private Float uharm4; +// +// /** +// * 5次谐波电压限值 +// */ +// @TableField("uharm_5") +// private Float uharm5; +// +// /** +// * 6次谐波电压限值 +// */ +// @TableField("uharm_6") +// private Float uharm6; +// +// /** +// * 7次谐波电压限值 +// */ +// @TableField("uharm_7") +// private Float uharm7; +// +// /** +// * 8次谐波电压限值 +// */ +// @TableField("uharm_8") +// private Float uharm8; +// +// /** +// * 9次谐波电压限值 +// */ +// @TableField("uharm_9") +// private Float uharm9; +// +// /** +// * 10次谐波电压限值 +// */ +// @TableField("uharm_10") +// private Float uharm10; +// +// /** +// * 11次谐波电压限值 +// */ +// @TableField("uharm_11") +// private Float uharm11; +// +// /** +// * 12次谐波电压限值 +// */ +// @TableField("uharm_12") +// private Float uharm12; +// +// /** +// * 13次谐波电压限值 +// */ +// @TableField("uharm_13") +// private Float uharm13; +// +// /** +// * 14次谐波电压限值 +// */ +// @TableField("uharm_14") +// private Float uharm14; +// +// /** +// * 15次谐波电压限值 +// */ +// @TableField("uharm_15") +// private Float uharm15; +// +// /** +// * 16次谐波电压限值 +// */ +// @TableField("uharm_16") +// private Float uharm16; +// +// /** +// * 17次谐波电压限值 +// */ +// @TableField("uharm_17") +// private Float uharm17; +// +// /** +// * 18次谐波电压限值 +// */ +// @TableField("uharm_18") +// private Float uharm18; +// +// /** +// * 19次谐波电压限值 +// */ +// @TableField("uharm_19") +// private Float uharm19; +// +// /** +// * 20次谐波电压限值 +// */ +// @TableField("uharm_20") +// private Float uharm20; +// +// /** +// * 21次谐波电压限值 +// */ +// @TableField("uharm_21") +// private Float uharm21; +// +// /** +// * 22次谐波电压限值 +// */ +// @TableField("uharm_22") +// private Float uharm22; +// +// /** +// * 23次谐波电压限值 +// */ +// @TableField("uharm_23") +// private Float uharm23; +// +// /** +// * 24次谐波电压限值 +// */ +// @TableField("uharm_24") +// private Float uharm24; +// +// /** +// * 25次谐波电压限值 +// */ +// @TableField("uharm_25") +// private Float uharm25; +// +// /** +// * 2次谐波电压限值 +// */ +// @TableField("uharm_26") +// private Float uharm26; +// +// /** +// * 3次谐波电压限值 +// */ +// @TableField("uharm_27") +// private Float uharm27; +// +// /** +// * 4次谐波电压限值 +// */ +// @TableField("uharm_28") +// private Float uharm28; +// +// /** +// * 5次谐波电压限值 +// */ +// @TableField("uharm_29") +// private Float uharm29; +// +// /** +// * 6次谐波电压限值 +// */ +// @TableField("uharm_30") +// private Float uharm30; +// +// /** +// * 7次谐波电压限值 +// */ +// @TableField("uharm_31") +// private Float uharm31; +// +// /** +// * 8次谐波电压限值 +// */ +// @TableField("uharm_32") +// private Float uharm32; +// +// /** +// * 9次谐波电压限值 +// */ +// @TableField("uharm_33") +// private Float uharm33; +// +// /** +// * 10次谐波电压限值 +// */ +// @TableField("uharm_34") +// private Float uharm34; +// +// /** +// * 11次谐波电压限值 +// */ +// @TableField("uharm_35") +// private Float uharm35; +// +// /** +// * 12次谐波电压限值 +// */ +// @TableField("uharm_36") +// private Float uharm36; +// +// /** +// * 13次谐波电压限值 +// */ +// @TableField("uharm_37") +// private Float uharm37; +// +// /** +// * 14次谐波电压限值 +// */ +// @TableField("uharm_38") +// private Float uharm38; +// +// /** +// * 15次谐波电压限值 +// */ +// @TableField("uharm_39") +// private Float uharm39; +// +// /** +// * 16次谐波电压限值 +// */ +// @TableField("uharm_40") +// private Float uharm40; +// +// /** +// * 17次谐波电压限值 +// */ +// @TableField("uharm_41") +// private Float uharm41; +// +// /** +// * 18次谐波电压限值 +// */ +// @TableField("uharm_42") +// private Float uharm42; +// +// /** +// * 19次谐波电压限值 +// */ +// @TableField("uharm_43") +// private Float uharm43; +// +// /** +// * 20次谐波电压限值 +// */ +// @TableField("uharm_44") +// private Float uharm44; +// +// /** +// * 21次谐波电压限值 +// */ +// @TableField("uharm_45") +// private Float uharm45; +// +// /** +// * 22次谐波电压限值 +// */ +// @TableField("uharm_46") +// private Float uharm46; +// +// /** +// * 23次谐波电压限值 +// */ +// @TableField("uharm_47") +// private Float uharm47; +// +// /** +// * 24次谐波电压限值 +// */ +// @TableField("uharm_48") +// private Float uharm48; +// +// /** +// * 25次谐波电压限值 +// */ +// @TableField("uharm_49") +// private Float uharm49; +// +// /** +// * 50次谐波电压限值 +// */ +// @TableField("uharm_50") +// private Float uharm50; +// +// +// +// /** +// * 2次谐波电流限值 +// */ +// @TableField("iharm_2") +// private Float iharm2; +// +// /** +// * 3次谐波电流限值 +// */ +// @TableField("iharm_3") +// private Float iharm3; +// +// /** +// * 4次谐波电流限值 +// */ +// @TableField("iharm_4") +// private Float iharm4; +// +// /** +// * 5次谐波电流限值 +// */ +// @TableField("iharm_5") +// private Float iharm5; +// +// /** +// * 6次谐波电流限值 +// */ +// @TableField("iharm_6") +// private Float iharm6; +// +// /** +// * 7次谐波电流限值 +// */ +// @TableField("iharm_7") +// private Float iharm7; +// +// /** +// * 8次谐波电流限值 +// */ +// @TableField("iharm_8") +// private Float iharm8; +// +// /** +// * 9次谐波电流限值 +// */ +// @TableField("iharm_9") +// private Float iharm9; +// +// /** +// * 10次谐波电流限值 +// */ +// @TableField("iharm_10") +// private Float iharm10; +// +// /** +// * 11次谐波电流限值 +// */ +// @TableField("iharm_11") +// private Float iharm11; +// +// /** +// * 12次谐波电流限值 +// */ +// @TableField("iharm_12") +// private Float iharm12; +// +// /** +// * 13次谐波电流限值 +// */ +// @TableField("iharm_13") +// private Float iharm13; +// +// /** +// * 14次谐波电流限值 +// */ +// @TableField("iharm_14") +// private Float iharm14; +// +// /** +// * 15次谐波电流限值 +// */ +// @TableField("iharm_15") +// private Float iharm15; +// +// /** +// * 16次谐波电流限值 +// */ +// @TableField("iharm_16") +// private Float iharm16; +// +// /** +// * 17次谐波电流限值 +// */ +// @TableField("iharm_17") +// private Float iharm17; +// +// /** +// * 18次谐波电流限值 +// */ +// @TableField("iharm_18") +// private Float iharm18; +// +// /** +// * 19次谐波电流限值 +// */ +// @TableField("iharm_19") +// private Float iharm19; +// +// /** +// * 20次谐波电流限值 +// */ +// @TableField("iharm_20") +// private Float iharm20; +// +// /** +// * 21次谐波电流限值 +// */ +// @TableField("iharm_21") +// private Float iharm21; +// +// /** +// * 22次谐波电流限值 +// */ +// @TableField("iharm_22") +// private Float iharm22; +// +// /** +// * 23次谐波电流限值 +// */ +// @TableField("iharm_23") +// private Float iharm23; +// +// /** +// * 24次谐波电流限值 +// */ +// @TableField("iharm_24") +// private Float iharm24; +// +// /** +// * 25次谐波电流限值 +// */ +// @TableField("iharm_25") +// private Float iharm25; +// +// /** +// * 2次谐波电压限值 +// */ +// @TableField("iharm_26") +// private Float iharm26; +// +// /** +// * 3次谐波电压限值 +// */ +// @TableField("iharm_27") +// private Float iharm27; +// +// /** +// * 4次谐波电压限值 +// */ +// @TableField("iharm_28") +// private Float iharm28; +// +// /** +// * 5次谐波电压限值 +// */ +// @TableField("iharm_29") +// private Float iharm29; +// +// /** +// * 6次谐波电压限值 +// */ +// @TableField("iharm_30") +// private Float iharm30; +// +// /** +// * 7次谐波电压限值 +// */ +// @TableField("iharm_31") +// private Float iharm31; +// +// /** +// * 8次谐波电压限值 +// */ +// @TableField("iharm_32") +// private Float iharm32; +// +// /** +// * 9次谐波电压限值 +// */ +// @TableField("iharm_33") +// private Float iharm33; +// +// /** +// * 10次谐波电压限值 +// */ +// @TableField("iharm_34") +// private Float iharm34; +// +// /** +// * 11次谐波电压限值 +// */ +// @TableField("iharm_35") +// private Float iharm35; +// +// /** +// * 12次谐波电压限值 +// */ +// @TableField("iharm_36") +// private Float iharm36; +// +// /** +// * 13次谐波电压限值 +// */ +// @TableField("iharm_37") +// private Float iharm37; +// +// /** +// * 14次谐波电压限值 +// */ +// @TableField("iharm_38") +// private Float iharm38; +// +// /** +// * 15次谐波电压限值 +// */ +// @TableField("iharm_39") +// private Float iharm39; +// +// /** +// * 16次谐波电压限值 +// */ +// @TableField("iharm_40") +// private Float iharm40; +// +// /** +// * 17次谐波电压限值 +// */ +// @TableField("iharm_41") +// private Float iharm41; +// +// /** +// * 18次谐波电压限值 +// */ +// @TableField("iharm_42") +// private Float iharm42; +// +// /** +// * 19次谐波电压限值 +// */ +// @TableField("iharm_43") +// private Float iharm43; +// +// /** +// * 20次谐波电压限值 +// */ +// @TableField("iharm_44") +// private Float iharm44; +// +// /** +// * 21次谐波电压限值 +// */ +// @TableField("iharm_45") +// private Float iharm45; +// +// /** +// * 22次谐波电压限值 +// */ +// @TableField("iharm_46") +// private Float iharm46; +// +// /** +// * 23次谐波电压限值 +// */ +// @TableField("iharm_47") +// private Float iharm47; +// +// /** +// * 24次谐波电压限值 +// */ +// @TableField("iharm_48") +// private Float iharm48; +// +// /** +// * 25次谐波电压限值 +// */ +// @TableField("iharm_49") +// private Float iharm49; +// +// /** +// * 50次谐波电压限值 +// */ +// @TableField("iharm_50") +// private Float iharm50; +// +// +// +// /** +// * 0.5次间谐波电压限值 +// */ +// @TableField("inuharm_1") +// private Float inuharm1; +// +// /** +// * 1.5次间谐波电压限值 +// */ +// @TableField("inuharm_2") +// private Float inuharm2; +// +// /** +// * 2.5次间谐波电压限值 +// */ +// @TableField("inuharm_3") +// private Float inuharm3; +// +// /** +// * 3.5次间谐波电压限值 +// */ +// @TableField("inuharm_4") +// private Float inuharm4; +// +// /** +// * 4.5次间谐波电压限值 +// */ +// @TableField("inuharm_5") +// private Float inuharm5; +// +// /** +// * 5.5次间谐波电压限值 +// */ +// @TableField("inuharm_6") +// private Float inuharm6; +// +// /** +// * 6.5次间谐波电压限值 +// */ +// @TableField("inuharm_7") +// private Float inuharm7; +// +// /** +// * 7.5次间谐波电压限值 +// */ +// @TableField("inuharm_8") +// private Float inuharm8; +// +// /** +// * 8.5次间谐波电压限值 +// */ +// @TableField("inuharm_9") +// private Float inuharm9; +// +// /** +// * 9.5次间谐波电压限值 +// */ +// @TableField("inuharm_10") +// private Float inuharm10; +// +// /** +// * 10.5次间谐波电压限值 +// */ +// @TableField("inuharm_11") +// private Float inuharm11; +// +// /** +// * 11.5次间谐波电压限值 +// */ +// @TableField("inuharm_12") +// private Float inuharm12; +// +// /** +// * 12.5次间谐波电压限值 +// */ +// @TableField("inuharm_13") +// private Float inuharm13; +// +// /** +// * 13.5次间谐波电压限值 +// */ +// @TableField("inuharm_14") +// private Float inuharm14; +// +// /** +// * 14.5次间谐波电压限值 +// */ +// @TableField("inuharm_15") +// private Float inuharm15; +// +// /** +// * 15.5次间谐波电压限值 +// */ +// @TableField("inuharm_16") +// private Float inuharm16; +// +// public Overlimit(){} +// +// +// public Overlimit(String lineId, String scaTmp, float fDLRL, float fJZRL, float fXYRL, float fSBRL){ +// float[] fLimit = COverlimit.GetOverLimit(scaTmp, fDLRL, fJZRL, fXYRL, fSBRL); +// this.id=lineId; +// this.freqDev=fLimit[0]; +// this.voltageDev=fLimit[1]; +// this.ubalance=fLimit[2]; +// this.flicker=fLimit[3]; +// this.uaberrance=fLimit[4]; +// this.uharm2=fLimit[5]; +// this.uharm3=fLimit[6]; +// this.uharm4=fLimit[7]; +// this.uharm5=fLimit[8]; +// this.uharm6=fLimit[9]; +// this.uharm7=fLimit[10]; +// this.uharm8=fLimit[11]; +// this.uharm9=fLimit[12]; +// this.uharm10=fLimit[13]; +// this.uharm11=fLimit[14]; +// this.uharm12=fLimit[15]; +// this.uharm13=fLimit[16]; +// this.uharm14=fLimit[17]; +// this.uharm15=fLimit[18]; +// this.uharm16=fLimit[19]; +// this.uharm17=fLimit[20]; +// this.uharm18=fLimit[21]; +// this.uharm19=fLimit[22]; +// this.uharm20=fLimit[23]; +// this.uharm21=fLimit[24]; +// this.uharm22=fLimit[25]; +// this.uharm23=fLimit[26]; +// this.uharm24=fLimit[27]; +// this.uharm25=fLimit[28]; +// this.iharm2=fLimit[29]; +// this.iharm3=fLimit[30]; +// this.iharm4=fLimit[31]; +// this.iharm5=fLimit[32]; +// this.iharm6=fLimit[33]; +// this.iharm7=fLimit[34]; +// this.iharm8=fLimit[35]; +// this.iharm9=fLimit[36]; +// this.iharm10=fLimit[37]; +// this.iharm11=fLimit[38]; +// this.iharm12=fLimit[39]; +// this.iharm13=fLimit[40]; +// this.iharm14=fLimit[41]; +// this.iharm15=fLimit[42]; +// this.iharm16=fLimit[43]; +// this.iharm17=fLimit[44]; +// this.iharm18=fLimit[45]; +// this.iharm19=fLimit[46]; +// this.iharm20=fLimit[47]; +// this.iharm21=fLimit[48]; +// this.iharm22=fLimit[49]; +// this.iharm23=fLimit[50]; +// this.iharm24=fLimit[51]; +// this.iharm25=fLimit[52]; +// this.uvoltageDev=fLimit[53]; +// this.iNeg=fLimit[54]; +// this.inuharm1=fLimit[55]; +// this.inuharm2=fLimit[56]; +// this.inuharm3=fLimit[57]; +// this.inuharm4=fLimit[58]; +// this.inuharm5=fLimit[59]; +// this.inuharm6=fLimit[60]; +// this.inuharm7=fLimit[61]; +// this.inuharm8=fLimit[62]; +// this.inuharm9=fLimit[63]; +// this.inuharm10=fLimit[64]; +// this.inuharm11=fLimit[65]; +// this.inuharm12=fLimit[66]; +// this.inuharm13=fLimit[67]; +// this.inuharm14=fLimit[68]; +// this.inuharm15=fLimit[69]; +// this.inuharm16=fLimit[70]; +// } +// +// public void buildIHarm(Float[] iHarmTem){ +// this.iharm2= iHarmTem[0]; +// this.iharm4= iHarmTem[2]; +// this.iharm6= iHarmTem[4]; +// this.iharm8= iHarmTem[6]; +// this.iharm10= iHarmTem[8]; +// this.iharm12= iHarmTem[10]; +// this.iharm14= iHarmTem[12]; +// this.iharm16= iHarmTem[14]; +// this.iharm18= iHarmTem[16]; +// this.iharm20= iHarmTem[18]; +// this.iharm22= iHarmTem[20]; +// this.iharm24= iHarmTem[22]; +// this.iharm26= iHarmTem[24]; +// this.iharm28= iHarmTem[26]; +// this.iharm30= iHarmTem[28]; +// this.iharm32= iHarmTem[30]; +// this.iharm34= iHarmTem[32]; +// this.iharm36= iHarmTem[34]; +// this.iharm38= iHarmTem[36]; +// this.iharm40= iHarmTem[38]; +// this.iharm42= iHarmTem[40]; +// this.iharm44= iHarmTem[42]; +// this.iharm46= iHarmTem[44]; +// this.iharm48= iHarmTem[46]; +// this.iharm50= iHarmTem[48]; +// +// +// +// this.iharm3= iHarmTem[1]; +// this.iharm5= iHarmTem[3]; +// this.iharm7= iHarmTem[5]; +// this.iharm9= iHarmTem[7]; +// this.iharm11= iHarmTem[9]; +// this.iharm13= iHarmTem[11]; +// this.iharm15= iHarmTem[13]; +// this.iharm17= iHarmTem[15]; +// this.iharm19= iHarmTem[17]; +// this.iharm21= iHarmTem[19]; +// this.iharm23= iHarmTem[21]; +// this.iharm25= iHarmTem[23]; +// this.iharm27= iHarmTem[25]; +// this.iharm29= iHarmTem[27]; +// this.iharm31= iHarmTem[29]; +// this.iharm33= iHarmTem[31]; +// this.iharm35= iHarmTem[33]; +// this.iharm37= iHarmTem[35]; +// this.iharm39= iHarmTem[37]; +// this.iharm41= iHarmTem[39]; +// this.iharm43= iHarmTem[41]; +// this.iharm45= iHarmTem[43]; +// this.iharm47= iHarmTem[45]; +// this.iharm49= iHarmTem[47]; +// } +// +// public void buildUharm(Float resultEven,Float resultOdd){ +// this.uharm2=resultEven; +// this.uharm4=resultEven; +// this.uharm6=resultEven; +// this.uharm8=resultEven; +// this.uharm10=resultEven; +// this.uharm12=resultEven; +// this.uharm14=resultEven; +// this.uharm16=resultEven; +// this.uharm18=resultEven; +// this.uharm20=resultEven; +// this.uharm22=resultEven; +// this.uharm24=resultEven; +// this.uharm26=resultEven; +// this.uharm28=resultEven; +// this.uharm30=resultEven; +// this.uharm32=resultEven; +// this.uharm34=resultEven; +// this.uharm36=resultEven; +// this.uharm38=resultEven; +// this.uharm40=resultEven; +// this.uharm42=resultEven; +// this.uharm44=resultEven; +// this.uharm46=resultEven; +// this.uharm48=resultEven; +// this.uharm50=resultEven; +// +// +// this.uharm3=resultOdd; +// this.uharm5=resultOdd; +// this.uharm7=resultOdd; +// this.uharm9=resultOdd; +// this.uharm11=resultOdd; +// this.uharm13=resultOdd; +// this.uharm15=resultOdd; +// this.uharm17=resultOdd; +// this.uharm19=resultOdd; +// this.uharm21=resultOdd; +// this.uharm23=resultOdd; +// this.uharm25=resultOdd; +// this.uharm27=resultOdd; +// this.uharm29=resultOdd; +// this.uharm31=resultOdd; +// this.uharm33=resultOdd; +// this.uharm35=resultOdd; +// this.uharm37=resultOdd; +// this.uharm39=resultOdd; +// this.uharm41=resultOdd; +// this.uharm43=resultOdd; +// this.uharm45=resultOdd; +// this.uharm47=resultOdd; +// this.uharm49=resultOdd; +// } +// +// +// +// +//} diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/utils/COverlimitUtil.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/utils/COverlimitUtil.java index deadbc8..80557e7 100644 --- a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/utils/COverlimitUtil.java +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/utils/COverlimitUtil.java @@ -1,383 +1,383 @@ -package com.njcn.csdevice.utils; - -import com.njcn.csdevice.pojo.po.Overlimit; -import com.njcn.device.biz.enums.RunFlagEnum; -import com.njcn.system.enums.DicDataEnum; - -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.util.Objects; - - -/** - * pqs - * 限值计算工具类 - * - * @author cdf - * @date 2023/5/15 - */ -public class COverlimitUtil { - - - /** - * 谐波电流系数 - */ - 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}, - {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}, - {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}, - {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 protocolCapacity 协议容量 - * @param devCapacity 设备容量 - * @param shortCapacity 短路容量 - * @param powerFlag 0.用户侧 1.电网侧 - * @param lineType 0.主网 1.配网 需要注意配网目前没有四种容量,谐波电流幅值限值,负序电流限值无法计算默认-3.14159 - */ - public static Overlimit globalAssemble(Float voltageLevel, Float protocolCapacity, Float devCapacity, - Float shortCapacity, Integer powerFlag, Integer lineType) { - Overlimit overlimit = new Overlimit(); - voltageDeviation(overlimit,voltageLevel); - frequency(overlimit); - voltageFluctuation(overlimit,voltageLevel); - voltageFlicker(overlimit,voltageLevel); - totalHarmonicDistortion(overlimit,voltageLevel); - uHarm(overlimit,voltageLevel); - threeVoltageUnbalance(overlimit); - interharmonicCurrent(overlimit,voltageLevel); - - if(Objects.equals(lineType, RunFlagEnum.PW_FLAG.getStatus())) { - //配网 - Float[] iHarmTem = new Float[49]; - for (int i = 0; i <= 48; i++) { - - iHarmTem[i] = -3.14159f; - } - overlimit.buildIHarm(iHarmTem); - overlimit.setINeg(-3.14159f); - }else { - //主网 - iHarm(overlimit, voltageLevel, protocolCapacity, devCapacity, shortCapacity); - negativeSequenceCurrent(overlimit, voltageLevel, shortCapacity); - } - return overlimit; - } - - - /** - * 电压偏差限值 - * - */ - public static void voltageDeviation(Overlimit overlimit,Float voltageLevel) { - float voltageDev = 3.14159f,uvoltageDev = 3.14159f; - if(voltageLevel <= Float.parseFloat(DicDataEnum.V220.getCode())){ - voltageDev = 7.0f; - uvoltageDev=-10.0f; - }else if(voltageLevel>Float.parseFloat(DicDataEnum.V220.getCode())&&voltageLevel=Float.parseFloat(DicDataEnum.KV20.getCode())&&voltageLevel=Float.parseFloat(DicDataEnum.KV35.getCode())&&voltageLevel=Float.parseFloat(DicDataEnum.KV66.getCode())&&voltageLevel<=Float.parseFloat(DicDataEnum.KV110.getCode())){ - voltageDev = 7.0f; - uvoltageDev=-3.0f; - }else if(voltageLevel>Float.parseFloat(DicDataEnum.KV110.getCode())){ - voltageDev = 10.0f; - uvoltageDev=-10.0f; - } - overlimit.setVoltageDev(voltageDev); - overlimit.setUvoltageDev(uvoltageDev); - } - - - /** - * 频率偏差 - * 默认限值:±0.2Hz(即:-0.2 Hz≤限值≤0.2 Hz) - */ - public static void frequency(Overlimit overlimit) { - overlimit.setFreqDev(0.2f); - } - - - /** - * 电压波动 - * 对LV、MV:0≤限值≤3%;对HV:0≤限值≤2.5%。 - * LV、MV、HV的定义: - * 低压(LV) UN≤1kV - * 中压(MV) 1kV<UN≤35kV - * 高压(HV) 35kV<UN≤220kV - * 超高压(EHV),220kV<UN,参照HV执行 - */ - public static void voltageFluctuation(Overlimit overlimit, Float voltageLevel) { - if (voltageLevel < Float.parseFloat(DicDataEnum.KV35.getCode())) { - overlimit.setVoltageFluctuation(3.0f); - } else { - overlimit.setVoltageFluctuation(2.5f); - } - } - - - - /** - * 电压闪变 - * ≤110kV 1 - * >110kV 0.8 - */ - public static void voltageFlicker(Overlimit overlimit, Float voltageLevel) { - if (voltageLevel <= Float.parseFloat(DicDataEnum.KV110.getCode())) { - overlimit.setFlicker(1.0f); - } else { - overlimit.setFlicker(0.8f); - } - } - - - /** - * 总谐波电压畸变率 - * - * - */ - public static void totalHarmonicDistortion(Overlimit overlimit, Float voltageLevel) { - float result = 3.14159f; - if (voltageLevel < Float.parseFloat(DicDataEnum.KV6.getCode())) { - result = 5.0f; - } else if(voltageLevel >= Float.parseFloat(DicDataEnum.KV6.getCode()) && voltageLevel <= Float.parseFloat(DicDataEnum.KV20.getCode())){ - result = 4.0f; - } else if(voltageLevel >= Float.parseFloat(DicDataEnum.KV35.getCode()) && voltageLevel <= Float.parseFloat(DicDataEnum.KV66.getCode())){ - result = 3.0f; - } else if(voltageLevel >= Float.parseFloat(DicDataEnum.KV110.getCode()) && voltageLevel <= Float.parseFloat(DicDataEnum.KV1000.getCode())){ - result = 2.0f; - } - overlimit.setUaberrance(result); - } - - - - /** - * 谐波电压含有率 - */ - public static void uHarm(Overlimit overlimit, Float voltageLevel) { - float resultOdd = 3.14159f,resultEven = 3.14159f; - if (voltageLevel < Float.parseFloat(DicDataEnum.KV6.getCode())) { - resultOdd = 4.0f; - resultEven = 2.0f; - } else if(voltageLevel >= Float.parseFloat(DicDataEnum.KV6.getCode()) && voltageLevel <= Float.parseFloat(DicDataEnum.KV20.getCode())){ - resultOdd = 3.2f; - resultEven = 1.6f; - } else if(voltageLevel >= Float.parseFloat(DicDataEnum.KV35.getCode()) && voltageLevel <= Float.parseFloat(DicDataEnum.KV66.getCode())){ - resultOdd = 2.4f; - resultEven = 1.2f; - } else if(voltageLevel >= Float.parseFloat(DicDataEnum.KV110.getCode()) && voltageLevel <= Float.parseFloat(DicDataEnum.KV1000.getCode())){ - resultOdd = 1.6f; - resultEven = 0.8f; - } - overlimit.buildUharm(resultEven,resultOdd); - } - - - /** - * 负序电压不平衡(三相电压不平衡度) - * - */ - public static void threeVoltageUnbalance(Overlimit overlimit) { - overlimit.setUbalance(2.0f); - overlimit.setShortUbalance(4.0f); - } - - - /*---------------------------------谐波电流限值start-----------------------------------*/ - - /** - * 谐波电流限值 - */ - public static void iHarm(Overlimit overlimit, Float voltageLevel,Float protocolCapacity,Float devCapacity,Float shortCapacity) { - float calCap = shortCapacity/getDlCapByVoltageLevel(voltageLevel); - //24谐波电流幅值 - Float[] iHarmTem = new Float[49]; - for (int i = 0; i <= 48; i++) { - float inHarm = iHarmCalculate(i+2,voltageLevel,protocolCapacity,devCapacity,calCap); - iHarmTem[i] = inHarm; - } - overlimit.buildIHarm(iHarmTem); - } - /** - * @Description: iHarmCalculate - * @Param: protocolCapacity 协议容量 devCapacity设备容量 calCap 短路容量 - * @return: float - * @Author: clam - * @Date: 2024/2/4 - */ - private static float iHarmCalculate(int nHarm, Float voltageLevel,float protocolCapacity, float devCapacity,float calCap) { - double tag = calCap*getHarmTag(nHarm,voltageLevel); - 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); - return bigDecimal.floatValue(); - } - - - /** - * 电流谐波限值 - */ - private static Double getHarmTag(Integer iCount, Float voltageLevel) { - int x, y; - if (voltageLevel < DicDataEnum.KV6.getValue()) { - x = 0; - } else if (voltageLevelFloat.parseFloat(DicDataEnum.V220.getCode())&&voltageLevel=Float.parseFloat(DicDataEnum.KV20.getCode())&&voltageLevel=Float.parseFloat(DicDataEnum.KV35.getCode())&&voltageLevel=Float.parseFloat(DicDataEnum.KV66.getCode())&&voltageLevel<=Float.parseFloat(DicDataEnum.KV110.getCode())){ +// voltageDev = 7.0f; +// uvoltageDev=-3.0f; +// }else if(voltageLevel>Float.parseFloat(DicDataEnum.KV110.getCode())){ +// voltageDev = 10.0f; +// uvoltageDev=-10.0f; +// } +// overlimit.setVoltageDev(voltageDev); +// overlimit.setUvoltageDev(uvoltageDev); +// } +// +// +// /** +// * 频率偏差 +// * 默认限值:±0.2Hz(即:-0.2 Hz≤限值≤0.2 Hz) +// */ +// public static void frequency(Overlimit overlimit) { +// overlimit.setFreqDev(0.2f); +// } +// +// +// /** +// * 电压波动 +// * 对LV、MV:0≤限值≤3%;对HV:0≤限值≤2.5%。 +// * LV、MV、HV的定义: +// * 低压(LV) UN≤1kV +// * 中压(MV) 1kV<UN≤35kV +// * 高压(HV) 35kV<UN≤220kV +// * 超高压(EHV),220kV<UN,参照HV执行 +// */ +// public static void voltageFluctuation(Overlimit overlimit, Float voltageLevel) { +// if (voltageLevel < Float.parseFloat(DicDataEnum.KV35.getCode())) { +// overlimit.setVoltageFluctuation(3.0f); +// } else { +// overlimit.setVoltageFluctuation(2.5f); +// } +// } +// +// +// +// /** +// * 电压闪变 +// * ≤110kV 1 +// * >110kV 0.8 +// */ +// public static void voltageFlicker(Overlimit overlimit, Float voltageLevel) { +// if (voltageLevel <= Float.parseFloat(DicDataEnum.KV110.getCode())) { +// overlimit.setFlicker(1.0f); +// } else { +// overlimit.setFlicker(0.8f); +// } +// } +// +// +// /** +// * 总谐波电压畸变率 +// * +// * +// */ +// public static void totalHarmonicDistortion(Overlimit overlimit, Float voltageLevel) { +// float result = 3.14159f; +// if (voltageLevel < Float.parseFloat(DicDataEnum.KV6.getCode())) { +// result = 5.0f; +// } else if(voltageLevel >= Float.parseFloat(DicDataEnum.KV6.getCode()) && voltageLevel <= Float.parseFloat(DicDataEnum.KV20.getCode())){ +// result = 4.0f; +// } else if(voltageLevel >= Float.parseFloat(DicDataEnum.KV35.getCode()) && voltageLevel <= Float.parseFloat(DicDataEnum.KV66.getCode())){ +// result = 3.0f; +// } else if(voltageLevel >= Float.parseFloat(DicDataEnum.KV110.getCode()) && voltageLevel <= Float.parseFloat(DicDataEnum.KV1000.getCode())){ +// result = 2.0f; +// } +// overlimit.setUaberrance(result); +// } +// +// +// +// /** +// * 谐波电压含有率 +// */ +// public static void uHarm(Overlimit overlimit, Float voltageLevel) { +// float resultOdd = 3.14159f,resultEven = 3.14159f; +// if (voltageLevel < Float.parseFloat(DicDataEnum.KV6.getCode())) { +// resultOdd = 4.0f; +// resultEven = 2.0f; +// } else if(voltageLevel >= Float.parseFloat(DicDataEnum.KV6.getCode()) && voltageLevel <= Float.parseFloat(DicDataEnum.KV20.getCode())){ +// resultOdd = 3.2f; +// resultEven = 1.6f; +// } else if(voltageLevel >= Float.parseFloat(DicDataEnum.KV35.getCode()) && voltageLevel <= Float.parseFloat(DicDataEnum.KV66.getCode())){ +// resultOdd = 2.4f; +// resultEven = 1.2f; +// } else if(voltageLevel >= Float.parseFloat(DicDataEnum.KV110.getCode()) && voltageLevel <= Float.parseFloat(DicDataEnum.KV1000.getCode())){ +// resultOdd = 1.6f; +// resultEven = 0.8f; +// } +// overlimit.buildUharm(resultEven,resultOdd); +// } +// +// +// /** +// * 负序电压不平衡(三相电压不平衡度) +// * +// */ +// public static void threeVoltageUnbalance(Overlimit overlimit) { +// overlimit.setUbalance(2.0f); +// overlimit.setShortUbalance(4.0f); +// } +// +// +// /*---------------------------------谐波电流限值start-----------------------------------*/ +// +// /** +// * 谐波电流限值 +// */ +// public static void iHarm(Overlimit overlimit, Float voltageLevel,Float protocolCapacity,Float devCapacity,Float shortCapacity) { +// float calCap = shortCapacity/getDlCapByVoltageLevel(voltageLevel); +// //24谐波电流幅值 +// Float[] iHarmTem = new Float[49]; +// for (int i = 0; i <= 48; i++) { +// float inHarm = iHarmCalculate(i+2,voltageLevel,protocolCapacity,devCapacity,calCap); +// iHarmTem[i] = inHarm; +// } +// overlimit.buildIHarm(iHarmTem); +// } +// /** +// * @Description: iHarmCalculate +// * @Param: protocolCapacity 协议容量 devCapacity设备容量 calCap 短路容量 +// * @return: float +// * @Author: clam +// * @Date: 2024/2/4 +// */ +// private static float iHarmCalculate(int nHarm, Float voltageLevel,float protocolCapacity, float devCapacity,float calCap) { +// double tag = calCap*getHarmTag(nHarm,voltageLevel); +// 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); +// return bigDecimal.floatValue(); +// } +// +// +// /** +// * 电流谐波限值 +// */ +// private static Double getHarmTag(Integer iCount, Float voltageLevel) { +// int x, y; +// if (voltageLevel < DicDataEnum.KV6.getValue()) { +// x = 0; +// } else if (voltageLevel - * Mapper 接口 - *

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

+// * Mapper 接口 +// *

+// * +// * @author cdf +// * @since 2022-01-04 +// */ +//@DS("sjzx") +//@Mapper +//public interface OverlimitMapper extends BaseMapper { +// +//} diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/IOverLimitService.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/IOverLimitService.java index a9721d4..ad4b1e7 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/IOverLimitService.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/IOverLimitService.java @@ -2,8 +2,8 @@ package com.njcn.csdevice.service; import com.baomidou.mybatisplus.extension.service.IService; -import com.njcn.csdevice.pojo.po.Overlimit; import com.njcn.csdevice.pojo.vo.LineOverLimitVO; +import com.njcn.device.biz.pojo.po.Overlimit; /** *

diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsGroupServiceImpl.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsGroupServiceImpl.java index e2796ef..09c5b05 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsGroupServiceImpl.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsGroupServiceImpl.java @@ -38,6 +38,8 @@ import com.njcn.csharmonic.constant.HarmonicConstant; import com.njcn.csharmonic.param.*; import com.njcn.csharmonic.pojo.vo.ThdDataTdVO; 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.dto.EventDataSetDTO; import com.njcn.influx.pojo.dto.StatisticalDataDTO; @@ -1126,7 +1128,7 @@ public class CsGroupServiceImpl extends ServiceImpl impl } else { result.addAll(dataList); } - + } } return result; diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsLedgerServiceImpl.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsLedgerServiceImpl.java index 1172e46..0906288 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsLedgerServiceImpl.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsLedgerServiceImpl.java @@ -860,7 +860,7 @@ public class CsLedgerServiceImpl extends ServiceImpl i @Override public List objTree() { List result = new ArrayList<>(); - String userId = "fa37b93cc90d4c1784ca8f6debddee1a"; + String userId = RequestUtil.getUserIndex(); UserVO userVO = userFeignClient.getUserById(userId).getData(); List devIds; if (userVO.getType().equals(UserType.SUPER_ADMINISTRATOR) || userVO.getType().equals(UserType.ADMINISTRATOR)) { diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/IcdServiceImpl.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/IcdServiceImpl.java index 6579361..de8d458 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/IcdServiceImpl.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/IcdServiceImpl.java @@ -11,7 +11,6 @@ import com.alibaba.csp.sentinel.util.StringUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.njcn.access.utils.ChannelObjectUtil; import com.njcn.common.pojo.exception.BusinessException; -import com.njcn.csdevice.mapper.OverlimitMapper; import com.njcn.csdevice.param.IcdBzParam; import com.njcn.csdevice.param.IcdLedgerParam; 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.DeviceInfo; import com.njcn.csdevice.service.*; -import com.njcn.csdevice.utils.COverlimitUtil; import com.njcn.csharmonic.api.EventFeignClient; 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.template.BZEventMessageTemplate; import com.njcn.redis.pojo.enums.AppRedisKey; diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/OverLimitServiceImpl.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/OverLimitServiceImpl.java index b51a253..f7570ed 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/OverLimitServiceImpl.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/OverLimitServiceImpl.java @@ -3,10 +3,10 @@ package com.njcn.csdevice.service.impl; import cn.hutool.core.bean.BeanUtil; import com.baomidou.dynamic.datasource.annotation.DS; 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.service.IOverLimitService; +import com.njcn.device.biz.mapper.OverlimitMapper; +import com.njcn.device.biz.pojo.po.Overlimit; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/WlRecordServiceImpl.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/WlRecordServiceImpl.java index fe7cd4d..a77da0c 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/WlRecordServiceImpl.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/WlRecordServiceImpl.java @@ -24,7 +24,6 @@ import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO; import com.njcn.csdevice.pojo.param.WlRecordParam; import com.njcn.csdevice.pojo.po.CsDataSet; 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.vo.RecordAllDevTreeVo; 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.IWlRecordService; import com.njcn.csdevice.util.InfluxDbParamUtil; -import com.njcn.csdevice.utils.COverlimitUtil; import com.njcn.csdevice.utils.StringUtil; import com.njcn.csharmonic.param.CommonStatisticalQueryParam; 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.pojo.bo.CommonQueryParam; import com.njcn.influx.pojo.constant.InfluxDBTableConstant; diff --git a/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/pojo/dto/ReportTemplateDTO.java b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/pojo/dto/ReportTemplateDTO.java index a41891a..91d6cf6 100644 --- a/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/pojo/dto/ReportTemplateDTO.java +++ b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/pojo/dto/ReportTemplateDTO.java @@ -56,4 +56,6 @@ public class ReportTemplateDTO { */ private String value; + private String lowValue; + } diff --git a/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/pojo/param/ReportSearchParam.java b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/pojo/param/ReportSearchParam.java index 796a63b..520f436 100644 --- a/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/pojo/param/ReportSearchParam.java +++ b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/pojo/param/ReportSearchParam.java @@ -1,42 +1,42 @@ -package com.njcn.csharmonic.pojo.param; - -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -/** - * 模板动态更新数据 - * - * @author qijian - * @date 2022/10/11 - */ -@Data -public class ReportSearchParam { - - @ApiModelProperty(name = "lineId",value = "监测点id") - private String lineId; - - @ApiModelProperty(name = "tempId",value = "模板ID") - private String tempId; - - @ApiModelProperty(name = "activation",value = "激活状态") - private Integer activation; - - @ApiModelProperty(name = "type",value = "报表类型") - private Integer type; - - @ApiModelProperty(name = "startTime",value = "开始时间") - private String startTime; - - @ApiModelProperty(name = "endTime",value = "结束时间") - private String endTime; - - @ApiModelProperty(name = "deptId",value = "部门ID") - private String deptId; - - //目前用于区分不同系统资源,null默认 1.无线系统,配合cs-device - private Integer resourceType; - - //浙江无线报表特殊标识 null为通用报表 1.浙江无线报表 - private Integer customType; - -} +//package com.njcn.csharmonic.pojo.param; +// +//import io.swagger.annotations.ApiModelProperty; +//import lombok.Data; +// +///** +// * 模板动态更新数据 +// * +// * @author qijian +// * @date 2022/10/11 +// */ +//@Data +//public class ReportSearchParam { +// +// @ApiModelProperty(name = "lineId",value = "监测点id") +// private String lineId; +// +// @ApiModelProperty(name = "tempId",value = "模板ID") +// private String tempId; +// +// @ApiModelProperty(name = "activation",value = "激活状态") +// private Integer activation; +// +// @ApiModelProperty(name = "type",value = "报表类型") +// private Integer type; +// +// @ApiModelProperty(name = "startTime",value = "开始时间") +// private String startTime; +// +// @ApiModelProperty(name = "endTime",value = "结束时间") +// private String endTime; +// +// @ApiModelProperty(name = "deptId",value = "部门ID") +// private String deptId; +// +// //目前用于区分不同系统资源,null默认 1.无线系统,配合cs-device +// private Integer resourceType; +// +// //浙江无线报表特殊标识 null为通用报表 1.浙江无线报表 +// private Integer customType; +// +//} diff --git a/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/pojo/po/ExcelRptTemp.java b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/pojo/po/ExcelRptTemp.java index c03e095..b611389 100644 --- a/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/pojo/po/ExcelRptTemp.java +++ b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/pojo/po/ExcelRptTemp.java @@ -1,37 +1,37 @@ -package com.njcn.csharmonic.pojo.po; - -import com.baomidou.mybatisplus.annotation.TableName; -import com.njcn.db.bo.BaseEntity; -import lombok.Data; -import lombok.EqualsAndHashCode; - - -/** - * pqs - * 自定义报表 - * @author cdf - * @date 2022/8/16 - */ -@Data -@EqualsAndHashCode(callSuper = true) -@TableName(value = "sys_excel_rpt_temp") -public class ExcelRptTemp extends BaseEntity { - private String id; - - private String name; - - private String content; - - private Integer activation; - - private Integer state; - - private String valueTitle; - - private String reportType; - - private String reportForm; - - private Integer sort; - -} +//package com.njcn.csharmonic.pojo.po; +// +//import com.baomidou.mybatisplus.annotation.TableName; +//import com.njcn.db.bo.BaseEntity; +//import lombok.Data; +//import lombok.EqualsAndHashCode; +// +// +///** +// * pqs +// * 自定义报表 +// * @author cdf +// * @date 2022/8/16 +// */ +//@Data +//@EqualsAndHashCode(callSuper = true) +//@TableName(value = "sys_excel_rpt_temp") +//public class ExcelRptTemp extends BaseEntity { +// private String id; +// +// private String name; +// +// private String content; +// +// private Integer activation; +// +// private Integer state; +// +// private String valueTitle; +// +// private String reportType; +// +// private String reportForm; +// +// private Integer sort; +// +//} diff --git a/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/pojo/vo/ReportTemplateVO.java b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/pojo/vo/ReportTemplateVO.java index b3cc2e8..543c570 100644 --- a/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/pojo/vo/ReportTemplateVO.java +++ b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/pojo/vo/ReportTemplateVO.java @@ -1,34 +1,34 @@ -package com.njcn.csharmonic.pojo.vo; - -import com.njcn.db.bo.BaseEntity; -import lombok.Data; -import lombok.EqualsAndHashCode; - -/** - * pqs - * 自定义报表 - * @author cdf - * @date 2022/8/16 - */ -@Data -@EqualsAndHashCode(callSuper = true) -public class ReportTemplateVO extends BaseEntity { - private String id; - - private String name; - - private String content; - - private String deptId; - - private Integer activation; - - private Integer state; - - private String deptName; - - private String reportType; - - private String reportForm; - -} +//package com.njcn.csharmonic.pojo.vo; +// +//import com.njcn.db.bo.BaseEntity; +//import lombok.Data; +//import lombok.EqualsAndHashCode; +// +///** +// * pqs +// * 自定义报表 +// * @author cdf +// * @date 2022/8/16 +// */ +//@Data +//@EqualsAndHashCode(callSuper = true) +//public class ReportTemplateVO extends BaseEntity { +// private String id; +// +// private String name; +// +// private String content; +// +// private String deptId; +// +// private Integer activation; +// +// private Integer state; +// +// private String deptName; +// +// private String reportType; +// +// private String reportForm; +// +//} diff --git a/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/utils/report/ClearPathUtil.java b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/utils/report/ClearPathUtil.java index 5e06bb0..58c3e58 100644 --- a/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/utils/report/ClearPathUtil.java +++ b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/utils/report/ClearPathUtil.java @@ -1,142 +1,142 @@ -package com.njcn.csharmonic.utils.report; - -/** - * @author hongawen - * @date: 2020/8/20 13:36 - */ -public class ClearPathUtil { - - /** - * 针对漏洞,新增的特殊字符替换的扫描方法 - */ - public static String cleanString(String str) { - if (str == null) { - return null; - } - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < str.length(); ++i) { - sb.append(cleanChar(str.charAt(i))); - } - return sb.toString(); - } - - private static char cleanChar(char ch) { - - // 0 - 9 - for (int i = 48; i < 58; ++i) { - if (ch == i) { - return (char) i; - } - } - - // 'A' - 'Z' - for (int i = 65; i < 91; ++i) { - if (ch == i) { - return (char) i; - } - } - - // 'a' - 'z' - for (int i = 97; i < 123; ++i) { - if (ch == i) { - return (char) i; - } - } - - // other valid characters - switch (ch) { - case '/': - return '/'; - case '.': - return '.'; - case '-': - return '-'; - case '_': - return '_'; - case ',': - return ','; - case ' ': - return ' '; - case '!': - return '!'; - case '@': - return '@'; - case '#': - return '#'; - case '$': - return '$'; - case '%': - return '%'; - case '^': - return '^'; - case '&': - return '&'; - case '*': - return '*'; - case '(': - return '('; - case ')': - return ')'; - case '+': - return '+'; - case '=': - return '='; - case ':': - return ':'; - case ';': - return ';'; - case '?': - return '?'; - case '"': - return '"'; - case '<': - return '<'; - case '>': - return '>'; - case '`': - return '`'; - case '\\': - return '/'; - case 'I': - return 'I'; - case 'Ⅱ': - return 'Ⅱ'; - case 'Ⅲ': - return 'Ⅲ'; - case 'Ⅳ': - return 'Ⅳ'; - case 'Ⅴ': - return 'Ⅴ'; - case 'Ⅵ': - return 'Ⅵ'; - case 'Ⅶ': - return 'Ⅶ'; - case 'Ⅷ': - return 'Ⅷ'; - case 'Ⅸ': - return 'Ⅸ'; - - case 'V': - return 'V'; - case 'X': - return 'X'; - case 'Ⅹ': - return 'Ⅹ'; - default: - if (isChineseChar(ch)) { - return ch; - } - return '%'; - } - } - - // 根据Unicode编码判断中文汉字和符号 - private static boolean isChineseChar(char c) { - Character.UnicodeBlock ub = Character.UnicodeBlock.of(c); - 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_SYMBOLS_AND_PUNCTUATION || ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS - || ub == Character.UnicodeBlock.GENERAL_PUNCTUATION; - } - -} +//package com.njcn.csharmonic.utils.report; +// +///** +// * @author hongawen +// * @date: 2020/8/20 13:36 +// */ +//public class ClearPathUtil { +// +// /** +// * 针对漏洞,新增的特殊字符替换的扫描方法 +// */ +// public static String cleanString(String str) { +// if (str == null) { +// return null; +// } +// StringBuilder sb = new StringBuilder(); +// for (int i = 0; i < str.length(); ++i) { +// sb.append(cleanChar(str.charAt(i))); +// } +// return sb.toString(); +// } +// +// private static char cleanChar(char ch) { +// +// // 0 - 9 +// for (int i = 48; i < 58; ++i) { +// if (ch == i) { +// return (char) i; +// } +// } +// +// // 'A' - 'Z' +// for (int i = 65; i < 91; ++i) { +// if (ch == i) { +// return (char) i; +// } +// } +// +// // 'a' - 'z' +// for (int i = 97; i < 123; ++i) { +// if (ch == i) { +// return (char) i; +// } +// } +// +// // other valid characters +// switch (ch) { +// case '/': +// return '/'; +// case '.': +// return '.'; +// case '-': +// return '-'; +// case '_': +// return '_'; +// case ',': +// return ','; +// case ' ': +// return ' '; +// case '!': +// return '!'; +// case '@': +// return '@'; +// case '#': +// return '#'; +// case '$': +// return '$'; +// case '%': +// return '%'; +// case '^': +// return '^'; +// case '&': +// return '&'; +// case '*': +// return '*'; +// case '(': +// return '('; +// case ')': +// return ')'; +// case '+': +// return '+'; +// case '=': +// return '='; +// case ':': +// return ':'; +// case ';': +// return ';'; +// case '?': +// return '?'; +// case '"': +// return '"'; +// case '<': +// return '<'; +// case '>': +// return '>'; +// case '`': +// return '`'; +// case '\\': +// return '/'; +// case 'I': +// return 'I'; +// case 'Ⅱ': +// return 'Ⅱ'; +// case 'Ⅲ': +// return 'Ⅲ'; +// case 'Ⅳ': +// return 'Ⅳ'; +// case 'Ⅴ': +// return 'Ⅴ'; +// case 'Ⅵ': +// return 'Ⅵ'; +// case 'Ⅶ': +// return 'Ⅶ'; +// case 'Ⅷ': +// return 'Ⅷ'; +// case 'Ⅸ': +// return 'Ⅸ'; +// +// case 'V': +// return 'V'; +// case 'X': +// return 'X'; +// case 'Ⅹ': +// return 'Ⅹ'; +// default: +// if (isChineseChar(ch)) { +// return ch; +// } +// return '%'; +// } +// } +// +// // 根据Unicode编码判断中文汉字和符号 +// private static boolean isChineseChar(char c) { +// Character.UnicodeBlock ub = Character.UnicodeBlock.of(c); +// 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_SYMBOLS_AND_PUNCTUATION || ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS +// || ub == Character.UnicodeBlock.GENERAL_PUNCTUATION; +// } +// +//} diff --git a/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/utils/report/CustomXWPFDocument.java b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/utils/report/CustomXWPFDocument.java index aee0232..c8645bc 100644 --- a/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/utils/report/CustomXWPFDocument.java +++ b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/utils/report/CustomXWPFDocument.java @@ -1,83 +1,83 @@ -package com.njcn.csharmonic.utils.report; - -import lombok.extern.slf4j.Slf4j; -import org.apache.poi.openxml4j.opc.OPCPackage; -import org.apache.poi.xwpf.usermodel.XWPFDocument; -import org.apache.poi.xwpf.usermodel.XWPFParagraph; -import org.apache.xmlbeans.XmlException; -import org.apache.xmlbeans.XmlToken; -import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps; -import org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D; -import org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.CTInline; - -import java.io.IOException; -import java.io.InputStream; - -@Slf4j -public class CustomXWPFDocument extends XWPFDocument { - // 日志记录 - public CustomXWPFDocument(InputStream in) throws IOException { - super(in); - } - - public CustomXWPFDocument() { - super(); - } - - public CustomXWPFDocument(OPCPackage pkg) throws IOException { - super(pkg); - } - - /** - * @param id - * @param width - * 宽 - * @param height - * 高 - * @param paragraph - * 段落 - */ - public void createPicture(int id, int width, int height,String blipId, XWPFParagraph paragraph) { - final int EMU = 9525; - width *= EMU; - height *= EMU; -// String blipId = getAllPictures().get(id).getPackageRelationship().getId(); - CTInline inline = paragraph.createRun().getCTR().addNewDrawing().addNewInline(); - String picXml = "" + "" - + " " - + " " - + " " + " " - + " " + " " + " " - + " " - + " " + " " + " " - + " " + " " + " " - + " " + " " + " " + " " - + " " + " " + " " - + " " + " " + ""; - - inline.addNewGraphic().addNewGraphicData(); - XmlToken xmlToken = null; - try { - xmlToken = XmlToken.Factory.parse(picXml); - } catch (XmlException xe) { - log.error("生成报表发生异常,异常是"+xe.getMessage()); - } - inline.set(xmlToken); - - inline.setDistT(0); - inline.setDistB(0); - inline.setDistL(0); - inline.setDistR(0); - - CTPositiveSize2D extent = inline.addNewExtent(); - extent.setCx(width); - extent.setCy(height); - - CTNonVisualDrawingProps docPr = inline.addNewDocPr(); - docPr.setId(id); - docPr.setName("图片" + id); - docPr.setDescr("测试"); - } -} +//package com.njcn.csharmonic.utils.report; +// +//import lombok.extern.slf4j.Slf4j; +//import org.apache.poi.openxml4j.opc.OPCPackage; +//import org.apache.poi.xwpf.usermodel.XWPFDocument; +//import org.apache.poi.xwpf.usermodel.XWPFParagraph; +//import org.apache.xmlbeans.XmlException; +//import org.apache.xmlbeans.XmlToken; +//import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps; +//import org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D; +//import org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.CTInline; +// +//import java.io.IOException; +//import java.io.InputStream; +// +//@Slf4j +//public class CustomXWPFDocument extends XWPFDocument { +// // 日志记录 +// public CustomXWPFDocument(InputStream in) throws IOException { +// super(in); +// } +// +// public CustomXWPFDocument() { +// super(); +// } +// +// public CustomXWPFDocument(OPCPackage pkg) throws IOException { +// super(pkg); +// } +// +// /** +// * @param id +// * @param width +// * 宽 +// * @param height +// * 高 +// * @param paragraph +// * 段落 +// */ +// public void createPicture(int id, int width, int height,String blipId, XWPFParagraph paragraph) { +// final int EMU = 9525; +// width *= EMU; +// height *= EMU; +//// String blipId = getAllPictures().get(id).getPackageRelationship().getId(); +// CTInline inline = paragraph.createRun().getCTR().addNewDrawing().addNewInline(); +// String picXml = "" + "" +// + " " +// + " " +// + " " + " " +// + " " + " " + " " +// + " " +// + " " + " " + " " +// + " " + " " + " " +// + " " + " " + " " + " " +// + " " + " " + " " +// + " " + " " + ""; +// +// inline.addNewGraphic().addNewGraphicData(); +// XmlToken xmlToken = null; +// try { +// xmlToken = XmlToken.Factory.parse(picXml); +// } catch (XmlException xe) { +// log.error("生成报表发生异常,异常是"+xe.getMessage()); +// } +// inline.set(xmlToken); +// +// inline.setDistT(0); +// inline.setDistB(0); +// inline.setDistL(0); +// inline.setDistR(0); +// +// CTPositiveSize2D extent = inline.addNewExtent(); +// extent.setCx(width); +// extent.setCy(height); +// +// CTNonVisualDrawingProps docPr = inline.addNewDocPr(); +// docPr.setId(id); +// docPr.setName("图片" + id); +// docPr.setDescr("测试"); +// } +//} diff --git a/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/utils/report/FloatUtils.java b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/utils/report/FloatUtils.java index 0e9a3b7..de04db4 100644 --- a/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/utils/report/FloatUtils.java +++ b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/utils/report/FloatUtils.java @@ -1,28 +1,28 @@ -package com.njcn.csharmonic.utils.report; - -import java.math.BigDecimal; - -/** - * @author hongawen(创建) -----denghuajun(移植使用) - * @Date: 2018/8/27 11:29 - */ -public class FloatUtils { - - - /** - * 保留传入进来的float的两位小数,四舍五入的方式 - * - * @param data Float参数 - */ - public static float get2Float(Float data) { - if (data == null || data.isNaN() || data.isInfinite()) { - return 0f; - } - int scale = 2;//设置位数 - int roundingMode = 4;//表示四舍五入,可以选择其他舍值方式,例如去尾,等等. - BigDecimal bd = new BigDecimal(data); - bd = bd.setScale(scale, roundingMode); - data = bd.floatValue(); - return data; - } -} +//package com.njcn.csharmonic.utils.report; +// +//import java.math.BigDecimal; +// +///** +// * @author hongawen(创建) -----denghuajun(移植使用) +// * @Date: 2018/8/27 11:29 +// */ +//public class FloatUtils { +// +// +// /** +// * 保留传入进来的float的两位小数,四舍五入的方式 +// * +// * @param data Float参数 +// */ +// public static float get2Float(Float data) { +// if (data == null || data.isNaN() || data.isInfinite()) { +// return 0f; +// } +// int scale = 2;//设置位数 +// int roundingMode = 4;//表示四舍五入,可以选择其他舍值方式,例如去尾,等等. +// BigDecimal bd = new BigDecimal(data); +// bd = bd.setScale(scale, roundingMode); +// data = bd.floatValue(); +// return data; +// } +//} diff --git a/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/utils/report/PubUtils.java b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/utils/report/PubUtils.java index 393dd75..6737fc7 100644 --- a/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/utils/report/PubUtils.java +++ b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/utils/report/PubUtils.java @@ -1,224 +1,224 @@ -package com.njcn.csharmonic.utils.report; - -import cn.hutool.core.util.ObjectUtil; -import lombok.SneakyThrows; -import lombok.extern.slf4j.Slf4j; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.text.SimpleDateFormat; -import java.util.*; - -/** - * @author wr - * @description - * @date 2023/4/10 17:39 - */ -@Slf4j -public class PubUtils { - public static boolean createFile(String destFileName) { - File file = new File(destFileName); - if (file.exists()) { - log.warn("创建单个文件" + destFileName + "失败,目标文件已存在!"); - return false; - } - if (destFileName.endsWith(File.separator)) { - log.warn("创建单个文件" + destFileName + "失败,目标文件不能为目录!"); - return false; - } - //判断目标文件所在的目录是否存在 - if (!file.getParentFile().exists()) { - //如果目标文件所在的目录不存在,则创建父目录 - log.warn("目标文件所在目录不存在,准备创建它!"); - if (!file.getParentFile().mkdirs()) { - log.warn("创建目标文件所在目录失败!"); - return false; - } - } - //创建目标文件 - try { - if (file.createNewFile()) { - log.warn("创建单个文件" + destFileName + "成功!"); - return true; - } else { - log.warn("创建单个文件" + destFileName + "失败!"); - return false; - } - } catch (IOException e) { - log.warn("创建单个文件" + destFileName + "失败!" + e.getMessage()); - return false; - } - } - - /** - * 读取配置文件 - * - * @param cl 类名字 - * @param strPropertiesName 配置文件名称 - */ - public static Properties readProperties(ClassLoader cl, String strPropertiesName) { - Properties pros = new Properties(); - InputStream in = null; - try { - in = cl.getResourceAsStream(strPropertiesName); - pros.load(in); - } catch (Exception e) { - log.error("读取配置文件失败失败:" + e.getMessage()); - } finally { - if (in != null) { - PubUtils.safeClose(in, "安全关闭读取配置文件失败,异常为:"); - } - } - return pros; - } - - /** - * 安全关闭InputStream - * - * @param s - */ - public static void safeClose(InputStream s, String strError) { - if (s != null) { - try { - s.close(); - } catch (IOException e) { - log.error(strError + e.toString()); - } - } - } - - public static Double dataLimits(Double data) { - if (ObjectUtil.isNotNull(data)) { - return data > 100 ? 100 : data; - } - return data; - } - - @SneakyThrows - public static List getIntervalTime(String startTime, String endTime) { - List times = new ArrayList<>(); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM"); - Date start = sdf.parse(startTime); - Date end = sdf.parse(endTime); - // 同月 - if (start.getTime() == end.getTime()) { - String time = startTime.substring(0, 7); - times.add(time); - } else if (start.getYear() == end.getYear()) { - // 同年 - int startM = start.getMonth() + 1; - int endM = end.getMonth() + 1; - int temp = endM - startM; - for (int i = 0; i <= temp; i++) { - String time = start.getYear() + 1900 + ""; - int month = startM + i; - if (month < 10) { - time = time + "-0" + month; - } else { - time = time + "-" + month; - } - times.add(time); - } - } else { - // 不同年!!!!这里忽略了年份之间跨年的情况 - int startY = start.getYear() + 1900; - int startM = start.getMonth() + 1; - int endY = end.getYear() + 1900; - int endM = end.getMonth() + 1; - int tempS = 12 - startM; - // 连续的年份 - if (endY - startY == 1) { - // 第一年的时间获取 - for (int i = 0; i <= tempS; i++) { - int month = startM + i; - String time = startY + "-"; - if (month < 10) { - time = time + "0" + month; - } else { - time = time + month; - } - times.add(time); - } - // 第二年的时间获取 - - for (int i = 1; i <= endM; i++) { - String time = endY + "-"; - if (i < 10) { - time = time + "0" + i; - } else { - time = time + i; - } - times.add(time); - } - } else { - // 不连续的年份 - // 第一年的时间获取 - for (int i = 0; i <= tempS; i++) { - int month = startM + i; - String time = startY + "-"; - if (month < 10) { - time = time + "0" + month; - } else { - time = time + month; - } - times.add(time); - } - int tempY = endY - startY; - // 中间年份的时间 - for (int i = 1; i < tempY; i++) { - for (int j = 1; j <= 12; j++) { - String time = startY + i + "-"; - if (j < 10) { - time = time + "0" + j; - } else { - time = time + j; - } - times.add(time); - } - } - // 最后一年的时间获取 - for (int i = 1; i <= endM; i++) { - String time = endY + "-"; - if (i < 10) { - time = time + "0" + i; - } else { - time = time + i; - } - times.add(time); - } - } - - } - return times; - } - - @SneakyThrows - public static List getIntervalDateTime(Integer startTime, int beginDay, Integer endTime, Integer dd) { - List list = new ArrayList<>(); - Calendar calendar = Calendar.getInstance(Locale.CHINA); - calendar.set(startTime, endTime - 1, 1); - //年份 - int year = calendar.get(Calendar.YEAR); - //月份 - int month = calendar.get(Calendar.MONTH) + 1; - for (int i = beginDay; i <= dd; i++) { - String date = null; - if (month < 10 && i < 10) { - date = year + "-0" + month + "-0" + i; - } - if (month < 10 && i >= 10) { - date = year + "-0" + month + "-" + i; - } - if (month >= 10 && i < 10) { - date = year + "-" + month + "-0" + i; - } - if (month >= 10 && i >= 10) { - date = year + "-" + month + "-" + i; - } - - list.add(date); - } - return list; - } -} +//package com.njcn.csharmonic.utils.report; +// +//import cn.hutool.core.util.ObjectUtil; +//import lombok.SneakyThrows; +//import lombok.extern.slf4j.Slf4j; +// +//import java.io.File; +//import java.io.IOException; +//import java.io.InputStream; +//import java.text.SimpleDateFormat; +//import java.util.*; +// +///** +// * @author wr +// * @description +// * @date 2023/4/10 17:39 +// */ +//@Slf4j +//public class PubUtils { +// public static boolean createFile(String destFileName) { +// File file = new File(destFileName); +// if (file.exists()) { +// log.warn("创建单个文件" + destFileName + "失败,目标文件已存在!"); +// return false; +// } +// if (destFileName.endsWith(File.separator)) { +// log.warn("创建单个文件" + destFileName + "失败,目标文件不能为目录!"); +// return false; +// } +// //判断目标文件所在的目录是否存在 +// if (!file.getParentFile().exists()) { +// //如果目标文件所在的目录不存在,则创建父目录 +// log.warn("目标文件所在目录不存在,准备创建它!"); +// if (!file.getParentFile().mkdirs()) { +// log.warn("创建目标文件所在目录失败!"); +// return false; +// } +// } +// //创建目标文件 +// try { +// if (file.createNewFile()) { +// log.warn("创建单个文件" + destFileName + "成功!"); +// return true; +// } else { +// log.warn("创建单个文件" + destFileName + "失败!"); +// return false; +// } +// } catch (IOException e) { +// log.warn("创建单个文件" + destFileName + "失败!" + e.getMessage()); +// return false; +// } +// } +// +// /** +// * 读取配置文件 +// * +// * @param cl 类名字 +// * @param strPropertiesName 配置文件名称 +// */ +// public static Properties readProperties(ClassLoader cl, String strPropertiesName) { +// Properties pros = new Properties(); +// InputStream in = null; +// try { +// in = cl.getResourceAsStream(strPropertiesName); +// pros.load(in); +// } catch (Exception e) { +// log.error("读取配置文件失败失败:" + e.getMessage()); +// } finally { +// if (in != null) { +// PubUtils.safeClose(in, "安全关闭读取配置文件失败,异常为:"); +// } +// } +// return pros; +// } +// +// /** +// * 安全关闭InputStream +// * +// * @param s +// */ +// public static void safeClose(InputStream s, String strError) { +// if (s != null) { +// try { +// s.close(); +// } catch (IOException e) { +// log.error(strError + e.toString()); +// } +// } +// } +// +// public static Double dataLimits(Double data) { +// if (ObjectUtil.isNotNull(data)) { +// return data > 100 ? 100 : data; +// } +// return data; +// } +// +// @SneakyThrows +// public static List getIntervalTime(String startTime, String endTime) { +// List times = new ArrayList<>(); +// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM"); +// Date start = sdf.parse(startTime); +// Date end = sdf.parse(endTime); +// // 同月 +// if (start.getTime() == end.getTime()) { +// String time = startTime.substring(0, 7); +// times.add(time); +// } else if (start.getYear() == end.getYear()) { +// // 同年 +// int startM = start.getMonth() + 1; +// int endM = end.getMonth() + 1; +// int temp = endM - startM; +// for (int i = 0; i <= temp; i++) { +// String time = start.getYear() + 1900 + ""; +// int month = startM + i; +// if (month < 10) { +// time = time + "-0" + month; +// } else { +// time = time + "-" + month; +// } +// times.add(time); +// } +// } else { +// // 不同年!!!!这里忽略了年份之间跨年的情况 +// int startY = start.getYear() + 1900; +// int startM = start.getMonth() + 1; +// int endY = end.getYear() + 1900; +// int endM = end.getMonth() + 1; +// int tempS = 12 - startM; +// // 连续的年份 +// if (endY - startY == 1) { +// // 第一年的时间获取 +// for (int i = 0; i <= tempS; i++) { +// int month = startM + i; +// String time = startY + "-"; +// if (month < 10) { +// time = time + "0" + month; +// } else { +// time = time + month; +// } +// times.add(time); +// } +// // 第二年的时间获取 +// +// for (int i = 1; i <= endM; i++) { +// String time = endY + "-"; +// if (i < 10) { +// time = time + "0" + i; +// } else { +// time = time + i; +// } +// times.add(time); +// } +// } else { +// // 不连续的年份 +// // 第一年的时间获取 +// for (int i = 0; i <= tempS; i++) { +// int month = startM + i; +// String time = startY + "-"; +// if (month < 10) { +// time = time + "0" + month; +// } else { +// time = time + month; +// } +// times.add(time); +// } +// int tempY = endY - startY; +// // 中间年份的时间 +// for (int i = 1; i < tempY; i++) { +// for (int j = 1; j <= 12; j++) { +// String time = startY + i + "-"; +// if (j < 10) { +// time = time + "0" + j; +// } else { +// time = time + j; +// } +// times.add(time); +// } +// } +// // 最后一年的时间获取 +// for (int i = 1; i <= endM; i++) { +// String time = endY + "-"; +// if (i < 10) { +// time = time + "0" + i; +// } else { +// time = time + i; +// } +// times.add(time); +// } +// } +// +// } +// return times; +// } +// +// @SneakyThrows +// public static List getIntervalDateTime(Integer startTime, int beginDay, Integer endTime, Integer dd) { +// List list = new ArrayList<>(); +// Calendar calendar = Calendar.getInstance(Locale.CHINA); +// calendar.set(startTime, endTime - 1, 1); +// //年份 +// int year = calendar.get(Calendar.YEAR); +// //月份 +// int month = calendar.get(Calendar.MONTH) + 1; +// for (int i = beginDay; i <= dd; i++) { +// String date = null; +// if (month < 10 && i < 10) { +// date = year + "-0" + month + "-0" + i; +// } +// if (month < 10 && i >= 10) { +// date = year + "-0" + month + "-" + i; +// } +// if (month >= 10 && i < 10) { +// date = year + "-" + month + "-0" + i; +// } +// if (month >= 10 && i >= 10) { +// date = year + "-" + month + "-" + i; +// } +// +// list.add(date); +// } +// return list; +// } +//} diff --git a/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/utils/report/PublicDataUtils.java b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/utils/report/PublicDataUtils.java index cd01e41..376bb28 100644 --- a/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/utils/report/PublicDataUtils.java +++ b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/utils/report/PublicDataUtils.java @@ -1,30 +1,30 @@ -package com.njcn.csharmonic.utils.report; - -/** - * 数据公共工具类 - * - * @author qijian - * @version 1.0.0 - * @createTime 2022/10/14 - 10:07 - */ -public class PublicDataUtils { - /** - * 功能:下划线命名转驼峰命名 - * 将下划线替换为空格,将字符串根据空格分割成数组,再将每个单词首字母大写 - * @param s - * @return - */ - public static String underCamel(String s) - { - String separator = "_"; - String under=""; - s = s.toLowerCase().replace(separator, " "); - String sarr[]=s.split(" "); - for(int i=0;i params, String fileName,List> tableList, HttpServletResponse response) - throws Exception { - byte[] docBytes = null; - - path = ClearPathUtil.cleanString(path); - InputStream is = null; - CustomXWPFDocument doc = null; - //读取报告模板 - try { - Resource resource = resourceLoader.getResource("classpath:" + path); - if (!resource.exists()) { - throw new FileNotFoundException("模板文件未找到: " + path); - } - is = resource.getInputStream(); - doc = new CustomXWPFDocument(is); - if(CollUtil.isNotEmpty(tableList)){ - this.replaceInTable(doc, params,tableList); - }else{ - this.replaceInTable(doc, params); - } - // 替换表格里面的变量 - this.replaceInPara(doc, params); // 替换文本里面的变量 - } catch (IOException e) { - getError("获取报告模板异常,原因为:" + e); - } finally { - if (null != is) { - is.close(); - } - } - try { - ServletOutputStream outputStream = response.getOutputStream(); - response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\""); - response.setContentType("application/octet-stream;charset=UTF-8"); - doc.write(outputStream); - outputStream.close(); - } catch (Exception e) { - getError("输出稳态报告异常,原因为:" + e); - } finally { - if (doc != null) { - doc.close(); - } - } - } - - - - - // 辅助方法:字节数组转十六进制(便于打印排查) - private static String bytesToHex(byte[] bytes) { - StringBuilder sb = new StringBuilder(); - for (byte b : bytes) { - sb.append(String.format("%02X ", b)); - } - return sb.toString().trim(); - } - - - - - public InputStream getReportFile(String path, Map params, List> tableList) - throws Exception { - path = ClearPathUtil.cleanString(path); - InputStream inStream = null,in = null; - CustomXWPFDocument doc = null; - //读取报告模板 - try { - inStream = new ClassPathResource(path).getInputStream(); - doc = new CustomXWPFDocument(inStream); - this.replaceInTable(doc,params,tableList); - this.replaceInPara(doc, params); - } catch (IOException e) { - getError("获取报告模板异常,原因为:" + e); - } finally { - if (null != inStream) { - inStream.close(); - } - } - try { - //临时缓冲区 - ByteArrayOutputStream out = new ByteArrayOutputStream(); - doc.write(out); - byte[] docByteAry = out.toByteArray(); - in = new ByteArrayInputStream(docByteAry); - out.close(); - } catch (Exception e) { - getError("输出稳态报告异常,原因为:" + e); - } finally { - if (doc != null) { - doc.close(); - } - } - return in; - } - - - - public String getReportFileUrl(String path,String fileName,List> tableList, Map params) - throws Exception { - path = ClearPathUtil.cleanString(path); - InputStream inStream = null,in = null; - CustomXWPFDocument doc = null; - //读取报告模板 - try { - inStream = new ClassPathResource(path).getInputStream();; - doc = new CustomXWPFDocument(inStream); - if(CollUtil.isNotEmpty(tableList)){ - this.replaceInTable(doc, params,tableList); - }else{ - this.replaceInTable(doc, params); - } - this.replaceInPara(doc, params); // 替换文本里面的变量 - //临时缓冲区 - ByteArrayOutputStream out = new ByteArrayOutputStream(); - doc.write(out); - byte[] docByteAry = out.toByteArray(); - in = new ByteArrayInputStream(docByteAry); - out.close(); - } catch (IOException e) { - getError("获取报告模板异常,原因为:" + e); - } finally { - if (null != inStream) { - inStream.close(); - } - if (doc != null) { - doc.close(); - } - } - //上传文件服务器 - return fileStorageUtil.uploadStreamSpecifyName(in, OssPath.ONLINE_REPORT, fileName); - } - - - private static void getError(String e) { - log.error(e); - } - /** - * 替换段落里面的变量 - * - * @param doc 要替换的文档 - * @param params 参数 - */ - private void replaceInPara(CustomXWPFDocument doc, Map params) { - Iterator iterator = doc.getParagraphsIterator(); - List paragraphList = new ArrayList<>(); - XWPFParagraph para; - while (iterator.hasNext()) { - para = iterator.next(); - paragraphList.add(para); - } - processParagraphs(paragraphList, params, doc); - } - - private void replaceInTable(CustomXWPFDocument doc, Map params) { - Iterator it = doc.getTablesIterator(); - while (it.hasNext()) { - XWPFTable table = it.next(); - List rows = table.getRows(); - for (XWPFTableRow row : rows) { - List cells = row.getTableCells(); - for (XWPFTableCell cell : cells) { - List paragraphListTable = cell.getParagraphs(); - processParagraphs(paragraphListTable, params, doc); - } - } - } - } - - public static void processParagraphs(List paragraphList, Map param, - CustomXWPFDocument doc) { - if (paragraphList != null && paragraphList.size() > 0) { - for (XWPFParagraph paragraph : paragraphList) { - List runs = paragraph.getRuns(); - if (runs.size() > 0) { - for (XWPFRun run : runs) { - String bflag = ""; - String text = run.getText(0); - if (text != null) { - boolean isSetText = false; - for (Entry entry : param.entrySet()) { - String key = entry.getKey(); - if (text.indexOf(key) != -1) { - isSetText = true; - Object value = entry.getValue(); - if (value instanceof String) {// 文本替换 - text = text.replace(key, value.toString()); - } else if (value instanceof Map) {// 图片替换 - text = text.replace(key, ""); - Map pic = (Map) value; - int width = Integer.parseInt(pic.get("width").toString()); - int height = Integer.parseInt(pic.get("height").toString()); - int picType = getPictureType(pic.get("type").toString()); - byte[] byteArray = (byte[]) pic.get("content"); - ByteArrayInputStream byteInputStream = new ByteArrayInputStream(byteArray); - try { - String s = doc.addPictureData(byteInputStream, picType); - - doc.createPicture(doc.getAllPictures().size() - 1, width, height, - s,paragraph); - bflag = "break"; - } catch (Exception e) { - getError("文本替换发生异常,异常是" + e.getMessage()); - } - } - } - } - if (isSetText) { - run.setText(text, 0); - } - } - if (bflag == "break") { - break; - } - } - } - } - } - } - - /** - * 替换段落里面的变量 - * - * @param para 要替换的段落 - * @param params 参数 - */ - private void replaceInPara(XWPFParagraph para, Map params, CustomXWPFDocument doc) { - List runs; - Matcher matcher; - // if (this.matcher(para.getParagraphText()).find()) { - runs = para.getRuns(); - int start = -1; - int end = -1; - String str = ""; - for (int i = 0; i < runs.size(); i++) { - XWPFRun run = runs.get(i); - String runText = run.toString(); - if ('$' == runText.charAt(0) && '{' == runText.charAt(1)) { - start = i; - } - if ((start != -1)) { - str += runText; - } - if ('}' == runText.charAt(runText.length() - 1)) { - if (start != -1) { - end = i; - break; - } - } - } - - for (int i = start; i <= end; i++) { - para.removeRun(i); - i--; - end--; - } - - for (Entry entry : params.entrySet()) { - String key = entry.getKey(); - if (str.indexOf(key) != -1) { - Object value = entry.getValue(); - if (value instanceof String) { - str = str.replace(key, value.toString()); - para.createRun().setText(str, 0); - break; - } else if (value instanceof Map) { - str = str.replace(key, ""); - Map pic = (Map) value; - int width = Integer.parseInt(pic.get("width").toString()); - int height = Integer.parseInt(pic.get("height").toString()); - int picType = getPictureType(pic.get("type").toString()); - byte[] byteArray = (byte[]) pic.get("content"); - ByteArrayInputStream byteInputStream = new ByteArrayInputStream(byteArray); - try { - // int ind = doc.addPicture(byteInputStream,picType); - // doc.createPicture(ind, width , height,para); - String s = doc.addPictureData(byteInputStream, picType); - doc.createPicture(doc.getAllPictures().size() - 1, width, height,s, para); - para.createRun().setText(str, 0); - break; - } catch (Exception e) { - getError("文件替换发生异常,异常是" + e.getMessage()); - } - } - } - } - // } - } - - /** - * 为表格插入数据,行数不够添加新行 - * - * @param table 需要插入数据的表格 - * @param tableList 插入数据集合 - */ - private static void insertTable(XWPFTable table, List tableList) { - //删除占位符行数 - table.removeRow(1); - if (CollUtil.isNotEmpty(tableList)) { - // 创建行,根据需要插入的数据添加新行,不处理表头 - for (int i = 0; i < tableList.size(); i++) { - XWPFTableRow row = table.createRow(); - List cells = row.getTableCells(); - for (int j = 0; j < cells.size(); j++) { - String s = tableList.get(i)[j]; - XWPFTableCell cell = cells.get(j); - cell.removeParagraph(0); - XWPFParagraph paragraph = cell.addParagraph(); - paragraph.setAlignment(ParagraphAlignment.CENTER); - // 在段落中添加文本 - XWPFRun run = paragraph.createRun(); - run.setText(s); - } - } - } - } - - /** - * 替换表格里面的变量 - * - * @param doc 要替换的文档 - * @param tableList 存放数据顺序要与表格一致 - * @param params 参数 - */ - private void replaceInTable(CustomXWPFDocument doc, Map params, List> tableList) { - Iterator iterator = doc.getTablesIterator(); - XWPFTable table; - List rows; - List cells; - List paras; - Integer num=0; - while (iterator.hasNext()) { - table = iterator.next(); - if (table.getRows().size() > 1) { - // 判断表格是需要替换还是需要插入,判断逻辑有$为替换,表格无$为插入 - if (this.matcher(table.getText()).find()||this.matcherS(table.getText()).find()) { - rows = table.getRows(); - for (XWPFTableRow row : rows) { - cells = row.getTableCells(); - for (XWPFTableCell cell : cells) { - List paragraphListTable = cell.getParagraphs(); - processParagraphs(paragraphListTable, params, doc); - } - } - }else { - if (CollUtil.isNotEmpty(tableList.get(num))){ - insertTable(table, tableList.get(num)); // 插入数据 - } - num++; - } - } - } - } - - /** - * 正则匹配字符串 - * - * @param str - * @return - */ - private Matcher matcher(String str) { - Pattern pattern = Pattern.compile("\\$\\{(.+?)\\}", Pattern.CASE_INSENSITIVE); - Matcher matcher = pattern.matcher(str); - return matcher; - } - private Matcher matcherS(String str) { - Pattern pattern = Pattern.compile("\\$(.*?)\\$"); - Matcher matcher = pattern.matcher(str); - return matcher; - } - - /** - * 根据图片类型,取得对应的图片类型代码 - * - * @param picType - * @return int - */ - private static int getPictureType(String picType) { - int res = CustomXWPFDocument.PICTURE_TYPE_PICT; - if (picType != null) { - if (picType.equalsIgnoreCase("image/png")) { - res = CustomXWPFDocument.PICTURE_TYPE_PNG; - } else if (picType.equalsIgnoreCase("image/dib")) { - res = CustomXWPFDocument.PICTURE_TYPE_DIB; - } else if (picType.equalsIgnoreCase("image/emf")) { - res = CustomXWPFDocument.PICTURE_TYPE_EMF; - } else if (picType.equalsIgnoreCase("image/jpg") || picType.equalsIgnoreCase("image/jpeg")) { - res = CustomXWPFDocument.PICTURE_TYPE_JPEG; - } else if (picType.equalsIgnoreCase("image/wmf")) { - res = CustomXWPFDocument.PICTURE_TYPE_WMF; - } - } - return res; - } - -} +//package com.njcn.csharmonic.utils.report; +// +//import cn.hutool.core.collection.CollUtil; +//import com.njcn.oss.constant.OssPath; +//import com.njcn.oss.utils.FileStorageUtil; +//import lombok.RequiredArgsConstructor; +//import lombok.extern.slf4j.Slf4j; +//import org.apache.poi.xwpf.usermodel.*; +//import org.apache.tomcat.util.http.fileupload.IOUtils; +//import org.springframework.core.io.ClassPathResource; +//import org.springframework.core.io.Resource; +//import org.springframework.core.io.ResourceLoader; +//import org.springframework.stereotype.Component; +//import org.springframework.util.FileCopyUtils; +// +//import javax.servlet.ServletOutputStream; +//import javax.servlet.http.HttpServletResponse; +//import java.io.*; +//import java.util.*; +//import java.util.Map.Entry; +//import java.util.regex.Matcher; +//import java.util.regex.Pattern; +// +//@Slf4j +//@Component +//@RequiredArgsConstructor +//public class WordUtil2 { +// +// +// private final ResourceLoader resourceLoader; +// private final FileStorageUtil fileStorageUtil; +// +// +// public void getWord(String path, Map params, String fileName,List> tableList, HttpServletResponse response) +// throws Exception { +// byte[] docBytes = null; +// +// path = ClearPathUtil.cleanString(path); +// InputStream is = null; +// CustomXWPFDocument doc = null; +// //读取报告模板 +// try { +// Resource resource = resourceLoader.getResource("classpath:" + path); +// if (!resource.exists()) { +// throw new FileNotFoundException("模板文件未找到: " + path); +// } +// is = resource.getInputStream(); +// doc = new CustomXWPFDocument(is); +// if(CollUtil.isNotEmpty(tableList)){ +// this.replaceInTable(doc, params,tableList); +// }else{ +// this.replaceInTable(doc, params); +// } +// // 替换表格里面的变量 +// this.replaceInPara(doc, params); // 替换文本里面的变量 +// } catch (IOException e) { +// getError("获取报告模板异常,原因为:" + e); +// } finally { +// if (null != is) { +// is.close(); +// } +// } +// try { +// ServletOutputStream outputStream = response.getOutputStream(); +// response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\""); +// response.setContentType("application/octet-stream;charset=UTF-8"); +// doc.write(outputStream); +// outputStream.close(); +// } catch (Exception e) { +// getError("输出稳态报告异常,原因为:" + e); +// } finally { +// if (doc != null) { +// doc.close(); +// } +// } +// } +// +// +// +// +// // 辅助方法:字节数组转十六进制(便于打印排查) +// private static String bytesToHex(byte[] bytes) { +// StringBuilder sb = new StringBuilder(); +// for (byte b : bytes) { +// sb.append(String.format("%02X ", b)); +// } +// return sb.toString().trim(); +// } +// +// +// +// +// public InputStream getReportFile(String path, Map params, List> tableList) +// throws Exception { +// path = ClearPathUtil.cleanString(path); +// InputStream inStream = null,in = null; +// CustomXWPFDocument doc = null; +// //读取报告模板 +// try { +// inStream = new ClassPathResource(path).getInputStream(); +// doc = new CustomXWPFDocument(inStream); +// this.replaceInTable(doc,params,tableList); +// this.replaceInPara(doc, params); +// } catch (IOException e) { +// getError("获取报告模板异常,原因为:" + e); +// } finally { +// if (null != inStream) { +// inStream.close(); +// } +// } +// try { +// //临时缓冲区 +// ByteArrayOutputStream out = new ByteArrayOutputStream(); +// doc.write(out); +// byte[] docByteAry = out.toByteArray(); +// in = new ByteArrayInputStream(docByteAry); +// out.close(); +// } catch (Exception e) { +// getError("输出稳态报告异常,原因为:" + e); +// } finally { +// if (doc != null) { +// doc.close(); +// } +// } +// return in; +// } +// +// +// +// public String getReportFileUrl(String path,String fileName,List> tableList, Map params) +// throws Exception { +// path = ClearPathUtil.cleanString(path); +// InputStream inStream = null,in = null; +// CustomXWPFDocument doc = null; +// //读取报告模板 +// try { +// inStream = new ClassPathResource(path).getInputStream();; +// doc = new CustomXWPFDocument(inStream); +// if(CollUtil.isNotEmpty(tableList)){ +// this.replaceInTable(doc, params,tableList); +// }else{ +// this.replaceInTable(doc, params); +// } +// this.replaceInPara(doc, params); // 替换文本里面的变量 +// //临时缓冲区 +// ByteArrayOutputStream out = new ByteArrayOutputStream(); +// doc.write(out); +// byte[] docByteAry = out.toByteArray(); +// in = new ByteArrayInputStream(docByteAry); +// out.close(); +// } catch (IOException e) { +// getError("获取报告模板异常,原因为:" + e); +// } finally { +// if (null != inStream) { +// inStream.close(); +// } +// if (doc != null) { +// doc.close(); +// } +// } +// //上传文件服务器 +// return fileStorageUtil.uploadStreamSpecifyName(in, OssPath.ONLINE_REPORT, fileName); +// } +// +// +// private static void getError(String e) { +// log.error(e); +// } +// /** +// * 替换段落里面的变量 +// * +// * @param doc 要替换的文档 +// * @param params 参数 +// */ +// private void replaceInPara(CustomXWPFDocument doc, Map params) { +// Iterator iterator = doc.getParagraphsIterator(); +// List paragraphList = new ArrayList<>(); +// XWPFParagraph para; +// while (iterator.hasNext()) { +// para = iterator.next(); +// paragraphList.add(para); +// } +// processParagraphs(paragraphList, params, doc); +// } +// +// private void replaceInTable(CustomXWPFDocument doc, Map params) { +// Iterator it = doc.getTablesIterator(); +// while (it.hasNext()) { +// XWPFTable table = it.next(); +// List rows = table.getRows(); +// for (XWPFTableRow row : rows) { +// List cells = row.getTableCells(); +// for (XWPFTableCell cell : cells) { +// List paragraphListTable = cell.getParagraphs(); +// processParagraphs(paragraphListTable, params, doc); +// } +// } +// } +// } +// +// public static void processParagraphs(List paragraphList, Map param, +// CustomXWPFDocument doc) { +// if (paragraphList != null && paragraphList.size() > 0) { +// for (XWPFParagraph paragraph : paragraphList) { +// List runs = paragraph.getRuns(); +// if (runs.size() > 0) { +// for (XWPFRun run : runs) { +// String bflag = ""; +// String text = run.getText(0); +// if (text != null) { +// boolean isSetText = false; +// for (Entry entry : param.entrySet()) { +// String key = entry.getKey(); +// if (text.indexOf(key) != -1) { +// isSetText = true; +// Object value = entry.getValue(); +// if (value instanceof String) {// 文本替换 +// text = text.replace(key, value.toString()); +// } else if (value instanceof Map) {// 图片替换 +// text = text.replace(key, ""); +// Map pic = (Map) value; +// int width = Integer.parseInt(pic.get("width").toString()); +// int height = Integer.parseInt(pic.get("height").toString()); +// int picType = getPictureType(pic.get("type").toString()); +// byte[] byteArray = (byte[]) pic.get("content"); +// ByteArrayInputStream byteInputStream = new ByteArrayInputStream(byteArray); +// try { +// String s = doc.addPictureData(byteInputStream, picType); +// +// doc.createPicture(doc.getAllPictures().size() - 1, width, height, +// s,paragraph); +// bflag = "break"; +// } catch (Exception e) { +// getError("文本替换发生异常,异常是" + e.getMessage()); +// } +// } +// } +// } +// if (isSetText) { +// run.setText(text, 0); +// } +// } +// if (bflag == "break") { +// break; +// } +// } +// } +// } +// } +// } +// +// /** +// * 替换段落里面的变量 +// * +// * @param para 要替换的段落 +// * @param params 参数 +// */ +// private void replaceInPara(XWPFParagraph para, Map params, CustomXWPFDocument doc) { +// List runs; +// Matcher matcher; +// // if (this.matcher(para.getParagraphText()).find()) { +// runs = para.getRuns(); +// int start = -1; +// int end = -1; +// String str = ""; +// for (int i = 0; i < runs.size(); i++) { +// XWPFRun run = runs.get(i); +// String runText = run.toString(); +// if ('$' == runText.charAt(0) && '{' == runText.charAt(1)) { +// start = i; +// } +// if ((start != -1)) { +// str += runText; +// } +// if ('}' == runText.charAt(runText.length() - 1)) { +// if (start != -1) { +// end = i; +// break; +// } +// } +// } +// +// for (int i = start; i <= end; i++) { +// para.removeRun(i); +// i--; +// end--; +// } +// +// for (Entry entry : params.entrySet()) { +// String key = entry.getKey(); +// if (str.indexOf(key) != -1) { +// Object value = entry.getValue(); +// if (value instanceof String) { +// str = str.replace(key, value.toString()); +// para.createRun().setText(str, 0); +// break; +// } else if (value instanceof Map) { +// str = str.replace(key, ""); +// Map pic = (Map) value; +// int width = Integer.parseInt(pic.get("width").toString()); +// int height = Integer.parseInt(pic.get("height").toString()); +// int picType = getPictureType(pic.get("type").toString()); +// byte[] byteArray = (byte[]) pic.get("content"); +// ByteArrayInputStream byteInputStream = new ByteArrayInputStream(byteArray); +// try { +// // int ind = doc.addPicture(byteInputStream,picType); +// // doc.createPicture(ind, width , height,para); +// String s = doc.addPictureData(byteInputStream, picType); +// doc.createPicture(doc.getAllPictures().size() - 1, width, height,s, para); +// para.createRun().setText(str, 0); +// break; +// } catch (Exception e) { +// getError("文件替换发生异常,异常是" + e.getMessage()); +// } +// } +// } +// } +// // } +// } +// +// /** +// * 为表格插入数据,行数不够添加新行 +// * +// * @param table 需要插入数据的表格 +// * @param tableList 插入数据集合 +// */ +// private static void insertTable(XWPFTable table, List tableList) { +// //删除占位符行数 +// table.removeRow(1); +// if (CollUtil.isNotEmpty(tableList)) { +// // 创建行,根据需要插入的数据添加新行,不处理表头 +// for (int i = 0; i < tableList.size(); i++) { +// XWPFTableRow row = table.createRow(); +// List cells = row.getTableCells(); +// for (int j = 0; j < cells.size(); j++) { +// String s = tableList.get(i)[j]; +// XWPFTableCell cell = cells.get(j); +// cell.removeParagraph(0); +// XWPFParagraph paragraph = cell.addParagraph(); +// paragraph.setAlignment(ParagraphAlignment.CENTER); +// // 在段落中添加文本 +// XWPFRun run = paragraph.createRun(); +// run.setText(s); +// } +// } +// } +// } +// +// /** +// * 替换表格里面的变量 +// * +// * @param doc 要替换的文档 +// * @param tableList 存放数据顺序要与表格一致 +// * @param params 参数 +// */ +// private void replaceInTable(CustomXWPFDocument doc, Map params, List> tableList) { +// Iterator iterator = doc.getTablesIterator(); +// XWPFTable table; +// List rows; +// List cells; +// List paras; +// Integer num=0; +// while (iterator.hasNext()) { +// table = iterator.next(); +// if (table.getRows().size() > 1) { +// // 判断表格是需要替换还是需要插入,判断逻辑有$为替换,表格无$为插入 +// if (this.matcher(table.getText()).find()||this.matcherS(table.getText()).find()) { +// rows = table.getRows(); +// for (XWPFTableRow row : rows) { +// cells = row.getTableCells(); +// for (XWPFTableCell cell : cells) { +// List paragraphListTable = cell.getParagraphs(); +// processParagraphs(paragraphListTable, params, doc); +// } +// } +// }else { +// if (CollUtil.isNotEmpty(tableList.get(num))){ +// insertTable(table, tableList.get(num)); // 插入数据 +// } +// num++; +// } +// } +// } +// } +// +// /** +// * 正则匹配字符串 +// * +// * @param str +// * @return +// */ +// private Matcher matcher(String str) { +// Pattern pattern = Pattern.compile("\\$\\{(.+?)\\}", Pattern.CASE_INSENSITIVE); +// Matcher matcher = pattern.matcher(str); +// return matcher; +// } +// private Matcher matcherS(String str) { +// Pattern pattern = Pattern.compile("\\$(.*?)\\$"); +// Matcher matcher = pattern.matcher(str); +// return matcher; +// } +// +// /** +// * 根据图片类型,取得对应的图片类型代码 +// * +// * @param picType +// * @return int +// */ +// private static int getPictureType(String picType) { +// int res = CustomXWPFDocument.PICTURE_TYPE_PICT; +// if (picType != null) { +// if (picType.equalsIgnoreCase("image/png")) { +// res = CustomXWPFDocument.PICTURE_TYPE_PNG; +// } else if (picType.equalsIgnoreCase("image/dib")) { +// res = CustomXWPFDocument.PICTURE_TYPE_DIB; +// } else if (picType.equalsIgnoreCase("image/emf")) { +// res = CustomXWPFDocument.PICTURE_TYPE_EMF; +// } else if (picType.equalsIgnoreCase("image/jpg") || picType.equalsIgnoreCase("image/jpeg")) { +// res = CustomXWPFDocument.PICTURE_TYPE_JPEG; +// } else if (picType.equalsIgnoreCase("image/wmf")) { +// res = CustomXWPFDocument.PICTURE_TYPE_WMF; +// } +// } +// return res; +// } +// +//} diff --git a/cs-harmonic/cs-harmonic-boot/pom.xml b/cs-harmonic/cs-harmonic-boot/pom.xml index b98c12a..ee659e7 100644 --- a/cs-harmonic/cs-harmonic-boot/pom.xml +++ b/cs-harmonic/cs-harmonic-boot/pom.xml @@ -141,6 +141,14 @@ 1.0.0 compile + + + com.njcn + harmonic-common + 1.0.0 + compile + + diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/controller/CustomReportController.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/controller/CustomReportController.java index 5d64989..c46392e 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/controller/CustomReportController.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/controller/CustomReportController.java @@ -8,13 +8,13 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.utils.HttpResultUtil; import com.njcn.csharmonic.param.SensitiveUserReportQueryParam; -import com.njcn.csharmonic.pojo.param.ReportSearchParam; 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.SysDeptTempVO; 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 io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/controller/WordExportModelController.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/controller/WordExportModelController.java index 15a18cd..37417bf 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/controller/WordExportModelController.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/controller/WordExportModelController.java @@ -1,49 +1,26 @@ package com.njcn.csharmonic.controller; -import cn.hutool.core.date.DatePattern; -import cn.hutool.core.date.DateTime; -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.util.ObjectUtil; -import com.njcn.common.pojo.enums.response.CommonResponseEnum; -import com.njcn.common.pojo.exception.BusinessException; -import com.njcn.common.pojo.response.HttpResult; -import com.njcn.common.utils.HttpResultUtil; -import com.njcn.common.utils.PubUtils; +import cn.hutool.core.bean.BeanUtil; import com.njcn.csdevice.api.CsLineFeignClient; import com.njcn.csdevice.pojo.vo.LineDetailDataVO; -import com.njcn.csharmonic.pojo.dto.report.EnumPass; -import com.njcn.csharmonic.pojo.dto.report.OverLimitInfo; -import com.njcn.csharmonic.pojo.dto.report.Pass; -import com.njcn.csharmonic.pojo.dto.report.ReportTarget; -import com.njcn.csharmonic.pojo.param.report.ReportQueryParam; -import com.njcn.csharmonic.pojo.vo.report.ReportValue; -import com.njcn.csharmonic.service.ReportService; -import com.njcn.csharmonic.utils.report.WordUtil2; import com.njcn.device.biz.pojo.po.Overlimit; import com.njcn.device.biz.pojo.po.PqsDeviceUnit; -import com.njcn.system.api.DicDataFeignClient; -import com.njcn.system.api.ThemeFeignClient; -import com.njcn.system.enums.DicDataEnum; -import com.njcn.system.enums.DicDataTypeEnum; -import com.njcn.system.pojo.po.DictData; -import com.njcn.system.pojo.po.Theme; +import com.njcn.harmonic.common.pojo.dto.DeviceUnitCommDTO; +import com.njcn.harmonic.common.pojo.dto.LineDetailDataCommVO; +import com.njcn.harmonic.common.pojo.dto.OverLimitInfoCommDTO; +import com.njcn.harmonic.common.service.MonitorHarmonicReportService; + import com.njcn.web.controller.BaseController; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.core.io.ClassPathResource; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; -import sun.misc.BASE64Encoder; import javax.servlet.http.HttpServletResponse; import java.io.IOException; -import java.io.InputStream; -import java.text.SimpleDateFormat; -import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -59,33 +36,11 @@ import java.util.stream.Stream; @AllArgsConstructor public class WordExportModelController extends BaseController { - /** - * 非谐波数据 - */ - List listVirtual; - List listPower; - List listFlicker; - List listDistortion; - List listVdeviation; - List listFrequency; - List listThreephase; - /** - * 谐波电压数据 - */ - List listVoltageRate; - /** - * 谐波电流数据 - */ - List listICurrent; - - private final CsLineFeignClient csLineFeignClient; - //private final MonitorClient monitorClient; - private final DicDataFeignClient dicDataFeignClient; - private final ThemeFeignClient themeFeignClient; - private final ReportService reportService; - //private final DeviceUnitClient deviceUnitClient; - private final WordUtil2 wordUtil2; + + + + private final MonitorHarmonicReportService monitorHarmonicReportService; /** * @param response @@ -103,7 +58,7 @@ public class WordExportModelController extends BaseController { */ @PostMapping("/exportModel") @ApiOperation("word报告") - public HttpResult exportWorld(HttpServletResponse response, + public void exportWorld(HttpServletResponse response, @RequestParam(value ="startTime",required = false) String startTime, @RequestParam(value ="endTime",required = false) String endTime, @RequestParam(value ="type",required = false) Integer type, @@ -114,1646 +69,27 @@ public class WordExportModelController extends BaseController { @RequestParam(value = "isUrl",required = false) Boolean isUrl, @RequestPart(value ="file",required = false) MultipartFile file) throws IOException { String methodDescribe = getMethodDescribe("exportWorld"); - //获取监测点信息 - String bdname = ""; - Integer pttype = 0; - String areaName = ""; - String atype = ""; - String btype = ""; - String ctype = ""; - LineDetailDataVO lineDto = new LineDetailDataVO(); - if (type == 0) { - lineDto = csLineFeignClient.getLineDetailData(lineIndex).getData(); - if (ObjectUtil.isNull(lineDto)) { - throw new BusinessException(CommonResponseEnum.NO_DATA); - } - bdname = lineDto.getBdName(); - areaName = lineDto.getAreaName(); - if("冀北".equals(areaName)){ - areaName="国网"+areaName; - } - pttype = PubUtils.ptTypeName(lineDto.getPtType()); - } else { - /* List monitorList = monitorClient.getMonitorList(Collections.singletonList(lineIndex)).getData(); - if (ObjectUtil.isNull(monitorList)) { - throw new BusinessException(CommonResponseEnum.NO_DATA); - } - Monitor monitor = monitorList.get(0); - bdname = monitor.getPowerrName(); - areaName = monitor.getOrgName(); - String terminalWiringMethod = dicDataFeignClient.getDicDataById(monitor.getTerminalWiringMethod()).getData().getName(); - pttype = PubUtils.ptTypeName(terminalWiringMethod); - lineDto.setPt(monitor.getPt1() + "/" + monitor.getPt2()); - lineDto.setCt(monitor.getCt1() + "/" + monitor.getCt2()); - //基准容量 - lineDto.setStandardCapacity(monitor.getStandShortCapacity()); - //短路容量 - lineDto.setShortCapacity(monitor.getMinShortCircuitCapacity()); - //协议容量 - lineDto.setDealCapacity(monitor.getUserAgreementCapacity()); - //设备容量 - lineDto.setDevCapacity(monitor.getPowerSupplyEqCapacity()); - //电压等级 - lineDto.setScale(dicDataFeignClient.getDicDataById(monitor.getVoltageLevel()).getData().getName());*/ - } - if (pttype == 0) { - atype = "A相"; - btype = "B相"; - ctype = "C相"; - } else if (pttype == 1) { - atype = "AB相"; - btype = "BC相"; - ctype = "CA相"; - } else if (pttype == 2) { - atype = "AB相"; - btype = "BC相"; - ctype = "-"; + LineDetailDataCommVO lineDetailDataCommVO; + OverLimitInfoCommDTO overLimitInfoCommDTO; + DeviceUnitCommDTO deviceUnitCommDTO; - } - DateTime startDate = DateUtil.beginOfDay(DateUtil.parse(startTime)); - DateTime endDate = DateUtil.endOfDay(DateUtil.parse(endTime)); - long day = DateUtil.betweenDay(startDate, endDate, false); - //通用查询条件 - ReportQueryParam param = new ReportQueryParam(); - param.setLineId(lineIndex); - param.setStartTime(DateUtil.format(startDate, "yyyy-MM-dd HH:mm:ss")); - LocalDateTime parse = LocalDateTimeUtil.parse(DateUtil.format(endDate, "yyyy-MM-dd HH:mm:ss"), DatePattern.NORM_DATETIME_PATTERN); - if(LocalDateTime.now().isBefore(parse)){ + Overlimit overLimit = new Overlimit(); + LineDetailDataVO lineDto = csLineFeignClient.getLineDetailData(lineIndex).getData(); + lineDetailDataCommVO = BeanUtil.copyProperties(lineDto, LineDetailDataCommVO.class); - param.setEndTime(LocalDateTimeUtil.format(LocalDateTime.now(),DatePattern.NORM_DATETIME_PATTERN)); - endDate = DateUtil.parse(LocalDateTimeUtil.format(LocalDateTime.now(),DatePattern.NORM_DATETIME_PATTERN)); + List overLimitList = csLineFeignClient.getOverLimitData(Stream.of(lineIndex).collect(Collectors.toList())).getData(); + overLimit = overLimitList.get(0); + overLimitInfoCommDTO = BeanUtil.copyProperties(overLimit, OverLimitInfoCommDTO.class); - }else { - param.setEndTime(DateUtil.format(endDate, "yyyy-MM-dd HH:mm:ss")); - } - param.setB(day == 0); - //限值 - OverLimitInfo overLimitData = reportService.getOverLimitData(param); - Overlimit overLimit; - if (type == 0) { - overLimit = csLineFeignClient.getOverLimitData(Stream.of(param.getLineId()).collect(Collectors.toList())).getData().get(0); - } else { - overLimit = csLineFeignClient.getOverLimitData(Stream.of(param.getLineId()).collect(Collectors.toList())).getData().get(0); + PqsDeviceUnit pqsDeviceUnit = new PqsDeviceUnit(); + deviceUnitCommDTO = BeanUtil.copyProperties(pqsDeviceUnit, DeviceUnitCommDTO.class); - } - param.setCount(overLimitData.getCount()); - overLimitData.setOverLimitRate(Arrays.asList(overLimit)); + monitorHarmonicReportService.exportWorld(response, startTime, endTime, type, lineIndex, name, reportNumber, crmName, isUrl, file, lineDetailDataCommVO, overLimitInfoCommDTO,deviceUnitCommDTO); - if (0 == overLimitData.getOverLimitRate().size()) { - return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, "dataFail", methodDescribe); - } - - String rtfPath; - String picPath = "file/default.jpg"; - - Theme theme = themeFeignClient.getTheme().getData(); - if (theme.getRemark().equals("国网")) { - rtfPath = "file/reportModelGW.docx"; - } else if (theme.getRemark().equals("南网")) { - rtfPath = "file/reportModelNW.docx"; - } else if (theme.getRemark().equals("灿能")) { - rtfPath = "file/reportModelCN.docx"; - } else if (theme.getName().contains("物联")) { - rtfPath = "file/reportModelWL.docx"; - } else { - rtfPath = "file/reportModel.docx"; - } - - //获取图片信息 - ClassPathResource picPathResource = null; - try { - picPathResource = new ClassPathResource(picPath); - rtfPath = rtfPath.replaceAll("%20", " "); - } catch (Exception e1) { - log.info("获取报表发生异常,异常是" + e1.getMessage()); - } - - // 报告Map - Map reportmap = new HashMap<>(16); - //数据单位 - PqsDeviceUnit deviceUnit = new PqsDeviceUnit(); - reportmap.putAll(unitMap(deviceUnit)); - reportmap.put("$atype$", atype); - reportmap.put("$btype$", btype); - reportmap.put("$ctype$", ctype); - - Map header = new HashMap<>(16); - if (ObjectUtil.isNotEmpty(file)) { - byte[] bytes = file.getBytes(); - if(bytes.length>0){ - header.put("width", 400); - header.put("height", 250); - header.put("type", file.getContentType()); - header.put("content", bytes); - }else{ - InputStream inStream = null; - byte[] data = null; - try { - inStream = picPathResource.getInputStream(); - data = new byte[inStream.available()]; - inStream.read(data); - } catch (Exception e) { - log.info("读取报表信息失败:" + e.getMessage()); - } finally { - if (inStream != null) { - inStream.close(); - } - } - String contentType = "application/x-jpg"; - header.put("width", 400); - header.put("height", 250); - header.put("type", contentType); - header.put("content", data); - } - } else { - InputStream inStream = null; - byte[] data = null; - try { - inStream = picPathResource.getInputStream(); - data = new byte[inStream.available()]; - inStream.read(data); - } catch (Exception e) { - log.info("读取报表信息失败:" + e.getMessage()); - } finally { - if (inStream != null) { - inStream.close(); - } - } - String contentType = "application/x-jpg"; - header.put("width", 400); - header.put("height", 250); - header.put("type", contentType); - header.put("content", data); - } - - reportmap.put("$image$", header); - - getVirtualData(param); - // 电压幅值 - ReportValue voltage1 = this.listVirtual.get(0).getList().get(0); - // 电压幅值 - ReportValue voltage2 = this.listVirtual.get(0).getList().get(1); - // 电压幅值 - ReportValue voltage3 = this.listVirtual.get(0).getList().get(2); - // 电流幅值 - ReportValue current1 = this.listVirtual.get(1).getList().get(0); - // 电流幅值 - ReportValue current2 = this.listVirtual.get(1).getList().get(1); - // 电流幅值 - ReportValue current3 = this.listVirtual.get(1).getList().get(2); - - String strLineBaseName = String.format("%s%s", new String[]{bdname + "_", name}); - // 分析建议 - String strAnalysis = ""; - // 报表错误 - String strError = ""; - - /************************************************************** - **** 基波电压/电流有效值表格 - * 一、用基波电压和基波电流做是否有值的判断, 判断策略为所有的基波电压和基波电流都为空 - * ************************************* - * ************************************* 二、基本数据判断 - * ①、(最大值>=最小值、平均值、95%概率值) ②、(平均值>=最小值) ③、(95%概率值>=最小值) - ***************************************************************/ - String strBaseVIResult = ""; - // 基波电压最大值 - - reportmap.put("$B" + "V0" + "X" + "_A$", judgeNull(voltage1.getFmaxValue())); - - reportmap.put("$B" + "V0" + "X" + "_B$", judgeNull(voltage2.getFmaxValue())); - reportmap.put("$B" + "V0" + "X" + "_C$", judgeNull(voltage3.getFmaxValue())); - - // 基波电流最大值 - reportmap.put("$B" + "I0" + "X" + "_A$", judgeNull(current1.getFmaxValue())); - reportmap.put("$B" + "I0" + "X" + "_B$", judgeNull(current2.getFmaxValue())); - reportmap.put("$B" + "I0" + "X" + "_C$", judgeNull(current3.getFmaxValue())); - - /************************************************************** - **** 三张大表基础数据幅值 - ***************************************************************/ - // 基波电压最大值 - reportmap.put("$C" + "V0" + "X" + "_A$", judgeNull(voltage1.getFmaxValue())); - reportmap.put("$C" + "V0" + "X" + "_B$", judgeNull(voltage2.getFmaxValue())); - reportmap.put("$C" + "V0" + "X" + "_C$", judgeNull(voltage3.getFmaxValue())); - - // 基波电流最大值 - reportmap.put("$C" + "I0" + "X" + "_A$", judgeNull(current1.getFmaxValue())); - reportmap.put("$C" + "I0" + "X" + "_B$", judgeNull(current2.getFmaxValue())); - reportmap.put("$C" + "I0" + "X" + "_C$", judgeNull(current3.getFmaxValue())); - - // 基波电压最小值 - reportmap.put("$B" + "V0" + "N" + "_A$", judgeNull(voltage1.getMinValue())); - reportmap.put("$B" + "V0" + "N" + "_B$", judgeNull(voltage2.getMinValue())); - reportmap.put("$B" + "V0" + "N" + "_C$", judgeNull(voltage3.getMinValue())); - - // 基波电流最小值 - reportmap.put("$B" + "I0" + "N" + "_A$", judgeNull(current1.getMinValue())); - reportmap.put("$B" + "I0" + "N" + "_B$", judgeNull(current2.getMinValue())); - reportmap.put("$B" + "I0" + "N" + "_C$", judgeNull(current3.getMinValue())); - - /************************************************************** - **** 三张大表基础数据幅值 - ***************************************************************/ - // 基波电压最小值 - reportmap.put("$C" + "V0" + "N" + "_A$", judgeNull(voltage1.getMinValue())); - reportmap.put("$C" + "V0" + "N" + "_B$", judgeNull(voltage2.getMinValue())); - reportmap.put("$C" + "V0" + "N" + "_C$", judgeNull(voltage3.getMinValue())); - - // 基波电流最小值 - reportmap.put("$C" + "I0" + "N" + "_A$", judgeNull(current1.getMinValue())); - reportmap.put("$C" + "I0" + "N" + "_B$", judgeNull(current2.getMinValue())); - reportmap.put("$C" + "I0" + "N" + "_C$", judgeNull(current3.getMinValue())); - - // 基波电压平均值 - reportmap.put("$B" + "V0" + "E" + "_A$", judgeNull(voltage1.getMeanValue())); - reportmap.put("$B" + "V0" + "E" + "_B$", judgeNull(voltage2.getMeanValue())); - reportmap.put("$B" + "V0" + "E" + "_C$", judgeNull(voltage3.getMeanValue())); - - // 基波电流平均值 - reportmap.put("$B" + "I0" + "E" + "_A$", judgeNull(current1.getMeanValue())); - reportmap.put("$B" + "I0" + "E" + "_B$", judgeNull(current2.getMeanValue())); - reportmap.put("$B" + "I0" + "E" + "_C$", judgeNull(current3.getMeanValue())); - - /************************************************************** - **** 三张大表基础数据幅值 - ***************************************************************/ - // 基波电压平均值 - reportmap.put("$C" + "V0" + "E" + "_A$", judgeNull(voltage1.getMeanValue())); - reportmap.put("$C" + "V0" + "E" + "_B$", judgeNull(voltage2.getMeanValue())); - reportmap.put("$C" + "V0" + "E" + "_C$", judgeNull(voltage3.getMeanValue())); - - // 基波电流平均值 - reportmap.put("$C" + "I0" + "E" + "_A$", judgeNull(current1.getMeanValue())); - reportmap.put("$C" + "I0" + "E" + "_B$", judgeNull(current2.getMeanValue())); - reportmap.put("$C" + "I0" + "E" + "_C$", judgeNull(current3.getMeanValue())); - - // 基波电压cp95值 - reportmap.put("$B" + "V0" + "%" + "_A$", judgeNull(voltage1.getCp95Value())); - reportmap.put("$B" + "V0" + "%" + "_B$", judgeNull(voltage2.getCp95Value())); - reportmap.put("$B" + "V0" + "%" + "_C$", judgeNull(voltage3.getCp95Value())); - - // 基波电流cp95值 - reportmap.put("$B" + "I0" + "%" + "_A$", judgeNull(current1.getCp95Value())); - reportmap.put("$B" + "I0" + "%" + "_B$", judgeNull(current2.getCp95Value())); - reportmap.put("$B" + "I0" + "%" + "_C$", judgeNull(current3.getCp95Value())); - - /************************************************************** - **** 三张大表基础数据幅值 - ***************************************************************/ - // 基波电压cp95值 - reportmap.put("$C" + "V0" + "%" + "_A$", judgeNull(voltage1.getCp95Value())); - reportmap.put("$C" + "V0" + "%" + "_B$", judgeNull(voltage2.getCp95Value())); - reportmap.put("$C" + "V0" + "%" + "_C$", judgeNull(voltage3.getCp95Value())); - - // 基波电流cp95值 - reportmap.put("$C" + "I0" + "%" + "_A$", judgeNull(current1.getCp95Value())); - reportmap.put("$C" + "I0" + "%" + "_B$", judgeNull(current2.getCp95Value())); - reportmap.put("$C" + "I0" + "%" + "_C$", judgeNull(current3.getCp95Value())); - - // 遍历map中的值 - int iCount = 0; - // 判断所取的基波电压、基波电流值是否为null - for (Object value : reportmap.values()) { - if (value == null) - iCount++; - } - // 假如所有的数据都为null,则返回(所选的时间段内未找到数据) - if (iCount == reportmap.size()) { - return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, "exportWorld", methodDescribe); - } - // 基本数据判断 - for (int i = 0; i < 3; i++) { - String tmpstrMap = "A"; - switch (i) { - case 0: - tmpstrMap = "A"; - break; - case 1: - tmpstrMap = "B"; - break; - default: - tmpstrMap = "C"; - break; - } - try { - // 基波电压 - Double vmaxValue = Double.parseDouble(reportmap.get("$BV0X_" + tmpstrMap + "$").toString()); - Double vminValue = Double.parseDouble(reportmap.get("$BV0N_" + tmpstrMap + "$").toString()); - Double vaveValue = Double.parseDouble(reportmap.get("$BV0E_" + tmpstrMap + "$").toString()); - Double vcp95Value = Double.parseDouble(reportmap.get("$BV0%_" + tmpstrMap + "$").toString()); - // 基波电流 - Double imaxValue = Double.parseDouble(reportmap.get("$BI0X_" + tmpstrMap + "$").toString()); - Double iminValue = Double.parseDouble(reportmap.get("$BI0N_" + tmpstrMap + "$").toString()); - Double iaveValue = Double.parseDouble(reportmap.get("$BI0E_" + tmpstrMap + "$").toString()); - Double icp95Value = Double.parseDouble(reportmap.get("$BI0%_" + tmpstrMap + "$").toString()); - - if (!(vmaxValue >= vminValue && vmaxValue >= vaveValue && vmaxValue >= vcp95Value)) { - strBaseVIResult += "注意:从上表中可以看出" + strLineBaseName - + "基波电压/电流数据存在异常( 1、最大值>=最小值、平均值、95%概率值;2、平均值>=最小值;3、95%概率值>=最小值)。"; - break; - } else if (vaveValue < vminValue) { - strBaseVIResult += "注意:从上表中可以看出" + strLineBaseName - + "基波电压/电流数据存在异常( 1、最大值>=最小值、平均值、95%概率值;2、平均值>=最小值;3、95%概率值>=最小值)。"; - break; - } else if (vcp95Value < vminValue) { - strBaseVIResult += "注意:从上表中可以看出" + strLineBaseName - + "基波电压/电流数据存在异常( 1、最大值>=最小值、平均值、95%概率值;2、平均值>=最小值;3、95%概率值>=最小值)。"; - break; - } else if (!(imaxValue >= iminValue && imaxValue >= iaveValue && imaxValue >= icp95Value)) { - strBaseVIResult += "注意:从上表中可以看出" + strLineBaseName - + "基波电压/电流数据存在异常( 1、最大值>=最小值、平均值、95%概率值;2、平均值>=最小值;3、95%概率值>=最小值)。"; - break; - } else if (iaveValue < iminValue) { - strBaseVIResult += "注意:从上表中可以看出" + strLineBaseName - + "基波电压/电流数据存在异常( 1、最大值>=最小值、平均值、95%概率值;2、平均值>=最小值;3、95%概率值>=最小值)。"; - break; - } else if (icp95Value < iminValue) { - strBaseVIResult += "注意:从上表中可以看出" + strLineBaseName - + "基波电压/电流数据存在异常( 1、最大值>=最小值、平均值、95%概率值;2、平均值>=最小值;3、95%概率值>=最小值)。"; - break; - } - } catch (Exception e) { - strBaseVIResult += "注意:从上表中可以看出" + strLineBaseName + "基波电压/电流数据存在异常(不是数值类型)。"; - break; - } - } - reportmap.put("$BaseVIResult$", strBaseVIResult); - if (!"".equals(strBaseVIResult)) - strError += strBaseVIResult; - - /************************************************************** - **** 所选的时间段内有数据存在则进行其他加载 - ***************************************************************/ - -// Depts dep = R.getCurrentDept(); -// String detpName = dep.getArea(); - // 区域名称 - reportmap.put("$detpName$", areaName); - // 获取报告生成时间 - Date currentTime = new Date(); - // 报告日期格式 - SimpleDateFormat dayFormatter = new SimpleDateFormat("yyyy年MM月dd日"); - // 报告时分秒格式 - SimpleDateFormat formatter = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒"); - String strTime = String.format("%s——%s。", - new String[]{DateUtil.format(startDate, "yyyy年MM月dd日 HH时mm分ss秒"), - DateUtil.format(endDate, "yyyy年MM月dd日 HH时mm分ss秒")}); - // 报告编号 - reportmap.put("$number$", reportNumber); - // 客户名称 - reportmap.put("$titlePoint$", crmName); - // 报告生成时间 - reportmap.put("$TitleTime$", dayFormatter.format(currentTime)); - - // 报告标题 - reportmap.put("$ReportTitle$", - String.format("对该地区%s电能质量在线监测数据进行分析, 以判断电能质量指标是否满足国标。", new String[]{strLineBaseName})); - // 报告分析时间段 - reportmap.put("$ReportTime$", strTime); - // 运行数据分析 - reportmap.put("$RunBaseName$", String.format("以下将对%s电能质量统计数据进行分析,数据包括基波电压/电流、谐波电压/电流、电压偏差、三相电压不平衡度、电压闪变、频率偏差。", - new String[]{strLineBaseName})); - // 基波电压和电流 - reportmap.put("$BaseVITable$", String.format("报告分析时间段内%s的基波电压/电流分钟统计数据见下表。", new String[]{strLineBaseName})); - // 供电电压偏差 - reportmap.put("$VDTable$", String.format("报告分析时间段内%s的电压偏差统计数据见下表。", new String[]{strLineBaseName})); - // 频率偏差 - reportmap.put("$FRETable$", String.format("报告分析时间段内%s的频率偏差统计数据见下表。", new String[]{strLineBaseName})); - // 三相电压不平衡度 - reportmap.put("$THETable$", String.format("报告分析时间段内%s的三相电压不平衡度统计数据见下表。", new String[]{strLineBaseName})); - // 闪变 - reportmap.put("$PLTTable$", String.format("报告分析时间段内%s的闪变统计数据见下表。", new String[]{strLineBaseName})); - // 谐波电压 - reportmap.put("$RVTable$", - String.format("报告分析时间段内%s的2-25次谐波电压含有率CP95概率值统计数据见下表。", new String[]{strLineBaseName})); - // 谐波电流 - reportmap.put("$RITable$", - String.format("报告分析时间段内%s的2-25次谐波电流幅值CP95概率值统计数据见下表。", new String[]{strLineBaseName})); - // 监测点名称1 - reportmap.put("$LineName1$", name); - // 监测点名称2 - reportmap.put("$LineName2$", name); - // 监测点名称3 - reportmap.put("$LineName3$", name); - // 监测点名称4 - reportmap.put("$LineName4$", name); - // 监测点名称5 - reportmap.put("$LineName5$", name); - - /********************** - **** 数据获取 - ***********************/ - - getPowerData(param); - getFlicker(param, overLimit); - getVdeviation(param, overLimit); - getDistortion(param, overLimit); - getFre(param, overLimit); - getThreePhase(param, overLimit); - getVoltageRate(param, overLimit); - getCurrentRate(param, overLimit); - // 短闪 - ReportValue pst1 = this.listFlicker.get(0).getList().get(0); - // 短闪 - ReportValue pst2 = this.listFlicker.get(0).getList().get(1); - // 短闪 - ReportValue pst3 = this.listFlicker.get(0).getList().get(2); - // 长闪 - ReportValue plt1 = this.listFlicker.get(1).getList().get(0); - // 长闪 - ReportValue plt2 = this.listFlicker.get(1).getList().get(1); - // 长闪 - ReportValue plt3 = this.listFlicker.get(1).getList().get(2); - // 监测点基本信息 - reportmap.put("$LineBase$", String.format("%s%s,CT变比为:%s,PT变比为:%s。", - new String[]{bdname, name, lineDto.getCt(), lineDto.getPt()})); - - /************************************************************** - **** 三张大表基础数据幅值 - ***************************************************************/ - reportmap.put("$CI_JCD$", bdname); - reportmap.put("$bdTitle$", bdname); - - reportmap.put("$CI_Time$", strTime); - reportmap.put("$CI_JCXL$", name); - reportmap.put("$CI_PT$", lineDto.getPt()); - reportmap.put("$CI_DYDJ$", lineDto.getScale()); - reportmap.put("$CI_CT$", lineDto.getCt()); - reportmap.put("$CI_JZRL$", String.valueOf(lineDto.getStandardCapacity())); - reportmap.put("$CI_DLRL$", String.valueOf(lineDto.getShortCapacity())); - reportmap.put("$CI_XYRL$", String.valueOf(lineDto.getDealCapacity())); - reportmap.put("$CI_SBRL$", String.valueOf(lineDto.getDevCapacity())); - - reportmap.put("$CV_JCD$", bdname); - reportmap.put("$CV_Time$", strTime); - reportmap.put("$CV_JCXL$", name); - reportmap.put("$CV_PT$", lineDto.getPt()); - reportmap.put("$CV_DYDJ$", lineDto.getScale()); - reportmap.put("$CV_CT$", lineDto.getCt()); - reportmap.put("$CV_JZRL$", String.valueOf(lineDto.getStandardCapacity())); - reportmap.put("$CV_DLRL$", String.valueOf(lineDto.getShortCapacity())); - reportmap.put("$CV_XYRL$", String.valueOf(lineDto.getDealCapacity())); - reportmap.put("$CV_SBRL$", String.valueOf(lineDto.getDevCapacity())); - - reportmap.put("$FV_JCD$", bdname); - reportmap.put("$FV_Time$", strTime); - reportmap.put("$FV_JCXL$", name); - reportmap.put("$FV_PT$", lineDto.getPt()); - reportmap.put("$FV_DYDJ$", lineDto.getScale()); - reportmap.put("$FV_CT$", lineDto.getCt()); - reportmap.put("$FV_JZRL$", String.valueOf(lineDto.getStandardCapacity())); - reportmap.put("$FV_DLRL$", String.valueOf(lineDto.getShortCapacity())); - reportmap.put("$FV_XYRL$", String.valueOf(lineDto.getDealCapacity())); - reportmap.put("$FV_SBRL$", String.valueOf(lineDto.getDevCapacity())); - - Double maxValue = 0.00; - Double minValue = 0.00; - Double aveValue = 0.00; - Double cp95Value = 0.00; - Double cp95ValueA = 0.00; - Double cp95ValueB = 0.00; - Double cp95ValueC = 0.00; - Double limit = 0.00; - /************************************************************** - **** 电压偏差(上偏差和下偏差) - ***************************************************************/ - ReportValue vdeviation1 = this.listVdeviation.get(0).getList().get(0); - ReportValue vdeviation2 = this.listVdeviation.get(0).getList().get(1); - ReportValue vdeviation3 = this.listVdeviation.get(0).getList().get(2); - // 获取电压上下偏差的国标限值 - String vdeviationLimit = judgeNull(this.listVdeviation.get(0).getOverLimit()); - reportmap.put("$VD_L$", vdeviationLimit); - String strResultVdeviationdata = ""; - String tmpstrResultVdeviationdata = ""; - String strResultVdeviationdataValue = ""; - // 获取电压偏差 - String tmpstrMap = ""; - reportmap.put("$VDTX_A$", judgeNull(vdeviation1.getFmaxValue())); - reportmap.put("$VDTN_A$", judgeNull(vdeviation1.getMinValue())); - reportmap.put("$VDTE_A$", judgeNull(vdeviation1.getMeanValue())); - reportmap.put("$VDT%_A$", judgeNull(vdeviation1.getCp95Value())); - reportmap.put("$VDTX_B$", judgeNull(vdeviation2.getFmaxValue())); - reportmap.put("$VDTN_B$", judgeNull(vdeviation2.getMinValue())); - reportmap.put("$VDTE_B$", judgeNull(vdeviation2.getMeanValue())); - reportmap.put("$VDT%_B$", judgeNull(vdeviation2.getCp95Value())); - if (pttype != 2) { - reportmap.put("$VDTX_C$", judgeNull(vdeviation3.getFmaxValue())); - reportmap.put("$VDTN_C$", judgeNull(vdeviation3.getMinValue())); - reportmap.put("$VDTE_C$", judgeNull(vdeviation3.getMeanValue())); - reportmap.put("$VDT%_C$", judgeNull(vdeviation3.getCp95Value())); - } else { - reportmap.put("$VDTX_C$", "-"); - reportmap.put("$VDTN_C$", "-"); - reportmap.put("$VDTE_C$", "-"); - reportmap.put("$VDT%_C$", "-"); - } - - // 值错误判断 - try { - maxValue = Math.abs(Double.parseDouble(vdeviation1.getFmaxValue().toString())); - minValue = Math.abs(Double.parseDouble(vdeviation1.getMinValue().toString())); - aveValue = Math.abs(Double.parseDouble(vdeviation1.getMeanValue().toString())); - cp95Value = Math.abs(Double.parseDouble(vdeviation1.getCp95Value().toString())); - limit = Math.abs(Double.parseDouble(vdeviationLimit)); - } catch (Exception e) { - strResultVdeviationdataValue += "注意:从上表中可以看出" + strLineBaseName + "电压偏差数据存在异常(不是数值类型)。"; - } - - if ("".equals(strResultVdeviationdataValue)) { - if (!(maxValue >= minValue && maxValue >= aveValue && maxValue >= cp95Value)) { - strResultVdeviationdataValue += "注意:从上表中可以看出" + strLineBaseName - + "电压偏差数据存在异常( 1、最大值>=最小值、平均值、95%概率值;2、平均值>=最小值;3、95%概率值>=最小值)。"; - } else if (aveValue < minValue) { - strResultVdeviationdataValue += "注意:从上表中可以看出" + strLineBaseName - + "电压偏差数据存在异常( 1、最大值>=最小值、平均值、95%概率值;2、平均值>=最小值;3、95%概率值>=最小值)。"; - } else if (cp95Value < minValue) { - strResultVdeviationdataValue += "注意:从上表中可以看出" + strLineBaseName - + "电压偏差数据存在异常( 1、最大值>=最小值、平均值、95%概率值;2、平均值>=最小值;3、95%概率值>=最小值)。"; - } - } - // 限值判断 - if (maxValue > limit) { - if (!"".equals(tmpstrResultVdeviationdata)) - tmpstrResultVdeviationdata += "、"; - tmpstrResultVdeviationdata += tmpstrMap + "相"; - } - Overlimit pojo = overLimitData.getOverLimitRate().get(0); - // 假如为空则所有的都满足 - if ("".equals(tmpstrResultVdeviationdata)) { - strResultVdeviationdata += "从上表中可以看出" + strLineBaseName + "A、B、C三相电压偏差满足国标限值(上限"+pojo.getVoltageDev()+"%,下限"+pojo.getUvoltageDev()+"%)的要求。"; - } else { - strAnalysis += tmpstrResultVdeviationdata + "电压偏差不满足国标限值(上限"+pojo.getVoltageDev()+"%,下限"+pojo.getUvoltageDev()+"%)的要求。"; - strResultVdeviationdata += "从上表中可以看出" + strLineBaseName + tmpstrResultVdeviationdata - + "电压偏差不满足国标限值(上限"+pojo.getVoltageDev()+"%,下限"+pojo.getUvoltageDev()+"%)的要求。"; - } - - reportmap.put("$ResultVdeviationdata$", strResultVdeviationdata); - reportmap.put("$ResultVdeviationdataValue$", strResultVdeviationdataValue); - strError += strResultVdeviationdataValue; - - /************************************************************** - **** 频率偏差 - ***************************************************************/ - ReportValue valueOfFreValue = this.listFrequency.get(1).getList().get(0); - // 获取频率偏差国标限值 - String valueOfFreLimit = judgeNull(this.listFrequency.get(1).getOverLimit()); - reportmap.put("$FRE_L$", valueOfFreLimit); - String strResultFre = ""; - String tmpstrResultFre = ""; - String strResultFreValue = ""; - - reportmap.put("$FREX$", judgeNull(valueOfFreValue.getFmaxValue())); - reportmap.put("$FREN$", judgeNull(valueOfFreValue.getMinValue())); - reportmap.put("$FREE$", judgeNull(valueOfFreValue.getMeanValue())); - reportmap.put("$FRE%$", judgeNull(valueOfFreValue.getCp95Value())); - - /************************************ - **** 三张大表取值 - **************************************/ - reportmap.put("$FV0L$", valueOfFreLimit); - reportmap.put("$FV0X$", judgeNull(valueOfFreValue.getFmaxValue())); - reportmap.put("$FV0N$", judgeNull(valueOfFreValue.getMinValue())); - reportmap.put("$FV0E$", judgeNull(valueOfFreValue.getMeanValue())); - reportmap.put("$FV0%$", judgeNull(valueOfFreValue.getCp95Value())); - - try { - maxValue = Double.parseDouble(valueOfFreValue.getFmaxValue().toString()); - minValue = Double.parseDouble(valueOfFreValue.getMinValue().toString()); - aveValue = Double.parseDouble(valueOfFreValue.getMeanValue().toString()); - cp95Value = Double.parseDouble(valueOfFreValue.getCp95Value().toString()); - limit = Math.abs(Double.parseDouble(valueOfFreLimit)); - } catch (Exception e) { - strResultFreValue += "注意:从上表中可以看出" + strLineBaseName + "频率偏差数据存在异常(不是数值类型)。"; - } - - if (Math.abs(maxValue) > limit) { - tmpstrResultFre += "最大值为:" + valueOfFreValue.getFmaxValue().toString() + deviceUnit.getUnitFrequencyDev(); - } - if (Math.abs(minValue) > limit) { - tmpstrResultFre += "最小值为:" + valueOfFreValue.getMinValue().toString() + deviceUnit.getUnitFrequencyDev(); - } - if (Math.abs(aveValue) > limit) { - tmpstrResultFre += "平均值为:" + valueOfFreValue.getMeanValue().toString() + deviceUnit.getUnitFrequencyDev(); - } - if (Math.abs(cp95Value) > limit) { - tmpstrResultFre += "95%概率值为:" + valueOfFreValue.getCp95Value().toString() + deviceUnit.getUnitFrequencyDev(); - } - - if (!(maxValue >= minValue && maxValue >= aveValue && maxValue >= cp95Value)) { - strResultFreValue += "注意:从上表中可以看出" + strLineBaseName - + "频率偏差数据存在异常( 1、最大值>=最小值、平均值、95%概率值;2、平均值>=最小值;3、95%概率值>=最小值)。"; - } else if (aveValue < minValue) { - strResultFreValue += "注意:从上表中可以看出" + strLineBaseName - + "频率偏差数据存在异常( 1、最大值>=最小值、平均值、95%概率值;2、平均值>=最小值;3、95%概率值>=最小值)。"; - } else if (cp95Value < minValue) { - strResultFreValue += "注意:从上表中可以看出" + strLineBaseName - + "频率偏差数据存在异常( 1、最大值>=最小值、平均值、95%概率值;2、平均值>=最小值;3、95%概率值>=最小值)。"; - } - - if ("".equals(tmpstrResultFre)) { - // 三张大表取值 - reportmap.put("$FV0R$", "合格"); - strResultFre += "从上表中可以看出" + strLineBaseName + "频率偏差均满足国标限值(±" + valueOfFreLimit + deviceUnit.getUnitFrequencyDev() + ")的要求。"; - } else { - // 三张大表取值 - reportmap.put("$FV0R$", "不合格"); - strAnalysis += tmpstrResultFre + ",均不满足国标限值(±" + valueOfFreLimit + deviceUnit.getUnitFrequencyDev() + ")的要求。"; - strResultFre += "从上表中可以看出" + strLineBaseName + "频率偏差" + tmpstrResultFre + ",均不满足国标限值(±" + valueOfFreLimit - + deviceUnit.getUnitFrequencyDev() + ")的要求。"; - } - - reportmap.put("$ResultFre$", strResultFre); - reportmap.put("$ResultFreValue$", strResultFreValue); - strError += strResultFreValue; - - /************************************************************** - **** 三相电压不平衡度 - ***************************************************************/ - ReportValue valueOfThree = this.listThreephase.get(0).getList().get(0); - // 获取三相电压不平衡度国标限值 - String valueOfThreeLimit = judgeNull(this.listThreephase.get(0).getOverLimit()); - reportmap.put("$THE_L$", valueOfThreeLimit); - String strResultThree = ""; - String tmpstrResultThree = ""; - String strResultThreeValue = ""; - reportmap.put("$THEX$", judgeNull(valueOfThree.getFmaxValue())); - reportmap.put("$THEN$", judgeNull(valueOfThree.getMinValue())); - reportmap.put("$THEE$", judgeNull(valueOfThree.getMeanValue())); - reportmap.put("$THE%$", judgeNull(valueOfThree.getCp95Value())); - - /************************************ - **** 三张大表取值 - **************************************/ - reportmap.put("$TV0L$", valueOfThreeLimit); - reportmap.put("$TV0X$", judgeNull(valueOfThree.getFmaxValue())); - reportmap.put("$TV0N$", judgeNull(valueOfThree.getMinValue())); - reportmap.put("$TV0E$", judgeNull(valueOfThree.getMeanValue())); - reportmap.put("$TV0%$", judgeNull(valueOfThree.getCp95Value())); - - try { - maxValue = Double.parseDouble(valueOfThree.getFmaxValue().toString()); - minValue = Double.parseDouble(valueOfThree.getMinValue().toString()); - aveValue = Double.parseDouble(valueOfThree.getMeanValue().toString()); - cp95Value = Double.parseDouble(valueOfThree.getCp95Value().toString()); - limit = Double.parseDouble(valueOfThreeLimit); - } catch (Exception e) { - strResultThreeValue += "注意:从上表中可以看出" + strLineBaseName + "三相电压不平衡度数据存在异常(不是数值类型)。"; - } - if (cp95Value > limit) { - // 三张大表取值 - reportmap.put("$TV0R$", "不合格"); - tmpstrResultThree += "三相电压不平衡度95%概率值为:" + valueOfThree.getCp95Value().toString(); - } else { - // 三张大表取值 - reportmap.put("$TV0R$", "合格"); - } - - if (!(maxValue >= minValue && maxValue >= aveValue && maxValue >= cp95Value)) { - strResultThreeValue += "注意:从上表中可以看出" + strLineBaseName - + "三相电压不平衡度数据存在异常( 1、最大值>=最小值、平均值、95%概率值;2、平均值>=最小值;3、95%概率值>=最小值)。"; - } else if (aveValue < minValue) { - strResultThreeValue += "注意:从上表中可以看出" + strLineBaseName - + "三相电压不平衡度数据存在异常( 1、最大值>=最小值、平均值、95%概率值;2、平均值>=最小值;3、95%概率值>=最小值)。"; - } else if (cp95Value < minValue) { - strResultThreeValue += "注意:从上表中可以看出" + strLineBaseName - + "三相电压不平衡度数据存在异常( 1、最大值>=最小值、平均值、95%概率值;2、平均值>=最小值;3、95%概率值>=最小值)。"; - } - - if ("".equals(tmpstrResultThree)) { - strResultThree += "三相电压不平衡度根据国标标准测量结果以95%概率值作为判断是否合格的依据,从上表中可以看出" + strLineBaseName + tmpstrResultThree - + ",满足国标限值(" + valueOfThreeLimit + "%)的要求。"; - } else { - strAnalysis += tmpstrResultThree + ",不满足国标限值(" + valueOfThreeLimit + "%)的要求。"; - strResultThree += "三相电压不平衡度根据国标标准测量结果以95%概率值作为判断是否合格的依据,从上表中可以看出" + strLineBaseName + tmpstrResultThree - + ",不满足国标限值(" + valueOfThreeLimit + "%)的要求。"; - } - - reportmap.put("$ResultThree$", strResultThree); - reportmap.put("$ResultThreeValue$", strResultThreeValue); - strError += strResultThreeValue; - - /************************************************************** - **** 电压闪变 - ***************************************************************/ - // 获取电压长时闪变的限值 - String valueOfFlickerLimit = judgeNull(this.listFlicker.get(1).getOverLimit()); - reportmap.put("$PLT_L$", valueOfFlickerLimit); - String strResultFlicker = ""; - String tmpstrResultFlicker = ""; - String strResultFlickerValue = ""; - Double fmaxValue1 = 0.0; - Double fmaxValue2 = 0.0; - Double fmaxValue3 = 0.0; - Double flickerLimit = 0.0; - try { - fmaxValue1 = Double.parseDouble(plt1.getFmaxValue().toString()); - fmaxValue2 = Double.parseDouble(plt2.getFmaxValue().toString()); - fmaxValue3 = Double.parseDouble(plt3.getFmaxValue().toString()); - flickerLimit = Double.parseDouble(valueOfFlickerLimit); - } catch (Exception e) { - strResultFlickerValue += "注意:从上表中可以看出" + strLineBaseName + "长时闪变数据存在异常(不是数值类型)。"; - } - if (fmaxValue1 > flickerLimit) { - if (!"".equals(tmpstrResultFlicker)) - tmpstrResultFlicker += ","; - tmpstrResultFlicker += atype + "最大值为:" + plt1.getFmaxValue().toString(); - reportmap.put("$" + "L" + "V0R_" + "A" + "$", "不合格"); - } else { - reportmap.put("$" + "L" + "V0R_" + "A" + "$", "合格"); - } - - if (fmaxValue2 > flickerLimit) { - if (!"".equals(tmpstrResultFlicker)) - tmpstrResultFlicker += ","; - tmpstrResultFlicker += btype + "最大值为:" + plt2.getFmaxValue().toString(); - reportmap.put("$" + "L" + "V0R_" + "B" + "$", "不合格"); - } else { - reportmap.put("$" + "L" + "V0R_" + "B" + "$", "合格"); - } - - if (fmaxValue3 > flickerLimit && pttype != 2) { - if (!"".equals(tmpstrResultFlicker)) - tmpstrResultFlicker += ","; - tmpstrResultFlicker += ctype + "最大值为:" + plt3.getFmaxValue().toString(); - reportmap.put("$" + "L" + "V0R_" + "C" + "$", "不合格"); - } else { - reportmap.put("$" + "L" + "V0R_" + "C" + "$", "合格"); - } - - reportmap.put("$PSTX_A$", judgeNull(pst1.getFmaxValue())); - reportmap.put("$PSTN_A$", judgeNull(pst1.getMinValue())); - reportmap.put("$PSTE_A$", judgeNull(pst1.getMeanValue())); - reportmap.put("$PST%_A$", judgeNull(pst1.getCp95Value())); - reportmap.put("$PSTX_B$", judgeNull(pst2.getFmaxValue())); - reportmap.put("$PSTN_B$", judgeNull(pst2.getMinValue())); - reportmap.put("$PSTE_B$", judgeNull(pst2.getMeanValue())); - reportmap.put("$PST%_B$", judgeNull(pst2.getCp95Value())); - if (pttype != 2) { - reportmap.put("$PSTX_C$", judgeNull(pst3.getFmaxValue())); - reportmap.put("$PSTN_C$", judgeNull(pst3.getMinValue())); - reportmap.put("$PSTE_C$", judgeNull(pst3.getMeanValue())); - reportmap.put("$PST%_C$", judgeNull(pst3.getCp95Value())); - } else { - reportmap.put("$PSTX_C$", "-"); - reportmap.put("$PSTN_C$", "-"); - reportmap.put("$PSTE_C$", "-"); - reportmap.put("$PST%_C$", "-"); - } - - reportmap.put("$PLTX_A$", judgeNull(plt1.getFmaxValue())); - reportmap.put("$PLTN_A$", judgeNull(plt1.getMinValue())); - reportmap.put("$PLTE_A$", judgeNull(plt1.getMeanValue())); - reportmap.put("$PLT%_A$", judgeNull(plt1.getCp95Value())); - reportmap.put("$PLTX_B$", judgeNull(plt2.getFmaxValue())); - reportmap.put("$PLTN_B$", judgeNull(plt2.getMinValue())); - reportmap.put("$PLTE_B$", judgeNull(plt2.getMeanValue())); - reportmap.put("$PLT%_B$", judgeNull(plt2.getCp95Value())); - if (pttype != 2) { - reportmap.put("$PLTX_C$", judgeNull(plt3.getFmaxValue())); - reportmap.put("$PLTN_C$", judgeNull(plt3.getMinValue())); - reportmap.put("$PLTE_C$", judgeNull(plt3.getMeanValue())); - reportmap.put("$PLT%_C$", judgeNull(plt3.getCp95Value())); - } else { - reportmap.put("$PLTX_C$", "-"); - reportmap.put("$PLTN_C$", "-"); - reportmap.put("$PLTE_C$", "-"); - reportmap.put("$PLT%_C$", "-"); - } - reportmap.put("$PLT_L$", valueOfFlickerLimit); - - /************************************ - **** 三张大表取值 - **************************************/ - reportmap.put("$" + "L" + "V0" + "X" + "_" + "A" + "$", judgeNull(plt1.getFmaxValue())); - reportmap.put("$" + "L" + "V0" + "E" + "_" + "A" + "$", judgeNull(plt1.getMeanValue())); - reportmap.put("$" + "L" + "V0" + "N" + "_" + "A" + "$", judgeNull(plt1.getMinValue())); - reportmap.put("$" + "L" + "V0" + "%" + "_" + "A" + "$", judgeNull(plt1.getCp95Value())); - reportmap.put("$" + "L" + "V0" + "X" + "_" + "B" + "$", judgeNull(plt2.getFmaxValue())); - reportmap.put("$" + "L" + "V0" + "E" + "_" + "B" + "$", judgeNull(plt2.getMeanValue())); - reportmap.put("$" + "L" + "V0" + "N" + "_" + "B" + "$", judgeNull(plt2.getMinValue())); - reportmap.put("$" + "L" + "V0" + "%" + "_" + "B" + "$", judgeNull(plt2.getCp95Value())); - reportmap.put("$" + "L" + "V0" + "X" + "_" + "C" + "$", judgeNull(plt3.getFmaxValue())); - reportmap.put("$" + "L" + "V0" + "E" + "_" + "C" + "$", judgeNull(plt3.getMeanValue())); - reportmap.put("$" + "L" + "V0" + "N" + "_" + "C" + "$", judgeNull(plt3.getMinValue())); - reportmap.put("$" + "L" + "V0" + "%" + "_" + "C" + "$", judgeNull(plt3.getCp95Value())); - reportmap.put("$LV0%_L$", valueOfFlickerLimit); - - reportmap.put("$" + "S" + "V0" + "X" + "_" + "A" + "$", judgeNull(pst1.getFmaxValue())); - reportmap.put("$" + "S" + "V0" + "E" + "_" + "A" + "$", judgeNull(pst1.getMeanValue())); - reportmap.put("$" + "S" + "V0" + "N" + "_" + "A" + "$", judgeNull(pst1.getMinValue())); - reportmap.put("$" + "S" + "V0" + "%" + "_" + "A" + "$", judgeNull(pst1.getCp95Value())); - reportmap.put("$" + "S" + "V0" + "X" + "_" + "B" + "$", judgeNull(pst2.getFmaxValue())); - reportmap.put("$" + "S" + "V0" + "E" + "_" + "B" + "$", judgeNull(pst2.getMeanValue())); - reportmap.put("$" + "S" + "V0" + "N" + "_" + "B" + "$", judgeNull(pst2.getMinValue())); - reportmap.put("$" + "S" + "V0" + "%" + "_" + "B" + "$", judgeNull(pst2.getCp95Value())); - reportmap.put("$" + "S" + "V0" + "X" + "_" + "C" + "$", judgeNull(pst3.getFmaxValue())); - reportmap.put("$" + "S" + "V0" + "E" + "_" + "C" + "$", judgeNull(pst3.getMeanValue())); - reportmap.put("$" + "S" + "V0" + "N" + "_" + "C" + "$", judgeNull(pst3.getMinValue())); - reportmap.put("$" + "S" + "V0" + "%" + "_" + "C" + "$", judgeNull(pst3.getCp95Value())); - - if ("".equals(tmpstrResultFlicker)) { - strResultFlicker += "电压长时闪变根据国标标准测量结果以最大值、最小值、95%概率值作为判断是否合格的依据,从上表中可以看出" + strLineBaseName + "长时闪变" - + tmpstrResultFlicker + ",其满足国标限值(" + valueOfFlickerLimit + ")的要求。"; - } else { - strAnalysis += "长时闪变" + tmpstrResultFlicker + ",其不满足国标限值(" + valueOfFlickerLimit + ")的要求。"; - strResultFlicker += "电压长时闪变根据国标标准测量结果以最大值、最小值、95%概率值作为判断是否合格的依据,从上表中可以看出" + strLineBaseName + "长时闪变" - + tmpstrResultFlicker + ",其不满足国标限值(" + valueOfFlickerLimit + ")的要求。"; - } - - reportmap.put("$ResultFlicker$", strResultFlicker); - reportmap.put("$ResultFlickerValue$", strResultFlickerValue); - strError += strResultFlickerValue; - - /************************************************************** - **** 电压含有率 - ***************************************************************/ - String strResultVoltageRate = ""; - String tmpstrResultVoltageRate = ""; - String strResultVoltageRateValue = ""; - String strCurrentA, strCurrentB, strCurrentC, strLimit; - // 获取25次谐波 - for (int i = 1; i < 25; i++) { - String strMap = "$RV"; - String strCurrentRate = strMap + (i + 1) + "%"; - - // 基波电压含有率 - strCurrentA = judgeNull((this.listVoltageRate.get(i).getList().get(0)).getCp95Value()); - strCurrentB = judgeNull((this.listVoltageRate.get(i).getList().get(1)).getCp95Value()); - strCurrentC = judgeNull((this.listVoltageRate.get(i).getList().get(2)).getCp95Value()); - strLimit = judgeNull(this.listVoltageRate.get(i).getOverLimit()); - - reportmap.put(strCurrentRate + "_A$", strCurrentA); - reportmap.put(strCurrentRate + "_B$", strCurrentB); - if (pttype != 2) { - reportmap.put(strCurrentRate + "_C$", strCurrentC); - } else { - reportmap.put(strCurrentRate + "_C$", "-"); - } - reportmap.put(strCurrentRate + "_L$", strLimit); - - /************************************ - **** 三张大表取值 - **************************************/ - reportmap.put("$CV" + (i + 1) + "X_A$", - judgeNull((this.listVoltageRate.get(i).getList().get(0)).getFmaxValue())); - reportmap.put("$CV" + (i + 1) + "X_B$", - judgeNull((this.listVoltageRate.get(i).getList().get(1)).getFmaxValue())); - - reportmap.put("$CV" + (i + 1) + "N_A$", - judgeNull((this.listVoltageRate.get(i).getList().get(0)).getMinValue())); - reportmap.put("$CV" + (i + 1) + "N_B$", - judgeNull((this.listVoltageRate.get(i).getList().get(1)).getMinValue())); - - reportmap.put("$CV" + (i + 1) + "E_A$", - judgeNull((this.listVoltageRate.get(i).getList().get(0)).getMeanValue())); - reportmap.put("$CV" + (i + 1) + "E_B$", - judgeNull((this.listVoltageRate.get(i).getList().get(1)).getMeanValue())); - - if (pttype != 2) { - reportmap.put("$CV" + (i + 1) + "X_C$", - judgeNull((this.listVoltageRate.get(i).getList().get(2)).getFmaxValue())); - reportmap.put("$CV" + (i + 1) + "N_C$", - judgeNull((this.listVoltageRate.get(i).getList().get(2)).getMinValue())); - reportmap.put("$CV" + (i + 1) + "E_C$", - judgeNull((this.listVoltageRate.get(i).getList().get(2)).getMeanValue())); - reportmap.put("$CV" + (i + 1) + "%_C$", strCurrentC); - } else { - reportmap.put("$CV" + (i + 1) + "X_C$", "-"); - reportmap.put("$CV" + (i + 1) + "N_C$", "-"); - reportmap.put("$CV" + (i + 1) + "E_C$", "-"); - reportmap.put("$CV" + (i + 1) + "%_C$", "-"); - } - - reportmap.put("$CV" + (i + 1) + "%_A$", strCurrentA); - reportmap.put("$CV" + (i + 1) + "%_B$", strCurrentB); - reportmap.put("$CV" + (i + 1) + "L$", strLimit); - - try { - maxValue = Double.parseDouble(strCurrentA); - minValue = Double.parseDouble(strCurrentB); - aveValue = Double.parseDouble(strCurrentC); - limit = Double.parseDouble(strLimit); - } catch (Exception e) { - strResultVoltageRateValue += "注意:从上表中可以看出" + strLineBaseName + "谐波电压含有率95%概率值数据存在异常(不是数值类型)。"; - } - - String tmpstrResult = ""; - if (maxValue > limit) { - if (!"".equals(tmpstrResult)) { - tmpstrResult += "、"; - } - tmpstrResult += "A"; - // 三张大表取值 - reportmap.put("$CV" + (i + 1) + "R_A$", "不合格"); - } else { - // 三张大表取值 - reportmap.put("$CV" + (i + 1) + "R_A$", "合格"); - } - if (minValue > limit) { - if (!"".equals(tmpstrResult)) { - tmpstrResult += "、"; - } - tmpstrResult += "B"; - // 三张大表取值 - reportmap.put("$CV" + (i + 1) + "R_B$", "不合格"); - } else { - // 三张大表取值 - reportmap.put("$CV" + (i + 1) + "R_B$", "合格"); - } - if (aveValue > limit) { - if (!"".equals(tmpstrResult)) { - tmpstrResult += "、"; - } - tmpstrResult += "C"; - // 三张大表取值 - reportmap.put("$CV" + (i + 1) + "R_C$", "不合格"); - } else { - // 三张大表取值 - reportmap.put("$CV" + (i + 1) + "R_C$", "合格"); - } - // 判断单个结论是否存在 - if (!"".equals(tmpstrResult)) { - tmpstrResultVoltageRate += (i + 1) + "次谐波电压含有率95%概率值" + tmpstrResult + ";"; - } - } - - // 假如为空则所有的都满足 - if ("".equals(tmpstrResultVoltageRate)) { - strResultVoltageRate += "从上表中可以看出" + strLineBaseName + "2-25次谐波电压含有率95%概率值均满足国标限值要求。"; - } else { - strAnalysis += tmpstrResultVoltageRate + "2-25次谐波电压含有率95%概率值均不满足国标限值要求。"; - strResultVoltageRate += "从上表中可以看出" + strLineBaseName + tmpstrResultVoltageRate + "均不满足国标限值要求。"; - } - - /************************************************************** - **** 电压总谐波畸变率(THD) - ***************************************************************/ - ReportValue distortion1 = this.listDistortion.get(0).getList().get(0); - ReportValue distortion2 = this.listDistortion.get(0).getList().get(1); - ReportValue distortion3 = this.listDistortion.get(0).getList().get(2); - String distortionLimit = judgeNull(this.listDistortion.get(0).getOverLimit()); - reportmap.put("$DV0%_L$", distortionLimit); - - String strResultDistortion = ""; - String tmpstrResultDistortion = ""; - String strResultDistortionValue = ""; - - reportmap.put("$DV0%_A$", judgeNull(distortion1.getCp95Value())); - reportmap.put("$DV0%_B$", judgeNull(distortion2.getCp95Value())); - reportmap.put("$DV0%_C$", judgeNull(distortion3.getCp95Value())); - - /************************************ - **** 三张大表取值 - **************************************/ - reportmap.put("$TV0X_L$", distortionLimit); - reportmap.put("$TV0X_A$", judgeNull(distortion1.getFmaxValue())); - reportmap.put("$TV0E_A$", judgeNull(distortion1.getMeanValue())); - reportmap.put("$TV0N_A$", judgeNull(distortion1.getMinValue())); - reportmap.put("$TV0%_A$", judgeNull(distortion1.getCp95Value())); - - reportmap.put("$TV0X_B$", judgeNull(distortion2.getFmaxValue())); - reportmap.put("$TV0E_B$", judgeNull(distortion2.getMeanValue())); - reportmap.put("$TV0N_B$", judgeNull(distortion2.getMinValue())); - reportmap.put("$TV0%_B$", judgeNull(distortion2.getCp95Value())); - - reportmap.put("$TV0X_C$", judgeNull(distortion3.getFmaxValue())); - reportmap.put("$TV0E_C$", judgeNull(distortion3.getMeanValue())); - reportmap.put("$TV0N_C$", judgeNull(distortion3.getMinValue())); - reportmap.put("$TV0%_C$", judgeNull(distortion3.getCp95Value())); - - // 值错误判断 - try { - cp95ValueA = Math.abs(Double.parseDouble(distortion1.getCp95Value().toString())); - cp95ValueB = Math.abs(Double.parseDouble(distortion2.getCp95Value().toString())); - cp95ValueC = Math.abs(Double.parseDouble(distortion3.getCp95Value().toString())); - limit = Math.abs(Double.parseDouble(distortionLimit)); - } catch (Exception e) { - strResultDistortionValue += "注意:从上表中可以看出" + strLineBaseName + "电压总谐波畸变率(THD)数据存在异常(不是数值类型)。"; - } - // 限值判断 - if (cp95ValueA > limit) { - if (!"".equals(tmpstrResultDistortion)) { - tmpstrResultDistortion += "、"; - } - tmpstrResultDistortion += atype; - // 三张大表取值 - reportmap.put("$TV0R_A$", "不合格"); - } else { - // 三张大表取值 - reportmap.put("$TV0R_A$", "合格"); - } - if (cp95ValueB > limit) { - if (!"".equals(tmpstrResultDistortion)) { - tmpstrResultDistortion += "、"; - } - tmpstrResultDistortion += btype; - // 三张大表取值 - reportmap.put("$TV0R_B$", "不合格"); - } else { - // 三张大表取值 - reportmap.put("$TV0R_B$", "合格"); - } - if (cp95ValueC > limit && pttype != 2) { - if (!"".equals(tmpstrResultDistortion)) { - tmpstrResultDistortion += "、"; - } - tmpstrResultDistortion += ctype; - // 三张大表取值 - reportmap.put("$TV0R_C$", "不合格"); - } else { - // 三张大表取值 - reportmap.put("$TV0R_C$", "合格"); - } - - // 假如为空则所有的都满足 - if ("".equals(tmpstrResultDistortion)) { - strResultDistortion += "电压总谐波畸变率(THD)95%概率值均满足国标限值要求。"; - } else { - strAnalysis += "电压总谐波畸变率(THD)95%概率值" + tmpstrResultDistortion + "均不满足国标限值要求。"; - strResultDistortion += "电压总谐波畸变率(THD)95%概率值" + tmpstrResultDistortion + "均不满足国标限值要求。"; - } - reportmap.put("$ResultVoltageRate$", strResultVoltageRate + strResultDistortion); - reportmap.put("$ResultVoltageRateValue$", strResultVoltageRateValue + strResultDistortionValue); - strError += strResultVoltageRateValue + strResultDistortionValue; - - /************************************************************** - **** 谐波电流幅值 - ***************************************************************/ - String strResultCurrent = ""; - String tmpstrResultCurrent = ""; - String strResultCurrentValue = ""; - // 获取25次谐波 - for (int i = 1; i < 25; i++) { - String strMap = "$RI"; - String strCurrent = strMap + (i + 1) + "%"; - - // 基波电压含有率 - strCurrentA = judgeNull(this.listICurrent.get(i).getList().get(0).getCp95Value()); - strCurrentB = judgeNull(this.listICurrent.get(i).getList().get(1).getCp95Value()); - strCurrentC = judgeNull(this.listICurrent.get(i).getList().get(2).getCp95Value()); - strLimit = judgeNull(this.listICurrent.get(i).getOverLimit()); - - reportmap.put(strCurrent + "_A$", strCurrentA); - reportmap.put(strCurrent + "_B$", strCurrentB); - reportmap.put(strCurrent + "_C$", strCurrentC); - reportmap.put(strCurrent + "_L$", strLimit); - - /************************************ - **** 三张大表取值 - **************************************/ - reportmap.put("$CI" + (i + 1) + "X_A$", judgeNull(this.listICurrent.get(i).getList().get(0).getFmaxValue())); - reportmap.put("$CI" + (i + 1) + "X_B$", judgeNull(this.listICurrent.get(i).getList().get(1).getFmaxValue())); - reportmap.put("$CI" + (i + 1) + "X_C$", judgeNull(this.listICurrent.get(i).getList().get(2).getFmaxValue())); - - reportmap.put("$CI" + (i + 1) + "N_A$", judgeNull(this.listICurrent.get(i).getList().get(0).getMinValue())); - reportmap.put("$CI" + (i + 1) + "N_B$", judgeNull(this.listICurrent.get(i).getList().get(1).getMinValue())); - reportmap.put("$CI" + (i + 1) + "N_C$", judgeNull(this.listICurrent.get(i).getList().get(2).getMinValue())); - - reportmap.put("$CI" + (i + 1) + "E_A$", judgeNull(this.listICurrent.get(i).getList().get(0).getMeanValue())); - reportmap.put("$CI" + (i + 1) + "E_B$", judgeNull(this.listICurrent.get(i).getList().get(1).getMeanValue())); - reportmap.put("$CI" + (i + 1) + "E_C$", judgeNull(this.listICurrent.get(i).getList().get(2).getMeanValue())); - - reportmap.put("$CI" + (i + 1) + "%_A$", strCurrentA); - reportmap.put("$CI" + (i + 1) + "%_B$", strCurrentB); - reportmap.put("$CI" + (i + 1) + "%_C$", strCurrentC); - reportmap.put("$CI" + (i + 1) + "L$", strLimit); - - try { - maxValue = Double.parseDouble(strCurrentA); - minValue = Double.parseDouble(strCurrentB); - aveValue = Double.parseDouble(strCurrentC); - limit = Double.parseDouble(strLimit); - } catch (Exception e) { - strResultCurrentValue += "注意:从上表中可以看出" + strLineBaseName + "谐波电流幅值95%概率值数据存在异常(不是数值类型)。"; - } - - String tmpstrResult = ""; - if (maxValue > limit) { - if (!"".equals(tmpstrResult)) { - tmpstrResult += "、"; - } - tmpstrResult += "A"; - // 三张大表取值 - reportmap.put("$CI" + (i + 1) + "R_A$", "不合格"); - } else { - // 三张大表取值 - reportmap.put("$CI" + (i + 1) + "R_A$", "合格"); - } - if (minValue > limit) { - if (!"".equals(tmpstrResult)) { - tmpstrResult += "、"; - } - tmpstrResult += "B"; - // 三张大表取值 - reportmap.put("$CI" + (i + 1) + "R_B$", "不合格"); - } else { - // 三张大表取值 - reportmap.put("$CI" + (i + 1) + "R_B$", "合格"); - } - if (aveValue > limit) { - if (!"".equals(tmpstrResult)) { - tmpstrResult += "、"; - } - tmpstrResult += "C"; - // 三张大表取值 - reportmap.put("$CI" + (i + 1) + "R_C$", "不合格"); - } else { - // 三张大表取值 - reportmap.put("$CI" + (i + 1) + "R_C$", "合格"); - } - // 判断单个结论是否存在 - if (!"".equals(tmpstrResult)) { - tmpstrResultCurrent += (i + 1) + "次谐波电流幅值95%概率值" + tmpstrResult + ";"; - } - } - - // 假如为空则所有的都满足 - if ("".equals(tmpstrResultCurrent)) { - strResultCurrent += "从上表中可以看出" + strLineBaseName + "2-25次谐波电流幅值95%概率值均满足国标限值要求。"; - } else { - strAnalysis += tmpstrResultCurrent + "均不满足国标限值要求。"; - strResultCurrent += "从上表中可以看出" + strLineBaseName + tmpstrResultCurrent + "均不满足国标限值要求。"; - } - - reportmap.put("$ResultCurrent$", strResultCurrent); - reportmap.put("$ResultCurrentValue$", strResultCurrentValue); - strError += strResultCurrentValue; - - // 测试结果填写 - reportmap.put("$ResultTitle$", String.format("通过对(%s——%s)时间段内%s电能质量统计数据分析后得出以下结论:", - new String[]{DateUtil.format(startDate, "yyyy年MM月dd日 HH时mm分ss秒"), - DateUtil.format(endDate, "yyyy年MM月dd日 HH时mm分ss秒"), strLineBaseName})); - - // 电压偏差 - reportmap.put("$Result_VD$", String.format("(1)电压偏差:%s", new String[]{strResultVdeviationdata})); - // 频率偏差 - reportmap.put("$Result_FRE$", String.format("(2)频率偏差:%s", new String[]{strResultFre})); - // 三相电压不平衡度 - reportmap.put("$Result_THE$", String.format("(3)三相电压不平衡度:%s", new String[]{strResultThree})); - // 电压长时闪变 - reportmap.put("$Result_FIC$", String.format("(4)电压长时闪变:%s", new String[]{strResultFlicker})); - // 谐波电压 - reportmap.put("$Result_VOL$", String.format("(5)谐波电压:%s", new String[]{strResultVoltageRate})); - // 谐波电流 - reportmap.put("$Result_CUR$", String.format("(6)谐波电流:%s", new String[]{strResultCurrent})); - // 分析建议填写 - if (!"".equals(strAnalysis) || !"".equals(strError)) { - // 分析建议 - reportmap.put("$Analysis$", "根据统计数据结果分析,监测点为:" + name + "," + strAnalysis + strError); - } else { - // 分析建议 - reportmap.put("$Analysis$", "根据统计数据结果分析,监测点为:" + name + ",电能质量数据满足国标限值要求。"); - } - - /************************************ - **** 三张大表取值 有功:0-11 无功:12-23 视在:24-31 基波有功汇总:32-35 基波无功汇总:36-39 - * 基波视在汇总:40-43 功率因数:44-46 - **************************************/ - ReportValue powerDto1 = this.listPower.get(0).getList().get(3); - ReportValue powerDto2 = this.listPower.get(1).getList().get(3); - ReportValue powerDto3 = this.listPower.get(2).getList().get(3); - ReportValue powerDto4 = this.listPower.get(3).getList().get(3); - reportmap.put("$BF0X$", judgeNull(powerDto1.getFmaxValue())); - reportmap.put("$BF0N$", judgeNull(powerDto1.getMinValue())); - reportmap.put("$BF0E$", judgeNull(powerDto1.getMeanValue())); - - reportmap.put("$NF0X$", judgeNull(powerDto2.getFmaxValue())); - reportmap.put("$NF0N$", judgeNull(powerDto2.getMinValue())); - reportmap.put("$NF0E$", judgeNull(powerDto2.getMeanValue())); - - reportmap.put("$SF0X$", judgeNull(powerDto3.getFmaxValue())); - reportmap.put("$SF0N$", judgeNull(powerDto3.getMinValue())); - reportmap.put("$SF0E$", judgeNull(powerDto3.getMeanValue())); - - reportmap.put("$YF0X$", judgeNull(powerDto4.getFmaxValue())); - reportmap.put("$YF0N$", judgeNull(powerDto4.getMinValue())); - reportmap.put("$YF0E$", judgeNull(powerDto4.getMeanValue())); - // 报告时分秒格式 - formatter = new SimpleDateFormat("yyyyMMddHHmmss"); - - String reportFileUrl = ""; - try { - String fileName = name + formatter.format(currentTime) + ".docx"; - if(ObjectUtil.isNotNull(isUrl)){ - if (isUrl) { - reportFileUrl = wordUtil2.getReportFileUrl(rtfPath, name + formatter.format(currentTime) + ".docx",null ,reportmap); - return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, reportFileUrl, methodDescribe); - } - } - wordUtil2.getWord(rtfPath, reportmap, fileName,null, response); - } catch (Exception e) { - log.error("获取报告发生异常,异常是:",e); - } - return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, reportFileUrl, methodDescribe); - } - - /** - * 数据单位信息 重组 - * - * @param deviceUnit 数据单位对象 - * @return - */ - private Map unitMap(PqsDeviceUnit deviceUnit) { - List dictData = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEVICE_UNIT.getCode()).getData(); - Map unit = new HashMap<>(16); - List list = dictData.stream().map(DictData::getCode).collect(Collectors.toList()); - for (String s : list) { - //有效值 - if (s.equals(DicDataEnum.EFFECTIVE.getCode())) { - unit.put("$" + s + "_i$", deviceUnit.getIeffective()); - unit.put("$" + s + "_v$", deviceUnit.getLineVoltage()); - } - //功率 - if (s.equals(DicDataEnum.POWER.getCode())) { - unit.put("$" + s + "_p$", deviceUnit.getTotalActiveP()); - unit.put("$" + s + "_q$", deviceUnit.getTotalNoP()); - unit.put("$" + s + "_s$", deviceUnit.getTotalViewP()); - } - //畸变率 - if (s.equals(DicDataEnum.DISTORTION.getCode())) { - unit.put("$" + s + "_v$", deviceUnit.getVdistortion()); - } - //电压偏差 - if (s.equals(DicDataEnum.VOLTAGE.getCode())) { - unit.put("$" + s + "_v$", deviceUnit.getVoltageDev()); - } - //频率 - if (s.equals(DicDataEnum.UNIT_FREQUENCY.getCode())) { - unit.put("$" + s + "_freq$", deviceUnit.getUnitFrequency()); - unit.put("$" + s + "_freqDev$", deviceUnit.getUnitFrequencyDev()); - } - //三项不平衡度 - if (s.equals(DicDataEnum.UNBALANCE.getCode())) { - unit.put("$" + s + "_v$", "%"); - unit.put("$" + s + "_vPos$", deviceUnit.getPositiveV()); - unit.put("$" + s + "_vNeg$", deviceUnit.getNoPositiveV()); - unit.put("$" + s + "_vZero$", deviceUnit.getNoPositiveV()); - unit.put("$" + s + "_i$", "%"); - unit.put("$" + s + "_iPos$", "A"); - unit.put("$" + s + "_iNeg$", "A"); - unit.put("$" + s + "_iZero$", "A"); - } - //基波 - if (s.equals(DicDataEnum.FUND.getCode())) { - unit.put("$" + s + "_i$", deviceUnit.getIfund()); - unit.put("$" + s + "_v$", deviceUnit.getVfundEffective()); - - } - } - return unit; } - /** - * 解析base64,返回图片所在路径 - */ - @SuppressWarnings("restriction") - private String decodeBase64(byte[] base64Info) { - if (base64Info.length == 0) { - return null; - } - BASE64Encoder decoder = new BASE64Encoder(); - - return decoder.encode(base64Info); - } - - private void transformData(List list, List listValue, List listOverlimit, boolean... b) { - int offset = b[0] ? 3 : 1; - offset = (b.length == 2 && !b[1]) ? 4 : offset; - int i = 0; - - for (int index = 0; index < listValue.size(); index += offset) { - if (i == listOverlimit.size()) { - break; - } - ReportTarget reportTarget = new ReportTarget(); - reportTarget.setList(listValue.subList(index, index + offset)); - Float overLimit = listOverlimit.get(i).getOverLimit(); - reportTarget.setOverLimit(overLimit); - - switch (listOverlimit.get(i).getCode()) { - case 1: - for (int k = 0; k < reportTarget.getList().size(); k++) { - if (null == reportTarget.getList().get(k).getFmaxValue()) { - break; - } else if (reportTarget.getList().get(k).getFmaxValue().floatValue() > overLimit.floatValue()) { - reportTarget.setPass(EnumPass.NOPASS.getCode()); - break; - } else { - reportTarget.setPass(EnumPass.PASS.getCode()); - } - } - break; - case 2: - for (int k = 0; k < reportTarget.getList().size(); k++) { - if (null == reportTarget.getList().get(k).getMinValue()) { - break; - } else if (reportTarget.getList().get(k).getMinValue().floatValue() > overLimit.floatValue()) { - reportTarget.setPass(EnumPass.NOPASS.getCode()); - break; - } else { - reportTarget.setPass(EnumPass.PASS.getCode()); - } - } - break; - case 3: - for (int k = 0; k < reportTarget.getList().size(); k++) { - if (null == reportTarget.getList().get(k).getMeanValue()) { - break; - } else if (reportTarget.getList().get(k).getMeanValue().floatValue() > overLimit.floatValue()) { - reportTarget.setPass(EnumPass.NOPASS.getCode()); - break; - } else { - reportTarget.setPass(EnumPass.PASS.getCode()); - } - } - break; - case 4: - for (int k = 0; k < reportTarget.getList().size(); k++) { - if (null == reportTarget.getList().get(k).getCp95Value()) { - break; - } else if (reportTarget.getList().get(k).getCp95Value().floatValue() > overLimit.floatValue()) { - reportTarget.setPass(EnumPass.NOPASS.getCode()); - break; - } else { - reportTarget.setPass(EnumPass.PASS.getCode()); - } - } - break; - default: - break; - } - - i++; - list.add(reportTarget); - } - } - - /** - * 基波幅值 - */ - public void getVirtualData(ReportQueryParam param) { - - List listVirtual = reportService.getVirtualData(param); - - List list = new ArrayList<>(); - - for (int i = 0; i < 3; i++) { - Pass pass = new Pass(null); - list.add(pass); - } - - this.listVirtual = new ArrayList<>(); - - transformData(this.listVirtual, listVirtual, list, true); - - - } - - /** - * 功率 - */ - public void getPowerData(ReportQueryParam param) { - List listPower = reportService.getPowerData(param); - - List list = new ArrayList<>(); - - for (int i = 0; i < 4; i++) { - Pass pass = new Pass(null); - list.add(pass); - } - this.listPower = new ArrayList<>(); - transformData(this.listPower, listPower, list, true, false); - } - - /** - * 闪变 - */ - public void getFlicker(ReportQueryParam param, Overlimit overLimit) { - List listFlicker = reportService.getFlickerData(param); - List list = new ArrayList<>(); - for (int i = 0; i < 2; i++) { - Pass pass; - if (i == 1) { - pass = new Pass(overLimit.getFlicker(), EnumPass.MAX.getCode()); - } else { - pass = new Pass(null); - } - list.add(pass); - } - this.listFlicker = new ArrayList<>(); - transformData(this.listFlicker, listFlicker, list, true); - } - - /** - * 电压偏差 - */ - public void getVdeviation(ReportQueryParam param, Overlimit overLimit) { - List listVdeviation = reportService.getVdeviation(param); - List list = new ArrayList<>(); - for (int i = 0; i < 2; i++) { - Pass pass; - pass = new Pass(overLimit.getVoltageDev(), EnumPass.MAX.getCode()); - list.add(pass); - } - this.listVdeviation = new ArrayList<>(); - transformData(this.listVdeviation, listVdeviation, list, true); - } - - /** - * 畸变率 - */ - public void getDistortion(ReportQueryParam param, Overlimit overLimit) { - List listDistortion = reportService.getDistortionData(param); - List list = new ArrayList<>(); - for (int i = 0; i < 2; i++) { - Pass pass; - - if (i == 0) { - pass = new Pass(overLimit.getUaberrance(), EnumPass.MAX.getCode()); - } else { - pass = new Pass(null); - } - - list.add(pass); - } - this.listDistortion = new ArrayList<>(); - transformData(this.listDistortion, listDistortion, list, true); - } - - /** - * 频率 - */ - public void getFre(ReportQueryParam param, Overlimit overLimit) { - List listFrequency = reportService.getFrequencyData(param); - - List list = new ArrayList<>(); - - for (int i = 0; i < 2; i++) { - Pass pass; - if (i == 1) { - pass = new Pass(overLimit.getFreqDev(), EnumPass.MAX.getCode()); - } else { - pass = new Pass(null); - } - list.add(pass); - } - - this.listFrequency = new ArrayList<>(); - transformData(this.listFrequency, listFrequency, list, false); - } - - - /** - * 三相不平衡 - */ - public void getThreePhase(ReportQueryParam param, Overlimit overLimit) { - List listThreephase = reportService.getThreephase(param); - - List list = new ArrayList<>(); - - for (int i = 0; i < 8; i++) { - Pass pass; - - if (i == 0) { - pass = new Pass(overLimit.getUbalance(), EnumPass.CP95.getCode()); - } else { - pass = new Pass(null); - } - - list.add(pass); - } - - this.listThreephase = new ArrayList<>(); - transformData(this.listThreephase, listThreephase, list, false); - } - - - /** - * 谐波电流 - */ - public void getCurrentRate(ReportQueryParam param, Overlimit overLimit) { - List listICurrent = reportService.getICurrent(param); - - List list = new ArrayList<>(); - List iHarmList = getIHarmList(overLimit); - for (int i = 0; i < 50; i++) { - Pass pass; - if (i < iHarmList.size() + 1 && i > 0) { - pass = new Pass(iHarmList.get(i - 1), - EnumPass.CP95.getCode()); - } else { - pass = new Pass(null); - } - list.add(pass); - } - - this.listICurrent = new ArrayList<>(); - transformData(this.listICurrent, listICurrent, list, true); - } - - /** - * 谐波电压 - */ - public void getVoltageRate(ReportQueryParam param, Overlimit overLimit) { - List listVoltageRate = reportService.getVoltageRate(param); - - List list = new ArrayList<>(); - List vHarmList = getVHarmList(overLimit); - for (int i = 0; i < 51; i++) { - Pass pass; - - if (i == 0) { - pass = new Pass(null); - } else if (i == 50) { - pass = new Pass(overLimit.getUaberrance(), EnumPass.MAX.getCode()); - } else if (i < vHarmList.size() + 1) { - pass = new Pass(vHarmList.get(i - 1), - EnumPass.CP95.getCode()); - } else { - pass = new Pass(null); - } - - list.add(pass); - } - - this.listVoltageRate = new ArrayList<>(); - transformData(this.listVoltageRate, listVoltageRate, list, true); - } - - public String judgeNull(Float result) { - return (result == null) ? "/" : result.toString(); - } - - /** - * 谐波电流限值 - * - * @param overLimit - * @return - */ - public List getIHarmList(Overlimit overLimit) { - List list = new ArrayList<>(); - list.add(overLimit.getIharm2()); - list.add(overLimit.getIharm3()); - list.add(overLimit.getIharm4()); - list.add(overLimit.getIharm5()); - list.add(overLimit.getIharm6()); - list.add(overLimit.getIharm7()); - list.add(overLimit.getIharm8()); - list.add(overLimit.getIharm9()); - list.add(overLimit.getIharm10()); - list.add(overLimit.getIharm11()); - list.add(overLimit.getIharm12()); - list.add(overLimit.getIharm13()); - list.add(overLimit.getIharm14()); - list.add(overLimit.getIharm15()); - list.add(overLimit.getIharm16()); - list.add(overLimit.getIharm17()); - list.add(overLimit.getIharm18()); - list.add(overLimit.getIharm19()); - list.add(overLimit.getIharm20()); - list.add(overLimit.getIharm21()); - list.add(overLimit.getIharm22()); - list.add(overLimit.getIharm23()); - list.add(overLimit.getIharm24()); - list.add(overLimit.getIharm25()); - return list; - } - - /** - * 谐波电压限值 - * - * @return - */ - public List getVHarmList(Overlimit overLimit) { - List list = new ArrayList<>(); - list.add(overLimit.getUharm2()); - list.add(overLimit.getUharm3()); - list.add(overLimit.getUharm4()); - list.add(overLimit.getUharm5()); - list.add(overLimit.getUharm6()); - list.add(overLimit.getUharm7()); - list.add(overLimit.getUharm8()); - list.add(overLimit.getUharm9()); - list.add(overLimit.getUharm10()); - list.add(overLimit.getUharm11()); - list.add(overLimit.getUharm12()); - list.add(overLimit.getUharm13()); - list.add(overLimit.getUharm14()); - list.add(overLimit.getUharm15()); - list.add(overLimit.getUharm16()); - list.add(overLimit.getUharm17()); - list.add(overLimit.getUharm18()); - list.add(overLimit.getUharm19()); - list.add(overLimit.getUharm20()); - list.add(overLimit.getUharm21()); - list.add(overLimit.getUharm22()); - list.add(overLimit.getUharm23()); - list.add(overLimit.getUharm24()); - list.add(overLimit.getUharm25()); - return list; - } } diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/ExcelRptTempMapper.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/ExcelRptTempMapper.java deleted file mode 100644 index 076f10f..0000000 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/ExcelRptTempMapper.java +++ /dev/null @@ -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 { - - Page getReportTemplateListPage(Page page, @Param("baseParam")BaseParam baseParam); - - List getReportTemplateList(@Param("reportSearchParam")ReportSearchParam reportSearchParam); - - List getReportTemplateByDept(@Param("ids") List ids); - - - @Select("${sqlStr}") - StatisticalDataDTO dynamicSql(@Param("sqlStr")String sql); - - @Select("${sqlStr}") - Map dynamicSqlMap(@Param("sqlStr")String sql); -} diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/mapping/ExcelRptTempMapper.xml b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/mapping/ExcelRptTempMapper.xml deleted file mode 100644 index aa2d64d..0000000 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/mapping/ExcelRptTempMapper.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/report/ExcelRptTempMapper.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/report/ExcelRptTempMapper.java new file mode 100644 index 0000000..cf2350c --- /dev/null +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/report/ExcelRptTempMapper.java @@ -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 { +// +// Page getReportTemplateListPage(Page page, @Param("baseParam")BaseParam baseParam); +// +// List getReportTemplateList(@Param("reportSearchParam")ReportSearchParam reportSearchParam); +// +// List getReportTemplateByDept(@Param("ids") List ids); +// +// +// @Select("${sqlStr}") +// StatisticalDataDTO dynamicSql(@Param("sqlStr")String sql); +// +// @Select("${sqlStr}") +// Map dynamicSqlMap(@Param("sqlStr")String sql); +//} diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/report/RStatDataHarmRateVDMapper.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/report/RStatDataHarmRateVDMapper.java index 26601bc..5e43d89 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/report/RStatDataHarmRateVDMapper.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/report/RStatDataHarmRateVDMapper.java @@ -1,16 +1,16 @@ -package com.njcn.csharmonic.mapper.report; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.njcn.csharmonic.pojo.po.day.RStatDataHarmrateVDPO; - -/** - *

- * Mapper 接口 - *

- * - * @author wr - * @since 2023-04-17 - */ -public interface RStatDataHarmRateVDMapper extends BaseMapper { - -} +//package com.njcn.csharmonic.mapper.report; +// +//import com.baomidou.mybatisplus.core.mapper.BaseMapper; +//import com.njcn.csharmonic.pojo.po.day.RStatDataHarmrateVDPO; +// +///** +// *

+// * Mapper 接口 +// *

+// * +// * @author wr +// * @since 2023-04-17 +// */ +//public interface RStatDataHarmRateVDMapper extends BaseMapper { +// +//} diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/report/RStatDataIDMapper.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/report/RStatDataIDMapper.java index ecace9a..063901a 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/report/RStatDataIDMapper.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/report/RStatDataIDMapper.java @@ -1,29 +1,29 @@ -package com.njcn.csharmonic.mapper.report; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.njcn.csharmonic.pojo.po.day.RStatDataIDPO; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -/** - *

- * Mapper 接口 - *

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

+// * Mapper 接口 +// *

+// * +// * @author wr +// * @since 2023-04-17 +// */ +//public interface RStatDataIDMapper extends BaseMapper { +// +// /** +// * 获取监测点负序电流 +// * @return +// */ +// List getINeg(@Param("list") List lineList, @Param("startTime") String startTime, @Param("endTime") String endTime); +// +// /** +// * 谐波电流 +// */ +// List getI(@Param("list") List lineList, @Param("startTime") String startTime, @Param("endTime") String endTime); +//} diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/report/RStatDataInharmVDMapper.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/report/RStatDataInharmVDMapper.java index aceee4f..0100f3b 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/report/RStatDataInharmVDMapper.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/report/RStatDataInharmVDMapper.java @@ -1,17 +1,17 @@ -package com.njcn.csharmonic.mapper.report; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.njcn.csharmonic.pojo.po.day.RStatDataInharmVDPO; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -/** - * @Description: - * @Author: wr - * @Date: 2024/7/31 9:24 - */ -public interface RStatDataInharmVDMapper extends BaseMapper { - - //List getV(@Param("list") List lineList, @Param("startTime") String startTime, @Param("endTime") String endTime); -} +//package com.njcn.csharmonic.mapper.report; +// +//import com.baomidou.mybatisplus.core.mapper.BaseMapper; +//import com.njcn.csharmonic.pojo.po.day.RStatDataInharmVDPO; +//import org.apache.ibatis.annotations.Param; +// +//import java.util.List; +// +///** +// * @Description: +// * @Author: wr +// * @Date: 2024/7/31 9:24 +// */ +//public interface RStatDataInharmVDMapper extends BaseMapper { +// +// //List getV(@Param("list") List lineList, @Param("startTime") String startTime, @Param("endTime") String endTime); +//} diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/report/RStatDataVDPOMapper.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/report/RStatDataVDPOMapper.java index 58cd72e..1bf3ae5 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/report/RStatDataVDPOMapper.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/report/RStatDataVDPOMapper.java @@ -1,43 +1,43 @@ -package com.njcn.csharmonic.mapper.report; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.njcn.csharmonic.pojo.po.day.RStatDataVDPO; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -/** - *

- * Mapper 接口 - *

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

+// * Mapper 接口 +// *

+// * +// * @author wr +// * @since 2023-03-31 +// */ +//public interface RStatDataVDPOMapper extends BaseMapper { +// +// /** +// * 获取频率偏差、三相电压不平衡度 +// */ +// List getFreqDev(@Param("list") List lineList, @Param("startTime") String startTime, @Param("endTime") String endTime); +// +// /** +// * 获取电压偏差 +// */ +// List getVuDev(@Param("list") List lineList, @Param("startTime") String startTime, @Param("endTime") String endTime); +// +// /** +// * 获取电压总谐波畸变率 +// */ +// List getVthd(@Param("list") List lineList, @Param("startTime") String startTime, @Param("endTime") String endTime); +// +// /** +// * 获取三相电压不平衡度 +// */ +// List getUnbalance(@Param("list") List lineList, @Param("startTime") String startTime, @Param("endTime") String endTime); +// +// /** +// * 获取谐波电压 +// */ +// List getV(@Param("list") List lineList, @Param("startTime") String startTime, @Param("endTime") String endTime); +//} diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/report/ReportMapper.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/report/ReportMapper.java index f024378..2386e9c 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/report/ReportMapper.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/report/ReportMapper.java @@ -1,138 +1,138 @@ -package com.njcn.csharmonic.mapper.report; - - -import com.njcn.csharmonic.pojo.param.report.ReportQueryParam; -import com.njcn.csharmonic.pojo.vo.report.ReportValue; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -/** - * 谐波报告查询 - */ -public interface ReportMapper { - /** - * 获取电流有效值 - * @return - */ - List getVirtualDataI(@Param("param") ReportQueryParam param); - - /** - * 获取电压有效值 - * @return - */ - List getVirtualDataV(@Param("param") ReportQueryParam param); - - /** - * CP95条数 - * @param param - * @return - */ - Integer getTotalCP95Day(@Param("param")ReportQueryParam param); - /** - * CP95条数 - * @param param - * @return - */ - Integer getTotalPltCP95Day(@Param("param")ReportQueryParam param); - /** - * CP95条数 - * @param param - * @return - */ - Integer getTotalPstCP95Day(@Param("param")ReportQueryParam param); - - - List getVVirtualData(@Param("param")ReportQueryParam param); - - /** - * 获取有功功率 - * @param param - * @return - */ - List getPowerP(@Param("param")ReportQueryParam param); - - /** - * 无功功率 - * @param param - * @return - */ - List getPowerQ(@Param("param")ReportQueryParam param); - - /** - * 视在功率 - * @param param - * @return - */ - List getPowerS(@Param("param")ReportQueryParam param); - - /** - * 功率因数 - * @param param - * @return - */ - List getPF(@Param("param")ReportQueryParam param); - - /** - * 短时闪变 - * @param param - * @return - */ - List getFlickerData(@Param("param")ReportQueryParam param); - - /** - * 长时闪变 - * @param param - * @return - */ - List getLFlickerData(@Param("param")ReportQueryParam param); - - /** - * 电压负偏差 - * @param param - * @return - */ - List getUVdeviationData(@Param("param")ReportQueryParam param); - - /** - * 电压正偏差 - * @param param - * @return - */ - List getLVdeviationData(@Param("param")ReportQueryParam param); - - /** - * 获取电压畸变率 - * @param param - * @return - */ - List getDistortionDataV(@Param("param")ReportQueryParam param); - - /** - * 获取电流畸变率 - * @param param - * @return - */ - List getDistortionDataI(@Param("param")ReportQueryParam param); - - /** - *频率 - * @param param - * @return - */ - List getFrequencyData(@Param("param")ReportQueryParam param); - - /** - *频率 - * @param param - * @return - */ - List getDEVFrequencyData(@Param("param")ReportQueryParam param); - - /** - * 负序电流 - * @param param - * @return - */ - List getINegData(@Param("param")ReportQueryParam param); -} +//package com.njcn.csharmonic.mapper.report; +// +// +//import com.njcn.csharmonic.pojo.param.report.ReportQueryParam; +//import com.njcn.csharmonic.pojo.vo.report.ReportValue; +//import org.apache.ibatis.annotations.Param; +// +//import java.util.List; +// +///** +// * 谐波报告查询 +// */ +//public interface ReportMapper { +// /** +// * 获取电流有效值 +// * @return +// */ +// List getVirtualDataI(@Param("param") ReportQueryParam param); +// +// /** +// * 获取电压有效值 +// * @return +// */ +// List getVirtualDataV(@Param("param") ReportQueryParam param); +// +// /** +// * CP95条数 +// * @param param +// * @return +// */ +// Integer getTotalCP95Day(@Param("param")ReportQueryParam param); +// /** +// * CP95条数 +// * @param param +// * @return +// */ +// Integer getTotalPltCP95Day(@Param("param")ReportQueryParam param); +// /** +// * CP95条数 +// * @param param +// * @return +// */ +// Integer getTotalPstCP95Day(@Param("param")ReportQueryParam param); +// +// +// List getVVirtualData(@Param("param")ReportQueryParam param); +// +// /** +// * 获取有功功率 +// * @param param +// * @return +// */ +// List getPowerP(@Param("param")ReportQueryParam param); +// +// /** +// * 无功功率 +// * @param param +// * @return +// */ +// List getPowerQ(@Param("param")ReportQueryParam param); +// +// /** +// * 视在功率 +// * @param param +// * @return +// */ +// List getPowerS(@Param("param")ReportQueryParam param); +// +// /** +// * 功率因数 +// * @param param +// * @return +// */ +// List getPF(@Param("param")ReportQueryParam param); +// +// /** +// * 短时闪变 +// * @param param +// * @return +// */ +// List getFlickerData(@Param("param")ReportQueryParam param); +// +// /** +// * 长时闪变 +// * @param param +// * @return +// */ +// List getLFlickerData(@Param("param")ReportQueryParam param); +// +// /** +// * 电压负偏差 +// * @param param +// * @return +// */ +// List getUVdeviationData(@Param("param")ReportQueryParam param); +// +// /** +// * 电压正偏差 +// * @param param +// * @return +// */ +// List getLVdeviationData(@Param("param")ReportQueryParam param); +// +// /** +// * 获取电压畸变率 +// * @param param +// * @return +// */ +// List getDistortionDataV(@Param("param")ReportQueryParam param); +// +// /** +// * 获取电流畸变率 +// * @param param +// * @return +// */ +// List getDistortionDataI(@Param("param")ReportQueryParam param); +// +// /** +// *频率 +// * @param param +// * @return +// */ +// List getFrequencyData(@Param("param")ReportQueryParam param); +// +// /** +// *频率 +// * @param param +// * @return +// */ +// List getDEVFrequencyData(@Param("param")ReportQueryParam param); +// +// /** +// * 负序电流 +// * @param param +// * @return +// */ +// List getINegData(@Param("param")ReportQueryParam param); +//} diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/CustomReportService.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/CustomReportService.java index 7895c67..1b9100e 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/CustomReportService.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/CustomReportService.java @@ -1,12 +1,12 @@ package com.njcn.csharmonic.service; 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.po.ExcelRptTemp; -import com.njcn.csharmonic.pojo.vo.ReportTemplateVO; import com.njcn.csharmonic.pojo.vo.ReportTreeVO; 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 java.util.List; diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CustomReportServiceImpl.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CustomReportServiceImpl.java index eaac9b8..fea24fa 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CustomReportServiceImpl.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CustomReportServiceImpl.java @@ -15,6 +15,7 @@ import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.toolkit.SqlRunner; 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.utils.FileUtil; 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.WlRecord; import com.njcn.csharmonic.enums.CsHarmonicResponseEnum; -import com.njcn.csharmonic.mapper.ExcelRptTempMapper; import com.njcn.csharmonic.param.SensitiveUserReportQueryParam; 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.po.ExcelRptTemp; 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.SysDeptTempVO; import com.njcn.csharmonic.service.CustomReportService; import com.njcn.csharmonic.utils.DataChangeUtil; import com.njcn.device.biz.commApi.CommTerminalGeneralClient; 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.pojo.constant.InfluxDBTableConstant; import com.njcn.influx.utils.InfluxDbUtils; @@ -118,6 +119,9 @@ public class CustomReportServiceImpl implements CustomReportService { private final String STR_FIVE = "~"; 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 LOAD_SIDE_DICT_CODE = "Load_Side"; @@ -839,7 +843,7 @@ public class CustomReportServiceImpl implements CustomReportService { * @date 2023/10/20 */ - private void assSqlByMysql(List data, StringBuilder sql, List endList, String method, ReportSearchParam reportSearchParam, Map limitMap, Map overLimitMap, Map assNoPassMap) { + private void assSqlByMysql(List data, StringBuilder sql, List endList, String method, ReportSearchParam reportSearchParam, Map limitMap, Map overLimitMap, Map assNoPassMap,List noPhaseList) { //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)) { for (int i = 0; i < data.size(); i++) { @@ -849,14 +853,14 @@ public class CustomReportServiceImpl implements CustomReportService { .append(data.get(i).getTemplateName()) .append(InfluxDbSqlConstant.RBK) .append(InfluxDbSqlConstant.AS) - .append("\"" + data.get(i).getItemName() + "\""); + .append("\""+data.get(i).getItemName()+"\""); } else { sql.append(InfluxDbSqlConstant.MAX) .append(InfluxDbSqlConstant.LBK) .append(data.get(i).getTemplateName()) .append(InfluxDbSqlConstant.RBK) .append(InfluxDbSqlConstant.AS) - .append("\"" + data.get(i).getItemName() + "\"").append(StrUtil.COMMA); + .append("\""+data.get(i).getItemName()+"\"").append(StrUtil.COMMA); } } } else { @@ -867,14 +871,14 @@ public class CustomReportServiceImpl implements CustomReportService { .append(data.get(i).getTemplateName()) .append(InfluxDbSqlConstant.RBK) .append(InfluxDbSqlConstant.AS) - .append("\"" + data.get(i).getItemName() + "\""); + .append("\""+data.get(i).getItemName()+"\""); } else { sql.append(method) .append(InfluxDbSqlConstant.LBK) .append(data.get(i).getTemplateName()) .append(InfluxDbSqlConstant.RBK) .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相 - 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) .append(InfluxDBTableConstant.PHASIC_TYPE) .append(InfluxDbSqlConstant.EQ) @@ -931,6 +938,7 @@ public class CustomReportServiceImpl implements CustomReportService { if (CollUtil.isEmpty(mapList) || Objects.isNull(mapList.get(0))) { data = data.stream().peek(item -> item.setValue("/")).collect(Collectors.toList()); } else { + //兼容达梦数据库方法 Map map = convertKeysToUpperCase(mapList.get(0)); for (ReportTemplateDTO item : data) { if (map.containsKey(item.getItemName())) { @@ -938,10 +946,22 @@ public class CustomReportServiceImpl implements CustomReportService { item.setValue(String.format("%.3f", v)); if (overLimitMap.containsKey(item.getLimitName())) { Float tagVal = overLimitMap.get(item.getLimitName()); - if (v > tagVal) { - item.setOverLimitFlag(1); - } else { - item.setOverLimitFlag(0); + + if(item.getLimitName().equalsIgnoreCase(UVOLTAGE_DEV)){ + //对电压偏差特殊处理 + Float tagVal_U = overLimitMap.get(UVOLTAGE_DEV); + if (v > tagVal || v tagVal) { + item.setOverLimitFlag(1); + } else { + item.setOverLimitFlag(0); + } } } @@ -951,12 +971,27 @@ public class CustomReportServiceImpl implements CustomReportService { if (limitMap.containsKey(key)) { ReportTemplateDTO tem = limitMap.get(key); double limitVal = Double.parseDouble(tem.getValue()); - if (v > limitVal) { - tem.setOverLimitFlag(1); - assNoPassMap.put(key, tem); - } else if (!assNoPassMap.containsKey(key)) { - tem.setOverLimitFlag(0); - assNoPassMap.put(key, tem); + + if(VOLTAGE_DEV.equalsIgnoreCase(tem.getLimitName())){ + //针对电压偏差特殊处理 + double limitLowVal = Double.parseDouble(tem.getLowValue()); + + if (v > limitVal || 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); } - private void assSqlByMysqlNew(List data, StringBuilder sql, List 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') if (InfluxDbSqlConstant.CP95.equals(method)) { @@ -1113,9 +1147,23 @@ public class CustomReportServiceImpl implements CustomReportService { 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 temTargetList = eleEpdMapper.selectList(new LambdaQueryWrapper().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 eleEpdPqdList= epdFeignClient.dictMarkByDataType(epdDic.getId()).getData(); + eleEpdPqdList = eleEpdPqdList.stream().filter(it->"T".equals(it.getPhase())||"M".equals(it.getPhase())).collect(Collectors.toList()); + List 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()); - Map limitMap = overLimitDeal(reportLimitList, reportSearchParam.getLineId()); + Map limitMap = overLimitDeal(reportLimitList, reportSearchParam); //存放限值指标的map Map limitTargetMapX = reportLimitList.stream().collect(Collectors.toMap(ReportTemplateDTO::getItemName, Function.identity())); @@ -1141,13 +1189,13 @@ public class CustomReportServiceImpl implements CustomReportService { phaseMap.forEach((phaseKey, phaseVal) -> { StringBuilder sql = new StringBuilder(InfluxDbSqlConstant.SELECT); 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)) { - 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)) { - 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)) { - 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) { //$HA[_25]#max#classId$ reportTemplateDTO.setTemplateName(vItem[0].toUpperCase()); - reportTemplateDTO.setPhase("M"); + reportTemplateDTO.setPhase("T"); reportTemplateDTO.setStatMethod(vItem[1].toUpperCase()); reportTemplateDTO.setResourceId(vItem[2].toUpperCase()); reportTemplateDTO.setLimitName(vItem[3].toUpperCase()); @@ -1373,7 +1421,7 @@ public class CustomReportServiceImpl implements CustomReportService { } else if (vItem.length == 4) { //$HA[_25]#max#classId#no$ indexDataVO.setTemplateName(vItem[0].toUpperCase()); - indexDataVO.setPhase("M"); + indexDataVO.setPhase("T"); indexDataVO.setStatMethod(vItem[1].toUpperCase()); indexDataVO.setResourceId(vItem[2].toUpperCase()); } @@ -1417,7 +1465,7 @@ public class CustomReportServiceImpl implements CustomReportService { } else if (vItem.length == 4) { //$HA[_25]#max#classId#no$ indexDataVO.setTemplateName(vItem[0].toUpperCase()); - indexDataVO.setPhase("M"); + indexDataVO.setPhase("T"); indexDataVO.setStatMethod(vItem[1].toUpperCase()); indexDataVO.setResourceId(vItem[2].toUpperCase()); } @@ -1440,18 +1488,21 @@ public class CustomReportServiceImpl implements CustomReportService { * @author cdf * @date 2023/10/23 */ - private Map overLimitDeal(List reportLimitList, String lineId) { + private Map overLimitDeal(List reportLimitList, ReportSearchParam + reportSearchParam) { Map limitMap = new HashMap<>(); if (CollUtil.isNotEmpty(reportLimitList)) { StringBuilder sql = new StringBuilder(InfluxDbSqlConstant.SELECT); for (int i = 0; i < reportLimitList.size(); i++) { if (i == reportLimitList.size() - 1) { + sql.append(UVOLTAGE_DEV).append(StrUtil.COMMA); sql.append(reportLimitList.get(i).getTemplateName()).append(StrUtil.C_SPACE); } else { 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()); if (Objects.isNull(limitMap)) { throw new BusinessException("当前报表测点限值缺失!"); @@ -1459,6 +1510,10 @@ public class CustomReportServiceImpl implements CustomReportService { for (ReportTemplateDTO item : reportLimitList) { 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()); } } @@ -1515,7 +1570,7 @@ public class CustomReportServiceImpl implements CustomReportService { .sorted(Comparator.comparing(ReportTemplateDTO::getItemName)) .collect(Collectors.toList()); - Map limitMap = overLimitDeal(reportLimitList, reportSearchParam.getLineId()); + Map limitMap = overLimitDeal(reportLimitList, reportSearchParam); //存放限值指标的map Map limitTargetMapX = reportLimitList.stream().collect(Collectors.toMap(ReportTemplateDTO::getItemName, Function.identity())); @@ -1903,13 +1958,18 @@ public class CustomReportServiceImpl implements CustomReportService { (Map assNoPassMap, Map limitTargetMapX, List endList) { assNoPassMap.forEach((key, val) -> { 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()); } + + String expend = ""; + if(Objects.nonNull(val.getLowValue())){ + expend = val.getLowValue()+","; + } if (val.getOverLimitFlag() == 1) { - val.setValue("不合格 (" + val.getValue() + ")"); + val.setValue("不合格 (" + expend+val.getValue() + ")"); } else { - val.setValue("合格 (" + val.getValue() + ")"); + val.setValue("合格 (" + expend+val.getValue() + ")"); } 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) { //$HA[_25]#max#classId$ reportTemplateDTO.setTemplateName(vItem[0]); - reportTemplateDTO.setPhase("M"); + reportTemplateDTO.setPhase("T"); reportTemplateDTO.setStatMethod(vItem[1]); reportTemplateDTO.setResourceId(vItem[2]); reportTemplateDTO.setLimitName(vItem[3]); diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/RStatLimitRateDetailDServiceImpl.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/RStatLimitRateDetailDServiceImpl.java index d8bc2c4..c47d794 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/RStatLimitRateDetailDServiceImpl.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/RStatLimitRateDetailDServiceImpl.java @@ -14,7 +14,6 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.njcn.csdevice.api.CsLineFeignClient; import com.njcn.csdevice.api.CsOverLimitClient; import com.njcn.csdevice.pojo.po.CsLinePO; -import com.njcn.csdevice.pojo.po.Overlimit; import com.njcn.csharmonic.mapper.RStatLimitRateDetailDMapper; import com.njcn.csharmonic.pojo.param.LimitCalendarQueryParam; 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.LimitTimeProbabilityVO; import com.njcn.csharmonic.service.IRStatLimitRateDetailDService; +import com.njcn.device.biz.pojo.po.Overlimit; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/ReportServiceImpl.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/ReportServiceImpl.java index 32dcd83..ad8397c 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/ReportServiceImpl.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/ReportServiceImpl.java @@ -1,676 +1,676 @@ -package com.njcn.csharmonic.service.impl; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.StrUtil; -import com.baomidou.dynamic.datasource.annotation.DS; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.njcn.csharmonic.mapper.report.*; -import com.njcn.csharmonic.pojo.dto.report.OverLimitInfo; -import com.njcn.csharmonic.pojo.param.report.ReportQueryParam; -import com.njcn.csharmonic.pojo.po.day.RStatDataHarmrateVDPO; -import com.njcn.csharmonic.pojo.po.day.RStatDataIDPO; -import com.njcn.csharmonic.pojo.po.day.RStatDataInharmVDPO; -import com.njcn.csharmonic.pojo.po.day.RStatDataVDPO; -import com.njcn.csharmonic.pojo.vo.report.ReportValue; -import com.njcn.csharmonic.service.ReportService; -import com.njcn.csharmonic.util.RegroupData; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; - -import java.lang.reflect.Field; -import java.math.BigDecimal; -import java.util.*; -import java.util.stream.Collectors; - -/** - * @author wr - */ -@Service -@RequiredArgsConstructor -@DS("sjzx") -public class ReportServiceImpl implements ReportService { - - private final ReportMapper reportMapper; - private final RStatDataVDPOMapper rStatDataVDMapper; - private final RStatDataHarmRateVDMapper rStatDataHarmRateVDMapper; - private final RStatDataIDMapper rStatDataIDMapper; - private final RStatDataInharmVDMapper rStatDataInharmVDMapper; - - @Override - public OverLimitInfo getOverLimitData(ReportQueryParam param) { - - - OverLimitInfo overLimitInfo = new OverLimitInfo(); - - //查询时间段内共有多少条记录,并*0.95取整处理,用来计算CP95值 降序*0.05进一位计算 - double count = 0; - double pstCount = 0; - double pltCount = 0; - if (param.getB()) { - count = Math.ceil(1); - pltCount = Math.ceil(1); - pstCount = Math.ceil(1); - } else { - count = Math.ceil(reportMapper.getTotalCP95Day(param).intValue() * 0.05); - pltCount = Math.ceil(reportMapper.getTotalPltCP95Day(param).intValue() * 0.05); - pstCount = Math.ceil(reportMapper.getTotalPstCP95Day(param).intValue() * 0.05); - } - overLimitInfo.setCount(count); - overLimitInfo.setPltCount(pltCount); - overLimitInfo.setPstCount(pstCount); - return overLimitInfo; - } - - @Override - public List getVirtualData(ReportQueryParam param) { - List list = new ArrayList<>(); - - // 获取电流有效值 - List listI = reportMapper.getVirtualDataI(param); - //获取电压有效值 - List listV = reportMapper.getVirtualDataV(param); - //获取线电压有效值 - List listVV = reportMapper.getVVirtualData(param); - - RegroupData.regroupData(listV, true); - RegroupData.regroupData(listI, true); - RegroupData.regroupData(listVV, true); - list.addAll(listV); - list.addAll(listI); - list.addAll(listVV); - - return list; - } - - @Override - public List getPowerData(ReportQueryParam param) { - List list = new ArrayList<>(); - //获取有功功率 - List listP = reportMapper.getPowerP(param); - //获取无功功率 - List listQ = reportMapper.getPowerQ(param); - //获取视在功率 - List listS = reportMapper.getPowerS(param); - //获取功率因数 - List listF = reportMapper.getPF(param); - - RegroupData.regroupData(listP, true, false); - RegroupData.regroupData(listQ, true, false); - RegroupData.regroupData(listS, true, false); - RegroupData.regroupData(listF, true, false); - list.addAll(listP); - list.addAll(listQ); - list.addAll(listS); - list.addAll(listF); - return list; - } - - @Override - public List getFlickerData(ReportQueryParam param) { - List list = new ArrayList<>(); - - //短时闪变 - List listFlicker = reportMapper.getFlickerData(param); - //长时闪变 - List listLFlicker = reportMapper.getLFlickerData(param); - - RegroupData.regroupData(listFlicker, true); - RegroupData.regroupData(listLFlicker, true); - list.addAll(listFlicker); - list.addAll(listLFlicker); - - return list; - } - - @Override - public List getVdeviation(ReportQueryParam param) { - List list = new ArrayList<>(); - - //获取电压偏差 - List listU = reportMapper.getUVdeviationData(param); - List listL = reportMapper.getLVdeviationData(param); - - RegroupData.regroupData(listU, true); - RegroupData.regroupData(listL, true); - list.addAll(listU); - list.addAll(listL); - return list; - } - - @Override - public List getDistortionData(ReportQueryParam param) { - List list = new ArrayList<>(); - //获取电压畸变率 - List listU = reportMapper.getDistortionDataV(param); - //获取电流畸变率 - List listI = reportMapper.getDistortionDataI(param); - - //添加之前判断数据库是否有数据,如果没有数据模拟数据添加到集合中 - RegroupData.regroupData(listU, true); - RegroupData.regroupData(listI, true); - list.addAll(listU); - list.addAll(listI); - - return list; - } - - @Override - public List getFrequencyData(ReportQueryParam param) { - List list = new ArrayList<>(); - - List listFre = reportMapper.getFrequencyData(param); - List listFreDEV = reportMapper.getDEVFrequencyData(param); - - - RegroupData.regroupData(listFre, true); - RegroupData.regroupData(listFreDEV, true); - list.addAll(listFre); - list.addAll(listFreDEV); - return list; - } - - @Override - public List getThreephase(ReportQueryParam param) { - List list = new ArrayList<>(); - //电压三相不平衡度 - List listV = dataV(param, Arrays.asList("T"), 1, 5, true, 0); - //电流三相不平衡度 - List listI = dataI(param, Arrays.asList("T"), 1, 5, true, 0); - - if (CollUtil.isNotEmpty(listV)) { - list.addAll(listV); - } else { - regroupData(list); - } - - if (CollUtil.isNotEmpty(listI)) { - list.addAll(listI); - } else { - regroupData(list); - } - return list; - } - - @Override - public List getICurrent(ReportQueryParam param) { - List list = new ArrayList<>(); - - //获取电流幅值,包含基波 - List listI = dataI(param, Arrays.asList("A", "B", "C"), 1, 51, false, 0); - if (CollUtil.isEmpty(listI)) { - for (int i = 0; i < 50; i++) { - RegroupData.regroupData(list, true, true); - } - } else { - list.addAll(listI); - } - return list; - } - - @Override - public List getVoltageRate(ReportQueryParam param) { - List list = new ArrayList<>(); - - //获取基波电压幅值,单位kV - List listV = dataV(param, Arrays.asList("A", "B", "C"), 0, 1, true, 5); - - if (CollUtil.isEmpty(listV)) { - RegroupData.regroupData(list, true, true); - } else { - list.addAll(listV); - } - - //获取电压含有率,不包含基波 -// List listRate = dataV(param, Arrays.asList("A", "B", "C"), 2, 51, false, 1); - List listRate = dataHarmRateV(param, Arrays.asList("A", "B", "C"), 2, 51, false, 1); - - if (CollUtil.isEmpty(listRate)) { - for (int i = 0; i < 49; i++) { - RegroupData.regroupData(list, true, true); - } - } else { - list.addAll(listRate); - } - - //获取电压畸变率 - List listU = reportMapper.getDistortionDataV(param); - RegroupData.regroupData(listU, true); - list.addAll(listU); - return list; - } - - @Override - public List getInharmVeRate(ReportQueryParam param) { - List inharm = rStatDataInharmVDMapper.selectList(new LambdaQueryWrapper() - .eq(RStatDataInharmVDPO::getLineId, param.getLineId()) - .in(RStatDataInharmVDPO::getPhaseType, Arrays.asList("A", "B", "C")) - .ge(StrUtil.isNotBlank(param.getStartTime()), RStatDataInharmVDPO::getTime, DateUtil.beginOfDay(DateUtil.parse(param.getStartTime()))) - .le(StrUtil.isNotBlank(param.getEndTime()), RStatDataInharmVDPO::getTime, DateUtil.endOfDay(DateUtil.parse(param.getEndTime()))) - ); - String max = "MAX"; - String avg = "AVG"; - String min = "MIN"; - String cp95 = "CP95"; - List a = new ArrayList<>(); - Map> collect = inharm.stream().collect(Collectors.groupingBy(RStatDataInharmVDPO::getPhaseType)); - collect.forEach((key, value) -> { - Map> valueTypeMap = value.stream().collect(Collectors.groupingBy(RStatDataInharmVDPO::getValueType)); - - for (int i = 1; i < 17; i++) { - ReportValue reportValue = new ReportValue(); - String attribute = "v" + i; - - if (valueTypeMap.containsKey(max)) { - List aa = reflectDataInV(valueTypeMap.get(max), max, attribute); - reportValue.setPhaseType(key); - Float maxNum = aa.stream().distinct().max(Float::compareTo).get(); - reportValue.setFmaxValue(maxNum); - } - if (valueTypeMap.containsKey(avg)) { - List aa = reflectDataInV(valueTypeMap.get(avg), avg, attribute); - reportValue.setPhaseType(key); - Double avgNum = aa.stream().distinct().collect(Collectors.averagingDouble(Float::doubleValue)); - reportValue.setMeanValue(avgNum.floatValue()); - } - if (valueTypeMap.containsKey(min)) { - List aa = reflectDataInV(valueTypeMap.get(min), min, attribute); - reportValue.setPhaseType(key); - double minNum = aa.stream().distinct().min(Float::compareTo).get(); - reportValue.setMinValue((float) minNum); - } - if (valueTypeMap.containsKey(cp95)) { - List aa = reflectDataInV(valueTypeMap.get(cp95), cp95, attribute); - reportValue.setPhaseType(key); - List cp95Num = aa.stream().distinct().sorted(Comparator.comparing(Float::doubleValue).reversed()).collect(Collectors.toList()); - reportValue.setCp95Value(cp95Num.get(0).floatValue()); - } - a.add(reportValue); - } - }); - if (CollUtil.isEmpty(a)) { - for (int i = 1; i < 17; i++) { - RegroupData.regroupData(a, true, true); - } - } - return a; - } - - @Override - public List getINegDataRate(ReportQueryParam param) { - List list = new ArrayList<>(); - //负序电流 - List iNegData = reportMapper.getINegData(param); - RegroupData.regroupData(iNegData, true); - list.addAll(iNegData); - return list; - } - - //赋值默认值 - private void regroupData(List list) { - for (int i = 0; i < 4; i++) { - List list1 = new ArrayList<>(); - RegroupData.regroupData(list1, false); - list.addAll(list1); - } - } - - /** - * 电压信息 - * - * @param param 查询条件 - * @param valueTypes 区分类别 例如"A","B","C" - * @param num 循环开始 - * @param size 循环结束 - * @param fly 否是启用获取属性电压 - * @param index 获取属性位置名称 - * @return - */ - private List dataV(ReportQueryParam param, List valueTypes, Integer num, Integer size, Boolean fly, Integer index) { - List rStatDataVDS = rStatDataVDMapper.selectList(new LambdaQueryWrapper() - .eq(RStatDataVDPO::getLineId, param.getLineId()) - .in(CollUtil.isNotEmpty(valueTypes), RStatDataVDPO::getPhaseType, valueTypes) - .ge(StrUtil.isNotBlank(param.getStartTime()), RStatDataVDPO::getTime, DateUtil.beginOfDay(DateUtil.parse(param.getStartTime()))) - .le(StrUtil.isNotBlank(param.getEndTime()), RStatDataVDPO::getTime, DateUtil.endOfDay(DateUtil.parse(param.getEndTime()))) - ); - String max = "MAX"; - String avg = "AVG"; - String min = "MIN"; - String cp95 = "CP95"; - List a = new ArrayList<>(); - Map> collect = rStatDataVDS.stream().collect(Collectors.groupingBy(RStatDataVDPO::getPhaseType)); - collect.forEach((key, value) -> { - Map> valueTypeMap = value.stream().collect(Collectors.groupingBy(RStatDataVDPO::getValueType)); - - for (int i = num; i < size; i++) { - ReportValue reportValue = new ReportValue(); - String attribute = ""; - if (fly) { - if (index == 0) { - attribute = attributeV(i); - } else { - attribute = attributeV(index); - } - } else { - attribute = "v" + i; - } - - if (valueTypeMap.containsKey(max)) { - List aa = reflectDataV(valueTypeMap.get(max), max, attribute); - reportValue.setPhaseType(key); - Float maxNum = aa.stream().distinct().max(Float::compareTo).get(); - reportValue.setFmaxValue(maxNum); - } - if (valueTypeMap.containsKey(avg)) { - List aa = reflectDataV(valueTypeMap.get(avg), avg, attribute); - reportValue.setPhaseType(key); - Double avgNum = aa.stream().distinct().collect(Collectors.averagingDouble(Float::doubleValue)); - reportValue.setMeanValue(avgNum.floatValue()); - } - if (valueTypeMap.containsKey(min)) { - List aa = reflectDataV(valueTypeMap.get(min), min, attribute); - reportValue.setPhaseType(key); - double minNum = aa.stream().distinct().min(Float::compareTo).get(); - reportValue.setMinValue((float) minNum); - } - if (valueTypeMap.containsKey(cp95)) { - List aa = reflectDataV(valueTypeMap.get(cp95), cp95, attribute); - reportValue.setPhaseType(key); - List cp95Num = aa.stream().distinct().sorted(Comparator.comparing(Float::doubleValue).reversed()).collect(Collectors.toList()); - reportValue.setCp95Value(cp95Num.get(0).floatValue()); - } - a.add(reportValue); - } - }); - return a; - } - - //获取电压含有率应该取dataHarmRateV,不是dataV - private List dataHarmRateV(ReportQueryParam param, List valueTypes, Integer num, Integer size, Boolean fly, Integer index) { - List rStatDataVDS = rStatDataHarmRateVDMapper.selectList(new LambdaQueryWrapper() - .eq(RStatDataHarmrateVDPO::getLineId, param.getLineId()) - .in(CollUtil.isNotEmpty(valueTypes), RStatDataHarmrateVDPO::getPhaseType, valueTypes) - .ge(StrUtil.isNotBlank(param.getStartTime()), RStatDataHarmrateVDPO::getTime, DateUtil.beginOfDay(DateUtil.parse(param.getStartTime()))) - .le(StrUtil.isNotBlank(param.getEndTime()), RStatDataHarmrateVDPO::getTime, DateUtil.endOfDay(DateUtil.parse(param.getEndTime()))) - ); - String max = "MAX"; - String avg = "AVG"; - String min = "MIN"; - String cp95 = "CP95"; - List a = new ArrayList<>(); - Map> collect = rStatDataVDS.stream().collect(Collectors.groupingBy(RStatDataHarmrateVDPO::getPhaseType)); - collect.forEach((key, value) -> { - Map> valueTypeMap = value.stream().collect(Collectors.groupingBy(RStatDataHarmrateVDPO::getValueType)); - - for (int i = num; i < size; i++) { - ReportValue reportValue = new ReportValue(); - String attribute = ""; - if (fly) { - if (index == 0) { - attribute = attributeV(i); - } else { - attribute = attributeV(index); - } - } else { - attribute = "v" + i; - } - - if (valueTypeMap.containsKey(max)) { - List aa = reflectDataHarmRateV(valueTypeMap.get(max), max, attribute); - reportValue.setPhaseType(key); - Float maxNum = aa.stream().distinct().max(Float::compareTo).get(); - reportValue.setFmaxValue(maxNum); - } - if (valueTypeMap.containsKey(avg)) { - List aa = reflectDataHarmRateV(valueTypeMap.get(avg), avg, attribute); - reportValue.setPhaseType(key); - Double avgNum = aa.stream().distinct().collect(Collectors.averagingDouble(Float::doubleValue)); - reportValue.setMeanValue(avgNum.floatValue()); - } - if (valueTypeMap.containsKey(min)) { - List aa = reflectDataHarmRateV(valueTypeMap.get(min), min, attribute); - reportValue.setPhaseType(key); - double minNum = aa.stream().distinct().min(Float::compareTo).get(); - reportValue.setMinValue((float) minNum); - } - if (valueTypeMap.containsKey(cp95)) { - List aa = reflectDataHarmRateV(valueTypeMap.get(cp95), cp95, attribute); - reportValue.setPhaseType(key); - List cp95Num = aa.stream().distinct().sorted(Comparator.comparing(Float::doubleValue).reversed()).collect(Collectors.toList()); - reportValue.setCp95Value(cp95Num.get(0).floatValue()); - } - a.add(reportValue); - } - }); - return a; - } - - /** - * 电压反射取属性值 - * - * @param value - * @param name - * @return - */ - private List reflectDataV(List value, String name, String attribute) { - Field field = null; - try { - field = RStatDataVDPO.class.getDeclaredField(attribute); - } catch (NoSuchFieldException e) { - throw new RuntimeException(e); - } - field.setAccessible(true); - - Field finalField = field; - return value.stream().filter(x -> x.getValueType().equals(name)).map(temp -> { - BigDecimal o = null; - try { - o = BigDecimal.valueOf((Double) finalField.get(temp)); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } - - return o.floatValue(); - }).collect(Collectors.toList()); - } - - private List reflectDataHarmRateV(List value, String name, String attribute) { - Field field = null; - try { - field = RStatDataHarmrateVDPO.class.getDeclaredField(attribute); - } catch (NoSuchFieldException e) { - throw new RuntimeException(e); - } - field.setAccessible(true); - - Field finalField = field; - return value.stream().filter(x -> x.getValueType().equals(name)).map(temp -> { - BigDecimal o = null; - try { - o = BigDecimal.valueOf((Double) finalField.get(temp)); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } - - return o.floatValue(); - }).collect(Collectors.toList()); - } - - /** - * 电压反射取属性值 - * - * @param value - * @param name - * @return - */ - private List reflectDataInV(List value, String name, String attribute) { - Field field; - try { - field = RStatDataInharmVDPO.class.getDeclaredField(attribute); - } catch (NoSuchFieldException e) { - throw new RuntimeException(e); - } - field.setAccessible(true); - - Field finalField = field; - return value.stream().filter(x -> x.getValueType().equals(name)).map(temp -> { - Double o; - try { - o = (Double) finalField.get(temp); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } - - return o.floatValue(); - }).collect(Collectors.toList()); - } - - /** - * 电流信息 - * - * @param param - * @return - */ - private List dataI(ReportQueryParam param, List valueTypes, Integer num, Integer size, Boolean fly, Integer index) { - List rStatDataVDS = rStatDataIDMapper.selectList(new LambdaQueryWrapper() - .eq(RStatDataIDPO::getLineId, param.getLineId()) - .in(CollUtil.isNotEmpty(valueTypes), RStatDataIDPO::getPhaseType, valueTypes) - .ge(StrUtil.isNotBlank(param.getStartTime()), RStatDataIDPO::getTime, DateUtil.beginOfDay(DateUtil.parse(param.getStartTime()))) - .le(StrUtil.isNotBlank(param.getEndTime()), RStatDataIDPO::getTime, DateUtil.endOfDay(DateUtil.parse(param.getEndTime()))) - ); - String max = "MAX"; - String avg = "AVG"; - String min = "MIN"; - String cp95 = "CP95"; - List a = new ArrayList<>(); - Map> collect = rStatDataVDS.stream().collect(Collectors.groupingBy(RStatDataIDPO::getPhaseType)); - collect.forEach((key, value) -> { - Map> valueTypeMap = value.stream().collect(Collectors.groupingBy(RStatDataIDPO::getValueType)); - - for (int i = num; i < size; i++) { - ReportValue reportValue = new ReportValue(); - String attribute = ""; - if (fly) { - if (index == 0) { - attribute = attributeI(i); - } else { - attribute = attributeI(index); - } - } else { - attribute = "i" + i; - } - if (valueTypeMap.containsKey(max)) { - List aa = reflectDataI(valueTypeMap.get(max), max, attribute); - reportValue.setPhaseType(key); - Float maxNum = aa.stream().distinct().max(Float::compareTo).get(); - reportValue.setFmaxValue(maxNum); - } - if (valueTypeMap.containsKey(avg)) { - List aa = reflectDataI(valueTypeMap.get(avg), avg, attribute); - reportValue.setPhaseType(key); - Double avgNum = aa.stream().distinct().collect(Collectors.averagingDouble(Float::doubleValue)); - reportValue.setMeanValue(avgNum.floatValue()); - } - if (valueTypeMap.containsKey(min)) { - List aa = reflectDataI(valueTypeMap.get(min), min, attribute); - reportValue.setPhaseType(key); - double minNum = aa.stream().distinct().min(Float::compareTo).get(); - reportValue.setMinValue((float) minNum); - } - if (valueTypeMap.containsKey(cp95)) { - List aa = reflectDataI(valueTypeMap.get(cp95), cp95, attribute); - reportValue.setPhaseType(key); - List cp95Num = aa.stream().distinct().sorted(Comparator.comparing(Float::doubleValue).reversed()).collect(Collectors.toList()); - reportValue.setCp95Value(cp95Num.get(0).floatValue()); - } - a.add(reportValue); - } - }); - return a; - } - - /** - * 电流反射取属性值 - * - * @param value - * @param name - * @return - */ - private List reflectDataI(List value, String name, String attribute) { - Field field = null; - try { - field = RStatDataIDPO.class.getDeclaredField(attribute); - } catch (NoSuchFieldException e) { - throw new RuntimeException(e); - } - field.setAccessible(true); - Field finalField = field; - return value.stream().filter(x -> x.getValueType().equals(name)).map(temp -> { - Double o = null; - try { - o = (Double) finalField.get(temp); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } - - return o.floatValue(); - }).collect(Collectors.toList()); - } - - /** - * 获取属性电压 - * - * @param i - * @return - */ - private String attributeV(Integer i) { - String str = null; - switch (i) { - case 1: - str = "vUnbalance"; - break; - case 2: - str = "vPos"; - break; - case 3: - str = "vNeg"; - break; - case 4: - str = "vZero"; - break; - case 5: - str = "v1"; - break; - default: - break; - } - return str; - } - - /** - * 获取属性电流 - * - * @param i - * @return - */ - private String attributeI(Integer i) { - String str = null; - switch (i) { - case 1: - str = "iUnbalance"; - break; - case 2: - str = "iPos"; - break; - case 3: - str = "iNeg"; - break; - case 4: - str = "iZero"; - break; - default: - break; - } - return str; - } -} +//package com.njcn.csharmonic.service.impl; +// +//import cn.hutool.core.collection.CollUtil; +//import cn.hutool.core.date.DateUtil; +//import cn.hutool.core.util.StrUtil; +//import com.baomidou.dynamic.datasource.annotation.DS; +//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +//import com.njcn.csharmonic.mapper.report.*; +//import com.njcn.csharmonic.pojo.dto.report.OverLimitInfo; +//import com.njcn.csharmonic.pojo.param.report.ReportQueryParam; +//import com.njcn.csharmonic.pojo.po.day.RStatDataHarmrateVDPO; +//import com.njcn.csharmonic.pojo.po.day.RStatDataIDPO; +//import com.njcn.csharmonic.pojo.po.day.RStatDataInharmVDPO; +//import com.njcn.csharmonic.pojo.po.day.RStatDataVDPO; +//import com.njcn.csharmonic.pojo.vo.report.ReportValue; +//import com.njcn.csharmonic.service.ReportService; +//import com.njcn.csharmonic.util.RegroupData; +//import lombok.RequiredArgsConstructor; +//import org.springframework.stereotype.Service; +// +//import java.lang.reflect.Field; +//import java.math.BigDecimal; +//import java.util.*; +//import java.util.stream.Collectors; +// +///** +// * @author wr +// */ +//@Service +//@RequiredArgsConstructor +//@DS("sjzx") +//public class ReportServiceImpl implements ReportService { +// +// private final ReportMapper reportMapper; +// private final RStatDataVDPOMapper rStatDataVDMapper; +// private final RStatDataHarmRateVDMapper rStatDataHarmRateVDMapper; +// private final RStatDataIDMapper rStatDataIDMapper; +// private final RStatDataInharmVDMapper rStatDataInharmVDMapper; +// +// @Override +// public OverLimitInfo getOverLimitData(ReportQueryParam param) { +// +// +// OverLimitInfo overLimitInfo = new OverLimitInfo(); +// +// //查询时间段内共有多少条记录,并*0.95取整处理,用来计算CP95值 降序*0.05进一位计算 +// double count = 0; +// double pstCount = 0; +// double pltCount = 0; +// if (param.getB()) { +// count = Math.ceil(1); +// pltCount = Math.ceil(1); +// pstCount = Math.ceil(1); +// } else { +// count = Math.ceil(reportMapper.getTotalCP95Day(param).intValue() * 0.05); +// pltCount = Math.ceil(reportMapper.getTotalPltCP95Day(param).intValue() * 0.05); +// pstCount = Math.ceil(reportMapper.getTotalPstCP95Day(param).intValue() * 0.05); +// } +// overLimitInfo.setCount(count); +// overLimitInfo.setPltCount(pltCount); +// overLimitInfo.setPstCount(pstCount); +// return overLimitInfo; +// } +// +// @Override +// public List getVirtualData(ReportQueryParam param) { +// List list = new ArrayList<>(); +// +// // 获取电流有效值 +// List listI = reportMapper.getVirtualDataI(param); +// //获取电压有效值 +// List listV = reportMapper.getVirtualDataV(param); +// //获取线电压有效值 +// List listVV = reportMapper.getVVirtualData(param); +// +// RegroupData.regroupData(listV, true); +// RegroupData.regroupData(listI, true); +// RegroupData.regroupData(listVV, true); +// list.addAll(listV); +// list.addAll(listI); +// list.addAll(listVV); +// +// return list; +// } +// +// @Override +// public List getPowerData(ReportQueryParam param) { +// List list = new ArrayList<>(); +// //获取有功功率 +// List listP = reportMapper.getPowerP(param); +// //获取无功功率 +// List listQ = reportMapper.getPowerQ(param); +// //获取视在功率 +// List listS = reportMapper.getPowerS(param); +// //获取功率因数 +// List listF = reportMapper.getPF(param); +// +// RegroupData.regroupData(listP, true, false); +// RegroupData.regroupData(listQ, true, false); +// RegroupData.regroupData(listS, true, false); +// RegroupData.regroupData(listF, true, false); +// list.addAll(listP); +// list.addAll(listQ); +// list.addAll(listS); +// list.addAll(listF); +// return list; +// } +// +// @Override +// public List getFlickerData(ReportQueryParam param) { +// List list = new ArrayList<>(); +// +// //短时闪变 +// List listFlicker = reportMapper.getFlickerData(param); +// //长时闪变 +// List listLFlicker = reportMapper.getLFlickerData(param); +// +// RegroupData.regroupData(listFlicker, true); +// RegroupData.regroupData(listLFlicker, true); +// list.addAll(listFlicker); +// list.addAll(listLFlicker); +// +// return list; +// } +// +// @Override +// public List getVdeviation(ReportQueryParam param) { +// List list = new ArrayList<>(); +// +// //获取电压偏差 +// List listU = reportMapper.getUVdeviationData(param); +// List listL = reportMapper.getLVdeviationData(param); +// +// RegroupData.regroupData(listU, true); +// RegroupData.regroupData(listL, true); +// list.addAll(listU); +// list.addAll(listL); +// return list; +// } +// +// @Override +// public List getDistortionData(ReportQueryParam param) { +// List list = new ArrayList<>(); +// //获取电压畸变率 +// List listU = reportMapper.getDistortionDataV(param); +// //获取电流畸变率 +// List listI = reportMapper.getDistortionDataI(param); +// +// //添加之前判断数据库是否有数据,如果没有数据模拟数据添加到集合中 +// RegroupData.regroupData(listU, true); +// RegroupData.regroupData(listI, true); +// list.addAll(listU); +// list.addAll(listI); +// +// return list; +// } +// +// @Override +// public List getFrequencyData(ReportQueryParam param) { +// List list = new ArrayList<>(); +// +// List listFre = reportMapper.getFrequencyData(param); +// List listFreDEV = reportMapper.getDEVFrequencyData(param); +// +// +// RegroupData.regroupData(listFre, true); +// RegroupData.regroupData(listFreDEV, true); +// list.addAll(listFre); +// list.addAll(listFreDEV); +// return list; +// } +// +// @Override +// public List getThreephase(ReportQueryParam param) { +// List list = new ArrayList<>(); +// //电压三相不平衡度 +// List listV = dataV(param, Arrays.asList("T"), 1, 5, true, 0); +// //电流三相不平衡度 +// List listI = dataI(param, Arrays.asList("T"), 1, 5, true, 0); +// +// if (CollUtil.isNotEmpty(listV)) { +// list.addAll(listV); +// } else { +// regroupData(list); +// } +// +// if (CollUtil.isNotEmpty(listI)) { +// list.addAll(listI); +// } else { +// regroupData(list); +// } +// return list; +// } +// +// @Override +// public List getICurrent(ReportQueryParam param) { +// List list = new ArrayList<>(); +// +// //获取电流幅值,包含基波 +// List listI = dataI(param, Arrays.asList("A", "B", "C"), 1, 51, false, 0); +// if (CollUtil.isEmpty(listI)) { +// for (int i = 0; i < 50; i++) { +// RegroupData.regroupData(list, true, true); +// } +// } else { +// list.addAll(listI); +// } +// return list; +// } +// +// @Override +// public List getVoltageRate(ReportQueryParam param) { +// List list = new ArrayList<>(); +// +// //获取基波电压幅值,单位kV +// List listV = dataV(param, Arrays.asList("A", "B", "C"), 0, 1, true, 5); +// +// if (CollUtil.isEmpty(listV)) { +// RegroupData.regroupData(list, true, true); +// } else { +// list.addAll(listV); +// } +// +// //获取电压含有率,不包含基波 +//// List listRate = dataV(param, Arrays.asList("A", "B", "C"), 2, 51, false, 1); +// List listRate = dataHarmRateV(param, Arrays.asList("A", "B", "C"), 2, 51, false, 1); +// +// if (CollUtil.isEmpty(listRate)) { +// for (int i = 0; i < 49; i++) { +// RegroupData.regroupData(list, true, true); +// } +// } else { +// list.addAll(listRate); +// } +// +// //获取电压畸变率 +// List listU = reportMapper.getDistortionDataV(param); +// RegroupData.regroupData(listU, true); +// list.addAll(listU); +// return list; +// } +// +// @Override +// public List getInharmVeRate(ReportQueryParam param) { +// List inharm = rStatDataInharmVDMapper.selectList(new LambdaQueryWrapper() +// .eq(RStatDataInharmVDPO::getLineId, param.getLineId()) +// .in(RStatDataInharmVDPO::getPhaseType, Arrays.asList("A", "B", "C")) +// .ge(StrUtil.isNotBlank(param.getStartTime()), RStatDataInharmVDPO::getTime, DateUtil.beginOfDay(DateUtil.parse(param.getStartTime()))) +// .le(StrUtil.isNotBlank(param.getEndTime()), RStatDataInharmVDPO::getTime, DateUtil.endOfDay(DateUtil.parse(param.getEndTime()))) +// ); +// String max = "MAX"; +// String avg = "AVG"; +// String min = "MIN"; +// String cp95 = "CP95"; +// List a = new ArrayList<>(); +// Map> collect = inharm.stream().collect(Collectors.groupingBy(RStatDataInharmVDPO::getPhaseType)); +// collect.forEach((key, value) -> { +// Map> valueTypeMap = value.stream().collect(Collectors.groupingBy(RStatDataInharmVDPO::getValueType)); +// +// for (int i = 1; i < 17; i++) { +// ReportValue reportValue = new ReportValue(); +// String attribute = "v" + i; +// +// if (valueTypeMap.containsKey(max)) { +// List aa = reflectDataInV(valueTypeMap.get(max), max, attribute); +// reportValue.setPhaseType(key); +// Float maxNum = aa.stream().distinct().max(Float::compareTo).get(); +// reportValue.setFmaxValue(maxNum); +// } +// if (valueTypeMap.containsKey(avg)) { +// List aa = reflectDataInV(valueTypeMap.get(avg), avg, attribute); +// reportValue.setPhaseType(key); +// Double avgNum = aa.stream().distinct().collect(Collectors.averagingDouble(Float::doubleValue)); +// reportValue.setMeanValue(avgNum.floatValue()); +// } +// if (valueTypeMap.containsKey(min)) { +// List aa = reflectDataInV(valueTypeMap.get(min), min, attribute); +// reportValue.setPhaseType(key); +// double minNum = aa.stream().distinct().min(Float::compareTo).get(); +// reportValue.setMinValue((float) minNum); +// } +// if (valueTypeMap.containsKey(cp95)) { +// List aa = reflectDataInV(valueTypeMap.get(cp95), cp95, attribute); +// reportValue.setPhaseType(key); +// List cp95Num = aa.stream().distinct().sorted(Comparator.comparing(Float::doubleValue).reversed()).collect(Collectors.toList()); +// reportValue.setCp95Value(cp95Num.get(0).floatValue()); +// } +// a.add(reportValue); +// } +// }); +// if (CollUtil.isEmpty(a)) { +// for (int i = 1; i < 17; i++) { +// RegroupData.regroupData(a, true, true); +// } +// } +// return a; +// } +// +// @Override +// public List getINegDataRate(ReportQueryParam param) { +// List list = new ArrayList<>(); +// //负序电流 +// List iNegData = reportMapper.getINegData(param); +// RegroupData.regroupData(iNegData, true); +// list.addAll(iNegData); +// return list; +// } +// +// //赋值默认值 +// private void regroupData(List list) { +// for (int i = 0; i < 4; i++) { +// List list1 = new ArrayList<>(); +// RegroupData.regroupData(list1, false); +// list.addAll(list1); +// } +// } +// +// /** +// * 电压信息 +// * +// * @param param 查询条件 +// * @param valueTypes 区分类别 例如"A","B","C" +// * @param num 循环开始 +// * @param size 循环结束 +// * @param fly 否是启用获取属性电压 +// * @param index 获取属性位置名称 +// * @return +// */ +// private List dataV(ReportQueryParam param, List valueTypes, Integer num, Integer size, Boolean fly, Integer index) { +// List rStatDataVDS = rStatDataVDMapper.selectList(new LambdaQueryWrapper() +// .eq(RStatDataVDPO::getLineId, param.getLineId()) +// .in(CollUtil.isNotEmpty(valueTypes), RStatDataVDPO::getPhaseType, valueTypes) +// .ge(StrUtil.isNotBlank(param.getStartTime()), RStatDataVDPO::getTime, DateUtil.beginOfDay(DateUtil.parse(param.getStartTime()))) +// .le(StrUtil.isNotBlank(param.getEndTime()), RStatDataVDPO::getTime, DateUtil.endOfDay(DateUtil.parse(param.getEndTime()))) +// ); +// String max = "MAX"; +// String avg = "AVG"; +// String min = "MIN"; +// String cp95 = "CP95"; +// List a = new ArrayList<>(); +// Map> collect = rStatDataVDS.stream().collect(Collectors.groupingBy(RStatDataVDPO::getPhaseType)); +// collect.forEach((key, value) -> { +// Map> valueTypeMap = value.stream().collect(Collectors.groupingBy(RStatDataVDPO::getValueType)); +// +// for (int i = num; i < size; i++) { +// ReportValue reportValue = new ReportValue(); +// String attribute = ""; +// if (fly) { +// if (index == 0) { +// attribute = attributeV(i); +// } else { +// attribute = attributeV(index); +// } +// } else { +// attribute = "v" + i; +// } +// +// if (valueTypeMap.containsKey(max)) { +// List aa = reflectDataV(valueTypeMap.get(max), max, attribute); +// reportValue.setPhaseType(key); +// Float maxNum = aa.stream().distinct().max(Float::compareTo).get(); +// reportValue.setFmaxValue(maxNum); +// } +// if (valueTypeMap.containsKey(avg)) { +// List aa = reflectDataV(valueTypeMap.get(avg), avg, attribute); +// reportValue.setPhaseType(key); +// Double avgNum = aa.stream().distinct().collect(Collectors.averagingDouble(Float::doubleValue)); +// reportValue.setMeanValue(avgNum.floatValue()); +// } +// if (valueTypeMap.containsKey(min)) { +// List aa = reflectDataV(valueTypeMap.get(min), min, attribute); +// reportValue.setPhaseType(key); +// double minNum = aa.stream().distinct().min(Float::compareTo).get(); +// reportValue.setMinValue((float) minNum); +// } +// if (valueTypeMap.containsKey(cp95)) { +// List aa = reflectDataV(valueTypeMap.get(cp95), cp95, attribute); +// reportValue.setPhaseType(key); +// List cp95Num = aa.stream().distinct().sorted(Comparator.comparing(Float::doubleValue).reversed()).collect(Collectors.toList()); +// reportValue.setCp95Value(cp95Num.get(0).floatValue()); +// } +// a.add(reportValue); +// } +// }); +// return a; +// } +// +// //获取电压含有率应该取dataHarmRateV,不是dataV +// private List dataHarmRateV(ReportQueryParam param, List valueTypes, Integer num, Integer size, Boolean fly, Integer index) { +// List rStatDataVDS = rStatDataHarmRateVDMapper.selectList(new LambdaQueryWrapper() +// .eq(RStatDataHarmrateVDPO::getLineId, param.getLineId()) +// .in(CollUtil.isNotEmpty(valueTypes), RStatDataHarmrateVDPO::getPhaseType, valueTypes) +// .ge(StrUtil.isNotBlank(param.getStartTime()), RStatDataHarmrateVDPO::getTime, DateUtil.beginOfDay(DateUtil.parse(param.getStartTime()))) +// .le(StrUtil.isNotBlank(param.getEndTime()), RStatDataHarmrateVDPO::getTime, DateUtil.endOfDay(DateUtil.parse(param.getEndTime()))) +// ); +// String max = "MAX"; +// String avg = "AVG"; +// String min = "MIN"; +// String cp95 = "CP95"; +// List a = new ArrayList<>(); +// Map> collect = rStatDataVDS.stream().collect(Collectors.groupingBy(RStatDataHarmrateVDPO::getPhaseType)); +// collect.forEach((key, value) -> { +// Map> valueTypeMap = value.stream().collect(Collectors.groupingBy(RStatDataHarmrateVDPO::getValueType)); +// +// for (int i = num; i < size; i++) { +// ReportValue reportValue = new ReportValue(); +// String attribute = ""; +// if (fly) { +// if (index == 0) { +// attribute = attributeV(i); +// } else { +// attribute = attributeV(index); +// } +// } else { +// attribute = "v" + i; +// } +// +// if (valueTypeMap.containsKey(max)) { +// List aa = reflectDataHarmRateV(valueTypeMap.get(max), max, attribute); +// reportValue.setPhaseType(key); +// Float maxNum = aa.stream().distinct().max(Float::compareTo).get(); +// reportValue.setFmaxValue(maxNum); +// } +// if (valueTypeMap.containsKey(avg)) { +// List aa = reflectDataHarmRateV(valueTypeMap.get(avg), avg, attribute); +// reportValue.setPhaseType(key); +// Double avgNum = aa.stream().distinct().collect(Collectors.averagingDouble(Float::doubleValue)); +// reportValue.setMeanValue(avgNum.floatValue()); +// } +// if (valueTypeMap.containsKey(min)) { +// List aa = reflectDataHarmRateV(valueTypeMap.get(min), min, attribute); +// reportValue.setPhaseType(key); +// double minNum = aa.stream().distinct().min(Float::compareTo).get(); +// reportValue.setMinValue((float) minNum); +// } +// if (valueTypeMap.containsKey(cp95)) { +// List aa = reflectDataHarmRateV(valueTypeMap.get(cp95), cp95, attribute); +// reportValue.setPhaseType(key); +// List cp95Num = aa.stream().distinct().sorted(Comparator.comparing(Float::doubleValue).reversed()).collect(Collectors.toList()); +// reportValue.setCp95Value(cp95Num.get(0).floatValue()); +// } +// a.add(reportValue); +// } +// }); +// return a; +// } +// +// /** +// * 电压反射取属性值 +// * +// * @param value +// * @param name +// * @return +// */ +// private List reflectDataV(List value, String name, String attribute) { +// Field field = null; +// try { +// field = RStatDataVDPO.class.getDeclaredField(attribute); +// } catch (NoSuchFieldException e) { +// throw new RuntimeException(e); +// } +// field.setAccessible(true); +// +// Field finalField = field; +// return value.stream().filter(x -> x.getValueType().equals(name)).map(temp -> { +// BigDecimal o = null; +// try { +// o = BigDecimal.valueOf((Double) finalField.get(temp)); +// } catch (IllegalAccessException e) { +// throw new RuntimeException(e); +// } +// +// return o.floatValue(); +// }).collect(Collectors.toList()); +// } +// +// private List reflectDataHarmRateV(List value, String name, String attribute) { +// Field field = null; +// try { +// field = RStatDataHarmrateVDPO.class.getDeclaredField(attribute); +// } catch (NoSuchFieldException e) { +// throw new RuntimeException(e); +// } +// field.setAccessible(true); +// +// Field finalField = field; +// return value.stream().filter(x -> x.getValueType().equals(name)).map(temp -> { +// BigDecimal o = null; +// try { +// o = BigDecimal.valueOf((Double) finalField.get(temp)); +// } catch (IllegalAccessException e) { +// throw new RuntimeException(e); +// } +// +// return o.floatValue(); +// }).collect(Collectors.toList()); +// } +// +// /** +// * 电压反射取属性值 +// * +// * @param value +// * @param name +// * @return +// */ +// private List reflectDataInV(List value, String name, String attribute) { +// Field field; +// try { +// field = RStatDataInharmVDPO.class.getDeclaredField(attribute); +// } catch (NoSuchFieldException e) { +// throw new RuntimeException(e); +// } +// field.setAccessible(true); +// +// Field finalField = field; +// return value.stream().filter(x -> x.getValueType().equals(name)).map(temp -> { +// Double o; +// try { +// o = (Double) finalField.get(temp); +// } catch (IllegalAccessException e) { +// throw new RuntimeException(e); +// } +// +// return o.floatValue(); +// }).collect(Collectors.toList()); +// } +// +// /** +// * 电流信息 +// * +// * @param param +// * @return +// */ +// private List dataI(ReportQueryParam param, List valueTypes, Integer num, Integer size, Boolean fly, Integer index) { +// List rStatDataVDS = rStatDataIDMapper.selectList(new LambdaQueryWrapper() +// .eq(RStatDataIDPO::getLineId, param.getLineId()) +// .in(CollUtil.isNotEmpty(valueTypes), RStatDataIDPO::getPhaseType, valueTypes) +// .ge(StrUtil.isNotBlank(param.getStartTime()), RStatDataIDPO::getTime, DateUtil.beginOfDay(DateUtil.parse(param.getStartTime()))) +// .le(StrUtil.isNotBlank(param.getEndTime()), RStatDataIDPO::getTime, DateUtil.endOfDay(DateUtil.parse(param.getEndTime()))) +// ); +// String max = "MAX"; +// String avg = "AVG"; +// String min = "MIN"; +// String cp95 = "CP95"; +// List a = new ArrayList<>(); +// Map> collect = rStatDataVDS.stream().collect(Collectors.groupingBy(RStatDataIDPO::getPhaseType)); +// collect.forEach((key, value) -> { +// Map> valueTypeMap = value.stream().collect(Collectors.groupingBy(RStatDataIDPO::getValueType)); +// +// for (int i = num; i < size; i++) { +// ReportValue reportValue = new ReportValue(); +// String attribute = ""; +// if (fly) { +// if (index == 0) { +// attribute = attributeI(i); +// } else { +// attribute = attributeI(index); +// } +// } else { +// attribute = "i" + i; +// } +// if (valueTypeMap.containsKey(max)) { +// List aa = reflectDataI(valueTypeMap.get(max), max, attribute); +// reportValue.setPhaseType(key); +// Float maxNum = aa.stream().distinct().max(Float::compareTo).get(); +// reportValue.setFmaxValue(maxNum); +// } +// if (valueTypeMap.containsKey(avg)) { +// List aa = reflectDataI(valueTypeMap.get(avg), avg, attribute); +// reportValue.setPhaseType(key); +// Double avgNum = aa.stream().distinct().collect(Collectors.averagingDouble(Float::doubleValue)); +// reportValue.setMeanValue(avgNum.floatValue()); +// } +// if (valueTypeMap.containsKey(min)) { +// List aa = reflectDataI(valueTypeMap.get(min), min, attribute); +// reportValue.setPhaseType(key); +// double minNum = aa.stream().distinct().min(Float::compareTo).get(); +// reportValue.setMinValue((float) minNum); +// } +// if (valueTypeMap.containsKey(cp95)) { +// List aa = reflectDataI(valueTypeMap.get(cp95), cp95, attribute); +// reportValue.setPhaseType(key); +// List cp95Num = aa.stream().distinct().sorted(Comparator.comparing(Float::doubleValue).reversed()).collect(Collectors.toList()); +// reportValue.setCp95Value(cp95Num.get(0).floatValue()); +// } +// a.add(reportValue); +// } +// }); +// return a; +// } +// +// /** +// * 电流反射取属性值 +// * +// * @param value +// * @param name +// * @return +// */ +// private List reflectDataI(List value, String name, String attribute) { +// Field field = null; +// try { +// field = RStatDataIDPO.class.getDeclaredField(attribute); +// } catch (NoSuchFieldException e) { +// throw new RuntimeException(e); +// } +// field.setAccessible(true); +// Field finalField = field; +// return value.stream().filter(x -> x.getValueType().equals(name)).map(temp -> { +// Double o = null; +// try { +// o = (Double) finalField.get(temp); +// } catch (IllegalAccessException e) { +// throw new RuntimeException(e); +// } +// +// return o.floatValue(); +// }).collect(Collectors.toList()); +// } +// +// /** +// * 获取属性电压 +// * +// * @param i +// * @return +// */ +// private String attributeV(Integer i) { +// String str = null; +// switch (i) { +// case 1: +// str = "vUnbalance"; +// break; +// case 2: +// str = "vPos"; +// break; +// case 3: +// str = "vNeg"; +// break; +// case 4: +// str = "vZero"; +// break; +// case 5: +// str = "v1"; +// break; +// default: +// break; +// } +// return str; +// } +// +// /** +// * 获取属性电流 +// * +// * @param i +// * @return +// */ +// private String attributeI(Integer i) { +// String str = null; +// switch (i) { +// case 1: +// str = "iUnbalance"; +// break; +// case 2: +// str = "iPos"; +// break; +// case 3: +// str = "iNeg"; +// break; +// case 4: +// str = "iZero"; +// break; +// default: +// break; +// } +// return str; +// } +//} diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/util/RegroupData.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/util/RegroupData.java index f3d1de6..72ecb7f 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/util/RegroupData.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/util/RegroupData.java @@ -1,45 +1,45 @@ -package com.njcn.csharmonic.util; - - -import com.njcn.csharmonic.pojo.vo.report.ReportValue; - -import java.util.List; - -public class RegroupData { - public static void regroupData(List list, boolean... b) { - if (1 == b.length || (2 == b.length && b[1] == false)) { - if (0 < list.size()) { - return; - } - } - - Float value = null; - int length = b[0] ? 3 : 1; - - length = (b.length == 2 && !b[1]) ? 4 : length; - - for (int i = 0; i < length; i++) { - String str = null; - - if (b[0]) { - switch (i) { - case 0: - str = "A"; - break; - case 1: - str = "B"; - break; - case 2: - str = "C"; - break; - case 3: - str = "T"; - break; - } - } - - ReportValue reportValue = new ReportValue(str, value, value, value, value); - list.add(reportValue); - } - } -} +//package com.njcn.csharmonic.util; +// +// +//import com.njcn.csharmonic.pojo.vo.report.ReportValue; +// +//import java.util.List; +// +//public class RegroupData { +// public static void regroupData(List list, boolean... b) { +// if (1 == b.length || (2 == b.length && b[1] == false)) { +// if (0 < list.size()) { +// return; +// } +// } +// +// Float value = null; +// int length = b[0] ? 3 : 1; +// +// length = (b.length == 2 && !b[1]) ? 4 : length; +// +// for (int i = 0; i < length; i++) { +// String str = null; +// +// if (b[0]) { +// switch (i) { +// case 0: +// str = "A"; +// break; +// case 1: +// str = "B"; +// break; +// case 2: +// str = "C"; +// break; +// case 3: +// str = "T"; +// break; +// } +// } +// +// ReportValue reportValue = new ReportValue(str, value, value, value, value); +// list.add(reportValue); +// } +// } +//}