| | |
| | | Integer year = productionCalendar.getYear(); |
| | | LocalDate queryStartDay = LocalDate.of(year.intValue(), 1, 1); |
| | | Long calendarId = productionCalendar.getId(); |
| | | /* |
| | | Set<LocalDate> dateList = dateDTOList.stream().filter(c -> { |
| | | return !Func.isNull(c.getModelId()) && Func.isNull(c.getOffDayId()); |
| | | }).map((v0) -> { |
| | | return v0.getCalendarDate(); |
| | | }).collect(Collectors.toSet()); |
| | | */ |
| | | |
| | | Set<LocalDate> dateList = dateDTOList.stream().filter(c -> { |
| | | return !Func.isNull(c.getModelId()) && Func.isNull(c.getOffDayId()); |
| | | }).map(CalendarDateDTO::getCalendarDate).collect(Collectors.toSet()); |
| | | |
| | | /* |
| | | Set<LocalDate> offDay = dateDTOList.stream().filter(c2 -> { |
| | | return !Func.isNull(c2.getOffDayId()); |
| | | }).map((v0) -> { |
| | | return v0.getCalendarDate(); |
| | | }).collect(Collectors.toSet()); |
| | | */ |
| | | Set<LocalDate> offDay = dateDTOList.stream().filter(c2 -> { |
| | | return !Func.isNull(c2.getOffDayId()); |
| | | }).map(CalendarDateDTO::getCalendarDate).collect(Collectors.toSet()); |
| | | |
| | | List<ProductionCalendarDaytime> productionCalendarDaytimeList = new ArrayList<>(); |
| | | List<ProductionCalendarDay> productionCalendarDayList = new ArrayList<>(); |
| | | /* |
| | | List<Long> modelIds = dateDTOList.stream().map((v0) -> { |
| | | return v0.getModelId(); |
| | | }).distinct().collect(Collectors.toList()); |
| | | */ |
| | | List<Long> modelIds = dateDTOList.stream().map(CalendarDateDTO::getModelId).distinct().collect(Collectors.toList()); |
| | | |
| | | Map<Long, ShiftVO> shiftDetailMap = this.shiftModelService.getShiftDetail(modelIds); |
| | | Snowflake snowflake = IdUtil.createSnowflake(1L, 1L); |
| | | List<ProductionCalendarDaytime> curProductionCalendarDayTimeList = new ArrayList<>(); |
| | |
| | | } |
| | | |
| | | /* JADX WARN: Multi-variable type inference failed */ |
| | | /** |
| | | * 处理年的第一天? |
| | | * @param productionCalendar |
| | | * @param productionCalendarDaytimeList |
| | | * @param needHandleDate |
| | | */ |
| | | private void handleFirstDayOfYear(ProductionCalendar productionCalendar, List<ProductionCalendarDaytime> productionCalendarDaytimeList, LocalDate needHandleDate) { |
| | | Integer year = productionCalendar.getYear(); |
| | | List<ProductionCalendarDaytime> lastYearDateTimeList = new ArrayList<>(); |
| | | |
| | | ProductionCalendar item = (ProductionCalendar)(this.baseMapper.selectOne((new QueryWrapper<ProductionCalendar>()).lambda() |
| | | //查询上一年(year.intValue() - 1) 日历编号相同的日历 |
| | | ProductionCalendar item = this.baseMapper.selectOne((new QueryWrapper<ProductionCalendar>()).lambda() |
| | | .eq(ProductionCalendar::getStatus, ProductionTimeConstant.ENABLE) |
| | | .eq(ProductionCalendar::getCode, productionCalendar.getCode()) |
| | | .eq(ProductionCalendar::getYear, Integer.valueOf(year.intValue() - 1)))); |
| | | .eq(ProductionCalendar::getYear, Integer.valueOf(year.intValue() - 1))); |
| | | /* |
| | | ProductionCalendar item = (ProductionCalendar) this.baseMapper.selectOne((Wrapper) ((LambdaQueryWrapper) ((LambdaQueryWrapper) new QueryWrapper().lambda().eq((v0) -> { |
| | | return v0.getStatus(); |
| | |
| | | }, Integer.valueOf(year.intValue() - 1))); |
| | | */ |
| | | if (Func.isNotEmpty(item)) { |
| | | //若找到了去年的日历,查询去年12.31日的那天数据 |
| | | lastYearDateTimeList = this.calendarDaytimeService.list(new QueryWrapper<ProductionCalendarDaytime>().lambda() |
| | | .eq(ProductionCalendarDaytime::getCalendarDate, LocalDate.of(productionCalendar.getYear().intValue() - 1, 12, 31)) |
| | | .eq(ProductionCalendarDaytime::getCalendarId, item.getId()) |
| | |
| | | }));*/ |
| | | } |
| | | ProductionCalendarDaytime firstDateTime = productionCalendarDaytimeList.get(0); |
| | | if (!Func.isNotEmpty(lastYearDateTimeList)) { |
| | | if (!Func.isNotEmpty(lastYearDateTimeList)) {//啥代码啊?isEmpty不行吗? |
| | | if (Func.isEmpty(lastYearDateTimeList) && firstDateTime.getStartTime().isAfter(LocalDateTime.of(needHandleDate, LocalTime.of(0, 0, 0)))) { |
| | | ProductionCalendarDaytime productionCalendarDaytime = ProductionCalendarDaytime.builder().calendarDate(needHandleDate).year(year).week(firstDateTime.getWeek()).month(firstDateTime.getMonth()).shiftIndex(ProductionTimeConstant.OUT_OF_SHIFT_TIME).calendarId(firstDateTime.getCalendarId()).startTime(LocalDateTime.of(needHandleDate, LocalTime.of(0, 0, 0))).endTime(firstDateTime.getStartTime()).shiftType(ProductionTimeConstant.UNDEFINED_TIME_OUT).isHighPriority(ProductionTimeConstant.LOW_PRIORITY).isUndefined(firstDateTime.getIsUndefined()).build(); |
| | | productionCalendarDaytimeList.add(productionCalendarDaytime); |
| | |
| | | } |
| | | return; |
| | | } |
| | | |
| | | //找到去年12.31日数据的情况,先取最后一条 |
| | | ProductionCalendarDaytime lastYearDateTime = lastYearDateTimeList.get(lastYearDateTimeList.size() - 1); |
| | | boolean useLastShift = isUseLastShift(firstDateTime, lastYearDateTime); |
| | | boolean useThisShift = isUseThisShift(firstDateTime, lastYearDateTime); |
| | | boolean useLastShift = isUseLastShift(firstDateTime, lastYearDateTime);//是否使用上一个日历的班制 |
| | | boolean useThisShift = isUseThisShift(firstDateTime, lastYearDateTime);//是否使用当前日历的班制,里面有isHighPriority属性的使用(isCurrentHighPriority方法内) |
| | | boolean conflictShift = isConflictShift(firstDateTime, lastYearDateTime); |
| | | if (conflictShift) { |
| | | throw new ServiceException(MessageUtils.message("calendar.time.slice.of.the.day.affected", new Object[0])); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 日历天时间上是否冲突 |
| | | * @param firstDateTime |
| | | * @param lastYearDateTime |
| | | * @return |
| | | */ |
| | | private boolean isConflictShift(ProductionCalendarDaytime firstDateTime, ProductionCalendarDaytime lastYearDateTime) { |
| | | return lastYearDateTime.getCalendarDate().equals(LocalDate.now()) && firstDateTime.getStartTime().isBefore(lastYearDateTime.getEndTime()) && firstDateTime.getIsUndefined().equals(ProductionTimeConstant.DEFINED); |
| | | } |
| | | |
| | | /** |
| | | * 是否使用去年12.31的班制,逻辑是:当前日历的年份在去年12.31日之前,且去年12.31日的日历数据优先(IsHighPriority=1) |
| | | * @param firstDateTime 当前日历第一天 |
| | | * @param lastYearDateTime 去年日历(相同编码)12.31 |
| | | * @return |
| | | */ |
| | | private boolean isUseLastShift(ProductionCalendarDaytime firstDateTime, ProductionCalendarDaytime lastYearDateTime) { |
| | | boolean useLastShift = firstDateTime.getStartTime().isBefore(lastYearDateTime.getEndTime()) && (lastYearDateTime.getIsHighPriority().equals(ProductionTimeConstant.HIGH_PRIORITY) || (lastYearDateTime.getIsUndefined().equals(ProductionTimeConstant.DEFINED) && firstDateTime.getIsUndefined().equals(ProductionTimeConstant.UNDEFINED))); |
| | | return useLastShift; |
| | | } |
| | | |
| | | /** |
| | | * 是否使用firstDateTime所在的班制 |
| | | * @param firstDateTime |
| | | * @param lastYearDateTime |
| | | * @return |
| | | */ |
| | | private boolean isUseThisShift(ProductionCalendarDaytime firstDateTime, ProductionCalendarDaytime lastYearDateTime) { |
| | | boolean useThisShift = firstDateTime.getStartTime().isBefore(lastYearDateTime.getEndTime()) && !lastYearDateTime.getCalendarDate().equals(LocalDate.now()) && isCurrentHighPriority(firstDateTime, lastYearDateTime); |
| | | return useThisShift; |
| | | } |
| | | |
| | | /** |
| | | * 当前日期(firstDateTime)是否是高优先级 |
| | | * @param firstDateTime |
| | | * @param lastYearDateTime |
| | | * @return |
| | | */ |
| | | private boolean isCurrentHighPriority(ProductionCalendarDaytime firstDateTime, ProductionCalendarDaytime lastYearDateTime) { |
| | | return firstDateTime.getIsHighPriority().equals(ProductionTimeConstant.HIGH_PRIORITY) || (firstDateTime.getIsUndefined().equals(ProductionTimeConstant.DEFINED) && lastYearDateTime.getIsHighPriority().equals(ProductionTimeConstant.LOW_PRIORITY)); |
| | | } |