暂降治理一期工作内容
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<SgMachineVO> machineVOList;
|
||||
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -88,6 +88,12 @@ public class SgEventParam {
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class SgEventParamQueryParam extends BaseParam {
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@ApiModelProperty("用户id")
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 生产线id
|
||||
*/
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -82,7 +82,7 @@ public class SgSensitiveUnitParam {
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class SgSensitiveUnitUpdateParam extends SgMachineParam {
|
||||
public static class SgSensitiveUnitUpdateParam extends SgSensitiveUnitParam {
|
||||
|
||||
/**
|
||||
* 表Id
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @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;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
}
|
||||
@@ -51,10 +51,10 @@ public class SgProductLine extends BaseEntity {
|
||||
/**
|
||||
* 中断导致的产能损失(默认为0)
|
||||
*/
|
||||
private Float capacityLoss;
|
||||
private Double capacityLoss;
|
||||
|
||||
/**
|
||||
* 用户状态 0-删除;1-正常;默认正常
|
||||
* 数据状态 0-删除;1-正常;默认正常
|
||||
*/
|
||||
private Integer state;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @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;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -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<String> yearsArray;
|
||||
|
||||
/**
|
||||
* 用户每年的投资,由集合转为字符的
|
||||
*/
|
||||
private List<Double> investYearArray;
|
||||
|
||||
/**
|
||||
* 治理效果每年
|
||||
*/
|
||||
private List<Double> governEffectArray;
|
||||
|
||||
/**
|
||||
* 用户每年的收益,由集合转为字符的
|
||||
*/
|
||||
private List<Double> payBackArray;
|
||||
|
||||
/**
|
||||
* 5年 10年 15年的成本
|
||||
*/
|
||||
private List<Double> costArray;
|
||||
|
||||
/**
|
||||
* 5年 10年 15年的投资收益率
|
||||
*/
|
||||
private List<Double> 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;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
}
|
||||
@@ -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<SgSensitiveUnitVO> sgSensitiveUnitList;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.njcn.advance.pojo.vo.govern.voltage;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TransientEventCountVO {
|
||||
|
||||
private String[][] values;
|
||||
|
||||
}
|
||||
@@ -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<Integer> getBinaryList(int num) {
|
||||
ArrayList<Integer> list = new ArrayList<Integer>();
|
||||
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<arr.length; i++) {
|
||||
if(equal(arr[i], key)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.njcn.advance.controller.govern.harmonic;
|
||||
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.njcn.advance.enums.AdvanceResponseEnum;
|
||||
import com.njcn.advance.pojo.dto.govern.voltage.SgEventExcel;
|
||||
import com.njcn.advance.pojo.po.govern.harmonic.SgHarmonicFile;
|
||||
import com.njcn.advance.service.govern.harmonic.ISgHarmonicFileService;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
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.oss.constant.OssPath;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import com.njcn.poi.util.PoiUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
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.RequestMapping;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @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<String> 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<List<SgHarmonicFile>> listHarmonicData() {
|
||||
String methodDescribe = getMethodDescribe("listHarmonicData");
|
||||
LambdaQueryWrapper<SgHarmonicFile> sgHarmonicFileLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
sgHarmonicFileLambdaQueryWrapper.eq(SgHarmonicFile::getState,DataStateEnum.ENABLE.getCode());
|
||||
List<SgHarmonicFile> files = harmonicFileService.list(sgHarmonicFileLambdaQueryWrapper);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, files, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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<SgGovernSchemeHistoryAllVO> 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<Page<SgGovernSchemeHistoryVO>> list(@RequestBody SgGovernSchemeHistoryParam.SgSchemeHistoryQueryParam sgSchemeHistoryQueryParam) {
|
||||
String methodDescribe = getMethodDescribe("list");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, sgSchemeHistoryQueryParam);
|
||||
Page<SgGovernSchemeHistoryVO> 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<Object> delete(@RequestBody List<String> 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<SgGovernSchemeHistoryAllVO> detail(String id) {
|
||||
String methodDescribe = getMethodDescribe("detail");
|
||||
LogUtil.njcnDebug(log, "{},治理方案索引为:{}", methodDescribe, id);
|
||||
SgGovernSchemeHistoryAllVO sgGovernSchemeHistoryAllVO = governSchemeCalcService.detail(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, sgGovernSchemeHistoryAllVO, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @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<List<SgEventVO>> getEventDataByProductLineId(@RequestBody SgEventParam.SgEventParamQueryParam sgEventParamQueryParam) {
|
||||
String methodDescribe = getMethodDescribe("getEventDataByProductLineId");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, sgEventParamQueryParam);
|
||||
List<SgEventVO> 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<TransientEventCountVO> 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<String> 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<SgEventExcel> 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<SgEventExcel> 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<String> 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<Object> delete(@RequestBody List<String> 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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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<List<SgOption>> lineList( ) {
|
||||
String methodDescribe = getMethodDescribe("lineList");
|
||||
LogUtil.njcnDebug(log, "{}", methodDescribe);
|
||||
List<SgOption> result = sgIncomingLineService.lineList();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
|
||||
@PostMapping("/add")
|
||||
|
||||
@@ -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<List<SgMachineVO>> querySgMachineByProductLineId(String productId) {
|
||||
String methodDescribe = getMethodDescribe("querySgMachineByProductLineId");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, productId);
|
||||
List<SgMachineVO> result = sgMachineService.listAllMachineByProductLineId(productId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
|
||||
@PostMapping("/add")
|
||||
|
||||
@@ -60,10 +60,10 @@ public class SgProductLineController extends BaseController {
|
||||
@GetMapping("/querySgProductLineByUserId")
|
||||
@ApiOperation("根据用户id查询所有的生产线信息")
|
||||
@ApiImplicitParam(name = "userId", value = "用户id", required = true)
|
||||
public HttpResult<List<SgProductLine>> querySgProductLineByUserId(String userId) {
|
||||
public HttpResult<List<SgProductLineVO>> querySgProductLineByUserId(String userId) {
|
||||
String methodDescribe = getMethodDescribe("querySgProductLineByUserId");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, userId);
|
||||
List<SgProductLine> result = sgProductLineService.querySgProductLineByUserId(userId);
|
||||
List<SgProductLineVO> result = sgProductLineService.querySgProductLineByUserId(userId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@@ -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<List<SgSensitiveUnitVO>> queryUnitByMachineId(String machineId) {
|
||||
String methodDescribe = getMethodDescribe("queryUnitByMachineId");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, machineId);
|
||||
List<SgSensitiveUnitVO> 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("更新元器件")
|
||||
|
||||
@@ -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<List<SgUser>> sgUserList() {
|
||||
String methodDescribe = getMethodDescribe("list");
|
||||
LogUtil.njcnDebug(log, "{},查询所有的用户数据", methodDescribe);
|
||||
List<SgUser> result = sgUserService.sgUserAllList();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("新增业务用户")
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2024-04-17
|
||||
*/
|
||||
public interface SgHarmonicFileMapper extends BaseMapper<SgHarmonicFile> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.advance.mapper.govern.harmonic.SgHarmonicFileMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2024-02-29
|
||||
*/
|
||||
public interface SgEventMapper extends BaseMapper<SgEvent> {
|
||||
Page<SgEventVO> page(@Param("page") Page<Object> objectPage, @Param("ew") QueryWrapper<SgEventVO> sgEventVOQueryWrapper);
|
||||
|
||||
List<SgEventVO> getAllEventData(@Param("incomingList") List<String> incomingLineIdList, @Param("beginDate") LocalDateTime beginDate, @Param("endDate") LocalDateTime endDate);
|
||||
|
||||
List<SgEventVO> getEventDataByProductLineId(@Param("productId") String productId, @Param("beginDate") LocalDateTime beginDate, @Param("endDate") LocalDateTime endDate);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2024-03-27
|
||||
*/
|
||||
public interface SgGovernSchemeHistoryDetailMapper extends BaseMapper<SgGovernSchemeHistoryDetail> {
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2024-03-27
|
||||
*/
|
||||
public interface SgGovernSchemeHistoryMapper extends BaseMapper<SgGovernSchemeHistory> {
|
||||
|
||||
Page<SgGovernSchemeHistoryVO> page(@Param("page") Page<SgGovernSchemeHistoryVO> objectPage, @Param("ew") QueryWrapper<SgGovernSchemeHistoryVO> queryWrapper);
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2024-03-27
|
||||
*/
|
||||
public interface SgGovernSchemeParamMapper extends BaseMapper<SgGovernSchemeParam> {
|
||||
|
||||
}
|
||||
@@ -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<SgIncomingLine> {
|
||||
|
||||
List<IncomingLineVO> queryLineByUserId(@Param("userId")String userId);
|
||||
|
||||
List<SgOption> lineList();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
@@ -18,4 +20,6 @@ import org.apache.ibatis.annotations.Param;
|
||||
public interface SgMachineMapper extends BaseMapper<SgMachine> {
|
||||
|
||||
Page<SgMachineVO> page(@Param("page") Page<Object> objectPage, @Param("ew") QueryWrapper<SgMachineVO> queryWrapper);
|
||||
|
||||
List<SgMachineVO> listAllMachineByProductLineId(@Param("productLineId")String productLineId);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
@@ -20,4 +22,7 @@ public interface SgProductLineMapper extends BaseMapper<SgProductLine> {
|
||||
Page<SgProductLineVO> page(@Param("page")Page<SgProductLineVO> objectPage, @Param("ew") QueryWrapper<SgProductLineVO> queryWrapper);
|
||||
|
||||
|
||||
List<SgProductLineVO> querySgProductLineByUserId(@Param("ew") QueryWrapper<SgProductLineVO> sgProductLineVOQueryWrapper);
|
||||
|
||||
String getUserNameByProductId(@Param("productId")String id);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
@@ -18,4 +20,6 @@ import org.apache.ibatis.annotations.Param;
|
||||
public interface SgSensitiveUnitMapper extends BaseMapper<SgSensitiveUnit> {
|
||||
|
||||
Page<SgSensitiveUnitVO> page(@Param("page") Page<Object> objectPage, @Param("ew")QueryWrapper<SgSensitiveUnitVO> queryWrapper);
|
||||
|
||||
List<SgSensitiveUnitVO> listAllUnitByMachineId(@Param("machineId")String machineId);
|
||||
}
|
||||
|
||||
@@ -2,4 +2,44 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.advance.mapper.govern.voltage.SgEventMapper">
|
||||
|
||||
<!--获取暂降事件分页列表-->
|
||||
<select id="page" resultType="SgEventVO">
|
||||
SELECT sg_event.*,
|
||||
sg_incoming_line.name incomingLineName
|
||||
FROM sg_event sg_event,
|
||||
sg_incoming_line sg_incoming_line
|
||||
WHERE sg_event.incoming_line_id = sg_incoming_line.id
|
||||
AND ${ew.sqlSegment}
|
||||
</select>
|
||||
|
||||
|
||||
<!--获取暂降事件,不分页-->
|
||||
<select id="getAllEventData" resultType="SgEventVO">
|
||||
SELECT sg_event.*,
|
||||
sg_incoming_line.name incomingLineName
|
||||
FROM sg_event sg_event,
|
||||
sg_incoming_line sg_incoming_line
|
||||
WHERE sg_event.incoming_line_id = sg_incoming_line.id
|
||||
AND sg_event.incoming_line_id in
|
||||
<foreach collection="incomingList" separator="," open="(" close=")" item="item">
|
||||
#{item}
|
||||
</foreach>
|
||||
AND sg_event.start_time between #{beginDate} and #{endDate}
|
||||
AND sg_event.state = 1
|
||||
</select>
|
||||
|
||||
|
||||
<!--获取生产下的所有事件-->
|
||||
<select id="getEventDataByProductLineId" resultType="SgEventVO">
|
||||
SELECT sg_event.*,
|
||||
sg_incoming_line.name incomingLineName
|
||||
FROM sg_event sg_event,
|
||||
sg_incoming_line sg_incoming_line
|
||||
WHERE sg_event.incoming_line_id = sg_incoming_line.id
|
||||
AND sg_event.product_line_id = #{productId}
|
||||
AND sg_event.start_time between #{beginDate} and #{endDate}
|
||||
AND sg_event.state = 1
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.advance.mapper.govern.voltage.SgGovernSchemeHistoryDetailMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.advance.mapper.govern.voltage.SgGovernSchemeHistoryMapper">
|
||||
|
||||
<!--获取生产线分页列表-->
|
||||
<select id="page" resultType="SgGovernSchemeHistoryVO">
|
||||
SELECT
|
||||
sg_govern_scheme_history.*,
|
||||
sg_govern_scheme_history.loss - sg_govern_scheme_history_detail.loss governEffect,
|
||||
sg_govern_scheme_history_detail.equipment schemeEquipment,
|
||||
sg_govern_scheme_history_detail.maintain schemeMaintain,
|
||||
sg_govern_scheme_history_detail.actual_pay_back payBackYear,
|
||||
sg_govern_scheme_history_detail.type schemeType,
|
||||
sg_product_line.name productLineName,
|
||||
sg_user.user_name userName
|
||||
FROM
|
||||
sg_govern_scheme_history sg_govern_scheme_history ,
|
||||
sg_govern_scheme_history_detail sg_govern_scheme_history_detail ,
|
||||
sg_product_line sg_product_line,
|
||||
sg_user sg_user
|
||||
WHERE sg_govern_scheme_history.Best_scheme_id = sg_govern_scheme_history_detail.id
|
||||
AND sg_govern_scheme_history.product_line_id = sg_product_line.id
|
||||
AND sg_product_line.user_id = sg_user.id
|
||||
AND ${ew.sqlSegment}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.advance.mapper.govern.voltage.SgGovernSchemeParamMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -16,4 +16,14 @@
|
||||
ORDER BY sg_incoming_line.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="lineList" resultType="com.njcn.advance.pojo.vo.govern.voltage.SgOption">
|
||||
SELECT
|
||||
id id,
|
||||
name name
|
||||
FROM
|
||||
pq_line
|
||||
WHERE
|
||||
Level = 6
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -9,4 +9,12 @@
|
||||
WHERE ${ew.sqlSegment}
|
||||
</select>
|
||||
|
||||
<!--获取设备所有数据,根据生产线ID-->
|
||||
<select id="listAllMachineByProductLineId" resultType="SgMachineVO">
|
||||
SELECT sg_machine.*
|
||||
FROM sg_machine sg_machine
|
||||
WHERE sg_machine.product_line_id = #{productLineId}
|
||||
AND sg_machine.state = 1
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -17,5 +17,31 @@
|
||||
AND ${ew.sqlSegment}
|
||||
</select>
|
||||
|
||||
<!--获取生产线分页列表-->
|
||||
<select id="querySgProductLineByUserId" resultType="SgProductLineVO">
|
||||
SELECT
|
||||
sg_product_line.*,
|
||||
sg_user.user_name userName,
|
||||
sg_incoming_line.name incomingLineName
|
||||
FROM
|
||||
sg_product_line sg_product_line ,
|
||||
sg_user sg_user ,
|
||||
sg_incoming_line sg_incoming_line
|
||||
WHERE sg_product_line.user_id = sg_user.id
|
||||
AND sg_product_line.incoming_line_id = sg_incoming_line.id
|
||||
AND ${ew.sqlSegment}
|
||||
</select>
|
||||
|
||||
<select id="getUserNameByProductId" resultType="String">
|
||||
SELECT sg_user.user_name userName
|
||||
FROM sg_product_line sg_product_line,
|
||||
sg_user sg_user
|
||||
WHERE sg_product_line.user_id = sg_user.id
|
||||
AND sg_product_line.id = #{productId}
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -7,4 +7,12 @@
|
||||
FROM sg_sensitive_unit sg_sensitive_unit
|
||||
WHERE ${ew.sqlSegment}
|
||||
</select>
|
||||
|
||||
<!--根据设备ID获取所有的敏感元器件-->
|
||||
<select id="listAllUnitByMachineId" resultType="SgSensitiveUnitVO">
|
||||
SELECT sg_sensitive_unit.*
|
||||
FROM sg_sensitive_unit sg_sensitive_unit
|
||||
WHERE sg_sensitive_unit.machine_id = #{machineId}
|
||||
AND sg_sensitive_unit.state = 1
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2024-04-17
|
||||
*/
|
||||
public interface ISgHarmonicFileService extends IService<SgHarmonicFile> {
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2024-04-17
|
||||
*/
|
||||
@Service
|
||||
public class SgHarmonicFileServiceImpl extends ServiceImpl<SgHarmonicFileMapper, SgHarmonicFile> implements ISgHarmonicFileService {
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
@@ -17,4 +23,28 @@ import com.njcn.advance.pojo.vo.govern.voltage.SgEventVO;
|
||||
public interface ISgEventService extends IService<SgEvent> {
|
||||
|
||||
Page<SgEventVO> sgEventList(SgEventParam.SgEventParamQueryParam sgEventParamQueryParam);
|
||||
|
||||
void downloadTemplate();
|
||||
|
||||
void exportEventData(SgEventParam.SgEventParamQueryParam sgEventParamQueryParam);
|
||||
|
||||
void importEventData(List<SgEventExcel> sgEventExcels, String incomingLineId,String productLineId);
|
||||
|
||||
List<SgEvent> getEventData(String id, String startTime, String endTime);
|
||||
|
||||
Map<Integer[], Integer> getEventMap(String id, String startTime, String endTime);
|
||||
|
||||
Map<Integer[], Integer> countEventMap4Switch(Map<Integer[], Integer> eventMap, String id, String incomingLineId, String startTime, String endTime, Double actionTime);
|
||||
|
||||
List<SgEvent> countEvent4Switch(List<SgEvent> sgEventList, String id, String incomingLineId, String startTime, String endTime, Double actionTime);
|
||||
|
||||
boolean deleteEventData(List<String> ids);
|
||||
|
||||
TransientEventCountVO threeDList(SgEventParam.SgEventParamQueryParam sgEventParamQueryParam);
|
||||
|
||||
void calcLoss(String id);
|
||||
|
||||
Double[] getEventLossAndFailureRate(ProductLineComputeData productLineComputeData, double amplitude, double durationTime);
|
||||
|
||||
List<SgEventVO> getEventDataByProductLineId(SgEventParam.SgEventParamQueryParam sgEventParamQueryParam);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2024-03-27
|
||||
*/
|
||||
public interface ISgGovernSchemeHistoryDetailService extends IService<SgGovernSchemeHistoryDetail> {
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2024-03-27
|
||||
*/
|
||||
public interface ISgGovernSchemeHistoryService extends IService<SgGovernSchemeHistory> {
|
||||
|
||||
Page<SgGovernSchemeHistoryVO> schemeHistoryList(SgGovernSchemeHistoryParam.SgSchemeHistoryQueryParam sgSchemeHistoryQueryParam);
|
||||
|
||||
boolean deleteScheme(List<String> ids);
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2024-03-27
|
||||
*/
|
||||
public interface ISgGovernSchemeParamService extends IService<SgGovernSchemeParam> {
|
||||
|
||||
}
|
||||
@@ -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<SgIncomingLine> {
|
||||
boolean updateIncomingLine(IncomingLineParam.IncomingLineUpdateParam updateParam);
|
||||
|
||||
boolean deleteIncomingLineData(List<String> ids);
|
||||
|
||||
List<SgOption> lineList();
|
||||
}
|
||||
|
||||
@@ -25,4 +25,7 @@ public interface ISgMachineService extends IService<SgMachine> {
|
||||
boolean updateSgMachine(SgMachineParam.SgMachineUpdateParam updateParam);
|
||||
|
||||
boolean deleteSgMachineData(List<String> ids);
|
||||
|
||||
List<SgMachineVO> listAllMachineByProductLineId(String productLineId);
|
||||
|
||||
}
|
||||
|
||||
@@ -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<SgProductLine> {
|
||||
|
||||
boolean deleteSgProductData(List<String> ids);
|
||||
|
||||
List<SgProductLine> querySgProductLineByUserId(String userId);
|
||||
List<SgProductLineVO> querySgProductLineByUserId(String userId);
|
||||
|
||||
ProductLineComputeData assginProductLineComputeData(String productLineId);
|
||||
|
||||
String getUserNameByProductId(String id);
|
||||
}
|
||||
|
||||
@@ -25,4 +25,7 @@ public interface ISgSensitiveUnitService extends IService<SgSensitiveUnit> {
|
||||
boolean updateSgSensitiveUnit(SgSensitiveUnitParam.SgSensitiveUnitUpdateParam updateParam);
|
||||
|
||||
boolean deleteSgSensitiveUnitData(List<String> ids);
|
||||
|
||||
List<SgSensitiveUnitVO> listAllUnitByMachineId(String id);
|
||||
|
||||
}
|
||||
|
||||
@@ -25,4 +25,6 @@ public interface ISgUserService extends IService<SgUser> {
|
||||
boolean updateSgUser(SgUserParam.SgUserUpdateParam updateParam);
|
||||
|
||||
boolean deleteSgUserData(List<String> ids);
|
||||
|
||||
List<SgUser> sgUserAllList();
|
||||
}
|
||||
|
||||
@@ -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<Scheme2>, 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<ProductDevice> devices1 = new ArrayList<ProductDevice>();
|
||||
// @ApiModelProperty("被治理设备组合中的串型设备名称")
|
||||
// List<String> deviceNames1 = new ArrayList<String>();
|
||||
// //被治理设备组合中的并型设备
|
||||
// @ApiModelProperty("被治理设备组合中的并型设备")
|
||||
// List<ProductDevice> devices2 = new ArrayList<ProductDevice>();
|
||||
// @ApiModelProperty("被治理设备组合中的并型设备名称")
|
||||
// List<String> deviceNames2 = new ArrayList<String>();
|
||||
//
|
||||
// //10kV快切开关的进线组合
|
||||
// @ApiModelProperty("10kV快切开关的进线组合")
|
||||
// List<String> inlineCombinationList = new ArrayList();
|
||||
// @ApiModelProperty("10kV快切开关的进线组合名称")
|
||||
// List<String> 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;
|
||||
// }
|
||||
//
|
||||
//
|
||||
//}
|
||||
@@ -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<Integer[], Integer> eventMap = eventService.getEventMap(sgIncomingLine.getId(), startTime, endTime);
|
||||
List<SgEvent> 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<SgEvent> 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<SgGovernSchemeHistoryDetail> 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<Double> governEffectUPS = new ArrayList<>();
|
||||
for (int i = 0; i < allVO.getPayBackPeriod(); i++) {
|
||||
governEffectUPS.add(allVO.getLoss()- upsVo.getLoss());
|
||||
}
|
||||
upsVo.setGovernEffectArray(governEffectUPS);
|
||||
allVO.setUpsData(upsVo);
|
||||
LambdaQueryWrapper<SgGovernSchemeParam> 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<SgGovernSchemeHistoryDetail> 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<Double> governEffectAVC = new ArrayList<>();
|
||||
for (int i = 0; i < allVO.getPayBackPeriod(); i++) {
|
||||
governEffectAVC.add(allVO.getLoss()- avcVo.getLoss());
|
||||
}
|
||||
avcVo.setGovernEffectArray(governEffectAVC);
|
||||
allVO.setAvcData(avcVo);
|
||||
LambdaQueryWrapper<SgGovernSchemeParam> 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<SgGovernSchemeHistoryDetail> 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<Double> governEffectQuick = new ArrayList<>();
|
||||
for (int i = 0; i < allVO.getPayBackPeriod(); i++) {
|
||||
governEffectQuick.add(allVO.getLoss()- quickVo.getLoss());
|
||||
}
|
||||
quickVo.setGovernEffectArray(governEffectQuick);
|
||||
allVO.setQuickData(quickVo);
|
||||
LambdaQueryWrapper<SgGovernSchemeParam> 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<String> data = Arrays.asList(upsResult.getInvestYield().split(StrPool.UNDERLINE));
|
||||
List<Double> doubleList = data.stream()
|
||||
.map(Double::parseDouble)
|
||||
.collect(Collectors.toList());
|
||||
upsVo.setInvestYieldArray(doubleList);
|
||||
|
||||
|
||||
upsVo.setYearsArray(Arrays.asList(upsResult.getYears().split(StrPool.UNDERLINE)));
|
||||
|
||||
|
||||
List<String> data1 = Arrays.asList(upsResult.getInvestYear().split(StrPool.UNDERLINE));
|
||||
List<Double> doubleList1 = data1.stream()
|
||||
.map(Double::parseDouble)
|
||||
.collect(Collectors.toList());
|
||||
upsVo.setInvestYearArray(doubleList1);
|
||||
|
||||
|
||||
List<String> data2 = Arrays.asList(upsResult.getPayBack().split(StrPool.UNDERLINE));
|
||||
List<Double> doubleList2 = data2.stream()
|
||||
.map(Double::parseDouble)
|
||||
.collect(Collectors.toList());
|
||||
upsVo.setPayBackArray(doubleList2);
|
||||
|
||||
List<String> data3 = Arrays.asList(upsResult.getCost().split(StrPool.UNDERLINE));
|
||||
List<Double> 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<SgGovernSchemeHistoryDetailVO> tempList = new ArrayList<>();
|
||||
tempList.add(upsData);
|
||||
tempList.add(avcData);
|
||||
tempList.add(quickData);
|
||||
// 使用Stream API根据综合得分排序
|
||||
List<SgGovernSchemeHistoryDetailVO> 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<SgMachineVO> 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、计算生产线的故障率,计算出生产线的产能损失
|
||||
* <p>
|
||||
* 根据电网接入水平以及生产线的各敏感元器件,计算各方案下每年经济的损失
|
||||
*
|
||||
* @param eventList 暂降事件列表
|
||||
* @param sgGovernSchemeHistoryAllVO 待返回前台展示数据
|
||||
* @param governSchemeEnum 治理方案
|
||||
* @param yearRate 年化率
|
||||
*/
|
||||
private void computeProductLineLoss(List<SgEvent> 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<Double> investYear = new ArrayList<>();
|
||||
List<Double> payBack = new ArrayList<>();
|
||||
List<Double> investYearThree = new ArrayList<>();
|
||||
List<Double> payBackThree = new ArrayList<>();
|
||||
List<Double> cost = new ArrayList<>();
|
||||
List<Double> investYield = new ArrayList<>();
|
||||
//存在收益,计算下回收期,默认最大回收周期为最后一年
|
||||
int actualPayBack = sgGovernSchemeHistoryAllVO.getPayBackPeriod();
|
||||
boolean isFirst = true;
|
||||
//治理效果
|
||||
List<Double> 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<Double> tempInvest = investYearThree.subList(0, i);
|
||||
double sum = tempInvest.stream().mapToDouble(Double::doubleValue).sum();
|
||||
cost.add(PubUtils.doubleRound(2, sum));
|
||||
|
||||
List<Double> 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<String> 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<AVCInfo> 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<AVCInfo> {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2024-02-29
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SgEventServiceImpl extends ServiceImpl<SgEventMapper, SgEvent> 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<double[], Integer> AMPLITUDE_KEY_MAP = new HashMap<double[], Integer>() {{
|
||||
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<double[], Integer> DURATION_TIME_KEY_MAP = new HashMap<double[], Integer>() {{
|
||||
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<SgEventVO> sgEventList(SgEventParam.SgEventParamQueryParam sgEventParamQueryParam) {
|
||||
//暂降数据实际跟进线耦合的,需要根据所传的生产线获取进线id
|
||||
String productId = sgEventParamQueryParam.getProductId();
|
||||
|
||||
return null;
|
||||
//暂降数据实际跟进线耦合的,需要根据所传的用户获取进线id
|
||||
String userId = sgEventParamQueryParam.getUserId();
|
||||
LambdaQueryWrapper<SgIncomingLine> sgIncomingLineLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
sgIncomingLineLambdaQueryWrapper.eq(SgIncomingLine::getUserId, userId)
|
||||
.eq(SgIncomingLine::getState, DataStateEnum.ENABLE.getCode());
|
||||
List<SgIncomingLine> imcomingLineList = sgIncomingLineService.list(sgIncomingLineLambdaQueryWrapper);
|
||||
//以分页的方式查询出所有的暂降数据
|
||||
if (CollectionUtil.isNotEmpty(imcomingLineList)) {
|
||||
List<String> incomingLineIdList = imcomingLineList.stream().map(SgIncomingLine::getId).collect(Collectors.toList());
|
||||
QueryWrapper<SgEventVO> 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<SgEventVO> sgEventVOList;
|
||||
String userId = sgEventParamQueryParam.getUserId();
|
||||
LambdaQueryWrapper<SgIncomingLine> sgIncomingLineLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
sgIncomingLineLambdaQueryWrapper.eq(SgIncomingLine::getUserId, userId)
|
||||
.eq(SgIncomingLine::getState, DataStateEnum.ENABLE.getCode());
|
||||
List<SgIncomingLine> imcomingLineList = sgIncomingLineService.list(sgIncomingLineLambdaQueryWrapper);
|
||||
if (CollectionUtil.isEmpty(imcomingLineList)) {
|
||||
ExcelUtil.exportExcel("暂降事件数据.xls", "暂降数据", SgEventVO.class, new ArrayList<>());
|
||||
} else {
|
||||
List<String> 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<SgEventExcel> sgEventExcels, String incomingLineId, String productLineId) {
|
||||
//获取生产线信息
|
||||
ProductLineComputeData productLineComputeData = productLineService.assginProductLineComputeData(productLineId);
|
||||
if (CollectionUtil.isNotEmpty(sgEventExcels)) {
|
||||
List<SgEvent> 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<SgEvent> getEventData(String id, String startTime, String endTime) {
|
||||
LambdaQueryWrapper<SgEvent> 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<Integer[], Integer> getEventMap(String id, String startTime, String endTime) {
|
||||
Map<Integer[], Integer> eventMap = new HashMap<>();
|
||||
LambdaQueryWrapper<SgEvent> 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<Integer[], Integer> countEventMap4Switch(Map<Integer[], Integer> eventMap, String id, String incomingLineId, String startTime, String endTime, Double actionTime) {
|
||||
LambdaQueryWrapper<SgEvent> 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<SgEvent> mainList = this.list(lambdaQueryWrapper);
|
||||
List<SgEvent> subList = new ArrayList<>();
|
||||
int beforeCount = mainList.size();
|
||||
if (beforeCount > 0) {
|
||||
// 主线有暂降在算辅线
|
||||
LambdaQueryWrapper<SgEvent> 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<SgEvent> countEvent4Switch(List<SgEvent> sgEventList, String id, String incomingLineId, String startTime, String endTime, Double actionTime) {
|
||||
LambdaQueryWrapper<SgEvent> 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<SgEvent> mainList = this.list(lambdaQueryWrapper);
|
||||
List<SgEvent> subList = new ArrayList<>();
|
||||
int beforeCount = mainList.size();
|
||||
if (beforeCount > 0) {
|
||||
// 主线有暂降在算辅线
|
||||
LambdaQueryWrapper<SgEvent> 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<String> 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<SgIncomingLine> sgIncomingLineLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
sgIncomingLineLambdaQueryWrapper.eq(SgIncomingLine::getUserId, userId)
|
||||
.eq(SgIncomingLine::getState, DataStateEnum.ENABLE.getCode());
|
||||
List<SgIncomingLine> imcomingLineList = sgIncomingLineService.list(sgIncomingLineLambdaQueryWrapper);
|
||||
//根据用户id获取所有的进线id
|
||||
if (CollectionUtil.isEmpty(imcomingLineList)) {
|
||||
return null;
|
||||
}
|
||||
List<String> incomingLineIDList = imcomingLineList.stream().map(SgIncomingLine::getId).collect(Collectors.toList());
|
||||
List<List<Object>> list = countEventTims(incomingLineIDList, beginDate, endDate);
|
||||
// 转换
|
||||
ArrayList<String> amplitudes = new ArrayList<>();
|
||||
ArrayList<String> durations = new ArrayList<>();
|
||||
ArrayList<ArrayList<String>> value = new ArrayList<>();
|
||||
List<TransientEventCount> tbList = new ArrayList<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
List<Object> 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<String> vv = new ArrayList<String>();
|
||||
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<String> v = value.get(i);
|
||||
String[] vv = v.toArray(new String[v.size()]);
|
||||
strTwo[i] = vv;
|
||||
}
|
||||
params.setValues(strTwo);
|
||||
|
||||
list.remove(0);
|
||||
for (List<Object> 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<SgMachineVO> machineVOList = productLineComputeData.getMachineVOList();
|
||||
if (CollectionUtil.isNotEmpty(machineVOList)) {
|
||||
for (int i = 0; i < machineVOList.size(); i++) {
|
||||
List<SgSensitiveUnitVO> 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<SgEventVO> 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<SgSensitiveUnitVO> 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<List<Object>> countEventTims(List<String> lineIds, String beginDate, String endDate) {
|
||||
List<List<Object>> rList = new ArrayList();
|
||||
List<Object> firstRow = new ArrayList<>();
|
||||
firstRow.add("幅值\\持续时间");
|
||||
rList.add(firstRow);
|
||||
boolean b = true;
|
||||
for (double[] amplitudeRange : AMPLITUDE) {
|
||||
ArrayList<Object> 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<Object> getOneRowEventTimesData(List<Object> firstRow, double[] amplitudeRange, double[][] durationTime, List<String> lineIds, String beginDate, String endDate) {
|
||||
ArrayList<Object> rList = new ArrayList<Object>();
|
||||
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<SgEvent> 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<SgEvent> intersectionList(List<SgEvent> aList, List<SgEvent> bList) {
|
||||
List<SgEvent> 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<SgEvent> processTimeResponse(List<SgEvent> mainEvents, List<SgEvent> backupEvents, int timeResponse) {
|
||||
List<SgEvent> 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<Integer[], Integer> fillMap(List<SgEvent> eventList) {
|
||||
Map<Integer[], Integer> 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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2024-03-27
|
||||
*/
|
||||
@Service
|
||||
public class SgGovernSchemeHistoryDetailServiceImpl extends ServiceImpl<SgGovernSchemeHistoryDetailMapper, SgGovernSchemeHistoryDetail> implements ISgGovernSchemeHistoryDetailService {
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2024-03-27
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SgGovernSchemeHistoryServiceImpl extends ServiceImpl<SgGovernSchemeHistoryMapper, SgGovernSchemeHistory> implements ISgGovernSchemeHistoryService {
|
||||
|
||||
|
||||
private final ISgProductLineService productLineService;
|
||||
|
||||
/**
|
||||
* 分页查询出治理方案下的历史数据
|
||||
*
|
||||
* @param sgSchemeHistoryQueryParam 查询条件
|
||||
*/
|
||||
@Override
|
||||
public Page<SgGovernSchemeHistoryVO> schemeHistoryList(SgGovernSchemeHistoryParam.SgSchemeHistoryQueryParam sgSchemeHistoryQueryParam) {
|
||||
QueryWrapper<SgGovernSchemeHistoryVO> queryWrapper = new QueryWrapper<>();
|
||||
List<String> productId = new ArrayList<>();
|
||||
if (StrUtil.isNotBlank(sgSchemeHistoryQueryParam.getUserId())) {
|
||||
//查询出该用户下所有的生产线
|
||||
LambdaQueryWrapper<SgProductLine> sgProductLineLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
sgProductLineLambdaQueryWrapper
|
||||
.select(SgProductLine::getId)
|
||||
.eq(SgProductLine::getUserId, sgSchemeHistoryQueryParam.getUserId())
|
||||
.eq(SgProductLine::getState, DataStateEnum.ENABLE.getCode());
|
||||
List<SgProductLine> 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<SgGovernSchemeHistoryVO> data = this.baseMapper.page(new Page<>(PageFactory.getPageNum(sgSchemeHistoryQueryParam), PageFactory.getPageSize(sgSchemeHistoryQueryParam)), queryWrapper);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteScheme(List<String> ids) {
|
||||
return this.lambdaUpdate()
|
||||
.set(SgGovernSchemeHistory::getState, DataStateEnum.DELETED.getCode())
|
||||
.in(SgGovernSchemeHistory::getId, ids)
|
||||
.update();
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2024-03-27
|
||||
*/
|
||||
@Service
|
||||
public class SgGovernSchemeParamServiceImpl extends ServiceImpl<SgGovernSchemeParamMapper, SgGovernSchemeParam> implements ISgGovernSchemeParamService {
|
||||
|
||||
}
|
||||
@@ -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<SgIncomingLineMapper,
|
||||
.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SgOption> lineList() {
|
||||
return this.baseMapper.lineList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验进线名称是否有重复的
|
||||
* @param incomingLineParam 进线数据
|
||||
|
||||
@@ -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<SgMachineMapper, SgMachine> implements ISgMachineService {
|
||||
|
||||
private final ISgSensitiveUnitService sgSensitiveUnitService;
|
||||
|
||||
@Override
|
||||
public Page<SgMachineVO> sgMachineListByProductLineId(SgMachineParam.SgMachineQueryParam sgMachineQueryParam) {
|
||||
if(StrUtil.isBlank(sgMachineQueryParam.getProductLineId())){
|
||||
@@ -76,10 +83,31 @@ public class SgMachineServiceImpl extends ServiceImpl<SgMachineMapper, SgMachine
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteSgMachineData(List<String> ids) {
|
||||
return this.lambdaUpdate()
|
||||
.set(SgMachine::getState, DataStateEnum.DELETED.getCode())
|
||||
.in(SgMachine::getId, ids)
|
||||
.update();
|
||||
LambdaQueryWrapper<SgSensitiveUnit> 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<SgMachineVO> listAllMachineByProductLineId(String productLineId) {
|
||||
return this.baseMapper.listAllMachineByProductLineId(productLineId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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<SgProductLineMapper, S
|
||||
|
||||
private final ISgMachineService machineService;
|
||||
|
||||
private final ISgSensitiveUnitService sgSensitiveUnitService;
|
||||
|
||||
|
||||
/**
|
||||
* 因为理论上不会超过5条生产线,所以该分页其实也没有多大的必要
|
||||
@@ -57,22 +64,22 @@ public class SgProductLineServiceImpl extends ServiceImpl<SgProductLineMapper, S
|
||||
queryWrapper.eq("sg_product_line.user_id", userId)
|
||||
.eq("sg_product_line.state", DataStateEnum.ENABLE.getCode())
|
||||
.orderByDesc("sg_product_line.create_time");
|
||||
Page<SgProductLineVO> data = this.baseMapper.page(new Page<>(PageFactory.getPageNum(sgProductLineQueryParam), PageFactory.getPageSize(sgProductLineQueryParam)), queryWrapper);
|
||||
Page<SgProductLineVO> data = this.baseMapper.page(new Page<>(PageFactory.getPageNum(sgProductLineQueryParam), PageFactory.getPageSize(sgProductLineQueryParam)), queryWrapper);
|
||||
List<SgProductLineVO> records = data.getRecords();
|
||||
//循环遍历处理下生产线总功率、设备损失、原料损失
|
||||
if(CollectionUtil.isNotEmpty(records)){
|
||||
if (CollectionUtil.isNotEmpty(records)) {
|
||||
//根据生产线获取下面所有设备
|
||||
List<String> productLineIdList = records.stream().map(SgProductLineVO::getId).collect(Collectors.toList());
|
||||
LambdaQueryWrapper<SgMachine> 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<SgMachine> machineList = machineService.list(sgMachineLambdaQueryWrapper);
|
||||
//判断是否有设备数据,有的话,进行java分组,以生产线id为key
|
||||
Map<String, List<SgMachine>> stringListMap = machineList.stream().collect(Collectors.groupingBy(SgMachine::getProductLineId));
|
||||
for (SgProductLineVO sgProductLineVO : records) {
|
||||
String productLineId = sgProductLineVO.getId();
|
||||
List<SgMachine> 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<SgProductLineMapper, S
|
||||
|
||||
/**
|
||||
* 新增生产线
|
||||
*
|
||||
* @param sgProductLineParam 数据内容
|
||||
*/
|
||||
@Override
|
||||
@@ -105,6 +113,7 @@ public class SgProductLineServiceImpl extends ServiceImpl<SgProductLineMapper, S
|
||||
|
||||
/**
|
||||
* 更新生产线
|
||||
*
|
||||
* @param updateParam 数据内容
|
||||
*/
|
||||
@Override
|
||||
@@ -117,27 +126,71 @@ public class SgProductLineServiceImpl extends ServiceImpl<SgProductLineMapper, S
|
||||
|
||||
/**
|
||||
* 根据id逻辑删除生产线数据
|
||||
*
|
||||
* @param ids id集合
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteSgProductData(List<String> ids) {
|
||||
return this.lambdaUpdate()
|
||||
.set(SgProductLine::getState, DataStateEnum.DELETED.getCode())
|
||||
.in(SgProductLine::getId, ids)
|
||||
.update();
|
||||
LambdaQueryWrapper<SgMachine> 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<SgProductLine> querySgProductLineByUserId(String userId) {
|
||||
LambdaQueryWrapper<SgProductLine> sgProductLineLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
sgProductLineLambdaQueryWrapper
|
||||
.eq(SgProductLine::getUserId, userId)
|
||||
.eq(SgProductLine::getState, DataStateEnum.ENABLE.getCode());
|
||||
return this.list(sgProductLineLambdaQueryWrapper);
|
||||
public List<SgProductLineVO> querySgProductLineByUserId(String userId) {
|
||||
QueryWrapper<SgProductLineVO> 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<SgMachineVO> sgMachineVOList = machineService.listAllMachineByProductLineId(productLineId);
|
||||
if (CollectionUtil.isNotEmpty(sgMachineVOList)) {
|
||||
productLineComputeData.setMachineVOList(sgMachineVOList);
|
||||
//获取每个设备下的敏感元器件数据
|
||||
for (SgMachineVO sgMachineVO : sgMachineVOList) {
|
||||
List<SgSensitiveUnitVO> 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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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<SgSensitiveUnitMappe
|
||||
.in(SgSensitiveUnit::getId, ids)
|
||||
.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SgSensitiveUnitVO> listAllUnitByMachineId(String machineId) {
|
||||
if(StrUtil.isBlank(machineId)){
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return this.baseMapper.listAllUnitByMachineId(machineId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<SgUserMapper, SgUser> implements ISgUserService {
|
||||
|
||||
private final ISgProductLineService productLineService;
|
||||
|
||||
private final ISgIncomingLineService incomingLineService;
|
||||
|
||||
@Override
|
||||
public Page<SgUserVO> sgUserList(SgUserParam.SgUserQueryParam sgUserQueryParam) {
|
||||
QueryWrapper<SgUserVO> queryWrapper = new QueryWrapper<>();
|
||||
@@ -57,7 +67,23 @@ public class SgUserServiceImpl extends ServiceImpl<SgUserMapper, SgUser> 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<SgUserVO> sgUserVOPage = this.baseMapper.page(new Page<>(PageFactory.getPageNum(sgUserQueryParam), PageFactory.getPageSize(sgUserQueryParam)), queryWrapper);
|
||||
if (CollectionUtil.isNotEmpty(sgUserVOPage.getRecords())) {
|
||||
List<SgUserVO> records = sgUserVOPage.getRecords();
|
||||
//获取该用户的生产线数量和进线数量
|
||||
for (SgUserVO record : records) {
|
||||
LambdaQueryWrapper<SgProductLine> productLineLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
productLineLambdaQueryWrapper.eq(SgProductLine::getUserId, record.getId())
|
||||
.eq(SgProductLine::getState, DataStateEnum.ENABLE.getCode());
|
||||
record.setProductCount(productLineService.count(productLineLambdaQueryWrapper));
|
||||
LambdaQueryWrapper<SgIncomingLine> 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<SgUserMapper, SgUser> 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<SgUserMapper, SgUser> impleme
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteSgUserData(List<String> ids) {
|
||||
return this.lambdaUpdate()
|
||||
.set(SgUser::getState, DataStateEnum.DELETED.getCode())
|
||||
.in(SgUser::getId, ids)
|
||||
.update();
|
||||
LambdaQueryWrapper<SgProductLine> 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<SgUser> sgUserAllList() {
|
||||
LambdaQueryWrapper<SgUser> sgUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
sgUserLambdaQueryWrapper
|
||||
.eq(SgUser::getState, DataStateEnum.ENABLE.getCode())
|
||||
.orderByDesc(SgUser::getCreateTime);
|
||||
return this.list(sgUserLambdaQueryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,6 +27,18 @@
|
||||
<artifactId>common-web</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<!--oracle驱动-->
|
||||
<dependency>
|
||||
<groupId>com.oracle.database.jdbc</groupId>
|
||||
<artifactId>ojdbc8</artifactId>
|
||||
</dependency>
|
||||
<!-- 不支持的字符集 (在类路径中添加 orai18n.jar): ZHS16GBK -->
|
||||
<dependency>
|
||||
<groupId>com.oracle.database.nls</groupId>
|
||||
<artifactId>orai18n</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- mybatis-plus自动生成代码 -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
|
||||
@@ -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<Module> 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);
|
||||
|
||||
@@ -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********************************************************
|
||||
|
||||
@@ -121,5 +121,10 @@ public interface OssPath {
|
||||
*/
|
||||
String EVENT_WAVE_PIC="event/wave/";
|
||||
|
||||
/***
|
||||
* 谐波治理的数据文件
|
||||
*/
|
||||
String GOVERN_HARMONIC_FILE="govern/harmonic/";
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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/**
|
||||
|
||||
Reference in New Issue
Block a user