Browse Source

#云服务告警

zhongwei
yang_shj 5 months ago
parent
commit
c72fe2374f
  1. 8
      hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/entity/AlarmEntity.java
  2. 2
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java
  3. 9
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/DroolsAlarmServiceImpl.java
  4. 6
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/FdpAlarmServiceImpl.java
  5. 7
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/LevelAlarmServiceImpl.java
  6. 7
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/SoeAlarmServiceImpl.java
  7. 10
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/SystemAlarmServiceImpl.java
  8. 6
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/VideoAlarmServiceImpl.java
  9. 1
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/equipment/ThreeGenerateMapper.java
  10. 2
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/ThreeGenerateService.java
  11. 2
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/ThirtyGenerateServiceImpl.java
  12. 12
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/ThreeGenerateServiceImpl.java
  13. 48
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ObtainGenerationServiceImpl.java
  14. 8
      hzims-service/hzims-scheduled/src/main/resources/mapper/equipment/ThreeGenerateMapper.xml
  15. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java

8
hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/entity/AlarmEntity.java

@ -11,6 +11,8 @@ import org.springblade.core.tool.utils.DateUtil;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.Date;
@ -71,9 +73,9 @@ public class AlarmEntity extends TenantEntity {
private Integer alarmCount;
@ApiModelProperty(value = "告警时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss.sss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.sss")
private Date alarmTime;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
private LocalDateTime alarmTime;
@ApiModelProperty(value = "监测点")
private String realId;

2
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java

@ -109,7 +109,7 @@ public class AlarmServiceImpl extends BaseServiceImpl<AlarmMapper, AlarmEntity>
*/
private List<StationEntity> stations() {
StationEntity station = new StationEntity();
station.setServeType("2");
//station.setServeType("2");
station.setType(0);
R<List<StationEntity>> result = stationClient.list(station);
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){

9
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/DroolsAlarmServiceImpl.java

@ -16,6 +16,8 @@ import org.springblade.core.tool.api.R;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@ -55,18 +57,19 @@ public class DroolsAlarmServiceImpl implements DroolsAlarmService {
private AlarmEntity getAlarmEntity(DroolsAlarmVo item) {
AlarmEntity entity = new AlarmEntity();
String format = DateUtil.format(item.getTs(), org.springblade.core.tool.utils.DateUtil.PATTERN_DATETIME_MINI);
String format = DateUtil.format(item.getTs(), DateUtil.PATTERN_DATETIME_MINI);
entity.setAlarmId(format+"-"+item.getDeviceCode());
entity.setAlarmSource(CONDITION_ALARM);
entity.setAlarmType(CONDITION);
entity.setAlarmContext(item.getName());
entity.setAlarmTime(item.getTs());
ZoneId zoneId = ZoneId.systemDefault();
LocalDateTime localDateTime = LocalDateTime.ofInstant(item.getTs().toInstant(), zoneId);
entity.setAlarmTime(localDateTime);
entity.setAlarmValue(item.getCurrentValue());
entity.setAlarmSignage(item.getSignage());
entity.setAlarmLevel(Integer.valueOf(item.getLevel()));
entity.setAlarmStatus(1);
entity.setDeviceCode(item.getDeviceCode());
entity.setTenantId("200000");
entity.setStationId(item.getProjectId());
R<StationEntity> stationByCode = stationClient.getStationByCode(item.getProjectId());
if (stationByCode.isSuccess()&& ObjectUtils.isNotEmpty(stationByCode.getData())){

6
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/FdpAlarmServiceImpl.java

@ -19,6 +19,8 @@ import org.springblade.system.feign.ISysClient;
import org.springblade.system.user.feign.IUserClient;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -82,7 +84,9 @@ public class FdpAlarmServiceImpl implements FdpAlarmService {
AlarmEntity entity = new AlarmEntity();
entity.setAlarmId(item.getUUID());
entity.setRealId(item.getFaultId());
entity.setAlarmTime(item.getCreateTime());
ZoneId zoneId = ZoneId.systemDefault();
LocalDateTime localDateTime = LocalDateTime.ofInstant(item.getCreateTime().toInstant(), zoneId);
entity.setAlarmTime(localDateTime);
entity.setAlarmContext(item.getFinfo());
entity.setAlarmSource(EARLY_WARNING);
entity.setAlarmType(EARLY);

7
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/LevelAlarmServiceImpl.java

@ -21,6 +21,9 @@ import org.springblade.core.tool.utils.DateUtil;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -91,7 +94,9 @@ public class LevelAlarmServiceImpl implements LevelAlarmService {
AlarmEntity entity = new AlarmEntity();
entity.setAlarmSource(AlarmConstants.LEVEL_ALARM);
entity.setAlarmId(level.getId());
entity.setAlarmTime(new Date(level.getTs()));
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.sss");
LocalDateTime localDateTime = LocalDateTime.parse(level.getTs(), formatter);
entity.setAlarmTime(localDateTime);
entity.setAlarmType(level.getType());
entity.setRealId(level.getSignage());
entity.setAlarmContext(level.getName());

7
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/SoeAlarmServiceImpl.java

@ -19,6 +19,8 @@ import org.springblade.core.tool.utils.CollectionUtil;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
@ -66,13 +68,14 @@ public class SoeAlarmServiceImpl implements SoeAlarmService {
private AlarmEntity getAlarmEntity(SoeAlarmVo item) {
AlarmEntity entity = new AlarmEntity();
String format = DateUtil.format(item.getTs(), org.springblade.core.tool.utils.DateUtil.PATTERN_DATETIME_MINI);
entity.setAlarmId(format+"-"+item.getDeviceCode());
entity.setAlarmSource(LEVEL_ALARM);
entity.setAlarmType(ONE_LEVEL);
entity.setAlarmContext(item.getName());
entity.setAlarmTime(item.getTs());
ZoneId zoneId = ZoneId.systemDefault();
LocalDateTime localDateTime = LocalDateTime.ofInstant(item.getTs().toInstant(), zoneId);
entity.setAlarmTime(localDateTime);
entity.setAlarmValue(item.getCurrentValue());
entity.setAlarmSignage(item.getSignage());
entity.setAlarmLevel(Integer.valueOf(item.getLevel()));

10
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/SystemAlarmServiceImpl.java

@ -24,6 +24,8 @@ import org.springblade.system.feign.ISysClient;
import org.springblade.system.user.feign.IUserClient;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
@ -83,9 +85,11 @@ public class SystemAlarmServiceImpl implements SystemAlarmService {
private AlarmEntity getAlarmEntity(SystemAlarmVo item) {
AlarmEntity entity = new AlarmEntity();
entity.setAlarmId(item.getId());
// Date date = new Date(item.getTs());
// entity.setAlarmTime(DateUtil.parse(item.getTs().toString(),PATTERN_DATETIME_MILLIS));
entity.setAlarmTime( new Date(item.getTs()));
ZoneId zoneId = ZoneId.systemDefault();
Date alarmTime = new Date();
alarmTime.setTime(item.getTs());
LocalDateTime localDateTime = LocalDateTime.ofInstant(alarmTime.toInstant(), zoneId);
entity.setAlarmTime(localDateTime);
entity.setAlarmContext(item.getContext());
entity.setAlarmType(item.getType());
entity.setAlarmStatus(item.getState());

6
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/VideoAlarmServiceImpl.java

@ -23,6 +23,8 @@ import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -101,7 +103,9 @@ public class VideoAlarmServiceImpl implements VideoAlarmService {
private AlarmEntity getAlarmEntity(DeviceSoeVO item) {
AlarmEntity entity = new AlarmEntity();
entity.setAlarmId(item.getId());
entity.setAlarmTime(DateUtil.parse(item.getTs(), PATTERN_DATETIME_MILLIS));
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.sss");
LocalDateTime localDateTime = LocalDateTime.parse(item.getTs(), formatter);
entity.setAlarmTime(localDateTime);
entity.setAlarmContext(item.getSoeExplain());
entity.setAlarmType(AlarmHandleConstant.VIDEO_ALARM);
entity.setAlarmStatus(Integer.valueOf(item.getSoeStatus()));

1
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/equipment/ThreeGenerateMapper.java

@ -12,5 +12,4 @@ public interface ThreeGenerateMapper extends BaseMapper<ThreeGenerationEntity> {
void deletemMonthGenerate(@Param("month") String month,@Param("before") String before);
void deleteFillGenerate(@Param("before") String before);
}

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

@ -10,6 +10,4 @@ import org.springblade.core.mp.base.BaseService;
public interface ThreeGenerateService extends BaseService<ThreeGenerationEntity> {
void deletemMonthGenerate(@Param("month") String month);
void deleteFillGenerate();
}

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

@ -30,7 +30,7 @@ public class ThirtyGenerateServiceImpl extends BaseServiceImpl<ThirtyGenerateMap
@Override
public void deleteDayGenerate(String month) {
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_MONTH,-30);
calendar.add(Calendar.DAY_OF_MONTH,-29);
calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY));
calendar.add(Calendar.MINUTE,-calendar.get(Calendar.MINUTE));
calendar.add(Calendar.SECOND,-calendar.get(Calendar.SECOND));

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

@ -35,16 +35,4 @@ public class ThreeGenerateServiceImpl extends BaseServiceImpl<ThreeGenerateMappe
this.baseMapper.deletemMonthGenerate(month,year + "-01-01");
}
/**
* 清除填报发电量
*/
@Override
public void deleteFillGenerate() {
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_MONTH,-29);
calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY));
calendar.add(Calendar.MINUTE,-calendar.get(Calendar.MINUTE));
calendar.add(Calendar.SECOND,-calendar.get(Calendar.SECOND));
this.baseMapper.deleteFillGenerate(DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATETIME));
}
}

48
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ObtainGenerationServiceImpl.java

@ -99,7 +99,7 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
*/
@Override
public void thisDayPowerGeneration(String param) {
String month = DateUtil.format(new Date(),"yyyy-MM") ;
String month = DateUtil.format(new Date(),DateUtil.PATTERN_DATE);
// 步骤1.水电、光伏站点
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery().in(StationEntity::getType, Arrays.asList(HomePageConstant.HYDROPOWER,HomePageConstant.PHOTOVOLTAIC)));
@ -107,7 +107,7 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
List<EminfoAndEmParamVo> devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_cofig_final).toString(), new TypeReference<List<EminfoAndEmParamVo>>() {});
// 步骤3.站点-设备当日发电量
this.refreshDayGeneration(stations,devices,month + "-01");
this.refreshDayGeneration(stations,devices,month);
// 步骤4.近3年的当月发电量
this.thirtyMonthGenerate(stations,month);
@ -194,22 +194,20 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
* 更新近3年的当月发电量
*/
private void thirtyMonthGenerate(List<StationEntity> stations,String month) {
String queryMonth = DateUtil.format(DateUtil.parse(month,DateUtil.PATTERN_DATE),"yyyy-MM");
// 步骤1.查询设备当月累计发电量
List<ThirtyGenerationEntity> generations = thirtyGenerateService.list(Wrappers.<ThirtyGenerationEntity>lambdaQuery().like(ThirtyGenerationEntity::getStrDay,month));
List<ThirtyGenerationEntity> generations = thirtyGenerateService.list(Wrappers.<ThirtyGenerationEntity>lambdaQuery().like(ThirtyGenerationEntity::getStrDay,queryMonth));
// 步骤2.删除近3年当月发电量
threeGenerateService.deletemMonthGenerate(month + "-01");
// 步骤2.删除近3年当月发电量,清除填报发电量
threeGenerateService.deletemMonthGenerate(queryMonth + "-01");
// 步骤3.将当月累计发电量新增表
this.saveThreeMonthGenerate(generations,month);
// 步骤4.清除填报发电量
threeGenerateService.deleteFillGenerate();
// 步骤5.清除超出30日发电量
// 步骤4.清除超出30日发电量
thirtyGenerateService.deleteDayGenerate(month);
// 步骤6.重新补充填报发电量
// 步骤5.重新补充填报发电量
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH) + 12);
calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1);
@ -231,20 +229,21 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
if(CollectionUtil.isEmpty(generations)){
return;
}
threeGenerateService.saveBatch(generations.stream().collect(Collectors.groupingBy(ThirtyGenerationEntity::getDeviceCode)).entrySet().stream().map(entry->{
threeGenerateService.saveBatch(generations.stream().collect(Collectors.groupingBy(ThirtyGenerationEntity::getDeviceCode)).values().stream().map(thirtyGenerationEntities -> {
ThreeGenerationEntity generate = new ThreeGenerationEntity();
generate.setStationId(entry.getValue().get(0).getStationId());
generate.setStationName(entry.getValue().get(0).getStationName());
generate.setDeviceCode(entry.getValue().get(0).getDeviceCode());
generate.setDeviceName(entry.getValue().get(0).getDeviceName());
generate.setTenantId(entry.getValue().get(0).getTenantId());
generate.setCreateDept(entry.getValue().get(0).getCreateDept());
generate.setCreateUser(entry.getValue().get(0).getCreateUser());
generate.setUpdateUser(entry.getValue().get(0).getUpdateUser());
String strMonth = month + "-01";
generate.setStationId(thirtyGenerationEntities.get(0).getStationId());
generate.setStationName(thirtyGenerationEntities.get(0).getStationName());
generate.setDeviceCode(thirtyGenerationEntities.get(0).getDeviceCode());
generate.setDeviceName(thirtyGenerationEntities.get(0).getDeviceName());
generate.setTenantId(thirtyGenerationEntities.get(0).getTenantId());
generate.setCreateDept(thirtyGenerationEntities.get(0).getCreateDept());
generate.setCreateUser(thirtyGenerationEntities.get(0).getCreateUser());
generate.setUpdateUser(thirtyGenerationEntities.get(0).getUpdateUser());
Date date = DateUtil.parse(month, DateUtil.PATTERN_DATE);
String strMonth = DateUtil.format(date, "yyyy-MM") + "-01";
generate.setStrMonth(strMonth);
generate.setMonth(DateUtil.parse(strMonth,DateUtil.PATTERN_DATE).getMonth() + 1);
generate.setGenerate(BigDecimal.valueOf(entry.getValue().stream().mapToDouble(o->o.getGenerate().doubleValue()).sum()).setScale(2, RoundingMode.HALF_UP));
generate.setMonth(date.getMonth() + 1);
generate.setGenerate(BigDecimal.valueOf(thirtyGenerationEntities.stream().mapToDouble(o -> o.getGenerate().doubleValue()).sum()).setScale(2, RoundingMode.HALF_UP));
return generate;
}).collect(Collectors.toList()));
}
@ -293,7 +292,7 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
generate.setUpdateUser(station.getUpdateUser());
Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s");
generate.setStrDay(DateUtil.format(time,DateUtil.PATTERN_DATETIME));
generate.setDay(time.getDay());
generate.setDay(time.getDate());
if(StringUtil.isEmpty(record.getVal())){
generate.setGenerate(BigDecimal.ZERO);
}else{
@ -421,7 +420,8 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
generation.setCreateUser(station.getCreateUser());
generation.setUpdateUser(station.getUpdateUser());
generation.setStrMonth(power.getStrMonth());
generation.setMonth(power.getMonth());
Date date = DateUtil.parse(power.getStrMonth(),DateUtil.PATTERN_DATE);
generation.setMonth(date.getMonth() + 1);
if(power.getPower() <= 0){
generation.setGenerate(BigDecimal.ZERO);
}else{

8
hzims-service/hzims-scheduled/src/main/resources/mapper/equipment/ThreeGenerateMapper.xml

@ -5,13 +5,7 @@
<delete id="deletemMonthGenerate">
DELETE FROM HZIMS_EM_THREE_GENERATE
WHERE STR_MONTH = #{month}
<if test="before != null and before != ''">
OR STR_MONTH &lt; #{before}
</if>
</delete>
<delete id="deleteFillGenerate">
DELETE FROM HZIMS_EM_THREE_GENERATE
WHERE DEVICE_CODE IS NULL
OR DEVICE_CODE IS NULL
<if test="before != null and before != ''">
OR STR_MONTH &lt; #{before}
</if>

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java

@ -258,7 +258,7 @@ public class RealMonitorServiceImpl implements IRealMonitorService {
if(ObjectUtil.isEmpty(o.getSort())){
o.setSort(999);
}
}).sorted(Comparator.comparing((RealStationVo::getSort))).collect(Collectors.toList())));
}).sorted(Comparator.comparing((RealStationVo::getSort)).thenComparing(RealStationVo::getStationName)).collect(Collectors.toList())));
}
/**

Loading…
Cancel
Save