From e4001ad4187596e677c45bd7dbc1a499bff51a9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AE=B5=E9=A3=9E=E5=AE=87?= <2684146481@qq.com> Date: Wed, 13 Sep 2023 14:44:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E5=B8=B8=E7=BB=B4=E6=8A=A4=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E7=AB=99=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/OperMaintenancePlanEntity.java | 6 ++ .../dto/OperMaintenanceMonitorReportMonthDTO.java | 5 + .../impl/OperMaintenanceMonitorServiceImpl.java | 107 +++++++++++---------- .../operational/src/main/resources/db/1.0.1.sql | 1 + 4 files changed, 66 insertions(+), 53 deletions(-) create mode 100644 hzims-service/operational/src/main/resources/db/1.0.1.sql diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/maintenance/entity/OperMaintenancePlanEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/maintenance/entity/OperMaintenancePlanEntity.java index 968d033..82364f4 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/maintenance/entity/OperMaintenancePlanEntity.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/maintenance/entity/OperMaintenancePlanEntity.java @@ -108,4 +108,10 @@ public class OperMaintenancePlanEntity extends TenantEntity { @JsonSerialize(nullsUsing = NullSerializer.class) private Long messageTemplateId; + + /** + * 站点code + */ + private String stationCode; + } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/dto/OperMaintenanceMonitorReportMonthDTO.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/dto/OperMaintenanceMonitorReportMonthDTO.java index 53147cb..5e5405b 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/dto/OperMaintenanceMonitorReportMonthDTO.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/dto/OperMaintenanceMonitorReportMonthDTO.java @@ -24,4 +24,9 @@ public class OperMaintenanceMonitorReportMonthDTO implements Serializable { @ApiModelProperty(value = "月", required = true) private Integer month; + + /** + * 站点code + */ + private String stationCode; } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceMonitorServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceMonitorServiceImpl.java index 6c21a91..cc007e1 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceMonitorServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceMonitorServiceImpl.java @@ -12,6 +12,7 @@ import com.hnac.hzims.operational.maintenance.mapper.OperMaintenanceTaskMapper; import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceMonitorService; import com.hnac.hzims.operational.maintenance.vo.OperMaintenancePlanVO; import com.hnac.hzims.operational.maintenance.wrapper.OperMaintenancePlanWrapper; +import org.apache.commons.lang3.StringUtils; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.*; import org.springblade.system.user.cache.UserCache; @@ -32,61 +33,61 @@ import java.util.stream.Collectors; **/ @Service public class OperMaintenanceMonitorServiceImpl implements IOperMaintenanceMonitorService { - @Autowired - private OperMaintenanceParameterMapper parameterMapper; - @Autowired - private OperMaintenanceTaskMapper taskMapper; - @Autowired - private OperMaintenancePlanMapper planMapper; - @Autowired - private IImsDutyClassService imsDutyClassService; + @Autowired + private OperMaintenanceParameterMapper parameterMapper; + @Autowired + private OperMaintenanceTaskMapper taskMapper; + @Autowired + private OperMaintenancePlanMapper planMapper; + @Autowired + private IImsDutyClassService imsDutyClassService; - @Override - public R>> reportMonth(OperMaintenanceMonitorReportMonthDTO req) { - List planEntities = planMapper.selectList(new LambdaQueryWrapper() {{ - LocalDate startDate = LocalDate.of(req.getYear(), req.getMonth(),1); - // Date startTime = DateUtil.parse(DateUtil.format(DateUtil.now(), "yyyy-MM") + "-01", DateUtil.PATTERN_DATE); - eq(OperMaintenancePlanEntity::getIsDeleted, 0L); - ge(OperMaintenancePlanEntity::getDisposeTime, startDate); - lt(OperMaintenancePlanEntity::getDisposeTime, startDate.with(TemporalAdjusters.lastDayOfMonth())); - }}); + @Override + public R>> reportMonth(OperMaintenanceMonitorReportMonthDTO req) { + List planEntities = planMapper.selectList(new LambdaQueryWrapper() {{ + LocalDate startDate = LocalDate.of(req.getYear(), req.getMonth(), 1); + // Date startTime = DateUtil.parse(DateUtil.format(DateUtil.now(), "yyyy-MM") + "-01", DateUtil.PATTERN_DATE); + eq(OperMaintenancePlanEntity::getIsDeleted, 0L); + ge(OperMaintenancePlanEntity::getDisposeTime, startDate); + lt(OperMaintenancePlanEntity::getDisposeTime, startDate.with(TemporalAdjusters.lastDayOfMonth())) + .eq(StringUtils.isNoneBlank(req.getStationCode()), OperMaintenancePlanEntity::getStationCode, req.getStationCode()); + }}); - //获取列表班次ID集合 - List classIdList = planEntities.stream().filter(planEntity -> ObjectUtil.isNotEmpty(planEntity.getImsDutyClassId())) - .map(OperMaintenancePlanEntity::getImsDutyClassId).collect(Collectors.toList()); - IImsDutyClassService imsDutyClassService = SpringUtil.getBean(IImsDutyClassService.class); - Map> classMap = null; - if(CollectionUtil.isNotEmpty(classIdList)) { - List classEntityList = imsDutyClassService.list(new LambdaQueryWrapper(){{ - in(ImsDutyClassEntity::getId,classIdList); - }}); - if(CollectionUtil.isNotEmpty(classEntityList)) { - classMap = classEntityList.stream().collect(Collectors.groupingBy(ImsDutyClassEntity::getId)); - } - } + //获取列表班次ID集合 + List classIdList = planEntities.stream().filter(planEntity -> ObjectUtil.isNotEmpty(planEntity.getImsDutyClassId())) + .map(OperMaintenancePlanEntity::getImsDutyClassId).collect(Collectors.toList()); + IImsDutyClassService imsDutyClassService = SpringUtil.getBean(IImsDutyClassService.class); + Map> classMap = null; + if (CollectionUtil.isNotEmpty(classIdList)) { + List classEntityList = imsDutyClassService.list(new LambdaQueryWrapper() {{ + in(ImsDutyClassEntity::getId, classIdList); + }}); + if (CollectionUtil.isNotEmpty(classEntityList)) { + classMap = classEntityList.stream().collect(Collectors.groupingBy(ImsDutyClassEntity::getId)); + } + } - //完善班次与执行人 - List operMaintenancePlanVOS = new ArrayList<>(); - Map> finalClassMap = classMap; - planEntities.forEach(planEntity -> { - OperMaintenancePlanVO planVO = BeanUtil.copy(planEntity,OperMaintenancePlanVO.class); - if(ObjectUtil.isNotEmpty(planEntity.getImsDutyClassId())) { - //类型为班次时 获取班次名称 - planVO.setDutyClassName(finalClassMap.get(planEntity.getImsDutyClassId()).get(0).getClassName()); - } - else if(ObjectUtil.isNotEmpty(planEntity.getDisposer())) { - //类型为人员类型时 获取执行人名称 - planVO.setDisposerName(Optional.ofNullable(UserCache.getUser(planEntity.getDisposer())).map(User::getName).orElse(null)); - } - //当月是否生成任务 默认是false - LocalDateTime createTaskTime = com.hnac.hzims.common.utils.DateUtil.DateToLocalDateTime(planEntity.getCreateTaskTime()); - if(ObjectUtil.isNotEmpty(createTaskTime) && com.hnac.hzims.common.utils.DateUtil.judgeSameDay(createTaskTime, LocalDate.now())) { - planVO.setGenerateSign(true); - } - operMaintenancePlanVOS.add(planVO); - }); + //完善班次与执行人 + List operMaintenancePlanVOS = new ArrayList<>(); + Map> finalClassMap = classMap; + planEntities.forEach(planEntity -> { + OperMaintenancePlanVO planVO = BeanUtil.copy(planEntity, OperMaintenancePlanVO.class); + if (ObjectUtil.isNotEmpty(planEntity.getImsDutyClassId())) { + //类型为班次时 获取班次名称 + planVO.setDutyClassName(finalClassMap.get(planEntity.getImsDutyClassId()).get(0).getClassName()); + } else if (ObjectUtil.isNotEmpty(planEntity.getDisposer())) { + //类型为人员类型时 获取执行人名称 + planVO.setDisposerName(Optional.ofNullable(UserCache.getUser(planEntity.getDisposer())).map(User::getName).orElse(null)); + } + //当月是否生成任务 默认是false + LocalDateTime createTaskTime = com.hnac.hzims.common.utils.DateUtil.DateToLocalDateTime(planEntity.getCreateTaskTime()); + if (ObjectUtil.isNotEmpty(createTaskTime) && com.hnac.hzims.common.utils.DateUtil.judgeSameDay(createTaskTime, LocalDate.now())) { + planVO.setGenerateSign(true); + } + operMaintenancePlanVOS.add(planVO); + }); - Map> data = operMaintenancePlanVOS.stream().collect(Collectors.groupingBy(o -> DateUtil.formatDate(o.getDisposeTime()))); - return R.data(new TreeMap<>(data)); - } + Map> data = operMaintenancePlanVOS.stream().collect(Collectors.groupingBy(o -> DateUtil.formatDate(o.getDisposeTime()))); + return R.data(new TreeMap<>(data)); + } } diff --git a/hzims-service/operational/src/main/resources/db/1.0.1.sql b/hzims-service/operational/src/main/resources/db/1.0.1.sql new file mode 100644 index 0000000..657046f --- /dev/null +++ b/hzims-service/operational/src/main/resources/db/1.0.1.sql @@ -0,0 +1 @@ +alter table hzims_oper_maintenance_plan add station_code varchar(60) comment '站点编码' \ No newline at end of file