Browse Source

修改水电站运行月报导出

zhongwei
tyty 12 months ago
parent
commit
6efdf34196
  1. 2
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/OperationalConstants.java
  2. 4
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/TicketChartCell.java
  3. 3
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/AreaMonthReportController.java
  4. 3
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IAreaMonthReportService.java
  5. 78
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java
  6. 22
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/TimeUtils.java
  7. BIN
      hzims-service/operational/src/main/resources/template/waterMonReport.docx

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

@ -4,7 +4,7 @@ import lombok.Getter;
public class OperationalConstants { public class OperationalConstants {
public final static String APP_NAME = "hzims-operational"; public final static String APP_NAME = "hzims-operational-ty";

4
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/TicketChartCell.java

@ -17,10 +17,14 @@ public class TicketChartCell {
private String ticketName; private String ticketName;
@ApiModelProperty(value = "本月数量") @ApiModelProperty(value = "本月数量")
private int ticketMon; private int ticketMon;
@ApiModelProperty(value = "本月合格数量")
private int ticketMonPassCount;
@ApiModelProperty(value = "本月合格率") @ApiModelProperty(value = "本月合格率")
private double ticketMonPerc; private double ticketMonPerc;
@ApiModelProperty(value = "本年数量") @ApiModelProperty(value = "本年数量")
private int ticketYear; private int ticketYear;
@ApiModelProperty(value = "本年合格数量")
private int ticketYearPassCount;
@ApiModelProperty(value = "本年合格率") @ApiModelProperty(value = "本年合格率")
private double ticketYeaPercr; private double ticketYeaPercr;
} }

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

@ -30,6 +30,7 @@ import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.io.IOException; import java.io.IOException;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.text.ParseException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
@ -125,7 +126,7 @@ public class AreaMonthReportController extends BladeController {
@ApiOperation("导出水电站月报") @ApiOperation("导出水电站月报")
@GetMapping("/exportHydropowerStationMonthReport") @GetMapping("/exportHydropowerStationMonthReport")
public R exportHydropowerStationMonthReport(HttpServletResponse response, @ApiParam(value = "日期-年", required = true) Integer year,@ApiParam(value = "日期-月", required = true) Integer month, public R exportHydropowerStationMonthReport(HttpServletResponse response, @ApiParam(value = "日期-年", required = true) Integer year,@ApiParam(value = "日期-月", required = true) Integer month,
@ApiParam(value = "站点Id", required = true) Long deptId,@ApiParam(value = "月报类型", required = true) Long type) { @ApiParam(value = "站点Id", required = true) Long deptId,@ApiParam(value = "月报类型", required = true) Long type) throws ParseException {
HashMap<String, Object> map = new HashMap<>(); HashMap<String, Object> map = new HashMap<>();
if (Func.isEmpty(year)||Func.isEmpty(deptId)||Func.isEmpty(month)||year==0||deptId==0||month==0){ if (Func.isEmpty(year)||Func.isEmpty(deptId)||Func.isEmpty(month)||year==0||deptId==0||month==0){

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

@ -4,6 +4,7 @@ import com.hnac.hzims.operational.main.vo.AreaMonthReportVo;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.text.ParseException;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -18,5 +19,5 @@ public interface IAreaMonthReportService {
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) throws ParseException;
} }

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

@ -201,7 +201,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
return R.data("success"); return R.data("success");
} }
@Override @Override
public R exportHydropowerStationMonthReport(HttpServletResponse response, HashMap<String, Object> map, Integer year, Integer month, Long deptId,String deptName) { public R exportHydropowerStationMonthReport(HttpServletResponse response, HashMap<String, Object> map, Integer year, Integer month, Long deptId,String deptName) throws ParseException {
R<List<Dept>> deptByCurrentUser = sysClient.getDeptByCurrentUser(); R<List<Dept>> deptByCurrentUser = sysClient.getDeptByCurrentUser();
if (!deptByCurrentUser.isSuccess()||deptByCurrentUser.getData()==null){ if (!deptByCurrentUser.isSuccess()||deptByCurrentUser.getData()==null){
return R.fail("用户权限查询失败"); return R.fail("用户权限查询失败");
@ -219,9 +219,9 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
List<StationEntity> stationEntityList = stationService.list(Wrappers.<StationEntity>lambdaQuery() List<StationEntity> stationEntityList = stationService.list(Wrappers.<StationEntity>lambdaQuery()
.in(StationEntity::getRefDept, deptIds) .in(StationEntity::getRefDept, deptIds)
.eq(StationEntity::getType, HomePageConstant.HYDROPOWER)); .eq(StationEntity::getType, HomePageConstant.HYDROPOWER));
stationEntityList=Optional.ofNullable(stationEntityList).orElse(new ArrayList<>()).stream().filter(s->Func.isNotEmpty(s.getCommissionTime())).collect(Collectors.toList()); List<StationEntity> stationEntityListByCommissionTime=Optional.ofNullable(stationEntityList).orElse(new ArrayList<>()).stream().filter(s->Func.isNotEmpty(s.getCommissionTime())).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(stationEntityList)) { if (CollectionUtil.isNotEmpty(stationEntityListByCommissionTime)) {
int commissionTime = stationEntityList.stream().map(s -> { int commissionTime = stationEntityListByCommissionTime.stream().map(s -> {
Duration dur = Duration.between(s.getCommissionTime(), LocalDateTime.now()); Duration dur = Duration.between(s.getCommissionTime(), LocalDateTime.now());
return (int) dur.toDays(); return (int) dur.toDays();
}).reduce(Integer::max).get(); }).reduce(Integer::max).get();
@ -236,10 +236,11 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
Integer yearBefore = year - 1; Integer yearBefore = year - 1;
map.put("yearBefore", yearBefore); map.put("yearBefore", yearBefore);
map.put("month", month); map.put("month", month);
Integer monthBefore = month - 1; String monStartMonBefore = TimeUtils.getEarlyTime(yearBefore, month);
String[] split = monStartMonBefore.split("-");
Integer monthBefore = Integer.valueOf(split[1]);
map.put("monthBefore", monthBefore); map.put("monthBefore", monthBefore);
// map.put("date", date); // map.put("date", date);
map.put("stationName", deptName); map.put("stationName", deptName);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日");
map.put("writeTime", simpleDateFormat.format(new Date())); map.put("writeTime", simpleDateFormat.format(new Date()));
@ -262,7 +263,6 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
// 今年当月 // 今年当月
String monthStart = TimeUtils.getMonthStart(year, month); String monthStart = TimeUtils.getMonthStart(year, month);
String monthEndV2 = TimeUtils.getMonthEndV2(year, month); String monthEndV2 = TimeUtils.getMonthEndV2(year, month);
List<HydropowerUnitRealVo> reals = (List<HydropowerUnitRealVo>) redisTemplate.opsForValue().get(load_hydropower_unit_real_key); List<HydropowerUnitRealVo> reals = (List<HydropowerUnitRealVo>) redisTemplate.opsForValue().get(load_hydropower_unit_real_key);
List<HydropowerUnitRealVo> realsByDept = reals.stream().filter(s -> deptIds.contains(s.getDeptId())).collect(Collectors.toList()); List<HydropowerUnitRealVo> realsByDept = reals.stream().filter(s -> deptIds.contains(s.getDeptId())).collect(Collectors.toList());
// 装机容量占比数据组装 // 装机容量占比数据组装
@ -294,6 +294,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
//装机容量占比图 //装机容量占比图
ImageEntity capacityProportionChart = JFreeUtil.pieChartByDouble("水电项目装机容量占比图", capacityProportionMap, 500, 400); ImageEntity capacityProportionChart = JFreeUtil.pieChartByDouble("水电项目装机容量占比图", capacityProportionMap, 500, 400);
map.put("capacityProportionChart", capacityProportionChart); map.put("capacityProportionChart", capacityProportionChart);
map.put("factoryComparisonChart", "---暂无数据---");
//各发电站发电量环比图+表格数据组装 //各发电站发电量环比图+表格数据组装
List<MonPowerPercentageVo> powerPercentageVoList = getMonPowerPercentageVos(year, month, deptList, deptIds, stationEntityList, stationIds, yearBefore, monthBefore); List<MonPowerPercentageVo> powerPercentageVoList = getMonPowerPercentageVos(year, month, deptList, deptIds, stationEntityList, stationIds, yearBefore, monthBefore);
// getPowerData(deptList, yearStart, yearEnd, yearBeforeStart, yearBeforeEnd, monthStart, monthEnd, beforeMonthStart, beforeMonthEnd, monthStartBeforeYear, monthEndBeforeYear, devices, planYearData, powerPercentageVoList); // getPowerData(deptList, yearStart, yearEnd, yearBeforeStart, yearBeforeEnd, monthStart, monthEnd, beforeMonthStart, beforeMonthEnd, monthStartBeforeYear, monthEndBeforeYear, devices, planYearData, powerPercentageVoList);
@ -315,14 +316,21 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
for (MonPowerPercentageVo monPowerPercentageVo : powerPercentageVoList) { for (MonPowerPercentageVo monPowerPercentageVo : powerPercentageVoList) {
HashMap<String, String> power = new HashMap<>(); HashMap<String, String> power = new HashMap<>();
power.put("name", monPowerPercentageVo.getDeptName()); power.put("name", monPowerPercentageVo.getDeptName());
power.put("monthBefore", monPowerPercentageVo.getPowerMonBefore()+"MW"); power.put("monthBefore", monPowerPercentageVo.getPowerMonBefore()+"MkWh");
power.put("month",monPowerPercentageVo.getPowerMon()+"MW"); power.put("month",monPowerPercentageVo.getPowerMon()+"MkWh");
powerMap.add(power); powerMap.add(power);
} }
map.put("power", powerMap); map.put("power", powerMap);
String dateFormat="";
if (month<10){
dateFormat=year+"-"+"0"+month;
}else {
dateFormat=year+"-"+month;
}
//表格总计 //表格总计
List<PlanGenerationEntity> planYearAll = planGenertionClient.getPlanGenerationByParam(null, Collections.singletonList(deptId.toString()), year.toString()); List<String> deptIdsString = deptIds.stream().map(String::valueOf).collect(Collectors.toList());
List<PlanGenerationEntity> planMonAll = planGenertionClient.getPlanGenerationByParam(null, Collections.singletonList(deptId.toString()), year + "-" + month); List<PlanGenerationEntity> planYearAll = planGenertionClient.getPlanGenerationByParam(null, deptIdsString, year.toString());
List<PlanGenerationEntity> planMonAll = planGenertionClient.getPlanGenerationByParam(null, deptIdsString, dateFormat);
getTabelSum(deptId, powerPercentageVoList, planYearAll, planMonAll, map); getTabelSum(deptId, powerPercentageVoList, planYearAll, planMonAll, map);
//发电情况统计表数据 //发电情况统计表数据
ArrayList<HashMap<String, String>> list = new ArrayList<>(powerPercentageVoList.size()); ArrayList<HashMap<String, String>> list = new ArrayList<>(powerPercentageVoList.size());
@ -335,7 +343,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
temp.put("year", String.valueOf(monPowerPercentageVo.getPowerYear())); temp.put("year", String.valueOf(monPowerPercentageVo.getPowerYear()));
temp.put("monPercentage", monPowerPercentageVo.getPowerMonPercentage() * 100 + "%"); temp.put("monPercentage", monPowerPercentageVo.getPowerMonPercentage() * 100 + "%");
temp.put("yearPercentage", monPowerPercentageVo.getPowerYearPercentage() * 100 + "%"); temp.put("yearPercentage", monPowerPercentageVo.getPowerYearPercentage() * 100 + "%");
temp.put("plan", monPowerPercentageVo.getPlanPercentage() * 100 + "%"); temp.put("plan", monPowerPercentageVo.getPlanPercentage()+ "%");
list.add(temp); list.add(temp);
} }
map.put("powerGeneration", list); map.put("powerGeneration", list);
@ -402,7 +410,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
//表格数据 //表格数据
HashMap<String, String> temp = new HashMap<>(); HashMap<String, String> temp = new HashMap<>();
temp.put("deptName", "总计"); temp.put("deptName", "总计");
temp.put("checkLevel", "无等级"); temp.put("checkLevel", "");
temp.put("findShortagesMon", "0"); temp.put("findShortagesMon", "0");
temp.put("shortagesMon", "0"); temp.put("shortagesMon", "0");
temp.put("findShortagesYear", "0"); temp.put("findShortagesYear", "0");
@ -503,10 +511,12 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
int count = yearTicketCollect.size(); int count = yearTicketCollect.size();
ticketChartCell.setTicketYear(count); ticketChartCell.setTicketYear(count);
List<Long> ticketIds = yearTicketCollect.stream().map(BaseEntity::getId).collect(Collectors.toList()); List<Long> ticketIds = yearTicketCollect.stream().map(BaseEntity::getId).collect(Collectors.toList());
ticketChartCell.setTicketYearPassCount(0);
R<Long> ticketPassCount = ticketInfoClient.getTicketPassByIds(ticketIds); R<Long> ticketPassCount = ticketInfoClient.getTicketPassByIds(ticketIds);
if (ticketPassCount.isSuccess() && ticketPassCount.getData() != null && count != 0) { if (ticketPassCount.isSuccess() && ticketPassCount.getData() != null && count != 0) {
double ticketYearPerc = BigDecimal.valueOf(ticketPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue(); double ticketYearPerc = BigDecimal.valueOf(ticketPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue();
ticketChartCell.setTicketYeaPercr(ticketYearPerc); ticketChartCell.setTicketYeaPercr(ticketYearPerc);
ticketChartCell.setTicketYearPassCount(ticketPassCount.getData().intValue());
} }
} }
if (CollectionUtils.isNotEmpty(monthTicketCollect)) { if (CollectionUtils.isNotEmpty(monthTicketCollect)) {
@ -514,10 +524,13 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
int count = monthTicketCollect.size(); int count = monthTicketCollect.size();
ticketChartCell.setTicketMon(count); ticketChartCell.setTicketMon(count);
List<Long> monthTicketIds = monthTicketCollect.stream().map(BaseEntity::getId).collect(Collectors.toList()); List<Long> monthTicketIds = monthTicketCollect.stream().map(BaseEntity::getId).collect(Collectors.toList());
//合格数量
R<Long> ticketMonthPassCount = ticketInfoClient.getTicketPassByIds(monthTicketIds); R<Long> ticketMonthPassCount = ticketInfoClient.getTicketPassByIds(monthTicketIds);
ticketChartCell.setTicketMonPassCount(0);
if (ticketMonthPassCount.isSuccess() && ticketMonthPassCount.getData() != null && count != 0) { if (ticketMonthPassCount.isSuccess() && ticketMonthPassCount.getData() != null && count != 0) {
double ticketMonthPerc = BigDecimal.valueOf(ticketMonthPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue(); double ticketMonthPerc = BigDecimal.valueOf(ticketMonthPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue();
ticketChartCell.setTicketMonPerc(ticketMonthPerc); ticketChartCell.setTicketMonPerc(ticketMonthPerc);
ticketChartCell.setTicketMonPassCount(ticketMonthPassCount.getData().intValue());
} }
} }
} }
@ -536,9 +549,11 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
ticketChartCell.setTicketYear(count); ticketChartCell.setTicketYear(count);
List<Long> ticketIds = yearOperateCollect.stream().map(BaseEntity::getId).collect(Collectors.toList()); List<Long> ticketIds = yearOperateCollect.stream().map(BaseEntity::getId).collect(Collectors.toList());
R<Long> ticketPassCount = ticketInfoClient.getTicketPassByIds(ticketIds); R<Long> ticketPassCount = ticketInfoClient.getTicketPassByIds(ticketIds);
ticketChartCell.setTicketYearPassCount(0);
if (ticketPassCount.isSuccess() && ticketPassCount.getData() != null && count != 0) { if (ticketPassCount.isSuccess() && ticketPassCount.getData() != null && count != 0) {
double ticketYearPerc = BigDecimal.valueOf(ticketPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue(); double ticketYearPerc = BigDecimal.valueOf(ticketPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue();
ticketChartCell.setTicketYeaPercr(ticketYearPerc); ticketChartCell.setTicketYeaPercr(ticketYearPerc);
ticketChartCell.setTicketYearPassCount(ticketPassCount.getData().intValue());
} }
} }
if (CollectionUtils.isNotEmpty(monthOperateCollect)) { if (CollectionUtils.isNotEmpty(monthOperateCollect)) {
@ -547,9 +562,11 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
ticketChartCell.setTicketMon(count); ticketChartCell.setTicketMon(count);
List<Long> monthTicketIds = monthOperateCollect.stream().map(BaseEntity::getId).collect(Collectors.toList()); List<Long> monthTicketIds = monthOperateCollect.stream().map(BaseEntity::getId).collect(Collectors.toList());
R<Long> ticketMonthPassCount = ticketInfoClient.getTicketPassByIds(monthTicketIds); R<Long> ticketMonthPassCount = ticketInfoClient.getTicketPassByIds(monthTicketIds);
ticketChartCell.setTicketMonPassCount(0);
if (ticketMonthPassCount.isSuccess() && ticketMonthPassCount.getData() != null && count != 0) { if (ticketMonthPassCount.isSuccess() && ticketMonthPassCount.getData() != null && count != 0) {
double ticketMonthPerc = BigDecimal.valueOf(ticketMonthPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue(); double ticketMonthPerc = BigDecimal.valueOf(ticketMonthPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue();
ticketChartCell.setTicketMonPerc(ticketMonthPerc); ticketChartCell.setTicketMonPerc(ticketMonthPerc);
ticketChartCell.setTicketMonPassCount(ticketMonthPassCount.getData().intValue());
} }
} }
} }
@ -569,10 +586,20 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
sumCell.setTicketType(mapTicketChart.getKey()); sumCell.setTicketType(mapTicketChart.getKey());
sumCell.setTicketName(TicketConstants.TicketTypeNameEnum.getTicketNameByType(mapTicketChart.getKey())); sumCell.setTicketName(TicketConstants.TicketTypeNameEnum.getTicketNameByType(mapTicketChart.getKey()));
List<TicketChartCell> ticketChartValue = mapTicketChart.getValue(); List<TicketChartCell> ticketChartValue = mapTicketChart.getValue();
sumCell.setTicketMon(ticketChartValue.stream().mapToInt(TicketChartCell::getTicketMon).sum()); int sumTicketMon = ticketChartValue.stream().mapToInt(TicketChartCell::getTicketMon).sum();
sumCell.setTicketYear(ticketChartValue.stream().mapToInt(TicketChartCell::getTicketYear).sum()); sumCell.setTicketMon(sumTicketMon);
sumCell.setTicketMonPerc(ticketChartValue.stream().mapToDouble(TicketChartCell::getTicketMonPerc).sum()); int sumTicketYear = ticketChartValue.stream().mapToInt(TicketChartCell::getTicketYear).sum();
sumCell.setTicketYeaPercr(ticketChartValue.stream().mapToDouble(TicketChartCell::getTicketYeaPercr).sum()); sumCell.setTicketYear(sumTicketYear);
int sumTicketMonPass = ticketChartValue.stream().mapToInt(TicketChartCell::getTicketMonPassCount).sum();
int sumTicketYearPass = ticketChartValue.stream().mapToInt(TicketChartCell::getTicketYearPassCount).sum();
if (sumTicketMonPass>0&&sumTicketMon>0){
BigDecimal monPassPerc = new BigDecimal(sumTicketMonPass).divide(new BigDecimal(sumTicketMon), 2, BigDecimal.ROUND_UP);
sumCell.setTicketMonPerc(monPassPerc.doubleValue());
}
if (sumTicketYear>0&&sumTicketYearPass>0){
BigDecimal yearPassPerc = new BigDecimal(sumTicketYearPass).divide(new BigDecimal(sumTicketYear), 2, BigDecimal.ROUND_UP);
sumCell.setTicketYeaPercr(yearPassPerc.doubleValue());
}
sumCollect.add(sumCell); sumCollect.add(sumCell);
} }
TicketChartVo ticketChartVo = new TicketChartVo(); TicketChartVo ticketChartVo = new TicketChartVo();
@ -621,6 +648,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
private List<MonPowerPercentageVo> getMonPowerPercentageVos(Integer year, Integer month, List<Dept> deptList, List<Long> deptIds, List<StationEntity> stationEntityList, List<Long> stationIds, Integer yearBefore, Integer monthBefore) { private List<MonPowerPercentageVo> getMonPowerPercentageVos(Integer year, Integer month, List<Dept> deptList, List<Long> deptIds, List<StationEntity> stationEntityList, List<Long> stationIds, Integer yearBefore, Integer monthBefore) {
List<String> deptIdsString = deptIds.stream().map(String::valueOf).collect(Collectors.toList()); List<String> deptIdsString = deptIds.stream().map(String::valueOf).collect(Collectors.toList());
//年计划发电量
List<PlanGenerationEntity> planYearData = planGenertionClient.getPlanGenerationByParam(null, deptIdsString, year.toString()); List<PlanGenerationEntity> planYearData = planGenertionClient.getPlanGenerationByParam(null, deptIdsString, year.toString());
List<MonPowerPercentageVo> powerPercentageVoList = new ArrayList<>(); List<MonPowerPercentageVo> powerPercentageVoList = new ArrayList<>();
//水电站,光伏站和带代运维数据近三年数据 //水电站,光伏站和带代运维数据近三年数据
@ -629,7 +657,8 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
List<String> listByYearBefore = TimeUtils.getListByYear(yearBefore); List<String> listByYearBefore = TimeUtils.getListByYear(yearBefore);
String monStart = TimeUtils.getMon(year, month); String monStart = TimeUtils.getMon(year, month);
String monStartYearBefore = TimeUtils.getMon(yearBefore, month); String monStartYearBefore = TimeUtils.getMon(yearBefore, month);
String monStartMonBefore = TimeUtils.getMon(year, monthBefore); String monStartMonBefore = TimeUtils.getEarlyTime(yearBefore, month);
// String monStartMonBefore = TimeUtils.getMon(year, monthBefore);
// 格式:站点-日期-发电量 // 格式:站点-日期-发电量
for (Map.Entry<Long, Map<String, Float>> deviceMap : powerMapThree.entrySet()) { for (Map.Entry<Long, Map<String, Float>> deviceMap : powerMapThree.entrySet()) {
String deptNameByKey; String deptNameByKey;
@ -649,7 +678,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
Double planGeneration = 0d; Double planGeneration = 0d;
List<PlanGenerationEntity> planGenerationById = planYearData.stream().filter(s -> collect.get(0).getRefDept().equals(s.getStationDeptId())).collect(Collectors.toList()); List<PlanGenerationEntity> planGenerationById = planYearData.stream().filter(s -> collect.get(0).getRefDept().equals(s.getStationDeptId())).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(planGenerationById)) { if (CollectionUtils.isNotEmpty(planGenerationById)) {
planGeneration = Double.valueOf(planGenerationById.get(0).getPlanGeneration()); planGeneration = Double.valueOf(planGenerationById.stream().mapToDouble(PlanGenerationEntity::getPlanGeneration).sum());
} }
//当前机构近三年的数据 //当前机构近三年的数据
Map<String, Float> value = deviceMap.getValue(); Map<String, Float> value = deviceMap.getValue();
@ -778,11 +807,12 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
private static void getTabelSum(Long deptId, List<MonPowerPercentageVo> powerPercentageVoList, List<PlanGenerationEntity> planYearAll, List<PlanGenerationEntity> planMonAll, HashMap<String, Object> map) { private static void getTabelSum(Long deptId, List<MonPowerPercentageVo> powerPercentageVoList, List<PlanGenerationEntity> planYearAll, List<PlanGenerationEntity> planMonAll, HashMap<String, Object> map) {
Float planGeneration = 0f; Float planGeneration = 0f;
if (Func.isNotEmpty(planYearAll)) { if (Func.isNotEmpty(planYearAll)) {
planGeneration = planYearAll.get(0).getPlanGeneration(); planGeneration =Double.valueOf(planYearAll.stream().mapToDouble(PlanGenerationEntity::getPlanGeneration).sum()).floatValue() ;
} }
Float planMonGeneration = 0f; Float planMonGeneration = 0f;
if (Func.isNotEmpty(planMonAll)) { if (Func.isNotEmpty(planMonAll)) {
planMonGeneration = planMonAll.get(0).getPlanGeneration(); planMonGeneration =Double.valueOf(planMonAll.stream().mapToDouble(PlanGenerationEntity::getPlanGeneration).sum()).floatValue() ;
// planMonGeneration = planMonAll.get(0).getPlanGeneration();
} }
MonPowerPercentageVo powerVo = new MonPowerPercentageVo(); MonPowerPercentageVo powerVo = new MonPowerPercentageVo();
powerVo.setDeptId(deptId); powerVo.setDeptId(deptId);
@ -803,7 +833,8 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
yearPercentage = (powerYear.subtract(powerYearBefore)).divide(powerYearBefore, 2, BigDecimal.ROUND_UP); yearPercentage = (powerYear.subtract(powerYearBefore)).divide(powerYearBefore, 2, BigDecimal.ROUND_UP);
} }
if (BigDecimal.valueOf(planGeneration).compareTo(BigDecimal.ZERO) != 0) { if (BigDecimal.valueOf(planGeneration).compareTo(BigDecimal.ZERO) != 0) {
planPercentage = powerYear.divide(BigDecimal.valueOf(planGeneration), 2, BigDecimal.ROUND_UP); //因为计划发电量的单位是kwh,发电量已经转换为万kwh,再加上百分比转换所以需要乘以10000*100
planPercentage = powerYear.divide(BigDecimal.valueOf(planGeneration).divide(new BigDecimal(1000000)), 2, BigDecimal.ROUND_UP);
// 年计划完成率 // 年计划完成率
map.put("yearCompletionRate", planPercentage.toString()); map.put("yearCompletionRate", planPercentage.toString());
} else { } else {
@ -820,7 +851,8 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
// 项目月计划完成量 // 项目月计划完成量
BigDecimal planMonPercentage = new BigDecimal(0); BigDecimal planMonPercentage = new BigDecimal(0);
if (powerMonth.compareTo(BigDecimal.ZERO) != 0 && BigDecimal.valueOf(planMonGeneration).compareTo(BigDecimal.ZERO) != 0) { if (powerMonth.compareTo(BigDecimal.ZERO) != 0 && BigDecimal.valueOf(planMonGeneration).compareTo(BigDecimal.ZERO) != 0) {
planMonPercentage = powerMonth.divide(BigDecimal.valueOf(planMonGeneration), 2, BigDecimal.ROUND_UP); //因为计划发电量的单位是kwh,发电量已经转换为万kwh,再加上百分比转换所以需要乘以10000*100
planMonPercentage = powerMonth.divide(BigDecimal.valueOf(planMonGeneration).divide(new BigDecimal(1000000)), 2, BigDecimal.ROUND_UP);
} }
map.put("monCompletionRate", planMonPercentage); map.put("monCompletionRate", planMonPercentage);
BigDecimal powerMonthBefore = powerPercentageVoList.stream() BigDecimal powerMonthBefore = powerPercentageVoList.stream()

22
hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/TimeUtils.java

@ -112,7 +112,7 @@ public class TimeUtils {
} }
public static List<String> getListByYear(Integer year) { public static List<String> getListByYear(Integer year) {
List<String> monthList=new ArrayList<>(); List<String> monthList=new ArrayList<>();
for (int i = 1; i <13; i++) { for (int i = 0; i <12; i++) {
// 创建一个Calendar对象 // 创建一个Calendar对象
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
// 设置年份 // 设置年份
@ -143,4 +143,24 @@ public class TimeUtils {
String start = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATE) ; String start = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATE) ;
return start; return start;
} }
public static String getEarlyTime(Integer year, Integer month) {
// 创建一个Calendar对象
Calendar calendar = Calendar.getInstance();
// 设置年份
calendar.set(Calendar.YEAR, year);
// 设置月份为1(即一月)
calendar.set(Calendar.MONTH, month-1);
// 设置日期为1
calendar.set(Calendar.DATE, 1);
// 设置时间为0点0分0秒
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.add(Calendar.MONTH, -1);
String start = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATE) ;
return start;
}
} }

BIN
hzims-service/operational/src/main/resources/template/waterMonReport.docx

Binary file not shown.
Loading…
Cancel
Save