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 org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable; import java.io.Serializable;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.Date; import java.util.Date;
@ -71,9 +73,9 @@ public class AlarmEntity extends TenantEntity {
private Integer alarmCount; private Integer alarmCount;
@ApiModelProperty(value = "告警时间") @ApiModelProperty(value = "告警时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss.sss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.sss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
private Date alarmTime; private LocalDateTime alarmTime;
@ApiModelProperty(value = "监测点") @ApiModelProperty(value = "监测点")
private String realId; 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() { private List<StationEntity> stations() {
StationEntity station = new StationEntity(); StationEntity station = new StationEntity();
station.setServeType("2"); //station.setServeType("2");
station.setType(0); station.setType(0);
R<List<StationEntity>> result = stationClient.list(station); R<List<StationEntity>> result = stationClient.list(station);
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ 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.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -55,18 +57,19 @@ public class DroolsAlarmServiceImpl implements DroolsAlarmService {
private AlarmEntity getAlarmEntity(DroolsAlarmVo item) { private AlarmEntity getAlarmEntity(DroolsAlarmVo item) {
AlarmEntity entity = new AlarmEntity(); 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.setAlarmId(format+"-"+item.getDeviceCode());
entity.setAlarmSource(CONDITION_ALARM); entity.setAlarmSource(CONDITION_ALARM);
entity.setAlarmType(CONDITION); entity.setAlarmType(CONDITION);
entity.setAlarmContext(item.getName()); 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.setAlarmValue(item.getCurrentValue());
entity.setAlarmSignage(item.getSignage()); entity.setAlarmSignage(item.getSignage());
entity.setAlarmLevel(Integer.valueOf(item.getLevel())); entity.setAlarmLevel(Integer.valueOf(item.getLevel()));
entity.setAlarmStatus(1); entity.setAlarmStatus(1);
entity.setDeviceCode(item.getDeviceCode()); entity.setDeviceCode(item.getDeviceCode());
entity.setTenantId("200000");
entity.setStationId(item.getProjectId()); entity.setStationId(item.getProjectId());
R<StationEntity> stationByCode = stationClient.getStationByCode(item.getProjectId()); R<StationEntity> stationByCode = stationClient.getStationByCode(item.getProjectId());
if (stationByCode.isSuccess()&& ObjectUtils.isNotEmpty(stationByCode.getData())){ 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.springblade.system.user.feign.IUserClient;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -82,7 +84,9 @@ public class FdpAlarmServiceImpl implements FdpAlarmService {
AlarmEntity entity = new AlarmEntity(); AlarmEntity entity = new AlarmEntity();
entity.setAlarmId(item.getUUID()); entity.setAlarmId(item.getUUID());
entity.setRealId(item.getFaultId()); 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.setAlarmContext(item.getFinfo());
entity.setAlarmSource(EARLY_WARNING); entity.setAlarmSource(EARLY_WARNING);
entity.setAlarmType(EARLY); 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.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; 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.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -91,7 +94,9 @@ public class LevelAlarmServiceImpl implements LevelAlarmService {
AlarmEntity entity = new AlarmEntity(); AlarmEntity entity = new AlarmEntity();
entity.setAlarmSource(AlarmConstants.LEVEL_ALARM); entity.setAlarmSource(AlarmConstants.LEVEL_ALARM);
entity.setAlarmId(level.getId()); 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.setAlarmType(level.getType());
entity.setRealId(level.getSignage()); entity.setRealId(level.getSignage());
entity.setAlarmContext(level.getName()); 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.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
@ -66,13 +68,14 @@ public class SoeAlarmServiceImpl implements SoeAlarmService {
private AlarmEntity getAlarmEntity(SoeAlarmVo item) { private AlarmEntity getAlarmEntity(SoeAlarmVo item) {
AlarmEntity entity = new AlarmEntity(); 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(), org.springblade.core.tool.utils.DateUtil.PATTERN_DATETIME_MINI);
entity.setAlarmId(format+"-"+item.getDeviceCode()); entity.setAlarmId(format+"-"+item.getDeviceCode());
entity.setAlarmSource(LEVEL_ALARM); entity.setAlarmSource(LEVEL_ALARM);
entity.setAlarmType(ONE_LEVEL); entity.setAlarmType(ONE_LEVEL);
entity.setAlarmContext(item.getName()); 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.setAlarmValue(item.getCurrentValue());
entity.setAlarmSignage(item.getSignage()); entity.setAlarmSignage(item.getSignage());
entity.setAlarmLevel(Integer.valueOf(item.getLevel())); 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.springblade.system.user.feign.IUserClient;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -83,9 +85,11 @@ public class SystemAlarmServiceImpl implements SystemAlarmService {
private AlarmEntity getAlarmEntity(SystemAlarmVo item) { private AlarmEntity getAlarmEntity(SystemAlarmVo item) {
AlarmEntity entity = new AlarmEntity(); AlarmEntity entity = new AlarmEntity();
entity.setAlarmId(item.getId()); entity.setAlarmId(item.getId());
// Date date = new Date(item.getTs()); ZoneId zoneId = ZoneId.systemDefault();
// entity.setAlarmTime(DateUtil.parse(item.getTs().toString(),PATTERN_DATETIME_MILLIS)); Date alarmTime = new Date();
entity.setAlarmTime( new Date(item.getTs())); alarmTime.setTime(item.getTs());
LocalDateTime localDateTime = LocalDateTime.ofInstant(alarmTime.toInstant(), zoneId);
entity.setAlarmTime(localDateTime);
entity.setAlarmContext(item.getContext()); entity.setAlarmContext(item.getContext());
entity.setAlarmType(item.getType()); entity.setAlarmType(item.getType());
entity.setAlarmStatus(item.getState()); 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.springblade.core.tool.utils.DateUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -101,7 +103,9 @@ public class VideoAlarmServiceImpl implements VideoAlarmService {
private AlarmEntity getAlarmEntity(DeviceSoeVO item) { private AlarmEntity getAlarmEntity(DeviceSoeVO item) {
AlarmEntity entity = new AlarmEntity(); AlarmEntity entity = new AlarmEntity();
entity.setAlarmId(item.getId()); 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.setAlarmContext(item.getSoeExplain());
entity.setAlarmType(AlarmHandleConstant.VIDEO_ALARM); entity.setAlarmType(AlarmHandleConstant.VIDEO_ALARM);
entity.setAlarmStatus(Integer.valueOf(item.getSoeStatus())); 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 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> { public interface ThreeGenerateService extends BaseService<ThreeGenerationEntity> {
void deletemMonthGenerate(@Param("month") String month); 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 @Override
public void deleteDayGenerate(String month) { public void deleteDayGenerate(String month) {
Calendar calendar = Calendar.getInstance(); 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.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY));
calendar.add(Calendar.MINUTE,-calendar.get(Calendar.MINUTE)); calendar.add(Calendar.MINUTE,-calendar.get(Calendar.MINUTE));
calendar.add(Calendar.SECOND,-calendar.get(Calendar.SECOND)); 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"); 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 @Override
public void thisDayPowerGeneration(String param) { public void thisDayPowerGeneration(String param) {
String month = DateUtil.format(new Date(),"yyyy-MM") ; String month = DateUtil.format(new Date(),DateUtil.PATTERN_DATE);
// 步骤1.水电、光伏站点 // 步骤1.水电、光伏站点
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery().in(StationEntity::getType, Arrays.asList(HomePageConstant.HYDROPOWER,HomePageConstant.PHOTOVOLTAIC))); 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>>() {}); List<EminfoAndEmParamVo> devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_cofig_final).toString(), new TypeReference<List<EminfoAndEmParamVo>>() {});
// 步骤3.站点-设备当日发电量 // 步骤3.站点-设备当日发电量
this.refreshDayGeneration(stations,devices,month + "-01"); this.refreshDayGeneration(stations,devices,month);
// 步骤4.近3年的当月发电量 // 步骤4.近3年的当月发电量
this.thirtyMonthGenerate(stations,month); this.thirtyMonthGenerate(stations,month);
@ -194,22 +194,20 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
* 更新近3年的当月发电量 * 更新近3年的当月发电量
*/ */
private void thirtyMonthGenerate(List<StationEntity> stations,String month) { private void thirtyMonthGenerate(List<StationEntity> stations,String month) {
String queryMonth = DateUtil.format(DateUtil.parse(month,DateUtil.PATTERN_DATE),"yyyy-MM");
// 步骤1.查询设备当月累计发电量 // 步骤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年当月发电量 // 步骤2.删除近3年当月发电量,清除填报发电量
threeGenerateService.deletemMonthGenerate(month + "-01"); threeGenerateService.deletemMonthGenerate(queryMonth + "-01");
// 步骤3.将当月累计发电量新增表 // 步骤3.将当月累计发电量新增表
this.saveThreeMonthGenerate(generations,month); this.saveThreeMonthGenerate(generations,month);
// 步骤4.清除填报发电量 // 步骤4.清除超出30日发电量
threeGenerateService.deleteFillGenerate();
// 步骤5.清除超出30日发电量
thirtyGenerateService.deleteDayGenerate(month); thirtyGenerateService.deleteDayGenerate(month);
// 步骤6.重新补充填报发电量 // 步骤5.重新补充填报发电量
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH) + 12); calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH) + 12);
calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1); calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1);
@ -231,20 +229,21 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
if(CollectionUtil.isEmpty(generations)){ if(CollectionUtil.isEmpty(generations)){
return; 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(); ThreeGenerationEntity generate = new ThreeGenerationEntity();
generate.setStationId(entry.getValue().get(0).getStationId()); generate.setStationId(thirtyGenerationEntities.get(0).getStationId());
generate.setStationName(entry.getValue().get(0).getStationName()); generate.setStationName(thirtyGenerationEntities.get(0).getStationName());
generate.setDeviceCode(entry.getValue().get(0).getDeviceCode()); generate.setDeviceCode(thirtyGenerationEntities.get(0).getDeviceCode());
generate.setDeviceName(entry.getValue().get(0).getDeviceName()); generate.setDeviceName(thirtyGenerationEntities.get(0).getDeviceName());
generate.setTenantId(entry.getValue().get(0).getTenantId()); generate.setTenantId(thirtyGenerationEntities.get(0).getTenantId());
generate.setCreateDept(entry.getValue().get(0).getCreateDept()); generate.setCreateDept(thirtyGenerationEntities.get(0).getCreateDept());
generate.setCreateUser(entry.getValue().get(0).getCreateUser()); generate.setCreateUser(thirtyGenerationEntities.get(0).getCreateUser());
generate.setUpdateUser(entry.getValue().get(0).getUpdateUser()); generate.setUpdateUser(thirtyGenerationEntities.get(0).getUpdateUser());
String strMonth = month + "-01"; Date date = DateUtil.parse(month, DateUtil.PATTERN_DATE);
String strMonth = DateUtil.format(date, "yyyy-MM") + "-01";
generate.setStrMonth(strMonth); generate.setStrMonth(strMonth);
generate.setMonth(DateUtil.parse(strMonth,DateUtil.PATTERN_DATE).getMonth() + 1); generate.setMonth(date.getMonth() + 1);
generate.setGenerate(BigDecimal.valueOf(entry.getValue().stream().mapToDouble(o->o.getGenerate().doubleValue()).sum()).setScale(2, RoundingMode.HALF_UP)); generate.setGenerate(BigDecimal.valueOf(thirtyGenerationEntities.stream().mapToDouble(o -> o.getGenerate().doubleValue()).sum()).setScale(2, RoundingMode.HALF_UP));
return generate; return generate;
}).collect(Collectors.toList())); }).collect(Collectors.toList()));
} }
@ -293,7 +292,7 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
generate.setUpdateUser(station.getUpdateUser()); generate.setUpdateUser(station.getUpdateUser());
Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s");
generate.setStrDay(DateUtil.format(time,DateUtil.PATTERN_DATETIME)); generate.setStrDay(DateUtil.format(time,DateUtil.PATTERN_DATETIME));
generate.setDay(time.getDay()); generate.setDay(time.getDate());
if(StringUtil.isEmpty(record.getVal())){ if(StringUtil.isEmpty(record.getVal())){
generate.setGenerate(BigDecimal.ZERO); generate.setGenerate(BigDecimal.ZERO);
}else{ }else{
@ -421,7 +420,8 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
generation.setCreateUser(station.getCreateUser()); generation.setCreateUser(station.getCreateUser());
generation.setUpdateUser(station.getUpdateUser()); generation.setUpdateUser(station.getUpdateUser());
generation.setStrMonth(power.getStrMonth()); 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){ if(power.getPower() <= 0){
generation.setGenerate(BigDecimal.ZERO); generation.setGenerate(BigDecimal.ZERO);
}else{ }else{

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

@ -5,13 +5,7 @@
<delete id="deletemMonthGenerate"> <delete id="deletemMonthGenerate">
DELETE FROM HZIMS_EM_THREE_GENERATE DELETE FROM HZIMS_EM_THREE_GENERATE
WHERE STR_MONTH = #{month} WHERE STR_MONTH = #{month}
<if test="before != null and before != ''"> OR DEVICE_CODE IS NULL
OR STR_MONTH &lt; #{before}
</if>
</delete>
<delete id="deleteFillGenerate">
DELETE FROM HZIMS_EM_THREE_GENERATE
WHERE DEVICE_CODE IS NULL
<if test="before != null and before != ''"> <if test="before != null and before != ''">
OR STR_MONTH &lt; #{before} OR STR_MONTH &lt; #{before}
</if> </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())){ if(ObjectUtil.isEmpty(o.getSort())){
o.setSort(999); 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