| | |
| | | package com.qianwen.smartman.modules.cps.service.impl; |
| | | |
| | | import cn.hutool.core.lang.Snowflake; |
| | | import cn.hutool.core.util.IdUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.google.common.collect.Lists; |
| | | import java.lang.invoke.SerializedLambda; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | |
| | | import java.time.temporal.TemporalUnit; |
| | | import java.util.ArrayList; |
| | | import java.util.Calendar; |
| | | import java.util.Collection; |
| | | import java.util.Comparator; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.google.common.collect.Lists; |
| | | import com.qianwen.core.log.exception.ServiceException; |
| | | import com.qianwen.core.redis.cache.BladeRedis; |
| | | import com.qianwen.core.secure.utils.AuthUtil; |
| | | import com.qianwen.core.tool.utils.CollectionUtil; |
| | | import com.qianwen.core.tool.utils.DateUtil; |
| | | import com.qianwen.core.tool.utils.Func; |
| | | import com.qianwen.smartman.common.cache.ParamCache; |
| | | import com.qianwen.smartman.common.cache.RegionCache; |
| | | import com.qianwen.smartman.common.cache.cps.TimeSliceCache; |
| | | import com.qianwen.smartman.common.constant.CalendarConstant; |
| | | import com.qianwen.smartman.common.constant.CommonConstant; |
| | |
| | | import com.qianwen.smartman.common.utils.CommonUtil; |
| | | import com.qianwen.smartman.common.utils.LocalDateTimeUtils; |
| | | import com.qianwen.smartman.common.utils.MessageUtils; |
| | | import com.qianwen.core.log.exception.ServiceException; |
| | | import com.qianwen.core.redis.cache.BladeRedis; |
| | | import com.qianwen.core.secure.utils.AuthUtil; |
| | | import com.qianwen.core.tool.utils.CollectionUtil; |
| | | import com.qianwen.core.tool.utils.DateUtil; |
| | | import com.qianwen.core.tool.utils.Func; |
| | | import com.qianwen.smartman.modules.cps.convert.ProductionCalendarConvert; |
| | | import com.qianwen.smartman.modules.cps.dto.CacheBuildDTO; |
| | | import com.qianwen.smartman.modules.cps.dto.CalendarCacheDTO; |
| | |
| | | import com.qianwen.smartman.modules.cps.vo.ShiftTimeDetailVO; |
| | | import com.qianwen.smartman.modules.cps.vo.ShiftVO; |
| | | import com.qianwen.smartman.modules.mdc.dto.ShiftIndexNameDTO; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import cn.hutool.core.lang.Snowflake; |
| | | import cn.hutool.core.util.IdUtil; |
| | | |
| | | @Service |
| | | /* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/cps/service/impl/CalendarServiceImpl.class */ |
| | | public class CalendarServiceImpl extends ServiceImpl<CalendarMapper, ProductionCalendar> implements ICalendarService { |
| | | private static final Logger log = LoggerFactory.getLogger(CalendarServiceImpl.class); |
| | | @Autowired |
| | |
| | | @Autowired |
| | | private BladeRedis bladeRedis; |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICalendarService |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public ProductionCalendar saveCalendar(CalendarSaveVO calendarSaveVO) { |
| | | checkCalendar(calendarSaveVO, AuthUtil.getTenantId()); |
| | |
| | | return productionCalendar; |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICalendarService |
| | | @Override |
| | | public ProductionCalendar saveYearCalendar(CalendarSaveVO calendarSaveVO) { |
| | | checkCalendar(calendarSaveVO, AuthUtil.getTenantId()); |
| | | ProductionCalendar productionCalendar = new ProductionCalendar(); |
| | |
| | | return productionCalendar; |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICalendarService |
| | | @Override |
| | | public ProductionCalendar updateCalendar(CalendarUpdateVO calendarUpdateVO) { |
| | | this.calendarDayService.deleteByCalendarId(calendarUpdateVO.getId()); |
| | | this.calendarDaytimeService.deleteByCalendarId(calendarUpdateVO.getId()); |
| | |
| | | Integer year = productionCalendar.getYear(); |
| | | LocalDate queryStartDay = LocalDate.of(year.intValue(), 1, 1); |
| | | Long calendarId = productionCalendar.getId(); |
| | | Set<LocalDate> dateList = (Set) dateDTOList.stream().filter(c -> { |
| | | 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> offDay = (Set) dateDTOList.stream().filter(c2 -> { |
| | | Set<LocalDate> offDay = dateDTOList.stream().filter(c2 -> { |
| | | return !Func.isNull(c2.getOffDayId()); |
| | | }).map((v0) -> { |
| | | return v0.getCalendarDate(); |
| | | }).collect(Collectors.toSet()); |
| | | List<ProductionCalendarDaytime> productionCalendarDaytimeList = new ArrayList<>(); |
| | | List<ProductionCalendarDay> productionCalendarDayList = new ArrayList<>(); |
| | | List<Long> modelIds = (List) dateDTOList.stream().map((v0) -> { |
| | | List<Long> modelIds = dateDTOList.stream().map((v0) -> { |
| | | return v0.getModelId(); |
| | | }).distinct().collect(Collectors.toList()); |
| | | Map<Long, ShiftVO> shiftDetailMap = this.shiftModelService.getShiftDetail(modelIds); |
| | |
| | | private void buildCalendarOffDay(ProductionCalendarDay productionCalendarDay, Snowflake snowflake, List<ProductionCalendarDay> productionCalendarDayList, ShiftVO shiftDetail, Long calendarId, List<ProductionCalendarDaytime> curProductionCalendarDayTimeList, CalendarDateDTO calendarDateDTO, Integer week, Integer month, Integer year, Integer startDate, Integer endDate) { |
| | | productionCalendarDay.setId(Long.valueOf(snowflake.nextId())); |
| | | productionCalendarDayList.add(productionCalendarDay); |
| | | List<ShiftDetailVO> collect = (List) shiftDetail.getShiftDetailVOList().stream().sorted(Comparator.comparing((v0) -> { |
| | | List<ShiftDetailVO> collect = shiftDetail.getShiftDetailVOList().stream().sorted(Comparator.comparing((v0) -> { |
| | | return v0.getShiftStartTime(); |
| | | })).collect(Collectors.toList()); |
| | | for (int i = 0; i < collect.size(); i++) { |
| | |
| | | Integer endTime = shiftDetailVO.getShiftEndTime(); |
| | | createUndefinedDaytime(calendarId, curProductionCalendarDayTimeList, calendarDateDTO, week, month, year, startDate, endDate, productionCalendarDay, collect, i, startTime, endTime); |
| | | if (CollectionUtil.isNotEmpty(shiftDetailVO.getShiftRestTimeVOList())) { |
| | | List<ShiftRestTimeVO> shiftRestTimeVOList = (List) shiftDetailVO.getShiftRestTimeVOList().stream().sorted(Comparator.comparing((v0) -> { |
| | | List<ShiftRestTimeVO> shiftRestTimeVOList = shiftDetailVO.getShiftRestTimeVOList().stream().sorted(Comparator.comparing((v0) -> { |
| | | return v0.getRestStartTime(); |
| | | })).collect(Collectors.toList()); |
| | | createShiftDayTime(calendarId, curProductionCalendarDayTimeList, calendarDateDTO, week, month, year, productionCalendarDay, shiftDetailVO, startTime, endTime, shiftRestTimeVOList); |
| | |
| | | Long calendarId = calenadar.getId(); |
| | | Integer year = calenadar.getYear(); |
| | | Integer currentYear = Integer.valueOf(LocalDate.now().getYear()); |
| | | Set<LocalDate> dateList = (Set) dateDTOList.stream().filter(c -> { |
| | | 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> offDay = (Set) dateDTOList.stream().filter(c2 -> { |
| | | Set<LocalDate> offDay = dateDTOList.stream().filter(c2 -> { |
| | | return !Func.isNull(c2.getOffDayId()); |
| | | }).map((v0) -> { |
| | | return v0.getCalendarDate(); |
| | | }).collect(Collectors.toSet()); |
| | | List<ProductionCalendarDaytime> productionCalendarDaytimeList = new ArrayList<>(); |
| | | List<ProductionCalendarDay> productionCalendarDayList = new ArrayList<>(); |
| | | List<Long> modelIds = (List) dateDTOList.stream().map((v0) -> { |
| | | List<Long> modelIds = dateDTOList.stream().map((v0) -> { |
| | | return v0.getModelId(); |
| | | }).distinct().collect(Collectors.toList()); |
| | | Map<Long, ShiftVO> shiftDetailMap = this.shiftModelService.getShiftDetail(modelIds); |
| | |
| | | productionCalendarDaytimeList.addAll(curProductionCalendarDayTimeList); |
| | | return; |
| | | } |
| | | List<ProductionCalendarDaytime> filterList = (List) curProductionCalendarDayTimeList.stream().filter(item -> { |
| | | List<ProductionCalendarDaytime> filterList = curProductionCalendarDayTimeList.stream().filter(item -> { |
| | | return item.getStartTime().isBefore(nextStartTime); |
| | | }).sorted(Comparator.comparing((v0) -> { |
| | | return v0.getStartTime(); |
| | |
| | | }); |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICalendarService |
| | | @Override |
| | | public CalendarVO getCalendar(Long calendarId) { |
| | | CalendarVO calendarDetail = this.baseMapper.getCalendarDetail(calendarId); |
| | | List<CalendarDayVO> otherCalendarDayVOList = new ArrayList<>(); |
| | |
| | | |
| | | private void entityToVo(List<CalendarDayVO> otherCalendarDayVOList, List<ProductionCalendarDay> list) { |
| | | if (Func.isNotEmpty(list)) { |
| | | otherCalendarDayVOList.addAll((Collection) list.stream().map(productionCalendarDay -> { |
| | | otherCalendarDayVOList.addAll(list.stream().map(productionCalendarDay -> { |
| | | CalendarDayVO calendarDayVO = new CalendarDayVO(); |
| | | BeanUtils.copyProperties(productionCalendarDay, calendarDayVO); |
| | | return calendarDayVO; |
| | |
| | | } |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICalendarService |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public ProductionCalendar copyCalendar(CalendarCopyVO calendarCopyVO) { |
| | | CalendarSaveVO calendarSaveVO = new CalendarSaveVO(); |
| | |
| | | private void saveYearCalendarDayTime(List<CalendarDateDTO> dateDTOList, ProductionCalendar productionCalendar) { |
| | | Integer year = productionCalendar.getYear(); |
| | | Long calendarId = productionCalendar.getId(); |
| | | Set<LocalDate> dateList = (Set) dateDTOList.stream().filter(c -> { |
| | | 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> offDay = (Set) dateDTOList.stream().filter(c2 -> { |
| | | Set<LocalDate> offDay = dateDTOList.stream().filter(c2 -> { |
| | | return !Func.isNull(c2.getOffDayId()); |
| | | }).map((v0) -> { |
| | | return v0.getCalendarDate(); |
| | | }).collect(Collectors.toSet()); |
| | | List<ProductionCalendarDaytime> productionCalendarDaytimeList = new ArrayList<>(); |
| | | List<ProductionCalendarDay> productionCalendarDayList = new ArrayList<>(); |
| | | List<Long> modelIds = (List) dateDTOList.stream().map((v0) -> { |
| | | List<Long> modelIds = dateDTOList.stream().map((v0) -> { |
| | | return v0.getModelId(); |
| | | }).distinct().collect(Collectors.toList()); |
| | | Map<Long, ShiftVO> shiftDetailMap = this.shiftModelService.getShiftDetail(modelIds); |
| | |
| | | } |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICalendarService |
| | | @Override |
| | | public List<TimestampToProductionTimeCacheDto> buildProductionTimeCache(CacheBuildDTO cacheBuildDTO) { |
| | | LocalDate targetDate = cacheBuildDTO.getTargetDate(); |
| | | Set<String> tenantIds = cacheBuildDTO.getTenantIds(); |
| | |
| | | timeSlicesDTOMap.put(Integer.valueOf(i), calendarShiftTimeSlicesDTO); |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICalendarService |
| | | @Override |
| | | public List<CalendarSimpleVO> getCalendarList(String tenantId) { |
| | | return list(Wrappers.<ProductionCalendar>query().lambda() |
| | | .eq(ProductionCalendar::getTenantId, tenantId)) |
| | |
| | | */ |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICalendarService |
| | | @Override |
| | | public List<CalendarShiftDetailDTO> getDaytimeList(String tenantId, String calendarCode, Integer year) { |
| | | List<CalendarShiftDetailDTO> result = new ArrayList<>(); |
| | | Optional.ofNullable(getOne(new QueryWrapper<ProductionCalendar>().lambda() |
| | |
| | | return result; |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICalendarService |
| | | @Override |
| | | public List<CalendarCacheDTO> buildCalendarShift(CacheBuildDTO cacheBuildDTO) { |
| | | List<CalendarCacheDTO> calendarCacheDTOList = new LinkedList<>(); |
| | | LocalDate targetDate = cacheBuildDTO.getTargetDate(); |
| | |
| | | return calendarCacheDTOList; |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICalendarService |
| | | @Override |
| | | public List<CurShiftDTO> getCurShift(String tenantId, List<String> calendarCodeList) { |
| | | List<ProductionCalendar> list = list(new QueryWrapper<ProductionCalendar>().lambda() |
| | | .in(ProductionCalendar::getCode, calendarCodeList) |
| | |
| | | return curShiftDTOS; |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICalendarService |
| | | @Override |
| | | public Map<String, FactoryDayInfoDTO> getFactoryDayInfo(LocalDateTime date, String tenantId, List<String> calendarCodeList) { |
| | | List<FactoryDayInfoDTO> factoryDayInfoDTOList = new ArrayList<>(); |
| | | Integer minute = Integer.valueOf((date.getHour() * 60) + date.getMinute()); |
| | |
| | | }).collect(Collectors.toMap(FactoryDayInfoDTO::getCalendarCode, v -> v)); |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICalendarService |
| | | @Override |
| | | public ShiftSlicesDTO getShiftSlices(ShiftSlicesClientDTO shiftSlicesClientDTO) { |
| | | String tenantId = shiftSlicesClientDTO.getTenantId(); |
| | | String calendarCode = shiftSlicesClientDTO.getCalendarCode(); |
| | |
| | | return shiftSlicesDTO; |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICalendarService |
| | | @Override |
| | | public List<ShiftSlicesCalendarCodeDTO> getShiftSlicesList(ShiftSlicesClientCalendarCodesDTO shiftSlicesClientCalendarCodesDTO) { |
| | | List<String> calendarCodes = shiftSlicesClientCalendarCodesDTO.getCalendarCodes(); |
| | | ArrayList<ShiftSlicesCalendarCodeDTO> shiftSlicesCalendarCodeDTOList = new ArrayList<>(); |
| | |
| | | return shiftSlicesCalendarCodeDTOList; |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICalendarService |
| | | @Override |
| | | public Long getShiftTimeWithoutRest(String calendarCode) { |
| | | ProductionCalendar productionCalendar = getOne(Wrappers.<ProductionCalendar>lambdaQuery() |
| | | .eq(ProductionCalendar::getCode, calendarCode) |
| | |
| | | }).sum()); |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICalendarService |
| | | @Override |
| | | public ShiftIndexNameVO getShiftIndexName() { |
| | | return this.shiftModelService.getShiftIndexName(); |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICalendarService |
| | | @Override |
| | | public String getShiftIndexNameByCodeAndYear(String calendarCode, CalendarShiftTimeSlicesDTO calendarShiftTimeSlicesDTO) { |
| | | return this.baseMapper.getShiftIndexNameByCodeAndYear(calendarCode, calendarShiftTimeSlicesDTO.getFactoryYear(), calendarShiftTimeSlicesDTO.getFactoryDate(), calendarShiftTimeSlicesDTO.getShiftIndex(), AuthUtil.getTenantId()); |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICalendarService |
| | | @Override |
| | | public String expireCalendarInfo() { |
| | | String code = this.baseMapper.expireCalendarInfo(LocalDate.now().getYear()); |
| | | LocalDate now = LocalDate.now(); |
| | |
| | | return null; |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICalendarService |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public Boolean deleteCalendar(Long id) { |
| | | //Workstation::getCalendarCodeWaiting |
| | |
| | | return true; |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICalendarService |
| | | @Override |
| | | public Long getShiftModelByFactoryDay(String calendarCode, LocalDate factoryDay) { |
| | | return this.baseMapper.getShiftModelByFactoryDay(calendarCode, Integer.valueOf(LocalDate.now().getYear()), factoryDay); |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICalendarService |
| | | @Override |
| | | public List<ShiftTimeDetailVO> getShiftDetailDates(String calendarCode, List<LocalDate> dates) { |
| | | |
| | | //ProductionCalendar |
| | |
| | | })).orderByAsc("calendar_date", new String[]{"shift_index"}));*/ |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICalendarService |
| | | @Override |
| | | public List<CalendarShiftDTO> getTimeShiftAll(String calendarCode, Date startTime, Date endTime) { |
| | | |
| | | QueryWrapper<Object> wrapper = Wrappers.query().eq("bpc.is_deleted", 0) |
| | |
| | | */ |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICalendarService |
| | | @Override |
| | | public List<ShiftIndexInfoDTO> getWorkstationShiftIndexListByDate(Long workstationId, LocalDate localDate) { |
| | | List<ShiftIndexInfoDTO> result = Lists.newArrayList(); |
| | | |
| | |
| | | return workstationShiftIndexListByDate; |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICalendarService |
| | | @Override |
| | | public Boolean associateWorkstation(CalendarAssociateWorkstationVO calendarAssociateWorkstationVO) { |
| | | return this.workstationService.update(Wrappers.<Workstation>lambdaUpdate() |
| | | .set(Workstation::getCalendarCodeWaiting, calendarAssociateWorkstationVO.getCalendarCode()) |
| | |
| | | }, calendarAssociateWorkstationVO.getWorkstationIdList())));*/ |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICalendarService |
| | | @Override |
| | | public List<ShiftIndexNameDTO> queryShiftIndexName(String calendarCode, Integer year, String day) { |
| | | Integer maxShiftIndex; |
| | | List<ShiftIndexNameDTO> shiftIndexNameDTOList = this.baseMapper.queryShiftIndexName(calendarCode, year, day); |
| | |
| | | return shiftIndexNameDTOList; |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICalendarService |
| | | @Override |
| | | public List<ShiftInfoDTO> listShiftInfo(List<Long> workstationIdList, LocalDate startDay, LocalDate endDay) { |
| | | Integer maxShiftIndex; |
| | | List<ShiftInfoDTO> shiftInfoDTOList = this.baseMapper.listShiftInfo(workstationIdList, startDay, endDay); |