Browse Source

水电站月报代码提交demo

zhongwei
tyty 2 years ago
parent
commit
16e3e57c4d
  1. 20
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/MonPowerPercentageVo.java
  2. 13
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/TicketChartCell.java
  3. 648
      hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/constants/TicketConstants.java
  4. 8
      hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/feign/ITicketInfoClient.java
  5. 5
      hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/feign/TicketInfoClientFallback.java
  6. 17
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/AreaMonthReportController.java
  7. 666
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java
  8. 288
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/JFreeUtil.java
  9. 6
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/TimeUtils.java
  10. 15
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/feign/TicketInfoClient.java

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

@ -12,7 +12,7 @@ import lombok.Data;
public class MonPowerPercentageVo {
@ApiModelProperty(value = "机构Id")
private Long deptId;
private long deptId;
@ApiModelProperty(value = "机构名称")
private String deptName;
@ -21,23 +21,23 @@ public class MonPowerPercentageVo {
private String deviceName;
@ApiModelProperty(value = "年计划发电量")
private Float planPower;
private double planPower;
@ApiModelProperty(value = "今年发电量")
private Float powerYear;
private double powerYear;
@ApiModelProperty(value = "去年发电量")
private Float powerYearBefore;
private double powerYearBefore;
@ApiModelProperty(value = "当月发电量")
private Float powerMon;
private double powerMon;
@ApiModelProperty(value = "上个月发电量")
private Float powerMonBefore;
private double powerMonBefore;
@ApiModelProperty(value = "去年当月发电量")
private Float powerMonYearBefore;
private double powerMonYearBefore;
@ApiModelProperty(value = "两年间:年发电量环比")
private Float powerYearPercentage;
private double powerYearPercentage;
@ApiModelProperty(value = "两年间:月发电量环比")
private Float powerMonPercentage;
private double powerMonPercentage;
@ApiModelProperty(value = "年计划完成率")
private Float planPercentage;
private double planPercentage;
}

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

@ -10,14 +10,17 @@ import lombok.Data;
@Data
@ApiModel("两票统计单元格")
public class TicketChartCell {
@ApiModelProperty(value = "票名")
@ApiModelProperty(value = "票的种类")
// 操作票:3:倒闸 4:开机 5:停机
// 工作票:6:第一种 7:第二种 8水力机械票
private String ticketType;
private String ticketName;
@ApiModelProperty(value = "本月数量")
private Integer ticketMon;
private int ticketMon;
@ApiModelProperty(value = "本月合格率")
private Double ticketMonPerc;
private double ticketMonPerc;
@ApiModelProperty(value = "本年数量")
private Integer ticketYear;
private int ticketYear;
@ApiModelProperty(value = "本年合格率")
private Double ticketYeaPercr;
private double ticketYeaPercr;
}

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

@ -10,302 +10,354 @@ import java.util.Optional;
* @author hx
*/
public interface TicketConstants {
String APP_NAME = "hzims-ticket";
String TICKET_DATE_PATTERN = "yyyy年MM月dd日 HH时mm分";
Integer MATTER_FINISH_STATUS = 2;
String MEASURE_TYPE_ONE = "1";
String MEASURE_TYPE_TWO = "2";
String MEASURE_TYPE_THREE = "3";
String SIGNER_ROLE = "signer";
String LICENSOR_ROLE = "licensor";
/**工作票安措新增类型**/
String DUTY_PATTERN = "1";
String LICENSE_PATTERN = "2";
int MEASURE_NOT_EXECUTE = 1;
int MEASURE_EXECUTE = 2;
int MEASURE_NOT_COMPLETE = 3;
int MEASURE_COMPLETE = 4;
/**开票任务类型**/
enum TaskTypeEnum {
RCWH("1","日常维护"),
JXRW("2","检修任务"),
JXJH("3","检修计划")
;
@Getter
private String type;
@Getter
private String typeName;
TaskTypeEnum(String type, String typeName) {
this.type = type;
this.typeName = typeName;
}
}
/**
* 工作票流程环节
*/
enum WorkTicketFlowEnum {
/**开票**/
START("1","startEvent1","开票"),
/**签发人签发**/
SIGN("1","sid-5E7013A9-385A-4EE4-91B6-FD5328D05E2A","签发人签发"),
/**运行人员接收**/
RECEIVE("2","sid-355DB6EC-7D54-4537-B80F-C26CD716ADA1","运行人员接收"),
/**运行人员布置安全措施**/
FIX_UP("3","sid-F35C4A79-53AF-40B8-AFBD-AF7283CC5708","运行人员布置安全措施"),
/**工作负责人确认安全措施**/
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
private String status;
@Getter
private String flowId;
@Getter
private String segment;
WorkTicketFlowEnum(String status, String flowId, String segment) {
this.status = status;
this.flowId = flowId;
this.segment = segment;
}
public static WorkTicketFlowEnum getEnumByFlowId(String flowId) {
Optional<WorkTicketFlowEnum> workTicketFlowEnum = Arrays.stream(WorkTicketFlowEnum.class.getEnumConstants()).filter(flowEnum -> flowId.equals(flowEnum.flowId)).findFirst();
return workTicketFlowEnum.orElse(null);
}
}
enum WordFileNameEnum {
OPERATE("1","操作票"),
WORK("2","工作票"),
SWITCH_OFF("3","大隆水电站倒闸操作票模板"),
BOOT_UP("4","大隆水电站倒闸操作票模板"),
DOWNTIME("5","大隆水电站倒闸操作票模板"),
FIRST_WORK("6","大隆水电站电气第一种工作票模板"),
SECOND_WORK("7","大隆水电站电气第二种工作票模板"),
MECHANICAL_WORK("8","大隆水电站水力机械工作票模板"),
EMERGENCY_REPAIR("9","大隆水电站事故应急抢修单模板"),
NEW_FIRST_WORK("10","新电气第一种工作票模板"),
NEW_FIRST_WORK1("11","第一种工作票"),
;
@Getter
private String type;
@Getter
private String fileName;
WordFileNameEnum(String type, String fileName) {
this.type = type;
this.fileName = fileName;
}
public static String getFileNameByType(String type) {
Optional<WordFileNameEnum> optional = Arrays.stream(WordFileNameEnum.values()).filter(e->type.equals(e.getType())).findFirst();
return optional.map(e->e.fileName).orElse(null);
}
}
/**
* 工作票安全注意事项类型
*/
enum MeasureTypeEnum {
INIT_MEASURE("1","开票时的安全措施"),
SIGN_MEASURE("2","签发补充安全措施"),
LICENSE_MEASURE("3","许可人补充安全措施")
;
@Getter
private String type;
@Getter
private String describe;
MeasureTypeEnum(String type, String describe) {
this.type = type;
this.describe = describe;
}
}
@AllArgsConstructor
enum TicketCodePreEnum {
DQ_WORK("6","S-DQ","电气工作票","workTicketInfoService"),
DQ_OPERATE("3","YX-DQ","电气标准票","standardTicketInfoService")
;
@Getter
private String type;
@Getter
private String prefix;
@Getter
private String describe;
@Getter
private String service;
}
enum DelayStatusEnum {
PRINCIPAL_INITIATE(1,"负责人发起"),
LICENSOR_CONFIRM(2,"许可人确认"),
PRINCIPAL_CONFIRM(3,"负责人确认")
;
@Getter
private int status;
@Getter
private String describe;
DelayStatusEnum(int status, String describe) {
this.status = status;
this.describe = describe;
}
}
/**
* 安全措施/注意事项
*/
@AllArgsConstructor
enum SafetyMeasureStatusEnum{
NO_EXECUTE(1,"未执行"),
EXECUTED(2,"执行中"),
NO_FINISH(4,"执行中"),
FINISH(3,"已执行")
;
@Getter
private Integer status;
@Getter
private String describe;
/**根据status获取describe**/
public static String getDescribeByStatus(Integer status){
Optional<SafetyMeasureStatusEnum> optional = Arrays.stream(SafetyMeasureStatusEnum.values())
.filter(p -> status.equals(p.getStatus())).findFirst();
String describe = optional.isPresent() ? optional.get().getDescribe() : status.toString();
return describe;
}
}
/**
* 工作票处理流程
*/
enum FirstWorkTicketFlowEnum {
SIGN("sign","签发"),
LICENSE("license","许可人确认安全事项"),
RECEIVE("receive","负责人确认收到工作票"),
CONFIRM_MEASURE_PRINCIPAL("principalConfirm","负责人确认安全事项"),
CONFIRM_MEASURE_MEMBERS("membersConfirm","工作组员确认安全事项"),
FINISH("finish","工作票结束"),
END("end","工作票终结"),
PRINCIPAL_DELAY("principalDelay","负责人发起工作票延期"),
LICENSOR_DELAY("licensorDelay","许可人确认工作票延期"),
;
@Getter
private String code;
@Getter
private String describe;
FirstWorkTicketFlowEnum(String code, String describe) {
this.code = code;
this.describe = describe;
}
}
/**
* 标准票处理流程
*/
enum StandardTicketStatusEnum{
GUARDIAN_CONFIRM(1,"待监护人确认"),
PRINCIPAL_CONFIRM(2,"待值班负责人确认"),
END(3,"结束"),
TERMINATION(4,"终止")
;
@Getter
private Integer status;
@Getter
private String describe;
StandardTicketStatusEnum(Integer status, String describe) {
this.status = status;
this.describe = describe;
}
}
/**
* 工作票处理流程
*/
@AllArgsConstructor
enum FirstWorkTicketFlowStatusEnum {
SIGN(1,"待签发"),
RECEIVE(2,"待确认收到工作票"),
LICENSE(3,"待许可"),
CONFIRM_MEASURE_PRINCIPAL(4,"待负责人确认安全措施"),
CONFIRM_MEASURE_MEMBERS(5,"待班组成员确认安全措施"),
CONFIRM_OPERATION_SITUATION(6,"待确认执行情况"),
COMPLETE_PRINCIPAL_CONTENT(7,"待工作成员完成任务"),
CONFIRM_PRINCIPAL_CONTENT(8,"待负责人确认完成工作"),
CONFIRM_WORK_FINISH(9,"待确认工作结束"),
END(10,"待终结"),
FINISH(11,"完成"),
LICENSOR_DELAY(12,"待许可人确认工作票延期"),
PRINCIPAL_DELAY(13,"待负责人确认工作票延期"),
INVALID(14,"作废"),
OFFLINE(15,"线下开票"),
TERMINATION(16,"终止"),
UNDONE(17,"逾期未完成"),
OFFLINE_OPERATE(18,"线下执行任务"),
OFFLINE_LICENSE(19,"线下许可人许可"),
OFFLINE_END(20,"线下结束")
;
@Getter
private Integer status;
@Getter
private String describe;
/**
* 根据status获取对应枚举类
* @param status
* @return
*/
public static FirstWorkTicketFlowStatusEnum getFlowEnumByStatus(Integer status) {
Optional<FirstWorkTicketFlowStatusEnum> result = Arrays.stream(FirstWorkTicketFlowStatusEnum.class.getEnumConstants()).filter(
e -> status.equals(e.getStatus())
).findAny();
if(result.isPresent()){
return result.get();
}
return null;
}
}
/**
* 票据合格
*/
enum TicketQualifiedEnum{
Qualified(1,"合格"),
No_Qualified(2,"不合格");
@Getter
private Integer code;
@Getter
private String msg;
TicketQualifiedEnum(Integer code, String msg) {
this.code = code;
this.msg = msg;
}
}
String APP_NAME = "hzims-ticket";
String TICKET_DATE_PATTERN = "yyyy年MM月dd日 HH时mm分";
Integer MATTER_FINISH_STATUS = 2;
String MEASURE_TYPE_ONE = "1";
String MEASURE_TYPE_TWO = "2";
String MEASURE_TYPE_THREE = "3";
String SIGNER_ROLE = "signer";
String LICENSOR_ROLE = "licensor";
/**
* 工作票安措新增类型
**/
String DUTY_PATTERN = "1";
String LICENSE_PATTERN = "2";
int MEASURE_NOT_EXECUTE = 1;
int MEASURE_EXECUTE = 2;
int MEASURE_NOT_COMPLETE = 3;
int MEASURE_COMPLETE = 4;
/**
* 开票任务类型
**/
enum TaskTypeEnum {
RCWH("1", "日常维护"),
JXRW("2", "检修任务"),
JXJH("3", "检修计划");
@Getter
private String type;
@Getter
private String typeName;
TaskTypeEnum(String type, String typeName) {
this.type = type;
this.typeName = typeName;
}
}
/**
* 工作票流程环节
*/
enum WorkTicketFlowEnum {
/**
* 开票
**/
START("1", "startEvent1", "开票"),
/**
* 签发人签发
**/
SIGN("1", "sid-5E7013A9-385A-4EE4-91B6-FD5328D05E2A", "签发人签发"),
/**
* 运行人员接收
**/
RECEIVE("2", "sid-355DB6EC-7D54-4537-B80F-C26CD716ADA1", "运行人员接收"),
/**
* 运行人员布置安全措施
**/
FIX_UP("3", "sid-F35C4A79-53AF-40B8-AFBD-AF7283CC5708", "运行人员布置安全措施"),
/**
* 工作负责人确认安全措施
**/
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
private String status;
@Getter
private String flowId;
@Getter
private String segment;
WorkTicketFlowEnum(String status, String flowId, String segment) {
this.status = status;
this.flowId = flowId;
this.segment = segment;
}
public static WorkTicketFlowEnum getEnumByFlowId(String flowId) {
Optional<WorkTicketFlowEnum> workTicketFlowEnum = Arrays.stream(WorkTicketFlowEnum.class.getEnumConstants()).filter(flowEnum -> flowId.equals(flowEnum.flowId)).findFirst();
return workTicketFlowEnum.orElse(null);
}
}
enum WordFileNameEnum {
OPERATE("1", "操作票"),
WORK("2", "工作票"),
SWITCH_OFF("3", "大隆水电站倒闸操作票模板"),
BOOT_UP("4", "大隆水电站倒闸操作票模板"),
DOWNTIME("5", "大隆水电站倒闸操作票模板"),
FIRST_WORK("6", "大隆水电站电气第一种工作票模板"),
SECOND_WORK("7", "大隆水电站电气第二种工作票模板"),
MECHANICAL_WORK("8", "大隆水电站水力机械工作票模板"),
EMERGENCY_REPAIR("9", "大隆水电站事故应急抢修单模板"),
NEW_FIRST_WORK("10", "新电气第一种工作票模板"),
NEW_FIRST_WORK1("11", "第一种工作票"),
;
@Getter
private String type;
@Getter
private String fileName;
WordFileNameEnum(String type, String fileName) {
this.type = type;
this.fileName = fileName;
}
public static String getFileNameByType(String type) {
Optional<WordFileNameEnum> optional = Arrays.stream(WordFileNameEnum.values()).filter(e -> type.equals(e.getType())).findFirst();
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);
}
}
/**
* 工作票安全注意事项类型
*/
enum MeasureTypeEnum {
INIT_MEASURE("1", "开票时的安全措施"),
SIGN_MEASURE("2", "签发补充安全措施"),
LICENSE_MEASURE("3", "许可人补充安全措施");
@Getter
private String type;
@Getter
private String describe;
MeasureTypeEnum(String type, String describe) {
this.type = type;
this.describe = describe;
}
}
@AllArgsConstructor
enum TicketCodePreEnum {
DQ_WORK("6", "S-DQ", "电气工作票", "workTicketInfoService"),
DQ_OPERATE("3", "YX-DQ", "电气标准票", "standardTicketInfoService");
@Getter
private String type;
@Getter
private String prefix;
@Getter
private String describe;
@Getter
private String service;
}
enum DelayStatusEnum {
PRINCIPAL_INITIATE(1, "负责人发起"),
LICENSOR_CONFIRM(2, "许可人确认"),
PRINCIPAL_CONFIRM(3, "负责人确认");
@Getter
private int status;
@Getter
private String describe;
DelayStatusEnum(int status, String describe) {
this.status = status;
this.describe = describe;
}
}
/**
* 安全措施/注意事项
*/
@AllArgsConstructor
enum SafetyMeasureStatusEnum {
NO_EXECUTE(1, "未执行"),
EXECUTED(2, "执行中"),
NO_FINISH(4, "执行中"),
FINISH(3, "已执行");
@Getter
private Integer status;
@Getter
private String describe;
/**
* 根据status获取describe
**/
public static String getDescribeByStatus(Integer status) {
Optional<SafetyMeasureStatusEnum> optional = Arrays.stream(SafetyMeasureStatusEnum.values())
.filter(p -> status.equals(p.getStatus())).findFirst();
String describe = optional.isPresent() ? optional.get().getDescribe() : status.toString();
return describe;
}
}
/**
* 工作票处理流程
*/
enum FirstWorkTicketFlowEnum {
SIGN("sign", "签发"),
LICENSE("license", "许可人确认安全事项"),
RECEIVE("receive", "负责人确认收到工作票"),
CONFIRM_MEASURE_PRINCIPAL("principalConfirm", "负责人确认安全事项"),
CONFIRM_MEASURE_MEMBERS("membersConfirm", "工作组员确认安全事项"),
FINISH("finish", "工作票结束"),
END("end", "工作票终结"),
PRINCIPAL_DELAY("principalDelay", "负责人发起工作票延期"),
LICENSOR_DELAY("licensorDelay", "许可人确认工作票延期"),
;
@Getter
private String code;
@Getter
private String describe;
FirstWorkTicketFlowEnum(String code, String describe) {
this.code = code;
this.describe = describe;
}
}
/**
* 标准票处理流程
*/
enum StandardTicketStatusEnum {
GUARDIAN_CONFIRM(1, "待监护人确认"),
PRINCIPAL_CONFIRM(2, "待值班负责人确认"),
END(3, "结束"),
TERMINATION(4, "终止");
@Getter
private Integer status;
@Getter
private String describe;
StandardTicketStatusEnum(Integer status, String describe) {
this.status = status;
this.describe = describe;
}
}
/**
* 工作票处理流程
*/
@AllArgsConstructor
enum FirstWorkTicketFlowStatusEnum {
SIGN(1, "待签发"),
RECEIVE(2, "待确认收到工作票"),
LICENSE(3, "待许可"),
CONFIRM_MEASURE_PRINCIPAL(4, "待负责人确认安全措施"),
CONFIRM_MEASURE_MEMBERS(5, "待班组成员确认安全措施"),
CONFIRM_OPERATION_SITUATION(6, "待确认执行情况"),
COMPLETE_PRINCIPAL_CONTENT(7, "待工作成员完成任务"),
CONFIRM_PRINCIPAL_CONTENT(8, "待负责人确认完成工作"),
CONFIRM_WORK_FINISH(9, "待确认工作结束"),
END(10, "待终结"),
FINISH(11, "完成"),
LICENSOR_DELAY(12, "待许可人确认工作票延期"),
PRINCIPAL_DELAY(13, "待负责人确认工作票延期"),
INVALID(14, "作废"),
OFFLINE(15, "线下开票"),
TERMINATION(16, "终止"),
UNDONE(17, "逾期未完成"),
OFFLINE_OPERATE(18, "线下执行任务"),
OFFLINE_LICENSE(19, "线下许可人许可"),
OFFLINE_END(20, "线下结束");
@Getter
private Integer status;
@Getter
private String describe;
/**
* 根据status获取对应枚举类
*
* @param status
* @return
*/
public static FirstWorkTicketFlowStatusEnum getFlowEnumByStatus(Integer status) {
Optional<FirstWorkTicketFlowStatusEnum> result = Arrays.stream(FirstWorkTicketFlowStatusEnum.class.getEnumConstants()).filter(
e -> status.equals(e.getStatus())
).findAny();
if (result.isPresent()) {
return result.get();
}
return null;
}
}
/**
* 票据合格
*/
enum TicketQualifiedEnum {
Qualified(1, "合格"),
No_Qualified(2, "不合格");
@Getter
private Integer code;
@Getter
private String msg;
TicketQualifiedEnum(Integer code, String msg) {
this.code = code;
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 GET_WORK_TICKET_BY_TIME = API_PREFIX + "/getWorkTicketByTime";
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_STATISTIC = API_PREFIX + "/getWorkTicketStatistic";
String GET_OPERATE_TICKET_STATISTIC = API_PREFIX + "/getOperateTicketStatistic";
@ -61,6 +62,13 @@ public interface ITicketInfoClient {
@GetMapping(GET_OPERATE_TICKET_BY_TIME)
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

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

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

@ -86,7 +86,7 @@ public class AreaMonthReportController extends BladeController {
//模拟柱状图图数据
String[] monthArray = {"一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月"};
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);
//模拟其它普通数据
@ -118,15 +118,16 @@ public class AreaMonthReportController extends BladeController {
@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) {
HashMap<String, Object> map = new HashMap<>(4);
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生成的文件名称、数据源
// map.put("personlist", list);
//word模板相对路径、word生成路径、word生成的文件名称、数据源
WordUtils.exportWord("template/demo2.docx", "F:/", "生成文件.docx", map);
service.exportHydropowerStationMonthReport(response, map,year,month,date,stationId);
}
return R.success("测试成功");
}

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

@ -3,8 +3,8 @@ 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.EquipmentConstants;
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.vo.EminfoAndEmParamVo;
import com.hnac.hzims.message.dto.MailPushDto;
@ -20,17 +20,16 @@ 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.OverhaulVo;
import com.hnac.hzims.operational.report.vo.CheckChartVo;
import com.hnac.hzims.operational.report.vo.DutyDefectVO;
import com.hnac.hzims.operational.report.vo.MonPowerPercentageVo;
import com.hnac.hzims.operational.report.vo.TicketChartCell;
import com.hnac.hzims.operational.report.vo.*;
import com.hnac.hzims.operational.station.entity.StationEntity;
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.feign.ISafeCheckClient;
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;
@ -48,6 +47,7 @@ import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.util.CellRangeAddress;
import org.jfree.data.category.DefaultCategoryDataset;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil;
@ -83,7 +83,7 @@ import java.util.stream.Collectors;
*/
@Service
@RequiredArgsConstructor
public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
@NotNull
private final IMainTaskStatisticService mainTaskStatisticService;
@ -96,6 +96,8 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
@NotNull
private final IPlanGenertionClient planGenertionClient;
@NotNull
private final IEmParamClient emParamClient;
@NotNull
private final SideHustleServiceImpl sideHustleService;
@NotNull
private final AnalyseDataServiceImpl analyseDataService;
@ -201,6 +203,49 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
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);
@ -209,11 +254,11 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
}
String deptName = deptNameR.getData();
R<List<Dept>> deptR = sysClient.getDeptByType("200000", deptId, 4);
if (!deptR.isSuccess()||deptR.getData()==null) {
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) {
if (deptList == null) {
return R.fail("该机构不包含水站信息");
}
List<Long> deptIds = deptList.stream().map(s -> s.getId()).collect(Collectors.toList());
@ -235,20 +280,31 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
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 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 beforeMonthStart = TimeUtils.getMonthStart(year, monthBefore);
String beforeMonthEnd = TimeUtils.getMonthEnd(year, monthBefore);
// 去年当月
String monthStartBeforeYear = TimeUtils.getMonthStart(yearBefore,month);
String monthEndBeforeYear = TimeUtils.getMonthEnd(yearBefore,month);
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);
List<HydropowerUnitRealVo> realsByDept = reals.stream().filter(s -> deptIds.contains(s.getDeptId())).collect(Collectors.toList());
// 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)
@ -262,23 +318,22 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
.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()) {
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.getDeptCode().equals(longListEntry.getKey())) {
if (dept.getId().equals(longListEntry.getKey())) {
capacityProportionMap.put(dept.getDeptName(), bigDecimal.doubleValue());
}
}
}
//装机容量占比图
ImageEntity capacityProportionChart = JFreeUtil.pieChartByDouble("水电项目装机容量占比图", capacityProportionMap, 1260, 60600);
ImageEntity capacityProportionChart = JFreeUtil.pieChartByDouble("水电项目装机容量占比图", capacityProportionMap, 500, 400);
map.put("capacityProportionChart", capacityProportionChart);
//各发电站发电量环比图+表格数据组装
List<MonPowerPercentageVo> powerPercentageVoList=new ArrayList<>();
List<MonPowerPercentageVo> powerPercentageVoList = new ArrayList<>();
for (Dept dept : deptList) {
MonPowerPercentageVo powerVo = new MonPowerPercentageVo();
powerVo.setDeptId(dept.getId());
@ -288,162 +343,214 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
BigDecimal powerMonth = new BigDecimal(0);
BigDecimal powerMonthBefore = new BigDecimal(0);
BigDecimal powerMonthYearBefore = new BigDecimal(0);
Float planGeneration=0f;
List<PlanGenerationEntity> planYearData = planGenertionClient.getPlanGenerationByParam(null, Arrays.asList(dept.getId().toString()), year.toString());
if(CollectionUtils.isNotEmpty(planYearData)){
planGeneration = planYearData.get(0).getPlanGeneration();
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);
// 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(Float.valueOf(ktv.getVal())))
.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);
// 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(Float.valueOf(ktv.getVal())))
.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);
// 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(Float.valueOf(ktv.getVal())))
.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);
// 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(Float.valueOf(ktv.getVal())))
.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);
// 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(Float.valueOf(ktv.getVal())))
.map(ktv -> BigDecimal.valueOf(Double.valueOf(ktv.getVal())))
.reduce(BigDecimal.ZERO, BigDecimal::add);
powerMonthYearBefore = powerMonthYearBefore.add(powerBefore);
}
}
powerVo.setPowerYear(powerYear.floatValue());
powerVo.setPowerMonYearBefore(powerYearBefore.floatValue());
BigDecimal yearPercentage =new BigDecimal(0);
BigDecimal planPercentage =new BigDecimal(0);
if (!powerYearBefore.equals(0)){
yearPercentage= powerYearBefore.divide(powerYear, 4, BigDecimal.ROUND_UP);
planPercentage= powerYearBefore.divide(BigDecimal.valueOf(planGeneration), 4, BigDecimal.ROUND_UP);
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);
}
powerVo.setPlanPercentage(planPercentage.floatValue());
powerVo.setPowerYearPercentage(yearPercentage.floatValue());
powerVo.setPowerMon(powerMonth.floatValue());
powerVo.setPowerMonBefore(powerMonthBefore.floatValue());
powerVo.setPowerMonYearBefore(powerMonthYearBefore.floatValue());
BigDecimal monPercentage =new BigDecimal(0);
if (!powerMonthYearBefore.equals(0)){
monPercentage= powerMonthYearBefore.divide(powerMonth, 4, BigDecimal.ROUND_UP);
if (BigDecimal.valueOf(planGeneration).compareTo(BigDecimal.ZERO)!=0) {
planPercentage = powerYear.divide(BigDecimal.valueOf(planGeneration), 2, BigDecimal.ROUND_UP);
}
powerVo.setPowerMonPercentage(monPercentage.floatValue());
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);
}
// 各发电站发电量环比图数据组装
//表格总计
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);
//柱状图图数据
// todo 把柱状重新写一个方法展示
String[] monthArray = {"一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月"};
double[] value = {20, 30, 25, 50, 40, 25, 50, 40};
ImageEntity powerChainHistogram = JFreeUtil.lineChart("测试111", monthArray, value, 300, 200);
// 创建数据
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", monPowerPercentageVo.getPowerMonYearBefore().toString());
temp.put("powerYearBefore", monPowerPercentageVo.getPowerYearBefore().toString());
temp.put("mon", monPowerPercentageVo.getPowerMon().toString());
temp.put("year", monPowerPercentageVo.getPowerYear().toString());
temp.put("monPercentage", monPowerPercentageVo.getPowerMonPercentage().toString());
temp.put("yearPercentage", monPowerPercentageVo.getPowerYearPercentage().toString());
temp.put("plan", monPowerPercentageVo.getPlanPercentage().toString());
list.add(temp);
}
map.put("powerGeneration", list);
}
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.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){
R<String> createDeptName = sysClient.getDeptName(createDept);
if (!createDeptName.isSuccess() && createDeptName.getData() != null) {
continue;
}
//表格数据
HashMap<String, String> temp = new HashMap<>();
temp.put("name", "name1");
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());
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);
map.put("checkList", checkList);
//各电站缺陷统计表
//本年缺陷
LambdaQueryWrapper<OperPhenomenonEntity> wrapperYear= Wrappers.lambdaQuery();
wrapper.ge(OperPhenomenonEntity::getCreateTime, yearStart);
wrapper.le(OperPhenomenonEntity::getCreateTime,yearEndV2);
wrapper.eq(OperPhenomenonEntity::getIsDefect, TreatMethodConstant.IS_DEFECT);
wrapper.eq(OperPhenomenonEntity::getDiscriminateStatus, TreatMethodConstant.AUTO_SCREENED);
wrapper.in(OperPhenomenonEntity::getCreateDept, deptIds);
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)) {
ArrayList<HashMap<String, String>> checkStatistics = new ArrayList<>(1);
//表格数据
HashMap<String, String> temp = new HashMap<>(7);
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");
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 {
List<CheckChartVo> checkChartRes=new ArrayList<>();
map.put("checkStatistics", checkStatistics);
} else {
Map<Long, Map<String, List<OperPhenomenonEntity>>> phenomenonMap = yearPhenomenonEntities.stream().collect(
Collectors.groupingBy(OperPhenomenonEntity::getCreateDept,
Collectors.groupingBy(OperPhenomenonEntity::getDefectGrading)));
@ -452,13 +559,13 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
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);
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);
}
}
@ -467,16 +574,31 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
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();
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);
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());
@ -486,82 +608,159 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
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()){
R<List<StandardTicketInfoEntity>> monthOperateTicket = ticketInfoClient.getOperateTicketByTime(monthStart, monthEndV2);
if (!monthTicket.isSuccess() || !yearTicket.isSuccess() || !yearOperateTicket.isSuccess() || !monthOperateTicket.isSuccess()) {
return R.fail("两票查询异常,请稍后重试");
}
yearPhenomenonEntities.stream().collect(Collectors.groupingBy(OperPhenomenonEntity::getDefectGrading));
//年工作票分组统计
Map<String, Map<String, List<WorkTicketInfoEntity>>> yearTicketCollect = Optional.ofNullable(yearTicket.getData()).orElse(new ArrayList<>()).stream()
.filter(s->s.getSignageCode()!=null)
.collect(Collectors.groupingBy(WorkTicketInfoEntity::getSignageCode,
Collectors.groupingBy(WorkTicketInfoEntity::getType)));
// 合格率计算
// Optional.ofNullable(yearTicket.getData()).orElse(new ArrayList<>()).stream()
// .filter(s->s.getSignageCode()!=null)
//年操作票分组统计
Map<String, Map<String, List<StandardTicketInfoEntity>>> yearOperateTicketCollect = Optional.ofNullable(yearOperateTicket.getData()).orElse(new ArrayList<>()).stream()
.filter(s->s.getSignageCode()!=null)
.collect(Collectors.groupingBy(StandardTicketInfoEntity::getSignageCode,
Collectors.groupingBy(StandardTicketInfoEntity::getTicketType)));
for (Map.Entry<String, Map<String, List<WorkTicketInfoEntity>>> deptTicketCollect : yearTicketCollect.entrySet()) {
List<TicketChartCell> cellList=new ArrayList<>();
for (Map.Entry<String, List<WorkTicketInfoEntity>> ticketCollect : deptTicketCollect.getValue().entrySet()) {
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();
//年合格率和数量
Integer count = ticketCollect.getValue().size();
Long passCount =ticketCollect.getValue().stream().filter(s->s.getStatus()==1).count();
Double ticketYearPerc=BigDecimal.valueOf(passCount).divide(BigDecimal.valueOf(count),2,BigDecimal.ROUND_UP).doubleValue();
ticketChartCell.setTicketYear(count);
ticketChartCell.setTicketYeaPercr(ticketYearPerc);
if (monthTicket.getData()!=null){
ticketChartCell.setTicketMon(0);
ticketChartCell.setTicketMonPerc(0d);
}else {
// 月合格率和数量
List<WorkTicketInfoEntity> monthTicketCollect = monthTicket.getData().stream()
.filter(s -> s.getCreateDept().equals(deptTicketCollect.getKey()))
.filter(s -> s.getType().equals(ticketCollect.getKey())).collect(Collectors.toList());
ticketChartCell.setTicketMon(monthTicketCollect.size());
Integer passCountMon =(int) monthTicketCollect.stream().filter(s->s.getStatus()==1).count();
Double ticketMonPerc=BigDecimal.valueOf(passCountMon).divide(BigDecimal.valueOf(monthTicketCollect.size()),2,BigDecimal.ROUND_UP).doubleValue();
ticketChartCell.setTicketMonPerc(ticketMonPerc);
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);
}
// 拿到对应的厂站进行分组展示
Map<String, List<StandardTicketInfoEntity>> deptOperateTicketCollect = yearOperateTicketCollect.get(deptTicketCollect.getKey());
if (deptOperateTicketCollect==null){
TicketChartCell ticketChartCell = new 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()));
}
for (Map.Entry<String, List<StandardTicketInfoEntity>> operateTicketCollect : deptOperateTicketCollect.entrySet()) {
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());
}
}
//模拟表格数据
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);
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);
// //模拟柱状图图数据
@ -571,75 +770,76 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
// map.put("lineEntity", lineEntity);
return R.success("成功");
// //todo
}
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();
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();
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().filter(s->s.getPowerYear()!=null)
.map(ktv -> BigDecimal.valueOf(Float.valueOf(ktv.getPowerYear())))
.reduce(BigDecimal.ZERO, BigDecimal::add);
powerVo.setPowerYear(powerYear.floatValue());
map.put("powerYear",powerYear.toString());
BigDecimal powerYearBefore= powerPercentageVoList.stream().filter(s->s.getPowerYearBefore()!=null)
.map(ktv -> BigDecimal.valueOf(Float.valueOf(ktv.getPowerYearBefore())))
BigDecimal powerYear = powerPercentageVoList.stream()
.map(ktv -> BigDecimal.valueOf(ktv.getPowerYear()))
.reduce(BigDecimal.ZERO, BigDecimal::add);
powerVo.setPowerMonYearBefore(powerYearBefore.floatValue());
BigDecimal yearPercentage =new BigDecimal(0);
BigDecimal planPercentage =new BigDecimal(0);
if (!powerYearBefore.equals(0)){
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= powerYearBefore.divide(powerYear, 4, BigDecimal.ROUND_UP);
planPercentage= powerYearBefore.divide(BigDecimal.valueOf(planGeneration), 4, BigDecimal.ROUND_UP);
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());
map.put("yearCompletionRate", planPercentage.toString());
}else {
map.put("yearCompletionRate", 0);
}
powerVo.setPowerYearPercentage(yearPercentage.floatValue());
powerVo.setPlanPercentage(planPercentage.floatValue());
BigDecimal powerMonth= powerPercentageVoList.stream().filter(s->s.getPowerMon()!=null)
.map(ktv -> BigDecimal.valueOf(Float.valueOf(ktv.getPowerMon())))
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.floatValue());
map.put("powerMon",powerMonth.toString());
powerVo.setPowerMon(powerMonth.doubleValue());
map.put("powerMon", powerMonth.toString());
// 项目月计划完成量
BigDecimal planMonPercentage =new BigDecimal(0);
if (!powerMonth.equals(0)&&planMonGeneration!=0){
planMonPercentage= powerMonth.divide(BigDecimal.valueOf(planMonGeneration), 4, BigDecimal.ROUND_UP);
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().filter(s->s.getPowerMonBefore()!=null)
.map(ktv -> BigDecimal.valueOf(Float.valueOf(ktv.getPowerMonBefore())))
map.put("monCompletionRate", planMonPercentage);
BigDecimal powerMonthBefore = powerPercentageVoList.stream()
.map(ktv -> BigDecimal.valueOf(ktv.getPowerMonBefore()))
.reduce(BigDecimal.ZERO, BigDecimal::add);
powerVo.setPowerMonBefore(powerMonthBefore.floatValue());
BigDecimal powerMonthYearBefore= powerPercentageVoList.stream().filter(s->s.getPowerMonYearBefore()!=null)
.map(ktv -> BigDecimal.valueOf(Float.valueOf(ktv.getPowerMonYearBefore())))
powerVo.setPowerMonBefore(powerMonthBefore.doubleValue());
BigDecimal powerMonthYearBefore = powerPercentageVoList.stream()
.map(ktv -> BigDecimal.valueOf(ktv.getPowerMonYearBefore()))
.reduce(BigDecimal.ZERO, BigDecimal::add);
powerVo.setPowerMonYearBefore(powerMonthYearBefore.floatValue());
BigDecimal monPercentage =new BigDecimal(0);
if (!powerMonthYearBefore.equals(0)){
monPercentage= powerMonthYearBefore.divide(powerMonth, 4, BigDecimal.ROUND_UP);
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 (monAdd.equals(0)){
map.put("percentageAdd",0);
}else {
map.put("percentageAdd", monAdd.divide(powerMonth, 4, BigDecimal.ROUND_UP).toString());
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.floatValue());
powerVo.setPowerMonPercentage(monPercentage.doubleValue());
powerPercentageVoList.add(powerVo);
}

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

@ -9,13 +9,20 @@ import org.jfree.chart.ChartUtils;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.StandardChartTheme;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.CategoryLabelPositions;
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.plot.CategoryPlot;
import org.jfree.chart.plot.DatasetRenderingOrder;
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.CategoryItemRenderer;
import org.jfree.chart.renderer.category.LineAndShapeRenderer;
import org.jfree.chart.renderer.category.StandardBarPainter;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.general.DefaultPieDataset;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTVMerge;
@ -26,6 +33,7 @@ import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.Map;
@Slf4j
@ -98,47 +106,7 @@ public class JFreeUtil {
Assert.notNull(imageEntity.getData(), "生成饼状图对象失败!");
return imageEntity;
}
public static ImageEntity lineChartV2( String title,String[] monthArray,double[] value,int width, int height) {
// 创建数据
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(1.0, "A", "Ⅰ");
dataset.addValue(3.0, "A", "Ⅱ");
dataset.addValue(5.0, "A", "Ⅲ");
dataset.addValue(5.0, "A", "Ⅳ");
dataset.addValue(5.0, "B", "Ⅰ");
dataset.addValue(6.0, "B", "Ⅱ");
dataset.addValue(10.0, "B", "Ⅲ");
dataset.addValue(4.0, "B", "Ⅳ");
// 创建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("Time"));
plot.setRangeAxis(new NumberAxis("Value"));
// 创建JFreeChart对象
JFreeChart chart = new JFreeChart(plot);
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 pieChart(String title, Map<String, Integer> datas, int width, int height) {
//创建主题样式
@ -177,7 +145,8 @@ public class JFreeUtil {
Assert.notNull(imageEntity.getData(), "生成饼状图对象失败!");
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");
@ -218,8 +187,40 @@ public class JFreeUtil {
// Assert.notNull(imageEntity.getData(),"生成饼状图对象失败!");
// 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();
dataset.addValue(1.0, "A", "Ⅰ");
@ -257,10 +258,211 @@ public class JFreeUtil {
e.printStackTrace();
}
ImageEntity imageEntity = new ImageEntity(imgToByte(tempImgPath2), width, height);
Assert.notNull(imageEntity.getData(),"生成饼状图对象失败!");
Assert.notNull(imageEntity.getData(), "生成饼状图对象失败!");
return imageEntity;
}
/**
* 创建柱状+折现统计复合图
*
* @param isAddLine
* @param title
* @param domainAxisLabel
* @param rangeAxisLabel
* @param dataset
* @param datasetLine
* @param width
* @param height
* @return
*/
public static ImageEntity iCreateBarLineChart(Boolean isAddLine, String title, String domainAxisLabel, String rangeAxisLabel,
DefaultCategoryDataset dataset, DefaultCategoryDataset datasetLine, int width, int height) {
// TODO Auto-generated method stub
JFreeChart chart = ChartFactory.createBarChart(title,
domainAxisLabel, rangeAxisLabel, dataset, PlotOrientation.VERTICAL, // 图表方向:水平、垂直
true, // 是否显示图例(对于简单的柱状图必须是false)
false, // 是否生成工具
false);
iSetBarChart(chart);
if (isAddLine) {
CategoryPlot categoryplot = chart.getCategoryPlot();
categoryplot.setDataset(1, datasetLine);
LineAndShapeRenderer lineandshaperenderer = new LineAndShapeRenderer();
lineandshaperenderer.setDefaultToolTipGenerator(new StandardCategoryToolTipGenerator());
lineandshaperenderer.setDefaultItemLabelGenerator(new StandardCategoryItemLabelGenerator());
lineandshaperenderer.setDefaultLinesVisible(true);
lineandshaperenderer.setSeriesPaint(0, Color.decode("#9BBB59"));
categoryplot.setRenderer(1, lineandshaperenderer);
NumberAxis numberaxis = new NumberAxis("平均值");
numberaxis.setLabelFont(new Font("宋体", Font.TRUETYPE_FONT, 12));
categoryplot.setRangeAxis(1, numberaxis);
categoryplot.mapDatasetToRangeAxis(1, 1);
categoryplot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
}
// JFreeChart lineChart = ChartFactory.createLineChart(title,
// domainAxisLabel, rangeAxisLabel, dataset);
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;
}
/**
* 双色柱状图
*
* @param title
* @param domainAxisLabel
* @param rangeAxisLabel
* @param dataset
* @param width
* @param height
* @return
*/
public static ImageEntity iCreateBarChart(String title, String domainAxisLabel, String rangeAxisLabel,
DefaultCategoryDataset dataset, int width, int height) {
// TODO Auto-generated method stub
JFreeChart chart = ChartFactory.createBarChart(title,
domainAxisLabel, rangeAxisLabel, dataset);
iSetBarChartDouble(chart);
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 void iSetBarChart(JFreeChart chart) {
CategoryPlot categoryplot = chart.getCategoryPlot();// 图本身
ValueAxis rangeAxis = categoryplot.getRangeAxis();
CategoryAxis domainAxis = categoryplot.getDomainAxis();
// 设置Y轴的提示文字样式
rangeAxis.setLabelFont(new Font("微软雅黑", Font.PLAIN, 12));
// 设置Y轴刻度线的长度
rangeAxis.setTickMarkInsideLength(10f);
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.STANDARD); // 横轴上的
domainAxis.setLowerMargin(0.1);
domainAxis.setUpperMargin(0.1);
// rangeAxis.setTickMarkOutsideLength(10f);
// 设置X轴下的标签文字
domainAxis.setLabelFont(new Font("微软雅黑", Font.PLAIN, 12));
// 设置X轴上提示文字样式
domainAxis.setTickLabelFont(new Font("微软雅黑", Font.PLAIN, 12));
NumberAxis vn = (NumberAxis) categoryplot.getRangeAxis();
// 设置Y轴的数字为百分比样式显示设置Y轴的数字为百分比样式显示
DecimalFormat df = new DecimalFormat("0.0");
vn.setNumberFormatOverride(df);
// 使柱状图反过来显示
// vn.setInverted(true);
// vn.setVerticalTickLabels(true);
// 自定义柱状图中柱子的样式
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
brender.setSeriesPaint(3, Color.decode("#00B050")); // 给series4 Bar
brender.setSeriesPaint(4, Color.decode("#7030A0")); // 给series5 Bar
brender.setSeriesPaint(5, Color.decode("#00BF00")); // 给series6 Bar
// 设置柱状图的顶端显示数字
brender.setIncludeBaseInRange(true);
brender.setDefaultItemLabelGenerator(new StandardCategoryItemLabelGenerator());
brender.setDefaultItemLabelsVisible(true);
// 设置柱子为平面图不是立体的
brender.setBarPainter(new StandardBarPainter());
// 设置柱状图之间的距离0.1代表10%;
brender.setItemMargin(0.3);
// 设置柱子的阴影,false代表没有阴影
brender.setShadowVisible(false);
// 设置图的背景为白色
categoryplot.setBackgroundPaint(Color.WHITE);
// 设置背景虚线的颜色
categoryplot.setRangeGridlinePaint(Color.decode("#B6A2DE"));
// 去掉柱状图的背景边框,使边框不可见
categoryplot.setOutlineVisible(false);
// 设置标题的字体样式
chart.getTitle().setFont(new Font("微软雅黑", Font.PLAIN, 24));
// 设置图表下方图例上的字体样式
chart.getLegend().setItemFont(new Font("微软雅黑", Font.PLAIN, 12));
categoryplot.setRenderer(brender);
}
public static void iSetBarChartDouble(JFreeChart chart) {
CategoryPlot categoryplot = chart.getCategoryPlot();// 图本身
ValueAxis rangeAxis = categoryplot.getRangeAxis();
CategoryAxis domainAxis = categoryplot.getDomainAxis();
// 设置Y轴的提示文字样式
rangeAxis.setLabelFont(new Font("微软雅黑", Font.PLAIN, 12));
// 设置Y轴刻度线的长度
rangeAxis.setTickMarkInsideLength(10f);
rangeAxis.setTickMarkOutsideLength(10f);
// 设置X轴下的标签文字
domainAxis.setLabelFont(new Font("微软雅黑", Font.PLAIN, 12));
// 设置X轴上提示文字样式
domainAxis.setTickLabelFont(new Font("微软雅黑", Font.PLAIN, 12));
NumberAxis vn = (NumberAxis) categoryplot.getRangeAxis();
// 设置Y轴的数字为百分比样式显示设置Y轴的数字为百分比样式显示
DecimalFormat df = new DecimalFormat("0.0");
vn.setNumberFormatOverride(df);
// 使柱状图反过来显示
// vn.setInverted(true);
// vn.setVerticalTickLabels(true);
// // 自定义柱状图中柱子的样式
BarRenderer brender = new BarRenderer();
brender.setSeriesPaint(0, Color.gray);
brender.setSeriesPaint(1, Color.orange);
// brender.setSeriesPaint(1, Color.decode("#C0504D")); // 给series1 Bar
// brender.setSeriesPaint(2, Color.decode("#C0504D")); // 给series1 Bar
// brender.setSeriesPaint(0, Color.decode("#E46C0A")); // 给series2 Bar
// brender.setSeriesPaint(2, Color.decode("#4F81BD")); // 给series3 Bar
// brender.setSeriesPaint(3, Color.decode("#00B050")); // 给series4 Bar
// 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());
// 设置柱子为平面图不是立体的
brender.setBarPainter(new StandardBarPainter());
// 设置柱状图之间的距离0.1代表10%;
brender.setItemMargin(0.1);
// // 设置柱子的阴影,false代表没有阴影
brender.setShadowVisible(false);
// 设置图的背景为白色
categoryplot.setBackgroundPaint(Color.WHITE);
// 设置背景虚线的颜色
categoryplot.setRangeGridlinePaint(Color.decode("#B6A2DE"));
// 去掉柱状图的背景边框,使边框不可见
categoryplot.setOutlineVisible(false);
// 设置标题的字体样式
chart.getTitle().setFont(new Font("微软雅黑", Font.PLAIN, 24));
// 设置图表下方图例上的字体样式
chart.getLegend().setItemFont(new Font("微软雅黑", Font.PLAIN, 12));
categoryplot.setRenderer(brender);
}
public static void mergeCell(XWPFTable table, int beginRowIndex, int endRowIndex, int colIndex) {
if (beginRowIndex == endRowIndex || beginRowIndex > endRowIndex) {
return;

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

@ -75,7 +75,7 @@ public class TimeUtils {
// 设置年份
calendar.set(Calendar.YEAR, year);
// 设置月份
calendar.set(Calendar.MONTH,mon);
calendar.set(Calendar.MONTH,mon-1);
// 设置日期为1
calendar.set(Calendar.DATE, 1);
String start = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATE) + " 00:00:00";
@ -88,7 +88,7 @@ public class TimeUtils {
// 设置年份
calendar.set(Calendar.YEAR, Integer.valueOf(year));
// 设置月份为1(即一月)
calendar.set(Calendar.MONTH, mon+1);
calendar.set(Calendar.MONTH, mon);
calendar.set(Calendar.DAY_OF_MONTH, 1);
// 将日期对象减去一天,即为当月的最后一天
calendar.add(Calendar.DAY_OF_MONTH, -1);
@ -101,7 +101,7 @@ public class TimeUtils {
// 设置年份
calendar.set(Calendar.YEAR, Integer.valueOf(year));
// 设置月份为1(即一月)
calendar.set(Calendar.MONTH, mon+1);
calendar.set(Calendar.MONTH, mon);
calendar.set(Calendar.DAY_OF_MONTH, 1);
// 将日期对象减去一天,即为当月的最后一天
calendar.add(Calendar.DAY_OF_MONTH, -1);

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.google.common.collect.Lists;
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.standardTicket.entity.StandardTicketInfoEntity;
import com.hnac.hzims.ticket.standardTicket.service.IStandardTicketInfoService;
@ -19,6 +21,7 @@ import com.hnac.hzims.vo.SafeCheckStatisticVO;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
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.utils.*;
import org.springblade.flow.core.feign.IFlowClient;
@ -52,6 +55,8 @@ public class TicketInfoClient implements ITicketInfoClient {
private final IFlowClient flowClient;
private final IWorkTicketDelayService delayService;
private final TicketInfoEvaluateService ticketInfoEvaluateService;
@Override
@GetMapping("/updateUndoneStatus")
@Transactional(rollbackFor = Exception.class)
@ -92,7 +97,15 @@ public class TicketInfoClient implements ITicketInfoClient {
}});
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
@GetMapping("/getWorkTicketTransfer")
public R<List<WorkTicketPrincipalChangeEntity>> getWorkTicketTransfer(@RequestParam String startDate, @RequestParam String endDate) {

Loading…
Cancel
Save