Browse Source

#水电站运行月报

zhongwei
yang_shj 6 months ago
parent
commit
e0a898c3d5
  1. 32
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/report/impl/ReportServiceImpl.java

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

@ -620,6 +620,9 @@ public class ReportServiceImpl implements ReportService {
if(CollectionUtil.isEmpty(stations)){ if(CollectionUtil.isEmpty(stations)){
return; return;
} }
// 删除上个月手动生成月报记录
this.deleteGenerateReport(stations);
// 计划发电量 // 计划发电量
List<PlanGenerationEntity> plans = planService.planGeneration(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()), null ,DateUtil.format(new Date(),"yyyy")); List<PlanGenerationEntity> plans = planService.planGeneration(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()), null ,DateUtil.format(new Date(),"yyyy"));
// 查询站点设备 // 查询站点设备
@ -633,7 +636,7 @@ public class ReportServiceImpl implements ReportService {
run.setStationCode(station.getCode()); run.setStationCode(station.getCode());
run.setStationName(station.getName()); run.setStationName(station.getName());
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.setTime(DateUtil.parse("2024-05-01 00:00:00",DateUtil.PATTERN_DATETIME)); calendar.setTime(new Date());
calendar.add(Calendar.DAY_OF_MONTH,-1); calendar.add(Calendar.DAY_OF_MONTH,-1);
run.setMonth(DateUtil.format(calendar.getTime(),"yyyy-MM")); run.setMonth(DateUtil.format(calendar.getTime(),"yyyy-MM"));
List<RideDeviceVo> stationDevices = devices.stream().filter(device->device.getDepartment().equals(station.getRefDept())).collect(Collectors.toList()); List<RideDeviceVo> stationDevices = devices.stream().filter(device->device.getDepartment().equals(station.getRefDept())).collect(Collectors.toList());
@ -654,6 +657,24 @@ public class ReportServiceImpl implements ReportService {
} }
/** /**
* 删除上月手动生成月报记录
* @param stations
*/
private void deleteGenerateReport(List<StationEntity> stations) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.add(Calendar.MONTH,-1);
List<RunMonthEntity> runs = runMonService.list(Wrappers.<RunMonthEntity>lambdaQuery()
.eq(RunMonthEntity::getMonth,DateUtil.format(calendar.getTime(),"yyyy-MM"))
.in(RunMonthEntity::getStationCode,stations.stream().map(StationEntity::getCode).collect(Collectors.toList()))
);
if(CollectionUtil.isEmpty(runs)){
return;
}
runMonService.deleteLogic(runs.stream().map(RunMonthEntity::getId).collect(Collectors.toList()));
}
/**
* 运行数据 * 运行数据
* @param devices * @param devices
* @return * @return
@ -699,7 +720,7 @@ public class ReportServiceImpl implements ReportService {
*/ */
private Double generate(int type,String deviceCode,double ride) { private Double generate(int type,String deviceCode,double ride) {
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.setTime(DateUtil.parse("2024-05-01 00:00:00",DateUtil.PATTERN_DATETIME)); calendar.setTime(new Date());
String end = null,start = null; String end = null,start = null;
int cycleType = 5; int cycleType = 5;
switch (type){ switch (type){
@ -773,7 +794,7 @@ public class ReportServiceImpl implements ReportService {
// 确定查询时间范围: 年、月 // 确定查询时间范围: 年、月
Date startDate,endDate; Date startDate,endDate;
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.setTime(DateUtil.parse("2024-05-01 00:00:00",DateUtil.PATTERN_DATETIME)); calendar.setTime(new Date());
endDate = calendar.getTime(); endDate = calendar.getTime();
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH)); calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH));
calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1); calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1);
@ -846,7 +867,7 @@ public class ReportServiceImpl implements ReportService {
*/ */
private String alarmData(String code) { private String alarmData(String code) {
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.setTime(DateUtil.parse("2024-05-01 00:00:00",DateUtil.PATTERN_DATETIME)); calendar.setTime(new Date());
calendar.add(Calendar.DAY_OF_MONTH,-1); calendar.add(Calendar.DAY_OF_MONTH,-1);
String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
calendar.add(Calendar.MONTH,-1); calendar.add(Calendar.MONTH,-1);
@ -952,8 +973,7 @@ public class ReportServiceImpl implements ReportService {
*/ */
private List<EchartVo> curve(List<AttributeVo> attributes, String deviceCode) { private List<EchartVo> curve(List<AttributeVo> attributes, String deviceCode) {
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.setTime(DateUtil.parse("2024-05-01 00:00:00",DateUtil.PATTERN_DATETIME)); calendar.setTime(DateUtil.parse(DateUtil.format(new Date(),DateUtil.PATTERN_DATE) + " 23:59:59",DateUtil.PATTERN_DATETIME));
//calendar.setTime(DateUtil.parse(DateUtil.format(new Date(),DateUtil.PATTERN_DATE) + " 23:59:59",DateUtil.PATTERN_DATETIME));
calendar.add(Calendar.DAY_OF_MONTH,-1); calendar.add(Calendar.DAY_OF_MONTH,-1);
String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
calendar.add(Calendar.MONTH,-1); calendar.add(Calendar.MONTH,-1);

Loading…
Cancel
Save