no message
							parent
							
								
									755b86ace9
								
							
						
					
					
						commit
						2e85985110
					
				| 
						 | 
				
			
			@ -43,8 +43,8 @@ public class MesController {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    @PostMapping("/zpjlZj")
 | 
			
		||||
    @Log("mes-其他整件叫料")
 | 
			
		||||
    @ApiOperation("mes-其他整件叫料")
 | 
			
		||||
    @Log("mes-整件叫料")
 | 
			
		||||
    @ApiOperation("mes-整件叫料")
 | 
			
		||||
    @AnonymousAccess
 | 
			
		||||
    public ResponseEntity<Object> zpjlZj(@Validated @RequestBody ZpjlZj zpjlZj) {
 | 
			
		||||
        try {
 | 
			
		||||
| 
						 | 
				
			
			@ -60,8 +60,8 @@ public class MesController {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    @PostMapping("/zpjlCt")
 | 
			
		||||
    @Log("mes-成套叫料")
 | 
			
		||||
    @ApiOperation("mes-成套叫料")
 | 
			
		||||
    @Log("mes-散件叫料")
 | 
			
		||||
    @ApiOperation("mes-散件叫料")
 | 
			
		||||
    @AnonymousAccess
 | 
			
		||||
    public ResponseEntity<Object> zpjlCt(@Validated @RequestBody ZpjlCt zpjlCt) {
 | 
			
		||||
        try {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -30,6 +30,7 @@ import java.util.ArrayList;
 | 
			
		|||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
import java.util.concurrent.ConcurrentHashMap;
 | 
			
		||||
import java.util.concurrent.atomic.AtomicInteger;
 | 
			
		||||
import java.util.stream.Collectors;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -96,7 +97,6 @@ public class MesServiceImpl implements MesService {
 | 
			
		|||
        if (!createPickDetails.isEmpty()) {
 | 
			
		||||
            pickDetailRepository.saveAll(createPickDetails);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
| 
						 | 
				
			
			@ -273,9 +273,7 @@ public class MesServiceImpl implements MesService {
 | 
			
		|||
        //创建Agv任务
 | 
			
		||||
        AgvTask agvTask = agvTaskService.createAgvTask(BizStatus.Cp_Off_Up, emptyStock, srcPoint.getCode(), endPoint.getCode(), "RACK_MOVE");
 | 
			
		||||
        // 更新点位状态
 | 
			
		||||
        synchronized (this) {
 | 
			
		||||
            pointService.usedPoint(endPoint);
 | 
			
		||||
        }
 | 
			
		||||
        pointService.usedPoint(endPoint);
 | 
			
		||||
        //下发任务
 | 
			
		||||
        kmReService.sendAgvTask(agvTask, kmReService.sendAgvTaskHjJson(agvTask));
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -296,13 +294,15 @@ public class MesServiceImpl implements MesService {
 | 
			
		|||
                if (agvTaskService.findByEndSlotCode(endPoint.getCode(), BizStatus.Cp_Off_Line, "RACK_MOVE")) {
 | 
			
		||||
                    //创建Agv任务
 | 
			
		||||
                    AgvTask agvTask = agvTaskService.createAgvTask(BizStatus.Cp_Off_Line, fullStock, srcPoint.getCode(), endPoint.getCode(), "RACK_MOVE");
 | 
			
		||||
                    synchronized (this) {
 | 
			
		||||
                    synchronized (endPoint) {
 | 
			
		||||
                        // 更新点位状态
 | 
			
		||||
                        pointService.usedPoint(endPoint);
 | 
			
		||||
 | 
			
		||||
                        //占用容器
 | 
			
		||||
                        stockService.usedStock(fullStock, srcPoint, BaseStatus.USED);
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                    //下发任务
 | 
			
		||||
                    kmReService.sendAgvTask(agvTask, kmReService.sendAgvTaskHjJson(agvTask));
 | 
			
		||||
                }
 | 
			
		||||
| 
						 | 
				
			
			@ -333,10 +333,14 @@ public class MesServiceImpl implements MesService {
 | 
			
		|||
 | 
			
		||||
        //创建Agv任务
 | 
			
		||||
        AgvTask agvTask = agvTaskService.createAgvTask(BizStatus.Cp_Off_Line, stock, srcPoint.getCode(), endPoint.getCode(), "RACK_MOVE");
 | 
			
		||||
        // 更新点位状态
 | 
			
		||||
        pointService.usedPoint(endPoint);
 | 
			
		||||
        //占用容器
 | 
			
		||||
        stockService.usedStock(stock, srcPoint, BaseStatus.USED);
 | 
			
		||||
 | 
			
		||||
        synchronized (endPoint) {
 | 
			
		||||
            // 更新点位状态
 | 
			
		||||
            pointService.usedPoint(endPoint);
 | 
			
		||||
            //占用容器
 | 
			
		||||
            stockService.usedStock(stock, srcPoint, BaseStatus.USED);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //下发任务
 | 
			
		||||
        kmReService.sendAgvTask(agvTask, kmReService.sendAgvTaskHjJson(agvTask));
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -192,7 +192,7 @@ public class TaskServiceImpl implements TaskService {
 | 
			
		|||
        }
 | 
			
		||||
 | 
			
		||||
        /* 更新出库单状态*/
 | 
			
		||||
        synchronized (this) {
 | 
			
		||||
        synchronized (pick) {
 | 
			
		||||
            pickService.refreshPickStatus(pick);
 | 
			
		||||
 | 
			
		||||
            if (BizStatus.ALLOCATE.equals(pick.getStatus()) || BizStatus.ASSIGN.equals(pick.getStatus())) {
 | 
			
		||||
| 
						 | 
				
			
			@ -215,34 +215,27 @@ public class TaskServiceImpl implements TaskService {
 | 
			
		|||
    public void materialPick(Pick pick) {
 | 
			
		||||
        AgvTask agvTask = null;
 | 
			
		||||
        List<Task> taskList = this.findByPickNotAllTask(pick.getId());
 | 
			
		||||
        synchronized (this) {
 | 
			
		||||
            for (Task task : taskList) {
 | 
			
		||||
                /*生成搬运任务*/
 | 
			
		||||
                List<AgvTask> agvTaskList = agvTaskService.findRepeat(task.getSrcStockCode(), task.getSrcPointCode(), task.getDstPointCode());
 | 
			
		||||
                if (agvTaskList.isEmpty()) {
 | 
			
		||||
                    //创建任务
 | 
			
		||||
                    agvTask = agvTaskService.createAgvTask(BizStatus.PICK, task.getSrcStock(), task.getSrcPoint().getCode(), task.getDstPoint().getCode(), "FORKLIFT_MOVE");
 | 
			
		||||
 | 
			
		||||
                    //终点占用
 | 
			
		||||
                    pointService.usedPoint(task.getDstPoint());
 | 
			
		||||
                } else {
 | 
			
		||||
                    agvTask = agvTaskList.get(0);
 | 
			
		||||
                }
 | 
			
		||||
                task.setAgvTask(agvTask);
 | 
			
		||||
                task.setTaskStatus(agvTask.getStatus());
 | 
			
		||||
                taskRepository.save(task);
 | 
			
		||||
 | 
			
		||||
        for (Task task : taskList) {
 | 
			
		||||
            /*生成搬运任务*/
 | 
			
		||||
            List<AgvTask> agvTaskList = agvTaskService.findRepeat(task.getSrcStockCode(), task.getSrcPointCode(), task.getDstPointCode());
 | 
			
		||||
            if (agvTaskList.isEmpty()) {
 | 
			
		||||
                //创建任务
 | 
			
		||||
                agvTask = agvTaskService.createAgvTask(BizStatus.PICK, task.getSrcStock(), task.getSrcPoint().getCode(), task.getDstPoint().getCode(), "FORKLIFT_MOVE");
 | 
			
		||||
 | 
			
		||||
                //终点占用
 | 
			
		||||
                pointService.usedPoint(task.getDstPoint());
 | 
			
		||||
            } else {
 | 
			
		||||
                agvTask = agvTaskList.get(0);
 | 
			
		||||
            }
 | 
			
		||||
            task.setAgvTask(agvTask);
 | 
			
		||||
            task.setTaskStatus(agvTask.getStatus());
 | 
			
		||||
            taskRepository.save(task);
 | 
			
		||||
           /* //叫料区是否有空车,呼叫到备料缓存区
 | 
			
		||||
            this.callEmptyStock(task.getPickDetail().getItem().getGoodType());*/
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /*更新出库单状态*/
 | 
			
		||||
        synchronized (this) {
 | 
			
		||||
            pick.setStatus(BizStatus.PICKUP);
 | 
			
		||||
            pickService.update(pick);
 | 
			
		||||
        }
 | 
			
		||||
        pick.setStatus(BizStatus.PICKUP);
 | 
			
		||||
        pickService.update(pick);
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -276,9 +269,7 @@ public class TaskServiceImpl implements TaskService {
 | 
			
		|||
        }
 | 
			
		||||
 | 
			
		||||
        //终点占用
 | 
			
		||||
        synchronized (this) {
 | 
			
		||||
            pointService.usedPoint(endPoint);
 | 
			
		||||
        }
 | 
			
		||||
        pointService.usedPoint(endPoint);
 | 
			
		||||
 | 
			
		||||
        //创建任务
 | 
			
		||||
        agvTaskService.createAgvTask(BizStatus.CALL_RETURN, stock, srcPoint.getCode(), endPoint.getCode(), "RACK_MOVE");
 | 
			
		||||
| 
						 | 
				
			
			@ -311,22 +302,21 @@ public class TaskServiceImpl implements TaskService {
 | 
			
		|||
 | 
			
		||||
        //绑定任务
 | 
			
		||||
        List<Task> taskList = this.findByPickAllTask(pick.getId());
 | 
			
		||||
        synchronized (this) {
 | 
			
		||||
            for (Task task : taskList) {
 | 
			
		||||
                task.setCallAgvTaskId(agvTask.getId());
 | 
			
		||||
                taskRepository.save(task);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            //起点占用
 | 
			
		||||
            pointService.usedPoint(srcPoint);
 | 
			
		||||
 | 
			
		||||
            //终点占用
 | 
			
		||||
            pointService.usedPoint(endPoint);
 | 
			
		||||
 | 
			
		||||
            //更新出库单状态为叫料中
 | 
			
		||||
            pick.setStatus(BizStatus.SHIP_PART);
 | 
			
		||||
            pickService.update(pick);
 | 
			
		||||
        for (Task task : taskList) {
 | 
			
		||||
            task.setCallAgvTaskId(agvTask.getId());
 | 
			
		||||
            taskRepository.save(task);
 | 
			
		||||
        }
 | 
			
		||||
        //起点占用
 | 
			
		||||
        pointService.usedPoint(srcPoint);
 | 
			
		||||
 | 
			
		||||
        //终点占用
 | 
			
		||||
        pointService.usedPoint(endPoint);
 | 
			
		||||
 | 
			
		||||
        //更新出库单状态为叫料中
 | 
			
		||||
        pick.setStatus(BizStatus.SHIP_PART);
 | 
			
		||||
        pickService.update(pick);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -354,9 +344,9 @@ public class TaskServiceImpl implements TaskService {
 | 
			
		|||
        //未分配数量
 | 
			
		||||
        double unQty = quantity;
 | 
			
		||||
        Set<String> tps = new HashSet<>();
 | 
			
		||||
        synchronized (this) {
 | 
			
		||||
            for (Inventory inv : inventoryList) {
 | 
			
		||||
                //判断托盘是否有任务
 | 
			
		||||
        for (Inventory inv : inventoryList) {
 | 
			
		||||
            //判断托盘是否有任务
 | 
			
		||||
            synchronized (inv) {
 | 
			
		||||
                if (this.existsByStock(pick.getCode(), inv.getStockCode()) >= 1) {
 | 
			
		||||
                    tps.add(inv.getStockCode());
 | 
			
		||||
                    continue;
 | 
			
		||||
| 
						 | 
				
			
			@ -384,7 +374,6 @@ public class TaskServiceImpl implements TaskService {
 | 
			
		|||
 | 
			
		||||
                //生成Task任务
 | 
			
		||||
                this.createTask(item, allocateQty, inv.getItemKey(), null, BizStatus.PICK, pickDetail, inv.getId(), inv.getStock(), startPoint, endPoint, null);
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -399,23 +388,20 @@ public class TaskServiceImpl implements TaskService {
 | 
			
		|||
    public void cancelAllocate(long id, double quantity) {
 | 
			
		||||
        PickDetail pd = pickDetailService.findById(id);
 | 
			
		||||
        List<Task> tasks = this.findByPickDetailNotAllTask(id);
 | 
			
		||||
        synchronized (this) {
 | 
			
		||||
            for (Task task : tasks) {
 | 
			
		||||
                //根据task找到对应的库存
 | 
			
		||||
                Inventory inv = inventoryService.findById(task.getInvId());
 | 
			
		||||
                inv.setQueuedQty(inv.getQueuedQty() - pd.getAllocatedQty());
 | 
			
		||||
                inventoryService.update(inv);
 | 
			
		||||
        for (Task task : tasks) {
 | 
			
		||||
            //根据task找到对应的库存
 | 
			
		||||
            Inventory inv = inventoryService.findById(task.getInvId());
 | 
			
		||||
            inv.setQueuedQty(inv.getQueuedQty() - pd.getAllocatedQty());
 | 
			
		||||
            inventoryService.update(inv);
 | 
			
		||||
 | 
			
		||||
                //删除Task
 | 
			
		||||
                taskRepository.delete(task);
 | 
			
		||||
 | 
			
		||||
                pd.setAllocatedQty(pd.getAllocatedQty() - quantity);
 | 
			
		||||
                if (pd.getAllocatedQty() == 0) {
 | 
			
		||||
                    pd.setStatus(BizStatus.OPEN);
 | 
			
		||||
                }
 | 
			
		||||
                pickDetailService.update(pd);
 | 
			
		||||
            //删除Task
 | 
			
		||||
            taskRepository.delete(task);
 | 
			
		||||
 | 
			
		||||
            pd.setAllocatedQty(pd.getAllocatedQty() - quantity);
 | 
			
		||||
            if (pd.getAllocatedQty() == 0) {
 | 
			
		||||
                pd.setStatus(BizStatus.OPEN);
 | 
			
		||||
            }
 | 
			
		||||
            pickDetailService.update(pd);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -431,11 +417,7 @@ public class TaskServiceImpl implements TaskService {
 | 
			
		|||
        if (task.getPlanQty() > task.getMoveQty()) {
 | 
			
		||||
            PickDetail pickDetail = task.getPickDetail();
 | 
			
		||||
            Inventory inv = inventoryService.findById(task.getInvId());
 | 
			
		||||
            synchronized (this) {
 | 
			
		||||
                task.setMoveQty(pickedQuantity);
 | 
			
		||||
                task.setTaskStatus(BizStatus.FINISH);
 | 
			
		||||
                taskRepository.save(task);
 | 
			
		||||
 | 
			
		||||
            synchronized (inv) {
 | 
			
		||||
                inv.setQuantity(inv.getQuantity() - pickedQuantity);
 | 
			
		||||
                inv.setQueuedQty(inv.getQueuedQty() - pickedQuantity);
 | 
			
		||||
                inventoryService.update(inv);
 | 
			
		||||
| 
						 | 
				
			
			@ -447,6 +429,10 @@ public class TaskServiceImpl implements TaskService {
 | 
			
		|||
                    inventoryService.deleteAll(new Long[]{inv.getId()});
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                task.setMoveQty(pickedQuantity);
 | 
			
		||||
                task.setTaskStatus(BizStatus.FINISH);
 | 
			
		||||
                taskRepository.save(task);
 | 
			
		||||
 | 
			
		||||
                //回写拣货数量
 | 
			
		||||
                pickDetail.setPickedQty(pickDetail.getPickedQty() + pickedQuantity);
 | 
			
		||||
                pickDetailService.update(pickDetail);
 | 
			
		||||
| 
						 | 
				
			
			@ -475,7 +461,7 @@ public class TaskServiceImpl implements TaskService {
 | 
			
		|||
 | 
			
		||||
        //退回库存
 | 
			
		||||
        double srcQty = inv.getQueuedQty();
 | 
			
		||||
        synchronized (this) {
 | 
			
		||||
        synchronized (inv) {
 | 
			
		||||
            inv.setQueuedQty(inv.getQueuedQty() + pickedQuantity);
 | 
			
		||||
            inv.setQuantity(inv.getQuantity() + pickedQuantity);
 | 
			
		||||
            inventoryService.update(inv);
 | 
			
		||||
| 
						 | 
				
			
			@ -537,17 +523,14 @@ public class TaskServiceImpl implements TaskService {
 | 
			
		|||
            throw new BadRequestException(orderNumber + "箱号库存数量不足,请更换箱号!");
 | 
			
		||||
        }
 | 
			
		||||
        Inventory srcinventory = inventoryService.findById(task.getInvId());
 | 
			
		||||
        synchronized (srcinventory) {
 | 
			
		||||
            synchronized (dstinventory) {
 | 
			
		||||
                srcinventory.setQueuedQty(srcinventory.getQueuedQty() - task.getPlanQty());
 | 
			
		||||
                inventoryService.update(srcinventory);
 | 
			
		||||
                dstinventory.setQueuedQty(dstinventory.getQueuedQty() + task.getPlanQty());
 | 
			
		||||
                inventoryService.update(dstinventory);
 | 
			
		||||
                task.setInvId(dstinventory.getId());
 | 
			
		||||
                task.setItemKey(dstinventory.getItemKey());
 | 
			
		||||
                taskRepository.save(task);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        srcinventory.setQueuedQty(srcinventory.getQueuedQty() - task.getPlanQty());
 | 
			
		||||
        inventoryService.update(srcinventory);
 | 
			
		||||
        dstinventory.setQueuedQty(dstinventory.getQueuedQty() + task.getPlanQty());
 | 
			
		||||
        inventoryService.update(dstinventory);
 | 
			
		||||
        task.setInvId(dstinventory.getId());
 | 
			
		||||
        task.setItemKey(dstinventory.getItemKey());
 | 
			
		||||
        taskRepository.save(task);
 | 
			
		||||
 | 
			
		||||
        return task;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -584,9 +567,7 @@ public class TaskServiceImpl implements TaskService {
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
        //容器占用
 | 
			
		||||
        synchronized (dstStock) {
 | 
			
		||||
            stockService.usedStock(dstStock, dstStock.getPoint(), BaseStatus.USED);
 | 
			
		||||
        }
 | 
			
		||||
        stockService.usedStock(dstStock, dstStock.getPoint(), BaseStatus.USED);
 | 
			
		||||
 | 
			
		||||
        //库存日志
 | 
			
		||||
        inventoryLogService.createInventoryLog(BizStatus.MOVE, BizStatus.ADD, task.getPickDetail().getPo(), task.getItemKey(), task.getDstPoint(), dstStock.getPoint(), task.getSrcStock(), dstStock, 0d, moveQty, BizStatus.PICK, task.getId(), newInventory.getId(), "");
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue