From f2c3ce35ea803a97cf0a849bca0d53c836c62af9 Mon Sep 17 00:00:00 2001 From: hongawen <83944980@qq.com> Date: Fri, 19 Apr 2024 14:33:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9A=82=E9=99=8D=E6=B2=BB=E7=90=86=E4=B8=80?= =?UTF-8?q?=E6=9C=9F=E5=B7=A5=E4=BD=9C=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../advance/enums/AdvanceResponseEnum.java | 18 + .../njcn/advance/enums/GovernSchemeEnum.java | 46 ++ .../voltage/ProductLineComputeData.java | 53 ++ .../pojo/dto/govern/voltage/SgEventExcel.java | 74 ++ .../govern/voltage/CommonSchemeParam.java | 53 ++ .../govern/voltage/QuickSchemeParam.java | 66 ++ .../param/govern/voltage/SgEventParam.java | 6 + .../voltage/SgGovernSchemeHistoryParam.java | 120 +++ .../govern/voltage/SgSensitiveUnitParam.java | 2 +- .../po/govern/harmonic/SgHarmonicFile.java | 49 ++ .../pojo/po/govern/voltage/SgEvent.java | 22 +- .../govern/voltage/SgGovernSchemeHistory.java | 80 ++ .../voltage/SgGovernSchemeHistoryDetail.java | 159 ++++ .../govern/voltage/SgGovernSchemeParam.java | 84 ++ .../pojo/po/govern/voltage/SgProductLine.java | 4 +- .../pojo/vo/govern/voltage/SgEventVO.java | 28 +- .../voltage/SgGovernSchemeHistoryAllVO.java | 34 + .../SgGovernSchemeHistoryDetailVO.java | 159 ++++ .../voltage/SgGovernSchemeHistoryVO.java | 147 ++++ .../pojo/vo/govern/voltage/SgMachineVO.java | 7 + .../pojo/vo/govern/voltage/SgOption.java | 14 + .../pojo/vo/govern/voltage/TableDataInfo.java | 91 ++ .../govern/voltage/TransientEventCount.java | 29 + .../govern/voltage/TransientEventCountVO.java | 10 + .../com/njcn/advance/utils/NumberUtil.java | 247 ++++++ .../harmonic/SgHarmonicFileController.java | 84 ++ .../voltage/SagGovernSchemeController.java | 93 +++ .../govern/voltage/SgEventController.java | 113 ++- .../voltage/SgIncomingLineController.java | 11 + .../govern/voltage/SgMachineController.java | 17 +- .../voltage/SgProductLineController.java | 4 +- .../voltage/SgSensitiveUnitController.java | 20 +- .../govern/voltage/SgUserController.java | 18 +- .../govern/harmonic/SgHarmonicFileMapper.java | 16 + .../harmonic/mapping/SgHarmonicFileMapper.xml | 5 + .../mapper/govern/voltage/SgEventMapper.java | 13 +- .../SgGovernSchemeHistoryDetailMapper.java | 16 + .../voltage/SgGovernSchemeHistoryMapper.java | 21 + .../voltage/SgGovernSchemeParamMapper.java | 16 + .../govern/voltage/SgIncomingLineMapper.java | 3 + .../govern/voltage/SgMachineMapper.java | 4 + .../govern/voltage/SgProductLineMapper.java | 5 + .../govern/voltage/SgSensitiveUnitMapper.java | 4 + .../govern/voltage/mapping/SgEventMapper.xml | 40 + .../SgGovernSchemeHistoryDetailMapper.xml | 5 + .../mapping/SgGovernSchemeHistoryMapper.xml | 27 + .../mapping/SgGovernSchemeParamMapper.xml | 5 + .../voltage/mapping/SgIncomingLineMapper.xml | 10 + .../voltage/mapping/SgMachineMapper.xml | 8 + .../voltage/mapping/SgProductLineMapper.xml | 26 + .../voltage/mapping/SgSensitiveUnitMapper.xml | 8 + .../harmonic/ISgHarmonicFileService.java | 16 + .../impl/SgHarmonicFileServiceImpl.java | 20 + .../voltage/IGovernSchemeCalcService.java | 13 + .../govern/voltage/ISgEventService.java | 32 +- .../ISgGovernSchemeHistoryDetailService.java | 16 + .../ISgGovernSchemeHistoryService.java | 24 + .../voltage/ISgGovernSchemeParamService.java | 16 + .../voltage/ISgIncomingLineService.java | 3 + .../govern/voltage/ISgMachineService.java | 3 + .../govern/voltage/ISgProductLineService.java | 7 +- .../voltage/ISgSensitiveUnitService.java | 3 + .../govern/voltage/ISgUserService.java | 2 + .../voltage/component/LossComputeUtil.java | 560 +++++++++++++ .../govern/voltage/component/temp/file.java | 0 .../impl/GovernSchemeCalcServiceImpl.java | 775 ++++++++++++++++++ .../voltage/impl/SgEventServiceImpl.java | 729 +++++++++++++++- ...gGovernSchemeHistoryDetailServiceImpl.java | 20 + .../SgGovernSchemeHistoryServiceImpl.java | 84 ++ .../impl/SgGovernSchemeParamServiceImpl.java | 20 + .../impl/SgIncomingLineServiceImpl.java | 6 + .../voltage/impl/SgMachineServiceImpl.java | 36 +- .../impl/SgProductLineServiceImpl.java | 83 +- .../impl/SgSensitiveUnitServiceImpl.java | 9 + .../voltage/impl/SgUserServiceImpl.java | 58 +- .../com/njcn/advance/utils/RadarUtil.java | 192 +++++ pqs-common/common-autocode/pom.xml | 12 + .../com/njcn/autocode/utils/GenerateCode.java | 9 +- .../java/com/njcn/common/utils/PubUtils.java | 14 +- .../java/com/njcn/oss/constant/OssPath.java | 5 + .../java/com/njcn/poi/excel/ExcelUtil.java | 60 +- pqs-gateway/src/main/resources/bootstrap.yml | 3 + 82 files changed, 4933 insertions(+), 91 deletions(-) create mode 100644 pqs-advance/advance-api/src/main/java/com/njcn/advance/enums/GovernSchemeEnum.java create mode 100644 pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/dto/govern/voltage/ProductLineComputeData.java create mode 100644 pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/dto/govern/voltage/SgEventExcel.java create mode 100644 pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/param/govern/voltage/CommonSchemeParam.java create mode 100644 pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/param/govern/voltage/QuickSchemeParam.java create mode 100644 pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/param/govern/voltage/SgGovernSchemeHistoryParam.java create mode 100644 pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/po/govern/harmonic/SgHarmonicFile.java create mode 100644 pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/po/govern/voltage/SgGovernSchemeHistory.java create mode 100644 pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/po/govern/voltage/SgGovernSchemeHistoryDetail.java create mode 100644 pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/po/govern/voltage/SgGovernSchemeParam.java create mode 100644 pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/vo/govern/voltage/SgGovernSchemeHistoryAllVO.java create mode 100644 pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/vo/govern/voltage/SgGovernSchemeHistoryDetailVO.java create mode 100644 pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/vo/govern/voltage/SgGovernSchemeHistoryVO.java create mode 100644 pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/vo/govern/voltage/SgOption.java create mode 100644 pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/vo/govern/voltage/TableDataInfo.java create mode 100644 pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/vo/govern/voltage/TransientEventCount.java create mode 100644 pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/vo/govern/voltage/TransientEventCountVO.java create mode 100644 pqs-advance/advance-api/src/main/java/com/njcn/advance/utils/NumberUtil.java create mode 100644 pqs-advance/advance-boot/src/main/java/com/njcn/advance/controller/govern/harmonic/SgHarmonicFileController.java create mode 100644 pqs-advance/advance-boot/src/main/java/com/njcn/advance/controller/govern/voltage/SagGovernSchemeController.java create mode 100644 pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/harmonic/SgHarmonicFileMapper.java create mode 100644 pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/harmonic/mapping/SgHarmonicFileMapper.xml create mode 100644 pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/SgGovernSchemeHistoryDetailMapper.java create mode 100644 pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/SgGovernSchemeHistoryMapper.java create mode 100644 pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/SgGovernSchemeParamMapper.java create mode 100644 pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/mapping/SgGovernSchemeHistoryDetailMapper.xml create mode 100644 pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/mapping/SgGovernSchemeHistoryMapper.xml create mode 100644 pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/mapping/SgGovernSchemeParamMapper.xml create mode 100644 pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/harmonic/ISgHarmonicFileService.java create mode 100644 pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/harmonic/impl/SgHarmonicFileServiceImpl.java create mode 100644 pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/IGovernSchemeCalcService.java create mode 100644 pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/ISgGovernSchemeHistoryDetailService.java create mode 100644 pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/ISgGovernSchemeHistoryService.java create mode 100644 pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/ISgGovernSchemeParamService.java create mode 100644 pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/component/LossComputeUtil.java create mode 100644 pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/component/temp/file.java create mode 100644 pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/GovernSchemeCalcServiceImpl.java create mode 100644 pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/SgGovernSchemeHistoryDetailServiceImpl.java create mode 100644 pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/SgGovernSchemeHistoryServiceImpl.java create mode 100644 pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/SgGovernSchemeParamServiceImpl.java create mode 100644 pqs-advance/advance-boot/src/main/java/com/njcn/advance/utils/RadarUtil.java diff --git a/pqs-advance/advance-api/src/main/java/com/njcn/advance/enums/AdvanceResponseEnum.java b/pqs-advance/advance-api/src/main/java/com/njcn/advance/enums/AdvanceResponseEnum.java index a8bca9a7c..dd1363d24 100644 --- a/pqs-advance/advance-api/src/main/java/com/njcn/advance/enums/AdvanceResponseEnum.java +++ b/pqs-advance/advance-api/src/main/java/com/njcn/advance/enums/AdvanceResponseEnum.java @@ -54,6 +54,24 @@ public enum AdvanceResponseEnum { SG_PRODUCT_LINE_ID_MISS("A0102","生产线id缺失"), SG_MACHINE_ID_MISS("A0102","设备id缺失"), + + IMPORT_EVENT_DATA_FAIL("A0102","请检查导入数据的准确性"), + + PRODUCT_LINE_DATA_MISS("A0102","生产线数据缺失"), + + MACHINE_DATA_MISS("A0102","设备数据缺失"), + + INCOMING_LINE_DATA_MISS("A0102","进线数据缺失"), + + EVENT_DATA_MISS("A0102","没有可供参考的暂降数据"), + + USER_HAS_PRODUCT("A0102","当前用户存在生产线"), + + PRODUCT_HAS_MACHINE("A0102","当前生产线存在设备"), + + MACHINE_HAS_UNIT("A0102","当前设备存在元器件"), + + EVENT_TIME_ERROR("A0102","暂降事件时间格式有误,请检查"), ; private final String code; diff --git a/pqs-advance/advance-api/src/main/java/com/njcn/advance/enums/GovernSchemeEnum.java b/pqs-advance/advance-api/src/main/java/com/njcn/advance/enums/GovernSchemeEnum.java new file mode 100644 index 000000000..4b868dcad --- /dev/null +++ b/pqs-advance/advance-api/src/main/java/com/njcn/advance/enums/GovernSchemeEnum.java @@ -0,0 +1,46 @@ +package com.njcn.advance.enums; + +import lombok.Getter; + +/** + * @author hongawen + * @version 1.0.0 + * @date 2021年04月13日 10:50 + */ +@Getter +public enum GovernSchemeEnum { + + + UPS(0, "UPS治理方案"), + + AVC(1, "AVC治理方案"), + + AVC_RTS(2, "AVC-RTS治理方案"), + + QUICK(3, "快切开关治理方案"), + + NO_SCHEME(4, "未采取任何治理措施"), + ; + + private final Integer code; + + private final String message; + + GovernSchemeEnum(Integer code, String message) { + this.code = code; + this.message = message; + } + + /** + * 根据code获取对应的枚举 + */ + public static GovernSchemeEnum getSchemeByCode(int code) { + for (GovernSchemeEnum governSchemeEnum : GovernSchemeEnum.values()) { + if (governSchemeEnum.code == code) { + return governSchemeEnum; + } + } + return GovernSchemeEnum.NO_SCHEME; + } + +} diff --git a/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/dto/govern/voltage/ProductLineComputeData.java b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/dto/govern/voltage/ProductLineComputeData.java new file mode 100644 index 000000000..e8500deae --- /dev/null +++ b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/dto/govern/voltage/ProductLineComputeData.java @@ -0,0 +1,53 @@ +package com.njcn.advance.pojo.dto.govern.voltage; + +import com.njcn.advance.pojo.po.govern.voltage.SgMachine; +import com.njcn.advance.pojo.vo.govern.voltage.SgMachineVO; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * 用于计算生产线损失各项数据的实体类 + */ +@Data +public class ProductLineComputeData implements Serializable { + + /** + * 生产线id + */ + private String id; + + /** + * 业务用户id + */ + private String userId; + + /** + * 进线id + */ + private String incomingLineId; + + /** + * 生产线名称 + */ + private String name; + + /** + * 计算模式 0-模式一(单次中断不计算设备、原料损失);1-模式二(计算) + */ + private Integer calcMode; + + /** + * 中断导致的产能损失(默认为0) + */ + private Double capacityLoss; + + /** + * 生产线下所有的设备集合 + * 默认为串联形式的 + */ + private List machineVOList; + + +} diff --git a/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/dto/govern/voltage/SgEventExcel.java b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/dto/govern/voltage/SgEventExcel.java new file mode 100644 index 000000000..dee6a88d9 --- /dev/null +++ b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/dto/govern/voltage/SgEventExcel.java @@ -0,0 +1,74 @@ +package com.njcn.advance.pojo.dto.govern.voltage; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import cn.afterturn.easypoi.handler.inter.IExcelModel; +import com.njcn.device.pq.pojo.constant.DeviceValidMessage; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +/** + *

+ * + *

+ * + * @author hongawen + * @since 2024-02-29 + */ +@Data +public class SgEventExcel implements Serializable { + + private static final long serialVersionUID = 1L; + + + + /** + * 暂降起始时间 + */ + @Excel(name="暂降发生时间(yyyy-MM-dd HH:mm:ss)",format = "yyyy-MM-dd HH:mm:ss",width = 45) + @NotBlank(message = "暂降时间不能为空") + private String startTime; + + /** + * 暂降发生毫秒 + */ + @Excel(name="暂降发生毫秒",width = 45) + @NotBlank(message = "暂降发生毫秒不能为空") + private String ms; + + /** + * 持续时间(单位:秒) + */ + @Excel(name="持续时间(ms)",width = 25) + @NotNull(message = "持续时间不能为空") + private Double duration; + + /** + * 特征幅值 + */ + @Excel(name="暂降幅值(范围0p.u.~1p.u.)",width = 28) + @NotNull(message = "暂降幅值不能为空") + @Min(value = 0) + @Max(value = 1) + private Double featureAmplitude; + + + /** + * 事件描述 + */ + @Excel(name="事件描述(非必填)",width = 30) + private String eventDescribe; + + @Data + @EqualsAndHashCode(callSuper = true) + public static class SgEventExcelMsg extends SgEventExcel implements Serializable, IExcelModel { + @Excel(name = "错误信息描述") + private String errorMsg; + } + +} diff --git a/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/param/govern/voltage/CommonSchemeParam.java b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/param/govern/voltage/CommonSchemeParam.java new file mode 100644 index 000000000..54c80c999 --- /dev/null +++ b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/param/govern/voltage/CommonSchemeParam.java @@ -0,0 +1,53 @@ +package com.njcn.advance.pojo.param.govern.voltage; + + +import com.njcn.web.constant.ValidMessage; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +/** + * 通用方案的参数,UPS/AVC + */ +@Data +public class CommonSchemeParam implements Serializable { + + /** + * 采购单价 + */ + @ApiModelProperty("采购单价") + @NotNull(message = ValidMessage.MISS_PREFIX + "price") + private Double price; + + /** + * 补偿能力 + */ + @ApiModelProperty("补偿能力") + @NotNull(message = ValidMessage.MISS_PREFIX + "compensation") + private Double compensation; + + /** + * 维护费 + */ + @ApiModelProperty("维护费") + @NotNull(message = ValidMessage.MISS_PREFIX + "maintainFee") + private Double maintainFee; + + /** + * 响应时间 + */ + @ApiModelProperty("响应时间") + @NotNull(message = ValidMessage.MISS_PREFIX + "responseTime") + private Double responseTime; + + /** + * 后备时间 + */ + @ApiModelProperty("后备时间") + @NotNull(message = ValidMessage.MISS_PREFIX + "backupTime") + private Double backupTime; + + +} diff --git a/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/param/govern/voltage/QuickSchemeParam.java b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/param/govern/voltage/QuickSchemeParam.java new file mode 100644 index 000000000..b26cd982d --- /dev/null +++ b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/param/govern/voltage/QuickSchemeParam.java @@ -0,0 +1,66 @@ +package com.njcn.advance.pojo.param.govern.voltage; + +import com.njcn.web.constant.ValidMessage; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +/** + * 快切评估参数 + */ +@Data +public class QuickSchemeParam implements Serializable { + + /** + * 备用进线ID + */ + @ApiModelProperty("备用进线ID") + @NotBlank(message = ValidMessage.MISS_PREFIX + "incomingLineId") + private String incomingLineId; + + /** + * 治理容量 + */ + @ApiModelProperty("治理容量") + @NotNull(message = ValidMessage.MISS_PREFIX + "governMachinePower") + private Double governMachinePower; + + /** + * 采购价格 + */ + @ApiModelProperty("采购价格") + @NotNull(message = ValidMessage.MISS_PREFIX + "price") + private Double price; + + /** + * 建设费用 + */ + @ApiModelProperty("建设费用") + @NotNull(message = ValidMessage.MISS_PREFIX + "buildFee") + private Double buildFee; + + /** + * 快切维护费用 + */ + @ApiModelProperty("快切维护费用") + @NotNull(message = ValidMessage.MISS_PREFIX + "quickMaintainFee") + private Double quickMaintainFee; + + /** + * 动作时间 + */ + @ApiModelProperty("动作时间") + @NotNull(message = ValidMessage.MISS_PREFIX + "actionTime") + private Double actionTime; + + + + + + + + +} diff --git a/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/param/govern/voltage/SgEventParam.java b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/param/govern/voltage/SgEventParam.java index 0fbcafa43..8e84a4c88 100644 --- a/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/param/govern/voltage/SgEventParam.java +++ b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/param/govern/voltage/SgEventParam.java @@ -88,6 +88,12 @@ public class SgEventParam { @EqualsAndHashCode(callSuper = true) public static class SgEventParamQueryParam extends BaseParam { + /** + * 用户id + */ + @ApiModelProperty("用户id") + private String userId; + /** * 生产线id */ diff --git a/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/param/govern/voltage/SgGovernSchemeHistoryParam.java b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/param/govern/voltage/SgGovernSchemeHistoryParam.java new file mode 100644 index 000000000..37643c6a0 --- /dev/null +++ b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/param/govern/voltage/SgGovernSchemeHistoryParam.java @@ -0,0 +1,120 @@ +package com.njcn.advance.pojo.param.govern.voltage; + +import com.njcn.web.constant.ValidMessage; +import com.njcn.web.pojo.param.BaseParam; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +/** + * @author hongawen + * @since 2024-03-27 + */ +@Data +public class SgGovernSchemeHistoryParam implements Serializable { + + private static final long serialVersionUID = 1L; + + + /** + * 生产线索引 + */ + @ApiModelProperty("生产线索引") + @NotBlank(message = ValidMessage.MISS_PREFIX + "productLineId") + private String productLineId; + + + /** + * 参数数据的起始时间 + */ + @ApiModelProperty("参数数据的起始时间") + @NotBlank(message = ValidMessage.MISS_PREFIX + "startTime") + private String startTime; + + /** + * 参考数据的截止时间 + */ + @ApiModelProperty("参考数据的截止时间") + @NotBlank(message = ValidMessage.MISS_PREFIX + "endTime") + private String endTime; + + + /** + * 评估人期望的回收周期 + */ + @ApiModelProperty("评估人期望的回收周期") + @NotNull(message = ValidMessage.MISS_PREFIX + "payBackPeriod") + private Integer payBackPeriod; + + /** + * UPS评估需要的参数 + */ + @NotNull(message = "UPS评估参数缺失") + private CommonSchemeParam ups; + + /** + * AVC评估需要的参数 + */ + @NotNull(message = "AVC评估参数缺失") + private CommonSchemeParam avc; + + /** + * 快切评估需要的参数 + */ + @NotNull(message = "快切评估参数缺失") + private QuickSchemeParam quick; + + + /** + * 评估批次 + */ + private String evaluationBatch; + + /** + * 最佳方案id + */ + private String bestSchemeId; + + + /** + * 治理容量(kW) + */ + private Double governPower; + + /** + * 暂降次数 + */ + private Integer eventCount; + + /** + * 中断次数 + */ + private Integer breakCount; + + /** + * 不做治理,可能造成的经济损失 + */ + private Double loss; + + + /** + * 分页查询实体 + */ + @Data + @EqualsAndHashCode(callSuper = true) + public static class SgSchemeHistoryQueryParam extends BaseParam { + + /** + * 生产线id + */ + @ApiModelProperty("用户id") + private String userId; + + } + + +} diff --git a/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/param/govern/voltage/SgSensitiveUnitParam.java b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/param/govern/voltage/SgSensitiveUnitParam.java index 55fb24b23..0d07f1a20 100644 --- a/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/param/govern/voltage/SgSensitiveUnitParam.java +++ b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/param/govern/voltage/SgSensitiveUnitParam.java @@ -82,7 +82,7 @@ public class SgSensitiveUnitParam { */ @Data @EqualsAndHashCode(callSuper = true) - public static class SgSensitiveUnitUpdateParam extends SgMachineParam { + public static class SgSensitiveUnitUpdateParam extends SgSensitiveUnitParam { /** * 表Id diff --git a/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/po/govern/harmonic/SgHarmonicFile.java b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/po/govern/harmonic/SgHarmonicFile.java new file mode 100644 index 000000000..54963d5eb --- /dev/null +++ b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/po/govern/harmonic/SgHarmonicFile.java @@ -0,0 +1,49 @@ +package com.njcn.advance.pojo.po.govern.harmonic; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.njcn.db.bo.BaseEntity; +import java.io.Serializable; +import java.time.LocalDateTime; + +import lombok.Data; +import lombok.Getter; +import lombok.Setter; + +/** + *

+ * + *

+ * + * @author hongawen + * @since 2024-04-17 + */ +@Data +@TableName("sg_harmonic_file") +public class SgHarmonicFile extends BaseEntity implements Serializable{ + + private static final long serialVersionUID = 1L; + + /** + * 谐波文件表id + */ + private String id; + + /** + * 文件名 + */ + private String dataName; + + /** + * 文件服务器的路径 + */ + private String dataPath; + + /** + * 状态 0-删除;1-正常;默认正常 + */ + private Integer state; + + + + +} diff --git a/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/po/govern/voltage/SgEvent.java b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/po/govern/voltage/SgEvent.java index e8157794b..0c516c817 100644 --- a/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/po/govern/voltage/SgEvent.java +++ b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/po/govern/voltage/SgEvent.java @@ -5,7 +5,10 @@ import com.njcn.db.bo.BaseEntity; import java.io.Serializable; import java.math.BigDecimal; import java.time.LocalDateTime; + +import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; /** @@ -19,7 +22,9 @@ import lombok.Setter; @Getter @Setter @TableName("sg_event") -public class SgEvent { +@NoArgsConstructor +@AllArgsConstructor +public class SgEvent implements Serializable{ private static final long serialVersionUID = 1L; @@ -28,6 +33,11 @@ public class SgEvent { */ private String id; + /** + * 生产线id + */ + private String productLineId; + /** * 进线id */ @@ -78,5 +88,15 @@ public class SgEvent { */ private Integer dataSource; + private Integer state; + + public SgEvent(String incomingLineId, Double duration, Double featureAmplitude, String eventDescribe, Integer dataSource) { + this.incomingLineId = incomingLineId; + this.startTime = startTime; + this.duration = duration; + this.featureAmplitude = featureAmplitude; + this.eventDescribe = eventDescribe; + this.dataSource = dataSource; + } } diff --git a/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/po/govern/voltage/SgGovernSchemeHistory.java b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/po/govern/voltage/SgGovernSchemeHistory.java new file mode 100644 index 000000000..11bf10436 --- /dev/null +++ b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/po/govern/voltage/SgGovernSchemeHistory.java @@ -0,0 +1,80 @@ +package com.njcn.advance.pojo.po.govern.voltage; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.njcn.db.bo.BaseEntity; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.time.LocalDateTime; + +import lombok.Getter; +import lombok.Setter; + +/** + * @author hongawen + * @since 2024-03-27 + */ +@Getter +@Setter +@TableName("sg_govern_scheme_history") +public class SgGovernSchemeHistory extends BaseEntity implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 治理评估历史数据表 + */ + private String id; + + + /** + * 生产线ID + */ + private String productLineId; + + /** + * 评估批次 + */ + private String evaluationBatch; + + /** + * 最佳方案id + */ + private String bestSchemeId; + + /** + * 期望回收周期 + */ + private Integer payBackPeriod; + + /** + * 参考数据时间范围 + */ + private String timeScope; + + /** + * 治理容量(kW) + */ + private Double governPower; + + /** + * 暂降次数 + */ + private Integer eventCount; + + /** + * 中断次数 + */ + private Integer breakCount; + + /** + * 不做治理,可能造成的经济损失 + */ + private Double loss; + + /** + * 用户状态 0-删除;1-正常;默认正常 + */ + private Integer state; + +} diff --git a/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/po/govern/voltage/SgGovernSchemeHistoryDetail.java b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/po/govern/voltage/SgGovernSchemeHistoryDetail.java new file mode 100644 index 000000000..3b61bd976 --- /dev/null +++ b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/po/govern/voltage/SgGovernSchemeHistoryDetail.java @@ -0,0 +1,159 @@ +package com.njcn.advance.pojo.po.govern.voltage; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.njcn.db.bo.BaseEntity; +import java.io.Serializable; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.List; + +import lombok.Getter; +import lombok.Setter; + +/** + * + * @author hongawen + * @since 2024-03-27 + */ +@Getter +@Setter +@TableName("sg_govern_scheme_history_detail") +public class SgGovernSchemeHistoryDetail extends BaseEntity implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 治理方案详细结果 + */ + private String id; + + /** + * 评估批次 + */ + private String evaluationBatch; + + /** + * 方案参数 + */ + private String schemeParamId; + + /** + * 参数类型(0 ups;1 avc;2 avc-rts;3 快切) + */ + private Integer type; + + /** + * 暂降次数 + */ + private Integer eventCount; + + /** + * 中断次数 + */ + private Integer breakCount; + + /** + * 治理设备总价格(万元) + */ + private Double equipment; + + /** + * 年维护费(万元/年) + */ + private Double maintain; + + /** + * 治理后的经济损失 + */ + private Double loss; + + /** + * 曲线图的X轴 + */ + private String years; + + /** + * 用户每年的投资,由集合转为字符的 + */ + private String investYear; + + /** + * 用户每年的收益,由集合转为字符的 + */ + private String payBack; + + + /** + * 5年 10年 15年的成本 + */ + private String cost; + + /** + * 5年 10年 15年的投资收益率 + */ + private String investYield; + + /** + * 实际回报年份 + */ + private int actualPayBack; + + + /** + * 尺寸(快切没有尺寸) + */ + private String size; + + /** + * 设备总数量 + */ + private Integer count; + + /** + * 设备总功率 + */ + private Double power; + + /** + * 治理前风险等级 + */ + private String riskLevelBefore; + + /** + * 治理后风险等级 + */ + private String riskLevelAfter; + + /** + * 治理效果 + */ + private Double radarResult; + + /** + * 去风险能力 + */ + private Double radarRisk; + + /** + * 投资意愿 + */ + private Double radarWish; + + /** + * 暂降免疫能力 + */ + private Double sagImmunity; + + /** + * 投资综合评估 + */ + private Double investmentResult; + + /** + * 状态 0-删除;1-正常;默认正常 + */ + private Integer state; + + + +} diff --git a/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/po/govern/voltage/SgGovernSchemeParam.java b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/po/govern/voltage/SgGovernSchemeParam.java new file mode 100644 index 000000000..e00ed3c1a --- /dev/null +++ b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/po/govern/voltage/SgGovernSchemeParam.java @@ -0,0 +1,84 @@ +package com.njcn.advance.pojo.po.govern.voltage; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.njcn.db.bo.BaseEntity; +import java.io.Serializable; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import lombok.Getter; +import lombok.Setter; + +/** + * + * @author hongawen + * @since 2024-03-27 + */ +@Getter +@Setter +@TableName("sg_govern_scheme_param") +public class SgGovernSchemeParam extends BaseEntity implements Serializable{ + + private static final long serialVersionUID = 1L; + + /** + * 方案初始参数 + */ + private String id; + + /** + * 购置价格(万元/kVA) + */ + private Double price; + + /** + * 补偿能力(p.u.) + */ + private Double compensation; + + /** + * 年维护费(万元/kVA) + */ + private Double maintainFee; + + /** + * 响应时间(ms) + */ + private Integer responseTime; + + /** + * 后备时间(s) + */ + private Integer backupTime; + + /** + * 治理设备容量(kVA) + */ + private Double governMachinePower; + + /** + * 建设成本(万元) + */ + private Double buildFee; + + /** + * 快切的年维护费(万元) + */ + private Double quickMaintainFee; + + /** + * 动作时间(ms) + */ + private Double actionTime; + + /** + * 备用进线id + */ + private String incomingLineId; + + /** + * 用户状态 0-删除;1-正常;默认正常 + */ + private Integer state; + + +} diff --git a/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/po/govern/voltage/SgProductLine.java b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/po/govern/voltage/SgProductLine.java index 4f9a43e9b..9b929aed5 100644 --- a/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/po/govern/voltage/SgProductLine.java +++ b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/po/govern/voltage/SgProductLine.java @@ -51,10 +51,10 @@ public class SgProductLine extends BaseEntity { /** * 中断导致的产能损失(默认为0) */ - private Float capacityLoss; + private Double capacityLoss; /** - * 用户状态 0-删除;1-正常;默认正常 + * 数据状态 0-删除;1-正常;默认正常 */ private Integer state; diff --git a/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/vo/govern/voltage/SgEventVO.java b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/vo/govern/voltage/SgEventVO.java index a479b44e2..ef3a870b1 100644 --- a/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/vo/govern/voltage/SgEventVO.java +++ b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/vo/govern/voltage/SgEventVO.java @@ -1,19 +1,21 @@ package com.njcn.advance.pojo.vo.govern.voltage; +import cn.afterturn.easypoi.excel.annotation.Excel; import lombok.Data; +import java.io.Serializable; import java.time.LocalDateTime; /** *

- * + * *

* * @author hongawen * @since 2024-02-29 */ @Data -public class SgEventVO { +public class SgEventVO implements Serializable { private static final long serialVersionUID = 1L; @@ -27,15 +29,18 @@ public class SgEventVO { */ private String incomingLineId; + /** * 进线名称 */ - private String lineName; + @Excel(name="进线名称",width = 25) + private String incomingLineName; /** * 暂降起始时间 */ - private LocalDateTime startTime; + @Excel(name="暂降发生时间",width = 35) + private String startTime; /** * 事件类型 @@ -45,21 +50,25 @@ public class SgEventVO { /** * 持续时间(单位:秒) */ + @Excel(name="持续时间(单位:秒)",width = 25) private Double duration; /** * 特征幅值 */ + @Excel(name="暂降幅值") private Double featureAmplitude; /** * 预估损失(单位:万元) */ + @Excel(name="预估损失(单位:万元)",width = 25) private Double estimatedLoss; /** * 事件描述 */ + @Excel(name="事件描述",width = 25) private String eventDescribe; /** @@ -67,15 +76,18 @@ public class SgEventVO { */ private Integer fileFlag; + /** + * 数据来源(0-离线导入 1-监测点实际数据同步) + */ + @Excel(name="数据来源", replace = { "监测点实际同步_1", "离线导入_0" },width = 25) + private Integer dataSource; + /** * 波形路径 */ private String wavePath; - /** - * 数据来源(0-离线导入 1-监测点实际数据同步) - */ - private Integer dataSource; + } diff --git a/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/vo/govern/voltage/SgGovernSchemeHistoryAllVO.java b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/vo/govern/voltage/SgGovernSchemeHistoryAllVO.java new file mode 100644 index 000000000..bcc4c85a9 --- /dev/null +++ b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/vo/govern/voltage/SgGovernSchemeHistoryAllVO.java @@ -0,0 +1,34 @@ +package com.njcn.advance.pojo.vo.govern.voltage; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class SgGovernSchemeHistoryAllVO extends SgGovernSchemeHistoryVO { + + + /** + * UPS的三条曲线数据 + */ + private SgGovernSchemeHistoryDetailVO upsData; + + + /** + * AVC的三条曲线数据 + */ + private SgGovernSchemeHistoryDetailVO avcData; + + + /** + * AVC+UPS的三条曲线数据 + */ + private SgGovernSchemeHistoryDetailVO upsRtsData; + + + /** + * 快切的三条曲线数据 + */ + private SgGovernSchemeHistoryDetailVO quickData; + +} \ No newline at end of file diff --git a/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/vo/govern/voltage/SgGovernSchemeHistoryDetailVO.java b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/vo/govern/voltage/SgGovernSchemeHistoryDetailVO.java new file mode 100644 index 000000000..20f4e7882 --- /dev/null +++ b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/vo/govern/voltage/SgGovernSchemeHistoryDetailVO.java @@ -0,0 +1,159 @@ +package com.njcn.advance.pojo.vo.govern.voltage; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * + * @author hongawen + * @since 2024-03-27 + */ +@Data +public class SgGovernSchemeHistoryDetailVO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 治理方案详细结果 + */ + private String id; + + /** + * 评估批次 + */ + private String evaluationBatch; + + /** + * 方案参数 + */ + private String schemeParamId; + + /** + * 参数类型(0 ups;1 avc;2 avc-rts;3 快切) + */ + private Integer type; + + /** + * 暂降次数 + */ + private Integer eventCount; + + /** + * 中断次数 + */ + private Integer breakCount; + + /** + * 治理后的经济损失 + */ + private Double loss; + + /** + * 治理可能的经济损失(万元/年) + */ + private Double yearLoss; + + /** + * 尺寸(快切没有尺寸) + */ + private String size; + + /** + * 设备总数量 + */ + private Integer count; + + /** + * 设备总功率 + */ + private Double power; + + + /** + * 治理设备总价格(万元) + */ + private Double equipment; + + /** + * 年维护费(万元/年) + */ + private Double maintain; + + + /** + * 曲线图的X轴 + */ + private List yearsArray; + + /** + * 用户每年的投资,由集合转为字符的 + */ + private List investYearArray; + + /** + * 治理效果每年 + */ + private List governEffectArray; + + /** + * 用户每年的收益,由集合转为字符的 + */ + private List payBackArray; + + /** + * 5年 10年 15年的成本 + */ + private List costArray; + + /** + * 5年 10年 15年的投资收益率 + */ + private List investYieldArray; + + /** + * 实际回报年份 + */ + private int actualPayBack; + + + /** + * 治理前风险等级 + */ + private String riskLevelBefore; + + /** + * 治理后风险等级 + */ + private String riskLevelAfter; + + /** + * 治理效果 + */ + private Double radarResult; + + /** + * 去风险能力 + */ + private Double radarRisk; + + /** + * 投资意愿 + */ + private Double radarWish; + + /** + * 暂降免疫能力 + */ + private Double sagImmunity; + + /** + * 投资综合评估 + */ + private Double investmentResult; + + + + +} diff --git a/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/vo/govern/voltage/SgGovernSchemeHistoryVO.java b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/vo/govern/voltage/SgGovernSchemeHistoryVO.java new file mode 100644 index 000000000..2260b300e --- /dev/null +++ b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/vo/govern/voltage/SgGovernSchemeHistoryVO.java @@ -0,0 +1,147 @@ +package com.njcn.advance.pojo.vo.govern.voltage; + +import com.njcn.advance.pojo.param.govern.voltage.CommonSchemeParam; +import com.njcn.advance.pojo.param.govern.voltage.QuickSchemeParam; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +/** + * 页面表格治理结果展示 + * + * @author hongawen + * @since 2024-03-27 + */ +@Data +public class SgGovernSchemeHistoryVO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 治理评估历史数据表 + */ + private String id; + + /** + * 用户名 + */ + private String userName; + + /** + * 生产线ID + */ + private String productLineId; + + /** + * 生产线名称 + */ + private String productLineName; + + /** + * 进线名称 + */ + private String inComingLineName; + + /** + * 评估批次 + */ + private String evaluationBatch; + + /** + * 最佳方案id + */ + private String bestSchemeId; + + /** + * 期望回收周期 + */ + private Integer payBackPeriod; + + /** + * 参考数据时间范围 + */ + private String timeScope; + + /** + * 治理容量(kW) + */ + private Double governPower; + + /** + * 暂降次数 + */ + private Integer eventCount; + + /** + * 中断次数 + */ + private Integer breakCount; + + /** + * 不做治理,可能造成的经济损失 + */ + private Double loss; + + /** + * 做治理,可能造成的经济损失 + */ + private Double governLoss; + + /** + * 治理效果,未治理-治理的 + */ + private Double governEffect; + + /** + * 不做治理,可能造成的经济损失 + */ + private Double yearLoss; + + /** + * 初期投资(万元)=设备费用+年维护费 + */ + private Double initialInvest; + + /** + * 设备费用(万元) + */ + private Double schemeEquipment; + + /** + * 年维护费(万元) + */ + private Double schemeMaintain; + + /** + * 投资回收期 + */ + private Integer payBackYear; + + /*** + * 治理效果每年 + */ + private Double governEffectMoney; + + /** + * 最佳治理方案 + */ + private Integer schemeType; + + /** + * UPS评估需要的参数 + */ + private CommonSchemeParam ups; + + /** + * AVC评估需要的参数 + */ + private CommonSchemeParam avc; + + /** + * 快切评估需要的参数 + */ + private QuickSchemeParam quick; + + +} diff --git a/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/vo/govern/voltage/SgMachineVO.java b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/vo/govern/voltage/SgMachineVO.java index fea1a5e89..856bcea66 100644 --- a/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/vo/govern/voltage/SgMachineVO.java +++ b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/vo/govern/voltage/SgMachineVO.java @@ -1,8 +1,10 @@ package com.njcn.advance.pojo.vo.govern.voltage; +import com.njcn.advance.pojo.po.govern.voltage.SgSensitiveUnit; import lombok.Data; import java.io.Serializable; +import java.util.List; @Data public class SgMachineVO implements Serializable { @@ -46,4 +48,9 @@ public class SgMachineVO implements Serializable { * 功率(默认为0) */ private Double machinePower; + + /** + * 敏感元器件列表 + */ + private List sgSensitiveUnitList; } diff --git a/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/vo/govern/voltage/SgOption.java b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/vo/govern/voltage/SgOption.java new file mode 100644 index 000000000..8e640f3f2 --- /dev/null +++ b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/vo/govern/voltage/SgOption.java @@ -0,0 +1,14 @@ +package com.njcn.advance.pojo.vo.govern.voltage; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class SgOption implements Serializable { + + private String id; + + private String name; + +} diff --git a/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/vo/govern/voltage/TableDataInfo.java b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/vo/govern/voltage/TableDataInfo.java new file mode 100644 index 000000000..97fb74d60 --- /dev/null +++ b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/vo/govern/voltage/TableDataInfo.java @@ -0,0 +1,91 @@ +package com.njcn.advance.pojo.vo.govern.voltage; + +import io.swagger.annotations.ApiModelProperty; + +import java.io.Serializable; +import java.util.List; + +/** + * 表格分页数据对象 + * + * @author ruoyi + */ +public class TableDataInfo implements Serializable +{ + private static final long serialVersionUID = 1L; + + /** 总记录数 */ + @ApiModelProperty("总记录数") + private long total; + + /** 数据列表 */ + @ApiModelProperty("数据列表") + private List rows; + + /** 消息状态码 */ + @ApiModelProperty("消息状态码") + private int code; + + /** 消息内容 */ + @ApiModelProperty("消息内容") + private String msg; + + /** + * 表格数据对象 + */ + public TableDataInfo() + { + } + + /** + * 分页 + * + * @param list 列表数据 + * @param total 总记录数 + */ + public TableDataInfo(List list, int total) + { + this.rows = list; + this.total = total; + } + + public long getTotal() + { + return total; + } + + public void setTotal(long total) + { + this.total = total; + } + + public List getRows() + { + return rows; + } + + public void setRows(List rows) + { + this.rows = rows; + } + + public int getCode() + { + return code; + } + + public void setCode(int code) + { + this.code = code; + } + + public String getMsg() + { + return msg; + } + + public void setMsg(String msg) + { + this.msg = msg; + } +} \ No newline at end of file diff --git a/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/vo/govern/voltage/TransientEventCount.java b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/vo/govern/voltage/TransientEventCount.java new file mode 100644 index 000000000..0350c5d19 --- /dev/null +++ b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/vo/govern/voltage/TransientEventCount.java @@ -0,0 +1,29 @@ +package com.njcn.advance.pojo.vo.govern.voltage; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +@Setter +@Getter +public class TransientEventCount { + + @ApiModelProperty("暂降幅值") + private String amplitude; + + @ApiModelProperty("持续时间(0.01-0.02)") + private String D001_002s; + + @ApiModelProperty("持续时间(0.02-0.05)") + private String D002_005s; + + @ApiModelProperty("持续时间(0.05-0.07)") + private String D005_007s; + + @ApiModelProperty("持续时间(0.07-0.10)") + private String D007_010s; + + @ApiModelProperty("持续时间(0.10-1.00)") + private String D010_100s; + +} \ No newline at end of file diff --git a/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/vo/govern/voltage/TransientEventCountVO.java b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/vo/govern/voltage/TransientEventCountVO.java new file mode 100644 index 000000000..87da3c581 --- /dev/null +++ b/pqs-advance/advance-api/src/main/java/com/njcn/advance/pojo/vo/govern/voltage/TransientEventCountVO.java @@ -0,0 +1,10 @@ +package com.njcn.advance.pojo.vo.govern.voltage; + +import lombok.Data; + +@Data +public class TransientEventCountVO { + + private String[][] values; + +} diff --git a/pqs-advance/advance-api/src/main/java/com/njcn/advance/utils/NumberUtil.java b/pqs-advance/advance-api/src/main/java/com/njcn/advance/utils/NumberUtil.java new file mode 100644 index 000000000..87ed78ba5 --- /dev/null +++ b/pqs-advance/advance-api/src/main/java/com/njcn/advance/utils/NumberUtil.java @@ -0,0 +1,247 @@ +package com.njcn.advance.utils; + +import cn.hutool.core.util.StrUtil; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.Random; + +import static java.math.BigDecimal.ROUND_HALF_UP; + +public class NumberUtil { + private static final int DEFAULT_SCALE = 10; + private static final RoundingMode DEFAULT_ROUNDINGMODE = RoundingMode.HALF_UP; + + private static Random rand = new Random(); + + public static boolean isNumber(String str) { + return isDouble(str); + } + + public static boolean isInt(String str) { + if (StrUtil.isEmpty(str)) + return false; + try + { + Integer.parseInt(str); + } catch (NumberFormatException e) { + return false; + } + return true; + } + + public static boolean isInteger(String str) { + return isInt(str); + } + + public static boolean isLong(String str) { + if (StrUtil.isEmpty(str)) + return false; + try + { + Long.parseLong(str); + } catch (NumberFormatException e) { + return false; + } + return true; + } + + public static boolean isFloat(String str) { + if (StrUtil.isEmpty(str)) + return false; + try + { + Float.parseFloat(str); + } catch (NumberFormatException e) { + return false; + } + return true; + } + + public static boolean isDouble(String str) { + if (StrUtil.isEmpty(str)) + return false; + try + { + Double.parseDouble(str); + } catch (NumberFormatException e) { + return false; + } + return true; + } + + public static double round(double v, int scale) { + BigDecimal b = new BigDecimal(Double.toString(v)); + return b.setScale(scale, ROUND_HALF_UP).doubleValue(); + } + + public static int getRandomInt(int max) { + return rand.nextInt(max); + } + + public static int toInt(byte[] bs) { + return toInt(bs, 0); + } + + public static int toInt(byte[] bs, int start) { + int i = 0; + i += ((bs[start] & 0xFF) << 24); + i += ((bs[(start + 1)] & 0xFF) << 16); + i += ((bs[(start + 2)] & 0xFF) << 8); + i += (bs[(start + 3)] & 0xFF); + return i; + } + + public static byte[] toBytes(int i) { + byte[] bs = new byte[4]; + bs[0] = ((byte)(i >> 24)); + bs[1] = ((byte)(i >> 16)); + bs[2] = ((byte)(i >> 8)); + bs[3] = ((byte)(i & 0xFF)); + return bs; + } + + public static void toBytes(int i, byte[] bs, int start) { + bs[start] = ((byte)(i >> 24)); + bs[(start + 1)] = ((byte)(i >> 16)); + bs[(start + 2)] = ((byte)(i >> 8)); + bs[(start + 3)] = ((byte)(i & 0xFF)); + } + + public static short toShort(byte[] bs) { + return toShort(bs, 0); + } + + public static short toShort(byte[] bs, int start) { + short i = 0; + i = (short)(i + ((bs[(start + 0)] & 0xFF) << 8)); + i = (short)(i + (bs[(start + 1)] & 0xFF)); + return i; + } + + public static byte[] toBytes(short i) { + byte[] bs = new byte[2]; + bs[0] = ((byte)(i >> 8)); + bs[1] = ((byte)(i & 0xFF)); + return bs; + } + + public static void toBytes(short i, byte[] bs, int start) { + bs[(start + 0)] = ((byte)(i >> 8)); + bs[(start + 1)] = ((byte)(i & 0xFF)); + } + + public static byte[] toBytes(long i) { + byte[] bs = new byte[8]; + bs[0] = ((byte)(int)(i >> 56)); + bs[1] = ((byte)(int)(i >> 48)); + bs[2] = ((byte)(int)(i >> 40)); + bs[3] = ((byte)(int)(i >> 32)); + bs[4] = ((byte)(int)(i >> 24)); + bs[5] = ((byte)(int)(i >> 16)); + bs[6] = ((byte)(int)(i >> 8)); + bs[7] = ((byte)(int)(i & 0xFF)); + return bs; + } + + public static void toBytes(long l, byte[] bs, int start) { + byte[] arr = toBytes(l); + for (int i = 0; i < 8; i++) + bs[(start + i)] = arr[i]; + } + + public static long toLong(byte[] bs) { + return toLong(bs, 0); + } + + public static long toLong(byte[] bs, int index) { + return (bs[index] & 0xFF) << 56 | (bs[(index + 1)] & 0xFF) << 48 | (bs[(index + 2)] & 0xFF) << 40 | + (bs[(index + 3)] & 0xFF) << 32 | (bs[(index + 4)] & 0xFF) << 24 | (bs[(index + 5)] & 0xFF) << 16 | + (bs[(index + 6)] & 0xFF) << 8 | (bs[(index + 7)] & 0xFF) << 0; + } + + public static String format(Number n, String format) { + DecimalFormat df = new DecimalFormat(format); + return df.format(n); + } + public static Double formatNumber(Number n, String format) { + return Double.valueOf(format(n,format)); + } + public static Double formatNumber(Number n) { + String format = "0.00"; + return Double.valueOf(format(n,format)); + } + + public static ArrayList getBinaryList(int num) { + ArrayList list = new ArrayList(); + String binStr = Integer.toBinaryString(num); + for (int i = 0; i < binStr.length(); i++) { + if (binStr.charAt(i) == '1') { + int intpow = (int)Math.pow(2.0D, binStr.length() - i - 1); + list.add(Integer.valueOf(intpow)); + } + } + return list; + } + + + public static BigDecimal getBigDecimal(Object number) { + if (number == null) { + return null; + } + if ((number instanceof BigDecimal)) + return (BigDecimal)number; + if (((number instanceof Double)) || ((number instanceof Float))) + return new BigDecimal(number.toString()); + if ((number instanceof Integer)) + return new BigDecimal(((Integer)number).intValue()); + if ((number instanceof Long)) { + return new BigDecimal(((Long)number).longValue()); + } + return new BigDecimal(number.toString()); + } + + public static Number div(Number a, Number b) { + return getBigDecimal(a).divide(getBigDecimal(b), DEFAULT_SCALE, DEFAULT_ROUNDINGMODE); + } + + public static Number div(Number a, Number b, int scale) { + return getBigDecimal(a).divide(getBigDecimal(b), scale, DEFAULT_ROUNDINGMODE); + } + + public static Number sum(Number a, Number b) { + return getBigDecimal(a).add(getBigDecimal(b)); + } + + public static Number sub(Number a, Number b) { + return getBigDecimal(a).subtract(getBigDecimal(b)); + } + + public static Number mul(Number a, Number b) { + return getBigDecimal(a).multiply(getBigDecimal(b)); + } + + public static boolean equal(Number a, Number b) { + if (((a instanceof Float)) || ((b instanceof Float)) || ((a instanceof Double)) || ((b instanceof Double))) { + return Math.abs(a.floatValue() - b.floatValue()) < 1.0E-006D; + } + return a.equals(b); + } + + /** + * 判断key在数组arr中是否存在 + * @param arr 数组 + * @param key 待查找值 + * @return key在数组arr中是否存在,true:存在,false:不存在 + */ + public static boolean exist(Long[] arr, long key) { + for(int i=0; i + * 前端控制器 + *

+ * + * @author hongawen + * @since 2024-04-17 + */ +@Slf4j +@RestController +@RequestMapping("/sgHarmonic") +@Api(tags = "暂降治理评估控制器") +@RequiredArgsConstructor +public class SgHarmonicFileController extends BaseController { + + private final FileStorageUtil fileStorageUtil; + private final ISgHarmonicFileService harmonicFileService; + + @PostMapping(value = "/importHarmonicData") + @ApiOperation("上传谐波数据文件") + @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD) + public HttpResult importHarmonicData(@RequestParam("file") MultipartFile file, @RequestParam("name") String name) { + String methodDescribe = getMethodDescribe("importHarmonicData"); + String filePath = fileStorageUtil.uploadMultipart(file, OssPath.GOVERN_HARMONIC_FILE); + SgHarmonicFile sgHarmonicFile = new SgHarmonicFile(); + sgHarmonicFile.setDataName(name); + sgHarmonicFile.setDataPath(filePath); + sgHarmonicFile.setState(DataStateEnum.ENABLE.getCode()); + harmonicFileService.save(sgHarmonicFile); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); + } + + + @PostMapping(value = "/listHarmonicData") + @ApiOperation("获取谐波数据数据") + @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.QUERY) + public HttpResult> listHarmonicData() { + String methodDescribe = getMethodDescribe("listHarmonicData"); + LambdaQueryWrapper sgHarmonicFileLambdaQueryWrapper = new LambdaQueryWrapper<>(); + sgHarmonicFileLambdaQueryWrapper.eq(SgHarmonicFile::getState,DataStateEnum.ENABLE.getCode()); + List files = harmonicFileService.list(sgHarmonicFileLambdaQueryWrapper); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, files, methodDescribe); + } + +} + diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/controller/govern/voltage/SagGovernSchemeController.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/controller/govern/voltage/SagGovernSchemeController.java new file mode 100644 index 000000000..72b4dd7c9 --- /dev/null +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/controller/govern/voltage/SagGovernSchemeController.java @@ -0,0 +1,93 @@ +package com.njcn.advance.controller.govern.voltage; + + +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.njcn.advance.pojo.param.govern.voltage.SgGovernSchemeHistoryParam; +import com.njcn.advance.pojo.param.govern.voltage.SgUserParam; +import com.njcn.advance.pojo.vo.govern.voltage.SgGovernSchemeHistoryAllVO; +import com.njcn.advance.pojo.vo.govern.voltage.SgGovernSchemeHistoryVO; +import com.njcn.advance.pojo.vo.govern.voltage.SgUserVO; +import com.njcn.advance.service.govern.voltage.IGovernSchemeCalcService; +import com.njcn.advance.service.govern.voltage.ISgGovernSchemeHistoryService; +import com.njcn.common.pojo.annotation.OperateInfo; +import com.njcn.common.pojo.constant.OperateType; +import com.njcn.common.pojo.enums.common.LogEnum; +import com.njcn.common.pojo.enums.response.CommonResponseEnum; +import com.njcn.common.pojo.response.HttpResult; +import com.njcn.common.utils.HttpResultUtil; +import com.njcn.common.utils.LogUtil; +import com.njcn.web.controller.BaseController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@Slf4j +@Validated +@RestController +@Api(tags = "暂降治理评估控制器") +@RequestMapping("/sagGovernScheme") +@RequiredArgsConstructor +public class SagGovernSchemeController extends BaseController { + + private final IGovernSchemeCalcService governSchemeCalcService; + + private final ISgGovernSchemeHistoryService sgGovernSchemeHistoryService; + + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/calc") + @ApiOperation("根据治理参数,进行暂降治理评估") + @ApiImplicitParam(name = "sgGovernSchemeHistoryParam", value = "计算参数", required = true) + public HttpResult calc(@RequestBody SgGovernSchemeHistoryParam sgGovernSchemeHistoryParam ) { + String methodDescribe = getMethodDescribe("calc"); + LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, sgGovernSchemeHistoryParam); + SgGovernSchemeHistoryAllVO sgGovernSchemeHistoryAllVO = governSchemeCalcService.calc(sgGovernSchemeHistoryParam); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, sgGovernSchemeHistoryAllVO, methodDescribe); + } + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/list") + @ApiOperation("查询历史治理方案") + @ApiImplicitParam(name = "SgSchemeHistoryQueryParam", value = "查询参数", required = true) + public HttpResult> list(@RequestBody SgGovernSchemeHistoryParam.SgSchemeHistoryQueryParam sgSchemeHistoryQueryParam) { + String methodDescribe = getMethodDescribe("list"); + LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, sgSchemeHistoryQueryParam); + Page result = sgGovernSchemeHistoryService.schemeHistoryList(sgSchemeHistoryQueryParam); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); + } + + + @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE) + @PostMapping("/delete") + @ApiOperation("删除治理方案") + @ApiImplicitParam(name = "ids", value = "治理方案索引", required = true, dataTypeClass = List.class) + public HttpResult delete(@RequestBody List ids) { + String methodDescribe = getMethodDescribe("delete"); + LogUtil.njcnDebug(log, "{},业务用户ID数据为:{}", methodDescribe, String.join(StrUtil.COMMA, ids)); + boolean result = sgGovernSchemeHistoryService.deleteScheme(ids); + if (result) { + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); + } else { + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe); + } + } + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @GetMapping("/detail") + @ApiOperation("根据治理方案索引,查询详细数据回显") + public HttpResult detail(String id) { + String methodDescribe = getMethodDescribe("detail"); + LogUtil.njcnDebug(log, "{},治理方案索引为:{}", methodDescribe, id); + SgGovernSchemeHistoryAllVO sgGovernSchemeHistoryAllVO = governSchemeCalcService.detail(id); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, sgGovernSchemeHistoryAllVO, methodDescribe); + } + + +} diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/controller/govern/voltage/SgEventController.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/controller/govern/voltage/SgEventController.java index 6e5ceceea..d51eb2dab 100644 --- a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/controller/govern/voltage/SgEventController.java +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/controller/govern/voltage/SgEventController.java @@ -1,34 +1,43 @@ package com.njcn.advance.controller.govern.voltage; +import cn.afterturn.easypoi.excel.ExcelImportUtil; +import cn.afterturn.easypoi.excel.entity.ImportParams; +import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; +import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.njcn.advance.enums.AdvanceResponseEnum; +import com.njcn.advance.pojo.dto.govern.voltage.SgEventExcel; import com.njcn.advance.pojo.param.govern.voltage.SgEventParam; -import com.njcn.advance.pojo.param.govern.voltage.SgUserParam; import com.njcn.advance.pojo.vo.govern.voltage.SgEventVO; -import com.njcn.advance.pojo.vo.govern.voltage.SgUserVO; +import com.njcn.advance.pojo.vo.govern.voltage.TransientEventCountVO; import com.njcn.advance.service.govern.voltage.ISgEventService; import com.njcn.common.pojo.annotation.OperateInfo; +import com.njcn.common.pojo.constant.OperateType; import com.njcn.common.pojo.enums.common.LogEnum; import com.njcn.common.pojo.enums.response.CommonResponseEnum; +import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.utils.HttpResultUtil; import com.njcn.common.utils.LogUtil; +import com.njcn.poi.util.PoiUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.*; -import org.springframework.web.bind.annotation.RestController; import com.njcn.web.controller.BaseController; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; /** *

- * 前端控制器 + * 前端控制器 *

* * @author hongawen @@ -38,7 +47,7 @@ import com.njcn.web.controller.BaseController; @Validated @RestController @Api(tags = "暂降治理暂降数据控制器") -@RequestMapping("/voltage/sgEvent") +@RequestMapping("/sgEvent") @RequiredArgsConstructor public class SgEventController extends BaseController { @@ -55,9 +64,97 @@ public class SgEventController extends BaseController { return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); } + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/getEventDataByProductLineId") + @ApiOperation("查询生产线下时间范围内的暂降数据") + @ApiImplicitParam(name = "sgEventParamQueryParam", value = "查询参数", required = true) + public HttpResult> getEventDataByProductLineId(@RequestBody SgEventParam.SgEventParamQueryParam sgEventParamQueryParam) { + String methodDescribe = getMethodDescribe("getEventDataByProductLineId"); + LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, sgEventParamQueryParam); + List result = sgEventService.getEventDataByProductLineId(sgEventParamQueryParam); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); + } + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @GetMapping("/downloadTemplate") + @ApiOperation("下载暂降事件模板") + public void downloadTemplate() { + sgEventService.downloadTemplate(); + } + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/exportEventData") + @ApiOperation("导出暂降数据") + @ApiImplicitParam(name = "sgEventParamQueryParam", value = "查询参数", required = true) + public void exportEventData(@RequestBody SgEventParam.SgEventParamQueryParam sgEventParamQueryParam) { + sgEventService.exportEventData(sgEventParamQueryParam); + } + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/3DList") + @ApiOperation("获取3d数据") + @ApiImplicitParam(name = "sgEventParamQueryParam", value = "查询参数", required = true) + public HttpResult threeDList(@RequestBody SgEventParam.SgEventParamQueryParam sgEventParamQueryParam) { + String methodDescribe = getMethodDescribe("threeDList"); + TransientEventCountVO result = sgEventService.threeDList(sgEventParamQueryParam); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); + } + + + @PostMapping(value = "/importEventData") + @ApiOperation("批量导入暂降数据") + @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD) + public HttpResult importEventData(@RequestParam("file") MultipartFile file, @RequestParam("incomingLineId") String incomingLineId, @RequestParam("productLineId") String productLineId,HttpServletResponse response) { + String methodDescribe = getMethodDescribe("importEventData"); + ImportParams params = new ImportParams(); + params.setHeadRows(1); + params.setNeedVerify(true); + params.setStartSheetIndex(0); + params.setSheetNum(1); + try { + ExcelImportResult sgEventExcelExcelImportResult = ExcelImportUtil.importExcelMore(file.getInputStream(), SgEventExcel.class, params); + //如果存在非法数据,将不合格的数据导出 + if (sgEventExcelExcelImportResult.isVerifyFail()) { +// PoiUtil.exportFileByWorkbook(sgEventExcelExcelImportResult.getFailWorkbook(), "非法暂降数据.xlsx", response); + throw new BusinessException(AdvanceResponseEnum.IMPORT_EVENT_DATA_FAIL); + } else { + //批量录入暂降数据 + List sgEventExcels = sgEventExcelExcelImportResult.getList(); + sgEventService.importEventData(sgEventExcels, incomingLineId,productLineId); + } + } catch (Exception e) { + throw new BusinessException(AdvanceResponseEnum.IMPORT_EVENT_DATA_FAIL); + } + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); + } + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @GetMapping("/calcLoss") + @ApiOperation("计算暂降损失") + public HttpResult calcLoss(String id) { + String methodDescribe = getMethodDescribe("calcLoss"); + LogUtil.njcnDebug(log, "{},暂降事件ID数据为:{}", methodDescribe, id); + sgEventService.calcLoss(id); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); + } + + + @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE) + @PostMapping("/delete") + @ApiOperation("删除暂降事件") + @ApiImplicitParam(name = "ids", value = "暂降事件索引", required = true, dataTypeClass = List.class) + public HttpResult delete(@RequestBody List ids) { + String methodDescribe = getMethodDescribe("delete"); + LogUtil.njcnDebug(log, "{},暂降事件ID数据为:{}", methodDescribe, String.join(StrUtil.COMMA, ids)); + boolean result = sgEventService.deleteEventData(ids); + if (result) { + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); + } else { + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe); + } + } } diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/controller/govern/voltage/SgIncomingLineController.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/controller/govern/voltage/SgIncomingLineController.java index 339937d12..491acf149 100644 --- a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/controller/govern/voltage/SgIncomingLineController.java +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/controller/govern/voltage/SgIncomingLineController.java @@ -4,6 +4,7 @@ package com.njcn.advance.controller.govern.voltage; import cn.hutool.core.util.StrUtil; import com.njcn.advance.pojo.param.govern.voltage.IncomingLineParam; import com.njcn.advance.pojo.vo.govern.voltage.IncomingLineVO; +import com.njcn.advance.pojo.vo.govern.voltage.SgOption; import com.njcn.advance.service.govern.voltage.ISgIncomingLineService; import com.njcn.common.pojo.annotation.OperateInfo; import com.njcn.common.pojo.constant.OperateType; @@ -52,6 +53,16 @@ public class SgIncomingLineController extends BaseController { return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); } + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @GetMapping("/lineList") + @ApiOperation("查询监测点数据") + public HttpResult> lineList( ) { + String methodDescribe = getMethodDescribe("lineList"); + LogUtil.njcnDebug(log, "{}", methodDescribe); + List result = sgIncomingLineService.lineList(); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); + } + @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD) @PostMapping("/add") diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/controller/govern/voltage/SgMachineController.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/controller/govern/voltage/SgMachineController.java index 65ad76d2b..831428f61 100644 --- a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/controller/govern/voltage/SgMachineController.java +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/controller/govern/voltage/SgMachineController.java @@ -5,6 +5,7 @@ import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.njcn.advance.pojo.param.govern.voltage.SgMachineParam; import com.njcn.advance.pojo.vo.govern.voltage.SgMachineVO; +import com.njcn.advance.pojo.vo.govern.voltage.SgProductLineVO; import com.njcn.advance.service.govern.voltage.ISgMachineService; import com.njcn.common.pojo.annotation.OperateInfo; import com.njcn.common.pojo.constant.OperateType; @@ -19,11 +20,8 @@ import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.*; -import org.springframework.web.bind.annotation.RestController; import com.njcn.web.controller.BaseController; import java.util.List; @@ -58,6 +56,17 @@ public class SgMachineController extends BaseController { return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); } + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @GetMapping("/querySgMachineByProductLineId") + @ApiOperation("根据生产线id查询所有的设备信息") + @ApiImplicitParam(name = "productId", value = "生产线Id", required = true) + public HttpResult> querySgMachineByProductLineId(String productId) { + String methodDescribe = getMethodDescribe("querySgMachineByProductLineId"); + LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, productId); + List result = sgMachineService.listAllMachineByProductLineId(productId); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); + } + @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD) @PostMapping("/add") diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/controller/govern/voltage/SgProductLineController.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/controller/govern/voltage/SgProductLineController.java index 727e56f57..dd627677e 100644 --- a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/controller/govern/voltage/SgProductLineController.java +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/controller/govern/voltage/SgProductLineController.java @@ -60,10 +60,10 @@ public class SgProductLineController extends BaseController { @GetMapping("/querySgProductLineByUserId") @ApiOperation("根据用户id查询所有的生产线信息") @ApiImplicitParam(name = "userId", value = "用户id", required = true) - public HttpResult> querySgProductLineByUserId(String userId) { + public HttpResult> querySgProductLineByUserId(String userId) { String methodDescribe = getMethodDescribe("querySgProductLineByUserId"); LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, userId); - List result = sgProductLineService.querySgProductLineByUserId(userId); + List result = sgProductLineService.querySgProductLineByUserId(userId); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); } diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/controller/govern/voltage/SgSensitiveUnitController.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/controller/govern/voltage/SgSensitiveUnitController.java index c16ab1985..852da3f7e 100644 --- a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/controller/govern/voltage/SgSensitiveUnitController.java +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/controller/govern/voltage/SgSensitiveUnitController.java @@ -4,6 +4,7 @@ package com.njcn.advance.controller.govern.voltage; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.njcn.advance.pojo.param.govern.voltage.SgSensitiveUnitParam; +import com.njcn.advance.pojo.vo.govern.voltage.SgMachineVO; import com.njcn.advance.pojo.vo.govern.voltage.SgSensitiveUnitVO; import com.njcn.advance.service.govern.voltage.ISgSensitiveUnitService; import com.njcn.common.pojo.annotation.OperateInfo; @@ -19,11 +20,8 @@ import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.*; -import org.springframework.web.bind.annotation.RestController; import com.njcn.web.controller.BaseController; import java.util.List; @@ -58,6 +56,18 @@ public class SgSensitiveUnitController extends BaseController { } + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @GetMapping("/queryUnitByMachineId") + @ApiOperation("根据设备id查询所有的元器件信息") + @ApiImplicitParam(name = "machineId", value = "设备id", required = true) + public HttpResult> queryUnitByMachineId(String machineId) { + String methodDescribe = getMethodDescribe("queryUnitByMachineId"); + LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, machineId); + List result = sgSensitiveUnitService.listAllUnitByMachineId(machineId); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); + } + + @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD) @PostMapping("/add") @ApiOperation("新增元器件") @@ -74,6 +84,8 @@ public class SgSensitiveUnitController extends BaseController { } + + @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD) @PostMapping("/update") @ApiOperation("更新元器件") diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/controller/govern/voltage/SgUserController.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/controller/govern/voltage/SgUserController.java index 64c7a006a..4d396b07d 100644 --- a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/controller/govern/voltage/SgUserController.java +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/controller/govern/voltage/SgUserController.java @@ -4,6 +4,7 @@ package com.njcn.advance.controller.govern.voltage; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.njcn.advance.pojo.param.govern.voltage.SgUserParam; +import com.njcn.advance.pojo.po.govern.voltage.SgUser; import com.njcn.advance.pojo.vo.govern.voltage.SgUserVO; import com.njcn.advance.service.govern.voltage.ISgUserService; import com.njcn.common.pojo.annotation.OperateInfo; @@ -19,11 +20,8 @@ import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.*; -import org.springframework.web.bind.annotation.RestController; import com.njcn.web.controller.BaseController; import java.util.List; @@ -58,6 +56,18 @@ public class SgUserController extends BaseController { } + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @GetMapping("/sgUserList") + @ApiOperation("查询所有的用户数据") + public HttpResult> sgUserList() { + String methodDescribe = getMethodDescribe("list"); + LogUtil.njcnDebug(log, "{},查询所有的用户数据", methodDescribe); + List result = sgUserService.sgUserAllList(); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); + } + + + @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD) @PostMapping("/add") @ApiOperation("新增业务用户") diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/harmonic/SgHarmonicFileMapper.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/harmonic/SgHarmonicFileMapper.java new file mode 100644 index 000000000..2c50bcdcf --- /dev/null +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/harmonic/SgHarmonicFileMapper.java @@ -0,0 +1,16 @@ +package com.njcn.advance.mapper.govern.harmonic; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.njcn.advance.pojo.po.govern.harmonic.SgHarmonicFile; + +/** + *

+ * Mapper 接口 + *

+ * + * @author hongawen + * @since 2024-04-17 + */ +public interface SgHarmonicFileMapper extends BaseMapper { + +} diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/harmonic/mapping/SgHarmonicFileMapper.xml b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/harmonic/mapping/SgHarmonicFileMapper.xml new file mode 100644 index 000000000..5add8acef --- /dev/null +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/harmonic/mapping/SgHarmonicFileMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/SgEventMapper.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/SgEventMapper.java index 842d66bf0..7db7eca75 100644 --- a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/SgEventMapper.java +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/SgEventMapper.java @@ -1,16 +1,27 @@ package com.njcn.advance.mapper.govern.voltage; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.njcn.advance.pojo.po.govern.voltage.SgEvent; +import com.njcn.advance.pojo.vo.govern.voltage.SgEventVO; +import org.apache.ibatis.annotations.Param; + +import java.time.LocalDateTime; +import java.util.List; /** *

- * Mapper 接口 + * Mapper 接口 *

* * @author hongawen * @since 2024-02-29 */ public interface SgEventMapper extends BaseMapper { + Page page(@Param("page") Page objectPage, @Param("ew") QueryWrapper sgEventVOQueryWrapper); + List getAllEventData(@Param("incomingList") List incomingLineIdList, @Param("beginDate") LocalDateTime beginDate, @Param("endDate") LocalDateTime endDate); + + List getEventDataByProductLineId(@Param("productId") String productId, @Param("beginDate") LocalDateTime beginDate, @Param("endDate") LocalDateTime endDate); } diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/SgGovernSchemeHistoryDetailMapper.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/SgGovernSchemeHistoryDetailMapper.java new file mode 100644 index 000000000..400db76a4 --- /dev/null +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/SgGovernSchemeHistoryDetailMapper.java @@ -0,0 +1,16 @@ +package com.njcn.advance.mapper.govern.voltage; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.njcn.advance.pojo.po.govern.voltage.SgGovernSchemeHistoryDetail; + +/** + *

+ * Mapper 接口 + *

+ * + * @author hongawen + * @since 2024-03-27 + */ +public interface SgGovernSchemeHistoryDetailMapper extends BaseMapper { + +} diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/SgGovernSchemeHistoryMapper.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/SgGovernSchemeHistoryMapper.java new file mode 100644 index 000000000..5bfe58043 --- /dev/null +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/SgGovernSchemeHistoryMapper.java @@ -0,0 +1,21 @@ +package com.njcn.advance.mapper.govern.voltage; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.njcn.advance.pojo.po.govern.voltage.SgGovernSchemeHistory; +import com.njcn.advance.pojo.vo.govern.voltage.SgGovernSchemeHistoryVO; +import org.apache.ibatis.annotations.Param; + +/** + *

+ * Mapper 接口 + *

+ * + * @author hongawen + * @since 2024-03-27 + */ +public interface SgGovernSchemeHistoryMapper extends BaseMapper { + + Page page(@Param("page") Page objectPage, @Param("ew") QueryWrapper queryWrapper); +} diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/SgGovernSchemeParamMapper.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/SgGovernSchemeParamMapper.java new file mode 100644 index 000000000..699c75a8f --- /dev/null +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/SgGovernSchemeParamMapper.java @@ -0,0 +1,16 @@ +package com.njcn.advance.mapper.govern.voltage; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.njcn.advance.pojo.po.govern.voltage.SgGovernSchemeParam; + +/** + *

+ * Mapper 接口 + *

+ * + * @author hongawen + * @since 2024-03-27 + */ +public interface SgGovernSchemeParamMapper extends BaseMapper { + +} diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/SgIncomingLineMapper.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/SgIncomingLineMapper.java index ac1c0739d..a52a935f5 100644 --- a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/SgIncomingLineMapper.java +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/SgIncomingLineMapper.java @@ -3,6 +3,7 @@ package com.njcn.advance.mapper.govern.voltage; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.njcn.advance.pojo.po.govern.voltage.SgIncomingLine; import com.njcn.advance.pojo.vo.govern.voltage.IncomingLineVO; +import com.njcn.advance.pojo.vo.govern.voltage.SgOption; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -18,4 +19,6 @@ import java.util.List; public interface SgIncomingLineMapper extends BaseMapper { List queryLineByUserId(@Param("userId")String userId); + + List lineList(); } diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/SgMachineMapper.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/SgMachineMapper.java index a03f3c2e2..a25877d47 100644 --- a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/SgMachineMapper.java +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/SgMachineMapper.java @@ -7,6 +7,8 @@ import com.njcn.advance.pojo.po.govern.voltage.SgMachine; import com.njcn.advance.pojo.vo.govern.voltage.SgMachineVO; import org.apache.ibatis.annotations.Param; +import java.util.List; + /** *

* Mapper 接口 @@ -18,4 +20,6 @@ import org.apache.ibatis.annotations.Param; public interface SgMachineMapper extends BaseMapper { Page page(@Param("page") Page objectPage, @Param("ew") QueryWrapper queryWrapper); + + List listAllMachineByProductLineId(@Param("productLineId")String productLineId); } diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/SgProductLineMapper.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/SgProductLineMapper.java index dba3938ed..0432aa135 100644 --- a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/SgProductLineMapper.java +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/SgProductLineMapper.java @@ -7,6 +7,8 @@ import com.njcn.advance.pojo.po.govern.voltage.SgProductLine; import com.njcn.advance.pojo.vo.govern.voltage.SgProductLineVO; import org.apache.ibatis.annotations.Param; +import java.util.List; + /** *

* Mapper 接口 @@ -20,4 +22,7 @@ public interface SgProductLineMapper extends BaseMapper { Page page(@Param("page")Page objectPage, @Param("ew") QueryWrapper queryWrapper); + List querySgProductLineByUserId(@Param("ew") QueryWrapper sgProductLineVOQueryWrapper); + + String getUserNameByProductId(@Param("productId")String id); } diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/SgSensitiveUnitMapper.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/SgSensitiveUnitMapper.java index 3140eb43b..93eed180f 100644 --- a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/SgSensitiveUnitMapper.java +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/SgSensitiveUnitMapper.java @@ -7,6 +7,8 @@ import com.njcn.advance.pojo.po.govern.voltage.SgSensitiveUnit; import com.njcn.advance.pojo.vo.govern.voltage.SgSensitiveUnitVO; import org.apache.ibatis.annotations.Param; +import java.util.List; + /** *

* Mapper 接口 @@ -18,4 +20,6 @@ import org.apache.ibatis.annotations.Param; public interface SgSensitiveUnitMapper extends BaseMapper { Page page(@Param("page") Page objectPage, @Param("ew")QueryWrapper queryWrapper); + + List listAllUnitByMachineId(@Param("machineId")String machineId); } diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/mapping/SgEventMapper.xml b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/mapping/SgEventMapper.xml index c2260504c..8b5b675e7 100644 --- a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/mapping/SgEventMapper.xml +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/mapping/SgEventMapper.xml @@ -2,4 +2,44 @@ + + + + + + + + + + + + diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/mapping/SgGovernSchemeHistoryDetailMapper.xml b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/mapping/SgGovernSchemeHistoryDetailMapper.xml new file mode 100644 index 000000000..fcac2f0c8 --- /dev/null +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/mapping/SgGovernSchemeHistoryDetailMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/mapping/SgGovernSchemeHistoryMapper.xml b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/mapping/SgGovernSchemeHistoryMapper.xml new file mode 100644 index 000000000..94ebf4559 --- /dev/null +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/mapping/SgGovernSchemeHistoryMapper.xml @@ -0,0 +1,27 @@ + + + + + + + + diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/mapping/SgGovernSchemeParamMapper.xml b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/mapping/SgGovernSchemeParamMapper.xml new file mode 100644 index 000000000..43915037f --- /dev/null +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/mapping/SgGovernSchemeParamMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/mapping/SgIncomingLineMapper.xml b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/mapping/SgIncomingLineMapper.xml index 5ed900331..1bd6ef43a 100644 --- a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/mapping/SgIncomingLineMapper.xml +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/mapping/SgIncomingLineMapper.xml @@ -16,4 +16,14 @@ ORDER BY sg_incoming_line.create_time desc + + diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/mapping/SgMachineMapper.xml b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/mapping/SgMachineMapper.xml index 2b9eb3c0d..bcf48bedb 100644 --- a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/mapping/SgMachineMapper.xml +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/mapping/SgMachineMapper.xml @@ -9,4 +9,12 @@ WHERE ${ew.sqlSegment} + + + diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/mapping/SgProductLineMapper.xml b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/mapping/SgProductLineMapper.xml index e03cfb7d2..5bfc52486 100644 --- a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/mapping/SgProductLineMapper.xml +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/mapping/SgProductLineMapper.xml @@ -17,5 +17,31 @@ AND ${ew.sqlSegment} + + + + + + + + diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/mapping/SgSensitiveUnitMapper.xml b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/mapping/SgSensitiveUnitMapper.xml index fc92fda15..29e6702bc 100644 --- a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/mapping/SgSensitiveUnitMapper.xml +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/mapper/govern/voltage/mapping/SgSensitiveUnitMapper.xml @@ -7,4 +7,12 @@ FROM sg_sensitive_unit sg_sensitive_unit WHERE ${ew.sqlSegment} + + + diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/harmonic/ISgHarmonicFileService.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/harmonic/ISgHarmonicFileService.java new file mode 100644 index 000000000..abbc88216 --- /dev/null +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/harmonic/ISgHarmonicFileService.java @@ -0,0 +1,16 @@ +package com.njcn.advance.service.govern.harmonic; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.njcn.advance.pojo.po.govern.harmonic.SgHarmonicFile; + +/** + *

+ * 服务类 + *

+ * + * @author hongawen + * @since 2024-04-17 + */ +public interface ISgHarmonicFileService extends IService { + +} diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/harmonic/impl/SgHarmonicFileServiceImpl.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/harmonic/impl/SgHarmonicFileServiceImpl.java new file mode 100644 index 000000000..5d14fb896 --- /dev/null +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/harmonic/impl/SgHarmonicFileServiceImpl.java @@ -0,0 +1,20 @@ +package com.njcn.advance.service.govern.harmonic.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.njcn.advance.mapper.govern.harmonic.SgHarmonicFileMapper; +import com.njcn.advance.pojo.po.govern.harmonic.SgHarmonicFile; +import com.njcn.advance.service.govern.harmonic.ISgHarmonicFileService; +import org.springframework.stereotype.Service; + +/** + *

+ * 服务实现类 + *

+ * + * @author hongawen + * @since 2024-04-17 + */ +@Service +public class SgHarmonicFileServiceImpl extends ServiceImpl implements ISgHarmonicFileService { + +} diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/IGovernSchemeCalcService.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/IGovernSchemeCalcService.java new file mode 100644 index 000000000..3c4344d90 --- /dev/null +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/IGovernSchemeCalcService.java @@ -0,0 +1,13 @@ +package com.njcn.advance.service.govern.voltage; + +import com.njcn.advance.pojo.dto.govern.voltage.ProductLineComputeData; +import com.njcn.advance.pojo.param.govern.voltage.SgGovernSchemeHistoryParam; +import com.njcn.advance.pojo.vo.govern.voltage.SgGovernSchemeHistoryAllVO; + +public interface IGovernSchemeCalcService { + SgGovernSchemeHistoryAllVO calc(SgGovernSchemeHistoryParam sgGovernSchemeHistoryParam); + + SgGovernSchemeHistoryAllVO detail(String id); + + +} diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/ISgEventService.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/ISgEventService.java index fe15805d6..b4752e4fd 100644 --- a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/ISgEventService.java +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/ISgEventService.java @@ -2,13 +2,19 @@ package com.njcn.advance.service.govern.voltage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; +import com.njcn.advance.pojo.dto.govern.voltage.ProductLineComputeData; +import com.njcn.advance.pojo.dto.govern.voltage.SgEventExcel; import com.njcn.advance.pojo.param.govern.voltage.SgEventParam; import com.njcn.advance.pojo.po.govern.voltage.SgEvent; import com.njcn.advance.pojo.vo.govern.voltage.SgEventVO; +import com.njcn.advance.pojo.vo.govern.voltage.TransientEventCountVO; + +import java.util.List; +import java.util.Map; /** *

- * 服务类 + * 服务类 *

* * @author hongawen @@ -17,4 +23,28 @@ import com.njcn.advance.pojo.vo.govern.voltage.SgEventVO; public interface ISgEventService extends IService { Page sgEventList(SgEventParam.SgEventParamQueryParam sgEventParamQueryParam); + + void downloadTemplate(); + + void exportEventData(SgEventParam.SgEventParamQueryParam sgEventParamQueryParam); + + void importEventData(List sgEventExcels, String incomingLineId,String productLineId); + + List getEventData(String id, String startTime, String endTime); + + Map getEventMap(String id, String startTime, String endTime); + + Map countEventMap4Switch(Map eventMap, String id, String incomingLineId, String startTime, String endTime, Double actionTime); + + List countEvent4Switch(List sgEventList, String id, String incomingLineId, String startTime, String endTime, Double actionTime); + + boolean deleteEventData(List ids); + + TransientEventCountVO threeDList(SgEventParam.SgEventParamQueryParam sgEventParamQueryParam); + + void calcLoss(String id); + + Double[] getEventLossAndFailureRate(ProductLineComputeData productLineComputeData, double amplitude, double durationTime); + + List getEventDataByProductLineId(SgEventParam.SgEventParamQueryParam sgEventParamQueryParam); } diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/ISgGovernSchemeHistoryDetailService.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/ISgGovernSchemeHistoryDetailService.java new file mode 100644 index 000000000..862958a73 --- /dev/null +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/ISgGovernSchemeHistoryDetailService.java @@ -0,0 +1,16 @@ +package com.njcn.advance.service.govern.voltage; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.njcn.advance.pojo.po.govern.voltage.SgGovernSchemeHistoryDetail; + +/** + *

+ * 服务类 + *

+ * + * @author hongawen + * @since 2024-03-27 + */ +public interface ISgGovernSchemeHistoryDetailService extends IService { + +} diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/ISgGovernSchemeHistoryService.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/ISgGovernSchemeHistoryService.java new file mode 100644 index 000000000..e2249afaa --- /dev/null +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/ISgGovernSchemeHistoryService.java @@ -0,0 +1,24 @@ +package com.njcn.advance.service.govern.voltage; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.njcn.advance.pojo.param.govern.voltage.SgGovernSchemeHistoryParam; +import com.njcn.advance.pojo.po.govern.voltage.SgGovernSchemeHistory; +import com.njcn.advance.pojo.vo.govern.voltage.SgGovernSchemeHistoryVO; + +import java.util.List; + +/** + *

+ * 服务类 + *

+ * + * @author hongawen + * @since 2024-03-27 + */ +public interface ISgGovernSchemeHistoryService extends IService { + + Page schemeHistoryList(SgGovernSchemeHistoryParam.SgSchemeHistoryQueryParam sgSchemeHistoryQueryParam); + + boolean deleteScheme(List ids); +} diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/ISgGovernSchemeParamService.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/ISgGovernSchemeParamService.java new file mode 100644 index 000000000..50cd285f3 --- /dev/null +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/ISgGovernSchemeParamService.java @@ -0,0 +1,16 @@ +package com.njcn.advance.service.govern.voltage; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.njcn.advance.pojo.po.govern.voltage.SgGovernSchemeParam; + +/** + *

+ * 服务类 + *

+ * + * @author hongawen + * @since 2024-03-27 + */ +public interface ISgGovernSchemeParamService extends IService { + +} diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/ISgIncomingLineService.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/ISgIncomingLineService.java index d158204dc..ca438ee9a 100644 --- a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/ISgIncomingLineService.java +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/ISgIncomingLineService.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.njcn.advance.pojo.param.govern.voltage.IncomingLineParam; import com.njcn.advance.pojo.po.govern.voltage.SgIncomingLine; import com.njcn.advance.pojo.vo.govern.voltage.IncomingLineVO; +import com.njcn.advance.pojo.vo.govern.voltage.SgOption; import java.util.List; @@ -24,4 +25,6 @@ public interface ISgIncomingLineService extends IService { boolean updateIncomingLine(IncomingLineParam.IncomingLineUpdateParam updateParam); boolean deleteIncomingLineData(List ids); + + List lineList(); } diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/ISgMachineService.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/ISgMachineService.java index 359b322f1..88a21e6d4 100644 --- a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/ISgMachineService.java +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/ISgMachineService.java @@ -25,4 +25,7 @@ public interface ISgMachineService extends IService { boolean updateSgMachine(SgMachineParam.SgMachineUpdateParam updateParam); boolean deleteSgMachineData(List ids); + + List listAllMachineByProductLineId(String productLineId); + } diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/ISgProductLineService.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/ISgProductLineService.java index 5144b1006..6686ecb7a 100644 --- a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/ISgProductLineService.java +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/ISgProductLineService.java @@ -2,6 +2,7 @@ package com.njcn.advance.service.govern.voltage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; +import com.njcn.advance.pojo.dto.govern.voltage.ProductLineComputeData; import com.njcn.advance.pojo.param.govern.voltage.SgProductLineParam; import com.njcn.advance.pojo.po.govern.voltage.SgProductLine; import com.njcn.advance.pojo.vo.govern.voltage.SgProductLineVO; @@ -26,5 +27,9 @@ public interface ISgProductLineService extends IService { boolean deleteSgProductData(List ids); - List querySgProductLineByUserId(String userId); + List querySgProductLineByUserId(String userId); + + ProductLineComputeData assginProductLineComputeData(String productLineId); + + String getUserNameByProductId(String id); } diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/ISgSensitiveUnitService.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/ISgSensitiveUnitService.java index bbacc02af..2ba727932 100644 --- a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/ISgSensitiveUnitService.java +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/ISgSensitiveUnitService.java @@ -25,4 +25,7 @@ public interface ISgSensitiveUnitService extends IService { boolean updateSgSensitiveUnit(SgSensitiveUnitParam.SgSensitiveUnitUpdateParam updateParam); boolean deleteSgSensitiveUnitData(List ids); + + List listAllUnitByMachineId(String id); + } diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/ISgUserService.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/ISgUserService.java index 6762df4bf..e057957c6 100644 --- a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/ISgUserService.java +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/ISgUserService.java @@ -25,4 +25,6 @@ public interface ISgUserService extends IService { boolean updateSgUser(SgUserParam.SgUserUpdateParam updateParam); boolean deleteSgUserData(List ids); + + List sgUserAllList(); } diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/component/LossComputeUtil.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/component/LossComputeUtil.java new file mode 100644 index 000000000..8e9f0a0d0 --- /dev/null +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/component/LossComputeUtil.java @@ -0,0 +1,560 @@ +// +//import io.swagger.annotations.ApiModel; +//import io.swagger.annotations.ApiModelProperty; +//import lombok.Getter; +//import lombok.Setter; +// +//import java.io.Serializable; +//import java.util.ArrayList; +//import java.util.List; +// +///** +// * 投资方案相关数据--返回结果 +// * 入参查询对象 +// * +// * @author Robin +// * @date 2020-09-07 +// */ +//@Setter +//@Getter +//@ApiModel("投资方案返回结果") +//public class Scheme2 implements Comparable, Serializable { +// private int minYears = 0; +// private int maxYears = 25; +// +// @ApiModelProperty("治理方案类型") +// String schemeType; +// @ApiModelProperty("治理方案类型名称") +// String schemeTypeName; +// @ApiModelProperty("治理方案描述") +// String schemeDescription; +// // 初始投资额 +// @ApiModelProperty("初始投资额") +// Double schemeEquipment; +// // 每年维护费 +// @ApiModelProperty("每年维护费") +// Double schemeMaintain; +// +// //被选中的设备总功率 +// @ApiModelProperty("被选中的串型设备总功率") +// Double totalPower1 = 0.0; +// @ApiModelProperty("被选中的并型设备总功率") +// Double totalPower2 = 0.0; +// +// //治理设备的尺寸 +// @ApiModelProperty("串型治理设备的尺寸") +// String governDeviceSize1; +// @ApiModelProperty("并型治理设备的尺寸") +// String governDeviceSize2; +// +// //治理设备的功率 +// @ApiModelProperty("串型治理设备的功率") +// Double governDevicePower1; +// @ApiModelProperty("并型治理设备的功率") +// Double governDevicePower2; +// +// //所需治理设备数量 +// @ApiModelProperty("所需串型治理设备数量") +// Integer governDeviceQty1; +// @ApiModelProperty("所需并型治理设备数量") +// Integer governDeviceQty2; +// +// //预期投资回收期 +// @ApiModelProperty("预期投资回收期") +// Double expectPeriod = 0D; +// //实际投资回收期(大略值) +// @ApiModelProperty("实际投资回收期(大略值)") +// Integer practialPeriod = 0; +// //实际投资回收期(精确值) +// @ApiModelProperty("实际投资回收期(精确值)") +// Double practialPeriod2 = 0.0; +// +// //年平均治理效果,用于判断最优投资的标准 +// @ApiModelProperty("年平均治理效果") +// Double grovenResult = 0D; +// +// //雷达图相关数据 +// //治理效果 +// @ApiModelProperty("雷达图治理效果") +// Double radarResult = 0D; +// //投资意愿 +// @ApiModelProperty("雷达图投资意愿") +// Double radarWish = 0D; +// //抗风险能力 +// @ApiModelProperty("雷达图抗风险能力") +// Double radarRisk = 0D; +// //免疫力 +// @ApiModelProperty("雷达图免疫力") +// Double radarRmmunity = 0D; +// //方案优先级指数 +// @ApiModelProperty("雷达图方案优先级指数") +// Double optimizingResult = 0D; +// +// //被治理设备组合 +// @ApiModelProperty("被治理设备组合") +// ActiveDevices activeDevices; +// //被治理设备组合中的串型设备 +// @ApiModelProperty("被治理设备组合中的串型设备") +// List devices1 = new ArrayList(); +// @ApiModelProperty("被治理设备组合中的串型设备名称") +// List deviceNames1 = new ArrayList(); +// //被治理设备组合中的并型设备 +// @ApiModelProperty("被治理设备组合中的并型设备") +// List devices2 = new ArrayList(); +// @ApiModelProperty("被治理设备组合中的并型设备名称") +// List deviceNames2 = new ArrayList(); +// +// //10kV快切开关的进线组合 +// @ApiModelProperty("10kV快切开关的进线组合") +// List inlineCombinationList = new ArrayList(); +// @ApiModelProperty("10kV快切开关的进线组合名称") +// List inlineCombinationListEx = new ArrayList(); +// +// //风险等级(治理前) +// @ApiModelProperty("风险等级(治理前)") +// double riskLevel1 = 2; +// @ApiModelProperty("风险等级名称(治理前)") +// String riskLevelName1 = "二级"; +// //风险等级(治理后) +// @ApiModelProperty("风险等级(治理后)") +// double riskLevel2 = 5; +// @ApiModelProperty("风险等级名称(治理后)") +// String riskLevelName2 = "五级"; +// +// //治理前暂降次数 +// @ApiModelProperty("治理前暂降次数") +// private int eventCount1 = 0; +// //治理前中断次数 +// @ApiModelProperty("治理前中断次数") +// private int offCount1 = 0; +// +// //治理后暂降次数 +// @ApiModelProperty("治理后暂降次数") +// private int eventCount2 = 0; +// //治理后中断次数 +// @ApiModelProperty("治理后中断次数") +// private int offCount2 = 0; +// +// +// //投资 +// @ApiModelProperty("每年投资") +// Double[] tz; +// @ApiModelProperty("每年投资累计") +// Double[] tzTotal; +// //效果 +// @ApiModelProperty("每年治理效果") +// Double[] xg; +// @ApiModelProperty("每年治理效果累计") +// Double[] xgTotal; +// //收益 +// @ApiModelProperty("每年收益") +// Double[] sy; +// @ApiModelProperty("每年收益累计") +// Double[] syTotal; +// //收益率 +// @ApiModelProperty("每年收益率") +// Double[] syRate; +// +// //治理前的最大年损失 +// @ApiModelProperty("治理前的最大年损失") +// double unGovernLossMax = 0; +// //治理前的年平均损失 +// @ApiModelProperty("治理前的年平均损失") +// double unGovernLossAverage = 0; +// //治理后的年平均损失 +// @ApiModelProperty("治理后的年平均损失") +// double governLossAverage = 0; +// +// +//// public Scheme2(){ +//// super(); +//// } +// +// private String getLevelName(double level) { +// String[] levelName = {"一级", "二级", "三级", "四级", "五级"}; +// if (level >= 0 && level < 0.2) { +// return levelName[0]; +// } else if (level >= 0.2 && level < 0.4) { +// return levelName[1]; +// } else if (level >= 0.4 && level < 0.6) { +// return levelName[2]; +// } else if (level >= 0.6 && level < 0.8) { +// return levelName[3]; +// } else if (level >= 0.8 && level <= 1.0) { +// return levelName[4]; +// } +// return "异常了!"; +// } +// +// public Scheme2(int listSize) { +// super(); +// this.minYears = listSize; +// if (listSize > this.maxYears) +// this.maxYears = listSize; +// //投资 +// tz = new Double[this.maxYears]; +// //效果 +// xg = new Double[this.maxYears]; +// //收益 +// sy = new Double[this.maxYears]; +// +// tzTotal = new Double[this.maxYears]; +// xgTotal = new Double[this.maxYears]; +// syTotal = new Double[this.maxYears]; +// +// syRate = new Double[this.maxYears]; +// +// for (int i = 0; i < this.maxYears; i++) { +// tz[i] = 0.0; +// xg[i] = 0.0; +// sy[i] = 0.0; +// tzTotal[i] = 0.0; +// xgTotal[i] = 0.0; +// syTotal[i] = 0.0; +// syRate[i] = 0.0; +// } +// } +// +// +// public void processData(int i, ActiveDevices devices, Double loss) { +// if (ObjectUtil.empty(loss)) { +// loss = 0D; +// } +// this.activeDevices = devices; +// xg[i] += loss; +// } +// +// public void processTZ(Double equipment, Double maintain) { +//// if(equipment==812){ +//// System.out.print(""); +//// } +// this.schemeEquipment = equipment; +// this.schemeMaintain = maintain; +// +// for (int i = 0; i < this.tz.length; i++) { +// if (i == 0) { +// this.tz[i] = equipment; +// this.tzTotal[i] = equipment; +// //this.sy[i] += 0-equipment; +// } else { +// this.tz[i] = maintain; +// this.tzTotal[i] = tzTotal[i - 1] + maintain; +// //this.sy[i] += 0-maintain; +// } +// } +// } +// +// public void processXG(Double value) { +// //总的治理效果,用于排序 +// this.grovenResult = value; +// +// for (int i = 0; i < this.xg.length; i++) { +// this.xg[i] = value; +// if (i == 0) { +// this.xgTotal[i] = value; +// } else { +// this.xgTotal[i] = xgTotal[i - 1] + value; +// } +// } +// } +// +// public void processSY() { +// double small = 0.0, big = 0.0; +// this.practialPeriod = 0; +// //初始收益=0-初始投资 +// this.sy[0] = 0 - this.tz[0]; +// this.syTotal[0] = 0 - this.tz[0]; +// if (this.sy[0] < 0) { +// this.practialPeriod = 1; +// } +// if (ObjectUtil.notEmpty(this.syTotal[0]) && ObjectUtil.notEmpty(this.tzTotal[0])) +// this.syRate[0] = this.syTotal[0] / this.tzTotal[0]; +// +// for (int i = 1; i < this.sy.length; i++) { +// this.sy[i] = this.xg[i] - this.tz[i];// + this.sy[i - 1]; +// this.syTotal[i] = this.syTotal[i - 1] + this.sy[i]; +// if (this.syTotal[i] < 0) { +// this.practialPeriod = this.practialPeriod + 1; +// } else if (NumberUtil.equal(this.syTotal[i], 0.0)) { +// this.practialPeriod2 = this.practialPeriod + 0.0; +// } +// if (this.syTotal[i - 1] < 0 && this.syTotal[i] > 0 && NumberUtil.equal(this.practialPeriod2, 0.0)) { +// this.practialPeriod2 = this.practialPeriod - 1 + Math.abs(this.syTotal[i - 1]) / Math.abs(Math.abs(this.syTotal[i - 1]) + this.syTotal[i]); +// } +// +// // 计算收益率 +// if (!NumberUtil.equal(this.tzTotal[i], 0) && !NumberUtil.equal(this.syTotal[i], 0)) { +// this.syRate[i] = this.syTotal[i] / this.tzTotal[i]; +// } +// } +// +// double last = this.sy[this.sy.length - 1]; +// if (last < 0) { +//// if(!NumberUtil.equal(this.xg[0], 0)) { +//// Number n = NumberUtil.div(Math.abs(last), this.xg[0]); +//// this.practialPeriod = this.practialPeriod + n.intValue() + 1;//可能多一年,不过无所谓 +//// } +// this.practialPeriod = -1; +// } +// } +// +// /** +// * 获得投资总额 +// * +// * @return +// */ +// public Double getTotalTz() { +// if (this.minYears == 0 || this.tzTotal == null || this.tzTotal.length == 0) { +// return 0D; +// } +// return this.tzTotal[this.minYears - 1]; +// } +// +// public void formatData() { +// if (schemeType.equals("A")) { +// schemeTypeName = "串联型补偿设备"; +// } else if (schemeType.equals("B")) { +// schemeTypeName = "并联型补偿设备"; +// } else if (schemeType.equals("AB")) { +// schemeTypeName = "并联+串联"; +// } else if (schemeType.equals("C")) { +// schemeTypeName = "380V快切开关"; +// } else if (schemeType.equals("D")) { +// schemeTypeName = "10kV快切开关"; +// } else { +// schemeTypeName = "无需治理"; +// } +// +// +// this.riskLevel1 = getRadarRisk(this.unGovernLossAverage, 0.9); +//// if(this.riskLevel1>0.8) { +//// this.riskLevel1 = this.riskLevel1 - 0.1; +//// } +// this.riskLevel2 = getRadarRisk(this.governLossAverage, 0.1); +//// if(this.riskLevel2>0.8) { +//// this.riskLevel2 = this.riskLevel2 - 0.1; +//// } +// +// this.riskLevelName1 = getLevelName(1 - this.riskLevel1); +// this.riskLevelName2 = getLevelName(1 - this.riskLevel2); +// +// // 治理效果 +// // this.radarResult = this.xgTotal[minYears-1]; +// if (this.grovenResult == 0D || this.unGovernLossAverage == 0) { +// this.radarResult = 0D; +// } else { +// this.radarResult = this.grovenResult / (Math.ceil(this.unGovernLossAverage / 100D) * 100); +// } +// +// // 去风险能力 +// this.radarRisk = this.riskLevel2 * 0.9; +// // if(this.radarRisk>0.9){this.radarRisk = this.radarRisk * 0.9;} +// +// // 投资意愿=(期望回收期上限—投资回收期)/期望回收期上限 +// if (ObjectUtil.notEmpty(this.expectPeriod) && !NumberUtil.equal(this.expectPeriod, 0)) {// && !NumberUtil.equal(this.expectPeriod,this.practialPeriod) +// this.radarWish = Double.valueOf(NumberUtil.format((this.expectPeriod - this.practialPeriod2) / this.expectPeriod, "0.00")); +// } +// +// // 暂降免疫能力=(治理前暂降次数—治理后中断次数)/治理前暂降次数 +// if (ObjectUtil.notEmpty(this.eventCount1) && !NumberUtil.equal(this.eventCount1, 0)) { +// this.radarRmmunity = Double.valueOf(NumberUtil.format(1.0D * (this.eventCount1 - this.offCount2) / this.eventCount1, "0.00")); +// } +// +// //风险能力 +// Double radarRiskFactor = 0.1070; +// //投资意愿 +// Double radarWishFactor = 0.2538; +// //暂降免疫能力 +// Double radarRmmunityFactor = 0.0443; +// //治理效果 +// Double radarResultFactor = 0.5949; +// +// //方案优先指数 +// this.optimizingResult = this.radarResult * radarResultFactor +// + this.radarWish * radarWishFactor +// + this.radarRisk * radarRiskFactor +// + this.radarRmmunity * radarRmmunityFactor; +// +// for (int i = 0; i < this.maxYears; i++) { +// this.xg[i] = NumberUtil.round(this.xg[i], 2); +// this.xgTotal[i] = NumberUtil.round(this.xgTotal[i], 2); +// this.tz[i] = NumberUtil.round(this.tz[i], 2); +// this.tzTotal[i] = NumberUtil.round(this.tzTotal[i], 2); +// this.sy[i] = NumberUtil.round(this.sy[i], 2); +// this.syTotal[i] = NumberUtil.round(this.syTotal[i], 2); +// if (ObjectUtil.notEmpty(this.syRate[i])) { +// this.syRate[i] = NumberUtil.round(this.syRate[i], 2); +// } +// } +// +// } +// +// +// /** +// * 是不是因为也考虑一下回收年数呢? +// * +// * @param o +// * @return +// */ +// @Override +// public int compareTo(Scheme2 o) { +// +// int rInt = 0; +// // 指数 越大越好 +// rInt = this.optimizingResult.compareTo(o.optimizingResult); +// +//// // 治理后中断次数越小越好 +//// //rInt = Integer.compare(o.offCount2,this.offCount2); +//// +//// // 治理效果越大越好 +//// if(rInt == 0) { +//// Double d = 0D; +//// if (this.grovenResult != null && o.grovenResult != null) { +//// rInt = this.grovenResult.compareTo(o.grovenResult); +//// } else if (this.grovenResult == null && o.grovenResult != null) { +//// rInt = d.compareTo(o.grovenResult); +//// } else if (this.grovenResult != null && o.grovenResult == null) { +//// rInt = this.grovenResult.compareTo(d); +//// } +//// } +//// +//// // 投资周期越小越好 +//// if(rInt == 0){ +//// rInt = o.practialPeriod.compareTo(this.practialPeriod); +//// } +//// +//// // 投资越小越好 +//// if(rInt == 0){ +//// Double tz1 = this.getTotalTz(); +//// Double tz2 = o.getTotalTz(); +//// rInt = tz2.compareTo(tz1); +//// } +// return -1 * rInt; +// } +// +// private Double getRadarRisk(double x, double y) { +// return getN(x, y); +// } +// +// private double getN(double x, double y) { +// double n = 0d; +// double temp = 0d; +// double[] b = getB(x, y); +// +// for (int i = 0; i < a.length; i++) { +// int j = 0; +// for (; j < b.length; j++) { +// temp = temp + Math.abs(a[i][j] - b[j]); +// } +// temp = 1 - temp / j; +// if (temp > n) { +// n = temp; +// } +// } +// return n; +// } +// +// private double[] getB(double x, double y) { +// double[] b = {0, 0, 0, 0, 0}; +// double[] l = getLossDegree(x); +// double[] o2 = getOther3Degree(y); +// double[] o3 = o2; +// double[] o4 = o2; +// for (int i = 0; i < b.length; i++) { +// b[i] = w[0] * l[i] +// + w[1] * o2[i] +// + w[2] * o3[i] +// + w[3] * o4[i]; +// } +// return b; +// } +// +// ; +// +// private static double[] w = {0.565, 0.2622, 0.1175, 0.0553}; +// private static int[][] a = {{1, 0, 0, 0, 0}, {0, 1, 0, 0, 0}, {0, 0, 1, 0, 0}, {0, 0, 0, 1, 0}, {0, 0, 0, 0, 1}}; +// +// private double[] getLossDegree(double x) { +// double[] r = {0, 0, 0, 0, 0}; +// //0A1 +// if (x < 10) { +// r[0] = 1; +// } else if (x >= 10 && x < 25) { +// r[0] = (25 - x) / (25 - 10); +// } +// //1B1 +// if (x >= 5 && x < 20) { +// r[1] = (x - 5) / (20 - 5); +// } else if (x >= 20 && x < 30) { +// r[1] = 1; +// } else if (x >= 30 && x < 45) { +// r[1] = (45 - x) / (45 - 30); +// } +// //2C1 +// if (x >= 25 && x < 40) { +// r[2] = (x - 25) / (40 - 25); +// } else if (x >= 40 && x < 50) { +// r[2] = 1; +// } else if (x >= 50 && x < 65) { +// r[2] = (65 - x) / (65 - 50); +// } +// //3D1 +// if (x >= 45 && x < 60) { +// r[3] = (x - 45) / (60 - 45); +// } else if (x >= 60 && x < 70) { +// r[3] = 1; +// } else if (x >= 70 && x < 85) { +// r[3] = (85 - x) / (85 - 70); +// } +// //4E1 +// if (x >= 65 && x < 80) { +// r[4] = (x - 65) / (80 - 65); +// } else if (x >= 80) { +// r[4] = 1; +// } +// return r; +// } +// +// private double[] getOther3Degree(double y) { +// double[] r = {0, 0, 0, 0, 0}; +// //0A2 +// if (y < 11) { +// r[0] = 1; +// } else if (y >= 1 && y < 2.5) { +// r[0] = (2.5 - y) / (2.5 - 1.0); +// } +// //1B1 +// if (y >= 0.5 && y < 2.0) { +// r[1] = (y - 0.5) / (2.0 - 0.5); +// } else if (y >= 2.0 && y < 3.0) { +// r[1] = 1; +// } else if (y >= 3.0 && y < 4.5) { +// r[1] = (4.5 - y) / (4.5 - 3.0); +// } +// //2C1 +// if (y >= 2.5 && y < 4.0) { +// r[2] = (y - 2.5) / (4.0 - 2.5); +// } else if (y >= 4.0 && y < 5.0) { +// r[2] = 1; +// } else if (y >= 5.0 && y < 6.5) { +// r[2] = (6.5 - y) / (6.5 - 5.0); +// } +// //3D1 +// if (y >= 4.5 && y < 6.0) { +// r[3] = (y - 4.5) / (6.0 - 4.5); +// } else if (y >= 6.0 && y < 7.0) { +// r[3] = 1; +// } else if (y >= 7.0 && y < 8.5) { +// r[3] = (8.5 - y) / (8.5 - 7.0); +// } +// //4E1 +// if (y >= 6.5 && y < 8.0) { +// r[4] = (y - 6.5) / (8.0 - 6.5); +// } else if (y >= 8.0) { +// r[4] = 1; +// } +// return r; +// } +// +// +//} \ No newline at end of file diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/component/temp/file.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/component/temp/file.java new file mode 100644 index 000000000..e69de29bb diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/GovernSchemeCalcServiceImpl.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/GovernSchemeCalcServiceImpl.java new file mode 100644 index 000000000..2dbe756aa --- /dev/null +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/GovernSchemeCalcServiceImpl.java @@ -0,0 +1,775 @@ +package com.njcn.advance.service.govern.voltage.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.date.DatePattern; +import cn.hutool.core.date.LocalDateTimeUtil; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.text.CharPool; +import cn.hutool.core.text.StrPool; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.IdWorker; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.njcn.advance.enums.AdvanceResponseEnum; +import com.njcn.advance.enums.GovernSchemeEnum; +import com.njcn.advance.pojo.dto.govern.voltage.ProductLineComputeData; +import com.njcn.advance.pojo.param.govern.voltage.CommonSchemeParam; +import com.njcn.advance.pojo.param.govern.voltage.QuickSchemeParam; +import com.njcn.advance.pojo.param.govern.voltage.SgGovernSchemeHistoryParam; +import com.njcn.advance.pojo.po.govern.voltage.*; +import com.njcn.advance.pojo.vo.govern.voltage.*; +import com.njcn.advance.service.govern.voltage.*; +import com.njcn.advance.utils.RadarUtil; +import com.njcn.common.pojo.enums.common.DataStateEnum; +import com.njcn.common.pojo.exception.BusinessException; +import com.njcn.common.utils.PubUtils; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import lombok.Setter; +import org.springframework.stereotype.Service; + +import java.time.LocalDate; +import java.util.*; +import java.util.stream.Collectors; + +@Service +@RequiredArgsConstructor +public class GovernSchemeCalcServiceImpl implements IGovernSchemeCalcService { + + private final ISgProductLineService productLineService; + + private final ISgUserService userService; + + private final ISgIncomingLineService incomingLineService; + + private final ISgGovernSchemeParamService sgGovernSchemeParamService; + + private final ISgEventService eventService; + + private final ISgGovernSchemeHistoryDetailService sgGovernSchemeHistoryDetailService; + + private final ISgGovernSchemeHistoryService sgGovernSchemeHistoryService; + + + /** + * 根据前台传递的治理方案的各参数,进行每个治理方案的治理评估 + * + * @param sgGovernSchemeHistoryParam 方案参数 + */ + @Override + public SgGovernSchemeHistoryAllVO calc(SgGovernSchemeHistoryParam sgGovernSchemeHistoryParam) { + SgGovernSchemeHistoryAllVO sgGovernSchemeHistoryAllVO = initInvestmentScheme(sgGovernSchemeHistoryParam); + //准备暂降数据 + SgProductLine sgProductLine = productLineService.getById(sgGovernSchemeHistoryAllVO.getProductLineId()); + if (Objects.isNull(sgProductLine)) { + throw new BusinessException(AdvanceResponseEnum.PRODUCT_LINE_DATA_MISS); + } + //根据生产线获取该用户名称 + String userName = productLineService.getUserNameByProductId(sgProductLine.getId()); + sgGovernSchemeHistoryAllVO.setUserName(userName); + sgGovernSchemeHistoryAllVO.setProductLineName(sgProductLine.getName()); + SgIncomingLine sgIncomingLine = incomingLineService.getById(sgProductLine.getIncomingLineId()); + if (Objects.isNull(sgIncomingLine)) { + throw new BusinessException(AdvanceResponseEnum.INCOMING_LINE_DATA_MISS); + } + sgGovernSchemeHistoryAllVO.setInComingLineName(sgIncomingLine.getName()); + //时间内的电网接入水平(暂降次数) + String startTime = sgGovernSchemeHistoryParam.getStartTime(); + String endTime = sgGovernSchemeHistoryParam.getEndTime(); + //这种区间计算损失不合适,经过平均后,特征幅值在40%以下,直接被平均为25%,故此处我准备按实际的暂态信息计算 +// Map eventMap = eventService.getEventMap(sgIncomingLine.getId(), startTime, endTime); + List sgEventList = eventService.getEventData(sgIncomingLine.getId(), startTime, endTime); + if (CollectionUtil.isEmpty(sgEventList)) { + throw new BusinessException(AdvanceResponseEnum.EVENT_DATA_MISS); + } + + //求数据时间区间的年化率 + int days = (int) LocalDateTimeUtil.between(LocalDateTimeUtil.parse(startTime, DatePattern.NORM_DATE_PATTERN), LocalDateTimeUtil.parse(endTime, DatePattern.NORM_DATE_PATTERN)).toDays(); + //只能求一个大致的年化率,默认为一年365天 + double yearRate = 365.0 / (double) days; + ProductLineComputeData productLineComputeData = productLineService.assginProductLineComputeData(sgGovernSchemeHistoryAllVO.getProductLineId()); + computeProductLineLoss(sgEventList, sgGovernSchemeHistoryAllVO, GovernSchemeEnum.NO_SCHEME, yearRate, productLineComputeData); + computeProductLineLoss(sgEventList, sgGovernSchemeHistoryAllVO, GovernSchemeEnum.UPS, yearRate, productLineComputeData); + computeProductLineLoss(sgEventList, sgGovernSchemeHistoryAllVO, GovernSchemeEnum.AVC, yearRate, productLineComputeData); + + //开关快切治理方案单独计算 + Double actionTime = sgGovernSchemeHistoryAllVO.getQuick().getActionTime(); + String incomingLineId = sgGovernSchemeHistoryAllVO.getQuick().getIncomingLineId(); + List eventQuick = eventService.countEvent4Switch( + sgEventList, + sgIncomingLine.getId(), + incomingLineId, + startTime, + endTime, + actionTime); + SgGovernSchemeParam schemeParam = new SgGovernSchemeParam(); + schemeParam.setState(DataStateEnum.ENABLE.getCode()); + BeanUtil.copyProperties(sgGovernSchemeHistoryAllVO.getQuick(), schemeParam); + sgGovernSchemeParamService.save(schemeParam); + if (CollectionUtil.isEmpty(eventQuick)) { + SgGovernSchemeHistoryDetailVO quickSgGovernSchemeHistoryDetailVO = new SgGovernSchemeHistoryDetailVO(); + //说明被治理的很好,切到备用线路后,没有暂降事件了 + quickSgGovernSchemeHistoryDetailVO.setEventCount(0); + quickSgGovernSchemeHistoryDetailVO.setBreakCount(0); + quickSgGovernSchemeHistoryDetailVO.setLoss(0.0); + quickSgGovernSchemeHistoryDetailVO.setYearLoss(0.0); + quickSgGovernSchemeHistoryDetailVO.setType(GovernSchemeEnum.QUICK.getCode()); + quickSgGovernSchemeHistoryDetailVO.setEvaluationBatch(sgGovernSchemeHistoryAllVO.getEvaluationBatch()); + sgGovernSchemeHistoryAllVO.setQuickData(quickSgGovernSchemeHistoryDetailVO); + } else { + //说明没有必要切换备用线路,备用线路也存在同时间范围内的暂降 + computeProductLineLoss(eventQuick, sgGovernSchemeHistoryAllVO, GovernSchemeEnum.QUICK, yearRate, productLineComputeData); + } + sgGovernSchemeHistoryAllVO.getQuickData().setSchemeParamId(schemeParam.getId()); + //每个方案的损失已经计算完毕,开始准备给前台数据回显 + generateSchemeView(sgGovernSchemeHistoryAllVO, productLineComputeData); + //从各个方案中找一个最佳方案 + chooseBestScheme(sgGovernSchemeHistoryAllVO); + //todo...待做的还有文字信息 + return sgGovernSchemeHistoryAllVO; + } + + @Override + public SgGovernSchemeHistoryAllVO detail(String id) { + SgGovernSchemeHistoryAllVO allVO = new SgGovernSchemeHistoryAllVO(); + SgGovernSchemeHistory sgGovernSchemeHistory = sgGovernSchemeHistoryService.getById(id); + BeanUtil.copyProperties(sgGovernSchemeHistory, allVO); + //获取生产线、进线、用户名 + SgProductLine sgProductLine = productLineService.getById(sgGovernSchemeHistory.getProductLineId()); + SgUser sgUser = userService.getById(sgProductLine.getUserId()); + SgIncomingLine incomingLine = incomingLineService.getById(sgProductLine.getIncomingLineId()); + allVO.setUserName(sgUser.getUserName()); + allVO.setInComingLineName(incomingLine.getName()); + allVO.setProductLineName(sgProductLine.getName()); + + //查询UPS的结果和参数 + LambdaQueryWrapper historyDetailLambdaQueryWrapper = new LambdaQueryWrapper<>(); + historyDetailLambdaQueryWrapper.eq(SgGovernSchemeHistoryDetail::getEvaluationBatch, sgGovernSchemeHistory.getEvaluationBatch()) + .eq(SgGovernSchemeHistoryDetail::getType, GovernSchemeEnum.UPS.getCode()); + SgGovernSchemeHistoryDetail upsResult = sgGovernSchemeHistoryDetailService.getOne(historyDetailLambdaQueryWrapper); + SgGovernSchemeHistoryDetailVO upsVo = new SgGovernSchemeHistoryDetailVO(); + BeanUtil.copyProperties(upsResult, upsVo); + copyHistoryVo(upsResult, upsVo); + if (allVO.getBestSchemeId().equals(upsVo.getId())) { + allVO.setSchemeType(GovernSchemeEnum.UPS.getCode()); + } + List governEffectUPS = new ArrayList<>(); + for (int i = 0; i < allVO.getPayBackPeriod(); i++) { + governEffectUPS.add(allVO.getLoss()- upsVo.getLoss()); + } + upsVo.setGovernEffectArray(governEffectUPS); + allVO.setUpsData(upsVo); + LambdaQueryWrapper sgGovernSchemeParamLambdaQueryWrapper = new LambdaQueryWrapper<>(); + sgGovernSchemeParamLambdaQueryWrapper.eq(SgGovernSchemeParam::getId, upsResult.getSchemeParamId()); + SgGovernSchemeParam upsParamOne = sgGovernSchemeParamService.getOne(sgGovernSchemeParamLambdaQueryWrapper); + CommonSchemeParam upsParam = new CommonSchemeParam(); + BeanUtil.copyProperties(upsParamOne, upsParam); + allVO.setUps(upsParam); + //查询AVC的结果和参数 + LambdaQueryWrapper historyDetailLambdaQueryWrapperAVC = new LambdaQueryWrapper<>(); + historyDetailLambdaQueryWrapperAVC.eq(SgGovernSchemeHistoryDetail::getEvaluationBatch, sgGovernSchemeHistory.getEvaluationBatch()) + .eq(SgGovernSchemeHistoryDetail::getType, GovernSchemeEnum.AVC.getCode()); + SgGovernSchemeHistoryDetail avcResult = sgGovernSchemeHistoryDetailService.getOne(historyDetailLambdaQueryWrapperAVC); + SgGovernSchemeHistoryDetailVO avcVo = new SgGovernSchemeHistoryDetailVO(); + BeanUtil.copyProperties(avcResult, avcVo); + if (allVO.getBestSchemeId().equals(avcVo.getId())) { + allVO.setSchemeType(GovernSchemeEnum.AVC.getCode()); + } + copyHistoryVo(avcResult, avcVo); + List governEffectAVC = new ArrayList<>(); + for (int i = 0; i < allVO.getPayBackPeriod(); i++) { + governEffectAVC.add(allVO.getLoss()- avcVo.getLoss()); + } + avcVo.setGovernEffectArray(governEffectAVC); + allVO.setAvcData(avcVo); + LambdaQueryWrapper sgGovernSchemeParamLambdaQueryWrapperAVC = new LambdaQueryWrapper<>(); + sgGovernSchemeParamLambdaQueryWrapperAVC.eq(SgGovernSchemeParam::getId, avcResult.getSchemeParamId()); + SgGovernSchemeParam avcParamOne = sgGovernSchemeParamService.getOne(sgGovernSchemeParamLambdaQueryWrapperAVC); + CommonSchemeParam avcParam = new CommonSchemeParam(); + BeanUtil.copyProperties(avcParamOne, avcParam); + allVO.setAvc(avcParam); + //处理快切的结果和参数 + LambdaQueryWrapper historyDetailLambdaQueryWrapperQuick = new LambdaQueryWrapper<>(); + historyDetailLambdaQueryWrapperQuick.eq(SgGovernSchemeHistoryDetail::getEvaluationBatch, sgGovernSchemeHistory.getEvaluationBatch()) + .eq(SgGovernSchemeHistoryDetail::getType, GovernSchemeEnum.QUICK.getCode()); + SgGovernSchemeHistoryDetail quickResult = sgGovernSchemeHistoryDetailService.getOne(historyDetailLambdaQueryWrapperQuick); + SgGovernSchemeHistoryDetailVO quickVo = new SgGovernSchemeHistoryDetailVO(); + BeanUtil.copyProperties(quickResult, quickVo); + copyHistoryVo(quickResult, quickVo); + if (allVO.getBestSchemeId().equals(quickVo.getId())) { + allVO.setSchemeType(GovernSchemeEnum.QUICK.getCode()); + } + List governEffectQuick = new ArrayList<>(); + for (int i = 0; i < allVO.getPayBackPeriod(); i++) { + governEffectQuick.add(allVO.getLoss()- quickVo.getLoss()); + } + quickVo.setGovernEffectArray(governEffectQuick); + allVO.setQuickData(quickVo); + LambdaQueryWrapper sgGovernSchemeParamLambdaQueryWrapperQuick = new LambdaQueryWrapper<>(); + sgGovernSchemeParamLambdaQueryWrapperQuick.eq(SgGovernSchemeParam::getId, quickResult.getSchemeParamId()); + SgGovernSchemeParam quickParamOne = sgGovernSchemeParamService.getOne(sgGovernSchemeParamLambdaQueryWrapperQuick); + QuickSchemeParam quickParam = new QuickSchemeParam(); + BeanUtil.copyProperties(quickParamOne, quickParam); + SgIncomingLine sgIncomingLine = incomingLineService.getById(quickParam.getIncomingLineId()); + if(Objects.nonNull(sgIncomingLine)){ + quickParam.setIncomingLineId(sgIncomingLine.getName()); + } + allVO.setQuick(quickParam); + return allVO; + } + + private void copyHistoryVo(SgGovernSchemeHistoryDetail upsResult, SgGovernSchemeHistoryDetailVO upsVo) { + List data = Arrays.asList(upsResult.getInvestYield().split(StrPool.UNDERLINE)); + List doubleList = data.stream() + .map(Double::parseDouble) + .collect(Collectors.toList()); + upsVo.setInvestYieldArray(doubleList); + + + upsVo.setYearsArray(Arrays.asList(upsResult.getYears().split(StrPool.UNDERLINE))); + + + List data1 = Arrays.asList(upsResult.getInvestYear().split(StrPool.UNDERLINE)); + List doubleList1 = data1.stream() + .map(Double::parseDouble) + .collect(Collectors.toList()); + upsVo.setInvestYearArray(doubleList1); + + + List data2 = Arrays.asList(upsResult.getPayBack().split(StrPool.UNDERLINE)); + List doubleList2 = data2.stream() + .map(Double::parseDouble) + .collect(Collectors.toList()); + upsVo.setPayBackArray(doubleList2); + + List data3 = Arrays.asList(upsResult.getCost().split(StrPool.UNDERLINE)); + List doubleList3 = data3.stream() + .map(Double::parseDouble) + .collect(Collectors.toList()); + upsVo.setCostArray(doubleList3); + + } + + /** + * 从每个方案选一个作为最佳方案,顺便入库,方便日后查询历史数据 + * + * @param sgGovernSchemeHistoryAllVO 方案数据 + */ + private void chooseBestScheme(SgGovernSchemeHistoryAllVO sgGovernSchemeHistoryAllVO) { + SgGovernSchemeHistoryDetailVO upsData = sgGovernSchemeHistoryAllVO.getUpsData(); + upsData.setId(IdWorker.get32UUID()); + SgGovernSchemeHistoryDetailVO avcData = sgGovernSchemeHistoryAllVO.getAvcData(); + avcData.setId(IdWorker.get32UUID()); + SgGovernSchemeHistoryDetailVO quickData = sgGovernSchemeHistoryAllVO.getQuickData(); + quickData.setId(IdWorker.get32UUID()); + List tempList = new ArrayList<>(); + tempList.add(upsData); + tempList.add(avcData); + tempList.add(quickData); + // 使用Stream API根据综合得分排序 + List sortedByResult = tempList.stream() + .sorted(Comparator.comparingDouble(SgGovernSchemeHistoryDetailVO::getInvestmentResult).reversed()) + .collect(Collectors.toList()); + sgGovernSchemeHistoryAllVO.setBestSchemeId(sortedByResult.get(0).getId()); + //执行持久化操作 + SgGovernSchemeHistoryDetail upsDataPO = new SgGovernSchemeHistoryDetail(); + //拷贝数据到持久化对象中 + copyHistoryDetail(upsData, upsDataPO); + sgGovernSchemeHistoryDetailService.save(upsDataPO); + SgGovernSchemeHistoryDetail avcDataPO = new SgGovernSchemeHistoryDetail(); + copyHistoryDetail(avcData, avcDataPO); + sgGovernSchemeHistoryDetailService.save(avcDataPO); + SgGovernSchemeHistoryDetail quickDataPO = new SgGovernSchemeHistoryDetail(); + copyHistoryDetail(quickData, quickDataPO); + sgGovernSchemeHistoryDetailService.save(quickDataPO); + //将治理方案的历史数据存入库中 + SgGovernSchemeHistory sgGovernSchemeHistory = new SgGovernSchemeHistory(); + BeanUtil.copyProperties(sgGovernSchemeHistoryAllVO, sgGovernSchemeHistory); + sgGovernSchemeHistoryService.save(sgGovernSchemeHistory); + } + + /** + * 拷贝数据到持久化对象中 + * + * @param sourceData 源数据 + * @param targetData 持久化对象 + */ + private void copyHistoryDetail(SgGovernSchemeHistoryDetailVO sourceData, SgGovernSchemeHistoryDetail targetData) { + BeanUtil.copyProperties(sourceData, targetData); + targetData.setYears(String.join(StrPool.UNDERLINE, sourceData.getYearsArray())); + + String investYear = sourceData.getInvestYearArray().stream() + .map(String::valueOf) + .collect(Collectors.joining(StrPool.UNDERLINE)); + targetData.setInvestYear(investYear); + + + String payBack = sourceData.getPayBackArray().stream() + .map(String::valueOf) + .collect(Collectors.joining(StrPool.UNDERLINE)); + targetData.setPayBack(payBack); + + + String cost = sourceData.getCostArray().stream() + .map(String::valueOf) + .collect(Collectors.joining(StrPool.UNDERLINE)); + targetData.setCost(cost); + + String investYield = sourceData.getInvestYieldArray().stream() + .map(String::valueOf) + .collect(Collectors.joining(StrPool.UNDERLINE)); + targetData.setInvestYield(investYield); + + } + + + /** + * 将半成品梳理成合理的页面数据内容回显 + * + * @param sgGovernSchemeHistoryAllVO 页面视图半成品 + */ + private void generateSchemeView(SgGovernSchemeHistoryAllVO sgGovernSchemeHistoryAllVO, ProductLineComputeData productLineComputeData) { + //待治理的总功率 + List machineVOList = productLineComputeData.getMachineVOList(); + double totalPower = machineVOList.stream().mapToDouble(SgMachineVO::getMachinePower).sum(); + sgGovernSchemeHistoryAllVO.setGovernPower(totalPower); + //处理需要投资的信息 + //先处理UPS,即中电的串联 + calcEquipment(GovernSchemeEnum.UPS, sgGovernSchemeHistoryAllVO.getUps(), null, totalPower, sgGovernSchemeHistoryAllVO.getUpsData()); + calcEquipment(GovernSchemeEnum.AVC, sgGovernSchemeHistoryAllVO.getAvc(), null, totalPower, sgGovernSchemeHistoryAllVO.getAvcData()); + calcEquipment(GovernSchemeEnum.QUICK, null, sgGovernSchemeHistoryAllVO.getQuick(), totalPower, sgGovernSchemeHistoryAllVO.getQuickData()); + //处理雷达图 + //先处理UPS,即中电的串联 + calcRadar(sgGovernSchemeHistoryAllVO, GovernSchemeEnum.UPS); + calcRadar(sgGovernSchemeHistoryAllVO, GovernSchemeEnum.AVC); + calcRadar(sgGovernSchemeHistoryAllVO, GovernSchemeEnum.QUICK); + //计算各个方案的优先指数 + calcPrecedence(sgGovernSchemeHistoryAllVO.getUpsData()); + calcPrecedence(sgGovernSchemeHistoryAllVO.getAvcData()); + calcPrecedence(sgGovernSchemeHistoryAllVO.getQuickData()); + + + } + + + /** + * 步骤拆解 + * 1、首先获取到生产线所有的设备数据 + * 2、循环时间范围内的电网接入水平 + * 3、再根据治理方案循环,计算出各个治理方案下的 特征幅值、持续时间的治理后的结果 + * 4、计算故障率 + * 4.1、计算设备的故障率,并计算出该设备的设备损失+原料损失 + * 4.2、计算生产线的故障率,计算出生产线的产能损失 + *

+ * 根据电网接入水平以及生产线的各敏感元器件,计算各方案下每年经济的损失 + * + * @param eventList 暂降事件列表 + * @param sgGovernSchemeHistoryAllVO 待返回前台展示数据 + * @param governSchemeEnum 治理方案 + * @param yearRate 年化率 + */ + private void computeProductLineLoss(List eventList, + SgGovernSchemeHistoryAllVO sgGovernSchemeHistoryAllVO, GovernSchemeEnum governSchemeEnum, + double yearRate, ProductLineComputeData productLineComputeData) { + //为了数据好看点,除以年期望值 + Integer payBackPeriod = 1; +// Integer payBackPeriod = sgGovernSchemeHistoryAllVO.getPayBackPeriod(); + SgGovernSchemeParam schemeParam; + //总计暂降次数 + int eventCount = 0; + //总计中断次数 + double breakCount = 0.0; + //总计损失经济 + double totalLoss = 0.0; + //特征幅值,持续时间 + double amplitude, durationTime; + //计算每个频次再各方案下的累计损失 + switch (governSchemeEnum) { + case UPS: + for (SgEvent sgEvent : eventList) { + amplitude = calcAmplitude(sgGovernSchemeHistoryAllVO.getUps(), sgEvent.getFeatureAmplitude(), sgEvent.getDuration()); + durationTime = calcDuration(sgGovernSchemeHistoryAllVO.getUps(), sgEvent.getDuration()); + //得出当前该接入水平的经济损失以及生产线故障率 + Double[] eventEffect = eventService.getEventLossAndFailureRate(productLineComputeData, amplitude, durationTime); + Double singleLoss = eventEffect[0]; + Double productLineFailureRate = eventEffect[1]; +// totalLoss = totalLoss + singleLoss * eventMap.get(sagData); + totalLoss = totalLoss + singleLoss; + if (amplitude < 0.9) { + eventCount++; + breakCount = breakCount + productLineFailureRate; + } + } + schemeParam = new SgGovernSchemeParam(); + schemeParam.setState(DataStateEnum.ENABLE.getCode()); + BeanUtil.copyProperties(sgGovernSchemeHistoryAllVO.getUps(), schemeParam); + sgGovernSchemeParamService.save(schemeParam); + SgGovernSchemeHistoryDetailVO upsGovernSchemeHistoryDetailVO = new SgGovernSchemeHistoryDetailVO(); + upsGovernSchemeHistoryDetailVO.setSchemeParamId(schemeParam.getId()); + upsGovernSchemeHistoryDetailVO.setEventCount(eventCount); + upsGovernSchemeHistoryDetailVO.setBreakCount((int) breakCount); + upsGovernSchemeHistoryDetailVO.setLoss(PubUtils.doubleRound(2, totalLoss)); + upsGovernSchemeHistoryDetailVO.setYearLoss(PubUtils.doubleRound(2, upsGovernSchemeHistoryDetailVO.getLoss() / payBackPeriod)); + upsGovernSchemeHistoryDetailVO.setEvaluationBatch(sgGovernSchemeHistoryAllVO.getEvaluationBatch()); + upsGovernSchemeHistoryDetailVO.setType(GovernSchemeEnum.UPS.getCode()); + sgGovernSchemeHistoryAllVO.setUpsData(upsGovernSchemeHistoryDetailVO); + break; + case AVC: + for (SgEvent sgEvent : eventList) { + amplitude = calcAmplitude(sgGovernSchemeHistoryAllVO.getAvc(), sgEvent.getFeatureAmplitude(), sgEvent.getDuration()); + durationTime = calcDuration(sgGovernSchemeHistoryAllVO.getAvc(), sgEvent.getDuration()); + //得出当前该接入水平的经济损失以及生产线故障率 + Double[] eventEffect = eventService.getEventLossAndFailureRate(productLineComputeData, amplitude, durationTime); + Double singleLoss = eventEffect[0]; + Double productLineFailureRate = eventEffect[1]; +// totalLoss = totalLoss + singleLoss * eventMap.get(sagData); + totalLoss = totalLoss + singleLoss; + if (amplitude < 0.9) { + eventCount++; + breakCount = breakCount + productLineFailureRate; + } + } + schemeParam = new SgGovernSchemeParam(); + schemeParam.setState(DataStateEnum.ENABLE.getCode()); + BeanUtil.copyProperties(sgGovernSchemeHistoryAllVO.getAvc(), schemeParam); + sgGovernSchemeParamService.save(schemeParam); + SgGovernSchemeHistoryDetailVO avcGovernSchemeHistoryDetailVO = new SgGovernSchemeHistoryDetailVO(); + avcGovernSchemeHistoryDetailVO.setSchemeParamId(schemeParam.getId()); + avcGovernSchemeHistoryDetailVO.setEventCount(eventCount); + avcGovernSchemeHistoryDetailVO.setBreakCount((int) breakCount); + avcGovernSchemeHistoryDetailVO.setLoss(PubUtils.doubleRound(2, totalLoss)); + avcGovernSchemeHistoryDetailVO.setYearLoss(PubUtils.doubleRound(2, avcGovernSchemeHistoryDetailVO.getLoss() / payBackPeriod)); + avcGovernSchemeHistoryDetailVO.setEvaluationBatch(sgGovernSchemeHistoryAllVO.getEvaluationBatch()); + avcGovernSchemeHistoryDetailVO.setType(GovernSchemeEnum.AVC.getCode()); + sgGovernSchemeHistoryAllVO.setAvcData(avcGovernSchemeHistoryDetailVO); + break; + case AVC_RTS: + //暂时无法知道如何计算串并联的治理方案 + break; + default: + for (SgEvent sgEvent : eventList) { + //不做治理 + amplitude = sgEvent.getFeatureAmplitude(); + durationTime = sgEvent.getDuration(); + //得出当前该接入水平的经济损失以及生产线故障率 + Double[] eventEffect = eventService.getEventLossAndFailureRate(productLineComputeData, amplitude, durationTime); + Double singleLoss = eventEffect[0]; + Double productLineFailureRate = eventEffect[1]; + totalLoss = totalLoss + singleLoss; + eventCount++; + breakCount = breakCount + productLineFailureRate; + } + if (governSchemeEnum.getCode() == 3) { + //快切治理的经济 + SgGovernSchemeHistoryDetailVO quickSgGovernSchemeHistoryDetailVO = new SgGovernSchemeHistoryDetailVO(); + quickSgGovernSchemeHistoryDetailVO.setEventCount(eventCount); + quickSgGovernSchemeHistoryDetailVO.setBreakCount((int) breakCount); + quickSgGovernSchemeHistoryDetailVO.setLoss(PubUtils.doubleRound(2, totalLoss)); + quickSgGovernSchemeHistoryDetailVO.setYearLoss(PubUtils.doubleRound(2, quickSgGovernSchemeHistoryDetailVO.getLoss() / payBackPeriod)); + quickSgGovernSchemeHistoryDetailVO.setEvaluationBatch(sgGovernSchemeHistoryAllVO.getEvaluationBatch()); + quickSgGovernSchemeHistoryDetailVO.setType(GovernSchemeEnum.QUICK.getCode()); + sgGovernSchemeHistoryAllVO.setQuickData(quickSgGovernSchemeHistoryDetailVO); + } else { + //治理前的经济损失 + sgGovernSchemeHistoryAllVO.setEventCount(eventCount); + sgGovernSchemeHistoryAllVO.setBreakCount((int) breakCount); + sgGovernSchemeHistoryAllVO.setLoss(totalLoss); + sgGovernSchemeHistoryAllVO.setYearLoss(PubUtils.doubleRound(2, sgGovernSchemeHistoryAllVO.getLoss() / payBackPeriod)); + } + break; + } + } + + + /** + * 计算治理幅度 + * + * @param schemeParam 治理参数 + * @param oriAmplitude 原始暂降降幅 + * @param oriDuration 原始持续时间 + * @return 新幅度 + */ + private double calcAmplitude(CommonSchemeParam schemeParam, double oriAmplitude, double oriDuration) { + double newAmplitude = oriAmplitude; + // 如果响应时间小于持续时间,并且后备时间大于持续时间,可治理,否则不做暂降治理 + if (schemeParam.getResponseTime() < oriDuration && schemeParam.getBackupTime() * 1000 > oriDuration) { + newAmplitude = newAmplitude + schemeParam.getCompensation(); + if (newAmplitude > 1.0) { + newAmplitude = 1.0; + } + } + return newAmplitude; + } + + + /** + * 计算治理时间 + * + * @param schemeParam 治理参数 + * @param oriDuration 原始持续时间 + * @return 新幅度 + */ + private double calcDuration(CommonSchemeParam schemeParam, double oriDuration) { + double newDuration = oriDuration; + // 如果响应时间小于持续时间,就将持续时间需改为响应时间(后备时间暂不考虑),否则不做持续时间治理 + if (schemeParam.getResponseTime() < oriDuration) { + newDuration = schemeParam.getResponseTime(); + } + return newDuration; + } + + /** + * @param sgGovernSchemeHistoryParam 页面参数 + * @return 初始化方案数据 + */ + private SgGovernSchemeHistoryAllVO initInvestmentScheme(SgGovernSchemeHistoryParam sgGovernSchemeHistoryParam) { + SgGovernSchemeHistoryAllVO sgGovernSchemeHistoryAllVO = new SgGovernSchemeHistoryAllVO(); + BeanUtil.copyProperties(sgGovernSchemeHistoryParam, sgGovernSchemeHistoryAllVO); + //提前获得一个id,作为该次评估所有方案的一个批次号 + String batchNo = IdWorker.get32UUID(); + sgGovernSchemeHistoryAllVO.setEvaluationBatch(batchNo); + sgGovernSchemeHistoryAllVO.setTimeScope(sgGovernSchemeHistoryParam.getStartTime().concat("至").concat(sgGovernSchemeHistoryParam.getEndTime())); + sgGovernSchemeHistoryAllVO.setQuick(sgGovernSchemeHistoryParam.getQuick()); + return sgGovernSchemeHistoryAllVO; + } + + /** + * 根据补偿方案和功率计算补偿设备 + * + * @param governSchemeEnum 方案类型 + * @param commonSchemeParam 补偿标准 + * @param power 功率 + */ + private void calcEquipment(GovernSchemeEnum governSchemeEnum, CommonSchemeParam commonSchemeParam, QuickSchemeParam quickSchemeParam, Double power, SgGovernSchemeHistoryDetailVO resultVo) { + resultVo.setCount(0);//避免NULL时报错 + double priceIndex; + switch (governSchemeEnum) { + case UPS: + resultVo.setSize("[2200*1100*2000]"); + resultVo.setCount((int) Math.ceil(power / 400)); + double totalPower; + //根据新需求,总功率低于50kW时,按10kW一跳且价格上浮50%;高于50kW时每50kW一跳。 + if (power < 50) { + priceIndex = 1.5; + totalPower = 10 * Math.ceil(power / 10); + } else { + priceIndex = 1; + totalPower = 50 * Math.ceil(power / 50); + } + resultVo.setPower(PubUtils.doubleRound(2, totalPower)); + resultVo.setEquipment(PubUtils.doubleRound(2, commonSchemeParam.getPrice() * resultVo.getPower() * priceIndex)); + resultVo.setMaintain(PubUtils.doubleRound(2, commonSchemeParam.getMaintainFee() * resultVo.getPower() * priceIndex)); + break; + case AVC: + AVCInfo avcInfo = calcAvc(power); + resultVo.setSize(avcInfo.getSize()); + resultVo.setCount(avcInfo.getCount()); + resultVo.setPower(PubUtils.doubleRound(2, (double) avcInfo.getTotalPower())); + //根据新需求,总功率低于50kW时,按50kW一跳且价格上浮50%;高于50kW时每50kW一跳。 + priceIndex = 1; + if (avcInfo.getTotalPower() < 50) { + priceIndex = 1.5; + } + resultVo.setEquipment(PubUtils.doubleRound(2, commonSchemeParam.getPrice() * resultVo.getPower() * priceIndex)); + resultVo.setMaintain(PubUtils.doubleRound(2, commonSchemeParam.getMaintainFee() * resultVo.getPower() * priceIndex)); + break; + default: + //默认为快切 + resultVo.setCount((int) Math.ceil(power / quickSchemeParam.getGovernMachinePower())); + resultVo.setPower(PubUtils.doubleRound(2, quickSchemeParam.getGovernMachinePower() * resultVo.getCount())); + resultVo.setSize(""); + resultVo.setEquipment(PubUtils.doubleRound(2, quickSchemeParam.getPrice() * resultVo.getCount() + quickSchemeParam.getBuildFee())); + resultVo.setMaintain(PubUtils.doubleRound(2, quickSchemeParam.getQuickMaintainFee())); + break; + + } + } + + /** + * 计算每个治理方案的治理效果,包括用户投资曲线、用户收益曲线、雷达图 + * + * @param sgGovernSchemeHistoryAllVO 未治理前的一些数据 + * @param governSchemeEnum 指定治理方案枚举 + */ + private void calcRadar(SgGovernSchemeHistoryAllVO sgGovernSchemeHistoryAllVO, GovernSchemeEnum governSchemeEnum) { + SgGovernSchemeHistoryDetailVO tempData; + switch (governSchemeEnum) { + case UPS: + tempData = sgGovernSchemeHistoryAllVO.getUpsData(); + break; + case AVC: + tempData = sgGovernSchemeHistoryAllVO.getAvcData(); + break; + default: + tempData = sgGovernSchemeHistoryAllVO.getQuickData(); + break; + } + tempData.setRiskLevelBefore(RadarUtil.getRadarRiskLevel(sgGovernSchemeHistoryAllVO.getYearLoss(), 0.9)); + tempData.setRiskLevelAfter(RadarUtil.getRadarRiskLevel(tempData.getYearLoss(), 0.1)); + tempData.setRadarResult(RadarUtil.getRadarResult(sgGovernSchemeHistoryAllVO.getYearLoss(), tempData.getYearLoss())); + tempData.setRadarRisk(RadarUtil.getRadarRisk(tempData.getYearLoss(), 0.1)); + //每年的投资效益,治理效果 + double earnings = sgGovernSchemeHistoryAllVO.getYearLoss() - tempData.getYearLoss(); + List investYear = new ArrayList<>(); + List payBack = new ArrayList<>(); + List investYearThree = new ArrayList<>(); + List payBackThree = new ArrayList<>(); + List cost = new ArrayList<>(); + List investYield = new ArrayList<>(); + //存在收益,计算下回收期,默认最大回收周期为最后一年 + int actualPayBack = sgGovernSchemeHistoryAllVO.getPayBackPeriod(); + boolean isFirst = true; + //治理效果 + List governEffect = new ArrayList<>(); + for (int i = 1; i <= 15; i++) { + //一直计算到用户最大期望回收周期 + double investMoney; + if (i == 1) { + //第一年的投资为设备费用+运维费 + investMoney = tempData.getEquipment() + tempData.getMaintain(); + } else { + //每年的投资为运维费 + investMoney = tempData.getMaintain(); + } + investMoney = PubUtils.doubleRound(2, investMoney); + //需要计算额外的5 10 15年需要的数据 + if (i <= sgGovernSchemeHistoryAllVO.getPayBackPeriod()) { + investYear.add(investMoney); + investYearThree.add(investMoney); + double totalInvest = investYear.stream().mapToDouble(Double::doubleValue).sum(); + payBack.add(PubUtils.doubleRound(2, earnings * i - totalInvest)); + payBackThree.add(earnings * i - totalInvest); + if (earnings * i - totalInvest > 0) { + if (isFirst) { + //仅第一次给投资期赋值 + actualPayBack = i; + isFirst = false; + } + } + governEffect.add(earnings); + } else { + //如果超出预期日期,还需要循环15次,把数据添加进来,用于计算5 10 15的数据 + investYearThree.add(investMoney); + double totalInvest = investYear.stream().mapToDouble(Double::doubleValue).sum(); + payBackThree.add(earnings * i - totalInvest); + } + } + + //计算 5 10 15的数据 + for (int i = 5; i <= 15; i += 5) { + List tempInvest = investYearThree.subList(0, i); + double sum = tempInvest.stream().mapToDouble(Double::doubleValue).sum(); + cost.add(PubUtils.doubleRound(2, sum)); + + List tempPayBack = payBackThree.subList(0, i); + double sumPayBack = tempPayBack.stream().mapToDouble(Double::doubleValue).sum(); + double yield = sumPayBack / sum * 100; + investYield.add(PubUtils.doubleRound(2, yield)); + } + tempData.setGovernEffectArray(governEffect); + tempData.setCostArray(cost); + tempData.setInvestYieldArray(investYield); + + if (earnings > 0) { + double wish = (double) (sgGovernSchemeHistoryAllVO.getPayBackPeriod() - actualPayBack) / sgGovernSchemeHistoryAllVO.getPayBackPeriod(); + tempData.setRadarWish(PubUtils.doubleRound(2, wish)); + } else { + //没有收益,则投资意愿自然为0 + tempData.setRadarWish(0D); + } + //每年投资 + tempData.setInvestYearArray(investYear); + //每年收益 + tempData.setPayBackArray(payBack); + //实际回报年份 + tempData.setActualPayBack(actualPayBack); + //年份 + List years = new ArrayList<>(); + //从当前年份作为起始年份,截止年份采用期望回收周期 + int year = LocalDate.now().getYear(); + for (int i = 0; i < sgGovernSchemeHistoryAllVO.getPayBackPeriod(); i++) { + years.add(String.valueOf(year + i)); + } + tempData.setYearsArray(years); + double sagImmunity = (double) (sgGovernSchemeHistoryAllVO.getEventCount() - tempData.getEventCount()) / sgGovernSchemeHistoryAllVO.getEventCount(); + tempData.setSagImmunity(PubUtils.doubleRound(2, sagImmunity)); + } + + + /** + * 计算各方案下优先指数 + * + * @param governSchemeHistoryDetailVO 投资方案下的所有数据,根据雷达信息计算出优先指数 + */ + private void calcPrecedence(SgGovernSchemeHistoryDetailVO governSchemeHistoryDetailVO) { + //去风险能力 + double radarRiskFactor = 0.1070; + //投资意愿 + double radarWishFactor = 0.2538; + //暂降免疫能力 + double radarRmmunityFactor = 0.0443; + //治理效果 + double radarResultFactor = 0.5949; + //方案优先指数 + double optimizingResult = governSchemeHistoryDetailVO.getRadarResult() * radarResultFactor + + governSchemeHistoryDetailVO.getRadarWish() * radarWishFactor + + governSchemeHistoryDetailVO.getRadarRisk() * radarRiskFactor + + governSchemeHistoryDetailVO.getSagImmunity() * radarRmmunityFactor; + governSchemeHistoryDetailVO.setInvestmentResult(PubUtils.doubleRound(4, optimizingResult)); + } + + + /** + * 根据总功率计算需要的设备 + * + * @param power 总功率 + */ + private AVCInfo calcAvc(Double power) { + List dvrParamList = new ArrayList<>(); + dvrParamList.add(new AVCInfo(300, "[1600*1000*2100]", power)); + dvrParamList.add(new AVCInfo(600, "[3200*1100*2100]", power)); + dvrParamList.add(new AVCInfo(900, "[4800*1100*2100]", power)); + dvrParamList.add(new AVCInfo(1200, "[6400*1100*2100]", power)); + dvrParamList.add(new AVCInfo(1500, "[8000*1100*2100]", power)); + dvrParamList.add(new AVCInfo(1800, "[8200*1100*2100]", power)); + dvrParamList.add(new AVCInfo(2100, "[8200*1100*2100]", power)); + dvrParamList.add(new AVCInfo(2400, "[8200*1100*2100]", power)); + Collections.sort(dvrParamList); + return dvrParamList.get(0); + } + + @Setter + @Getter + class AVCInfo implements Comparable { + private int totalPower; + private int power; + private int count; + private String size; + + public AVCInfo(int power, String size, double totalPower) { + this.power = power; + this.count = (int) Math.ceil(totalPower / this.power); + this.size = size; + this.totalPower = this.power * this.count; + //根据新需求,总功率低于50kW时,按50kW一跳且价格上浮50%;高于50kW时每50kW一跳。 + double power4price; + if (totalPower >= 50) { + power4price = 50; + } else { + power4price = 10; + } + this.totalPower = (int) (power4price * (Math.ceil(totalPower / power4price))); + } + + @Override + public int compareTo(AVCInfo o) { + int a = this.totalPower - o.getTotalPower(); + if (a == 0) { + return this.getCount() - o.getCount(); + } else { + return a; + } + } + } + +} diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/SgEventServiceImpl.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/SgEventServiceImpl.java index 64e80d800..f56643a30 100644 --- a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/SgEventServiceImpl.java +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/SgEventServiceImpl.java @@ -1,34 +1,751 @@ package com.njcn.advance.service.govern.voltage.impl; +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.date.DatePattern; +import cn.hutool.core.date.LocalDateTimeUtil; +import cn.hutool.core.text.StrPool; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.njcn.advance.enums.AdvanceResponseEnum; import com.njcn.advance.mapper.govern.voltage.SgEventMapper; +import com.njcn.advance.pojo.dto.govern.voltage.ProductLineComputeData; +import com.njcn.advance.pojo.dto.govern.voltage.SgEventExcel; import com.njcn.advance.pojo.param.govern.voltage.SgEventParam; import com.njcn.advance.pojo.po.govern.voltage.SgEvent; -import com.njcn.advance.pojo.vo.govern.voltage.SgEventVO; +import com.njcn.advance.pojo.po.govern.voltage.SgIncomingLine; +import com.njcn.advance.pojo.vo.govern.voltage.*; +import com.njcn.advance.service.govern.voltage.IGovernSchemeCalcService; import com.njcn.advance.service.govern.voltage.ISgEventService; +import com.njcn.advance.service.govern.voltage.ISgIncomingLineService; +import com.njcn.advance.service.govern.voltage.ISgProductLineService; +import com.njcn.advance.utils.NumberUtil; +import com.njcn.common.pojo.enums.common.DataStateEnum; +import com.njcn.common.pojo.exception.BusinessException; +import com.njcn.common.utils.PubUtils; +import com.njcn.poi.excel.ExcelUtil; +import com.njcn.web.factory.PageFactory; +import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import java.time.LocalDateTime; +import java.time.temporal.ChronoUnit; +import java.util.*; +import java.util.stream.Collectors; + /** *

- * 服务实现类 + * 服务实现类 *

* * @author hongawen * @since 2024-02-29 */ @Service +@RequiredArgsConstructor public class SgEventServiceImpl extends ServiceImpl implements ISgEventService { + private final ISgIncomingLineService sgIncomingLineService; + + private final ISgProductLineService productLineService; + + /** + * 暂降幅值,不是特征幅值 + */ + private static final double[][] AMPLITUDE = { + {80, 90}, + {70, 80}, + {60, 70}, + {50, 60}, + {40, 50}, + {10, 40} + }; + + /** + * 暂降持续时间 ms + */ + private static final double[][] DURATION_TIME = { + {10, 20}, + {20, 50}, + {50, 70}, + {70, 100}, + {100, 1000} + }; + + private static final Map AMPLITUDE_KEY_MAP = new HashMap() {{ + put(AMPLITUDE[0], 85); + put(AMPLITUDE[1], 75); + put(AMPLITUDE[2], 65); + put(AMPLITUDE[3], 55); + put(AMPLITUDE[4], 45); + put(AMPLITUDE[5], 25); + }}; + + private static final Map DURATION_TIME_KEY_MAP = new HashMap() {{ + put(DURATION_TIME[0], 15); + put(DURATION_TIME[1], 35); + put(DURATION_TIME[2], 60); + put(DURATION_TIME[3], 85); + put(DURATION_TIME[4], 550); + }}; + /** * 根据查询条件返回分页的暂降数据 + * * @param sgEventParamQueryParam 查询条件 */ @Override public Page sgEventList(SgEventParam.SgEventParamQueryParam sgEventParamQueryParam) { - //暂降数据实际跟进线耦合的,需要根据所传的生产线获取进线id - String productId = sgEventParamQueryParam.getProductId(); - - return null; + //暂降数据实际跟进线耦合的,需要根据所传的用户获取进线id + String userId = sgEventParamQueryParam.getUserId(); + LambdaQueryWrapper sgIncomingLineLambdaQueryWrapper = new LambdaQueryWrapper<>(); + sgIncomingLineLambdaQueryWrapper.eq(SgIncomingLine::getUserId, userId) + .eq(SgIncomingLine::getState, DataStateEnum.ENABLE.getCode()); + List imcomingLineList = sgIncomingLineService.list(sgIncomingLineLambdaQueryWrapper); + //以分页的方式查询出所有的暂降数据 + if (CollectionUtil.isNotEmpty(imcomingLineList)) { + List incomingLineIdList = imcomingLineList.stream().map(SgIncomingLine::getId).collect(Collectors.toList()); + QueryWrapper sgEventVOQueryWrapper = new QueryWrapper<>(); + sgEventVOQueryWrapper.in("sg_event.incoming_line_id", incomingLineIdList) + .between("sg_event.start_time", LocalDateTimeUtil.parse(sgEventParamQueryParam.getSearchBeginTime(), DatePattern.NORM_DATE_PATTERN), + LocalDateTimeUtil.parse(sgEventParamQueryParam.getSearchEndTime(), DatePattern.NORM_DATE_PATTERN)) + .eq("sg_event.state", DataStateEnum.ENABLE.getCode()) + .orderByDesc("sg_event.start_time"); + return this.baseMapper.page(new Page<>(PageFactory.getPageNum(sgEventParamQueryParam), PageFactory.getPageSize(sgEventParamQueryParam)), sgEventVOQueryWrapper); + } + return new Page<>(); } + + @Override + public void downloadTemplate() { + ExcelUtil.exportExcel("暂降事件模板.xls", "暂降数据", SgEventExcel.class, new ArrayList<>()); + } + + /** + * 导出条件范围内所有的数据 + */ + @Override + public void exportEventData(SgEventParam.SgEventParamQueryParam sgEventParamQueryParam) { + List sgEventVOList; + String userId = sgEventParamQueryParam.getUserId(); + LambdaQueryWrapper sgIncomingLineLambdaQueryWrapper = new LambdaQueryWrapper<>(); + sgIncomingLineLambdaQueryWrapper.eq(SgIncomingLine::getUserId, userId) + .eq(SgIncomingLine::getState, DataStateEnum.ENABLE.getCode()); + List imcomingLineList = sgIncomingLineService.list(sgIncomingLineLambdaQueryWrapper); + if (CollectionUtil.isEmpty(imcomingLineList)) { + ExcelUtil.exportExcel("暂降事件数据.xls", "暂降数据", SgEventVO.class, new ArrayList<>()); + } else { + List incomingLineIdList = imcomingLineList.stream().map(SgIncomingLine::getId).collect(Collectors.toList()); + sgEventVOList = this.baseMapper.getAllEventData(incomingLineIdList, LocalDateTimeUtil.parse(sgEventParamQueryParam.getSearchBeginTime(), DatePattern.NORM_DATE_PATTERN), LocalDateTimeUtil.parse(sgEventParamQueryParam.getSearchEndTime(), DatePattern.NORM_DATE_PATTERN)); + ExcelUtil.exportExcel("暂降事件数据.xls", "暂降数据", SgEventVO.class, sgEventVOList); + } + } + + @Override + public void importEventData(List sgEventExcels, String incomingLineId, String productLineId) { + //获取生产线信息 + ProductLineComputeData productLineComputeData = productLineService.assginProductLineComputeData(productLineId); + if (CollectionUtil.isNotEmpty(sgEventExcels)) { + List sgEventList = sgEventExcels.stream().map(temp -> { + SgEvent sgEvent = new SgEvent(incomingLineId, temp.getDuration(), temp.getFeatureAmplitude(), temp.getEventDescribe(), 0); + String startTimeStr = temp.getStartTime().concat(StrPool.DOT).concat(dealMs(temp.getMs())); + try { + sgEvent.setStartTime(LocalDateTimeUtil.parse(startTimeStr, DatePattern.NORM_DATETIME_MS_PATTERN)); + } catch (Exception exception) { + throw new BusinessException(AdvanceResponseEnum.EVENT_TIME_ERROR); + } + Double[] eventEffect = this.getEventLossAndFailureRate(productLineComputeData, sgEvent.getFeatureAmplitude(), sgEvent.getDuration()); + Double singleLoss = eventEffect[0]; + sgEvent.setEstimatedLoss(singleLoss); + sgEvent.setProductLineId(productLineId); + sgEvent.setFileFlag(0); + sgEvent.setEventType("暂降"); + return sgEvent; + }).collect(Collectors.toList()); + //先一个个的插,功能完成后来优化成批量插入,todo... + for (SgEvent sgEvent : sgEventList) { + this.baseMapper.insert(sgEvent); + } + } + } + + /** + * 处理毫秒补零操作 + * + * @param ms 1位就补2位0 + */ + private String dealMs(String ms) { + if (ms.length() >= 3) { + return ms.substring(0, 3); + } else if (ms.length() == 2) { + return "0".concat(ms); + } else { + return "00".concat(ms); + } + } + + /** + * 根据进线、时间获取范围内发生的暂降事件 + * + * @param id 进线id + * @param startTime 起始时间 + * @param endTime 截止时间 + */ + @Override + public List getEventData(String id, String startTime, String endTime) { + LambdaQueryWrapper sgEventLambdaQueryWrapper = new LambdaQueryWrapper<>(); + sgEventLambdaQueryWrapper.eq(SgEvent::getIncomingLineId, id) + .between(SgEvent::getStartTime, + LocalDateTimeUtil.parse(startTime, DatePattern.NORM_DATE_PATTERN), + LocalDateTimeUtil.parse(endTime, DatePattern.NORM_DATE_PATTERN) + ) + .eq(SgEvent::getState, DataStateEnum.ENABLE.getCode()) + .orderByDesc(SgEvent::getStartTime); + return this.list(sgEventLambdaQueryWrapper); + } + + /** + * 根据进线、时间获取范围内电网接入水平 + * + * @param id 进线id + * @param startTime 起始时间 + * @param endTime 截止时间 + */ + @Override + public Map getEventMap(String id, String startTime, String endTime) { + Map eventMap = new HashMap<>(); + LambdaQueryWrapper lambdaQueryWrapper; + for (double[] amplitudeRange : AMPLITUDE) { + for (double[] durationTimeRange : DURATION_TIME) { + lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper.eq(SgEvent::getIncomingLineId, id) + .ge(SgEvent::getFeatureAmplitude, amplitudeRange[0] * 0.01) + .lt(SgEvent::getFeatureAmplitude, amplitudeRange[1] * 0.01) + .ge(SgEvent::getDuration, durationTimeRange[0]) + .lt(SgEvent::getDuration, durationTimeRange[1]) + .eq(SgEvent::getState, DataStateEnum.ENABLE.getCode()) + .between(SgEvent::getStartTime, + LocalDateTimeUtil.parse(startTime, DatePattern.NORM_DATE_PATTERN), + LocalDateTimeUtil.parse(endTime, DatePattern.NORM_DATE_PATTERN) + ); + int count = this.count(lambdaQueryWrapper); + if (count > 0) { + Integer[] key = new Integer[2]; + key[0] = (int) ((amplitudeRange[0] + amplitudeRange[1]) / 2); + key[1] = (int) ((durationTimeRange[0] + durationTimeRange[1]) / 2); + eventMap.put(key, count); + } + } + } + return eventMap; + } + + /** + * 根据备用路线查询暂降事件与当前进线做对比,是否能做治理优化 + * + * @param id 当前进线id + * @param incomingLineId 备用进线id + * @param startTime 起始时间 + * @param endTime 截止时间 + * @param actionTime 动作时间 + */ + @Override + public Map countEventMap4Switch(Map eventMap, String id, String incomingLineId, String startTime, String endTime, Double actionTime) { + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper.eq(SgEvent::getIncomingLineId, id) + .between(SgEvent::getStartTime, + LocalDateTimeUtil.parse(startTime, DatePattern.NORM_DATE_PATTERN), + LocalDateTimeUtil.parse(endTime, DatePattern.NORM_DATE_PATTERN) + ); + List mainList = this.list(lambdaQueryWrapper); + List subList = new ArrayList<>(); + int beforeCount = mainList.size(); + if (beforeCount > 0) { + // 主线有暂降在算辅线 + LambdaQueryWrapper lambdaQueryWrapperBackup = new LambdaQueryWrapper<>(); + lambdaQueryWrapperBackup.eq(SgEvent::getIncomingLineId, incomingLineId) + .between(SgEvent::getStartTime, + LocalDateTimeUtil.parse(startTime, DatePattern.NORM_DATE_PATTERN), + LocalDateTimeUtil.parse(endTime, DatePattern.NORM_DATE_PATTERN) + ).eq(SgEvent::getState, DataStateEnum.ENABLE.getCode()); + subList = this.list(lambdaQueryWrapperBackup); + subList = intersectionList(mainList, subList); + } + int afterCount = subList.size(); + if (beforeCount > 0 && afterCount > 0) { + //两条进线的暂降发生时间可重复度超过50%,不输出快切开关治理 + if ((double) afterCount / (double) beforeCount > 0.5) { + return eventMap; + } + } + + // 按响应时间对暂降数据进行过滤,并合并重复暂降数据 + mainList = processTimeResponse(mainList, subList, actionTime.intValue()); + return fillMap(mainList); + } + + @Override + public List countEvent4Switch(List sgEventList, String id, String incomingLineId, String startTime, String endTime, Double actionTime) { + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper.eq(SgEvent::getIncomingLineId, id) + .between(SgEvent::getStartTime, + LocalDateTimeUtil.parse(startTime, DatePattern.NORM_DATE_PATTERN), + LocalDateTimeUtil.parse(endTime, DatePattern.NORM_DATE_PATTERN) + ); + List mainList = this.list(lambdaQueryWrapper); + List subList = new ArrayList<>(); + int beforeCount = mainList.size(); + if (beforeCount > 0) { + // 主线有暂降在算辅线 + LambdaQueryWrapper lambdaQueryWrapperBackup = new LambdaQueryWrapper<>(); + lambdaQueryWrapperBackup.eq(SgEvent::getIncomingLineId, incomingLineId) + .between(SgEvent::getStartTime, + LocalDateTimeUtil.parse(startTime, DatePattern.NORM_DATE_PATTERN), + LocalDateTimeUtil.parse(endTime, DatePattern.NORM_DATE_PATTERN) + ).eq(SgEvent::getState, DataStateEnum.ENABLE.getCode()); + subList = this.list(lambdaQueryWrapperBackup); + subList = intersectionList(mainList, subList); + } + int afterCount = subList.size(); + if (beforeCount > 0 && afterCount > 0) { + //两条进线的暂降发生时间可重复度超过50%,不输出快切开关治理 + if ((double) afterCount / (double) beforeCount > 0.5) { + return sgEventList; + } + } + + // 按响应时间对暂降数据进行过滤,并合并重复暂降数据 + mainList = processTimeResponse(mainList, subList, actionTime.intValue()); + return mainList; + + } + + @Override + public boolean deleteEventData(List ids) { + return this.lambdaUpdate() + .set(SgEvent::getState, DataStateEnum.DELETED.getCode()) + .in(SgEvent::getId, ids) + .update(); + } + + @Override + public TransientEventCountVO threeDList(SgEventParam.SgEventParamQueryParam sgEventParamQueryParam) { + TransientEventCountVO params = new TransientEventCountVO(); + String beginDate = sgEventParamQueryParam.getSearchBeginTime(); + String endDate = sgEventParamQueryParam.getSearchEndTime(); + String userId = sgEventParamQueryParam.getUserId(); + LambdaQueryWrapper sgIncomingLineLambdaQueryWrapper = new LambdaQueryWrapper<>(); + sgIncomingLineLambdaQueryWrapper.eq(SgIncomingLine::getUserId, userId) + .eq(SgIncomingLine::getState, DataStateEnum.ENABLE.getCode()); + List imcomingLineList = sgIncomingLineService.list(sgIncomingLineLambdaQueryWrapper); + //根据用户id获取所有的进线id + if (CollectionUtil.isEmpty(imcomingLineList)) { + return null; + } + List incomingLineIDList = imcomingLineList.stream().map(SgIncomingLine::getId).collect(Collectors.toList()); + List> list = countEventTims(incomingLineIDList, beginDate, endDate); + // 转换 + ArrayList amplitudes = new ArrayList<>(); + ArrayList durations = new ArrayList<>(); + ArrayList> value = new ArrayList<>(); + List tbList = new ArrayList<>(); + for (int i = 0; i < list.size(); i++) { + List list1 = list.get(i); + for (int j = 0; j < list1.size(); j++) { + if (i == 0 && j == 0) + continue; + Object v = list1.get(j); + if (i == 0) {//第一行为持续时间 + durations.add(String.valueOf(v)); + } else { + if (j == 0) {//第一列为幅值 + amplitudes.add(String.valueOf(v)); + } else { + ArrayList vv = new ArrayList(); + String amplitude = amplitudes.get(i - 1); + vv.add(amplitude); + + String duration = durations.get(j - 1); + vv.add(duration); + + vv.add(String.valueOf(v)); + value.add(vv); + } + } + } + } + String strTwo[][] = new String[value.size()][]; + for (int i = 0; i < value.size(); i++) { + ArrayList v = value.get(i); + String[] vv = v.toArray(new String[v.size()]); + strTwo[i] = vv; + } + params.setValues(strTwo); + + list.remove(0); + for (List l : list) { + TransientEventCount count = new TransientEventCount(); + count.setAmplitude(String.valueOf(l.get(0))); + count.setD001_002s(String.valueOf(l.get(1))); + count.setD002_005s(String.valueOf(l.get(2))); + count.setD005_007s(String.valueOf(l.get(3))); + count.setD007_010s(String.valueOf(l.get(4))); + count.setD010_100s(String.valueOf(l.get(5))); + tbList.add(count); + } + return params; + } + + @Override + public void calcLoss(String id) { + SgEvent sgEvent = this.getById(id); + //获取生产线信息 + ProductLineComputeData productLineComputeData = productLineService.assginProductLineComputeData(sgEvent.getProductLineId()); + //根据暂降信息计算预估损失 + Double[] eventEffect = this.getEventLossAndFailureRate(productLineComputeData, sgEvent.getFeatureAmplitude(), sgEvent.getDuration()); + Double singleLoss = eventEffect[0]; + sgEvent.setEstimatedLoss(singleLoss); + this.baseMapper.updateById(sgEvent); + } + + + /** + * 需要计算出生产线故障率和生产线此次的损失 + * + * @param productLineComputeData 生产线数据 + * @param amplitude 特征幅值 + * @param durationTime 持续时间 + */ + @Override + public Double[] getEventLossAndFailureRate(ProductLineComputeData productLineComputeData, double amplitude, double durationTime) { + //总损失 + Double totalLoss = 0.0; + //生产线故障率 + Double productFailureRate = 0.0; + //如果是模式二,需要独立计算下设备损失+原料损失 + List machineVOList = productLineComputeData.getMachineVOList(); + if (CollectionUtil.isNotEmpty(machineVOList)) { + for (int i = 0; i < machineVOList.size(); i++) { + List sgSensitiveUnitList = machineVOList.get(i).getSgSensitiveUnitList(); + //计算故障率 + double devFailureRate = getDevFailureRate(sgSensitiveUnitList, amplitude, durationTime); + if (productLineComputeData.getCalcMode() == 1) { + //根据该故障率以及设备损失、原料损失计算出该设备单次的损失 + double machineLoss = (machineVOList.get(i).getMachineLoss() + machineVOList.get(i).getMaterialLoss()) * devFailureRate; + totalLoss = totalLoss + machineLoss; + } + //顺便计算出生产线的故障率 + if (i == 0) { + productFailureRate = devFailureRate; + } else { + // 默认设备是串联的 + productFailureRate = 1 - (1 - productFailureRate) * (1 - devFailureRate); + } + } + //计算完各个设备的损失,最终计算下生产线在该暂降幅值、持续时间条件下的单独的经济损失 + totalLoss = totalLoss + productLineComputeData.getCapacityLoss() * productFailureRate; + } + totalLoss = PubUtils.doubleRound(2, totalLoss); + return new Double[]{totalLoss, productFailureRate}; + } + + @Override + public List getEventDataByProductLineId(SgEventParam.SgEventParamQueryParam sgEventParamQueryParam) { + return this.baseMapper.getEventDataByProductLineId(sgEventParamQueryParam.getProductId(), LocalDateTimeUtil.parse(sgEventParamQueryParam.getSearchBeginTime(), DatePattern.NORM_DATE_PATTERN), + LocalDateTimeUtil.parse(sgEventParamQueryParam.getSearchEndTime(), DatePattern.NORM_DATE_PATTERN)); + } + + /** + * 计算生产线下设备的故障率 + * + * @param sgSensitiveUnitList 敏感元件数据 + * @param amplitude 特征幅值 + * @param durationTime 持续时间 ms + */ + private double getDevFailureRate(List sgSensitiveUnitList, double amplitude, double durationTime) { + if (CollectionUtil.isEmpty(sgSensitiveUnitList)) { + return 0; + } + double rate = 0; + boolean first = true; + for (SgSensitiveUnitVO sgSensitiveUnitVO : sgSensitiveUnitList) { + double unitRate = 0; + Double uMax = sgSensitiveUnitVO.getVtcAmpUpper(); + Double uMin = sgSensitiveUnitVO.getVtcAmpLower(); + Double timeMax = sgSensitiveUnitVO.getVtcTimeLower(); + Double timeMin = sgSensitiveUnitVO.getVtcTimeUpper(); + if (amplitude > uMax || durationTime < timeMin) { + // 暂降幅值大于最大值,或者持续时间小于最小值,属于正常状态(故障率0) + unitRate = 0; + } else if (amplitude < uMin && durationTime > timeMax) { + // 暂降幅值小于最小值和持续时间大于最大值,有一个故障就返回故障(故障率1) + unitRate = 1; + } else { + // 根据灵敏度得到FtFu + double fu, ft; + if (sgSensitiveUnitVO.getSensitivity() == 3) { + // 低灵敏度 + // 残余电压取指数分布,公式1-6 + double tt1 = amplitude - uMin; + tt1 = -100 * tt1; + tt1 = Math.exp(tt1); + fu = 100 * tt1; + // 持续时间取反指数分布,公式1-7 + double tt2 = durationTime - timeMin; + tt2 = 100 * tt2; + tt2 = Math.exp(tt2); + ft = 100 * tt2; + } else if (sgSensitiveUnitVO.getSensitivity() == 2) { + // 中灵敏度,残余电压和持续时间均取正态分布,公式1-8 + double tt1 = (double) 1 / (0.17 * Math.sqrt(2 * 3.14)); + double tt2 = Math.pow(durationTime - (uMax + uMin) / 2, 2); + double tt3 = Math.pow(amplitude - (timeMin + timeMax) / 2, 2); + double tt4 = (double) 2 * Math.pow(0.17, 2); + // 残余电压 + double ttt1 = tt2 / tt4; + ttt1 = 0 - ttt1; + ttt1 = Math.exp(ttt1); + fu = tt1 * ttt1; + // 持续时间 + double ttt2 = tt3 / tt4; + ttt2 = 0 - ttt2; + ttt2 = Math.exp(ttt2); + ft = tt1 * ttt2; + } else if (sgSensitiveUnitVO.getSensitivity() == 1) { + // 高灵敏度 + // 残余电压取反指数分布,公式1-7 + double tt1 = amplitude - uMax; + tt1 = 100 * tt1; + tt1 = Math.exp(tt1); + fu = 100 * tt1; + // 持续时间取指数分布,公式1-6 + double tt2 = durationTime - timeMin; + tt2 = -100 * tt2; + tt2 = Math.exp(tt2); + ft = 100 * tt2; + } else { + // 默认灵敏度,均匀分布,公式1-5 + fu = (float) 1 / (uMax - uMin); + ft = (float) 1 / (timeMax - timeMin); + } + + //判断在ABC哪个区域 + if (durationTime >= timeMin && durationTime <= timeMax && amplitude >= uMin && amplitude <= uMax) { + // A区,公式1-1 + if (Double.isNaN(fu) || Double.isNaN(ft)) { + unitRate = 0; + } else if (Double.isInfinite(fu) || Double.isInfinite(ft)) { + unitRate = 1; + } else { + unitRate = (uMax - amplitude) * fu * (durationTime - timeMin) * ft; + } + } + if (durationTime > timeMax && amplitude >= uMin && amplitude <= uMax) { + // B区,公式1-2 + unitRate = (uMax - amplitude) * fu; + } + if (durationTime > timeMin && durationTime <= timeMax && amplitude < uMin) { + // C区,公式1-3 + if (Double.isNaN(ft)) { + unitRate = 0; + } else if (Double.isInfinite(ft)) { + unitRate = 1; + } else { + unitRate = (durationTime - timeMin) * ft; + } + } + } + if (first) { + rate = unitRate; + first = false; + } else { + // 元器件串联 + rate = 1 - (1 - rate) * (1 - unitRate); + } + } + return rate; + } + + + /** + * 统计暂降事件发生次数, 限定条件降幅范围和持续时间范围 + * + * @param lineIds + * @param beginDate + * @param endDate + * @return + */ + public List> countEventTims(List lineIds, String beginDate, String endDate) { + List> rList = new ArrayList(); + List firstRow = new ArrayList<>(); + firstRow.add("幅值\\持续时间"); + rList.add(firstRow); + boolean b = true; + for (double[] amplitudeRange : AMPLITUDE) { + ArrayList row = getOneRowEventTimesData(b ? firstRow : null, amplitudeRange, DURATION_TIME, lineIds, beginDate, endDate); + rList.add(row); + b = false; + } + return rList; + } + + /** + * 获取一行事件次数统计数据 + * + * @param amplitudeRange + * @param durationTime + * @param lineIds + * @param beginDate + * @param endDate + * @return + */ + private ArrayList getOneRowEventTimesData(List firstRow, double[] amplitudeRange, double[][] durationTime, List lineIds, String beginDate, String endDate) { + ArrayList rList = new ArrayList(); + rList.add(NumberUtil.format(amplitudeRange[0] * 0.01, "0.0") + "~" + NumberUtil.format(amplitudeRange[1] * 0.01, "0.0")); + for (double[] durationTimeRange : durationTime) { + if (firstRow != null) { + firstRow.add(NumberUtil.format(durationTimeRange[0] * 0.001, "0.00") + "~" + NumberUtil.format(durationTimeRange[1] * 0.001, "0.00")); + } + LambdaQueryWrapper sgEventLambdaQueryWrapper = new LambdaQueryWrapper<>(); + sgEventLambdaQueryWrapper.eq(SgEvent::getState, DataStateEnum.ENABLE.getCode()) + .between(SgEvent::getStartTime, + LocalDateTimeUtil.parse(beginDate, DatePattern.NORM_DATE_PATTERN), + LocalDateTimeUtil.parse(endDate, DatePattern.NORM_DATE_PATTERN) + ) + .in(SgEvent::getIncomingLineId, lineIds) + .between(SgEvent::getDuration, durationTimeRange[0], durationTimeRange[1]) + .between(SgEvent::getFeatureAmplitude, amplitudeRange[0] * 0.01, amplitudeRange[1] * 0.01); + Integer count = this.count(sgEventLambdaQueryWrapper); + rList.add(count); + } + return rList; + } + + + /** + * 计算两个List的交集 + * + * @param aList 主进线的暂降事件 + * @param bList 备用进线的暂降事件 + */ + private List intersectionList(List aList, List bList) { + List rList = new ArrayList<>(); + for (SgEvent a : aList) { + boolean bol = false; + // 如果响应时间小于持续时间,再看辅线是否暂降 + for (SgEvent b : bList) { + bol = comparisonEvent(a, b); + if (bol) { + break; + } + } + if (bol) { + rList.add(a); + } + } + return rList; + } + + /** + * 用于判断两个事件持续的时间是否有重合,重合即不可修复。 + * + * @param mainEvent 主进线事件 + * @param backUpEvent 备用进线事件 + */ + private boolean comparisonEvent(SgEvent mainEvent, SgEvent backUpEvent) { + LocalDateTime begin = mainEvent.getStartTime(); + LocalDateTime end = LocalDateTimeUtil.offset(begin, mainEvent.getDuration().longValue(), ChronoUnit.MILLIS); + LocalDateTime target = backUpEvent.getStartTime(); + if (!target.isBefore(begin) && !target.isAfter(end)) { + return true; + } else { + return false; + } + } + + /** + * 拼接不能治理的暂降数据和重复暂降数据 + * + * @param mainEvents 原始暂降数据 + * @param backupEvents 重复的暂降数据 + * @param timeResponse 快切开关响应时间 + */ + private List processTimeResponse(List mainEvents, List backupEvents, int timeResponse) { + List rList = new ArrayList<>(); + for (SgEvent a : mainEvents) { + boolean bol = false; + // 考虑响应时间 + if (timeResponse > a.getDuration()) { + bol = true; + } + if (bol) { + rList.add(a); + } + } + + // 将重复的暂降数据bList加入到rList中 + for (SgEvent b : backupEvents) { + boolean bol = false; + for (SgEvent c : rList) { + // 重复检测 + if (Objects.equals(b.getId(), c.getId())) { + bol = true; + break; + } + } + + if (!bol) { + rList.add(b); + } + } + + return rList; + } + + + /** + * 通过循环List累加的方式,统计频次 + * + * @param eventList 暂降事件集合 + */ + private Map fillMap(List eventList) { + Map rMap = new HashMap<>(); + for (SgEvent event : eventList) { + Integer[] key = getKey(event.getDuration(), event.getFeatureAmplitude()); + if (rMap.containsKey(key)) { + rMap.put(key, rMap.get(key) + 1); + } else { + rMap.put(key, 1); + } + } + return rMap; + } + + /** + * 通过持续时间和幅值,获取频次表的key + * + * @param eventDurationTime 持续时间 + * @param eventAmplitude 特征幅值 + */ + private Integer[] getKey(double eventDurationTime, double eventAmplitude) { + Integer[] key = {0, 0}; + double eAmpl = eventAmplitude * 100; + for (double[] a : AMPLITUDE) { + if (eAmpl > a[0] && eAmpl <= a[1]) { + Integer t2 = AMPLITUDE_KEY_MAP.get(a); + key[0] = t2; + } + } + double eTime = eventDurationTime; + for (double[] a : DURATION_TIME) { + if (eTime > a[0] && eTime <= a[1]) { + Integer t1 = DURATION_TIME_KEY_MAP.get(a); + key[1] = t1; + } + } + return key; + } + + } diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/SgGovernSchemeHistoryDetailServiceImpl.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/SgGovernSchemeHistoryDetailServiceImpl.java new file mode 100644 index 000000000..a099b3344 --- /dev/null +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/SgGovernSchemeHistoryDetailServiceImpl.java @@ -0,0 +1,20 @@ +package com.njcn.advance.service.govern.voltage.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.njcn.advance.mapper.govern.voltage.SgGovernSchemeHistoryDetailMapper; +import com.njcn.advance.pojo.po.govern.voltage.SgGovernSchemeHistoryDetail; +import com.njcn.advance.service.govern.voltage.ISgGovernSchemeHistoryDetailService; +import org.springframework.stereotype.Service; + +/** + *

+ * 服务实现类 + *

+ * + * @author hongawen + * @since 2024-03-27 + */ +@Service +public class SgGovernSchemeHistoryDetailServiceImpl extends ServiceImpl implements ISgGovernSchemeHistoryDetailService { + +} diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/SgGovernSchemeHistoryServiceImpl.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/SgGovernSchemeHistoryServiceImpl.java new file mode 100644 index 000000000..d5c5e7a10 --- /dev/null +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/SgGovernSchemeHistoryServiceImpl.java @@ -0,0 +1,84 @@ +package com.njcn.advance.service.govern.voltage.impl; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.njcn.advance.mapper.govern.voltage.SgGovernSchemeHistoryMapper; +import com.njcn.advance.pojo.param.govern.voltage.SgGovernSchemeHistoryParam; +import com.njcn.advance.pojo.po.govern.voltage.SgGovernSchemeHistory; +import com.njcn.advance.pojo.po.govern.voltage.SgProductLine; +import com.njcn.advance.pojo.po.govern.voltage.SgUser; +import com.njcn.advance.pojo.vo.govern.voltage.SgGovernSchemeHistoryVO; +import com.njcn.advance.pojo.vo.govern.voltage.SgProductLineVO; +import com.njcn.advance.service.govern.voltage.ISgGovernSchemeHistoryService; +import com.njcn.advance.service.govern.voltage.ISgProductLineService; +import com.njcn.common.pojo.enums.common.DataStateEnum; +import com.njcn.web.factory.PageFactory; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** + *

+ * 服务实现类 + *

+ * + * @author hongawen + * @since 2024-03-27 + */ +@Service +@RequiredArgsConstructor +public class SgGovernSchemeHistoryServiceImpl extends ServiceImpl implements ISgGovernSchemeHistoryService { + + + private final ISgProductLineService productLineService; + + /** + * 分页查询出治理方案下的历史数据 + * + * @param sgSchemeHistoryQueryParam 查询条件 + */ + @Override + public Page schemeHistoryList(SgGovernSchemeHistoryParam.SgSchemeHistoryQueryParam sgSchemeHistoryQueryParam) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + List productId = new ArrayList<>(); + if (StrUtil.isNotBlank(sgSchemeHistoryQueryParam.getUserId())) { + //查询出该用户下所有的生产线 + LambdaQueryWrapper sgProductLineLambdaQueryWrapper = new LambdaQueryWrapper<>(); + sgProductLineLambdaQueryWrapper + .select(SgProductLine::getId) + .eq(SgProductLine::getUserId, sgSchemeHistoryQueryParam.getUserId()) + .eq(SgProductLine::getState, DataStateEnum.ENABLE.getCode()); + List sgProductLineList = productLineService.list(sgProductLineLambdaQueryWrapper); + if (CollectionUtil.isNotEmpty(sgProductLineList)) { + productId = sgProductLineList.stream().map(SgProductLine::getId).collect(Collectors.toList()); + } + if(CollectionUtil.isEmpty(productId)){ + return new Page<>(); + } + } + //如果生产线不为空,则加入生产线查询 + if (CollectionUtil.isNotEmpty(productId)) { + queryWrapper.in("sg_govern_scheme_history.product_line_id", productId); + } + queryWrapper.eq("sg_govern_scheme_history.state", DataStateEnum.ENABLE.getCode()); + queryWrapper.orderByDesc("sg_govern_scheme_history.create_time"); + Page data = this.baseMapper.page(new Page<>(PageFactory.getPageNum(sgSchemeHistoryQueryParam), PageFactory.getPageSize(sgSchemeHistoryQueryParam)), queryWrapper); + + return data; + } + + @Override + public boolean deleteScheme(List ids) { + return this.lambdaUpdate() + .set(SgGovernSchemeHistory::getState, DataStateEnum.DELETED.getCode()) + .in(SgGovernSchemeHistory::getId, ids) + .update(); + } +} diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/SgGovernSchemeParamServiceImpl.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/SgGovernSchemeParamServiceImpl.java new file mode 100644 index 000000000..39c6e9acf --- /dev/null +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/SgGovernSchemeParamServiceImpl.java @@ -0,0 +1,20 @@ +package com.njcn.advance.service.govern.voltage.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.njcn.advance.mapper.govern.voltage.SgGovernSchemeParamMapper; +import com.njcn.advance.pojo.po.govern.voltage.SgGovernSchemeParam; +import com.njcn.advance.service.govern.voltage.ISgGovernSchemeParamService; +import org.springframework.stereotype.Service; + +/** + *

+ * 服务实现类 + *

+ * + * @author hongawen + * @since 2024-03-27 + */ +@Service +public class SgGovernSchemeParamServiceImpl extends ServiceImpl implements ISgGovernSchemeParamService { + +} diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/SgIncomingLineServiceImpl.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/SgIncomingLineServiceImpl.java index 58a7bb580..d72a098ed 100644 --- a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/SgIncomingLineServiceImpl.java +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/SgIncomingLineServiceImpl.java @@ -11,6 +11,7 @@ import com.njcn.advance.pojo.param.govern.voltage.SgUserParam; import com.njcn.advance.pojo.po.govern.voltage.SgIncomingLine; import com.njcn.advance.pojo.po.govern.voltage.SgUser; import com.njcn.advance.pojo.vo.govern.voltage.IncomingLineVO; +import com.njcn.advance.pojo.vo.govern.voltage.SgOption; import com.njcn.advance.service.govern.voltage.ISgIncomingLineService; import com.njcn.common.pojo.enums.common.DataStateEnum; import com.njcn.common.pojo.exception.BusinessException; @@ -82,6 +83,11 @@ public class SgIncomingLineServiceImpl extends ServiceImpl lineList() { + return this.baseMapper.lineList(); + } + /** * 校验进线名称是否有重复的 * @param incomingLineParam 进线数据 diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/SgMachineServiceImpl.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/SgMachineServiceImpl.java index 008bb6feb..43d7178c0 100644 --- a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/SgMachineServiceImpl.java +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/SgMachineServiceImpl.java @@ -12,12 +12,16 @@ import com.njcn.advance.pojo.param.govern.voltage.SgMachineParam; import com.njcn.advance.pojo.param.govern.voltage.SgProductLineParam; import com.njcn.advance.pojo.po.govern.voltage.SgMachine; import com.njcn.advance.pojo.po.govern.voltage.SgProductLine; +import com.njcn.advance.pojo.po.govern.voltage.SgSensitiveUnit; +import com.njcn.advance.pojo.po.govern.voltage.SgUser; import com.njcn.advance.pojo.vo.govern.voltage.SgMachineVO; import com.njcn.advance.pojo.vo.govern.voltage.SgProductLineVO; import com.njcn.advance.service.govern.voltage.ISgMachineService; +import com.njcn.advance.service.govern.voltage.ISgSensitiveUnitService; import com.njcn.common.pojo.enums.common.DataStateEnum; import com.njcn.common.pojo.exception.BusinessException; import com.njcn.web.factory.PageFactory; +import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import java.util.List; @@ -31,8 +35,11 @@ import java.util.List; * @since 2024-03-14 */ @Service +@RequiredArgsConstructor public class SgMachineServiceImpl extends ServiceImpl implements ISgMachineService { + private final ISgSensitiveUnitService sgSensitiveUnitService; + @Override public Page sgMachineListByProductLineId(SgMachineParam.SgMachineQueryParam sgMachineQueryParam) { if(StrUtil.isBlank(sgMachineQueryParam.getProductLineId())){ @@ -76,10 +83,31 @@ public class SgMachineServiceImpl extends ServiceImpl ids) { - return this.lambdaUpdate() - .set(SgMachine::getState, DataStateEnum.DELETED.getCode()) - .in(SgMachine::getId, ids) - .update(); + LambdaQueryWrapper sgSensitiveUnitLambdaQueryWrapper; + for (String id : ids) { + sgSensitiveUnitLambdaQueryWrapper = new LambdaQueryWrapper<>(); + sgSensitiveUnitLambdaQueryWrapper.eq(SgSensitiveUnit::getMachineId, id) + .eq(SgSensitiveUnit::getState, DataStateEnum.ENABLE.getCode()); + int count = sgSensitiveUnitService.count(sgSensitiveUnitLambdaQueryWrapper); + if (count > 0) { + throw new BusinessException(AdvanceResponseEnum.MACHINE_HAS_UNIT); + } else { + this.lambdaUpdate().set(SgMachine::getState, DataStateEnum.DELETED.getCode()) + .eq(SgMachine::getId, id) + .update(); + } + + } + return true; + } + + /** + * 根据生产线获取其所有的设备信息 + * @param productLineId 生产线id + */ + @Override + public List listAllMachineByProductLineId(String productLineId) { + return this.baseMapper.listAllMachineByProductLineId(productLineId); } diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/SgProductLineServiceImpl.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/SgProductLineServiceImpl.java index e70eeebc3..c7e6b06fb 100644 --- a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/SgProductLineServiceImpl.java +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/SgProductLineServiceImpl.java @@ -9,15 +9,20 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.njcn.advance.enums.AdvanceResponseEnum; import com.njcn.advance.mapper.govern.voltage.SgProductLineMapper; +import com.njcn.advance.pojo.dto.govern.voltage.ProductLineComputeData; import com.njcn.advance.pojo.param.govern.voltage.SgProductLineParam; import com.njcn.advance.pojo.param.govern.voltage.SgUserParam; import com.njcn.advance.pojo.po.govern.voltage.SgMachine; import com.njcn.advance.pojo.po.govern.voltage.SgProductLine; +import com.njcn.advance.pojo.po.govern.voltage.SgSensitiveUnit; import com.njcn.advance.pojo.po.govern.voltage.SgUser; +import com.njcn.advance.pojo.vo.govern.voltage.SgMachineVO; import com.njcn.advance.pojo.vo.govern.voltage.SgProductLineVO; +import com.njcn.advance.pojo.vo.govern.voltage.SgSensitiveUnitVO; import com.njcn.advance.pojo.vo.govern.voltage.SgUserVO; import com.njcn.advance.service.govern.voltage.ISgMachineService; import com.njcn.advance.service.govern.voltage.ISgProductLineService; +import com.njcn.advance.service.govern.voltage.ISgSensitiveUnitService; import com.njcn.common.pojo.enums.common.DataStateEnum; import com.njcn.common.pojo.exception.BusinessException; import com.njcn.web.factory.PageFactory; @@ -43,6 +48,8 @@ public class SgProductLineServiceImpl extends ServiceImpl data = this.baseMapper.page(new Page<>(PageFactory.getPageNum(sgProductLineQueryParam), PageFactory.getPageSize(sgProductLineQueryParam)), queryWrapper); + Page data = this.baseMapper.page(new Page<>(PageFactory.getPageNum(sgProductLineQueryParam), PageFactory.getPageSize(sgProductLineQueryParam)), queryWrapper); List records = data.getRecords(); //循环遍历处理下生产线总功率、设备损失、原料损失 - if(CollectionUtil.isNotEmpty(records)){ + if (CollectionUtil.isNotEmpty(records)) { //根据生产线获取下面所有设备 List productLineIdList = records.stream().map(SgProductLineVO::getId).collect(Collectors.toList()); LambdaQueryWrapper sgMachineLambdaQueryWrapper = new LambdaQueryWrapper<>(); - sgMachineLambdaQueryWrapper.in(SgMachine::getProductLineId,productLineIdList) - .eq(SgMachine::getState,DataStateEnum.ENABLE.getCode()); + sgMachineLambdaQueryWrapper.in(SgMachine::getProductLineId, productLineIdList) + .eq(SgMachine::getState, DataStateEnum.ENABLE.getCode()); List machineList = machineService.list(sgMachineLambdaQueryWrapper); //判断是否有设备数据,有的话,进行java分组,以生产线id为key Map> stringListMap = machineList.stream().collect(Collectors.groupingBy(SgMachine::getProductLineId)); for (SgProductLineVO sgProductLineVO : records) { String productLineId = sgProductLineVO.getId(); List machineListTemp = stringListMap.get(productLineId); - if(CollectionUtil.isNotEmpty(machineListTemp)){ + if (CollectionUtil.isNotEmpty(machineListTemp)) { //设备总损失 double machineLossSum = machineListTemp.stream().mapToDouble(SgMachine::getMachineLoss).sum(); sgProductLineVO.setMachineLoss(machineLossSum); @@ -90,6 +97,7 @@ public class SgProductLineServiceImpl extends ServiceImpl ids) { - return this.lambdaUpdate() - .set(SgProductLine::getState, DataStateEnum.DELETED.getCode()) - .in(SgProductLine::getId, ids) - .update(); + LambdaQueryWrapper sgMachineLambdaQueryWrapper; + for (String id : ids) { + sgMachineLambdaQueryWrapper = new LambdaQueryWrapper<>(); + sgMachineLambdaQueryWrapper.eq(SgMachine::getProductLineId, id) + .eq(SgMachine::getState, DataStateEnum.ENABLE.getCode()); + int count = machineService.count(sgMachineLambdaQueryWrapper); + if (count > 0) { + throw new BusinessException(AdvanceResponseEnum.PRODUCT_HAS_MACHINE); + } else { + this.lambdaUpdate() + .set(SgProductLine::getState, DataStateEnum.DELETED.getCode()) + .eq(SgProductLine::getId, id) + .update(); + } + } + return true; } /** * 根据用户id获取生产线信息 + * * @param userId 用户id */ @Override - public List querySgProductLineByUserId(String userId) { - LambdaQueryWrapper sgProductLineLambdaQueryWrapper = new LambdaQueryWrapper<>(); - sgProductLineLambdaQueryWrapper - .eq(SgProductLine::getUserId, userId) - .eq(SgProductLine::getState, DataStateEnum.ENABLE.getCode()); - return this.list(sgProductLineLambdaQueryWrapper); + public List querySgProductLineByUserId(String userId) { + QueryWrapper sgProductLineVOQueryWrapper = new QueryWrapper<>(); + sgProductLineVOQueryWrapper.eq("sg_product_line.user_id", userId) + .eq("sg_product_line.state", DataStateEnum.ENABLE.getCode()) + .orderByDesc("sg_product_line.create_time"); + return this.baseMapper.querySgProductLineByUserId(sgProductLineVOQueryWrapper); + } + + /** + * 根据生产线id获取待计算的损失的所有设备、元器件数据 + * + * @param productLineId 生产线id + */ + @Override + public ProductLineComputeData assginProductLineComputeData(String productLineId) { + ProductLineComputeData productLineComputeData = new ProductLineComputeData(); + SgProductLine sgProductLine = this.getById(productLineId); + BeanUtil.copyProperties(sgProductLine, productLineComputeData); + //获取该生产线下所有设备数据 + List sgMachineVOList = machineService.listAllMachineByProductLineId(productLineId); + if (CollectionUtil.isNotEmpty(sgMachineVOList)) { + productLineComputeData.setMachineVOList(sgMachineVOList); + //获取每个设备下的敏感元器件数据 + for (SgMachineVO sgMachineVO : sgMachineVOList) { + List sgSensitiveUnitVOList = sgSensitiveUnitService.listAllUnitByMachineId(sgMachineVO.getId()); + if(CollectionUtil.isNotEmpty(sgSensitiveUnitVOList)){ + sgMachineVO.setSgSensitiveUnitList(sgSensitiveUnitVOList); + } + } + } + return productLineComputeData; + } + + @Override + public String getUserNameByProductId(String id) { + return this.baseMapper.getUserNameByProductId(id); } /** diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/SgSensitiveUnitServiceImpl.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/SgSensitiveUnitServiceImpl.java index faa920695..7ddf2a8e5 100644 --- a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/SgSensitiveUnitServiceImpl.java +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/SgSensitiveUnitServiceImpl.java @@ -18,6 +18,7 @@ import com.njcn.common.pojo.exception.BusinessException; import com.njcn.web.factory.PageFactory; import org.springframework.stereotype.Service; +import java.util.ArrayList; import java.util.List; /** @@ -84,4 +85,12 @@ public class SgSensitiveUnitServiceImpl extends ServiceImpl listAllUnitByMachineId(String machineId) { + if(StrUtil.isBlank(machineId)){ + return new ArrayList<>(); + } + return this.baseMapper.listAllUnitByMachineId(machineId); + } } diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/SgUserServiceImpl.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/SgUserServiceImpl.java index ec927514e..45b969504 100644 --- a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/SgUserServiceImpl.java +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/service/govern/voltage/impl/SgUserServiceImpl.java @@ -10,14 +10,19 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.njcn.advance.mapper.govern.voltage.SgUserMapper; import com.njcn.advance.pojo.param.govern.voltage.SgUserParam; +import com.njcn.advance.pojo.po.govern.voltage.SgIncomingLine; +import com.njcn.advance.pojo.po.govern.voltage.SgProductLine; import com.njcn.advance.pojo.po.govern.voltage.SgUser; import com.njcn.advance.pojo.vo.govern.voltage.SgUserVO; +import com.njcn.advance.service.govern.voltage.ISgIncomingLineService; +import com.njcn.advance.service.govern.voltage.ISgProductLineService; import com.njcn.advance.service.govern.voltage.ISgUserService; import com.njcn.common.pojo.enums.common.DataStateEnum; import com.njcn.common.pojo.exception.BusinessException; import com.njcn.db.constant.DbConstant; import com.njcn.advance.enums.AdvanceResponseEnum; import com.njcn.web.factory.PageFactory; +import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import java.util.List; @@ -31,8 +36,13 @@ import java.util.List; * @since 2024-02-29 */ @Service +@RequiredArgsConstructor public class SgUserServiceImpl extends ServiceImpl implements ISgUserService { + private final ISgProductLineService productLineService; + + private final ISgIncomingLineService incomingLineService; + @Override public Page sgUserList(SgUserParam.SgUserQueryParam sgUserQueryParam) { QueryWrapper queryWrapper = new QueryWrapper<>(); @@ -57,7 +67,23 @@ public class SgUserServiceImpl extends ServiceImpl impleme queryWrapper.orderByDesc("sg_user.create_time"); } queryWrapper.eq("sg_user.state", DataStateEnum.ENABLE.getCode()); - return this.baseMapper.page(new Page<>(PageFactory.getPageNum(sgUserQueryParam), PageFactory.getPageSize(sgUserQueryParam)), queryWrapper); + Page sgUserVOPage = this.baseMapper.page(new Page<>(PageFactory.getPageNum(sgUserQueryParam), PageFactory.getPageSize(sgUserQueryParam)), queryWrapper); + if (CollectionUtil.isNotEmpty(sgUserVOPage.getRecords())) { + List records = sgUserVOPage.getRecords(); + //获取该用户的生产线数量和进线数量 + for (SgUserVO record : records) { + LambdaQueryWrapper productLineLambdaQueryWrapper = new LambdaQueryWrapper<>(); + productLineLambdaQueryWrapper.eq(SgProductLine::getUserId, record.getId()) + .eq(SgProductLine::getState, DataStateEnum.ENABLE.getCode()); + record.setProductCount(productLineService.count(productLineLambdaQueryWrapper)); + LambdaQueryWrapper incomingLineLambdaQueryWrapper = new LambdaQueryWrapper<>(); + incomingLineLambdaQueryWrapper.eq(SgIncomingLine::getUserId, record.getId()) + .eq(SgIncomingLine::getState, DataStateEnum.ENABLE.getCode()); + record.setLineCount(incomingLineService.count(incomingLineLambdaQueryWrapper)); + } + } + + return sgUserVOPage; } /** @@ -87,6 +113,7 @@ public class SgUserServiceImpl extends ServiceImpl impleme checkSgUserName(updateParam, true); SgUser sgUser = new SgUser(); BeanUtil.copyProperties(updateParam, sgUser); + sgUser.setAddr(updateParam.getAddrStrOption()); return this.updateById(sgUser); } @@ -97,10 +124,31 @@ public class SgUserServiceImpl extends ServiceImpl impleme */ @Override public boolean deleteSgUserData(List ids) { - return this.lambdaUpdate() - .set(SgUser::getState, DataStateEnum.DELETED.getCode()) - .in(SgUser::getId, ids) - .update(); + LambdaQueryWrapper sgProductLineLambdaQueryWrapper; + for (String id : ids) { + sgProductLineLambdaQueryWrapper = new LambdaQueryWrapper<>(); + sgProductLineLambdaQueryWrapper.eq(SgProductLine::getUserId, id) + .eq(SgProductLine::getState, DataStateEnum.ENABLE.getCode()); + int count = productLineService.count(sgProductLineLambdaQueryWrapper); + if (count > 0) { + throw new BusinessException(AdvanceResponseEnum.USER_HAS_PRODUCT); + } else { + this.lambdaUpdate().set(SgUser::getState, DataStateEnum.DELETED.getCode()) + .eq(SgUser::getId, id) + .update(); + } + + } + return true; + } + + @Override + public List sgUserAllList() { + LambdaQueryWrapper sgUserLambdaQueryWrapper = new LambdaQueryWrapper<>(); + sgUserLambdaQueryWrapper + .eq(SgUser::getState, DataStateEnum.ENABLE.getCode()) + .orderByDesc(SgUser::getCreateTime); + return this.list(sgUserLambdaQueryWrapper); } /** diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/utils/RadarUtil.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/utils/RadarUtil.java new file mode 100644 index 000000000..b341f289f --- /dev/null +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/utils/RadarUtil.java @@ -0,0 +1,192 @@ +package com.njcn.advance.utils; + +import com.njcn.common.utils.PubUtils; + +/** + * 用于处理暂降治理针对各方案下的雷达信息处理的工具类 + */ +public class RadarUtil { + + private static double[] w = {0.565, 0.2622, 0.1175, 0.0553}; + private static int[][] a = {{1, 0, 0, 0, 0}, {0, 1, 0, 0, 0}, {0, 0, 1, 0, 0}, {0, 0, 0, 1, 0}, {0, 0, 0, 0, 1}}; + + /** + * 获取治理前后的风险评估等级 + * + * @param lossAverage 年评价损失金额 + * @param coefficient 系数 + */ + public static String getRadarRiskLevel(double lossAverage, double coefficient) { + double n = 0d; + double temp = 0d; + double[] b = getB(lossAverage, coefficient); + + for (int i = 0; i < a.length; i++) { + int j = 0; + for (; j < b.length; j++) { + temp = temp + Math.abs(a[i][j] - b[j]); + } + temp = 1 - temp / j; + if (temp > n) { + n = temp; + } + } + return getLevelName(1 - n); + } + + /** + * 获取去风险能力 + * + * @param lossAverage 年评价损失金额 + * @param coefficient 系数 + */ + public static double getRadarRisk(double lossAverage, double coefficient) { + double n = 0d; + double temp = 0d; + double[] b = getB(lossAverage, coefficient); + + for (int i = 0; i < a.length; i++) { + int j = 0; + for (; j < b.length; j++) { + temp = temp + Math.abs(a[i][j] - b[j]); + } + temp = 1 - temp / j; + if (temp > n) { + n = temp; + } + } + return n * 0.9; + } + + + private static double[] getB(double x, double y) { + double[] b = {0, 0, 0, 0, 0}; + double[] l = getLossDegree(x); + double[] o2 = getOther3Degree(y); + double[] o3 = o2; + double[] o4 = o2; + for (int i = 0; i < b.length; i++) { + b[i] = w[0] * l[i] + + w[1] * o2[i] + + w[2] * o3[i] + + w[3] * o4[i]; + } + return b; + } + + private static double[] getLossDegree(double x) { + double[] r = {0, 0, 0, 0, 0}; + //0A1 + if (x < 10) { + r[0] = 1; + } else if (x >= 10 && x < 25) { + r[0] = (25 - x) / (25 - 10); + } + //1B1 + if (x >= 5 && x < 20) { + r[1] = (x - 5) / (20 - 5); + } else if (x >= 20 && x < 30) { + r[1] = 1; + } else if (x >= 30 && x < 45) { + r[1] = (45 - x) / (45 - 30); + } + //2C1 + if (x >= 25 && x < 40) { + r[2] = (x - 25) / (40 - 25); + } else if (x >= 40 && x < 50) { + r[2] = 1; + } else if (x >= 50 && x < 65) { + r[2] = (65 - x) / (65 - 50); + } + //3D1 + if (x >= 45 && x < 60) { + r[3] = (x - 45) / (60 - 45); + } else if (x >= 60 && x < 70) { + r[3] = 1; + } else if (x >= 70 && x < 85) { + r[3] = (85 - x) / (85 - 70); + } + //4E1 + if (x >= 65 && x < 80) { + r[4] = (x - 65) / (80 - 65); + } else if (x >= 80) { + r[4] = 1; + } + return r; + } + + + private static double[] getOther3Degree(double y) { + double[] r = {0, 0, 0, 0, 0}; + //0A2 + if (y < 11) { + r[0] = 1; + } else if (y >= 1 && y < 2.5) { + r[0] = (2.5 - y) / (2.5 - 1.0); + } + //1B1 + if (y >= 0.5 && y < 2.0) { + r[1] = (y - 0.5) / (2.0 - 0.5); + } else if (y >= 2.0 && y < 3.0) { + r[1] = 1; + } else if (y >= 3.0 && y < 4.5) { + r[1] = (4.5 - y) / (4.5 - 3.0); + } + //2C1 + if (y >= 2.5 && y < 4.0) { + r[2] = (y - 2.5) / (4.0 - 2.5); + } else if (y >= 4.0 && y < 5.0) { + r[2] = 1; + } else if (y >= 5.0 && y < 6.5) { + r[2] = (6.5 - y) / (6.5 - 5.0); + } + //3D1 + if (y >= 4.5 && y < 6.0) { + r[3] = (y - 4.5) / (6.0 - 4.5); + } else if (y >= 6.0 && y < 7.0) { + r[3] = 1; + } else if (y >= 7.0 && y < 8.5) { + r[3] = (8.5 - y) / (8.5 - 7.0); + } + //4E1 + if (y >= 6.5 && y < 8.0) { + r[4] = (y - 6.5) / (8.0 - 6.5); + } else if (y >= 8.0) { + r[4] = 1; + } + return r; + } + + + private static String getLevelName(double level) { + String[] levelName = {"一级", "二级", "三级", "四级", "五级"}; + if (level >= 0 && level < 0.2) { + return levelName[0]; + } else if (level >= 0.2 && level < 0.4) { + return levelName[1]; + } else if (level >= 0.4 && level < 0.6) { + return levelName[2]; + } else if (level >= 0.6 && level < 0.8) { + return levelName[3]; + } else if (level >= 0.8 && level <= 1.0) { + return levelName[4]; + } + return "异常了!"; + } + + /** + * 根据治理损失求方案的治理效果 + * + * @param yearLoss 治理前损失 + * @param governYearLoss 治理后损失 + */ + public static Double getRadarResult(Double yearLoss, Double governYearLoss) { + double loss = yearLoss - governYearLoss; + if (loss == 0D || yearLoss == 0) { + return 0D; + } else { + return PubUtils.doubleRound(2,loss / (Math.ceil(yearLoss / 100D) * 100)); + } + } + +} diff --git a/pqs-common/common-autocode/pom.xml b/pqs-common/common-autocode/pom.xml index fa4569a85..ea50addd1 100644 --- a/pqs-common/common-autocode/pom.xml +++ b/pqs-common/common-autocode/pom.xml @@ -27,6 +27,18 @@ common-web 1.0.0 + + + + com.oracle.database.jdbc + ojdbc8 + + + + com.oracle.database.nls + orai18n + + com.baomidou diff --git a/pqs-common/common-autocode/src/main/java/com/njcn/autocode/utils/GenerateCode.java b/pqs-common/common-autocode/src/main/java/com/njcn/autocode/utils/GenerateCode.java index e751aecd7..65cb93d26 100644 --- a/pqs-common/common-autocode/src/main/java/com/njcn/autocode/utils/GenerateCode.java +++ b/pqs-common/common-autocode/src/main/java/com/njcn/autocode/utils/GenerateCode.java @@ -19,9 +19,10 @@ import java.util.stream.Stream; */ public class GenerateCode { - private static final String TARGET_DIR = "C://code"; + private static final String TARGET_DIR = "D://code"; - private static final String DB_URL = "jdbc:mysql://192.168.1.16:13306/pqsinfo"; + private static final String DB_URL = "jdbc:mysql://192.168.1.24:13306/pqsinfo_hn"; +// private static final String DB_URL = "jdbc:oracle:thin:@192.168.1.170:1521:pqsbase"; private static final String USERNAME = "root"; @@ -29,8 +30,8 @@ public class GenerateCode { public static void main(String[] args) { List modules = Stream.of( - new Module("xuyang", "1", "1", Stream.of( - "pqs_top_msg" + new Module("hongawen", "com.njcn.advance.govern", "voltage", Stream.of( + "sg_harmonic_file" ).collect(Collectors.toList()), "") ).collect(Collectors.toList()); generateJavaFile(modules); diff --git a/pqs-common/common-core/src/main/java/com/njcn/common/utils/PubUtils.java b/pqs-common/common-core/src/main/java/com/njcn/common/utils/PubUtils.java index fc2ec2335..2a38f2703 100644 --- a/pqs-common/common-core/src/main/java/com/njcn/common/utils/PubUtils.java +++ b/pqs-common/common-core/src/main/java/com/njcn/common/utils/PubUtils.java @@ -18,6 +18,7 @@ import java.io.IOException; import java.lang.reflect.Method; import java.lang.reflect.Type; import java.math.BigDecimal; +import java.math.RoundingMode; import java.net.InetAddress; import java.net.UnknownHostException; import java.text.DateFormat; @@ -442,7 +443,18 @@ public class PubUtils { */ public static Float floatRound(int i, float value) { BigDecimal bp = new BigDecimal(value); - return bp.setScale(i, BigDecimal.ROUND_HALF_UP).floatValue(); + return bp.setScale(i, RoundingMode.HALF_UP).floatValue(); + } + + /** + * 根据参数返回double的四舍五入值 + * + * @param i 保留的位数 + * @param value double原值 + */ + public static double doubleRound(int i, double value) { + BigDecimal bp = new BigDecimal(value); + return bp.setScale(i, RoundingMode.HALF_UP).doubleValue(); } //*****************************************xuyang添加,用于App******************************************************** diff --git a/pqs-common/common-oss/src/main/java/com/njcn/oss/constant/OssPath.java b/pqs-common/common-oss/src/main/java/com/njcn/oss/constant/OssPath.java index 9507d26df..84478b071 100644 --- a/pqs-common/common-oss/src/main/java/com/njcn/oss/constant/OssPath.java +++ b/pqs-common/common-oss/src/main/java/com/njcn/oss/constant/OssPath.java @@ -121,5 +121,10 @@ public interface OssPath { */ String EVENT_WAVE_PIC="event/wave/"; + /*** + * 谐波治理的数据文件 + */ + String GOVERN_HARMONIC_FILE="govern/harmonic/"; + } diff --git a/pqs-common/common-poi/src/main/java/com/njcn/poi/excel/ExcelUtil.java b/pqs-common/common-poi/src/main/java/com/njcn/poi/excel/ExcelUtil.java index 5173ff6c2..7aee7c8a2 100644 --- a/pqs-common/common-poi/src/main/java/com/njcn/poi/excel/ExcelUtil.java +++ b/pqs-common/common-poi/src/main/java/com/njcn/poi/excel/ExcelUtil.java @@ -45,7 +45,29 @@ public class ExcelUtil { response.reset(); response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\""); response.setContentType("application/octet-stream;charset=UTF-8"); - Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), pojoClass, dataSet); + ExportParams exportParams = new ExportParams(); + Workbook workbook = ExcelExportUtil.exportExcel(exportParams, pojoClass, dataSet); + workbook.write(outputStream); + } catch (IOException e) { + log.error(">>> 导出数据异常:{}", e.getMessage()); + } + } + + /** + * 指定名称、sheet名、数据下载报表 + * + * @param fileName 文件名 + */ + public static void exportExcel(String fileName, String sheetName, Class pojoClass, Collection dataSet) { + HttpServletResponse response = HttpServletUtil.getResponse(); + try (ServletOutputStream outputStream = response.getOutputStream()) { + fileName = URLEncoder.encode(fileName, CharsetUtil.UTF_8); + response.reset(); + response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\""); + response.setContentType("application/octet-stream;charset=UTF-8"); + ExportParams exportParams = new ExportParams(); + exportParams.setSheetName(sheetName); + Workbook workbook = ExcelExportUtil.exportExcel(exportParams, pojoClass, dataSet); workbook.write(outputStream); } catch (IOException e) { log.error(">>> 导出数据异常:{}", e.getMessage()); @@ -57,8 +79,8 @@ public class ExcelUtil { * * @param fileName 文件名 */ - public static void exportExcel(ExportParams exportParams,String fileName, Class pojoClass, Collection dataSet) { - exportExcelPullDown(exportParams,fileName,null ,pojoClass, dataSet); + public static void exportExcel(ExportParams exportParams, String fileName, Class pojoClass, Collection dataSet) { + exportExcelPullDown(exportParams, fileName, null, pojoClass, dataSet); } @@ -72,10 +94,10 @@ public class ExcelUtil { try (ServletOutputStream outputStream = response.getOutputStream()) { fileName = URLEncoder.encode(fileName, CharsetUtil.UTF_8); response.reset(); - response.setHeader("Content-Disposition", "attachment;filename=" + fileName ); + response.setHeader("Content-Disposition", "attachment;filename=" + fileName); response.setContentType("application/octet-stream;charset=UTF-8"); Workbook workbook = ExcelExportUtil.exportExcel(exportParams, pojoClass, dataSet); - if(CollUtil.isNotEmpty(pullDowns)){ + if (CollUtil.isNotEmpty(pullDowns)) { for (PullDown pullDown : pullDowns) { ExcelUtil.selectList(workbook, pullDown.getFirstCol(), pullDown.getLastCol(), pullDown.getStrings().toArray(new String[]{})); } @@ -94,7 +116,7 @@ public class ExcelUtil { CellStyle cellStyle = workbook.createCellStyle(); //获取单元格内容对象 Font font = workbook.createFont(); - font.setFontHeightInPoints((short)12); + font.setFontHeightInPoints((short) 12); //一定要装入 样式中才会生效 cellStyle.setFont(font); //设置居中对齐 @@ -106,25 +128,25 @@ public class ExcelUtil { String stringCellValue = cell.getStringCellValue(); if (stringCellValue.contains("*")) { // 创建一个富文本 - XSSFRichTextString xssfRichTextString = new XSSFRichTextString(stringCellValue); + XSSFRichTextString xssfRichTextString = new XSSFRichTextString(stringCellValue); int startIndex = stringCellValue.indexOf("*"); int entIndex = stringCellValue.lastIndexOf("*"); - if(entIndex!=0){ + if (entIndex != 0) { Font font3 = workbook.createFont(); - font3.setFontHeightInPoints((short)12); + font3.setFontHeightInPoints((short) 12); font3.setColor(Font.COLOR_NORMAL); xssfRichTextString.applyFont(0, entIndex, font3); } //设置带*样式 Font font1 = workbook.createFont(); - font1.setFontHeightInPoints((short)12); + font1.setFontHeightInPoints((short) 12); font1.setColor(Font.COLOR_RED); - xssfRichTextString.applyFont(startIndex, entIndex+1, font1); + xssfRichTextString.applyFont(startIndex, entIndex + 1, font1); //其他样式 Font font2 = workbook.createFont(); - font2.setFontHeightInPoints((short)12); + font2.setFontHeightInPoints((short) 12); font2.setColor(Font.COLOR_NORMAL); - xssfRichTextString.applyFont(entIndex+1, stringCellValue.length(), font2); + xssfRichTextString.applyFont(entIndex + 1, stringCellValue.length(), font2); cell.setCellValue(xssfRichTextString); } } @@ -175,11 +197,12 @@ public class ExcelUtil { /** * firstRow 開始行號 根据此项目,默认为2(下标0开始) * lastRow 根据此项目,默认为最大65535 + * * @param firstCol 区域中第一个单元格的列号 (下标0开始) - * @param lastCol 区域中最后一个单元格的列号 - * @param strings 下拉内容 - * */ - public static void selectList(Workbook workbook,int firstCol,int lastCol,String[] strings ){ + * @param lastCol 区域中最后一个单元格的列号 + * @param strings 下拉内容 + */ + public static void selectList(Workbook workbook, int firstCol, int lastCol, String[] strings) { Sheet sheet = workbook.getSheetAt(0); // 生成下拉列表 @@ -189,12 +212,11 @@ public class ExcelUtil { DataValidationHelper dvHelper = sheet.getDataValidationHelper(); XSSFDataValidationConstraint dvConstraint = (XSSFDataValidationConstraint) dvHelper.createExplicitListConstraint(strings); - XSSFDataValidation validation =(XSSFDataValidation)dvHelper.createValidation( + XSSFDataValidation validation = (XSSFDataValidation) dvHelper.createValidation( dvConstraint, cellRangeAddressList); // 对sheet页生效 sheet.addValidationData(validation); } - } diff --git a/pqs-gateway/src/main/resources/bootstrap.yml b/pqs-gateway/src/main/resources/bootstrap.yml index c9d2a6106..2800aceb1 100644 --- a/pqs-gateway/src/main/resources/bootstrap.yml +++ b/pqs-gateway/src/main/resources/bootstrap.yml @@ -201,6 +201,9 @@ whitelist: - /system-boot/image/toStream - /cs-system-boot/appinfo/queryAppInfoByType - /system-boot/dictType/dictDataCache + - /system-boot/file/** + - /system-boot/area/** + - /advance-boot/** #- /device-boot/** #- /system-boot/** #- /harmonic-boot/**