no message
							parent
							
								
									80b45283b4
								
							
						
					
					
						commit
						2862fdef4f
					
				| 
						 | 
					@ -427,102 +427,98 @@ public class MlsServiceImpl implements MlsService {
 | 
				
			||||||
        if (inventoryListFuture.join().isEmpty()) {
 | 
					        if (inventoryListFuture.join().isEmpty()) {
 | 
				
			||||||
            throw new RuntimeException("无库存信息!");
 | 
					            throw new RuntimeException("无库存信息!");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        List<String> errorMsgList = new ArrayList<>();
 | 
					        try {
 | 
				
			||||||
        inventoryListFuture.thenAccept((result) -> {
 | 
					            inventoryListFuture.thenAccept((result) -> {
 | 
				
			||||||
            //目标点
 | 
					                //目标点
 | 
				
			||||||
            /*Point endPoint = redisObjectUtils.getObjectFromCache("ckjbk", () -> pointService.findByCode(null, BaseStatus.FREE, null, "出库接驳口", null),
 | 
					            /*Point endPoint = redisObjectUtils.getObjectFromCache("ckjbk", () -> pointService.findByCode(null, BaseStatus.FREE, null, "出库接驳口", null),
 | 
				
			||||||
                    "系统无此点位!");*/
 | 
					                    "系统无此点位!");*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            List<Inventory> inventoryToUpdate = new ArrayList<>();
 | 
					                List<Inventory> inventoryToUpdate = new ArrayList<>();
 | 
				
			||||||
            List<PickDetail> pickDetailToCreate = new ArrayList<>();
 | 
					                List<PickDetail> pickDetailToCreate = new ArrayList<>();
 | 
				
			||||||
            List<AgvTask> agvTaskToCreate = new ArrayList<>();
 | 
					                List<AgvTask> agvTaskToCreate = new ArrayList<>();
 | 
				
			||||||
            List<Task> taskToCreate = new ArrayList<>();
 | 
					                List<Task> taskToCreate = new ArrayList<>();
 | 
				
			||||||
            for (Inventory inv : result) {
 | 
					                for (Inventory inv : result) {
 | 
				
			||||||
                /* 按顺序获取出库接驳点*/
 | 
					                    /* 按顺序获取出库接驳点*/
 | 
				
			||||||
                Point endPoint;
 | 
					                    Point endPoint;
 | 
				
			||||||
                List<Point> pointList = pointRepository.findByAreaAndStatus("出库接驳口", BaseStatus.FREE);
 | 
					                    List<Point> pointList = pointRepository.findByAreaAndStatus("出库接驳口", BaseStatus.FREE);
 | 
				
			||||||
                if (pointList.size() < 1) {
 | 
					                    if (pointList.size() < 1) {
 | 
				
			||||||
                    errorMsgList.add(inv.getItemKey().getPropC1() + "标签分配无空闲缓存位!");
 | 
					                        throw new RuntimeException("无空闲出库接驳口!");
 | 
				
			||||||
                    continue;
 | 
					                        /* 出库接驳口无空闲库位,更新状态重新分配*/
 | 
				
			||||||
                    /* 出库接驳口无空闲库位,更新状态重新分配*/
 | 
					 | 
				
			||||||
                    /*pointList = pointRepository.findByAreaAndStatus("出库接驳口", BaseStatus.USED);
 | 
					                    /*pointList = pointRepository.findByAreaAndStatus("出库接驳口", BaseStatus.USED);
 | 
				
			||||||
                    for (Point p : pointList) {
 | 
					                    for (Point p : pointList) {
 | 
				
			||||||
                        p.setStatus(BaseStatus.FREE);
 | 
					                        p.setStatus(BaseStatus.FREE);
 | 
				
			||||||
                        pointRepository.save(p);
 | 
					                        pointRepository.save(p);
 | 
				
			||||||
                    }*/
 | 
					                    }*/
 | 
				
			||||||
                }
 | 
					                    }
 | 
				
			||||||
                endPoint = pointList.get(0);
 | 
					                    endPoint = pointList.get(0);
 | 
				
			||||||
                endPoint.setStatus(BaseStatus.USED);
 | 
					                    endPoint.setStatus(BaseStatus.USED);
 | 
				
			||||||
                pointRepository.save(endPoint);
 | 
					                    pointRepository.save(endPoint);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                //根据库存信息生成叫料任务
 | 
					                    //根据库存信息生成叫料任务
 | 
				
			||||||
                Stock stock = inv.getStock();//容器
 | 
					                    Stock stock = inv.getStock();//容器
 | 
				
			||||||
                Point startPoint = inv.getPoint();//起始点位
 | 
					                    Point startPoint = inv.getPoint();//起始点位
 | 
				
			||||||
                ItemKey itemKey = inv.getItemKey();
 | 
					                    ItemKey itemKey = inv.getItemKey();
 | 
				
			||||||
                Item item = inv.getItemKey().getItem();
 | 
					                    Item item = inv.getItemKey().getItem();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                //更新库存信息
 | 
					                    //更新库存信息
 | 
				
			||||||
                inventoryToUpdate.add(updateInventory(inv));
 | 
					                    inventoryToUpdate.add(updateInventory(inv));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                //生成出库明细
 | 
					                    //生成出库明细
 | 
				
			||||||
                PickDetail pd = createPickDetail(item, inv.getBillCode(), itemKey.getPropC1(), inv.getQuantity(), issueInfo.getTaskNumber());
 | 
					                    PickDetail pd = createPickDetail(item, inv.getBillCode(), itemKey.getPropC1(), inv.getQuantity(), issueInfo.getTaskNumber());
 | 
				
			||||||
                pickDetailToCreate.add(pd);
 | 
					                    pickDetailToCreate.add(pd);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                //生成搬运任务
 | 
					                    //生成搬运任务
 | 
				
			||||||
                AgvTask agvTask = new AgvTask(BizStatus.PICK, stock.getCode(), startPoint.getCode(), endPoint.getCode(), BizStatus.OPEN, "PICKER_MOVE");
 | 
					                    AgvTask agvTask = new AgvTask(BizStatus.PICK, stock.getCode(), startPoint.getCode(), endPoint.getCode(), BizStatus.OPEN, "PICKER_MOVE");
 | 
				
			||||||
                agvTaskToCreate.add(agvTask);
 | 
					                    agvTaskToCreate.add(agvTask);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                //生成Task
 | 
					                    //生成Task
 | 
				
			||||||
                Task task = createTask(item, itemKey, pd, inv.getBillCode(), stock, startPoint, endPoint, agvTask, inv);
 | 
					                    Task task = createTask(item, itemKey, pd, inv.getBillCode(), stock, startPoint, endPoint, agvTask, inv);
 | 
				
			||||||
                taskToCreate.add(task);
 | 
					                    taskToCreate.add(task);
 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            ExecutorService executor = ThreadPoolExecutorUtil.getPoll("getIssueInfo-job");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            // 批量更新库存信息
 | 
					 | 
				
			||||||
            CompletableFuture<Void> inventoryFuture = CompletableFuture.runAsync(() -> {
 | 
					 | 
				
			||||||
                //批量更新库存信息
 | 
					 | 
				
			||||||
                if (!inventoryToUpdate.isEmpty()) {
 | 
					 | 
				
			||||||
                    batchCreateOrUpdate.batchUpdate(inventoryToUpdate);
 | 
					 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            }, executor);
 | 
					                ExecutorService executor = ThreadPoolExecutorUtil.getPoll("getIssueInfo-job");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                // 批量更新库存信息
 | 
				
			||||||
 | 
					                CompletableFuture<Void> inventoryFuture = CompletableFuture.runAsync(() -> {
 | 
				
			||||||
 | 
					                    //批量更新库存信息
 | 
				
			||||||
 | 
					                    if (!inventoryToUpdate.isEmpty()) {
 | 
				
			||||||
 | 
					                        batchCreateOrUpdate.batchUpdate(inventoryToUpdate);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                }, executor);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            CompletableFuture<Void> pickDetailFuture = inventoryFuture.thenRunAsync(() -> {
 | 
					                CompletableFuture<Void> pickDetailFuture = inventoryFuture.thenRunAsync(() -> {
 | 
				
			||||||
                //批量生成叫料明细
 | 
					                    //批量生成叫料明细
 | 
				
			||||||
                if (!pickDetailToCreate.isEmpty()) {
 | 
					                    if (!pickDetailToCreate.isEmpty()) {
 | 
				
			||||||
                    batchCreateOrUpdate.batchCreate(pickDetailToCreate);
 | 
					                        batchCreateOrUpdate.batchCreate(pickDetailToCreate);
 | 
				
			||||||
                }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            }, executor);
 | 
					                }, executor);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            CompletableFuture<Void> agvTaskFuture = pickDetailFuture.thenRunAsync(() -> {
 | 
					                CompletableFuture<Void> agvTaskFuture = pickDetailFuture.thenRunAsync(() -> {
 | 
				
			||||||
                // 批量生成agv任务
 | 
					                    // 批量生成agv任务
 | 
				
			||||||
                if (!agvTaskToCreate.isEmpty()) {
 | 
					                    if (!agvTaskToCreate.isEmpty()) {
 | 
				
			||||||
                    batchCreateOrUpdate.batchCreate(agvTaskToCreate);
 | 
					                        batchCreateOrUpdate.batchCreate(agvTaskToCreate);
 | 
				
			||||||
                }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            }, executor);
 | 
					                }, executor);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            CompletableFuture<Void> taskFuture = agvTaskFuture.thenRunAsync(() -> {
 | 
					                CompletableFuture<Void> taskFuture = agvTaskFuture.thenRunAsync(() -> {
 | 
				
			||||||
                // 批量生成任务
 | 
					                    // 批量生成任务
 | 
				
			||||||
                if (!taskToCreate.isEmpty()) {
 | 
					                    if (!taskToCreate.isEmpty()) {
 | 
				
			||||||
                    batchCreateOrUpdate.batchCreate(taskToCreate);
 | 
					                        batchCreateOrUpdate.batchCreate(taskToCreate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            }, executor);
 | 
					                }, executor);
 | 
				
			||||||
            taskFuture.join();
 | 
					                taskFuture.join();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            executor.shutdown();
 | 
					                executor.shutdown();
 | 
				
			||||||
        });
 | 
					            }).join();
 | 
				
			||||||
 | 
					        } catch (Exception e) {
 | 
				
			||||||
        if (!errorMsgList.isEmpty()) {
 | 
					            throw new RuntimeException(e.getMessage());
 | 
				
			||||||
            throw new RuntimeException(errorMsgList.toString());
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private void processInventory(Inventory inv, Point endPoint) {
 | 
					    private void processInventory(Inventory inv, Point endPoint) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue