diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java index 7819df5..2a696c7 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java @@ -61,7 +61,8 @@ public interface HomePageConstant { List SIGNAGES = Arrays.asList(HomePageConstant.JOINT_RELAY,HomePageConstant.SWITCH_ON_OFF,HomePageConstant.ELECTRICITY_CONSUMPTION, HomePageConstant.ACTIVE_POWER,HomePageConstant.REACTIVE_POWER,HomePageConstant.POWER_FACTOR,HomePageConstant.VOLTAGE,HomePageConstant.CURRENT, HomePageConstant.HYDROPOWER_GENERATE_POWER,HomePageConstant.HYDROPOWER_POWERFACTOR,HomePageConstant.HYDROPOWER_FREQUENCY,HomePageConstant.HYDROPOWER_GUIDEOPEN, - HomePageConstant.HYDROPOWER_VOLTAGE,HomePageConstant.HYDROPOWER_CURRENT,HomePageConstant.UNIT_SPEED,HomePageConstant.ACTIVE_POWER_GIVEN,HomePageConstant.REACTIVE_POWER_GIVEN); + HomePageConstant.HYDROPOWER_VOLTAGE,HomePageConstant.HYDROPOWER_CURRENT,HomePageConstant.UNIT_SPEED,HomePageConstant.ACTIVE_POWER_GIVEN,HomePageConstant.REACTIVE_POWER_GIVEN, + HomePageConstant.PV_GENERATION_DAY); /** * 站点类型 : 运维服务 @@ -168,16 +169,26 @@ public interface HomePageConstant { String P_ATTRIBUTES = "P"; /*==========================================================================================*/ // 光伏电站-电表-物模型监测点标识 + /**开关机状态**/ + String PV_JOINT_RELAY = "joint_relay"; /**总有功电度**/ String PV_GENERATION_CAPACITY = "generation_capacity"; + /**日发电量**/ + String PV_GENERATION_DAY = "generate_day"; + /**有功功率**/ + String PV_LOAD = "active_power"; /**正向无功**/ String PV_REACTIVE_POWER = "reactive_power"; - /**遥信1**/ - String PV_JOINT_RELAY = "joint_relay"; + /**电压**/ + String PV_VOLTAGE = "voltage"; + /**电流**/ + String PV_CURRENT = "current"; + /*==========================================================================================*/ // 光伏指标属性 - String PHOTOVOLTAIC_GENERATE = "generation_capacity"; // 发电量 - String PHOTOVOLTAIC_LOAD = "active_power"; // 功率 + String PHOTOVOLTAIC_OFF = "1.0"; // 开机 + + String PHOTOVOLTAIC_LOAD_TARGET = "0"; /*==========================================================================================*/ // 水电集团、区域指标关联 /**功率**/ diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/GenerationPowerVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/GenerationPowerVo.java index afc10af..b744dba 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/GenerationPowerVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/GenerationPowerVo.java @@ -12,5 +12,8 @@ public class GenerationPowerVo { private String date; @ApiModelProperty(value = "发电量") - private Float generationPower; + private Float generate; + + @ApiModelProperty(value = "功率·") + private Float load; } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/GenerationVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/GenerationVo.java index cb1f13f..1c23bce 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/GenerationVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/GenerationVo.java @@ -17,6 +17,6 @@ public class GenerationVo { @ApiModelProperty(value = "周期") private String period; - @ApiModelProperty(value = "月发电量") + @ApiModelProperty(value = "发电量") private Float power; } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicDeviceStateVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicDeviceStateVo.java new file mode 100644 index 0000000..1cd5742 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicDeviceStateVo.java @@ -0,0 +1,21 @@ +package com.hnac.hzims.operational.main.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author ysj + * @date 2023/04/03 16:57:22 + * @version 4.0.0 + */ +@Data +@ApiModel(value = "光伏站点设备状态对象") +public class PhotovoltaicDeviceStateVo { + + @ApiModelProperty(value = "设备装态 : 0 - 离线 1 - 在线 2 - 故障") + private Integer state; + + @ApiModelProperty(value = "数量") + private Integer count; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicDeviceVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicDeviceVo.java index 3e62dab..b4b9c05 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicDeviceVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicDeviceVo.java @@ -75,6 +75,11 @@ public class PhotovoltaicDeviceVo { @JsonSerialize(nullsUsing = NullSerializer.class) private Double tec; + + @ApiModelProperty(value = "减少森林砍伐:1kwh = 0.000553") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double deforest; + @ApiModelProperty(value = "收益: 元") @JsonSerialize(nullsUsing = NullSerializer.class) private Double income; diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicLoadGenerateVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicLoadGenerateVo.java new file mode 100644 index 0000000..0a093a1 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicLoadGenerateVo.java @@ -0,0 +1,31 @@ +package com.hnac.hzims.operational.main.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.NullSerializer; +import com.hnac.hzims.hzimsweather.response.weather.Daily; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springblade.core.tool.utils.DateUtil; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDateTime; +import java.util.List; + +/** + * @author ysj + * @date 2023/03/29 15:14:34 + * @version 4.0.0 + */ +@Data +@ApiModel(value = "水利站点首页对象") +public class PhotovoltaicLoadGenerateVo { + + @ApiModelProperty(value = "周期") + private String period; + + @ApiModelProperty(value = "数据值") + private Float value; + +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicLoadVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicLoadVo.java new file mode 100644 index 0000000..22733f7 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicLoadVo.java @@ -0,0 +1,31 @@ +package com.hnac.hzims.operational.main.vo; + + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.NullSerializer; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author ysj + * @date 2023/04/04 09:28:34 + * @version 4.0.0 + */ +@Data +@ApiModel(value = "发电量数据") +public class PhotovoltaicLoadVo { + + @ApiModelProperty(value = "机构ID") + private Long deptId; + + @ApiModelProperty(value = "站点编码") + private String code; + + @ApiModelProperty(value = "站点名称") + private String name; + + @ApiModelProperty(value = "实时功率") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double load; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicPowerVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicPowerVo.java index 94e760d..f1cd386 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicPowerVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicPowerVo.java @@ -10,7 +10,7 @@ import lombok.Data; public class PhotovoltaicPowerVo { @ApiModelProperty(value = "小时") - private String hour; + private Integer hour; @ApiModelProperty(value = "有功功率") private String activePower; diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicStationAppVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicStationAppVo.java new file mode 100644 index 0000000..83cb0eb --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicStationAppVo.java @@ -0,0 +1,75 @@ +package com.hnac.hzims.operational.main.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.NullSerializer; +import com.hnac.hzims.hzimsweather.response.weather.Daily; +import com.hnac.hzims.hzimsweather.response.weather.Now; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springblade.core.tool.utils.DateUtil; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDateTime; +import java.util.List; + +/** + * @author ysj + * @date 2023/03/29 15:14:34 + * @version 4.0.0 + */ +@Data +@ApiModel(value = "光伏站点首页对象") +public class PhotovoltaicStationAppVo { + + @ApiModelProperty(value = "机构Id") + private Long deptId; + + @ApiModelProperty(value = "机构名称") + private String deptName; + + @ApiModelProperty(value = "站点编码") + private String stationCode; + + @ApiModelProperty(value = "地址") + private String address; + + @ApiModelProperty(value = "总发电负荷") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double load; + + @ApiModelProperty(value = "日发电量") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double generateDay; + + @ApiModelProperty(value = "月发电量") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double generateMon; + + @ApiModelProperty(value = "总发电量") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double generate; + + @ApiModelProperty(value = "天气") + private Now now; + + @ApiModelProperty(value = "站点收益") + private Double income; + + @ApiModelProperty(value = "co2减排: kg") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double co2; + + @ApiModelProperty(value = "节约标准煤减排: kt") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double tec; + + @ApiModelProperty(value = "减少森林砍伐:1kwh = 0.000553") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double deforest; + + @ApiModelProperty(value = "减少森林砍伐:1kwh = 0.000553") + @JsonSerialize(nullsUsing = NullSerializer.class) + private List deviceState; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicSubordinateAppVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicSubordinateAppVo.java new file mode 100644 index 0000000..4ff8edd --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicSubordinateAppVo.java @@ -0,0 +1,91 @@ +package com.hnac.hzims.operational.main.vo; + + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.NullSerializer; +import com.hnac.hzims.hzimsweather.response.weather.Now; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author ysj + * @date 2023/03/24 09:58:57 + * @version 4.0.0 + */ +@Data +@ApiModel(value = "发电量数据") +public class PhotovoltaicSubordinateAppVo { + + @ApiModelProperty(value = "机构ID") + private Long deptId; + + @ApiModelProperty(value = "机构名称") + private String deptName; + + @ApiModelProperty(value = "天气") + private Now now; + + @ApiModelProperty(value = "地址") + private String address; + + @ApiModelProperty(value = "容量") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double capacity; + + @ApiModelProperty(value = "今日发电量") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double generateDay; + + @ApiModelProperty(value = "实时功率") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double load; + + @ApiModelProperty(value = "站点实时功率列表") + private List stationLoads; + + @ApiModelProperty(value = "日常任务数量") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Integer maintenanceCount; + + @ApiModelProperty(value = "日常任务完成数量") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Integer maintenanceFinishCount; + + @ApiModelProperty(value = "缺陷任务数量") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Integer defectCount; + + @ApiModelProperty(value = "缺陷任务完成数量") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Integer defectFinishCount; + + @ApiModelProperty(value = "检修任务数量") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Integer overhaulCount; + + @ApiModelProperty(value = "检修任务完成数量") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Integer overhaulFinishCount; + + @ApiModelProperty(value = "操作票任务数量") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Integer operateCount; + + @ApiModelProperty(value = "操作票任务完成数量") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Integer operateFinishCount; + + @ApiModelProperty(value = "操作票任务数量") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Integer workCount; + + @ApiModelProperty(value = "操作票任务完成数量") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Integer workFinishCount; + + @ApiModelProperty(value = "排序") + private Integer sort; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/SubordinateVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicSubordinateVo.java similarity index 98% rename from hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/SubordinateVo.java rename to hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicSubordinateVo.java index 2baaa0b..4dd253a 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/SubordinateVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicSubordinateVo.java @@ -17,7 +17,7 @@ import java.util.List; */ @Data @ApiModel(value = "发电量数据") -public class SubordinateVo { +public class PhotovoltaicSubordinateVo { @ApiModelProperty(value = "机构ID") private Long deptId; diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/mybatisplus/CodeGenerator.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/mybatisplus/CodeGenerator.java index b3d63f6..50f2d36 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/mybatisplus/CodeGenerator.java +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/mybatisplus/CodeGenerator.java @@ -92,7 +92,7 @@ public class CodeGenerator { // strategy.setSuperControllerClass("你自己的父类控制器,没有就不用设置!"); // 写于父类中的公共字段 // strategy.setSuperEntityColumns("id"); - strategy.setInclude("hzims_sys_log"); + strategy.setInclude("hzims_statistics"); strategy.setControllerMappingHyphenStyle(true); strategy.setTablePrefix("hzims_"); mpg.setStrategy(strategy); diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/config/SysLogConfig.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/config/SysLogConfig.java new file mode 100644 index 0000000..006d3aa --- /dev/null +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/config/SysLogConfig.java @@ -0,0 +1,29 @@ +package com.hnac.hzims.middle.systemlog.config; + +import com.hnac.hzims.middle.systemlog.task.SyslogTimerTask; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.util.Timer; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/4/8 14:15 + */ +@Configuration +public class SysLogConfig { + + @Bean + public void syslogTimer() { + //1.创建一个timer实例 + Timer timer = new Timer(); + //2.创建一个SyslogTimerTask实例 + SyslogTimerTask myTimeTask = new SyslogTimerTask(); + //3.通过timer定时定频率调用SyslogTimerTask的业务逻辑 + // 即 第一次执行是在当前时间的两秒之后,之后每隔30秒钟执行一次 + timer.schedule(myTimeTask,2000L,30000L); + } + +} diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/controller/StatisticsController.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/controller/StatisticsController.java new file mode 100644 index 0000000..7e5a59b --- /dev/null +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/controller/StatisticsController.java @@ -0,0 +1,21 @@ +package com.hnac.hzims.middle.systemlog.controller; + + +import org.springframework.web.bind.annotation.RequestMapping; + +import org.springframework.web.bind.annotation.RestController; + +/** + *

+ * 操作日志统计数据 前端控制器 + *

+ * + * @author dfy + * @since 2023-04-08 + */ +@RestController +@RequestMapping("/systemlog/statistics") +public class StatisticsController { + +} + diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/entity/Statistics.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/entity/Statistics.java new file mode 100644 index 0000000..09bde87 --- /dev/null +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/entity/Statistics.java @@ -0,0 +1,70 @@ +package com.hnac.hzims.middle.systemlog.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 操作日志统计数据 + *

+ * + * @author dfy + * @since 2023-04-08 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("hzims_statistics") +public class Statistics implements Serializable { + + private static final long serialVersionUID=1L; + + /** + * 编号 + */ + @TableField("id") + private Long id; + + /** + * 统计日期 + */ + @TableField("date_calculated") + private String dateCalculated; + + /** + * 操作模块统计 + */ + @TableField("title_num") + private Integer titleNum; + + /** + * 功能模块统计 + */ + @TableField("module_name_num") + private Integer moduleNameNum; + + /** + * 请求路径统计 + */ + @TableField("path_num") + private Integer pathNum; + + /** + * 创建时间 + */ + @TableField("create_time") + private LocalDateTime createTime; + + /** + * 更新时间 + */ + @TableField("update_time") + private LocalDateTime updateTime; + + +} diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/entity/SysLog.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/entity/SysLog.java index 484f955..210acca 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/entity/SysLog.java +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/entity/SysLog.java @@ -195,4 +195,5 @@ public class SysLog implements Serializable { private Integer isDeleted; + } diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/mapper/StatisticsMapper.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/mapper/StatisticsMapper.java new file mode 100644 index 0000000..53166f0 --- /dev/null +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/mapper/StatisticsMapper.java @@ -0,0 +1,16 @@ +package com.hnac.hzims.middle.systemlog.mapper; + +import com.hnac.hzims.middle.systemlog.entity.Statistics; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 操作日志统计数据 Mapper 接口 + *

+ * + * @author dfy + * @since 2023-04-08 + */ +public interface StatisticsMapper extends BaseMapper { + +} diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/mapper/xml/StatisticsMapper.xml b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/mapper/xml/StatisticsMapper.xml new file mode 100644 index 0000000..093a8d3 --- /dev/null +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/mapper/xml/StatisticsMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/StatisticsService.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/StatisticsService.java new file mode 100644 index 0000000..a04f72c --- /dev/null +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/StatisticsService.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.middle.systemlog.service; + +import com.hnac.hzims.middle.systemlog.entity.Statistics; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 操作日志统计数据 服务类 + *

+ * + * @author dfy + * @since 2023-04-08 + */ +public interface StatisticsService extends IService { + + /** + * 保存统计的数据 + */ + void saveCountStatistics(); +} diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/StatisticsServiceImpl.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/StatisticsServiceImpl.java new file mode 100644 index 0000000..b1f5c97 --- /dev/null +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/StatisticsServiceImpl.java @@ -0,0 +1,34 @@ +package com.hnac.hzims.middle.systemlog.service.impl; + +import com.hnac.hzims.middle.systemlog.entity.Statistics; +import com.hnac.hzims.middle.systemlog.mapper.StatisticsMapper; +import com.hnac.hzims.middle.systemlog.service.StatisticsService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnac.hzims.middle.systemlog.service.SysLogService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + *

+ * 操作日志统计数据 服务实现类 + *

+ * + * @author dfy + * @since 2023-04-08 + */ +@Service +public class StatisticsServiceImpl extends ServiceImpl implements StatisticsService { + + @Autowired + private SysLogService sysLogService; + + + /** + * 保存统计的数据 + */ + @Override + public void saveCountStatistics() { + //1. 保存操作模块的数据 + + } +} diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/task/SyslogTimerTask.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/task/SyslogTimerTask.java new file mode 100644 index 0000000..99a09d0 --- /dev/null +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/task/SyslogTimerTask.java @@ -0,0 +1,31 @@ +package com.hnac.hzims.middle.systemlog.task; + +import com.hnac.hzims.middle.systemlog.service.StatisticsService; +import com.hnac.hzims.middle.systemlog.service.SysLogService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.TimerTask; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/4/8 14:13 + */ +@Component +public class SyslogTimerTask extends TimerTask { + + + @Autowired + private StatisticsService statisticsService; + + /** + * The action to be performed by this timer task. + */ + @Override + public void run() { + //保存统计的数据 + statisticsService.saveCountStatistics(); + } +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java index 0d2f513..0ad4b3e 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java @@ -270,6 +270,7 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl("SUCCESS"); } @@ -292,30 +292,30 @@ public class ScheduledCreateTask { } /** - * 光伏站-逆变器指标加载 + * 光伏站-逆变器实时加载 * @return ReturnT */ - @XxlJob(LOAD_PHOTOVOLTAIC_TARGET) - //@Scheduled(cron = "0/40 * * * * ? ") - public ReturnT loadPhotovoltaicTarget(String param) throws Exception { + @XxlJob(LOAD_PHOTOVOLTAIC_REAL) + //@Scheduled(cron = "0/50 * * * * ? ") + public ReturnT loadPhotovoltaicReal(String param) throws Exception { if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); } - photovoltaicService.loadPhotovoltaicTarget(param); + photovoltaicService.loadPhotovoltaicReal(param); return new ReturnT<>("SUCCESS"); } /** - * 光伏站-逆变器实时加载 + * 光伏站-逆变器指标加载 * @return ReturnT */ - @XxlJob(LOAD_PHOTOVOLTAIC_REAL) - //@Scheduled(cron = "0/50 * * * * ? ") - public ReturnT loadPhotovoltaicReal(String param) throws Exception { + @XxlJob(LOAD_PHOTOVOLTAIC_TARGET) + //@Scheduled(cron = "0/40 * * * * ? ") + public ReturnT loadPhotovoltaicTarget(String param) throws Exception { if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); } - photovoltaicService.loadPhotovoltaicReal(param); + photovoltaicService.loadPhotovoltaicTarget(param); return new ReturnT<>("SUCCESS"); } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IAnalyseDataService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IAnalyseDataService.java index ef30137..421d09e 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IAnalyseDataService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IAnalyseDataService.java @@ -1,8 +1,9 @@ package com.hnac.hzims.operational.main.service; +import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO; import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO; +import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeDataConditionVO; import com.hnac.hzinfo.sdk.analyse.po.MultiAnalyzeCodePO; -import org.apache.poi.ss.formula.functions.T; import java.util.List; import java.util.function.Function; @@ -11,6 +12,11 @@ import java.util.function.Function; * @author hx */ public interface IAnalyseDataService { + List getAnalyzeCodeBySignages(Function convert, T resource); + + List periodTargetData(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, String signages); + + Float periodTargetFloat(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, Integer ride ,String signages); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/PhotovoltaicService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/PhotovoltaicService.java index 7f8fb6f..3ae3e87 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/PhotovoltaicService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/PhotovoltaicService.java @@ -1,9 +1,6 @@ package com.hnac.hzims.operational.main.service; -import com.hnac.hzims.operational.main.vo.GenerationVo; -import com.hnac.hzims.operational.main.vo.PhotovoltaicKPIsVo; -import com.hnac.hzims.operational.main.vo.PhotovoltaicStationVo; -import com.hnac.hzims.operational.main.vo.SubordinateVo; +import com.hnac.hzims.operational.main.vo.*; import java.util.List; @@ -27,8 +24,17 @@ public interface PhotovoltaicService { List generation(Long deptId,String type); // 集团/区域下属数据占比 - List subordinate(Long deptId); + List subordinate(Long deptId); // 站点数据 PhotovoltaicStationVo station(Long deptId); + + // app区域数据 + List app_subordinate(Long deptId); + + // app站点数据 + PhotovoltaicStationAppVo app_station(Long deptId); + + // App功率/发电量查询 + List app_load_generate(Long deptId, String type,String queryType); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AnalyseDataServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AnalyseDataServiceImpl.java index d2b360e..c7acf95 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AnalyseDataServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AnalyseDataServiceImpl.java @@ -1,16 +1,30 @@ package com.hnac.hzims.operational.main.service.impl; import com.google.common.collect.Lists; +import com.hnac.hzims.EquipmentConstants; +import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; import com.hnac.hzims.operational.main.service.IAnalyseDataService; import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; +import com.hnac.hzinfo.datasearch.analyse.po.AnalyseCodeByAnalyseDataPO; +import com.hnac.hzinfo.datasearch.analyse.po.AnalyzeDataConditionPO; +import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO; import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO; +import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeDataConditionVO; import com.hnac.hzinfo.sdk.analyse.po.MultiAnalyzeCodePO; import lombok.AllArgsConstructor; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.DateUtil; +import org.springblade.core.tool.utils.ObjectUtil; +import org.springblade.core.tool.utils.StringUtil; import org.springframework.stereotype.Service; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.Date; import java.util.List; +import java.util.Random; import java.util.function.Function; import java.util.stream.Collectors; @@ -33,4 +47,89 @@ public class AnalyseDataServiceImpl implements IAnalyseDataService { } return result; } + + /*** + * 指标数据列表查询 + * @param startTime 开始时间 + * @param endTime 结束时间 + * @param accessRules 取数规则 : 0=最早值 1=最大值 2=最小值 3=平均值 4=和值 5=差值 6=最新值 + * @param cycleType 间隔周期 : 0-> 秒 1-> 分 2-> 小时 3->天 4-> 周 5-> 月 6-> 年 + * @param deviceCode 设备编号 + * @param signages 指标 + * @return + */ + @Override + public List periodTargetData(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, String signages) { + AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO(); + List signboardConditions = new ArrayList<>(); + AnalyzeDataConditionPO analyzeDataConditionPO = new AnalyzeDataConditionPO(); + analyzeDataConditionPO.setFull(1); + po.setDeviceCode(deviceCode); + analyzeDataConditionPO.setSignages(signages); + analyzeDataConditionPO.setAccessRules(accessRules); + analyzeDataConditionPO.setSaveTimeType(cycleType); + // 间隔 + analyzeDataConditionPO.setTimeInterval(1); + analyzeDataConditionPO.setBeginTime(LocalDateTime.parse(DateUtil.format(new Date(), startTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME))); + analyzeDataConditionPO.setEndTime(LocalDateTime.parse(DateUtil.format(new Date(), endTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME))); + signboardConditions.add(analyzeDataConditionPO); + po.setSignboardConditions(signboardConditions); + R> result = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(po); + if (!result.isSuccess() || CollectionUtil.isEmpty(result.getData())) { + return new ArrayList<>(); + } + return result.getData().get(0).getList(); + } + + /*** + * 指标数据列表查询 + * @param startTime 开始时间 + * @param endTime 结束时间 + * @param accessRules 间隔周期 : 0-> 秒 1-> 分 2-> 小时 3->天 4-> 周 5-> 月 6-> 年 + * @param cycleType 取数规则 : 0=最早值 1=最大值 2=最小值 3=平均值 4=和值 5=差值 6=最新值 + * @param deviceCode 设备编号 + * @param ride 配电比 + * @param signages 指标 + * @return + */ + @Override + public Float periodTargetFloat(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode,Integer ride,String signages) { + AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO(); + List signboardConditions = new ArrayList<>(); + AnalyzeDataConditionPO analyzeDataConditionPO = new AnalyzeDataConditionPO(); + analyzeDataConditionPO.setFull(1); + po.setDeviceCode(deviceCode); + analyzeDataConditionPO.setSignages(signages); + analyzeDataConditionPO.setAccessRules(accessRules); + analyzeDataConditionPO.setSaveTimeType(cycleType); + // 间隔 + analyzeDataConditionPO.setTimeInterval(1); + analyzeDataConditionPO.setBeginTime(LocalDateTime.parse(DateUtil.format(new Date(), startTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME))); + analyzeDataConditionPO.setEndTime(LocalDateTime.parse(DateUtil.format(new Date(), endTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME))); + signboardConditions.add(analyzeDataConditionPO); + po.setSignboardConditions(signboardConditions); + R> result = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(po); + if (!result.isSuccess() || CollectionUtil.isEmpty(result.getData())) { + return 0f; + } + List records = result.getData(); + if(CollectionUtil.isEmpty(records)){ + return 0f; + } + AnalyzeDataConditionVO analyzeDataConditionVO = records.get(0); + if (ObjectUtil.isEmpty(analyzeDataConditionVO)) { + return 0f; + } + List analyseDataTaosVOList = analyzeDataConditionVO.getList(); + if (CollectionUtil.isEmpty(analyseDataTaosVOList)) { + return 0f; + } + AnalyseDataTaosVO analyseDataTaosVO = analyzeDataConditionVO.getList().get(0); + if (ObjectUtil.isEmpty(analyseDataTaosVO) || StringUtil.isBlank(analyseDataTaosVO.getVal())) { + return 0f; + } + return Float.parseFloat(analyseDataTaosVO.getVal()) * ride; + } + + } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomePageServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomePageServiceImpl.java index 06ce852..e2fc91b 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomePageServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomePageServiceImpl.java @@ -11,6 +11,7 @@ import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; import com.hnac.hzims.monitor.utils.DateUtils; import com.hnac.hzims.operational.fill.entity.*; import com.hnac.hzims.operational.fill.service.*; +import com.hnac.hzims.operational.main.service.IAnalyseDataService; import com.hnac.hzims.operational.main.service.IHomePageService; import com.hnac.hzims.operational.main.service.IMainSystemMonitoringService; import com.hnac.hzims.operational.main.service.IMainTaskStatisticService; @@ -69,7 +70,8 @@ import java.util.stream.Collectors; @Slf4j public class HomePageServiceImpl implements IHomePageService { - private final IAnalyseDataSearchClient analyseDataSearchClient; + + private final IAnalyseDataService analyseDataService; private final IPlanGenertionClient planGenertionClient; private final IMainSystemMonitoringService maintenanceTaskService; private final IMainTaskStatisticService mainTaskStatisticService; @@ -219,41 +221,70 @@ public class HomePageServiceImpl implements IHomePageService { * * @param param 时间 * @param serveType 站点类型 - * @param yearCount 近几年 + * @param year 近几年 */ @Override - public void loadPowerData(String param,List types, Integer serveType, int yearCount) { + public void loadPowerData(String param,List types, Integer serveType, int year) { // 站点查询 List stationList = stationService.getStationType(serveType, types, null); // 设备信息 - List equipmentInfoList = maintenanceTaskService.getEmInfoList(); + List devices = maintenanceTaskService.getEmInfoList(); + // 开始事件 + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH) + 12); + calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1); + String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00"; + // 结束日期 + calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) - year); + calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH)); + String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00"; // 存储数据map :<站点id,<月份,发电量>> Map> powerMap = new HashMap<>(); - // 获取需要遍历月份 - List monList = this.getMonthList(yearCount, 12,true); - Random random = new Random(); stationList.forEach(station -> { - Long departId = station.getRefDept(); - // 获取对应站点设备 - List effEmInfoList = equipmentInfoList.stream().filter(o -> departId.equals(o.getCreateDept())).collect(Collectors.toList()); - if (CollectionUtil.isEmpty(effEmInfoList)) { + // 站点设备集合 + List stationDevices = devices.stream().filter(device -> device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(stationDevices)){ return; } - Map floatMap = new HashMap<>(); - for (int i = 0; i < monList.size() - 1; i++) { - if (this.compareDate(monList.get(i))) { - floatMap.put(monList.get(i), 0f); - continue; - } - float power = getPowerGeneration(effEmInfoList, monList.get(i) + " 00:00:00", monList.get(i + 1) + " 00:00:00",EquipmentConstants.CycleTypeEnum.MONTH_CYCLE.getType()); - floatMap.put(monList.get(i), power); + Map generateMap = this.getGenerateYear(stationDevices,start,end); + if(MapUtils.isEmpty(generateMap)){ + return; } - powerMap.put(station.getId(), floatMap); + powerMap.put(station.getId(),generateMap); }); redisTemplate.opsForValue().set(RECENT_YEAR_POWER_DATA, powerMap); } /** + * 获取年发电量 + * @param devices + * @param start + * @param end + * @return + */ + private Map getGenerateYear(List devices, String start, String end) { + List datas = new ArrayList<>(); + devices.forEach(device->{ + List records = analyseDataService.periodTargetData(start,end,5,5,device.getEmCode(),HomePageConstant.HYDROPOWER_GENERATE_POWER); + if(CollectionUtil.isEmpty(records)){ + return; + } + datas.addAll(records.stream().map(record -> { + PowerMonthVo generate = new PowerMonthVo(); + Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + generate.setStrMonth(DateUtil.format(time,DateUtil.PATTERN_DATE)); + generate.setPower(Float.valueOf(Optional.ofNullable(record.getVal()).orElse("0")) * device.getRideCount()); + return generate; + }).collect(Collectors.toList())); + }); + if(CollectionUtil.isEmpty(datas)){ + return null; + } + return datas.stream().collect(Collectors.groupingBy(PowerMonthVo::getStrMonth, Collectors.collectingAndThen( + Collectors.mapping(PowerMonthVo::getPower, Collectors.reducing(Float::sum)),Optional::get))); + } + + /** * @param stationList * @return */ diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java index e36e12e..b12c294 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java @@ -13,12 +13,16 @@ import com.hnac.hzims.operational.main.service.*; import com.hnac.hzims.operational.main.vo.*; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.service.IStationService; +import com.hnac.hzims.ticket.workTicket.feign.ITicketInfoClient; +import com.hnac.hzims.ticket.workTicket.vo.TicketMonthVO; import com.hnac.hzinfo.datasearch.PointData; +import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO; import com.hnac.hzinfo.datasearch.history.IHistoryDataSearchClient; import com.hnac.hzinfo.datasearch.history.OriginalDataQuery; import com.hnac.hzinfo.sdk.core.response.HzPage; import com.hnac.hzinfo.sdk.core.response.Result; import lombok.RequiredArgsConstructor; +import net.sf.jsqlparser.expression.StringValue; import org.apache.commons.collections4.MapUtils; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.tool.api.R; @@ -38,15 +42,19 @@ import java.text.SimpleDateFormat; import java.time.Duration; import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.LocalTime; import java.time.format.DateTimeFormatter; import java.util.*; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import java.util.stream.Collectors; /** * @author ysj - * @date 2023/03/23 16:51:43 * @version 4.0.0 + * @date 2023/03/23 16:51:43 */ @Service @RequiredArgsConstructor @@ -62,136 +70,288 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { private final IWeatherService weatherService; + private final IAnalyseDataService analyseDataService; + private final IHistoryDataSearchClient historySearchClient; + private final IMainTaskStatisticService taskService; + private final ISysClient sysClient; + private final ITicketInfoClient ticketInfoClient; + private final RedisTemplate redisTemplate; private final static String load_photovoltaic_real_key = "hzims:operation:photovoltaic:real:key"; private final static String load_photovoltaic_target_key = "hzims:operation:photovoltaic:target:key"; - private final static String RECENT_YEAR_POWER_DATA = "hzims:operation:key:power:data"; + private final static String recent_year_power_data = "hzims:operation:key:power:data"; @Value("${hzims.operation.realIdKey}") public String real_id_key; + // 线程数量 + private final static int POOL_QUANTITY = 4; + /** * 光伏站-逆变器实时加载 + * * @param param */ @Override public void loadPhotovoltaicReal(String param) { // 查询设备 List devices = this.getPhotovoltaicDevice(); - if(CollectionUtil.isEmpty(devices)){ + if (CollectionUtil.isEmpty(devices)) { return; } // 取redis实时数据 Map map = this.getRealData(); - List list = new ArrayList<>(); - Random random = new Random(); - devices.forEach(device->{ + if(MapUtils.isEmpty(map)){ + return; + } + // redis缓存设备实时数据 + List history = (List) redisTemplate.opsForValue().get(load_photovoltaic_real_key); + // 设备实时数据 + List list = devices.stream().map(device -> { PhotovoltaicRealVo real = new PhotovoltaicRealVo(); real.setDeptId(device.getCreateDept()); real.setDeviceCode(device.getEmCode()); real.setDeviceName(device.getName()); - real.setState(random.nextInt(2)-1); + real.setState(this.getPhotovoltaicState(device,map)); // 容量 real.setCapacity(device.getInstalledCapacity()); // 发电量 - real.setGenerate(random.nextDouble() * 25000 * 300 * 2); + real.setGenerate(Double.valueOf(this.getSignageValue(device,map,HomePageConstant.PV_GENERATION_CAPACITY))); + // 功率 + real.setLoad(Double.valueOf(this.getSignageValue(device,map,HomePageConstant.PV_LOAD))); // 电压 - real.setVoltage(random.nextDouble() * 300); + real.setVoltage(Double.valueOf(this.getSignageValue(device,map,HomePageConstant.PV_VOLTAGE))); // 电流 - real.setCurrent(random.nextDouble() * 300); - // 功率 - real.setLoad(random.nextDouble() * 300); + real.setCurrent(Double.valueOf(this.getSignageValue(device,map,HomePageConstant.PV_CURRENT))); // 上次功率 - real.setLastLoad(random.nextDouble() * 300); - list.add(real); - }); - redisTemplate.opsForValue().set(load_photovoltaic_real_key,list); + real.setLastLoad(this.getLastLoad(device,history)); + return real; + }).collect(Collectors.toList()); + // 存储redis + redisTemplate.opsForValue().set(load_photovoltaic_real_key, list); } /** * 光伏站-逆变器指标加载 + * * @param param */ @Override public void loadPhotovoltaicTarget(String param) { // 有效设备 List devices = this.getPhotovoltaicDevice(); - if(CollectionUtil.isEmpty(devices)){ + if (CollectionUtil.isEmpty(devices)) { return; } List list = new ArrayList<>(); - Random random = new Random(); - devices.forEach(device->{ + devices.forEach(device -> { PhotovoltaicTargetVo target = new PhotovoltaicTargetVo(); target.setDeptId(device.getCreateDept()); target.setDeviceCode(device.getEmCode()); target.setDeviceName(device.getName()); target.setDeptName(device.getName()); // 当日运行时长 - // target.setRunHours(this.runHours(device.getPoint().get(HomePageConstant.PV_JOINT_RELAY))); - // 当天有功功率 - // List activePowerVoList = waterService.getActivePowerVoList(device); - // FIXME 测试数据 - // 当天运行时长 - target.setRunHours(new Random().nextDouble() * 24); + //target.setRunHours(this.runHours(device.getPoint().get(HomePageConstant.PV_JOINT_RELAY))); // 年发电量 - target.setGenerationYear(random.nextDouble() * 25000 * 360); + target.setGenerationYear((double) this.sumValueByTime(device.getEmCode(),device.getRideCount(),"0")); // 月发电量 - target.setGenerationMon(random.nextDouble() * 25000 * 30); + target.setGenerationMon((double) this.sumValueByTime(device.getEmCode(),device.getRideCount(),"1")); // 日发电量 - target.setGenerationDay(random.nextDouble() * 25000); + target.setGenerationDay((double) this.sumValueByTime(device.getEmCode(),device.getRideCount(),"2")); + // 昨日发电量 + target.setGenerationYesterday((double) this.sumValueByTime(device.getEmCode(),device.getRideCount(),"3")); // 收益 target.setIncome(target.getGenerationDay() * 0.34); - // 昨日发电量 - target.setGenerationYesterday(random.nextDouble() * 25000); // 节约标准煤 target.setTec(target.getGenerationMon() * 0.0001229); // 二氧化碳减排 target.setCo2(target.getGenerationMon() * 0.000997); // 减少森林砍伐 target.setDeforest(target.getGenerationMon() * 0.000553); - // FIXME 测试模拟数据30天功率 - List photovoltaicPowers = this.activePowerVoList(device); - target.setActivePowerVoList(photovoltaicPowers); + // 当天有功功率 + target.setActivePowerVoList(this.getLoadsByDay(device)); // 30天发电量 - List generationPowerVoList = this.getGenerationPowerList(device); - target.setGenerationPowerVoList(generationPowerVoList); + target.setGenerationPowerVoList(this.getGenerateByMon(device)); list.add(target); }); - redisTemplate.opsForValue().set(load_photovoltaic_target_key,list); + redisTemplate.opsForValue().set(load_photovoltaic_target_key, list); } - // FIXME 测试模拟 - private List activePowerVoList(EminfoAndEmParamVo device) { - List hours = getTestDay(); - Random random = new Random(); - return hours.stream().map(hour -> { - PhotovoltaicPowerVo power = new PhotovoltaicPowerVo(); - power.setHour(hour); - power.setActivePower(String.valueOf(random.nextDouble() * 500)); - return power; - }).collect(Collectors.toList()); + /** + * 当天有功功率 + * @param device + * @return + */ + private List getLoadsByDay(EminfoAndEmParamVo device) { + String start = DateUtil.format(new Date(),DateUtil.PATTERN_DATE) + " 00:00:00"; + String end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME); + List records = analyseDataService.periodTargetData(start,end,1,2,device.getEmCode(),HomePageConstant.PV_LOAD); + if(CollectionUtil.isEmpty(records)){ + return new ArrayList<>(); + } + return records.stream().map(record -> { + PhotovoltaicPowerVo load = new PhotovoltaicPowerVo(); + Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + load.setHour(time.getHours()); + load.setActivePower(Optional.ofNullable(record.getVal()).orElse("0")); + return load; + }).sorted(Comparator.comparing(PhotovoltaicPowerVo::getHour)).collect(Collectors.toList()); + } + + /** + * 近30天发电量 + * @param device + * @return + */ + private List getGenerateByMon(EminfoAndEmParamVo device) { + Calendar calendar = Calendar.getInstance(); + String end = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATETIME); + calendar.add(Calendar.DAY_OF_MONTH, -29); + calendar.add(Calendar.HOUR_OF_DAY, -calendar.get(Calendar.HOUR_OF_DAY)); + calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE)); + calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND)); + String start = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATETIME); + List records = analyseDataService.periodTargetData(start,end,5,3,device.getEmCode(),HomePageConstant.PV_GENERATION_CAPACITY); + if(CollectionUtil.isEmpty(records)){ + return new ArrayList<>(); + } + return records.stream().map(record -> { + GenerationPowerVo generate = new GenerationPowerVo(); + Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + generate.setDate(DateUtil.format(time,DateUtil.PATTERN_DATE)); + generate.setGenerate(Float.valueOf(Optional.ofNullable(record.getVal()).orElse("0"))); + return generate; + }).sorted(Comparator.comparing(GenerationPowerVo::getDate)).collect(Collectors.toList()); } /** + * 根据事件查询数据值 + * @param deviceCode + * @param rideCount + * @param type + * @return + */ + private float sumValueByTime(String deviceCode, int rideCount,String type) { + Calendar calendar = Calendar.getInstance(); + String start = null,end = null; + Integer cycleType = 3; + switch (type){ + //年 + case "0": + calendar.add(Calendar.HOUR_OF_DAY, + 1); + end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); + calendar.setTime(new Date()); + calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH)); + calendar.add(Calendar.DAY_OF_MONTH, -calendar.get(Calendar.DATE) + 1); + calendar.add(Calendar.HOUR_OF_DAY, -calendar.get(Calendar.HOUR_OF_DAY)); + calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE)); + calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND)); + start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); + cycleType = 6; + break; + //月 + case "1": + start = DateUtil.format(new Date(),"yyyy-MM") + "-01 00:00:00"; + end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME); + cycleType = 5; + break; + //日 + case "2": + start = DateUtil.format(new Date(),DateUtil.PATTERN_DATE) + " 00:00:00"; + end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME); + break; + //昨日 + case "3": + calendar.add(Calendar.DAY_OF_MONTH, - 1); + calendar.add(Calendar.HOUR_OF_DAY, -calendar.get(Calendar.HOUR_OF_DAY)); + calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE)); + calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND)); + start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); + end = DateUtil.format(new Date(),DateUtil.PATTERN_DATE) + " 00:00:00"; + break; + } + return analyseDataService.periodTargetFloat(start,end,5,cycleType,deviceCode,rideCount,HomePageConstant.PV_GENERATION_CAPACITY); + } + + /** + * 获取上一次功率 + * @param device + * @param history + * @return + */ + private Double getLastLoad(EminfoAndEmParamVo device, List history) { + if(CollectionUtil.isEmpty(history)){ + return 0.0; + } + List historyDevice = history.stream().filter(o -> o.getDeviceCode().equals(device.getEmCode())).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(historyDevice)){ + return 0.0; + } + return historyDevice.get(0).getLoad(); + } + + /** + * 获取开机状态 + * @param device + * @return + */ + private int getPhotovoltaicState(EminfoAndEmParamVo device,Map map) { + // 获取开关机监测点实时数据 + String value = this.getSignageValue(device,map,HomePageConstant.PV_JOINT_RELAY); + // 开机状态 + if (HomePageConstant.OFF.equals(value)) { + return 0; + } + return 1; + } + + /** + * 获取监测点实时数据 + * @param em + * @param map + * @param targets + * @return + */ + private String getSignageValue(EminfoAndEmParamVo em,Map map, String targets) { + if(ObjectUtil.isEmpty(em) || MapUtils.isEmpty(map)){ + return "0"; + } + Map point = em.getPoint(); + if(MapUtils.isEmpty(point)){ + return "0"; + } + String realId = point.get(targets); + if(StringUtil.isEmpty(realId)){ + return "0"; + } + String value = map.get(realId); + if(StringUtil.isEmpty(realId)){ + return "0"; + } + // 获取value + return value; + } + + /** * 当天运行时长 + * * @param realId * @return */ private Double runHours(String realId) { Calendar calendar = Calendar.getInstance(); Date end = calendar.getTime(); - calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY)); - calendar.add(Calendar.MINUTE,-calendar.get(Calendar.MINUTE)); - calendar.add(Calendar.SECOND,-calendar.get(Calendar.SECOND)); + calendar.add(Calendar.HOUR_OF_DAY, -calendar.get(Calendar.HOUR_OF_DAY)); + calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE)); + calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND)); Date start = calendar.getTime(); OriginalDataQuery originalDataQuery = new OriginalDataQuery(); originalDataQuery.setRealId(realId); @@ -201,44 +361,65 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { originalDataQuery.setPage(1); // 查询时间范围开关机监测点历史数据 Result> R = historySearchClient.getOriginalDataByRealIds(originalDataQuery); - if(!R.isSuccess() || ObjectUtil.isEmpty(R.getData())){ + if (!R.isSuccess() || ObjectUtil.isEmpty(R.getData())) { return 0.0; } // 过滤相邻开关机状态相同数据 List result = this.filterData(R.getData().getRecords()); - if(CollectionUtil.isEmpty(result)){ + if (CollectionUtil.isEmpty(result)) { return 0.0; } // 开机运行时长 - long time = this.runTime(result,start,end); + long time = this.runTime(result, start, end); return BigDecimal.valueOf(time / (1000 * 60 * 60.00)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); } /** + * 当天运行时长 + * + * @return + */ + private List getDayHours() { + List list = new ArrayList<>(); + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.HOUR_OF_DAY, -calendar.get(Calendar.HOUR_OF_DAY)); + calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE)); + calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND)); + // 获取时间 + while (calendar.getTime().compareTo(new Date()) <= 0) { + list.add(String.valueOf(calendar.get(Calendar.HOUR_OF_DAY))); + calendar.add(Calendar.HOUR_OF_DAY, +1); + } + return list.stream().sorted(Comparator.comparing(String::valueOf)).collect(Collectors.toList()); + } + + + /** * 过滤相邻开关机状态相同数据 + * * @param list * @return */ private List filterData(List list) { - if(CollectionUtil.isEmpty(list)){ + if (CollectionUtil.isEmpty(list)) { return null; } List result = new ArrayList<>(); // 遍历数据 - for(int i = 0; i< list.size() ; i++){ + for (int i = 0; i < list.size(); i++) { // 第一个数据保存下来 - if(i == 0){ + if (i == 0) { result.add(list.get(i)); continue; } // 遍历数据状态 String value = list.get(i).getValue(); - if(StringUtil.isBlank(value)){ + if (StringUtil.isBlank(value)) { continue; } // 上一条数据状态 - String up_value = list.get(i-1).getValue(); - if(value.equals(up_value)){ + String up_value = list.get(i - 1).getValue(); + if (value.equals(up_value)) { continue; } result.add(list.get(i)); @@ -248,32 +429,32 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { /** * 获取运行时长 + * * @param result * @return */ - private long runTime(List result,Date startDate,Date endDate) { - if(result.size() == 1){ + private long runTime(List result, Date startDate, Date endDate) { + if (result.size() == 1) { // 一直开机 - if(HomePageConstant.OFF.equals(result.get(0).getValue())){ + if (HomePageConstant.PHOTOVOLTAIC_OFF.equals(result.get(0).getValue())) { return endDate.getTime() - startDate.getTime(); } // 一直关机 return 0; } - long time=0; + long time = 0; // 遍历累计开机时长 - for(int i = 0; i< result.size() ; i++){ + for (int i = 0; i < result.size(); i++) { // 记录为开机状态 就计算到下次关机的时间差 - if(HomePageConstant.ON.equals(result.get(i).getValue())){ + if (HomePageConstant.ON.equals(result.get(i).getValue())) { continue; } - Date endTime,startTime = DateUtil.parse(result.get(i).getTime(), DateUtil.PATTERN_DATETIME); + Date endTime, startTime = DateUtil.parse(result.get(i).getTime(), DateUtil.PATTERN_DATETIME); // 遍历至最后一条数据,累计至当前时间 - if(i == result.size() - 1){ + if (i == result.size() - 1) { endTime = endDate; - } - else { - endTime = DateUtil.parse(result.get(i+1).getTime(), DateUtil.PATTERN_DATETIME); + } else { + endTime = DateUtil.parse(result.get(i + 1).getTime(), DateUtil.PATTERN_DATETIME); } time += endTime.getTime() - startTime.getTime(); } @@ -283,18 +464,19 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { /** * 获取年、月、日发电量 + * * @param device * @param scope * @return */ - private float getGenerationPower(EminfoAndEmParamVo device,int scope) { + private float getGenerationPower(EminfoAndEmParamVo device, int scope) { // 日期格式化yyyy-mm-dd SimpleDateFormat df = new SimpleDateFormat(DateUtil.PATTERN_DATE); // 日期格式化yyyy-mm-dd SimpleDateFormat sdf = new SimpleDateFormat(DateUtil.PATTERN_DATETIME); - String startTime,endTime; + String startTime, endTime; int cycle; - switch (scope){ + switch (scope) { // 年 case 0: Calendar calendar = Calendar.getInstance(); @@ -322,53 +504,12 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { default: throw new IllegalStateException("Unexpected value: " + scope); } - return homePageService.getAnalyzeCodeAndSignages(device,startTime,endTime,cycle,HomePageConstant.PHOTOVOLTAIC_GENERATE); - } - - /** - * 近30天发电量 - * @param device - * @return - */ - private List getGenerationPowerList(EminfoAndEmParamVo device) { - List generationPowerVoList = new ArrayList<>(); - // 近30天日期集合 - List dayList = this.getRecent30Day(); - for (int i = 0; i < dayList.size() - 1; i++) { - GenerationPowerVo generationPowerVo = new GenerationPowerVo(); - generationPowerVo.setDate(dayList.get(i)); - // 某天发电量 - float power = homePageService.getAnalyzeCodeAndSignages(device, dayList.get(i) + " 00:00:00", dayList.get(i + 1) + " 00:00:00",EquipmentConstants.CycleTypeEnum.DAY_CYCLE.getType(),HomePageConstant.PHOTOVOLTAIC_GENERATE); - generationPowerVo.setGenerationPower(power); - generationPowerVoList.add(generationPowerVo); - } - return generationPowerVoList; - } - - /** - * 近7天发电量 - * @param device - * @return - */ - private List getGenerationPowerWeek(EminfoAndEmParamVo device) { - List generationPowerVoList = new ArrayList<>(); - // 近一周日期集合 - List dayList = this.getRecentWeek(); - SimpleDateFormat sdf = new SimpleDateFormat("EEEE"); - for (int i = 0; i < dayList.size() - 1; i++) { - GenerationPowerVo generationPowerVo = new GenerationPowerVo(); - generationPowerVo.setDate(sdf.format(DateUtil.parse(dayList.get(i),DateUtil.PATTERN_DATE))); - // 某天发电量 - float power = homePageService.getAnalyzeCodeAndSignages(device, dayList.get(i) + " 00:00:00", dayList.get(i + 1) + " 00:00:00",EquipmentConstants.CycleTypeEnum.DAY_CYCLE.getType(),HomePageConstant.PHOTOVOLTAIC_GENERATE); - generationPowerVo.setGenerationPower(power); - generationPowerVoList.add(generationPowerVo); - } - return generationPowerVoList; + return homePageService.getAnalyzeCodeAndSignages(device, startTime, endTime, cycle, HomePageConstant.PV_GENERATION_CAPACITY); } - /** * 当天功率 + * * @return */ private List getTestDay() { @@ -378,12 +519,12 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { // 开始日期 Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date()); - calendar.add(Calendar.HOUR_OF_DAY, - calendar.get(Calendar.HOUR_OF_DAY)); - calendar.add(Calendar.HOUR_OF_DAY, + 1); + calendar.add(Calendar.HOUR_OF_DAY, -calendar.get(Calendar.HOUR_OF_DAY)); + calendar.add(Calendar.HOUR_OF_DAY, +1); list.add(df.format(calendar.getTime())); // 获取时间 while (calendar.getTime().compareTo(new Date()) <= 0) { - calendar.add(Calendar.HOUR_OF_DAY, + 1); + calendar.add(Calendar.HOUR_OF_DAY, +1); list.add(df.format(calendar.getTime())); } return list.stream().sorted(Comparator.comparing(String::valueOf)).collect(Collectors.toList()); @@ -391,6 +532,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { /** * 获取近30天集合 + * * @return */ private List getRecentWeek() { @@ -400,36 +542,13 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { // 开始日期 Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date()); - calendar.add(Calendar.DATE, + 1); - list.add(df.format(calendar.getTime())); - // 获取日期之间的月 - int i = 0; - while (i < 7) { - calendar.add(Calendar.DATE, - 1); - list.add(df.format(calendar.getTime())); - i++; - } - return list.stream().sorted(Comparator.comparing(String::valueOf)).collect(Collectors.toList()); - } - - /** - * 获取近30天集合 - * @return - */ - private List getRecent30Day() { - // 日期格式化yyyy-mm-dd - SimpleDateFormat df = new SimpleDateFormat(DateUtil.PATTERN_DATE); - List list = new ArrayList<>(); - // 开始日期 - Calendar calendar = Calendar.getInstance(); - calendar.setTime(new Date()); - calendar.add(Calendar.DATE, + 1); + calendar.add(Calendar.DATE, +1); list.add(df.format(calendar.getTime())); // 获取日期之间的月 int i = 0; - while (i < 30) { - calendar.add(Calendar.DATE, - 1); + while (i <= 7) { list.add(df.format(calendar.getTime())); + calendar.add(Calendar.DATE, -1); i++; } return list.stream().sorted(Comparator.comparing(String::valueOf)).collect(Collectors.toList()); @@ -437,29 +556,32 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { /** * 获取实时数据 + * * @return */ private Map getRealData() { String json = (String) redisTemplate.opsForValue().get(real_id_key); - if(StringUtil.isBlank(json)){ + if (StringUtil.isBlank(json)) { return null; } - return JSONObject.parseObject(json, new TypeReference>() {}); + return JSONObject.parseObject(json, new TypeReference>() { + }); } /** * 获取光伏设备 + * * @return */ private List getPhotovoltaicDevice() { // 光伏站点 - List stations = stationService.getStationType(HomePageConstant.HYDROPOWER_SERVETYPE, Collections.singletonList(HomePageConstant.PHOTOVOLTAIC),null); - if(CollectionUtil.isEmpty(stations)){ + List stations = stationService.getStationType(HomePageConstant.HYDROPOWER_SERVETYPE, Collections.singletonList(HomePageConstant.PHOTOVOLTAIC), null); + if (CollectionUtil.isEmpty(stations)) { return null; } // 设备 List devices = deviceService.getEmInfoList(); - if(CollectionUtil.isEmpty(devices)){ + if (CollectionUtil.isEmpty(devices)) { return null; } return devices.stream().filter(device -> @@ -469,14 +591,15 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { /** * 集团/区域关键指标 + * * @param deptId * @return */ @Override public PhotovoltaicKPIsVo KPIs(Long deptId) { // 查询光伏站点 - List stations = stationService.getHomeStationList(deptId,Collections.singletonList(HomePageConstant.PHOTOVOLTAIC),HomePageConstant.HYDROPOWER_SERVETYPE); - if(CollectionUtil.isEmpty(stations)){ + List stations = stationService.getHomeStationList(deptId, Collections.singletonList(HomePageConstant.PHOTOVOLTAIC), HomePageConstant.HYDROPOWER_SERVETYPE); + if (CollectionUtil.isEmpty(stations)) { return new PhotovoltaicKPIsVo(); } PhotovoltaicKPIsVo kpi = new PhotovoltaicKPIsVo(); @@ -484,9 +607,9 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { kpi.setCount(stations.size()); // 实时数据 List deviceReals = (List) redisTemplate.opsForValue().get(load_photovoltaic_real_key); - if(CollectionUtil.isNotEmpty(deviceReals)){ + if (CollectionUtil.isNotEmpty(deviceReals)) { List reals = deviceReals.stream().filter(device -> stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(device.getDeptId())).collect(Collectors.toList()); - if(CollectionUtil.isNotEmpty(reals)){ + if (CollectionUtil.isNotEmpty(reals)) { // 容量 kpi.setInstalledCapacity(reals.stream().mapToDouble(PhotovoltaicRealVo::getCapacity).sum()); // 负荷 @@ -495,11 +618,11 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { } // 指标数据 List deviceTargets = (List) redisTemplate.opsForValue().get(load_photovoltaic_target_key); - if(CollectionUtil.isEmpty(deviceTargets)){ + if (CollectionUtil.isEmpty(deviceTargets)) { return kpi; } List targets = deviceTargets.stream().filter(device -> stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(device.getDeptId())).collect(Collectors.toList()); - if(CollectionUtil.isEmpty(targets)){ + if (CollectionUtil.isEmpty(targets)) { return kpi; } // 年发电量 @@ -521,12 +644,13 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { /** * 获取近3年发电量 + * * @return */ private List getPowerList(List stations) { // 站点近年发电数据 key - stationCode value - 月份,发电量 - Map> map = (Map>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA); - if(MapUtils.isEmpty(map)){ + Map> map = (Map>) redisTemplate.opsForValue().get(recent_year_power_data); + if (MapUtils.isEmpty(map)) { return new ArrayList<>(); } List> filter = map.entrySet().stream().filter(e -> stations.contains(e.getKey())).map(Map.Entry::getValue).collect(Collectors.toList()); @@ -543,7 +667,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { powerMonthVos.add(powerMonthVo); }); }); - Map> months = powerMonthVos.stream().collect(Collectors.groupingBy(PowerMonthVo::getStrMonth)); + Map> months = powerMonthVos.stream().collect(Collectors.groupingBy(PowerMonthVo::getStrMonth)); // 总和所有相同月份的发电量 List powerMonthVoList = months.entrySet().stream().map(entry -> { PowerMonthVo powerMonth = new PowerMonthVo(); @@ -571,6 +695,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { /** * 集团/区域发电量 + * * @param deptId * @param type * @return @@ -578,17 +703,17 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { @Override public List generation(Long deptId, String type) { // 查询光伏站点 - List stations = stationService.getHomeStationList(deptId,Collections.singletonList(HomePageConstant.PHOTOVOLTAIC),HomePageConstant.HYDROPOWER_SERVETYPE); - if(CollectionUtil.isEmpty(stations)){ + List stations = stationService.getHomeStationList(deptId, Collections.singletonList(HomePageConstant.PHOTOVOLTAIC), HomePageConstant.HYDROPOWER_SERVETYPE); + if (CollectionUtil.isEmpty(stations)) { return new ArrayList<>(); } - switch (type){ + switch (type) { // 周 case "0": - return this.getGeneration(stations.stream().map(StationEntity::getRefDept).distinct().collect(Collectors.toList()),true); + return this.getGeneration(stations.stream().map(StationEntity::getRefDept).distinct().collect(Collectors.toList()), true); // 月 case "1": - return this.getGeneration(stations.stream().map(StationEntity::getRefDept).distinct().collect(Collectors.toList()),false); + return this.getGeneration(stations.stream().map(StationEntity::getRefDept).distinct().collect(Collectors.toList()), false); // 年 case "2": return this.getGenerationYear(stations.stream().map(StationEntity::getId).distinct().collect(Collectors.toList())); @@ -599,58 +724,60 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { /** * 获取发电量(周/月) + * * @return */ - private List getGeneration(List stations,boolean flag) { + private List getGeneration(List stations, boolean flag) { // redis实时数据 List photovoltaics = (List) redisTemplate.opsForValue().get(load_photovoltaic_target_key); - if(CollectionUtil.isEmpty(photovoltaics)){ + if (CollectionUtil.isEmpty(photovoltaics)) { return new ArrayList(); } // 过滤有效光伏设备 List filters = photovoltaics.stream().filter(photovoltaic -> stations.contains(photovoltaic.getDeptId())).collect(Collectors.toList()); - if(CollectionUtil.isEmpty(filters)){ + if (CollectionUtil.isEmpty(filters)) { return new ArrayList<>(); } // 数据集合 List generations = new ArrayList<>(); - for (PhotovoltaicTargetVo target : filters){ - if(CollectionUtil.isEmpty(target.getGenerationPowerVoList())){ + for (PhotovoltaicTargetVo target : filters) { + if (CollectionUtil.isEmpty(target.getGenerationPowerVoList())) { continue; } generations.addAll(target.getGenerationPowerVoList()); } - if(CollectionUtil.isEmpty(generations)){ + if (CollectionUtil.isEmpty(generations)) { return new ArrayList<>(); } List weeks = this.getRecentWeek(); // 周 - if(flag){ + if (flag) { // 根据日期分组 - return generations.stream().filter(generation -> weeks.contains(generation.getDate())).collect(Collectors.groupingBy(GenerationPowerVo::getDate)).entrySet().stream().map(entry->{ + return generations.stream().filter(generation -> weeks.contains(generation.getDate())).collect(Collectors.groupingBy(GenerationPowerVo::getDate)).entrySet().stream().map(entry -> { GenerationVo generation = new GenerationVo(); generation.setPeriod(entry.getKey()); - generation.setPower((float)entry.getValue().stream().mapToDouble(GenerationPowerVo::getGenerationPower).sum()); + generation.setPower((float) entry.getValue().stream().mapToDouble(GenerationPowerVo::getGenerate).sum()); return generation; }).sorted(Comparator.comparing(GenerationVo::getPeriod)).collect(Collectors.toList()); } // 月 - return generations.stream().collect(Collectors.groupingBy(GenerationPowerVo::getDate)).entrySet().stream().map(entry->{ + return generations.stream().collect(Collectors.groupingBy(GenerationPowerVo::getDate)).entrySet().stream().map(entry -> { GenerationVo generation = new GenerationVo(); generation.setPeriod(entry.getKey()); - generation.setPower((float)entry.getValue().stream().mapToDouble(GenerationPowerVo::getGenerationPower).sum()); + generation.setPower((float) entry.getValue().stream().mapToDouble(GenerationPowerVo::getGenerate).sum()); return generation; }).sorted(Comparator.comparing(GenerationVo::getPeriod)).collect(Collectors.toList()); } /** * 获取发电量(年) + * * @return */ private List getGenerationYear(List stations) { // 站点近年发电数据 key - stationCode value - 月份,发电量 - Map> map = (Map>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA); - if(MapUtils.isEmpty(map)){ + Map> map = (Map>) redisTemplate.opsForValue().get(recent_year_power_data); + if (MapUtils.isEmpty(map)) { return new ArrayList<>(); } List> filter = map.entrySet().stream().filter(e -> stations.contains(e.getKey())).map(Map.Entry::getValue).collect(Collectors.toList()); @@ -667,7 +794,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { powerMonthVos.add(powerMonthVo); }); }); - Map> months = powerMonthVos.stream().collect(Collectors.groupingBy(PowerMonthVo::getStrMonth)); + Map> months = powerMonthVos.stream().collect(Collectors.groupingBy(PowerMonthVo::getStrMonth)); // 总和所有相同月份的发电量 String year = String.valueOf(LocalDate.now().getYear()); return months.entrySet().stream().filter(entry -> entry.getKey().contains(year)).map(entry -> { @@ -681,14 +808,15 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { /** * 集团/区域下属数据占比 + * * @param deptId * @return */ @Override - public List subordinate(Long deptId) { + public List subordinate(Long deptId) { // 获取区域或者站点map结构 - Map> map = sideHustleService.getAreaOrStaion(deptId,Collections.singletonList(HomePageConstant.PHOTOVOLTAIC)); - if(MapUtils.isEmpty(map)){ + Map> map = sideHustleService.getAreaOrStaion(deptId, Collections.singletonList(HomePageConstant.PHOTOVOLTAIC)); + if (MapUtils.isEmpty(map)) { return new ArrayList<>(); } // 实时数据 @@ -696,10 +824,10 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { // 指标数据 List deviceTargets = (List) redisTemplate.opsForValue().get(load_photovoltaic_target_key); // 遍历数据 - List list = new ArrayList<>(); - for (Map.Entry> entry : map.entrySet()) { - SubordinateVo subordinate = new SubordinateVo(); - if(ObjectUtil.isEmpty(entry.getValue())){ + List list = new ArrayList<>(); + for (Map.Entry> entry : map.entrySet()) { + PhotovoltaicSubordinateVo subordinate = new PhotovoltaicSubordinateVo(); + if (ObjectUtil.isEmpty(entry.getValue())) { continue; } subordinate.setDeptId(entry.getKey().getId()); @@ -712,7 +840,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { // 省市编码 String areaCode = station.getAreaCode(); subordinate.setAreaCode(areaCode); - if(!StringUtil.isEmpty(areaCode)){ + if (!StringUtil.isEmpty(areaCode)) { String[] arrCode = areaCode.split(","); R R = sysClient.getRegion(arrCode[1]); if (R.isSuccess() && ObjectUtil.isNotEmpty(R.getData())) { @@ -720,23 +848,23 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { } } // 站点类型 - if(HomePageConstant.STATION.equals(entry.getKey().getDeptCategory())){ + if (HomePageConstant.STATION.equals(entry.getKey().getDeptCategory())) { subordinate.setType(entry.getValue().get(0).getPhotovoltaicType()); } // 获取实时天气 Map nowWeather = this.weatherService.getNowWeather(Collections.singletonList(station.getCode())); - if(MapUtils.isNotEmpty(nowWeather)){ + if (MapUtils.isNotEmpty(nowWeather)) { subordinate.setTemp(nowWeather.get(station.getCode()).getNow().getTemp()); } // 获取七天天气 Map weekWeather = weatherService.getWeekWeather(Collections.singletonList(station.getCode())); - if(MapUtils.isNotEmpty(weekWeather)){ + if (MapUtils.isNotEmpty(weekWeather)) { subordinate.setTemp(nowWeather.get(station.getCode()).getNow().getTemp()); } subordinate.setWeather(weekWeather.get(station.getCode()).getDaily()); // 区域/站点 设备实时数据 List reals = deviceReals.stream().filter(photovoltaic -> entry.getValue().stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(photovoltaic.getDeptId())).collect(Collectors.toList()); - if(CollectionUtil.isNotEmpty(reals)){ + if (CollectionUtil.isNotEmpty(reals)) { subordinate.setStationCount(Long.valueOf(entry.getValue().size())); subordinate.setStationUseCount(reals.stream().filter(device -> HomePageConstant.OFF.equals(device.getState())).map(PhotovoltaicRealVo::getDeptId).distinct().count()); subordinate.setCapacity(reals.stream().mapToDouble(PhotovoltaicRealVo::getCapacity).sum()); @@ -744,20 +872,20 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { } // 区域/站点 设备指标数据 List targets = deviceTargets.stream().filter(photovoltaic -> entry.getValue().stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(photovoltaic.getDeptId())).collect(Collectors.toList()); - if(CollectionUtil.isNotEmpty(targets)){ + if (CollectionUtil.isNotEmpty(targets)) { subordinate.setGeneration(targets.stream().mapToDouble(PhotovoltaicTargetVo::getGenerationYear).sum()); } list.add(subordinate); } - if(CollectionUtil.isEmpty(list)){ + if (CollectionUtil.isEmpty(list)) { return new ArrayList<>(); } // 总数据 : 发电量 、 容量 、 电站数 - Double sumGeneration = list.stream().mapToDouble(SubordinateVo::getGeneration).sum(); - Double sumLoad = list.stream().mapToDouble(SubordinateVo::getCapacity).sum(); - Double sumStationCount = list.stream().mapToDouble(SubordinateVo::getStationCount).sum(); + Double sumGeneration = list.stream().mapToDouble(PhotovoltaicSubordinateVo::getGeneration).sum(); + Double sumLoad = list.stream().mapToDouble(PhotovoltaicSubordinateVo::getCapacity).sum(); + Double sumStationCount = list.stream().mapToDouble(PhotovoltaicSubordinateVo::getStationCount).sum(); // 计算 :集团发电占比 电站利用率 容量利用率 - return list.stream().map(subordinate ->{ + return list.stream().map(subordinate -> { if (Math.abs(sumGeneration) <= 0) { subordinate.setGenerationRate(0.0); } else { @@ -774,23 +902,24 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { subordinate.setStationUse(BigDecimal.valueOf(subordinate.getStationUseCount() / sumStationCount * 100L).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); } return subordinate; - }).sorted(Comparator.comparing(SubordinateVo::getCapacity)).collect(Collectors.toList()); + }).sorted(Comparator.comparing(PhotovoltaicSubordinateVo::getCapacity)).collect(Collectors.toList()); } /** * 站点数据 + * * @param deptId * @return */ @Override public PhotovoltaicStationVo station(Long deptId) { // 参数检查 - if(ObjectUtil.isEmpty(deptId)){ + if (ObjectUtil.isEmpty(deptId)) { return new PhotovoltaicStationVo(); } // 查询站点 - StationEntity station = stationService.getOne(Wrappers.lambdaQuery().eq(StationEntity::getRefDept,deptId)); - if(ObjectUtil.isEmpty(station)){ + StationEntity station = stationService.getOne(Wrappers.lambdaQuery().eq(StationEntity::getRefDept, deptId)); + if (ObjectUtil.isEmpty(station)) { return new PhotovoltaicStationVo(); } // 实时监测点数据 @@ -798,7 +927,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { // 获取站点机组指标数据 List targets = (List) redisTemplate.opsForValue().get(load_photovoltaic_target_key); // 站点设备 - List devices = deviceService.getEmInfoList().stream().filter(o-> o.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); + List devices = deviceService.getEmInfoList().stream().filter(o -> o.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); // 实时天气 Map weather = weatherService.getNowWeather(Collections.singletonList(station.getCode())); // 七天天气 @@ -812,15 +941,15 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { // 站点投运时间 photovoltaic.setOperationTime(station.getCommissionTime()); // 站点实时天气 - photovoltaic.setTemp(this.temp(weather,station.getCode())); + photovoltaic.setTemp(this.temp(weather, station.getCode())); // 站点七天天气 - photovoltaic.setWeather(this.week(weekWeather,station.getCode())); + photovoltaic.setWeather(this.week(weekWeather, station.getCode())); // 逆变器数量 photovoltaic.setInverterCount(devices.size()); // 运行天数 photovoltaic.setRunDay(this.run_day(station)); // 设备实时数据、指标数据: 容量、发电量、实时功率、电流、co2、节约标准煤、30日发电量、当日功率 - photovoltaic.setDevices(this.deviceRealTarget(devices,reals,targets)); + photovoltaic.setDevices(this.deviceRealTarget(devices, reals, targets)); // 设备排行榜 photovoltaic.setCharts(this.deviceCharts(photovoltaic.getDevices())); // 站点实时数据: 装机容量、总发电量、功率、收益 @@ -831,17 +960,407 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { } /** + * App区域下属数据 + * + * @param deptId + * @return + */ + @Override + public List app_subordinate(Long deptId) { + // 获取区域或者站点map结构 + Map> map = sideHustleService.getAreaOrStaion(deptId, Collections.singletonList(HomePageConstant.PHOTOVOLTAIC)); + if (MapUtils.isEmpty(map)) { + return new ArrayList<>(); + } + // 实时数据 + List deviceReals = (List) redisTemplate.opsForValue().get(load_photovoltaic_real_key); + // 指标数据 + List deviceTargets = (List) redisTemplate.opsForValue().get(load_photovoltaic_target_key); + // 遍历数据 + List subordinates = new ArrayList<>(); + for (Map.Entry> entry : map.entrySet()) { + PhotovoltaicSubordinateAppVo subordinate = new PhotovoltaicSubordinateAppVo(); + if (ObjectUtil.isEmpty(entry.getValue())) { + continue; + } + StationEntity station = entry.getValue().get(0); + subordinate.setDeptId(entry.getKey().getId()); + subordinate.setDeptName(entry.getKey().getDeptName()); + subordinate.setSort(entry.getKey().getSort()); + subordinate.setAddress(station.getAddress()); + // 获取实时天气 + Map nowWeather = this.weatherService.getNowWeather(Collections.singletonList(station.getCode())); + if (MapUtils.isNotEmpty(nowWeather)) { + subordinate.setNow(nowWeather.get(station.getCode()).getNow()); + } + // 容量、实时功率、今日发电量 + this.subordinateTargetData(subordinate, entry.getValue().stream().collect(Collectors.toList()), deviceReals, deviceTargets); + // 当月任务执行情况 + this.subordinateTaskMon(subordinate,Collections.singletonList(entry.getKey().getId())); + subordinates.add(subordinate); + } + return subordinates; + } + + /** + * 当月任务执行情况 + * @param subordinate + */ + private void subordinateTaskMon(PhotovoltaicSubordinateAppVo subordinate,List depts) { + DateTimeFormatter dtf = DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME); + LocalDate firstDay = LocalDate.now().withDayOfMonth(1); + LocalDateTime startTime = LocalDateTime.of(firstDay, LocalTime.MIN); + LocalDateTime endTime = LocalDateTime.now(); + //通过线程池异步获取月报各模块内容 主要分为五块内容 + ExecutorService exe = Executors.newFixedThreadPool(POOL_QUANTITY); + //监控线程执行完后返回结果 + CountDownLatch countDownLatch = new CountDownLatch(POOL_QUANTITY); + // 日常维护 + exe.execute(()->{ + MaintainVo maintainVo = taskService.getMaintain(dtf.format(startTime),dtf.format(endTime),depts); + subordinate.setMaintenanceCount(maintainVo.getMaintain()); + subordinate.setMaintenanceFinishCount(maintainVo.getMaintainFinish()); + countDownLatch.countDown(); + }); + + // 消缺 + exe.execute(()->{ + ShortagesVo shortages = taskService.getShortages(depts); + subordinate.setDefectCount(shortages.getShortagesSum()); + subordinate.setDefectFinishCount(shortages.getShortages()); + countDownLatch.countDown(); + }); + // 检修 + exe.execute(()->{ + OverhaulVo overhaulVo = taskService.getOverhaul(dtf.format(startTime),dtf.format(endTime),depts); + int overhaul = overhaulVo.getOverhaul(); + int overhaulFinish = overhaulVo.getOverhaulFinish(); + subordinate.setOverhaulCount(overhaul); + subordinate.setOverhaulFinishCount(overhaulFinish); + countDownLatch.countDown(); + }); + // 操作票&工作票 + exe.execute(()->{ + Map map = new HashMap<>(); + map.put("startDate",dtf.format(startTime)); + map.put("endDate",dtf.format(endTime)); + map.put("deptList",depts); + R R = ticketInfoClient.getOperateWorkStatistic(map); + if (!R.isSuccess() || ObjectUtil.isEmpty(R.getData())) { + return; + } + TicketMonthVO ticketMonthVO = R.getData(); + // 操作票 + subordinate.setOperateCount(ticketMonthVO.getOperate()); + subordinate.setOperateFinishCount(ticketMonthVO.getOperateQualify()); + // 工作票 + subordinate.setWorkCount(ticketMonthVO.getWork()); + subordinate.setWorkFinishCount(ticketMonthVO.getWorkQualify()); + countDownLatch.countDown(); + }); + } + + /** + * App集团/区域指标数据 + * + * @param stations + * @param deviceReals + * @param deviceTargets + */ + private void subordinateTargetData(PhotovoltaicSubordinateAppVo subordinate, List stations, List deviceReals, List deviceTargets) { + if (CollectionUtil.isEmpty(deviceReals) && CollectionUtil.isEmpty(deviceTargets)) { + return; + } + List reals = deviceReals.stream().filter(o -> stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(o.getDeptId())).collect(Collectors.toList()); + List targets = deviceTargets.stream().filter(o -> stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(o.getDeptId())).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(reals)) { + // 容量 、 实时功率 + subordinate.setCapacity(reals.stream().mapToDouble(PhotovoltaicRealVo::getCapacity).sum()); + subordinate.setLoad(reals.stream().mapToDouble(PhotovoltaicRealVo::getLoad).sum()); + subordinate.setStationLoads( + stations.stream().map(station -> { + PhotovoltaicLoadVo load = new PhotovoltaicLoadVo(); + load.setDeptId(station.getRefDept()); + load.setCode(station.getCode()); + load.setName(station.getName()); + load.setLoad(reals.stream().filter(o -> o.getDeptId().equals(station.getRefDept())).mapToDouble(PhotovoltaicRealVo::getLoad).sum()); + return load; + }).sorted(Comparator.comparing(PhotovoltaicLoadVo::getLoad).reversed()).collect(Collectors.toList()) + ); + } + if (CollectionUtil.isNotEmpty(targets)) { + // 今日发电量 + subordinate.setGenerateDay(targets.stream().mapToDouble(PhotovoltaicTargetVo::getGenerationDay).sum()); + } + + } + + /** + * App光伏站点数据 + * + * @param deptId + * @return + */ + @Override + public PhotovoltaicStationAppVo app_station(Long deptId) { + // 参数检查 + if (ObjectUtil.isEmpty(deptId)) { + return new PhotovoltaicStationAppVo(); + } + // 查询站点 + StationEntity station = stationService.getOne(Wrappers.lambdaQuery().eq(StationEntity::getRefDept, deptId)); + if (ObjectUtil.isEmpty(station)) { + return new PhotovoltaicStationAppVo(); + } + PhotovoltaicStationAppVo photovoltaic = new PhotovoltaicStationAppVo(); + // 站点温度 + Map weather = weatherService.getNowWeather(Collections.singletonList(station.getCode())); + photovoltaic.setStationCode(station.getCode()); + photovoltaic.setDeptId(station.getRefDept()); + photovoltaic.setDeptName(station.getName()); + photovoltaic.setNow(weather.get(station.getCode()).getNow()); + photovoltaic.setAddress(station.getAddress()); + // 站点实时数据: 设备状态统计、实时功率、总发电量 、 日发电量 、 月发电量 、 co2减排 、 节约标准煤减排 、 减少森林砍伐 + this.app_data(photovoltaic); + return photovoltaic; + } + + /** + * 站点指标数据 + * + * @param photovoltaic + */ + private void app_data(PhotovoltaicStationAppVo photovoltaic) { + // 实时监测点数据 + List reals = (List) redisTemplate.opsForValue().get(load_photovoltaic_real_key); + // 获取站点机组指标数据 + List targets = (List) redisTemplate.opsForValue().get(load_photovoltaic_target_key); + if (CollectionUtil.isEmpty(reals) && CollectionUtil.isEmpty(targets)) { + return; + } + List mateReals = reals.stream().filter(o -> o.getDeptId().equals(photovoltaic.getDeptId())).collect(Collectors.toList()); + List mateTargets = targets.stream().filter(o -> o.getDeptId().equals(photovoltaic.getDeptId())).collect(Collectors.toList()); + if (CollectionUtil.isEmpty(mateReals) && CollectionUtil.isEmpty(mateTargets)) { + return; + } + // 实时数据 : 实时功率、总发电量 + if (CollectionUtil.isNotEmpty(mateReals)) { + // 设备状态统计 + photovoltaic.setDeviceState( + mateReals.stream().collect(Collectors.groupingBy(PhotovoltaicRealVo::getState)).entrySet().stream().map(entry -> { + PhotovoltaicDeviceStateVo state = new PhotovoltaicDeviceStateVo(); + state.setState(entry.getKey()); + state.setCount(entry.getValue().size()); + return state; + }).collect(Collectors.toList()) + ); + photovoltaic.setLoad(mateReals.stream().mapToDouble(PhotovoltaicRealVo::getLoad).sum()); + photovoltaic.setGenerate(mateReals.stream().mapToDouble(PhotovoltaicRealVo::getGenerate).sum()); + } + // 指标数据 : 日发电量 、 月发电量 、 co2减排 、 节约标准煤减排 、 减少森林砍伐 + if (CollectionUtil.isNotEmpty(mateTargets)) { + photovoltaic.setGenerateDay(mateTargets.stream().mapToDouble(PhotovoltaicTargetVo::getGenerationDay).sum()); + photovoltaic.setGenerateMon(mateTargets.stream().mapToDouble(PhotovoltaicTargetVo::getGenerationMon).sum()); + photovoltaic.setCo2(mateTargets.stream().mapToDouble(PhotovoltaicTargetVo::getCo2).sum()); + photovoltaic.setTec(mateTargets.stream().mapToDouble(PhotovoltaicTargetVo::getTec).sum()); + photovoltaic.setIncome(mateTargets.stream().mapToDouble(PhotovoltaicTargetVo::getIncome).sum()); + photovoltaic.setDeforest(mateTargets.stream().mapToDouble(PhotovoltaicTargetVo::getDeforest).sum()); + } + } + + /** + * App功率/发电量查询 + * + * @param deptId + * @param type + * @return + */ + @Override + public List app_load_generate(Long deptId, String type, String queryType) { + // 查询光伏站点 + List stations = stationService.getHomeStationList(deptId, Collections.singletonList(HomePageConstant.PHOTOVOLTAIC), HomePageConstant.HYDROPOWER_SERVETYPE); + if (CollectionUtil.isEmpty(stations)) { + return new ArrayList<>(); + } + // 区别查询周期 + switch (queryType) { + // 日 + case "0": + return this.periodLoadDay(stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList())); + // 周 + case "1": + return this.periodLoadGenerate(stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()), type, true); + // 月 + case "2": + return this.periodLoadGenerate(stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()), type, false); + // 年 + case "3": + return this.periodLoadGenerateYear(stations.stream().map(StationEntity::getId).collect(Collectors.toList())); + default: + throw new ServiceException("无效查询类型!"); + + } + } + + /** + * 查询光伏设备日数据 + * + * @param stations + * @return + */ + private List periodLoadDay(List stations) { + // FIXME 测试数据 + List hours = getDayHours(); + Random random = new Random(); + return hours.stream().map(hour -> { + PhotovoltaicLoadGenerateVo target = new PhotovoltaicLoadGenerateVo(); + target.setPeriod(hour); + target.setValue((float) (random.nextDouble() * 500)); + return target; + }).sorted(Comparator.comparing(PhotovoltaicLoadGenerateVo::getPeriod)).collect(Collectors.toList()); + + /*// redis实时数据 + List photovoltaics = (List) redisTemplate.opsForValue().get(load_photovoltaic_target_key); + if(CollectionUtil.isEmpty(photovoltaics)){ + return new ArrayList(); + } + // 过滤有效光伏设备 + List devices = photovoltaics.stream().filter(photovoltaic -> stations.contains(photovoltaic.getDeptId())).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(devices)){ + return new ArrayList<>(); + } + SimpleDateFormat sdf = new SimpleDateFormat(DateUtil.PATTERN_DATE); + // 开始日期 + Calendar calendar = Calendar.getInstance(); + String start = sdf.format(calendar.getTime()); + calendar.add(Calendar.HOUR_OF_DAY, -calendar.get(Calendar.HOUR_OF_DAY)); + calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE)); + calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND)); + String end = sdf.format(calendar.getTime()); + List list = new ArrayList<>(); + for(PhotovoltaicTargetVo device : devices){ + list.addAll(analyseDataService.periodTargetData(start,end,1,2,device.getDeviceCode(),HomePageConstant.PHOTOVOLTAIC_LOAD)); + }; + if(CollectionUtil.isEmpty(list)){ + return new ArrayList<>(); + } + return list.stream().collect(Collectors.groupingBy(AnalyseDataTaosVO::getTs)).entrySet().stream().map(entry ->{ + PhotovoltaicLoadGenerateVo target = new PhotovoltaicLoadGenerateVo(); + LocalDateTime time = LocalDateTime.parse(DateUtil.format(new Date(), entry.getKey()), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME)); + target.setPeriod(String.valueOf(time.getHour())); + target.setValue((float) entry.getValue().stream().mapToDouble(o-> Double.parseDouble(String.valueOf(o.getVal()))).sum()); + return target; + }).collect(Collectors.toList());*/ + } + + /** + * 查询周、月数据 + * + * @param type + * @param flag + * @return + */ + private List periodLoadGenerate(List stations, String type, boolean flag) { + // redis实时数据 + List photovoltaics = (List) redisTemplate.opsForValue().get(load_photovoltaic_target_key); + if (CollectionUtil.isEmpty(photovoltaics)) { + return new ArrayList(); + } + // 过滤有效光伏设备 + List filters = photovoltaics.stream().filter(photovoltaic -> stations.contains(photovoltaic.getDeptId())).collect(Collectors.toList()); + if (CollectionUtil.isEmpty(filters)) { + return new ArrayList<>(); + } + // 数据集合 + List targets = new ArrayList<>(); + for (PhotovoltaicTargetVo target : filters) { + if (CollectionUtil.isEmpty(target.getGenerationPowerVoList())) { + continue; + } + targets.addAll(target.getGenerationPowerVoList()); + } + if (CollectionUtil.isEmpty(targets)) { + return new ArrayList<>(); + } + List weeks = this.getRecentWeek(); + // 周 + if (flag) { + // 根据日期分组 + return targets.stream().filter(generation -> weeks.contains(generation.getDate())).collect(Collectors.groupingBy(GenerationPowerVo::getDate)).entrySet().stream().map(entry -> { + PhotovoltaicLoadGenerateVo target = new PhotovoltaicLoadGenerateVo(); + target.setPeriod(entry.getKey()); + if (HomePageConstant.PHOTOVOLTAIC_LOAD_TARGET.equals(type)) { + target.setValue((float) entry.getValue().stream().mapToDouble(GenerationPowerVo::getLoad).sum()); + } else { + target.setValue((float) entry.getValue().stream().mapToDouble(GenerationPowerVo::getGenerate).sum()); + } + return target; + }).sorted(Comparator.comparing(PhotovoltaicLoadGenerateVo::getPeriod)).collect(Collectors.toList()); + } + // 月 + return targets.stream().collect(Collectors.groupingBy(GenerationPowerVo::getDate)).entrySet().stream().map(entry -> { + PhotovoltaicLoadGenerateVo target = new PhotovoltaicLoadGenerateVo(); + target.setPeriod(entry.getKey()); + if (HomePageConstant.PHOTOVOLTAIC_LOAD_TARGET.equals(type)) { + target.setValue((float) entry.getValue().stream().mapToDouble(GenerationPowerVo::getLoad).sum()); + } else { + target.setValue((float) entry.getValue().stream().mapToDouble(GenerationPowerVo::getGenerate).sum()); + } + return target; + }).sorted(Comparator.comparing(PhotovoltaicLoadGenerateVo::getPeriod)).collect(Collectors.toList()); + } + + /** + * 光伏站点年数据查询 + * + * @param stations + * @return + */ + private List periodLoadGenerateYear(List stations) { + // 站点近年发电数据 key - stationCode value - 月份,发电量 + Map> map = (Map>) redisTemplate.opsForValue().get(recent_year_power_data); + if (MapUtils.isEmpty(map)) { + return new ArrayList<>(); + } + List> filter = map.entrySet().stream().filter(e -> stations.contains(e.getKey())).map(Map.Entry::getValue).collect(Collectors.toList()); + if (CollectionUtil.isEmpty(filter)) { + return new ArrayList<>(); + } + // 根据月份分组 + List powerMonthVos = new ArrayList<>(); + filter.forEach(item -> { + item.forEach((key, value) -> { + PowerMonthVo powerMonthVo = new PowerMonthVo(); + powerMonthVo.setStrMonth(key); + powerMonthVo.setPower(value); + powerMonthVos.add(powerMonthVo); + }); + }); + Map> months = powerMonthVos.stream().collect(Collectors.groupingBy(PowerMonthVo::getStrMonth)); + // 总和所有相同月份的发电量 + String year = String.valueOf(LocalDate.now().getYear()); + return months.entrySet().stream().filter(entry -> entry.getKey().contains(year)).map(entry -> { + PhotovoltaicLoadGenerateVo target = new PhotovoltaicLoadGenerateVo(); + target.setPeriod(entry.getKey()); + target.setValue((float) entry.getValue().stream().mapToDouble(PowerMonthVo::getPower).sum()); + return target; + }).sorted(Comparator.comparing(PhotovoltaicLoadGenerateVo::getPeriod)).collect(Collectors.toList()); + } + + + /** * 获取实时温度 + * * @param weather * @param code * @return */ private String temp(Map weather, String code) { - if(MapUtils.isEmpty(weather)){ + if (MapUtils.isEmpty(weather)) { return "21"; } HeWeatherWeatherNowResponse now = weather.get(code); - if(ObjectUtil.isEmpty(now) || ObjectUtil.isEmpty(now.getNow())){ + if (ObjectUtil.isEmpty(now) || ObjectUtil.isEmpty(now.getNow())) { return "21"; } return now.getNow().getTemp(); @@ -849,16 +1368,17 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { /** * 获取七天天气 + * * @param weekWeather * @param code * @return */ private List week(Map weekWeather, String code) { - if(MapUtils.isEmpty(weekWeather)){ + if (MapUtils.isEmpty(weekWeather)) { return null; } HeWeatherWeatherDailyResponse week = weekWeather.get(code); - if(ObjectUtil.isEmpty(week)){ + if (ObjectUtil.isEmpty(week)) { return null; } return week.getDaily(); @@ -866,6 +1386,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { /** * 获取站点运行天数 + * * @param station * @return */ @@ -880,11 +1401,12 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { /** * 站点实时数据统计 + * * @param photovoltaic */ private void real_data(PhotovoltaicStationVo photovoltaic) { // 站点设备检查 - if(CollectionUtil.isEmpty(photovoltaic.getDevices())){ + if (CollectionUtil.isEmpty(photovoltaic.getDevices())) { return; } // 容量 @@ -905,16 +1427,17 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { /** * 光伏设备实时、指标数据 + * * @param devices * @param reals * @param targets * @return */ private List deviceRealTarget(List devices, List reals, List targets) { - if(CollectionUtil.isEmpty(devices)){ + if (CollectionUtil.isEmpty(devices)) { return new ArrayList<>(); } - return devices.stream().map(device->{ + return devices.stream().map(device -> { PhotovoltaicDeviceVo item = new PhotovoltaicDeviceVo(); item.setDeviceCode(device.getEmCode()); item.setDeviceName(device.getName()); @@ -922,37 +1445,38 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { // 装机容量 item.setCapacity(device.getInstalledCapacity()); // 实时数据 - List mateReals = reals.stream().filter(o->o.getDeviceCode().equals(device.getEmCode())).collect(Collectors.toList()); - if(CollectionUtil.isNotEmpty(mateReals)){ + List mateReals = reals.stream().filter(o -> o.getDeviceCode().equals(device.getEmCode())).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(mateReals)) { // 总发电量、实时功率、电压、电流、环比功率 item.setGenerate(mateReals.get(0).getGenerate()); item.setLoad(mateReals.get(0).getLoad()); item.setVoltage(mateReals.get(0).getVoltage()); item.setCurrent(mateReals.get(0).getCurrent()); // 环比功率 - if(Math.abs(mateReals.get(0).getLoad()) <= 0 || mateReals.get(0).getLastLoad() <= 0 ){ + if (Math.abs(mateReals.get(0).getLoad()) <= 0 || mateReals.get(0).getLastLoad() <= 0) { item.setLoadRatio(0.0); - }else{ + } else { item.setLoadRatio(BigDecimal.valueOf((mateReals.get(0).getLoad() - mateReals.get(0).getLastLoad()) / mateReals.get(0).getLastLoad() * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); } } // 指标数据 - List mateTargets = targets.stream().filter(o->o.getDeviceCode().equals(device.getEmCode())).collect(Collectors.toList()); - if(CollectionUtil.isNotEmpty(mateTargets)){ + List mateTargets = targets.stream().filter(o -> o.getDeviceCode().equals(device.getEmCode())).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(mateTargets)) { // 年发电量、月发电量、日发电量、co2减排、节约标准煤、收益、30天发电量、当日功率、环比日发电量 item.setGenerateYear(mateTargets.get(0).getGenerationYear()); item.setGenerateMon(mateTargets.get(0).getGenerationMon()); item.setGenerateDay(mateTargets.get(0).getGenerationDay()); item.setCo2(mateTargets.get(0).getCo2()); item.setTec(mateTargets.get(0).getTec()); + item.setDeforest(mateTargets.get(0).getDeforest()); item.setIncome(mateTargets.get(0).getIncome()); item.setActivePowerVoList(mateTargets.get(0).getActivePowerVoList()); item.setGenerationPowerVoList(mateTargets.get(0).getGenerationPowerVoList()); // 环比发电量 - if(Math.abs(mateTargets.get(0).getGenerationDay()) <= 0 || mateTargets.get(0).getGenerationYesterday() <= 0 ){ + if (Math.abs(mateTargets.get(0).getGenerationDay()) <= 0 || mateTargets.get(0).getGenerationYesterday() <= 0) { item.setGenerateDayRatio(0.0); - }else{ + } else { item.setGenerateDayRatio(BigDecimal.valueOf((mateTargets.get(0).getGenerationDay() - mateTargets.get(0).getGenerationYesterday()) / mateTargets.get(0).getGenerationYesterday() * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); } } @@ -962,14 +1486,15 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { /** * 设备排行榜 + * * @param devices * @return */ private List deviceCharts(List devices) { - if(CollectionUtil.isEmpty(devices)){ + if (CollectionUtil.isEmpty(devices)) { return new ArrayList<>(); } - return devices.stream().map(device->{ + return devices.stream().map(device -> { PhotovoltaicDeviceChartsVo chart = new PhotovoltaicDeviceChartsVo(); chart.setDeptId(device.getDeptId()); chart.setDeviceCode(device.getDeviceCode()); @@ -982,20 +1507,21 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { /** * 年发电量比较概括 + * * @return */ private List generateSurvey(Long station) { - Map> map = (Map>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA); - if(MapUtils.isEmpty(map)){ + Map> map = (Map>) redisTemplate.opsForValue().get(recent_year_power_data); + if (MapUtils.isEmpty(map)) { return new ArrayList<>(); } // 站点发电数据 - if(!map.containsKey(station)){ + if (!map.containsKey(station)) { return new ArrayList<>(); } // 转换成集合 List generates = new ArrayList<>(); - map.get(station).forEach((key,value) -> { + map.get(station).forEach((key, value) -> { PowerMonthVo generate = new PowerMonthVo(); LocalDate localDate = LocalDate.parse(DateUtil.format(new Date(), key), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); generate.setYear(localDate.getYear()); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/SideHustleServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/SideHustleServiceImpl.java index ceb6160..d68d83d 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/SideHustleServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/SideHustleServiceImpl.java @@ -1634,7 +1634,7 @@ public class SideHustleServiceImpl implements ISideHustleService { if(CollectionUtil.isEmpty(list)){ return 0; } - return (float) list.stream().filter(v->o.equals(v.getDate())).mapToDouble(GenerationPowerVo::getGenerationPower).sum(); + return (float) list.stream().filter(v->o.equals(v.getDate())).mapToDouble(GenerationPowerVo::getGenerate).sum(); } /** diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WebHomeServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WebHomeServiceImpl.java index de93401..e90839d 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WebHomeServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WebHomeServiceImpl.java @@ -322,7 +322,7 @@ public class WebHomeServiceImpl implements IWebHomeService { generationPowerVo.setDate(dayList.get(i)); // 某天发电量 float power = homePageService.getAnalyzeCodeAndSignages(device, dayList.get(i) + " 00:00:00", dayList.get(i + 1) + " 00:00:00",EquipmentConstants.CycleTypeEnum.DAY_CYCLE.getType(),HomePageConstant.HYDROPOWER_GENERATE_POWER); - generationPowerVo.setGenerationPower(power); + generationPowerVo.setGenerate(power); generationPowerVoList.add(generationPowerVo); } return generationPowerVoList; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java index 3be9342..5181197 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java @@ -16,11 +16,11 @@ import com.hnac.hzims.operational.config.service.StAlamRecordService; import com.hnac.hzims.operational.config.service.StFocusPropertiesService; import com.hnac.hzims.operational.config.vo.MessageParamVo; import com.hnac.hzims.operational.config.vo.StationRealVo; +import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.main.service.IMainSystemMonitoringService; import com.hnac.hzims.operational.main.service.IWeatherService; import com.hnac.hzims.operational.main.vo.JointRelayVo; import com.hnac.hzims.operational.main.vo.WaterLevelVo; -import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.station.entity.StationAttributeEntity; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.service.IRealMonitorService; @@ -31,6 +31,7 @@ import com.hnac.hzims.operational.station.vo.RealAttributeVo; import com.hnac.hzims.operational.station.vo.RealDeviceVo; import com.hnac.hzims.operational.station.vo.RealStationVo; import com.hnac.hzims.operational.station.vo.WeatherVo; +import com.hnac.hzinfo.sdk.v5.redis.RedisClient; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.MapUtils; @@ -88,6 +89,8 @@ public class RealMonitorServiceImpl implements IRealMonitorService { @NotNull private final AbnormalAlarmService abnormalAlarmService; + private final RedisClient redisClient; + @NotNull private final ISysClient sysClient; @@ -131,8 +134,6 @@ public class RealMonitorServiceImpl implements IRealMonitorService { private final static String loadwater_level_key = "hzims:operation:loadwater:level:key"; - private final static String redis_real_prefix_key = "iot:real:data:"; - @Override public void realTimeData(String param) { @@ -146,10 +147,14 @@ public class RealMonitorServiceImpl implements IRealMonitorService { return ""; } String jointRelay = points.get(HomePageConstant.JOINT_RELAY); - if(StringUtil.isBlank(jointRelay)){ - return ""; + if(!StringUtil.isEmpty(jointRelay)){ + return jointRelay; + } + String onOff = points.get(HomePageConstant.SWITCH_ON_OFF); + if(!StringUtil.isEmpty(onOff)){ + return onOff; } - return jointRelay; + return ""; }).collect(Collectors.toList()); // 获取站点缓存数据 List stationRealVos = (List) redisTemplate.opsForValue().get(moniter_realId_key); @@ -169,11 +174,11 @@ public class RealMonitorServiceImpl implements IRealMonitorService { list.forEach(stations -> { stations.forEach(stationReal -> { String[] realIdArr = stationReal.getRealId(); - List realIds = Stream.of(realIdArr).map(o-> redis_real_prefix_key + stationReal.getStation() + ":" + o).collect(Collectors.toList()); + List realIds = Stream.of(realIdArr).collect(Collectors.toList()); if(CollectionUtil.isEmpty(realIds)){ return; } - List objects = redisTemplate.opsForValue().multiGet(realIds); + List objects = redisClient.getBatchRealDataByRealId(stationReal.getStation(),realIds); if(CollectionUtil.isEmpty(objects)){ return; } @@ -182,11 +187,12 @@ public class RealMonitorServiceImpl implements IRealMonitorService { log.error(realIds.get(i) + "is null"); continue; } - Map attribute = (Map) objects.get(i); - attribute.put("realId",realIdArr[i]); + Map attribute = (Map) JSONObject.parse(objects.get(i)); + attribute.put("realId",attribute.get("k")); attribute.put("value",attribute.get("v")); attribute.put("time",attribute.get("t")); attribute.remove("v"); + attribute.remove("k"); attribute.remove("t"); this.getCheckMap(attribute,switchOnOff); valueMap.put(realIdArr[i],attribute.get("value")); @@ -217,15 +223,15 @@ public class RealMonitorServiceImpl implements IRealMonitorService { * @param value * @return */ - private Map getCheckMap(Map value,List switchOnOff){ + private void getCheckMap(Map value,List switchOnOff){ try{ - String time = value.get("time"); - if(StringUtil.isEmpty(time)){ - return value; - } // 不处理开机状态监测点 if(switchOnOff.contains(value.get("realId"))){ - return value; + return; + } + String time = value.get("time"); + if(StringUtil.isEmpty(time)){ + return; } SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DateUtil.PATTERN_DATETIME); Date date = simpleDateFormat.parse(time); @@ -234,9 +240,8 @@ public class RealMonitorServiceImpl implements IRealMonitorService { value.put("value","0"); } }catch (ParseException e){ - return value; + return; } - return value; } /** diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/controller/ProcessTypeController.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/controller/ProcessTypeController.java index ade2805..07f176a 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/controller/ProcessTypeController.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/controller/ProcessTypeController.java @@ -43,15 +43,13 @@ public class ProcessTypeController { private final TicketProperties ticketProperties; - private final ProcessTypeService processTypeService; - private final List ticketServiceList; - private final RedisTemplate redisTemplate; + private final RedisTemplate redisTemplate; private final IFlowClient flowClient; @@ -59,8 +57,6 @@ public class ProcessTypeController { private final QueueProduceService queueProduceService; - - @GetMapping("/add") public void add() { List workTickets = ticketProperties.getWorkTickets(); @@ -81,15 +77,13 @@ public class ProcessTypeController { //判断执行具体的实现类 WorkflowQueue workflowQueue = new WorkflowQueue(); workflowQueue.setProcessDefinitionKey(key); - ProcessService ticketService = - ticketServiceList.stream().filter(item -> item.isWorkflowProcess(workflowQueue)) - .findFirst().orElse(null); + ProcessService ticketService = ticketServiceList.stream().filter(item -> item.isWorkflowProcess(workflowQueue)).findFirst().orElse(null); ticketService.calculate(null); return "key"; } - @OperationAnnotation(title = "操作模块", operatorType = OperatorType.MOBILE, businessType = BusinessType.GENCODE,action ="获取redis数据") + @OperationAnnotation(title = "操作模块", operatorType = OperatorType.MOBILE, businessType = BusinessType.GENCODE, action = "获取redis数据") @GetMapping("/redis/{value}") public int opens(@PathVariable String value) { redisTemplate.convertAndSend("blade:queue:flow", JSON.toJSONString(value)); @@ -97,18 +91,16 @@ public class ProcessTypeController { } - @OperationAnnotation(title = "工作流审批类型", operatorType = OperatorType.MOBILE, businessType = BusinessType.GENCODE, - action ="查询") + @OperationAnnotation(title = "工作流审批类型", operatorType = OperatorType.MOBILE, businessType = BusinessType.GENCODE, action = "查询") @GetMapping("/list") public R list() { List list = processTypeService.list(); - System.out.println(1/0); + System.out.println(1 / 0); return R.data(list); } - @OperationAnnotation(title = "工作流审批类型", operatorType = OperatorType.MOBILE, businessType = BusinessType.GENCODE, - action ="审批流处理") + @OperationAnnotation(title = "工作流审批类型", operatorType = OperatorType.MOBILE, businessType = BusinessType.GENCODE, action = "审批流处理") @GetMapping("/build") public void addList() { ProcessWorkFlowResponse workTicketMessageResponse = new ProcessWorkFlowResponse(); @@ -117,7 +109,9 @@ public class ProcessTypeController { workTicketMessageResponse.setTaskName("1"); workTicketMessageResponse.setFormData("1"); String qqqq = JsonUtil.toJson(workTicketMessageResponse); - queueProduceService.sendMessage("blade:queue:flow",qqqq); + queueProduceService.sendMessage("blade:queue:flow", qqqq); } + + } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/mapper/WorkTicketInfoMapper.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/mapper/WorkTicketInfoMapper.java deleted file mode 100644 index 5185416..0000000 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/mapper/WorkTicketInfoMapper.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.hnac.hzims.ticket.twoTicket.mapper; - -import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity; -import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; -import org.springframework.stereotype.Repository; -import org.springframework.stereotype.Service; - -/** - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/4/8 11:29 - */ -@Repository -public interface WorkTicketInfoMapper extends UserDataScopeBaseMapper { - -} diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/WorkTicketInfoService.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/WorkTicketInfoService.java deleted file mode 100644 index bfd29d3..0000000 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/WorkTicketInfoService.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.hnac.hzims.ticket.twoTicket.service; - -import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity; -import org.springblade.core.mp.base.BaseService; - -/** - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/4/8 11:31 - */ -public interface WorkTicketInfoService extends BaseService { - -} diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java index 995459f..3ed5371 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java @@ -2,12 +2,15 @@ package com.hnac.hzims.ticket.twoTicket.service.impl; import com.hnac.hzims.ticket.response.ProcessWorkFlowResponse; import com.hnac.hzims.ticket.twoTicket.service.TicketProcessService; -import com.hnac.hzims.ticket.twoTicket.service.WorkTicketInfoService; +import com.hnac.hzims.ticket.workTicket.service.IWorkTicketInfoService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.flow.core.feign.IFlowClient; import org.springframework.stereotype.Service; +import java.util.HashMap; +import java.util.Map; + /** * 开票处理流程实现类 * @Author WL @@ -24,7 +27,7 @@ public class TicketProcessServiceImpl implements TicketProcessService { private final IFlowClient flowClient; - private final WorkTicketInfoService workTicketInfoService; + private final IWorkTicketInfoService workTicketInfoService; /** * 启动开票流程 @@ -33,6 +36,20 @@ public class TicketProcessServiceImpl implements TicketProcessService { */ @Override public void startUp(ProcessWorkFlowResponse response) { + //当前环节Id + String processDefinitionKey = response.getProcessDefinitionKey(); + //当前任务Id + String taskId = response.getTaskId(); + //表单数据 + String formData = response.getFormData(); + log.info("当前任务ID:{},当前流程定义ID:{},启动开票流程", taskId, processDefinitionKey); + System.out.println(formData); + + // Map variables = new HashMap<>(); + // variables.put("task_id", taskId); + // variables.put("signUserIds", formData); + + // flowClient.startProcessInstanceContainNameByKey(processDefinitionKey,"workTicket:task:"+1,) } } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/WorkTicketInfoServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/WorkTicketInfoServiceImpl.java deleted file mode 100644 index 276a347..0000000 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/WorkTicketInfoServiceImpl.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.hnac.hzims.ticket.twoTicket.service.impl; - -import com.hnac.hzims.ticket.twoTicket.mapper.WorkTicketInfoMapper; -import com.hnac.hzims.ticket.twoTicket.service.WorkTicketInfoService; -import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity; -import org.springblade.core.mp.base.BaseServiceImpl; -import org.springframework.stereotype.Service; - -/** - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/4/8 11:32 - */ -@Service -public class WorkTicketInfoServiceImpl extends BaseServiceImpl implements WorkTicketInfoService { -}