Browse Source

Merge remote-tracking branch 'origin/master'

zhongwei
yang_shj 1 year ago
parent
commit
5d9dcac540
  1. 38
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/CheckChartVo.java
  2. 43
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/MonPowerPercentageVo.java
  3. 26
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/TicketChartCell.java
  4. 22
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/TicketChartVo.java
  5. 248
      hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/constants/TicketConstants.java
  6. 8
      hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/feign/ITicketInfoClient.java
  7. 5
      hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/feign/TicketInfoClientFallback.java
  8. 6
      hzims-service/operational/pom.xml
  9. 3
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyEmergencyServiceImpl.java
  10. 19
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/AreaMonthReportController.java
  11. 3
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IAreaMonthReportService.java
  12. 727
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java
  13. 835
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/JFreeUtil.java
  14. 91
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/TimeUtils.java
  15. 15
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/feign/TicketInfoClient.java

38
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/CheckChartVo.java

@ -0,0 +1,38 @@
package com.hnac.hzims.operational.report.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author hx
*/
@Data
@ApiModel("缺陷统计表")
public class CheckChartVo {
@ApiModelProperty(value = "场站名称")
private String deptName;
@ApiModelProperty(value = "缺陷分类")
private String checkLevel;
@ApiModelProperty(value = "本月-发现缺陷")
private Integer findShortagesMon;
@ApiModelProperty(value = "本月-消缺数")
private Integer shortagesMon;
@ApiModelProperty(value = "本年-发现缺陷")
private Integer findShortagesYear;
@ApiModelProperty(value = "本年-消缺数")
private Integer shortagesYear;
@ApiModelProperty(value = "本年-消缺率")
private Double shortagesRate;
public CheckChartVo(String deptName, String checkLevel, Integer findShortagesMon, Integer shortagesMon, Integer findShortagesYear, Integer shortagesYear, Double shortagesRate) {
this.deptName=deptName;
this.checkLevel=checkLevel;
this.findShortagesMon=findShortagesMon;
this.shortagesMon=shortagesMon;
this.findShortagesYear=findShortagesYear;
this.shortagesYear=shortagesYear;
this.shortagesRate=shortagesRate;
}
}

43
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/MonPowerPercentageVo.java

@ -0,0 +1,43 @@
package com.hnac.hzims.operational.report.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author ysj
*/
@Data
@ApiModel(value = "水电站发电量同比数据对象")
public class MonPowerPercentageVo {
@ApiModelProperty(value = "机构Id")
private long deptId;
@ApiModelProperty(value = "机构名称")
private String deptName;
@ApiModelProperty(value = "设备名称")
private String deviceName;
@ApiModelProperty(value = "年计划发电量")
private double planPower;
@ApiModelProperty(value = "今年发电量")
private double powerYear;
@ApiModelProperty(value = "去年发电量")
private double powerYearBefore;
@ApiModelProperty(value = "当月发电量")
private double powerMon;
@ApiModelProperty(value = "上个月发电量")
private double powerMonBefore;
@ApiModelProperty(value = "去年当月发电量")
private double powerMonYearBefore;
@ApiModelProperty(value = "两年间:年发电量环比")
private double powerYearPercentage;
@ApiModelProperty(value = "两年间:月发电量环比")
private double powerMonPercentage;
@ApiModelProperty(value = "年计划完成率")
private double planPercentage;
}

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

@ -0,0 +1,26 @@
package com.hnac.hzims.operational.report.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author hx
*/
@Data
@ApiModel("两票统计单元格")
public class TicketChartCell {
@ApiModelProperty(value = "票的种类")
// 操作票:3:倒闸 4:开机 5:停机
// 工作票:6:第一种 7:第二种 8水力机械票
private String ticketType;
private String ticketName;
@ApiModelProperty(value = "本月数量")
private int ticketMon;
@ApiModelProperty(value = "本月合格率")
private double ticketMonPerc;
@ApiModelProperty(value = "本年数量")
private int ticketYear;
@ApiModelProperty(value = "本年合格率")
private double ticketYeaPercr;
}

22
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/TicketChartVo.java

@ -0,0 +1,22 @@
package com.hnac.hzims.operational.report.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author hx
*/
@Data
@ApiModel("两票统计表")
public class TicketChartVo {
@ApiModelProperty(value = "场站名称")
private String deptName;
@ApiModelProperty(value = "数量和合格率")
private List<TicketChartCell> chartCells;
}

248
hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/constants/TicketConstants.java

@ -23,7 +23,9 @@ public interface TicketConstants {
String SIGNER_ROLE = "signer"; String SIGNER_ROLE = "signer";
String LICENSOR_ROLE = "licensor"; String LICENSOR_ROLE = "licensor";
/**工作票安措新增类型**/ /**
* 工作票安措新增类型
**/
String DUTY_PATTERN = "1"; String DUTY_PATTERN = "1";
String LICENSE_PATTERN = "2"; String LICENSE_PATTERN = "2";
@ -32,12 +34,13 @@ public interface TicketConstants {
int MEASURE_NOT_COMPLETE = 3; int MEASURE_NOT_COMPLETE = 3;
int MEASURE_COMPLETE = 4; int MEASURE_COMPLETE = 4;
/**开票任务类型**/ /**
* 开票任务类型
**/
enum TaskTypeEnum { enum TaskTypeEnum {
RCWH("1","日常维护"), RCWH("1", "日常维护"),
JXRW("2","检修任务"), JXRW("2", "检修任务"),
JXJH("3","检修计划") JXJH("3", "检修计划");
;
@Getter @Getter
private String type; private String type;
@Getter @Getter
@ -53,26 +56,46 @@ public interface TicketConstants {
* 工作票流程环节 * 工作票流程环节
*/ */
enum WorkTicketFlowEnum { enum WorkTicketFlowEnum {
/**开票**/ /**
START("1","startEvent1","开票"), * 开票
/**签发人签发**/ **/
SIGN("1","sid-5E7013A9-385A-4EE4-91B6-FD5328D05E2A","签发人签发"), START("1", "startEvent1", "开票"),
/**运行人员接收**/ /**
RECEIVE("2","sid-355DB6EC-7D54-4537-B80F-C26CD716ADA1","运行人员接收"), * 签发人签发
/**运行人员布置安全措施**/ **/
FIX_UP("3","sid-F35C4A79-53AF-40B8-AFBD-AF7283CC5708","运行人员布置安全措施"), SIGN("1", "sid-5E7013A9-385A-4EE4-91B6-FD5328D05E2A", "签发人签发"),
/**工作负责人确认安全措施**/ /**
PRINCIPAL_CONFIRM_MEASURE("4","sid-5476EB52-438F-4C74-94FB-88A6EA6625EA","工作负责人确认安全措施"), * 运行人员接收
/**许可人许可**/ **/
LICENCE("5","sid-0CB1456A-D85C-4473-A032-FAEF62EFBF22","许可人许可"), RECEIVE("2", "sid-355DB6EC-7D54-4537-B80F-C26CD716ADA1", "运行人员接收"),
/**工作负责人确认工作内容执行**/ /**
PRINCIPAL_CONFIRM_CONTENT("6","sid-5476EB52-438F-4C74-94FB-88A6EA6625EA","工作负责人确认工作内容执行"), * 运行人员布置安全措施
/**工作负责人确认工作票结束**/ **/
PRINCIPAL_CONFIRM_END("7","sid-5476EB52-438F-4C74-94FB-88A6EA6625EA","工作负责人确认工作票结束、终结"), FIX_UP("3", "sid-F35C4A79-53AF-40B8-AFBD-AF7283CC5708", "运行人员布置安全措施"),
/**工作负责人确认工作票结束**/ /**
LICENSE_CONFIRM_END("8","sid-5476EB52-438F-4C74-94FB-88A6EA6625EA","工作负责人确认工作票结束、终结"), * 工作负责人确认安全措施
/**签发人审核**/ **/
SIGN_CONFIRM_DELAY("9","sid-5476EB52-438F-4C74-94FB-88A6EA6625EA","签发人审核"), PRINCIPAL_CONFIRM_MEASURE("4", "sid-5476EB52-438F-4C74-94FB-88A6EA6625EA", "工作负责人确认安全措施"),
/**
* 许可人许可
**/
LICENCE("5", "sid-0CB1456A-D85C-4473-A032-FAEF62EFBF22", "许可人许可"),
/**
* 工作负责人确认工作内容执行
**/
PRINCIPAL_CONFIRM_CONTENT("6", "sid-5476EB52-438F-4C74-94FB-88A6EA6625EA", "工作负责人确认工作内容执行"),
/**
* 工作负责人确认工作票结束
**/
PRINCIPAL_CONFIRM_END("7", "sid-5476EB52-438F-4C74-94FB-88A6EA6625EA", "工作负责人确认工作票结束、终结"),
/**
* 工作负责人确认工作票结束
**/
LICENSE_CONFIRM_END("8", "sid-5476EB52-438F-4C74-94FB-88A6EA6625EA", "工作负责人确认工作票结束、终结"),
/**
* 签发人审核
**/
SIGN_CONFIRM_DELAY("9", "sid-5476EB52-438F-4C74-94FB-88A6EA6625EA", "签发人审核"),
; ;
@Getter @Getter
private String status; private String status;
@ -86,23 +109,25 @@ public interface TicketConstants {
this.flowId = flowId; this.flowId = flowId;
this.segment = segment; this.segment = segment;
} }
public static WorkTicketFlowEnum getEnumByFlowId(String flowId) { public static WorkTicketFlowEnum getEnumByFlowId(String flowId) {
Optional<WorkTicketFlowEnum> workTicketFlowEnum = Arrays.stream(WorkTicketFlowEnum.class.getEnumConstants()).filter(flowEnum -> flowId.equals(flowEnum.flowId)).findFirst(); Optional<WorkTicketFlowEnum> workTicketFlowEnum = Arrays.stream(WorkTicketFlowEnum.class.getEnumConstants()).filter(flowEnum -> flowId.equals(flowEnum.flowId)).findFirst();
return workTicketFlowEnum.orElse(null); return workTicketFlowEnum.orElse(null);
} }
} }
enum WordFileNameEnum { enum WordFileNameEnum {
OPERATE("1","操作票"), OPERATE("1", "操作票"),
WORK("2","工作票"), WORK("2", "工作票"),
SWITCH_OFF("3","大隆水电站倒闸操作票模板"), SWITCH_OFF("3", "大隆水电站倒闸操作票模板"),
BOOT_UP("4","大隆水电站倒闸操作票模板"), BOOT_UP("4", "大隆水电站倒闸操作票模板"),
DOWNTIME("5","大隆水电站倒闸操作票模板"), DOWNTIME("5", "大隆水电站倒闸操作票模板"),
FIRST_WORK("6","大隆水电站电气第一种工作票模板"), FIRST_WORK("6", "大隆水电站电气第一种工作票模板"),
SECOND_WORK("7","大隆水电站电气第二种工作票模板"), SECOND_WORK("7", "大隆水电站电气第二种工作票模板"),
MECHANICAL_WORK("8","大隆水电站水力机械工作票模板"), MECHANICAL_WORK("8", "大隆水电站水力机械工作票模板"),
EMERGENCY_REPAIR("9","大隆水电站事故应急抢修单模板"), EMERGENCY_REPAIR("9", "大隆水电站事故应急抢修单模板"),
NEW_FIRST_WORK("10","新电气第一种工作票模板"), NEW_FIRST_WORK("10", "新电气第一种工作票模板"),
NEW_FIRST_WORK1("11","第一种工作票"), NEW_FIRST_WORK1("11", "第一种工作票"),
; ;
@Getter @Getter
private String type; private String type;
@ -115,8 +140,37 @@ public interface TicketConstants {
} }
public static String getFileNameByType(String type) { public static String getFileNameByType(String type) {
Optional<WordFileNameEnum> optional = Arrays.stream(WordFileNameEnum.values()).filter(e->type.equals(e.getType())).findFirst(); Optional<WordFileNameEnum> optional = Arrays.stream(WordFileNameEnum.values()).filter(e -> type.equals(e.getType())).findFirst();
return optional.map(e->e.fileName).orElse(null); return optional.map(e -> e.fileName).orElse(null);
}
}
// 两票类型枚举类
enum TicketTypeNameEnum {
SWITCH_OFF("3", "倒闸操作票",1),
BOOT_UP("4", "开机操作票",1),
DOWNTIME("5", "停机操作票",1),
FIRST_WORK("6", "第一种工作票",2),
SECOND_WORK("7", "第二种工作票",2),
MECHANICAL_WORK("8", "水力机械工作票",2),
;
@Getter
private String type;
@Getter
private String fileName;
@Getter
private Integer ticketType;
TicketTypeNameEnum(String type, String fileName, Integer ticketType) {
this.type = type;
this.fileName = fileName;
this.ticketType = ticketType;
}
public static String getTicketNameByType(String type) {
Optional<WordFileNameEnum> optional = Arrays.stream(WordFileNameEnum.values()).filter(e -> type.equals(e.getType())).findFirst();
return optional.map(e -> e.fileName).orElse(null);
} }
} }
@ -124,10 +178,9 @@ public interface TicketConstants {
* 工作票安全注意事项类型 * 工作票安全注意事项类型
*/ */
enum MeasureTypeEnum { enum MeasureTypeEnum {
INIT_MEASURE("1","开票时的安全措施"), INIT_MEASURE("1", "开票时的安全措施"),
SIGN_MEASURE("2","签发补充安全措施"), SIGN_MEASURE("2", "签发补充安全措施"),
LICENSE_MEASURE("3","许可人补充安全措施") LICENSE_MEASURE("3", "许可人补充安全措施");
;
@Getter @Getter
private String type; private String type;
@Getter @Getter
@ -141,9 +194,8 @@ public interface TicketConstants {
@AllArgsConstructor @AllArgsConstructor
enum TicketCodePreEnum { enum TicketCodePreEnum {
DQ_WORK("6","S-DQ","电气工作票","workTicketInfoService"), DQ_WORK("6", "S-DQ", "电气工作票", "workTicketInfoService"),
DQ_OPERATE("3","YX-DQ","电气标准票","standardTicketInfoService") DQ_OPERATE("3", "YX-DQ", "电气标准票", "standardTicketInfoService");
;
@Getter @Getter
private String type; private String type;
@Getter @Getter
@ -157,10 +209,9 @@ public interface TicketConstants {
} }
enum DelayStatusEnum { enum DelayStatusEnum {
PRINCIPAL_INITIATE(1,"负责人发起"), PRINCIPAL_INITIATE(1, "负责人发起"),
LICENSOR_CONFIRM(2,"许可人确认"), LICENSOR_CONFIRM(2, "许可人确认"),
PRINCIPAL_CONFIRM(3,"负责人确认") PRINCIPAL_CONFIRM(3, "负责人确认");
;
@Getter @Getter
private int status; private int status;
@Getter @Getter
@ -176,19 +227,20 @@ public interface TicketConstants {
* 安全措施/注意事项 * 安全措施/注意事项
*/ */
@AllArgsConstructor @AllArgsConstructor
enum SafetyMeasureStatusEnum{ enum SafetyMeasureStatusEnum {
NO_EXECUTE(1,"未执行"), NO_EXECUTE(1, "未执行"),
EXECUTED(2,"执行中"), EXECUTED(2, "执行中"),
NO_FINISH(4,"执行中"), NO_FINISH(4, "执行中"),
FINISH(3,"已执行") FINISH(3, "已执行");
;
@Getter @Getter
private Integer status; private Integer status;
@Getter @Getter
private String describe; private String describe;
/**根据status获取describe**/ /**
public static String getDescribeByStatus(Integer status){ * 根据status获取describe
**/
public static String getDescribeByStatus(Integer status) {
Optional<SafetyMeasureStatusEnum> optional = Arrays.stream(SafetyMeasureStatusEnum.values()) Optional<SafetyMeasureStatusEnum> optional = Arrays.stream(SafetyMeasureStatusEnum.values())
.filter(p -> status.equals(p.getStatus())).findFirst(); .filter(p -> status.equals(p.getStatus())).findFirst();
String describe = optional.isPresent() ? optional.get().getDescribe() : status.toString(); String describe = optional.isPresent() ? optional.get().getDescribe() : status.toString();
@ -200,15 +252,15 @@ public interface TicketConstants {
* 工作票处理流程 * 工作票处理流程
*/ */
enum FirstWorkTicketFlowEnum { enum FirstWorkTicketFlowEnum {
SIGN("sign","签发"), SIGN("sign", "签发"),
LICENSE("license","许可人确认安全事项"), LICENSE("license", "许可人确认安全事项"),
RECEIVE("receive","负责人确认收到工作票"), RECEIVE("receive", "负责人确认收到工作票"),
CONFIRM_MEASURE_PRINCIPAL("principalConfirm","负责人确认安全事项"), CONFIRM_MEASURE_PRINCIPAL("principalConfirm", "负责人确认安全事项"),
CONFIRM_MEASURE_MEMBERS("membersConfirm","工作组员确认安全事项"), CONFIRM_MEASURE_MEMBERS("membersConfirm", "工作组员确认安全事项"),
FINISH("finish","工作票结束"), FINISH("finish", "工作票结束"),
END("end","工作票终结"), END("end", "工作票终结"),
PRINCIPAL_DELAY("principalDelay","负责人发起工作票延期"), PRINCIPAL_DELAY("principalDelay", "负责人发起工作票延期"),
LICENSOR_DELAY("licensorDelay","许可人确认工作票延期"), LICENSOR_DELAY("licensorDelay", "许可人确认工作票延期"),
; ;
@Getter @Getter
private String code; private String code;
@ -224,12 +276,11 @@ public interface TicketConstants {
/** /**
* 标准票处理流程 * 标准票处理流程
*/ */
enum StandardTicketStatusEnum{ enum StandardTicketStatusEnum {
GUARDIAN_CONFIRM(1,"待监护人确认"), GUARDIAN_CONFIRM(1, "待监护人确认"),
PRINCIPAL_CONFIRM(2,"待值班负责人确认"), PRINCIPAL_CONFIRM(2, "待值班负责人确认"),
END(3,"结束"), END(3, "结束"),
TERMINATION(4,"终止") TERMINATION(4, "终止");
;
@Getter @Getter
private Integer status; private Integer status;
@ -247,27 +298,26 @@ public interface TicketConstants {
*/ */
@AllArgsConstructor @AllArgsConstructor
enum FirstWorkTicketFlowStatusEnum { enum FirstWorkTicketFlowStatusEnum {
SIGN(1,"待签发"), SIGN(1, "待签发"),
RECEIVE(2,"待确认收到工作票"), RECEIVE(2, "待确认收到工作票"),
LICENSE(3,"待许可"), LICENSE(3, "待许可"),
CONFIRM_MEASURE_PRINCIPAL(4,"待负责人确认安全措施"), CONFIRM_MEASURE_PRINCIPAL(4, "待负责人确认安全措施"),
CONFIRM_MEASURE_MEMBERS(5,"待班组成员确认安全措施"), CONFIRM_MEASURE_MEMBERS(5, "待班组成员确认安全措施"),
CONFIRM_OPERATION_SITUATION(6,"待确认执行情况"), CONFIRM_OPERATION_SITUATION(6, "待确认执行情况"),
COMPLETE_PRINCIPAL_CONTENT(7,"待工作成员完成任务"), COMPLETE_PRINCIPAL_CONTENT(7, "待工作成员完成任务"),
CONFIRM_PRINCIPAL_CONTENT(8,"待负责人确认完成工作"), CONFIRM_PRINCIPAL_CONTENT(8, "待负责人确认完成工作"),
CONFIRM_WORK_FINISH(9,"待确认工作结束"), CONFIRM_WORK_FINISH(9, "待确认工作结束"),
END(10,"待终结"), END(10, "待终结"),
FINISH(11,"完成"), FINISH(11, "完成"),
LICENSOR_DELAY(12,"待许可人确认工作票延期"), LICENSOR_DELAY(12, "待许可人确认工作票延期"),
PRINCIPAL_DELAY(13,"待负责人确认工作票延期"), PRINCIPAL_DELAY(13, "待负责人确认工作票延期"),
INVALID(14,"作废"), INVALID(14, "作废"),
OFFLINE(15,"线下开票"), OFFLINE(15, "线下开票"),
TERMINATION(16,"终止"), TERMINATION(16, "终止"),
UNDONE(17,"逾期未完成"), UNDONE(17, "逾期未完成"),
OFFLINE_OPERATE(18,"线下执行任务"), OFFLINE_OPERATE(18, "线下执行任务"),
OFFLINE_LICENSE(19,"线下许可人许可"), OFFLINE_LICENSE(19, "线下许可人许可"),
OFFLINE_END(20,"线下结束") OFFLINE_END(20, "线下结束");
;
@Getter @Getter
private Integer status; private Integer status;
@Getter @Getter
@ -275,6 +325,7 @@ public interface TicketConstants {
/** /**
* 根据status获取对应枚举类 * 根据status获取对应枚举类
*
* @param status * @param status
* @return * @return
*/ */
@ -282,7 +333,7 @@ public interface TicketConstants {
Optional<FirstWorkTicketFlowStatusEnum> result = Arrays.stream(FirstWorkTicketFlowStatusEnum.class.getEnumConstants()).filter( Optional<FirstWorkTicketFlowStatusEnum> result = Arrays.stream(FirstWorkTicketFlowStatusEnum.class.getEnumConstants()).filter(
e -> status.equals(e.getStatus()) e -> status.equals(e.getStatus())
).findAny(); ).findAny();
if(result.isPresent()){ if (result.isPresent()) {
return result.get(); return result.get();
} }
return null; return null;
@ -294,15 +345,16 @@ public interface TicketConstants {
/** /**
* 票据合格 * 票据合格
*/ */
enum TicketQualifiedEnum{ enum TicketQualifiedEnum {
Qualified(1,"合格"), Qualified(1, "合格"),
No_Qualified(2,"不合格"); No_Qualified(2, "不合格");
@Getter @Getter
private Integer code; private Integer code;
@Getter @Getter
private String msg; private String msg;
TicketQualifiedEnum(Integer code, String msg) { TicketQualifiedEnum(Integer code, String msg) {
this.code = code; this.code = code;
this.msg = msg; this.msg = msg;

8
hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/feign/ITicketInfoClient.java

@ -29,6 +29,7 @@ public interface ITicketInfoClient {
String UPDATE_UNDONE_STATUS = API_PREFIX + "/updateUndoneStatus"; String UPDATE_UNDONE_STATUS = API_PREFIX + "/updateUndoneStatus";
String GET_WORK_TICKET_BY_TIME = API_PREFIX + "/getWorkTicketByTime"; String GET_WORK_TICKET_BY_TIME = API_PREFIX + "/getWorkTicketByTime";
String GET_OPERATE_TICKET_BY_TIME = API_PREFIX + "/getOperateTicketByTime"; String GET_OPERATE_TICKET_BY_TIME = API_PREFIX + "/getOperateTicketByTime";
String GET_TICKET_PASS_BY_IDS = API_PREFIX + "/getTicketPassByIds";
String GET_WORK_TICKET_TRANSFER = API_PREFIX + "/getWorkTicketTransfer"; String GET_WORK_TICKET_TRANSFER = API_PREFIX + "/getWorkTicketTransfer";
String GET_WORK_TICKET_STATISTIC = API_PREFIX + "/getWorkTicketStatistic"; String GET_WORK_TICKET_STATISTIC = API_PREFIX + "/getWorkTicketStatistic";
String GET_OPERATE_TICKET_STATISTIC = API_PREFIX + "/getOperateTicketStatistic"; String GET_OPERATE_TICKET_STATISTIC = API_PREFIX + "/getOperateTicketStatistic";
@ -61,6 +62,13 @@ public interface ITicketInfoClient {
@GetMapping(GET_OPERATE_TICKET_BY_TIME) @GetMapping(GET_OPERATE_TICKET_BY_TIME)
R<List<StandardTicketInfoEntity>> getOperateTicketByTime(@RequestParam String startDate, @RequestParam String endDate); R<List<StandardTicketInfoEntity>> getOperateTicketByTime(@RequestParam String startDate, @RequestParam String endDate);
/**
* 获取操作票的合格率
* @param ticekeIds
* @return
*/
@GetMapping(GET_TICKET_PASS_BY_IDS)
R<Long> getTicketPassByIds(@RequestParam List<Long> ticekeIds);
/*** /***
* 根据时间段获取工作票变更负责人列表 * 根据时间段获取工作票变更负责人列表
* @param startDate * @param startDate

5
hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/feign/TicketInfoClientFallback.java

@ -8,6 +8,7 @@ import com.hnac.hzims.ticket.workTicket.vo.WorkTicketStatisticVO;
import com.hnac.hzims.vo.SafeCheckStatisticVO; import com.hnac.hzims.vo.SafeCheckStatisticVO;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -33,6 +34,10 @@ public class TicketInfoClientFallback implements ITicketInfoClient {
} }
@Override @Override
public R<Long> getTicketPassByIds(@RequestParam List<Long> ticekeIds) {
return R.fail("查询失败!");
}
@Override
public R<List<WorkTicketPrincipalChangeEntity>> getWorkTicketTransfer(String startDate, String endDate) { public R<List<WorkTicketPrincipalChangeEntity>> getWorkTicketTransfer(String startDate, String endDate) {
return R.fail("查询失败!"); return R.fail("查询失败!");
} }

6
hzims-service/operational/pom.xml

@ -74,6 +74,12 @@
<artifactId>poi-ooxml-schemas</artifactId> <artifactId>poi-ooxml-schemas</artifactId>
<version>3.15</version> <version>3.15</version>
</dependency> </dependency>
<!-- 由于poi使用的poi-ooxml-schemas是ooxml-schemas的精简版,所以在was服务器上导出Excel可能会报错-->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>ooxml-schemas</artifactId>
<version>1.1</version>
</dependency>
<dependency> <dependency>
<groupId>org.jfree</groupId> <groupId>org.jfree</groupId>
<artifactId>jcommon</artifactId> <artifactId>jcommon</artifactId>

3
hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyEmergencyServiceImpl.java

@ -80,6 +80,9 @@ public class ImsDutyEmergencyServiceImpl extends BaseServiceImpl<ImsDutyEmergenc
if (CollectionUtils.isNotEmpty(records)){ if (CollectionUtils.isNotEmpty(records)){
collect= records.stream().map(sig -> { collect= records.stream().map(sig -> {
R<User> user = userClient.userInfoById(sig.getRegistrant()); R<User> user = userClient.userInfoById(sig.getRegistrant());
if (!user.isSuccess()&&ObjectUtils.isNotEmpty(user)){
}
sig.setRegistrantName(user.getData().getName()); sig.setRegistrantName(user.getData().getName());
R<User> userR = userClient.userInfoById(sig.getChargePerson()); R<User> userR = userClient.userInfoById(sig.getChargePerson());
sig.setChargePersonName(userR.getData().getName()); sig.setChargePersonName(userR.getData().getName());

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

@ -38,6 +38,7 @@ public class AreaMonthReportController extends BladeController {
@NotNull @NotNull
private final IAreaMonthReportService service; private final IAreaMonthReportService service;
private final static String load_hydropower_unit_real_key = "hzims:operation:loadhydropowerunit:real:key";
@ApiLog @ApiLog
@ApiOperationSupport(order = 1) @ApiOperationSupport(order = 1)
@ -85,7 +86,7 @@ public class AreaMonthReportController extends BladeController {
//模拟柱状图图数据 //模拟柱状图图数据
String[] monthArray = {"一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月"}; String[] monthArray = {"一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月"};
double[] value = {20, 30, 25, 50, 40, 25, 50, 40}; double[] value = {20, 30, 25, 50, 40, 25, 50, 40};
ImageEntity lineEntity = JFreeUtil.lineChart("测试111", monthArray, value,300, 200); ImageEntity lineEntity = JFreeUtil.lineChartV1("测试111", monthArray, value,300, 200);
map.put("lineEntity", lineEntity); map.put("lineEntity", lineEntity);
//模拟其它普通数据 //模拟其它普通数据
@ -113,5 +114,21 @@ public class AreaMonthReportController extends BladeController {
WordUtils.exportWord("template/demo2.docx", "F:/", "生成文件.docx", map); WordUtils.exportWord("template/demo2.docx", "F:/", "生成文件.docx", map);
return R.success("测试成功"); return R.success("测试成功");
} }
@ApiLog
@ApiOperationSupport(order = 3)
@ApiOperation("导出水电站月报")
@GetMapping("/exportHydropowerStationMonthReport")
public R exportHydropowerStationMonthReport(HttpServletResponse response, @ApiParam(value = "日期-年", required = true) Integer year,@ApiParam(value = "日期-月", required = true) Integer month,
@ApiParam(value = "日期-日", required = true) Integer date,@ApiParam(value = "站点Id", required = true) Long stationId,@ApiParam(value = "月报类型", required = true) Long type) {
if (type==1){
HashMap<String, Object> map = new HashMap<>();
service.exportHydropowerStationMonthReport(response, map,year,month,date,stationId);
WordUtils.exportWord("template/waterMonV3.docx", "F:/", "生成月报.docx", map);
//word模板相对路径、word生成路径、word生成的文件名称、数据源
}
return R.success("测试成功");
}
} }

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

@ -4,6 +4,7 @@ import com.hnac.hzims.operational.main.vo.AreaMonthReportVo;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List; import java.util.List;
/** /**
@ -16,4 +17,6 @@ public interface IAreaMonthReportService {
R<List<AreaMonthReportVo>> getReport(String date); R<List<AreaMonthReportVo>> getReport(String date);
R export(HttpServletResponse response, String date); R export(HttpServletResponse response, String date);
R exportHydropowerStationMonthReport(HttpServletResponse response, HashMap<String, Object> map, Integer year, Integer month, Integer date,Long stationId);
} }

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

@ -1,27 +1,44 @@
package com.hnac.hzims.operational.main.service.impl; package com.hnac.hzims.operational.main.service.impl;
import cn.afterturn.easypoi.entity.ImageEntity;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.equipment.entity.PlanGenerationEntity; import com.hnac.hzims.equipment.entity.PlanGenerationEntity;
import com.hnac.hzims.equipment.feign.IEmParamClient;
import com.hnac.hzims.equipment.feign.IPlanGenertionClient; import com.hnac.hzims.equipment.feign.IPlanGenertionClient;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.message.dto.MailPushDto; import com.hnac.hzims.message.dto.MailPushDto;
import com.hnac.hzims.message.fegin.IPushMsgClient; import com.hnac.hzims.message.fegin.IPushMsgClient;
import com.hnac.hzims.operational.defect.constants.TreatMethodConstant;
import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity;
import com.hnac.hzims.operational.defect.service.IOperPhenomenonService; import com.hnac.hzims.operational.defect.service.IOperPhenomenonService;
import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.main.service.IAreaMonthReportService; import com.hnac.hzims.operational.main.service.IAreaMonthReportService;
import com.hnac.hzims.operational.main.service.IMainSystemMonitoringService;
import com.hnac.hzims.operational.main.service.IMainTaskStatisticService; import com.hnac.hzims.operational.main.service.IMainTaskStatisticService;
import com.hnac.hzims.operational.main.vo.AreaMonthReportVo; import com.hnac.hzims.operational.main.vo.AreaMonthReportVo;
import com.hnac.hzims.operational.main.vo.HydropowerUnitRealVo;
import com.hnac.hzims.operational.main.vo.MaintainVo; import com.hnac.hzims.operational.main.vo.MaintainVo;
import com.hnac.hzims.operational.main.vo.OverhaulVo; import com.hnac.hzims.operational.main.vo.OverhaulVo;
import com.hnac.hzims.operational.report.vo.DutyDefectVO; import com.hnac.hzims.operational.report.vo.*;
import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.service.IStationService; import com.hnac.hzims.operational.station.service.IStationService;
import com.hnac.hzims.operational.util.JFreeUtil;
import com.hnac.hzims.operational.util.TimeUtils;
import com.hnac.hzims.operational.util.WordUtils;
import com.hnac.hzims.safeproduct.dto.SafeEquipmentTrialDTO; import com.hnac.hzims.safeproduct.dto.SafeEquipmentTrialDTO;
import com.hnac.hzims.safeproduct.feign.ISafeCheckClient; import com.hnac.hzims.safeproduct.feign.ISafeCheckClient;
import com.hnac.hzims.safeproduct.feign.ISafeEquipmentTrialClient; import com.hnac.hzims.safeproduct.feign.ISafeEquipmentTrialClient;
import com.hnac.hzims.ticket.constants.TicketConstants;
import com.hnac.hzims.ticket.standardTicket.entity.StandardTicketInfoEntity;
import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity;
import com.hnac.hzims.ticket.workTicket.feign.ITicketInfoClient; import com.hnac.hzims.ticket.workTicket.feign.ITicketInfoClient;
import com.hnac.hzims.ticket.workTicket.vo.TicketMonthVO; import com.hnac.hzims.ticket.workTicket.vo.TicketMonthVO;
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO;
import com.hnac.hzinfo.inspect.task.feign.IInspectTaskReportClient; import com.hnac.hzinfo.inspect.task.feign.IInspectTaskReportClient;
import com.hnac.hzinfo.inspect.task.vo.DutyInspectTaskVO; import com.hnac.hzinfo.inspect.task.vo.DutyInspectTaskVO;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
import org.apache.poi.hssf.usermodel.*; import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.hssf.util.HSSFColor; import org.apache.poi.hssf.util.HSSFColor;
@ -30,6 +47,7 @@ import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.ss.usermodel.HorizontalAlignment; import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.VerticalAlignment; import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellRangeAddress;
import org.jfree.data.category.DefaultCategoryDataset;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.DateUtil;
@ -78,6 +96,14 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
@NotNull @NotNull
private final IPlanGenertionClient planGenertionClient; private final IPlanGenertionClient planGenertionClient;
@NotNull @NotNull
private final IEmParamClient emParamClient;
@NotNull
private final SideHustleServiceImpl sideHustleService;
@NotNull
private final AnalyseDataServiceImpl analyseDataService;
@NotNull
private final IMainSystemMonitoringService mainSystemMonitoringService;
@NotNull
private final ISysClient sysClient; private final ISysClient sysClient;
@NotNull @NotNull
private final IUserClient userClient; private final IUserClient userClient;
@ -93,10 +119,15 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
private final ISafeCheckClient safeCheckClient; private final ISafeCheckClient safeCheckClient;
@Value("${hzims.operation.area.report}") @Value("${hzims.operation.area.report}")
private String area_month_report_key; private String area_month_report_key;
private final static String RECENT_YEAR_POWER_DATA = "hzims:operation:key:power:data"; private final static String RECENT_YEAR_POWER_DATA = "hzims:operation:key:power:data";
private final static String load_hydropower_unit_real_key = "hzims:operation:loadhydropowerunit:real:key";
private final static String load_hydropower_unit_target_key = "hzims:operation:loadhydropowerunit:target:key";
private final static String recent_year_power_data = "hzims:operation:key:power:data";
// 线程数量 // 线程数量
private final static int POOL_QUANTITY = 4; private final static int POOL_QUANTITY = 4;
@ -117,12 +148,12 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
*/ */
@Override @Override
public R<List<AreaMonthReportVo>> getReport(String date) { public R<List<AreaMonthReportVo>> getReport(String date) {
List<AreaMonthReportVo> areaMonthReportVoList = this.getAreaMonthReport(date,false); List<AreaMonthReportVo> areaMonthReportVoList = this.getAreaMonthReport(date, false);
if (CollectionUtil.isEmpty(areaMonthReportVoList)) { if (CollectionUtil.isEmpty(areaMonthReportVoList)) {
R.fail("选择月份无统计报表数据"); R.fail("选择月份无统计报表数据");
} }
//根据用户权限获取机构 //根据用户权限获取机构
return R.data(areaMonthReportVoList.stream().sorted(Comparator.comparing(AreaMonthReportVo::getActualPower,Comparator.reverseOrder())).collect(Collectors.toList())); return R.data(areaMonthReportVoList.stream().sorted(Comparator.comparing(AreaMonthReportVo::getActualPower, Comparator.reverseOrder())).collect(Collectors.toList()));
} }
/** /**
@ -133,7 +164,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
*/ */
@Override @Override
public R export(HttpServletResponse response, String date) { public R export(HttpServletResponse response, String date) {
List<AreaMonthReportVo> monthReportVoList = this.getAreaMonthReport(date,true); List<AreaMonthReportVo> monthReportVoList = this.getAreaMonthReport(date, true);
// 创建Excel文件 // 创建Excel文件
HSSFWorkbook hssWB = new HSSFWorkbook(); HSSFWorkbook hssWB = new HSSFWorkbook();
// 添加sheet页 // 添加sheet页
@ -172,6 +203,647 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
return R.data("success"); return R.data("success");
} }
public static void main(String[] args) {
HashMap<String, Object> map = new HashMap<>();
List<TicketChartVo> ticketList = new ArrayList<>();
TicketConstants.TicketTypeNameEnum[] values = TicketConstants.TicketTypeNameEnum.values();
TicketChartVo sum=new TicketChartVo();
List<TicketChartCell> sas = new ArrayList<>();
sum.setDeptName("总计");
for (TicketConstants.TicketTypeNameEnum value : values) {
TicketChartCell ticketChartCell = new TicketChartCell();
ticketChartCell.setTicketType(value.getType());
ticketChartCell.setTicketName(value.getFileName());
Integer integer = Integer.valueOf(value.getType());
ticketChartCell.setTicketMon(30+ integer);
BigDecimal d=BigDecimal.valueOf(integer).divide(BigDecimal.valueOf(100),2,BigDecimal.ROUND_UP);
ticketChartCell.setTicketMonPerc(0.3+ d.doubleValue());
sas.add(ticketChartCell);
}
sum.setChartCells(sas);
ticketList.add(sum);
//两票柱状图数据
// 创建数据
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
for (TicketChartVo chartVo : ticketList) {
for (int i = 0; i < chartVo.getChartCells().size(); i++) {
TicketChartCell ticketChartCell = chartVo.getChartCells().get(i);
dataset.addValue(ticketChartCell.getTicketMon(), ticketChartCell.getTicketName(), ticketChartCell.getTicketName());
}
}
DefaultCategoryDataset datasetLine = new DefaultCategoryDataset();
for (TicketChartVo chartVo : ticketList) {
for (int i = 0; i < chartVo.getChartCells().size(); i++) {
TicketChartCell ticketChartCell = chartVo.getChartCells().get(i);
datasetLine.addValue(ticketChartCell.getTicketMonPerc(), "合格率", ticketChartCell.getTicketName());
}
}
String title="水电运维项目两票统计表";
String domainAxis="数量";
String rangeAxis="票据类型";
ImageEntity ticketImage = JFreeUtil.iCreateBarLineChart(false, title, domainAxis, rangeAxis, dataset, datasetLine,662, 378);
map.put("ticketImage", ticketImage);
WordUtils.exportWord("template/waterMonV4.docx", "F:/", "888.docx", map);
}
@Override
public R exportHydropowerStationMonthReport(HttpServletResponse response, HashMap<String, Object> map, Integer year, Integer month, Integer date, Long deptId) {
R<String> deptNameR = sysClient.getDeptName(deptId);
if (!deptNameR.isSuccess()) {
return R.fail("暂无该机构");
}
String deptName = deptNameR.getData();
R<List<Dept>> deptR = sysClient.getDeptByType("200000", deptId, 4);
if (!deptR.isSuccess() || deptR.getData() == null) {
return R.fail("该机构不包含水站信息");
}
List<Dept> deptList = deptR.getData().stream().filter(s -> s.getStationId() != null).collect(Collectors.toList());
if (deptList == null) {
return R.fail("该机构不包含水站信息");
}
List<Long> deptIds = deptList.stream().map(s -> s.getId()).collect(Collectors.toList());
//其它普通数据
map.put("year", year);
Integer yearBefore = year - 1;
map.put("yearBefore", yearBefore);
map.put("month", month);
Integer monthBefore = month - 1;
map.put("monthBefore", monthBefore);
map.put("date", date);
map.put("commissionTime", "commissionTime");
map.put("stationName", deptName);
// 今年年度
String yearStart = TimeUtils.getYear(year);
String yearEnd = TimeUtils.getYearEnd(year);
String yearEndV2 = TimeUtils.getYearEndV2(year);
//去年年度
String yearBeforeStart = TimeUtils.getYear(yearBefore);
String yearBeforeEnd = TimeUtils.getYearEnd(yearBefore);
// 今年当月
String monthStart = TimeUtils.getMonthStart(year, month);
String monthEnd = TimeUtils.getMonthEnd(year, month);
String monthEndV2 = TimeUtils.getMonthEndV2(year, month);
// 今年上个月
String beforeMonthStart = TimeUtils.getMonthStart(year, monthBefore);
String beforeMonthEnd = TimeUtils.getMonthEnd(year, monthBefore);
// 去年当月
String monthStartBeforeYear = TimeUtils.getMonthStart(yearBefore, month);
String monthEndBeforeYear = TimeUtils.getMonthEnd(yearBefore, month);
// 所有设备信息
List<EminfoAndEmParamVo> devices = mainSystemMonitoringService.getEmInfoList();
List<HydropowerUnitRealVo> reals = (List<HydropowerUnitRealVo>) redisTemplate.opsForValue().get(load_hydropower_unit_real_key);
// R<Integer> installedCapacityCountByDepts = emParamClient.getInstalledCapacityCountByDepts(deptIds);
// if (installedCapacityCountByDepts.isSuccess()){
// double sum = Optional.ofNullable(installedCapacityCountByDepts.getData())
// .orElse(new ArrayList<>()).stream()
// .filter(s -> s.getInstalledCapacity() != null)
// .mapToDouble(HydropowerUnitRealVo::getInstalledCapacity).sum();
// map.put("installedCapacity", 0);
// }
// List<HydropowerUnitRealVo> realsByDept = reals.stream().filter(s -> deptIds.contains(s.getDeptId())).collect(Collectors.toList());
// TODO 伪造数据
List<HydropowerUnitRealVo> realsByDept = reals.stream().filter(s -> deptIds.contains(s.getDeptId())).map(s->{s.setInstalledCapacity(3.2);return s;}).collect(Collectors.toList());
// 装机容量占比数据组装
//总容量
double sum = Optional.ofNullable(realsByDept)
.orElse(new ArrayList<>()).stream()
.filter(s -> s.getInstalledCapacity() != null)
.mapToDouble(HydropowerUnitRealVo::getInstalledCapacity).sum();
map.put("installedCapacity", sum);
//各站点分组
Map<Long, List<HydropowerUnitRealVo>> listMap = Optional.ofNullable(realsByDept)
.orElse(new ArrayList<>()).stream()
.filter(s -> s.getInstalledCapacity() != null)
.collect(Collectors.groupingBy(HydropowerUnitRealVo::getDeptId));
Map<String, Double> capacityProportionMap = new HashMap<>();
for (Map.Entry<Long, List<HydropowerUnitRealVo>> longListEntry : listMap.entrySet()) {
BigDecimal bigDecimal = BigDecimal.valueOf(0);
for (HydropowerUnitRealVo hydropowerUnitRealVo : longListEntry.getValue()) {
bigDecimal = BigDecimal.valueOf(hydropowerUnitRealVo.getInstalledCapacity()).add(bigDecimal);
}
for (Dept dept : deptList) {
if (dept.getId().equals(longListEntry.getKey())) {
capacityProportionMap.put(dept.getDeptName(), bigDecimal.doubleValue());
}
}
}
//装机容量占比图
ImageEntity capacityProportionChart = JFreeUtil.pieChartByDouble("水电项目装机容量占比图", capacityProportionMap, 500, 400);
map.put("capacityProportionChart", capacityProportionChart);
//各发电站发电量环比图+表格数据组装
List<MonPowerPercentageVo> powerPercentageVoList = new ArrayList<>();
for (Dept dept : deptList) {
MonPowerPercentageVo powerVo = new MonPowerPercentageVo();
powerVo.setDeptId(dept.getId());
powerVo.setDeptName(dept.getDeptName());
BigDecimal powerYear = new BigDecimal(0);
BigDecimal powerYearBefore = new BigDecimal(0);
BigDecimal powerMonth = new BigDecimal(0);
BigDecimal powerMonthBefore = new BigDecimal(0);
BigDecimal powerMonthYearBefore = new BigDecimal(0);
Double planGeneration = 0d;
// todo shuju
// List<PlanGenerationEntity> planYearData = planGenertionClient.getPlanGenerationByParam(null, Arrays.asList(dept.getId().toString()), year.toString());
PlanGenerationEntity planGenerationEntity=new PlanGenerationEntity();
planGenerationEntity.setPlanGeneration(2f);
List<PlanGenerationEntity> planYearData =new ArrayList<>();
planYearData.add(planGenerationEntity);
if (CollectionUtils.isNotEmpty(planYearData)) {
planGeneration = Double.valueOf(planYearData.get(0).getPlanGeneration());
}
// 站点设备集合
List<EminfoAndEmParamVo> stationDevices = devices.stream().filter(device -> device.getCreateDept().equals(dept.getId())).collect(Collectors.toList());
for (EminfoAndEmParamVo device : stationDevices) {
//今年发电量
// List<AnalyseDataTaosVO> analyseData = analyseDataService.periodTargetData(yearStart, yearEnd, 3, EquipmentConstants.CycleTypeEnum.YEAR_CYCLE.getType(), device.getEmCode(), HomePageConstant.ELECTRICITY_CONSUMPTION);
AnalyseDataTaosVO analyseData1=new AnalyseDataTaosVO();
analyseData1.setVal("2");
List<AnalyseDataTaosVO> analyseData =new ArrayList<>();
analyseData.add(analyseData1);
// todo 数据还原
if (CollectionUtil.isNotEmpty(analyseData)) {
BigDecimal yearPower = analyseData.stream().filter(ktv -> ktv.getVal() != null)
.map(ktv -> BigDecimal.valueOf(Double.valueOf(ktv.getVal())))
.reduce(BigDecimal.ZERO, BigDecimal::add);
powerYear = powerYear.add(yearPower);
}
//去年发电量
// List<AnalyseDataTaosVO> analyseDataYearBefore = analyseDataService.periodTargetData(yearBeforeStart, yearBeforeEnd, 3, EquipmentConstants.CycleTypeEnum.YEAR_CYCLE.getType(), device.getEmCode(), HomePageConstant.ELECTRICITY_CONSUMPTION);
AnalyseDataTaosVO analyseDataYearBefore1=new AnalyseDataTaosVO();
analyseDataYearBefore1.setVal("16");
List<AnalyseDataTaosVO> analyseDataYearBefore =new ArrayList<>();
analyseDataYearBefore.add(analyseDataYearBefore1);
// todo 数据还原
if (CollectionUtil.isNotEmpty(analyseDataYearBefore)) {
BigDecimal powerBefore = analyseDataYearBefore.stream().filter(ktv -> ktv.getVal() != null)
.map(ktv -> BigDecimal.valueOf(Double.valueOf(ktv.getVal())))
.reduce(BigDecimal.ZERO, BigDecimal::add);
powerYearBefore = powerYearBefore.add(powerBefore);
}
//今年当月发电量
// List<AnalyseDataTaosVO> analyseDataMonth = analyseDataService.periodTargetData(monthStart, monthEnd, 3, EquipmentConstants.CycleTypeEnum.MONTH_CYCLE.getType(), device.getEmCode(), HomePageConstant.ELECTRICITY_CONSUMPTION);
AnalyseDataTaosVO analyseDataMonth1=new AnalyseDataTaosVO();
analyseDataMonth1.setVal("0.66");
List<AnalyseDataTaosVO> analyseDataMonth =new ArrayList<>();
analyseDataMonth.add(analyseDataMonth1);
// todo 数据还原
if (CollectionUtil.isNotEmpty(analyseDataMonth)) {
BigDecimal powerBefore = analyseDataMonth.stream().filter(ktv -> ktv.getVal() != null)
.map(ktv -> BigDecimal.valueOf(Double.valueOf(ktv.getVal())))
.reduce(BigDecimal.ZERO, BigDecimal::add);
powerMonth = powerMonth.add(powerBefore);
}
//上个月发电量
// List<AnalyseDataTaosVO> analyseDataMonthBefore = analyseDataService.periodTargetData(beforeMonthStart, beforeMonthEnd, 3, EquipmentConstants.CycleTypeEnum.MONTH_CYCLE.getType(), device.getEmCode(), HomePageConstant.ELECTRICITY_CONSUMPTION);
AnalyseDataTaosVO analyseDataMonthBefore1=new AnalyseDataTaosVO();
analyseDataMonthBefore1.setVal("0.56");
List<AnalyseDataTaosVO> analyseDataMonthBefore =new ArrayList<>();
analyseDataMonthBefore.add(analyseDataMonthBefore1);
// todo 数据还原
if (CollectionUtil.isNotEmpty(analyseDataMonthBefore)) {
BigDecimal powerBefore = analyseDataMonthBefore.stream().filter(ktv -> ktv.getVal() != null)
.map(ktv -> BigDecimal.valueOf(Double.valueOf(ktv.getVal())))
.reduce(BigDecimal.ZERO, BigDecimal::add);
powerMonthBefore = powerMonthBefore.add(powerBefore);
}
//去年当月发电量
// List<AnalyseDataTaosVO> analyseDataMonthBeforeYear = analyseDataService.periodTargetData(monthStartBeforeYear, monthEndBeforeYear, 3, EquipmentConstants.CycleTypeEnum.MONTH_CYCLE.getType(), device.getEmCode(), HomePageConstant.ELECTRICITY_CONSUMPTION);
AnalyseDataTaosVO analyseDataMonthBeforeYear1=new AnalyseDataTaosVO();
analyseDataMonthBeforeYear1.setVal("0.3");
List<AnalyseDataTaosVO> analyseDataMonthBeforeYear =new ArrayList<>();
analyseDataMonthBeforeYear.add(analyseDataMonthBeforeYear1);
// todo 数据还原
if (CollectionUtil.isNotEmpty(analyseDataMonthBeforeYear)) {
BigDecimal powerBefore = analyseDataMonthBeforeYear.stream().filter(ktv -> ktv.getVal() != null)
.map(ktv -> BigDecimal.valueOf(Double.valueOf(ktv.getVal())))
.reduce(BigDecimal.ZERO, BigDecimal::add);
powerMonthYearBefore = powerMonthYearBefore.add(powerBefore);
}
}
powerVo.setPowerYear(powerYear.doubleValue());
powerVo.setPowerYearBefore(powerYearBefore.doubleValue());
BigDecimal yearPercentage = new BigDecimal(0);
BigDecimal planPercentage = new BigDecimal(0);
if (powerYearBefore.compareTo(BigDecimal.ZERO)!=0) {
yearPercentage = (powerYear.subtract(powerYearBefore)).divide(powerYearBefore, 2, BigDecimal.ROUND_UP);
}
if (BigDecimal.valueOf(planGeneration).compareTo(BigDecimal.ZERO)!=0) {
planPercentage = powerYear.divide(BigDecimal.valueOf(planGeneration), 2, BigDecimal.ROUND_UP);
}
powerVo.setPlanPercentage(planPercentage.doubleValue());
powerVo.setPowerYearPercentage(yearPercentage.doubleValue());
powerVo.setPowerMon(powerMonth.doubleValue());
powerVo.setPowerMonBefore(powerMonthBefore.doubleValue());
powerVo.setPowerMonYearBefore(powerMonthYearBefore.doubleValue());
BigDecimal monPercentage = new BigDecimal(0);
if (powerMonthYearBefore.compareTo(BigDecimal.ZERO)!=0) {
monPercentage = (powerMonth.subtract(powerMonthYearBefore)).divide(powerMonthYearBefore, 2, BigDecimal.ROUND_UP);
}
powerVo.setPowerMonPercentage(monPercentage.doubleValue());
powerPercentageVoList.add(powerVo);
}
// 各发电站发电量环比图数据组装
//柱状图图数据
// 创建数据
DefaultCategoryDataset powerDataset = new DefaultCategoryDataset();
for (MonPowerPercentageVo monPowerPercentageVo : powerPercentageVoList) {
powerDataset.addValue(monPowerPercentageVo.getPowerMonYearBefore(),monthBefore +"月", monPowerPercentageVo.getDeptName());
powerDataset.addValue(monPowerPercentageVo.getPowerMon(), month +"月", monPowerPercentageVo.getDeptName());
}
String powerTitle=deptName+"水电运维项目各电站发电量环比对比图(万kWh)";
String powerDomainAxis="发电量";
String powerRangeAxis="站点名称";
ImageEntity powerChainHistogram = JFreeUtil.iCreateBarChart( powerTitle, powerDomainAxis, powerRangeAxis, powerDataset, 500, 400);
map.put("powerChainHistogram", powerChainHistogram);
//柱状图下的表格
if (powerPercentageVoList != null) {
ArrayList<HashMap<String, String>> powerMap = new ArrayList<>(powerPercentageVoList.size());
for (MonPowerPercentageVo monPowerPercentageVo : powerPercentageVoList) {
HashMap<String, String> power = new HashMap<>();
power.put("name", monPowerPercentageVo.getDeptName());
power.put("monthBefore", String.valueOf(monPowerPercentageVo.getPowerMonBefore()));
power.put("month", String.valueOf(monPowerPercentageVo.getPowerMon()));
powerMap.add(power);
}
map.put("power", powerMap);
}
//表格总计
List<PlanGenerationEntity> planYearAll = planGenertionClient.getPlanGenerationByParam(null, Arrays.asList(deptId.toString()), year.toString());
List<PlanGenerationEntity> planMonAll = planGenertionClient.getPlanGenerationByParam(null, Arrays.asList(deptId.toString()), year + "-" + month);
getTabelSum(deptId, powerPercentageVoList, planYearAll, planMonAll, map);
//发电情况统计表数据
if (powerPercentageVoList != null) {
ArrayList<HashMap<String, String>> list = new ArrayList<>(powerPercentageVoList.size());
for (MonPowerPercentageVo monPowerPercentageVo : powerPercentageVoList) {
HashMap<String, String> temp = new HashMap<>(8);
temp.put("name", monPowerPercentageVo.getDeptName());
temp.put("powerMonBefore", String.valueOf(monPowerPercentageVo.getPowerMonYearBefore()));
temp.put("powerYearBefore", String.valueOf(monPowerPercentageVo.getPowerYearBefore()));
temp.put("mon",String.valueOf(monPowerPercentageVo.getPowerMon()));
temp.put("year",String.valueOf(monPowerPercentageVo.getPowerYear()));
temp.put("monPercentage", monPowerPercentageVo.getPowerMonPercentage()*100+"%");
temp.put("yearPercentage", monPowerPercentageVo.getPowerYearPercentage()*100+"%");
temp.put("plan",monPowerPercentageVo.getPlanPercentage()*100+"%");
list.add(temp);
}
map.put("powerGeneration", list);
}
//本月缺陷
LambdaQueryWrapper<OperPhenomenonEntity> wrapper = Wrappers.lambdaQuery();
wrapper.ge(OperPhenomenonEntity::getCreateTime, monthStart);
wrapper.le(OperPhenomenonEntity::getCreateTime, monthEndV2);
wrapper.eq(OperPhenomenonEntity::getIsDefect, TreatMethodConstant.IS_DEFECT);
wrapper.eq(OperPhenomenonEntity::getDiscriminateStatus, TreatMethodConstant.AUTO_SCREENED);
wrapper.in(OperPhenomenonEntity::getCreateDept, deptIds);
List<OperPhenomenonEntity> monPhenomenonList = operPhenomenonService.list(wrapper);
monPhenomenonList= monPhenomenonList.stream().filter(s -> s.getDefectLevel() != null).collect(Collectors.toList());
List<OperPhenomenonEntity> monConclusionList = monPhenomenonList.stream().filter(s -> s.getConclusionStatus().equals(1)).collect(Collectors.toList());
// 各电站缺陷处理统计表
monConclusionList.stream().sorted(Comparator.comparing(OperPhenomenonEntity::getDefectGrading).reversed().thenComparing(OperPhenomenonEntity::getCreateTime));
ArrayList<HashMap<String, String>> checkList = new ArrayList<>(monConclusionList.size());
for (OperPhenomenonEntity operPhenomenonEntity : monConclusionList) {
Long createDept = operPhenomenonEntity.getCreateDept();
R<String> createDeptName = sysClient.getDeptName(createDept);
if (!createDeptName.isSuccess() && createDeptName.getData() != null) {
continue;
}
//表格数据
HashMap<String, String> temp = new HashMap<>();
temp.put("name", createDeptName.getData());
temp.put("level", operPhenomenonEntity.getDefectGrading());
temp.put("createTime", operPhenomenonEntity.getCreateTime().toString());
temp.put("findTime", operPhenomenonEntity.getFindTime().toString());
temp.put("descripiton", operPhenomenonEntity.getDescripiton());
temp.put("disposeDesc", operPhenomenonEntity.getDisposeDesc());
checkList.add(temp);
}
map.put("checkList", checkList);
//各电站缺陷统计表
//本年缺陷
LambdaQueryWrapper<OperPhenomenonEntity> wrapperYear = Wrappers.lambdaQuery();
wrapperYear.ge(OperPhenomenonEntity::getCreateTime, yearStart);
wrapperYear.le(OperPhenomenonEntity::getCreateTime, yearEndV2);
wrapperYear.eq(OperPhenomenonEntity::getIsDefect, TreatMethodConstant.IS_DEFECT);
wrapperYear.eq(OperPhenomenonEntity::getDiscriminateStatus, TreatMethodConstant.AUTO_SCREENED);
wrapperYear.in(OperPhenomenonEntity::getCreateDept, deptIds);
List<OperPhenomenonEntity> yearPhenomenonEntities = operPhenomenonService.list(wrapperYear);
yearPhenomenonEntities= yearPhenomenonEntities.stream().filter(s ->StringUtil.isNotBlank(s.getDefectGrading())).filter(s -> ObjectUtil.isNotEmpty(s.getCreateDept())).collect(Collectors.toList());
List<OperPhenomenonEntity> yearConclusionList = yearPhenomenonEntities.stream().filter(s -> s.getConclusionStatus().equals(1)).collect(Collectors.toList());
ArrayList<HashMap<String, String>> checkStatistics = new ArrayList<>();
List<CheckChartVo> checkChartRes = new ArrayList<>();
if (CollectionUtil.isEmpty(yearPhenomenonEntities)) {
//表格数据
HashMap<String, String> temp = new HashMap<>();
temp.put("deptName", "总计");
temp.put("checkLevel", "0");
temp.put("findShortagesMon", "0");
temp.put("shortagesMon", "0");
temp.put("findShortagesYear", "0");
temp.put("shortagesYear", "0");
temp.put("shortagesRate", "0");
checkList.add(temp);
map.put("checkStatistics", checkStatistics);
} else {
Map<Long, Map<String, List<OperPhenomenonEntity>>> phenomenonMap = yearPhenomenonEntities.stream().collect(
Collectors.groupingBy(OperPhenomenonEntity::getCreateDept,
Collectors.groupingBy(OperPhenomenonEntity::getDefectGrading)));
for (Map.Entry<Long, Map<String, List<OperPhenomenonEntity>>> deptMapEntry : phenomenonMap.entrySet()) {
R<String> deptName1 = sysClient.getDeptName(deptMapEntry.getKey());
for (Map.Entry<String, List<OperPhenomenonEntity>> levelList : deptMapEntry.getValue().entrySet()) {
Integer findShortagesYear = levelList.getValue().size();
Integer shortagesYear = yearConclusionList.stream().filter(s -> s.getDefectLevel().equals(deptMapEntry)).filter(s -> s.getDefectLevel().equals(deptMapEntry)).collect(Collectors.toList()).size();
Double shortagesRate = 0d;
if (findShortagesYear != 0 && shortagesYear != 0) {
shortagesRate = BigDecimal.valueOf(shortagesYear).divide(BigDecimal.valueOf(findShortagesYear), 2, BigDecimal.ROUND_UP).doubleValue();
}
Integer findShortagesMon = Optional.ofNullable(monPhenomenonList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectLevel().equals(deptMapEntry)).filter(s -> s.getDefectLevel().equals(deptMapEntry)).collect(Collectors.toList()).size();
Integer shortagesMon = Optional.ofNullable(monConclusionList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectLevel().equals(deptMapEntry)).filter(s -> s.getDefectLevel().equals(deptMapEntry)).collect(Collectors.toList()).size();
CheckChartVo checkChartVo = new CheckChartVo(deptName1.getData(), levelList.getKey(), findShortagesMon, shortagesMon, findShortagesYear, shortagesYear, shortagesRate);
checkChartRes.add(checkChartVo);
}
}
// 总计
Map<String, List<OperPhenomenonEntity>> levelPhenomenonList = yearPhenomenonEntities.stream().collect(Collectors.groupingBy(OperPhenomenonEntity::getDefectGrading));
for (Map.Entry<String, List<OperPhenomenonEntity>> levelPhenomenon : levelPhenomenonList.entrySet()) {
Integer findShortagesYear = levelPhenomenon.getValue().size();
Integer shortagesYear = Optional.ofNullable(yearConclusionList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectLevel().equals(levelPhenomenon)).collect(Collectors.toList()).size();
Double shortagesRate = 0d;
if (findShortagesYear != 0 && shortagesYear != 0) {
shortagesRate = BigDecimal.valueOf(shortagesYear).divide(BigDecimal.valueOf(findShortagesYear), 2, BigDecimal.ROUND_UP).doubleValue();
}
Integer findShortagesMon = Optional.ofNullable(monPhenomenonList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectLevel().equals(levelPhenomenon)).collect(Collectors.toList()).size();
Integer shortagesMon = Optional.ofNullable(monConclusionList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectLevel().equals(levelPhenomenon)).collect(Collectors.toList()).size();
CheckChartVo checkChartVo = new CheckChartVo("总计", levelPhenomenon.getKey(), findShortagesMon, shortagesMon, findShortagesYear, shortagesYear, shortagesRate);
checkChartRes.add(checkChartVo);
}
}
for (CheckChartVo checkChartRe : checkChartRes) {
//表格数据
HashMap<String, String> temp = new HashMap<>();
temp.put("deptName", checkChartRe.getDeptName());
temp.put("checkLevel", checkChartRe.getCheckLevel());
temp.put("findShortagesMon",checkChartRe.getFindShortagesMon().toString());
temp.put("shortagesMon",checkChartRe.getShortagesMon().toString());
temp.put("findShortagesYear", checkChartRe.getShortagesYear().toString());
temp.put("shortagesYear", checkChartRe.getFindShortagesYear().toString());
temp.put("shortagesRate", checkChartRe.getShortagesRate().toString());
checkList.add(temp);
map.put("checkStatistics", checkStatistics);
}
// if (CollectionUtils.isNotEmpty(ticketNumbers)) {
// String percent = PercentCountUtils.getPercent(evaluateEntities.size(), ticketNumbers.size());
// ticketCount.setPercentPassTicket(percent);
// }
// 两票执行情况
R<List<WorkTicketInfoEntity>> yearTicket = ticketInfoClient.getWorkTicketByTime(yearStart, yearEndV2);
R<List<StandardTicketInfoEntity>> yearOperateTicket = ticketInfoClient.getOperateTicketByTime(yearStart, yearEndV2);
R<List<WorkTicketInfoEntity>> monthTicket = ticketInfoClient.getWorkTicketByTime(monthStart, monthEndV2);
R<List<StandardTicketInfoEntity>> monthOperateTicket = ticketInfoClient.getOperateTicketByTime(monthStart, monthEndV2);
if (!monthTicket.isSuccess() || !yearTicket.isSuccess() || !yearOperateTicket.isSuccess() || !monthOperateTicket.isSuccess()) {
return R.fail("两票查询异常,请稍后重试");
}
List<TicketChartVo> ticketList = new ArrayList<>();
for (Dept dept : deptList) {
String stationId = dept.getStationId();
if (stationId==null){
continue;
}
TicketChartVo chartVo = new TicketChartVo();
chartVo.setDeptName(dept.getDeptName());
List<TicketChartCell> cellList = new ArrayList<>();
for (TicketConstants.TicketTypeNameEnum value : TicketConstants.TicketTypeNameEnum.values()) {
TicketChartCell ticketChartCell = new TicketChartCell();
ticketChartCell.setTicketType(value.getType());
ticketChartCell.setTicketName(value.getFileName());
if (value.getTicketType()==2){
List<WorkTicketInfoEntity> yearTicketCollect = Optional.ofNullable(yearTicket.getData()).orElse(new ArrayList<>()).stream()
.filter(s ->stationId.equals(s.getSignageCode()))
.filter(s -> s.getType().equals(value.getType())).collect(Collectors.toList());
List<WorkTicketInfoEntity> monthTicketCollect = Optional.ofNullable(monthTicket.getData()).orElse(new ArrayList<>()).stream()
.filter(s -> s.getSignageCode().equals(stationId))
.filter(s -> s.getType().equals(value.getType())).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(yearTicketCollect)){
//年合格率和数量
Integer count = yearTicketCollect.size();
ticketChartCell.setTicketYear(count);
List<Long> ticketIds = yearTicketCollect.stream().map(s -> s.getId()).collect(Collectors.toList());
R<Long> ticketPassCount = ticketInfoClient.getTicketPassByIds(ticketIds);
if (ticketPassCount.isSuccess() && ticketPassCount.getData() != null&&count!=0) {
Double ticketYearPerc = BigDecimal.valueOf(ticketPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue();
ticketChartCell.setTicketYeaPercr(ticketYearPerc);
}
}
if (CollectionUtils.isNotEmpty(monthTicketCollect)){
//月合格率和数量
Integer count = monthTicketCollect.size();
ticketChartCell.setTicketMon(count);
List<Long> monthTicketIds = monthTicketCollect.stream().map(s -> s.getId()).collect(Collectors.toList());
R<Long> ticketMonthPassCount = ticketInfoClient.getTicketPassByIds(monthTicketIds);
if (ticketMonthPassCount.isSuccess() && ticketMonthPassCount.getData() != null&&count!=0) {
Double ticketMonthPerc = BigDecimal.valueOf(ticketMonthPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue();
ticketChartCell.setTicketMonPerc(ticketMonthPerc);
}
}
}
if (value.getTicketType()==1){
List<StandardTicketInfoEntity> yearOperateCollect = Optional.ofNullable(yearOperateTicket.getData()).orElse(new ArrayList<>()).stream()
.filter(s ->stationId.equals(s.getSignageCode()))
.filter(s -> s.getTicketType().equals(value.getType())).collect(Collectors.toList());
List<StandardTicketInfoEntity> monthOperateCollect = Optional.ofNullable(monthOperateTicket.getData()).orElse(new ArrayList<>()).stream()
.filter(s -> s.getSignageCode().equals(stationId))
.filter(s -> s.getTicketType().equals(value.getType())).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(yearOperateCollect)){
//年合格率和数量
Integer count = yearOperateCollect.size();
ticketChartCell.setTicketYear(count);
List<Long> ticketIds = yearOperateCollect.stream().map(s -> s.getId()).collect(Collectors.toList());
R<Long> ticketPassCount = ticketInfoClient.getTicketPassByIds(ticketIds);
if (ticketPassCount.isSuccess() && ticketPassCount.getData() != null&&count!=0) {
Double ticketYearPerc = BigDecimal.valueOf(ticketPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue();
ticketChartCell.setTicketYeaPercr(ticketYearPerc);
}
}
if (CollectionUtils.isNotEmpty(monthOperateCollect)){
//月合格率和数量
Integer count = monthOperateCollect.size();
ticketChartCell.setTicketMon(count);
List<Long> monthTicketIds = monthOperateCollect.stream().map(s -> s.getId()).collect(Collectors.toList());
R<Long> ticketMonthPassCount = ticketInfoClient.getTicketPassByIds(monthTicketIds);
if (ticketMonthPassCount.isSuccess() && ticketMonthPassCount.getData() != null&&count!=0) {
Double ticketMonthPerc = BigDecimal.valueOf(ticketMonthPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue();
ticketChartCell.setTicketMonPerc(ticketMonthPerc);
}
}
}
cellList.add(ticketChartCell);
}
chartVo.setChartCells(cellList);
ticketList.add(chartVo);
}
List<TicketChartCell> sumCollect=new ArrayList<>();
ticketList.stream().map(s -> sumCollect.addAll(s.getChartCells()));
Map<String, List<TicketChartCell>> groupingCollect = sumCollect.stream().collect(Collectors.groupingBy(TicketChartCell::getTicketType));
for (Map.Entry<String, List<TicketChartCell>> mapTicketChart : groupingCollect.entrySet()) {
TicketChartCell sumCell=new TicketChartCell();
sumCell.setTicketType(mapTicketChart.getKey());
sumCell.setTicketName(TicketConstants.TicketTypeNameEnum.getTicketNameByType(mapTicketChart.getKey()));
List<TicketChartCell> ticketChartValue = mapTicketChart.getValue();
sumCell.setTicketMon(ticketChartValue.stream().mapToInt(TicketChartCell::getTicketMon).sum());
sumCell.setTicketYear(ticketChartValue.stream().mapToInt(TicketChartCell::getTicketYear).sum());
sumCell.setTicketMonPerc(ticketChartValue.stream().mapToDouble(TicketChartCell::getTicketMonPerc).sum());
sumCell.setTicketYeaPercr(ticketChartValue.stream().mapToDouble(TicketChartCell::getTicketYeaPercr).sum());
sumCollect.add(sumCell);
}
TicketChartVo ticketChartVo=new TicketChartVo();
ticketChartVo.setDeptName("总计");
ticketChartVo.setChartCells(sumCollect);
//两票表格数据
ArrayList<HashMap<String, String>> ticketListRes = new ArrayList<>();
for (TicketChartVo chartVo : ticketList) {
HashMap<String, String> ticketMap = new HashMap<>();
for (TicketChartCell chartCell : chartVo.getChartCells()) {
String ticketType = chartCell.getTicketType();
ticketMap.put("deptName",chartVo.getDeptName());
ticketMap.put("info","执行");
ticketMap.put("infoPass","合格率");
ticketMap.put("ticketMon"+ticketType,String.valueOf(chartCell.getTicketMon()));
ticketMap.put("ticketYear"+ticketType,String.valueOf(chartCell.getTicketYear()));
ticketMap.put("ticketMonPerc"+ticketType,String.valueOf(chartCell.getTicketMonPerc()));
ticketMap.put("ticketYeaPercr"+ticketType,String.valueOf(chartCell.getTicketYeaPercr()));
}
ticketListRes.add(ticketMap);
}
map.put("ticketList", ticketListRes);
//两票柱状图数据
// 创建数据
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
for (TicketChartVo chartVo : ticketList) {
for (int i = 0; i < chartVo.getChartCells().size(); i++) {
TicketChartCell ticketChartCell = chartVo.getChartCells().get(i);
dataset.addValue(ticketChartCell.getTicketMon(), String.valueOf(i), ticketChartCell.getTicketName());
}
}
DefaultCategoryDataset datasetLine = new DefaultCategoryDataset();
for (TicketChartVo chartVo : ticketList) {
for (int i = 0; i < chartVo.getChartCells().size(); i++) {
TicketChartCell ticketChartCell = chartVo.getChartCells().get(i);
datasetLine.addValue(ticketChartCell.getTicketMonPerc(), ticketChartCell.getTicketName(), ticketChartCell.getTicketName());
}
}
String title=deptName+"水电运维项目两票统计表";
String domainAxis="数量";
String rangeAxis="票据类型";
ImageEntity ticketImage = JFreeUtil.iCreateBarLineChart(true, title, domainAxis, rangeAxis, dataset, datasetLine,662, 378);
map.put("ticketImage", ticketImage);
// //模拟表格数据
// ArrayList<HashMap<String, String>> list = new ArrayList<>(2);
//
// HashMap<String, String> temp = new HashMap<>(3);
// temp.put("name", "name1");
//// temp.put("name", "第一个人");
//// temp.put("age", "23");
// list.add(temp);
// temp = new HashMap<>(3);
// temp.put("name", "2");
//// temp.put("name", "第二个人");
//// temp.put("age", "24");
// list.add(temp);
// map.put("safelist", list);
// //模拟柱状图图数据
// String[] monthArray = {"一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月"};
// double[] value = {20, 30, 25, 50, 40, 25, 50, 40};
// ImageEntity lineEntity = JFreeUtil.lineChart("测试111", monthArray, value, 300, 200);
// map.put("lineEntity", lineEntity);
return R.success("成功");
}
private static void getTabelSum(Long deptId, List<MonPowerPercentageVo> powerPercentageVoList, List<PlanGenerationEntity> planYearAll, List<PlanGenerationEntity> planMonAll, HashMap<String, Object> map) {
Float planGeneration = 0f;
if (CollectionUtil.isNotEmpty(planYearAll)) {
planGeneration = planYearAll.get(0).getPlanGeneration();
}
Float planMonGeneration = 0f;
if (CollectionUtil.isNotEmpty(planYearAll)) {
planMonGeneration = planMonAll.get(0).getPlanGeneration();
}
MonPowerPercentageVo powerVo = new MonPowerPercentageVo();
powerVo.setDeptId(deptId);
powerVo.setDeptName("总计");
BigDecimal powerYear = powerPercentageVoList.stream()
.map(ktv -> BigDecimal.valueOf(ktv.getPowerYear()))
.reduce(BigDecimal.ZERO, BigDecimal::add);
powerVo.setPowerYear(powerYear.doubleValue());
map.put("powerYear", powerYear.toString());
BigDecimal powerYearBefore = powerPercentageVoList.stream()
.map(ktv -> BigDecimal.valueOf(ktv.getPowerYearBefore()))
.reduce(BigDecimal.ZERO, BigDecimal::add);
powerVo.setPowerYearBefore(powerYearBefore.doubleValue());
BigDecimal yearPercentage = new BigDecimal(0);
BigDecimal planPercentage = new BigDecimal(0);
if (powerYearBefore.compareTo(BigDecimal.ZERO)!=0) {
// 年累计环比
yearPercentage = (powerYear.subtract(powerYearBefore)).divide(powerYearBefore, 2, BigDecimal.ROUND_UP);
}
if (BigDecimal.valueOf(planGeneration).compareTo(BigDecimal.ZERO)!=0) {
planPercentage = powerYear.divide(BigDecimal.valueOf(planGeneration), 2, BigDecimal.ROUND_UP);
// 年计划完成率
map.put("yearCompletionRate", planPercentage.toString());
}else {
map.put("yearCompletionRate", 0);
}
powerVo.setPowerYearPercentage(yearPercentage.doubleValue());
powerVo.setPlanPercentage(planPercentage.doubleValue());
BigDecimal powerMonth = powerPercentageVoList.stream()
.map(ktv -> BigDecimal.valueOf(ktv.getPowerMon()))
.reduce(BigDecimal.ZERO, BigDecimal::add);
// 项目月发电量
powerVo.setPowerMon(powerMonth.doubleValue());
map.put("powerMon", powerMonth.toString());
// 项目月计划完成量
BigDecimal planMonPercentage = new BigDecimal(0);
if (powerMonth.compareTo(BigDecimal.ZERO)!=0 &&BigDecimal.valueOf(planMonGeneration).compareTo(BigDecimal.ZERO)!=0) {
planMonPercentage = powerMonth.divide(BigDecimal.valueOf(planMonGeneration), 2, BigDecimal.ROUND_UP);
}
map.put("monCompletionRate", planMonPercentage);
BigDecimal powerMonthBefore = powerPercentageVoList.stream()
.map(ktv -> BigDecimal.valueOf(ktv.getPowerMonBefore()))
.reduce(BigDecimal.ZERO, BigDecimal::add);
powerVo.setPowerMonBefore(powerMonthBefore.doubleValue());
BigDecimal powerMonthYearBefore = powerPercentageVoList.stream()
.map(ktv -> BigDecimal.valueOf(ktv.getPowerMonYearBefore()))
.reduce(BigDecimal.ZERO, BigDecimal::add);
powerVo.setPowerMonYearBefore(powerMonthYearBefore.doubleValue());
BigDecimal monPercentage = new BigDecimal(0);
if (powerMonthYearBefore.compareTo(BigDecimal.ZERO)!=0) {
monPercentage =(powerMonth.subtract(powerMonthYearBefore)).divide(powerMonthYearBefore, 2, BigDecimal.ROUND_UP);
}
//发电量环比增加
BigDecimal monAdd = powerMonth.subtract(powerMonthBefore);
if (powerMonthBefore.compareTo(BigDecimal.ZERO)==0) {
map.put("percentageAdd", 0);
} else {
map.put("percentageAdd", monAdd.divide(powerMonthBefore, 2, BigDecimal.ROUND_UP).toString());
}
powerVo.setPowerMonPercentage(monPercentage.doubleValue());
powerPercentageVoList.add(powerVo);
}
/** /**
* 首行表头样式 * 首行表头样式
* *
@ -406,7 +1078,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
* *
* @return * @return
*/ */
private List<AreaMonthReportVo> getAreaMonthReport(String date,boolean isSendFlag) { private List<AreaMonthReportVo> getAreaMonthReport(String date, boolean isSendFlag) {
R<List<Dept>> D = sysClient.getDeptByCurrentUser(); R<List<Dept>> D = sysClient.getDeptByCurrentUser();
if (!D.isSuccess() || CollectionUtil.isEmpty(D.getData())) { if (!D.isSuccess() || CollectionUtil.isEmpty(D.getData())) {
return null; return null;
@ -419,9 +1091,9 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
if (MapUtils.isEmpty(map)) { if (MapUtils.isEmpty(map)) {
return null; return null;
} }
if(isSendFlag){ if (isSendFlag) {
// 发送邮件 // 发送邮件
this.sendMonthReport(map,D.getData()); this.sendMonthReport(map, D.getData());
} }
return map.get(date); return map.get(date);
} }
@ -509,9 +1181,9 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
// 站点实际发电量 // 站点实际发电量
Map<Long, Float> actualMap = getActualPower(powerMap, stationList, mon + "-01"); Map<Long, Float> actualMap = getActualPower(powerMap, stationList, mon + "-01");
// 站点去年发电量 // 站点去年发电量
Map<Long, Float> oldActualMap = getActualPower(powerMap, stationList, getLastyear(1,mon)); Map<Long, Float> oldActualMap = getActualPower(powerMap, stationList, getLastyear(1, mon));
// 站点前发电量 // 站点前发电量
Map<Long, Float> oldOldActualMap = getActualPower(powerMap, stationList, getLastyear(2,mon)); Map<Long, Float> oldOldActualMap = getActualPower(powerMap, stationList, getLastyear(2, mon));
// 取机构中区域部分 // 取机构中区域部分
List<Dept> areaList = deptList.stream().filter(o -> o.getDeptCategory().equals(3)).collect(Collectors.toList()); List<Dept> areaList = deptList.stream().filter(o -> o.getDeptCategory().equals(3)).collect(Collectors.toList());
if (CollectionUtil.isEmpty(areaList)) { if (CollectionUtil.isEmpty(areaList)) {
@ -535,11 +1207,11 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
// 日常维护、巡检任务、缺陷数、消缺率、检修任务 // 日常维护、巡检任务、缺陷数、消缺率、检修任务
this.taskMonth(Collections.singletonList(area.getId()), areaMonthReport, mon + "-01 00:00:00", getStrEndTime(mon)); this.taskMonth(Collections.singletonList(area.getId()), areaMonthReport, mon + "-01 00:00:00", getStrEndTime(mon));
// 预测 // 预测
this.getPredictPlanPower(oldActualMap,oldOldActualMap,areaStationList,areaMonthReport); this.getPredictPlanPower(oldActualMap, oldOldActualMap, areaStationList, areaMonthReport);
// 安全生产会议次数、月度检查报告、技能培训、安全大检查 // 安全生产会议次数、月度检查报告、技能培训、安全大检查
this.getSecurityCheck(Collections.singletonList(area.getId()),areaMonthReport,mon + "-01 00:00:00", getStrEndTime(mon)); this.getSecurityCheck(Collections.singletonList(area.getId()), areaMonthReport, mon + "-01 00:00:00", getStrEndTime(mon));
// 设备试验 // 设备试验
this.getDeviceTry(mon + "-01 00:00:00", getStrEndTime(mon), Collections.singletonList(area.getId()),areaMonthReport); this.getDeviceTry(mon + "-01 00:00:00", getStrEndTime(mon), Collections.singletonList(area.getId()), areaMonthReport);
areaMonthReportVoList.add(areaMonthReport); areaMonthReportVoList.add(areaMonthReport);
}); });
return areaMonthReportVoList; return areaMonthReportVoList;
@ -547,6 +1219,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
/** /**
* 预测发电量 * 预测发电量
*
* @param oldActualMap * @param oldActualMap
* @param oldOldActualMap * @param oldOldActualMap
* @param areaStationList * @param areaStationList
@ -556,12 +1229,12 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
areaMonthReport.setPredictPlanPower(0.0); areaMonthReport.setPredictPlanPower(0.0);
// 实际发电量 // 实际发电量
List<Long> ids = areaStationList.stream().map(StationEntity::getId).collect(Collectors.toList()); List<Long> ids = areaStationList.stream().map(StationEntity::getId).collect(Collectors.toList());
if(CollectionUtil.isEmpty(ids)){ if (CollectionUtil.isEmpty(ids)) {
return; return;
} }
double oldActualPower = oldActualMap.entrySet().stream().filter(e -> ids.contains(e.getKey())).mapToDouble(Map.Entry::getValue).sum(); double oldActualPower = oldActualMap.entrySet().stream().filter(e -> ids.contains(e.getKey())).mapToDouble(Map.Entry::getValue).sum();
double oldOldActualPower = oldOldActualMap.entrySet().stream().filter(e -> ids.contains(e.getKey())).mapToDouble(Map.Entry::getValue).sum(); double oldOldActualPower = oldOldActualMap.entrySet().stream().filter(e -> ids.contains(e.getKey())).mapToDouble(Map.Entry::getValue).sum();
if(Math.abs(oldActualPower) <= 0 && Math.abs(oldOldActualPower) <= 0 ){ if (Math.abs(oldActualPower) <= 0 && Math.abs(oldOldActualPower) <= 0) {
return; return;
} }
double predictPlanPower = BigDecimal.valueOf((oldActualPower + oldOldActualPower) / 2).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); double predictPlanPower = BigDecimal.valueOf((oldActualPower + oldOldActualPower) / 2).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
@ -580,19 +1253,19 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
} }
// 获取邮件接收人 // 获取邮件接收人
Dept dept = list.stream().min(Comparator.comparing(Dept::getDeptCategory)).get(); Dept dept = list.stream().min(Comparator.comparing(Dept::getDeptCategory)).get();
if(ObjectUtil.isEmpty(dept)){ if (ObjectUtil.isEmpty(dept)) {
return; return;
} }
R<List<User>> userR = userClient.userListByDeptAndChildrenWithAuth(dept.getId()); R<List<User>> userR = userClient.userListByDeptAndChildrenWithAuth(dept.getId());
if(!userR.isSuccess() && CollectionUtil.isEmpty(userR.getData())){ if (!userR.isSuccess() && CollectionUtil.isEmpty(userR.getData())) {
return; return;
} }
List<User> userList = userR.getData().stream().filter(o->dept.getId().equals(o.getCreateDept())).collect(Collectors.toList()); List<User> userList = userR.getData().stream().filter(o -> dept.getId().equals(o.getCreateDept())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(userList)){ if (CollectionUtil.isEmpty(userList)) {
return; return;
} }
List<String> mailList = userList.stream().map(User::getEmail).filter(StringUtil::isNotBlank).collect(Collectors.toList()); List<String> mailList = userList.stream().map(User::getEmail).filter(StringUtil::isNotBlank).collect(Collectors.toList());
if(CollectionUtil.isEmpty(mailList)){ if (CollectionUtil.isEmpty(mailList)) {
return; return;
} }
// 获取月报数据 // 获取月报数据
@ -608,7 +1281,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
Map<String, Object> param = new HashMap<>(); Map<String, Object> param = new HashMap<>();
param.put("templatePath", "/data/hzims/message/mail/template/stationRunMonthReport.html"); param.put("templatePath", "/data/hzims/message/mail/template/stationRunMonthReport.html");
Map<String, Object> parameters = new HashMap<>(); Map<String, Object> parameters = new HashMap<>();
parameters.put("data",entityList); parameters.put("data", entityList);
param.put("parameters", parameters); param.put("parameters", parameters);
pushDto.setExtras(param); pushDto.setExtras(param);
pushDto.setText("水电站生产运行月报内容"); pushDto.setText("水电站生产运行月报内容");
@ -692,7 +1365,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
return; return;
} }
float actualPower = 0f; float actualPower = 0f;
if(ObjectUtil.isNotEmpty(monthMap.get(month))){ if (ObjectUtil.isNotEmpty(monthMap.get(month))) {
actualPower = monthMap.get(month); actualPower = monthMap.get(month);
} }
actualPowerMap.put(key, actualPower); actualPowerMap.put(key, actualPower);
@ -854,12 +1527,13 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
/** /**
* 安全检查 * 安全检查
*
* @param areas * @param areas
* @param areaMonthReport * @param areaMonthReport
* @param startTime * @param startTime
* @param endTime * @param endTime
*/ */
private void getSecurityCheck(List<Long> areas, AreaMonthReportVo areaMonthReport,String startTime,String endTime) { private void getSecurityCheck(List<Long> areas, AreaMonthReportVo areaMonthReport, String startTime, String endTime) {
areaMonthReport.setSafetyMeeting(0); areaMonthReport.setSafetyMeeting(0);
areaMonthReport.setSelfReport(0); areaMonthReport.setSelfReport(0);
areaMonthReport.setSkillTrainy(0); areaMonthReport.setSkillTrainy(0);
@ -871,7 +1545,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
map.put("deptList", areas); map.put("deptList", areas);
// 调用安全大检查fegin接口 // 调用安全大检查fegin接口
R<Map<String, Object>> R = safeCheckClient.getCount(map); R<Map<String, Object>> R = safeCheckClient.getCount(map);
if(!R.isSuccess() || MapUtils.isEmpty(R.getData())){ if (!R.isSuccess() || MapUtils.isEmpty(R.getData())) {
return; return;
} }
// 安全生产会议 // 安全生产会议
@ -886,19 +1560,20 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
/** /**
* 获取设备试验数据 * 获取设备试验数据
*
* @param startTime * @param startTime
* @param endTime * @param endTime
* @param areas * @param areas
* @param areaMonthReport * @param areaMonthReport
*/ */
private void getDeviceTry(String startTime,String endTime,List<Long> areas,AreaMonthReportVo areaMonthReport) { private void getDeviceTry(String startTime, String endTime, List<Long> areas, AreaMonthReportVo areaMonthReport) {
areaMonthReport.setDeviceTry(0); areaMonthReport.setDeviceTry(0);
SafeEquipmentTrialDTO request = new SafeEquipmentTrialDTO(); SafeEquipmentTrialDTO request = new SafeEquipmentTrialDTO();
request.setDeptList(areas); request.setDeptList(areas);
request.setStartTime(startTime); request.setStartTime(startTime);
request.setEndTime(endTime); request.setEndTime(endTime);
R<Integer> R = safeEquipmentTrialClient.getCount(request); R<Integer> R = safeEquipmentTrialClient.getCount(request);
if(!R.isSuccess() || ObjectUtil.isEmpty(R.getData())){ if (!R.isSuccess() || ObjectUtil.isEmpty(R.getData())) {
return; return;
} }
areaMonthReport.setDeviceTry(R.getData()); areaMonthReport.setDeviceTry(R.getData());
@ -909,7 +1584,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
* *
* @return * @return
*/ */
private String getLastyear(int year,String mon) { private String getLastyear(int year, String mon) {
try { try {
Date date = sdf.parse(mon + "-01 00:00:00"); Date date = sdf.parse(mon + "-01 00:00:00");
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();

835
hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/JFreeUtil.java

@ -3,26 +3,37 @@ package com.hnac.hzims.operational.util;
import cn.afterturn.easypoi.entity.ImageEntity; import cn.afterturn.easypoi.entity.ImageEntity;
import cn.hutool.core.lang.Assert; import cn.hutool.core.lang.Assert;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.poi.xwpf.usermodel.XWPFTable;
import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartUtils; import org.jfree.chart.ChartUtils;
import org.jfree.chart.JFreeChart; import org.jfree.chart.JFreeChart;
import org.jfree.chart.StandardChartTheme; import org.jfree.chart.StandardChartTheme;
import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.CategoryLabelPositions;
import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.labels.StandardCategoryItemLabelGenerator;
import org.jfree.chart.labels.StandardCategoryToolTipGenerator;
import org.jfree.chart.labels.StandardPieSectionLabelGenerator; import org.jfree.chart.labels.StandardPieSectionLabelGenerator;
import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.DatasetRenderingOrder;
import org.jfree.chart.plot.PiePlot; import org.jfree.chart.plot.PiePlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.category.BarRenderer; import org.jfree.chart.renderer.category.BarRenderer;
import org.jfree.chart.renderer.category.CategoryItemRenderer; import org.jfree.chart.renderer.category.CategoryItemRenderer;
import org.jfree.chart.renderer.category.LineAndShapeRenderer; import org.jfree.chart.renderer.category.LineAndShapeRenderer;
import org.jfree.chart.renderer.category.StandardBarPainter;
import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.general.DefaultPieDataset; import org.jfree.data.general.DefaultPieDataset;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTVMerge;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STMerge;
import java.awt.*; import java.awt.*;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.text.DecimalFormat;
import java.util.Map; import java.util.Map;
@Slf4j @Slf4j
@ -57,6 +68,44 @@ public class JFreeUtil {
file.delete(); file.delete();
return buffer; return buffer;
} }
public static ImageEntity pieChartByDouble(String title, Map<String, Double> datas, int width, int height) {
//创建主题样式
StandardChartTheme standardChartTheme = new StandardChartTheme("CN");
//设置标题字体
standardChartTheme.setExtraLargeFont(new Font("宋体", Font.BOLD, 20));
//设置图例的字体
standardChartTheme.setRegularFont(new Font("宋体", Font.PLAIN, 15));
//设置轴向的字体
standardChartTheme.setLargeFont(new Font("宋体", Font.PLAIN, 15));
//设置主题样式
ChartFactory.setChartTheme(standardChartTheme);
//根据jfree生成一个本地饼状图
DefaultPieDataset pds = new DefaultPieDataset();
datas.forEach(pds::setValue);
//图标标题、数据集合、是否显示图例标识、是否显示tooltips、是否支持超链接
JFreeChart chart = ChartFactory.createPieChart(title, pds, true, false, false);
//设置抗锯齿
chart.setTextAntiAlias(false);
PiePlot plot = (PiePlot) chart.getPlot();
plot.setNoDataMessage("暂无数据");
//忽略无值的分类
plot.setIgnoreNullValues(true);
plot.setBackgroundAlpha(0f);
//设置标签阴影颜色
plot.setShadowPaint(new Color(255, 255, 255));
//设置标签生成器(默认{0})
plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}({1})/{2}"));
try {
ChartUtils.saveChartAsJPEG(new File(tempImgPath), chart, width, height);
} catch (IOException e1) {
log.error("生成饼状图失败!");
}
ImageEntity imageEntity = new ImageEntity(imgToByte(tempImgPath), width, height);
Assert.notNull(imageEntity.getData(), "生成饼状图对象失败!");
return imageEntity;
}
public static ImageEntity pieChart(String title, Map<String, Integer> datas, int width, int height) { public static ImageEntity pieChart(String title, Map<String, Integer> datas, int width, int height) {
@ -96,7 +145,8 @@ public class JFreeUtil {
Assert.notNull(imageEntity.getData(), "生成饼状图对象失败!"); Assert.notNull(imageEntity.getData(), "生成饼状图对象失败!");
return imageEntity; return imageEntity;
} }
// public static ImageEntity lineChart(String title, Map<String, Integer> datas, int width, int height) {
// public static ImageEntity lineChart(String title, Map<String, Integer> datas, int width, int height) {
// //
// //创建主题样式 // //创建主题样式
// StandardChartTheme standardChartTheme = new StandardChartTheme("CN"); // StandardChartTheme standardChartTheme = new StandardChartTheme("CN");
@ -137,8 +187,40 @@ public class JFreeUtil {
// Assert.notNull(imageEntity.getData(),"生成饼状图对象失败!"); // Assert.notNull(imageEntity.getData(),"生成饼状图对象失败!");
// return imageEntity; // return imageEntity;
// } // }
public static ImageEntity lineChart(String title, DefaultCategoryDataset dataset, double[] value, int width, int height) {
// 创建CategoryPlot对象
CategoryPlot plot = new CategoryPlot();
// 添加第一个数据集并渲染为line
CategoryItemRenderer lineRenderer = new LineAndShapeRenderer();
plot.setDataset(0, dataset);
plot.setRenderer(0, lineRenderer);
// 添加第二个数据集并渲染为线条bar
CategoryItemRenderer baRenderer = new BarRenderer();
plot.setDataset(1, dataset);
plot.setRenderer(1, baRenderer);
// 设置坐标轴
plot.setDomainAxis(new CategoryAxis("数量"));
plot.setRangeAxis(new NumberAxis("票据类型"));
// 创建JFreeChart对象
JFreeChart chart = new JFreeChart(plot);
// todo 标题验证
chart.setTitle(title);
try {
ChartUtils.saveChartAsJPEG(new File(tempImgPath2), chart, width, height);
} catch (IOException e) {
e.printStackTrace();
}
ImageEntity imageEntity = new ImageEntity(imgToByte(tempImgPath2), width, height);
Assert.notNull(imageEntity.getData(), "生成柱状图对象失败!");
return imageEntity;
}
public static ImageEntity lineChart( String title,String[] monthArray,double[] value,int width, int height) { public static ImageEntity lineChartV1(String title, String[] monthArray, double[] value, int width, int height) {
// 创建数据 // 创建数据
DefaultCategoryDataset dataset = new DefaultCategoryDataset(); DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(1.0, "A", "Ⅰ"); dataset.addValue(1.0, "A", "Ⅰ");
@ -176,537 +258,224 @@ public class JFreeUtil {
e.printStackTrace(); e.printStackTrace();
} }
ImageEntity imageEntity = new ImageEntity(imgToByte(tempImgPath2), width, height); ImageEntity imageEntity = new ImageEntity(imgToByte(tempImgPath2), width, height);
Assert.notNull(imageEntity.getData(),"生成饼状图对象失败!"); Assert.notNull(imageEntity.getData(), "生成饼状图对象失败!");
return imageEntity; return imageEntity;
} }
// public static ImageEntity lineChart( String title,String[] monthArray,double[] value,int width, int height) {
// //如果不使用Font,中文将显示不出来 /**
// Font font = new Font("新宋体", Font.BOLD, 15); * 创建柱状+折现统计复合图
// // 创建数据 *
// Map<String, Map<String, Double>> datas = new HashMap<String, Map<String, Double>>(); * @param isAddLine
// for (int i = 0; i < monthArray.length; i++) { * @param title
// Map<String, Double> map = new HashMap<String, Double>(); * @param domainAxisLabel
// map.put("故障数量", value[i]); * @param rangeAxisLabel
// datas.put(monthArray[i], map); * @param dataset
// } * @param datasetLine
// JFreeChart chart = createLineChart(title, datas, "月份", "故障次数(次)", font); * @param width
// try { * @param height
// ChartUtils.saveChartAsJPEG(new File(tempImgPath), chart, 800, 600); * @return
// } catch (IOException e) { */
// e.printStackTrace(); public static ImageEntity iCreateBarLineChart(Boolean isAddLine, String title, String domainAxisLabel, String rangeAxisLabel,
// } DefaultCategoryDataset dataset, DefaultCategoryDataset datasetLine, int width, int height) {
// ImageEntity imageEntity = new ImageEntity(imgToByte(), 800, 600); // TODO Auto-generated method stub
// Assert.notNull(imageEntity.getData(),"生成饼状图对象失败!"); JFreeChart chart = ChartFactory.createBarChart(title,
// return imageEntity; domainAxisLabel, rangeAxisLabel, dataset, PlotOrientation.VERTICAL, // 图表方向:水平、垂直
// } true, // 是否显示图例(对于简单的柱状图必须是false)
// false, // 是否生成工具
// public static JFreeChart createLineChart(String title, Map<String, Map<String, Double>> data, String type, String unit, Font font) { false);
// try { iSetBarChart(chart);
// DefaultCategoryDataset ds = new DefaultCategoryDataset(); if (isAddLine) {
// Set<Map.Entry<String, Map<String, Double>>> set1 = data.entrySet(); CategoryPlot categoryplot = chart.getCategoryPlot();
// Iterator iterator1 = set1.iterator(); categoryplot.setDataset(1, datasetLine);
// Iterator iterator2; LineAndShapeRenderer lineandshaperenderer = new LineAndShapeRenderer();
// HashMap<String, Double> map; lineandshaperenderer.setDefaultToolTipGenerator(new StandardCategoryToolTipGenerator());
// Set<Map.Entry<String, Double>> set2; lineandshaperenderer.setDefaultItemLabelGenerator(new StandardCategoryItemLabelGenerator());
// Map.Entry entry1; lineandshaperenderer.setDefaultLinesVisible(true);
// Map.Entry entry2; lineandshaperenderer.setSeriesPaint(0, Color.decode("#9BBB59"));
// while (iterator1.hasNext()) { categoryplot.setRenderer(1, lineandshaperenderer);
// entry1 = (Map.Entry) iterator1.next(); NumberAxis numberaxis = new NumberAxis("平均值");
// map = (HashMap<String, Double>) entry1.getValue(); numberaxis.setLabelFont(new Font("宋体", Font.TRUETYPE_FONT, 12));
// set2 = map.entrySet(); categoryplot.setRangeAxis(1, numberaxis);
// iterator2 = set2.iterator(); categoryplot.mapDatasetToRangeAxis(1, 1);
// while (iterator2.hasNext()) { categoryplot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
// entry2 = (Map.Entry) iterator2.next(); }
// ds.setValue(Double.parseDouble(entry2.getValue().toString()), entry2.getKey().toString(), entry1.getKey().toString()); // JFreeChart lineChart = ChartFactory.createLineChart(title,
// } // domainAxisLabel, rangeAxisLabel, dataset);
// } try {
// ChartUtils.saveChartAsJPEG(new File(tempImgPath2), chart, width, height);
// //创建折线图,折线图分水平显示和垂直显示两种 } catch (IOException e) {
// // //2D折线图 e.printStackTrace();
// JFreeChart chart = ChartFactory.createLineChart(title, type, unit, ds, PlotOrientation.VERTICAL, true, true, true); }
// // //3D折线图 ImageEntity imageEntity = new ImageEntity(imgToByte(tempImgPath2), width, height);
//// JFreeChart chart2 = ChartFactory.createLineChart3D(title, type, unit, ds, PlotOrientation.VERTICAL, true, true, false); Assert.notNull(imageEntity.getData(), "生成柱状+折现统计复合图对象失败!");
// return imageEntity;
// //设置整个图片的标题字体 }
// chart.getTitle().setFont(font);
// /**
// //设置提示条字体 * 双色柱状图
// font = new Font("宋体", Font.BOLD, 15); *
// chart.getLegend().setItemFont(font); * @param title
// * @param domainAxisLabel
// //得到绘图区 * @param rangeAxisLabel
// CategoryPlot plot = (CategoryPlot) chart.getPlot(); * @param dataset
// //得到绘图区的域轴(横轴),设置标签的字体 * @param width
// plot.getDomainAxis().setLabelFont(font); * @param height
// * @return
// // 设置背景透明度 */
// plot.setBackgroundAlpha(0.1f); public static ImageEntity iCreateBarChart(String title, String domainAxisLabel, String rangeAxisLabel,
// // 设置网格横线颜色 DefaultCategoryDataset dataset, int width, int height) {
// plot.setRangeGridlinePaint(Color.gray); // TODO Auto-generated method stub
// // 设置网格横线大小 JFreeChart chart = ChartFactory.createBarChart(title,
// plot.setDomainGridlineStroke(new BasicStroke(0.2F)); domainAxisLabel, rangeAxisLabel, dataset);
// plot.setRangeGridlineStroke(new BasicStroke(0.2F)); iSetBarChartDouble(chart);
// try {
// //设置横轴标签项字体 ChartUtils.saveChartAsJPEG(new File(tempImgPath2), chart, width, height);
// plot.getDomainAxis().setTickLabelFont(font); } catch (IOException e) {
// e.printStackTrace();
// // 生成折线图上的数字 }
// //绘图区域(红色矩形框的部分) ImageEntity imageEntity = new ImageEntity(imgToByte(tempImgPath2), width, height);
// LineAndShapeRenderer lineAndShapeRenderer = (LineAndShapeRenderer) plot.getRenderer(); Assert.notNull(imageEntity.getData(), "生成柱状+折现统计复合图对象失败!");
// lineAndShapeRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); return imageEntity;
// //设置图表上的数字可见 }
// lineAndShapeRenderer.setBaseItemLabelsVisible(true);
// //设置图表上的数字字体
// lineAndShapeRenderer.setBaseItemLabelFont(new Font("宋体", Font.BOLD, 15)); public static void iSetBarChart(JFreeChart chart) {
// CategoryPlot categoryplot = chart.getCategoryPlot();// 图本身
// //设置折线图拐角上的正方形 ValueAxis rangeAxis = categoryplot.getRangeAxis();
// //创建一个正方形 CategoryAxis domainAxis = categoryplot.getDomainAxis();
// Rectangle shape = new Rectangle(4, 4); // 设置Y轴的提示文字样式
// lineAndShapeRenderer.setSeriesShape(0, shape); rangeAxis.setLabelFont(new Font("微软雅黑", Font.PLAIN, 12));
// //设置拐角上图形可见 // 设置Y轴刻度线的长度
// lineAndShapeRenderer.setSeriesShapesVisible(0, true); rangeAxis.setTickMarkInsideLength(10f);
//
// /*// 获取显示线条的对象 domainAxis.setCategoryLabelPositions(CategoryLabelPositions.STANDARD); // 横轴上的
// LineAndShapeRenderer lasp = (LineAndShapeRenderer) plot.getRenderer(); domainAxis.setLowerMargin(0.1);
// // 设置拐点是否可见/是否显示拐点 domainAxis.setUpperMargin(0.1);
// lasp.setBaseShapesVisible(true);
// // 设置拐点不同用不同的形状 // rangeAxis.setTickMarkOutsideLength(10f);
// lasp.setDrawOutlines(true); // 设置X轴下的标签文字
// // 设置线条是否被显示填充颜色 domainAxis.setLabelFont(new Font("微软雅黑", Font.PLAIN, 12));
// lasp.setUseFillPaint(true); // 设置X轴上提示文字样式
// // 设置拐点颜色 domainAxis.setTickLabelFont(new Font("微软雅黑", Font.PLAIN, 12));
// lasp.setBaseFillPaint(Color.blue);//蓝色*/ NumberAxis vn = (NumberAxis) categoryplot.getRangeAxis();
// //设置范围轴(纵轴)字体
// font = new Font("宋体", Font.BOLD, 18); // 设置Y轴的数字为百分比样式显示设置Y轴的数字为百分比样式显示
// plot.getRangeAxis().setLabelFont(font); DecimalFormat df = new DecimalFormat("0.0");
//// plot.setForegroundAlpha(1.0f); vn.setNumberFormatOverride(df);
// return chart; // 使柱状图反过来显示
// } catch (Exception e) { // vn.setInverted(true);
// e.printStackTrace(); // vn.setVerticalTickLabels(true);
// return null;
// } // 自定义柱状图中柱子的样式
// } BarRenderer brender = new BarRenderer();
// brender.setSeriesPaint(0, Color.decode("#C0504D")); // 给series1 Bar
// /** brender.setSeriesPaint(1, Color.decode("#E46C0A")); // 给series2 Bar
// * 生成折线图 brender.setSeriesPaint(2, Color.decode("#4F81BD")); // 给series3 Bar
// * 1.解析数据<br> brender.setSeriesPaint(3, Color.decode("#00B050")); // 给series4 Bar
// * 2.迭代数据,产出图片数据流,并添加到List<br> brender.setSeriesPaint(4, Color.decode("#7030A0")); // 给series5 Bar
// * brender.setSeriesPaint(5, Color.decode("#00BF00")); // 给series6 Bar
// * @throws IOException // 设置柱状图的顶端显示数字
// */ brender.setIncludeBaseInRange(true);
// public ArrayList createLineAndShapeChart(double[][] data, String[] rowKeys, String[] columnKeys, ChartEntity entity) throws IOException { brender.setDefaultItemLabelGenerator(new StandardCategoryItemLabelGenerator());
// ArrayList list = new ArrayList(); brender.setDefaultItemLabelsVisible(true);
// byte[] bytes = new byte[]{}; // 设置柱子为平面图不是立体的
// // 解析数据 brender.setBarPainter(new StandardBarPainter());
// Map map = this.parseDataForBarPage(data, rowKeys, columnKeys); // 设置柱状图之间的距离0.1代表10%;
// int pageNum = Integer.parseInt("" + map.get("pageNum")); brender.setItemMargin(0.3);
// // 迭代,产生图片数据流 // 设置柱子的阴影,false代表没有阴影
// for (int i = 0; i < pageNum; i++) { brender.setShadowVisible(false);
// bytes = createSingleLineAndShapeChart((double[][]) (map.get("data" + i)), (String[]) (map.get("rowKeys" + i)),
// (String[]) (map.get("columnKeys" + i)), entity); // 设置图的背景为白色
// list.add(bytes); categoryplot.setBackgroundPaint(Color.WHITE);
// } // 设置背景虚线的颜色
// return list; categoryplot.setRangeGridlinePaint(Color.decode("#B6A2DE"));
// } // 去掉柱状图的背景边框,使边框不可见
// categoryplot.setOutlineVisible(false);
// /** // 设置标题的字体样式
// * 生成单个折线图数据流 chart.getTitle().setFont(new Font("微软雅黑", Font.PLAIN, 24));
// * // 设置图表下方图例上的字体样式
// * @param data chart.getLegend().setItemFont(new Font("微软雅黑", Font.PLAIN, 12));
// * @param rowKeys
// * @param columnKeys categoryplot.setRenderer(brender);
// * @param entity
// * @return
// * @throws IOException }
// */
// public byte[] createSingleLineAndShapeChart(double[][] data, String[] rowKeys, String[] columnKeys, ChartEntity entity) throws IOException { public static void iSetBarChartDouble(JFreeChart chart) {
// CategoryDataset dataset = getBarData(data, rowKeys, columnKeys); CategoryPlot categoryplot = chart.getCategoryPlot();// 图本身
// JFreeChart chart = createTimeXYChar(dataset, entity); ValueAxis rangeAxis = categoryplot.getRangeAxis();
// byte[] bytes = this.createImage(chart, entity); CategoryAxis domainAxis = categoryplot.getDomainAxis();
// return bytes; // 设置Y轴的提示文字样式
// } rangeAxis.setLabelFont(new Font("微软雅黑", Font.PLAIN, 12));
// // 设置Y轴刻度线的长度
// rangeAxis.setTickMarkInsideLength(10f);
// /**
// * 生成柱状图<br> rangeAxis.setTickMarkOutsideLength(10f);
// * 1.解析数据<br> // 设置X轴下的标签文字
// * 2.迭代数据,产出图片数据流,并添加到List<br> domainAxis.setLabelFont(new Font("微软雅黑", Font.PLAIN, 12));
// * // 设置X轴上提示文字样式
// * @param data 数据 domainAxis.setTickLabelFont(new Font("微软雅黑", Font.PLAIN, 12));
// * @param rowKeys 行 NumberAxis vn = (NumberAxis) categoryplot.getRangeAxis();
// * @param columnKeys 列
// * @param entity 图片配置对象 // 设置Y轴的数字为百分比样式显示设置Y轴的数字为百分比样式显示
// * @return 包含多个图片数据流的List DecimalFormat df = new DecimalFormat("0.0");
// * @throws IOException vn.setNumberFormatOverride(df);
// */ // 使柱状图反过来显示
// public ArrayList createStackedBarChart(double[][] data, String[] rowKeys, String[] columnKeys, ChartEntity entity) throws IOException { // vn.setInverted(true);
// // 解析数据 // vn.setVerticalTickLabels(true);
// ArrayList list = new ArrayList();
// byte[] bytes = new byte[]{}; // // 自定义柱状图中柱子的样式
// Map map = this.parseDataForBarPage(data, rowKeys, columnKeys); BarRenderer brender = new BarRenderer();
// int pageNum = Integer.parseInt("" + map.get("pageNum")); brender.setSeriesPaint(0, Color.gray);
// // 迭代数据,产出图片数据流,并添加到List brender.setSeriesPaint(1, Color.orange);
// for (int i = 0; i < pageNum; i++) { // brender.setSeriesPaint(1, Color.decode("#C0504D")); // 给series1 Bar
// bytes = createSingleStackedBarChart((double[][]) (map.get("data" + i)), (String[]) (map.get("rowKeys" + i)), // brender.setSeriesPaint(2, Color.decode("#C0504D")); // 给series1 Bar
// (String[]) (map.get("columnKeys" + i)), entity); // brender.setSeriesPaint(0, Color.decode("#E46C0A")); // 给series2 Bar
// list.add(bytes); // brender.setSeriesPaint(2, Color.decode("#4F81BD")); // 给series3 Bar
// } // brender.setSeriesPaint(3, Color.decode("#00B050")); // 给series4 Bar
// return list; // brender.setSeriesPaint(4, Color.decode("#7030A0")); // 给series5 Bar
// } // brender.setSeriesPaint(5, Color.decode("#00BF00")); // 给series6 Bar
// // 设置柱状图的顶端显示数字
// /** brender.setIncludeBaseInRange(true);
// * 解析生成柱状图分页数据 // brender.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
// * // brender.setBaseItemLabelsVisible(isBaseItemLabelsVisible());
// * @param data // 设置柱子为平面图不是立体的
// * @param rowKeys brender.setBarPainter(new StandardBarPainter());
// * @param columnKeys // 设置柱状图之间的距离0.1代表10%;
// * @return brender.setItemMargin(0.1);
// */ // // 设置柱子的阴影,false代表没有阴影
// private Map parseDataForBarPage(double[][] data, String[] rowKeys, String[] columnKeys) { brender.setShadowVisible(false);
// Map map = new HashMap();
// // 设置图的背景为白色
// double[][] pageData = null; categoryplot.setBackgroundPaint(Color.WHITE);
// String[] pageColumn = null; // 设置背景虚线的颜色
// categoryplot.setRangeGridlinePaint(Color.decode("#B6A2DE"));
// int sumColumnNum = columnKeys.length; // 总列数 // 去掉柱状图的背景边框,使边框不可见
// int indexNum = Config.getInt("image.export.pagesize", 10);// 分页的列数 categoryplot.setOutlineVisible(false);
// int pageNum = sumColumnNum % indexNum == 0 ? sumColumnNum / indexNum : sumColumnNum / indexNum + 1; // 分页数 // 设置标题的字体样式
// int rowNum = rowKeys.length; chart.getTitle().setFont(new Font("微软雅黑", Font.PLAIN, 24));
// // 设置图表下方图例上的字体样式
// // log.debug("data.length="+data.length+"sumColumnNum="+sumColumnNum+" indexNum="+indexNum+" pageNum="+pageNum+" rowNum="+rowNum+" "); chart.getLegend().setItemFont(new Font("微软雅黑", Font.PLAIN, 12));
//
// // 解析传递过来的数据 categoryplot.setRenderer(brender);
// for (int i = 0; i < pageNum; i++) {
// int columnNum = (sumColumnNum - i * indexNum) / indexNum > 0 ? indexNum : (sumColumnNum - i * indexNum) % indexNum;//当前页列数
// pageData = new double[rowNum][columnNum]; }
// // 取数据值
// for (int j = 0; j < rowNum; j++) {
// pageColumn = new String[columnNum]; public static void mergeCell(XWPFTable table, int beginRowIndex, int endRowIndex, int colIndex) {
// for (int k = 0; k < columnNum; k++) { if (beginRowIndex == endRowIndex || beginRowIndex > endRowIndex) {
// pageData[j][k] = data[j][k + i * indexNum]; // 数据 return;
// } }
// } //合并行单元格的第一个单元格
// // 取列值 CTVMerge startMerge = CTVMerge.Factory.newInstance();
// for (int j = 0; j < columnNum; j++) { startMerge.setVal(STMerge.RESTART);
// pageColumn[j] = columnKeys[j + i * indexNum]; // 列 //合并行单元格的第一个单元格之后的单元格
// } CTVMerge endMerge = CTVMerge.Factory.newInstance();
// // 保存数据并返回 endMerge.setVal(STMerge.CONTINUE);
// map.put("data" + i, pageData); table.getRow(beginRowIndex).getCell(colIndex).getCTTc().getTcPr().setVMerge(startMerge);
// map.put("rowKeys" + i, rowKeys); for (int i = beginRowIndex + 1; i <= endRowIndex; i++) {
// map.put("columnKeys" + i, pageColumn); table.getRow(i).getCell(colIndex).getCTTc().getTcPr().setVMerge(endMerge);
// } }
// // 保存分页数 }
// map.put("pageNum", pageNum);
// return map;
// }
//
// /**
// * 解析生成折线图分页数据
// *
// * @param data
// * @param rowKeys
// * @param columnKeys
// * @return
// */
// private Map parseDataForLinePage(double[][] data, String[] rowKeys, String[] columnKeys) {
// Map map = new HashMap();
//
// double[][] pageData = null;
// String[] pageColumn = null;
//
// int sumColumnNum = columnKeys.length; // 总列数
// int indexNum = Config.getInt("image.export.pagesize", 10);// 分页的列数
// int pageNum = sumColumnNum % indexNum == 0 ? sumColumnNum / indexNum : sumColumnNum / indexNum + 1; // 分页数
// int rowNum = rowKeys.length;
//
// // log.debug("data.length="+data.length+"sumColumnNum="+sumColumnNum+" indexNum="+indexNum+" pageNum="+pageNum+" rowNum="+rowNum+" ");
//
// // 解析传递过来的数据
// for (int i = 0; i < pageNum; i++) {
// int columnNum = (sumColumnNum - i * indexNum) / indexNum > 0 ? indexNum : (sumColumnNum - i * indexNum) % indexNum;//当前页列数
// pageData = new double[rowNum][columnNum];
// // 取数据值
// for (int j = 0; j < rowNum; j++) {
// pageColumn = new String[columnNum];
// for (int k = 0; k < columnNum; k++) {
// pageData[j][k] = data[j][k + i * indexNum]; // 数据
// }
// }
// // 取列值
// for (int j = 0; j < columnNum; j++) {
// pageColumn[j] = columnKeys[j + i * indexNum]; // 列
// }
// // 保存数据并返回
// map.put("data" + i, pageData);
// map.put("rowKeys" + i, rowKeys);
// map.put("columnKeys" + i, pageColumn);
// }
// // 保存分页数
// map.put("pageNum", pageNum);
// return map;
// }
//
// /**
// * 生成单个堆栈柱状图
// *
// * @return 图片数据流
// * @throws IOException
// */
// public byte[] createSingleStackedBarChart(double[][] data, String[] rowKeys, String[] columnKeys, ChartEntity entity) throws IOException {
// CategoryDataset dataset = getBarData(data, rowKeys, columnKeys);
// JFreeChart chart = createStackedBarChart(dataset, entity);
// byte[] bytes = this.createImage(chart, entity);
// return bytes;
// }
//
// // 柱状图,折线图 数据集
// private CategoryDataset getBarData(double[][] data, String[] rowKeys,
// String[] columnKeys) {
// return DatasetUtilities.createCategoryDataset(rowKeys, columnKeys, data);
//
// }
//
// /**
// * 判断文件夹是否存在,如果不存在则新建
// *
// * @param chartPath
// */
// private void isChartPathExist(String chartPath) {
// File file = new File(chartPath);
// if (!file.exists()) {
// file.mkdirs();
// }
// }
//
// /**
// * 折线图
// */
// private JFreeChart createTimeXYChar(CategoryDataset xyDataset, ChartEntity entity) {
//
// JFreeChart chart = ChartFactory.createLineChart(
// entity.getTitle(),
// entity.getXname(),
// entity.getYname(),
// xyDataset,
// PlotOrientation.VERTICAL,
// true,
// true,
// false);
//
// chart.setTextAntiAlias(false);
// chart.setBackgroundPaint(Color.WHITE);
//
// CategoryPlot categoryplot = (CategoryPlot) chart.getPlot();
// // 没有数据时显示
// this.configNoData(chart, "没有查询到数据 !");
//
// // x轴 // 分类轴网格是否可见
// categoryplot.setDomainGridlinesVisible(true);
// // y轴 //数据轴网格是否可见
// categoryplot.setRangeGridlinesVisible(true);
//
// categoryplot.setRangeGridlinePaint(Color.WHITE);// 虚线色彩
//
// categoryplot.setDomainGridlinePaint(Color.WHITE);// 虚线色彩
//
// categoryplot.setBackgroundPaint(Color.lightGray);
//
//
// // 配置字体
// this.configFont(chart);
//
// // x轴设置
// CategoryAxis domainAxis = categoryplot.getDomainAxis();
//
// // 设置距离图片左端距离
// domainAxis.setLowerMargin(0.0);
// // 设置距离图片右端距离
// domainAxis.setUpperMargin(0.0);
// domainAxis.setTickLabelPaint(Color.BLUE);
// domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); // 横轴上的label斜显示
//
// NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
// numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
// numberaxis.setAutoRangeIncludesZero(true);
//
// // 获得renderer 注意这里是下嗍造型到lineandshaperenderer!!
// LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer();
// lineandshaperenderer.setBaseShapesVisible(true); // series 点(即数据点)可见
// lineandshaperenderer.setBaseLinesVisible(true); // series 点(即数据点)间有连线可见
//
// // 显示折点数据
// lineandshaperenderer.setBaseItemLabelGenerator(new
// StandardCategoryItemLabelGenerator());
// lineandshaperenderer.setBaseItemLabelsVisible(true);
//
// return chart;
// }
//
// /**
// * 堆栈柱状图
// */
// private JFreeChart createStackedBarChart(CategoryDataset dataset, ChartEntity entity) {
//
// JFreeChart chart = ChartFactory.createStackedBarChart3D(
// entity.getTitle(),
// entity.getXname(),
// entity.getYname(),
// dataset,
// PlotOrientation.VERTICAL,
// true,
// false,
// false);
//
// // 没有数据配置
// this.configNoData(chart, "没有查询到数据 !");
//
// // 配置字体
// this.configFont(chart);
//
// // 配置 Renderer
// this.configBarRenderer(chart);
//
// // 其他配置
// this.configOtherForBar(chart);
//
// return chart;
// }
//
// /**
// * 配置字体
// *
// * @param chart JFreeChart 对象
// */
// private void configFont(JFreeChart chart) {
// // 配置字体
// Font xfont = new Font("宋体", Font.PLAIN, 12);// X轴
// Font yfont = new Font("宋体", Font.PLAIN, 12);// Y轴
// Font kfont = new Font("宋体", Font.PLAIN, 12);// 底部
// Font titleFont = new Font("隶书", Font.BOLD, 25); // 图片标题
// CategoryPlot plot = chart.getCategoryPlot();// 图形的绘制结构对象
//
// // 图片标题
// chart.setTitle(new TextTitle(chart.getTitle().getText(), titleFont));
//
// // 底部
// chart.getLegend().setItemFont(kfont);
//
// // X 轴
// CategoryAxis domainAxis = plot.getDomainAxis();
// domainAxis.setLabelFont(xfont);// 轴标题
// domainAxis.setTickLabelFont(xfont);// 轴数值
// domainAxis.setTickLabelPaint(Color.BLUE); // 字体颜色
// domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); // 横轴上的label斜显示
//
// // Y 轴
// ValueAxis rangeAxis = plot.getRangeAxis();
// rangeAxis.setLabelFont(yfont);
// rangeAxis.setLabelPaint(Color.BLUE); // 字体颜色
// rangeAxis.setTickLabelFont(yfont);
//
// }
//
// /**
// * 配置柱状图
// *
// * @param chart
// */
// private void configBarRenderer(JFreeChart chart) {
//
// CategoryPlot categoryplot = (CategoryPlot) chart.getPlot();
// // 自定义显示柱子上的总值
// ExtendedStackedBarRenderer extendedstackedbarrenderer = new ExtendedStackedBarRenderer();
// extendedstackedbarrenderer.setBaseItemLabelsVisible(true);
// extendedstackedbarrenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
// extendedstackedbarrenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
// categoryplot.setRenderer(extendedstackedbarrenderer);
//
// BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer();
// barrenderer.setDrawBarOutline(false);
// barrenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
// barrenderer.setBaseItemLabelsVisible(true);
// barrenderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER));
// barrenderer.setBaseNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER));
//
// // 柱子显示数值
// // barrenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}",new DecimalFormat("0.0%")));
// // barrenderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator());
// barrenderer.setItemLabelFont(new Font("Arial Unicode MS", Font.PLAIN, 9));
// barrenderer.setItemLabelsVisible(true);
//
// // 如果数值没有显示空间,设置显示格式
// // ItemLabelPosition itemLabelPositionFallback=new ItemLabelPosition(
// // ItemLabelAnchor.OUTSIDE12,TextAnchor.BASELINE_LEFT,
// // TextAnchor.HALF_ASCENT_LEFT,0D);
// // barrenderer.setPositiveItemLabelPositionFallback(itemLabelPositionFallback);
// // barrenderer.setNegativeItemLabelPositionFallback(itemLabelPositionFallback);
//
// categoryplot.setRenderer(barrenderer);
// }
//
// /**
// * 配置没有数据时的显示信息
// *
// * @param chart
// */
// private void configNoData(JFreeChart chart, String message) {
// CategoryPlot categoryplot = (CategoryPlot) chart.getPlot();
// // 没有数据时的显示
// categoryplot.setNoDataMessage(message);
// categoryplot.setNoDataMessageFont(new Font("黑体", Font.BOLD, 25));
// }
//
// /**
// * 其他配置
// *
// * @param chart
// */
// private void configOtherForBar(JFreeChart chart) {
//
// chart.setTextAntiAlias(false); // 图例字体清晰
//
// chart.setBackgroundPaint(Color.WHITE); // 背景颜色
//
// CategoryPlot plot = chart.getCategoryPlot();// 图形的绘制结构对象
// NumberAxis numberaxis = (NumberAxis) plot.getRangeAxis();
// numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
// numberaxis.setAutoRangeIncludesZero(true);
// }
//
// /**
// * 创建图片的数据流
// *
// * @param chart
// * @param entity 图片配置对象
// * @return 图片数据流
// * @throws IOException
// */
// private byte[] createImage(JFreeChart chart, ChartEntity entity) throws IOException {
// return ChartUtilities.encodeAsPNG(chart.createBufferedImage(entity.getWidth(), entity.getHeight()));
// }
//
// /**
// * 创建图片文件到硬盘
// *
// * @param chart
// * @param entity
// * @throws IOException
// */
// private void createImageFile(JFreeChart chart, ChartEntity entity) throws IOException {
// FileOutputStream fos_jpg = null;
// try {
// isChartPathExist(tempImgPath);
// String chartName = tempImgPath + entity.getFileName();
// fos_jpg = new FileOutputStream(chartName);
// ChartUtilities.writeChartAsJPEG(fos_jpg, chart, entity.getWidth(), entity.getHeight());
// } catch (Exception e) {
// e.printStackTrace();
// } finally {
// try {
// fos_jpg.close();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// }
} }

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

@ -1,5 +1,8 @@
package com.hnac.hzims.operational.util; package com.hnac.hzims.operational.util;
import org.springblade.core.tool.utils.DateUtil;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
public class TimeUtils { public class TimeUtils {
@ -9,18 +12,100 @@ public class TimeUtils {
/** /**
* 相差时数 * 相差时数
* @author ty *
* @param endDate * @param endDate
* @param nowDate * @param nowDate
* @return * @return
* @author ty
*/ */
public static Long getDifferTime(Date nowDate,Date endDate ) { public static Long getDifferTime(Date nowDate, Date endDate) {
long nh = 1000 * 60 * 60L; long nh = 1000 * 60 * 60L;
// 获得两个时间的毫秒时间差异 // 获得两个时间的毫秒时间差异
long diff = endDate.getTime() - nowDate.getTime(); long diff = endDate.getTime() - nowDate.getTime();
// 计算差多少小时 // 计算差多少小时
long hour = diff/ nh; long hour = diff / nh;
return hour; return hour;
} }
public static String getYear(Integer year) {
// 创建一个Calendar对象
Calendar calendar = Calendar.getInstance();
// 设置年份
calendar.set(Calendar.YEAR, year);
// 设置月份为1(即一月)
calendar.set(Calendar.MONTH, Calendar.JANUARY);
// 设置日期为1
calendar.set(Calendar.DATE, 1);
// 设置时间为0点0分0秒
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
String start = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATE) + " 00:00:00";
return start;
}
public static String getYearEnd(Integer year) {
// 创建一个Calendar对象
Calendar calendar = Calendar.getInstance();
// 设置年份
calendar.set(Calendar.YEAR, year);
// 设置月份为12(即十二月)
calendar.set(Calendar.MONTH, Calendar.DECEMBER);
// 设置日期为31
calendar.set(Calendar.DATE, 31);
String end = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATE) + " 00:00:00";
return end;
}
public static String getYearEndV2(Integer year) {
// 创建一个Calendar对象
Calendar calendar = Calendar.getInstance();
// 设置年份
calendar.set(Calendar.YEAR, year);
// 设置月份为12(即十二月)
calendar.set(Calendar.MONTH, Calendar.DECEMBER);
// 设置日期为31
calendar.set(Calendar.DATE, 31);
String end = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATE) + " 23:59:59";
return end;
}
public static String getMonthStart(Integer year, Integer mon) {
// 创建一个Calendar对象
Calendar calendar = Calendar.getInstance();
// 设置年份
calendar.set(Calendar.YEAR, year);
// 设置月份
calendar.set(Calendar.MONTH,mon-1);
// 设置日期为1
calendar.set(Calendar.DATE, 1);
String start = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATE) + " 00:00:00";
return start;
}
public static String getMonthEnd(Integer year, Integer mon) {
// 创建一个Calendar对象
Calendar calendar = Calendar.getInstance();
// 设置年份
calendar.set(Calendar.YEAR, Integer.valueOf(year));
// 设置月份为1(即一月)
calendar.set(Calendar.MONTH, mon);
calendar.set(Calendar.DAY_OF_MONTH, 1);
// 将日期对象减去一天,即为当月的最后一天
calendar.add(Calendar.DAY_OF_MONTH, -1);
String end = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATE) + " 00:00:00";
return end;
}
public static String getMonthEndV2(Integer year, Integer mon) {
// 创建一个Calendar对象
Calendar calendar = Calendar.getInstance();
// 设置年份
calendar.set(Calendar.YEAR, Integer.valueOf(year));
// 设置月份为1(即一月)
calendar.set(Calendar.MONTH, mon);
calendar.set(Calendar.DAY_OF_MONTH, 1);
// 将日期对象减去一天,即为当月的最后一天
calendar.add(Calendar.DAY_OF_MONTH, -1);
String end = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATE) + " 23:59:59";
return end;
}
} }

15
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/feign/TicketInfoClient.java

@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.hnac.hzims.safeproduct.Constants; import com.hnac.hzims.safeproduct.Constants;
import com.hnac.hzims.ticket.allTicket.entity.TicketInfoEvaluateEntity;
import com.hnac.hzims.ticket.allTicket.service.TicketInfoEvaluateService;
import com.hnac.hzims.ticket.constants.TicketConstants; import com.hnac.hzims.ticket.constants.TicketConstants;
import com.hnac.hzims.ticket.standardTicket.entity.StandardTicketInfoEntity; import com.hnac.hzims.ticket.standardTicket.entity.StandardTicketInfoEntity;
import com.hnac.hzims.ticket.standardTicket.service.IStandardTicketInfoService; import com.hnac.hzims.ticket.standardTicket.service.IStandardTicketInfoService;
@ -19,6 +21,7 @@ import com.hnac.hzims.vo.SafeCheckStatisticVO;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseEntity;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.*; import org.springblade.core.tool.utils.*;
import org.springblade.flow.core.feign.IFlowClient; import org.springblade.flow.core.feign.IFlowClient;
@ -52,6 +55,8 @@ public class TicketInfoClient implements ITicketInfoClient {
private final IFlowClient flowClient; private final IFlowClient flowClient;
private final IWorkTicketDelayService delayService; private final IWorkTicketDelayService delayService;
private final TicketInfoEvaluateService ticketInfoEvaluateService;
@Override @Override
@GetMapping("/updateUndoneStatus") @GetMapping("/updateUndoneStatus")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@ -92,7 +97,15 @@ public class TicketInfoClient implements ITicketInfoClient {
}}); }});
return R.data(infoList); return R.data(infoList);
} }
@Override
@GetMapping("/getTicketPassByIds")
public R<Long> getTicketPassByIds(@RequestParam List<Long> ticekeIds) {
LambdaQueryWrapper<TicketInfoEvaluateEntity> evaluateEntityLambdaQueryWrapper = new LambdaQueryWrapper<>();
evaluateEntityLambdaQueryWrapper.in(TicketInfoEvaluateEntity::getTicketId, ticekeIds);
evaluateEntityLambdaQueryWrapper.eq(BaseEntity::getStatus, 1);
Long count =Long.valueOf(ticketInfoEvaluateService.count(evaluateEntityLambdaQueryWrapper));
return R.data(count);
}
@Override @Override
@GetMapping("/getWorkTicketTransfer") @GetMapping("/getWorkTicketTransfer")
public R<List<WorkTicketPrincipalChangeEntity>> getWorkTicketTransfer(@RequestParam String startDate, @RequestParam String endDate) { public R<List<WorkTicketPrincipalChangeEntity>> getWorkTicketTransfer(@RequestParam String startDate, @RequestParam String endDate) {

Loading…
Cancel
Save