Browse Source

#运行报表

zhongwei
yang_shj 2 months ago
parent
commit
33e51df49d
  1. 2
      hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/constants/AlarmConstants.java
  2. 8
      hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/vo/AlarmHistoryVo.java
  3. 3
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/RunDeviceSignagesVo.java
  4. 20
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/RunParamSignageVo.java
  5. 8
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/RunParamVo.java
  6. 8
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/RunResultValueVo.java
  7. 6
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/FrameRecordEntity.java
  8. 27
      hzims-service/equipment/src/main/java/com/hnac/hzims/electric/controller/ElectricReportController.java
  9. 8
      hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/IElectricReportService.java
  10. 691
      hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/impl/ElectricReportServiceImpl.java
  11. 1
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/mapper/AlarmHandleMapper.xml
  12. 20
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/mapper/AlarmMapper.xml
  13. 16
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java
  14. 2
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/GenerationScheduledTask.java
  15. 8
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ShowScheduledTask.java
  16. 2
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/StartStopScheduledTask.java
  17. 1
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java
  18. 5
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/StartStopDurationServiceImpl.java
  19. 2
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/business/impl/PhenomenonServiceImpl.java
  20. 6
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ObtainGenerationServiceImpl.java
  21. 5
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java
  22. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/TargetController.java
  23. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java
  24. 28
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/impl/HydroelectricServiceImpl.java

2
hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/constants/AlarmConstants.java

@ -70,5 +70,5 @@ public interface AlarmConstants {
String FDP_INVALID_ZOME_STATUS = "1";
List<Integer> WHOLE_ALARM_TYPE = Arrays.asList(AlarmConstants.WARNING,AlarmConstants.FAULT,AlarmConstants.OFFSIDE,AlarmConstants.INTERRUPT,AlarmConstants.ABNORMAL,AlarmConstants.EARLY,AlarmConstants.START,AlarmConstants.STOP);
List<Integer> WHOLE_ALARM_TYPE = Arrays.asList(AlarmConstants.WARNING,AlarmConstants.FAULT,AlarmConstants.OFFSIDE,AlarmConstants.INTERRUPT,AlarmConstants.ABNORMAL,AlarmConstants.EARLY,AlarmConstants.ONE_LEVEL,AlarmConstants.TWO_LEVEL,AlarmConstants.THREE_LEVEL);
}

8
hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/vo/AlarmHistoryVo.java

@ -23,17 +23,23 @@ public class AlarmHistoryVo {
@ApiModelProperty(value = "站点名称")
private String stationName;
@ApiModelProperty(value = "告警Id")
private String alarmId;
@ApiModelProperty(value = "告警类型")
private Integer alarmType;
@ApiModelProperty(value = "告警内容")
private String alarmContext;
@ApiModelProperty(value = "处理方式")
private Long handleWay;
@ApiModelProperty("处理人")
private Long handleUser;
@ApiModelProperty("处理人名称")
private Long handleUserName;
private String handleUserName;
@ApiModelProperty("处理附件地址")
private String filePath;

3
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/RunDeviceSignagesVo.java

@ -12,9 +12,6 @@ import java.util.List;
@Data
public class RunDeviceSignagesVo {
@ApiModelProperty(value = "设备编号")
private String deviceCode;
@ApiModelProperty(value = "属性标识")
private List<String> signages;
}

20
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/RunParamSignageVo.java

@ -0,0 +1,20 @@
package com.hnac.hzims.electric.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author ysj
*/
@Data
public class RunParamSignageVo {
@ApiModelProperty(value = "属性标识")
private String signage;
@ApiModelProperty(value = "属性名称")
private String signagesName;
}

8
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/RunParamVo.java

@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
import java.util.Map;
/**
@ -15,9 +16,6 @@ public class RunParamVo {
@ApiModelProperty(value = "时间 :yyyy-MM-dd")
private String time;
@ApiModelProperty(value = "机构Id")
private Long deptId;
@ApiModelProperty(value = "机构Id")
private List<RunDeviceSignagesVo> deviceSignages;
@ApiModelProperty(value = "属性标识数组")
private List<RunParamSignageVo> signages;
}

8
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/RunResultVo.java → hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/RunResultValueVo.java

@ -3,14 +3,18 @@ package com.hnac.hzims.electric.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Map;
/**
* @author ysj
*/
@Data
public class RunResultVo {
public class RunResultValueVo {
@ApiModelProperty(value = "时间")
private String time;
private String ts;
@ApiModelProperty(value = "值")
private String val;
}

6
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/FrameRecordEntity.java

@ -31,4 +31,10 @@ public class FrameRecordEntity extends TenantEntity {
@ApiModelProperty("实时画面地址")
private String frameAddress;
@ApiModelProperty("区分站点V3、v4")
private String type;
@ApiModelProperty("画面来源: 0云组态 、1 hz3000v3.0、 2 hz3000v4.0")
private Integer picSource;
}

27
hzims-service/equipment/src/main/java/com/hnac/hzims/electric/controller/ElectricReportController.java

@ -4,7 +4,6 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.electric.service.IElectricReportService;
import com.hnac.hzims.electric.vo.ComprehensiveElectricVo;
import com.hnac.hzims.electric.vo.RunParamVo;
import com.hnac.hzims.electric.vo.RunResultVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
@ -12,6 +11,7 @@ import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
@ -31,20 +31,39 @@ public class ElectricReportController extends BladeController {
@ApiOperation(value = "基础报表", notes = "传入 type : 0-日报 1-月报 2-年报")
public R<Map<String,Object>> basics(@RequestParam(value = "deptId",required = false) Long deptId,
@RequestParam(value = "type") Long type,
@RequestParam(value = "time") String time) {
@RequestParam(value = "time") String time) {
return R.data(service.basics(deptId,type,time));
}
@GetMapping("/comprehensive")
@GetMapping("/basics/export")
@ApiOperationSupport(order = 2)
@ApiOperation(value = "基础报表导出", notes = "传入 deptId、year")
public void basicsExport(HttpServletResponse response,
@RequestParam(value = "deptId",required = false) Long deptId,
@RequestParam(value = "type") Long type,
@RequestParam(value = "time") String time) {
service.basicsExport(response,deptId,type,time);
}
@GetMapping("/comprehensive")
@ApiOperationSupport(order = 3)
@ApiOperation(value = "综合报表", notes = "传入 deptId、year")
public R<List<ComprehensiveElectricVo>> comprehensive(@RequestParam(value = "deptId") Long deptId,
@RequestParam(value = "year") String year) {
return R.data(service.comprehensive(deptId,year));
}
@GetMapping("/comprehensive/export")
@ApiOperationSupport(order = 4)
@ApiOperation(value = "综合报表导出", notes = "传入 deptId、year")
public void comprehensiveExport(HttpServletResponse response,
@RequestParam(value = "deptId") Long deptId,
@RequestParam(value = "year") String year) {
service.comprehensiveExport(response,deptId,year);
}
@PostMapping("/run")
@ApiOperationSupport(order = 3)
@ApiOperationSupport(order = 5)
@ApiOperation(value = "运行报表", notes = "传入 deptId、day")
public R<Map<String,Object>> run(@RequestBody RunParamVo param) {
return R.data(service.run(param));

8
hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/IElectricReportService.java

@ -2,8 +2,8 @@ package com.hnac.hzims.electric.service;
import com.hnac.hzims.electric.vo.ComprehensiveElectricVo;
import com.hnac.hzims.electric.vo.RunParamVo;
import com.hnac.hzims.electric.vo.RunResultVo;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
@ -15,7 +15,11 @@ public interface IElectricReportService {
Map<String, Object> basics(Long deptId, Long type,String time);
void basicsExport(HttpServletResponse response, Long deptId, Long type, String time);
List<ComprehensiveElectricVo> comprehensive(Long deptId,String year);
Map<String, Object> run(RunParamVo param);
void comprehensiveExport(HttpServletResponse response, Long deptId, String year);
Map<String,Object> run(RunParamVo param);
}

691
hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/impl/ElectricReportServiceImpl.java

@ -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;
}
}

1
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/mapper/AlarmHandleMapper.xml

@ -34,6 +34,7 @@
FROM HZIMS_ALARM_HANDLE HANDLER
<where>
HANDLER.IS_DELETED = 0
AND NOT HANDLER.ALARM_ID IS NULL
<if test="start != null and end != null">
AND HANDLER.CREATE_TIME BETWEEN #{start} AND #{end}
</if>

20
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/mapper/AlarmMapper.xml

@ -3,9 +3,8 @@
<mapper namespace="com.hnac.hzims.alarm.show.mapper.AlarmMapper">
<select id="pageCondition" resultType="com.hnac.hzims.alarm.config.vo.AlarmHistoryVo">
SELECT ALARM.STATION_ID,ALARM.STATION_NAME,ALARM.ALARM_TYPE,ALARM.ALARM_CONTEXT,
HANDLE.HANDLE_WAY,HANDLE.CREATE_USER HANDLE_USER,HANDLE.CREATE_USER_NAME HANDLE_USER_NAME,ALARM.ALARM_TIME,
HANDLE.CREATE_TIME HANDLE_TIME,HANDLE.FILE_PATH
SELECT ALARM.STATION_ID,ALARM.STATION_NAME,ALARM.ALARM_ID,ALARM.ALARM_TYPE,ALARM.ALARM_CONTEXT,
HANDLE.HANDLE_WAY,HANDLE.HANDLE_USER HANDLE_USER,ALARM.ALARM_TIME,HANDLE.CREATE_TIME HANDLE_TIME,HANDLE.FILE_PATH
FROM HZIMS_ALARM ALARM
LEFT JOIN HZIMS_ALARM_HANDLE HANDLE
ON ALARM.ALARM_ID = HANDLE.ALARM_ID
@ -20,12 +19,21 @@
<if test="param.endTime != null and param.endTime != ''">
AND ALARM.ALARM_TIME &lt;= #{param.endTime}
</if>
<if test="param.alarmType != null and param.alarmType != ''">
AND ALARM.ALARM_TYPE = #{param.alarmType}
</if>
<if test="param.handleWay != null and param.handleWay != ''">
AND HANDLE.HANDLE_WAY = #{param.handleWay}
</if>
<choose>
<when test="param.alarmType != null and param.alarmType != '' and param.alarmType == 60">
AND ALARM.ALARM_SIGNAGE in ('plc_remote_power','plc_generation_order')
</when>
<when test="param.alarmType != null and param.alarmType != '' and param.alarmType == 61">
AND ALARM.ALARM_SIGNAGE in ('plc_remote_shutdown','plc_shutdown_order','plc_emergency_stop','plc_urgent_shutdown')
</when>
<when test="param.alarmType != null and param.alarmType != ''">
AND ALARM.ALARM_TYPE = #{param.alarmType}
</when>
</choose>
</where>
ORDER BY ALARM.ALARM_TIME DESC
</select>
</mapper>

16
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java

@ -41,6 +41,9 @@ import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.message.fegin.IMessageClient;
import org.springblade.system.cache.DictCache;
import org.springblade.system.user.cache.UserCache;
import org.springblade.system.user.entity.User;
import org.springblade.system.user.feign.IUserClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@ -553,6 +556,17 @@ public class AlarmServiceImpl extends ServiceImpl<AlarmMapper, AlarmEntity> impl
*/
@Override
public IPage<AlarmHistoryVo> pageCondition(AlarmHistoryParamVo param, IPage<AlarmHistoryVo> page) {
return this.baseMapper.pageCondition(param,page);
IPage<AlarmHistoryVo> iPage = this.baseMapper.pageCondition(param,page);
if(CollectionUtil.isNotEmpty(iPage.getRecords())){
iPage.setRecords(iPage.getRecords().stream().peek(record->{
if(ObjectUtil.isNotEmpty(record.getHandleUser())){
User user = UserCache.getUser(record.getHandleUser());
if(ObjectUtil.isNotEmpty(user)){
record.setHandleUserName(user.getRealName());
}
}
}).collect(Collectors.toList()));
}
return iPage;
}
}

2
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/GenerationScheduledTask.java

@ -80,7 +80,7 @@ public class GenerationScheduledTask {
* @return
*/
//@XxlJob(LOAD_THREE_YEAR_POWER_GENERATION)
@Scheduled(cron = "0 0 1 * * ? ")
@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> loadThreeYearPowerGeneration() {
String param = "";
if (Func.isBlank(param)) {

8
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ShowScheduledTask.java

@ -7,6 +7,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.Date;
@ -41,9 +42,10 @@ public class ShowScheduledTask {
/**
* 首页-区域班组数据
*/
@XxlJob(REGIONAL_DUTY_INFO)
//@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> loadRegionalDuty(String param) {
// @XxlJob(REGIONAL_DUTY_INFO)
@Scheduled(cron = "0 0/5 * * * ? ")
public ReturnT<String> loadRegionalDuty() {
String param = "";
if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss");
}

2
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/StartStopScheduledTask.java

@ -45,7 +45,7 @@ public class StartStopScheduledTask {
* 设备开停机时间记录
*/
//@XxlJob(START_STOP_TIME_RECORD)
@Scheduled(cron = "0 0/2 * * * ? ")
@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> startStopTimeRecord() {
String param = "";
if (Func.isBlank(param)) {

1
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java

@ -200,6 +200,7 @@ public class AlarmServiceImpl implements AlarmService {
public void interruption(String param) {
// 查询接入站点
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery()
.eq(StationEntity::getType,0)
.eq(StationEntity::getDataOrigin,"0")
);
if(CollectionUtil.isEmpty(stations)){

5
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/StartStopDurationServiceImpl.java

@ -6,6 +6,7 @@ import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.hnac.hzims.common.logs.utils.StringUtils;
import com.hnac.hzims.equipment.entity.StartStopDurationEntity;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.equipment.vo.StartStopTimeVO;
@ -181,7 +182,7 @@ public class StartStopDurationServiceImpl extends ServiceImpl<StartStopDurationM
}
// 调用fegin接口查询实时数据
List<FieldsData> fields = dataService.getRealDataByAnalyzeCode(device.getEmCode(),Collections.singletonList(HomePageConstant.START_STOP_STATUS));
if(CollectionUtil.isEmpty(fields) || fields.get(0).getQ() > -1){
if(CollectionUtil.isEmpty(fields) || fields.get(0).getQ() != 0){
startStopTime.setQuality(-1);
return startStopTime;
}
@ -189,7 +190,7 @@ public class StartStopDurationServiceImpl extends ServiceImpl<StartStopDurationM
if(CollectionUtil.isNotEmpty(startStopTimes)){
// 寻找设备上次记录值
Optional<StartStopTimeVO> optional = startStopTimes.stream().filter(o->o.getDeviceCode().equals(device.getEmCode())).findFirst();
if(optional.isPresent() && optional.get().getValue().equals(fields.get(0).getValue())){
if(optional.isPresent() && StringUtils.isNotEmpty(optional.get().getValue()) && optional.get().getValue().equals(fields.get(0).getValue())){
startStopTime.setValue(optional.get().getValue());
startStopTime.setTime(optional.get().getTime());
startStopTime.setQuality(optional.get().getQuality());

2
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/business/impl/PhenomenonServiceImpl.java

@ -118,7 +118,7 @@ public class PhenomenonServiceImpl extends ServiceImpl<PhenomenonMapper, OperPhe
}
// 消缺数
shortagesVo.setShortagesSum(defects.size());
List<Long> shortagesList = defects.stream().filter(defect-> !ObjectUtil.isEmpty(defect.getHandleTaskId())).map(OperPhenomenonEntity::getId).collect(Collectors.toList());
List<Long> shortagesList = defects.stream().filter(defect-> "流程结束".equals(defect.getCurrentOperator())).map(OperPhenomenonEntity::getId).collect(Collectors.toList());
if(CollectionUtil.isEmpty(shortagesList)){
shortagesVo.setShortages(0);
}

6
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ObtainGenerationServiceImpl.java

@ -107,7 +107,6 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
// 步骤1.水电、光伏站点
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery().
in(StationEntity::getType, Arrays.asList(HomePageConstant.HYDROPOWER,HomePageConstant.PHOTOVOLTAIC))
.in(StationEntity::getCode, Arrays.asList("901800000612","901800000137"))
);
// 步骤2.缓存设备信息
@ -276,6 +275,7 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
generate.setStrMonth(strMonth);
generate.setMonth(date.getMonth() + 1);
generate.setGenerate(BigDecimal.valueOf(thirtyGenerationEntities.stream().mapToDouble(o -> o.getGenerate().doubleValue()).sum()).setScale(2, RoundingMode.HALF_UP));
generate.setReactiveGenerate(BigDecimal.valueOf(thirtyGenerationEntities.stream().mapToDouble(o -> o.getReactiveGenerate().doubleValue()).sum()).setScale(2, RoundingMode.HALF_UP));
return generate;
}).collect(Collectors.toList()));
}
@ -503,9 +503,7 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
}else{
generation.setGenerate(BigDecimal.valueOf(Double.parseDouble(power.getPower().toString())).setScale(2, RoundingMode.HALF_UP));
}
generation.setReactiveGenerate(BigDecimal.ZERO
);
generation.setReactiveGenerate(BigDecimal.ZERO);
return generation;
}).collect(Collectors.toList());
}

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

@ -339,6 +339,7 @@ public class RealTargetServiceImpl implements RealTargetService {
target.setStartupDurationYear(-1.0);
target.setShutDownDurationYear(-1.0);
}
targets.add(target);
countDownLatch.countDown();
}catch (Exception exception){
countDownLatch.countDown();
@ -1656,6 +1657,10 @@ public class RealTargetServiceImpl implements RealTargetService {
target.setPowerDay(generateService.generate(day,station.getCode()));
// 昨日发电量
target.setPowerYesterDay(0f);
// 开机时长
target.setStartupDurationYear(-1.0);
// 关机时长
target.setShutDownDurationYear(-1.0);
// 30天发电量
target.setGenerationPowerVoList(generateService.generate30Day(day,station.getCode()));
return target;

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/TargetController.java

@ -137,7 +137,7 @@ public class TargetController {
public R<IPage<DeviceClassifyVo>> deviceClassify(Query query,
@RequestParam(value = "stationName",required = false) String stationName,
@RequestParam(value = "deptId",required = false) Long deptId,
@RequestParam(value="status")Integer status) {
@RequestParam(value="status",required = false)Integer status) {
return R.data(service.deviceClassify(Condition.getPage(query),stationName,deptId,status));
}

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java

@ -1186,7 +1186,7 @@ public class TargetServiceImpl implements TargetService {
le(OperPhenomenonEntity::getCreateTime,business.getEndTime());
}
if(!StringUtil.isBlank(business.getType()) && "1".equals(business.getType())){
isNotNull(OperPhenomenonEntity::getHandleTaskId);
eq(OperPhenomenonEntity::getCurrentOperator,"流程结束");
}
if(!StringUtil.isBlank(business.getDeptIds())){
in(OperPhenomenonEntity::getCreateDept, Func.toLongList(",",business.getDeptIds()));

28
hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/impl/HydroelectricServiceImpl.java

@ -159,11 +159,19 @@ public class HydroelectricServiceImpl implements HydroelectricService {
if(CollectionUtil.isNotEmpty(target.get().getActivePowerVoList())){
device.setGenerates(target.get().getGenerationPowerVoList().stream().map(o-> BeanUtil.copy(o, HydroelectricDeviceGenerateVo.class)).collect(Collectors.toList()));
}
}else{
device.setPowerDay(0f);
device.setPowerYesterDay(0f);
device.setPowerYear(0f);
device.setPowerYesterYear(0f);
device.setPowerMon(0f);
device.setStartupDurationYear(-1.0);
device.setShutDownDurationYear(-1.0);
}
// 开停机数据
Optional<StartStopTimeVO> startStop = startStopTimes.stream().filter(o->iter.equals(o.getDeviceCode())).findFirst();
Optional<StartStopTimeVO> startStop = startStopTimes.stream().filter(o->iter.getEmCode().equals(o.getDeviceCode())).findFirst();
if(startStop.isPresent()){
if(startStop.get().getQuality() > 0){
if(startStop.get().getQuality() == 0){
Date time;
if(startStop.get().getTime().contains(".000")){
time = DateUtil.parse(startStop.get().getTime(), "yyyy-MM-dd HH:mm:ss.sss");
@ -171,7 +179,7 @@ public class HydroelectricServiceImpl implements HydroelectricService {
time = DateUtil.parse(startStop.get().getTime(), DateUtil.PATTERN_DATETIME);
}
device.setStartDownTime(DateUtil.format(time,DateUtil.PATTERN_DATETIME));
device.setStartupDownDuration(BigDecimal.valueOf(new Date().getTime() - time.getTime() / (1000 * 60 * 60.00)).setScale(2, RoundingMode.HALF_UP).doubleValue());
device.setStartupDownDuration(BigDecimal.valueOf((System.currentTimeMillis() - time.getTime()) / (1000 * 60 * 60.00)).setScale(2, RoundingMode.HALF_UP).doubleValue());
}else{
device.setStartDownTime("-1");
device.setStartupDownDuration(-1.0);
@ -199,7 +207,7 @@ public class HydroelectricServiceImpl implements HydroelectricService {
}else{
result.setPowerMonPlan(0.0);
}
result.setPowerMon(result.getDevices().stream().mapToDouble(HydroelectricDeviceVo::getPowerMon).sum());
result.setPowerMon(targets.stream().filter(o->o.getDeptId().equals(station.getRefDept())).mapToDouble(HydropowerUnitTargetVo::getPowerMon).sum());
if(result.getPowerMonPlan() <= 0 || result.getPowerMon() <= 0){
result.setPowerRateMon(0.0);
}else{
@ -212,7 +220,7 @@ public class HydroelectricServiceImpl implements HydroelectricService {
}else{
result.setPowerYearPlan(0.0);
}
result.setPowerYear(result.getDevices().stream().mapToDouble(HydroelectricDeviceVo::getPowerYear).sum());
result.setPowerYear(targets.stream().filter(o->ObjectUtil.isNotEmpty(o.getPowerYear()) && o.getDeptId().equals(station.getRefDept())).mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum());
if(result.getPowerYearPlan() <= 0 || result.getPowerYear() <= 0){
result.setPowerRateYear(0.0);
}else{
@ -220,11 +228,12 @@ public class HydroelectricServiceImpl implements HydroelectricService {
}
// 今日发电量、昨日发电量
result.setPowerDay(result.getDevices().stream().mapToDouble(HydroelectricDeviceVo::getPowerDay).sum());
result.setPowerYesterDay(result.getDevices().stream().mapToDouble(HydroelectricDeviceVo::getPowerYesterDay).sum());
result.setPowerDay(result.getDevices().stream().filter(o->ObjectUtil.isNotEmpty(o.getPowerDay())).mapToDouble(HydroelectricDeviceVo::getPowerDay).sum());
result.setPowerYesterDay(result.getDevices().stream().filter(o->ObjectUtil.isNotEmpty(o.getPowerYesterDay())).mapToDouble(HydroelectricDeviceVo::getPowerYesterDay).sum());
}
// 站点水位
result.setWater(this.water(waterLevels,station.getCode()));
// 近30日降雨量/发电量
//result.setPowerRains(this.stationPowerRains(result.getDevices(),rains));
// 近24小时总有功率/水位
@ -361,6 +370,7 @@ public class HydroelectricServiceImpl implements HydroelectricService {
List<Long> refDepts = stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList());
// 站点数量
group.setCount(stations.size());
group.setGeneratePlanYear(plans.stream().mapToDouble(PlanGenerationEntity::getPlanGeneration).sum());
// 实时数据
List<HydropowerUnitRealVo> reals = (List<HydropowerUnitRealVo>) redisTemplate.opsForValue().get(LOAD_HYDROPOWER_REAL_KEY);
if (CollectionUtil.isNotEmpty(reals)) {
@ -395,10 +405,6 @@ public class HydroelectricServiceImpl implements HydroelectricService {
// 日发电量
group.setGenerateDay(stationTargets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerDay).sum());
// 年计划发电量
DevicePlanGenerationVo planParam = new DevicePlanGenerationVo();
param.setStationIds(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()));
param.setDate(DateUtil.format(new Date(),"yyyy"));
group.setGeneratePlanYear(planClient.getPlanPowerYear(planParam));
if(group.getGeneratePlanYear() <= 0 || group.getGenerateYear() <= 0){
group.setGenerateRate(0.0);
}else{

Loading…
Cancel
Save