Browse Source

Merge remote-tracking branch 'origin/prod-5.1.3' into prod-5.1.3

zhongwei
haungxing 2 months ago
parent
commit
26aa73c6a2
  1. 36
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/feign/IThreeElectricClient.java
  2. 21
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/feign/IThreeElectricClientBack.java
  3. 28
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/vo/StartStopGenerateVO.java
  4. 2
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/startStop/entity/StartStopDurationEntity.java
  5. 33
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/startStop/feign/IStartStopClient.java
  6. 15
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/startStop/feign/IStartStopClientBack.java
  7. 2
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java
  8. 30
      hzims-service/equipment/src/main/java/com/hnac/hzims/electric/feign/ThreeElectricClient.java
  9. 4
      hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/ThreeService.java
  10. 17
      hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/impl/ThreeServiceImpl.java
  11. 24
      hzims-service/equipment/src/main/java/com/hnac/hzims/startStop/feign/StartStopClient.java
  12. 13
      hzims-service/equipment/src/main/java/com/hnac/hzims/startStop/mapper/StartStopDurationMapper.java
  13. 5
      hzims-service/equipment/src/main/java/com/hnac/hzims/startStop/mapper/StartStopDurationMapper.xml
  14. 13
      hzims-service/equipment/src/main/java/com/hnac/hzims/startStop/service/IStartStopDurationService.java
  15. 44
      hzims-service/equipment/src/main/java/com/hnac/hzims/startStop/service/impl/StartStopDurationServiceImpl.java
  16. 13
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/impl/AlarmConfigDetailServiceImpl.java
  17. 1
      hzims-service/hzims-scheduled/pom.xml
  18. 11
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/ScheduledApplication.java
  19. 34
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/controller/ScheduledController.java
  20. 11
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/alarm/ConfigDetailMapper.java
  21. 11
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/alarm/ConfigMapper.java
  22. 5
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/alarm/HandleMapper.java
  23. 2
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/equipment/StartStopDurationMapper.java
  24. 19
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/AlarmScheduledTask.java
  25. 12
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/AlarmDefaulConfigService.java
  26. 2
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/AlarmService.java
  27. 16
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/ConfigDetailService.java
  28. 13
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/ConfigService.java
  29. 14
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/DefaulConfigService.java
  30. 4
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/HandleService.java
  31. 2
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/QueryService.java
  32. 209
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java
  33. 10
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/ConfigDetailServiceImpl.java
  34. 62
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/ConfigServiceImpl.java
  35. 48
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/DefaulConfigServiceImpl.java
  36. 24
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/HandleServiceImpl.java
  37. 14
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/QueryServiceImpl.java
  38. 5
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/StartStopDurationService.java
  39. 4
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/ThreeGenerateService.java
  40. 105
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/StartStopDurationServiceImpl.java
  41. 16
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/ThreeGenerateServiceImpl.java
  42. 2
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java
  43. 6
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java
  44. 102
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/report/impl/ReportServiceImpl.java
  45. 5
      hzims-service/hzims-scheduled/src/main/resources/mapper/alarm/ConfigDetailMapper.xml
  46. 5
      hzims-service/hzims-scheduled/src/main/resources/mapper/alarm/ConfigMapper.xml
  47. 28
      hzims-service/hzims-scheduled/src/main/resources/mapper/alarm/HandleMapper.xml
  48. 207
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java

36
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/feign/IThreeElectricClient.java

@ -0,0 +1,36 @@
package com.hnac.hzims.electric.feign;
import com.hnac.hzims.EquipmentConstants;
import com.hnac.hzims.electric.entity.ThreeEntity;
import com.hnac.hzims.equipment.entity.ThreeGenerationEntity;
import com.hnac.hzims.monitor.feign.IMonitorClientBack;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* @author ysj
*/
@FeignClient(
value = EquipmentConstants.APP_NAME,
fallback = IMonitorClientBack.class
)
public interface IThreeElectricClient {
String API_PREFIX = "/threeElectric";
String ELECTRICS = API_PREFIX + "/electrics";
/**
* 设备运行时长
* @param stationId
* @param startTime
* @param endTime
* @return
*/
@GetMapping(ELECTRICS)
List<ThreeEntity> electrics(@RequestParam(value = "stationId") String stationId,
@RequestParam(value = "year") String year);
}

21
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/feign/IThreeElectricClientBack.java

@ -0,0 +1,21 @@
package com.hnac.hzims.electric.feign;
import com.hnac.hzims.electric.entity.ThreeEntity;
import com.hnac.hzims.equipment.entity.ThreeGenerationEntity;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
/**
* @author ysj
*/
@Component
public class IThreeElectricClientBack implements IThreeElectricClient {
@Override
public List<ThreeEntity> electrics(String stationId, String year) {
return new ArrayList<>();
}
}

28
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/vo/StartStopGenerateVO.java

@ -0,0 +1,28 @@
package com.hnac.hzims.equipment.vo;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author ysj
*/
@Data
public class StartStopGenerateVO{
@ApiModelProperty(value = "站点编码集合")
@JsonSerialize(nullsUsing = NullSerializer.class)
private List<String> stations;
@ApiModelProperty(value = "开始时间")
@JsonSerialize(nullsUsing = NullSerializer.class)
private String start;
@ApiModelProperty(value = "结束时间")
@JsonSerialize(nullsUsing = NullSerializer.class)
private String end;
}

2
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/StartStopDurationEntity.java → hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/startStop/entity/StartStopDurationEntity.java

@ -1,4 +1,4 @@
package com.hnac.hzims.equipment.entity;
package com.hnac.hzims.startStop.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;

33
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/startStop/feign/IStartStopClient.java

@ -0,0 +1,33 @@
package com.hnac.hzims.startStop.feign;
import com.hnac.hzims.EquipmentConstants;
import com.hnac.hzims.monitor.feign.IMonitorClientBack;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
* @author ysj
*/
@FeignClient(
value = EquipmentConstants.APP_NAME,
fallback = IMonitorClientBack.class
)
public interface IStartStopClient {
String API_PREFIX = "/startStop";
String DEVICE_START_STOP_DURATION = API_PREFIX + "/deviceDuration";
/**
* 设备运行时长
* @param deviceCode
* @param startTime
* @param endTime
* @return
*/
@GetMapping(DEVICE_START_STOP_DURATION)
Double deviceDuration(@RequestParam(value = "deviceCode") String deviceCode,
@RequestParam(value = "startTime") String startTime,
@RequestParam(value = "endTime") String endTime);
}

15
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/startStop/feign/IStartStopClientBack.java

@ -0,0 +1,15 @@
package com.hnac.hzims.startStop.feign;
import org.springframework.stereotype.Component;
/**
* @author ysj
*/
@Component
public class IStartStopClientBack implements IStartStopClient {
@Override
public Double deviceDuration(String deviceCode, String startTime, String endTime) {
return 0.0;
}
}

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

@ -152,7 +152,7 @@ public interface HomePageConstant {
// 水利-泵组实时属性名称
String JOINT_RELAY = "joint_relay"; // 开机状态
String START_STOP_STATUS = "power_on"; // 开关机状态
String START_STOP_STATUS = "dlqhw"; // 断路器合位
String SWITCH_ON_OFF = "switch_on_off"; // 开机状态
String OFF = "1.0"; // 开机
String OFF_COMPLEX = "1"; // 开机

30
hzims-service/equipment/src/main/java/com/hnac/hzims/electric/feign/ThreeElectricClient.java

@ -0,0 +1,30 @@
package com.hnac.hzims.electric.feign;
import com.hnac.hzims.electric.entity.ThreeEntity;
import com.hnac.hzims.electric.service.ThreeService;
import com.hnac.hzims.equipment.entity.ThreeGenerationEntity;
import com.hnac.hzims.startStop.feign.IStartStopClient;
import com.hnac.hzims.startStop.service.IStartStopDurationService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author ysj
*/
@RestController
@AllArgsConstructor
public class ThreeElectricClient implements IThreeElectricClient {
private final ThreeService service;
@Override
@GetMapping(ELECTRICS)
public List<ThreeEntity> electrics(String stationId, String year) {
return service.electrics(stationId,year);
}
}

4
hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/ThreeService.java

@ -1,11 +1,15 @@
package com.hnac.hzims.electric.service;
import com.hnac.hzims.electric.entity.ThreeEntity;
import com.hnac.hzims.equipment.entity.ThreeGenerationEntity;
import org.springblade.core.mp.base.BaseService;
import java.util.List;
/**
* @author ysj
*/
public interface ThreeService extends BaseService<ThreeEntity> {
List<ThreeEntity> electrics(String stationId, String year);
}

17
hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/impl/ThreeServiceImpl.java

@ -1,13 +1,17 @@
package com.hnac.hzims.electric.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.electric.entity.ThreeEntity;
import com.hnac.hzims.electric.mapper.ThreeMapper;
import com.hnac.hzims.electric.service.ThreeService;
import com.hnac.hzims.equipment.entity.ThreeGenerationEntity;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author ysj
*/
@ -17,4 +21,17 @@ import org.springframework.stereotype.Service;
public class ThreeServiceImpl extends BaseServiceImpl<ThreeMapper, ThreeEntity> implements ThreeService {
/**
* 查询站点年发电量
* @param stationId
* @param year
* @return
*/
@Override
public List<ThreeEntity> electrics(String stationId, String year) {
return this.list(Wrappers.<ThreeEntity>lambdaQuery()
.eq(ThreeEntity::getStationId,stationId)
.like(ThreeEntity::getStrMonth,year)
);
}
}

24
hzims-service/equipment/src/main/java/com/hnac/hzims/startStop/feign/StartStopClient.java

@ -0,0 +1,24 @@
package com.hnac.hzims.startStop.feign;
import com.hnac.hzims.startStop.service.IStartStopDurationService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author ysj
*/
@RestController
@AllArgsConstructor
public class StartStopClient implements IStartStopClient {
private final IStartStopDurationService service;
@Override
@GetMapping(DEVICE_START_STOP_DURATION)
public Double deviceDuration(String deviceCode, String startTime, String endTime) {
return service.deviceDuration(deviceCode,startTime,endTime);
}
}

13
hzims-service/equipment/src/main/java/com/hnac/hzims/startStop/mapper/StartStopDurationMapper.java

@ -0,0 +1,13 @@
package com.hnac.hzims.startStop.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzims.startStop.entity.StartStopDurationEntity;
import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper;
/**
* @author ysj
*/
public interface StartStopDurationMapper extends BaseMapper<StartStopDurationEntity> {
}

5
hzims-service/equipment/src/main/java/com/hnac/hzims/startStop/mapper/StartStopDurationMapper.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.startStop.mapper.StartStopDurationMapper" >
</mapper>

13
hzims-service/equipment/src/main/java/com/hnac/hzims/startStop/service/IStartStopDurationService.java

@ -0,0 +1,13 @@
package com.hnac.hzims.startStop.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzims.startStop.entity.StartStopDurationEntity;
/**
* @author ysj
*/
public interface IStartStopDurationService extends IService<StartStopDurationEntity> {
Double deviceDuration(String deviceCode, String startTime, String endTime);
}

44
hzims-service/equipment/src/main/java/com/hnac/hzims/startStop/service/impl/StartStopDurationServiceImpl.java

@ -0,0 +1,44 @@
package com.hnac.hzims.startStop.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.startStop.entity.StartStopDurationEntity;
import com.hnac.hzims.startStop.mapper.StartStopDurationMapper;
import com.hnac.hzims.startStop.service.IStartStopDurationService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author ysj
*/
@Service
@AllArgsConstructor
@Slf4j
public class StartStopDurationServiceImpl extends ServiceImpl<StartStopDurationMapper, StartStopDurationEntity> implements IStartStopDurationService {
/**
* 查询设备开停机时长
* @param deviceCode
* @param startTime
* @param endTime
* @return
*/
@Override
public Double deviceDuration(String deviceCode, String startTime, String endTime) {
List<StartStopDurationEntity> durations = this.list(Wrappers.<StartStopDurationEntity>lambdaQuery()
.eq(StartStopDurationEntity::getDeviceCode,deviceCode)
.ge(StartStopDurationEntity::getStrDay,startTime)
.le(StartStopDurationEntity::getStrDay,endTime)
);
if(CollectionUtil.isEmpty(durations)){
return 0.0;
}
return durations.stream().mapToDouble(StartStopDurationEntity::getStartDuration).sum();
}
}

13
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/config/service/impl/AlarmConfigDetailServiceImpl.java

@ -91,19 +91,6 @@ public class AlarmConfigDetailServiceImpl extends ServiceImpl<AlarmConfigDetailM
return alarmHandleMarkVo;
}
return null;
// // HZ3000告警
// if(AlarmConstants.HZ3000_ALARM.equals(source)){
// return this.hz3000Marik(type);
// // 等级告警
// }else if(AlarmConstants.LEVEL_ALARM.equals(source)){
// return this.levelMark(type);
// // 条件告警
// }else if(AlarmConstants.CONDITION_ALARM.equals(source)){
// return this.conditionMark(type);
// // 智能预警
// }else if(AlarmConstants.EARLY_WARNING.equals(source)){
// return this.earlyMark(type);
// }
}
/**

1
hzims-service/hzims-scheduled/pom.xml

@ -47,7 +47,6 @@
<dependency>
<groupId>com.hnac.hzims</groupId>
<artifactId>alarm-api</artifactId>
<version>4.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.hnac.hzims</groupId>

11
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/ScheduledApplication.java

@ -1,16 +1,9 @@
package com.hnac.hzims.scheduled;
import org.mybatis.spring.annotation.MapperScan;
import org.springblade.core.cloud.feign.EnableBladeFeign;
import org.springblade.core.launch.BladeApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.cloud.client.SpringCloudApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
import javax.annotation.Resource;
/**
@ -21,7 +14,7 @@ import javax.annotation.Resource;
@EnableFeignClients(basePackages = {"org.springblade", "com.hnac"})
public class ScheduledApplication {
public static void main(String[] args) {
BladeApplication.run("hzims-scheduled", ScheduledApplication.class, args);
BladeApplication.run("hzims-scheduled-ysj", ScheduledApplication.class, args);
}
}
}

34
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/controller/ScheduledController.java

@ -0,0 +1,34 @@
package com.hnac.hzims.scheduled.controller;
import com.hnac.hzims.equipment.vo.StartStopGenerateVO;
import com.hnac.hzims.scheduled.service.equipment.StartStopDurationService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.*;
/**
* @author ysj
*/
@Slf4j
@RequestMapping("/scheduled")
@RestController
@RequiredArgsConstructor
public class ScheduledController {
private final StartStopDurationService service;
/**
* 开停机时长统计接口
* @param param
* @return
*/
@PostMapping("/startStopGenerate")
public R startStopGenerate(@RequestBody StartStopGenerateVO param) {
return R.status(service.startStopGenerate(param));
}
}

11
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/alarm/ConfigDetailMapper.java

@ -0,0 +1,11 @@
package com.hnac.hzims.scheduled.mapper.alarm;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzims.alarm.config.entity.AlarmConfigDetailEntity;
/**
* @author ysj
*/
public interface ConfigDetailMapper extends BaseMapper<AlarmConfigDetailEntity> {
}

11
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/alarm/ConfigMapper.java

@ -0,0 +1,11 @@
package com.hnac.hzims.scheduled.mapper.alarm;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzims.alarm.config.entity.AlarmConfigEntity;
/**
* @author ysj
*/
public interface ConfigMapper extends BaseMapper<AlarmConfigEntity> {
}

5
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/alarm/HandleMapper.java

@ -12,5 +12,10 @@ import java.util.List;
* @version 4.0.0
*/
public interface HandleMapper extends UserDataScopeBaseMapper<AlarmHandleEntity> {
List<String> handles(@Param("start") String start,@Param("end") String end);
List<String> sameDayContent(@Param("start") String start,@Param("end") String end,@Param("code") String code);
List<String> incompleteContent(@Param("end") String end,@Param("code") String code);
}

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

@ -1,7 +1,7 @@
package com.hnac.hzims.scheduled.mapper.equipment;
import com.hnac.hzims.equipment.entity.StartStopDurationEntity;
import com.hnac.hzims.startStop.entity.StartStopDurationEntity;
import org.apache.ibatis.annotations.Param;
import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper;

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

@ -11,7 +11,8 @@ import org.springframework.stereotype.Component;
import java.util.Date;
import static com.hnac.hzims.operational.main.constant.MainConstants.*;
import static com.hnac.hzims.operational.main.constant.MainConstants.CLEAR_HISTORY_ALARM;
import static com.hnac.hzims.operational.main.constant.MainConstants.INTERRUPT_ALARM;
/**
@ -41,28 +42,12 @@ public class AlarmScheduledTask {
}
/**
* 开停机告警
* @return ReturnT<String>
*/
@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");
}
alarmService.startStopAlarm(param);
return new ReturnT<>("SUCCESS");
}
/**
* 数据通讯中断
* @param param
* @return
*/
@XxlJob(INTERRUPT_ALARM)
//@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> interruption(String param) {
if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM");

12
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/AlarmDefaulConfigService.java

@ -1,12 +0,0 @@
package com.hnac.hzims.scheduled.service.alarm;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzims.alarm.config.entity.AlarmDefaultConfigEntity;
/**
* @author ysj
*/
public interface AlarmDefaulConfigService extends IService<AlarmDefaultConfigEntity> {
}

2
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/AlarmService.java

@ -5,8 +5,6 @@ package com.hnac.hzims.scheduled.service.alarm;
*/
public interface AlarmService {
void startStopAlarm(String param);
void clearHistoryAlarm(String param);
void interruption(String param);

16
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/ConfigDetailService.java

@ -0,0 +1,16 @@
package com.hnac.hzims.scheduled.service.alarm;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzims.alarm.config.entity.AlarmConfigDetailEntity;
import com.hnac.hzims.alarm.config.entity.AlarmConfigEntity;
import com.hnac.hzims.alarm.config.vo.AlarmConfigSourceVo;
import com.hnac.hzims.alarm.config.vo.AlarmHandleMarkVo;
import java.util.List;
/**
* @author ysj
*/
public interface ConfigDetailService extends IService<AlarmConfigDetailEntity> {
}

13
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/ConfigService.java

@ -0,0 +1,13 @@
package com.hnac.hzims.scheduled.service.alarm;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzims.alarm.config.entity.AlarmConfigEntity;
import com.hnac.hzims.alarm.config.vo.AlarmHandleMarkVo;
/**
* @author ysj
*/
public interface ConfigService extends IService<AlarmConfigEntity> {
AlarmHandleMarkVo mark(String code,Integer source,Integer type);
}

14
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/DefaulConfigService.java

@ -0,0 +1,14 @@
package com.hnac.hzims.scheduled.service.alarm;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzims.alarm.config.entity.AlarmDefaultConfigEntity;
import com.hnac.hzims.alarm.config.vo.AlarmHandleMarkVo;
/**
* @author ysj
*/
public interface DefaulConfigService extends IService<AlarmDefaultConfigEntity> {
AlarmHandleMarkVo defaultMark(Integer source, Integer type);
}

4
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/HandleService.java

@ -19,4 +19,8 @@ import java.util.List;
public interface HandleService extends BaseService<AlarmHandleEntity> {
List<String> handles();
List<String> sameDayContent(String code);
List<String> incompleteContent(String code);
}

2
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/AlarmQueryService.java → hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/QueryService.java

@ -9,7 +9,7 @@ import java.util.List;
/**
* @author ysj
*/
public interface AlarmQueryService extends IService<AlarmEntity> {
public interface QueryService extends IService<AlarmEntity> {
void clear(String param);

209
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java

@ -1,19 +1,16 @@
package com.hnac.hzims.scheduled.service.alarm.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.alarm.config.constants.AlarmConstants;
import com.hnac.hzims.alarm.config.entity.AlarmDefaultConfigEntity;
import com.hnac.hzims.alarm.config.entity.AlarmEntity;
import com.hnac.hzims.alarm.config.vo.SystemAlarmVo;
import com.hnac.hzims.alarm.config.vo.AlarmHandleMarkVo;
import com.hnac.hzims.business.interruption.constants.InterruptionConstants;
import com.hnac.hzims.business.interruption.entity.InterruptionEntity;
import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.main.vo.HydropowerUnitRealVo;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.scheduled.service.alarm.AlarmDefaulConfigService;
import com.hnac.hzims.scheduled.service.alarm.AlarmQueryService;
import com.hnac.hzims.scheduled.service.alarm.AlarmService;
import com.hnac.hzims.scheduled.service.alarm.*;
import com.hnac.hzims.scheduled.service.operation.station.StationService;
import com.hnac.hzinfo.datasearch.soe.ISoeClient;
import com.hnac.hzinfo.datasearch.soe.domian.SoeData;
@ -22,15 +19,16 @@ import com.hnac.hzinfo.sdk.core.response.HzPage;
import com.hnac.hzinfo.sdk.core.response.Result;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.jackson.JsonUtil;
import org.springblade.core.tool.utils.*;
import org.springblade.mqtt.producer.IMqttSender;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
@ -41,11 +39,13 @@ import java.util.stream.Collectors;
@Slf4j
public class AlarmServiceImpl implements AlarmService {
private final HandleService handleService;
private final StationService stationService;
private final AlarmQueryService alarmQueryService;
private final QueryService queryService;
private final AlarmDefaulConfigService defaulConfigService;
private final ConfigService alarmConfigService;
private final InterruptionAlarmServiceImpl interruptionAlarmService;
@ -53,84 +53,13 @@ public class AlarmServiceImpl implements AlarmService {
private final RedisTemplate redisTemplate;
private final StringRedisTemplate stringRedisTemplate;
private final IMqttSender mqttSender;
private final static String start_stop_cache_final = "hzims:operation:start:stop:key";
private final static String load_hydropower_unit_real_key = "hzims:operation:loadhydropowerunit:real:key";
/**
* 开停机告警
* @param param
*/
@Override
public void startStopAlarm(String param) {
// 获取站点开关机状态
Map<String,Integer> startStopMap = (HashMap<String, Integer>) redisTemplate.opsForValue().get(start_stop_cache_final);
// 查询接入水电站点
List<StationEntity> stations = stationService.list(new LambdaQueryWrapper<StationEntity>()
.eq(StationEntity::getDataOrigin,0)
.eq(StationEntity::getType, HomePageConstant.HYDROPOWER)
);
if(CollectionUtil.isEmpty(stations)){
return;
}
// 查询开关机默认告警配置
AlarmDefaultConfigEntity start = defaulConfigService.getOne(Wrappers.<AlarmDefaultConfigEntity>lambdaQuery()
.eq(AlarmDefaultConfigEntity::getSource,6)
.eq(AlarmDefaultConfigEntity::getAlarmChiledType,60)
);
AlarmDefaultConfigEntity stop = defaulConfigService.getOne(Wrappers.<AlarmDefaultConfigEntity>lambdaQuery()
.eq(AlarmDefaultConfigEntity::getSource,6)
.eq(AlarmDefaultConfigEntity::getAlarmChiledType,61)
);
// 获取站点设备实时数据
List<HydropowerUnitRealVo> reals = (List<HydropowerUnitRealVo>) redisTemplate.opsForValue().get(load_hydropower_unit_real_key);
if(CollectionUtil.isEmpty(reals)){
return;
}
Map<String,Integer> refresh = new HashMap<>();
// 实时设备遍历
reals.forEach(real->{
// 过滤站点
List<StationEntity> list = stations.stream().filter(item -> item.getRefDept().equals(real.getDeptId())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(list)){
return;
}
// 确定站点
StationEntity station = list.get(0);
// 数据初始化记录
if(CollectionUtil.isEmpty(startStopMap)){
if(Math.abs(real.getActivePower()) > 0){
refresh.put(real.getDeviceCode(),1);
}else{
refresh.put(real.getDeviceCode(),0);
}
return;
}
// 比对开机状态
if(real.getActivePower() > 0){
if(startStopMap.containsKey(real.getDeviceCode()) && startStopMap.get(real.getDeviceCode()) == 0){
refresh.put(real.getDeviceCode(),1);
// 记录开机告警
this.saveStartStopAlarm(station,real,start,1);
}else{
refresh.put(real.getDeviceCode(),1);
}
}else{
if(startStopMap.containsKey(real.getDeviceCode()) && startStopMap.get(real.getDeviceCode()) == 1){
refresh.put(real.getDeviceCode(),0);
// 记录关机告警
this.saveStartStopAlarm(station,real,stop,0);
}else{
refresh.put(real.getDeviceCode(),0);
}
}
});
redisTemplate.opsForValue().set(start_stop_cache_final,refresh);
}
/**
* 清理历史告警数据
@ -138,7 +67,7 @@ public class AlarmServiceImpl implements AlarmService {
*/
@Override
public void clearHistoryAlarm(String param) {
this.alarmQueryService.clear(param);
this.queryService.clear(param);
}
/**
@ -147,7 +76,7 @@ public class AlarmServiceImpl implements AlarmService {
* @param real
* @param state
*/
private void saveStartStopAlarm(StationEntity station, HydropowerUnitRealVo real,AlarmDefaultConfigEntity defaultConfig, int state) {
private void saveStartStopAlarm(StationEntity station, HydropowerUnitRealVo real, AlarmDefaultConfigEntity defaultConfig, int state) {
AlarmEntity alarm = new AlarmEntity();
alarm.setStationId(station.getCode());
alarm.setStationName(station.getName());
@ -187,7 +116,7 @@ public class AlarmServiceImpl implements AlarmService {
alarm.setCreateUser(station.getCreateUser());
alarm.setUpdateUser(station.getUpdateUser());
alarm.setUpdateTime(station.getUpdateTime());
this.alarmQueryService.save(alarm);
this.queryService.save(alarm);
}
@ -226,7 +155,7 @@ public class AlarmServiceImpl implements AlarmService {
// 查询当天数据中断告警记录
List<InterruptionEntity> saves = this.saveInterruptions(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()));
List<InterruptionEntity> entities = soes.stream().filter(
o -> (CollectionUtil.isEmpty(saves) || !saves.stream().map(itr -> itr.getStationId() + itr.getRealId() + itr.getAlarmTime()).collect(Collectors.toList()).contains(o.getStation() + o.getRealId() + o.getTs()))
o -> (CollectionUtil.isEmpty(saves) || !saves.stream().map(InterruptionEntity::getAlarmId).collect(Collectors.toList()).contains(o.getId()))
&& StringUtil.isNotBlank(o.getStation())).map(soe->{
InterruptionEntity entity = new InterruptionEntity();
Optional<StationEntity> optional = stations.stream().filter(o->o.getCode().equals(soe.getStation())).findFirst();
@ -256,30 +185,96 @@ public class AlarmServiceImpl implements AlarmService {
}
// 批量保存中断告警数据
this.interruptionAlarmService.saveBatch(entities);
// 发送HZ3000中通讯告警
this.sendInterruptionMsg(entities);
// 保存通讯中断告警
entities.forEach(this::alarmSave);
}
/**
* 发送HZ3000中通讯告警
* @param entities
*/
private void sendInterruptionMsg(List<InterruptionEntity> entities) {
entities.forEach(entity->{
SystemAlarmVo alarm = new SystemAlarmVo();
if(ObjectUtil.isEmpty(entity.getId())){
alarm.setId(DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME_MINI));
}else{
alarm.setId(String.valueOf(entity.getId()));
public Boolean alarmSave(InterruptionEntity entity) {
AlarmEntity alarm = new AlarmEntity();
alarm.setAlarmId(entity.getAlarmId().toString());
ZoneId zoneId = ZoneId.systemDefault();
LocalDateTime localDateTime = LocalDateTime.ofInstant(entity.getAlarmTime().toInstant(), zoneId);
alarm.setAlarmTime(localDateTime);
alarm.setAlarmContext(entity.getSoeExplain());
alarm.setAlarmType(Integer.valueOf(entity.getType()));
alarm.setAlarmStatus(entity.getStatus());
alarm.setStationId(entity.getStationId());
alarm.setRealId(entity.getRealId());
alarm.setAlarmSource(AlarmConstants.HZ3000_ALARM);
// 步骤1.查询告警数据对应站点
StationEntity station = stationService.getOne(Wrappers.<StationEntity>lambdaQuery().eq(StationEntity::getCode,alarm.getStationId()));
if(ObjectUtil.isEmpty(station)){
return false;
}
// 步骤2.查询当天处理的告警
List<String> handlers = handleService.sameDayContent(station.getCode());
// 步骤3.查询延后未完成的告警
List<String> delays = handleService.incompleteContent(station.getCode());
// 步骤4.近5分钟内告警
Set<String> keys = stringRedisTemplate.keys("hzims:queue:filter:alarm" + "*");
// 步骤5.遍历保存告警数据
// 告警已处理
if(CollectionUtil.isNotEmpty(handlers) && handlers.contains(alarm.getAlarmContext())){
return false;
}
// 告警已延后处理
if(CollectionUtil.isNotEmpty(delays) && delays.contains(alarm.getAlarmContext())){
return false;
}
// 告警站点名称截取
if(StringUtil.isNotBlank(alarm.getAlarmContext()) && !AlarmConstants.CONDITION_ALARM.equals(alarm.getAlarmSource()) && !AlarmConstants.INTERRUPT.equals(alarm.getAlarmType())
&& !AlarmConstants.ABNORMAL.equals(alarm.getAlarmType())){
String[] countext = alarm.getAlarmContext().split("\\.");
alarm.setAlarmContext(countext[countext.length - 1]);
}
// 近5分钟内告警重复
if(CollectionUtil.isNotEmpty(keys)){
for (String key : keys) {
String value = stringRedisTemplate.opsForValue().get(key);
if (value.equals(station.getName()+alarm.getAlarmContext())){
return false;
}
}
alarm.setTs(entity.getAlarmTime().getTime());
alarm.setType(Integer.parseInt(entity.getType()));
alarm.setStation(entity.getStationId());
alarm.setRealId(entity.getRealId());
alarm.setContext(entity.getSoeExplain());
alarm.setState(entity.getStatus());
mqttSender.sendToMqtt(InterruptionConstants.HZ3000_TOPIC_PREFIX + entity.getStationId(), JsonUtil.toJson(alarm));
});
}
// 步骤3.站点参数设置
alarm.setCreateDept(station.getCreateDept());
alarm.setStationName(station.getName());
alarm.setTenantId(station.getTenantId());
if(StringUtil.isNotBlank(alarm.getAlarmValue()) && alarm.getAlarmValue().length() > 2048){
alarm.setAlarmValue(alarm.getAlarmValue().substring(0,2048));
}
alarm.setStatus(0);
// 步骤4.根据站点查询配置标识
AlarmHandleMarkVo mark = alarmConfigService.mark(alarm.getStationId(),alarm.getAlarmSource(),alarm.getAlarmType());
if(ObjectUtil.isEmpty(mark)){
log.error("alarm_obtain_mark_is_null : {}",alarm.getAlarmId());
return false;
}
// 步骤5.告警处理标识赋值
alarm.setIsRightTabulation(mark.getIsRightTabulation());
alarm.setIsBroadcast(mark.getIsBroadcast());
alarm.setIsMask(mark.getIsMask());
alarm.setIsPlatformMessage(mark.getIsPlatformMessage());
alarm.setIsShowAlert(mark.getIsShowAlert());
alarm.setIsSmallBell(mark.getIsSmallBell());
alarm.setIsShortMessage(mark.getIsShortMessage());
alarm.setIsWxMessage(mark.getIsWxMessage());
// 步骤6.保存当日告警数据
boolean isSave = queryService.save(alarm);
if(!isSave){
log.error("alarm_save_fail : {}",alarm.getAlarmId());
return false;
}
String key="hzims:queue:filter:alarm"+alarm.getAlarmId();
stringRedisTemplate.opsForValue().set(key,station.getName()+alarm.getAlarmContext());
stringRedisTemplate.expire(key,5, TimeUnit.MINUTES);
// 步骤7.发生数据至redis告警队列
stringRedisTemplate.opsForList().rightPush("hzims:queue:alarm", JSON.toJSONString(alarm));
return true;
}
/**

10
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmDefaulConfigServiceImpl.java → hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/ConfigDetailServiceImpl.java

@ -1,12 +1,12 @@
package com.hnac.hzims.scheduled.service.alarm.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.hnac.hzims.alarm.config.entity.AlarmDefaultConfigEntity;
import com.hnac.hzims.scheduled.mapper.alarm.AlarmDefaulConfigMapper;
import com.hnac.hzims.scheduled.service.alarm.AlarmDefaulConfigService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.alarm.config.entity.AlarmConfigDetailEntity;
import com.hnac.hzims.scheduled.mapper.alarm.ConfigDetailMapper;
import com.hnac.hzims.scheduled.service.alarm.ConfigDetailService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
@ -16,6 +16,6 @@ import org.springframework.stereotype.Service;
@Service
@Slf4j
@DS("alarm")
public class AlarmDefaulConfigServiceImpl extends ServiceImpl<AlarmDefaulConfigMapper, AlarmDefaultConfigEntity> implements AlarmDefaulConfigService {
public class ConfigDetailServiceImpl extends ServiceImpl<ConfigDetailMapper, AlarmConfigDetailEntity> implements ConfigDetailService {
}

62
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/ConfigServiceImpl.java

@ -0,0 +1,62 @@
package com.hnac.hzims.scheduled.service.alarm.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.alarm.config.entity.AlarmConfigDetailEntity;
import com.hnac.hzims.alarm.config.entity.AlarmConfigEntity;
import com.hnac.hzims.alarm.config.vo.AlarmHandleMarkVo;
import com.hnac.hzims.scheduled.mapper.alarm.ConfigMapper;
import com.hnac.hzims.scheduled.service.alarm.ConfigDetailService;
import com.hnac.hzims.scheduled.service.alarm.ConfigService;
import com.hnac.hzims.scheduled.service.alarm.DefaulConfigService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springframework.stereotype.Service;
/**
* @author ysj
*/
@AllArgsConstructor
@Service
@Slf4j
@DS("alarm")
public class ConfigServiceImpl extends ServiceImpl<ConfigMapper, AlarmConfigEntity> implements ConfigService {
private final ConfigDetailService configDetailService;
private final DefaulConfigService detailService;
/**
* 查询站点告警标识
* @param code
* @return
*/
@Override
public AlarmHandleMarkVo mark(String code, Integer source,Integer type) {
AlarmConfigEntity config = this.getOne(Wrappers.<AlarmConfigEntity>lambdaQuery()
.eq(AlarmConfigEntity::getStationId,code));
if(ObjectUtil.isEmpty(config)){
return detailService.defaultMark(source,type);
}
AlarmConfigDetailEntity detail = configDetailService.getOne(Wrappers.<AlarmConfigDetailEntity>lambdaQuery()
.eq(AlarmConfigDetailEntity::getStrategyId,config.getId())
.eq(AlarmConfigDetailEntity::getAlarmType,source)
.eq(AlarmConfigDetailEntity::getAlarmChiledType,type)
);
if(ObjectUtil.isEmpty(detail)){
return detailService.defaultMark(source,type);
}
AlarmHandleMarkVo mark = new AlarmHandleMarkVo();
mark.setIsRightTabulation(detail.getIsRightTabulation());
mark.setIsBroadcast(detail.getIsBroadcast());
mark.setIsMask(detail.getIsMask());
mark.setIsPlatformMessage(detail.getIsPlatformMessage());
mark.setIsShowAlert(detail.getIsShowAlert());
mark.setIsSmallBell(detail.getIsSmallBell());
mark.setIsShortMessage(detail.getIsShortMessage());
mark.setIsWxMessage(detail.getIsWxMessage());
return mark;
}
}

48
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/DefaulConfigServiceImpl.java

@ -0,0 +1,48 @@
package com.hnac.hzims.scheduled.service.alarm.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.alarm.config.entity.AlarmDefaultConfigEntity;
import com.hnac.hzims.alarm.config.vo.AlarmHandleMarkVo;
import com.hnac.hzims.scheduled.mapper.alarm.AlarmDefaulConfigMapper;
import com.hnac.hzims.scheduled.service.alarm.DefaulConfigService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
/**
* @author ysj
*/
@AllArgsConstructor
@Service
@Slf4j
@DS("alarm")
public class DefaulConfigServiceImpl extends ServiceImpl<AlarmDefaulConfigMapper, AlarmDefaultConfigEntity> implements DefaulConfigService {
private final AlarmDefaulConfigMapper alarmDefaulConfigMapper;
@Override
public AlarmHandleMarkVo defaultMark(Integer source,Integer type) {
// 告警来源 : 0- HZ3000告警 1 -等级告警 2 -条件告警 3-FDP智能预警 4-视频预警 5-开关机告警
// 子类告警
// HZ3000告警 : 2-告警 3-故障 5-遥测越限 13-通讯中断 14-数据异常
// 等级告警 : 21-一级告警 22-二级告警 23-三级告警
// 智能预警 : 30-智能预警
// 条件告警 : 40-条件告警
// 开关机告警 : 50-开机告警 51-关机告警
AlarmDefaultConfigEntity alarmDefaultConfigEntity = alarmDefaulConfigMapper.selectOne(new LambdaQueryWrapper<AlarmDefaultConfigEntity>() {{
eq(AlarmDefaultConfigEntity::getSource, source);
eq(AlarmDefaultConfigEntity::getAlarmChiledType, type);
last("limit 1;");
}});
if (ObjectUtils.isNotEmpty(alarmDefaultConfigEntity)){
AlarmHandleMarkVo alarmHandleMarkVo = new AlarmHandleMarkVo();
BeanUtils.copyProperties(alarmDefaultConfigEntity,alarmHandleMarkVo);
return alarmHandleMarkVo;
}
return new AlarmHandleMarkVo();
}
}

24
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/HandleServiceImpl.java

@ -10,6 +10,7 @@ import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.utils.DateUtil;
import org.springframework.stereotype.Service;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
@ -36,4 +37,27 @@ public class HandleServiceImpl extends BaseServiceImpl<HandleMapper, AlarmHandle
String end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME);
return this.baseMapper.handles(start, end);
}
/**
* 查询近一小时处理告警的内容
* @return
*/
@Override
public List<String> sameDayContent(String code) {
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.HOUR_OF_DAY,-1);
String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
String end = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME);
return this.baseMapper.sameDayContent(start,end,code);
}
/**
* 查询未到延后期限告警的内容
* @return
*/
@Override
public List<String> incompleteContent(String code) {
String end = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME);
return this.baseMapper.incompleteContent(end,code);
}
}

14
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmQueryServiceImpl.java → hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/QueryServiceImpl.java

@ -1,26 +1,16 @@
package com.hnac.hzims.scheduled.service.alarm.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.alarm.config.constants.AlarmConstants;
import com.hnac.hzims.alarm.config.entity.AlarmEntity;
import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.main.vo.HydropowerUnitRealVo;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.scheduled.mapper.alarm.AlarmQueryMapper;
import com.hnac.hzims.scheduled.service.alarm.AlarmQueryService;
import com.hnac.hzims.scheduled.service.alarm.QueryService;
import com.hnac.hzims.scheduled.service.alarm.HandleService;
import com.hnac.hzims.scheduled.service.operation.station.StationService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.util.*;
@ -33,7 +23,7 @@ import java.util.stream.Collectors;
@Service
@Slf4j
@DS("alarm")
public class AlarmQueryServiceImpl extends ServiceImpl<AlarmQueryMapper, AlarmEntity> implements AlarmQueryService {
public class QueryServiceImpl extends ServiceImpl<AlarmQueryMapper, AlarmEntity> implements QueryService {
private HandleService handleService;

5
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/StartStopDurationService.java

@ -1,7 +1,8 @@
package com.hnac.hzims.scheduled.service.equipment;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzims.equipment.entity.StartStopDurationEntity;
import com.hnac.hzims.startStop.entity.StartStopDurationEntity;
import com.hnac.hzims.equipment.vo.StartStopGenerateVO;
/**
* @author ysj
@ -11,4 +12,6 @@ public interface StartStopDurationService extends IService<StartStopDurationEnti
void thisDayStartStopRecord(String param);
void startStopTimeRecord(String param);
boolean startStopGenerate(StartStopGenerateVO param);
}

4
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/ThreeGenerateService.java

@ -4,10 +4,14 @@ import com.hnac.hzims.equipment.entity.ThreeGenerationEntity;
import org.apache.ibatis.annotations.Param;
import org.springblade.core.mp.base.BaseService;
import java.util.List;
/**
* @author ysj
*/
public interface ThreeGenerateService extends BaseService<ThreeGenerationEntity> {
void deletemMonthGenerate(@Param("month") String month);
List<ThreeGenerationEntity> threes(List<String> codes, String year);
}

105
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/StartStopDurationServiceImpl.java

@ -7,8 +7,9 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.hnac.hzims.common.logs.utils.StringUtils;
import com.hnac.hzims.equipment.entity.StartStopDurationEntity;
import com.hnac.hzims.startStop.entity.StartStopDurationEntity;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.equipment.vo.StartStopGenerateVO;
import com.hnac.hzims.equipment.vo.StartStopTimeVO;
import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.station.entity.StationEntity;
@ -21,17 +22,14 @@ import com.hnac.hzinfo.datasearch.PointData;
import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData;
import com.hnac.hzinfo.datasearch.history.IHistoryDataSearchClient;
import com.hnac.hzinfo.datasearch.history.OriginalDataQuery;
import com.hnac.hzinfo.datasearch.real.po.RealDataSearchPO;
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.source.dto.HisDeviceSourceDataDTO;
import com.hnac.hzinfo.sdk.v5.device.source.dto.HisFacSourceDataDTO;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
import org.springblade.core.tool.api.R;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.ObjectUtil;
@ -66,6 +64,8 @@ public class StartStopDurationServiceImpl extends ServiceImpl<StartStopDurationM
private final DeviceDataClient deviceDataClient;
private final IHistoryDataSearchClient historyDataSearchClient;
private final RedisTemplate redisTemplate;
@Value("${hzims.equipment.emInfo.emInfoList}")
@ -276,4 +276,99 @@ public class StartStopDurationServiceImpl extends ServiceImpl<StartStopDurationM
return time;
}
/**
* 开停机时长生成
* @param param
* @return
*/
@Override
public boolean startStopGenerate(StartStopGenerateVO param) {
if(CollectionUtil.isEmpty(param.getStations()) || StringUtils.isEmpty(param.getStart()) || StringUtils.isEmpty(param.getEnd())){
throw new ServiceException("缺少必要参数!");
}
Date start = DateUtil.parse(param.getStart(),DateUtil.PATTERN_DATETIME);
Date end = DateUtil.parse(param.getEnd(),DateUtil.PATTERN_DATETIME);
// 查询站点
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery()
.eq(StationEntity::getType, HomePageConstant.HYDROPOWER)
.in(StationEntity::getCode,param.getStations())
);
if(CollectionUtil.isEmpty(stations)){
throw new ServiceException("无可统计开关机时长站点!");
}
// 查询设备信息
List<EminfoAndEmParamVo> eminfos = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_cofig_final).toString(), new TypeReference<List<EminfoAndEmParamVo>>() {});
if(CollectionUtil.isEmpty(eminfos)){
throw new ServiceException("未查询到设备信息!");
}
// 查询时间
Calendar calendar = Calendar.getInstance();
calendar.setTime(start);
while (start.compareTo(end) <= 0){
calendar.add(Calendar.HOUR_OF_DAY,+1);
Date complete = calendar.getTime();
// 删除日期开关机记录
this.baseMapper.deleteThisDayStartStopRecord(DateUtil.format(start,DateUtil.PATTERN_DATETIME));
// 遍历站点记录当日开停机时间
for(StationEntity station:stations){
List<EminfoAndEmParamVo> devices = eminfos.stream().filter(device -> device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(devices)){
continue;
}
// 遍历设备
for(EminfoAndEmParamVo device:devices){
// 设备开关机状态监测点
Map<String,String> point = device.getPoint();
if(MapUtils.isEmpty(point)){
continue;
}
// 监测点
String realId = point.get(HomePageConstant.START_STOP_STATUS);
if(StringUtil.isBlank(realId)){
continue;
}
// 查询时间范围开关机监测点历史数据
HisDeviceSourceDataDTO source = new HisDeviceSourceDataDTO();
source.setProjectId(station.getCode());
source.setDeviceCode(device.getEmCode());
source.setAttrSignages(Collections.singletonList(HomePageConstant.START_STOP_STATUS));
source.setBeginTime(LocalDateTime.parse(DateUtil.format(new Date(), DateUtil.format(start,DateUtil.PATTERN_DATETIME)), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME)));
source.setFinishTime(LocalDateTime.parse(DateUtil.format(new Date(), DateUtil.format(complete,DateUtil.PATTERN_DATETIME)), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME)));
source.setIsPage(false);
source.setCurrent(1);
source.setPageSize(100000);
Result<List<Map<String, Object>>> sources = deviceDataClient.hisDeviceSourceData(source);
if(!sources.isSuccess() || CollectionUtil.isEmpty(sources.getData())){
continue;
}
// 相邻数据处理
List<StartStopDurationRecordVo> adjacents = this.adjacents(sources.getData());
// 开机时长
long runTimes = this.runTimes(adjacents,start,complete);
StartStopDurationEntity duration = new StartStopDurationEntity();
duration.setTenantId(station.getTenantId());
duration.setCreateDept(station.getRefDept());
duration.setCreateUser(station.getCreateUser());
duration.setUpdateUser(station.getUpdateUser());
duration.setStationId(station.getCode());
duration.setStationName(station.getName());
duration.setDeviceCode(device.getEmCode());
duration.setDeviceName(device.getName());
duration.setStartDuration(BigDecimal.valueOf(runTimes / (1000 * 60 * 60.00)).setScale(2, RoundingMode.HALF_UP).doubleValue());
duration.setStopDuration(BigDecimal.valueOf((complete.getTime() - start.getTime() - runTimes) / (1000 * 60 * 60.00)).setScale(2, RoundingMode.HALF_UP).doubleValue());
duration.setStrDay(DateUtil.format(start,DateUtil.PATTERN_DATETIME));
this.save(duration);
}
}
start = calendar.getTime();
}
return true;
}
}

16
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/ThreeGenerateServiceImpl.java

@ -1,6 +1,7 @@
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.common.utils.DateUtil;
import com.hnac.hzims.equipment.entity.ThreeGenerationEntity;
import com.hnac.hzims.scheduled.mapper.equipment.ThreeGenerateMapper;
@ -11,6 +12,7 @@ import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;
import java.util.Calendar;
import java.util.List;
/**
* @author ysj
@ -35,4 +37,18 @@ public class ThreeGenerateServiceImpl extends BaseServiceImpl<ThreeGenerateMappe
this.baseMapper.deletemMonthGenerate(month,year + "-01-01");
}
/**
* 查询发电量
* @param codes
* @param year
* @return
*/
@Override
public List<ThreeGenerationEntity> threes(List<String> codes, String year) {
return this.list(Wrappers.<ThreeGenerationEntity>lambdaQuery()
.in(ThreeGenerationEntity::getStationId,codes)
.like(ThreeGenerationEntity::getStrMonth,year)
);
}
}

2
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java

@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.hnac.hzims.EquipmentConstants;
import com.hnac.hzims.equipment.entity.EmParamEntity;
import com.hnac.hzims.equipment.entity.StartStopDurationEntity;
import com.hnac.hzims.startStop.entity.StartStopDurationEntity;
import com.hnac.hzims.equipment.entity.ThirtyGenerationEntity;
import com.hnac.hzims.equipment.entity.ThreeGenerationEntity;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;

6
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java

@ -17,7 +17,7 @@ import com.hnac.hzims.operational.main.vo.RealDeviceVo;
import com.hnac.hzims.operational.main.vo.RealStationVo;
import com.hnac.hzims.operational.station.entity.StationAttributeEntity;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.scheduled.service.alarm.AlarmQueryService;
import com.hnac.hzims.scheduled.service.alarm.QueryService;
import com.hnac.hzims.scheduled.service.alarm.InterruptionAlarmService;
import com.hnac.hzims.scheduled.service.equipment.WorkshopInfoService;
import com.hnac.hzims.scheduled.service.operation.alarm.RecordService;
@ -63,7 +63,7 @@ public class MonitorServiceImpl implements MonitorService {
private final StationService stationService;
private final AlarmQueryService alarmQueryService;
private final QueryService queryService;
private final StationAttributeService attbtService;
@ -328,7 +328,7 @@ public class MonitorServiceImpl implements MonitorService {
Map<Long,Integer> sorts = this.monitorDeptSorts();
List<String> operations = stations.stream().filter(o->HomePageConstant.HYDROPOWER_SERVETYPE_STRING.equals(o.getServeType())).map(StationEntity::getCode).collect(Collectors.toList());
// 告警铃铛(代运维)
List<String> bells = alarmQueryService.bells(operations);
List<String> bells = queryService.bells(operations);
// 数据中断(代运维)
List<String> aborts = interruptionAlarmService.aborts(operations);
// 设备状态分类

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

@ -8,6 +8,7 @@ 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.entity.ThreeGenerationEntity;
import com.hnac.hzims.equipment.vo.RideDeviceVo;
import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.main.vo.AreaMonthReportVo;
@ -19,6 +20,7 @@ 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.equipment.ThreeGenerateService;
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;
@ -101,11 +103,12 @@ public class ReportServiceImpl implements ReportService {
private final StationService stationService;
private final PhenomenonService phenomenonService;
private final MaintenanceService maintenanceService;
private final ThreeGenerateService threeGenerateService;
private final ISysClient sysClient;
private final IUserClient userClient;
@ -624,6 +627,8 @@ public class ReportServiceImpl implements ReportService {
// 计划发电量
List<PlanGenerationEntity> plans = planService.planGeneration(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()), null ,DateUtil.format(new Date(),"yyyy"));
// 实际发电量
List<ThreeGenerationEntity> threes = threeGenerateService.threes(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()),DateUtil.format(new Date(),"yyyy"));
// 查询站点设备
List<RideDeviceVo> devices = deviceService.rideDevices(stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()));
stations.forEach(station->{
@ -643,13 +648,11 @@ public class ReportServiceImpl implements ReportService {
return;
}
// 运行数据
run.setRunData(this.runData(station.getCode(),stationDevices,plans));
run.setRunData(this.runData(station.getCode(),stationDevices,plans,threes));
// 告警数据
run.setAlarmData(this.alarmData(station.getCode()));
// 月度运行曲线
run.setCurveData(this.curveData(stationDevices));
// TODO 运行数据分析
// TODO 运行建议及其他
runMonService.save(run);
});
@ -678,7 +681,10 @@ public class ReportServiceImpl implements ReportService {
* @param devices
* @return
*/
private String runData(String stationCode,List<RideDeviceVo> devices,List<PlanGenerationEntity> plans) {
private String runData(String stationCode,List<RideDeviceVo> devices,List<PlanGenerationEntity> plans,List<ThreeGenerationEntity> threes) {
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_MONTH,-calendar.get(Calendar.DAY_OF_MONTH));
String month = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
List<RunDataVo> runs = new ArrayList<>();
devices.forEach(device->{
RunDataVo run = new RunDataVo();
@ -686,66 +692,54 @@ public class ReportServiceImpl implements ReportService {
run.setDeviceName(device.getName());
// 运行时长
run.setRunHours(this.runHours(device));
// 月发电量
Double day = this.generate(0,device.getNumber(),device.getRide());
if(ObjectUtil.isEmpty(day)){
// 发电量 以万kwh为单位
if(CollectionUtil.isEmpty(threes)){
run.setGenerate(0.0);
run.setGenerateYear(0.0);
}else{
run.setGenerate(day/10000);
// 月发电量 以万kwh为单位
double generate = threes.stream().filter(o-> StringUtils.isNotEmpty(o.getDeviceCode()) && stationCode.equals(o.getStationId()) && device.getNumber().equals(o.getDeviceCode()) && month.contains(o.getStrMonth())).mapToDouble(o->o.getGenerate().doubleValue()).sum();
if(generate > 0){
run.setGenerate(generate / 10000);
}else{
run.setGenerate(0.0);
}
// 年发电量 以万kwh为单位
double year = threes.stream().filter(o->stationCode.equals(o.getStationId())).mapToDouble(o->o.getGenerate().doubleValue()).sum();
if(year > 0){
run.setGenerateYear(year / 10000);
}else{
run.setGenerateYear(0.0);
}
}
// 年发电量
Double year = this.generate(1,device.getNumber(),device.getRide());
if(ObjectUtil.isEmpty(day)){
run.setGenerateYear(0.0);
// 计划发电量 以万kwh为单位
if(CollectionUtil.isEmpty(plans)){
run.setPlan(0.0);
run.setPlanYear(0.0);
}else{
run.setGenerateYear(year/10000);
// 月计划发电量 以万kwh为单位
double generate = plans.stream().filter(o-> stationCode.equals(o.getStationId()) && month.contains(o.getDateTime())).mapToDouble(o->o.getPlanGeneration().doubleValue()).sum();
if(generate > 0){
run.setPlan(generate / 10000);
}else{
run.setPlan(0.0);
}
// 年计划发电量 以万kwh为单位
double year = plans.stream().filter(o-> stationCode.equals(o.getStationId())).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum();
if(year > 0){
run.setPlanYear(year / 10000);
}else{
run.setPlanYear(0.0);
}
}
// 计划发电量
run.setPlan(this.planGenerate(0,stationCode,plans)/10000);
// 年计划发电量
run.setPlanYear(this.planGenerate(1,stationCode,plans)/10000);
runs.add(run);
});
return JSONObject.toJSONString(runs);
}
/**
* 实际发电量
* @param type
* @param deviceCode
* @param ride
* @return
*/
private Double generate(int type,String deviceCode,double ride) {
Calendar calendar = Calendar.getInstance();
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));
calendar.add(Calendar.DAY_OF_MONTH,1);
start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
break;
}
return Double.valueOf(dataService.periodTargetFloat(start,end,5,cycleType,deviceCode,ride,HomePageConstant.HYDROPOWER_GENERATE_POWER));
}
/**
* 计划发电量

5
hzims-service/hzims-scheduled/src/main/resources/mapper/alarm/ConfigDetailMapper.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.alarm.ConfigDetailMapper">
</mapper>

5
hzims-service/hzims-scheduled/src/main/resources/mapper/alarm/ConfigMapper.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.alarm.ConfigMapper">
</mapper>

28
hzims-service/hzims-scheduled/src/main/resources/mapper/alarm/HandleMapper.xml

@ -13,5 +13,33 @@
AND (HANDLER.DELAY_TIME &gt; #{end} OR HANDLER.DELAY_TIME IS NULL)
</where>
</select>
<select id="sameDayContent" resultType="java.lang.String">
SELECT HANDLER.ALARM_CONTENT
FROM HZIMS_ALARM_HANDLE HANDLER
<where>
HANDLER.IS_DELETED = 0
AND HANDLER.HANDLE_WAY in (5,6)
<if test="start != null and end != null">
AND HANDLER.CREATE_TIME BETWEEN #{start} AND #{end}
</if>
<if test="code != null and code != ''">
and HANDLER.STATION_CODE = #{code}
</if>
</where>
</select>
<select id="incompleteContent" resultType="java.lang.String">
SELECT HANDLER.ALARM_CONTENT
FROM HZIMS_ALARM_HANDLE HANDLER
<where>
HANDLER.IS_DELETED = 0
AND HANDLER.HANDLE_WAY = 1
AND (HANDLER.DELAY_TIME &gt; #{end})
<if test="code != null and code != ''">
and HANDLER.STATION_CODE = #{code}
</if>
</where>
</select>
</mapper>

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

@ -7,11 +7,13 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
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.gglm.bigmodel.api.feign.IDataAnalyseClient;
import com.hnac.gglm.bigmodel.business.dto.*;
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.electric.entity.ThreeEntity;
import com.hnac.hzims.electric.feign.IThreeElectricClient;
import com.hnac.hzims.equipment.entity.EmInfoEntity;
import com.hnac.hzims.equipment.entity.PlanGenerationEntity;
import com.hnac.hzims.equipment.feign.IEmInfoClient;
@ -29,17 +31,14 @@ import com.hnac.hzims.operational.report.vo.*;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.service.IStationService;
import com.hnac.hzims.operational.station.vo.StationVO;
import com.hnac.hzinfo.datasearch.PointData;
import com.hnac.hzims.startStop.feign.IStartStopClient;
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.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.exception.HzServiceException;
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;
@ -101,6 +100,10 @@ public class RunMonthServiceImpl extends ServiceImpl<RunMonthMapper, RunMonthEnt
private final IPlanGenertionClient planClient;
private final IStartStopClient startStopClient;
private final IThreeElectricClient threeElectricClient;
private final IHistoryDataSearchClient historyDataSearchClient;
private final IDataAnalyseClient dataAnalyseClient;
@ -236,11 +239,18 @@ public class RunMonthServiceImpl extends ServiceImpl<RunMonthMapper, RunMonthEnt
if (CollectionUtil.isEmpty(devices)) {
throw new ServiceException("站点未配置机组设备信息、请先为站点添加设备,绑定设备实例,再进行月报查询!");
}
Calendar calendar = Calendar.getInstance();
calendar.setTime(DateUtil.parse(mon, "yyyy-MM"));
// 计划发电量
DevicePlanGenerationVo param = new DevicePlanGenerationVo();
param.setStationIds(Collections.singletonList(stationCode));
param.setDate(DateUtil.format(new Date(), "yyyy"));
param.setDate(DateUtil.format(calendar.getTime(), "yyyy"));
List<PlanGenerationEntity> plans = planClient.getPlanGenerationByParam(param);
// 实际发电量
List<ThreeEntity> threes = threeElectricClient.electrics(stationCode,DateUtil.format(calendar.getTime(), "yyyy"));
RunMonthEntity run = new RunMonthEntity();
run.setTenantId(station.getTenantId());
run.setCreateDept(station.getRefDept());
@ -249,8 +259,6 @@ public class RunMonthServiceImpl extends ServiceImpl<RunMonthMapper, RunMonthEnt
run.setStationCode(station.getCode());
run.setStationName(station.getName());
run.setMonth(mon);
Calendar calendar = Calendar.getInstance();
calendar.setTime(DateUtil.parse(mon, "yyyy-MM"));
String start = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATETIME);
calendar.add(Calendar.MONTH, 1);
calendar.add(Calendar.DAY_OF_MONTH, -1);
@ -261,37 +269,16 @@ public class RunMonthServiceImpl extends ServiceImpl<RunMonthMapper, RunMonthEnt
List<CurveEchartVo> curveEcharts = new ArrayList<>();
for (RideDeviceVo device : devices) {
// 运行数据
runDatas.add(this.runData(station.getCode(), device, plans, start, end));
runDatas.add(this.runData(station.getCode(), device, plans,threes,start,end));
// 月度运行曲线
curveEcharts.add(this.curveData(device, start, end));
}
/*CountDownLatch countDownLatch = new CountDownLatch(devices.size());
List<RunDataVo> runDatas = new CopyOnWriteArrayList<>();
List<CurveEchartVo> curveEcharts = new CopyOnWriteArrayList<>();
for (RideDeviceVo device : devices){
pool.submit(()->{
// 运行数据
runDatas.add(this.runData(station.getCode(),device,plans,start,end));
// 月度运行曲线
curveEcharts.add(this.curveData(device,start,end));
countDownLatch.countDown();
});
}
//所有模板数据获取完成后释放锁
try {
countDownLatch.await();
} catch (InterruptedException e) {
e.printStackTrace();
Thread.currentThread().interrupt();
}*/
if (!CollectionUtil.isEmpty(runDatas)) {
run.setRunData(JSONObject.toJSONString(runDatas));
}
if (!CollectionUtil.isEmpty(curveEcharts)) {
run.setCurveData(JSONObject.toJSONString(curveEcharts));
}
// TODO 运行数据分析
// TODO 运行建议及其他
// 先删除原先月报数据
this.deleteRunReport(mon, stationCode);
// 保存生成月报数据
@ -473,53 +460,55 @@ public class RunMonthServiceImpl extends ServiceImpl<RunMonthMapper, RunMonthEnt
* @param devices
* @return
*/
private RunDataVo runData(String stationCode, RideDeviceVo device, List<PlanGenerationEntity> plans, String start, String end) {
private RunDataVo runData(String stationCode, RideDeviceVo device, List<PlanGenerationEntity> plans,List<ThreeEntity> threes, String start, String end) {
RunDataVo run = new RunDataVo();
run.setDeviceCode(device.getNumber());
run.setDeviceName(device.getName());
// 运行时长
run.setRunHours(this.runHours(device, DateUtil.parse(start, DateUtil.PATTERN_DATETIME), DateUtil.parse(end, DateUtil.PATTERN_DATETIME)));
// 月发电量
Double day = this.generates(0, device.getNumber(), device.getRide(), start, end);
if (ObjectUtil.isEmpty(day)) {
run.setRunHours(startStopClient.deviceDuration(device.getNumber(),start,end));
// 发电量 以万kwh为单位
if(CollectionUtil.isEmpty(threes)){
run.setGenerate(0.0);
} else {
run.setGenerate(day / 10000);
}
// 年发电量
Double year = this.generates(1, device.getNumber(), device.getRide(), start, end);
if (ObjectUtil.isEmpty(day)) {
run.setGenerateYear(0.0);
} else {
run.setGenerateYear(year / 10000);
}else{
// 月发电量 以万kwh为单位
double generate = threes.stream().filter(o-> StringUtils.isNotEmpty(o.getDeviceCode()) && device.getNumber().equals(o.getDeviceCode()) && start.contains(o.getStrMonth())).mapToDouble(o->o.getGenerate().doubleValue()).sum();
if(generate > 0){
run.setGenerate(generate / 10000);
}else{
run.setGenerate(0.0);
}
// 年发电量 以万kwh为单位
double year = threes.stream().mapToDouble(o->o.getGenerate().doubleValue()).sum();
if(year > 0){
run.setGenerateYear(year / 10000);
}else{
run.setGenerateYear(0.0);
}
}
// 计划发电量
run.setPlan(this.planGenerate(0, stationCode, plans) / 10000);
// 年计划发电量
run.setPlanYear(this.planGenerate(1, stationCode, plans) / 10000);
return run;
}
// 计划发电量 以万kwh为单位
if(CollectionUtil.isEmpty(plans)){
run.setPlan(0.0);
run.setPlanYear(0.0);
}else{
// 月计划发电量 以万kwh为单位
double generate = plans.stream().filter(o-> start.contains(o.getDateTime())).mapToDouble(o->o.getPlanGeneration().doubleValue()).sum();
if(generate > 0){
run.setPlan(generate / 10000);
}else{
run.setPlan(0.0);
}
/**
* 实际发电量
*
* @param type
* @param deviceCode
* @param ride
* @return
*/
private Double generates(int type, String deviceCode, double ride, String start, String end) {
if (type == 0) {
return Double.valueOf(dataService.periodTargetFloat(start, end, 5, 5, deviceCode, ride, HomePageConstant.HYDROPOWER_GENERATE_POWER));
// 年计划发电量 以万kwh为单位
double year = plans.stream().mapToDouble(PlanGenerationEntity::getPlanGeneration).sum();
if(year > 0){
run.setPlanYear(year / 10000);
}else{
run.setPlanYear(0.0);
}
}
Calendar calendar = Calendar.getInstance();
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));
calendar.add(Calendar.DAY_OF_MONTH, 1);
return Double.valueOf(dataService.periodTargetFloat(DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATETIME), end, 5, 6, deviceCode, ride, HomePageConstant.HYDROPOWER_GENERATE_POWER));
return run;
}
/**
@ -547,86 +536,6 @@ public class RunMonthServiceImpl extends ServiceImpl<RunMonthMapper, RunMonthEnt
.mapToDouble(PlanGenerationEntity::getPlanGeneration).sum();
}
/**
* 获取运行数据
*
* @param device
* @return
*/
private Double runHours(RideDeviceVo device, Date startDate, Date endDate) {
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;
}
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;
}
/**
* 告警数据

Loading…
Cancel
Save