|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package com.hnac.hzims.electric.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.alibaba.fastjson.TypeReference; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
@ -10,10 +11,7 @@ import com.hnac.hzims.electric.entity.ThreeEntity;
|
|
|
|
|
import com.hnac.hzims.electric.service.IElectricReportService; |
|
|
|
|
import com.hnac.hzims.electric.service.ThirtyService; |
|
|
|
|
import com.hnac.hzims.electric.service.ThreeService; |
|
|
|
|
import com.hnac.hzims.electric.vo.ComprehensiveElectricVo; |
|
|
|
|
import com.hnac.hzims.electric.vo.DeviceElectricVo; |
|
|
|
|
import com.hnac.hzims.electric.vo.RunParamVo; |
|
|
|
|
import com.hnac.hzims.electric.vo.TableHeadVo; |
|
|
|
|
import com.hnac.hzims.electric.vo.*; |
|
|
|
|
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; |
|
|
|
|
import com.hnac.hzims.hzimsweather.feign.IRainfallClient; |
|
|
|
|
import com.hnac.hzims.operational.station.entity.StationEntity; |
|
|
|
@ -22,8 +20,20 @@ import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient;
|
|
|
|
|
import com.hnac.hzinfo.datasearch.analyse.po.AnalyseCodeByAnalyseDataPO; |
|
|
|
|
import com.hnac.hzinfo.datasearch.analyse.po.AnalyzeDataConditionPO; |
|
|
|
|
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeDataConditionVO; |
|
|
|
|
import com.hnac.hzinfo.sdk.core.response.Result; |
|
|
|
|
import com.hnac.hzinfo.sdk.v5.device.DeviceDataClient; |
|
|
|
|
import com.hnac.hzinfo.sdk.v5.device.source.dto.HisFacSlicerDataDTO; |
|
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.apache.commons.collections4.MapUtils; |
|
|
|
|
import org.apache.poi.hssf.usermodel.*; |
|
|
|
|
import org.apache.poi.hssf.util.HSSFColor; |
|
|
|
|
import org.apache.poi.ss.usermodel.BorderStyle; |
|
|
|
|
import org.apache.poi.ss.usermodel.FillPatternType; |
|
|
|
|
import org.apache.poi.ss.usermodel.HorizontalAlignment; |
|
|
|
|
import org.apache.poi.ss.usermodel.VerticalAlignment; |
|
|
|
|
import org.apache.poi.ss.util.CellRangeAddress; |
|
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
import org.springblade.core.tool.utils.CollectionUtil; |
|
|
|
|
import org.springblade.core.tool.utils.DateUtil; |
|
|
|
@ -33,9 +43,14 @@ import org.springblade.system.feign.ISysClient;
|
|
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
import javax.servlet.ServletOutputStream; |
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
import java.math.RoundingMode; |
|
|
|
|
import java.net.URLEncoder; |
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
|
import java.time.ZoneId; |
|
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
@ -56,6 +71,8 @@ public class ElectricReportServiceImpl implements IElectricReportService {
|
|
|
|
|
|
|
|
|
|
private final IRainfallClient rainClient; |
|
|
|
|
|
|
|
|
|
private final DeviceDataClient deviceDataClient; |
|
|
|
|
|
|
|
|
|
private final IStationClient stationClient; |
|
|
|
|
|
|
|
|
|
private final IAnalyseDataSearchClient analyseDataSearchClient; |
|
|
|
@ -100,6 +117,145 @@ public class ElectricReportServiceImpl implements IElectricReportService {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 基础报表导出 |
|
|
|
|
* @param response |
|
|
|
|
* @param deptId |
|
|
|
|
* @param type |
|
|
|
|
* @param time |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public void basicsExport(HttpServletResponse response, Long deptId, Long type, String time) { |
|
|
|
|
Map<String, Object> basics = this.basics(deptId,type,time); |
|
|
|
|
if(MapUtils.isEmpty(basics)){ |
|
|
|
|
throw new ServiceException("暂无可进行导出报表!"); |
|
|
|
|
} |
|
|
|
|
// 创建Excel文件
|
|
|
|
|
HSSFWorkbook hssWB = new HSSFWorkbook(); |
|
|
|
|
// 添加sheet页
|
|
|
|
|
HSSFSheet sheet = hssWB.createSheet("电量报表"); |
|
|
|
|
// 行高
|
|
|
|
|
sheet.setDefaultRowHeight((short) (20 * 25)); |
|
|
|
|
// 列宽
|
|
|
|
|
sheet.setDefaultColumnWidth(15); |
|
|
|
|
// 填充数据
|
|
|
|
|
List<TableHeadVo> tableHeads = JSONObject.parseArray(JSONObject.toJSONString(basics.get("tableHead")),TableHeadVo.class); |
|
|
|
|
List<List<Object>> tableBodys = JSON.parseObject(JSONObject.toJSONString(basics.get("tableDate")), new TypeReference<List<List<Object>>>() {}); |
|
|
|
|
// 表头
|
|
|
|
|
this.setBasicsHeader(hssWB, sheet,tableHeads); |
|
|
|
|
if (!MapUtils.isEmpty(basics)) { |
|
|
|
|
// 数据填充
|
|
|
|
|
this.setBasicsWork(hssWB, sheet, tableBodys); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 下载导出
|
|
|
|
|
StringBuilder filename = new StringBuilder(); |
|
|
|
|
filename.append(sysClient.getDept(deptId).getData().getDeptName()); |
|
|
|
|
if(type == 0){ |
|
|
|
|
filename.append("_电量(").append(time).append(")日报表"); |
|
|
|
|
}else if(type == 1){ |
|
|
|
|
filename.append("_电量(").append(time).append(")月报表"); |
|
|
|
|
}else if(type == 2){ |
|
|
|
|
filename.append("_电量(").append(time).append(")年报表"); |
|
|
|
|
}else{ |
|
|
|
|
filename.append("_电量报表"); |
|
|
|
|
} |
|
|
|
|
// 设置头信息
|
|
|
|
|
response.setCharacterEncoding("UTF-8"); |
|
|
|
|
response.setContentType("application/vnd.ms-excel"); |
|
|
|
|
ServletOutputStream outputStream; |
|
|
|
|
try { |
|
|
|
|
//设置xlsx格式
|
|
|
|
|
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename + ".xls", "UTF-8")); |
|
|
|
|
//创建一个输出流
|
|
|
|
|
outputStream = response.getOutputStream(); |
|
|
|
|
//写入数据
|
|
|
|
|
hssWB.write(outputStream); |
|
|
|
|
// 关闭
|
|
|
|
|
outputStream.close(); |
|
|
|
|
hssWB.close(); |
|
|
|
|
} catch (IOException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 基础报表表头 |
|
|
|
|
* @param hssWB |
|
|
|
|
* @param sheet |
|
|
|
|
* @param tableHeads |
|
|
|
|
*/ |
|
|
|
|
private void setBasicsHeader(HSSFWorkbook hssWB, HSSFSheet sheet, List<TableHeadVo> tableHeads) { |
|
|
|
|
// 第一行
|
|
|
|
|
int size = tableHeads.size(); |
|
|
|
|
int rowIndex = 0; |
|
|
|
|
HSSFRow row = sheet.createRow(rowIndex); |
|
|
|
|
// 首列暂一个单元格,下标从0开始,所以要减2
|
|
|
|
|
this.setTitileStyle(hssWB, row, (size * 2) - 1 - 1 , true); |
|
|
|
|
for (int i = 0; i < size; i++) { |
|
|
|
|
if(i == 0){ |
|
|
|
|
HSSFCell heade_cell = row.getCell(i); |
|
|
|
|
heade_cell.setCellValue(tableHeads.get(i).getTableName()); |
|
|
|
|
CellRangeAddress heade_region = new CellRangeAddress(rowIndex, rowIndex + 1, (short) 0, (short) 0); |
|
|
|
|
sheet.addMergedRegion(heade_region); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
int line = ((i - 1) * 2) + 1; |
|
|
|
|
HSSFCell heade_cell = row.getCell(line); |
|
|
|
|
heade_cell.setCellValue(tableHeads.get(i).getTableName()); |
|
|
|
|
CellRangeAddress heade_region = new CellRangeAddress(rowIndex, rowIndex, (short) line, (short) line + 1); |
|
|
|
|
sheet.addMergedRegion(heade_region); |
|
|
|
|
} |
|
|
|
|
// 第二行
|
|
|
|
|
rowIndex = 1; |
|
|
|
|
HSSFRow heade_row = sheet.createRow(rowIndex); |
|
|
|
|
// 首列暂一个单元格,下标从0开始,所以要减2
|
|
|
|
|
this.setTitileStyle(hssWB, heade_row, (size * 2) - 1 - 1, true); |
|
|
|
|
for (int i = 0; i < size; i++) { |
|
|
|
|
if(tableHeads.get(i).getIsChildren()){ |
|
|
|
|
int line = ((i - 1) * 2) + 1; |
|
|
|
|
HSSFCell heade_cell = heade_row.getCell(line); |
|
|
|
|
heade_cell.setCellValue(tableHeads.get(i).getChildren().get(0)); |
|
|
|
|
|
|
|
|
|
HSSFCell heade_cell_1 = heade_row.getCell(line + 1); |
|
|
|
|
heade_cell_1.setCellValue(tableHeads.get(i).getChildren().get(1)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 基础报表内容填充 |
|
|
|
|
* @param hssWB |
|
|
|
|
* @param sheet |
|
|
|
|
* @param tableBodys |
|
|
|
|
*/ |
|
|
|
|
private void setBasicsWork(HSSFWorkbook hssWB, HSSFSheet sheet, List<List<Object>> tableBodys) { |
|
|
|
|
// 第一行
|
|
|
|
|
int rowIndex = 2; |
|
|
|
|
// 首列暂一个单元格,下标从0开始,所以要减2
|
|
|
|
|
for(List<Object> bodys : tableBodys){ |
|
|
|
|
HSSFRow bodyRow = sheet.createRow(rowIndex); |
|
|
|
|
// 下标从0开始,所以要减1
|
|
|
|
|
this.setTitileStyle(hssWB, bodyRow, bodys.size() - 1, false); |
|
|
|
|
// 内容填充
|
|
|
|
|
for(int i = 0; i < bodys.size() ; i++){ |
|
|
|
|
HSSFCell body_cell = bodyRow.getCell(i); |
|
|
|
|
if(i > 0){ |
|
|
|
|
double value = BigDecimal.valueOf(Double.parseDouble(bodys.get(i).toString())).setScale(2, RoundingMode.HALF_UP).doubleValue(); |
|
|
|
|
if(value >= 0){ |
|
|
|
|
body_cell.setCellValue(value); |
|
|
|
|
} else{ |
|
|
|
|
body_cell.setCellValue("-"); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
body_cell.setCellValue(bodys.get(0).toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
rowIndex++; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 综合报表 |
|
|
|
|
* @param deptId |
|
|
|
|
* @return |
|
|
|
@ -140,8 +296,6 @@ public class ElectricReportServiceImpl implements IElectricReportService {
|
|
|
|
|
Date finish = calendar.getTime(); |
|
|
|
|
calendar.add(Calendar.YEAR,-1); |
|
|
|
|
Date current = calendar.getTime(); |
|
|
|
|
// fixme 随机器模拟数据
|
|
|
|
|
Random random = new Random(); |
|
|
|
|
List<ComprehensiveElectricVo> electrics = new ArrayList<>(); |
|
|
|
|
while (current.compareTo(finish) < 0){ |
|
|
|
|
ComprehensiveElectricVo comprehensive = new ComprehensiveElectricVo(); |
|
|
|
@ -174,8 +328,8 @@ public class ElectricReportServiceImpl implements IElectricReportService {
|
|
|
|
|
calendar.add(Calendar.YEAR,1); |
|
|
|
|
// 电量
|
|
|
|
|
if(CollectionUtil.isNotEmpty(threes)){ |
|
|
|
|
comprehensive.setMonthGenerate(threes.stream().filter(o->o.getStrMonth().contains(currentMon)).mapToDouble(o->o.getGenerate().doubleValue()).sum()); |
|
|
|
|
comprehensive.setLastMonthGenerate(threes.stream().filter(o->o.getStrMonth().contains(lastMon)).mapToDouble(o->o.getGenerate().doubleValue()).sum()); |
|
|
|
|
comprehensive.setMonthGenerate(BigDecimal.valueOf(threes.stream().filter(o->o.getStrMonth().contains(currentMon)).mapToDouble(o->o.getGenerate().doubleValue()).sum() / 10000).setScale(2, RoundingMode.HALF_UP).doubleValue()); |
|
|
|
|
comprehensive.setLastMonthGenerate(BigDecimal.valueOf(threes.stream().filter(o->o.getStrMonth().contains(lastMon)).mapToDouble(o->o.getGenerate().doubleValue()).sum() / 10000).setScale(2, RoundingMode.HALF_UP).doubleValue()); |
|
|
|
|
if(comprehensive.getMonthGenerate() > 0 && comprehensive.getLastMonthGenerate() > 0){ |
|
|
|
|
comprehensive.setLastMonthGenerateRate(BigDecimal.valueOf(comprehensive.getMonthGenerate() / comprehensive.getLastMonthGenerate() * 100).setScale(2, RoundingMode.HALF_UP).doubleValue()); |
|
|
|
|
}else{ |
|
|
|
@ -275,6 +429,346 @@ public class ElectricReportServiceImpl implements IElectricReportService {
|
|
|
|
|
return electrics; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 综合报表导出 |
|
|
|
|
* @param response |
|
|
|
|
* @param deptId |
|
|
|
|
* @param year |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public void comprehensiveExport(HttpServletResponse response, Long deptId, String year) { |
|
|
|
|
// 创建Excel文件
|
|
|
|
|
HSSFWorkbook hssWB = new HSSFWorkbook(); |
|
|
|
|
// 添加sheet页
|
|
|
|
|
HSSFSheet sheet = hssWB.createSheet("综合报表"); |
|
|
|
|
// 行高
|
|
|
|
|
sheet.setDefaultRowHeight((short) (20 * 25)); |
|
|
|
|
// 列宽
|
|
|
|
|
sheet.setDefaultColumnWidth(6); |
|
|
|
|
// 表头
|
|
|
|
|
this.setHeader(hssWB, sheet); |
|
|
|
|
// 填充数据
|
|
|
|
|
List<ComprehensiveElectricVo> comprehensives = this.comprehensive(deptId,year); |
|
|
|
|
if (!CollectionUtil.isEmpty(comprehensives)) { |
|
|
|
|
// 数据填充
|
|
|
|
|
this.setWork(hssWB, sheet, comprehensives); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 下载导出
|
|
|
|
|
String filename = sysClient.getDept(deptId).getData().getDeptName() + "_" + year + "_综合报表"; |
|
|
|
|
// 设置头信息
|
|
|
|
|
response.setCharacterEncoding("UTF-8"); |
|
|
|
|
response.setContentType("application/vnd.ms-excel"); |
|
|
|
|
ServletOutputStream outputStream; |
|
|
|
|
try { |
|
|
|
|
//设置xlsx格式
|
|
|
|
|
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename + ".xls", "UTF-8")); |
|
|
|
|
//创建一个输出流
|
|
|
|
|
outputStream = response.getOutputStream(); |
|
|
|
|
//写入数据
|
|
|
|
|
hssWB.write(outputStream); |
|
|
|
|
// 关闭
|
|
|
|
|
outputStream.close(); |
|
|
|
|
hssWB.close(); |
|
|
|
|
} catch (IOException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 首行表头样式 |
|
|
|
|
* @param hssWB |
|
|
|
|
* @param sheet |
|
|
|
|
*/ |
|
|
|
|
private void setHeader(HSSFWorkbook hssWB, HSSFSheet sheet) { |
|
|
|
|
// 第一行
|
|
|
|
|
HSSFRow fisrtRow = sheet.createRow(0); |
|
|
|
|
this.setTitileStyle(hssWB, fisrtRow, 28, true); |
|
|
|
|
// 第一个单元格...
|
|
|
|
|
HSSFCell headCell = fisrtRow.getCell(0); |
|
|
|
|
headCell.setCellValue("月份"); |
|
|
|
|
HSSFCell headCell1 = fisrtRow.getCell(1); |
|
|
|
|
headCell1.setCellValue("发电量(万kWh)"); |
|
|
|
|
HSSFCell headCell2 = fisrtRow.getCell(13); |
|
|
|
|
headCell2.setCellValue("降雨量(mm)"); |
|
|
|
|
HSSFCell headCell3 = fisrtRow.getCell(21); |
|
|
|
|
headCell3.setCellValue("等效小时"); |
|
|
|
|
// 第一行合并情况
|
|
|
|
|
CellRangeAddress region1 = new CellRangeAddress(0, 1, (short) 0, (short) 0); |
|
|
|
|
CellRangeAddress region2 = new CellRangeAddress(0, 0, (short) 1, (short) 12); |
|
|
|
|
CellRangeAddress region3 = new CellRangeAddress(0, 0, (short) 13, (short) 20); |
|
|
|
|
CellRangeAddress region4 = new CellRangeAddress(0, 0, (short) 21, (short) 28); |
|
|
|
|
sheet.addMergedRegion(region1); |
|
|
|
|
sheet.addMergedRegion(region2); |
|
|
|
|
sheet.addMergedRegion(region3); |
|
|
|
|
sheet.addMergedRegion(region4); |
|
|
|
|
|
|
|
|
|
// 第二行
|
|
|
|
|
HSSFRow secondRow = sheet.createRow(1); |
|
|
|
|
this.setTitileStyle(hssWB, secondRow, 28, true); |
|
|
|
|
|
|
|
|
|
// 第二行第一个单元格
|
|
|
|
|
HSSFCell secondRow_cell = secondRow.getCell(1); |
|
|
|
|
secondRow_cell.setCellValue("本月"); |
|
|
|
|
HSSFCell secondRow_cell_1 = secondRow.getCell(3); |
|
|
|
|
secondRow_cell_1.setCellValue("去年同月"); |
|
|
|
|
HSSFCell secondRow_cell_2 = secondRow.getCell(5); |
|
|
|
|
secondRow_cell_2.setCellValue("月同比"); |
|
|
|
|
HSSFCell secondRow_cell_3 = secondRow.getCell(7); |
|
|
|
|
secondRow_cell_3.setCellValue("本年"); |
|
|
|
|
HSSFCell secondRow_cell_4 = secondRow.getCell(9); |
|
|
|
|
secondRow_cell_4.setCellValue("去年同期"); |
|
|
|
|
HSSFCell secondRow_cell_5 = secondRow.getCell(11); |
|
|
|
|
secondRow_cell_5.setCellValue("年同比"); |
|
|
|
|
HSSFCell secondRow_cell_6 = secondRow.getCell(13); |
|
|
|
|
secondRow_cell_6.setCellValue("本月"); |
|
|
|
|
HSSFCell secondRow_cell_7 = secondRow.getCell(15); |
|
|
|
|
secondRow_cell_7.setCellValue("去年同月"); |
|
|
|
|
HSSFCell secondRow_cell_8 = secondRow.getCell(17); |
|
|
|
|
secondRow_cell_8.setCellValue("本年"); |
|
|
|
|
HSSFCell secondRow_cell_9 = secondRow.getCell(19); |
|
|
|
|
secondRow_cell_9.setCellValue("去年同期"); |
|
|
|
|
HSSFCell secondRow_cell_10 = secondRow.getCell(21); |
|
|
|
|
secondRow_cell_10.setCellValue("本月"); |
|
|
|
|
HSSFCell secondRow_cell_11 = secondRow.getCell(23); |
|
|
|
|
secondRow_cell_11.setCellValue("去年同月"); |
|
|
|
|
HSSFCell secondRow_cell_12 = secondRow.getCell(25); |
|
|
|
|
secondRow_cell_12.setCellValue("本年"); |
|
|
|
|
HSSFCell secondRow_cell_13 = secondRow.getCell(27); |
|
|
|
|
secondRow_cell_13.setCellValue("去年同期"); |
|
|
|
|
|
|
|
|
|
// 第二行合并情况
|
|
|
|
|
// 发电量
|
|
|
|
|
CellRangeAddress second1 = new CellRangeAddress(1, 1, (short) 1, (short) 2); |
|
|
|
|
CellRangeAddress second2 = new CellRangeAddress(1, 1, (short) 3, (short) 4); |
|
|
|
|
CellRangeAddress second3 = new CellRangeAddress(1, 1, (short) 5, (short) 6); |
|
|
|
|
CellRangeAddress second4 = new CellRangeAddress(1, 1, (short) 7, (short) 8); |
|
|
|
|
CellRangeAddress second5 = new CellRangeAddress(1, 1, (short) 9, (short) 10); |
|
|
|
|
CellRangeAddress second6 = new CellRangeAddress(1, 1, (short) 11, (short) 12); |
|
|
|
|
// 降雨量
|
|
|
|
|
CellRangeAddress second7 = new CellRangeAddress(1, 1, (short) 13, (short) 14); |
|
|
|
|
CellRangeAddress second8 = new CellRangeAddress(1, 1, (short) 15, (short) 16); |
|
|
|
|
CellRangeAddress second9 = new CellRangeAddress(1, 1, (short) 17, (short) 18); |
|
|
|
|
CellRangeAddress second10 = new CellRangeAddress(1, 1, (short) 19, (short) 20); |
|
|
|
|
// 等效小时
|
|
|
|
|
CellRangeAddress second11 = new CellRangeAddress(1, 1, (short) 21, (short) 22); |
|
|
|
|
CellRangeAddress second12 = new CellRangeAddress(1, 1, (short) 23, (short) 24); |
|
|
|
|
CellRangeAddress second13 = new CellRangeAddress(1, 1, (short) 25, (short) 26); |
|
|
|
|
CellRangeAddress second14 = new CellRangeAddress(1, 1, (short) 27, (short) 28); |
|
|
|
|
|
|
|
|
|
sheet.addMergedRegion(second1); |
|
|
|
|
sheet.addMergedRegion(second2); |
|
|
|
|
sheet.addMergedRegion(second3); |
|
|
|
|
sheet.addMergedRegion(second4); |
|
|
|
|
sheet.addMergedRegion(second5); |
|
|
|
|
sheet.addMergedRegion(second6); |
|
|
|
|
sheet.addMergedRegion(second7); |
|
|
|
|
sheet.addMergedRegion(second8); |
|
|
|
|
sheet.addMergedRegion(second9); |
|
|
|
|
sheet.addMergedRegion(second10); |
|
|
|
|
sheet.addMergedRegion(second11); |
|
|
|
|
sheet.addMergedRegion(second12); |
|
|
|
|
sheet.addMergedRegion(second13); |
|
|
|
|
sheet.addMergedRegion(second14); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void setWork(HSSFWorkbook hssWB, HSSFSheet sheet, List<ComprehensiveElectricVo> comprehensives) { |
|
|
|
|
int size = comprehensives.size(); |
|
|
|
|
for (int i = 0; i < size; i++) { |
|
|
|
|
int rowIndex = i + 2; |
|
|
|
|
HSSFRow row = sheet.createRow(rowIndex); |
|
|
|
|
this.setTitileStyle(hssWB, row, 28, false); |
|
|
|
|
ComprehensiveElectricVo comprehensive = comprehensives.get(i); |
|
|
|
|
// 月份
|
|
|
|
|
HSSFCell body_cell_0 = row.getCell(0); |
|
|
|
|
body_cell_0.setCellValue(comprehensive.getMonth()); |
|
|
|
|
// 本月
|
|
|
|
|
HSSFCell body_cell_1 = row.getCell(1); |
|
|
|
|
if(comprehensive.getMonthGenerate() >= 0){ |
|
|
|
|
body_cell_1.setCellValue(comprehensive.getMonthGenerate()); |
|
|
|
|
}else{ |
|
|
|
|
body_cell_1.setCellValue("-"); |
|
|
|
|
} |
|
|
|
|
// 去年同月
|
|
|
|
|
HSSFCell body_cell_2 = row.getCell(3); |
|
|
|
|
if(comprehensive.getLastMonthGenerate() >= 0){ |
|
|
|
|
body_cell_2.setCellValue(comprehensive.getLastMonthGenerate()); |
|
|
|
|
}else{ |
|
|
|
|
body_cell_2.setCellValue("-"); |
|
|
|
|
} |
|
|
|
|
// 月同比
|
|
|
|
|
HSSFCell body_cell_3 = row.getCell(5); |
|
|
|
|
if(comprehensive.getLastMonthGenerateRate() >= 0){ |
|
|
|
|
body_cell_3.setCellValue(comprehensive.getLastMonthGenerateRate()); |
|
|
|
|
}else{ |
|
|
|
|
body_cell_3.setCellValue("-"); |
|
|
|
|
} |
|
|
|
|
// 本年
|
|
|
|
|
HSSFCell body_cell_4 = row.getCell(7); |
|
|
|
|
if(comprehensive.getYearGenerate() >= 0){ |
|
|
|
|
body_cell_4.setCellValue(comprehensive.getYearGenerate()); |
|
|
|
|
}else{ |
|
|
|
|
body_cell_4.setCellValue("-"); |
|
|
|
|
} |
|
|
|
|
// 去年同期
|
|
|
|
|
HSSFCell body_cell_5 = row.getCell(9); |
|
|
|
|
if(comprehensive.getLastYearGenerate() >= 0){ |
|
|
|
|
body_cell_5.setCellValue(comprehensive.getLastYearGenerate()); |
|
|
|
|
}else{ |
|
|
|
|
body_cell_5.setCellValue("-"); |
|
|
|
|
} |
|
|
|
|
// 年同比
|
|
|
|
|
HSSFCell body_cell_6 = row.getCell(11); |
|
|
|
|
if(comprehensive.getLastYearGenerateRate() >= 0){ |
|
|
|
|
body_cell_6.setCellValue(comprehensive.getLastYearGenerateRate()); |
|
|
|
|
}else{ |
|
|
|
|
body_cell_6.setCellValue("-"); |
|
|
|
|
} |
|
|
|
|
// 本月降雨
|
|
|
|
|
HSSFCell body_cell_7 = row.getCell(13); |
|
|
|
|
if(comprehensive.getMonthRain() >= 0){ |
|
|
|
|
body_cell_7.setCellValue(comprehensive.getMonthRain()); |
|
|
|
|
}else{ |
|
|
|
|
body_cell_7.setCellValue("-"); |
|
|
|
|
} |
|
|
|
|
// 去年同月降雨
|
|
|
|
|
HSSFCell body_cell_8 = row.getCell(15); |
|
|
|
|
if(comprehensive.getMonthRain() >= 0){ |
|
|
|
|
body_cell_8.setCellValue(comprehensive.getLastMonthRain()); |
|
|
|
|
}else{ |
|
|
|
|
body_cell_8.setCellValue("-"); |
|
|
|
|
} |
|
|
|
|
// 本年降雨
|
|
|
|
|
HSSFCell body_cell_9 = row.getCell(17); |
|
|
|
|
if(comprehensive.getYearRain() >= 0){ |
|
|
|
|
body_cell_9.setCellValue(comprehensive.getYearRain()); |
|
|
|
|
}else{ |
|
|
|
|
body_cell_9.setCellValue("-"); |
|
|
|
|
} |
|
|
|
|
// 去年同期降雨
|
|
|
|
|
HSSFCell body_cell_10 = row.getCell(19); |
|
|
|
|
if(comprehensive.getYearRain() >= 0){ |
|
|
|
|
body_cell_10.setCellValue(comprehensive.getLastYearRain()); |
|
|
|
|
}else{ |
|
|
|
|
body_cell_10.setCellValue("-"); |
|
|
|
|
} |
|
|
|
|
// 本月等效小时
|
|
|
|
|
HSSFCell body_cell_11 = row.getCell(21); |
|
|
|
|
if(comprehensive.getMonthEquivalent() >= 0){ |
|
|
|
|
body_cell_11.setCellValue(comprehensive.getMonthEquivalent()); |
|
|
|
|
}else{ |
|
|
|
|
body_cell_11.setCellValue("-"); |
|
|
|
|
} |
|
|
|
|
// 去年同月等效小时
|
|
|
|
|
HSSFCell body_cell_12 = row.getCell(23); |
|
|
|
|
if(comprehensive.getLastMonthEquivalent() >= 0){ |
|
|
|
|
body_cell_12.setCellValue(comprehensive.getLastMonthEquivalent()); |
|
|
|
|
}else{ |
|
|
|
|
body_cell_12.setCellValue("-"); |
|
|
|
|
} |
|
|
|
|
// 本年等效小时
|
|
|
|
|
HSSFCell body_cell_13 = row.getCell(25); |
|
|
|
|
if(comprehensive.getYearEquivalent() >= 0){ |
|
|
|
|
body_cell_13.setCellValue(comprehensive.getYearEquivalent()); |
|
|
|
|
}else{ |
|
|
|
|
body_cell_13.setCellValue("-"); |
|
|
|
|
} |
|
|
|
|
// 去年同期等效小时
|
|
|
|
|
HSSFCell body_cell_14 = row.getCell(27); |
|
|
|
|
if(comprehensive.getLastYearEquivalent() >= 0){ |
|
|
|
|
body_cell_14.setCellValue(comprehensive.getLastYearEquivalent()); |
|
|
|
|
}else{ |
|
|
|
|
body_cell_14.setCellValue("-"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
CellRangeAddress body1 = new CellRangeAddress(rowIndex, rowIndex, (short) 1, (short) 2); |
|
|
|
|
CellRangeAddress body2 = new CellRangeAddress(rowIndex, rowIndex, (short) 3, (short) 4); |
|
|
|
|
CellRangeAddress body3 = new CellRangeAddress(rowIndex, rowIndex, (short) 5, (short) 6); |
|
|
|
|
CellRangeAddress body4 = new CellRangeAddress(rowIndex, rowIndex, (short) 7, (short) 8); |
|
|
|
|
CellRangeAddress body5 = new CellRangeAddress(rowIndex, rowIndex, (short) 9, (short) 10); |
|
|
|
|
CellRangeAddress body6 = new CellRangeAddress(rowIndex, rowIndex, (short) 11, (short) 12); |
|
|
|
|
CellRangeAddress body7 = new CellRangeAddress(rowIndex, rowIndex, (short) 13, (short) 14); |
|
|
|
|
CellRangeAddress body8 = new CellRangeAddress(rowIndex, rowIndex, (short) 15, (short) 16); |
|
|
|
|
CellRangeAddress body9 = new CellRangeAddress(rowIndex, rowIndex, (short) 17, (short) 18); |
|
|
|
|
CellRangeAddress body10 = new CellRangeAddress(rowIndex, rowIndex, (short) 19, (short) 20); |
|
|
|
|
CellRangeAddress body11 = new CellRangeAddress(rowIndex, rowIndex, (short) 21, (short) 22); |
|
|
|
|
CellRangeAddress body12 = new CellRangeAddress(rowIndex, rowIndex, (short) 23, (short) 24); |
|
|
|
|
CellRangeAddress body13 = new CellRangeAddress(rowIndex, rowIndex, (short) 25, (short) 26); |
|
|
|
|
CellRangeAddress body14 = new CellRangeAddress(rowIndex, rowIndex, (short) 27, (short) 28); |
|
|
|
|
|
|
|
|
|
sheet.addMergedRegion(body1); |
|
|
|
|
sheet.addMergedRegion(body2); |
|
|
|
|
sheet.addMergedRegion(body3); |
|
|
|
|
sheet.addMergedRegion(body4); |
|
|
|
|
sheet.addMergedRegion(body5); |
|
|
|
|
sheet.addMergedRegion(body6); |
|
|
|
|
sheet.addMergedRegion(body7); |
|
|
|
|
sheet.addMergedRegion(body8); |
|
|
|
|
sheet.addMergedRegion(body9); |
|
|
|
|
sheet.addMergedRegion(body10); |
|
|
|
|
sheet.addMergedRegion(body11); |
|
|
|
|
sheet.addMergedRegion(body12); |
|
|
|
|
sheet.addMergedRegion(body13); |
|
|
|
|
sheet.addMergedRegion(body14); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 设置Titile单元格样式 |
|
|
|
|
* |
|
|
|
|
* @param hssWB |
|
|
|
|
* @param row |
|
|
|
|
* @param len |
|
|
|
|
*/ |
|
|
|
|
private void setTitileStyle(HSSFWorkbook hssWB, HSSFRow row, int len, boolean isHead) { |
|
|
|
|
HSSFCellStyle cellStyle = getHeadStyle(hssWB, isHead); |
|
|
|
|
for (int i = 0; i <= len; i++) { |
|
|
|
|
HSSFCell hssfcell = row.createCell(i); |
|
|
|
|
hssfcell.setCellStyle(cellStyle); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 设置表头样式 |
|
|
|
|
* |
|
|
|
|
* @param hssWB |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private HSSFCellStyle getHeadStyle(HSSFWorkbook hssWB, boolean isHead) { |
|
|
|
|
HSSFCellStyle headStyle = hssWB.createCellStyle(); |
|
|
|
|
//边框
|
|
|
|
|
headStyle.setBorderLeft(BorderStyle.THIN); |
|
|
|
|
headStyle.setBorderRight(BorderStyle.THIN); |
|
|
|
|
headStyle.setBorderTop(BorderStyle.THIN); |
|
|
|
|
headStyle.setBorderBottom(BorderStyle.THIN); |
|
|
|
|
//居中:
|
|
|
|
|
headStyle.setAlignment(HorizontalAlignment.CENTER); |
|
|
|
|
// 垂直居中
|
|
|
|
|
headStyle.setVerticalAlignment(VerticalAlignment.CENTER); |
|
|
|
|
//字体:
|
|
|
|
|
HSSFFont font = hssWB.createFont(); |
|
|
|
|
font.setFontName("黑体"); |
|
|
|
|
if (isHead) { |
|
|
|
|
//设置字体大小
|
|
|
|
|
font.setFontHeightInPoints((short) 12); |
|
|
|
|
//背景颜色
|
|
|
|
|
headStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); |
|
|
|
|
headStyle.setFillForegroundColor(HSSFColor.HSSFColorPredefined.GREY_25_PERCENT.getIndex()); |
|
|
|
|
} else { |
|
|
|
|
//设置字体大小
|
|
|
|
|
font.setFontHeightInPoints((short) 8); |
|
|
|
|
//背景颜色
|
|
|
|
|
headStyle.setFillPattern(FillPatternType.NO_FILL); |
|
|
|
|
headStyle.setFillForegroundColor(HSSFColor.HSSFColorPredefined.WHITE.getIndex()); |
|
|
|
|
} |
|
|
|
|
//字体格式
|
|
|
|
|
headStyle.setFont(font); |
|
|
|
|
return headStyle; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 站点降雨量查询 |
|
|
|
|
* @param stationId |
|
|
|
@ -333,7 +827,7 @@ public class ElectricReportServiceImpl implements IElectricReportService {
|
|
|
|
|
// 查询月数据
|
|
|
|
|
List<ThirtyEntity> thirtys = thirtyService.list(Wrappers.<ThirtyEntity>lambdaQuery() |
|
|
|
|
//.isNotNull(ThirtyEntity::getDeviceCode)
|
|
|
|
|
.in(ThirtyEntity::getStationId,stations.getData().stream().map(StationEntity::getCode).collect(Collectors.toList())) |
|
|
|
|
.in(ThirtyEntity::getStationId,stations.getData().stream().filter(station->deptIds.contains(station.getRefDept())).map(StationEntity::getCode).collect(Collectors.toList())) |
|
|
|
|
.like(ThirtyEntity::getStrDay,time) |
|
|
|
|
); |
|
|
|
|
if(CollectionUtil.isEmpty(thirtys)){ |
|
|
|
@ -382,8 +876,9 @@ public class ElectricReportServiceImpl implements IElectricReportService {
|
|
|
|
|
item.add(-1.0); |
|
|
|
|
item.add(-1.0); |
|
|
|
|
}); |
|
|
|
|
calendar.add(Calendar.HOUR_OF_DAY,1); |
|
|
|
|
calendar.add(Calendar.DAY_OF_MONTH,1); |
|
|
|
|
start = calendar.getTime(); |
|
|
|
|
tableDate.add(item); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -405,7 +900,12 @@ public class ElectricReportServiceImpl implements IElectricReportService {
|
|
|
|
|
item.add("合计"); |
|
|
|
|
for(int i = 1 ; i < tableDate.get(0).size() ; i++){ |
|
|
|
|
int index = i; |
|
|
|
|
item.add(tableDate.stream().mapToDouble(o-> Double.parseDouble(o.get(index).toString())).sum()); |
|
|
|
|
item.add(tableDate.stream().mapToDouble(o-> { |
|
|
|
|
if(Double.parseDouble(o.get(index).toString()) >= 0){ |
|
|
|
|
return Double.parseDouble(o.get(index).toString()); |
|
|
|
|
} |
|
|
|
|
return 0.0; |
|
|
|
|
}).sum()); |
|
|
|
|
} |
|
|
|
|
tableDate.add(item); |
|
|
|
|
result.put("tableDate",tableDate); |
|
|
|
@ -415,7 +915,7 @@ public class ElectricReportServiceImpl implements IElectricReportService {
|
|
|
|
|
// 查询月数据
|
|
|
|
|
List<ThreeEntity> threes = threeService.list(Wrappers.<ThreeEntity>lambdaQuery() |
|
|
|
|
//.isNotNull(ThreeEntity::getDeviceCode)
|
|
|
|
|
.in(ThreeEntity::getStationId,stations.getData().stream().map(StationEntity::getCode).collect(Collectors.toList())) |
|
|
|
|
.in(ThreeEntity::getStationId,stations.getData().stream().filter(station->deptIds.contains(station.getRefDept())).map(StationEntity::getCode).collect(Collectors.toList())) |
|
|
|
|
.like(ThreeEntity::getStrMonth,time) |
|
|
|
|
); |
|
|
|
|
if(CollectionUtil.isEmpty(threes)){ |
|
|
|
@ -456,6 +956,19 @@ public class ElectricReportServiceImpl implements IElectricReportService {
|
|
|
|
|
List<Object> item = new ArrayList<>(); |
|
|
|
|
String mon = DateUtil.format(start,"yyyy-MM"); |
|
|
|
|
item.add(start.getMonth() + 1 + "月"); |
|
|
|
|
if(start.compareTo(new Date()) > 0){ |
|
|
|
|
item.add(-1.0); |
|
|
|
|
item.add(-1.0); |
|
|
|
|
group.entrySet().stream().sorted(Map.Entry. |
|
|
|
|
comparingByKey()).forEach(entry->{ |
|
|
|
|
item.add(-1.0); |
|
|
|
|
item.add(-1.0); |
|
|
|
|
}); |
|
|
|
|
calendar.add(Calendar.MONTH,1); |
|
|
|
|
start = calendar.getTime(); |
|
|
|
|
tableDate.add(item); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
// 总计:有功、无功
|
|
|
|
|
item.add(threes.stream().filter(three -> three.getStrMonth().contains(mon)).mapToDouble(o->o.getGenerate().doubleValue()).sum()); |
|
|
|
|
item.add(threes.stream().filter(three -> three.getStrMonth().contains(mon)).mapToDouble(o->o.getReactiveGenerate().doubleValue()).sum()); |
|
|
|
@ -474,7 +987,12 @@ public class ElectricReportServiceImpl implements IElectricReportService {
|
|
|
|
|
item.add("合计"); |
|
|
|
|
for(int i = 1 ; i < tableDate.get(0).size() ; i++){ |
|
|
|
|
int index = i; |
|
|
|
|
item.add(tableDate.stream().mapToDouble(o-> Double.parseDouble(o.get(index).toString())).sum()); |
|
|
|
|
item.add(tableDate.stream().mapToDouble(o-> { |
|
|
|
|
if(Double.parseDouble(o.get(index).toString()) >= 0){ |
|
|
|
|
return Double.parseDouble(o.get(index).toString()); |
|
|
|
|
} |
|
|
|
|
return 0.0; |
|
|
|
|
}).sum()); |
|
|
|
|
} |
|
|
|
|
tableDate.add(item); |
|
|
|
|
result.put("tableDate",tableDate); |
|
|
|
@ -533,7 +1051,7 @@ public class ElectricReportServiceImpl implements IElectricReportService {
|
|
|
|
|
if(CollectionUtil.isEmpty(childs)){ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
List<String> codes = stations.getData().stream().filter(o-> childs.contains(o.getRefDept()) && ObjectUtil.isNotEmpty(o.getType()) && o.getType().equals(0)).map(StationEntity::getCode).collect(Collectors.toList()); |
|
|
|
|
List<String> codes = stations.getData().stream().filter(o-> childs.contains(o.getRefDept())).map(StationEntity::getCode).collect(Collectors.toList()); |
|
|
|
|
if(CollectionUtil.isEmpty(codes)){ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
@ -564,8 +1082,9 @@ public class ElectricReportServiceImpl implements IElectricReportService {
|
|
|
|
|
item.add(-1.0); |
|
|
|
|
item.add(-1.0); |
|
|
|
|
}); |
|
|
|
|
calendar.add(Calendar.HOUR_OF_DAY,1); |
|
|
|
|
calendar.add(Calendar.DAY_OF_MONTH,1); |
|
|
|
|
start = calendar.getTime(); |
|
|
|
|
tableDate.add(item); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -598,7 +1117,12 @@ public class ElectricReportServiceImpl implements IElectricReportService {
|
|
|
|
|
item.add("合计"); |
|
|
|
|
for(int i = 1 ; i < tableDate.get(0).size() ; i++){ |
|
|
|
|
int index = i; |
|
|
|
|
item.add(tableDate.stream().mapToDouble(o-> Double.parseDouble(o.get(index).toString())).sum()); |
|
|
|
|
item.add(tableDate.stream().mapToDouble(o-> { |
|
|
|
|
if(Double.parseDouble(o.get(index).toString()) >= 0){ |
|
|
|
|
return Double.parseDouble(o.get(index).toString()); |
|
|
|
|
} |
|
|
|
|
return 0.0; |
|
|
|
|
}).sum()); |
|
|
|
|
} |
|
|
|
|
tableDate.add(item); |
|
|
|
|
result.put("tableDate",tableDate); |
|
|
|
@ -655,6 +1179,19 @@ public class ElectricReportServiceImpl implements IElectricReportService {
|
|
|
|
|
List<Object> item = new ArrayList<>(); |
|
|
|
|
String mon = DateUtil.format(start,"yyyy-MM"); |
|
|
|
|
item.add(start.getMonth() + 1 + "月"); |
|
|
|
|
if(start.compareTo(new Date()) > 0){ |
|
|
|
|
item.add(-1.0); |
|
|
|
|
item.add(-1.0); |
|
|
|
|
areas.stream().sorted(Comparator.comparing(Dept::getDeptName)).forEach(area->{ |
|
|
|
|
item.add(-1.0); |
|
|
|
|
item.add(-1.0); |
|
|
|
|
}); |
|
|
|
|
calendar.add(Calendar.MONTH,1); |
|
|
|
|
start = calendar.getTime(); |
|
|
|
|
tableDate.add(item); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 总计:有功、无功
|
|
|
|
|
item.add(threes.stream().filter(three -> three.getStrMonth().contains(mon)).mapToDouble(o->o.getGenerate().doubleValue()).sum()); |
|
|
|
|
item.add(threes.stream().filter(three -> three.getStrMonth().contains(mon)).mapToDouble(o->o.getReactiveGenerate().doubleValue()).sum()); |
|
|
|
@ -680,7 +1217,12 @@ public class ElectricReportServiceImpl implements IElectricReportService {
|
|
|
|
|
item.add("合计"); |
|
|
|
|
for(int i = 1 ; i < tableDate.get(0).size() ; i++){ |
|
|
|
|
int index = i; |
|
|
|
|
item.add(tableDate.stream().mapToDouble(o-> Double.parseDouble(o.get(index).toString())).sum()); |
|
|
|
|
item.add(tableDate.stream().mapToDouble(o-> { |
|
|
|
|
if(Double.parseDouble(o.get(index).toString()) >= 0){ |
|
|
|
|
return Double.parseDouble(o.get(index).toString()); |
|
|
|
|
} |
|
|
|
|
return 0.0; |
|
|
|
|
}).sum()); |
|
|
|
|
} |
|
|
|
|
tableDate.add(item); |
|
|
|
|
result.put("tableDate",tableDate); |
|
|
|
@ -761,6 +1303,7 @@ public class ElectricReportServiceImpl implements IElectricReportService {
|
|
|
|
|
}); |
|
|
|
|
calendar.add(Calendar.HOUR_OF_DAY,1); |
|
|
|
|
start = calendar.getTime(); |
|
|
|
|
tableDate.add(item); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
// 总计:有功、无功
|
|
|
|
@ -781,7 +1324,12 @@ public class ElectricReportServiceImpl implements IElectricReportService {
|
|
|
|
|
item.add("合计"); |
|
|
|
|
for(int i = 1 ; i < tableDate.get(0).size() ; i++){ |
|
|
|
|
int index = i; |
|
|
|
|
item.add(tableDate.stream().mapToDouble(o-> Double.parseDouble(o.get(index).toString())).sum()); |
|
|
|
|
item.add(tableDate.stream().mapToDouble(o-> { |
|
|
|
|
if(Double.parseDouble(o.get(index).toString()) >= 0){ |
|
|
|
|
return Double.parseDouble(o.get(index).toString()); |
|
|
|
|
} |
|
|
|
|
return 0.0; |
|
|
|
|
}).sum()); |
|
|
|
|
} |
|
|
|
|
tableDate.add(item); |
|
|
|
|
result.put("tableDate",tableDate); |
|
|
|
@ -832,6 +1380,20 @@ public class ElectricReportServiceImpl implements IElectricReportService {
|
|
|
|
|
List<Object> item = new ArrayList<>(); |
|
|
|
|
String day = DateUtil.format(start,DateUtil.PATTERN_DATE); |
|
|
|
|
item.add(start.getDate() + "日"); |
|
|
|
|
if(start.compareTo(new Date()) > 0){ |
|
|
|
|
item.add(-1.0); |
|
|
|
|
item.add(-1.0); |
|
|
|
|
group.entrySet().stream().sorted(Map.Entry. |
|
|
|
|
comparingByKey()).forEach(entry->{ |
|
|
|
|
item.add(-1.0); |
|
|
|
|
item.add(-1.0); |
|
|
|
|
}); |
|
|
|
|
calendar.add(Calendar.DAY_OF_MONTH,1); |
|
|
|
|
start = calendar.getTime(); |
|
|
|
|
tableDate.add(item); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 总计:有功、无功
|
|
|
|
|
item.add(thirtys.stream().filter(thirty -> thirty.getStrDay().contains(day)).mapToDouble(o->o.getGenerate().doubleValue()).sum()); |
|
|
|
|
item.add(thirtys.stream().filter(thirty -> thirty.getStrDay().contains(day)).mapToDouble(o->o.getReactiveGenerate().doubleValue()).sum()); |
|
|
|
@ -851,7 +1413,12 @@ public class ElectricReportServiceImpl implements IElectricReportService {
|
|
|
|
|
item.add("合计"); |
|
|
|
|
for(int i = 1 ; i < tableDate.get(0).size() ; i++){ |
|
|
|
|
int index = i; |
|
|
|
|
item.add(tableDate.stream().mapToDouble(o-> Double.parseDouble(o.get(index).toString())).sum()); |
|
|
|
|
item.add(tableDate.stream().mapToDouble(o-> { |
|
|
|
|
if(Double.parseDouble(o.get(index).toString()) >= 0){ |
|
|
|
|
return Double.parseDouble(o.get(index).toString()); |
|
|
|
|
} |
|
|
|
|
return 0.0; |
|
|
|
|
}).sum()); |
|
|
|
|
} |
|
|
|
|
tableDate.add(item); |
|
|
|
|
result.put("tableDate",tableDate); |
|
|
|
@ -902,6 +1469,19 @@ public class ElectricReportServiceImpl implements IElectricReportService {
|
|
|
|
|
List<Object> item = new ArrayList<>(); |
|
|
|
|
String mon = DateUtil.format(start,"yyyy-MM"); |
|
|
|
|
item.add(start.getMonth() + 1 + "月"); |
|
|
|
|
if(start.compareTo(new Date()) > 0){ |
|
|
|
|
item.add(-1.0); |
|
|
|
|
item.add(-1.0); |
|
|
|
|
group.entrySet().stream().sorted(Map.Entry. |
|
|
|
|
comparingByKey()).forEach(entry->{ |
|
|
|
|
item.add(-1.0); |
|
|
|
|
item.add(-1.0); |
|
|
|
|
}); |
|
|
|
|
calendar.add(Calendar.MONTH,1); |
|
|
|
|
start = calendar.getTime(); |
|
|
|
|
tableDate.add(item); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
// 总计:有功、无功
|
|
|
|
|
item.add(threes.stream().filter(three -> three.getStrMonth().contains(mon)).mapToDouble(o->o.getGenerate().doubleValue()).sum()); |
|
|
|
|
item.add(threes.stream().filter(three -> three.getStrMonth().contains(mon)).mapToDouble(o->o.getReactiveGenerate().doubleValue()).sum()); |
|
|
|
@ -921,7 +1501,12 @@ public class ElectricReportServiceImpl implements IElectricReportService {
|
|
|
|
|
item.add("合计"); |
|
|
|
|
for(int i = 1 ; i < tableDate.get(0).size() ; i++){ |
|
|
|
|
int index = i; |
|
|
|
|
item.add(tableDate.stream().mapToDouble(o-> Double.parseDouble(o.get(index).toString())).sum()); |
|
|
|
|
item.add(tableDate.stream().mapToDouble(o-> { |
|
|
|
|
if(Double.parseDouble(o.get(index).toString()) >= 0){ |
|
|
|
|
return Double.parseDouble(o.get(index).toString()); |
|
|
|
|
} |
|
|
|
|
return 0.0; |
|
|
|
|
}).sum()); |
|
|
|
|
} |
|
|
|
|
tableDate.add(item); |
|
|
|
|
result.put("tableDate",tableDate); |
|
|
|
@ -1014,25 +1599,65 @@ public class ElectricReportServiceImpl implements IElectricReportService {
|
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public Map<String, Object> run(RunParamVo param) { |
|
|
|
|
public Map<String,Object> run(RunParamVo param) { |
|
|
|
|
// 设备参数校验
|
|
|
|
|
if(CollectionUtil.isEmpty(param.getDeviceSignages())){ |
|
|
|
|
return new HashMap<>(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 查询站点
|
|
|
|
|
StationEntity query = new StationEntity(); |
|
|
|
|
query.setRefDept(param.getDeptId()); |
|
|
|
|
R<StationEntity> station = stationClient.getStationByCodeOrRedDept(query); |
|
|
|
|
if(!station.isSuccess() || ObjectUtil.isEmpty(station.getData())){ |
|
|
|
|
if(CollectionUtil.isEmpty(param.getSignages()) || StringUtils.isEmpty(param.getTime())){ |
|
|
|
|
return new HashMap<>(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 开始时间、结束时间
|
|
|
|
|
Date start = DateUtil.parse(param.getTime() + " 00:00:00",DateUtil.PATTERN_DATETIME); |
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
calendar.setTime(start); |
|
|
|
|
Date end = DateUtil.parse(param.getTime() + " 23:59:59",DateUtil.PATTERN_DATETIME); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
|
HisFacSlicerDataDTO facSlicer = new HisFacSlicerDataDTO(); |
|
|
|
|
List<String> attrIds = param.getSignages().stream().map(RunParamSignageVo::getSignage).collect(Collectors.toList()); |
|
|
|
|
facSlicer.setFacDeivceAttrIds(attrIds); |
|
|
|
|
facSlicer.setAccessRules(0); |
|
|
|
|
facSlicer.setSaveTimeType(2); |
|
|
|
|
facSlicer.setBeginTime(LocalDateTime.ofInstant(start.toInstant(), ZoneId.systemDefault())); |
|
|
|
|
facSlicer.setFinishTime(LocalDateTime.ofInstant(end.toInstant(), ZoneId.systemDefault())); |
|
|
|
|
facSlicer.setTimeInterval(1); |
|
|
|
|
facSlicer.setIsPage(false); |
|
|
|
|
facSlicer.setIsFill(false); |
|
|
|
|
facSlicer.setCurrent(1); |
|
|
|
|
facSlicer.setPageSize(1000); |
|
|
|
|
Result<Map<String, Object>> result = deviceDataClient.facHisDataSearch(facSlicer); |
|
|
|
|
if(!result.isSuccess()){ |
|
|
|
|
return new HashMap<>(); |
|
|
|
|
} |
|
|
|
|
// 头部
|
|
|
|
|
Map<String,Object> table = new HashMap<>(); |
|
|
|
|
List<Object> tableHeads = new ArrayList<>(); |
|
|
|
|
tableHeads.add("时间"); |
|
|
|
|
param.getSignages().forEach(signage -> tableHeads.add(signage.getSignagesName())); |
|
|
|
|
table.put("tableHead",tableHeads); |
|
|
|
|
// 内容
|
|
|
|
|
List<Object> tableDates = new ArrayList<>(); |
|
|
|
|
while (start.compareTo(end) < 0){ |
|
|
|
|
List<String> items = new ArrayList<>(); |
|
|
|
|
// 时间
|
|
|
|
|
String time = DateUtil.format(start,DateUtil.PATTERN_DATETIME); |
|
|
|
|
items.add(time); |
|
|
|
|
// 数据遍历
|
|
|
|
|
param.getSignages().forEach(signage -> { |
|
|
|
|
if (MapUtils.isEmpty(result.getData()) || !result.getData().containsKey(signage.getSignage())) { |
|
|
|
|
items.add("-"); |
|
|
|
|
}else{ |
|
|
|
|
List<RunResultValueVo> values = JSONObject.parseArray(JSONObject.toJSONString(result.getData().get(signage.getSignage())), RunResultValueVo.class); |
|
|
|
|
if (CollectionUtil.isEmpty(values)) { |
|
|
|
|
items.add("-"); |
|
|
|
|
}else{ |
|
|
|
|
items.add(String.valueOf(values.stream().filter(o -> StringUtils.isNotEmpty(o.getVal()) && o.getTs().contains(time)).mapToDouble(o -> Double.parseDouble(o.getVal())).sum())); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
// 填充一行内容
|
|
|
|
|
tableDates.add(items); |
|
|
|
|
calendar.add(Calendar.HOUR_OF_DAY,1); |
|
|
|
|
start = calendar.getTime(); |
|
|
|
|
} |
|
|
|
|
table.put("tableDate",tableDates); |
|
|
|
|
return table; |
|
|
|
|
} |
|
|
|
|
} |