| | |
| | | package com.vincent.rsf.server.api.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.generator.config.IFileCreate; |
| | | import com.vincent.rsf.framework.common.Cools; |
| | | import com.vincent.rsf.framework.common.R; |
| | | import com.vincent.rsf.framework.exception.CoolException; |
| | | import com.vincent.rsf.server.api.entity.dto.ContainerWaveDto; |
| | | import com.vincent.rsf.server.api.entity.params.CallForEmptyContainersParam; |
| | | import com.vincent.rsf.server.api.entity.params.ContainerWaveParam; |
| | | import com.vincent.rsf.server.api.service.PdaOutStockService; |
| | | import com.vincent.rsf.server.manager.entity.*; |
| | | import com.vincent.rsf.server.manager.enums.AsnExceStatus; |
| | | import com.vincent.rsf.server.manager.enums.StationTypeEnum; |
| | | import com.vincent.rsf.server.manager.enums.TaskStsType; |
| | | import com.vincent.rsf.server.manager.service.*; |
| | | import com.vincent.rsf.server.manager.service.impl.BasContainerServiceImpl; |
| | | import lombok.Synchronized; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | |
| | | private AsnOrderItemService asnOrderItemService; |
| | | @Autowired |
| | | private WaveOrderRelaService waveOrderRelaService; |
| | | @Autowired |
| | | private BasStationService basStationService; |
| | | @Autowired |
| | | private LocService locService; |
| | | @Autowired |
| | | private BasContainerServiceImpl basContainerService; |
| | | |
| | | @Override |
| | | public R getOutStockTaskItem(String barcode) { |
| | |
| | | if (Cools.isEmpty(waveOrderRelas)) { |
| | | throw new CoolException("波次对应关联单未找到"); |
| | | } |
| | | List<Long> ids = waveOrderRelas.stream().map(WaveOrderRela::getOrderId).collect(Collectors.toList()); |
| | | Set<Long> ids = waveOrderRelas.stream().map(WaveOrderRela::getOrderId).collect(Collectors.toSet()); |
| | | ArrayList<WkOrderItem> list = new ArrayList<>(); |
| | | List<WkOrder> wkOrderList = asnOrderService.list(new LambdaQueryWrapper<WkOrder>().in(WkOrder::getId, ids)); |
| | | for (WkOrder wkOrder : wkOrderList) { |
| | | WkOrderItem orderItem = asnOrderItemService.getOne(new LambdaQueryWrapper<WkOrderItem>() |
| | | List<WkOrderItem> orderItem = asnOrderItemService.list(new LambdaQueryWrapper<WkOrderItem>() |
| | | .eq(WkOrderItem::getOrderId, wkOrder.getId()) |
| | | .eq(StringUtils.isNotEmpty(taskItem.getMatnrCode()), WkOrderItem::getMatnrCode, taskItem.getMatnrCode()) |
| | | .eq(StringUtils.isNotEmpty(taskItem.getBatch()), WkOrderItem::getSplrBatch, taskItem.getBatch()) |
| | | // .eq(StringUtils.isNotEmpty(taskItem.getBatch()), WkOrderItem::getSplrBatch, taskItem.getBatch()) |
| | | ); |
| | | if (null != orderItem) { |
| | | list.add(orderItem); |
| | | list.addAll(orderItem); |
| | | } |
| | | } |
| | | containerWaveDto.setWkOrderItems(list); |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Synchronized |
| | | public R callForEmptyContainers(CallForEmptyContainersParam containerWaveParam, Long loginUserId) { |
| | | // 参数校验 |
| | | if (Objects.isNull(containerWaveParam) || StringUtils.isEmpty(containerWaveParam.getStaNo())) { |
| | | throw new CoolException("参数错误,站点号不能为空"); |
| | | } |
| | | // 1. 站点信息判断 - 终点 |
| | | BasStation basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>() |
| | | .eq(BasStation::getStationName, containerWaveParam.getStaNo()) |
| | | .orderByDesc(BasStation::getId) |
| | | .last("LIMIT 1"), false); |
| | | |
| | | if (Objects.isNull(basStation)) { |
| | | throw new CoolException(containerWaveParam.getStaNo() + "站点不存在!!"); |
| | | } |
| | | if (!basStation.getUseStatus().equals("O")) { |
| | | throw new CoolException("站点状态不为空闲"); |
| | | } |
| | | |
| | | List<Long> areaList = JSONObject.parseArray(basStation.getCrossZoneArea(), Long.class); |
| | | if (Cools.isEmpty(areaList)){ |
| | | throw new CoolException("当前站点库区未配置"); |
| | | } |
| | | |
| | | BasContainer basContainer = basContainerService.getOne(new LambdaQueryWrapper<BasContainer>() |
| | | .in(BasContainer::getContainerType, containerWaveParam.getType(), false)); |
| | | if (Cools.isEmpty(basContainer)){ |
| | | throw new CoolException("未查询到相关容器规则"); |
| | | } |
| | | String barcodeType = "barcode REGEXP "+basContainer.getCodeType(); |
| | | //容器类型查询 起点 |
| | | Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>() |
| | | .apply(barcodeType) |
| | | .eq(Loc::getDeleted, 0) |
| | | .eq(Loc::getStatus, 1) |
| | | .in(Loc::getAreaId, areaList) |
| | | .eq(Loc::getUseStatus, "O") |
| | | .orderByDesc(Loc::getId) |
| | | .last("LIMIT 1"), |
| | | false); |
| | | |
| | | if (Cools.isEmpty(loc)){ |
| | | throw new CoolException("未查询到符合条件的托盘"); |
| | | } |
| | | // if (basStation.getType().equals(StationTypeEnum.STATION_TYPE_MUTI.type)) { |
| | | // //光电站点: |
| | | // Long area = basStation.getArea(); |
| | | // //是否需要转非光电站点 |
| | | // //立库出库==》结束 |
| | | // //AGV==》立库==》结束 |
| | | // } else { |
| | | // //非光电站点 |
| | | // //是否需要转光电站点 |
| | | // //AGV==》结束 |
| | | // //立库出库==》AGV==》结束 |
| | | // |
| | | // } |
| | | |
| | | return R.ok().add(loc); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | private Boolean checkWaveComplete(TaskItem taskItem) { |
| | | Wave wave = waveService.getById(taskItem.getSourceId()); |