| | |
| | | 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.controller.params.CheckObjParams; |
| | | import com.vincent.rsf.server.api.controller.params.OpStockParams; |
| | | import com.vincent.rsf.server.api.controller.params.OtherReceiptParams; |
| | | import com.vincent.rsf.server.api.controller.params.ReceiptParams; |
| | | import com.vincent.rsf.server.api.entity.dto.CheckObjDto; |
| | | import com.vincent.rsf.server.api.entity.dto.InspectDetlDto; |
| | | import com.vincent.rsf.server.api.entity.dto.InspectItemDto; |
| | | import com.vincent.rsf.server.api.entity.dto.ReceiptDetlsDto; |
| | | import com.vincent.rsf.server.api.controller.params.*; |
| | | import com.vincent.rsf.server.api.entity.dto.*; |
| | | import com.vincent.rsf.server.api.entity.enums.OrderWorkType; |
| | | import com.vincent.rsf.server.api.service.MobileService; |
| | | import com.vincent.rsf.server.common.config.ConfigProperties; |
| | |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author Ryan |
| | |
| | | |
| | | @Autowired |
| | | private WaitPakinItemService waitPakinItemService; |
| | | |
| | | @Autowired |
| | | private AsnOrderItemLogService asnOrderItemLogService; |
| | | |
| | | @Autowired |
| | | private FieldsItemService fieldsItemService; |
| | | |
| | | @Autowired |
| | | private LocService locService; |
| | | |
| | | @Autowired |
| | | private PurchaseService purchaseService; |
| | | @Autowired |
| | | private StockService stockService; |
| | | @Autowired |
| | | private StockItemService stockItemService; |
| | | @Autowired |
| | | private TaskService taskService; |
| | | @Autowired |
| | | private TaskItemService taskItemService; |
| | | @Autowired |
| | | private LocAreaMatRelaMapper locAreaMatRelaMapper; |
| | | @Autowired |
| | | private LocAreaRelaMapper locAreaRelaMapper; |
| | | @Autowired |
| | | private LocAreaMapper locAreaMapper; |
| | | |
| | | /** |
| | | * @author Ryan |
| | |
| | | } |
| | | |
| | | /** |
| | | * 人工上架入库 |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R publicToStock(PublicToStockParams params) { |
| | | if (Objects.isNull(params.getLocCode()) || StringUtils.isBlank(params.getLocCode())) { |
| | | throw new CoolException("库位不能为空!!"); |
| | | } |
| | | if (Objects.isNull(params.getItemList()) || params.getItemList().isEmpty()) { |
| | | throw new CoolException("单据明细不能为空!!"); |
| | | } |
| | | Long OrderId = params.getItemList().stream().findFirst().get().getAsnId(); |
| | | AsnOrder order = asnOrderMapper.getOne(new LambdaQueryWrapper<AsnOrder>().eq(AsnOrder::getId, OrderId)); |
| | | if (Objects.isNull(order)) { |
| | | throw new CoolException("单据不存在!!"); |
| | | } |
| | | Stock stock = new Stock(); |
| | | stock.setAsnId(OrderId).setAsnCode(order.getCode()); |
| | | if (!Objects.isNull(order.getPoCode()) && StringUtils.isNotBlank(order.getPoCode())) { |
| | | Purchase purchase = purchaseService.getOne(new LambdaQueryWrapper<Purchase>().eq(Purchase::getCode, order.getPoCode())); |
| | | stock.setPlatOrderNo(purchase.getPlatCode()).setPlatToken(purchase.getPlatId()); |
| | | } |
| | | String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_STOCK_CODE, null); |
| | | if (StringUtils.isBlank(ruleCode)) { |
| | | throw new CoolException("当前业务:" + SerialRuleCode.SYS_STOCK_CODE + ",编码规则不存在!!"); |
| | | } |
| | | if (!stockService.save(stock)) { |
| | | throw new CoolException("库存保存失败!!"); |
| | | } |
| | | Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getBarcode, params.getLocCode())); |
| | | if (Objects.isNull(loc)) { |
| | | throw new CoolException("库位不存在!!"); |
| | | } |
| | | List<StockItem> stockItems = new ArrayList<>(); |
| | | params.getItemList().forEach(orderItem -> { |
| | | StockItem stockItem = new StockItem(); |
| | | BeanUtils.copyProperties(orderItem, stockItem); |
| | | stockItem.setAsnItemId(orderItem.getId()) |
| | | .setBarcode(orderItem.getBarcode()) |
| | | .setLocId(loc.getId()) |
| | | .setId(null) |
| | | .setStockId(stock.getId()); |
| | | stockItems.add(stockItem); |
| | | }); |
| | | |
| | | if (!stockItemService.saveBatch(stockItems)) { |
| | | throw new CoolException("任务上架失败!!"); |
| | | } |
| | | return R.ok(stock); |
| | | } |
| | | |
| | | /** |
| | | * 获取任务信息 |
| | | * @param code |
| | | * @return |
| | | */ |
| | | @Override |
| | | public R taskToStock(String code) { |
| | | if (StringUtils.isBlank(code)) { |
| | | throw new CoolException("拖盘码不能为空!!"); |
| | | } |
| | | Task task = taskService.getOne(new LambdaQueryWrapper<Task>().eq(Task::getBarcode, code)); |
| | | if (Objects.isNull(task)) { |
| | | throw new CoolException("拖盘任务不存在!!"); |
| | | } |
| | | List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId())); |
| | | if (!taskItems.isEmpty()) { |
| | | throw new CoolException("拖盘任务明细不存在!!"); |
| | | } |
| | | TaskQueueDto queueDto = new TaskQueueDto(); |
| | | queueDto.setTask(task).setTaskItems(taskItems); |
| | | List<Long> list = taskItems.stream().map(TaskItem::getMatnrId).collect(Collectors.toList()); |
| | | List<LocAreaMatRela> matRelas = locAreaMatRelaMapper.selectList(new LambdaQueryWrapper<LocAreaMatRela>().in(LocAreaMatRela::getMatnrId, |
| | | list)); |
| | | TaskLocAreaDto locAreaDto = new TaskLocAreaDto(); |
| | | /**判断是否为空*/ |
| | | if (matRelas.isEmpty()) { |
| | | locAreaDto.setLocs(new ArrayList<>()); |
| | | } else { |
| | | Long ids = matRelas.stream().map(LocAreaMatRela::getLocId).collect(Collectors.toList()).stream().findFirst().get(); |
| | | List<Loc> locs = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getId, ids)); |
| | | if (locs.isEmpty()) { |
| | | locAreaDto.setLocs(new ArrayList<>()); |
| | | } else { |
| | | LocArea locArea = locAreaMapper.selectById(new LambdaQueryWrapper<Loc>().in(Loc::getId, ids)); |
| | | if (!Objects.isNull(locArea)) { |
| | | locAreaDto.setAreaName(locArea.getName()).setAreaCode(locArea.getCode()).setAreaId(locArea.getId()); |
| | | } |
| | | locAreaDto.setLocs(locs); |
| | | } |
| | | } |
| | | queueDto.setLocArea(locAreaDto); |
| | | |
| | | return R.ok(queueDto); |
| | | } |
| | | |
| | | /** |
| | | * @Author Ryan |
| | | * @param code |
| | | * @desc 任务上架 |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R taskGetLocs(String code) throws Exception { |
| | | if (StringUtils.isBlank(code)) { |
| | | throw new CoolException("拖盘码不能为空!!"); |
| | | } |
| | | Task task = taskService.getOne(new LambdaQueryWrapper<Task>().eq(Task::getBarcode, code)); |
| | | if (Objects.isNull(task)) { |
| | | throw new CoolException("拖盘任务不存在!!"); |
| | | } |
| | | List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId())); |
| | | if (!taskItems.isEmpty()) { |
| | | throw new CoolException("拖盘任务明细不存在!!"); |
| | | } |
| | | List<Task> tasks = new ArrayList<>(); |
| | | tasks.add(task); |
| | | |
| | | taskService.completeTask(tasks); |
| | | |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 获取ReceiptDetlsDtos |
| | | */ |
| | | private R getAsnOrderItem(List<AsnOrderItem> items) { |