From dbfcc91f35a6f8f723eb9cc85dbed56d2cf48790 Mon Sep 17 00:00:00 2001
From: xumiao <1365304440@qq.com>
Date: Thu, 1 Dec 2022 16:40:33 +0800
Subject: [PATCH] 接收agv取货完成,解锁、清除源点位

---
 src/main/java/com/huaheng/api/acs/service/AcsServiceImpl.java              | 17 ++++++++++++-----
 src/main/java/com/huaheng/common/constant/QuantityConstant.java            |  2 +-
 src/main/java/com/huaheng/pc/agv/domain/AgvInventory.java                  |  2 ++
 src/main/java/com/huaheng/pc/agv/service/impl/AgvInventoryServiceImpl.java |  1 +
 4 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/src/main/java/com/huaheng/api/acs/service/AcsServiceImpl.java b/src/main/java/com/huaheng/api/acs/service/AcsServiceImpl.java
index 99c0a32..d47a5a6 100644
--- a/src/main/java/com/huaheng/api/acs/service/AcsServiceImpl.java
+++ b/src/main/java/com/huaheng/api/acs/service/AcsServiceImpl.java
@@ -569,6 +569,7 @@ public class AcsServiceImpl extends ServiceImpl<AcsMapper,AgvTask> implements Ac
                     agvInventory.setWorkStationCode(workStation.getCode());
                     agvInventory.setAgvPortId(agvPort.getId());
                     agvInventory.setAgvPortCode(agvPort.getCode());
+                    agvInventory.setStatus("empty");
                     iAgvInventoryService.updateById(agvInventory);
                 });
             }else {
@@ -689,9 +690,9 @@ public class AcsServiceImpl extends ServiceImpl<AcsMapper,AgvTask> implements Ac
         if (StringUtils.isNull(sourcePosition)) {
             throw new ServiceException("源点位:" + sourcePosition.getName() + "未找到");
         }
-        if(sourcePosition.getStatus().equals(QuantityConstant.STATUS_POSITION_LOCK)){
-            throw new ServiceException("源点位:" + sourcePosition.getName() + "禁用");
-        }
+//        if(sourcePosition.getStatus().equals(QuantityConstant.STATUS_POSITION_LOCK)){
+//            throw new ServiceException("源点位:" + sourcePosition.getName() + "禁用");
+//        }
 
         if (StringUtils.isEmpty(agvTask.getToPort())) {
             throw  new ServiceException("目标点位为空");
@@ -808,6 +809,11 @@ public class AcsServiceImpl extends ServiceImpl<AcsMapper,AgvTask> implements Ac
             agvPortService.updateStatus(task.getFromPort(),QuantityConstant.STATUS_POSITION_EMPTY);
             agvPortService.setContainerCode(task.getFromPort(),null);
             updateById(agvTask);
+            AgvInventory agvInventory=new AgvInventory();
+            agvInventory.setStatus("lock");
+            LambdaQueryWrapper<AgvInventory> lambdaQueryWrapper=Wrappers.lambdaQuery();
+            lambdaQueryWrapper.eq(AgvInventory::getContainerCode,task.getContainerCode());
+            iAgvInventoryService.update(agvInventory,lambdaQueryWrapper);
         }
         if(o3.equals(QuantityConstant.STATUS_TASK_FINISH)){
             if(StringUtils.isNotEmpty(task.getPreTaskNo())){
@@ -822,8 +828,8 @@ public class AcsServiceImpl extends ServiceImpl<AcsMapper,AgvTask> implements Ac
             }
             task.setStatus(100);
             task.setCarNo(agvTask.getCarNo());
-            agvPortService.updateStatus(task.getFromPort(),QuantityConstant.STATUS_POSITION_EMPTY);
-            agvPortService.setContainerCode(task.getFromPort(),null);
+//            agvPortService.updateStatus(task.getFromPort(),QuantityConstant.STATUS_POSITION_EMPTY);
+//            agvPortService.setContainerCode(task.getFromPort(),null);
             updateById(task);
             //处理一下agv_inventory
             AgvPort toPort = agvPortService.getAgvportByCode(task.getToPort());
@@ -838,6 +844,7 @@ public class AcsServiceImpl extends ServiceImpl<AcsMapper,AgvTask> implements Ac
                     agvInventory.setWorkStationCode(workStation.getCode());
                     agvInventory.setAgvPortId(toPort.getId());
                     agvInventory.setAgvPortCode(toPort.getCode());
+                    agvInventory.setStatus("empty");
                     iAgvInventoryService.updateById(agvInventory);
                 });
             }else {
diff --git a/src/main/java/com/huaheng/common/constant/QuantityConstant.java b/src/main/java/com/huaheng/common/constant/QuantityConstant.java
index 98d1099..a665900 100644
--- a/src/main/java/com/huaheng/common/constant/QuantityConstant.java
+++ b/src/main/java/com/huaheng/common/constant/QuantityConstant.java
@@ -380,7 +380,7 @@ public class QuantityConstant {
     public static final  String STATUS_TASK_WAITING_MANUALLY_FINISH="waiting_manually_finish";
     public static final  String STATUS_TASK_MANUALLY_FINISH="manually_finish";
     public static final  String STATUS_TASK_AGV_START="start";
-    public static final  String STATUS_TASK_AGV_TASKOVER="taskOver";
+    public static final  String STATUS_TASK_AGV_TASKOVER="takeOver";
     public static final  String STATUS_TASK_AGV_FINISH="finish";
     public static final  String STATUS_TASK_AGV_ERROR="error";
     public static final  String STATUS_TASK_AGV_CANCEL="cancel";
diff --git a/src/main/java/com/huaheng/pc/agv/domain/AgvInventory.java b/src/main/java/com/huaheng/pc/agv/domain/AgvInventory.java
index ff7112f..1a1c7fd 100644
--- a/src/main/java/com/huaheng/pc/agv/domain/AgvInventory.java
+++ b/src/main/java/com/huaheng/pc/agv/domain/AgvInventory.java
@@ -44,6 +44,8 @@ public class AgvInventory implements Serializable{
         /** 数量 */
         @TableField(value = "qty")
     	private Long qty;
+    @TableField(value = "status")
+    private String status;
     /**
      * 创建时间
      */
diff --git a/src/main/java/com/huaheng/pc/agv/service/impl/AgvInventoryServiceImpl.java b/src/main/java/com/huaheng/pc/agv/service/impl/AgvInventoryServiceImpl.java
index 2e37e5f..d097a15 100644
--- a/src/main/java/com/huaheng/pc/agv/service/impl/AgvInventoryServiceImpl.java
+++ b/src/main/java/com/huaheng/pc/agv/service/impl/AgvInventoryServiceImpl.java
@@ -45,6 +45,7 @@ public class AgvInventoryServiceImpl extends ServiceImpl<AgvInventoryMapper, Agv
     public List<AgvInventory> getListByPortCode(String portCode) {
         LambdaQueryWrapper<AgvInventory> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.eq(AgvInventory::getAgvPortCode, portCode);
+        queryWrapper.eq(AgvInventory::getStatus, "empty");
         return list(queryWrapper);
     }
 
--
libgit2 0.22.2