no message
							parent
							
								
									013e0a56f0
								
							
						
					
					
						commit
						3a900f3cb5
					
				| 
						 | 
				
			
			@ -510,29 +510,16 @@ public class StockServiceImpl implements StockService {
 | 
			
		|||
        /**验证任务*/
 | 
			
		||||
        Task task = validateTask(taskId, orderNumber);
 | 
			
		||||
 | 
			
		||||
        /**工单*/
 | 
			
		||||
        Pick pick = task.getPickDetail().getPick();
 | 
			
		||||
 | 
			
		||||
        /**验证目标容器*/
 | 
			
		||||
        Stock dstStock = validatedstStock(dstStockCode);
 | 
			
		||||
        Stock dstStock = validatedstStock(pick, dstStockCode);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        /**待拣货数量*/
 | 
			
		||||
        double moveQty = task.getPlanQty();
 | 
			
		||||
 | 
			
		||||
        if (pick.getStock() == null) {
 | 
			
		||||
            List<Inventory> inventoryList = inventoryRepository.findByStock(dstStock.getId());
 | 
			
		||||
            if (!inventoryList.isEmpty()) {
 | 
			
		||||
                throw new BadRequestException(dstStock + "目标托盘已绑定其他出库单,请更换其它的托盘!");
 | 
			
		||||
            }
 | 
			
		||||
            pick.setStock(dstStock);
 | 
			
		||||
            pickRepository.save(pick);
 | 
			
		||||
        } else {
 | 
			
		||||
            Stock oldStock = pick.getStock();
 | 
			
		||||
            if (!dstStockCode.equals(pick.getStock().getCode())) {
 | 
			
		||||
                throw new BadRequestException(pick.getGdCode() + "工单只能放入同一个货架!" + "请放入" + oldStock.getCode() + "货架!");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /**库存移位*/
 | 
			
		||||
        moveInventory(task, dstStock, moveQty);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -659,7 +646,7 @@ public class StockServiceImpl implements StockService {
 | 
			
		|||
    public String stockMsg() {
 | 
			
		||||
        try {
 | 
			
		||||
            WebSocketServer.sendInfo(new SocketMsg("容器未解绑,请及时处理!", MsgType.INFO), "stock");
 | 
			
		||||
        }catch (Exception e){
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
        }
 | 
			
		||||
        return "ok";
 | 
			
		||||
| 
						 | 
				
			
			@ -680,29 +667,30 @@ public class StockServiceImpl implements StockService {
 | 
			
		|||
        Task task = taskService.toEntity(taskDto);//Dto转实体
 | 
			
		||||
        if (orderNumber.equals(task.getItemKey().getOrderNumber())) {
 | 
			
		||||
            return task;
 | 
			
		||||
        }else{
 | 
			
		||||
        } else {
 | 
			
		||||
            //重新分配
 | 
			
		||||
            return reassignTask(task, orderNumber);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 重新分配任务
 | 
			
		||||
     */
 | 
			
		||||
    private Task reassignTask(Task task, String orderNumber) {
 | 
			
		||||
        Inventory dstinventory = inventoryRepository.findByOrderNumber(orderNumber,task.getSrcStockCode());
 | 
			
		||||
        if(dstinventory==null){
 | 
			
		||||
            throw new BadRequestException(orderNumber+"箱号无库存,请更换箱号!");
 | 
			
		||||
        Inventory dstinventory = inventoryRepository.findByOrderNumber(orderNumber, task.getSrcStockCode());
 | 
			
		||||
        if (dstinventory == null) {
 | 
			
		||||
            throw new BadRequestException(orderNumber + "箱号无库存,请更换箱号!");
 | 
			
		||||
        }
 | 
			
		||||
        double kyQty = dstinventory.getQuantity()-dstinventory.getQueuedQty();
 | 
			
		||||
        if(kyQty<task.getPlanQty()){
 | 
			
		||||
        double kyQty = dstinventory.getQuantity() - dstinventory.getQueuedQty();
 | 
			
		||||
        if (kyQty < task.getPlanQty()) {
 | 
			
		||||
            throw new BadRequestException("库存数量不足,请更换箱号!");
 | 
			
		||||
        }
 | 
			
		||||
        Inventory srcinventory = inventoryRepository.findById(task.getInvId()).get();
 | 
			
		||||
        srcinventory.setQueuedQty(srcinventory.getQueuedQty()-task.getPlanQty());
 | 
			
		||||
        srcinventory.setQueuedQty(srcinventory.getQueuedQty() - task.getPlanQty());
 | 
			
		||||
        inventoryRepository.save(srcinventory);
 | 
			
		||||
        dstinventory.setQueuedQty(dstinventory.getQueuedQty()+task.getPlanQty());
 | 
			
		||||
        dstinventory.setQueuedQty(dstinventory.getQueuedQty() + task.getPlanQty());
 | 
			
		||||
        inventoryRepository.save(dstinventory);
 | 
			
		||||
        task.setInvId(dstinventory.getId());
 | 
			
		||||
        task.setItemKey(dstinventory.getItemKey());
 | 
			
		||||
| 
						 | 
				
			
			@ -717,7 +705,7 @@ public class StockServiceImpl implements StockService {
 | 
			
		|||
     * @param dstStockCode
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    private Stock validatedstStock(String dstStockCode) {
 | 
			
		||||
    private Stock validatedstStock(Pick pick, String dstStockCode) {
 | 
			
		||||
        if (StringUtils.isEmpty(dstStockCode)) {
 | 
			
		||||
            throw new BadRequestException("请扫描目标托盘号!");
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -731,6 +719,16 @@ public class StockServiceImpl implements StockService {
 | 
			
		|||
        if (dstStock.getPoint() == null) {
 | 
			
		||||
            throw new BadRequestException(dstStockCode + "目标托盘没有关联点位!");
 | 
			
		||||
        }
 | 
			
		||||
        if (pick.getStock() == null) {
 | 
			
		||||
            List<Inventory> inventoryList = inventoryRepository.findByStock(dstStock.getId());
 | 
			
		||||
            if (!inventoryList.isEmpty()) {
 | 
			
		||||
                throw new BadRequestException(dstStock + "目标托盘已绑定其他出库单,请更换其它的托盘!");
 | 
			
		||||
            }
 | 
			
		||||
            pick.setStock(dstStock);
 | 
			
		||||
            pickRepository.save(pick);
 | 
			
		||||
        } else if (!dstStockCode.equals(pick.getStock().getCode())) {
 | 
			
		||||
            throw new BadRequestException(pick.getGdCode() + "工单只能放入同一个货架! 请放入" + pick.getStock().getCode() + "货架!");
 | 
			
		||||
        }
 | 
			
		||||
        return dstStock;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue