|
|
|
@ -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<Map<String, List<OperMaintenancePlanVO>>> reportMonth(OperMaintenanceMonitorReportMonthDTO req) { |
|
|
|
|
List<OperMaintenancePlanEntity> planEntities = planMapper.selectList(new LambdaQueryWrapper<OperMaintenancePlanEntity>() {{ |
|
|
|
|
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<Map<String, List<OperMaintenancePlanVO>>> reportMonth(OperMaintenanceMonitorReportMonthDTO req) { |
|
|
|
|
List<OperMaintenancePlanEntity> planEntities = planMapper.selectList(new LambdaQueryWrapper<OperMaintenancePlanEntity>() {{ |
|
|
|
|
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<Long> classIdList = planEntities.stream().filter(planEntity -> ObjectUtil.isNotEmpty(planEntity.getImsDutyClassId())) |
|
|
|
|
.map(OperMaintenancePlanEntity::getImsDutyClassId).collect(Collectors.toList()); |
|
|
|
|
IImsDutyClassService imsDutyClassService = SpringUtil.getBean(IImsDutyClassService.class); |
|
|
|
|
Map<Long,List<ImsDutyClassEntity>> classMap = null; |
|
|
|
|
if(CollectionUtil.isNotEmpty(classIdList)) { |
|
|
|
|
List<ImsDutyClassEntity> classEntityList = imsDutyClassService.list(new LambdaQueryWrapper<ImsDutyClassEntity>(){{ |
|
|
|
|
in(ImsDutyClassEntity::getId,classIdList); |
|
|
|
|
}}); |
|
|
|
|
if(CollectionUtil.isNotEmpty(classEntityList)) { |
|
|
|
|
classMap = classEntityList.stream().collect(Collectors.groupingBy(ImsDutyClassEntity::getId)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//获取列表班次ID集合
|
|
|
|
|
List<Long> classIdList = planEntities.stream().filter(planEntity -> ObjectUtil.isNotEmpty(planEntity.getImsDutyClassId())) |
|
|
|
|
.map(OperMaintenancePlanEntity::getImsDutyClassId).collect(Collectors.toList()); |
|
|
|
|
IImsDutyClassService imsDutyClassService = SpringUtil.getBean(IImsDutyClassService.class); |
|
|
|
|
Map<Long, List<ImsDutyClassEntity>> classMap = null; |
|
|
|
|
if (CollectionUtil.isNotEmpty(classIdList)) { |
|
|
|
|
List<ImsDutyClassEntity> classEntityList = imsDutyClassService.list(new LambdaQueryWrapper<ImsDutyClassEntity>() {{ |
|
|
|
|
in(ImsDutyClassEntity::getId, classIdList); |
|
|
|
|
}}); |
|
|
|
|
if (CollectionUtil.isNotEmpty(classEntityList)) { |
|
|
|
|
classMap = classEntityList.stream().collect(Collectors.groupingBy(ImsDutyClassEntity::getId)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//完善班次与执行人
|
|
|
|
|
List<OperMaintenancePlanVO> operMaintenancePlanVOS = new ArrayList<>(); |
|
|
|
|
Map<Long, List<ImsDutyClassEntity>> 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<OperMaintenancePlanVO> operMaintenancePlanVOS = new ArrayList<>(); |
|
|
|
|
Map<Long, List<ImsDutyClassEntity>> 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<String, List<OperMaintenancePlanVO>> data = operMaintenancePlanVOS.stream().collect(Collectors.groupingBy(o -> DateUtil.formatDate(o.getDisposeTime()))); |
|
|
|
|
return R.data(new TreeMap<>(data)); |
|
|
|
|
} |
|
|
|
|
Map<String, List<OperMaintenancePlanVO>> data = operMaintenancePlanVOS.stream().collect(Collectors.groupingBy(o -> DateUtil.formatDate(o.getDisposeTime()))); |
|
|
|
|
return R.data(new TreeMap<>(data)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|