Browse Source

#运行月报告

zhongwei
yang_shj 10 months ago
parent
commit
bad4a2681a
  1. 6
      hzims-biz-common/src/main/java/com/hnac/hzims/common/utils/HiKUtil.java
  2. 23
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/vo/RideDeviceVo.java
  3. 23
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java
  4. 2
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/MainConstants.java
  5. 40
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/entity/RunMonthEntity.java
  6. 22
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/AttributeVo.java
  7. 25
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/CurveAttributeVo.java
  8. 30
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/CurveDataVo.java
  9. 20
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/CurveVo.java
  10. 35
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/RunAlarmVo.java
  11. 32
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/RunDataShowVo.java
  12. 34
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/RunDataVo.java
  13. 2
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/tabulate/controller/AlarmTabulateController.java
  14. 2
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/tabulate/service/AlarmTabulateService.java
  15. 17
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/tabulate/service/impl/AlarmTabulateServiceImpl.java
  16. 3
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/equipment/DeviceParamMapper.java
  17. 13
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/RunMonMapper.java
  18. 10
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/AlarmScheduledTask.java
  19. 7
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/MonitorScheduledTask.java
  20. 7
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java
  21. 17
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ReportScheduledTask.java
  22. 2
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/DeviceParamService.java
  23. 3
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/DeviceService.java
  24. 14
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/DeviceParamServiceImpl.java
  25. 62
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/DeviceServiceImpl.java
  26. 3
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/report/ReportService.java
  27. 11
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/report/RunMonService.java
  28. 490
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/report/impl/ReportServiceImpl.java
  29. 19
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/report/impl/RunMonServiceImpl.java
  30. 11
      hzims-service/hzims-scheduled/src/main/resources/mapper/equipment/DeviceParamMapper.xml
  31. 5
      hzims-service/hzims-scheduled/src/main/resources/mapper/operation/RunMonMapper.xml
  32. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessLibraryController.java
  33. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/IOperAccessLibraryService.java
  34. 8
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessLibraryServiceImpl.java
  35. 41
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/RunMonthController.java
  36. 3
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/mapper/MonthReportMapper.java
  37. 10
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/mapper/RunMonthMapper.java
  38. 14
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/RunMonthService.java
  39. 79
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java
  40. 6
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java
  41. BIN
      hzims-service/operational/src/main/resources/template/excel/access_import_template.xlsx

6
hzims-biz-common/src/main/java/com/hnac/hzims/common/utils/HiKUtil.java

@ -1,3 +1,4 @@
/*
package com.hnac.hzims.common.utils;
import com.alibaba.druid.support.json.JSONUtils;
@ -27,10 +28,12 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
*/
/**
* @Author: huangxing
* @Date: 2024/1/10 14:40
*/
*//*
public class HiKUtil {
public static String APP_KEY = "26486442";
@ -70,3 +73,4 @@ public class HiKUtil {
}
}
*/

23
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/vo/RideDeviceVo.java

@ -0,0 +1,23 @@
package com.hnac.hzims.equipment.vo;
import com.hnac.hzims.equipment.entity.EmInfoEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* @author ysj
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class RideDeviceVo extends EmInfoEntity {
@ApiModelProperty(value = "ct")
private Integer ct;
@ApiModelProperty(value = "pt")
private Integer pt;
@ApiModelProperty(value = "配电比")
private Integer ride;
}

23
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java

@ -331,4 +331,27 @@ public interface HomePageConstant {
* 功率
**/
Integer LOADING = 0;
/*=============================================运行月报曲线=============================================*/
String A_PHASE_IRON_CORE_TEMP = "ax_txwd";
String B_PHASE_IRON_CORE_TEMP = "bx_txwd";
String C_PHASE_IRON_CORE_TEMP = "cx_txwd";
String UPPER_GUIDE_BEARING_TEMP = "sd_zwwd_1";
String UPPER_GUIDE_BEARING_OIL_GROOVE_TEMP = "sd_zcycwd";
String THRUST_BEARING_TEMP = "tl_zwwd_1";
String LOWER_GUIDE_BEARING_TEMP = "xd_zwwd_1";
String LOWER_GUIDE_OIL_TANK_TEMP = "xd_ycwd";
String WATER_GUIDE_TILE_TEMP = "wd_zwwd_1";
String WATER_GUIDE_OIL_TANK_TEMP = "sd_ycwd";
}

2
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/MainConstants.java

@ -61,6 +61,8 @@ public interface MainConstants {
String AREA_MONTH_REPORT = "areaMonthReport";
String WIND_AREA_MONTH_REPORT = "windAreaMonthReport";
String ENERGY_AREA_MONTH_REPORT = "energyAreaMonthReport";
// 运行月报告
String RUM_MONTH_REPORT = "runMonthReport";
// 站点数据统计
String STATION_DATA_COUNT = "stationDataCount";

40
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/entity/RunMonthEntity.java

@ -0,0 +1,40 @@
package com.hnac.hzims.operational.report.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.BaseEntity;
/**
* @author ysj
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("hzims_run_month_report")
@ApiModel(value = "运行月报告表", description = "运行月报告实体类")
public class RunMonthEntity extends BaseEntity {
@ApiModelProperty("站点编码")
private String stationCode;
@ApiModelProperty("月份")
private String month;
@ApiModelProperty("运行数据")
private String runData;
@ApiModelProperty("告警数据")
private String alarmData;
@ApiModelProperty("曲线数据")
private String curveData;
@ApiModelProperty("分析数据")
private String analysisData;
@ApiModelProperty("运行建议")
private String runPropose;
}

22
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/AttributeVo.java

@ -0,0 +1,22 @@
package com.hnac.hzims.operational.report.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author ysj
*/
@Data
@ApiModel("曲线对象")
public class AttributeVo {
@ApiModelProperty("设备编码")
private String deviceCode;
@ApiModelProperty("属性")
private String signage;
@ApiModelProperty("属性名称")
private String signageName;
}

25
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/CurveAttributeVo.java

@ -0,0 +1,25 @@
package com.hnac.hzims.operational.report.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author ysj
*/
@Data
@ApiModel("曲线对象")
public class CurveAttributeVo {
@ApiModelProperty("属性标识")
private String attribute;
@ApiModelProperty("属性名称")
private String attributeName;
@ApiModelProperty("曲线")
private List<CurveVo> Curves;
}

30
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/CurveDataVo.java

@ -0,0 +1,30 @@
package com.hnac.hzims.operational.report.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author ysj
*/
@Data
@ApiModel("运行数据对象")
public class CurveDataVo {
@ApiModelProperty("设备编码")
private String deviceCode;
@ApiModelProperty("设备名称")
private String deviceName;
@ApiModelProperty("负荷曲线")
private List<CurveAttributeVo> loadCurve;
@ApiModelProperty("轴承温度曲线")
private List<CurveAttributeVo> bearingTempCurve;
@ApiModelProperty("定子温度曲线")
private List<CurveAttributeVo> statorTempCurve;
}

20
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/CurveVo.java

@ -0,0 +1,20 @@
package com.hnac.hzims.operational.report.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author ysj
*/
@Data
@ApiModel("曲线对象")
public class CurveVo {
@ApiModelProperty("时间:day")
private String time;
@ApiModelProperty("值")
private Double value;
}

35
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/RunAlarmVo.java

@ -0,0 +1,35 @@
package com.hnac.hzims.operational.report.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author ysj
*/
@Data
@ApiModel("运行告警对象")
public class RunAlarmVo {
@ApiModelProperty("设备名称")
private String deviceName;
@ApiModelProperty("告警时间")
private String alarmTime;
@ApiModelProperty("告警内容")
private String content;
@ApiModelProperty("告警类型 : 3-故障 21-一级告警 30-智能预警")
private String type;
@ApiModelProperty("告警次数")
private Integer count;
@ApiModelProperty("初步原因分析")
private String reason;
@ApiModelProperty("处置")
private String dispose;
}

32
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/RunDataShowVo.java

@ -0,0 +1,32 @@
package com.hnac.hzims.operational.report.vo;
import com.hnac.hzims.operational.report.entity.RunMonthEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author ysj
*/
@Data
@ApiModel("运行数据对象")
public class RunDataShowVo extends RunMonthEntity {
@ApiModelProperty("月实际发电量")
private Double monSumGenerate;
@ApiModelProperty("月实际计划发电量")
private Double monSumPlan;
@ApiModelProperty("月计划完成率")
private Double monRate;
@ApiModelProperty("年实际发电量")
private Double yearSumGenerate;
@ApiModelProperty("月实际计划发电量")
private Double yearSumPlan;
@ApiModelProperty("年计划完成率")
private Double yearRate;
}

34
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/RunDataVo.java

@ -0,0 +1,34 @@
package com.hnac.hzims.operational.report.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author ysj
*/
@Data
@ApiModel("运行数据对象")
public class RunDataVo {
@ApiModelProperty("设备编码")
private String deviceCode;
@ApiModelProperty("设备名称")
private String deviceName;
@ApiModelProperty("运行时长")
private Double runHours;
@ApiModelProperty("发电量")
private Double generate;
@ApiModelProperty("计划发电量")
private Double plan;
@ApiModelProperty("年发电量")
private Double generateYear;
@ApiModelProperty("年计划发电量")
private Double planYear;
}

2
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/tabulate/controller/AlarmTabulateController.java

@ -39,7 +39,7 @@ public class AlarmTabulateController extends BladeController {
@GetMapping("/level")
@ApiOperationSupport(order = 2)
@ApiOperation(value = "等级告警(设备实例)", notes = "等级告警(设备实例)")
public R<IPage<StbAnalysisVO>> level(TabulateLevelVo param, Query query) {
public R<IPage<Object>> level(TabulateLevelVo param, Query query) {
return R.data(tabulateService.level(Condition.getPage(query), param));
}
}

2
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/tabulate/service/AlarmTabulateService.java

@ -14,5 +14,5 @@ public interface AlarmTabulateService {
IPage<StbAnalysisVO> early(IPage<StbAnalysisVO> page, TabulateEarlyVo param);
IPage<StbAnalysisVO> level(IPage<Object> page, TabulateLevelVo param);
IPage<Object> level(IPage<Object> page, TabulateLevelVo param);
}

17
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/tabulate/service/impl/AlarmTabulateServiceImpl.java

@ -7,12 +7,12 @@ import com.hnac.hzims.alarm.tabulate.vo.TabulateLevelVo;
import com.hnac.hzinfo.sdk.core.response.HzPage;
import com.hnac.hzinfo.sdk.core.response.Result;
import com.hnac.hzinfo.sdk.v5.device.DeviceDataClient;
import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient;
import com.hnac.hzinfo.sdk.v5.soe.SoeDataClient;
import com.hnac.hzinfo.sdk.v5.soe.dto.StbAnalysisDTO;
import com.hnac.hzinfo.sdk.v5.soe.vo.StbAnalysisVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.StringUtil;
@ -20,6 +20,8 @@ import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @author ysj
@ -69,8 +71,15 @@ public class AlarmTabulateServiceImpl implements AlarmTabulateService {
* @return
*/
@Override
public IPage<StbAnalysisVO> level(IPage<Object> page, TabulateLevelVo param) {
deviceDataClient.getDeviceSoeData(param.getProjectId(),param.getDimension(),param.getId(),param.getSoeType(),param.getStartTime(),param.getEndTime());
return null;
public IPage<Object> level(IPage<Object> page, TabulateLevelVo param) {
Result<Map<String, Object>> result = deviceDataClient.getDeviceSoeData(param.getProjectId(),param.getDimension(),param.getId(),param.getSoeType(),param.getStartTime(),param.getEndTime(),
true,(int) page.getCurrent(),(int)page.getSize());
if(!result.isSuccess() || MapUtils.isEmpty(result.getData())){
return page;
}
Map<String,Object> data = result.getData();
page.setTotal((Long) data.get("total"));
page.setRecords((List<Object>) data.get("data"));
return page;
}
}

3
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/equipment/DeviceParamMapper.java

@ -1,6 +1,7 @@
package com.hnac.hzims.scheduled.mapper.equipment;
import com.hnac.hzims.equipment.entity.EmParamEntity;
import org.apache.ibatis.annotations.Param;
import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper;
import java.util.List;
@ -13,4 +14,6 @@ import java.util.List;
public interface DeviceParamMapper extends UserDataScopeBaseMapper<EmParamEntity> {
List<EmParamEntity> params();
List<EmParamEntity> rides(@Param("deviceIds") List<Long> deviceIds);
}

13
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/RunMonMapper.java

@ -0,0 +1,13 @@
package com.hnac.hzims.scheduled.mapper.operation;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzims.operational.report.entity.RunMonthEntity;
/**
* @author ysj
* @date 2023/04/10 11:22:14
* @version 4.0.0
*/
public interface RunMonMapper extends BaseMapper<RunMonthEntity> {
}

10
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/AlarmScheduledTask.java

@ -2,6 +2,7 @@ package com.hnac.hzims.scheduled.scheduled;
import com.hnac.hzims.scheduled.service.alarm.AlarmQueryService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
@ -11,6 +12,8 @@ import org.springframework.stereotype.Component;
import java.util.Date;
import static com.hnac.hzims.operational.main.constant.MainConstants.START_STOP_ALARM;
/**
* 告警定时任务
@ -27,10 +30,9 @@ public class AlarmScheduledTask {
* 开停机告警
* @return ReturnT<String>
*/
//@XxlJob(START_STOP_ALARM)
@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> startStopAlarm() {
String param = "";
@XxlJob(START_STOP_ALARM)
//@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> startStopAlarm(String param) {
if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM");
}

7
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/MonitorScheduledTask.java

@ -42,10 +42,9 @@ public class MonitorScheduledTask {
* 实时数据刷新
* @return ReturnT<String>
*/
//@XxlJob(REAL_TIME_DATA)
@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> loadRealData() {
String param = "";
@XxlJob(REAL_TIME_DATA)
//@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> loadRealData( String param) {
if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM");
}

7
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java

@ -46,10 +46,9 @@ public class RealTargetScheduledTask {
/**
* 水电站-机组实时加载
*/
//@XxlJob(LOAD_HYDROPOWER_UNIT_REAL)
@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> loadHydropowerReal() {
String param = "";
@XxlJob(LOAD_HYDROPOWER_UNIT_REAL)
//@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> loadHydropowerReal(String param) {
if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM");
}

17
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ReportScheduledTask.java

@ -9,6 +9,7 @@ import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.Date;
@ -45,6 +46,7 @@ public class ReportScheduledTask {
service.loadMonthReport(param,1);
return new ReturnT<>("SUCCESS");
}
/**
* 首页-生产月报表
* @return ReturnT<String>
@ -57,6 +59,7 @@ public class ReportScheduledTask {
service.loadMonthReportByType(param,1, HomePageConstant.WIND_POWER,wind_recent_year_cache,wind_report_month_cache_final);
return new ReturnT<>("SUCCESS");
}
/**
* 首页-生产月报表
* @return ReturnT<String>
@ -70,5 +73,19 @@ public class ReportScheduledTask {
return new ReturnT<>("SUCCESS");
}
/**
* 站点运行月报
* @return ReturnT<String>
*/
//@XxlJob(RUM_MONTH_REPORT)
@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> runMonthReport() {
String param = "";
if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME);
}
service.runMonthReport(param);
return new ReturnT<>("SUCCESS");
}
}

2
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/DeviceParamService.java

@ -11,4 +11,6 @@ import java.util.List;
public interface DeviceParamService extends BaseService<EmParamEntity> {
List<EmParamEntity> params();
List<EmParamEntity> rides(List<Long> deviceIds);
}

3
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/DeviceService.java

@ -2,6 +2,7 @@ package com.hnac.hzims.scheduled.service.equipment;
import com.hnac.hzims.equipment.entity.EmInfoEntity;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.equipment.vo.RideDeviceVo;
import org.springblade.core.mp.base.BaseService;
import java.util.List;
@ -12,4 +13,6 @@ import java.util.List;
public interface DeviceService extends BaseService<EmInfoEntity> {
List<EminfoAndEmParamVo> device();
List<RideDeviceVo> rideDevices(List<Long> collect);
}

14
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/DeviceParamServiceImpl.java

@ -21,8 +21,22 @@ import java.util.List;
public class DeviceParamServiceImpl extends BaseServiceImpl<DeviceParamMapper, EmParamEntity> implements DeviceParamService {
/**
* 查询设备参数
* @return
*/
@Override
public List<EmParamEntity> params() {
return this.baseMapper.params();
}
/**
* 查询配电比
* @param deviceIds
* @return
*/
@Override
public List<EmParamEntity> rides(List<Long> deviceIds) {
return this.baseMapper.rides(deviceIds);
}
}

62
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/DeviceServiceImpl.java

@ -1,16 +1,24 @@
package com.hnac.hzims.scheduled.service.equipment.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.equipment.entity.EmInfoEntity;
import com.hnac.hzims.equipment.entity.EmParamEntity;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.equipment.vo.RideDeviceVo;
import com.hnac.hzims.scheduled.mapper.equipment.DeviceMapper;
import com.hnac.hzims.scheduled.service.equipment.DeviceParamService;
import com.hnac.hzims.scheduled.service.equipment.DeviceService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author ysj
@ -20,8 +28,62 @@ import java.util.List;
@Slf4j
@DS("equipment")
public class DeviceServiceImpl extends BaseServiceImpl<DeviceMapper, EmInfoEntity> implements DeviceService {
private final DeviceParamService deviceParamService;
/**
* 查询设备信息
* @return
*/
@Override
public List<EminfoAndEmParamVo> device() {
return this.baseMapper.device();
}
/**
* 设备信息(包含配电比)
* @param refDetps
* @return
*/
@Override
public List<RideDeviceVo> rideDevices(List<Long> refDetps) {
// 查询设备
List<EmInfoEntity> devices = this.list(Wrappers.<EmInfoEntity>lambdaQuery()
.in(EmInfoEntity::getDepartment,refDetps)
.eq(EmInfoEntity::getHomePageDisplay,"1")
);
if(CollectionUtil.isEmpty(devices)){
return new ArrayList<>();
}
List<EmParamEntity> paramList = deviceParamService.rides(devices.stream().map(EmInfoEntity::getId).collect(Collectors.toList()));
return devices.stream().map(device->{
RideDeviceVo rideDevice = new RideDeviceVo();
BeanUtil.copyProperties(device,rideDevice);
// 寻找设备配置参数
List<EmParamEntity> itemParamList = paramList.stream().filter(o->device.getId().equals(o.getInfoId())).collect(Collectors.toList());
if(CollectionUtil.isNotEmpty(itemParamList)) {
// 遍历设备配置参数
for (EmParamEntity paramEntity : itemParamList) {
String param_name = paramEntity.getParamName();
switch (param_name) {
case "ct":
rideDevice.setCt(Integer.parseInt(paramEntity.getParamValue()));
break;
case "pt":
rideDevice.setPt(Integer.parseInt(paramEntity.getParamValue()));
break;
default:
break;
}
}
// 设置ct * pt
if (null != rideDevice.getCt() && null != rideDevice.getPt()) {
rideDevice.setRide(rideDevice.getCt() * rideDevice.getPt());
}
}else{
rideDevice.setRide(1);
}
return rideDevice;
}).collect(Collectors.toList());
}
}

3
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/report/ReportService.java

@ -6,5 +6,8 @@ package com.hnac.hzims.scheduled.service.operation.report;
public interface ReportService {
void loadMonthReport(String param, int i);
void loadMonthReportByType(String param, int year,Integer type,String key,String saveKey);
void runMonthReport(String param);
}

11
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/report/RunMonService.java

@ -0,0 +1,11 @@
package com.hnac.hzims.scheduled.service.operation.report;
import com.hnac.hzims.operational.report.entity.RunMonthEntity;
import org.springblade.core.mp.base.BaseService;
/**
* @author ysj
*/
public interface RunMonService extends BaseService<RunMonthEntity> {
}

490
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/report/impl/ReportServiceImpl.java

@ -1,29 +1,53 @@
package com.hnac.hzims.scheduled.service.operation.report.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.hnac.hzims.alarm.config.constants.AlarmConstants;
import com.hnac.hzims.alarm.config.constants.AlarmHandleConstant;
import com.hnac.hzims.common.logs.utils.StringUtils;
import com.hnac.hzims.equipment.entity.EmInfoEntity;
import com.hnac.hzims.equipment.entity.PlanGenerationEntity;
import com.hnac.hzims.equipment.vo.RideDeviceVo;
import com.hnac.hzims.message.dto.MailPushDto;
import com.hnac.hzims.message.fegin.IPushMsgClient;
import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.main.vo.AreaMonthReportVo;
import com.hnac.hzims.operational.main.vo.MaintainVo;
import com.hnac.hzims.operational.main.vo.OverhaulVo;
import com.hnac.hzims.operational.report.vo.DutyDefectVO;
import com.hnac.hzims.operational.report.entity.RunMonthEntity;
import com.hnac.hzims.operational.report.vo.*;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.safeproduct.dto.SafeEquipmentTrialDTO;
import com.hnac.hzims.scheduled.service.equipment.DeviceService;
import com.hnac.hzims.scheduled.service.equipment.PlanService;
import com.hnac.hzims.scheduled.service.inspect.TaskService;
import com.hnac.hzims.scheduled.service.operation.business.AccessService;
import com.hnac.hzims.scheduled.service.operation.business.MaintenanceService;
import com.hnac.hzims.scheduled.service.operation.business.PhenomenonService;
import com.hnac.hzims.scheduled.service.operation.plate.DataService;
import com.hnac.hzims.scheduled.service.operation.report.ReportService;
import com.hnac.hzims.scheduled.service.operation.report.RunMonService;
import com.hnac.hzims.scheduled.service.operation.station.StationService;
import com.hnac.hzims.scheduled.service.safeproduct.MonthService;
import com.hnac.hzims.scheduled.service.safeproduct.TrialService;
import com.hnac.hzims.scheduled.service.ticket.TicketService;
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.analyse.vo.AnalyzeCodeBySignagesVO;
import com.hnac.hzinfo.datasearch.history.IHistoryDataSearchClient;
import com.hnac.hzinfo.datasearch.history.OriginalDataQuery;
import com.hnac.hzinfo.datasearch.soe.ISoeClient;
import com.hnac.hzinfo.datasearch.soe.domian.SoeData;
import com.hnac.hzinfo.datasearch.soe.domian.SoeQueryConditionByStation;
import com.hnac.hzinfo.inspect.task.vo.DutyInspectTaskVO;
import com.hnac.hzinfo.sdk.analyse.po.MultiAnalyzeCodePO;
import com.hnac.hzinfo.sdk.core.response.HzPage;
import com.hnac.hzinfo.sdk.core.response.Result;
import com.hnac.hzinfo.sdk.v5.soe.SoeDataClient;
import com.hnac.hzinfo.sdk.v5.soe.dto.StbAnalysisDTO;
import com.hnac.hzinfo.sdk.v5.soe.vo.StbAnalysisVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
@ -58,19 +82,44 @@ import java.util.stream.Collectors;
public class ReportServiceImpl implements ReportService {
private final PlanService planService;
private final TaskService taskService;
private final DataService dataService;
private final TrialService trialService;
private final MonthService monthService;
private final RunMonService runMonService;
private final AccessService accessService;
private final TicketService ticketService;
private final DeviceService deviceService;
private final StationService stationService;
private final MonthService monthService;
private final PhenomenonService phenomenonService;
private final MaintenanceService maintenanceService;
private final RedisTemplate redisTemplate;
private final ISysClient sysClient;
private final IUserClient userClient;
private final ISoeClient soeClient;
private final SoeDataClient soeDataClient;
private final IPushMsgClient pushMsgClient;
private final IHistoryDataSearchClient historyDataSearchClient;
private final RedisTemplate redisTemplate;
private final static String recent_year_cache_final = "hzims:operation:key:power:data";
public final static String wind_recent_year_cache = "hzims:operation:wind:power:data";
@ -568,4 +617,439 @@ public class ReportServiceImpl implements ReportService {
pushDto.setCreateDept(dept.getId());
pushMsgClient.sendMail(pushDto);
}
/**
* 运行月报告
* @param param
*/
@Override
public void runMonthReport(String param) {
// 查询接入站点
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery()
.eq(StationEntity::getDataOrigin,HomePageConstant.DATA_ORIGIN)
.eq(StationEntity::getType,HomePageConstant.HYDROPOWER)
);
if(CollectionUtil.isEmpty(stations)){
return;
}
// 计划发电量
List<PlanGenerationEntity> plans = planService.planGeneration(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()), null ,DateUtil.format(new Date(),"yyyy"));
// 查询站点设备
List<RideDeviceVo> devices = deviceService.rideDevices(stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()));
List<RunMonthEntity> runs = new ArrayList<>();
stations.forEach(station->{
RunMonthEntity run = new RunMonthEntity();
run.setStationCode(station.getCode());
Calendar calendar = Calendar.getInstance();
//calendar.setTime(new Date());
calendar.setTime(DateUtil.parse("2024-01-01 00:00:00",DateUtil.PATTERN_DATETIME));
calendar.add(Calendar.DAY_OF_MONTH,-1);
run.setMonth(DateUtil.format(calendar.getTime(),"yyyy-MM"));
List<RideDeviceVo> stationDevices = devices.stream().filter(device->device.getDepartment().equals(station.getRefDept())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(stationDevices)){
return;
}
// 运行数据
run.setRunData(this.runData(station.getCode(),stationDevices,plans));
// 告警数据
run.setAlarmData(this.alarmData(station.getCode()));
// 月度运行曲线
run.setCurveData(this.curveData(stationDevices));
// TODO 运行数据分析
// TODO 运行建议及其他
runs.add(run);
});
runMonService.saveBatch(runs);
}
/**
* 运行数据
* @param devices
* @return
*/
private String runData(String stationCode,List<RideDeviceVo> devices,List<PlanGenerationEntity> plans) {
List<RunDataVo> runs = new ArrayList<>();
devices.forEach(device->{
RunDataVo run = new RunDataVo();
run.setDeviceCode(device.getNumber());
run.setDeviceName(device.getName());
// 运行时长
run.setRunHours(this.runHours(device));
// 月发电量
run.setGenerate(this.generate(0,device.getNumber(),device.getRide()));
// 年发电量
run.setGenerateYear(this.generate(1,device.getNumber(),device.getRide()));
// 计划发电量
run.setPlan(this.planGenerate(0,stationCode,plans));
// 年计划发电量
run.setPlanYear(this.planGenerate(1,stationCode,plans));
runs.add(run);
});
return JSONObject.toJSONString(runs);
}
/**
* 实际发电量
* @param type
* @param deviceCode
* @param ride
* @return
*/
private Double generate(int type,String deviceCode,int ride) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(DateUtil.parse("2024-01-01 00:00:00",DateUtil.PATTERN_DATETIME));
//calendar.setTime(new Date());
String end = null,start = null;
int cycleType = 5;
switch (type){
case 0 :
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));
end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1);
start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
break;
case 1 :
cycleType = 6;
end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
calendar.add(Calendar.MONTH,-calendar.get(Calendar.MONTH));
calendar.add(Calendar.DAY_OF_MONTH,-calendar.get(Calendar.DAY_OF_MONTH));
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);
break;
}
return Double.valueOf(dataService.periodTargetFloat(start,end,5,cycleType,deviceCode,ride,HomePageConstant.HYDROPOWER_GENERATE_POWER));
}
/**
* 计划发电量
* @param type
* @param stationCode
* @param plans
* @return
*/
private Double planGenerate(int type, String stationCode,List<PlanGenerationEntity> plans) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(DateUtil.parse("2024-01-01 00:00:00",DateUtil.PATTERN_DATETIME));
//calendar.setTime(new Date());
if(type == 0){
calendar.add(Calendar.DAY_OF_MONTH,-1);
calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY) + 1);
calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE));
calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND));
String time = DateUtil.format(calendar.getTime(),"yyyy-MM");
return plans.stream().filter(plan -> plan.getStationId().equals(stationCode) && plan.getDateTime().contains(time))
.mapToDouble(PlanGenerationEntity::getPlanGeneration).sum();
}
String time = DateUtil.format(calendar.getTime(),"yyyy");
return plans.stream().filter(plan -> plan.getStationId().equals(stationCode) && plan.getDateTime().contains(time))
.mapToDouble(PlanGenerationEntity::getPlanGeneration).sum();
}
/**
* 获取运行数据
* @param device
* @return
*/
private Double runHours(EmInfoEntity device) {
MultiAnalyzeCodePO analyze = new MultiAnalyzeCodePO();
analyze.setDeviceCode(device.getNumber());
analyze.setSignages(Collections.singletonList(HomePageConstant.ACTIVE_POWER));
List<AnalyzeCodeBySignagesVO> signages = dataService.analyzeCodeBySignages(Collections.singletonList(analyze));
if(CollectionUtil.isEmpty(signages)){
return 0.0;
}
// 监测点
String realId = signages.get(0).getRealId();
if(StringUtils.isEmpty(realId)){
return 0.0;
}
// 确定查询时间范围: 年、月
Date startDate,endDate;
Calendar calendar = Calendar.getInstance();
calendar.setTime(DateUtil.parse("2024-01-01 00:00:00",DateUtil.PATTERN_DATETIME));
//calendar.setTime(new Date());
endDate = calendar.getTime();
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH));
calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1);
startDate = calendar.getTime();
return this.getRunConvertData(realId,startDate,endDate);
}
/**
* 获取时间范围内运行时长
* @param realId
* @param startDate
* @param endDate
* @return
*/
private Double getRunConvertData(String realId, Date startDate, Date endDate) {
OriginalDataQuery originalDataQuery = new OriginalDataQuery();
originalDataQuery.setRealId(realId);
originalDataQuery.setBeginTime(startDate);
originalDataQuery.setEndTime(endDate);
originalDataQuery.setLimit(100000);
originalDataQuery.setPage(1);
// 查询时间范围开关机监测点历史数据
Result<HzPage<PointData>> result = historyDataSearchClient.getOriginalDataByRealIds(originalDataQuery);
if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData())){
return 0.0;
}
// 开机运行时长
long time = this.getRunTime(result.getData().getRecords(),startDate,endDate);
return BigDecimal.valueOf(time / (1000 * 60 * 60.00)).setScale(2, RoundingMode.HALF_UP).doubleValue();
}
/**
* 获取运行时长
* @param result
* @return
*/
private long getRunTime(List<PointData> result,Date startDate,Date endDate) {
if(result.size() == 1){
// 一直开机
if(Double.parseDouble(result.get(0).getValue()) > 0){
return endDate.getTime() - startDate.getTime();
}
// 一直关机
return 0;
}
long time=0;
// 遍历累计开机时长
for(int i = 0; i< result.size() ; i++){
// 记录为开机状态 就计算到下次关机的时间差
if(Double.parseDouble(result.get(i).getValue()) <= 0){
continue;
}
Date endTime,startTime = DateUtil.parse(result.get(i).getTime(), DateUtil.PATTERN_DATETIME);
// 遍历至最后一条数据,累计至当前时间
if(i == result.size() - 1){
endTime = endDate;
}else {
endTime = DateUtil.parse(result.get(i+1).getTime(), DateUtil.PATTERN_DATETIME);
}
time += endTime.getTime() - startTime.getTime();
}
return time;
}
/**
* 告警数据
* @param code
* @return
*/
private String alarmData(String code) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(DateUtil.parse("2024-01-01 00:00:00",DateUtil.PATTERN_DATETIME));
calendar.add(Calendar.DAY_OF_MONTH,-1);
String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
calendar.add(Calendar.MONTH,-1);
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));
String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
// HZ3000:故障告警
List<RunAlarmVo> alarms = this.hz3000Alarm(code,start,end);
// FIXME 设备实例:一级告警
// FDP智能预警
// alarms.addAll(this.intelligentEarly(code,start,end));
return JSONObject.toJSONString(alarms);
}
/**
* 查询hz3000告警
* @param code
*/
private List<RunAlarmVo> hz3000Alarm(String code,String start,String end) {
SoeQueryConditionByStation query = new SoeQueryConditionByStation();
query.setStationIds(Collections.singletonList(code));
query.setTypes(Collections.singletonList(AlarmHandleConstant.FAULT));
query.setBeginTime(LocalDateTime.parse(start,DateUtil.DATETIME_FORMATTER));
query.setEndTime(LocalDateTime.parse(end,DateUtil.DATETIME_FORMATTER));
query.setNeedPage(false);
Result<HzPage<SoeData>> result = soeClient.getByStationsAndTime(query);
if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData()) || CollectionUtil.isEmpty(result.getData().getRecords())){
return new ArrayList<>();
}
return result.getData().getRecords().stream().collect(Collectors.groupingBy(SoeData::getSoeExplain)).entrySet().stream().map(entry->{
RunAlarmVo alarm = new RunAlarmVo();
alarm.setAlarmTime(DateUtil.format(entry.getValue().stream().sorted(Comparator.comparing(SoeData::getTs)).collect(Collectors.toList()).get(0).getTs(),DateUtil.PATTERN_DATETIME));
alarm.setDeviceName(entry.getValue().get(0).getDeviceName());
alarm.setContent(entry.getKey());
alarm.setType(String.valueOf(AlarmConstants.FAULT));
alarm.setCount(Math.max(entry.getValue().stream().filter(o->StringUtil.isNotBlank(o.getTraceCount())).mapToInt(soe->Integer.parseInt(soe.getTraceCount())).sum(), 1));
return alarm;
}).collect(Collectors.toList());
}
/**
* 智能预警
* @param code
* @param start
* @param end
* @return
*/
private List<RunAlarmVo> intelligentEarly(String code, String start, String end) {
StbAnalysisDTO param = new StbAnalysisDTO();
param.setStartTime(LocalDateTime.parse(start,DateUtil.DATETIME_FORMATTER));
param.setEndTime(LocalDateTime.parse(end, DateUtil.DATETIME_FORMATTER));
param.setStation(code);
param.setPage(0);
param.setPageSize(100000);
Result<HzPage<StbAnalysisVO>> result = soeDataClient.pageStbAnalysis(param);
if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData()) || CollectionUtil.isEmpty(result.getData().getRecords())){
return new ArrayList<>();
}
return result.getData().getRecords().stream().collect(Collectors.groupingBy(StbAnalysisVO::getContent)).entrySet().stream().map(entry->{
RunAlarmVo alarm = new RunAlarmVo();
alarm.setAlarmTime(entry.getValue().stream().sorted(Comparator.comparing(StbAnalysisVO::getTs)).collect(Collectors.toList()).get(0).getTs());
alarm.setDeviceName(entry.getValue().get(0).getDevicename());
alarm.setContent(entry.getKey());
alarm.setType(String.valueOf(AlarmConstants.EARLY));
alarm.setCount(entry.getValue().size());
return alarm;
}).collect(Collectors.toList());
}
/**
* 运行曲线
* @param devices
* @return
*/
private String curveData(List<RideDeviceVo> devices) {
List<CurveDataVo> curveDatas = devices.stream().map(device->{
CurveDataVo curveData = new CurveDataVo();
curveData.setDeviceCode(device.getNumber());
curveData.setDeviceName(device.getName());
// 负荷曲线
curveData.setLoadCurve(this.curve(this.attribute(0),device.getNumber()));
// 轴承温度曲线
curveData.setBearingTempCurve(this.curve(this.attribute(1),device.getNumber()));
// 定子温度曲线
curveData.setStatorTempCurve(this.curve(this.attribute(2),device.getNumber()));
return curveData;
}).collect(Collectors.toList());
return JSONObject.toJSONString(curveDatas);
}
/**
* 获取曲线数据
* @param attributes
* @param deviceCode
* @return
*/
private List<CurveAttributeVo> curve(List<AttributeVo> attributes, String deviceCode) {
Calendar calendar = Calendar.getInstance();
//calendar.setTime(new Date());
calendar.setTime(DateUtil.parse("2024-01-01 00:00:00",DateUtil.PATTERN_DATETIME));
calendar.add(Calendar.DAY_OF_MONTH,-1);
String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
calendar.add(Calendar.MONTH,-1);
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));
String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
List<CurveAttributeVo> curveAttributes = new ArrayList<>();
attributes.forEach(attribute -> {
CurveAttributeVo signage = new CurveAttributeVo();
signage.setAttribute(attribute.getSignage());
signage.setAttributeName(attribute.getSignageName());
List<AnalyseDataTaosVO> records = dataService.periodTargetData(start,end,3,3,deviceCode,attribute.getSignage());
if(CollectionUtil.isEmpty(records)){
return;
}
signage.setCurves(records.stream().map(record -> {
CurveVo curve = new CurveVo();
Date date = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s");
if(date.getDate() > 9){
curve.setTime("0" + date.getDay());
}else{
curve.setTime(date.getDay() + "");
}
if(StringUtil.isEmpty(record.getVal())){
curve.setValue(0.0);
}else{
curve.setValue(Double.valueOf(record.getVal()));
}
return curve;
}).collect(Collectors.toList()));
curveAttributes.add(signage);
});
return curveAttributes;
}
/**
* 曲线属性获取
* @param attributeType
* @return
*/
private List<AttributeVo> attribute(int attributeType) {
List<AttributeVo> attributes = new ArrayList<>();
switch (attributeType){
case 0:
AttributeVo attribute = new AttributeVo();
attribute.setSignage(HomePageConstant.ACTIVE_POWER);
attribute.setSignageName("负荷");
attributes.add(attribute);
break;
case 1:
AttributeVo upper_temp = new AttributeVo();
upper_temp.setSignage(HomePageConstant.UPPER_GUIDE_BEARING_TEMP);
upper_temp.setSignageName("上导轴承瓦温1");
attributes.add(upper_temp);
AttributeVo oil_tem = new AttributeVo();
oil_tem.setSignage(HomePageConstant.UPPER_GUIDE_BEARING_OIL_GROOVE_TEMP);
oil_tem.setSignageName("上导轴承油槽温度");
attributes.add(oil_tem);
AttributeVo thrust_tem = new AttributeVo();
thrust_tem.setSignage(HomePageConstant.THRUST_BEARING_TEMP);
thrust_tem.setSignageName("推力轴瓦温度1");
attributes.add(thrust_tem);
AttributeVo lower_tem = new AttributeVo();
lower_tem.setSignage(HomePageConstant.LOWER_GUIDE_BEARING_TEMP);
lower_tem.setSignageName("下导轴承瓦温1");
attributes.add(lower_tem);
AttributeVo tank_tem = new AttributeVo();
tank_tem.setSignage(HomePageConstant.LOWER_GUIDE_OIL_TANK_TEMP);
tank_tem.setSignageName("下导油槽温度");
attributes.add(tank_tem);
AttributeVo tile_tem = new AttributeVo();
tile_tem.setSignage(HomePageConstant.WATER_GUIDE_TILE_TEMP);
tile_tem.setSignageName("水导瓦温");
attributes.add(tile_tem);
AttributeVo water_tem = new AttributeVo();
water_tem.setSignage(HomePageConstant.WATER_GUIDE_OIL_TANK_TEMP);
water_tem.setSignageName("水导油槽温度");
attributes.add(water_tem);
break;
case 2:
AttributeVo A_tem = new AttributeVo();
A_tem.setSignage(HomePageConstant.A_PHASE_IRON_CORE_TEMP);
A_tem.setSignageName("A相铁芯温度1");
attributes.add(A_tem);
AttributeVo B_tem = new AttributeVo();
B_tem.setSignage(HomePageConstant.A_PHASE_IRON_CORE_TEMP);
B_tem.setSignageName("B相铁芯温度1");
attributes.add(B_tem);
AttributeVo C_tem = new AttributeVo();
C_tem.setSignage(HomePageConstant.A_PHASE_IRON_CORE_TEMP);
C_tem.setSignageName("C相铁芯温度1");
attributes.add(C_tem);
break;
}
return attributes;
}
}

19
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/report/impl/RunMonServiceImpl.java

@ -0,0 +1,19 @@
package com.hnac.hzims.scheduled.service.operation.report.impl;
import com.hnac.hzims.operational.report.entity.RunMonthEntity;
import com.hnac.hzims.scheduled.mapper.operation.RunMonMapper;
import com.hnac.hzims.scheduled.service.operation.report.RunMonService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;
/**
* @author ysj
*/
@Service
@RequiredArgsConstructor
@Slf4j
public class RunMonServiceImpl extends BaseServiceImpl<RunMonMapper, RunMonthEntity> implements RunMonService {
}

11
hzims-service/hzims-scheduled/src/main/resources/mapper/equipment/DeviceParamMapper.xml

@ -4,7 +4,7 @@
<select id="params" resultType="com.hnac.hzims.equipment.entity.EmParamEntity">
SELECT *
FROM hzims_em_param
FROM HZIMS_EM_PARAM
WHERE `IS_DELETED` = 0
AND (
PARAM_NAME = 'ct'
@ -12,4 +12,13 @@
OR PARAM_NAME = 'installedCapacity'
)
</select>
<select id="rides" resultType="com.hnac.hzims.equipment.entity.EmParamEntity">
SELECT * FROM HZIMS_EM_PARAM
WHERE `IS_DELETED` = 0
AND (PARAM_NAME = 'ct' OR PARAM_NAME = 'pt')
AND INFO_ID IN
<foreach collection="deviceIds" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</select>
</mapper>

5
hzims-service/hzims-scheduled/src/main/resources/mapper/operation/RunMonMapper.xml

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.hnac.hzims.scheduled.mapper.operation.RunMonMapper">
</mapper>

4
hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessLibraryController.java

@ -102,7 +102,7 @@ public class OperAccessLibraryController extends BladeController {
@ApiOperation(value = "检修库导入")
@ApiOperationSupport(order = 7)
@PostMapping(value = "/import")
public void libraryImport(@RequestParam MultipartFile multipartFile) {
service.libraryImport(multipartFile);
public void libraryImport(@RequestParam MultipartFile file) {
service.libraryImport(file);
}
}

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/IOperAccessLibraryService.java

@ -30,5 +30,5 @@ public interface IOperAccessLibraryService extends BaseService<OperAccessLibrary
void downLoad();
void libraryImport(MultipartFile multipartFile);
void libraryImport(MultipartFile file);
}

8
hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessLibraryServiceImpl.java

@ -144,18 +144,18 @@ public class OperAccessLibraryServiceImpl extends BaseServiceImpl<OperAccessLibr
/**
* 检修库导入
* @param multipartFile
* @param file
*/
@Override
public void libraryImport(MultipartFile multipartFile){
public void libraryImport(MultipartFile file){
// 文件名检查
String fileName = multipartFile.getOriginalFilename();
String fileName = file.getOriginalFilename();
if(!fileName.endsWith(PdfUtils.XLS_SUFFIX) && !fileName.endsWith(PdfUtils.XLSX_SUFFIX)){
throw new ServiceException("导入文件类型错误!");
}
Workbook workbook = null ;
try{
workbook = new HSSFWorkbook(multipartFile.getInputStream());
workbook = new HSSFWorkbook(file.getInputStream());
}catch (IOException ioException){
throw new ServiceException("导入文件读取失败!");
}

41
hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/RunMonthController.java

@ -0,0 +1,41 @@
package com.hnac.hzims.operational.report.controller;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.operational.report.entity.RunMonthEntity;
import com.hnac.hzims.operational.report.service.RunMonthService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* @author ysj
*/
@RestController
@Api(value = "运行月报",tags = "生产月报")
@AllArgsConstructor
@RequestMapping("/run/month")
public class RunMonthController {
private final RunMonthService runMonthService;
@GetMapping("/data")
@ApiOperation(value = "查询站点月报数据",notes = "查询站点月报数据")
@ApiOperationSupport(order = 3)
public R<RunMonthEntity> data(@RequestParam("mon") String mon,
@RequestParam("stationCode") String stationCode){
return R.data(runMonthService.data(mon,stationCode));
}
@GetMapping("/export")
@ApiOperation(value = "导出站点运行月报",notes = "导出站点运行月报")
@ApiOperationSupport(order = 3)
public void export(@RequestParam("mon") String mon,
@RequestParam("stationCode") String stationCode){
runMonthService.export(mon,stationCode);
}
}

3
hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/mapper/MonthReportMapper.java

@ -3,5 +3,8 @@ package com.hnac.hzims.operational.report.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzims.operational.report.entity.OperMonthReportEntity;
/**
* @author ysj
*/
public interface MonthReportMapper extends BaseMapper<OperMonthReportEntity> {
}

10
hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/mapper/RunMonthMapper.java

@ -0,0 +1,10 @@
package com.hnac.hzims.operational.report.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzims.operational.report.entity.RunMonthEntity;
/**
* @author ysj
*/
public interface RunMonthMapper extends BaseMapper<RunMonthEntity> {
}

14
hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/RunMonthService.java

@ -0,0 +1,14 @@
package com.hnac.hzims.operational.report.service;
import com.hnac.hzims.operational.report.entity.RunMonthEntity;
import org.springblade.core.mp.base.BaseService;
/**
* @author ysj
*/
public interface RunMonthService extends BaseService<RunMonthEntity> {
RunMonthEntity data(String mon, String stationCode);
void export(String mon, String stationCode);
}

79
hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java

@ -0,0 +1,79 @@
package com.hnac.hzims.operational.report.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.operational.report.entity.RunMonthEntity;
import com.hnac.hzims.operational.report.mapper.RunMonthMapper;
import com.hnac.hzims.operational.report.service.RunMonthService;
import com.hnac.hzims.operational.report.vo.RunDataShowVo;
import com.hnac.hzims.operational.report.vo.RunDataVo;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;
/**
* @author ysj
*/
@Service
@AllArgsConstructor
@Slf4j
public class RunMonthServiceImpl extends BaseServiceImpl<RunMonthMapper, RunMonthEntity> implements RunMonthService {
/**
* 查询站点月报运行数据
* @param mon
* @param stationCode
* @return
*/
@Override
public RunMonthEntity data(String mon, String stationCode) {
RunMonthEntity entity = this.getOne(Wrappers.<RunMonthEntity>lambdaQuery()
.eq(RunMonthEntity::getStationCode,stationCode)
.eq(RunMonthEntity::getMonth,mon)
);
if(ObjectUtil.isEmpty(entity)){
throw new ServiceException("站点" + mon + "月份未生成运行月报,请联系管理员进行处理!");
}
RunDataShowVo data = new RunDataShowVo();
BeanUtil.copyProperties(entity,data);
List<RunDataVo> run = JSONObject.parseObject(entity.getRunData(),new TypeReference<List<RunDataVo>>(){});
if(CollectionUtil.isEmpty(run)){
return data;
}
double monSumGenerate = run.stream().mapToDouble(RunDataVo::getGenerate).sum();
double monSumPlan = run.stream().mapToDouble(RunDataVo::getPlan).sum();
data.setMonSumGenerate(monSumGenerate);
data.setMonSumPlan(monSumPlan);
if(Math.abs(monSumGenerate) > 0 && Math.abs(monSumPlan) > 0){
data.setMonRate(BigDecimal.valueOf(monSumGenerate / monSumPlan * 100L).setScale(2, RoundingMode.HALF_UP).doubleValue());
}
double yearSumGenerate = run.stream().mapToDouble(RunDataVo::getGenerateYear).sum();
double yearSumPlan = run.stream().mapToDouble(RunDataVo::getPlanYear).sum();
data.setYearSumGenerate(yearSumGenerate);
data.setYearSumPlan(yearSumPlan);
if(Math.abs(yearSumGenerate) > 0 && Math.abs(yearSumPlan) > 0){
data.setYearRate(BigDecimal.valueOf(yearSumGenerate / yearSumPlan * 100L).setScale(2, RoundingMode.HALF_UP).doubleValue());
}
return data;
}
/**
* 导出站点月报文件
* @param mon
* @param stationCode
*/
@Override
public void export(String mon, String stationCode) {
}
}

6
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java

@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.common.utils.HiKUtil;
//import com.hnac.hzims.common.utils.HiKUtil;
import com.hnac.hzims.operational.config.HikPathConfiguration;
import com.hnac.hzims.operational.station.StationConstants;
import com.hnac.hzims.operational.station.dto.StationVideoTypeDTO;
@ -213,7 +213,7 @@ public class StationVideoTypeServiceImpl extends BaseServiceImpl<StationVideoTyp
}};
Arrays.stream(pointCodes.split(",")).forEach(pointCode -> {
param.put("cameraIndexCode",pointCode);
try{
/*try{
String data = HiKUtil.send("/api/video/v2/cameras/previewURLs", param, finalHost, finalAppKey, finalAppSecret);
if(StringUtil.isNotBlank(data)) {
Map<String, String> url = new HashMap<String, String>() {{
@ -224,7 +224,7 @@ public class StationVideoTypeServiceImpl extends BaseServiceImpl<StationVideoTyp
}
catch (Exception e) {
e.printStackTrace();
}
}*/
});
return result;
}

BIN
hzims-service/operational/src/main/resources/template/excel/access_import_template.xlsx

Binary file not shown.
Loading…
Cancel
Save