Browse Source

导出水电站月报bug修改

zhongwei
tyty 1 year ago
parent
commit
4aff9e5429
  1. 10
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/AreaMonthReportController.java
  2. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IAreaMonthReportService.java
  3. 26
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java

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

@ -19,6 +19,7 @@ import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.log.annotation.ApiLog;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@ -42,7 +43,6 @@ public class AreaMonthReportController extends BladeController {
@NotNull
private final IAreaMonthReportService service;
private final static String load_hydropower_unit_real_key = "hzims:operation:loadhydropowerunit:real:key";
@ApiLog
@ApiOperationSupport(order = 1)
@ -126,13 +126,17 @@ public class AreaMonthReportController extends BladeController {
@ApiParam(value = "站点Id", required = true) Long deptId,@ApiParam(value = "月报类型", required = true) Long type) {
HashMap<String, Object> map = new HashMap<>();
if (Func.isEmpty(year)||Func.isEmpty(deptId)||Func.isEmpty(month)||year==0||deptId==0||month==0){
return R.fail("传入格式不对,请重新导出");
}
String deptName="";
if (type==1){
service.exportHydropowerStationMonthReport(response, map,year,month,deptId);
service.exportHydropowerStationMonthReport(response, map,year,month,deptId,deptName);
//word模板相对路径、word生成路径、word生成的文件名称、数据源
}
XWPFDocument xwpfDocument = WordUtils.exportWordV2("template/waterMonReport.docx", map);
// 下载导出
String filename = "(" + year+"年"+month+"月"+ ")水电站月报";
String filename = "(" + year+"年"+month+"月"+ ")"+deptName+"水电站月报";
// 设置头信息
response.setCharacterEncoding("UTF-8");
response.setContentType("application/vnd.ms-excel");

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

@ -18,5 +18,5 @@ public interface IAreaMonthReportService {
R export(HttpServletResponse response, String date);
R exportHydropowerStationMonthReport(HttpServletResponse response, HashMap<String, Object> map, Integer year, Integer month,Long deptId);
R exportHydropowerStationMonthReport(HttpServletResponse response, HashMap<String, Object> map, Integer year, Integer month,Long deptId,String name);
}

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

@ -204,7 +204,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
return R.data("success");
}
@Override
public R exportHydropowerStationMonthReport(HttpServletResponse response, HashMap<String, Object> map, Integer year, Integer month, Long deptId) {
public R exportHydropowerStationMonthReport(HttpServletResponse response, HashMap<String, Object> map, Integer year, Integer month, Long deptId,String name) {
R<List<Dept>> deptByCurrentUser = sysClient.getDeptByCurrentUser();
if (!deptByCurrentUser.isSuccess()||deptByCurrentUser.getData()==null){
return R.fail("用户权限查询失败");
@ -214,6 +214,8 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
return R.fail("暂无该机构");
}
String deptName = deptNameR.getData();
// 赋值给导出表格名称
name=deptName;
R<List<Dept>> deptR = sysClient.getDeptByType("200000", deptId, 4);
if (!deptR.isSuccess() || deptR.getData() == null) {
return R.fail("该机构不包含水站信息");
@ -227,10 +229,17 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
List<StationEntity> stationEntityList = stationService.list(Wrappers.<StationEntity>lambdaQuery()
.in(StationEntity::getRefDept, deptIds)
.eq(StationEntity::getType, HomePageConstant.HYDROPOWER));
Integer commissionTime = stationEntityList.stream().map(s -> {
Duration dur = Duration.between(s.getCommissionTime(), LocalDateTime.now());
return (int) dur.toDays();}).reduce(Integer::max).get();
List<Long> stationIds = stationEntityList.stream().map(BaseEntity::getId).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(stationEntityList)) {
Integer commissionTime = stationEntityList.stream().map(s -> {
Duration dur = Duration.between(s.getCommissionTime(), LocalDateTime.now());
return (int) dur.toDays();
}).reduce(Integer::max).get();
map.put("commissionTime", commissionTime.toString());
}else {
map.put("commissionTime", 0);
}
List<Long> stationIds = Optional.ofNullable(stationEntityList)
.orElse(new ArrayList<>()).stream().map(BaseEntity::getId).collect(Collectors.toList());
//其它普通数据
map.put("year", year);
Integer yearBefore = year - 1;
@ -239,7 +248,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
Integer monthBefore = month - 1;
map.put("monthBefore", monthBefore);
// map.put("date", date);
map.put("commissionTime", commissionTime.toString());
map.put("stationName", deptName);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日");
map.put("writeTime", simpleDateFormat.format(new Date()));
@ -294,7 +303,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
//装机容量占比图
ImageEntity capacityProportionChart = JFreeUtil.pieChartByDouble("水电项目装机容量占比图", capacityProportionMap, 500, 400);
map.put("capacityProportionChart", capacityProportionChart);
//各发电站发电量环比图+表格数据组装
//各发电站发电量环比图+表格数据组装
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);
// 各发电站发电量环比图数据组装
@ -384,7 +393,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
checkList.add(temp);
}
map.put("checkList", checkList);
//各电站缺陷统计表
//各电站缺陷统计表
//本年缺陷
LambdaQueryWrapper<OperPhenomenonEntity> wrapperYear = Wrappers.lambdaQuery();
wrapperYear.ge(OperPhenomenonEntity::getCreateTime, yearStart);
@ -626,6 +635,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
String monStart = TimeUtils.getMon(year, month);
String monStartYearBefore = TimeUtils.getMon(yearBefore, month);
String monStartMonBefore = TimeUtils.getMon(year, monthBefore);
// 格式:站点-日期-发电量
for (Map.Entry<Long, Map<String, Float>> deviceMap : powerMapThree.entrySet()) {
String deptNameByKey;
if (stationIds.contains(deviceMap.getKey())) {

Loading…
Cancel
Save