| | |
| | | import com.vincent.rsf.server.manager.controller.dto.OrderOutItemDto; |
| | | import com.vincent.rsf.server.manager.controller.params.WaveToLocParams; |
| | | import com.vincent.rsf.server.manager.entity.*; |
| | | import com.vincent.rsf.server.manager.enums.ContainerType; |
| | | import com.vincent.rsf.server.manager.enums.TaskType; |
| | | import com.vincent.rsf.server.manager.enums.WaveRuleType; |
| | | import com.vincent.rsf.server.manager.service.*; |
| | | import com.vincent.rsf.server.manager.enums.LocStsType; |
| | | import io.swagger.models.auth.In; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | |
| | | import javax.swing.*; |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | |
| | | |
| | | public static String getTargetLoc(Long areaId, Long containerType) { |
| | | Long locType = null; |
| | | if (!Objects.isNull(containerType)) { |
| | | LocTypeService locService = SpringUtils.getBean(LocTypeService.class); |
| | | if (containerType.equals(ContainerType.CONTAINER_TYPE_NORMAL.val)) { |
| | | LocType low = locService.getOne(new LambdaQueryWrapper<LocType>() |
| | | .eq(LocType::getCode, "L")); |
| | | if (Objects.isNull(low)) { |
| | | throw new CoolException("庫位類型不存在!!"); |
| | | } |
| | | locType = low.getId(); |
| | | } else { |
| | | LocType low = locService.getOne(new LambdaQueryWrapper<LocType>() |
| | | .eq(LocType::getCode, "H")); |
| | | if (Objects.isNull(low)) { |
| | | throw new CoolException("庫位類型不存在!!"); |
| | | } |
| | | locType = low.getId(); |
| | | } |
| | | } |
| | | // if (!Objects.isNull(containerType)) { |
| | | // LocTypeService locService = SpringUtils.getBean(LocTypeService.class); |
| | | // if (containerType.equals(ContainerType.CONTAINER_TYPE_NORMAL.val)) { |
| | | // LocType low = locService.getOne(new LambdaQueryWrapper<LocType>() |
| | | // .eq(LocType::getCode, "L")); |
| | | // if (Objects.isNull(low)) { |
| | | // throw new CoolException("庫位類型不存在!!"); |
| | | // } |
| | | // locType = low.getId(); |
| | | // } else { |
| | | // LocType low = locService.getOne(new LambdaQueryWrapper<LocType>() |
| | | // .eq(LocType::getCode, "H")); |
| | | // if (Objects.isNull(low)) { |
| | | // throw new CoolException("庫位類型不存在!!"); |
| | | // } |
| | | // locType = low.getId(); |
| | | // } |
| | | // } |
| | | //TODO 库位策略后续排期 |
| | | LocService locService = SpringUtils.getBean(LocService.class); |
| | | Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>() |
| | |
| | | LambdaQueryWrapper<LocItem> locItemQueryWrapper = new LambdaQueryWrapper<>(); |
| | | locItemQueryWrapper.eq(LocItem::getMatnrCode, matnrCode); |
| | | locItemQueryWrapper.eq(StringUtils.isNotEmpty(splrBatch), LocItem::getBatch, splrBatch); |
| | | locItemQueryWrapper.orderByAsc(LocItem::getCreateTime); |
| | | //如果批次不为空,按批次先后出库 |
| | | if (StringUtils.isNotBlank(splrBatch)) { |
| | | locItemQueryWrapper.orderByAsc(LocItem::getBatch); |
| | | } else { |
| | | locItemQueryWrapper.orderByAsc(LocItem::getCreateTime); |
| | | } |
| | | String applySql = String.format( |
| | | "EXISTS (SELECT 1 FROM man_loc ml " + |
| | | "WHERE ml.use_status = '%s'" + |
| | |
| | | DeviceSiteService deviceSiteService = SpringUtils.getBean(DeviceSiteService.class); |
| | | |
| | | List<OrderOutItemDto> list = new ArrayList<>(); |
| | | //不让站点重复使用问题 |
| | | List<BasStation> stations = new ArrayList<>(); |
| | | Set<ExistDto> existDtos = new HashSet<>(); |
| | | for (WaveToLocParams item : params) { |
| | | BigDecimal issued = new BigDecimal(item.getAnfme().toString()) |
| | |
| | | locItems = LocManageUtil.getFirstInFirstOutItemList(item.getMatnrCode(), item.getBatch(), item.getAnfme()); |
| | | } |
| | | } |
| | | |
| | | for (LocItem locItem : locItems) { |
| | | Loc loc = locService.getById(locItem.getLocId()); |
| | | List<LocItem> itemList = locItemService.list(new LambdaQueryWrapper<LocItem>().eq(LocItem::getLocCode, locItem.getLocCode())); |
| | |
| | | if (existDtos.add(existDto)) { |
| | | locItem.setOutQty(issued.doubleValue() >= locItem.getAnfme() ? locItem.getAnfme() : issued.doubleValue()); |
| | | locItem.setBarcode(loc.getBarcode()) |
| | | .setSourceId(item.getWaveId()) |
| | | .setSource(item.getItemId()); |
| | | .setSourceId(item.getWaveId())//波次ID |
| | | .setSource(item.getItemId());//波次明细ID |
| | | OrderOutItemDto orderOutItemDto = new OrderOutItemDto(); |
| | | orderOutItemDto.setLocItem(locItem); |
| | | |
| | |
| | | maps.add(staListDto); |
| | | } |
| | | orderOutItemDto.setStaNos(maps); |
| | | //默认获取第一站点 |
| | | DeviceSite deviceSite = deviceSites.stream().findFirst().get(); |
| | | //获取满足条件站点 |
| | | Set<String> stationSet = deviceSites.stream().map(DeviceSite::getSite).collect(Collectors.toSet()); |
| | | //已使用站点 |
| | | Set<String> stas = stations.stream().map(BasStation::getStationName).collect(Collectors.toSet()); |
| | | BasStationService basStationService = SpringUtils.getBean(BasStationService.class); |
| | | BasStation basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>() |
| | | .eq(BasStation::getUseStatus, LocStsType.LOC_STS_TYPE_O.type) |
| | | .in(BasStation::getStationName, stationSet) |
| | | .notIn(!stas.isEmpty(), BasStation::getStationName, stas) |
| | | .last("LIMIT 1")); |
| | | stations.add(basStation); |
| | | |
| | | if (Objects.isNull(basStation)) { |
| | | throw new CoolException("站點不存在!!"); |
| | | } |
| | |
| | | |
| | | orderOutItemDto.setSource(item.getItemId()) |
| | | .setSourceId(item.getWaveId()); |
| | | |
| | | list.add(orderOutItemDto); |
| | | |
| | | issued = issued.subtract(new BigDecimal(locItem.getAnfme().toString())); |