Browse Source

新增储能、风电以及发电量批量新增接口

zhongwei
tyty 1 year ago
parent
commit
cef8710719
  1. 2
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/vo/QueryVo.java
  2. 4
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/MainConstants.java
  3. 14
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/StorageMapper.java
  4. 11
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/WindMapper.java
  5. 30
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java
  6. 35
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ReportScheduledTask.java
  7. 20
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/fill/StorageService.java
  8. 15
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/fill/WindService.java
  9. 51
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/fill/impl/StorageServiceImpl.java
  10. 52
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/fill/impl/WindServiceImpl.java
  11. 1
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/RealTargetService.java
  12. 76
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java
  13. 1
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/report/ReportService.java
  14. 39
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/report/impl/ReportServiceImpl.java
  15. 4
      hzims-service/hzims-scheduled/src/main/resources/mapper/operation/StorageMapper.xml
  16. 5
      hzims-service/hzims-scheduled/src/main/resources/mapper/operation/WindMapper.xml
  17. 11
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/controller/GenerateController.java
  18. 6
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/GenerateService.java
  19. 22
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java
  20. 35
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/AreaMonthReportController.java
  21. 5
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IAreaMonthReportService.java
  22. 137
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java

2
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/vo/QueryVo.java

@ -3,8 +3,6 @@ package com.hnac.hzims.operational.fill.vo;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.util.Date;
/** /**
* @author ysj * @author ysj
* @date 2023/04/10 11:16:07 * @date 2023/04/10 11:16:07

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

@ -48,6 +48,8 @@ public interface MainConstants {
// 近年发电量 // 近年发电量
String ELECTRICITY_GENERATION_RECENT_YEAR = "electricityGenerationRecentYear"; String ELECTRICITY_GENERATION_RECENT_YEAR = "electricityGenerationRecentYear";
// 風電儲能近年发电量
String WIND_POWER_GENERATION_RECENT_YEAR = "windPowerGenerationRecentYear";
// 区域值班信息 // 区域值班信息
String REGIONAL_DUTY_INFO = "regionalDutyInfo"; String REGIONAL_DUTY_INFO = "regionalDutyInfo";
@ -57,6 +59,8 @@ public interface MainConstants {
// 区域月报 // 区域月报
String AREA_MONTH_REPORT = "areaMonthReport"; String AREA_MONTH_REPORT = "areaMonthReport";
String WIND_AREA_MONTH_REPORT = "windAreaMonthReport";
String ENERGY_AREA_MONTH_REPORT = "energyAreaMonthReport";
// 站点数据统计 // 站点数据统计
String STATION_DATA_COUNT = "stationDataCount"; String STATION_DATA_COUNT = "stationDataCount";

14
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/StorageMapper.java

@ -0,0 +1,14 @@
package com.hnac.hzims.scheduled.mapper.operation;
import com.hnac.hzims.operational.fill.entity.StorageEntity;
import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper;
/**
* @author ysj
* @date 2023/03/09 16:12:22
* @version 4.0.0
*/
public interface StorageMapper extends UserDataScopeBaseMapper<StorageEntity> {
}

11
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/WindMapper.java

@ -0,0 +1,11 @@
package com.hnac.hzims.scheduled.mapper.operation;
import com.hnac.hzims.operational.fill.entity.WindEntity;
import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper;
/**
* @author ysj
*/
public interface WindMapper extends UserDataScopeBaseMapper<WindEntity> {
}

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

@ -8,12 +8,12 @@ import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
import static com.hnac.hzims.fdp.constants.ScheduledConstant.LOAD_EM_INFO;
import static com.hnac.hzims.operational.main.constant.MainConstants.*; import static com.hnac.hzims.operational.main.constant.MainConstants.*;
@ -33,9 +33,9 @@ public class RealTargetScheduledTask {
* @return * @return
* @throws Exception * @throws Exception
*/ */
@XxlJob(LOAD_EM_INFO) // @XxlJob(LOAD_EM_INFO)
// @Scheduled(cron = "0/40 * * * * ? ") // @Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> loadEmInfo(String param) { public ReturnT<String> loadEmInfo() {
service.loadEmInfo(); service.loadEmInfo();
return new ReturnT<>("SUCCESS"); return new ReturnT<>("SUCCESS");
} }
@ -128,12 +128,26 @@ public class RealTargetScheduledTask {
/** /**
* 获取站点近3年发电量数据 * 获取站点近3年发电量数据
*/ */
@XxlJob(ELECTRICITY_GENERATION_RECENT_YEAR) // @XxlJob(ELECTRICITY_GENERATION_RECENT_YEAR)
public ReturnT<String> loadPowerData(String param) { @Scheduled(cron = "0/40 * * * * ? ")
if (Func.isBlank(param)) { public ReturnT<String> loadPowerData() {
param = DateUtil.format(new Date(), "yyyy-MM"); // if (Func.isBlank(param)) {
// param = DateUtil.format(new Date(), "yyyy-MM");
// }
service.loadPowerData("", Arrays.asList(HomePageConstant.HYDROPOWER,HomePageConstant.PHOTOVOLTAIC),2,3);
return new ReturnT<>("SUCCESS");
} }
service.loadPowerData(param, Arrays.asList(HomePageConstant.HYDROPOWER,HomePageConstant.PHOTOVOLTAIC),2,3); /**
* 获取風電和儲能站点近3年发电量数据
*/
private final static String wind_recent_year_power_data = "hzims:operation:wind:power:data";
// @XxlJob(WIND_POWER_GENERATION_RECENT_YEAR)
@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> loadWindPowerData() {
// if (Func.isBlank(param)) {
// param = DateUtil.format(new Date(), "yyyy-MM");
// }
service.loadPowerDataByWindEnergy("", Arrays.asList(HomePageConstant.WIND_POWER,HomePageConstant.ENERGY_STORAGE),2,3,wind_recent_year_power_data);
return new ReturnT<>("SUCCESS"); return new ReturnT<>("SUCCESS");
} }
} }

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

@ -1,5 +1,6 @@
package com.hnac.hzims.scheduled.scheduled; package com.hnac.hzims.scheduled.scheduled;
import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.scheduled.service.operation.report.ReportService; import com.hnac.hzims.scheduled.service.operation.report.ReportService;
import com.xxl.job.core.biz.model.ReturnT; import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob; import com.xxl.job.core.handler.annotation.XxlJob;
@ -7,11 +8,13 @@ import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Date; import java.util.Date;
import static com.hnac.hzims.operational.main.constant.MainConstants.AREA_MONTH_REPORT; import static com.hnac.hzims.operational.main.constant.MainConstants.*;
import static com.hnac.hzims.scheduled.service.operation.report.impl.ReportServiceImpl.wind_recent_year_cache;
/** /**
@ -25,6 +28,11 @@ public class ReportScheduledTask {
@Autowired @Autowired
private ReportService service; private ReportService service;
@Value("${hzims.operation.wind.report}")
private String wind_report_month_cache_final;
@Value("${hzims.operation.energy.report}")
private String energy_report_month_cache_final;
/** /**
* 首页-生产月报表 * 首页-生产月报表
* @return ReturnT<String> * @return ReturnT<String>
@ -37,5 +45,30 @@ public class ReportScheduledTask {
service.loadMonthReport(param,1); service.loadMonthReport(param,1);
return new ReturnT<>("SUCCESS"); return new ReturnT<>("SUCCESS");
} }
/**
* 首页-生产月报表
* @return ReturnT<String>
*/
@XxlJob(WIND_AREA_MONTH_REPORT)
public ReturnT<String> loadWindMonthReport(String param) {
if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss");
}
service.loadMonthReportByType(param,1, HomePageConstant.WIND_POWER,wind_recent_year_cache,wind_report_month_cache_final);
return new ReturnT<>("SUCCESS");
}
/**
* 首页-生产月报表
* @return ReturnT<String>
*/
@XxlJob(ENERGY_AREA_MONTH_REPORT)
public ReturnT<String> loadEnergyMonthReport(String param) {
if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss");
}
service.loadMonthReportByType(param,1,HomePageConstant.ENERGY_STORAGE,wind_recent_year_cache,energy_report_month_cache_final);
return new ReturnT<>("SUCCESS");
}
} }

20
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/fill/StorageService.java

@ -0,0 +1,20 @@
package com.hnac.hzims.scheduled.service.operation.fill;
import com.hnac.hzims.operational.fill.entity.StorageEntity;
import com.hnac.hzims.operational.main.vo.PowerMonthVo;
import org.springblade.core.mp.base.BaseService;
import java.util.List;
/**
* @author ysj
* @date 2023/03/09 16:12:22
* @version 4.0.0
*/
/**
* 接入电站历史发电量填报
*/
public interface StorageService extends BaseService<StorageEntity> {
List<PowerMonthVo> generateThreeYear(String start, String end, Long station);
}

15
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/fill/WindService.java

@ -0,0 +1,15 @@
package com.hnac.hzims.scheduled.service.operation.fill;
import com.hnac.hzims.operational.fill.entity.WindEntity;
import com.hnac.hzims.operational.main.vo.PowerMonthVo;
import org.springblade.core.mp.base.BaseService;
import java.util.List;
/**
* @author ysj
*/
public interface WindService extends BaseService<WindEntity> {
List<PowerMonthVo> generateThreeYear(String start, String end, Long station);
}

51
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/fill/impl/StorageServiceImpl.java

@ -0,0 +1,51 @@
package com.hnac.hzims.scheduled.service.operation.fill.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.operational.fill.entity.StorageEntity;
import com.hnac.hzims.operational.main.vo.PowerMonthVo;
import com.hnac.hzims.scheduled.mapper.operation.StorageMapper;
import com.hnac.hzims.scheduled.service.operation.fill.StorageService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author ysj
* @date 2023/03/09 16:12:22
* @version 4.0.0
*/
@Slf4j
@Service
@AllArgsConstructor
public class StorageServiceImpl extends BaseServiceImpl<StorageMapper, StorageEntity> implements StorageService {
@Override
public List<PowerMonthVo> generateThreeYear(String start, String end, Long station) {
List<StorageEntity> fills = this.list(Wrappers.<StorageEntity>lambdaQuery()
.between(StorageEntity::getFillDate,start,end)
.eq(StorageEntity::getCreateDept,station)
);
if(CollectionUtil.isEmpty(fills)){
return new ArrayList<>();
}
return fills.stream().map(fill->{
PowerMonthVo mon = new PowerMonthVo();
mon.setStrMonth(DateUtil.format(fill.getFillDate(),DateUtil.PATTERN_DATE));
if(Math.abs(fill.getPower().intValue()) <= 0){
mon.setPower(0f);
}else{
mon.setPower(Float.parseFloat(fill.getPower().toString()));
}
return mon;
}).collect(Collectors.toList());
}
}

52
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/fill/impl/WindServiceImpl.java

@ -0,0 +1,52 @@
package com.hnac.hzims.scheduled.service.operation.fill.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.operational.fill.entity.WindEntity;
import com.hnac.hzims.operational.main.vo.PowerMonthVo;
import com.hnac.hzims.scheduled.mapper.operation.WindMapper;
import com.hnac.hzims.scheduled.service.operation.fill.WindService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author ysj
* @date 2023/04/10 11:16:07
* @version 4.0.0
*/
@Slf4j
@Service
@AllArgsConstructor
public class WindServiceImpl extends BaseServiceImpl<WindMapper, WindEntity> implements WindService {
@Override
public List<PowerMonthVo> generateThreeYear(String start, String end, Long station) {
List<WindEntity> fills = this.list(Wrappers.<WindEntity>lambdaQuery()
.between(WindEntity::getFillDate,start,end)
.eq(WindEntity::getCreateDept,station)
);
if(CollectionUtil.isEmpty(fills)){
return new ArrayList<>();
}
return fills.stream().map(fill->{
PowerMonthVo mon = new PowerMonthVo();
mon.setStrMonth(DateUtil.format(DateUtil.parse(fill.getFillDate(),DateUtil.PATTERN_DATE),DateUtil.PATTERN_DATE));
if(Math.abs(fill.getPower()) <= 0){
mon.setPower(0f);
}else{
mon.setPower(Float.parseFloat(fill.getPower().toString()));
}
return mon;
}).collect(Collectors.toList());
}
}

1
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/RealTargetService.java

@ -34,4 +34,5 @@ public interface RealTargetService {
// 光伏、水电站近3年发电量 // 光伏、水电站近3年发电量
void loadPowerData(String param, List<Integer> types, Integer serveType, int year); void loadPowerData(String param, List<Integer> types, Integer serveType, int year);
void loadPowerDataByWindEnergy(String param, List<Integer> types, Integer serveType, int year,String key);
} }

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

@ -14,18 +14,15 @@ import com.hnac.hzims.operational.station.entity.HzimsAnalyzeModelStationEntity;
import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.scheduled.service.equipment.DeviceParamService; import com.hnac.hzims.scheduled.service.equipment.DeviceParamService;
import com.hnac.hzims.scheduled.service.equipment.DeviceService; import com.hnac.hzims.scheduled.service.equipment.DeviceService;
import com.hnac.hzims.scheduled.service.operation.fill.*;
import com.hnac.hzims.scheduled.service.operation.home.ModelStationService; import com.hnac.hzims.scheduled.service.operation.home.ModelStationService;
import com.hnac.hzims.scheduled.service.operation.home.RealTargetService; import com.hnac.hzims.scheduled.service.operation.home.RealTargetService;
import com.hnac.hzims.scheduled.service.operation.fill.GenerateService; import com.hnac.hzims.scheduled.service.operation.plate.DataService;
import com.hnac.hzims.scheduled.service.operation.fill.PowerService;
import com.hnac.hzims.scheduled.service.operation.fill.UseService;
import com.hnac.hzims.scheduled.service.operation.station.StationAttributeService; import com.hnac.hzims.scheduled.service.operation.station.StationAttributeService;
import com.hnac.hzims.scheduled.service.operation.station.StationService; import com.hnac.hzims.scheduled.service.operation.station.StationService;
import com.hnac.hzims.scheduled.service.operation.plate.DataService;
import com.hnac.hzinfo.datasearch.PointData; import com.hnac.hzinfo.datasearch.PointData;
import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient;
import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData; import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData;
import com.hnac.hzinfo.datasearch.analyse.po.AnalyseCodeByAnalyseDataPO;
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO; import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO;
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO; import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO;
import com.hnac.hzinfo.datasearch.history.IHistoryDataSearchClient; import com.hnac.hzinfo.datasearch.history.IHistoryDataSearchClient;
@ -80,6 +77,8 @@ public class RealTargetServiceImpl implements RealTargetService {
private final ModelStationService modelStationService; private final ModelStationService modelStationService;
private final RedisTemplate redisTemplate; private final RedisTemplate redisTemplate;
private final WindService windService;
private final StorageService storageService;
private final IHistoryDataSearchClient historyDataSearchClient; private final IHistoryDataSearchClient historyDataSearchClient;
@ -1111,7 +1110,50 @@ public class RealTargetServiceImpl implements RealTargetService {
redisTemplate.opsForValue().set(recent_year_power_data, powerMap); redisTemplate.opsForValue().set(recent_year_power_data, powerMap);
} }
/**
* 近年发电量数据
*
* @param param 时间
* @param serveType 站点类型
* @param year 近几年
*/
@Override
public void loadPowerDataByWindEnergy(String param, List<Integer> types, Integer serveType, int year,String key) {
// 站点查询
List<StationEntity> stationList = stationService.list(new LambdaQueryWrapper<StationEntity>() {{
if (ObjectUtil.isNotEmpty(serveType)) {
eq(StationEntity::getServeType, serveType);
}
if (CollectionUtil.isNotEmpty(types)) {
in(StationEntity::getType, types);
}
}});
// 设备信息
// List<EminfoAndEmParamVo> devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_cofig_final).toString(), new TypeReference<List<EminfoAndEmParamVo>>() {
// });
// 开始时间
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH) + 12);
calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1);
String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00";
// 结束日期
calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) - year);
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH));
String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00";
// 存储数据map :<站点id,<月份,发电量>>
Map<Long, Map<String, Float>> powerMap = new HashMap<>();
stationList.forEach(station -> {
// 站点设备集合
// List<EminfoAndEmParamVo> stationDevices = devices.stream().filter(device -> device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList());
// log.error("load_power_data station :" + station.getCode() + "==== device :" + stationDevices );
Map<String, Float> generateMap = this.getGenerateYearByWindEnergy(station,start,end);
if(MapUtils.isEmpty(generateMap)){
return;
}
powerMap.put(station.getId(),generateMap);
});
redisTemplate.opsForValue().set(key, powerMap);
}
/** /**
* 当天有功功率 * 当天有功功率
* @param device * @param device
@ -1165,7 +1207,21 @@ public class RealTargetServiceImpl implements RealTargetService {
} }
return datas.stream().collect(Collectors.toMap(PowerMonthVo::getStrMonth, PowerMonthVo::getPower, Float::sum)); return datas.stream().collect(Collectors.toMap(PowerMonthVo::getStrMonth, PowerMonthVo::getPower, Float::sum));
} }
/**
* 获取风电或者储能的年发电量
* @param start
* @param end
* @return
*/
private Map<String, Float> getGenerateYearByWindEnergy(StationEntity station, String start, String end) {
List<PowerMonthVo> datas = new ArrayList<>();
// 补充填报数据
datas.addAll(this.generateFill(station,start,end));
if(CollectionUtil.isEmpty(datas)){
return null;
}
return datas.stream().collect(Collectors.toMap(PowerMonthVo::getStrMonth, PowerMonthVo::getPower, Float::sum));
}
/** /**
* 获取填报用电量 * 获取填报用电量
@ -1207,6 +1263,12 @@ public class RealTargetServiceImpl implements RealTargetService {
if(HomePageConstant.PHOTOVOLTAIC.equals(station.getType())){ if(HomePageConstant.PHOTOVOLTAIC.equals(station.getType())){
return powerService.generateThreeYear(start,end,station.getRefDept()); return powerService.generateThreeYear(start,end,station.getRefDept());
} }
if(HomePageConstant.WIND_POWER.equals(station.getType())){
return windService.generateThreeYear(start,end,station.getRefDept());
}
if(HomePageConstant.ENERGY_STORAGE.equals(station.getType())){
return storageService.generateThreeYear(start,end,station.getRefDept());
}
// 水电 // 水电
return generateService.generateThreeYear(start,end,station.getCode()); return generateService.generateThreeYear(start,end,station.getCode());
} }

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

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

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

@ -72,6 +72,7 @@ public class ReportServiceImpl implements ReportService {
private final static String recent_year_cache_final = "hzims:operation:key:power:data"; private final static String recent_year_cache_final = "hzims:operation:key:power:data";
public final static String wind_recent_year_cache = "hzims:operation:wind:power:data";
@Value("${hzims.operation.area.report}") @Value("${hzims.operation.area.report}")
private String report_month_cache_final; private String report_month_cache_final;
@ -115,6 +116,44 @@ public class ReportServiceImpl implements ReportService {
} }
/** /**
* 区域-月报-风电/储能/水利
* @param param
* @param year
*/
@Override
public void loadMonthReportByType(String param, int year,Integer type,String key,String saveKey) {
// 获取所有机构
R<List<Dept>> R = sysClient.getDeptList();
if (!R.isSuccess() || CollectionUtil.isEmpty(R.getData())) {
return;
}
// 查询所有服务类型——"运维服务"、站点类型——"水电站"
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery()
.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE)
.eq(StationEntity::getType,type)
);
if (CollectionUtil.isEmpty(stations)) {
return;
}
// 站点近年发电数据
Map<Long, Map<String, Float>> powerMap = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(key);
// 存储数据节点 key - 月份 value - 区域数据集合
Map<String, List<AreaMonthReportVo>> map = new HashMap<>();
// 月份集合
List<String> monthList = getMonthList(year, Calendar.getInstance().get(Calendar.MONTH));
monthList.forEach(mon -> {
List<AreaMonthReportVo> list = this.getAreaReportByMon(R.getData(), powerMap, stations, mon);
if (CollectionUtil.isEmpty(list)) {
return;
}
map.put(mon, list);
});
// 推送当月报表邮件
this.sendMonthReport(map, R.getData());
redisTemplate.opsForValue().set(report_month_cache_final, map);
}
/**
* 获取近年月份集合 * 获取近年月份集合
* *
* @param year * @param year

4
hzims-service/hzims-scheduled/src/main/resources/mapper/operation/StorageMapper.xml

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

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

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

11
hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/controller/GenerateController.java

@ -20,6 +20,8 @@ import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List;
/** /**
* @author ysj * @author ysj
@ -43,6 +45,15 @@ public class GenerateController extends BladeController {
public R saveOrUpdate(@RequestBody GenerateEntity entity) { public R saveOrUpdate(@RequestBody GenerateEntity entity) {
return R.status(service.saveUpdate(entity)); return R.status(service.saveUpdate(entity));
} }
/**
* 新增
*/
@PostMapping("/saveOrUpdateList")
@ApiOperationSupport(order = 1)
@ApiOperation(value = "新增", notes = "传入InsertPowerEntity对象")
public R saveOrUpdateList(@RequestBody List<GenerateEntity> entity) {
return service.saveUpdateList(entity);
}
/** /**
* 删除 * 删除

6
hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/GenerateService.java

@ -2,19 +2,15 @@ package com.hnac.hzims.operational.fill.service;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.operational.fill.entity.GenerateEntity; import com.hnac.hzims.operational.fill.entity.GenerateEntity;
import com.hnac.hzims.operational.fill.entity.RainfallEntity;
import com.hnac.hzims.operational.fill.vo.GenerateVo; import com.hnac.hzims.operational.fill.vo.GenerateVo;
import com.hnac.hzims.operational.fill.vo.QueryVo; import com.hnac.hzims.operational.fill.vo.QueryVo;
import com.hnac.hzims.operational.fill.vo.RainfallVo;
import com.hnac.hzims.operational.main.vo.GenerationPowerVo; import com.hnac.hzims.operational.main.vo.GenerationPowerVo;
import com.hnac.hzims.operational.main.vo.PowerMonthVo; import com.hnac.hzims.operational.main.vo.PowerMonthVo;
import com.hnac.hzims.operational.main.vo.UsrPowerVo;
import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.base.BaseService;
import org.springblade.core.mp.support.Query; import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @author ysj * @author ysj
@ -28,7 +24,7 @@ public interface GenerateService extends BaseService<GenerateEntity> {
// 新增/修改发电量填报数据 // 新增/修改发电量填报数据
boolean saveUpdate(GenerateEntity entity); boolean saveUpdate(GenerateEntity entity);
R saveUpdateList(List<GenerateEntity> entity);
// 查询填报用电量 // 查询填报用电量
Float generate(String date,String station); Float generate(String date,String station);

22
hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java

@ -24,6 +24,7 @@ import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil; import org.springblade.core.tool.utils.StringUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
@ -86,7 +87,28 @@ public class GenerateServiceImpl extends BaseServiceImpl<GenerateMapper, Generat
} }
return this.updateById(entity); return this.updateById(entity);
} }
@Override
@Transactional(rollbackFor = Exception.class)
public R saveUpdateList(List<GenerateEntity> entityList) {
//发电量不为空的,保存或者编辑
List<GenerateEntity> addList = entityList.stream().filter(s -> ObjectUtil.isNotEmpty(s.getGenerate())).collect(Collectors.toList());
boolean saveFlag = this.saveOrUpdateBatch(addList);
//发电量为空的,且有ID的为删除
List<Long> ids = entityList.stream().
filter(s -> ObjectUtil.isEmpty(s.getGenerate()))
.filter(s -> ObjectUtil.isNotEmpty(s.getId()))
.map(GenerateEntity::getId).collect(Collectors.toList());
boolean deleteFlag =true;
if (CollectionUtil.isNotEmpty(ids)){
deleteFlag= this.deleteLogic(ids);
}
if (saveFlag&&deleteFlag){
return R.success("保存成功");
}else {
return R.fail("保存失败");
}
}
/** /**
* 根据时间机构查询用电量 * 根据时间机构查询用电量
* @param date 时间: - yyyy/ yyyy-mm/ yyyy-mm-dd * @param date 时间: - yyyy/ yyyy-mm/ yyyy-mm-dd

35
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/AreaMonthReportController.java

@ -20,6 +20,7 @@ import org.springblade.core.log.annotation.ApiLog;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.system.feign.ISysClient; import org.springblade.system.feign.ISysClient;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -54,7 +55,14 @@ public class AreaMonthReportController extends BladeController {
service.loadMonthReport(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"), 1); service.loadMonthReport(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"), 1);
return R.success("success"); return R.success("success");
} }
@ApiLog
@ApiOperationSupport(order = 1)
@ApiOperation("生成区域月报")
@GetMapping("/loadMonthReportByType")
public R loadMonthReportByType(int type) {
service.loadMonthReportByType(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"), 1,type);
return R.success("success");
}
@ApiLog @ApiLog
@ApiOperationSupport(order = 2) @ApiOperationSupport(order = 2)
@ApiOperation("获取区域月报") @ApiOperation("获取区域月报")
@ -66,7 +74,30 @@ public class AreaMonthReportController extends BladeController {
public R<List<AreaMonthReportVo>> getAreaMonthReport(@ApiParam(value = "日期-年月", required = true) String date) { public R<List<AreaMonthReportVo>> getAreaMonthReport(@ApiParam(value = "日期-年月", required = true) String date) {
return service.getReport(date); return service.getReport(date);
} }
@ApiLog
@ApiOperationSupport(order = 2)
@ApiOperation("获取区域月报")
@GetMapping("/getAreaMonthReportByType")
@OperationAnnotation(
moduleName = "生产月报",
title = "水电生产运行月报", operatorType = OperatorType.MOBILE, businessType = BusinessType.GENCODE,
action = "获取区域月报")
public R<List<AreaMonthReportVo>> getAreaMonthReportByType(@ApiParam(value = "日期-年月", required = true) String date,Integer type) {
if (ObjectUtil.isEmpty(type)){
type=0;
}
return service.getReportByType(date,type);
}
@ApiLog
@ApiOperationSupport(order = 3)
@ApiOperation("导出区域月报")
@GetMapping("/exportAreaMonthReportByType")
public R exportAreaMonthReportByType(HttpServletResponse response, @ApiParam(value = "日期-年月", required = true) String date,Integer type) {
if (ObjectUtil.isEmpty(type)){
type=0;
}
return service.exportByType(response, date,type);
}
@ApiLog @ApiLog
@ApiOperationSupport(order = 3) @ApiOperationSupport(order = 3)
@ApiOperation("导出区域月报") @ApiOperation("导出区域月报")

5
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IAreaMonthReportService.java

@ -13,10 +13,15 @@ import java.util.List;
public interface IAreaMonthReportService { public interface IAreaMonthReportService {
void loadMonthReport(String param,int year); void loadMonthReport(String param,int year);
void loadMonthReportByType(String param,int year,int type);
R<List<AreaMonthReportVo>> getReport(String date); R<List<AreaMonthReportVo>> getReport(String date);
R export(HttpServletResponse response, String date); R export(HttpServletResponse response, String date);
R exportHydropowerStationMonthReport(HttpServletResponse response, HashMap<String, Object> map, Integer year, Integer month,Long deptId,String name); R exportHydropowerStationMonthReport(HttpServletResponse response, HashMap<String, Object> map, Integer year, Integer month,Long deptId,String name);
R<List<AreaMonthReportVo>> getReportByType(String date, Integer type);
R exportByType(HttpServletResponse response, String date, Integer type);
} }

137
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java

@ -121,7 +121,10 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
@Value("${hzims.operation.area.report}") @Value("${hzims.operation.area.report}")
private String area_month_report_key; private String area_month_report_key;
@Value("${hzims.operation.wind.report}")
private String wind_report_month_cache_final;
@Value("${hzims.operation.energy.report}")
private String energy_report_month_cache_final;
private final static String RECENT_YEAR_POWER_DATA = "hzims:operation:key:power:data"; private final static String RECENT_YEAR_POWER_DATA = "hzims:operation:key:power:data";
private final static String load_hydropower_unit_real_key = "hzims:operation:loadhydropowerunit:real:key"; private final static String load_hydropower_unit_real_key = "hzims:operation:loadhydropowerunit:real:key";
private final static String load_hydropower_unit_target_key = "hzims:operation:loadhydropowerunit:target:key"; private final static String load_hydropower_unit_target_key = "hzims:operation:loadhydropowerunit:target:key";
@ -153,7 +156,61 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
//根据用户权限获取机构 //根据用户权限获取机构
return R.data(areaMonthReportVoList.stream().sorted(Comparator.comparing(AreaMonthReportVo::getActualPower, Comparator.reverseOrder())).collect(Collectors.toList())); return R.data(areaMonthReportVoList.stream().sorted(Comparator.comparing(AreaMonthReportVo::getActualPower, Comparator.reverseOrder())).collect(Collectors.toList()));
} }
@Override
public R<List<AreaMonthReportVo>> getReportByType(String date, Integer type){
List<AreaMonthReportVo> areaMonthReportVoList = this.getAreaMonthReportByType(date, false,type);
if (CollectionUtil.isEmpty(areaMonthReportVoList)) {
return R.fail("选择月份无统计报表数据");
}
//根据用户权限获取机构
return R.data(areaMonthReportVoList.stream().sorted(Comparator.comparing(AreaMonthReportVo::getActualPower, Comparator.reverseOrder())).collect(Collectors.toList()));
}
/**
* 导出区域月报
*
* @param response
* @param date
*/
@Override
public R exportByType(HttpServletResponse response, String date, Integer type) {
List<AreaMonthReportVo> monthReportVoList = this.getAreaMonthReportByType(date, true,type);
// 创建Excel文件
HSSFWorkbook hssWB = new HSSFWorkbook();
// 添加sheet页
HSSFSheet sheet = hssWB.createSheet("运行月报(" + date + ")");
// 行高
sheet.setDefaultRowHeight((short) (20 * 25));
// 列宽
sheet.setDefaultColumnWidth(20);
this.setFirstHeader(hssWB, sheet);
// 第二行/三行 表头格式设置
this.setWorkHeader(hssWB, sheet);
if (!CollectionUtil.isEmpty(monthReportVoList)) {
// 数据填充
this.setWorkData(hssWB, sheet, monthReportVoList);
}
// 下载导出
String filename = "(" + date + ")水电站生产运行月报";
// 设置头信息
response.setCharacterEncoding("UTF-8");
response.setContentType("application/vnd.ms-excel");
ServletOutputStream outputStream;
try {
//设置xlsx格式
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename + ".xlsx", "UTF-8"));
//创建一个输出流
outputStream = response.getOutputStream();
//写入数据
hssWB.write(outputStream);
// 关闭
outputStream.close();
hssWB.close();
} catch (IOException e) {
e.printStackTrace();
}
return R.data("success");
}
/** /**
* 导出区域月报 * 导出区域月报
* *
@ -1103,6 +1160,37 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
/** /**
* 获取区域月报数据
*
* @return
*/
private List<AreaMonthReportVo> getAreaMonthReportByType(String date, boolean isSendFlag,Integer type) {
R<List<Dept>> D = sysClient.getDeptByCurrentUser();
if (!D.isSuccess() || CollectionUtil.isEmpty(D.getData())) {
return null;
}
List<Long> authList = D.getData().stream().filter(o -> o.getDeptCategory().equals(3)).map(Dept::getId).collect(Collectors.toList());
if (CollectionUtil.isEmpty(authList)) {
return null;
}
String key = area_month_report_key;
if (type.equals(HomePageConstant.WIND_POWER)){
key= wind_report_month_cache_final;
}
if (type.equals(HomePageConstant.ENERGY_STORAGE)){
key= energy_report_month_cache_final;
}
Map<String, List<AreaMonthReportVo>> map = (Map<String, List<AreaMonthReportVo>>) redisTemplate.opsForValue().get(key);
if (MapUtils.isEmpty(map)) {
return null;
}
if (isSendFlag) {
// 发送邮件
this.sendMonthReport(map, D.getData());
}
return map.get(date);
}
/**
* 区域-加载月报数据 * 区域-加载月报数据
* *
* @param param * @param param
@ -1133,10 +1221,53 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
map.put(mon, list); map.put(mon, list);
}); });
// 推送当月报表邮件 // 推送当月报表邮件
this.sendMonthReport(map, R.getData()); // this.sendMonthReport(map, R.getData());
redisTemplate.opsForValue().set(area_month_report_key, map); redisTemplate.opsForValue().set(area_month_report_key, map);
} }
/**
* 区域-加载月报数据
*
* @param param
*/
@Override
public void loadMonthReportByType(String param, int year,int type) {
// 获取所有机构
R<List<Dept>> R = sysClient.getDeptList();
if (!R.isSuccess() || CollectionUtil.isEmpty(R.getData())) {
return;
}
if (ObjectUtil.isEmpty(type)){
type=HomePageConstant.HYDROPOWER;
}
String saveKey=area_month_report_key;
if (type==HomePageConstant.WIND_POWER){
saveKey=wind_report_month_cache_final;
}
if (type==HomePageConstant.ENERGY_STORAGE){
saveKey=energy_report_month_cache_final;
}
// 查询所有服务类型——"运维服务"、站点类型——"水电站"
List<StationEntity> stationList = stationService.getStationType(HomePageConstant.HYDROPOWER_SERVETYPE, Collections.singletonList(type), null,true);
if (CollectionUtil.isEmpty(stationList)) {
return;
}
// 站点近年发电数据
Map<Long, Map<String, Float>> powerMap = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA);
// 存储数据节点 key - 月份 value - 区域数据集合
Map<String, List<AreaMonthReportVo>> map = new HashMap<>();
// 月份集合
List<String> monthList = getMonthList(year, Calendar.getInstance().get(Calendar.MONTH));
monthList.forEach(mon -> {
List<AreaMonthReportVo> list = this.getAreaReportByMon(R.getData(), powerMap, stationList, mon);
if (CollectionUtil.isEmpty(list)) {
return;
}
map.put(mon, list);
});
// 推送当月报表邮件
// this.sendMonthReport(map, R.getData());
redisTemplate.opsForValue().set(saveKey, map);
}
/** /**
* 获取近年月份集合 * 获取近年月份集合
* *

Loading…
Cancel
Save