diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/request/StationInfoReq.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/request/StationInfoReq.java index c4e56ed..d77141c 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/request/StationInfoReq.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/request/StationInfoReq.java @@ -36,4 +36,7 @@ public class StationInfoReq implements Serializable { @ApiModelProperty("站点描述") private String stationDesc; + @ApiModelProperty("租户ID") + private String tenantId; + } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/vo/StationRealVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/config/vo/StationRealVo.java similarity index 100% rename from hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/vo/StationRealVo.java rename to hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/config/vo/StationRealVo.java diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java index 30f464f..2879db1 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java @@ -146,7 +146,7 @@ public interface HomePageConstant { // 水利-泵组实时属性名称 String JOINT_RELAY = "joint_relay"; // 开机状态 String SWITCH_ON_OFF = "switch_on_off"; // 开机状态 - String OFF = "1"; // 开机 + String OFF = "1.0"; // 开机 String ON = "0"; // 关机 String ELECTRICITY_CONSUMPTION = "electricity_consumption"; // 用电量 diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/vo/RealAttributeVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/RealAttributeVo.java similarity index 95% rename from hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/vo/RealAttributeVo.java rename to hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/RealAttributeVo.java index 7e6c9c2..52a73ff 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/vo/RealAttributeVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/RealAttributeVo.java @@ -1,4 +1,4 @@ -package com.hnac.hzims.operational.station.vo; +package com.hnac.hzims.operational.main.vo; import io.swagger.annotations.ApiModelProperty; import lombok.Data; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/vo/RealDeviceVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/RealDeviceVo.java similarity index 91% rename from hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/vo/RealDeviceVo.java rename to hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/RealDeviceVo.java index 5d7319e..0522108 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/vo/RealDeviceVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/RealDeviceVo.java @@ -1,4 +1,4 @@ -package com.hnac.hzims.operational.station.vo; +package com.hnac.hzims.operational.main.vo; import io.swagger.annotations.ApiModelProperty; import lombok.Data; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/vo/RealStationVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/RealStationVo.java similarity index 95% rename from hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/vo/RealStationVo.java rename to hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/RealStationVo.java index 876eaf5..515d623 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/vo/RealStationVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/RealStationVo.java @@ -1,4 +1,4 @@ -package com.hnac.hzims.operational.station.vo; +package com.hnac.hzims.operational.main.vo; import io.swagger.annotations.ApiModelProperty; import io.swagger.models.auth.In; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/vo/WeatherVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WeatherVo.java similarity index 92% rename from hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/vo/WeatherVo.java rename to hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WeatherVo.java index fb9b7b3..284e995 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/vo/WeatherVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WeatherVo.java @@ -1,4 +1,4 @@ -package com.hnac.hzims.operational.station.vo; +package com.hnac.hzims.operational.main.vo; import lombok.Data; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/vo/DutyDefectVO.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/DutyDefectVO.java similarity index 93% rename from hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/vo/DutyDefectVO.java rename to hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/DutyDefectVO.java index 3e95f23..177185d 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/vo/DutyDefectVO.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/DutyDefectVO.java @@ -3,6 +3,9 @@ package com.hnac.hzims.operational.report.vo; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +/** + * @author ysj + */ @Data public class DutyDefectVO{ diff --git a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/MessageConstants.java b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/MessageConstants.java index e6a42b3..6741a3f 100644 --- a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/MessageConstants.java +++ b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/MessageConstants.java @@ -53,6 +53,8 @@ public class MessageConstants { DUTY("duty","值班消息"), SAFE("safe","安全消息"), ACCESS("access","检修消息"), + TICKETMESSAGE("ticket-message","工作票消息"), + OPERATIONTICKETMESSAGE("operation-ticket-message","操作票消息"), ; @Getter private String key; diff --git a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/constants/WorkTicketConstants.java b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/constants/WorkTicketConstants.java index 9fa55b4..68fbb3f 100644 --- a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/constants/WorkTicketConstants.java +++ b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/constants/WorkTicketConstants.java @@ -2,77 +2,85 @@ package com.hnac.hzims.ticket.constants; import lombok.AllArgsConstructor; import lombok.Getter; + import java.util.Arrays; import java.util.Optional; /** * 工作票中所需常数定义 + * * @author hx */ public interface WorkTicketConstants { - @AllArgsConstructor - enum WorkTicketMeasureTypeEnum { - /**第一种安措**/ - ONE("1","matterLibraryListOne"), - /**第二种安措**/ - TWO("2","matterLibraryListTwo"), - /**第三种安措**/ - THREE("3","matterLibraryListThree"), - FOUR("4","matterLibraryListFour"), - Five("5","matterLibraryListFive"), - Flow("6","matterLibraryListFlow"), - ; - @Getter - private String type; - @Getter - private String convertAttributes; - } + @AllArgsConstructor + enum WorkTicketMeasureTypeEnum { + /** 第一种安措 **/ + ONE("1", "matterLibraryListOne"), + /** 第二种安措 **/ + TWO("2", "matterLibraryListTwo"), + /** 第三种安措 **/ + THREE("3", "matterLibraryListThree"), + FOUR("4", "matterLibraryListFour"), + Five("5", "matterLibraryListFive"), + Flow("6", "matterLibraryListFlow"), + //第二种工作票 + SEVEN("7", "matterLibraryListSeven"), + //水力机器工作票 + EIGHT("8", "matterLibraryListEight"), + NINE("9", "matterLibraryListNine"), + TEN("10", "matterLibraryListTen"), + + ; + @Getter + private String type; + @Getter + private String convertAttributes; + } - @AllArgsConstructor - enum FirstWorkTicketStatusEnum { - /**签发**/ - SIGN(1,"签发"), - /**收到工作票**/ - RECEIVE(2,"收到工作票"), - /**许可人许可**/ - LICENSE(3,"许可人许可"), - /**确认条件具备**/ - CONFIRM_MEASURE(4,"确认条件具备"), - /**工作负责人确认工作**/ - CONFIRM_WORK(5,"工作负责人确认工作"), - /**许可人确认工作结束**/ - WORK_FINISH(6,"许可人确认工作结束"), - /**工作票终结**/ - TICKET_FINISH(7,"工作票终结"), - /**结束**/ - FINISH(8,"结束"), - /**许可人延期确认**/ - LICENSE_DELAY(9,"许可人延期确认"), - /**负责人延期确认**/ - CONFIRM_DELAY(10,"负责人延期确认"), - /**作废**/ - INVALID(11,"作废"), - /**逾期**/ - OVERDUE(12,"逾期"), - /**线下开票**/ - OFFLINE(13,"线下开票"), - /**线下执行任务**/ - OFFLINE_OPERATE(14,"线下执行任务"), - /**线下许可人许可**/ - OFFLINE_LICENSE(15,"线下许可人许可"), - /**线下结束**/ - OFFLINE_END(16,"线下结束") - ; - @Getter - private Integer status; - @Getter - private String description; + @AllArgsConstructor + enum FirstWorkTicketStatusEnum { + /** 签发 **/ + SIGN(1, "签发"), + /** 收到工作票 **/ + RECEIVE(2, "收到工作票"), + /** 许可人许可 **/ + LICENSE(3, "许可人许可"), + /** 确认条件具备 **/ + CONFIRM_MEASURE(4, "确认条件具备"), + /** 工作负责人确认工作 **/ + CONFIRM_WORK(5, "工作负责人确认工作"), + /** 许可人确认工作结束 **/ + WORK_FINISH(6, "许可人确认工作结束"), + /** 工作票终结 **/ + TICKET_FINISH(7, "工作票终结"), + /** 结束 **/ + FINISH(8, "结束"), + /** 许可人延期确认 **/ + LICENSE_DELAY(9, "许可人延期确认"), + /** 负责人延期确认 **/ + CONFIRM_DELAY(10, "负责人延期确认"), + /** 作废 **/ + INVALID(11, "作废"), + /** 逾期 **/ + OVERDUE(12, "逾期"), + /** 线下开票 **/ + OFFLINE(13, "线下开票"), + /** 线下执行任务 **/ + OFFLINE_OPERATE(14, "线下执行任务"), + /** 线下许可人许可 **/ + OFFLINE_LICENSE(15, "线下许可人许可"), + /** 线下结束 **/ + OFFLINE_END(16, "线下结束"); + @Getter + private Integer status; + @Getter + private String description; - public static FirstWorkTicketStatusEnum getEnumByStatus(Integer status) { - Optional statusOptional = Arrays.stream(FirstWorkTicketStatusEnum.class.getEnumConstants()) - .filter(e-> status.equals(e.getStatus())).findAny(); - return statusOptional.orElse(null); - } - } + public static FirstWorkTicketStatusEnum getEnumByStatus(Integer status) { + Optional statusOptional = Arrays.stream(FirstWorkTicketStatusEnum.class.getEnumConstants()) + .filter(e -> status.equals(e.getStatus())).findAny(); + return statusOptional.orElse(null); + } + } } diff --git a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/standardTicket/entity/StandardTicketInfoEntity.java b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/standardTicket/entity/StandardTicketInfoEntity.java index 9d273d7..62c627d 100644 --- a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/standardTicket/entity/StandardTicketInfoEntity.java +++ b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/standardTicket/entity/StandardTicketInfoEntity.java @@ -125,4 +125,62 @@ public class StandardTicketInfoEntity extends TenantEntity implements Serializab @ApiModelProperty("是否评价") private Integer isEvaluate; + + + /** + * AA/AAA/AAAA由建站时建站人填写必须系统验证唯一性 + * 站点标识-两票编码 + */ + @ApiModelProperty("站点标识-两票编码") + private String signage; + + + /** + * 编号(原站点ID) + */ + @ApiModelProperty("编号(原站点ID)") + private String signageCode; + + + /** + * 流程状态' + */ + @ApiModelProperty("流程状态") + private Integer flowStatus; + + /** + * 流程描述 + */ + @ApiModelProperty("流程描述") + private String flowDescription; + + + /** + * 下一个审批人 + */ + @ApiModelProperty("下一个审批人") + private String nextStepOperator; + + + /** + * 用户Id + */ + @ApiModelProperty("用户Id") + private String flowUserId; + + + /** + * 当前任务名 + */ + @ApiModelProperty("当前任务名") + private String flowTaskName; + + + /** + * 当前任务名 + */ + @ApiModelProperty("当前任务名") + private String flowTaskId; + + } diff --git a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/entity/WorkTicketInfoEntity.java b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/entity/WorkTicketInfoEntity.java index 77e63a0..ff89923 100644 --- a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/entity/WorkTicketInfoEntity.java +++ b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/entity/WorkTicketInfoEntity.java @@ -316,8 +316,8 @@ public class WorkTicketInfoEntity extends TenantEntity implements Serializable { /** * 工作条件(false 停电 true 不停电) */ - @ApiModelProperty("工作条件(false 停电 true 不停电)") - private Boolean isPower; + @ApiModelProperty("工作条件(停电或不停电)") + private String power; /** @@ -414,6 +414,13 @@ public class WorkTicketInfoEntity extends TenantEntity implements Serializable { /** + * 用户Id + */ + @ApiModelProperty("用户Id") + private String flowUserId; + + + /** * 当前任务名 */ @ApiModelProperty("当前任务名") diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpQuestionServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpQuestionServiceImpl.java index a70d510..44b498a 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpQuestionServiceImpl.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpQuestionServiceImpl.java @@ -20,6 +20,7 @@ import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.logger.BladeLogger; +import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.StringUtil; @@ -51,13 +52,16 @@ public class FdpQuestionServiceImpl implements IFdpQuestionService { R stationResult = stationClient.getStationByCode(stationCode); if(stationResult.isSuccess()) { StationEntity stationEntity = stationResult.getData(); + log.info("请求体为:{}",AuthUtil.getTenantId()); StationInfoReq infoReq = StationInfoReq.builder() - .stationId(stationCode) - .stationName(stationEntity.getName()) - .type(this.getStationType(stationEntity.getType())) - .stationDesc(Optional.ofNullable(stationDesc).orElse("")) + .stationId(stationCode) + .stationName(stationEntity.getName()) + .type(this.getStationType(stationEntity.getType())) + .stationDesc(Optional.ofNullable(stationDesc).orElse("")) + .tenantId("200000") .build(); if(Func.isNotEmpty(infoReq.getType())) { + log.info("请求体为:{}",JSON.toJSONString(infoReq)); HttpResponse httpResponse = HttpRequest.post(fdpUrlConfiguration.getSubmitStationInfo()) .body(JSON.toJSONString(infoReq)) .execute(); diff --git a/hzims-service/hzims-scheduled/pom.xml b/hzims-service/hzims-scheduled/pom.xml index 4183ad7..87e3691 100644 --- a/hzims-service/hzims-scheduled/pom.xml +++ b/hzims-service/hzims-scheduled/pom.xml @@ -2,15 +2,15 @@ - 4.0.0 com.hnac.hzims hzims-service 4.0.0-SNAPSHOT + 4.0.0 hzims-scheduled - + jar 8 8 @@ -81,42 +81,6 @@ com.xuxueli xxl-job-core - - - - org.apache.poi - ooxml-schemas - 1.4 - - - org.jfree - jcommon - 1.0.24 - - - org.jfree - jfreechart - 1.5.0 - - - com.hikvision.ga - artemis-http-client - - - - - org.apache.httpcomponents - httpclient - - - - - - org.freemarker - freemarker - - - com.hnac.hzims equipment-api @@ -146,47 +110,22 @@ com.google.zxing javase - org.springblade blade-user-api - - org.apache.commons commons-collections4 - - - org.springframework.boot - spring-boot-starter-websocket - - - org.springframework.boot - spring-boot-starter-tomcat - - - - - cn.hutool hutool-http - - cn.hutool hutool-core - - - - org.java-websocket - Java-WebSocket - - org.springblade blade-resource-api diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/config/XxlJobConfig.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/config/XxlJobConfig.java deleted file mode 100644 index 6b473a9..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/config/XxlJobConfig.java +++ /dev/null @@ -1,59 +0,0 @@ -// package com.hnac.hzims.scheduled.config; -// -// import com.xxl.job.core.executor.impl.XxlJobSpringExecutor; -// import lombok.extern.slf4j.Slf4j; -// import org.springframework.beans.factory.annotation.Value; -// import org.springframework.context.annotation.Bean; -// import org.springframework.context.annotation.ComponentScan; -// import org.springframework.context.annotation.Configuration; -// -// /** -// * @Author WL -// * @Version v1.0 -// * @Serial 1.0 -// * @Date 2022/1/8 10:23 -// */ -// @Slf4j -// @Configuration -// //指定任务Handler所在包路径 -// public class XxlJobConfig { -// -// -// @Value("${xxl.job.admin.addresses}") -// private String adminAddresses; -// -// @Value("${xxl.job.executor.appname}") -// private String appName; -// -// @Value("${xxl.job.executor.ip}") -// private String ip; -// -// @Value("${xxl.job.executor.port}") -// private int port; -// -// @Value("${xxl.job.accessToken}") -// private String accessToken; -// -// @Value("${xxl.job.executor.logpath}") -// private String logPath; -// -// @Value("${xxl.job.executor.logretentiondays}") -// private int logRetentionDays; -// -// -// @Bean(initMethod = "start", destroyMethod = "destroy") -// public XxlJobSpringExecutor xxlJobExecutor() { -// log.info("====xxl-job config init===="); -// XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor(); -// xxlJobSpringExecutor.setAdminAddresses(adminAddresses); -// xxlJobSpringExecutor.setAppName(appName); -// xxlJobSpringExecutor.setIp(ip); -// xxlJobSpringExecutor.setPort(port); -// xxlJobSpringExecutor.setAccessToken(accessToken); -// xxlJobSpringExecutor.setLogPath(logPath); -// xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays); -// return xxlJobSpringExecutor; -// } -// -// } -// diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/equipment/PlanMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/equipment/PlanMapper.java new file mode 100644 index 0000000..d2948fa --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/equipment/PlanMapper.java @@ -0,0 +1,17 @@ +package com.hnac.hzims.scheduled.mapper.equipment; + + +import com.hnac.hzims.equipment.entity.PlanGenerationEntity; +import org.apache.ibatis.annotations.Param; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + +import java.util.List; + +/** + * @author ysj + */ +public interface PlanMapper extends UserDataScopeBaseMapper { + + // 查询计划发电量 + List planGeneration(@Param("stationIds") List stationIds, @Param("deptIds") List deptIds, @Param("date") String date); +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/equipment/WorkshopInfoMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/equipment/WorkshopInfoMapper.java new file mode 100644 index 0000000..3e0d5c4 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/equipment/WorkshopInfoMapper.java @@ -0,0 +1,10 @@ +package com.hnac.hzims.scheduled.mapper.equipment; + +import com.hnac.hzims.equipment.entity.WorkshopInfoEntity; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + +/** + * @author ysj + */ +public interface WorkshopInfoMapper extends UserDataScopeBaseMapper { +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/inspect/TaskMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/inspect/TaskMapper.java new file mode 100644 index 0000000..1a4a34b --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/inspect/TaskMapper.java @@ -0,0 +1,13 @@ +package com.hnac.hzims.scheduled.mapper.inspect; + +import com.hnac.hzinfo.inspect.task.entity.TaskEntity; +import org.apache.ibatis.annotations.Mapper; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + +/** + * @author ysj + */ +@Mapper +public interface TaskMapper extends UserDataScopeBaseMapper { + +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/AbnormalAlarmMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/AbnormalAlarmMapper.java index b677a4e..12876bd 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/AbnormalAlarmMapper.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/AbnormalAlarmMapper.java @@ -1,20 +1,14 @@ package com.hnac.hzims.scheduled.mapper.operation; import com.hnac.hzims.operational.alert.entity.AbnormalAlarmEntity; -import org.apache.ibatis.annotations.Param; import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; import java.util.List; /** - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/5/19 10:30 + * @author ysj */ -public interface AbnormalAlarmMapper extends UserDataScopeBaseMapper{ +public interface AbnormalAlarmMapper extends UserDataScopeBaseMapper { - AbnormalAlarmEntity getAbnormalAlarm(@Param("stationId") String stationId, @Param("type") String type); - - List getAbnormalAlarmList(); + List abnormalAlarms(); } diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/AccessMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/AccessMapper.java new file mode 100644 index 0000000..a9b5957 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/AccessMapper.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.scheduled.mapper.operation; + +import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + +/** + * @author ysj + */ +public interface AccessMapper extends UserDataScopeBaseMapper { + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/DefectMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/DefectMapper.java new file mode 100644 index 0000000..34d3a1c --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/DefectMapper.java @@ -0,0 +1,12 @@ +package com.hnac.hzims.scheduled.mapper.operation; + +import com.hnac.hzims.operational.defect.entity.OperDefectEntity; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + +/** + * @author ysj + */ +public interface DefectMapper extends UserDataScopeBaseMapper { + + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/GenerateMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/GenerateMapper.java new file mode 100644 index 0000000..7f2eaa1 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/GenerateMapper.java @@ -0,0 +1,17 @@ +package com.hnac.hzims.scheduled.mapper.operation; + +import com.hnac.hzims.operational.fill.entity.GenerateEntity; +import org.apache.ibatis.annotations.Param; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + +import java.util.List; + +/** + * @author ysj + * @date 2023/04/10 11:22:14 + * @version 4.0.0 + */ +public interface GenerateMapper extends UserDataScopeBaseMapper { + + List records(@Param("date") String date,@Param("station") String station); +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/HistoryAbnormalAlarmMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/HistoryAbnormalAlarmMapper.java deleted file mode 100644 index e680c53..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/HistoryAbnormalAlarmMapper.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.hnac.hzims.scheduled.mapper.operation; - -import com.hnac.hzims.operational.alert.entity.HistoryAbnormalAlarmEntity; -import org.apache.ibatis.annotations.Param; -import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; - -import java.util.List; - -/** - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/5/19 11:12 - */ -public interface HistoryAbnormalAlarmMapper extends UserDataScopeBaseMapper { - - List getHistoryAbnormalAlarm(@Param("stationId") String stationId, @Param("type") String type); - - - -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/MaintenanceMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/MaintenanceMapper.java new file mode 100644 index 0000000..2480f52 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/MaintenanceMapper.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.scheduled.mapper.operation; + +import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + +/** + * @author ysj + */ +public interface MaintenanceMapper extends UserDataScopeBaseMapper { + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/HzimsAnalyzeModelStationMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/ModelStationMapper.java similarity index 53% rename from hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/HzimsAnalyzeModelStationMapper.java rename to hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/ModelStationMapper.java index 41ad4ad..907e4ff 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/HzimsAnalyzeModelStationMapper.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/ModelStationMapper.java @@ -3,11 +3,10 @@ package com.hnac.hzims.scheduled.mapper.operation; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.hnac.hzims.operational.station.entity.HzimsAnalyzeModelStationEntity; + /** - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/5/22 11:43 + * @author ysj */ -public interface HzimsAnalyzeModelStationMapper extends BaseMapper { +public interface ModelStationMapper extends BaseMapper { + } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/mapper/OtherMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/OtherMapper.java similarity index 73% rename from hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/mapper/OtherMapper.java rename to hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/OtherMapper.java index 5d0b450..90c2d6d 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/mapper/OtherMapper.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/OtherMapper.java @@ -1,8 +1,11 @@ -package com.hnac.hzims.operational.fill.mapper; +package com.hnac.hzims.scheduled.mapper.operation; import com.hnac.hzims.operational.fill.entity.OtherEntity; import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; +/** + * @author ysj + */ public interface OtherMapper extends UserDataScopeBaseMapper { } diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/OverDetailsMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/OverDetailsMapper.java new file mode 100644 index 0000000..32582ec --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/OverDetailsMapper.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.scheduled.mapper.operation; + +import com.hnac.hzims.operational.fill.entity.OverDetailsEntity; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + +/** + * @author ysj + */ +public interface OverDetailsMapper extends UserDataScopeBaseMapper { + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/OverMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/OverMapper.java new file mode 100644 index 0000000..17f20f9 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/OverMapper.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.scheduled.mapper.operation; + +import com.hnac.hzims.operational.fill.entity.OverEntity; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + +/** + * @author ysj + */ +public interface OverMapper extends UserDataScopeBaseMapper { + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/PhenomenonMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/PhenomenonMapper.java new file mode 100644 index 0000000..58eebab --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/PhenomenonMapper.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.scheduled.mapper.operation; + +import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + +/** + * @author ysj + */ +public interface PhenomenonMapper extends UserDataScopeBaseMapper { + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/PowerMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/PowerMapper.java new file mode 100644 index 0000000..d463fd1 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/PowerMapper.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.scheduled.mapper.operation; + +import com.hnac.hzims.operational.fill.entity.PowerEntity; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + +/** + * @author ysj + */ +public interface PowerMapper extends UserDataScopeBaseMapper { + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/StAlarmRecordMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/RecordMapper.java similarity index 51% rename from hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/StAlarmRecordMapper.java rename to hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/RecordMapper.java index 8b3e211..27d01a1 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/StAlarmRecordMapper.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/RecordMapper.java @@ -1,14 +1,17 @@ package com.hnac.hzims.scheduled.mapper.operation; + import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzims.operational.config.entity.StAlarmRecordEntity; +import com.hnac.hzims.operational.config.vo.StAlarmRecordVo; + +import java.util.List; /** - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/5/19 15:47 + * @author ysj */ -public interface StAlarmRecordMapper extends BaseMapper { +public interface RecordMapper extends BaseMapper { + Long insertReturnId(StAlarmRecordEntity record); } diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/SolveMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/SolveMapper.java new file mode 100644 index 0000000..e09fef2 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/SolveMapper.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.scheduled.mapper.operation; + +import com.hnac.hzims.operational.fill.entity.SolveEntity; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + +/** + * @author ysj + */ +public interface SolveMapper extends UserDataScopeBaseMapper { + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/StFocusPropertiesMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/StFocusPropertiesMapper.java deleted file mode 100644 index 68d7a3d..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/StFocusPropertiesMapper.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.hnac.hzims.scheduled.mapper.operation; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.hnac.hzims.operational.config.entity.StFocusPropertiesEntity; - -/** - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/5/19 11:28 - */ -public interface StFocusPropertiesMapper extends BaseMapper { -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/StationAttrConfigMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/StationAttrConfigMapper.java index 76a7952..04a16ee 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/StationAttrConfigMapper.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/StationAttrConfigMapper.java @@ -4,10 +4,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.hnac.hzims.operational.station.entity.StationAttrConfigEntity; /** - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/5/19 16:09 + * @author ysj */ public interface StationAttrConfigMapper extends BaseMapper { + } diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/StationAttributeMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/StationAttributeMapper.java index 89cf2a3..9cfd0f9 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/StationAttributeMapper.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/StationAttributeMapper.java @@ -1,13 +1,16 @@ package com.hnac.hzims.scheduled.mapper.operation; import com.hnac.hzims.operational.station.entity.StationAttributeEntity; +import org.apache.ibatis.annotations.Mapper; import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; +import java.util.List; + /** - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/5/19 11:39 + * @author hx */ +@Mapper public interface StationAttributeMapper extends UserDataScopeBaseMapper { + + List PointUnit(); } diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/StationMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/StationMapper.java index 3b81746..f1d3745 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/StationMapper.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/StationMapper.java @@ -1,21 +1,12 @@ package com.hnac.hzims.scheduled.mapper.operation; + import com.hnac.hzims.operational.station.entity.StationEntity; import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; -import java.util.List; - /** - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/5/19 10:36 + * @author ysj */ public interface StationMapper extends UserDataScopeBaseMapper { - List selectStationByType(Integer stationType, Integer serveType); - - List selectAll(); - - List selectStationByInCode(List codes); } diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/UseMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/UseMapper.java new file mode 100644 index 0000000..364bce0 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/UseMapper.java @@ -0,0 +1,13 @@ +package com.hnac.hzims.scheduled.mapper.operation; + +import com.hnac.hzims.operational.fill.entity.UseEntity; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + +/** + * @author ysj + * @date 2023/04/10 11:22:14 + * @version 4.0.0 + */ +public interface UseMapper extends UserDataScopeBaseMapper { + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/safeproduct/CompanyMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/safeproduct/CompanyMapper.java new file mode 100644 index 0000000..00aa8a5 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/safeproduct/CompanyMapper.java @@ -0,0 +1,10 @@ +package com.hnac.hzims.scheduled.mapper.safeproduct; + +import com.hnac.hzims.safeproduct.entity.CheckCompanyEntity; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + +/** + * @author ysj + */ +public interface CompanyMapper extends UserDataScopeBaseMapper { +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/safeproduct/InstanceMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/safeproduct/InstanceMapper.java new file mode 100644 index 0000000..3e3d781 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/safeproduct/InstanceMapper.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.scheduled.mapper.safeproduct; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.safeproduct.entity.CheckItemInstanceEntity; + +/** + * @author Lch + */ +public interface InstanceMapper extends BaseMapper { + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/safeproduct/MonthMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/safeproduct/MonthMapper.java new file mode 100644 index 0000000..4454508 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/safeproduct/MonthMapper.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.scheduled.mapper.safeproduct; + +import com.hnac.hzims.safeproduct.entity.CheckMonthEntity; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + +/** + * @author ysj + */ +public interface MonthMapper extends UserDataScopeBaseMapper { + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/safeproduct/TrialMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/safeproduct/TrialMapper.java new file mode 100644 index 0000000..04496f0 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/safeproduct/TrialMapper.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.scheduled.mapper.safeproduct; + +import com.hnac.hzims.safeproduct.entity.SafeEquipmentTrialEntity; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + +/** + * 设备试验mapper接口 + */ +public interface TrialMapper extends UserDataScopeBaseMapper { + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/ticket/TicketEvaluateMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/ticket/TicketEvaluateMapper.java new file mode 100644 index 0000000..31feb3e --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/ticket/TicketEvaluateMapper.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.scheduled.mapper.ticket; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.ticket.allTicket.entity.TicketInfoEvaluateEntity; + +/** + * @author ysj + */ +public interface TicketEvaluateMapper extends BaseMapper { + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/ticket/TicketMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/ticket/TicketMapper.java new file mode 100644 index 0000000..a17dd00 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/ticket/TicketMapper.java @@ -0,0 +1,13 @@ +package com.hnac.hzims.scheduled.mapper.ticket; + +import com.hnac.hzims.ticket.standardTicket.entity.StandardTicketInfoEntity; +import org.apache.ibatis.annotations.Mapper; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + +/** + * @author ysj + */ +@Mapper +public interface TicketMapper extends UserDataScopeBaseMapper { + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/ticket/WorkTicketMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/ticket/WorkTicketMapper.java new file mode 100644 index 0000000..e30a55e --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/ticket/WorkTicketMapper.java @@ -0,0 +1,14 @@ +package com.hnac.hzims.scheduled.mapper.ticket; + +import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity; +import org.apache.ibatis.annotations.Mapper; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + +/** + * @author ysj + */ +@Mapper +public interface WorkTicketMapper extends UserDataScopeBaseMapper { + + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/MonitorScheduledTask.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/MonitorScheduledTask.java new file mode 100644 index 0000000..6e5a0e9 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/MonitorScheduledTask.java @@ -0,0 +1,65 @@ +package com.hnac.hzims.scheduled.scheduled; + +import com.hnac.hzims.scheduled.service.operation.MonitorService; +import com.xxl.job.core.biz.model.ReturnT; +import com.xxl.job.core.handler.annotation.XxlJob; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.utils.DateUtil; +import org.springblade.core.tool.utils.Func; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.Date; + +import static com.hnac.hzims.operational.main.constant.MainConstants.*; + + +/** + * @author ysj + */ +@Slf4j +@Component +public class MonitorScheduledTask { + + @Autowired + private MonitorService service; + + /** + * realId刷新 + */ + @XxlJob(REAL_ID_DATA) + public ReturnT loadRealId(String param) { + if (Func.isBlank(param)) { + param = DateUtil.format(new Date(), "yyyy-MM"); + } + service.loadRealId(param); + return new ReturnT<>("SUCCESS"); + } + + /** + * 实时数据刷新 + * @return ReturnT + */ + @XxlJob(REAL_TIME_DATA) + //@Scheduled(cron = "0/40 * * * * ? ") + public ReturnT loadRealData(String param) { + if (Func.isBlank(param)) { + param = DateUtil.format(new Date(), "yyyy-MM"); + } + service.loadRealData(param); + return new ReturnT<>("SUCCESS"); + } + + /** + * 集中监控数据处理 + * @return ReturnT + */ + @XxlJob(CENTRALIZED_MONITORING) + public ReturnT loadMonitoring(String param) { + if (Func.isBlank(param)) { + param = DateUtil.format(new Date(), "yyyy-MM"); + } + service.loadMonitoring(param); + return new ReturnT<>("SUCCESS"); + } +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java new file mode 100644 index 0000000..b589578 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java @@ -0,0 +1,126 @@ +package com.hnac.hzims.scheduled.scheduled; + +import com.hnac.hzims.operational.main.constant.HomePageConstant; +import com.hnac.hzims.scheduled.service.operation.RealTargetService; +import com.xxl.job.core.biz.model.ReturnT; +import com.xxl.job.core.handler.annotation.XxlJob; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.utils.DateUtil; +import org.springblade.core.tool.utils.Func; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.Arrays; +import java.util.Date; + +import static com.hnac.hzims.operational.main.constant.MainConstants.*; + + +/** + * @author ysj + */ +@Slf4j +@Component +public class RealTargetScheduledTask { + + @Autowired + private RealTargetService service; + + + /** + * 水电站-机组实时加载 + */ + @XxlJob(LOAD_HYDROPOWER_UNIT_REAL) + public ReturnT loadHydropowerReal(String param) { + if (Func.isBlank(param)) { + param = DateUtil.format(new Date(), "yyyy-MM"); + } + service.loadHydropowerReal(param); + return new ReturnT<>("SUCCESS"); + } + + /** + * 水电站-机组指标加载 + */ + @XxlJob(LOAD_HYDROPOWER_UNIT_TARGET) + public ReturnT loadHydropowerTarget(String param) { + if (Func.isBlank(param)) { + param = DateUtil.format(new Date(), "yyyy-MM"); + } + service.loadHydropowerTarget(param); + return new ReturnT<>("SUCCESS"); + } + + /** + * 水利-泵组实时加载 + */ + @XxlJob(LOAD_WATER_PUMP_REAL) + public ReturnT loadWaterPumpReal(String param) { + if (Func.isBlank(param)) { + param = DateUtil.format(new Date(), "yyyy-MM"); + } + service.loadWaterPumpReal(param); + return new ReturnT<>("SUCCESS"); + } + + + /** + * 水利-泵组指标加载 + */ + @XxlJob(LOAD_WATER_PUMP_TARGET) + public ReturnT loadWaterPumpTarget(String param) { + if (Func.isBlank(param)) { + param = DateUtil.format(new Date(), "yyyy-MM"); + } + service.loadWaterPumpTarget(param); + return new ReturnT<>("SUCCESS"); + } + + /** + * 水利-站点水位数据 + */ + @XxlJob(LOAD_WATER_LEVEL) + public ReturnT loadWaterLevel(String param) { + if (Func.isBlank(param)) { + param = DateUtil.format(new Date(), "yyyy-MM"); + } + service.loadWaterLevel(param); + return new ReturnT<>("SUCCESS"); + } + + /** + * 光伏站-逆变器实时加载 + */ + @XxlJob(LOAD_PHOTOVOLTAIC_REAL) + public ReturnT loadPhotovoltaicReal(String param) { + if (Func.isBlank(param)) { + param = DateUtil.format(new Date(), "yyyy-MM"); + } + service.loadPhotovoltaicReal(param); + return new ReturnT<>("SUCCESS"); + } + + /** + * 光伏站-逆变器指标加载 + */ + @XxlJob(LOAD_PHOTOVOLTAIC_TARGET) + public ReturnT loadPhotovoltaicTarget(String param) { + if (Func.isBlank(param)) { + param = DateUtil.format(new Date(), "yyyy-MM"); + } + service.loadPhotovoltaicTarget(param); + return new ReturnT<>("SUCCESS"); + } + + /** + * 获取站点近3年发电量数据 + */ + @XxlJob(ELECTRICITY_GENERATION_RECENT_YEAR) + public ReturnT loadPowerData(String param) { + if (Func.isBlank(param)) { + param = DateUtil.format(new Date(), "yyyy-MM"); + } + service.loadPowerData(param, Arrays.asList(HomePageConstant.HYDROPOWER,HomePageConstant.PHOTOVOLTAIC),2,3); + return new ReturnT<>("SUCCESS"); + } +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ReportScheduledTask.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ReportScheduledTask.java new file mode 100644 index 0000000..7f59697 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ReportScheduledTask.java @@ -0,0 +1,40 @@ +package com.hnac.hzims.scheduled.scheduled; + +import com.hnac.hzims.scheduled.service.operation.ReportService; +import com.xxl.job.core.biz.model.ReturnT; +import com.xxl.job.core.handler.annotation.XxlJob; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.utils.DateUtil; +import org.springblade.core.tool.utils.Func; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.Date; + +import static com.hnac.hzims.operational.main.constant.MainConstants.AREA_MONTH_REPORT; + + +/** + * @author ysj + */ +@Slf4j +@Component +public class ReportScheduledTask { + + @Autowired + private ReportService service; + + /** + * 首页-生产月报表 + * @return ReturnT + */ + @XxlJob(AREA_MONTH_REPORT) + public ReturnT loadMonthReport(String param) { + if (Func.isBlank(param)) { + param = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + } + service.loadMonthReport(param,1); + return new ReturnT<>("SUCCESS"); + } + +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ScheduledCreateTask.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ScheduledCreateTask.java deleted file mode 100644 index 81cb979..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ScheduledCreateTask.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.hnac.hzims.scheduled.scheduled; - -import com.hnac.hzims.scheduled.service.IWaterService; -import com.xxl.job.core.biz.model.ReturnT; -import com.xxl.job.core.handler.annotation.XxlJob; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.tool.utils.DateUtil; -import org.springblade.core.tool.utils.Func; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.util.Date; - -import static com.hnac.hzims.operational.main.constant.MainConstants.LOAD_WATER_LEVEL; - -/** - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/5/22 11:21 - */ -@Slf4j -@Component -public class ScheduledCreateTask { - - @Autowired - private IWaterService waterService; - - /** - * 水利-站点水位数据 - * @return ReturnT - */ - @XxlJob(LOAD_WATER_LEVEL) - public ReturnT loadWaterLevel(String param) throws Exception { - if (Func.isBlank(param)) { - param = DateUtil.format(new Date(), "yyyy-MM"); - } - waterService.loadWaterLevel(param); - return new ReturnT<>("SUCCESS"); - } - - - - /** - * 水利-站点水位数据 - * @return ReturnT - */ - @XxlJob("cheshi") - public ReturnT cheshi(String param) throws Exception { - System.out.println("执行呢方法"); - return new ReturnT<>("SUCCESS"); - } - -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ShowScheduledTask.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ShowScheduledTask.java new file mode 100644 index 0000000..426502e --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ShowScheduledTask.java @@ -0,0 +1,38 @@ +package com.hnac.hzims.scheduled.scheduled; + +import com.hnac.hzims.scheduled.service.operation.ShowService; +import com.xxl.job.core.biz.model.ReturnT; +import com.xxl.job.core.handler.annotation.XxlJob; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.utils.DateUtil; +import org.springblade.core.tool.utils.Func; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.Date; + +import static com.hnac.hzims.operational.main.constant.MainConstants.LOAD_HOME_TARGET; + + +/** + * @author ysj + */ +@Slf4j +@Component +public class ShowScheduledTask { + + @Autowired + private ShowService service; + + /** + * 首页-指标数据加载 + */ + @XxlJob(LOAD_HOME_TARGET) + public ReturnT loadHomeTarget(String param) { + if (Func.isBlank(param)) { + param = DateUtil.format(new Date(), "yyyy-MM"); + } + service.loadHomeTarget(param); + return new ReturnT<>("SUCCESS"); + } +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/StAlamRecordTask.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/StAlamRecordTask.java deleted file mode 100644 index b253c41..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/StAlamRecordTask.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.hnac.hzims.scheduled.scheduled; - -import com.hnac.hzims.scheduled.service.AbnormalAlarmService; -import com.hnac.hzims.scheduled.service.IRealMonitorService; -import com.hnac.hzims.scheduled.service.StFocusPropertiesService; -import com.xxl.job.core.biz.model.ReturnT; -import com.xxl.job.core.handler.annotation.XxlJob; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.tool.utils.DateUtil; -import org.springblade.core.tool.utils.Func; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; - -import java.util.Date; - -import static com.hnac.hzims.operational.main.constant.MainConstants.*; - -/** - * 集中监控 - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/5/19 10:17 - */ -@Slf4j -@Component -public class StAlamRecordTask { - - @Value("${hzims.operation.comprehensiveD}") - public String path; - - // @Autowired - private IRealMonitorService monitorService; - - @Autowired - private AbnormalAlarmService abnormalAlarmService; - - @Autowired - private StFocusPropertiesService stFocusPropertiesService; - - /** - * 数据中断告警 - * @return ReturnT - */ - @XxlJob(ALARM_DATA_HANDLE) - public ReturnT alarmDataHandle(String param) throws Exception { - if (Func.isBlank(param)) { - param = DateUtil.format(new Date(), "yyyy-MM"); - } - abnormalAlarmService.alarmDataHandle(param); - return new ReturnT<>("SUCCESS"); - } - - - - /** - * realId获取 - * @return ReturnT - */ - @XxlJob(REAL_ID_DATA) - public ReturnT realIdData(String param) throws Exception { - if (Func.isBlank(param)) { - param = DateUtil.format(new Date(), "yyyy-MM"); - } - stFocusPropertiesService.getStationRealIds(param); - return new ReturnT<>("SUCCESS"); - } - - /** - * 站点实时数据 - * @return ReturnT - */ - @XxlJob(REAL_TIME_DATA) - //@Scheduled(cron = "0/40 * * * * ? ") - public ReturnT realTimeData(String param) throws Exception { - if (Func.isBlank(param)) { - param = DateUtil.format(new Date(), "yyyy-MM"); - } - monitorService.realTimeData(param); - return new ReturnT<>("SUCCESS"); - } - - - - /** - * 集中监控数据处理 - * @return ReturnT - */ - @XxlJob(CENTRALIZED_MONITORING) - //@Scheduled(cron = "0/40 * * * * ? ") - public ReturnT centralizedMonitoring(String param) throws Exception { - if (Func.isBlank(param)) { - param = DateUtil.format(new Date(), "yyyy-MM"); - } - monitorService.centralizedMonitoring(param); - return new ReturnT<>("SUCCESS"); - } - - -} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/HistoryAbnormalAlarmService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/HistoryAbnormalAlarmService.java deleted file mode 100644 index 4c2816e..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/HistoryAbnormalAlarmService.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.hnac.hzims.scheduled.service; - -import com.hnac.hzims.operational.alert.entity.HistoryAbnormalAlarmEntity; -import org.springblade.core.mp.base.BaseService; - -/** - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/5/19 11:09 - */ -public interface HistoryAbnormalAlarmService extends BaseService { - - - HistoryAbnormalAlarmEntity getAbnormalAlarm(String station, String soeType); -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/IHzimsAnalyzeModelStationService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/IHzimsAnalyzeModelStationService.java deleted file mode 100644 index 15c7b7a..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/IHzimsAnalyzeModelStationService.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.hnac.hzims.scheduled.service; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.hnac.hzims.operational.station.entity.HzimsAnalyzeModelStationEntity; -import org.springblade.core.mp.base.BaseService; - -import java.util.List; - -/** - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/5/22 11:31 - */ -public interface IHzimsAnalyzeModelStationService extends BaseService { - -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/IMainSystemMonitoringService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/IMainSystemMonitoringService.java deleted file mode 100644 index d9b6c4e..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/IMainSystemMonitoringService.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.hnac.hzims.scheduled.service; - -import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; - -import java.util.List; - -/** - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/5/19 14:00 - */ -public interface IMainSystemMonitoringService { - - List getEmInfoList(); -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/IRealMonitorService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/IRealMonitorService.java deleted file mode 100644 index 9de496f..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/IRealMonitorService.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.hnac.hzims.scheduled.service; - -/** - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/5/19 10:20 - */ -public interface IRealMonitorService { - void realTimeData(String param); - - void centralizedMonitoring(String param); -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/IStationAttrConfigService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/IStationAttrConfigService.java deleted file mode 100644 index 747bcc4..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/IStationAttrConfigService.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.hnac.hzims.scheduled.service; - -import com.hnac.hzims.operational.station.entity.StationAttrConfigEntity; -import org.springblade.core.mp.base.BaseService; - -import java.util.List; - -/** - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/5/19 16:06 - */ -public interface IStationAttrConfigService extends BaseService { - List getHideList(); -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/IStationAttributeService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/IStationAttributeService.java deleted file mode 100644 index 0713bb1..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/IStationAttributeService.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.hnac.hzims.scheduled.service; - -import com.hnac.hzims.operational.station.entity.StationAttributeEntity; -import org.springblade.core.mp.base.BaseService; - -/** - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/5/19 11:34 - */ -public interface IStationAttributeService extends BaseService { -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/IStationService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/IStationService.java deleted file mode 100644 index 246d261..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/IStationService.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.hnac.hzims.scheduled.service; - -import com.hnac.hzims.operational.station.entity.StationEntity; -import org.springblade.core.mp.base.BaseService; - -import java.util.ArrayList; -import java.util.List; - -/** - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/5/19 10:33 - */ -public interface IStationService extends BaseService { - - List getStationByType(Integer stationType, Integer serveType); - - List getAll(); - - List getStationByInCode(List strings); - - - List getStationType(Integer serveType,List typeList,List departIdList); - - -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/IWaterService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/IWaterService.java deleted file mode 100644 index e50d049..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/IWaterService.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.hnac.hzims.scheduled.service; - -/** - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/5/22 11:22 - */ -public interface IWaterService { - void loadWaterLevel(String param); -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/StAlamRecordService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/StAlamRecordService.java deleted file mode 100644 index cff89fd..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/StAlamRecordService.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.hnac.hzims.scheduled.service; - -import com.hnac.hzims.operational.config.entity.StAlarmRecordEntity; -import org.springblade.core.mp.base.BaseService; - -/** - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/5/19 15:41 - */ -public interface StAlamRecordService extends BaseService { - Long insertAlert(String stationId, String monitorId); -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/StFocusPropertiesService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/StFocusPropertiesService.java deleted file mode 100644 index 479b4b3..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/StFocusPropertiesService.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.hnac.hzims.scheduled.service; - -import com.hnac.hzims.operational.config.entity.StFocusPropertiesEntity; -import org.springblade.core.mp.base.BaseService; - -/** - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/5/19 10:21 - */ -public interface StFocusPropertiesService extends BaseService { - void getStationRealIds(String param); -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/PlanService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/PlanService.java new file mode 100644 index 0000000..52f4d3a --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/PlanService.java @@ -0,0 +1,16 @@ +package com.hnac.hzims.scheduled.service.equipment; + +import com.hnac.hzims.equipment.entity.PlanGenerationEntity; +import org.springblade.core.mp.base.BaseService; + +import java.util.List; + +/** + * @author ysj + */ +public interface PlanService extends BaseService { + + + // 查询计划发电量 + List planGeneration(List stationIds, List deptIds, String date); +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/WorkshopInfoService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/WorkshopInfoService.java new file mode 100644 index 0000000..3fe8199 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/WorkshopInfoService.java @@ -0,0 +1,12 @@ +package com.hnac.hzims.scheduled.service.equipment; + +import com.hnac.hzims.equipment.entity.WorkshopInfoEntity; +import org.springblade.core.mp.base.BaseService; + + +/** + * @author hx + */ +public interface WorkshopInfoService extends BaseService { + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/PlanServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/PlanServiceImpl.java new file mode 100644 index 0000000..56cc7ca --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/PlanServiceImpl.java @@ -0,0 +1,35 @@ +package com.hnac.hzims.scheduled.service.equipment.impl; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.hnac.hzims.equipment.entity.PlanGenerationEntity; +import com.hnac.hzims.scheduled.mapper.equipment.PlanMapper; +import com.hnac.hzims.scheduled.service.equipment.PlanService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @author ysj + */ +@Service +@Slf4j +@AllArgsConstructor +@DS("equipment") +public class PlanServiceImpl extends BaseServiceImpl implements PlanService { + + + /** + * 查询计划发电量 + * @param stationIds + * @param deptIds + * @param date + * @return + */ + @Override + public List planGeneration(List stationIds, List deptIds, String date) { + return this.baseMapper.planGeneration(stationIds,deptIds,date); + } +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/WorkshopInfoServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/WorkshopInfoServiceImpl.java new file mode 100644 index 0000000..d7ae08f --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/WorkshopInfoServiceImpl.java @@ -0,0 +1,21 @@ +package com.hnac.hzims.scheduled.service.equipment.impl; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.hnac.hzims.equipment.entity.WorkshopInfoEntity; +import com.hnac.hzims.scheduled.mapper.equipment.WorkshopInfoMapper; +import com.hnac.hzims.scheduled.service.equipment.WorkshopInfoService; +import groovy.util.logging.Slf4j; +import lombok.AllArgsConstructor; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +/** + * @author hx + */ +@Service +@AllArgsConstructor +@Slf4j +@DS("equipment") +public class WorkshopInfoServiceImpl extends BaseServiceImpl implements WorkshopInfoService { + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/impl/AbnormalAlarmServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/impl/AbnormalAlarmServiceImpl.java deleted file mode 100644 index 9a57ee4..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/impl/AbnormalAlarmServiceImpl.java +++ /dev/null @@ -1,242 +0,0 @@ -package com.hnac.hzims.scheduled.service.impl; - -import com.hnac.hzims.message.MessageConstants; -import com.hnac.hzims.message.dto.MessagePushRecordDto; -import com.hnac.hzims.message.fegin.IMessageClient; -import com.hnac.hzims.operational.alert.constants.AbnormalAlarmConstant; -import com.hnac.hzims.operational.alert.entity.AbnormalAlarmEntity; -import com.hnac.hzims.operational.alert.entity.HistoryAbnormalAlarmEntity; -import com.hnac.hzims.operational.main.constant.HomePageConstant; -import com.hnac.hzims.operational.station.entity.StationEntity; -import com.hnac.hzims.scheduled.mapper.operation.AbnormalAlarmMapper; -import com.hnac.hzims.scheduled.service.AbnormalAlarmService; -import com.hnac.hzims.scheduled.service.HistoryAbnormalAlarmService; -import com.hnac.hzims.scheduled.service.IStationService; -import com.hnac.hzinfo.datasearch.soe.ISoeClient; -import com.hnac.hzinfo.datasearch.soe.domian.SoeData; -import com.hnac.hzinfo.datasearch.soe.domian.SoeQueryConditionByStation; -import com.hnac.hzinfo.sdk.core.response.HzPage; -import com.hnac.hzinfo.sdk.core.response.Result; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.mp.base.BaseServiceImpl; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.CollectionUtil; -import org.springblade.core.tool.utils.DateUtil; -import org.springblade.core.tool.utils.ObjectUtil; -import org.springblade.core.tool.utils.StringUtil; -import org.springblade.system.feign.ISysClient; -import org.springblade.system.user.entity.User; -import org.springblade.system.user.feign.IUserClient; -import org.springframework.stereotype.Service; - -import java.time.LocalDateTime; -import java.util.*; -import java.util.concurrent.CompletableFuture; -import java.util.function.Function; -import java.util.stream.Collectors; - -/** - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/5/19 10:29 - */ -@Slf4j -@Service -@RequiredArgsConstructor -public class AbnormalAlarmServiceImpl extends BaseServiceImpl implements AbnormalAlarmService { - - - private final IStationService stationService; - - - private final HistoryAbnormalAlarmService historyAbnormalAlarmService; - - private final ISysClient sysClient; - - private final ISoeClient soeClient; - - private final IUserClient userClient; - - private final IMessageClient messageClient; - - - /** - * 数据中断、数据异常告警 - * @param param - */ - @Override - public void alarmDataHandle(String param) { - // 查询代运维站点 - List stations = stationService.getStationByType(null, HomePageConstant.HYDROPOWER_SERVETYPE); - if(CollectionUtil.isEmpty(stations)){ - return; - } - SoeQueryConditionByStation query = new SoeQueryConditionByStation(); - query.setTypes(AbnormalAlarmConstant.SEND_MESSSAGE_TYPE_LIST); - query.setStationIds(stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); - Calendar calendar = Calendar.getInstance(); - query.setEndTime(LocalDateTime.parse(DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATETIME),DateUtil.DATETIME_FORMATTER)); - calendar.add(Calendar.MINUTE,-2); - query.setBeginTime(LocalDateTime.parse(DateUtil.format(calendar.getTime() , DateUtil.PATTERN_DATETIME),DateUtil.DATETIME_FORMATTER)); - query.setNeedPage(false); - log.error("alarm_data_handle_param : {}",query); - Result> result = soeClient.getByStationsAndTime(query); - // 未查询到告警信息 - if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData().getRecords())){ - return; - } - log.error("alarm_data_handle_begin_result : {}",result.getData().getRecords()); - // 遍历告警信息 - List list = new ArrayList<>(result.getData().getRecords().stream().sorted(Comparator.comparing(SoeData::getTs).reversed()) - .collect(Collectors.toMap(o -> o.getStation() + o.getSoeType(), Function.identity(), (o1, o2) -> o1)).values()); - log.error("alarm_data_handle_end_result : {}",list); - list.forEach(item -> { - AbnormalAlarmEntity queryEntity = this.baseMapper.getAbnormalAlarm(item.getStation(),item.getSoeType()); - boolean flag = AbnormalAlarmConstant.ABNORMAL_STATUS.equals(item.getSoeAlarmType()); - String stationName = Optional.ofNullable(stations.stream().filter(o-> o.getCode().equals(item.getStation())).collect(Collectors.toList())).map(o->o.get(0).getName()).orElse(null); - if(ObjectUtil.isEmpty(queryEntity)){ - AbnormalAlarmEntity entity = new AbnormalAlarmEntity(); - entity.setStationId(item.getStation()); - entity.setStationName(stationName); - entity.setRealId(item.getRealId()); - entity.setSoeExplain(item.getSoeExplain()); - entity.setType(item.getSoeType()); - entity.setStartTime(item.getTs()); - entity.setEndTime(null); - entity.setStatus(0); - if(flag){ - entity.setStartTime(null); - entity.setEndTime(item.getTs()); - entity.setStatus(1); - } - // 保存告警信息 - this.save(entity); - return; - } - queryEntity.setSoeExplain(item.getSoeExplain()); - queryEntity.setStationName(stationName); - queryEntity.setType(item.getSoeType()); - queryEntity.setStartTime(queryEntity.getStartTime()); - queryEntity.setUpdateTime(new Date()); - queryEntity.setEndTime(null); - queryEntity.setStatus(0); - if(flag){ - queryEntity.setEndTime(item.getTs()); - queryEntity.setStatus(1); - } - this.updateById(queryEntity); - }); - - // 异步保存历史告警 - CompletableFuture.supplyAsync(()-> this.saveHistoryAlarm(result.getData().getRecords(),stations)); - } - - - /** - * 保存告警历史信息 - * @param list - * @return - */ - private String saveHistoryAlarm(List list,List stations) { - list.forEach(item -> { - Date ts = DateUtil.parse(DateUtil.format(item.getTs(),DateUtil.PATTERN_DATETIME),DateUtil.DATETIME_FORMAT); - // 历史数据异常查询 - HistoryAbnormalAlarmEntity queryEntity = this.historyAbnormalAlarmService.getAbnormalAlarm(item.getStation(),item.getSoeType()); - // 数据中断恢复 - boolean flag = AbnormalAlarmConstant.ABNORMAL_STATUS.equals(item.getSoeAlarmType()); - String stationName = Optional.ofNullable(stations.stream().filter(o-> o.getCode().equals(item.getStation())).collect(Collectors.toList())).map(o->o.get(0).getName()).orElse(null); - if(ObjectUtil.isEmpty(queryEntity) || !flag){ - HistoryAbnormalAlarmEntity entity = new HistoryAbnormalAlarmEntity(); - entity.setAlarmId(item.getId()); - entity.setStationId(item.getStation()); - entity.setStationName(stationName); - entity.setRealId(item.getRealId()); - entity.setSoeExplain(item.getSoeExplain()); - entity.setType(item.getSoeType()); - entity.setStartTime(ts); - entity.setStatus(0); - this.historyAbnormalAlarmService.save(entity); - // 消息推送 - this.sendAlarmMessage(Collections.singletonList(entity),stations); - return; - } - queryEntity.setSoeExplain(item.getSoeExplain()); - queryEntity.setUpdateTime(new Date()); - queryEntity.setEndTime(ts); - queryEntity.setStatus(1); - this.historyAbnormalAlarmService.updateById(queryEntity); - }); - return "success"; - } - - - - /** - * 告警消息推送 - * @param entitys - */ - private void sendAlarmMessage(List entitys,List stations) { - if(CollectionUtil.isEmpty(entitys)){ - return; - } - // 告警等级 :事故、数据中断 - List alarms = entitys.stream().filter(entity -> AbnormalAlarmConstant.SEND_MESSSAGE_TYPE_LIST.contains(entity.getType())).collect(Collectors.toList()); - if(CollectionUtil.isEmpty(alarms)){ - return; - } - // 查询站点用户 - entitys.forEach(entity->{ - if(StringUtil.isEmpty(entity.getStationId())){ - return; - } - List depts = stations.stream().filter(station -> station.getCode().equals(entity.getStationId())).map(StationEntity::getRefDept).collect(Collectors.toList()); - if(CollectionUtil.isEmpty(depts)){ - return; - } - // 获取站点用户 - R> result = userClient.userListByDeptId(depts.get(0)); - if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ - return; - } - MessagePushRecordDto message = new MessagePushRecordDto(); - message.setBusinessClassify("warning"); - message.setBusinessKey(MessageConstants.BusinessClassifyEnum.WARNING.getKey()); - message.setSubject(MessageConstants.BusinessClassifyEnum.WARNING.getDescription()); - message.setTaskId(entity.getId()); - message.setTenantId("200000"); - message.setContent(entity.getSoeExplain()); - message.setTypes(Arrays.asList(MessageConstants.APP_PUSH, MessageConstants.WS_PUSH)); - message.setPushType(MessageConstants.IMMEDIATELY); - message.setDeptId(depts.get(0)); - R deptName = sysClient.getDeptName(depts.get(0)); - if (deptName.isSuccess()) { - message.setDeptName(deptName.getData()); - } - User admin = userClient.userByAccount("200000", "admin").getData(); - message.setCreateDept(admin.getCreateDept()); - message.setCreateUser(admin.getCreateUser()); - result.getData().forEach(user->{ - message.setPusher(String.valueOf(user.getId())); - message.setPusherName(user.getName()); - message.setAccount(String.valueOf(user.getId())); - messageClient.sendMessage(message); - }); - }); - } - - - /** - * 查询实时告警数据 - * @return - */ - @Override - public List getAbnormalAlarmList() { - List alarmList = this.baseMapper.getAbnormalAlarmList(); - if(CollectionUtil.isEmpty(alarmList)){ - return new ArrayList<>(); - } - return alarmList; - } -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/impl/HistoryAbnormalAlarmServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/impl/HistoryAbnormalAlarmServiceImpl.java deleted file mode 100644 index 6824c7a..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/impl/HistoryAbnormalAlarmServiceImpl.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.hnac.hzims.scheduled.service.impl; - -import com.hnac.hzims.operational.alert.entity.HistoryAbnormalAlarmEntity; -import com.hnac.hzims.scheduled.mapper.operation.HistoryAbnormalAlarmMapper; -import com.hnac.hzims.scheduled.service.HistoryAbnormalAlarmService; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.mp.base.BaseServiceImpl; -import org.springblade.core.tool.utils.CollectionUtil; -import org.springframework.stereotype.Service; - -import java.util.Comparator; -import java.util.List; -import java.util.stream.Collectors; - -/** - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/5/19 11:12 - */ -@Slf4j -@Service -@RequiredArgsConstructor -public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl implements HistoryAbnormalAlarmService { - /** - * 查询单条历史告警 - * - * @param station - * @param soeType - * @return - */ - @Override - public HistoryAbnormalAlarmEntity getAbnormalAlarm(String station, String soeType) { - List alarms = this.baseMapper.getHistoryAbnormalAlarm(station, soeType); - if(CollectionUtil.isEmpty(alarms)){ - return null; - } - return alarms.stream().sorted(Comparator.comparing(HistoryAbnormalAlarmEntity::getStartTime)).collect(Collectors.toList()).get(0); - } -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/impl/HzimsAnalyzeModelStationServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/impl/HzimsAnalyzeModelStationServiceImpl.java deleted file mode 100644 index 26c1e39..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/impl/HzimsAnalyzeModelStationServiceImpl.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.hnac.hzims.scheduled.service.impl; - -import com.hnac.hzims.operational.station.entity.HzimsAnalyzeModelStationEntity; -import com.hnac.hzims.scheduled.mapper.operation.HzimsAnalyzeModelStationMapper; -import com.hnac.hzims.scheduled.service.IHzimsAnalyzeModelStationService; -import org.springblade.core.mp.base.BaseServiceImpl; -import org.springframework.stereotype.Service; - -/** - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/5/22 11:42 - */ -@Service -public class HzimsAnalyzeModelStationServiceImpl extends BaseServiceImpl implements IHzimsAnalyzeModelStationService { -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/impl/MainSystemMonitoringServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/impl/MainSystemMonitoringServiceImpl.java deleted file mode 100644 index 2620394..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/impl/MainSystemMonitoringServiceImpl.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.hnac.hzims.scheduled.service.impl; - -import com.alibaba.fastjson.JSONObject; -import com.alibaba.fastjson.TypeReference; -import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; -import com.hnac.hzims.scheduled.service.IMainSystemMonitoringService; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.tool.utils.ObjectUtil; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.List; - -/** - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/5/19 14:01 - */ -@Service -@Slf4j -@RequiredArgsConstructor -public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringService { - - - private final RedisTemplate redisTemplate; - - - @Value("${hzims.equipment.emInfo.emInfoList}") - public String emInfoListPath; - - /** - * 从Redis获取设备信息 - * - * @return - */ - @Override - public List getEmInfoList() { - List list = new ArrayList<>(); - Object json = redisTemplate.opsForValue().get(emInfoListPath); - if (ObjectUtil.isNotEmpty(json)) { - list = JSONObject.parseObject(json.toString(), new TypeReference>() { - }); - } - return list; - } - -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/impl/StFocusPropertiesServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/impl/StFocusPropertiesServiceImpl.java deleted file mode 100644 index f10b67e..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/impl/StFocusPropertiesServiceImpl.java +++ /dev/null @@ -1,164 +0,0 @@ -package com.hnac.hzims.scheduled.service.impl; - -import com.alibaba.fastjson.JSONObject; -import com.alibaba.fastjson.TypeReference; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.google.common.collect.Lists; -import com.hnac.hzims.equipment.entity.WorkshopInfoEntity; -import com.hnac.hzims.equipment.feign.IEmInfoClient; -import com.hnac.hzims.equipment.feign.IWorkshopInfoClient; -import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; -import com.hnac.hzims.operational.config.entity.StFocusPropertiesEntity; -import com.hnac.hzims.operational.main.constant.HomePageConstant; -import com.hnac.hzims.operational.station.entity.StationAttributeEntity; -import com.hnac.hzims.operational.station.entity.StationEntity; -import com.hnac.hzims.scheduled.mapper.operation.StFocusPropertiesMapper; -import com.hnac.hzims.scheduled.service.IStationAttributeService; -import com.hnac.hzims.scheduled.service.IStationService; -import com.hnac.hzims.scheduled.service.StFocusPropertiesService; -import com.hnac.hzims.scheduled.vo.StationRealVo; -import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; -import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO; -import com.hnac.hzinfo.sdk.analyse.po.MultiAnalyzeCodePO; -import lombok.RequiredArgsConstructor; -import org.springblade.core.log.logger.BladeLogger; -import org.springblade.core.mp.base.BaseServiceImpl; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.CollectionUtil; -import org.springblade.core.tool.utils.Func; -import org.springblade.core.tool.utils.ObjectUtil; -import org.springblade.core.tool.utils.StringUtil; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.function.Function; -import java.util.stream.Collectors; - -/** - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/5/19 11:27 - */ -@Service -@RequiredArgsConstructor -public class StFocusPropertiesServiceImpl extends BaseServiceImpl implements StFocusPropertiesService { - - - private final IStationService stationService; - - private final IStationAttributeService attbtService; - - private final IEmInfoClient emInfoClient; - - private final IAnalyseDataSearchClient analyseDataSearchClient; - - private final IWorkshopInfoClient workshopInfoClient; - - private final RedisTemplate redisTemplate; - - private final BladeLogger logger; - - @Value("${hzims.operation.monitor.realId}") - public String moniter_realId_key; - - @Value("${hzims.equipment.emInfo.emInfoList}") - public String em_info_list_path; - - @Override - public void getStationRealIds(String param) { - // 所有站点 - List stationList = stationService.getAll(); - if(CollectionUtil.isEmpty(stationList)){ - return; - } - // 设备监测点list - Object json = redisTemplate.opsForValue().get(em_info_list_path); - List eminfoAndEmParams = JSONObject.parseObject(json.toString(), new TypeReference>() {}); - // 厂房监测点list - List wsMonitorList = this.getRealIdByWsCodeAndSign(); - // 实时监控监测点list - List timeList = attbtService.list(new LambdaQueryWrapper() {{ - eq(StationAttributeEntity::getIsDeleted, "0"); - isNotNull(StationAttributeEntity::getMonitorId); - orderByAsc(StationAttributeEntity::getSort); - }}); - // 监测点存储list - List list = new ArrayList<>(); - stationList.forEach(station->{ - StationRealVo stationRealVo = new StationRealVo(); - stationRealVo.setStation(station.getCode()); - List realDeviceList = this.getRealDeviceList(station.getRefDept(),eminfoAndEmParams); - // 厂站匹配站点监测点集合 - List realWsList = wsMonitorList.stream().filter( - o -> Func.isNotEmpty(o.getStation()) && o.getStation().equals(station.getCode()) - ).map(AnalyzeCodeBySignagesVO::getRealId).collect(Collectors.toList()); - // 实时监控匹配站点监测点集合 - List realTimeList = timeList.stream().filter(o -> null != o.getStationId() && o.getStationId().equals(station.getCode())).map(StationAttributeEntity::getMonitorId).collect(Collectors.toList()); - if(CollectionUtil.isNotEmpty(realTimeList)){ - realDeviceList.addAll(realTimeList); - } - if(CollectionUtil.isNotEmpty(realWsList)) { - realDeviceList.addAll(realWsList); - } - if(CollectionUtil.isEmpty(realDeviceList)){ - return; - } - List realList = realDeviceList.stream().distinct().collect(Collectors.toList()); - String[] realArr = StringUtil.join(realList,",").split(","); - stationRealVo.setRealId(realArr); - list.add(stationRealVo); - }); - redisTemplate.opsForValue().set(moniter_realId_key,list); - } - - - - private List getRealIdByWsCodeAndSign() { - R> wsInfoListR = workshopInfoClient.getAllWorkshop(); - List wsInfoList = Optional.ofNullable(wsInfoListR).filter(r -> r.isSuccess() && CollectionUtil.isNotEmpty(wsInfoListR.getData())) - .map(R::getData).orElse(null); - if(CollectionUtil.isEmpty(wsInfoList)) { - return Lists.newArrayList(); - } - Function getAnalyzeCodePO = wsCode -> { - MultiAnalyzeCodePO multiAnalyzeCodePO = new MultiAnalyzeCodePO(); - multiAnalyzeCodePO.setDeviceCode(wsCode); - multiAnalyzeCodePO.setSignages(Lists.newArrayList(HomePageConstant.PV_JOINT_RELAY,HomePageConstant.PV_REACTIVE_POWER,HomePageConstant.PV_GENERATION_CAPACITY)); - return multiAnalyzeCodePO; - }; - List analyzeCodePOList = wsInfoList.stream().map(WorkshopInfoEntity::getNumber).map(getAnalyzeCodePO).collect(Collectors.toList()); - R> analyzeCodeBySignages = analyseDataSearchClient.getAnalyzeCodeBySignages(analyzeCodePOList); - return Optional.ofNullable(analyzeCodeBySignages).filter(r -> r.isSuccess()).map(R::getData).orElse(Lists.newArrayList()); - } - - - - /** - * 获取站点realId - * @param refDept - * @param eminfoAndEmParams - * @return - */ - private List getRealDeviceList(Long refDept, List eminfoAndEmParams) { - // 参数检查 - if(CollectionUtil.isEmpty(eminfoAndEmParams) || ObjectUtil.isEmpty(refDept)){ - return new ArrayList<>(); - } - // 有效设备 - List filters = eminfoAndEmParams.stream().filter(o-> o.getCreateDept().equals(refDept)).collect(Collectors.toList()); - if(CollectionUtil.isEmpty(filters)){ - return new ArrayList<>(); - } - // 遍历设备 - List result = new ArrayList<>(); - for(EminfoAndEmParamVo device : filters){ - result.addAll(device.getPoint().values()); - } - return result; - } -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/impl/StationAttributeServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/impl/StationAttributeServiceImpl.java deleted file mode 100644 index ae6cc6c..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/impl/StationAttributeServiceImpl.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.hnac.hzims.scheduled.service.impl; - -import com.hnac.hzims.operational.station.entity.StationAttributeEntity; -import com.hnac.hzims.scheduled.mapper.operation.StationAttributeMapper; -import com.hnac.hzims.scheduled.service.IStationAttributeService; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.mp.base.BaseServiceImpl; -import org.springframework.stereotype.Service; - -/** - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/5/19 11:39 - */ -@Service -@Slf4j -@RequiredArgsConstructor -public class StationAttributeServiceImpl extends BaseServiceImpl implements IStationAttributeService { - -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/impl/StationServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/impl/StationServiceImpl.java deleted file mode 100644 index 7490ba6..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/impl/StationServiceImpl.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.hnac.hzims.scheduled.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.hnac.hzims.operational.station.entity.StationEntity; -import com.hnac.hzims.scheduled.mapper.operation.StationMapper; -import com.hnac.hzims.scheduled.service.IStationService; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.mp.base.BaseServiceImpl; -import org.springblade.core.tool.utils.CollectionUtil; -import org.springblade.core.tool.utils.ObjectUtil; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/5/19 10:36 - */ -@Service -@RequiredArgsConstructor -@Slf4j -public class StationServiceImpl extends BaseServiceImpl implements IStationService { - - @Override - public List getStationByType(Integer stationType, Integer serveType) { - return this.baseMapper.selectStationByType(stationType, serveType); - } - - @Override - public List getAll() { - return this.baseMapper.selectAll(); - } - - - @Override - public List getStationByInCode(List codes) { - return this.baseMapper.selectStationByInCode(codes); - } - - - - @Override - public List getStationType(Integer serveType, List typeList, List departIdList) { - return this.list(new LambdaQueryWrapper() {{ - eq(StationEntity::getIsDeleted, 0); - if (ObjectUtil.isNotEmpty(serveType)) { - eq(StationEntity::getServeType, serveType); - } - if (CollectionUtil.isNotEmpty(typeList)) { - in(StationEntity::getType, typeList); - } - if (CollectionUtil.isNotEmpty(departIdList)) { - in(StationEntity::getRefDept, departIdList); - } - }}); - } -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/impl/WaterServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/impl/WaterServiceImpl.java deleted file mode 100644 index 0218fe0..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/impl/WaterServiceImpl.java +++ /dev/null @@ -1,201 +0,0 @@ -package com.hnac.hzims.scheduled.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.hnac.hzims.EquipmentConstants; -import com.hnac.hzims.operational.main.constant.HomePageConstant; -import com.hnac.hzims.operational.main.vo.WaterLevelVo; -import com.hnac.hzims.operational.station.entity.HzimsAnalyzeModelStationEntity; -import com.hnac.hzims.operational.station.entity.StationEntity; -import com.hnac.hzims.scheduled.service.IHzimsAnalyzeModelStationService; -import com.hnac.hzims.scheduled.service.IStationService; -import com.hnac.hzims.scheduled.service.IWaterService; -import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; -import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData; -import com.hnac.hzinfo.datasearch.analyse.po.AnalyseCodeByAnalyseDataPO; -import com.hnac.hzinfo.datasearch.analyse.po.AnalyzeDataConditionPO; -import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO; -import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeDataConditionVO; -import com.hnac.hzinfo.datasearch.real.po.RealDataSearchPO; -import com.hnac.hzinfo.sdk.analyse.po.MultiAnalyzeCodePO; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.CollectionUtil; -import org.springblade.core.tool.utils.DateUtil; -import org.springblade.core.tool.utils.StringUtil; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.stereotype.Service; - -import java.time.LocalDateTime; -import java.util.*; -import java.util.stream.Collectors; - -/** - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/5/22 11:23 - */ -@Service -@RequiredArgsConstructor -@Slf4j -public class WaterServiceImpl implements IWaterService { - - - private final IStationService stationService; - - - private final IHzimsAnalyzeModelStationService modelStationService; - - - - private final IAnalyseDataSearchClient analyseDataSearchClient; - - - - private final RedisTemplate redisTemplate; - - - - private final static String loadwater_level_key = "hzims:operation:loadwater:level:key"; - /** - * 水利-站点水位数据 - * @param param - */ - @Override - public void loadWaterLevel(String param) { - // 有效站点模型 - List modelList = getModelStationList(); - if(CollectionUtil.isEmpty(modelList)){ - return; - } - List list = new ArrayList<>(); - modelList.forEach(item -> { - List multiAnalyzeCodePOList = new ArrayList<>(); - MultiAnalyzeCodePO multiAnalyzeCodePO = new MultiAnalyzeCodePO(); - multiAnalyzeCodePO.setDeviceCode(item.getInstanceCode()); - multiAnalyzeCodePO.setSignages(Collections.singletonList(HomePageConstant.FRONT_WATER_LEVEL)); - multiAnalyzeCodePOList.add(multiAnalyzeCodePO); - R> result = analyseDataSearchClient.getAnalyzeCodeBySignages(multiAnalyzeCodePOList); - if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ - return; - } - WaterLevelVo waterLevelVo = new WaterLevelVo(); - waterLevelVo.setStationCode(item.getStationId()); - // 前水位 - double frontWaterLevel = this.getWaterLevel(item.getInstanceCode(),HomePageConstant.FRONT_WATER_LEVEL); - waterLevelVo.setFrontWaterLevel(frontWaterLevel); - // 后水位 - double rearWaterLevel = this.getWaterLevel(item.getInstanceCode(),HomePageConstant.REAR_WATER_LEVEL); - waterLevelVo.setRearWaterLevel(rearWaterLevel); - // 前水位当日曲线 - Map frontCurveMap = this.getWaterLevelMap(item.getInstanceCode(),HomePageConstant.FRONT_WATER_LEVEL); - waterLevelVo.setFrontCurveMap(frontCurveMap); - // 后水位当日曲线 - Map rearCurveMap = this.getWaterLevelMap(item.getInstanceCode(),HomePageConstant.REAR_WATER_LEVEL); - waterLevelVo.setRearCurveMap(rearCurveMap); - list.add(waterLevelVo); - }); - redisTemplate.opsForValue().set(loadwater_level_key,list); - } - - - /** - * 获取水位实时数据 - * @param instanceCode - * @param signage - * @return - */ - private double getWaterLevel(String instanceCode, String signage) { - RealDataSearchPO realData = new RealDataSearchPO(); - realData.setAnalyzeCode(instanceCode); - List signages = Collections.singletonList(signage); - realData.setSignages(signages); - // 调用fegin接口查询实时数据 - R> R = analyseDataSearchClient.getRealDataByAnalyzeCode(realData); - if(!R.isSuccess() || CollectionUtil.isEmpty(R.getData())){ - return 0.0; - } - // 时间限制 - String time = R.getData().get(0).getTime(); - if(StringUtil.isEmpty(time) || "-".equals(time)){ - return 0.0; - } - Date date = DateUtil.parse(time, "yyyy-MM-dd HH:mm:ss.sss"); - if(System.currentTimeMillis() - date.getTime() > 30 * 60 * 1000L){ - return 0.0; - } - return Double.parseDouble(R.getData().get(0).getValue()); - } - - - - /** - * 获取水位当年数据 - * @param instanceCode - * @param signage - * @return - */ - private Map getWaterLevelMap(String instanceCode, String signage) { - LocalDateTime beginTime = LocalDateTime.parse(DateUtil.format(new Date(), "yyyy-MM-dd 00:00:00"), DateUtil.DATETIME_FORMATTER); - LocalDateTime endTime = LocalDateTime.now(); - AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO(); - List signboardConditions = new ArrayList<>(); - AnalyzeDataConditionPO analyzeDataConditionPO = new AnalyzeDataConditionPO(); - analyzeDataConditionPO.setFull(1); - analyzeDataConditionPO.setSignages(signage); - // 取数规则: 0=(整点值/最早值)、1=最大值、2=最小值、3=平均值、4=(累计值/和值)、5=(变化值/差值) 6=最新值 - analyzeDataConditionPO.setAccessRules(EquipmentConstants.AccessRulesEnum.FINAL_CYCLE.getType()); - // 周期类型: 0-> s(秒) 1->、m(分)、2->h(小时)3->、d(天)4->、w(周)5->、n(自然月)、6->y(自然年) - analyzeDataConditionPO.setSaveTimeType(2); - // 间隔 - analyzeDataConditionPO.setTimeInterval(1); - analyzeDataConditionPO.setBeginTime(beginTime); - analyzeDataConditionPO.setEndTime(endTime); - signboardConditions.add(analyzeDataConditionPO); - po.setDeviceCode(instanceCode); - po.setSignboardConditions(signboardConditions); - R> R = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(po); - if(!R.isSuccess() || CollectionUtil.isEmpty(R.getData())){ - return null; - } - if(CollectionUtil.isEmpty(R.getData().get(0).getList())){ - return null; - } - return R.getData().get(0).getList().stream().collect(Collectors.toMap(key-> { - Date dateTime = DateUtil.parse(key.getTs(), "yyyy-MM-dd HH:mm:ss.s"); - return dateTime.getHours(); - }, value -> { - if(StringUtil.isBlank(value.getVal())){ - return "0"; - } - return value.getVal(); - })); - } - - /** - * 获取有效站点模型 - * @return - */ - private List getModelStationList() { - // 水利站点(All) - List stationList = stationService.getStationType(HomePageConstant.HYDROPOWER_SERVETYPE, null, null); - if(CollectionUtil.isEmpty(stationList)){ - return null; - } - // 站点code集合 - List codes = stationList.stream().map(StationEntity::getCode).collect(Collectors.toList()); - if(CollectionUtil.isEmpty(codes)){ - return null; - } - // 查询站点模型列表 - List list = modelStationService.list(new LambdaQueryWrapper() {{ - in(HzimsAnalyzeModelStationEntity::getStationId, codes); - }}); - if(CollectionUtil.isEmpty(list)){ - return null; - } - return list; - } -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/TaskService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/TaskService.java new file mode 100644 index 0000000..6d25531 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/TaskService.java @@ -0,0 +1,15 @@ +package com.hnac.hzims.scheduled.service.inspect; + +import com.hnac.hzinfo.inspect.task.entity.TaskEntity; +import com.hnac.hzinfo.inspect.task.vo.DutyInspectTaskVO; +import org.springblade.core.mp.base.BaseService; + +import java.util.List; + +/** + * @author ysj + */ +public interface TaskService extends BaseService { + + DutyInspectTaskVO task(String start, String end, List areas); +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/TaskServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/TaskServiceImpl.java new file mode 100644 index 0000000..6fcc206 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/TaskServiceImpl.java @@ -0,0 +1,64 @@ +package com.hnac.hzims.scheduled.service.inspect.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.hnac.hzims.scheduled.mapper.inspect.TaskMapper; +import com.hnac.hzims.scheduled.service.inspect.TaskService; +import com.hnac.hzinfo.inspect.task.entity.TaskEntity; +import com.hnac.hzinfo.inspect.task.vo.DutyInspectTaskVO; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author ysj + */ +@Service +@Slf4j +@AllArgsConstructor +public class TaskServiceImpl extends BaseServiceImpl implements TaskService { + + /** + * 时间区间机构的巡检任务数据查询 + * @param start + * @param end + * @param areas + * @return + */ + @Override + public DutyInspectTaskVO task(String start, String end, List areas) { + DutyInspectTaskVO task = new DutyInspectTaskVO(); + task.setInspectTaskSum(0); + task.setInspectTaskFinish(0); + task.setNotExecuteTaskCount(0); + // 查询所有巡检任务 + List tasks = this.list(new LambdaQueryWrapper() {{ + ge(TaskEntity::getPlanStartTime, start) + .le(TaskEntity::getPlanStartTime, end) + .in(TaskEntity::getCreateDept, areas); + }}); + if(CollectionUtil.isEmpty(tasks)){ + return task; + } + task.setInspectTaskIds(tasks.stream().map(TaskEntity::getId).map(Object::toString).collect(Collectors.joining(","))); + task.setInspectTaskSum(tasks.size()); + // 所有处理完成巡检任务 + List finshList = tasks.stream().filter(o-> null != o.getStatus() && o.getStatus().equals(3)).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(finshList)){ + return task; + } + task.setInspectTaskFinish(finshList.size()); + // 未执行任务数 + List notExecuteList = tasks.stream().filter(o-> null != o.getStatus() && o.getStatus().equals(0)).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(notExecuteList)){ + return task; + } + task.setNotExecuteTaskCount(notExecuteList.size()); + return task; + } +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/AbnormalAlarmService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/AbnormalAlarmService.java similarity index 56% rename from hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/AbnormalAlarmService.java rename to hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/AbnormalAlarmService.java index 180d275..53997ff 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/AbnormalAlarmService.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/AbnormalAlarmService.java @@ -1,4 +1,4 @@ -package com.hnac.hzims.scheduled.service; +package com.hnac.hzims.scheduled.service.operation; import com.hnac.hzims.operational.alert.entity.AbnormalAlarmEntity; import org.springblade.core.mp.base.BaseService; @@ -7,13 +7,9 @@ import java.util.List; /** * 告警处理接口 - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/5/19 10:20 + * @author ysj */ public interface AbnormalAlarmService extends BaseService { - void alarmDataHandle(String param); - List getAbnormalAlarmList(); + List abnormalAlarms(); } diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/AccessService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/AccessService.java new file mode 100644 index 0000000..9a2d858 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/AccessService.java @@ -0,0 +1,17 @@ +package com.hnac.hzims.scheduled.service.operation; + +import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity; +import com.hnac.hzims.operational.main.vo.OverhaulVo; +import org.springblade.core.mp.base.BaseService; + +import java.util.List; + +/** + * @author ysj + */ +public interface AccessService extends BaseService { + + double accessCount(List areas); + + OverhaulVo overhaul(String start, String end, List areas); +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/AnalyseDataService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/AnalyseDataService.java new file mode 100644 index 0000000..7f2fb5c --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/AnalyseDataService.java @@ -0,0 +1,22 @@ +package com.hnac.hzims.scheduled.service.operation; + +import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO; +import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO; +import com.hnac.hzinfo.sdk.analyse.po.MultiAnalyzeCodePO; + +import java.util.List; +import java.util.function.Function; + + +/** + * @author ysj + */ +public interface AnalyseDataService { + + List getAnalyzeCodeBySignages(Function convert, T resource); + + + List periodTargetData(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, String signages); + + Float periodTargetFloat(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, Integer ride ,String signages); +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/DefectService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/DefectService.java new file mode 100644 index 0000000..929732f --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/DefectService.java @@ -0,0 +1,14 @@ +package com.hnac.hzims.scheduled.service.operation; + +import com.hnac.hzims.operational.defect.entity.OperDefectEntity; +import org.springblade.core.mp.base.BaseService; + +import java.util.List; + +/** + * @author Lch + */ +public interface DefectService extends BaseService { + + Double defectCount(List areas); +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/GenerateService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/GenerateService.java new file mode 100644 index 0000000..8f9e1b1 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/GenerateService.java @@ -0,0 +1,25 @@ +package com.hnac.hzims.scheduled.service.operation; + +import com.hnac.hzims.operational.fill.entity.GenerateEntity; +import com.hnac.hzims.operational.main.vo.GenerationPowerVo; +import com.hnac.hzims.operational.main.vo.PowerMonthVo; +import org.springblade.core.mp.base.BaseService; + +import java.util.List; + +/** + * @author ysj + * @date 2023/04/10 11:16:07 + * @version 4.0.0 + */ +public interface GenerateService extends BaseService { + + // 查询填报用电量 + Float generate(String date,String station); + + // 查询30天填报用电量 + List generate30Day(String day, String station); + + // 获取站点填报发电量 + List generateThreeYear(String start, String end, String station); +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/MaintenanceService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/MaintenanceService.java new file mode 100644 index 0000000..31d2be0 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/MaintenanceService.java @@ -0,0 +1,18 @@ +package com.hnac.hzims.scheduled.service.operation; + +import com.hnac.hzims.operational.main.vo.MaintainVo; +import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity; +import org.springblade.core.mp.base.BaseService; + +import java.util.List; + +/** + * @author ysj + */ +public interface MaintenanceService extends BaseService { + + // 查询当年日常维护数量 + Integer maintenanceCount(List departList); + + MaintainVo maintain(String start, String end, List areas); +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/ModelStationService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/ModelStationService.java new file mode 100644 index 0000000..e8e4560 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/ModelStationService.java @@ -0,0 +1,12 @@ +package com.hnac.hzims.scheduled.service.operation; + + +import com.hnac.hzims.operational.station.entity.HzimsAnalyzeModelStationEntity; +import org.springblade.core.mp.base.BaseService; + +/** + * @author ysj + */ +public interface ModelStationService extends BaseService { + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/MonitorService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/MonitorService.java new file mode 100644 index 0000000..5df3786 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/MonitorService.java @@ -0,0 +1,21 @@ +package com.hnac.hzims.scheduled.service.operation; + +import org.springblade.core.tool.api.R; + +import java.util.Map; + +/** + * WEB水电站首页接口 + * @author ysj + */ +public interface MonitorService { + + // realId刷新 + void loadRealId(String param); + + // 实时数据刷新 + void loadRealData(String param); + + // 集中监控数据处理 + void loadMonitoring(String param); +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/OtherService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/OtherService.java new file mode 100644 index 0000000..50451a4 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/OtherService.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.scheduled.service.operation; + +import com.hnac.hzims.operational.fill.entity.OtherEntity; +import org.springblade.core.mp.base.BaseService; + +/** + * @author ysj + */ +public interface OtherService extends BaseService { + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/OverDetailsService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/OverDetailsService.java new file mode 100644 index 0000000..13e6eab --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/OverDetailsService.java @@ -0,0 +1,12 @@ +package com.hnac.hzims.scheduled.service.operation; + + +import com.hnac.hzims.operational.fill.entity.OverDetailsEntity; +import org.springblade.core.mp.base.BaseService; + +/** + * @author ysj + */ +public interface OverDetailsService extends BaseService { + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/OverService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/OverService.java new file mode 100644 index 0000000..3412374 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/OverService.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.scheduled.service.operation; + +import com.hnac.hzims.operational.fill.entity.OverEntity; +import org.springblade.core.mp.base.BaseService; + +/** + * @author ysj + */ +public interface OverService extends BaseService { + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/PhenomenonService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/PhenomenonService.java new file mode 100644 index 0000000..fe294d8 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/PhenomenonService.java @@ -0,0 +1,15 @@ +package com.hnac.hzims.scheduled.service.operation; + +import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity; +import com.hnac.hzims.operational.report.vo.DutyDefectVO; +import org.springblade.core.mp.base.BaseService; + +import java.util.List; + +/** + * @author ysj + */ +public interface PhenomenonService extends BaseService { + + DutyDefectVO defect(String start, String end, List areas); +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/PowerService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/PowerService.java new file mode 100644 index 0000000..d6d3007 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/PowerService.java @@ -0,0 +1,17 @@ +package com.hnac.hzims.scheduled.service.operation; + +import com.hnac.hzims.operational.fill.entity.PowerEntity; +import com.hnac.hzims.operational.main.vo.PowerMonthVo; +import org.springblade.core.mp.base.BaseService; + +import java.util.List; + +/** + * @author ysj + */ +public interface PowerService extends BaseService { + + Double generate(String date,Long station); + + List generateThreeYear(String start,String end,Long station); +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/RealTargetService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/RealTargetService.java new file mode 100644 index 0000000..43afd9e --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/RealTargetService.java @@ -0,0 +1,34 @@ +package com.hnac.hzims.scheduled.service.operation; + +import java.util.List; + +/** + * WEB水电站首页接口 + * @author ysj + */ +public interface RealTargetService { + + // 水电站实时数据加载 + void loadHydropowerReal(String param); + + // 水电站指标数据加载 + void loadHydropowerTarget(String param); + + // 泵站实时数据加载 + void loadWaterPumpReal(String param); + + // 泵站指标数据加载 + void loadWaterPumpTarget(String param); + + // 站点水位指标数据 + void loadWaterLevel(String param); + + // 光伏站实时数据加载 + void loadPhotovoltaicReal(String param); + + // 光伏站指标数据加载 + void loadPhotovoltaicTarget(String param); + + // 光伏、水电站近3年发电量 + void loadPowerData(String param, List types, Integer serveType, int year); +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/RecordService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/RecordService.java new file mode 100644 index 0000000..00da41d --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/RecordService.java @@ -0,0 +1,13 @@ +package com.hnac.hzims.scheduled.service.operation; + + +import com.hnac.hzims.operational.config.entity.StAlarmRecordEntity; +import org.springblade.core.mp.base.BaseService; + +/** + * @author ysj + */ +public interface RecordService extends BaseService { + + Long insertAlert(String stationId, String monitorId); +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/ReportService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/ReportService.java new file mode 100644 index 0000000..2fe62ac --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/ReportService.java @@ -0,0 +1,9 @@ +package com.hnac.hzims.scheduled.service.operation; + +/** + * @author ysj + */ +public interface ReportService { + + void loadMonthReport(String param, int i); +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/ShowService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/ShowService.java new file mode 100644 index 0000000..a86eed7 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/ShowService.java @@ -0,0 +1,9 @@ +package com.hnac.hzims.scheduled.service.operation; + +/** + * @author ysj + */ +public interface ShowService { + + void loadHomeTarget(String param); +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/SolveService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/SolveService.java new file mode 100644 index 0000000..5888433 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/SolveService.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.scheduled.service.operation; + +import com.hnac.hzims.operational.fill.entity.SolveEntity; +import org.springblade.core.mp.base.BaseService; + +/** + * @author ysj + */ +public interface SolveService extends BaseService { + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/StationAttrConfigService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/StationAttrConfigService.java new file mode 100644 index 0000000..47dce3f --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/StationAttrConfigService.java @@ -0,0 +1,14 @@ +package com.hnac.hzims.scheduled.service.operation; + +import com.hnac.hzims.operational.station.entity.StationAttrConfigEntity; +import org.springblade.core.mp.base.BaseService; + +import java.util.List; + +/** + * @author ysj + */ +public interface StationAttrConfigService extends BaseService { + + List getHideList(); +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/StationAttributeService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/StationAttributeService.java new file mode 100644 index 0000000..53479ba --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/StationAttributeService.java @@ -0,0 +1,14 @@ +package com.hnac.hzims.scheduled.service.operation; + +import com.hnac.hzims.operational.station.entity.StationAttributeEntity; +import org.springblade.core.mp.base.BaseService; + +import java.util.Map; + +/** + * @author hx + */ +public interface StationAttributeService extends BaseService { + + Map PointUnit(); +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/StationService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/StationService.java new file mode 100644 index 0000000..2757282 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/StationService.java @@ -0,0 +1,12 @@ +package com.hnac.hzims.scheduled.service.operation; + +import com.hnac.hzims.operational.station.entity.StationEntity; +import org.springblade.core.mp.base.BaseService; + +/** + * @author ysj + */ +public interface StationService extends BaseService { + + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/UseService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/UseService.java new file mode 100644 index 0000000..72dc927 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/UseService.java @@ -0,0 +1,29 @@ +package com.hnac.hzims.scheduled.service.operation; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.hnac.hzims.operational.fill.entity.UseEntity; +import com.hnac.hzims.operational.fill.vo.QueryVo; +import com.hnac.hzims.operational.fill.vo.UseVo; +import com.hnac.hzims.operational.main.vo.UsrPowerVo; +import org.springblade.core.mp.base.BaseService; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; + +import java.util.List; +import java.util.Map; + +/** + * @author ysj + * @date 2023/04/10 11:16:07 + * @version 4.0.0 + */ +public interface UseService extends BaseService { + + // 查询填报用电量 + Float use(String date,String station); + + // 查询30天填报用电量 + List use30Day(String day, String station); + + Map generateThreeYear(String start, String end, String station); +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/AbnormalAlarmServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/AbnormalAlarmServiceImpl.java new file mode 100644 index 0000000..fa8ef8a --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/AbnormalAlarmServiceImpl.java @@ -0,0 +1,33 @@ +package com.hnac.hzims.scheduled.service.operation.impl; + +import com.hnac.hzims.operational.alert.entity.AbnormalAlarmEntity; +import com.hnac.hzims.scheduled.mapper.operation.AbnormalAlarmMapper; +import com.hnac.hzims.scheduled.service.operation.AbnormalAlarmService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +/** + * 告警实现类 + * @author ysj + */ +@Slf4j +@Service +@RequiredArgsConstructor +public class AbnormalAlarmServiceImpl extends BaseServiceImpl implements AbnormalAlarmService { + + + @Override + public List abnormalAlarms() { + List alarmList = this.baseMapper.abnormalAlarms(); + if(CollectionUtil.isEmpty(alarmList)){ + return new ArrayList<>(); + } + return alarmList; + } +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/AccessServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/AccessServiceImpl.java new file mode 100644 index 0000000..da01d8e --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/AccessServiceImpl.java @@ -0,0 +1,86 @@ +package com.hnac.hzims.scheduled.service.operation.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.hnac.hzims.operational.access.constants.AccessConstants; +import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity; +import com.hnac.hzims.operational.main.vo.OverhaulVo; +import com.hnac.hzims.scheduled.mapper.operation.AccessMapper; +import com.hnac.hzims.scheduled.service.operation.AccessService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.Func; +import org.springframework.stereotype.Service; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author ysj + */ +@Service +@Slf4j +@AllArgsConstructor +public class AccessServiceImpl extends BaseServiceImpl implements AccessService { + + /** + * 查询当年检修任务数量 + * @param areas + * @return + */ + @Override + public double accessCount(List areas) { + if(CollectionUtil.isEmpty(areas)) { + return 0; + } + LocalDate firstDay = LocalDate.now().withDayOfYear(1); + LocalDateTime firstDateTime = LocalDateTime.of(firstDay, LocalTime.MIN); + LocalDateTime now = LocalDateTime.now(); + //日常维护 + List accesss = this.list(new LambdaQueryWrapper(){{ + ge(OperAccessTaskEntity::getPlanStartTime,firstDateTime); + le(OperAccessTaskEntity::getPlanStartTime,now); + in(OperAccessTaskEntity::getCreateDept,areas); + }}); + if(CollectionUtil.isEmpty(accesss)){ + return 0; + } + return accesss.size(); + } + + /** + * 时间区间机构的巡检数据查询 + * @param start + * @param end + * @param areas + * @return + */ + @Override + public OverhaulVo overhaul(String start, String end, List areas) { + OverhaulVo overhaulVo = new OverhaulVo(); + // 检修总数 + List overhaulList = this.list(new LambdaQueryWrapper(){{ + ge(OperAccessTaskEntity::getPlanStartTime,start); + le(OperAccessTaskEntity::getPlanStartTime,end); + in(OperAccessTaskEntity::getCreateDept,areas); + }}); + if(CollectionUtil.isEmpty(overhaulList)){ + overhaulVo.setOverhaul(0); + overhaulVo.setOverhaulFinish(0); + return overhaulVo; + } + overhaulVo.setOverhaul(overhaulList.size()); + // 检修完成数量 + List overhaulFinishTask = overhaulList.stream().filter(task-> Func.isNotEmpty(task.getStatus()) && AccessConstants.ACCESS_TASK_STATUS_4 == task.getStatus()) + .map(OperAccessTaskEntity::getId).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(overhaulFinishTask)){ + overhaulVo.setOverhaulFinish(0); + } + overhaulVo.setOverhaulFinish(overhaulFinishTask.size()); + return overhaulVo; + } +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/AnalyseDataServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/AnalyseDataServiceImpl.java new file mode 100644 index 0000000..b469c8a --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/AnalyseDataServiceImpl.java @@ -0,0 +1,139 @@ +package com.hnac.hzims.scheduled.service.operation.impl; + +import com.google.common.collect.Lists; +import com.hnac.hzims.scheduled.service.operation.AnalyseDataService; +import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; +import com.hnac.hzinfo.datasearch.analyse.po.AnalyseCodeByAnalyseDataPO; +import com.hnac.hzinfo.datasearch.analyse.po.AnalyzeDataConditionPO; +import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO; +import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO; +import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeDataConditionVO; +import com.hnac.hzinfo.sdk.analyse.po.MultiAnalyzeCodePO; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.DateUtil; +import org.springblade.core.tool.utils.ObjectUtil; +import org.springblade.core.tool.utils.StringUtil; +import org.springframework.stereotype.Service; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Optional; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * @author hx + */ +@Service +@AllArgsConstructor +@Slf4j +public class AnalyseDataServiceImpl implements AnalyseDataService { + + private final IAnalyseDataSearchClient analyseDataSearchClient; + + @Override + public List getAnalyzeCodeBySignages(Function convert, T resource) { + List result = Lists.newArrayList(); + List multiAnalyzeCodePOList = Lists.newArrayList(resource).stream().map(convert).collect(Collectors.toList()); + R> analyzeCodeBySignResult = analyseDataSearchClient.getAnalyzeCodeBySignages(multiAnalyzeCodePOList); + if(analyzeCodeBySignResult.isSuccess() && CollectionUtil.isNotEmpty(analyzeCodeBySignResult.getData())) { + result = analyzeCodeBySignResult.getData(); + } + return result; + } + + /*** + * 指标数据列表查询 + * @param startTime 开始时间 + * @param endTime 结束时间 + * @param accessRules 取数规则 : 0=最早值 1=最大值 2=最小值 3=平均值 4=和值 5=差值 6=最新值 + * @param cycleType 间隔周期 : 0-> 秒 1-> 分 2-> 小时 3->天 4-> 周 5-> 月 6-> 年 + * @param deviceCode 设备编号 + * @param signages 指标 + * @return + */ + @Override + public List periodTargetData(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, String signages) { + AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO(); + List signboardConditions = new ArrayList<>(); + AnalyzeDataConditionPO analyzeDataConditionPO = new AnalyzeDataConditionPO(); + analyzeDataConditionPO.setFull(1); + po.setDeviceCode(deviceCode); + analyzeDataConditionPO.setSignages(signages); + analyzeDataConditionPO.setKeepFigures(2); + analyzeDataConditionPO.setAccessRules(accessRules); + analyzeDataConditionPO.setSaveTimeType(cycleType); + // 间隔 + analyzeDataConditionPO.setTimeInterval(1); + analyzeDataConditionPO.setBeginTime(LocalDateTime.parse(DateUtil.format(new Date(), startTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME))); + analyzeDataConditionPO.setEndTime(LocalDateTime.parse(DateUtil.format(new Date(), endTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME))); + signboardConditions.add(analyzeDataConditionPO); + po.setSignboardConditions(signboardConditions); + log.error("period_target_data_request {}",po); + R> result = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(po); + if (!result.isSuccess() || CollectionUtil.isEmpty(result.getData())) { + return new ArrayList<>(); + } + log.error("period_target_data_resp {}",result); + return result.getData().get(0).getList(); + } + + /*** + * 指标数据列表查询 + * @param startTime 开始时间 + * @param endTime 结束时间 + * @param accessRules 取数规则 : 0=最早值 1=最大值 2=最小值 3=平均值 4=和值 5=差值 6=最新值 + * @param cycleType 间隔周期 : 0-> 秒 1-> 分 2-> 小时 3->天 4-> 周 5-> 月 6-> 年 + * @param deviceCode 设备编号 + * @param ride 配电比 + * @param signages 指标 + * @return + */ + @Override + public Float periodTargetFloat(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode,Integer ride,String signages) { + AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO(); + List signboardConditions = new ArrayList<>(); + AnalyzeDataConditionPO analyzeDataConditionPO = new AnalyzeDataConditionPO(); + analyzeDataConditionPO.setFull(1); + po.setDeviceCode(deviceCode); + analyzeDataConditionPO.setSignages(signages); + analyzeDataConditionPO.setKeepFigures(2); + analyzeDataConditionPO.setAccessRules(accessRules); + analyzeDataConditionPO.setSaveTimeType(cycleType); + // 间隔 + analyzeDataConditionPO.setTimeInterval(1); + analyzeDataConditionPO.setBeginTime(LocalDateTime.parse(DateUtil.format(new Date(), startTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME))); + analyzeDataConditionPO.setEndTime(LocalDateTime.parse(DateUtil.format(new Date(), endTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME))); + signboardConditions.add(analyzeDataConditionPO); + po.setSignboardConditions(signboardConditions); + R> result = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(po); + if (!result.isSuccess() || CollectionUtil.isEmpty(result.getData())) { + return 0f; + } + List records = result.getData(); + if(CollectionUtil.isEmpty(records)){ + return 0f; + } + AnalyzeDataConditionVO analyzeDataConditionVO = records.get(0); + if (ObjectUtil.isEmpty(analyzeDataConditionVO)) { + return 0f; + } + List analyseDataTaosVOList = analyzeDataConditionVO.getList(); + if (CollectionUtil.isEmpty(analyseDataTaosVOList)) { + return 0f; + } + AnalyseDataTaosVO analyseDataTaosVO = analyzeDataConditionVO.getList().get(0); + if (ObjectUtil.isEmpty(analyseDataTaosVO) || StringUtil.isBlank(analyseDataTaosVO.getVal())) { + return 0f; + } + return Float.parseFloat(Optional.ofNullable(analyseDataTaosVO.getVal()).orElse("0")) * ride; + } + + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/DefectServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/DefectServiceImpl.java new file mode 100644 index 0000000..84af907 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/DefectServiceImpl.java @@ -0,0 +1,55 @@ +package com.hnac.hzims.scheduled.service.operation.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.hnac.hzims.operational.defect.entity.OperDefectEntity; +import com.hnac.hzims.scheduled.mapper.operation.DefectMapper; +import com.hnac.hzims.scheduled.service.operation.DefectService; +import lombok.AllArgsConstructor; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author ysj + */ +@Service +@AllArgsConstructor +public class DefectServiceImpl extends BaseServiceImpl implements DefectService { + + /** + * 获取消缺率 + * @param areas + * @return + */ + @Override + public Double defectCount(List areas) { + if(CollectionUtil.isEmpty(areas)) { + return 100.00; + } + LocalDate firstDay = LocalDate.now().withDayOfYear(1); + LocalDateTime firstDateTime = LocalDateTime.of(firstDay, LocalTime.MIN); + LocalDateTime now = LocalDateTime.now(); + List pTaskList = this.list(new LambdaQueryWrapper(){{ + ge(OperDefectEntity::getCreateTime,firstDateTime); + le(OperDefectEntity::getCreateTime,now); + in(OperDefectEntity::getCreateDept,areas); + }}); + if(CollectionUtil.isEmpty(pTaskList)){ + return 0.0; + } + // 缺陷处理完成数 + List finishTask = pTaskList.stream().filter(defect -> "1".equals(defect.getHandleStatus())).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(finishTask)){ + return 0.0; + } + // 消缺率 = (缺陷数 / 总数) * 100 + return BigDecimal.valueOf(finishTask.size() / (double) pTaskList.size() * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + } +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/GenerateServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/GenerateServiceImpl.java new file mode 100644 index 0000000..470f95e --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/GenerateServiceImpl.java @@ -0,0 +1,112 @@ +package com.hnac.hzims.scheduled.service.operation.impl; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hnac.hzims.operational.fill.entity.GenerateEntity; +import com.hnac.hzims.operational.main.vo.GenerationPowerVo; +import com.hnac.hzims.operational.main.vo.PowerMonthVo; +import com.hnac.hzims.scheduled.mapper.operation.GenerateMapper; +import com.hnac.hzims.scheduled.service.operation.GenerateService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.DateUtil; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author ysj + * @date 2023/04/10 11:16:07 + * @version 4.0.0 + */ +@Slf4j +@Service +@AllArgsConstructor +public class GenerateServiceImpl extends BaseServiceImpl implements GenerateService { + + /** + * 根据时间、机构查询用电量 + * @param date 时间: 年 - yyyy/月 yyyy-mm/日 yyyy-mm-dd + * @param station 所属机构 + * @return + */ + @Override + public Float generate(String date, String station) { + List powers = this.list(Wrappers.lambdaQuery() + .likeRight(GenerateEntity::getFillDate,date) + .eq(GenerateEntity::getStationCode,station) + ); + if(CollectionUtil.isEmpty(powers)){ + return 0f; + } + return (float) powers.stream().mapToDouble(GenerateEntity::getGenerate).sum(); + } + + /** + * 查询30天填报用电量 + * @param day : 结束日期 yyyy-MM-dd + * @param station 站点编码 + * @return + */ + @Override + public List generate30Day(String day, String station) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(DateUtil.parse(day,DateUtil.PATTERN_DATE)); + String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE); + calendar.add(Calendar.DAY_OF_MONTH,-29); + String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE); + List records = this.list(Wrappers.lambdaQuery() + .between(GenerateEntity::getFillDate,start,end) + .eq(GenerateEntity::getStationCode,station) + ); + if(CollectionUtil.isEmpty(records)){ + return new ArrayList<>(); + } + return records.stream().map(record->{ + GenerationPowerVo generate = new GenerationPowerVo(); + generate.setDate(record.getFillDate()); + if(Math.abs(record.getGenerate()) <= 0){ + generate.setGenerate(0f); + }else{ + generate.setGenerate(Float.parseFloat(record.getGenerate().toString())); + } + return generate; + }).collect(Collectors.toList()); + } + + /** + * + * @param start 时间: 年 - yyyy/月 yyyy-mm/日 yyyy-mm-dd + * @param end 时间: 年 - yyyy/月 yyyy-mm/日 yyyy-mm-dd + * @param station 站点编码 + * @return + */ + @Override + public List generateThreeYear(String start, String end, String station) { + List records = this.list(Wrappers.lambdaQuery() + .eq(GenerateEntity::getStationCode,station) + .between(GenerateEntity::getFillDate,start,end) + ); + if(CollectionUtil.isEmpty(records)){ + return new ArrayList<>(); + } + // 返回结果 + return records.stream().peek( + record-> record.setFillDate(DateUtil.format(DateUtil.parse(record.getFillDate(),"yyyy-MM"),"yyyy-MM") + "-01") + ).collect(Collectors.toMap(GenerateEntity::getFillDate,GenerateEntity::getGenerate,Double::sum)). + entrySet().stream().map(entry->{ + PowerMonthVo mon = new PowerMonthVo(); + mon.setStrMonth(entry.getKey()); + if(Math.abs(entry.getValue()) <= 0){ + mon.setPower(0f); + }else{ + mon.setPower(Float.parseFloat(entry.getValue().toString())); + } + return mon; + }).collect(Collectors.toList()); + } +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/MaintenanceServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/MaintenanceServiceImpl.java new file mode 100644 index 0000000..7152ace --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/MaintenanceServiceImpl.java @@ -0,0 +1,88 @@ +package com.hnac.hzims.scheduled.service.operation.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.hnac.hzims.operational.main.vo.MaintainVo; +import com.hnac.hzims.operational.maintenance.constants.MaintenanceConstant; +import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity; +import com.hnac.hzims.scheduled.mapper.operation.MaintenanceMapper; +import com.hnac.hzims.scheduled.service.operation.MaintenanceService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.Func; +import org.springframework.stereotype.Service; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author ysj + */ +@Service +@RequiredArgsConstructor +@Slf4j +public class MaintenanceServiceImpl extends BaseServiceImpl implements MaintenanceService { + + /** + * 获取日常维护数量 + * @param departList + * @return + */ + @Override + public Integer maintenanceCount(List departList) { + if(CollectionUtil.isEmpty(departList)){ + return 0; + } + LocalDate firstDay = LocalDate.now().withDayOfYear(1); + LocalDateTime firstDateTime = LocalDateTime.of(firstDay, LocalTime.MIN); + LocalDateTime now = LocalDateTime.now(); + //日常维护 + List mTaskList = this.list(new LambdaQueryWrapper(){{ + ge(OperMaintenanceTaskEntity::getDisposeTime,firstDateTime); + le(OperMaintenanceTaskEntity::getDisposeTime,now); + in(OperMaintenanceTaskEntity::getCreateDept,departList); + }}); + if(CollectionUtil.isEmpty(mTaskList)){ + return 0; + } + return mTaskList.size(); + } + + /** + * 时间区间机构的日常维护数据查询 + * @param start + * @param end + * @param areas + * @return + */ + @Override + public MaintainVo maintain(String start, String end, List areas) { + MaintainVo maintainVo = new MaintainVo(); + //日常维护 + List maintainList = this.list(new LambdaQueryWrapper(){{ + ge(OperMaintenanceTaskEntity::getDisposeTime,start); + le(OperMaintenanceTaskEntity::getDisposeTime,end); + in(OperMaintenanceTaskEntity::getCreateDept,areas); + }}); + if(CollectionUtil.isEmpty(maintainList)){ + maintainVo.setMaintain(0); + maintainVo.setMaintainFinish(0); + return maintainVo; + } + // 日常维护完成数 + maintainVo.setMaintain(maintainList.size()); + List maintainFinish = maintainList.stream().filter(o-> Func.isNotEmpty(o.getStatus()) && MaintenanceConstant.TASK_STATUS_5 == o.getStatus()) + .map(OperMaintenanceTaskEntity::getId).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(maintainFinish)){ + maintainVo.setMaintainFinish(0); + } + maintainVo.setMaintainFinish(maintainFinish.size()); + return maintainVo; + } + + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/ModelStationServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/ModelStationServiceImpl.java new file mode 100644 index 0000000..946fdab --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/ModelStationServiceImpl.java @@ -0,0 +1,16 @@ +package com.hnac.hzims.scheduled.service.operation.impl; + + +import com.hnac.hzims.operational.station.entity.HzimsAnalyzeModelStationEntity; +import com.hnac.hzims.scheduled.mapper.operation.ModelStationMapper; +import com.hnac.hzims.scheduled.service.operation.ModelStationService; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +/** + * @author ysj + */ +@Service +public class ModelStationServiceImpl extends BaseServiceImpl implements ModelStationService { + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/impl/RealMonitorServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/MonitorServiceImpl.java similarity index 72% rename from hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/impl/RealMonitorServiceImpl.java rename to hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/MonitorServiceImpl.java index 4a595ad..06145f6 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/impl/RealMonitorServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/MonitorServiceImpl.java @@ -1,125 +1,150 @@ -package com.hnac.hzims.scheduled.service.impl; +package com.hnac.hzims.scheduled.service.operation.impl; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.google.common.collect.Lists; +import com.google.common.util.concurrent.ThreadFactoryBuilder; +import com.hnac.hzims.equipment.entity.WorkshopInfoEntity; import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; import com.hnac.hzims.fdp.vo.FdpFaultStatusVo; import com.hnac.hzims.operational.config.entity.StAlarmRecordEntity; import com.hnac.hzims.operational.config.enume.ConfigStatus; +import com.hnac.hzims.operational.config.vo.StationRealVo; import com.hnac.hzims.operational.main.constant.HomePageConstant; +import com.hnac.hzims.operational.main.vo.RealAttributeVo; +import com.hnac.hzims.operational.main.vo.RealDeviceVo; +import com.hnac.hzims.operational.main.vo.RealStationVo; import com.hnac.hzims.operational.station.entity.StationAttributeEntity; import com.hnac.hzims.operational.station.entity.StationEntity; -import com.hnac.hzims.scheduled.service.*; -import com.hnac.hzims.scheduled.vo.RealAttributeVo; -import com.hnac.hzims.scheduled.vo.RealDeviceVo; -import com.hnac.hzims.scheduled.vo.RealStationVo; -import com.hnac.hzims.scheduled.vo.StationRealVo; +import com.hnac.hzims.scheduled.service.equipment.WorkshopInfoService; +import com.hnac.hzims.scheduled.service.operation.*; +import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; +import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO; +import com.hnac.hzinfo.sdk.analyse.po.MultiAnalyzeCodePO; import com.hnac.hzinfo.sdk.v5.redis.RedisClient; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.MapUtils; import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.CollectionUtil; -import org.springblade.core.tool.utils.DateUtil; -import org.springblade.core.tool.utils.ObjectUtil; -import org.springblade.core.tool.utils.StringUtil; +import org.springblade.core.tool.utils.*; import org.springblade.system.entity.Dept; import org.springblade.system.feign.ISysClient; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; -import javax.validation.constraints.NotNull; import java.util.*; import java.util.concurrent.*; +import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; /** - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/5/19 13:54 + * 集中监控数据获取实现类 + * @author ysj */ @Service @RequiredArgsConstructor @Slf4j -public class RealMonitorServiceImpl implements IRealMonitorService { - - @NotNull - private final IStationAttributeService attbtService; - +public class MonitorServiceImpl implements MonitorService { + private final RecordService alertService; + private final StationService stationService; + private final StationAttributeService attbtService; + private final WorkshopInfoService workshopInfoService; private final AbnormalAlarmService abnormalAlarmService; - - private final StAlamRecordService alertService; - - @NotNull - private final IStationService stationService; - @NotNull - private final IMainSystemMonitoringService maintenanceTaskService; - @NotNull + private final StationAttrConfigService attrConfigService; private final RedisTemplate redisTemplate; - - - private final IMainSystemMonitoringService systemMonitoringService; - - - private final RedisClient redisClient; - - @NotNull private final ISysClient sysClient; + private final RedisClient redisClient; + private final IAnalyseDataSearchClient analyseDataSearchClient; + @Value("${hzims.equipment.emInfo.emInfoList}") + public String device_cache_final; - private final IStationAttrConfigService stationAttrConfigService; + @Value("${hzims.operation.realIdKey}") + public String real_cache_final; - @Value("${hzims.operation.monitor.realId}") - public String moniter_realId_key; + @Value("${hzims.operation.realIdKeyGather}") + public String real_gather_cache_final; - @Value("${hzims.operation.monitor.station}") - public String moniter_station_key; + @Value("${hzims.operation.realIdKeyGather}") + public String real_data_cache_final; @Value("${hzims.equipment.fdp.redisData}") - public String fdp_fault_data_key; + public String fdp_fault_cache_final; - @Value("${hzims.operation.homePage.activePowerKey}") - public String active_power_key; + @Value("${hzims.equipment.fdp.lessThan}") + public Double less_than_cache_final; @Value("${hzims.equipment.fdp.greaterThan}") - public Double greater_than; + public Double greater_than_cache_final; - @Value("${hzims.equipment.fdp.lessThan}") - public Double less_than; + @Value("${hzims.operation.monitor.realId}") + public String moniter_realId_cache_final; + + @Value("${hzims.operation.monitor.station}") + public String moniter_station_cache_final; @Value("${hzims.equipment.fdp.beEqualOrGreaterThan}") - public Double be_equal_or_greater_than; + public Double be_equa_cache_final; @Value("${hzims.operation.region.deviceClassifyKey}") - private String device_classify_key; - - @Value("${hzims.operation.realIdKeyGather}") - public String real_id_key_gather_path; - - @Value("${hzims.operation.realIdKey}") - public String real_id_key_path; - - @Value("${hzims.operation.homePage.jointRelayKey}") - public String joint_relay_key; - - /** - * 10站点为一组数据 - */ - private static final Integer MAX_SEND = 5; - - private final static String loadwater_level_key = "hzims:operation:loadwater:level:key"; + private String device_classify_cache_final; + @Override + public void loadRealId(String param) { + // 所有站点 + List stationList = stationService.list(); + if(CollectionUtil.isEmpty(stationList)){ + return; + } + // 设备监测点list + Object json = redisTemplate.opsForValue().get(device_cache_final); + List eminfoAndEmParams = JSONObject.parseObject(json.toString(), new TypeReference>() {}); + // 厂房监测点list + List wsMonitorList = this.getRealIdByWsCodeAndSign(); + // 实时监控监测点list + List timeList = attbtService.list(new LambdaQueryWrapper() {{ + eq(StationAttributeEntity::getIsDeleted, "0"); + isNotNull(StationAttributeEntity::getMonitorId); + orderByAsc(StationAttributeEntity::getSort); + }}); + // 监测点存储list + List list = new ArrayList<>(); + stationList.forEach(station->{ + StationRealVo stationRealVo = new StationRealVo(); + stationRealVo.setStation(station.getCode()); + List realDeviceList = this.getRealDeviceList(station.getRefDept(),eminfoAndEmParams); + // 厂站匹配站点监测点集合 + List realWsList = wsMonitorList.stream().filter( + o -> Func.isNotEmpty(o.getStation()) && o.getStation().equals(station.getCode()) + ).map(AnalyzeCodeBySignagesVO::getRealId).collect(Collectors.toList()); + // 实时监控匹配站点监测点集合 + List realTimeList = timeList.stream().filter(o -> null != o.getStationId() && o.getStationId().equals(station.getCode())).map(StationAttributeEntity::getMonitorId).collect(Collectors.toList()); + if(CollectionUtil.isNotEmpty(realTimeList)){ + realDeviceList.addAll(realTimeList); + } + if(CollectionUtil.isNotEmpty(realWsList)) { + realDeviceList.addAll(realWsList); + } + if(CollectionUtil.isEmpty(realDeviceList)){ + return; + } + List realList = realDeviceList.stream().distinct().collect(Collectors.toList()); + String[] realArr = StringUtil.join(realList,",").split(","); + stationRealVo.setRealId(realArr); + list.add(stationRealVo); + }); + redisTemplate.opsForValue().set(moniter_realId_cache_final,list); + } @Override - public void realTimeData(String param) { - Long beginTime = System.currentTimeMillis(); + public void loadRealData(String param) { // 获取设备 - List devices = systemMonitoringService.getEmInfoList(); + List devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_final).toString(),new TypeReference>() {});; // 设备开关机集合监测点 List switchOnOff = devices.stream().map(o->{ Map points = o.getPoint(); @@ -137,13 +162,13 @@ public class RealMonitorServiceImpl implements IRealMonitorService { return ""; }).collect(Collectors.toList()); // 获取站点缓存数据 - List stationRealVos = (List) redisTemplate.opsForValue().get(moniter_realId_key); + List stationRealVos = (List) redisTemplate.opsForValue().get(moniter_realId_cache_final); if(CollectionUtil.isEmpty(stationRealVos)){ return; } // 数据切割 int limit = countStep(stationRealVos.size()); - List> list = Stream.iterate(0, n -> n + 1).limit(limit).parallel().map(a -> stationRealVos.stream().skip((long) a * MAX_SEND).limit(MAX_SEND).parallel().collect(Collectors.toList())).collect(Collectors.toList()); + List> list = Stream.iterate(0, n -> n + 1).limit(limit).parallel().map(a -> stationRealVos.stream().skip((long) a * 5).limit(5).parallel().collect(Collectors.toList())).collect(Collectors.toList()); ExecutorService pool = Executors.newFixedThreadPool(limit); // Map valueMap = new ConcurrentHashMap<>(); @@ -187,23 +212,17 @@ public class RealMonitorServiceImpl implements IRealMonitorService { } pool.shutdown(); // redis 存储 - redisTemplate.opsForValue().set(real_id_key_path,JSONObject.toJSONString(valueMap)); - redisTemplate.opsForValue().set(real_id_key_gather_path,JSONObject.toJSONString(keyMap)); - Long endTime = System.currentTimeMillis(); - Long time = endTime - beginTime; - log.error("处理redis实时数据 耗时 : {}",time); + redisTemplate.opsForValue().set(real_cache_final,JSONObject.toJSONString(valueMap)); + redisTemplate.opsForValue().set(real_gather_cache_final,JSONObject.toJSONString(keyMap)); } - - /** * 计算切分次数 */ private static Integer countStep(Integer size) { - return (size + MAX_SEND - 1) / MAX_SEND; + return (size + 5 - 1) / 5; } - /** * 监测点过期数据检查 * @param value @@ -225,18 +244,14 @@ public class RealMonitorServiceImpl implements IRealMonitorService { } } - - - /** * 集中监控数据处理 * @param param */ @Override - public void centralizedMonitoring(String param) { - long beginTime = System.currentTimeMillis(); + public void loadMonitoring(String param) { Thread thread = Thread.currentThread(); - Object json = redisTemplate.opsForValue().get(real_id_key_gather_path); + Object json = redisTemplate.opsForValue().get(real_data_cache_final); if (ObjectUtil.isEmpty(json)) { return; } @@ -245,8 +260,6 @@ public class RealMonitorServiceImpl implements IRealMonitorService { if (MapUtils.isEmpty(map)) { return; } - log.info(thread.getName() + "步骤1获取检测点数据耗时 : {}",System.currentTimeMillis() - beginTime); - beginTime = System.currentTimeMillis(); // 获取所有设备重点属性 List list = attbtService.list(new LambdaQueryWrapper() {{ isNotNull(StationAttributeEntity::getStationId); @@ -256,48 +269,32 @@ public class RealMonitorServiceImpl implements IRealMonitorService { if (CollectionUtil.isEmpty(list)) { return; } - log.info(thread.getName() + "步骤2获取监控配置监测点 耗时 : {}",System.currentTimeMillis() - beginTime); - beginTime = System.currentTimeMillis(); // 获取所有告警记录 List alertList = alertService.list(new LambdaQueryWrapper() {{ orderByDesc(StAlarmRecordEntity::getCreateTime); }}); - log.info(thread.getName() + "步骤3获取告警记录 耗时 : {}",System.currentTimeMillis() - beginTime); - beginTime = System.currentTimeMillis(); - List alarmList = abnormalAlarmService.getAbnormalAlarmList(); - log.info(thread.getName() + "步骤4获取数据中断告警记录 耗时 : {}",System.currentTimeMillis() - beginTime); - beginTime = System.currentTimeMillis(); + List alarmList = abnormalAlarmService.abnormalAlarms(); // 获取所有故障记录 List faultList = this.getFdpFaultAll(); - log.info(thread.getName() + "步骤5获取故障记录 耗时 : {}",System.currentTimeMillis() - beginTime); - beginTime = System.currentTimeMillis(); // 所有设备分类 - Map> deviceClassifyMap = (Map>) redisTemplate.opsForValue().get(device_classify_key); - log.info(thread.getName() + "步骤6获取设备分类 耗时 : {}",System.currentTimeMillis() - beginTime); - beginTime = System.currentTimeMillis(); + Map> deviceClassifyMap = (Map>) redisTemplate.opsForValue().get(device_classify_cache_final); // 所有设备 - List emList = maintenanceTaskService.getEmInfoList(); - log.info(thread.getName() + "步骤7获取设备信息 耗时 : {}",System.currentTimeMillis() - beginTime); - beginTime = System.currentTimeMillis(); + List devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_final).toString(),new TypeReference>() {}); // 根据站点分组 Map> stationAttbtMap = list.stream().collect(Collectors.groupingBy(StationAttributeEntity::getStationId)); // 获取站点列表 - List stationEntityList = stationService.getStationByInCode(new ArrayList<>(stationAttbtMap.keySet())); - log.info(thread.getName() + "步骤8站点列表 耗时 : {}",System.currentTimeMillis() - beginTime); - beginTime = System.currentTimeMillis(); + List stationEntityList = stationService.list(Wrappers.lambdaQuery() + .in(StationEntity::getCode,new ArrayList<>(stationAttbtMap.keySet()))); // 隐藏设备列表 - List hideList = stationAttrConfigService.getHideList(); + List hideList = attrConfigService.getHideList(); // 分割,每个map限制10个长度 List>> handleList = this.mapChunk(stationAttbtMap); - log.info(thread.getName() + "步骤9监测点数据切割 耗时 : {}",System.currentTimeMillis() - beginTime); - beginTime = System.currentTimeMillis(); // 创建线程池 - ExecutorService pool = Executors.newFixedThreadPool(handleList.size()); + ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("load-monitoring-pool-%d").build(); + ExecutorService pool = new ThreadPoolExecutor(5, 5, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy()); CountDownLatch countDownLatch = new CountDownLatch(handleList.size()); - log.info(thread.getName() +"步骤10创建线程 耗时 : {}",System.currentTimeMillis() - beginTime); - beginTime = System.currentTimeMillis(); // 所有机构 - R> deptAll = sysClient. getDeptList(); + R> deptAll = sysClient.getDeptList(); // 存储数据节点 List stationList = new CopyOnWriteArrayList<>(); pool.execute(()->{ @@ -325,15 +322,13 @@ public class RealMonitorServiceImpl implements IRealMonitorService { deviceList.add(deviceVo); }); // 设备状态 - this.getDeviceParam(emList, deviceClassifyMap, deviceList); + this.getDeviceParam(devices, deviceClassifyMap, deviceList); station.setDeviceList(deviceList.stream().sorted(Comparator.comparing((RealDeviceVo::getDeviceName))).collect(Collectors.toList())); stationList.add(station); }); countDownLatch.countDown(); } }); - log.info(thread.getName() + "步骤11线程数据处理 耗时 : {}",System.currentTimeMillis() - beginTime); - beginTime = System.currentTimeMillis(); // 等待所有线程执行完成 try { countDownLatch.await(); @@ -342,57 +337,85 @@ public class RealMonitorServiceImpl implements IRealMonitorService { Thread.currentThread().interrupt(); } pool.shutdown(); - log.info(thread.getName() + "步骤12所有线程完成 耗时 : {}",System.currentTimeMillis() - beginTime); - redisTemplate.opsForValue().set(moniter_station_key, stationList); + redisTemplate.opsForValue().set(moniter_station_cache_final, stationList); } - /** - * map分割 + * 设备处理 * - * @param - * @param - * @param chunkMap - * @return + * @param list + * @param map + * @param device */ - private List> mapChunk(Map chunkMap) { - if (chunkMap == null || RealMonitorServiceImpl.MAX_SEND <= 0) { - List> list = new ArrayList<>(); - list.add(chunkMap); - return list; + private void handleDevice(List list, Map> map, + RealDeviceVo device, List alertList, + List faultList) { + if (CollectionUtil.isEmpty(list) || MapUtils.isEmpty(map)) { + return; } - Set keySet = chunkMap.keySet(); - Iterator iterator = keySet.iterator(); - int i = 1; - List> total = new ArrayList<>(); - Map tem = new HashMap<>(); - while (iterator.hasNext()) { - k next = iterator.next(); - tem.put(next, chunkMap.get(next)); - if (i == RealMonitorServiceImpl.MAX_SEND) { - total.add(tem); - tem = new HashMap<>(); - i = 0; + List attbtList = new ArrayList<>(); + list.forEach(item -> { + RealAttributeVo realAttributeVo = new RealAttributeVo(); + // 设备重点属性处理 : 单条-item + Map real = map.get(item.getMonitorId()); + if(MapUtils.isEmpty(real)){ + realAttributeVo.setName(item.getAttributes()); + realAttributeVo.setType(item.getAttributeType()); + realAttributeVo.setRealId(item.getMonitorId()); + realAttributeVo.setQuality(-1); + realAttributeVo.setStatus(0); + realAttributeVo.setValue("0"); + realAttributeVo.setUnit(item.getUnit()); + attbtList.add(realAttributeVo); + return; } - i++; + realAttributeVo = handleAttbt(item, real, alertList, faultList); + if (ObjectUtil.isEmpty(realAttributeVo)) { + return; + } + attbtList.add(realAttributeVo); + }); + device.setAttbtList(attbtList); + } + + /** + * 获取站点属性 + * @param stationEntityList + * @param item + */ + private void stationParam(List stationEntityList, RealStationVo item,List deptAll) { + if(CollectionUtil.isEmpty(stationEntityList)){ + return; } - if (!CollectionUtil.isEmpty(tem)) { - total.add(tem); + List filterList = stationEntityList.stream().filter(o->item.getStationCode().equals(o.getCode())).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(filterList)){ + return; } - return total; + StationEntity station = filterList.get(0); + if(ObjectUtil.isEmpty(station)){ + return; + } + item.setStationName(station.getName()); + item.setWaterLevelMax(station.getLimitWaterLevel()); + item.setServerType(station.getServeType()); + item.setStationDeptId(station.getRefDept()); + // 排序 + List list = deptAll.stream().filter(o-> station.getRefDept().equals(o.getId())).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(list)){ + return; + } + item.setSort(list.get(0).getSort()); } - - /** * 设备参数设置 * - * @param emList + * @param devices * @param deviceClassifyMap * @param deviceList */ - private void getDeviceParam(List emList, Map> deviceClassifyMap, List deviceList) { - if (CollectionUtil.isEmpty(emList) || CollectionUtil.isEmpty(deviceList) || MapUtils.isEmpty(deviceClassifyMap)) { + private void getDeviceParam(List devices, Map> deviceClassifyMap, List deviceList) { + if (CollectionUtil.isEmpty(devices) || CollectionUtil.isEmpty(deviceList) || MapUtils.isEmpty(deviceClassifyMap)) { return; } List faultList = deviceClassifyMap.get(HomePageConstant.FAULT); @@ -405,7 +428,7 @@ public class RealMonitorServiceImpl implements IRealMonitorService { device.setState(-1); return; } - List list = emList.stream().filter(o -> null != o.getId() && o.getId().toString().equals(device.getDeviceCode())).collect(Collectors.toList()); + List list = devices.stream().filter(o -> null != o.getId() && o.getId().toString().equals(device.getDeviceCode())).collect(Collectors.toList()); if (CollectionUtil.isEmpty(list)) { device.setState(-1); return; @@ -436,104 +459,6 @@ public class RealMonitorServiceImpl implements IRealMonitorService { } }); } - /** - * 获取所有告警记录 - * - * @return - */ - private List getFdpFaultAll() { - Object json = redisTemplate.opsForValue().get(fdp_fault_data_key); - if (ObjectUtil.isEmpty(json)) { - return new ArrayList<>(); - } - return (List) json; - } - - - - /** - * 设置站点状态 - * @param alarmList - * @param station - * @param key - */ - private void setStationStatus(List alarmList, RealStationVo station, String key) { - station.setStatus(0); - if(alarmList.contains(key)){ - station.setStatus(1); - } - } - - - /** - * 获取站点属性 - * @param stationEntityList - * @param item - */ - private void stationParam(List stationEntityList, RealStationVo item,List deptAll) { - if(CollectionUtil.isEmpty(stationEntityList)){ - return; - } - List filterList = stationEntityList.stream().filter(o->item.getStationCode().equals(o.getCode())).collect(Collectors.toList()); - if(CollectionUtil.isEmpty(filterList)){ - return; - } - StationEntity station = filterList.get(0); - if(ObjectUtil.isEmpty(station)){ - return; - } - item.setStationName(station.getName()); - item.setWaterLevelMax(station.getLimitWaterLevel()); - item.setServerType(station.getServeType()); - item.setStationDeptId(station.getRefDept()); - // 排序 - List list = deptAll.stream().filter(o-> station.getRefDept().equals(o.getId())).collect(Collectors.toList()); - if(CollectionUtil.isEmpty(list)){ - return; - } - item.setSort(list.get(0).getSort()); - } - - - - /** - * 设备处理 - * - * @param list - * @param map - * @param device - */ - private void handleDevice(List list, Map> map, - RealDeviceVo device, List alertList, - List faultList) { - if (CollectionUtil.isEmpty(list) || MapUtils.isEmpty(map)) { - return; - } - List attbtList = new ArrayList<>(); - list.forEach(item -> { - RealAttributeVo realAttributeVo = new RealAttributeVo(); - // 设备重点属性处理 : 单条-item - Map real = map.get(item.getMonitorId()); - if(MapUtils.isEmpty(real)){ - realAttributeVo.setName(item.getAttributes()); - realAttributeVo.setType(item.getAttributeType()); - realAttributeVo.setRealId(item.getMonitorId()); - realAttributeVo.setQuality(-1); - realAttributeVo.setStatus(0); - realAttributeVo.setValue("0"); - realAttributeVo.setUnit(item.getUnit()); - attbtList.add(realAttributeVo); - return; - } - realAttributeVo = handleAttbt(item, real, alertList, faultList); - if (ObjectUtil.isEmpty(realAttributeVo)) { - return; - } - attbtList.add(realAttributeVo); - }); - device.setAttbtList(attbtList); - } - /** * 设备单条重点属性处理 @@ -580,6 +505,39 @@ public class RealMonitorServiceImpl implements IRealMonitorService { } /** + * 设置重点属性参数 + * + * @param attest + * @param real + */ + private void setAttbtParam(RealAttributeVo attest, Map real) { + if (CollectionUtil.isEmpty(real)) { + return; + } + real.forEach((key, value) -> { + if (StringUtil.isBlank(value)) { + return; + } + switch (key) { + case "q": + attest.setQuality(Integer.parseInt(value)); + break; + case "realId": + attest.setRealId(value); + break; + case "value": + attest.setValue(Optional.ofNullable(value).orElse("-")); + break; + case "time": + attest.setTime(value); + break; + default: + break; + } + }); + } + + /** * 故障信息设置 * * @param attest @@ -596,10 +554,10 @@ public class RealMonitorServiceImpl implements IRealMonitorService { } FdpFaultStatusVo fdpFaultStatusVo = fault.get(0); // 黄色 - if (fdpFaultStatusVo.getValue() > greater_than && fdpFaultStatusVo.getValue() < less_than) { + if (fdpFaultStatusVo.getValue() > greater_than_cache_final && fdpFaultStatusVo.getValue() < less_than_cache_final) { attest.setStatus(ConfigStatus.ConfigStatusEnum.YELLOW.getStatus()); // 橙色 - } else if (fdpFaultStatusVo.getValue() >= be_equal_or_greater_than) { + } else if (fdpFaultStatusVo.getValue() >= be_equa_cache_final) { attest.setStatus(ConfigStatus.ConfigStatusEnum.ORANGE.getStatus()); } attest.setFdpRate(fdpFaultStatusVo.getValue()); @@ -680,34 +638,107 @@ public class RealMonitorServiceImpl implements IRealMonitorService { } } } + /** - * 设置重点属性参数 + * 设置站点状态 + * @param alarmList + * @param station + * @param key + */ + private void setStationStatus(List alarmList, RealStationVo station, String key) { + station.setStatus(0); + if(alarmList.contains(key)){ + station.setStatus(1); + } + } + + /** + * 获取所有告警记录 * - * @param attest - * @param real + * @return */ - private void setAttbtParam(RealAttributeVo attest, Map real) { - if (CollectionUtil.isEmpty(real)) { - return; + private List getFdpFaultAll() { + Object json = redisTemplate.opsForValue().get(fdp_fault_cache_final); + if (ObjectUtil.isEmpty(json)) { + return new ArrayList<>(); } - real.forEach((key, value) -> { - if (StringUtil.isBlank(value)) { - return; - } - switch (key) { - case "q": - attest.setQuality(Integer.parseInt(value)); - break; - case "realId": - attest.setRealId(value); - break; - case "value": - attest.setValue(Optional.ofNullable(value).orElse("-")); - break; - case "time": - attest.setTime(value); - break; + return (List) json; + } + + /** + * map分割 + * + * @param + * @param + * @param chunkMap + * @return + */ + private List> mapChunk(Map chunkMap) { + if (chunkMap == null) { + return Lists.newArrayList(); + } + Set keySet = chunkMap.keySet(); + Iterator iterator = keySet.iterator(); + int i = 1; + List> total = new ArrayList<>(); + Map tem = new HashMap<>(); + while (iterator.hasNext()) { + k next = iterator.next(); + tem.put(next, chunkMap.get(next)); + if (i == 5) { + total.add(tem); + tem = new HashMap<>(); + i = 0; } - }); + i++; + } + if (!CollectionUtil.isEmpty(tem)) { + total.add(tem); + } + return total; + } + + /** + * 获取厂房监测点 + * @return + */ + private List getRealIdByWsCodeAndSign() { + List wsInfoList = workshopInfoService.list(); + if(CollectionUtil.isEmpty(wsInfoList)) { + return Lists.newArrayList(); + } + Function getAnalyzeCodePO = wsCode -> { + MultiAnalyzeCodePO multiAnalyzeCodePO = new MultiAnalyzeCodePO(); + multiAnalyzeCodePO.setDeviceCode(wsCode); + multiAnalyzeCodePO.setSignages(Lists.newArrayList(HomePageConstant.PV_JOINT_RELAY,HomePageConstant.PV_REACTIVE_POWER,HomePageConstant.PV_GENERATION_CAPACITY)); + return multiAnalyzeCodePO; + }; + List analyzeCodePOList = wsInfoList.stream().map(WorkshopInfoEntity::getNumber).map(getAnalyzeCodePO).collect(Collectors.toList()); + R> analyzeCodeBySignages = analyseDataSearchClient.getAnalyzeCodeBySignages(analyzeCodePOList); + return Optional.ofNullable(analyzeCodeBySignages).filter(r -> r.isSuccess()).map(R::getData).orElse(Lists.newArrayList()); + } + + /** + * 获取站点realId + * @param refDept + * @param eminfoAndEmParams + * @return + */ + private List getRealDeviceList(Long refDept, List eminfoAndEmParams) { + // 参数检查 + if(CollectionUtil.isEmpty(eminfoAndEmParams) || ObjectUtil.isEmpty(refDept)){ + return new ArrayList<>(); + } + // 有效设备 + List filters = eminfoAndEmParams.stream().filter(o-> o.getCreateDept().equals(refDept)).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(filters)){ + return new ArrayList<>(); + } + // 遍历设备 + List result = new ArrayList<>(); + for(EminfoAndEmParamVo device : filters){ + result.addAll(device.getPoint().values()); + } + return result; } -} +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/OtherServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/OtherServiceImpl.java new file mode 100644 index 0000000..202c396 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/OtherServiceImpl.java @@ -0,0 +1,19 @@ +package com.hnac.hzims.scheduled.service.operation.impl; + +import com.hnac.hzims.operational.fill.entity.OtherEntity; +import com.hnac.hzims.scheduled.mapper.operation.OtherMapper; +import com.hnac.hzims.scheduled.service.operation.OtherService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +/** + * @author ysj + */ +@Slf4j +@Service +@AllArgsConstructor +public class OtherServiceImpl extends BaseServiceImpl implements OtherService { + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/OverDetailsServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/OverDetailsServiceImpl.java new file mode 100644 index 0000000..dc69ec3 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/OverDetailsServiceImpl.java @@ -0,0 +1,19 @@ +package com.hnac.hzims.scheduled.service.operation.impl; + +import com.hnac.hzims.operational.fill.entity.OverDetailsEntity; +import com.hnac.hzims.scheduled.mapper.operation.OverDetailsMapper; +import com.hnac.hzims.scheduled.service.operation.OverDetailsService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +/** + * @author ysj + */ +@Slf4j +@Service +@AllArgsConstructor +public class OverDetailsServiceImpl extends BaseServiceImpl implements OverDetailsService { + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/OverServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/OverServiceImpl.java new file mode 100644 index 0000000..f629fc7 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/OverServiceImpl.java @@ -0,0 +1,19 @@ +package com.hnac.hzims.scheduled.service.operation.impl; + +import com.hnac.hzims.operational.fill.entity.OverEntity; +import com.hnac.hzims.scheduled.mapper.operation.OverMapper; +import com.hnac.hzims.scheduled.service.operation.OverService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +/** + * @author ysj + */ +@Slf4j +@Service +@AllArgsConstructor +public class OverServiceImpl extends BaseServiceImpl implements OverService { + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/PhenomenonServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/PhenomenonServiceImpl.java new file mode 100644 index 0000000..4afdf08 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/PhenomenonServiceImpl.java @@ -0,0 +1,60 @@ +package com.hnac.hzims.scheduled.service.operation.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity; +import com.hnac.hzims.operational.report.vo.DutyDefectVO; +import com.hnac.hzims.scheduled.mapper.operation.PhenomenonMapper; +import com.hnac.hzims.scheduled.service.operation.PhenomenonService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.Func; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author ysj + */ +@Service +@Slf4j +@AllArgsConstructor +public class PhenomenonServiceImpl extends BaseServiceImpl implements PhenomenonService { + + /** + * 时间范围内机构缺陷数据查询 + * @param start + * @param end + * @param areas + * @return + */ + @Override + public DutyDefectVO defect(String start, String end, List areas) { + DutyDefectVO defectVO = new DutyDefectVO(); + // 查询缺陷现象总数 + List operPhenomenonList = this.list(new LambdaQueryWrapper(){{ + ge(OperPhenomenonEntity::getCreateTime,start); + le(OperPhenomenonEntity::getCreateTime,end); + in(OperPhenomenonEntity::getCreateDept,areas); + }}); + if(CollectionUtil.isEmpty(operPhenomenonList)){ + defectVO.setDefectSum(0); + defectVO.setDefect(0); + return defectVO; + } + defectVO.setTotalIds(operPhenomenonList.stream().map(o->String.valueOf(o.getId())).collect(Collectors.joining(","))); + defectVO.setDefectSum(operPhenomenonList.size()); + // 消缺数 + List defectList = operPhenomenonList.stream().filter(o -> (Func.isNotEmpty(o.getIsDefect()) && o.getIsDefect() == 0) || "1".equals(o.getConclusionStatus())). + map(OperPhenomenonEntity::getId).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(defectList)){ + defectVO.setDefect(0); + return defectVO; + } + // 缺陷总数 + defectVO.setDefect(defectList.size()); + return defectVO; + } +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/PowerServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/PowerServiceImpl.java new file mode 100644 index 0000000..265a8b7 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/PowerServiceImpl.java @@ -0,0 +1,77 @@ +package com.hnac.hzims.scheduled.service.operation.impl; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hnac.hzims.operational.fill.entity.PowerEntity; +import com.hnac.hzims.operational.main.vo.PowerMonthVo; +import com.hnac.hzims.scheduled.mapper.operation.PowerMapper; +import com.hnac.hzims.scheduled.service.operation.PowerService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.DateUtil; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + + +@Slf4j +@Service +@AllArgsConstructor +public class PowerServiceImpl extends BaseServiceImpl implements PowerService { + + + /** + * 根据时间、机构查询发电量 + * @param date 时间: 年 - yyyy/月 yyyy-mm/日 yyyy-mm-dd + * @param station 所属机构 + * @return + */ + @Override + public Double generate(String date, Long station) { + List powers = this.list(Wrappers.lambdaQuery() + .likeRight(PowerEntity::getMon,date) + .eq(PowerEntity::getCreateDept,station) + // 类型: 光伏 + .eq(PowerEntity::getType,1) + ); + if(CollectionUtil.isEmpty(powers)){ + return 0.0; + } + return powers.stream().mapToDouble(PowerEntity::getPowerMon).sum(); + } + + /** + * + * @param start 开始时间 : yyyy-mm + * @param end 结束时间 : yyyy-mm + * @param station 所属机构 + * @return + */ + @Override + public List generateThreeYear(String start, String end, Long station) { + List fills = this.list(Wrappers.lambdaQuery() + .between(PowerEntity::getMon,start,end) + .eq(PowerEntity::getCreateDept,station) + // 类型: 光伏 + .eq(PowerEntity::getType,1) + ); + if(CollectionUtil.isEmpty(fills)){ + return new ArrayList<>(); + + } + return fills.stream().map(fill->{ + PowerMonthVo mon = new PowerMonthVo(); + mon.setStrMonth(DateUtil.format(DateUtil.parse(fill.getMon(),"yyyy-MM"),DateUtil.PATTERN_DATE)); + if(Math.abs(fill.getPowerMon()) <= 0){ + mon.setPower(0f); + }else{ + mon.setPower(Float.parseFloat(fill.getPowerMon().toString())); + } + return mon; + }).collect(Collectors.toList()); + } + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/RealTargetServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/RealTargetServiceImpl.java new file mode 100644 index 0000000..6e08365 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/RealTargetServiceImpl.java @@ -0,0 +1,1510 @@ +package com.hnac.hzims.scheduled.service.operation.impl; + +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; +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.vo.EminfoAndEmParamVo; +import com.hnac.hzims.operational.main.constant.HomePageConstant; +import com.hnac.hzims.operational.main.vo.*; +import com.hnac.hzims.operational.station.StationConstants; +import com.hnac.hzims.operational.station.entity.HzimsAnalyzeModelStationEntity; +import com.hnac.hzims.operational.station.entity.StationEntity; +import com.hnac.hzims.scheduled.service.operation.*; +import com.hnac.hzinfo.datasearch.PointData; +import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; +import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData; +import com.hnac.hzinfo.datasearch.analyse.po.AnalyseCodeByAnalyseDataPO; +import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO; +import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO; +import com.hnac.hzinfo.datasearch.history.IHistoryDataSearchClient; +import com.hnac.hzinfo.datasearch.history.OriginalDataQuery; +import com.hnac.hzinfo.datasearch.real.po.RealDataSearchPO; +import com.hnac.hzinfo.sdk.analyse.po.MultiAnalyzeCodePO; +import com.hnac.hzinfo.sdk.core.response.HzPage; +import com.hnac.hzinfo.sdk.core.response.Result; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.MapUtils; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.DateUtil; +import org.springblade.core.tool.utils.ObjectUtil; +import org.springblade.core.tool.utils.StringUtil; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; + +/** + * APP首页实现类 + * @author ysj + */ +@Service +@RequiredArgsConstructor +@Slf4j +public class RealTargetServiceImpl implements RealTargetService { + + private final UseService useService; + + private final PowerService powerService; + + private final StationService stationService; + + private final GenerateService generateService; + + private final AnalyseDataService analyseDataService; + + private final StationAttributeService attributeService; + + private final ModelStationService modelStationService; + + private final RedisTemplate redisTemplate; + + private final IAnalyseDataSearchClient analyseDataSearchClient; + + private final IHistoryDataSearchClient historyDataSearchClient; + + @Value("${hzims.equipment.emInfo.emInfoList}") + public String device_cache_cofig_final; + + @Value("${hzims.operation.realIdKey}") + public String real_id_cofig_final; + + 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 loadwaterpump_target_key = "hzims:operation:loadwaterpump:target:key"; + private final static String loadwaterpump_real_key = "hzims:operation:loadwaterpump:real:key"; + private final static String loadwater_level_key = "hzims:operation:loadwater:level:key"; + private final static String load_photovoltaic_real_key = "hzims:operation:photovoltaic:real:key"; + private final static String load_photovoltaic_target_key = "hzims:operation:photovoltaic:target:key"; + + + /** + * 加载水电站机组实时数据 + * @param param + */ + @Override + public void loadHydropowerReal(String param) { + // 水电站站点 + List stations = stationService.list(Wrappers.lambdaQuery() + .eq(StationEntity::getType,HomePageConstant.HYDROPOWER) + ); + if(CollectionUtil.isEmpty(stations)){ + return; + } + // 水电站设备 + List devices = this.pumpDevices(stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList())); + if(CollectionUtil.isEmpty(devices)){ + return; + } + // 实时数据 + Map map = this.getRealMap(); + // 单位 + Map unitMap = this.attributeService.PointUnit(); + // 实时数据 + List reals = devices.stream().map(device->{ + HydropowerUnitRealVo real = new HydropowerUnitRealVo(); + real.setDeptId(device.getCreateDept()); + real.setDeviceCode(device.getEmCode()); + real.setDeptName(device.getName()); + real.setDeviceName(device.getName()); + // 装机容量 + real.setInstalledCapacity(device.getInstalledCapacity()); + // 开关机状态 + real.setState(this.state(device,map)); + // 有功功率 + real.setActivePower(this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_ACTIVE_POWER)); + // 无功功率 + real.setReactivePower(this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_REACTIVE_POWER)); + // 功率因数 + real.setPowerFactor(this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_POWERFACTOR)); + // 机组频率 + real.setFrequency(this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_FREQUENCY)); + // 导叶开度 + real.setGuideOpen(this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_GUIDEOPEN)); + // 定子电压 + real.setStatorVoltage(this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_VOLTAGE)); + // 定子电流 + real.setStatorCurrent(this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_CURRENT)); + // 单位设置 + this.setttingUnit(device,unitMap,real); + return real; + }).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(reals)){ + return; + } + redisTemplate.opsForValue().set(load_hydropower_unit_real_key,reals); + } + + /** + * 加载水电站机组指标数据 + * @param param + */ + @Override + public void loadHydropowerTarget(String param) { + // 水电站站点 + List stations = stationService.list(Wrappers.lambdaQuery() + //.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE) + .eq(StationEntity::getType,HomePageConstant.HYDROPOWER) + ); + if(CollectionUtil.isEmpty(stations)){ + return; + } + // 补充填补发电指标 + List targets = this.generteFill(stations); + // 水电站设备 + List devices = this.pumpDevices(stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList())); + if(CollectionUtil.isNotEmpty(devices)){ + targets.addAll(devices.stream().map(device->{ + HydropowerUnitTargetVo target = new HydropowerUnitTargetVo(); + target.setDeptId(device.getCreateDept()); + target.setDeviceCode(device.getEmCode()); + target.setDeviceName(device.getName()); + target.setDeptName(device.getName()); + // 当年发电量 + target.setPowerYear(this.getGenerationPower(device,0)); + // 当月发电量 + target.setPowerMon(this.getGenerationPower(device,1)); + // 当日发电量 + target.setPowerDay(this.getGenerationPower(device,2)); + // 当天有功功率 + target.setActivePowerVoList(this.getLoadsByDay(device)); + // 30天发电量 + target.setGenerationPowerVoList(this.getGenerationPowerList(device)); + return target; + }).collect(Collectors.toList())); + } + // 站点指标数据为空 + if(CollectionUtil.isEmpty(targets)){ + return; + } + redisTemplate.opsForValue().set(load_hydropower_unit_target_key,targets); + } + + /** + * 水利-泵组实时加载 + * @param param + */ + @Override + public void loadWaterPumpReal(String param) { + // 水利站点 + List stations = stationService.list(Wrappers.lambdaQuery() + .eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE) + .in(StationEntity::getType,HomePageConstant.waterList) + ); + if(CollectionUtil.isEmpty(stations)){ + return; + } + // 泵站设备 + List devices = this.pumpDevices(stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList())); + if(CollectionUtil.isEmpty(devices)){ + return; + } + // 实时数据 + Map map = this.getRealMap(); + List list = devices.stream().map(device->{ + WaterPumpRealVo real = new WaterPumpRealVo(); + real.setDeptId(device.getCreateDept()); + real.setDeviceCode(device.getEmCode()); + real.setDeptName(device.getName()); + // 装机容量 + real.setInstalledCapacity(device.getInstalledCapacity()); + // 开机状态 + real.setState(this.pumpState(device,map)); + // 功率因数 + real.setPowerFactor(this.getSignageValue(device,map,HomePageConstant.POWER_FACTOR)); + // 有功功率 + real.setActivePower(this.floatValue(device,map,HomePageConstant.ACTIVE_POWER)); + // 无功功率 + real.setReactivePower(this.floatValue(device,map,HomePageConstant.REACTIVE_POWER)); + // 电压 + real.setVoltage(this.getSignageValue(device,map,HomePageConstant.VOLTAGE)); + // 电流 + real.setCurrent(this.getSignageValue(device,map,HomePageConstant.CURRENT)); + return real; + }).collect(Collectors.toList()); + redisTemplate.opsForValue().set(loadwaterpump_real_key,list); + } + + /** + * 水利-泵组指标加载 + * @param param + */ + @Override + public void loadWaterPumpTarget(String param) { + // 水利站点 + List stations = stationService.list(Wrappers.lambdaQuery() + .eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE) + .in(StationEntity::getType,HomePageConstant.waterList) + ); + if(CollectionUtil.isEmpty(stations)){ + return; + } + // 泵站设备 + List devices = this.pumpDevices(stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList())); + // 补充站点填报发电量 + List list = this.useFill(stations); + // 站点设备数据统计 + if(CollectionUtil.isNotEmpty(devices)){ + list.addAll(devices.stream().map(device->{ + WaterPumpTargetVo target = new WaterPumpTargetVo(); + target.setDeptId(device.getCreateDept()); + target.setDeviceCode(device.getEmCode()); + target.setDeptName(device.getName()); + // 当年用电量 + target.setUsrPowerYear(this.getUsrPowerYear(device)); + // 当月用电量 + target.setUsrPowerMon(this.getUsrPowerMon(device)); + // 当日用电量 + target.setUsrPowerDay(this.getUsrPowerDay(device)); + // 当日机组有功功率 + target.setActivePowerVoList(this.getActivePowerVoList(device)); + // 近30天用电量 + target.setUsrPowerVoList(this.getUsrPowerVoList(device)); + // 近3年用电量 + target.setUsrYearMap(this.getUsrYearMap(device)); + // 月运行次数、时长 + WaterRunVo runMon = this.getRunData(device,1); + target.setRunCountMon(runMon.getCount()); + target.setRunDurationMon(runMon.getHour()); + // 年运行次数、时长 + WaterRunVo runYear = this.getRunData(device,0); + target.setRunCountYear(runYear.getCount()); + target.setRunDurationYear(runYear.getHour()); + return target; + }).collect(Collectors.toList())); + } + redisTemplate.opsForValue().set(loadwaterpump_target_key,list); + } + + /** + * 水利-站点水位数据 + * @param param + */ + @Override + public void loadWaterLevel(String param) { + // 有效站点模型 + List modelList = getModelStationList(); + if(CollectionUtil.isEmpty(modelList)){ + return; + } + List list = new ArrayList<>(); + modelList.forEach(item -> { + List multiAnalyzeCodePOList = new ArrayList<>(); + MultiAnalyzeCodePO multiAnalyzeCodePO = new MultiAnalyzeCodePO(); + multiAnalyzeCodePO.setDeviceCode(item.getInstanceCode()); + multiAnalyzeCodePO.setSignages(Collections.singletonList(HomePageConstant.FRONT_WATER_LEVEL)); + multiAnalyzeCodePOList.add(multiAnalyzeCodePO); + R> result = analyseDataSearchClient.getAnalyzeCodeBySignages(multiAnalyzeCodePOList); + if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ + return; + } + WaterLevelVo waterLevelVo = new WaterLevelVo(); + waterLevelVo.setStationCode(item.getStationId()); + // 前水位 + double frontWaterLevel = this.getWaterLevel(item.getInstanceCode(),HomePageConstant.FRONT_WATER_LEVEL); + waterLevelVo.setFrontWaterLevel(frontWaterLevel); + // 后水位 + double rearWaterLevel = this.getWaterLevel(item.getInstanceCode(),HomePageConstant.REAR_WATER_LEVEL); + waterLevelVo.setRearWaterLevel(rearWaterLevel); + // 前水位当日曲线 + Map frontCurveMap = this.getWaterLevelMap(item.getInstanceCode(),HomePageConstant.FRONT_WATER_LEVEL); + waterLevelVo.setFrontCurveMap(frontCurveMap); + // 后水位当日曲线 + Map rearCurveMap = this.getWaterLevelMap(item.getInstanceCode(),HomePageConstant.REAR_WATER_LEVEL); + waterLevelVo.setRearCurveMap(rearCurveMap); + list.add(waterLevelVo); + }); + redisTemplate.opsForValue().set(loadwater_level_key,list); + } + + /** + * 光伏站-逆变器实时加载 + * + * @param param + */ + + @Override + public void loadPhotovoltaicReal(String param) { + // 查询设备 + List devices = this.getPhotovoltaicDevice(); + if (CollectionUtil.isEmpty(devices)) { + return; + } + // 取redis实时数据 + Map map = this.getRealMap(); + if (MapUtils.isEmpty(map)) { + return; + } + // redis缓存设备实时数据 + List history = (List) redisTemplate.opsForValue().get(load_photovoltaic_real_key); + // 设备实时数据 + List list = devices.stream().map(device -> { + PhotovoltaicRealVo real = new PhotovoltaicRealVo(); + real.setDeptId(device.getCreateDept()); + real.setDeviceCode(device.getEmCode()); + real.setDeviceName(device.getName()); + real.setState(this.getPhotovoltaicState(device, map)); + // 容量 + real.setCapacity(device.getInstalledCapacity()); + // 发电量 + real.setGenerate(this.getSignageValue(device, map, HomePageConstant.PV_GENERATION_CAPACITY)); + // 功率 + real.setLoad(this.getSignageValue(device, map, HomePageConstant.PV_LOAD)); + // 交流电压 + real.setVoltage(this.getSignageValue(device, map, HomePageConstant.PV_VOLTAGE)); + // 交流电流 + real.setCurrent(this.getSignageValue(device, map, HomePageConstant.PV_CURRENT)); + // 交流电压2 + real.setVoltage_two(this.getSignageValue(device, map, HomePageConstant.PV_VOLTAGE_TWO)); + // 交流电流2 + real.setCurrent_two(this.getSignageValue(device, map, HomePageConstant.PV_CURRENT_TWO)); + // 交流电压3 + real.setVoltage_three(this.getSignageValue(device, map, HomePageConstant.PV_VOLTAGE_THREE)); + // 交流电流3 + real.setCurrent_three(this.getSignageValue(device, map, HomePageConstant.PV_CURRENT_THREE)); + // 直流电流1 + real.setDirect_one(this.getSignageValue(device, map, HomePageConstant.DIRECT_ONE)); + // 直流电流2 + real.setDirect_two(this.getSignageValue(device, map, HomePageConstant.DIRECT_TWO)); + // 直流电流3 + real.setDirect_three(this.getSignageValue(device, map, HomePageConstant.DIRECT_THREE)); + // 直流电流4 + real.setDirect_four(this.getSignageValue(device, map, HomePageConstant.DIRECT_FOUR)); + // 直流电流5 + real.setDirect_five(this.getSignageValue(device, map, HomePageConstant.DIRECT_FIVE)); + // 直流电流6 + real.setDirect_six(this.getSignageValue(device, map, HomePageConstant.DIRECT_SIX)); + // 直流电流7 + real.setDirect_seven(this.getSignageValue(device, map, HomePageConstant.DIRECT_SEVEN)); + // 直流电流8 + real.setDirect_eight(this.getSignageValue(device, map, HomePageConstant.DIRECT_EIGHT)); + // 直流电流9 + real.setDirect_nine(this.getSignageValue(device, map, HomePageConstant.DIRECT_NINE)); + // 直流电流10 + real.setDirect_ten(this.getSignageValue(device, map, HomePageConstant.DIRECT_TEN)); + // 直流电流11 + real.setDirect_eleven(this.getSignageValue(device, map, HomePageConstant.DIRECT_ELEVEN)); + // 直流电流12 + real.setDirect_twelve(this.getSignageValue(device, map, HomePageConstant.DIRECT_TWELVE)); + // 直流电压1 + real.setDc_voltage_one(this.getSignageValue(device, map, HomePageConstant.DC_VOLTAGE_ONE)); + // 直流电压2 + real.setDc_voltage_two(this.getSignageValue(device, map, HomePageConstant.DC_VOLTAGE_TWO)); + // 直流电压3 + real.setDc_voltage_three(this.getSignageValue(device, map, HomePageConstant.DC_VOLTAGE_THREE)); + // 直流电压4 + real.setDc_voltage_four(this.getSignageValue(device, map, HomePageConstant.DC_VOLTAGE_FOUR)); + // 直流电压5 + real.setDc_voltage_five(this.getSignageValue(device, map, HomePageConstant.DC_VOLTAGE_FIVE)); + // 直流电压6 + real.setDc_voltage_six(this.getSignageValue(device, map, HomePageConstant.DC_VOLTAGE_SIX)); + // 直流电压7 + real.setDc_voltage_seven(this.getSignageValue(device, map, HomePageConstant.DC_VOLTAGE_SEVEN)); + // 直流电压8 + real.setDc_voltage_eight(this.getSignageValue(device, map, HomePageConstant.DC_VOLTAGE_EIGHT)); + // 直流电压9 + real.setDc_voltage_nine(this.getSignageValue(device, map, HomePageConstant.DC_VOLTAGE_NINE)); + // 直流电压10 + real.setDc_voltage_ten(this.getSignageValue(device, map, HomePageConstant.DC_VOLTAGE_TEN)); + // 直流电压11 + real.setDc_voltage_eleven(this.getSignageValue(device, map, HomePageConstant.DC_VOLTAGE_ELEVEN)); + // 直流电压12 + real.setDc_voltage_twelve(this.getSignageValue(device, map, HomePageConstant.DC_VOLTAGE_TWELVE)); + // 串流电流1 + real.setDirect_one(this.getSignageValue(device, map, HomePageConstant.DIRECT_ONE)); + // 串流电流2 + real.setSeries_two(this.getSignageValue(device, map, HomePageConstant.SERIES_TWO)); + // 串流电流3 + real.setSeries_three(this.getSignageValue(device, map, HomePageConstant.SERIES_THREE)); + // 串流电流4 + real.setSeries_four(this.getSignageValue(device, map, HomePageConstant.SERIES_FOUR)); + // 串流电流5 + real.setSeries_five(this.getSignageValue(device, map, HomePageConstant.SERIES_FIVE)); + // 串流电流6 + real.setSeries_six(this.getSignageValue(device, map, HomePageConstant.SERIES_SIX)); + // 串流电流7 + real.setSeries_seven(this.getSignageValue(device, map, HomePageConstant.SERIES_SEVEN)); + // 串流电流8 + real.setSeries_eight(this.getSignageValue(device, map, HomePageConstant.SERIES_EIGHT)); + // 串流电流9 + real.setSeries_nine(this.getSignageValue(device, map, HomePageConstant.SERIES_NINE)); + // 串流电流10 + real.setSeries_ten(this.getSignageValue(device, map, HomePageConstant.SERIES_TEN)); + // 串流电流11 + real.setSeries_eleven(this.getSignageValue(device, map, HomePageConstant.SERIES_ELEVEN)); + // 串流电流12 + real.setSeries_twelve(this.getSignageValue(device, map, HomePageConstant.SERIES_TWELVE)); + // 串流电压1 + real.setSe_voltage_one(this.getSignageValue(device, map, HomePageConstant.SE_VOLTAGE_ONE)); + // 串流电压2 + real.setSe_voltage_two(this.getSignageValue(device, map, HomePageConstant.SE_VOLTAGE_TWO)); + // 串流电压3 + real.setSe_voltage_three(this.getSignageValue(device, map, HomePageConstant.SE_VOLTAGE_THREE)); + // 串流电压4 + real.setSe_voltage_four(this.getSignageValue(device, map, HomePageConstant.SE_VOLTAGE_FOUR)); + // 串流电压5 + real.setSe_voltage_five(this.getSignageValue(device, map, HomePageConstant.SE_VOLTAGE_FIVE)); + // 串流电压6 + real.setSe_voltage_six(this.getSignageValue(device, map, HomePageConstant.SE_VOLTAGE_SIX)); + // 串流电压7 + real.setSe_voltage_seven(this.getSignageValue(device, map, HomePageConstant.SE_VOLTAGE_SEVEN)); + // 串流电压8 + real.setSe_voltage_eight(this.getSignageValue(device, map, HomePageConstant.SE_VOLTAGE_EIGHT)); + // 串流电压9 + real.setSe_voltage_nine(this.getSignageValue(device, map, HomePageConstant.SE_VOLTAGE_NINE)); + // 串流电压10 + real.setSe_voltage_ten(this.getSignageValue(device, map, HomePageConstant.SE_VOLTAGE_TEN)); + // 串流电压11 + real.setSe_voltage_eleven(this.getSignageValue(device, map, HomePageConstant.SE_VOLTAGE_ELEVEN)); + // 串流电压12 + real.setSe_voltage_twelve(this.getSignageValue(device, map, HomePageConstant.SE_VOLTAGE_TWELVE)); + // 上次功率 + real.setLastLoad(this.getLastLoad(device, history)); + return real; + }).collect(Collectors.toList()); + // 存储redis + redisTemplate.opsForValue().set(load_photovoltaic_real_key, list); + } + + + + /** + * 光伏站-逆变器指标加载 + * + * @param param + */ + @Override + public void loadPhotovoltaicTarget(String param) { + // 有效设备 + List devices = this.getPhotovoltaicDevice(); + if (CollectionUtil.isEmpty(devices)) { + return; + } + List list = new ArrayList<>(); + // 接入站点设备统计 + devices.forEach(device -> { + PhotovoltaicTargetVo target = new PhotovoltaicTargetVo(); + target.setDeptId(device.getCreateDept()); + target.setDeviceCode(device.getEmCode()); + target.setDeviceName(device.getName()); + target.setDeptName(device.getName()); + // 当日运行时长 + target.setRunHours(this.runHours(device.getPoint().get(HomePageConstant.PV_JOINT_RELAY))); + // 年发电量 + target.setGenerationYear((double) this.sumValueByTime(device.getEmCode(), device.getRideCount(), "0")); + // 月发电量 + target.setGenerationMon((double) this.sumValueByTime(device.getEmCode(), device.getRideCount(), "1")); + // 日发电量 + target.setGenerationDay((double) this.sumValueByTime(device.getEmCode(), device.getRideCount(), "2")); + // 昨日发电量 + target.setGenerationYesterday((double) this.sumValueByTime(device.getEmCode(), device.getRideCount(), "3")); + // 收益 + target.setIncome(target.getGenerationDay() * 0.34); + // 节约标准煤 + target.setTec(target.getGenerationMon() * 0.0001229); + // 二氧化碳减排 + target.setCo2(target.getGenerationMon() * 0.000997); + // 减少森林砍伐 + target.setDeforest(target.getGenerationMon() * 0.000553); + // 当天有功功率 + target.setActivePowerVoList(this.photovoltaicLoadsByDay(device)); + // 30天发电量 + target.setGenerationPowerVoList(this.getGenerateByMon(device)); + list.add(target); + }); + // 补充站点填报发电量 + List stations = stationService.list(Wrappers.lambdaQuery() + .eq(StationEntity::getType, HomePageConstant.PHOTOVOLTAIC) + .eq(StationEntity::getServeType, HomePageConstant.HYDROPOWER_SERVETYPE) + ); + if(CollectionUtil.isNotEmpty(stations)){ + list.addAll(this.generateFill(stations)); + } + redisTemplate.opsForValue().set(load_photovoltaic_target_key, list); + } + + + /** + * 当日用电量 + * @param device + * @return + */ + private float getUsrPowerDay(EminfoAndEmParamVo device) { + String time = DateUtil.format(new Date(),DateUtil.PATTERN_DATE); + // 当日用电量 + return analyseDataService.periodTargetFloat(time + " 00:00:00",time + " 23:59:59",5,3,device.getEmCode(),device.getRideCount(),HomePageConstant.ELECTRICITY_CONSUMPTION); + + } + + /** + * 当月用电量 + * @param device + * @return + */ + private float getUsrPowerMon(EminfoAndEmParamVo device) { + String start = DateUtil.format(new Date(), "yyyy-MM") + "-01 00:00:00"; + String end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME); + // 当月用电量 + return analyseDataService.periodTargetFloat(start,end,5,5,device.getEmCode(),device.getRideCount(),HomePageConstant.ELECTRICITY_CONSUMPTION); + } + + /** + * 当年用电量 + * @param device + * @return + */ + private float getUsrPowerYear(EminfoAndEmParamVo device) { + Calendar calendar = Calendar.getInstance(); + String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); + calendar.setTime(new Date()); + calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH)); + calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1); + String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); + // 当年用电量 + return analyseDataService.periodTargetFloat(start,end,5,6,device.getEmCode(),device.getRideCount(),HomePageConstant.ELECTRICITY_CONSUMPTION); + } + + /** + * 当日机组有功功率 + * @param device + * @return + */ + public List getActivePowerVoList(EminfoAndEmParamVo device) { + String startTime = DateUtil.format(new Date(), "yyyy-MM-dd 00:00:00"); + String endTime = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + List datas = analyseDataService.periodTargetData(startTime,endTime,2,6,device.getEmCode(),HomePageConstant.ACTIVE_POWER); + if(CollectionUtil.isEmpty(datas)){ + return new ArrayList<>(); + } + return datas.stream().map(data->{ + ActivePowerVo active = new ActivePowerVo(); + Date dateTime = DateUtil.parse(data.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + active.setHour(dateTime.getHours()); + if (StringUtil.isBlank(data.getVal())) { + active.setActivePower("0"); + }else { + active.setActivePower(data.getVal()); + } + return active; + }).collect(Collectors.toList()); + } + + /** + * 近30天用电量 + * @param device + * @return + */ + private List getUsrPowerVoList(EminfoAndEmParamVo device) { + String start = DateUtil.format(new Date(),DateUtil.PATTERN_DATE) + " 00:00:00"; + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.DAY_OF_MONTH,-29); + String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); + List records = analyseDataService.periodTargetData(start,end,5,EquipmentConstants.CycleTypeEnum.DAY_CYCLE.getType(),device.getEmCode(),HomePageConstant.ELECTRICITY_CONSUMPTION); + if(CollectionUtil.isEmpty(records)){ + return new ArrayList<>(); + } + return records.stream().map(record -> { + UsrPowerVo usr = new UsrPowerVo(); + Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + usr.setDate(DateUtil.format(time,DateUtil.PATTERN_DATE)); + usr.setUsrPower(Float.valueOf(Optional.ofNullable(record.getVal()).orElse("0"))); + return usr; + }).collect(Collectors.toList()); + } + + /** + * 近3年发电量 + * + * @param device + * @return + */ + private Map getUsrYearMap(EminfoAndEmParamVo device) { + // 开始时间 + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH) + 12); + calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1); + String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00"; + // 结束日期 + calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) - 3); + calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH)); + String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00"; + // 查询数据 + List records = analyseDataService.periodTargetData(start,end,5,5,device.getEmCode(),HomePageConstant.ELECTRICITY_CONSUMPTION); + if(CollectionUtil.isEmpty(records)){ + return new HashMap<>(); + } + return records.stream().map(record -> { + PowerMonthVo generate = new PowerMonthVo(); + Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + generate.setStrMonth(DateUtil.format(time, DateUtil.PATTERN_DATE)); + generate.setPower(Float.parseFloat(Optional.ofNullable(record.getVal()).orElse("0")) * device.getRideCount()); + return generate; + }).collect(Collectors.toMap(PowerMonthVo::getStrMonth,PowerMonthVo::getPower)); + } + + /** + * 获取运行数据 + * @param device + * @param type + * @return + */ + private WaterRunVo getRunData(EminfoAndEmParamVo device, int type) { + // 默认返回运行数据 + WaterRunVo waterRunVo = new WaterRunVo(); + waterRunVo.setCount(0); + waterRunVo.setHour(0.0); + Map point = device.getPoint(); + if(MapUtils.isEmpty(point)){ + return waterRunVo; + } + // 监测点 + String realId = point.get(HomePageConstant.SWITCH_ON_OFF); + if(StringUtil.isBlank(realId)){ + return waterRunVo; + } + // 确定查询时间范围: 年、月 + Date startDate,endDate; + Calendar calendar = Calendar.getInstance(); + calendar.setTime(new Date()); + switch (type){ + case 0: + endDate = calendar.getTime(); + calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH)); + calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1); + startDate = calendar.getTime(); + break; + case 1: + endDate = calendar.getTime(); + calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1); + calendar.add(Calendar.HOUR_OF_DAY, -calendar.get(Calendar.HOUR_OF_DAY)); + calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE)); + calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND)); + startDate = calendar.getTime(); + break; + default: + throw new IllegalStateException("Unexpected value: " + type); + } + return this.getRunConvertData(realId,startDate,endDate,waterRunVo); + } + + /** + * 获取时间范围内开机次数、运行时长 + * @param realId + * @param startDate + * @param endDate + * @param waterRunVo + * @return + */ + private WaterRunVo getRunConvertData(String realId, Date startDate, Date endDate, WaterRunVo waterRunVo) { + OriginalDataQuery originalDataQuery = new OriginalDataQuery(); + originalDataQuery.setRealId(realId); + originalDataQuery.setBeginTime(startDate); + originalDataQuery.setEndTime(endDate); + originalDataQuery.setLimit(100000); + originalDataQuery.setPage(1); + // 查询时间范围开关机监测点历史数据 + Result> R = historyDataSearchClient.getOriginalDataByRealIds(originalDataQuery); + if(!R.isSuccess() || ObjectUtil.isEmpty(R.getData())){ + return waterRunVo; + } + // 过滤相邻开关机状态相同数据 + List result = this.getFilterList(R.getData().getRecords()); + if(CollectionUtil.isEmpty(result)){ + return waterRunVo; + } + // 开机次数 + int count = (int) result.stream().filter(o->HomePageConstant.OFF.equals(o.getValue())).count(); + waterRunVo.setCount(count); + // 开机运行时长 + long time = this.getRunTime(result,startDate,endDate); + waterRunVo.setHour(BigDecimal.valueOf(time / (1000 * 60 * 60.00)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); + return waterRunVo; + } + + /** + * 过滤相邻开关机状态相同数据 + * @param list + * @return + */ + private List getFilterList(List list) { + if(CollectionUtil.isEmpty(list)){ + return null; + } + List result = new ArrayList<>(); + // 遍历数据 + for(int i = 0; i< list.size() ; i++){ + // 第一个数据保存下来 + if(i == 0){ + result.add(list.get(i)); + continue; + } + // 遍历数据状态 + String value = list.get(i).getValue(); + if(StringUtil.isBlank(value)){ + continue; + } + // 上一条数据状态 + String up_value = list.get(i-1).getValue(); + if(value.equals(up_value)){ + continue; + } + result.add(list.get(i)); + } + return result; + } + + /** + * 获取运行时长 + * @param result + * @return + */ + private long getRunTime(List result,Date startDate,Date endDate) { + if(result.size() == 1){ + // 一直开机 + if(HomePageConstant.OFF.equals(result.get(0).getValue())){ + return endDate.getTime() - startDate.getTime(); + } + // 一直关机 + return 0; + } + long time=0; + // 遍历累计开机时长 + for(int i = 0; i< result.size() ; i++){ + // 记录为开机状态 就计算到下次关机的时间差 + if(HomePageConstant.ON.equals(result.get(i).getValue())){ + continue; + } + Date endTime,startTime = DateUtil.parse(result.get(i).getTime(), DateUtil.PATTERN_DATETIME); + // 遍历至最后一条数据,累计至当前时间 + if(i == result.size() - 1){ + endTime = endDate; + } + else { + endTime = DateUtil.parse(result.get(i+1).getTime(), DateUtil.PATTERN_DATETIME); + } + time += endTime.getTime() - startTime.getTime(); + } + return time; + } + + /** + * 获取填报用电量 + * @param stations + * @return + */ + private List useFill(List stations) { + Calendar calendar = Calendar.getInstance(); + String day = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE); + String mon = DateUtil.format(calendar.getTime(),"yyyy-MM"); + String year = String.valueOf(calendar.get(Calendar.YEAR)); + return stations.stream().map(station ->{ + WaterPumpTargetVo target = new WaterPumpTargetVo(); + target.setDeptId(station.getRefDept()); + target.setDeptName(station.getName()); + // 月运行次数、时长 + target.setRunCountMon(0); + target.setRunDurationMon(0.0); + // 年运行次数、时长 + target.setRunCountYear(0); + target.setRunDurationYear(0.0); + // 当年用电量 + target.setUsrPowerYear(useService.use(year,station.getCode())); + // 当月用电量 + target.setUsrPowerMon(useService.use(mon,station.getCode())); + // 当日用电量 + target.setUsrPowerDay(useService.use(day,station.getCode())); + if(StationConstants.DATA_ORIGIN_FILL.equals(station.getDataOrigin())){ + // 30天用电量 + target.setUsrPowerVoList(useService.use30Day(day,station.getCode())); + } + // 近3年用电量 + target.setUsrYearMap(this.useThreeYear(station.getCode())); + return target; + }).collect(Collectors.toList()); + } + + /** + * 获取水位实时数据 + * @param instanceCode + * @param signage + * @return + */ + private double getWaterLevel(String instanceCode, String signage) { + RealDataSearchPO realData = new RealDataSearchPO(); + realData.setAnalyzeCode(instanceCode); + List signages = Collections.singletonList(signage); + realData.setSignages(signages); + // 调用fegin接口查询实时数据 + R> R = analyseDataSearchClient.getRealDataByAnalyzeCode(realData); + if(!R.isSuccess() || CollectionUtil.isEmpty(R.getData())){ + return 0.0; + } + // 时间限制 + String time = R.getData().get(0).getTime(); + if(StringUtil.isEmpty(time) || "-".equals(time)){ + return 0.0; + } + Date date = DateUtil.parse(time, "yyyy-MM-dd HH:mm:ss.sss"); + if(System.currentTimeMillis() - date.getTime() > 30 * 60 * 1000L){ + return 0.0; + } + return Double.parseDouble(R.getData().get(0).getValue()); + } + + /** + * 获取水位当年数据 + * @param instanceCode + * @param signage + * @return + */ + private Map getWaterLevelMap(String instanceCode, String signage) { + String beginTime = DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00"; + String endTime = DateUtil.format(new Date(), DateUtil.PATTERN_DATE); + AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO(); + List datas = analyseDataService.periodTargetData(beginTime, endTime,2, 6,instanceCode,signage); + if(CollectionUtil.isEmpty(datas)){ + return new HashMap<>(); + } + return datas.stream().collect(Collectors.toMap( + key-> { + Date dateTime = DateUtil.parse(key.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + return dateTime.getHours(); + }, + value -> { + if(StringUtil.isBlank(value.getVal())){ + return "0"; + } + return value.getVal(); + }) + ); + } + + /** + * 填报近3年发电量 + * @param station + * @return + */ + private Map useThreeYear(String station) { + // 开始时间 + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH) + 12); + calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1); + String end = DateUtil.format(calendar.getTime(),"yyyy-MM"); + // 结束日期 + calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) - 3); + calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH)); + String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE); + return useService.generateThreeYear(start,end,station); + } + + + /** + * 获取有效站点模型 + * @return + */ + private List getModelStationList() { + // 水利站点(All) + List stations = stationService.list(new LambdaQueryWrapper() {{ + eq(StationEntity::getServeType, HomePageConstant.HYDROPOWER_SERVETYPE); + }}); + if(CollectionUtil.isEmpty(stations)){ + return new ArrayList<>(); + } + // 站点code集合 + List codes = stations.stream().map(StationEntity::getCode).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(codes)){ + return new ArrayList<>(); + } + // 查询站点模型列表 + List list = modelStationService.list(new LambdaQueryWrapper() {{ + in(HzimsAnalyzeModelStationEntity::getStationId, codes); + }}); + if(CollectionUtil.isEmpty(list)){ + return new ArrayList<>(); + } + return list; + } + + /** + * 获取开机状态 + * @param device + * @return + */ + private int pumpState(EminfoAndEmParamVo device,Map map) { + // 获取开关机监测点实时数据 + double value = this.getSignageValue(device,map,HomePageConstant.SWITCH_ON_OFF); + // 开机状态 + if (Math.abs(value) <= 0) { + return 0; + } + return 1; + } + + /** + * 有功功率 + * @param device + * @return + */ + private float floatValue(EminfoAndEmParamVo device,Map map,String target) { + // 获取有功功率监测点实时数据 + double value = this.getSignageValue(device,map,target); + // 转换float + return Float.parseFloat(String.valueOf(value)); + } + + /** + * 设备状态 + * @param device + * @param map + * @return + */ + private Boolean state(EminfoAndEmParamVo device, Map map) { + if(Math.abs(this.getSignageValue(device,map,HomePageConstant.JOINT_RELAY)) > 0){ + return true; + } + return Math.abs(this.getSignageValue(device, map, HomePageConstant.ACTIVE_POWER)) > 0; + } + + /** + * 近年发电量数据 + * + * @param param 时间 + * @param serveType 站点类型 + * @param year 近几年 + */ + @Override + public void loadPowerData(String param, List types, Integer serveType, int year) { + // 站点查询 + List stationList = stationService.list(new LambdaQueryWrapper() {{ + if (ObjectUtil.isNotEmpty(serveType)) { + eq(StationEntity::getServeType, serveType); + } + if (CollectionUtil.isNotEmpty(types)) { + in(StationEntity::getType, types); + } + }}); + // 设备信息 + List devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_cofig_final).toString(), new TypeReference>() { + }); + // 开始时间 + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH) + 12); + calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1); + String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00"; + // 结束日期 + calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) - year); + calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH)); + String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00"; + // 存储数据map :<站点id,<月份,发电量>> + Map> powerMap = new HashMap<>(); + stationList.forEach(station -> { + // 站点设备集合 + List stationDevices = devices.stream().filter(device -> device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); + log.error("load_power_data station :" + station.getCode() + "==== device :" + stationDevices ); + Map generateMap = this.getGenerateYear(station,stationDevices,start,end); + if(MapUtils.isEmpty(generateMap)){ + return; + } + powerMap.put(station.getId(),generateMap); + }); + redisTemplate.opsForValue().set(recent_year_power_data, powerMap); + } + + + /** + * 当天有功功率 + * @param device + * @return + */ + private List getLoadsByDay(EminfoAndEmParamVo device) { + String start = DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00"; + String end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME); + List records = analyseDataService.periodTargetData(start, end, 3, 2, device.getEmCode(), HomePageConstant.PV_LOAD); + if (CollectionUtil.isEmpty(records)) { + return new ArrayList<>(); + } + return records.stream().map(record -> { + ActivePowerVo load = new ActivePowerVo(); + Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + load.setHour(time.getHours()); + load.setActivePower(Optional.ofNullable(record.getVal()).orElse("0")); + return load; + }).sorted(Comparator.comparing(ActivePowerVo::getHour)).collect(Collectors.toList()); + } + + /** + * 获取年发电量 + * @param devices + * @param start + * @param end + * @return + */ + private Map getGenerateYear(StationEntity station,List devices, String start, String end) { + List datas = new ArrayList<>(); + // 设备采集发电量 + if(CollectionUtil.isNotEmpty(devices)){ + devices.forEach(device->{ + List records = analyseDataService.periodTargetData(start,end,5,5,device.getEmCode(),HomePageConstant.HYDROPOWER_GENERATE_POWER); + if(CollectionUtil.isEmpty(records)){ + return; + } + datas.addAll(records.stream().map(record -> { + PowerMonthVo generate = new PowerMonthVo(); + Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + generate.setStrMonth(DateUtil.format(time,DateUtil.PATTERN_DATE)); + generate.setPower(Float.parseFloat(Optional.ofNullable(record.getVal()).orElse("0")) * device.getRideCount()); + return generate; + }).collect(Collectors.toList())); + }); + } + // 补充填报数据 + datas.addAll(this.generateFill(station,start,end)); + if(CollectionUtil.isEmpty(datas)){ + return null; + } + return datas.stream().collect(Collectors.toMap(PowerMonthVo::getStrMonth, PowerMonthVo::getPower, Float::sum)); + } + + + /** + * 获取填报用电量 + * @param stations + * @return + */ + private List generteFill(List stations) { + Calendar calendar = Calendar.getInstance(); + String day = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE); + String mon = DateUtil.format(calendar.getTime(),"yyyy-MM"); + String year = String.valueOf(calendar.get(Calendar.YEAR)); + return stations.stream().map(station ->{ + HydropowerUnitTargetVo target = new HydropowerUnitTargetVo(); + target.setDeptId(station.getRefDept()); + target.setDeptName(station.getName()); + // 当年发电量 + target.setPowerYear(generateService.generate(year,station.getCode())); + // 当月发电量 + target.setPowerMon(generateService.generate(mon,station.getCode())); + // 当日发电量 + target.setPowerDay(generateService.generate(day,station.getCode())); + // 30天发电量 + target.setGenerationPowerVoList(generateService.generate30Day(day,station.getCode())); + return target; + }).collect(Collectors.toList()); + } + + + /** + * 补充填报数据 + * @param station + * @param start + * @param end + */ + private List generateFill(StationEntity station, String start, String end) { + start = DateUtil.format(DateUtil.parse(start,DateUtil.PATTERN_DATETIME),"yyyy-MM"); + end = DateUtil.format(DateUtil.parse(end,DateUtil.PATTERN_DATETIME),"yyyy-MM"); + // 光伏 + if(HomePageConstant.PHOTOVOLTAIC.equals(station.getType())){ + return powerService.generateThreeYear(start,end,station.getRefDept()); + } + // 水电 + return generateService.generateThreeYear(start,end,station.getCode()); + } + + /** + * 获取开机状态 + * + * @param device + * @return + */ + private int getPhotovoltaicState(EminfoAndEmParamVo device, Map map) { + // 获取开关机监测点实时数据 + Double value = this.getSignageValue(device, map, HomePageConstant.PV_JOINT_RELAY); + // 开机状态 + if (Math.abs(value) <= 0) { + return 0; + } + return 1; + } + + /** + * 获取上一次功率 + * + * @param device + * @param history + * @return + */ + private Double getLastLoad(EminfoAndEmParamVo device, List history) { + if (CollectionUtil.isEmpty(history)) { + return 0.0; + } + List historyDevice = history.stream().filter(o -> o.getDeviceCode().equals(device.getEmCode())).collect(Collectors.toList()); + if (CollectionUtil.isEmpty(historyDevice)) { + return 0.0; + } + return historyDevice.get(0).getLoad(); + } + + /** + * 获取光伏设备 + * + * @return + */ + private List getPhotovoltaicDevice() { + // 光伏站点 + List stations = stationService.list(Wrappers.lambdaQuery() + .eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE) + .eq(StationEntity::getType,HomePageConstant.PHOTOVOLTAIC) + ); + if (CollectionUtil.isEmpty(stations)) { + return new ArrayList<>(); + } + // 设备 + List devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_cofig_final).toString(), new TypeReference>() { + }); + if (CollectionUtil.isEmpty(devices)) { + return new ArrayList<>(); + } + return devices.stream().filter(device -> + stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(device.getCreateDept()) + ).collect(Collectors.toList()); + } + + /** + * 当天运行时长 + * + * @param realId + * @return + */ + private Double runHours(String realId) { + Calendar calendar = Calendar.getInstance(); + Date end = calendar.getTime(); + calendar.add(Calendar.HOUR_OF_DAY, -calendar.get(Calendar.HOUR_OF_DAY)); + calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE)); + calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND)); + Date start = calendar.getTime(); + OriginalDataQuery originalDataQuery = new OriginalDataQuery(); + originalDataQuery.setRealId(realId); + originalDataQuery.setBeginTime(start); + originalDataQuery.setEndTime(end); + originalDataQuery.setLimit(100000); + originalDataQuery.setPage(1); + // 查询时间范围开关机监测点历史数据 + Result> R = historyDataSearchClient.getOriginalDataByRealIds(originalDataQuery); + if (!R.isSuccess() || ObjectUtil.isEmpty(R.getData())) { + return 0.0; + } + // 过滤相邻开关机状态相同数据 + List result = this.getFilterList(R.getData().getRecords()); + if (CollectionUtil.isEmpty(result)) { + return 0.0; + } + // 开机运行时长 + long time = this.getRunTime(result, start, end); + return BigDecimal.valueOf(time / (1000 * 60 * 60.00)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + } + + /** + * 根据事件查询数据值 + * + * @param deviceCode + * @param rideCount + * @param type + * @return + */ + private float sumValueByTime(String deviceCode, int rideCount, String type) { + Calendar calendar = Calendar.getInstance(); + String start, end; + int cycleType = 3; + switch (type) { + //年 + case "0": + calendar.add(Calendar.HOUR_OF_DAY, +1); + end = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATETIME); + calendar.setTime(new Date()); + calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH)); + calendar.add(Calendar.DAY_OF_MONTH, -calendar.get(Calendar.DATE) + 1); + calendar.add(Calendar.HOUR_OF_DAY, -calendar.get(Calendar.HOUR_OF_DAY)); + calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE)); + calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND)); + start = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATETIME); + cycleType = 6; + break; + //月 + case "1": + start = DateUtil.format(new Date(), "yyyy-MM") + "-01 00:00:00"; + end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME); + cycleType = 5; + break; + //日 + case "2": + start = DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00"; + end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME); + break; + //昨日 + case "3": + calendar.add(Calendar.DAY_OF_MONTH, -1); + calendar.add(Calendar.HOUR_OF_DAY, -calendar.get(Calendar.HOUR_OF_DAY)); + calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE)); + calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND)); + start = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATETIME); + end = DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00"; + break; + default: + throw new ServiceException("无效查询类型!"); + } + return analyseDataService.periodTargetFloat(start, end, 5, cycleType, deviceCode, rideCount, HomePageConstant.PV_GENERATION_CAPACITY); + } + + /** + * 当天有功功率 + * + * @param device + * @return + */ + private List photovoltaicLoadsByDay(EminfoAndEmParamVo device) { + String start = DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00"; + String end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME); + List records = analyseDataService.periodTargetData(start, end, 1, 2, device.getEmCode(), HomePageConstant.PV_LOAD); + if (CollectionUtil.isEmpty(records)) { + return new ArrayList<>(); + } + return records.stream().map(record -> { + PhotovoltaicPowerVo load = new PhotovoltaicPowerVo(); + Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + load.setHour(time.getHours()); + load.setActivePower(Optional.ofNullable(record.getVal()).orElse("0")); + return load; + }).sorted(Comparator.comparing(PhotovoltaicPowerVo::getHour)).collect(Collectors.toList()); + } + + /** + * 近30天发电量 + * + * @param device + * @return + */ + private List getGenerateByMon(EminfoAndEmParamVo device) { + Calendar calendar = Calendar.getInstance(); + String end = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATETIME); + calendar.add(Calendar.DAY_OF_MONTH, -29); + calendar.add(Calendar.HOUR_OF_DAY, -calendar.get(Calendar.HOUR_OF_DAY)); + calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE)); + calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND)); + String start = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATETIME); + List records = analyseDataService.periodTargetData(start, end, 5, 3, device.getEmCode(), HomePageConstant.PV_GENERATION_CAPACITY); + if (CollectionUtil.isEmpty(records)) { + return new ArrayList<>(); + } + return records.stream().map(record -> { + GenerationPowerVo generate = new GenerationPowerVo(); + Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + generate.setDate(DateUtil.format(time, DateUtil.PATTERN_DATE)); + generate.setGenerate(Float.valueOf(Optional.ofNullable(record.getVal()).orElse("0"))); + return generate; + }).sorted(Comparator.comparing(GenerationPowerVo::getDate)).collect(Collectors.toList()); + } + + /** + * 获取光伏站点填报数据 + * @param stations + * @return + */ + private List generateFill(List stations) { + Calendar calendar = Calendar.getInstance(); + String mon = DateUtil.format(calendar.getTime(),"yyyy-MM"); + String year = String.valueOf(calendar.get(Calendar.YEAR)); + return stations.stream().map(station ->{ + PhotovoltaicTargetVo target = new PhotovoltaicTargetVo(); + target.setDeptId(station.getRefDept()); + target.setDeptName(station.getName()); + // 当日运行时长 + target.setRunHours(0.0); + // 日发电量 + target.setGenerationDay(0.0); + // 昨日发电量 + target.setGenerationYesterday(0.0); + // 收益 + target.setIncome(0.0); + // 日发电量 + // 月发电量 + target.setGenerationMon(powerService.generate(mon,station.getRefDept())); + // 节约标准煤 + target.setTec(target.getGenerationMon() * 0.0001229); + // 二氧化碳减排 + target.setCo2(target.getGenerationMon() * 0.000997); + // 减少森林砍伐 + target.setDeforest(target.getGenerationMon() * 0.000553); + // 年发电量 + target.setGenerationYear(powerService.generate(year,station.getRefDept())); + // 30天发电量 + return target; + }).collect(Collectors.toList()); + } + + /** + * 泵站设备 + * @param stations + * @return + */ + private List pumpDevices(List stations){ + if(CollectionUtil.isEmpty(stations)){ + return new ArrayList<>(); + } + List devices = null; + Object json = redisTemplate.opsForValue().get(device_cache_cofig_final); + if (ObjectUtil.isNotEmpty(json)) { + devices = JSONObject.parseObject(json.toString(),new TypeReference>() {}); + } + if(CollectionUtil.isEmpty(devices)){ + return new ArrayList<>(); + } + return devices.stream().filter(device->stations.contains(device.getCreateDept())).collect(Collectors.toList()); + } + + /** + * 获取实时数据 + * @return + */ + private Map getRealMap() { + String json = (String) redisTemplate.opsForValue().get(real_id_cofig_final); + if(StringUtil.isBlank(json)){ + return null; + } + return JSONObject.parseObject(json, new TypeReference>() {}); + } + + + /** + * 获取监测点实时数据 + * @param device + * @param targets + * @return + */ + private double getSignageValue(EminfoAndEmParamVo device,Map map, String targets) { + if(ObjectUtil.isEmpty(device) || MapUtils.isEmpty(map)){ + return 0.0; + } + Map point = device.getPoint(); + if(MapUtils.isEmpty(point)){ + return 0.0; + } + String realId = point.get(targets); + if(StringUtil.isBlank(realId)){ + return 0.0; + } + String value = map.get(realId); + if(StringUtil.isBlank(value)){ + return 0.0; + } + // 获取value + return Double.parseDouble(value); + } + + /** + * 单位设置 + * @param device + * @param unitMap + * @param realVo + */ + private void setttingUnit(EminfoAndEmParamVo device, Map unitMap, HydropowerUnitRealVo realVo) { + if(MapUtils.isEmpty(unitMap)){ + return; + } + // 有功功率单位 + String power = unitMap.get(device.getId()+HomePageConstant.CONCAT_P); + if(StringUtil.isNotBlank(power)){ + realVo.setPowerUnit(power); + } else { + realVo.setPowerUnit("kW"); + } + // 无功功率 + String reactivePowerUnit = unitMap.get(device.getId()+HomePageConstant.CONCAT_Q); + if(StringUtil.isNotBlank(reactivePowerUnit)){ + realVo.setReactivePowerUnit(reactivePowerUnit); + } else { + realVo.setReactivePowerUnit("kVa r"); + } + // 定子电压单位 + String voltage = unitMap.get(device.getId()+HomePageConstant.CONCAT_UAB); + if(StringUtil.isNotBlank(voltage)){ + realVo.setVoltageUnit(voltage); + } else { + realVo.setVoltageUnit("V"); + } + // 定子电流单位 + String current = unitMap.get(device.getId()+HomePageConstant.CONCAT_IA); + if(StringUtil.isNotBlank(current)){ + realVo.setCurrentUnit(current); + } else { + realVo.setCurrentUnit("A"); + } + } + + /** + * 获取年、月、日发电量 + * @param device + * @param scope + * @return + */ + private float getGenerationPower(EminfoAndEmParamVo device,int scope) { + String start,end; + int accessRules; + Calendar calendar = Calendar.getInstance(); + switch (scope){ + // 年 + case 0: + end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); + calendar.setTime(new Date()); + calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH)); + calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1); + start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00"; + accessRules = EquipmentConstants.CycleTypeEnum.YEAR_CYCLE.getType(); + break; + // 月 + case 1: + start = DateUtil.format(new Date(), "yyyy-MM") + "-01 00:00:00"; + end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME); + accessRules = EquipmentConstants.CycleTypeEnum.MONTH_CYCLE.getType(); + break; + // 日 + case 2: + String time = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE); + start = time + " 00:00:00"; + end = time + " 23:59:59"; + accessRules = EquipmentConstants.CycleTypeEnum.DAY_CYCLE.getType(); + break; + default: + throw new IllegalStateException("Unexpected value: " + scope); + } + return analyseDataService.periodTargetFloat(start,end,5,accessRules,device.getEmCode(),device.getRideCount(),HomePageConstant.HYDROPOWER_GENERATE_POWER); + } + + /** + * 近30天发电量 + * @param device + * @return + */ + private List getGenerationPowerList(EminfoAndEmParamVo device) { + String start = DateUtil.format(new Date(), "yyyy-MM") + "-01 00:00:00"; + String end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME); + List records = analyseDataService.periodTargetData(start,end,5,EquipmentConstants.CycleTypeEnum.DAY_CYCLE.getType(),device.getEmCode(),HomePageConstant.HYDROPOWER_GENERATE_POWER); + if(CollectionUtil.isEmpty(records)){ + return new ArrayList<>(); + } + return records.stream().map(record -> { + GenerationPowerVo generate = new GenerationPowerVo(); + Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + generate.setDate(DateUtil.format(time,DateUtil.PATTERN_DATE)); + generate.setGenerate(Float.parseFloat(Optional.ofNullable(record.getVal()).orElse("0")) * device.getRideCount()); + return generate; + }).collect(Collectors.toList()); + } +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/impl/StAlamRecordServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/RecordServiceImpl.java similarity index 63% rename from hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/impl/StAlamRecordServiceImpl.java rename to hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/RecordServiceImpl.java index 06d1fd0..d5489b8 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/impl/StAlamRecordServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/RecordServiceImpl.java @@ -1,8 +1,8 @@ -package com.hnac.hzims.scheduled.service.impl; +package com.hnac.hzims.scheduled.service.operation.impl; import com.hnac.hzims.operational.config.entity.StAlarmRecordEntity; -import com.hnac.hzims.scheduled.mapper.operation.StAlarmRecordMapper; -import com.hnac.hzims.scheduled.service.StAlamRecordService; +import com.hnac.hzims.scheduled.mapper.operation.RecordMapper; +import com.hnac.hzims.scheduled.service.operation.RecordService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.mp.base.BaseServiceImpl; @@ -11,16 +11,12 @@ import org.springframework.stereotype.Service; import java.util.Date; /** - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/5/19 15:46 + * @author ysj */ @Service @RequiredArgsConstructor @Slf4j -public class StAlamRecordServiceImpl extends BaseServiceImpl implements StAlamRecordService { - +public class RecordServiceImpl extends BaseServiceImpl implements RecordService { /** * 添加告警 @@ -35,8 +31,6 @@ public class StAlamRecordServiceImpl extends BaseServiceImpl> R = sysClient.getDeptList(); + if (!R.isSuccess() || CollectionUtil.isEmpty(R.getData())) { + return; + } + // 查询所有服务类型——"运维服务"、站点类型——"水电站" + List stations = stationService.list(Wrappers.lambdaQuery() + .eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE) + .eq(StationEntity::getType,HomePageConstant.HYDROPOWER) + ); + if (CollectionUtil.isEmpty(stations)) { + return; + } + // 站点近年发电数据 + Map> powerMap = (Map>) redisTemplate.opsForValue().get(recent_year_cache_final); + // 存储数据节点 key - 月份 value - 区域数据集合 + Map> map = new HashMap<>(); + // 月份集合 + List monthList = getMonthList(year, Calendar.getInstance().get(Calendar.MONTH)); + monthList.forEach(mon -> { + List list = this.getAreaReportByMon(R.getData(), powerMap, stations, mon); + if (CollectionUtil.isEmpty(list)) { + return; + } + map.put(mon, list); + }); + // 推送当月报表邮件 + this.sendMonthReport(map, R.getData()); + redisTemplate.opsForValue().set(report_month_cache_final, map); + } + + /** + * 获取近年月份集合 + * + * @param year + * @return + */ + public static List getMonthList(int year, int endMoth) { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM"); + // 开始日期 + Calendar endCal = Calendar.getInstance(); + endCal.setTime(new Date()); + endCal.add(Calendar.MONTH, -endCal.get(Calendar.MONTH) + endMoth); + endCal.add(Calendar.DATE, -endCal.get(Calendar.DATE) + 1); + + // 结束日期 + Calendar startCal = Calendar.getInstance(); + startCal.setTime(new Date()); + startCal.set(Calendar.YEAR, startCal.get(Calendar.YEAR) - year); + startCal.add(Calendar.MONTH, -startCal.get(Calendar.MONTH)); + startCal.add(Calendar.DATE, -startCal.get(Calendar.DATE) + 1); + // 获取日期之间的月份 + List list = new ArrayList<>(); + while (endCal.after(startCal)) { + list.add(format.format(startCal.getTime())); + startCal.add(Calendar.MONTH, 1); + } + list.add(format.format(endCal.getTime())); + return list; + } + + /** + * 区域月报数据加载 + * @param deptList + * @param powerMap + * @param stationList + * @param mon + * @return + */ + private List getAreaReportByMon(List deptList, Map> powerMap, List stationList, String mon) { + LocalDateTime startTime = LocalDateTime.parse(mon + "-01 00:00:00", DateUtil.DATETIME_FORMATTER); + LocalDateTime endTime = getEndTime(mon); + // 查询所有站点的计划发电量 + List planList = this.planPower(stationList, mon); + // 站点实际发电量 + Map actualMap = this.actualPower(powerMap, stationList, mon + "-01"); + // 站点去年发电量 + Map oldActualMap = this.actualPower(powerMap, stationList, lastyear(1,mon)); + // 站点前发电量 + Map oldOldActualMap = this.actualPower(powerMap, stationList, lastyear(2,mon)); + // 取机构中区域部分 + List areaList = deptList.stream().filter(o -> o.getDeptCategory().equals(3)).collect(Collectors.toList()); + if (CollectionUtil.isEmpty(areaList)) { + return null; + } + List areaMonthReportVoList = new ArrayList<>(); + areaList.forEach(area -> { + AreaMonthReportVo areaMonthReport = new AreaMonthReportVo(); + areaMonthReport.setAreaId(area.getId()); + areaMonthReport.setAreaName(area.getDeptName()); + // 获取区域下的站点 + List stationIdList = deptList.stream().filter(o -> o.getParentId().equals(area.getId()) && o.getDeptCategory().equals(4)).map(Dept::getId).collect(Collectors.toList()); + List areaStationList = stationList.stream().filter(o -> stationIdList.contains(o.getRefDept())).collect(Collectors.toList()); + if (CollectionUtil.isEmpty(areaStationList)) { + return; + } + // 计划发电量、实际发电量、发电完成率 + this.powerMonth(planList, actualMap, oldActualMap, areaStationList, areaMonthReport); + // 操作票、操作票合格率/ 工作票、工作票合格率 + this.doubleMonth(area, areaMonthReport, mon + "-01 00:00:00", this.strEndTime(mon)); + // 日常维护、巡检任务、缺陷数、消缺率、检修任务 + this.taskMonth(Collections.singletonList(area.getId()), areaMonthReport, mon + "-01 00:00:00", strEndTime(mon)); + // 预测 + this.predictPlanPower(oldActualMap,oldOldActualMap,areaStationList,areaMonthReport); + // 安全生产会议次数、月度检查报告、技能培训、安全大检查 + this.securityCheck(Collections.singletonList(area.getId()),areaMonthReport,mon + "-01 00:00:00", strEndTime(mon)); + // 设备试验 + this.getDeviceTry(mon + "-01 00:00:00", strEndTime(mon), Collections.singletonList(area.getId()),areaMonthReport); + areaMonthReportVoList.add(areaMonthReport); + }); + return areaMonthReportVoList; + } + + /** + * 获取结束时间 + */ + private LocalDateTime getEndTime(String mon) { + Date date = DateUtil.parse(mon + "-01 00:00:00",DateUtil.DATETIME_FORMAT); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + calendar.add(Calendar.MONTH, 1); + return calendar.getTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); + } + + /** + * 获取站点计划发电量 + */ + private List planPower(List stationList, String mon) { + List list = stationList.stream().map(StationEntity::getCode).collect(Collectors.toList()); + return planService.planGeneration(list, null, mon); + } + + /** + * 获取站点月份实际发电量 + */ + private Map actualPower(Map> powerMap, List stationList, String month) { + if (MapUtils.isEmpty(powerMap)) { + return null; + } + // 站点Id集合 + List stationIdList = stationList.stream().map(StationEntity::getId).collect(Collectors.toList()); + // 存储站点实际发电量 + Map actualPowerMap = new HashMap<>(); + stationIdList.forEach(key -> { + Map monthMap = powerMap.get(key); + if (MapUtils.isEmpty(monthMap)) { + return; + } + float actualPower = 0f; + if(ObjectUtil.isNotEmpty(monthMap.get(month))){ + actualPower = monthMap.get(month); + } + actualPowerMap.put(key, actualPower); + }); + return actualPowerMap; + } + + /** + * 获取去年时间 + */ + private String lastyear(int year,String mon) { + Date date = DateUtil.parse(mon + "-01 00:00:00",DateUtil.DATETIME_FORMAT); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) - year); + calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1); + return DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE); + } + + /** + * 获取结束时间 + */ + private String strEndTime(String mon) { + Date date = DateUtil.parse(mon + "-01 00:00:00",DateUtil.DATETIME_FORMAT); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + calendar.add(Calendar.MONTH, 1); + return DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE); + } + + /** + * 区域-月计划发电量、月实际发电量、月发电完成率、同比 + * + * @param planList + * @param actualMap + * @param oldActualMap + * @param areaStationList + * @param areaMonthReport + */ + private void powerMonth(List planList, Map actualMap, Map oldActualMap, List areaStationList, AreaMonthReportVo areaMonthReport) { + // 计划发电量 + List codeList = areaStationList.stream().map(StationEntity::getCode).collect(Collectors.toList()); + double planPower = planList.stream().filter(o -> codeList.contains(o.getStationId())).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum(); + areaMonthReport.setPlanPower(Float.parseFloat(String.valueOf(planPower))); + if (MapUtils.isEmpty(actualMap)) { + areaMonthReport.setActualPower(0f); + areaMonthReport.setPowerFinishRate(0.0); + return; + } + // 实际发电量 + List ids = areaStationList.stream().map(StationEntity::getId).collect(Collectors.toList()); + double actualPower = actualMap.entrySet().stream().filter(e -> ids.contains(e.getKey())).mapToDouble(Map.Entry::getValue).sum(); + areaMonthReport.setActualPower(Float.parseFloat(String.valueOf(actualPower))); + if (Math.abs(planPower) <= 0) { + areaMonthReport.setPowerFinishRate(0.0); + } else { + // 发电完成率 + double powerFinishRate = BigDecimal.valueOf(actualPower / planPower * 100).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue(); + areaMonthReport.setPowerFinishRate(powerFinishRate); + } + // 同比 + double oldActualPower = oldActualMap.entrySet().stream().filter(e -> ids.contains(e.getKey())).mapToDouble(Map.Entry::getValue).sum(); + if (Math.abs(actualPower) <= 0 || Math.abs(oldActualPower) <= 0) { + areaMonthReport.setComparePowerRate(0.0); + return; + } + double comparePowerRate = BigDecimal.valueOf(actualPower / oldActualPower).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + areaMonthReport.setComparePowerRate(comparePowerRate); + } + + /** + * 区域-操作票、操作票合格率/ 工作票、工作票合格率 + * + * @param area + * @param areaMonthReport + */ + private void doubleMonth(Dept area, AreaMonthReportVo areaMonthReport, String startTime, String endTime) { + // 站点归属机构集合 + TicketMonthVO ticket = ticketService.operateWork(startTime,endTime,Collections.singletonList(area.getId())); + if (ObjectUtil.isEmpty(ticket)) { + areaMonthReport.setOperate(0); + areaMonthReport.setOperaQualifyRate(0.0); + areaMonthReport.setWork(0); + areaMonthReport.setWorkQualifyRate(0.0); + return; + } + // 操作票 + int operate = ticket.getOperate(); + int operateQualify = ticket.getOperateQualify(); + areaMonthReport.setOperate(operate); + if (operateQualify <= 0) { + areaMonthReport.setOperaQualifyRate(0.0); + } else { + double operateQualifyRate = BigDecimal.valueOf(operateQualify / (double) operate * 100L).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue(); + areaMonthReport.setOperaQualifyRate(operateQualifyRate); + } + //工作票 + int work = ticket.getWork(); + int workQualify = ticket.getWorkQualify(); + areaMonthReport.setWork(work); + if (workQualify <= 0) { + areaMonthReport.setWorkQualifyRate(0.0); + } else { + double workQualifyRate = BigDecimal.valueOf(workQualify / (double) work * 100L).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue(); + areaMonthReport.setWorkQualifyRate(workQualifyRate); + } + } + + /** + * 任务月报-日常维护、巡检任务、缺陷数、消缺率、检修任务 + * + * @param areas + * @param areaMonthReport + */ + private void taskMonth(List areas, AreaMonthReportVo areaMonthReport, String startTime, String endTime) { + //通过线程池异步获取月报各模块内容 主要分为五块内容 + ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("area_month_report-pool-%d").build(); + ExecutorService exe = new ThreadPoolExecutor(4, 4, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy()); + //监控线程执行完后返回结果 + CountDownLatch countDownLatch = new CountDownLatch(4); + // 日常维护 + exe.execute(() -> { + MaintainVo maintainVo = maintenanceService.maintain(startTime, endTime, areas); + int maintainSum = maintainVo.getMaintain(); + areaMonthReport.setRoutineMaintenance(maintainSum); + countDownLatch.countDown(); + }); + + // 巡检任务 + exe.execute(() -> { + DutyInspectTaskVO task = taskService.task(startTime,endTime,areas); + if (ObjectUtil.isEmpty(task)) { + areaMonthReport.setInspect(0); + } else { + int inspect = task.getInspectTaskSum(); + areaMonthReport.setInspect(inspect); + } + countDownLatch.countDown(); + }); + + // 消缺 + exe.execute(() -> { + DutyDefectVO defectVO = phenomenonService.defect(startTime, endTime, areas); + int defectSum = defectVO.getDefectSum(); + int defect = defectVO.getDefect(); + areaMonthReport.setDefect(defectSum); + if (defectSum <= 0) { + areaMonthReport.setDefectRate(0.0); + } else { + double deletionRate = BigDecimal.valueOf(defect / defectSum * 100L).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue(); + areaMonthReport.setDefectRate(deletionRate); + } + countDownLatch.countDown(); + }); + + // 检修 + exe.execute(() -> { + OverhaulVo overhaulVo = accessService.overhaul(startTime, endTime, areas); + int overhaul = overhaulVo.getOverhaul(); + areaMonthReport.setMaintenanceTasks(overhaul); + countDownLatch.countDown(); + }); + + //所有模板数据获取完成后释放锁 + try { + countDownLatch.await(); + } catch (InterruptedException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); + } + exe.shutdown(); + } + + /** + * 预测发电量 + * @param oldActualMap + * @param oldOldActualMap + * @param areaStationList + * @param areaMonthReport + */ + private void predictPlanPower(Map oldActualMap, Map oldOldActualMap, List areaStationList, AreaMonthReportVo areaMonthReport) { + areaMonthReport.setPredictPlanPower(0.0); + // 实际发电量 + List ids = areaStationList.stream().map(StationEntity::getId).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(ids)){ + return; + } + 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(); + if(Math.abs(oldActualPower) <= 0 && Math.abs(oldOldActualPower) <= 0 ){ + return; + } + double predictPlanPower = BigDecimal.valueOf((oldActualPower + oldOldActualPower) / 2).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + areaMonthReport.setPredictPlanPower(predictPlanPower); + } + + /** + * 安全检查 + * @param areas + * @param areaMonthReport + * @param startTime + * @param endTime + */ + private void securityCheck(List areas, AreaMonthReportVo areaMonthReport,String startTime,String endTime) { + areaMonthReport.setSafetyMeeting(0); + areaMonthReport.setSelfReport(0); + areaMonthReport.setSkillTrainy(0); + areaMonthReport.setSecurityCheck(0); + // 站点归属机构集合 + Map map = new HashMap<>(); + map.put("startDate", startTime); + map.put("endDate", endTime); + map.put("deptList", areas); + // 调用安全大检查fegin接口 + Map count = monthService.check(map); + if(MapUtils.isEmpty(count)){ + return; + } + // 安全生产会议 + areaMonthReport.setSafetyMeeting((Integer) count.get("safetyMeetingNum")); + // 月度自查报告 + areaMonthReport.setSelfReport((Integer) count.get("monthCheckNum")); + // 技能培训 + areaMonthReport.setSkillTrainy((Integer) count.get("skillsTrainingNum")); + // 安全大检查 + areaMonthReport.setSecurityCheck((Integer) count.get("bigCheckNum")); + } + + /** + * 获取设备试验数据 + * @param startTime + * @param endTime + * @param areas + * @param areaMonthReport + */ + private void getDeviceTry(String startTime,String endTime,List areas,AreaMonthReportVo areaMonthReport) { + areaMonthReport.setDeviceTry(0); + SafeEquipmentTrialDTO request = new SafeEquipmentTrialDTO(); + request.setDeptList(areas); + request.setStartTime(startTime); + request.setEndTime(endTime); + areaMonthReport.setDeviceTry(trialService.count(request)); + } + + /** + * 推送当月月报 + * + * @param map + * @param list + */ + private void sendMonthReport(Map> map, List list) { + if (MapUtils.isEmpty(map) || CollectionUtil.isEmpty(list)) { + return; + } + // 获取邮件接收人 + Dept dept = list.stream().min(Comparator.comparing(Dept::getDeptCategory)).get(); + if(ObjectUtil.isEmpty(dept)){ + return; + } + R> userR = userClient.userListByDeptId(dept.getId()); + if(!userR.isSuccess() && CollectionUtil.isEmpty(userR.getData())){ + return; + } + List userList = userR.getData().stream().filter(o->dept.getId().equals(o.getCreateDept())).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(userList)){ + return; + } + List mailList = userList.stream().map(User::getEmail).filter(StringUtil::isNotBlank).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(mailList)){ + return; + } + // 获取月报数据 + List entityList = map.get(DateUtil.format(new Date(),"yyyy-MM")); + if (CollectionUtil.isEmpty(entityList)) { + return; + } + // 发送邮件 + MailPushDto pushDto = new MailPushDto(); + pushDto.setBusinessClassify("system"); + pushDto.setBusinessKey("Month_Report"); + pushDto.setSubject("水电站生产运行"); + Map param = new HashMap<>(); + param.put("templatePath", "/data/hzims/message/mail/template/stationRunMonthReport.html"); + Map parameters = new HashMap<>(); + parameters.put("data",entityList); + param.put("parameters", parameters); + pushDto.setExtras(param); + pushDto.setText("水电站生产运行月报内容"); + pushDto.setToAccount(mailList.toArray(new String[0])); + pushDto.setHtml(true); + pushDto.setCreateUser(userR.getData().get(0).getCreateUser()); + pushDto.setTenantId(dept.getTenantId()); + pushDto.setCreateDept(dept.getId()); + pushMsgClient.sendMail(pushDto); + } +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/ShowServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/ShowServiceImpl.java new file mode 100644 index 0000000..5d87218 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/ShowServiceImpl.java @@ -0,0 +1,480 @@ +package com.hnac.hzims.scheduled.service.operation.impl; + +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.google.common.util.concurrent.ThreadFactoryBuilder; +import com.hnac.hzims.equipment.entity.PlanGenerationEntity; +import com.hnac.hzims.operational.fill.entity.*; +import com.hnac.hzims.operational.main.constant.HomePageConstant; +import com.hnac.hzims.operational.main.vo.*; +import com.hnac.hzims.operational.station.entity.StationEntity; +import com.hnac.hzims.scheduled.service.equipment.PlanService; +import com.hnac.hzims.scheduled.service.operation.*; +import com.hnac.hzims.scheduled.service.ticket.TicketService; +import com.hnac.hzims.ticket.allTicket.vo.DoublePassRateVO; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.DateUtil; +import org.springblade.core.tool.utils.ObjectUtil; +import org.springblade.core.tool.utils.StringUtil; +import org.springblade.system.cache.DictCache; +import org.springblade.system.entity.Dept; +import org.springblade.system.feign.ISysClient; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.math.BigDecimal; +import java.net.HttpURLConnection; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.util.Date; +import java.util.List; +import java.util.concurrent.*; +import java.util.stream.Collectors; + +/** + * @author ysj + */ +@Service +@RequiredArgsConstructor +@Slf4j +public class ShowServiceImpl implements ShowService { + + private final OverService overService; + private final PlanService planService; + private final PowerService powerService; + private final SolveService solveService; + private final OtherService otherService; + private final AccessService accessService; + private final TicketService ticketService; + private final DefectService defectService; + private final StationService stationService; + private final OverDetailsService detailsService; + private final MaintenanceService maintenanceService; + private final RedisTemplate redisTemplate; + private final ISysClient sysClient; + + + private final static String charge = "hzims:operation:key:charge"; + private final static String home_target_cache_final = "load:operation:home:target:key"; + private final static String hydropower_real_cache_final = "hzims:operation:loadhydropowerunit:real:key"; + private final static String hydropower_target_cache_final = "hzims:operation:loadhydropowerunit:target:key"; + private final static String photovoltaic_real_cache_final = "hzims:operation:photovoltaic:real:key"; + private final static String photovoltaic_target_cache_final = "hzims:operation:photovoltaic:target:key"; + + @Value("${hzims.operation.homePage.charge.url}") + public String charge_url; + + /** + * 集团总指标-首页数据 + */ + @Override + public void loadHomeTarget(String param) { + List targets = HomePageConstant.HOME_TYPES.stream().map(type->{ + if(type == 0) { + return this.hydropowerTaget(); + } + if (type == 1) { + return this.windTaget(); + } + if (type == 2) { + return this.waterStorageTaget(true); + } + if (type == 3) { + return this.waterStorageTaget(false); + } + if (type == 4) { + return this.networkTaget(); + } + if (type == 5) { + return this.photovoltaicTaget(); + } + if (type == 6) { + return this.affairsTaget(); + } + if(type == 7) { + return this.chargeTarget(); + } + return new TargetVo(); + }).collect(Collectors.toList()); + redisTemplate.opsForValue().set(home_target_cache_final,targets.stream().filter(( target -> ObjectUtil.isNotEmpty(target.getType()))).collect(Collectors.toList())); + } + + /** + * 水电站指标 + * @return + */ + private TargetVo hydropowerTaget() { + TargetVo target = new TargetVo(); + target.setType(HomePageConstant.HYDROPOWER); + target.setTypeName(DictCache.getValue("stationType", HomePageConstant.HYDROPOWER)); + // 实时数据 + List reals = (List) redisTemplate.opsForValue().get(hydropower_real_cache_final); + // 指标数据 + List targets = (List) redisTemplate.opsForValue().get(hydropower_target_cache_final); + if(CollectionUtil.isNotEmpty(reals)){ + // 装机容量 + target.setTaget_one(reals.stream().mapToDouble(HydropowerUnitRealVo::getInstalledCapacity).sum()); + } + if(CollectionUtil.isNotEmpty(targets)){ + // 发电量 + target.setTaget_two(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum()); + } + // 计划发电量 + List stations = stationService.list(Wrappers.lambdaQuery() + .eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE) + .eq(StationEntity::getType,HomePageConstant.HYDROPOWER)); + if(CollectionUtil.isNotEmpty(stations)){ + List plans = planService.planGeneration(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()), null, DateUtil.format(new Date(), "yyyy")); + if(CollectionUtil.isNotEmpty(plans)){ + double plan = plans.stream().mapToDouble(PlanGenerationEntity::getPlanGeneration).sum(); + if(Math.abs(plan) > 0){ + target.setTaget_three(BigDecimal.valueOf(target.getTaget_two() / plan * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); + } + } + } + // 双票合格率 + R> result = sysClient.getDeptList(); + if(result.isSuccess() && CollectionUtil.isNotEmpty(result.getData()) && CollectionUtil.isNotEmpty(stations)){ + List areas = result.getData().stream().filter(dept -> stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(dept.getId())).map(Dept::getParentId).collect(Collectors.toList()); + if(CollectionUtil.isNotEmpty(areas)){ + LocalDateTime firstDateTime = LocalDateTime.of(LocalDate.now().withDayOfYear(1), LocalTime.MIN); + DoublePassRateVO pass = ticketService.doublePassRate(areas, firstDateTime, LocalDateTime.now()); + if(ObjectUtil.isNotEmpty(pass)){ + target.setTaget_four(Double.valueOf(pass.getDoublePassRate())); + } + } + } + return target; + } + + /** + * 风电指标 + * @return + */ + private TargetVo windTaget() { + TargetVo target = new TargetVo(); + target.setType(HomePageConstant.WIND_POWER); + target.setTypeName(DictCache.getValue("stationType", HomePageConstant.WIND_POWER)); + // 填报发电量 + List stations = stationService.list(Wrappers.lambdaQuery() + .eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE) + .eq(StationEntity::getType,HomePageConstant.WIND_POWER)); + if(CollectionUtil.isEmpty(stations)){ + return target; + } + QueryWrapper queryWrapper = new QueryWrapper() {{ + in("create_dept", stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList())); + eq("type", HomePageConstant.WIND_POWER_TYPE); + likeRight("mon", DateUtil.format(new Date(),"yyyy")); + }}; + List list = powerService.list(queryWrapper); + if(CollectionUtil.isEmpty(list)){ + return target; + } + double plan = list.stream().mapToDouble(PowerEntity::getPlannedPowerMon).sum(); + double pass = list.stream().mapToDouble(power -> Double.parseDouble(power.getDoubleQualifyRate())).sum(); + // 装机容量 + target.setTaget_one(list.stream().map(PowerEntity::getInstalledCapacity).collect(Collectors.toSet()).stream().mapToDouble(Double::valueOf).sum()); + // 发电量 + target.setTaget_two(list.stream().mapToDouble(PowerEntity::getPowerMon).sum()); + if(Math.abs(plan) > 0){ + // 发电完成率 + target.setTaget_three(BigDecimal.valueOf(target.getTaget_two() / plan * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); + } + // 双票合格率 + target.setTaget_four(BigDecimal.valueOf(pass / list.size()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); + return target; + } + + /** + * 储能指标 + * @param flag : true - 水利 false - 储能 + * @return + */ + private TargetVo waterStorageTaget(boolean flag) { + TargetVo target = new TargetVo(); + if(flag){ + target.setType(HomePageConstant.WATER_CONSERVANCY); + target.setTypeName(DictCache.getValue("stationType", HomePageConstant.WATER_CONSERVANCY)); + }else{ + target.setType(HomePageConstant.ENERGY_STORAGE); + target.setTypeName(DictCache.getValue("stationType", HomePageConstant.ENERGY_STORAGE)); + } + // 查询储能站点 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE); + if(flag){ + wrapper.eq(StationEntity::getType,HomePageConstant.WATER_CONSERVANCY); + }else{ + wrapper.eq(StationEntity::getType,HomePageConstant.ENERGY_STORAGE); + } + List stations = stationService.list(wrapper); + if(CollectionUtil.isEmpty(stations)){ + return target; + } + // 获取储能区域级别机构 + R> result = sysClient.getDeptList(); + if(result.isSuccess() && CollectionUtil.isNotEmpty(result.getData()) && CollectionUtil.isNotEmpty(stations)){ + List areas = result.getData().stream().filter(dept -> stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(dept.getId())).map(Dept::getParentId).collect(Collectors.toList()); + if(CollectionUtil.isNotEmpty(areas)){ + ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("storage-taget-pool-%d").build(); + ScheduledExecutorService exe = new ScheduledThreadPoolExecutor(4, namedThreadFactory, new ThreadPoolExecutor.AbortPolicy()); + // 监控线程执行完后返回结果 + CountDownLatch countDownLatch = new CountDownLatch(4); + // 日常维护 + exe.execute(() -> { + target.setTaget_one(Double.valueOf(maintenanceService.maintenanceCount(areas))); + countDownLatch.countDown(); + }); + // 检修任务 + exe.execute(() -> { + target.setTaget_two(accessService.accessCount(areas)); + countDownLatch.countDown(); + }); + // 消缺率 + exe.execute(() -> { + target.setTaget_three(defectService.defectCount(areas)); + countDownLatch.countDown(); + }); + // 双票合格率 + exe.execute(() -> { + LocalDate firstDay = LocalDate.now().withDayOfYear(1); + LocalDateTime firstDateTime = LocalDateTime.of(firstDay, LocalTime.MIN); + DoublePassRateVO pass = ticketService.doublePassRate(areas, firstDateTime, LocalDateTime.now()); + if (ObjectUtil.isNotEmpty(pass)) { + target.setTaget_four(Double.valueOf(pass.getDoublePassRate())); + } + countDownLatch.countDown(); + }); + try { + countDownLatch.await(); + } catch (InterruptedException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); + } + exe.shutdown(); + } + } + return target; + } + + /** + * 配网 + * @return + */ + private TargetVo networkTaget() { + TargetVo target = new TargetVo(); + target.setType(HomePageConstant.DISTRIBUTION_NETWORK); + target.setTypeName(DictCache.getValue("stationType", HomePageConstant.DISTRIBUTION_NETWORK)); + // 线程池 + ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("network-taget-pool-%d").build(); + ScheduledExecutorService exe = new ScheduledThreadPoolExecutor(3, namedThreadFactory, new ThreadPoolExecutor.AbortPolicy()); + // 监控线程执行完后返回结果 + CountDownLatch countDownLatch = new CountDownLatch(3); + // 当月 + LocalDate firstDay = LocalDate.now().withDayOfYear(1); + LocalDateTime firstDateTime = LocalDateTime.of(firstDay, LocalTime.MIN); + // 检修卡 + exe.execute(()->{ + List overs = overService.list(new QueryWrapper() {{ + ge("create_time", firstDateTime); + le("create_time", LocalDateTime.now()); + }}); + if(CollectionUtil.isEmpty(overs)){ + countDownLatch.countDown(); + return; + } + List details = detailsService.list(new QueryWrapper() {{ + ge("create_time", firstDateTime); + le("create_time", LocalDateTime.now()); + in("over_id",overs.stream().map(OverEntity::getId).collect(Collectors.toList())); + }}); + if(CollectionUtil.isEmpty(details)){ + countDownLatch.countDown(); + return; + } + target.setTaget_one(details.stream().mapToDouble(OverDetailsEntity::getQuantity).sum()); + countDownLatch.countDown(); + }); + // 消缺 + exe.execute(()->{ + List solves = solveService.list(new QueryWrapper() {{ + ge("create_time", firstDateTime); + le("create_time", LocalDateTime.now()); + }}); + if(CollectionUtil.isEmpty(solves)){ + countDownLatch.countDown(); + return; + } + target.setTaget_two(solves.stream().mapToDouble(SolveEntity::getSolveQuantity).sum()); + countDownLatch.countDown(); + }); + // 其他 + exe.execute(()->{ + List others = otherService.list(new QueryWrapper() {{ + ge("create_time", firstDateTime); + le("create_time", LocalDateTime.now()); + }}); + if(CollectionUtil.isEmpty(others)){ + countDownLatch.countDown(); + return; + } + // FA上线率 + double online = others.stream().mapToDouble(o-> Double.parseDouble(o.getOnlineRate())).sum(); + if(Math.abs(online) > 0){ + target.setTaget_three(BigDecimal.valueOf(online / others.size()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); + } + // FA投入条数 + target.setTaget_four(others.stream().mapToDouble(OtherEntity::getFaQuantity).sum()); + countDownLatch.countDown(); + }); + // 等待所有线程执行完成 + try { + countDownLatch.await(); + } catch (InterruptedException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); + } + return target; + } + + /** + * 光伏指标 + * @return + */ + private TargetVo photovoltaicTaget() { + TargetVo target = new TargetVo(); + target.setType(HomePageConstant.PHOTOVOLTAIC); + target.setTypeName(DictCache.getValue("stationType", HomePageConstant.PHOTOVOLTAIC)); + // 实时数据 + List reals = (List) redisTemplate.opsForValue().get(photovoltaic_real_cache_final); + // 指标数据 + List targets = (List) redisTemplate.opsForValue().get(photovoltaic_target_cache_final); + if(CollectionUtil.isNotEmpty(reals)){ + // 装机容量 + target.setTaget_one(reals.stream().mapToDouble(PhotovoltaicRealVo::getCapacity).sum()); + } + if(CollectionUtil.isNotEmpty(targets)){ + // 发电量 + target.setTaget_two(targets.stream().mapToDouble(PhotovoltaicTargetVo::getGenerationYear).sum()); + } + // 计划发电量、双票合格率 + List stations = stationService.list(Wrappers.lambdaQuery() + .eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE) + .eq(StationEntity::getType,HomePageConstant.PHOTOVOLTAIC)); + if(CollectionUtil.isNotEmpty(stations)){ + QueryWrapper queryWrapper = new QueryWrapper() {{ + in("create_dept", stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList())); + eq("type", HomePageConstant.PHOTOVOLTAIC_TYPE); + likeRight("mon", DateUtil.format(new Date(),"yyyy")); + }}; + List list = powerService.list(queryWrapper); + if(CollectionUtil.isEmpty(list)){ + return target; + } + double plan = list.stream().mapToDouble(PowerEntity::getPlannedPowerMon).sum(); + double pass = list.stream().mapToDouble(power -> Double.parseDouble(power.getDoubleQualifyRate())).sum(); + if(Math.abs(plan) > 0){ + // 发电完成率 + target.setTaget_three(BigDecimal.valueOf(target.getTaget_two() / plan * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); + } + // 双票合格率 + target.setTaget_four(BigDecimal.valueOf(pass / list.size()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); + } + return target; + } + + /** + * 水务指标 + * @return + */ + private TargetVo affairsTaget() { + TargetVo target = new TargetVo(); + target.setType(HomePageConstant.WATER_AFFAIRS); + target.setTypeName(DictCache.getValue("stationType", HomePageConstant.WATER_AFFAIRS)); + // TODO 统计业务数据 + return target; + } + + /** + * 充电桩 + * @return + */ + private TargetVo chargeTarget() { + TargetVo target = (TargetVo) redisTemplate.opsForValue().get(charge); + if(ObjectUtil.isNotEmpty(target)){ + return target; + } + target = new TargetVo(); + try { + URL serverUrl = new URL(charge_url); + HttpURLConnection conn = (HttpURLConnection) serverUrl.openConnection(); + conn.setRequestMethod("GET"); + conn.setRequestProperty("Content-type", "application/json"); + //必须设置false,否则会自动redirect到重定向后的地址 + conn.setInstanceFollowRedirects(false); + conn.connect(); + String result = responseFormat(conn); + if (StringUtil.isBlank(result)) { + return new TargetVo(); + } + JSONObject jsonObject = JSONObject.parseObject(result); + JSONObject data = JSONObject.parseObject(jsonObject.get("data").toString()); + target.setType(HomePageConstant.CHARGE); + target.setTypeName(DictCache.getValue("stationType", HomePageConstant.CHARGE)); + target.setTaget_one(Double.valueOf(data.get("ordersCount").toString())); + target.setTaget_two(Double.valueOf(data.get("todayDegree").toString())); + target.setTaget_three(Double.valueOf(data.get("income").toString())); + target.setTaget_four(Double.valueOf(data.get("kilowatt").toString())); + target.setCharge(Integer.valueOf(data.get("stationNum").toString())); + redisTemplate.opsForValue().set(charge,target); + redisTemplate.expire(charge,30, TimeUnit.MINUTES); + } catch (Exception e) { + target.setType(HomePageConstant.CHARGE); + target.setTypeName(DictCache.getValue("stationType", HomePageConstant.CHARGE)); + target.setTaget_one(0.0); + target.setTaget_two(0.0); + target.setTaget_three(0.0); + target.setTaget_four(0.0); + target.setCharge(0); + log.error("charge_target_exception: {} ", e.getMessage()); + } + return target; + } + + /*** + * 获取返回的内容 + * @param connection + * @return + */ + private String responseFormat(HttpURLConnection connection) { + StringBuilder stringBuilder = new StringBuilder(); + //将返回的输入流转换成字符串 + try ( + InputStream inputStream = connection.getInputStream(); + InputStreamReader inputStreamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8); + BufferedReader bufferedReader = new BufferedReader(inputStreamReader) + ) { + String str; + while ((str = bufferedReader.readLine()) != null) { + stringBuilder.append(str); + } + } catch (IOException e) { + return null; + } + return stringBuilder.toString(); + } +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/SolveServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/SolveServiceImpl.java new file mode 100644 index 0000000..6d5238a --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/SolveServiceImpl.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.scheduled.service.operation.impl; + +import com.hnac.hzims.operational.fill.entity.SolveEntity; +import com.hnac.hzims.scheduled.mapper.operation.SolveMapper; +import com.hnac.hzims.scheduled.service.operation.SolveService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +/** + * @author ysj + */ +@Slf4j +@Service +@AllArgsConstructor +public class SolveServiceImpl extends BaseServiceImpl implements SolveService { + + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/impl/StationAttrConfigServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/StationAttrConfigServiceImpl.java similarity index 74% rename from hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/impl/StationAttrConfigServiceImpl.java rename to hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/StationAttrConfigServiceImpl.java index 58bd475..d928365 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/impl/StationAttrConfigServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/StationAttrConfigServiceImpl.java @@ -1,10 +1,9 @@ -package com.hnac.hzims.scheduled.service.impl; +package com.hnac.hzims.scheduled.service.operation.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.hnac.hzims.operational.station.entity.StationAttrConfigEntity; import com.hnac.hzims.scheduled.mapper.operation.StationAttrConfigMapper; -import com.hnac.hzims.scheduled.service.IStationAttrConfigService; -import lombok.AllArgsConstructor; +import com.hnac.hzims.scheduled.service.operation.StationAttrConfigService; import lombok.extern.slf4j.Slf4j; import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.tool.utils.CollectionUtil; @@ -15,17 +14,11 @@ import java.util.List; import java.util.stream.Collectors; /** - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/5/19 16:07 + * @author ysj */ @Service @Slf4j -@AllArgsConstructor -public class StationAttrConfigServiceImpl extends BaseServiceImpl - implements IStationAttrConfigService { - +public class StationAttrConfigServiceImpl extends BaseServiceImpl implements StationAttrConfigService { @Override public List getHideList() { @@ -38,5 +31,4 @@ public class StationAttrConfigServiceImpl extends BaseServiceImpl implements StationAttributeService { + + /** + * 获取集中监控监测点单位 + * @return + */ + @Override + public Map PointUnit() { + List list = this.baseMapper.PointUnit(); + if(CollectionUtil.isEmpty(list)){ + return null; + } + return list.stream().collect(Collectors.toMap(StationAttributeEntity::getAttributes, StationAttributeEntity::getUnit)); + } +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/StationServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/StationServiceImpl.java new file mode 100644 index 0000000..8735909 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/StationServiceImpl.java @@ -0,0 +1,19 @@ +package com.hnac.hzims.scheduled.service.operation.impl; + +import com.hnac.hzims.operational.station.entity.StationEntity; +import com.hnac.hzims.scheduled.mapper.operation.StationMapper; +import com.hnac.hzims.scheduled.service.operation.StationService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +/** + * @author hx + */ +@Service +@RequiredArgsConstructor +@Slf4j +public class StationServiceImpl extends BaseServiceImpl implements StationService { + +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/UseServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/UseServiceImpl.java new file mode 100644 index 0000000..82ba5b1 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/UseServiceImpl.java @@ -0,0 +1,99 @@ +package com.hnac.hzims.scheduled.service.operation.impl; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hnac.hzims.operational.fill.entity.UseEntity; +import com.hnac.hzims.operational.main.vo.UsrPowerVo; +import com.hnac.hzims.scheduled.mapper.operation.UseMapper; +import com.hnac.hzims.scheduled.service.operation.UseService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.DateUtil; +import org.springframework.stereotype.Service; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * @author ysj + * @date 2023/04/10 11:16:07 + * @version 4.0.0 + */ +@Slf4j +@Service +@AllArgsConstructor +public class UseServiceImpl extends BaseServiceImpl implements UseService { + + /** + * 根据时间、机构查询用电量 + * @param date 时间: 年 - yyyy/月 yyyy-mm/日 yyyy-mm-dd + * @param station 所属机构 + * @return + */ + @Override + public Float use(String date, String station) { + List powers = this.list(Wrappers.lambdaQuery() + .likeRight(UseEntity::getFillDate,date) + .eq(UseEntity::getStationCode,station) + ); + if(CollectionUtil.isEmpty(powers)){ + return 0f; + } + return (float) powers.stream().mapToDouble(UseEntity::getEmploy).sum(); + } + + /** + * 查询30天填报用电量 + * @param day : 结束日期 yyyy-MM-dd + * @param station 站点编码 + * @return + */ + @Override + public List use30Day(String day, String station) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(DateUtil.parse(day,DateUtil.PATTERN_DATE)); + String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE); + calendar.add(Calendar.DAY_OF_MONTH,-29); + String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE); + List records = this.list(Wrappers.lambdaQuery() + .between(UseEntity::getFillDate,start,end) + .eq(UseEntity::getStationCode,station) + ); + if(CollectionUtil.isEmpty(records)){ + return new ArrayList<>(); + } + return records.stream().map(record->{ + UsrPowerVo use = new UsrPowerVo(); + use.setDate(record.getFillDate()); + if(Math.abs(record.getEmploy()) <= 0){ + use.setUsrPower(0f); + }else{ + use.setUsrPower(Float.parseFloat(record.getEmploy().toString())); + } + return use; + }).collect(Collectors.toList()); + } + + /** + * 查询近3年的填报用电量 + * @param start + * @param end + * @param station + * @return + */ + @Override + public Map generateThreeYear(String start, String end, String station) { + List records = this.list(Wrappers.lambdaQuery() + .between(UseEntity::getFillDate,start,end) + .eq(UseEntity::getStationCode,station) + ); + if(CollectionUtil.isEmpty(records)){ + return new HashMap<>(); + + } + return records.stream().peek(record-> record.setFillDate(DateUtil.format(DateUtil.parse(record.getFillDate(),"yyyy-MM"),"yyyy-MM") + "-01")). + collect(Collectors.toMap(UseEntity::getFillDate, value->Float.parseFloat(value.getEmploy().toString()),Float::sum)); + } + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/safeproduct/CompanyService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/safeproduct/CompanyService.java new file mode 100644 index 0000000..ecdb769 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/safeproduct/CompanyService.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.scheduled.service.safeproduct; + +import com.hnac.hzims.safeproduct.entity.CheckCompanyEntity; +import org.springblade.core.mp.base.BaseService; + +/** + * @author ysj + */ +public interface CompanyService extends BaseService { + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/safeproduct/InstanceService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/safeproduct/InstanceService.java new file mode 100644 index 0000000..0581c6f --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/safeproduct/InstanceService.java @@ -0,0 +1,12 @@ +package com.hnac.hzims.scheduled.service.safeproduct; + +import com.hnac.hzims.safeproduct.entity.CheckItemInstanceEntity; +import org.springblade.core.mp.base.BaseService; + +/** + * Created by Sam Huang 2022/5/6 8:28 + */ +public interface InstanceService extends BaseService { + + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/safeproduct/MonthService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/safeproduct/MonthService.java new file mode 100644 index 0000000..5582515 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/safeproduct/MonthService.java @@ -0,0 +1,14 @@ +package com.hnac.hzims.scheduled.service.safeproduct; + +import com.hnac.hzims.safeproduct.entity.CheckMonthEntity; +import org.springblade.core.mp.base.BaseService; + +import java.util.Map; + +/** + * @author ysj + */ +public interface MonthService extends BaseService { + + Map check(Map map); +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/safeproduct/TrialService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/safeproduct/TrialService.java new file mode 100644 index 0000000..c472c89 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/safeproduct/TrialService.java @@ -0,0 +1,13 @@ +package com.hnac.hzims.scheduled.service.safeproduct; + +import com.hnac.hzims.safeproduct.dto.SafeEquipmentTrialDTO; +import com.hnac.hzims.safeproduct.entity.SafeEquipmentTrialEntity; +import org.springblade.core.mp.base.BaseService; + +/** + * @author ysj + */ +public interface TrialService extends BaseService { + + int count(SafeEquipmentTrialDTO trial); +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/safeproduct/impl/CompanyServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/safeproduct/impl/CompanyServiceImpl.java new file mode 100644 index 0000000..7004ad3 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/safeproduct/impl/CompanyServiceImpl.java @@ -0,0 +1,19 @@ +package com.hnac.hzims.scheduled.service.safeproduct.impl; + +import com.hnac.hzims.safeproduct.entity.CheckCompanyEntity; +import com.hnac.hzims.scheduled.mapper.safeproduct.CompanyMapper; +import com.hnac.hzims.scheduled.service.safeproduct.CompanyService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +/** + * @author ysj + */ +@Service +@AllArgsConstructor +@Slf4j +public class CompanyServiceImpl extends BaseServiceImpl implements CompanyService { + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/safeproduct/impl/InstanceServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/safeproduct/impl/InstanceServiceImpl.java new file mode 100644 index 0000000..1b44fa8 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/safeproduct/impl/InstanceServiceImpl.java @@ -0,0 +1,19 @@ +package com.hnac.hzims.scheduled.service.safeproduct.impl; + +import com.hnac.hzims.safeproduct.entity.CheckItemInstanceEntity; +import com.hnac.hzims.scheduled.mapper.safeproduct.InstanceMapper; +import com.hnac.hzims.scheduled.service.safeproduct.InstanceService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +/** + * @author ysj + */ +@Service +@AllArgsConstructor +@Slf4j +public class InstanceServiceImpl extends BaseServiceImpl implements InstanceService { + +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/safeproduct/impl/MonthServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/safeproduct/impl/MonthServiceImpl.java new file mode 100644 index 0000000..697e6c0 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/safeproduct/impl/MonthServiceImpl.java @@ -0,0 +1,96 @@ +package com.hnac.hzims.scheduled.service.safeproduct.impl; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.hnac.hzims.safeproduct.entity.CheckCompanyEntity; +import com.hnac.hzims.safeproduct.entity.CheckItemInstanceEntity; +import com.hnac.hzims.safeproduct.entity.CheckMonthEntity; +import com.hnac.hzims.scheduled.mapper.safeproduct.MonthMapper; +import com.hnac.hzims.scheduled.service.safeproduct.CompanyService; +import com.hnac.hzims.scheduled.service.safeproduct.InstanceService; +import com.hnac.hzims.scheduled.service.safeproduct.MonthService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.ObjectUtil; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; + +/** + * @author ysj + */ +@Service +@AllArgsConstructor +@Slf4j +public class MonthServiceImpl extends BaseServiceImpl implements MonthService { + + private final CompanyService companyService; + private final InstanceService instanceService; + + @Override + public Map check(Map map) { + if (ObjectUtil.isEmpty(map)) { + return null; + } + Map result = new HashMap<>(); + String startDate = (String) map.get("startDate"); + String endDate = (String) map.get("endDate"); + List deptList = (List) map.get("deptList"); + String startMonth = startDate.substring(0, 7); + String endMonth = endDate.substring(0, 7); + //月度自查次数 + Wrapper wrapper = new LambdaQueryWrapper() {{ + in(CheckMonthEntity::getCreateDept, deptList); + between(CheckMonthEntity::getMonth, startMonth, endMonth); + }}; + List monthList = this.list(wrapper); + result.put("monthCheckNum", monthList != null ? monthList.size() : 0); + //公司大检查次数 + Wrapper wrapper1 = new LambdaQueryWrapper() {{ + in(CheckCompanyEntity::getCreateDept, deptList); + ge(CheckCompanyEntity::getStartTime, startDate); + le(CheckCompanyEntity::getEndTime, endDate); + }}; + List companyList = companyService.list(wrapper1); + result.put("bigCheckNum", companyList != null ? companyList.size() : 0); + + AtomicInteger safetyMeetingNum = new AtomicInteger(0); + AtomicInteger skillsTrainingNum = new AtomicInteger(0); + + if (CollectionUtil.isNotEmpty(monthList)) { + monthList.forEach(checkMonthEntity -> { + Long checkId = checkMonthEntity.getId(); + Wrapper wrapper2 = new LambdaQueryWrapper() {{ + eq(CheckItemInstanceEntity::getCheckId, checkId); + }}; + List list = instanceService.list(wrapper2); + if (CollectionUtil.isNotEmpty(list)) { + list.forEach(instanceEntity -> { + //安全生产会议检查项,系统统计情况不为空纳入统计次数 + if ("现场每月1次安全生产会议".equals(instanceEntity.getItem())) { + if (StringUtils.isNotEmpty(instanceEntity.getSystemSituation())) { + safetyMeetingNum.addAndGet(1); + } + } + //技能培训检查项,系统统计情况不为空纳入统计次数 + if ("每月开展1次技能培训".equals(instanceEntity.getItem())) { + if (StringUtils.isNotEmpty(instanceEntity.getSystemSituation())) { + skillsTrainingNum.addAndGet(1); + } + } + }); + } + }); + } + result.put("safetyMeetingNum", safetyMeetingNum.get()); + result.put("skillsTrainingNum", skillsTrainingNum.get()); + return result; + } +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/safeproduct/impl/TrialServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/safeproduct/impl/TrialServiceImpl.java new file mode 100644 index 0000000..37a2050 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/safeproduct/impl/TrialServiceImpl.java @@ -0,0 +1,50 @@ +package com.hnac.hzims.scheduled.service.safeproduct.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.hnac.hzims.safeproduct.dto.SafeEquipmentTrialDTO; +import com.hnac.hzims.safeproduct.entity.SafeEquipmentTrialEntity; +import com.hnac.hzims.scheduled.mapper.safeproduct.TrialMapper; +import com.hnac.hzims.scheduled.service.safeproduct.TrialService; +import lombok.RequiredArgsConstructor; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.ObjectUtil; +import org.springframework.stereotype.Service; + +import java.util.Optional; + +/** + * @author ysj + */ +@Service +@RequiredArgsConstructor +public class TrialServiceImpl extends BaseServiceImpl implements TrialService { + + /** + * 时间区间机构的设备实验数据查询 + * @param trial + * @return + */ + @Override + public int count(SafeEquipmentTrialDTO trial) { + if (ObjectUtil.isEmpty(trial)) { + return 0; + } + QueryWrapper queryWrapper = new QueryWrapper() {{ + if (CollectionUtil.isEmpty(trial.getDeptList())) { + if (Optional.ofNullable(trial.getCreateDept()).isPresent()) { + eq("create_dept", trial.getCreateDept()); + } + } else { + in("create_dept", trial.getDeptList()); + } + if (Optional.ofNullable(trial.getStartTime()).isPresent()) { + gt("create_time", trial.getStartTime()); + } + if (Optional.ofNullable(trial.getEndTime()).isPresent()) { + lt("create_time", trial.getEndTime()); + } + }}; + return this.baseMapper.selectCount(queryWrapper); + } +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/TicketEvaluateService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/TicketEvaluateService.java new file mode 100644 index 0000000..ad99144 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/TicketEvaluateService.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.scheduled.service.ticket; + +import com.hnac.hzims.ticket.allTicket.entity.TicketInfoEvaluateEntity; +import org.springblade.core.mp.base.BaseService; + +/** + * @author hx + */ +public interface TicketEvaluateService extends BaseService { + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/TicketService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/TicketService.java new file mode 100644 index 0000000..ff5e1ad --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/TicketService.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.scheduled.service.ticket; + +import com.hnac.hzims.ticket.allTicket.vo.DoublePassRateVO; +import com.hnac.hzims.ticket.standardTicket.entity.StandardTicketInfoEntity; +import com.hnac.hzims.ticket.workTicket.vo.TicketMonthVO; +import org.springblade.core.mp.base.BaseService; +import org.springblade.core.tool.api.R; + +import java.time.LocalDateTime; +import java.util.List; + +/** + * @author ysj + */ +public interface TicketService extends BaseService { + + DoublePassRateVO doublePassRate(List areas, LocalDateTime firstDateTime, LocalDateTime now); + + TicketMonthVO operateWork(String start, String end, List list); +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/WorkTicketService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/WorkTicketService.java new file mode 100644 index 0000000..0117669 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/WorkTicketService.java @@ -0,0 +1,10 @@ +package com.hnac.hzims.scheduled.service.ticket; + +import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity; +import org.springblade.core.mp.base.BaseService; + +/** + * @author ysj + */ +public interface WorkTicketService extends BaseService { +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/impl/TicketEvaluateServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/impl/TicketEvaluateServiceImpl.java new file mode 100644 index 0000000..253f645 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/impl/TicketEvaluateServiceImpl.java @@ -0,0 +1,22 @@ +package com.hnac.hzims.scheduled.service.ticket.impl; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.hnac.hzims.scheduled.mapper.ticket.TicketEvaluateMapper; +import com.hnac.hzims.scheduled.service.ticket.TicketEvaluateService; +import com.hnac.hzims.ticket.allTicket.entity.TicketInfoEvaluateEntity; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +/** + * @author ysj + */ +@Service +@RequiredArgsConstructor +@Slf4j +@DS("ticket") +public class TicketEvaluateServiceImpl extends BaseServiceImpl implements TicketEvaluateService { + + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/impl/TicketServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/impl/TicketServiceImpl.java new file mode 100644 index 0000000..62ef9a0 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/impl/TicketServiceImpl.java @@ -0,0 +1,150 @@ +package com.hnac.hzims.scheduled.service.ticket.impl; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.hnac.hzims.scheduled.mapper.ticket.TicketMapper; +import com.hnac.hzims.scheduled.service.ticket.TicketEvaluateService; +import com.hnac.hzims.scheduled.service.ticket.TicketService; +import com.hnac.hzims.scheduled.service.ticket.WorkTicketService; +import com.hnac.hzims.ticket.allTicket.entity.TicketInfoEvaluateEntity; +import com.hnac.hzims.ticket.allTicket.vo.DoublePassRateVO; +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.vo.TicketMonthVO; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author ysj + */ +@Service +@RequiredArgsConstructor +@Slf4j +@DS("ticket") +public class TicketServiceImpl extends BaseServiceImpl implements TicketService { + + private final WorkTicketService workTicketService; + + private final TicketEvaluateService ticketEvaluateService; + + /** + * 获取双票合格率 + * @param depatList + * @param firstDateTime + * @param now + * @return + */ + @Override + public DoublePassRateVO doublePassRate(List depatList, LocalDateTime firstDateTime, LocalDateTime now) { + DoublePassRateVO doublePassRateVO = new DoublePassRateVO(); + // 查询操作票 + List standardList = this.list(new LambdaQueryWrapper() {{ + ge(StandardTicketInfoEntity::getCreateTime, firstDateTime); + le(StandardTicketInfoEntity::getCreateTime, now); + in(StandardTicketInfoEntity::getCreateDept, depatList); + }}); + // 查询工作票 + List workList = workTicketService.list(new LambdaQueryWrapper() {{ + ge(WorkTicketInfoEntity::getCreateTime, firstDateTime); + le(WorkTicketInfoEntity::getCreateTime, now); + in(WorkTicketInfoEntity::getCreateDept, depatList); + }}); + if (CollectionUtil.isEmpty(standardList) && CollectionUtil.isEmpty(workList)) { + doublePassRateVO.setDoubleTicketCount(0); + doublePassRateVO.setDoubleTicketPassCount(0); + doublePassRateVO.setDoublePassRate("0"); + return doublePassRateVO; + } + List standardIdList = new ArrayList<>(); + standardIdList.addAll(standardList.stream().map(StandardTicketInfoEntity::getId).collect(Collectors.toList())); + standardIdList.addAll(workList.stream().map(WorkTicketInfoEntity::getId).collect(Collectors.toList())); + doublePassRateVO.setDoubleTicketCount(standardIdList.size()); + // 查询合格评价 + List evaluateList = ticketEvaluateService.list(new LambdaQueryWrapper() {{ + ge(TicketInfoEvaluateEntity::getCreateTime, firstDateTime); + le(TicketInfoEvaluateEntity::getCreateTime, now); + in(TicketInfoEvaluateEntity::getTicketId, standardIdList); + eq(TicketInfoEvaluateEntity::getStatus, TicketConstants.TicketQualifiedEnum.Qualified.getCode()); + }}); + if (CollectionUtil.isEmpty(evaluateList)) { + doublePassRateVO.setDoubleTicketPassCount(0); + doublePassRateVO.setDoublePassRate("0"); + return doublePassRateVO; + } + double doublePassRate = BigDecimal.valueOf(evaluateList.size() / (double) standardIdList.size() * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + doublePassRateVO.setDoubleTicketPassCount(evaluateList.size()); + doublePassRateVO.setDoublePassRate(String.valueOf(doublePassRate)); + return doublePassRateVO; + } + + /** + * 获取首页区域当月操作票 + * @param start + * @param end + * @param list + * @return + */ + @Override + public TicketMonthVO operateWork(String start, String end, List list) { + TicketMonthVO ticket = new TicketMonthVO(); + // 操作票 + List operateList = this.list(new LambdaQueryWrapper() {{ + ge(StandardTicketInfoEntity::getCreateTime, start); + le(StandardTicketInfoEntity::getCreateTime, end); + in(StandardTicketInfoEntity::getCreateDept, list); + }}); + if (CollectionUtil.isEmpty(operateList)) { + ticket.setOperate(0); + ticket.setOperateQualify(0); + }else{ + ticket.setOperate(operateList.size()); + List operateIdList = operateList.stream().map(StandardTicketInfoEntity::getId).collect(Collectors.toList()); + // 查询合格评价 + List operateQualifyList = ticketEvaluateService.list(new LambdaQueryWrapper() {{ + in(TicketInfoEvaluateEntity::getTicketId, operateIdList); + eq(TicketInfoEvaluateEntity::getStatus, TicketConstants.TicketQualifiedEnum.Qualified.getCode()); + }}); + if (CollectionUtil.isEmpty(operateQualifyList)) { + ticket.setOperateQualify(0); + }else{ + ticket.setOperateQualify(operateQualifyList.size()); + } + } + // 工作票 + List works = workTicketService.list(new LambdaQueryWrapper() {{ + ge(WorkTicketInfoEntity::getCreateTime, start); + le(WorkTicketInfoEntity::getCreateTime, end); + in(WorkTicketInfoEntity::getCreateDept, list); + }}); + if (CollectionUtil.isEmpty(works)) { + ticket.setWork(0); + ticket.setWorkQualify(0); + }else{ + ticket.setWork(works.size()); + List workIds = works.stream().map(WorkTicketInfoEntity::getId).collect(Collectors.toList()); + // 查询合格评价 + List operateQualifyList = ticketEvaluateService.list(new LambdaQueryWrapper() {{ + in(TicketInfoEvaluateEntity::getTicketId, workIds); + eq(TicketInfoEvaluateEntity::getStatus, TicketConstants.TicketQualifiedEnum.Qualified.getCode()); + }}); + if (CollectionUtil.isEmpty(operateQualifyList)) { + ticket.setOperateQualify(0); + }else{ + ticket.setWorkQualify(operateQualifyList.size()); + } + } + return ticket; + } + +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/impl/WorkTicketServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/impl/WorkTicketServiceImpl.java new file mode 100644 index 0000000..d859eeb --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/impl/WorkTicketServiceImpl.java @@ -0,0 +1,21 @@ +package com.hnac.hzims.scheduled.service.ticket.impl; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.hnac.hzims.scheduled.mapper.ticket.WorkTicketMapper; +import com.hnac.hzims.scheduled.service.ticket.WorkTicketService; +import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + + +/** + * @author ysj + */ +@Service +@Slf4j +@RequiredArgsConstructor +@DS("ticket") +public class WorkTicketServiceImpl extends BaseServiceImpl implements WorkTicketService { +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/vo/RealAttributeVo.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/vo/RealAttributeVo.java deleted file mode 100644 index 00ea9d8..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/vo/RealAttributeVo.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.hnac.hzims.scheduled.vo; - -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.io.Serializable; - -/** - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/5/19 15:27 - */ -@Data -public class RealAttributeVo implements Serializable { - - @ApiModelProperty("属性名称") - private String name; - - @ApiModelProperty("属性数值") - private String value; - - @ApiModelProperty("属性单位") - private String unit; - - @ApiModelProperty("属性类型:1-遥信 2-遥测") - private Integer type; - - @ApiModelProperty("属性实时数据Id") - private String realId; - - @ApiModelProperty("告警Id") - private Long id; - - @ApiModelProperty("属性状态:0:正常、1:预警、2:告警、3:空值、4:黄色、5:橙色") - private int status; - - @ApiModelProperty("属性质量") - private int quality; - - @ApiModelProperty("属性时间") - private String time; - - @ApiModelProperty("属性故障ID") - private String fdpFaultId; - - @ApiModelProperty("监测点") - private String fdpMonitorId; - - @ApiModelProperty("属性故障值") - private Double fdpRate; -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/vo/RealDeviceVo.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/vo/RealDeviceVo.java deleted file mode 100644 index 330a5df..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/vo/RealDeviceVo.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.hnac.hzims.scheduled.vo; - -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.io.Serializable; -import java.util.List; - -/** - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/5/19 15:26 - */ -@Data -public class RealDeviceVo implements Serializable { - - @ApiModelProperty("设备编号") - private String deviceCode; - - @ApiModelProperty("设备名称") - private String deviceName; - - @ApiModelProperty("设备状态") - private Integer state; - - @ApiModelProperty("排序字段") - private Integer sort; - - @ApiModelProperty("设备属性集合") - private List attbtList; -} - diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/vo/RealStationVo.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/vo/RealStationVo.java deleted file mode 100644 index 00a0c9e..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/vo/RealStationVo.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.hnac.hzims.scheduled.vo; - -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.io.Serializable; -import java.util.List; - -/** - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/5/19 15:24 - */ -@Data -public class RealStationVo implements Serializable { - - @ApiModelProperty("站点Id") - private String stationCode; - - @ApiModelProperty("站点名称") - private String stationName; - - @ApiModelProperty("站点机构Id") - private Long stationDeptId; - - @ApiModelProperty("站点类型") - private String serverType; - - @ApiModelProperty("当前天气") - private WeatherVo nowWater; - - @ApiModelProperty("总有功率") - private Double powerSum; - - @ApiModelProperty("降水") - private String precipitation; - - @ApiModelProperty("最大前池水位") - private Double waterLevelMax; - - @ApiModelProperty("前池水位") - private Double waterLevel; - - @ApiModelProperty("设备集合") - private List deviceList; - - @ApiModelProperty("站点状态 : 0-正常 1-数据中断") - private Integer status; - - @ApiModelProperty("排序") - private Integer sort; -} - diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/vo/StationRealVo.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/vo/StationRealVo.java deleted file mode 100644 index 8e9d7da..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/vo/StationRealVo.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.hnac.hzims.scheduled.vo; - -import lombok.Data; - -/** - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/5/19 11:43 - */ -@Data -public class StationRealVo { - - private String station; - - private String[] realId; -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/vo/WeatherVo.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/vo/WeatherVo.java deleted file mode 100644 index bd46d22..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/vo/WeatherVo.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.hnac.hzims.scheduled.vo; - -import lombok.Data; - -import java.io.Serializable; - -/** - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/5/19 15:25 - */ -@Data -public class WeatherVo implements Serializable { - - /**当前天气状况和图标的代码,图标可通过天气状况和图标下载; //100**/ - private String icon; - - /**实况温度,默认单位:摄氏度; //21**/ - private String temp; - - /**实况天气状况的文字描述,包括阴晴雨雪等天气状态的描述; //晴**/ - private String text; - - /**预报当天最高温度; //4**/ - private String tempMax; - - /**预报当天最低温度; //-5**/ - private String tempMin; -} diff --git a/hzims-service/hzims-scheduled/src/main/resources/application.yml b/hzims-service/hzims-scheduled/src/main/resources/application.yml deleted file mode 100644 index e738d56..0000000 --- a/hzims-service/hzims-scheduled/src/main/resources/application.yml +++ /dev/null @@ -1,208 +0,0 @@ -#服务器端口 -server: - port: 8501 - -#数据源配置 -spring: - cloud: - nacos: - discovery: - server-addr: 175.6.40.67:10056 - config: - server-addr: 175.6.40.67:10056 - application: - name: hzims-scheduled - main: - allow-bean-definition-overriding: true - #排除DruidDataSourceAutoConfigure - autoconfigure: - exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure - datasource: - dynamic: - primary: operational #设置默认的数据源或者数据源组,默认值即为master - strict: false #严格匹配数据源,默认false. true未匹配到指定数据源时抛异常,false使用默认数据源 - datasource: - operational: - url: jdbc:mysql://192.168.1.3:3576/dev_hzims_operation?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true - username: root - password: 123 - redis: - # redis数据库索引(默认为0),我们使用索引为0的数据库,避免和其他数据库冲突 - database: 0 - # redis服务器地址(默认为localhost) - host: 192.168.1.3 - # redis端口(默认为6379) - port: 3577 - # redis访问密码(默认为空) - password: 1qaz2WSX@redis - -#xxl: -# job: -# accessToken: '' -# admin: -# addresses: http://192.168.1.3:7009/xxl-job-admin -# executor: -# appname: hzims-operational -# ip: 192.168.1.3 -# logpath: /data/applogs/xxl-job/jobhandler -# logretentiondays: -1 -# port: 28501 - -xxl: - job: - accessToken: '' - admin: - addresses: http://192.168.5.128:9080/xxl-job-admin - executor: - appname: hzims-operational - ip: 192.168.18.232 - logpath: /data/applogs/xxl-job/jobhandler - logretentiondays: -1 - port: 28501 - - -#mybatis-plus配置 -mybatis-plus: - mapper-locations: classpath*:/mapper/**/*.xml - #实体扫描,多个package用逗号或者分号分隔 -# typeAliasesPackage: com.hnac.hzims.**.entity - configuration: - log-impl: org.apache.ibatis.logging.stdout.StdOutImpl - -#swagger扫描路径配置 -swagger: - base-packages: - - org.springbalde - - com.hnac - -hzims: - # 视频配置地址随机码 - video: - random-code: qnrld30yto85cji5 - # 视频配置秘钥属性 - videoProperties: - appKey: 21111042 - videoHost: 42.192.39.246:443 - appSecret: QXRevZ2AQeXtmlYZT6Rf - equipment: - emInfo: - code: hzims:equipment:emInfo:deviceCode.stationDeviceCode - emInfoList: hzims:equipment:emInfo:deviceCode.emInfoList - fdp: - redisData: hzims:equipment:fdp:fault.data.realIdAndValueList - greaterThan: 0.3 - lessThan: 0.9 - beEqualOrGreaterThan: 0.9 - alert: - # 接收告警的websocket url - ws-url: wss://175.6.40.67:9036/api/hzinfo-data-socket/websocket/soe - config: - #接收遥测或遥信实时数据的websocket url - ws-url: wss://175.6.40.67:9036/api/hzinfo-data-socket/websocket/data - level: - ws-url: wss://175.6.40.67:9036/api/hzinfo-data-socket/websocket/alarm - pdf: - # pdf文件存储路径,请配置绝对路径 - #file-path: /data/inspect/pdf/file - file-path: D:/data/hzinfo/file # windows - operation: - access: - task-key: hzims:operation:access:task - alert: - saveDefectIsOpen: true - save: - area: - url: http://49.234.126.72:8255/apiIntroduction/demo/saveHzimsArea - station: - url: http://49.234.126.72:8255/apiIntroduction/demo/saveHzimsStation - defect: - repair: /data/hzims/operational/defect/repair/应急抢修单.docx - area: - report: hzims.operation.area.report - monitor: - station: hzims:operation:monitor:station - realId : hzims:operation:monitor:realId - region: - areaDutyInfoKey: hzims:operation:region:areaDutyInfoKey - deviceClassifyKey: hzims.operation.region.deviceClassifyKey - projectDepartmentId: 200000000000101 - projectDepartmentName: 智能运维事业部 - notInDept: 2000000000001010048,2000000000001010049,2000000000001010050 - tenantId: 200000 - #工单返回记录(暂存) - workOrder: - access: hzims:operation:workOrder.access - defect: hzims:operation:workOrder.defect - task: - # 消息推送存入redis的key值 - templateCode: - maintenance: - taskDispose: hzinfo:operation:maintenance:task - # 消息推送code - jgPushCode: ops-push - comprehensiveD: hzims:operation:comprehensiveD:real.time - realIdKey: hzims:operation:comprehensiveD:realIdKey.realData - lastDayRealIdKey: hzims:operation:comprehensiveD:lastDayRealIdKey.realData - realIdKeyGather: hzims:operation:comprehensiveD:realIdKeyGather.realData - homePage: - charge: - url: https://www.hznychh.cn/api/charging-manage/manage/external/provide?secretKey=f5aee9fe24e4d1d80eb7564414392bc3 - activePowerKey: hzims:operation:homePage:activePowerKey - jointRelayKey: hzims:operation:homePage:jointRelayKey - systemMonitoring: - hydropowerStation: - hisData: hzims:operation:homePage:systemMonitoring:hydropowerStation:hisData:. - hisDataActivePower: hzims:operation:homePage:systemMonitoring:hydropowerStation:hisDataActivePower:. - theDayHydrograph: hzims:operation:homePage:systemMonitoring:hydropowerStation:theDayHydrograph:. - yearGeneration: hzims:operation:homePage:systemMonitoring:hydropowerStation:yearGeneration.data - hisDataNew: hzims:operation:homePage:systemMonitoring:hydropowerStation:hisDataNew - theDayHydrographNew: hzims:operation:homePage:systemMonitoring:hydropowerStation:theDayHydrographNew - alarm: - # "0-默认", "1-系统", "2-告警", "3-故障", "4-用户操作", "5-遥测越限", "6-遥信变位", "7-注册信息", "8-信息提示", "9-设备巡检", "10-遥控操作", "11-遥测越限恢复","12-未定义","13-通讯中断","14-数据异常" - types: 3,2,5,13,14 - -category: - id: 1384429129110360065 - -sanya: - one: 2000000000001010048 - tow: 2000000000001010049 - hoop: 2000000000001010050 - -defect: - # 超时自动甄别时间间隔:单位(小时) - discriminateDeadline: 1 - # 默认计划工时:单位(小时) - defaultPlanHoure: 8 - -blade: - data: - sdk: - enabled: true - url: http://175.6.40.67:37681/api/hzinfo-data-config - appId: '1635888805125099521' - appSecret: f4b6a4dc696b36445d2e5d38bbab2417 - redisIp: 192.168.1.13 - redisPort: 3577 - password: L_MM&h=+Nm&p)U9sk.uH - maxKeys: 1000 - data-scope: - enabled: false - lock: - enabled: true - address: redis://192.168.1.3:3577 - password: - database: 0 - ssl: false - -url: - video: - stationsPath: http://localhost:10001/stations - monitorsPath: http://localhost:10001/monitor - login: https://175.6.40.67:9300/hzApi/auth/mix/login?tenantId=200000&account=videoViewers&pwd=e10adc3949ba59abbe56e057f20f883e&grant_type=password&scope=all&type=account - water-out: - #工单受理 - orderCrtPackage: http://175.6.40.67:9021/api/water-out/orderCrt/package - orderCrtGrabPackage: http://175.6.40.67:9021/api/water-out/orderCrt/grabPackage - - diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/equipment/PlanMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/equipment/PlanMapper.xml new file mode 100644 index 0000000..4cb6c9b --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/equipment/PlanMapper.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/equipment/WorkshopInfoMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/equipment/WorkshopInfoMapper.xml new file mode 100644 index 0000000..933d153 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/equipment/WorkshopInfoMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/inspect/TaskMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/inspect/TaskMapper.xml new file mode 100644 index 0000000..9acf610 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/inspect/TaskMapper.xml @@ -0,0 +1,4 @@ + + + + diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/AbnormalAlarmMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/AbnormalAlarmMapper.xml index 49c1076..aab621f 100644 --- a/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/AbnormalAlarmMapper.xml +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/AbnormalAlarmMapper.xml @@ -2,16 +2,10 @@ - - select distinct station_id from hzims_abnormal_alarm where is_deleted = 0 - and type in (13,14) - and `STATUS` = 0 + and type in (13,14) + and `STATUS` = 0 diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/AccessMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/AccessMapper.xml new file mode 100644 index 0000000..41e93fb --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/AccessMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/DefectMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/DefectMapper.xml new file mode 100644 index 0000000..5e93d41 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/DefectMapper.xml @@ -0,0 +1,4 @@ + + + + diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/GenerateMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/GenerateMapper.xml new file mode 100644 index 0000000..2f3e18b --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/GenerateMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/MaintenanceMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/MaintenanceMapper.xml new file mode 100644 index 0000000..2cfd506 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/MaintenanceMapper.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/ModelStationMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/ModelStationMapper.xml new file mode 100644 index 0000000..df6a033 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/ModelStationMapper.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/mapper/OtherMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/OtherMapper.xml similarity index 95% rename from hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/mapper/OtherMapper.xml rename to hzims-service/hzims-scheduled/src/main/resources/mapper/operation/OtherMapper.xml index 44e22e4..af9c98d 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/mapper/OtherMapper.xml +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/OtherMapper.xml @@ -1,6 +1,6 @@ - + diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/OverDetailsMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/OverDetailsMapper.xml new file mode 100644 index 0000000..4f13622 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/OverDetailsMapper.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + ID, OVER_ID , OVER_CONFIG_ID , PRICE , QUANTITY , TOTAL_PRICE, TENANT_ID, STATUS, CREATE_TIME, UPDATE_TIME, + CREATE_USER, UPDATE_USER, IS_DELETED, CREATE_DEPT + + + diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/OverMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/OverMapper.xml new file mode 100644 index 0000000..c8d9cf8 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/OverMapper.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + ID, START_DATE , END_DATE , TOTAL_PRICE , ENCL_PATH , ENCL_NAME ,TENANT_ID, STATUS, + CREATE_TIME, UPDATE_TIME, CREATE_USER, UPDATE_USER, IS_DELETED, CREATE_DEPT + + + diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/PhenomenonMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/PhenomenonMapper.xml new file mode 100644 index 0000000..e12c289 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/PhenomenonMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/PowerMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/PowerMapper.xml new file mode 100644 index 0000000..73820fc --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/PowerMapper.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + ID, MON, INSTALLED_CAPACITY , PLANNED_POWER_YEAR , PLANNED_POWER_MON , POWER_MON , POWER_RATE_MON ,POWER_YEAR , + POWER_RATE_YEAR , DOUBLE_QUALIFY_RATE , TYPE , TENANT_ID, STATUS, CREATE_TIME, UPDATE_TIME, CREATE_USER, UPDATE_USER, + IS_DELETED, CREATE_DEPT + + + diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/RecordMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/RecordMapper.xml new file mode 100644 index 0000000..6086a5f --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/RecordMapper.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + SELECT LAST_INSERT_ID() AS id + + insert into hy_st_alarm_record (id, station_id, real_id, + status, phone_record, process_desc, + create_time, processor, process_time + ) + values (#{id,jdbcType=BIGINT}, #{stationId,jdbcType=VARCHAR}, #{realId,jdbcType=VARCHAR}, + #{status,jdbcType=TINYINT}, #{phoneRecord,jdbcType=VARCHAR}, #{processDesc,jdbcType=VARCHAR}, + #{createTime,jdbcType=TIMESTAMP}, #{processor,jdbcType=VARCHAR}, #{processTime,jdbcType=TIMESTAMP} + ) + + diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/SolveMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/SolveMapper.xml new file mode 100644 index 0000000..3e900d4 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/SolveMapper.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + ID, SOLVE_DATE , SOLVE_QUANTITY , SOLVE_SUC_QUANTITY ,TENANT_ID, STATUS, CREATE_TIME, + UPDATE_TIME, CREATE_USER, UPDATE_USER, IS_DELETED, CREATE_DEPT + + + diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/StAlarmRecordMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/StAlarmRecordMapper.xml deleted file mode 100644 index cfe513d..0000000 --- a/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/StAlarmRecordMapper.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - SELECT LAST_INSERT_ID() AS id - - insert into hy_st_alarm_record (id, station_id, real_id, - status, phone_record, process_desc, - create_time, processor, process_time - ) - values (#{id,jdbcType=BIGINT}, #{stationId,jdbcType=VARCHAR}, #{realId,jdbcType=VARCHAR}, - #{status,jdbcType=TINYINT}, #{phoneRecord,jdbcType=VARCHAR}, #{processDesc,jdbcType=VARCHAR}, - #{createTime,jdbcType=TIMESTAMP}, #{processor,jdbcType=VARCHAR}, #{processTime,jdbcType=TIMESTAMP} - ) - - - \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/StationAttrConfigMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/StationAttrConfigMapper.xml new file mode 100644 index 0000000..bf7b1e0 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/StationAttrConfigMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/StationAttributeMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/StationAttributeMapper.xml new file mode 100644 index 0000000..525d6fc --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/StationAttributeMapper.xml @@ -0,0 +1,15 @@ + + + + + + + \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/StationMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/StationMapper.xml new file mode 100644 index 0000000..23312d6 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/StationMapper.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/UseMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/UseMapper.xml new file mode 100644 index 0000000..021eaf7 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/UseMapper.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/safeproduct/CompanyMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/safeproduct/CompanyMapper.xml new file mode 100644 index 0000000..63605a2 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/safeproduct/CompanyMapper.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/safeproduct/InstanceMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/safeproduct/InstanceMapper.xml new file mode 100644 index 0000000..1e19e05 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/safeproduct/InstanceMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/safeproduct/MonthMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/safeproduct/MonthMapper.xml new file mode 100644 index 0000000..38f7539 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/safeproduct/MonthMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/safeproduct/TrialMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/safeproduct/TrialMapper.xml new file mode 100644 index 0000000..6fec5d0 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/safeproduct/TrialMapper.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/ticket/TicketEvaluateMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/ticket/TicketEvaluateMapper.xml new file mode 100644 index 0000000..d378bac --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/ticket/TicketEvaluateMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/ticket/TicketMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/ticket/TicketMapper.xml new file mode 100644 index 0000000..24b9def --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/ticket/TicketMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/ticket/WorkTicketMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/ticket/WorkTicketMapper.xml new file mode 100644 index 0000000..3eb5e81 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/ticket/WorkTicketMapper.xml @@ -0,0 +1,4 @@ + + + + diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/controller/CentralMonitorController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/controller/CentralMonitorController.java index da4018a..0989365 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/controller/CentralMonitorController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/controller/CentralMonitorController.java @@ -3,7 +3,7 @@ package com.hnac.hzims.operational.config.controller; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.operational.config.service.CentralMonitorService; import com.hnac.hzims.operational.station.service.IRealMonitorService; -import com.hnac.hzims.operational.station.vo.RealStationVo; +import com.hnac.hzims.operational.main.vo.RealStationVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/CentralMonitorService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/CentralMonitorService.java index 46bedcf..040e7c9 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/CentralMonitorService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/CentralMonitorService.java @@ -1,7 +1,7 @@ package com.hnac.hzims.operational.config.service; -import com.hnac.hzims.operational.station.vo.RealStationVo; +import com.hnac.hzims.operational.main.vo.RealStationVo; import java.util.List; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/CentralMonitorServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/CentralMonitorServiceImpl.java index 07b632d..2124c9c 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/CentralMonitorServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/CentralMonitorServiceImpl.java @@ -4,7 +4,7 @@ import com.hnac.hzims.operational.config.service.CentralMonitorService; import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.service.IStationService; -import com.hnac.hzims.operational.station.vo.RealStationVo; +import com.hnac.hzims.operational.main.vo.RealStationVo; import lombok.RequiredArgsConstructor; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.CollectionUtil; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/StAlamRecordServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/StAlamRecordServiceImpl.java index 5114295..e43b935 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/StAlamRecordServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/StAlamRecordServiceImpl.java @@ -236,7 +236,7 @@ public class StAlamRecordServiceImpl extends BaseServiceImpl stFocusPropertiesEntity.getUpperUpperLimit() || Double.valueOf(value) < stFocusPropertiesEntity.getLowerLowerLimit())) { if (alarmList.size() > 0) { - time = new Date().getTime() - alarmList.get(0).getProcessTime().getTime(); + time = System.currentTimeMillis() - alarmList.get(0).getProcessTime().getTime(); } if ((recordList.size() == 0 && alarmList.size() == 0) || (time / 1000 / 60 > 30 && recordList.size() == 0)) { isWarn = setStAlarmRecordEntity(dataSet, stFocusPropertiesEntity, isWarn, 2, true); @@ -251,7 +251,7 @@ public class StAlamRecordServiceImpl extends BaseServiceImpl stFocusPropertiesEntity.getUpperLimit() && Double.valueOf(value) < stFocusPropertiesEntity.getUpperUpperLimit()) || (Double.valueOf(value) > stFocusPropertiesEntity.getLowerLowerLimit() && Double.valueOf(value) < stFocusPropertiesEntity.getLowerLimit()))) { if (alarmList.size() > 0) { - time = new Date().getTime() - alarmList.get(0).getProcessTime().getTime(); + time = System.currentTimeMillis() - alarmList.get(0).getProcessTime().getTime(); } if ((recordList.size() == 0 && alarmList.size() == 0) || (time / 1000 / 60 > 30 && recordList.size() == 0)) { isWarn = setStAlarmRecordEntity(dataSet, stFocusPropertiesEntity, isWarn, ConfigStatus.ConfigStatusEnum.RED.getStatus(), false); @@ -737,15 +737,15 @@ public class StAlamRecordServiceImpl extends BaseServiceImpl list = JSONArray.parseArray(result,FaultVo.class); if(CollectionUtil.isEmpty(list)){ - return new ArrayList<>(); + return null; } + log.error("fault_list_stations: {}",stations); + log.error("fault_list_list: {}",list); Map map = stations.stream().collect(Collectors.toMap(StationEntity::getCode,StationEntity::getName)); - // 查询已处理预警数据 - List handles = handleService.handles(Collections.singletonList(AbnormalAlarmConstant.EARLY_WARNING),null); - if(CollectionUtil.isEmpty(handles)){ - return list.stream().filter(fault -> map.containsKey(fault.getStation())).peek(o-> o.setStationName(map.get(o.getStation()))).collect(Collectors.toList()); - } - return list.stream().filter(fault -> !handles.stream().map(AlarmHandleEntity::getAlarmId).collect(Collectors.toList()).contains(fault.getFaultId()) && map.containsKey(fault.getStation())).peek(o-> o.setStationName(map.get(o.getStation()))).collect(Collectors.toList()); + return list.stream().filter(fault -> map.containsKey(fault.getStation())).map(o->{ + o.setStationName(map.get(o.getStation())); + return o; + }).collect(Collectors.toList()); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/IOperDefectService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/IOperDefectService.java index f1e652b..30ab90c 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/IOperDefectService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/IOperDefectService.java @@ -1,101 +1,13 @@ package com.hnac.hzims.operational.defect.service; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.hnac.hzims.operational.defect.entity.OperDefectEntity; -import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity; -import com.hnac.hzims.operational.defect.vo.OperDefectVO; -import com.hnac.hzims.operational.report.vo.DefectReportsVO; -import com.hnac.hzims.vo.SafeCheckStatisticVO; import org.springblade.core.mp.base.BaseService; -import org.springblade.core.tool.api.R; -import org.springblade.flow.core.entity.BladeFlow; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.time.LocalDate; -import java.util.List; -import java.util.Map; /** - * 服务类 - * - * @author Chill + * @author ysj */ public interface IOperDefectService extends BaseService { - /** - * 开始问题处理流程 - * 问题处理流程的第一个处理节点人key 必须是 problemUser - * @param - */ - void startFlow(OperPhenomenonEntity entity, OperDefectEntity defectEntity); - /** - * 处理问题 - * @param flow - * @return - */ - boolean handleProcess(BladeFlow flow); - - /** - * 获取缺陷的统计月报 - * @param month 格式:"2021-01" - */ - Map getDefectStatistics(String month); - - /** - * 导出缺陷统计月报报表 - * @param response - * @param month 格式 "2021-01" - * @throws IOException - */ - void exportFualtMonthExcel(HttpServletResponse response, String month) throws IOException; - - - List getDefectList(String emCode,List list); - - List getDefectByEmCodeList(String emCode); - - /** - * 站点月报统计 - 消缺 - * @param startDate - * @param endDate - * @param deptIdList - * @return - */ - List getFaultByFaultCode(LocalDate startDate,LocalDate endDate,List deptIdList); - - List getFaultByFaultCode(Map params); - - List> getDefectConclusion(Map params); - - /** - * 缺陷详情 - * @param defect - * @return - */ - R detail(OperDefectEntity defect); - - /** - * 获取安全检查消缺项统计 - * @param startDate 开始时间 - * @param endDate 结束时间 - * @param dept 机构ID - * @param defectType 缺陷类型;1: 重大缺陷 2:一般缺陷 - * @return SafeCheckStatisticVO 对象 - */ - SafeCheckStatisticVO getDefectCheck(String startDate,String endDate,Long dept,String defectType); - - boolean updateDefectInfo(OperDefectEntity entity); - - boolean updateDefectHanderState(OperDefectEntity entity); - - /** - * 分页查询 - * @param operDefectEntityPage - * @param defect - * @return - */ - IPage selectPage(Page operDefectEntityPage, OperDefectEntity defect); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java index 8a6cb12..f1f74b4 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java @@ -269,6 +269,7 @@ public class HydropowerServiceImpl implements HydropowerService { stationList.forEach(station -> { // 站点设备集合 List stationDevices = devices.stream().filter(device -> device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); + log.error("load_power_data station :" + station.getCode() + "==== device :" + stationDevices ); Map generateMap = this.getGenerateYear(station,stationDevices,start,end); if(MapUtils.isEmpty(generateMap)){ return; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java index 7150980..9cd48e0 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java @@ -27,10 +27,10 @@ import com.hnac.hzims.operational.station.service.IRealMonitorService; import com.hnac.hzims.operational.station.service.IStationAttrConfigService; import com.hnac.hzims.operational.station.service.IStationAttributeService; import com.hnac.hzims.operational.station.service.IStationService; -import com.hnac.hzims.operational.station.vo.RealAttributeVo; -import com.hnac.hzims.operational.station.vo.RealDeviceVo; -import com.hnac.hzims.operational.station.vo.RealStationVo; -import com.hnac.hzims.operational.station.vo.WeatherVo; +import com.hnac.hzims.operational.main.vo.RealAttributeVo; +import com.hnac.hzims.operational.main.vo.RealDeviceVo; +import com.hnac.hzims.operational.main.vo.RealStationVo; +import com.hnac.hzims.operational.main.vo.WeatherVo; import com.hnac.hzinfo.sdk.v5.redis.RedisClient; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CheckItemServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CheckItemServiceImpl.java index 0a8eed5..b80c3d7 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CheckItemServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CheckItemServiceImpl.java @@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzims.operational.duty.dto.ChangeShiftsReqDTO; import com.hnac.hzims.operational.duty.dto.ChangeShiftsRspDTO; -import com.hnac.hzims.operational.duty.entity.ImsDutyGroupEntity; import com.hnac.hzims.operational.duty.feign.IDutyRecClient; import com.hnac.hzims.operational.feign.IOperTaskClient; import com.hnac.hzims.safeproduct.dto.CheckItemDTO; @@ -27,7 +26,6 @@ import com.hnac.hzims.ticket.workTicket.feign.IOperateTicketClient; import com.hnac.hzims.ticket.workTicket.feign.ITicketInfoClient; import com.hnac.hzims.vo.SafeCheckStatisticVO; import com.hnac.hzinfo.inspect.task.feign.IInspectTaskClient; -import jodd.util.ArraysUtil; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; @@ -43,7 +41,6 @@ import org.springblade.system.feign.ISysClient; import org.springblade.system.user.cache.UserCache; import org.springblade.system.user.entity.User; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import java.lang.reflect.Field; import java.time.LocalDateTime; diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/constant/TicketProcessConstant.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/constant/TicketProcessConstant.java index 46a48bc..1ad02a8 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/constant/TicketProcessConstant.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/constant/TicketProcessConstant.java @@ -10,5 +10,14 @@ package com.hnac.hzims.ticket.processflow.constant; */ public class TicketProcessConstant { - public final static String STARTEVENT = "workTicketFlow"; + /** + * 第一种工作票的key + */ + public static final String FIRST_TICKET_KEY = "networking"; + + + /** + * 操作票 + */ + public static final String OPERATION_TICKET_KEY = "moreActionBankDirect"; } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/consumer/StandardWorkTicketConsumer.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/consumer/StandardWorkTicketConsumer.java index 5936bed..956dc1e 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/consumer/StandardWorkTicketConsumer.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/consumer/StandardWorkTicketConsumer.java @@ -44,11 +44,12 @@ public class StandardWorkTicketConsumer implements IQueueConsume { WorkflowQueue ticker = new WorkflowQueue(); ticker.setProcessDefinitionKey(taskDefinitionKey); //判断执行具体的实现类 - ProcessService ticketService = ticketServiceList.stream().filter(item -> item.isWorkflowProcess(ticker)).findFirst().orElse(null); - if (ObjectUtils.isNotEmpty(ticketService)) { + ProcessService processService = + ticketServiceList.stream().filter(item -> item.isWorkflowProcess(ticker)).findFirst().orElse(null); + if (ObjectUtils.isNotEmpty(processService)) { //执行业务方法 try { - ticketService.calculate(response); + processService.calculate(response); } catch (Exception e) { e.printStackTrace(); //todo 业务出错误 做补偿 diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/controller/ProcessDictController.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/controller/ProcessDictController.java new file mode 100644 index 0000000..f267139 --- /dev/null +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/controller/ProcessDictController.java @@ -0,0 +1,54 @@ +package com.hnac.hzims.ticket.processflow.controller; + +import com.hnac.hzims.ticket.processflow.entity.ProcessDict; +import com.hnac.hzims.ticket.processflow.service.ProcessDictService; +import groovy.util.logging.Slf4j; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/6/5 9:35 + */ + +@Slf4j +@RequestMapping("/process-dict") +@RestController +@RequiredArgsConstructor +public class ProcessDictController { + + + private final ProcessDictService processDictService; + + + + + @GetMapping("/test") + public void test(){ + // ProcessDict processDict = new ProcessDict(); + // processDict.setDictKey("networking"); + // processDict.setDictSort(0); + // processDict.setDictValue("workTicketFlow"); + // processDict.setDictLabel("第一种工作票"); + // processDict.setIsDefault("Y"); + // processDict.setRemark("第一种工作票"); + // processDict.setDictType("工作票"); + // processDictService.save(processDict); + + ProcessDict processDict = new ProcessDict(); + processDict.setDictKey("moreActionBankDirect"); + processDict.setDictSort(0); + processDict.setDictValue("standardTicketFlow"); + processDict.setDictLabel("操作票"); + processDict.setIsDefault("Y"); + processDict.setRemark("操作票"); + processDict.setDictType("两票管理"); + processDictService.save(processDict); + } + + +} diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/entity/ProcessDict.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/entity/ProcessDict.java new file mode 100644 index 0000000..185fef7 --- /dev/null +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/entity/ProcessDict.java @@ -0,0 +1,115 @@ +package com.hnac.hzims.ticket.processflow.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; +import org.springblade.core.mp.base.BaseEntity; +import org.springblade.core.tenant.mp.TenantEntity; + +import java.time.LocalDateTime; +import java.util.Date; + +/** + * 票据字典表 + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/6/5 8:33 + */ +@Data +@ApiModel(value = "ProcessDict",description = "票据字典表") +@Accessors(chain = true) +@TableName("process_dict") +public class ProcessDict { + + + /** + * 票据编码 + */ + @TableId(type = IdType.AUTO) + @ApiModelProperty("票据编码") + private Long dictCode; + + + /** + *票据排序 + */ + @ApiModelProperty("票据排序") + private Integer dictSort; + + + /** + *票据字典码 + */ + @ApiModelProperty("票据字典码") + private String dictKey; + + + /** + *票据流程标识 + */ + @ApiModelProperty("票据流程标识") + private String dictValue; + + + + /** + *票据标签 + */ + @ApiModelProperty("票据标签") + private String dictLabel; + + /** + *票据类型 + */ + @ApiModelProperty("票据类型") + private String dictType; + + /** + *是否默认(Y是 N否) + */ + @ApiModelProperty("是否默认(Y是 N否)") + private String isDefault; + + + /** + *状态(0正常 1停用) + */ + @ApiModelProperty("状态(0正常 1停用)") + private Integer status; + + + + /** + * 所属机构 + */ + @ApiModelProperty("所属机构") + private Long createDept; + + + + /** + * 创建时间 + */ + @ApiModelProperty("创建时间") + private LocalDateTime createTime; + + + /** + * 更新时间 + */ + @ApiModelProperty("更新时间") + private LocalDateTime updateTime; + + + + /** + * 票据备注 + */ + @ApiModelProperty("票据备注") + private String remark; +} diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/mapper/ProcessDictMapper.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/mapper/ProcessDictMapper.java new file mode 100644 index 0000000..2bb86f5 --- /dev/null +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/mapper/ProcessDictMapper.java @@ -0,0 +1,14 @@ +package com.hnac.hzims.ticket.processflow.mapper; + +import com.hnac.hzims.ticket.processflow.entity.ProcessDict; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/6/5 8:49 + */ +public interface ProcessDictMapper extends UserDataScopeBaseMapper { + +} diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/service/ProcessDictService.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/service/ProcessDictService.java new file mode 100644 index 0000000..7113a06 --- /dev/null +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/service/ProcessDictService.java @@ -0,0 +1,22 @@ +package com.hnac.hzims.ticket.processflow.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnac.hzims.ticket.processflow.entity.ProcessDict; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/6/5 8:52 + */ +public interface ProcessDictService extends IService { + + + /** + * 根据字典key查询字典value + */ + String selectDictValueByKey(String dictKey); + + + +} diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/service/impl/ProcessDictServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/service/impl/ProcessDictServiceImpl.java new file mode 100644 index 0000000..84fbfd9 --- /dev/null +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/service/impl/ProcessDictServiceImpl.java @@ -0,0 +1,33 @@ +package com.hnac.hzims.ticket.processflow.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnac.hzims.ticket.processflow.entity.ProcessDict; +import com.hnac.hzims.ticket.processflow.mapper.ProcessDictMapper; +import com.hnac.hzims.ticket.processflow.service.ProcessDictService; +import groovy.util.logging.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/6/5 8:59 + */ +@Slf4j +@Service +public class ProcessDictServiceImpl extends ServiceImpl implements ProcessDictService { + /** + * 根据字典key查询字典value + * + * @param dictKey + */ + @Override + public String selectDictValueByKey(String dictKey) { + LambdaQueryChainWrapper processDictLambdaQueryChainWrapper = new LambdaQueryChainWrapper<>(baseMapper); + processDictLambdaQueryChainWrapper.eq(ProcessDict::getDictKey,dictKey); + return processDictLambdaQueryChainWrapper.one().getDictValue(); + } +} diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/core/ProcessIdWorker.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/core/ProcessIdWorker.java index 6fcddf2..6e1fdf9 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/core/ProcessIdWorker.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/core/ProcessIdWorker.java @@ -136,7 +136,7 @@ public class ProcessIdWorker { //6. sequencing 大于等于1000 的话,从头开始 if (sequencing.get() >= 1000) { sequencing.compareAndSet(sequencing.get(), 1); - System.out.println("sequencing >= 1000 被执行呢"); + log.error("sequencing >= 1000 被执行呢"); redisTemplate.delete(key); // cacheMap.remove(key); return sequencing.get(); diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/serviceimpl/OneTicketProcessServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/serviceimpl/OneTicketProcessServiceImpl.java index 82f64ce..4b1c653 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/serviceimpl/OneTicketProcessServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/serviceimpl/OneTicketProcessServiceImpl.java @@ -1,6 +1,7 @@ package com.hnac.hzims.ticket.processflow.strategy.serviceimpl; import com.hnac.hzims.ticket.processflow.constant.TicketProcessConstant; +import com.hnac.hzims.ticket.processflow.service.ProcessDictService; import com.hnac.hzims.ticket.response.ProcessWorkFlowResponse; import com.hnac.hzims.ticket.processflow.strategy.abstracts.ProcessAbstractService; import com.hnac.hzims.ticket.processflow.strategy.entity.WorkflowQueue; @@ -9,6 +10,8 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import static com.hnac.hzims.ticket.processflow.constant.TicketProcessConstant.FIRST_TICKET_KEY; + /** * 开工作票流程实现类 * @@ -27,6 +30,15 @@ public class OneTicketProcessServiceImpl extends ProcessAbstractService { private final TicketProcessService ticketProcessService; + + private final ProcessDictService processDictService; + + + + + + + /** * 设置执行那种实现类 * @@ -35,12 +47,13 @@ public class OneTicketProcessServiceImpl extends ProcessAbstractService { */ @Override public Boolean isWorkflowProcess(WorkflowQueue flowQueue) { - log.info("是否执行开第一种工作票流程环节操作~~~~,流程ticket: {}", flowQueue); - if (TicketProcessConstant.STARTEVENT.equals(flowQueue.getProcessDefinitionKey())) { - log.info("已执行第一种开工作票流程环节操作~~~~"); + log.info("是否执行开工作票流程环节操作~~~~,流程ticket: {}", flowQueue); + String dictValue = processDictService.selectDictValueByKey(FIRST_TICKET_KEY); + if (dictValue.equals(flowQueue.getProcessDefinitionKey())) { + log.info("已执行工作票流程环节操作~~~~"); return true; } - log.error("未是否执行第一种开工作票流程环节操作,请联系管理员~~~~"); + log.error("未是否执行工作票流程环节操作,请联系管理员~~~~"); return false; } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/serviceimpl/OperationTicketProcessServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/serviceimpl/OperationTicketProcessServiceImpl.java new file mode 100644 index 0000000..7590575 --- /dev/null +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/serviceimpl/OperationTicketProcessServiceImpl.java @@ -0,0 +1,69 @@ +package com.hnac.hzims.ticket.processflow.strategy.serviceimpl; + +import com.hnac.hzims.ticket.processflow.service.ProcessDictService; +import com.hnac.hzims.ticket.processflow.strategy.abstracts.ProcessAbstractService; +import com.hnac.hzims.ticket.processflow.strategy.entity.WorkflowQueue; +import com.hnac.hzims.ticket.response.ProcessWorkFlowResponse; +import com.hnac.hzims.ticket.standardTicket.service.OperationTicketService; +import com.hnac.hzims.ticket.twoTicket.service.TicketProcessService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import static com.hnac.hzims.ticket.processflow.constant.TicketProcessConstant.OPERATION_TICKET_KEY; + +/** + * 开工作票流程实现类 + * + * @Author dfy + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/3/28 8:47 + */ +@Slf4j +@Service +@RequiredArgsConstructor +public class OperationTicketProcessServiceImpl extends ProcessAbstractService { + + + + private final OperationTicketService operationTicketService; + + + + private final ProcessDictService processDictService; + + + + + + + + /** + * 设置执行那种实现类 + * + * @param flowQueue + * @return + */ + @Override + public Boolean isWorkflowProcess(WorkflowQueue flowQueue) { + log.info("是否执行开操作票流程环节操作~~~~,流程flowQueue: {}", flowQueue); + String dictValue = processDictService.selectDictValueByKey(OPERATION_TICKET_KEY); + if (dictValue.equals(flowQueue.getProcessDefinitionKey())) { + log.info("已执行操作票流程环节操作~~~~"); + return true; + } + log.error("未是否执行操作票流程环节操作,请联系管理员~~~~"); + return false; + } + + /** + * 两票管理业务方法 + * + * @param response + */ + @Override + public void calculate(ProcessWorkFlowResponse response) { + operationTicketService.findPending(response); + } +} diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/OperationTicketController.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/OperationTicketController.java new file mode 100644 index 0000000..b47e1e2 --- /dev/null +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/OperationTicketController.java @@ -0,0 +1,47 @@ +package com.hnac.hzims.ticket.standardTicket.controller; + +import com.hnac.hzims.ticket.standardTicket.service.OperationTicketService; +import com.hnac.hzims.ticket.twoTicket.vo.operation.StandardTicketInfoVo; +import com.hnac.hzims.ticket.twoTicket.vo.process.WorkTicketVo; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 操作票 + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/6/6 13:46 + */ +@RequiredArgsConstructor +@Slf4j +@RequestMapping("/operation-ticket") +@RestController +public class OperationTicketController { + + + private final OperationTicketService operationTicketService; + + + /** + * 启动流程 + * + * @return + */ + @ApiOperation("启动流程") + @PostMapping("/startUp") + public R start(@RequestBody StandardTicketInfoVo StandardTicketInfoVo) { + operationTicketService.startUp(StandardTicketInfoVo); + return R.success("申请开票成功"); + } + + + + +} diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/OperationTicketService.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/OperationTicketService.java new file mode 100644 index 0000000..f92497d --- /dev/null +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/OperationTicketService.java @@ -0,0 +1,28 @@ +package com.hnac.hzims.ticket.standardTicket.service; + +import com.hnac.hzims.ticket.response.ProcessWorkFlowResponse; +import com.hnac.hzims.ticket.twoTicket.vo.operation.StandardTicketInfoVo; +import com.hnac.hzims.ticket.twoTicket.vo.process.WorkTicketVo; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/6/6 13:48 + */ +public interface OperationTicketService { + + + /** + * 启动流程 + * @param standardTicketInfoVo + */ + void startUp(StandardTicketInfoVo standardTicketInfoVo); + + + /** + * 待处理 + * @param response + */ + void findPending(ProcessWorkFlowResponse response); +} diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/OperationTicketServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/OperationTicketServiceImpl.java new file mode 100644 index 0000000..7934a21 --- /dev/null +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/OperationTicketServiceImpl.java @@ -0,0 +1,360 @@ +package com.hnac.hzims.ticket.standardTicket.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; +import com.hnac.hzims.common.logs.utils.StringUtils; +import com.hnac.hzims.message.MessageConstants; +import com.hnac.hzims.message.dto.MessagePushRecordDto; +import com.hnac.hzims.message.fegin.IMessageClient; +import com.hnac.hzims.operational.station.entity.StationEntity; +import com.hnac.hzims.operational.station.feign.IStationClient; +import com.hnac.hzims.ticket.processflow.service.ProcessDictService; +import com.hnac.hzims.ticket.processflow.strategy.core.ProcessIdWorker; +import com.hnac.hzims.ticket.response.ProcessWorkFlowResponse; +import com.hnac.hzims.ticket.standardTicket.entity.StandardTicketInfoEntity; +import com.hnac.hzims.ticket.standardTicket.entity.StandardTicketMeasureEntity; +import com.hnac.hzims.ticket.standardTicket.service.IStandardTicketInfoService; +import com.hnac.hzims.ticket.standardTicket.service.IStandardTicketMeasureService; +import com.hnac.hzims.ticket.standardTicket.service.OperationTicketService; +import com.hnac.hzims.ticket.twoTicket.vo.operation.StandardTicketInfoVo; +import com.hnac.hzims.ticket.twoTicket.vo.operation.StandardTicketMeasureVo; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.math.NumberUtils; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.BeanUtil; +import org.springblade.flow.core.entity.BladeFlow; +import org.springblade.flow.core.feign.IFlowClient; +import org.springblade.system.feign.ISysClient; +import org.springblade.system.user.cache.UserCache; +import org.springblade.system.user.entity.User; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; + +import java.time.Duration; +import java.time.Instant; +import java.time.LocalDateTime; +import java.util.*; +import java.util.stream.Collectors; + +import static com.hnac.hzims.ticket.processflow.constant.TicketProcessConstant.OPERATION_TICKET_KEY; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/6/6 13:49 + */ + +@Slf4j +@Service +@RequiredArgsConstructor +public class OperationTicketServiceImpl implements OperationTicketService { + + private final IStandardTicketInfoService standardTicketInfoService; + + private final IStandardTicketMeasureService standardTicketMeasureService; + + private final IStationClient stationClient; + + + private final ProcessIdWorker processIdWorker; + + + private final ProcessDictService processDictService; + + + private final IFlowClient flowClient; + + + private final IMessageClient messageClient; + + + private final ISysClient sysClient; + + + /** + * 启动流程 + * + * @param standardTicketInfoVo + */ + @Override + public void startUp(StandardTicketInfoVo standardTicketInfoVo) { + log.info("执行 com.hnac.hzims.ticket.standardTicket.service.impl【startUp】 。。。方法"); + if (standardTicketInfoVo.getSignage() == null) { + throw new ServiceException("票据抬头未配置,请您到站点管理配置"); + } + StationEntity stationEntity = new StationEntity(); + stationEntity.setCode(standardTicketInfoVo.getSignageCode()); + R stationClientOne = stationClient.getOne(stationEntity); + if (!stationClientOne.isSuccess()) { + throw new IllegalArgumentException("票据抬头未配置,请您到站点管理配置?"); + } + StationEntity station = stationClientOne.getData(); + if (station == null) { + throw new ServiceException("票据抬头未配置,请您到站点管理配置"); + } + log.info("前端查的站点编号 :{}", standardTicketInfoVo.getSignage()); + log.info("后端查寻的站点编码 :{}", station.getSignage()); + if (!standardTicketInfoVo.getSignage().equals(station.getSignage())) { + throw new ServiceException("票据抬头未配置,请您到站点管理配置"); + } + + //获取站点编号 + String signage = station.getSignage(); + if (StringUtils.isBlank(signage) || signage.length() < 2) { + throw new ServiceException("票据抬头未配置,请您到站点管理配置"); + } + signage = signage.length() == 2 ? station.getSignage() : station.getSignage().substring(0, 2); + + standardTicketInfoVo.setSignage(signage); + standardTicketInfoVo.setSignageCode(station.getCode()); + //2. 获取编码 + String code = processIdWorker.getTicketByCode(standardTicketInfoVo.getSignage(), this.getTicketWichCode(standardTicketInfoVo.getTicketType()), LocalDateTime.now()); + standardTicketInfoVo.setCode(code); + //3. 保存操作对象 + this.saveStandardTicketInfo(standardTicketInfoVo); + //5. 保存安全措施 + List standardTicketInfoVos = this.saveStandardTicketMeasure( + this.saveStandardTicketMeasureWichTicket(standardTicketInfoVo)); + standardTicketInfoVo.setStandardTicketMeasureVos(standardTicketInfoVos); + //6. 查询第一种工作票值 + String dictValue = processDictService.selectDictValueByKey(OPERATION_TICKET_KEY); + // 7.启动流程 + this.startProcess(standardTicketInfoVo, dictValue); + } + + /** + * 待处理 + * + * @param response + */ + @Override + public void findPending(ProcessWorkFlowResponse response) { + log.info("获取businessKey: {}", response.getBusinessKey()); + log.info("获取taskId: {} ", response.getTaskId()); + log.info("获取下一个审批人是: {} ", response.getNextStepOperator()); + log.info("获取下一个用户Id是: {} ", response.getUserId()); + log.info("获取当前任务名称是: {} ", response.getTaskName()); + log.info("获取根据handleType区分是用户还是候选组角色: {}", response.getHandleType()); + //json转换表单 + String formData = JSON.toJSONString(response.getVariables()); + log.info("获取表单的数据:{}", formData); + StandardTicketInfoVo standardTicketInfoVo = null; + try { + JSONObject jsonObject = JSONObject.parseObject(formData); + standardTicketInfoVo = JSONObject.toJavaObject(jsonObject, StandardTicketInfoVo.class); + } catch (Exception e) { + log.error("获取表单出现异常了~~~~"); + throw new IllegalArgumentException(e.getMessage()); + } + + //1.查询操作票信息 + Long id = NumberUtils.toLong(response.getBusinessKey()); + StandardTicketInfoEntity standardTicketInfoEntity = standardTicketInfoService.getById(id); + if (ObjectUtils.isEmpty(standardTicketInfoEntity)) { + log.error("获取操作票不存在"); + return; + } + //设置id + StandardTicketInfoEntity newStandardTicketInfoEntity = new StandardTicketInfoEntity(); + BeanUtils.copyProperties(standardTicketInfoVo, newStandardTicketInfoEntity); + newStandardTicketInfoEntity.setId(id); + //填充操作票信息 + saveStandardTicketInfoEntity(newStandardTicketInfoEntity, response); + newStandardTicketInfoEntity.setProcessInstanceId(response.getProcessInstanceId()); + standardTicketInfoService.updateById(newStandardTicketInfoEntity); + + //更新安全措施 + List standardTicketMeasureVos = standardTicketInfoVo.getStandardTicketMeasureVos(); + if (CollectionUtils.isNotEmpty(standardTicketMeasureVos)) { + List standardTicketMeasureEntities = standardTicketMeasureVos.stream().map(standardTicketMeasureVo -> { + StandardTicketMeasureEntity standardTicketMeasureEntity = new StandardTicketMeasureEntity(); + BeanUtils.copyProperties(standardTicketMeasureVo, standardTicketMeasureEntity); + return standardTicketMeasureEntity; + }).collect(Collectors.toList()); + standardTicketMeasureService.updateBatchById(standardTicketMeasureEntities); + } + + + //推送消息 + if (response.getTaskId() != null) { + MessagePushRecordDto message = new MessagePushRecordDto(); + message.setBusinessClassify("business"); + message.setBusinessKey(MessageConstants.BusinessClassifyEnum.OPERATIONTICKETMESSAGE.getKey()); + message.setSubject(MessageConstants.BusinessClassifyEnum.OPERATIONTICKETMESSAGE.getDescription()); + message.setTaskId(standardTicketInfoEntity.getId()); + message.setTenantId("200000"); + message.setTypes(Arrays.asList(MessageConstants.APP_PUSH, MessageConstants.WS_PUSH)); + message.setPushType(MessageConstants.IMMEDIATELY); + //您有一张工作票待审批,工作内容:*****,审批环节:*****; + String countent = + "您有一张工作票待审批,工作内容:".concat(standardTicketInfoEntity.getTitle()) + .concat(",审批环节:") + .concat(response.getTaskName()); + message.setContent(countent); + message.setDeptId(standardTicketInfoEntity.getCreateDept()); + R deptName = sysClient.getDeptName(standardTicketInfoEntity.getCreateDept()); + if (deptName.isSuccess()) { + message.setDeptName(deptName.getData()); + } + String userIds = response.getUserId(); + if (StringUtils.isBlank(userIds)) { + log.error("推送的消息不能为空哦,{}", userIds); + return; + } + String[] split = userIds.split(","); + for (String userId : split) { + message.setPusher(userId); + User user = UserCache.getUser(NumberUtils.toLong(userId)); + if (ObjectUtils.isNotEmpty(user)) { + message.setPusherName(user.getName()); + } + message.setAccount(userId); + + message.setCreateUser(NumberUtils.toLong(userId)); + messageClient.sendMessage(message); + } + } + } + + /** + * 填充数据 + * + * @param newStandardTicketInfoEntity + * @param response + */ + private void saveStandardTicketInfoEntity(StandardTicketInfoEntity newStandardTicketInfoEntity, ProcessWorkFlowResponse response) { + String flowDescription = ""; + //如果response.getHandleType() 是0使用户 + newStandardTicketInfoEntity.setFlowUserId(response.getUserId()); + newStandardTicketInfoEntity.setNextStepOperator(response.getNextStepOperator()); + flowDescription = "审批中,当前环节是".concat(response.getTaskName()).concat(",待").concat(response.getNextStepOperator()).concat("审批"); + //如果taskId为空 + String taskId = response.getTaskId(); + if (StringUtils.isEmpty(taskId)) { + newStandardTicketInfoEntity.setFlowDescription("结束"); + newStandardTicketInfoEntity.setFlowTaskId(" "); + newStandardTicketInfoEntity.setFlowTaskName("结束"); + newStandardTicketInfoEntity.setNextStepOperator(" "); + newStandardTicketInfoEntity.setFlowStatus(999); + } else { + newStandardTicketInfoEntity.setFlowTaskId(taskId); + newStandardTicketInfoEntity.setFlowTaskName(response.getTaskName()); + newStandardTicketInfoEntity.setFlowDescription(flowDescription); + } + } + + /** + * 启动流程 + * + * @param standardTicketInfoVo + * @param dictValue + */ + private void startProcess(StandardTicketInfoVo standardTicketInfoVo, String dictValue) { + Instant start = Instant.now(); + Map params = new HashMap<>(4); + params.put("standardTicketInfoVo", standardTicketInfoVo); + params.put("taskId", standardTicketInfoVo.getId()); + params.put("guardianUserIds", "taskUser_".concat(standardTicketInfoVo.getGuardian().toString())); + //已开启流程 + R processInstanceContainNameByKey = flowClient.startProcessInstanceContainNameByKey(dictValue, + String.valueOf(standardTicketInfoVo.getId()), standardTicketInfoVo.getTitle(), params); + if (!processInstanceContainNameByKey.isSuccess()) { + log.error("processInstanceContainNameByKey {}", processInstanceContainNameByKey.getMsg()); + throw new ServiceException("不好意思,您暂无权限..."); + } + Duration between = Duration.between(start, Instant.now()); + log.info("================================================================"); + log.info("耗时: " + (between.getSeconds()) + "秒"); + log.info("耗时: " + (between.toMillis()) + "毫秒"); + log.info("================================================================"); + } + + + /** + * 设置安全措施值 + * + * @param standardTicketInfoVo + * @return + */ + private List saveStandardTicketMeasureWichTicket(StandardTicketInfoVo standardTicketInfoVo) { + List standardTicketMeasureVos = standardTicketInfoVo.getStandardTicketMeasureVos(); + if (CollectionUtils.isNotEmpty(standardTicketMeasureVos)) { + List measureEntityList = BeanUtil.copyProperties(standardTicketMeasureVos, + StandardTicketMeasureEntity.class); + List collect = measureEntityList.stream().map(item -> { + item.setTicketId(standardTicketInfoVo.getId()); + return item; + }).collect(Collectors.toList()); + return collect; + + } + return null; + } + + /** + * 保存安全措施 + * + * @param measureEntityList + * @return + */ + private List saveStandardTicketMeasure(List measureEntityList) { + if (CollectionUtils.isEmpty(measureEntityList)) { + log.error("安全措施为空哦"); + return new ArrayList<>(); + } + boolean save = standardTicketMeasureService.saveBatch(measureEntityList); + if (!save) { + throw new ServiceException("Save failed"); + } + + return measureEntityList.stream().map(item -> { + StandardTicketMeasureVo standardTicketMeasureVo = new StandardTicketMeasureVo(); + BeanUtils.copyProperties(item, standardTicketMeasureVo); + return standardTicketMeasureVo; + }).collect(Collectors.toList()); + } + + /** + * 保存工作对象 + * + * @param standardTicketInfoVo + * @return + */ + private void saveStandardTicketInfo(StandardTicketInfoVo standardTicketInfoVo) { + StandardTicketInfoEntity standardTicketInfo = new StandardTicketInfoEntity(); + BeanUtils.copyProperties(standardTicketInfoVo, standardTicketInfo); + boolean save = standardTicketInfoService.save(standardTicketInfo); + if (!save) { + throw new ServiceException("Save failed"); + } + BeanUtils.copyProperties(standardTicketInfo, standardTicketInfoVo); + } + + + /** + * 工作类型生成工作票类型 + */ + private String getTicketWichCode(String type) { + String result = null; + switch (type) { + case "3": + result = "DZ"; + break; + case "4": + result = type; + break; + case "5": + result = type; + break; + default: + result = "DZ"; + break; + } + return result; + } +} diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/constant/TicketConstant.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/constant/TicketConstant.java new file mode 100644 index 0000000..f74288f --- /dev/null +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/constant/TicketConstant.java @@ -0,0 +1,58 @@ +package com.hnac.hzims.ticket.twoTicket.constant; + +/** + * 定义ticket常量 + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/6/2 13:48 + */ +public class TicketConstant { + + /** + * window操作系统工作票访问路径 + */ + public static final String TICKET_WINDOW_PATH = "hzims-service/ticket/src/main/resources/template"; + + /** + * Liunx操作系统工作票访问路径 + */ + public static final String TICKET_LIUNX_PATH = "/data/hzims/ticket/word/template/ticket"; + + + /** + * window操作系统工作票合并输出路径 + */ + public static final String TICKET_WINDOW_MERGE_PATH = "D:\\导出excel\\"; + + /** + * liunx操作系统工作票合并输出路径 + */ + public static final String TICKET_LIUNX_MERGE_PATH = "/data/hzims/ticket/word/template/ticket/ouput/"; + + /** + * os.name + */ + public static final String OS_NAME = System.getProperty("os.name"); + + + /** + * 安全隔离措施附页 + */ + public static final String SECURE_PAGE = "/secondary/工作票安全措施附页.docx"; + + /** + * 危险点分析与预控措施票 + */ + public static final String SAFETY_PAGE = "/secondary/工作票危险点分析及控制措施票.docx"; + /** + * 动火工作票 + */ + public static final String FLIGHT_PAGE = "/secondary/动火工作票.docx"; + + /** + * 有限空间监测记录单 + */ + public static final String SPACE_PAGE = "/secondary/有限空间监测记录单.docx"; + +} diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/controller/TicketProcessController.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/controller/TicketProcessController.java index caf10e2..a15519d 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/controller/TicketProcessController.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/controller/TicketProcessController.java @@ -61,8 +61,9 @@ public class TicketProcessController { @ApiOperation(value = "新预览") @ApiOperationSupport(order = 11) public void preview(@RequestParam(value = "ticketId", required = true) Long ticketId, + @RequestParam(value = "status", required = true) Integer status, HttpServletResponse response) { - ticketProcessService.newPreview(ticketId, response); + ticketProcessService.newPreview(ticketId, status, response); } } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/entity/WorkTicketFinish.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/entity/WorkTicketFinish.java index 145b692..b785073 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/entity/WorkTicketFinish.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/entity/WorkTicketFinish.java @@ -4,10 +4,12 @@ import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; +import org.springframework.format.annotation.DateTimeFormat; import java.io.Serializable; import java.time.LocalDateTime; @@ -124,6 +126,8 @@ public class WorkTicketFinish implements Serializable { /** * 结束时间 */ + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime workEndTime; diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/TicketProcessService.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/TicketProcessService.java index 156e974..c4522ba 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/TicketProcessService.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/TicketProcessService.java @@ -30,8 +30,10 @@ public interface TicketProcessService { /** * 新预览 + * + * @param status * @param response * @return */ - void newPreview(Long ticketId, HttpServletResponse response); + void newPreview(Long ticketId, Integer status, HttpServletResponse response); } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java index 5931c64..d536b9d 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java @@ -4,11 +4,14 @@ package com.hnac.hzims.ticket.twoTicket.service.impl; import cn.afterturn.easypoi.word.WordExportUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; +import com.google.common.collect.Lists; import com.hnac.hzims.common.logs.utils.StringUtils; +import com.hnac.hzims.message.MessageConstants; +import com.hnac.hzims.message.dto.MessagePushRecordDto; +import com.hnac.hzims.message.fegin.IMessageClient; import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity; import com.hnac.hzims.operational.access.feign.IOperAccessTaskClient; import com.hnac.hzims.operational.feign.IAccessTaskClient; @@ -18,14 +21,18 @@ import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.feign.IStationClient; import com.hnac.hzims.ticket.constants.TicketConstants; import com.hnac.hzims.ticket.constants.WorkTicketConstants; +import com.hnac.hzims.ticket.processflow.service.ProcessDictService; import com.hnac.hzims.ticket.processflow.strategy.core.ProcessIdWorker; import com.hnac.hzims.ticket.response.ProcessWorkFlowResponse; +import com.hnac.hzims.ticket.twoTicket.constant.TicketConstant; import com.hnac.hzims.ticket.twoTicket.entity.TicketInfoDanger; import com.hnac.hzims.ticket.twoTicket.entity.WorkTicketFinish; import com.hnac.hzims.ticket.twoTicket.service.IFirstWorkTicketService; import com.hnac.hzims.ticket.twoTicket.service.IWorkTicketFinishService; import com.hnac.hzims.ticket.twoTicket.service.TicketInfoDangerService; import com.hnac.hzims.ticket.twoTicket.service.TicketProcessService; +import com.hnac.hzims.ticket.twoTicket.utils.WordHelper; +import com.hnac.hzims.ticket.twoTicket.utils.WordMapUtils; import com.hnac.hzims.ticket.twoTicket.vo.process.FristWorkTicketVo; import com.hnac.hzims.ticket.twoTicket.vo.process.WorkTicketVo; import com.hnac.hzims.ticket.utils.MergeDocUtils; @@ -48,6 +55,7 @@ import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.flow.core.entity.BladeFlow; import org.springblade.flow.core.feign.IFlowClient; +import org.springblade.system.feign.ISysClient; import org.springblade.system.user.cache.UserCache; import org.springblade.system.user.entity.User; import org.springblade.system.user.feign.IUserClient; @@ -58,12 +66,15 @@ import org.springframework.transaction.annotation.Transactional; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import java.io.File; -import java.io.FileOutputStream; +import java.time.Duration; +import java.time.Instant; import java.time.LocalDate; import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; +import static com.hnac.hzims.ticket.processflow.constant.TicketProcessConstant.FIRST_TICKET_KEY; + /** * 开票处理流程实现类 @@ -108,8 +119,6 @@ public class TicketProcessServiceImpl implements TicketProcessService { private final IAccessTaskClient accessTaskClient; - private String newFirstWorkTicketFlowKey = "workTicketFlow"; - private final IStationClient stationClient; @@ -137,6 +146,15 @@ public class TicketProcessServiceImpl implements TicketProcessService { private final TicketInfoDangerService ticketInfoDangerService; + private final ProcessDictService processDictService; + + + private final IMessageClient messageClient; + + + private final ISysClient sysClient; + + /** * 启动开票流程 * @@ -148,35 +166,36 @@ public class TicketProcessServiceImpl implements TicketProcessService { public void startUp(WorkTicketVo workTicketVo) { log.info("执行 com.hnac.hzims.ticket.twoTicket.service.impl【startUp】 。。。方法"); if (workTicketVo.getWorkTicket().getSignage() == null) { - throw new ServiceException("站点编码不能为空"); + throw new ServiceException("票据抬头未配置,请您到站点管理配置"); } StationEntity stationEntity = new StationEntity(); stationEntity.setCode(workTicketVo.getWorkTicket().getSignageCode()); R stationClientOne = stationClient.getOne(stationEntity); if (!stationClientOne.isSuccess()) { - throw new IllegalArgumentException("站点编码不能为空"); + throw new IllegalArgumentException("票据抬头未配置,请您到站点管理配置?"); } StationEntity station = stationClientOne.getData(); if (station == null) { - throw new ServiceException("站点编码不能为空"); + throw new ServiceException("票据抬头未配置,请您到站点管理配置"); } log.info("前端查的站点编号 :{}", workTicketVo.getWorkTicket().getSignage()); log.info("后端查寻的站点编码 :{}", station.getSignage()); if (!workTicketVo.getWorkTicket().getSignage().equals(station.getSignage())) { - throw new ServiceException("站点编码不能为空"); + throw new ServiceException("票据抬头未配置,请您到站点管理配置"); } //获取站点编号 String signage = station.getSignage(); if (StringUtils.isBlank(signage) || signage.length() < 2) { - throw new ServiceException("站点编码不能为空"); + throw new ServiceException("票据抬头未配置,请您到站点管理配置"); } signage = signage.length() == 2 ? station.getSignage() : station.getSignage().substring(0, 2); workTicketVo.getWorkTicket().setSignage(signage); workTicketVo.getWorkTicket().setSignageCode(station.getCode()); //2. 获取编码 - String code = processIdWorker.getTicketByCode(workTicketVo.getWorkTicket().getSignage(), workTicketVo.getWorkTicket().getType(), LocalDateTime.now()); + String code = processIdWorker.getTicketByCode(workTicketVo.getWorkTicket().getSignage(), this.getTicketWichCode(workTicketVo.getWorkTicket().getType()), + LocalDateTime.now()); workTicketVo.getWorkTicket().setCode(code); //3 .保存工作对象 this.saveWorkTicketInfo(workTicketVo.getWorkTicket()); @@ -184,9 +203,11 @@ public class TicketProcessServiceImpl implements TicketProcessService { this.saveSafetyMeasures(workTicketVo.getSafetyMeasuresList(), workTicketVo.getWorkTicket()); //5. 保存工作任务 this.saveWorkTicketContentDto(workTicketVo.getWorkTicketContentDtoList(), workTicketVo.getWorkTicket()); - //6. 开启动作流 - this.dealProcess(newFirstWorkTicketFlowKey, workTicketVo); - //7. 处理任务 + //6. 查询第一种工作票值 + String dictValue = processDictService.selectDictValueByKey(FIRST_TICKET_KEY); + //7. 开启动作流 + this.dealProcess(dictValue, workTicketVo); + //8. 处理任务 this.returnTicket(workTicketVo); } @@ -240,31 +261,40 @@ public class TicketProcessServiceImpl implements TicketProcessService { e.printStackTrace(); } //更新安全措施 - List safetyMeasuresList = workTicketVo.getSafetyMeasuresList(); - if (CollectionUtils.isNotEmpty(safetyMeasuresList)) { - log.info("获取安全措施的数据:{}", safetyMeasuresList); - safetyMeasuresList.forEach(item -> { - if (ObjectUtils.isNotEmpty(item.getTicketId())) { - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(WorkTicketSafetyMeasureEntity::getTicketId, item.getTicketId()); - workTicketSafetyMeasureService.update(item, queryWrapper); + try { + List safetyMeasuresList = workTicketVo.getSafetyMeasuresList(); + if (CollectionUtils.isNotEmpty(safetyMeasuresList)) { + log.info("获取安全措施的数据:{}", safetyMeasuresList); + for (WorkTicketSafetyMeasureEntity item : safetyMeasuresList) { + if (ObjectUtils.isNotEmpty(item.getId())) { + workTicketSafetyMeasureService.updateById(item); + } else { + item.setTicketId(workTicketInfo.getId()); + workTicketSafetyMeasureService.save(item); + } } - }); + } + } catch (Exception e) { + e.printStackTrace(); } - //工作票工作任务组 - // List workTicketContentDtoList = workTicketVo.getWorkTicketContentDtoList(); - // if (CollectionUtils.isNotEmpty(workTicketContentDtoList)) { - // log.info("获取工作票工作任务组:{}", workTicketContentDtoList); - // workTicketContentDtoList.forEach(item -> { - // if (ObjectUtils.isEmpty(item.getId())) { - // LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - // queryWrapper.eq(WorkTicketContentEntity::getTicketId, workTicketInfo.getId()); - // contentService.update(item, queryWrapper); - // } else { - // contentService.updateById(item); - // } - // }); - // } + // 第二种 工作票工作任务组 + List workTicketContentDtoList = workTicketVo.getWorkTicketContentDtoList(); + try { + if (CollectionUtils.isNotEmpty(workTicketContentDtoList)) { + log.info("获取工作票工作任务组:{}", workTicketContentDtoList); + workTicketContentDtoList.forEach(item -> { + if (ObjectUtils.isEmpty(item.getId())) { + contentService.save(item); + } else { + contentService.updateById(item); + } + }); + } + } catch (Exception e) { + e.printStackTrace(); + } + + // 工作票延期 WorkTicketDelayEntity workTicketDelay = workTicketVo.getWorkTicketDelay(); try { @@ -286,16 +316,21 @@ public class TicketProcessServiceImpl implements TicketProcessService { } catch (Exception e) { e.printStackTrace(); } + + //工作结束 WorkTicketFinish workTicketFinish = workTicketVo.getWorkTicketFinish(); try { - if (ObjectUtils.isNotEmpty(workTicketFinish) && 99 == workTicket.getFlowStatus().intValue()) { + log.info("工作结束==============>" + (workTicket.getFlowStatus().intValue())); + if (ObjectUtils.isNotEmpty(workTicketFinish)) { WorkTicketFinish ticketFinish = workTicketFinishService.selectByTicketId(workTicketInfo.getId()); log.info("获取工作结束:{}", workTicketFinish); if (ObjectUtils.isEmpty(workTicketFinish.getId()) || ObjectUtils.isEmpty(ticketFinish)) { + log.info("获取工作结束保存成功"); workTicketFinish.setTicketId(workTicketInfo.getId()); workTicketFinishService.save(workTicketFinish); } else { + log.info("获取工作结束更新成功"); workTicketDelay.setInitialTime(LocalDateTime.now()); workTicketFinishService.updateByTicketId(workTicketFinish); } @@ -365,6 +400,52 @@ public class TicketProcessServiceImpl implements TicketProcessService { } catch (Exception e) { e.printStackTrace(); } + + + if (response.getTaskId() != null || response.getUserId() != null) { + //推送消息 + try { + MessagePushRecordDto message = new MessagePushRecordDto(); + message.setBusinessClassify("business"); + message.setBusinessKey(MessageConstants.BusinessClassifyEnum.TICKETMESSAGE.getKey()); + message.setSubject(MessageConstants.BusinessClassifyEnum.TICKETMESSAGE.getDescription()); + message.setTaskId(workTicketInfo.getId()); + message.setTenantId("200000"); + message.setTypes(Arrays.asList(MessageConstants.APP_PUSH, MessageConstants.WS_PUSH)); + message.setPushType(MessageConstants.IMMEDIATELY); + //您有一张工作票待审批,工作内容:*****,审批环节:*****; + String countent = + "您有一张工作票待审批,工作内容:".concat(workTicketInfo.getWorkContent()) + .concat(",审批环节:") + .concat(response.getTaskName()); + message.setContent(countent); + message.setDeptId(workTicketInfo.getCreateDept()); + R deptName = sysClient.getDeptName(workTicketInfo.getCreateDept()); + if (deptName.isSuccess()) { + message.setDeptName(deptName.getData()); + } + String userIds = response.getUserId(); + if (StringUtils.isBlank(userIds)) { + log.error("推送的消息不能为空哦,{}", userIds); + return; + } + String[] split = userIds.split(","); + for (String userId : split) { + message.setPusher(userId); + User user = UserCache.getUser(NumberUtils.toLong(userId)); + if (ObjectUtils.isNotEmpty(user)) { + message.setPusherName(user.getName()); + } + message.setAccount(userId); + + message.setCreateUser(NumberUtils.toLong(userId)); + messageClient.sendMessage(message); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } @@ -405,17 +486,20 @@ public class TicketProcessServiceImpl implements TicketProcessService { // log.error("获取用户信息失败"); // workTicket.setNextStepOperator(null); // } + workTicket.setFlowUserId(response.getUserId()); workTicket.setNextStepOperator(response.getNextStepOperator()); + flowDescription = "审批中,当前环节是".concat(response.getTaskName()).concat(",待").concat(response.getNextStepOperator()).concat("审批"); } //如果taskId为空 String taskId = response.getTaskId(); if (StringUtils.isEmpty(taskId)) { workTicket.setFlowDescription("结束"); - workTicket.setFlowTaskId(" "); + // workTicket.setFlowTaskId(" "); workTicket.setFlowTaskName("结束"); workTicket.setNextStepOperator(" "); workTicket.setStepOperator(" "); + workTicket.setFlowStatus(999); } else { workTicket.setFlowTaskId(taskId); workTicket.setFlowTaskName(response.getTaskName()); @@ -504,35 +588,36 @@ public class TicketProcessServiceImpl implements TicketProcessService { * @param workTicketVo */ public void dealProcess(String newFirstWorkTicketFlowKey, WorkTicketVo workTicketVo) { + Instant start = Instant.now(); //若为线下工作票 则无需开启工作流 Integer status = WorkTicketConstants.FirstWorkTicketStatusEnum.SIGN.getStatus(); if (status.intValue() != workTicketVo.getWorkTicket().getFlowStatus().intValue()) { return; } - log.info("租户Id:{}", AuthUtil.getTenantId()); - log.info("用户部门Id: {}", AuthUtil.getUser().getDeptId()); - log.info("用户Id: {}", AuthUtil.getUserId()); + //log.info("租户Id:{}", AuthUtil.getTenantId()); + //log.info("用户部门Id: {}", AuthUtil.getUser().getDeptId()); + //log.info("用户Id: {}", AuthUtil.getUserId()); //获取签发人角色下的人员 - R> listR = userClient.relationUserListByRoleAlias(AuthUtil.getTenantId(), Long.parseLong(AuthUtil.getUser().getDeptId()), TicketConstants.SIGNER_ROLE); - if (!listR.isSuccess() || CollectionUtil.isEmpty(listR.getData())) { - throw new ServiceException("工作票签发人角色下未查询到相关人员"); - } - log.info("获取签发人角色下的人员: {}", listR.getData()); + // R> listR = userClient.relationUserListByRoleAlias(AuthUtil.getTenantId(), Long.parseLong(AuthUtil.getUser().getDeptId()), TicketConstants.SIGNER_ROLE); + // if (!listR.isSuccess() || CollectionUtil.isEmpty(listR.getData())) { + // throw new ServiceException("工作票签发人角色下未查询到相关人员"); + // } Map params = new HashMap<>(4); params.put("workTicketVo", workTicketVo); //已开启流程 - workTicketVo.setIsState(true); - log.info("获取表单的数据: {}", workTicketVo); R processInstanceContainNameByKey = flowClient.startProcessInstanceContainNameByKey(newFirstWorkTicketFlowKey, String.valueOf(workTicketVo.getWorkTicket().getId()), workTicketVo.getWorkTicket().getWorkContent(), params); log.info("processInstanceContainNameByKey.isSuccess() : {}", processInstanceContainNameByKey.isSuccess()); - log.info("processInstanceContainNameByKey.getData() : {}", processInstanceContainNameByKey.getData()); - log.info("BladeFlow processInstanceContainNameByKey:{}", processInstanceContainNameByKey); if (!processInstanceContainNameByKey.isSuccess() && processInstanceContainNameByKey.getCode() == 500) { log.error("processInstanceContainNameByKey {}", processInstanceContainNameByKey.getMsg()); throw new ServiceException("不好意思,您暂无权限..."); } log.info("获取启动流程数据 : {}", processInstanceContainNameByKey); + Duration between = Duration.between(start, Instant.now()); + log.info("================================================================"); + log.info("耗时: " + (between.getSeconds()) + "秒"); + log.info("耗时: " + (between.toMillis()) + "毫秒"); + log.info("================================================================"); } @@ -660,12 +745,13 @@ public class TicketProcessServiceImpl implements TicketProcessService { * 新预览 * * @param ticketId + * @param status * @param response * @return */ @SneakyThrows @Override - public void newPreview(Long ticketId, HttpServletResponse response) { + public void newPreview(Long ticketId, Integer status, HttpServletResponse response) { String fileName = IdWorker.get32UUID() + ".docx"; // response.setContentType("application/octet-stream;charset=ISO8859-1"); response.setHeader("Content-Disposition", "attachment; filename=" + fileName); @@ -675,65 +761,67 @@ public class TicketProcessServiceImpl implements TicketProcessService { WorkTicketVo workTicketVo = ticketInfoService.selectDetailsById(ticketId); //将查询的数据转换为map Map workTicketInfoMap = this.convertMap(workTicketVo); + Map resultMap = WordHelper.resultMap(workTicketInfoMap); //创建新的map - for (Map.Entry stringObjectEntry : workTicketInfoMap.entrySet()) { + for (Map.Entry stringObjectEntry : resultMap.entrySet()) { log.info("获取map : " + stringObjectEntry.getKey() + "=====>" + stringObjectEntry.getValue()); } WorkTicketInfoEntity workTicket = workTicketVo.getWorkTicket(); if ((workTicket.getIsSafety() == null && workTicket.getIsHazard() == null && workTicket.getIsLimited() == null && workTicket.getIsRailway() == null) || (workTicket.getIsSafety() == null || workTicket.getIsHazard() == null || workTicket.getIsLimited() == null || workTicket.getIsRailway() == null)) { - extractedWithWord(response, workTicketInfoMap); + extractedWithWord(response, resultMap, status); return; } //如果4个多为false 或为空 附件不展示附件 if (!workTicket.getIsSafety() && !workTicket.getIsHazard() && !workTicket.getIsLimited() && !workTicket.getIsRailway()) { - extractedWithWord(response, workTicketInfoMap); + extractedWithWord(response, resultMap, status); return; } - List docFileList = new ArrayList<>(); + List docFileList = new ArrayList<>(); // /template/secondary/工作票安全措施附页.docx - String os = System.getProperty("os.name"); - + String os = TicketConstant.OS_NAME; String prefix = null; //Windows操作系统 if (os != null && os.toLowerCase().startsWith("windows")) { - prefix = "hzims-service/ticket/src/main/resources/template"; + prefix = TicketConstant.TICKET_WINDOW_PATH; } else { - prefix = "/data/hzims/ticket/word/template/ticket"; + prefix = TicketConstant.TICKET_LIUNX_PATH; } + //获取工作票种类 + String workTicketStatus = WordMapUtils.getWorkTicketStatus(status); - docFileList.add(new File(prefix + "/电气第一种工作票模版.docx")); + docFileList.add(new File(prefix + "/" + workTicketStatus)); //安全隔离措施附页 (true,展示附件,false,不展示附件) if (workTicket.getIsSafety()) { - addFile(prefix, "/secondary/工作票安全措施附页.docx", docFileList); + addFile(prefix, TicketConstant.SECURE_PAGE, docFileList); // setWorkTicketPrincipalChange(docFileList); } //危险点分析与预控措施票 (true,展示附件,false,不展示附件) if (workTicket.getIsSafety()) { - addFile(prefix, "/secondary/工作票危险点分析及控制措施票.docx", docFileList); + addFile(prefix, TicketConstant.SAFETY_PAGE, docFileList); // setWorkTicketHazardPointChange(docFileList); } //动火工作票 (true,展示附件,false,不展示附件) if (workTicket.getIsRailway()) { - addFile(prefix, "/secondary/动火工作票.docx", docFileList); + addFile(prefix, TicketConstant.FLIGHT_PAGE, docFileList); // setWorkTicketRailwayChange(docFileList); } //有限空间监测记录单(true,展示附件,false,不展示附件) if (workTicket.getIsLimited()) { - addFile(prefix, "/secondary/有限空间监测记录单.docx", docFileList); + addFile(prefix, TicketConstant.SPACE_PAGE, docFileList); // setWorkTicketLimitedChange(docFileList); } String name = LocalDate.now() + "-" + UUID.randomUUID().toString().replaceAll("-", ""); String docPath = null; if (os != null && os.toLowerCase().startsWith("windows")) { - docPath = "D:\\导出excel\\"; + docPath = TicketConstant.TICKET_WINDOW_MERGE_PATH; } else { - docPath = "/data/hzims/ticket/word/template/ticket/ouput/"; + docPath = TicketConstant.TICKET_LIUNX_MERGE_PATH; } docPath = docPath + name + ".docx"; @@ -742,7 +830,7 @@ public class TicketProcessServiceImpl implements TicketProcessService { //导入文档 File file = new File(docPath); MergeDocUtils.mergeDoc(docFileList, file); - XWPFDocument xwpfDocument = WordExportUtil.exportWord07(docPath, workTicketInfoMap); + XWPFDocument xwpfDocument = WordExportUtil.exportWord07(docPath, resultMap); xwpfDocument.write(response.getOutputStream()); //删除路径 file.delete(); @@ -754,18 +842,21 @@ public class TicketProcessServiceImpl implements TicketProcessService { * * @param response * @param workTicketInfoMap + * @param status * @throws Exception */ - private static void extractedWithWord(HttpServletResponse response, Map workTicketInfoMap) throws Exception { - XWPFDocument doc = WordExportUtil.exportWord07("template/电气第一种工作票模版.docx", workTicketInfoMap); - String os = System.getProperty("os.name"); + private static void extractedWithWord(HttpServletResponse response, Map workTicketInfoMap, Integer status) throws Exception { + String workTicketStatus = WordMapUtils.getWorkTicketStatus(status); + String os = TicketConstant.OS_NAME; //Windows操作系统 if (os != null && os.toLowerCase().startsWith("windows")) { + String url = "template/" + workTicketStatus; + XWPFDocument doc = WordExportUtil.exportWord07(url, workTicketInfoMap); log.info("当前系统版本是:{}", os); - String name = "D:/导出excel/电气第一种工作票模版.docx"; - FileOutputStream fos = new FileOutputStream(name); - doc.write(fos); + doc.write(response.getOutputStream()); } else { + String url = TicketConstant.TICKET_LIUNX_PATH + "/" + workTicketStatus; + XWPFDocument doc = WordExportUtil.exportWord07(url, workTicketInfoMap); //其它操作系统 log.info("当前系统版本是:{}", os); ServletOutputStream outputStream = response.getOutputStream(); @@ -793,38 +884,35 @@ public class TicketProcessServiceImpl implements TicketProcessService { log.info("安全措施: {}", safetyMeasuresList); if (CollectionUtils.isNotEmpty(safetyMeasuresList)) { Map workTicketInfoMap1 = new HashMap<>(); - Map> measureMap = safetyMeasuresList.stream(). - collect(Collectors.groupingBy(WorkTicketSafetyMeasureEntity::getType)); - Arrays.stream(WorkTicketConstants.WorkTicketMeasureTypeEnum.class.getEnumConstants()) - .forEach(measureEnum -> { - if (CollectionUtil.isNotEmpty(measureMap.get(measureEnum.getType()))) { - List> mapList = new ArrayList<>(); - int tempIndex = 1, index = 1; - List workTicketSafetyMeasureEntities = measureMap - .get(measureEnum.getType()); - for (WorkTicketSafetyMeasureEntity measureVO : workTicketSafetyMeasureEntities) { - String type = measureEnum.getType(); - if (tempIndex != Integer.valueOf(type)) { - index = 1; - tempIndex++; - } - log.info("获取安全措施的信息: {}", measureVO); - Map map = PdfUtils.objectToMap(measureVO, true); - map.put("index", index); - map.put("safetyMeasure", ObjectUtil.isNotEmpty(map.get("measure")) ? map.get("measure") : null); - String status = TicketConstants.SafetyMeasureStatusEnum.FINISH.getStatus() - .equals(measureVO.getStatus()) ? "√" : ""; - map.put("status", status); - mapList.add(map); - index++; - } - workTicketInfoMap1.put(measureEnum.getConvertAttributes(), mapList); - } else { - workTicketInfoMap1.put(measureEnum.getConvertAttributes(), - new ArrayList()); + Map> measureMap = safetyMeasuresList.stream().collect(Collectors.groupingBy(WorkTicketSafetyMeasureEntity::getType)); + Arrays.stream(WorkTicketConstants.WorkTicketMeasureTypeEnum.class.getEnumConstants()).forEach(measureEnum -> { + if (CollectionUtil.isNotEmpty(measureMap.get(measureEnum.getType()))) { + List> mapList = new ArrayList<>(); + int tempIndex = 1, index = 1; + List workTicketSafetyMeasureEntities = measureMap.get(measureEnum.getType()); + for (WorkTicketSafetyMeasureEntity measureVO : workTicketSafetyMeasureEntities) { + String type = measureEnum.getType(); + if (tempIndex != Integer.valueOf(type)) { + index = 1; + tempIndex++; } - }); + log.info("获取安全措施的信息: {}", measureVO); + Map map = PdfUtils.objectToMap(measureVO, true); + map.put("index", index); + map.put("safetyMeasure", ObjectUtil.isNotEmpty(map.get("measure")) ? map.get("measure") : null); + String status = TicketConstants.SafetyMeasureStatusEnum.FINISH.getStatus().equals(measureVO.getStatus()) ? "√" : ""; + map.put("status", status); + mapList.add(map); + index++; + } + workTicketInfoMap1.put(measureEnum.getConvertAttributes(), mapList); + } else { + workTicketInfoMap1.put(measureEnum.getConvertAttributes(), new ArrayList()); + } + }); + //验证工作措施是有有数据 + this.isMatterLibraryList(workTicketInfoMap1); // 工作地点保留带电部位或注意事项 this.matterLibraryListWithMap(workTicketInfoMap1); result.putAll(workTicketInfoMap1); @@ -841,7 +929,7 @@ public class TicketProcessServiceImpl implements TicketProcessService { WorkTicketDelayEntity workTicketDelay = workTicketVo.getWorkTicketDelay(); log.info("工作票延期: {}", workTicketDelay); if (ObjectUtils.isNotEmpty(workTicketDelay)) { - result.putAll(PdfUtils.objectToMapResult(workTicket, result)); + result.putAll(PdfUtils.objectToMapResult(workTicketDelay, result)); } else { result.putAll(PdfUtils.objectToMapResult(new WorkTicketDelayEntity(), result)); } @@ -876,31 +964,117 @@ public class TicketProcessServiceImpl implements TicketProcessService { return newItem; }).collect(Collectors.toList()); - map.put("ticketInfoDangers", CollectionUtils.isNotEmpty(collect) ? collect - : new ArrayList>()); + map.put("ticketInfoDangers", CollectionUtils.isNotEmpty(collect) ? collect : new ArrayList>()); result.putAll(map); } + //工作票危险点分析及控制措施票 + WordMapUtils.newMapWithList("ticketInfoDangers", result, true, 4, "maintenance", "dangerousPoint"); //7. 是否包含 - isExists(result); - + this.isExists(result); + //8. 存入新的数据 + this.addMapPut(result); return result; } /** + * 验证是否有数据 + * + * @param workTicketInfoMap + */ + private void isMatterLibraryList(Map workTicketInfoMap) { + //1. 第一种工作票 + //1.1 应断开断路器和隔离开关,包括填写前已断开断路器和隔离开关(注明编号)、应取熔断器(保险) + WordMapUtils.newMapWithList(WorkTicketConstants.WorkTicketMeasureTypeEnum.ONE.getConvertAttributes(), workTicketInfoMap, true, 6, "safetyMeasure", "status"); + //1.2 应装设接地线、隔板、隔罩(注明确切地点),应合上接地刀闸(注明双重名称) + WordMapUtils.newMapWithList(WorkTicketConstants.WorkTicketMeasureTypeEnum.TWO.getConvertAttributes(), workTicketInfoMap, true, 3, "safetyMeasure", "status"); + //1.3 应装设遮拦、应挂标识牌及防止二次回路误碰等措施(注明确实地点、名称) + WordMapUtils.newMapWithList(WorkTicketConstants.WorkTicketMeasureTypeEnum.THREE.getConvertAttributes(), workTicketInfoMap, true, 6, "safetyMeasure", "status"); + + //2. 第二种工作票 + //2.1 应断开断路器和隔离开关,包括填写前已断开断路器和隔离开关(注明编号)、应取熔断器(保险) + WordMapUtils.newMapWithList(WorkTicketConstants.WorkTicketMeasureTypeEnum.SEVEN.getConvertAttributes(), workTicketInfoMap, true, 6, "safetyMeasure", "status"); + + + //3. 水利机器工作票 + //3.1 必须采取的安全措施 + WordMapUtils.newMapWithList(WorkTicketConstants.WorkTicketMeasureTypeEnum.EIGHT.getConvertAttributes(), workTicketInfoMap, true, 8, "safetyMeasure", "status"); + //3.2 检修工作要求检修人员自行执行的安全措施(由工作负责人填写) + WordMapUtils.newMapWithList(WorkTicketConstants.WorkTicketMeasureTypeEnum.NINE.getConvertAttributes(), workTicketInfoMap, true, 5, "safetyMeasure", "status"); + //3.3 检修工作要求检修人员自行执行的安全措施(由工作负责人填写) + WordMapUtils.newMapWithList(WorkTicketConstants.WorkTicketMeasureTypeEnum.TEN.getConvertAttributes(), workTicketInfoMap, true, 5, "safetyMeasure", "status"); + + + } + + + /** + * 存入新的数据 + * + * @param result + */ + private void addMapPut(Map result) { + log.info("存入新的数据"); + //许可人确认安全措施,负责人确认安全措施 + if (WordHelper.isNoneBlank(result, "licenseTime")) { + log.info("许可人确认安全措施,负责人确认安全措施"); + String principalName = WordHelper.toMapAsString(result, "principalName", 10); + result.put("principalName1", principalName); + } else { + WordHelper.putMap(result, "principalName1", 10); + } + + //负责人变更 + if (WordHelper.isNoneBlank(result, "initialPrincipalName")) { + log.info("负责人变更"); + //签发人 + String signerName = WordHelper.toMapAsString(result, "signerName", 10); + result.put("signerName2", signerName); + //许可人 + String licensorName = WordHelper.toMapAsString(result, "licensorName", 10); + result.put("licensorName1", licensorName); + } else { + WordHelper.putMap(result, "signerName2", 10); + WordHelper.putMap(result, "licensorName1", 10); + } + + //延期 + if (WordHelper.isNoneBlank(result, "changeTime")) { + log.info("延期"); + //负责人 + String licensorName = WordHelper.toMapAsString(result, "principalName", 10); + result.put("principalName2", licensorName); + } else { + WordHelper.putMap(result, "principalName2", 10); + } + + //许可人确认工作票终结 + if (WordHelper.isNoneBlank(result, "workEndTime")) { + log.info("许可人确认工作票终结"); + //负责人 + String principalName = WordHelper.toMapAsString(result, "principalName", 10); + result.put("principalName3", principalName); + //许可人 + String licensorName = WordHelper.toMapAsString(result, "licensorName", 10); + result.put("licensorName2", licensorName); + } else { + WordHelper.putMap(result, "principalName3", 10); + WordHelper.putMap(result, "licensorName2", 10); + } + } + + + /** * 工作地点保留带电部位或注意事项 - * 2 个map集合转成一个map集合 + * 2 个map集合转成一个map集合 + * * @param workTicketInfoMap */ private static void matterLibraryListWithMap(Map workTicketInfoMap) { - List> matterLibraryListFive1 = - workTicketInfoMap.get("matterLibraryListFive") == null ? new ArrayList>() - : (List>) workTicketInfoMap.get("matterLibraryListFive"); - List> matterLibraryListFlow1 = workTicketInfoMap.get("matterLibraryListFlow") == null - ? new ArrayList>() - : (List>) workTicketInfoMap.get("matterLibraryListFlow"); + List> matterLibraryListFive1 = workTicketInfoMap.get("matterLibraryListFive") == null ? new ArrayList>() : (List>) workTicketInfoMap.get("matterLibraryListFive"); + List> matterLibraryListFlow1 = workTicketInfoMap.get("matterLibraryListFlow") == null ? new ArrayList>() : (List>) workTicketInfoMap.get("matterLibraryListFlow"); if (matterLibraryListFive1 != null && matterLibraryListFlow1 != null) { List> matterLibraryListFive = matterLibraryListFive1; @@ -930,23 +1104,27 @@ public class TicketProcessServiceImpl implements TicketProcessService { } workTicketInfoMap.put("matterLibraryList", CollectionUtils.isEmpty(maps) ? new ArrayList<>() : maps); - } + + + WordMapUtils.newMapWithList("matterLibraryList", workTicketInfoMap, true, 3, null); + } /** * 判断是否包含,是否存在 + * * @param result */ private static void isExists(Map result) { if (!result.containsKey("ticketInfoDangers")) { - result.put("ticketInfoDangers",new ArrayList>()); + result.put("ticketInfoDangers", new ArrayList>()); } //项目名称 - if (!result.containsKey("projectName")) { - result.put("projectName","\u00A0 "); + if (!result.containsKey("projectName") || StringUtils.isBlank((CharSequence) result.get("projectName"))) { + result.put("projectName", "\u00A0 "); } } @@ -959,12 +1137,32 @@ public class TicketProcessServiceImpl implements TicketProcessService { * @param maps 新的Map * @param i 索引 */ - private static void listWichMap(List> matterLibraryListFive, List> matterLibraryListFlow, List> maps, int i) { - Map stringObjectMap = matterLibraryListFive.get(i); - Map stringObjectMap1 = matterLibraryListFlow.get(i); + private static void listWichMap(List> matterLibraryListFive, + List> matterLibraryListFlow, List> maps, int i) { HashMap objectObjectHashMap = new HashMap<>(); - objectObjectHashMap.put("safetyMeasure", stringObjectMap.get("safetyMeasure")); - objectObjectHashMap.put("safetyMeasure1", stringObjectMap1.get("safetyMeasure")); + if (matterLibraryListFive.size() > 0) { + if (matterLibraryListFive.size() <= i) { + objectObjectHashMap.put("safetyMeasure", ""); + } else { + Map stringObjectMap = matterLibraryListFive.get(i); + objectObjectHashMap.put("safetyMeasure", stringObjectMap.get("safetyMeasure")); + } + } else { + objectObjectHashMap.put("safetyMeasure", ""); + } + + + if (matterLibraryListFlow.size() > 0) { + if (matterLibraryListFlow.size() <= i) { + objectObjectHashMap.put("safetyMeasure1", ""); + } else { + Map stringObjectMap = matterLibraryListFive.get(i); + objectObjectHashMap.put("safetyMeasure1", stringObjectMap.get("safetyMeasure")); + } + } else { + objectObjectHashMap.put("safetyMeasure1", ""); + } + maps.add(objectObjectHashMap); } @@ -1004,7 +1202,6 @@ public class TicketProcessServiceImpl implements TicketProcessService { } - /** * 添加文件 * @@ -1018,7 +1215,6 @@ public class TicketProcessServiceImpl implements TicketProcessService { } - /** * value true转 ☑ 或 false转 □ * @@ -1031,6 +1227,30 @@ public class TicketProcessServiceImpl implements TicketProcessService { if (StringUtils.isNoneBlank(newValue)) { dataConversion.put(key, BooleanUtils.toBoolean(newValue) ? "☑" : "□"); } + + + } + + /** + * 工作类型生成工作票类型 + */ + private String getTicketWichCode(String type) { + String result = null; + switch (type) { + case "6": + result = "D1"; + break; + case "7": + result = "D2"; + break; + case "8": + result = "JX"; + break; + default: + result = "D1"; + break; + } + return result; } } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/WorkTicketFinishServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/WorkTicketFinishServiceImpl.java index f6e0b8e..83519ba 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/WorkTicketFinishServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/WorkTicketFinishServiceImpl.java @@ -2,6 +2,7 @@ package com.hnac.hzims.ticket.twoTicket.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.hnac.hzims.ticket.twoTicket.entity.WorkTicketFinish; import com.hnac.hzims.ticket.twoTicket.mapper.WorkTicketFinishMapper; @@ -34,8 +35,8 @@ public class WorkTicketFinishServiceImpl extends ServiceImpl queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(WorkTicketFinish::getTicketId, ticketId); queryWrapper.orderByDesc(WorkTicketFinish::getCreateTime); - queryWrapper.last("limit 1"); - return this.getOne(queryWrapper); + List list = this.list(queryWrapper); + return CollectionUtils.isNotEmpty(list) ? list.get(0) : null; } /** diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/utils/WordHelper.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/utils/WordHelper.java new file mode 100644 index 0000000..e8505ad --- /dev/null +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/utils/WordHelper.java @@ -0,0 +1,228 @@ +package com.hnac.hzims.ticket.twoTicket.utils; + + +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; +import lombok.AllArgsConstructor; +import lombok.Data; +import org.apache.commons.lang3.StringUtils; + +import java.util.*; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/6/2 14:27 + */ +public class WordHelper extends StringUtils { + + + /** + * Object转 toString + * + * @param object + * @return + */ + public static String toString(Object object) { + return object == null ? null : object.toString().trim(); + } + + + /** + * Map ===》 string + * + * @param result map + * @param key 值 + * @param count 存在多少空格 + * @return + */ + public static String toMapAsString(Map result, String key, int count) { + String signerName = WordHelper.toString(result.get(key)); + return isNotBlank(signerName) ? signerName : "\u00A0" + printSpace(count); + } + + + /** + * 存入map + * + * @param result map + * @param key 值 + * @param count 存在多少空格 + * @return + */ + public static void putMap(Map result, String key, int count) { + result.put(key, "\u00A0" + printSpace(count)); + } + + + /** + * 判断map是否为空 + */ + public static boolean isBlank(Map result, String key) { + String value = WordHelper.toString(result.get(key)); + if (StringUtils.isBlank(value)) { + return true; + } + return false; + } + + + /** + * 判断map不为为空 + */ + public static boolean isNoneBlank(Map result, String key) { + String value = WordHelper.toString(result.get(key)); + if (StringUtils.isNoneBlank(value)) { + return true; + } + return false; + } + + + /** + * 打印多少空格 + */ + public static String printSpace(int count) { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < count; i++) { + sb.append(" "); + } + return sb.toString(); + } + + /** + * map验证是value否为null + * + * @param params + */ + public static Map resultMap(Map params) { + //创建新的Map + Map result = new HashMap<>(); + isContainsKey(params,result); + //遍历 + Set> entries = params.entrySet(); + for (Map.Entry entry : entries) { + listEntryMap(result, entry.getKey(), entry.getValue()); + } + return result; + } + + + /** + * 包含移除 + * @param params + * @param result + */ + private static void isContainsKey(Map params, Map result) { + + + if (params.containsKey("principalName1")) { + result.put("principalName1", params.get("principalName1")); + params.remove("principalName1"); + } + + if (params.containsKey("signerName2")) { + result.put("signerName2", params.get("signerName2")); + params.remove("signerName2"); + } + + if (params.containsKey("licensorName1")) { + result.put("licensorName1", params.get("licensorName1")); + params.remove("licensorName1"); + } + + + if (params.containsKey("principalName2")) { + result.put("principalName2", params.get("principalName2")); + params.remove("principalName2"); + } + + + if (params.containsKey("principalName3")) { + result.put("principalName3", params.get("principalName3")); + params.remove("principalName3"); + } + + + if (params.containsKey("licensorName2")) { + result.put("licensorName2", params.get("licensorName2")); + params.remove("licensorName2"); + } + + } + + /** + * + */ + public static void listEntryMap(Map result, String key, Object value) { + List params = new ArrayList<>(); + paramsList(params); + for (Entry entry : params) { + isEntryMap(result, entry.getFileName(), key, value, entry.getCount()); + } + + } + + + @Data + @AllArgsConstructor + static class Entry { + /** + * key值 + */ + private String fileName; + + /** + * count + */ + private Integer count; + + } + + + /** + * 存储list + * + * @param params + */ + private static void paramsList(List params) { + params.add(new Entry("initialPrincipalName", 10)); + params.add(new Entry("principalChangeTime", 10)); + params.add(new Entry("principalName", 10)); + params.add(new Entry("jobReceiver", 10)); + params.add(new Entry("jobReceiverTime", 10)); + params.add(new Entry("watchPrincipalEndTime", 10)); + params.add(new Entry("licenseTime", 10)); + params.add(new Entry("signerDateTime", 10)); + params.add(new Entry("classGroupName", 10)); + params.add(new Entry("code", 10)); + params.add(new Entry("signerName", 10)); + params.add(new Entry("watchPrincipalName", 10)); + params.add(new Entry("projectName", 10)); + params.add(new Entry("groundNum", 5)); + params.add(new Entry("dismantleNum", 5)); + params.add(new Entry("retainNum", 5)); + } + + + /** + * 验证map是否为空 + * + * @param result + * @param fieldName + * @param key + * @param value + * @param count + */ + public static void isEntryMap(Map result, String fieldName, String key, Object value, int count) { + if (fieldName.equals(key)) { + Object newValue = StringUtils.isNoneBlank(toString(value).trim()) ? value : "\u00A0" + printSpace(count); + result.put(key, newValue); + } else { + Object newValue = StringUtils.isNoneBlank(toString(value).trim()) ? value : "\u00A0" + printSpace(4); + result.put(key, newValue); + } + } + + +} diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/utils/WordMapUtils.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/utils/WordMapUtils.java new file mode 100644 index 0000000..cdb46e2 --- /dev/null +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/utils/WordMapUtils.java @@ -0,0 +1,120 @@ +package com.hnac.hzims.ticket.twoTicket.utils; + +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/6/2 7:39 + */ +public class WordMapUtils { + + + + /** + * word 表格转换 + * + * @param key key值 + * @param result 存入数据 + * @param isIndex 是否需要索引 + * @param size word最多的表格数据 + * @param keys 多个key值 + */ + public static void newMapWithList(String key, Map result + , boolean isIndex, int size, String... keys) { + List> list = (List>) result.get(key); + if (CollectionUtils.isEmpty(list)) { + List> newMatterLibraryListTHREE = new ArrayList<>(); + for (int i = 1; i <= size; i++) { + Map map = new HashMap<>(); + //是否需要索引 + if (isIndex) { + map.put("index", i); + } + // 是否有keys + if (keys != null) { + for (String value : keys) { + map.put(value, ""); + } + } + newMatterLibraryListTHREE.add(map); + } + result.put(key, + newMatterLibraryListTHREE); + } else { + + int tempSize = list.size(); + + List> newList = new ArrayList<>(); + if (size > tempSize) { + int sizeLimit = 1; + int tempIndex = 1; + for (int i = 0; i < size; i++) { + Map map = new HashMap<>(); + if (tempSize >= sizeLimit) { + Map stringObjectMap = list.get(i); + // map.putAll(stringObjectMap); + newList.add(stringObjectMap); + tempIndex++; + sizeLimit++; + }else { + //是否需要索引 + if (isIndex) { + map.put("index", tempIndex); + + } + // 是否有keys + if (keys != null) { + for (String value : keys) { + map.put(value, ""); + } + } + tempIndex++; + newList.add(map); + } + } + } else { + for (int i = 0; i < tempSize; i++) { + Map map = list.get(i); + if (isIndex) { + map.put("index", i + 1); + } + newList.add(map); + } + } + result.put(key, newList); + } + } + + + + + /** + * 通过状态获取是第几种工作票 + */ + public static String getWorkTicketStatus(Integer status) { + String pathName = null; + switch (status) { + case 1: + pathName = "电气第一种工作票模版.docx"; + break; + case 2: + pathName = "电气第二种工作票模版.docx"; + break; + case 3: + pathName = "水力机械工作票模版.docx"; + break; + default: + pathName = "电气第一种工作票模版.docx"; + break; + } + return pathName; + } + +} diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/operation/StandardTicketInfoVo.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/operation/StandardTicketInfoVo.java new file mode 100644 index 0000000..70ca8e5 --- /dev/null +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/operation/StandardTicketInfoVo.java @@ -0,0 +1,120 @@ +package com.hnac.hzims.ticket.twoTicket.vo.operation; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; +import org.springblade.core.tenant.mp.TenantEntity; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDateTime; +import java.util.List; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/6/6 15:39 + */ +@Data +@Accessors(chain = true) +public class StandardTicketInfoVo extends TenantEntity { + + + @ApiModelProperty("票据类型") + private String ticketType; + + + + @ApiModelProperty("单位") + private String company; + + @ApiModelProperty("工作流ID") + private String processInstanceId; + + + @ApiModelProperty("编号") + private String code; + + @ApiModelProperty("发令人") + private Long issueOrderPerson; + + @ApiModelProperty("受令人") + private Long accessOrderPerson; + + @ApiModelProperty("发令时间") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime issueOrderTime; + + @ApiModelProperty("操作开始时间") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime startTime; + + @ApiModelProperty("操作结束时间") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime endTime; + + @ApiModelProperty("操作任务") + private String title; + + @ApiModelProperty("任务类型") + private String taskType; + + @ApiModelProperty("关联业务任务ID") + private Long taskId; + + @ApiModelProperty("关联业务名称") + private String taskName; + + @ApiModelProperty("备注") + private String remark; + + @ApiModelProperty("监护人") + private Long guardian; + + @ApiModelProperty("操作人") + private Long operator; + + @ApiModelProperty("操作时间") + private LocalDateTime operateTime; + + @ApiModelProperty("负责人确认时间") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime guardianshipTime; + + @ApiModelProperty("值班负责人") + private Long principal; + + @ApiModelProperty("值班负责人确认时间") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime principalTime; + + @ApiModelProperty("是否评价") + private Integer isEvaluate; + + + /** + * AA/AAA/AAAA由建站时建站人填写必须系统验证唯一性 + * 站点标识-两票编码 + */ + @ApiModelProperty("站点标识-两票编码") + private String signage; + + + /** + * 编号(原站点ID) + */ + @ApiModelProperty("编号(原站点ID)") + private String signageCode; + + + /** + * 安全措施 + */ + private List standardTicketMeasureVos; +} diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/operation/StandardTicketMeasureVo.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/operation/StandardTicketMeasureVo.java new file mode 100644 index 0000000..03702a7 --- /dev/null +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/operation/StandardTicketMeasureVo.java @@ -0,0 +1,57 @@ +package com.hnac.hzims.ticket.twoTicket.vo.operation; + +import com.baomidou.mybatisplus.annotation.FieldStrategy; +import com.baomidou.mybatisplus.annotation.TableField; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.NullSerializer; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springblade.core.mp.support.QueryField; +import org.springblade.core.mp.support.SqlCondition; +import org.springblade.core.tenant.mp.TenantEntity; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDateTime; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/6/6 15:47 + */ +@Data +public class StandardTicketMeasureVo extends TenantEntity { + + + private static final long serialVersionUID = 8503146008417850183L; + + @ApiModelProperty("标准票ID") + private Long ticketId; + + @ApiModelProperty("分组") + private Long matterGroup; + + @ApiModelProperty("安全措施ID") + private Long measureId; + + @ApiModelProperty("安全措施") + private String measure; + + @ApiModelProperty("执行人") + private Long executor; + + @ApiModelProperty("执行时间") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime executeTime; + + @ApiModelProperty("执行图片") + private String executeImgUrl; + + @ApiModelProperty("执行备注") + private String remark; + + @ApiModelProperty("操作事项排序") + private Integer sort; +} diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/process/WorkTicketVo.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/process/WorkTicketVo.java index 58da938..2dfa1e7 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/process/WorkTicketVo.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/process/WorkTicketVo.java @@ -69,11 +69,6 @@ public class WorkTicketVo { private WorkTicketPrincipalChangeEntity workTicketPrincipalChange; - /** - * 开启流程 - */ - private Boolean isState = true; - diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/utils/PdfUtils.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/utils/PdfUtils.java index 3e7b2d9..d9f32cc 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/utils/PdfUtils.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/utils/PdfUtils.java @@ -257,35 +257,8 @@ public class PdfUtils { result.put(StringUtil.isNoneBlank(defaultValue.name()) ? defaultValue.name() : field.getName(), ObjectUtil.isNotEmpty(defaultValue.value()) ? defaultValue.value() : value); } else { - if ("initialPrincipalName".equals(field.getName()) - || "principalChangeTime".equals(field.getName()) - || "principalName".equals(field.getName()) - || "jobReceiver".equals(field.getName()) - || "jobReceiverTime".equals(field.getName()) - || "watchPrincipalEndTime".equals(field.getName()) - || "licenseTime".equals(field.getName()) - || "licensorName".equals(field.getName()) - || "signerDateTime".equals(field.getName()) - || "classGroupName".equals(field.getName()) - || "code".equals(field.getName()) - || "signerName".equals(field.getName()) - || "watchPrincipalName".equals(field.getName())) - { - result.put(field.getName(), Optional.ofNullable(value).orElse("\u00A0 ")); - - } else if ( - "groundNum".equals(field.getName()) || - "dismantleNum".equals(field.getName()) || - "retainNum".equals(field.getName()) - - ) { - result.put(field.getName(), Optional.ofNullable(value).orElse("\u00A0 ")); - } else { - //如果导出word为null会出现{{ ,value设置"\u00A0" - result.put(field.getName(), Optional.ofNullable(value).orElse("\u00A0")); - } - - + //如果导出word为null会出现{{ ,value设置"\u00A0" + result.put(field.getName(), Optional.ofNullable(value).orElse("")); } }); } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/impl/WorkTicketInfoServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/impl/WorkTicketInfoServiceImpl.java index 1da1885..0105a3d 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/impl/WorkTicketInfoServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/impl/WorkTicketInfoServiceImpl.java @@ -256,7 +256,7 @@ public class WorkTicketInfoServiceImpl extends BaseServiceImpl { User user = UserCache.getUser(item.getCreateUser()); if (user != null) { - item.setCreateUserName(UserCache.getUser(item.getCreateUser()).getName()); + item.setCreateUserName(user.getName()); } }); diff --git a/hzims-service/ticket/src/main/resources/application.yml b/hzims-service/ticket/src/main/resources/application.yml index 9341ce3..1de0a34 100644 --- a/hzims-service/ticket/src/main/resources/application.yml +++ b/hzims-service/ticket/src/main/resources/application.yml @@ -16,6 +16,7 @@ swagger: + #ticket: # workTickets: # - status: 1 diff --git a/hzims-service/ticket/src/main/resources/mapper/processflow/ProcessDictMapper.xml b/hzims-service/ticket/src/main/resources/mapper/processflow/ProcessDictMapper.xml new file mode 100644 index 0000000..1882427 --- /dev/null +++ b/hzims-service/ticket/src/main/resources/mapper/processflow/ProcessDictMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/mapper/xml/ProcessTypeMapper.xml b/hzims-service/ticket/src/main/resources/mapper/processflow/ProcessTypeMapper.xml similarity index 100% rename from hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/mapper/xml/ProcessTypeMapper.xml rename to hzims-service/ticket/src/main/resources/mapper/processflow/ProcessTypeMapper.xml diff --git a/hzims-service/ticket/src/main/resources/template/secondary/工作票危险点分析及控制措施票.docx b/hzims-service/ticket/src/main/resources/template/secondary/工作票危险点分析及控制措施票.docx index 46cec0f..5e86dca 100644 Binary files a/hzims-service/ticket/src/main/resources/template/secondary/工作票危险点分析及控制措施票.docx and b/hzims-service/ticket/src/main/resources/template/secondary/工作票危险点分析及控制措施票.docx differ diff --git a/hzims-service/ticket/src/main/resources/template/水力机械工作票模版.docx b/hzims-service/ticket/src/main/resources/template/水力机械工作票模版.docx new file mode 100644 index 0000000..e43e2d5 Binary files /dev/null and b/hzims-service/ticket/src/main/resources/template/水力机械工作票模版.docx differ diff --git a/hzims-service/ticket/src/main/resources/template/电气第一种工作票模版.docx b/hzims-service/ticket/src/main/resources/template/电气第一种工作票模版.docx index 76478f2..4684a35 100644 Binary files a/hzims-service/ticket/src/main/resources/template/电气第一种工作票模版.docx and b/hzims-service/ticket/src/main/resources/template/电气第一种工作票模版.docx differ diff --git a/hzims-service/ticket/src/main/resources/template/电气第二种工作票模版.docx b/hzims-service/ticket/src/main/resources/template/电气第二种工作票模版.docx new file mode 100644 index 0000000..702f915 Binary files /dev/null and b/hzims-service/ticket/src/main/resources/template/电气第二种工作票模版.docx differ