From 1d7059e0408a6b658d2b5149317aea74dfc5ca29 Mon Sep 17 00:00:00 2001
From: youjie <272855983@qq.com>
Date: Fri, 10 Nov 2023 16:51:02 +0800
Subject: [PATCH] 模拟工位叫料

---
 ant-design-vue-jeecg/src/api/api.js                                                                                                |   2 +-
 ant-design-vue-jeecg/src/views/system/shipment/ShipmentContainerHeaderList.vue                                                     |  11 +++++++++--
 ant-design-vue-jeecg/src/views/system/shipment/modules/CreateShipmentTaskByAgvModal.vue                                            | 171 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 huaheng-wms-core/src/main/java/org/jeecg/modules/wms/monitor/job/AutoCreateAgvTask.java                                            |  14 +++++++-------
 huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/controller/ShipmentCombinationController.java    |  20 ++++++++++++++++++--
 huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/service/impl/ShipmentCombinationServiceImpl.java |  10 +++++++---
 huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/agvTask/service/IAgvTaskService.java                                     |  20 +++++++++++---------
 huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/agvTask/service/impl/AgvTaskServiceImpl.java                             |  38 +++++++++++++++++++++++---------------
 huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/entity/TaskHeader.java                                        |   2 +-
 huaheng-wms-core/src/main/java/org/jeecg/utils/constant/QuantityConstant.java                                                      |   8 ++++----
 10 files changed, 252 insertions(+), 44 deletions(-)
 create mode 100644 ant-design-vue-jeecg/src/views/system/shipment/modules/CreateShipmentTaskByAgvModal.vue

diff --git a/ant-design-vue-jeecg/src/api/api.js b/ant-design-vue-jeecg/src/api/api.js
index 7ddb057..bbe422b 100644
--- a/ant-design-vue-jeecg/src/api/api.js
+++ b/ant-design-vue-jeecg/src/api/api.js
@@ -275,7 +275,7 @@ export const qualityInventoryDetail = (params) => postAction('/inventory/invento
 //质检登记
 export const qualityRegister = (params) => postAction('/task/taskHeader/qualityRegister', params);
 //创建出库任务,AGV去接
-export const createShipmentTaskByAgv = (params) => postAction('/shipment/shipmentCombination/createShipmentTask', params);
+export const createShipmentTaskByAgv = (params) => postAction('/shipment/shipmentCombination/createShipmentTaskByAgv', params);
 
 // 中转HTTP请求
 export const transitRESTful = {
diff --git a/ant-design-vue-jeecg/src/views/system/shipment/ShipmentContainerHeaderList.vue b/ant-design-vue-jeecg/src/views/system/shipment/ShipmentContainerHeaderList.vue
index 4056167..273eb85 100644
--- a/ant-design-vue-jeecg/src/views/system/shipment/ShipmentContainerHeaderList.vue
+++ b/ant-design-vue-jeecg/src/views/system/shipment/ShipmentContainerHeaderList.vue
@@ -122,8 +122,8 @@
         </span>
 
         <span slot="action" slot-scope="text, record">
-          <a v-if="record.status == 0 && record.zoneType =='A'" @click="createShipmentTaskByAgv(record)"><a-button type="primary">生成任务</a-button><a-divider type="vertical"/></a>
-          <a v-if="record.status == 0 && record.zoneType !='A'" @click="selectPort(record)"><a-button type="primary">生成任务</a-button><a-divider type="vertical"/></a>
+<!--          <a v-if="record.status == 0 && record.zoneType =='A'" @click="selectPort(record)"><a-button type="primary">生成任务</a-button><a-divider type="vertical"/></a>-->
+          <a v-if="record.status == 0 && record.zoneType =='L'" @click="selectPort(record)"><a-button type="primary">生成任务</a-button><a-divider type="vertical"/></a>
           <a-popconfirm v-if="record.status == 0" v-has="'shipmentContainerHeader:delete'" title="确定取消配盘吗?" @confirm="() => handleDelete(record.id)">
              <a><a-button type="danger">取消配盘</a-button> <a-divider type="vertical"/></a>
           </a-popconfirm>
@@ -140,6 +140,7 @@
 
     <shipmentContainerHeader-modal ref="modalForm" @ok="modalFormOk"></shipmentContainerHeader-modal>
     <shipmentContainerSelect-modal ref="modalForm2" @ok="modalFormOk"></shipmentContainerSelect-modal>
+    <createShipmentTaskByAgv-modal ref="modalForm3" @ok="modalFormOk"></createShipmentTaskByAgv-modal>
   </a-card>
 </template>
 
@@ -154,11 +155,13 @@ import '@/assets/less/TableExpand.less'
 import {createShipmentTask, execute, getCompanyList, getCustomerList, getShipmentTypeList, getZoneList} from '@/api/api'
 import {selectSortingPort, createShipmentTaskByAgv} from '@/api/api'
 import ShipmentContainerSelectModal from "./modules/ShipmentContainerSelectModal";
+import CreateShipmentTaskByAgvModal from "./modules/CreateShipmentTaskByAgvModal";
 
 export default {
   name: "ShipmentContainerHeaderList",
   mixins: [JeecgListMixin],
   components: {
+    CreateShipmentTaskByAgvModal,
     ShipmentContainerSelectModal,
     ShipmentContainerDetailList,
     ShipmentContainerHeaderModal
@@ -341,6 +344,10 @@ export default {
       this.$refs.modalForm2.edit(record);
       this.$refs.modalForm2.title = "选择出库口";
     },
+    openCreateShipmentTaskAgv(record) {
+      this.$refs.modalForm3.edit(record);
+      this.$refs.modalForm3.title = "选择出库口";
+    },
     createShipmentTaskByAgv(record) {
       this.loading = true;
       createShipmentTaskByAgv(record).then((res) => {
diff --git a/ant-design-vue-jeecg/src/views/system/shipment/modules/CreateShipmentTaskByAgvModal.vue b/ant-design-vue-jeecg/src/views/system/shipment/modules/CreateShipmentTaskByAgvModal.vue
new file mode 100644
index 0000000..0ad9261
--- /dev/null
+++ b/ant-design-vue-jeecg/src/views/system/shipment/modules/CreateShipmentTaskByAgvModal.vue
@@ -0,0 +1,171 @@
+<template>
+  <j-modal
+    :title="title"
+    :width="width"
+    :visible="visible"
+    :confirmLoading="confirmLoading"
+    switchFullscreen
+    @ok="handleOk"
+    @cancel="handleCancel"
+    cancelText="关闭">
+    <a-spin :spinning="confirmLoading">
+      <a-form-model ref="form" :model="model" :rules="validatorRules">
+        <a-row>
+          <a-col :span="24">
+            <a-form-model-item label="出库口" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="toPort">
+              <a-select
+                show-search
+                placeholder="请选择出库口"
+                option-filter-prop="children"
+                v-model="model.toPort">
+                <a-select-option v-for="item in portList" :key="item.name" :value="item.code">{{
+                    item.name
+                  }}
+                </a-select-option>
+              </a-select>
+            </a-form-model-item>
+            <a-col :span="24">
+              <a-form-model-item label="去向工位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="toAgvPort">
+                <a-input v-model="model.toAgvPort" placeholder="请输入去向工位" style="width: 100%"/>
+              </a-form-model-item>
+            </a-col>
+          </a-col>
+        </a-row>
+      </a-form-model>
+    </a-spin>
+  </j-modal>
+</template>
+
+<script>
+
+import {httpAction} from '@/api/manage'
+import {validateDuplicateValue} from '@/utils/util'
+import {createShipmentTask, createShipmentTaskByAgv, createShipmentBatchTask} from '@/api/api'
+import {selectSortingPort} from '@/api/api'
+
+export default {
+  name: "CreateShipmentTaskByAgvModal",
+  components: {},
+  props: {
+    mainId: {
+      type: String,
+      required: false,
+      default: ''
+    }
+  },
+  data() {
+    return {
+      portList: [],
+      flag:'0',
+      shipmentContainerHeaderList:[],
+      title: "操作",
+      width: 500,
+      visible: false,
+      model: {},
+      labelCol: {
+        xs: {span: 24},
+        sm: {span: 5},
+      },
+      wrapperCol: {
+        xs: {span: 24},
+        sm: {span: 16},
+      },
+
+      confirmLoading: false,
+      validatorRules: {},
+      url: {
+        createTask: "/shipment/shipmentContainerHeader/createShipmentTask",
+      }
+
+    }
+  },
+  created() {
+    //备份model原始值
+    this.modelDefault = JSON.parse(JSON.stringify(this.model));
+  },
+  methods: {
+    add() {
+      this.edit(this.modelDefault);
+    },
+    edit(record) {
+      this.flag='0';
+      this.getPortList(record);
+    },
+    batchEdit(record) {
+      this.visible = true;
+      this.flag='1';
+      this.getPortList(record[0])
+      this.shipmentContainerHeaderList=record;
+    },
+    close() {
+      this.$emit('close');
+      this.visible = false;
+      this.$refs.form.clearValidate();
+    },
+    handleOk() {
+      const that = this;
+      if (this.flag=='1'){
+        this.$refs.form.validate(valid => {
+          if (valid) {
+            this.shipmentContainerHeaderList.forEach(x=>{
+              x["toPort"]=that.model.toPort;
+              x["toAgvPort"]=that.model.toAgvPort;
+            })
+            createShipmentBatchTask(this.shipmentContainerHeaderList).then((res) => {
+              if (res.success) {
+                that.$message.success(res.message);
+                that.$emit('ok');
+              } else {
+                that.$message.warning(res.message);
+              }
+            }).finally(() => {
+              that.confirmLoading = false;
+              that.close();
+            });
+          }else {
+            return false
+          }
+        })
+
+      }else{
+        // 触发表单验证
+        this.$refs.form.validate(valid => {
+          if (valid) {
+            that.confirmLoading = true;
+            createShipmentTaskByAgv(this.model).then((res) => {
+              if (res.success) {
+                that.$message.success(res.message);
+                that.$emit('ok');
+              } else {
+                that.$message.warning(res.message);
+              }
+            }).finally(() => {
+              that.confirmLoading = false;
+              that.close();
+            });
+          } else {
+            return false
+          }
+        })
+      }
+
+
+    },
+    handleCancel() {
+      this.close()
+    },
+    getPortList(record) {
+      console.log("getPortList");
+      selectSortingPort(record).then((res) => {
+        if (res.success) {
+          this.portList = res.result;
+          console.log("getPortList11");
+          this.model = Object.assign({}, record);
+          this.visible = true;
+        }
+      });
+    }
+
+  }
+}
+</script>
diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/monitor/job/AutoCreateAgvTask.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/monitor/job/AutoCreateAgvTask.java
index ce9954a..2d64abd 100644
--- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/monitor/job/AutoCreateAgvTask.java
+++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/monitor/job/AutoCreateAgvTask.java
@@ -36,18 +36,18 @@ public class AutoCreateAgvTask implements Job {
 
     @Override
     public void execute(JobExecutionContext context) throws JobExecutionException {
-        log.info(String.format("AutoSendAgvTask 下发AGV任务开始执行,时间:" + DateUtils.getTimestamp()));
+        log.info(String.format("AutoCreateAgvTask 生成AGV任务开始执行,时间:" + DateUtils.getTimestamp()));
         LambdaQueryWrapper<TaskHeader> taskHeaderLambdaQueryWrapper = Wrappers.lambdaQuery();
-        taskHeaderLambdaQueryWrapper.eq(TaskHeader::getSendAgv, QuantityConstant.AGV_NEED_SEND).le(TaskHeader::getStatus, QuantityConstant.TASK_STATUS_RELEASE)
-            .eq(TaskHeader::getTaskType, QuantityConstant.TASK_TYPE_WHOLESHIPMENT).ge(TaskHeader::getCreateTime, DateUtil.offsetDay(new Date(), -180))
-            .orderByAsc(TaskHeader::getCreateTime);
+        taskHeaderLambdaQueryWrapper.eq(TaskHeader::getCreateAgvTask, QuantityConstant.AGV_CREATE_NEED)
+            .eq(TaskHeader::getStatus, QuantityConstant.TASK_STATUS_COMPLETED).eq(TaskHeader::getTaskType, QuantityConstant.TASK_TYPE_WHOLESHIPMENT)
+            .ge(TaskHeader::getCreateTime, DateUtil.offsetDay(new Date(), -180)).orderByAsc(TaskHeader::getCreateTime);
         List<TaskHeader> taskHeaderList = taskHeaderService.list(taskHeaderLambdaQueryWrapper);
         for (TaskHeader taskHeader : taskHeaderList) {
             String containerCode = taskHeader.getContainerCode();
             String warehouseCode = taskHeader.getWarehouseCode();
             String zoneCode = taskHeader.getZoneCode();
-            String fromPortCode = taskHeader.getFromLocationCode();
-            String toPortCode = taskHeader.getToPortCode();
+            String fromPortCode = taskHeader.getToPortCode();
+            String toPortCode = taskHeader.getToAgvPort();
             AgvTask agvTask = new AgvTask();
             agvTask.setWarehouseCode(warehouseCode);
             agvTask.setZoneCode(zoneCode);
@@ -63,7 +63,7 @@ public class AutoCreateAgvTask implements Job {
                 taskHeader = new TaskHeader();
                 taskHeader.setId(taskHeaderId);
                 taskHeader.setAgvTaskId(agvTask.getId());
-                taskHeader.setSendAgv(QuantityConstant.AGV_SEND_OK);
+                taskHeader.setCreateAgvTask(QuantityConstant.AGV_CREATE_OK);
                 if (!taskHeaderService.updateById(taskHeader)) {
                     throw new JeecgBootException("更新下发任务状态失败");
                 }
diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/controller/ShipmentCombinationController.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/controller/ShipmentCombinationController.java
index 965045a..43fd2a0 100644
--- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/controller/ShipmentCombinationController.java
+++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/controller/ShipmentCombinationController.java
@@ -240,10 +240,11 @@ public class ShipmentCombinationController {
     }
 
     /**
-     * 创建出库任务,AGV去接
+     * 立库区
+     * 创建出库任务, 出库任务完成以后,AGV去接
      * @return
      */
-    @ApiOperation(value = "创建出库任务,AGV去接", notes = "创建出库任务,AGV去接")
+    @ApiOperation(value = "创建出库任务, 出库任务完成以后,AGV去接", notes = "创建出库任务, 出库任务完成以后,AGV去接")
     @PostMapping("/createShipmentTaskByAgv")
     @ResponseBody
     public Result createShipmentTaskByAgv(@RequestBody ShipmentContainerHeader shipmentContainerHeader, HttpServletRequest req) {
@@ -251,4 +252,19 @@ public class ShipmentCombinationController {
         Result result = shipmentCombinationService.createShipmentTask(shipmentContainerHeader, QuantityConstant.TASK_TYPE_WHOLESHIPMENT, warehouseCode, 0, 0, 0);
         return result;
     }
+
+    /**
+     * AGV库区
+     * 同时创建出库任务和AGV任务
+     * @return
+     */
+    @ApiOperation(value = "同时创建出库任务和AGV任务", notes = "同时创建出库任务和AGV任务")
+    @PostMapping("/createShipmentTaskAndAgvTask")
+    @ResponseBody
+    public Result createShipmentTaskAndAgvTask(@RequestBody ShipmentContainerHeader shipmentContainerHeader, HttpServletRequest req) {
+        String warehouseCode = HuahengJwtUtil.getWarehouseCodeByToken(req);
+        Result result = shipmentCombinationService.createShipmentTask(shipmentContainerHeader, QuantityConstant.TASK_TYPE_WHOLESHIPMENT, warehouseCode, 0, 0, 0);
+
+        return result;
+    }
 }
diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/service/impl/ShipmentCombinationServiceImpl.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/service/impl/ShipmentCombinationServiceImpl.java
index 5cc1d59..8d4b4f6 100644
--- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/service/impl/ShipmentCombinationServiceImpl.java
+++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/service/impl/ShipmentCombinationServiceImpl.java
@@ -852,6 +852,8 @@ public class ShipmentCombinationServiceImpl implements IShipmentCombinationServi
         int sequenceNumber) {
         Integer preTaskNo = 0;
         boolean success = false;
+        String toPort = shipmentContainerHeader.getToPort();
+        String toAgvPort = shipmentContainerHeader.getToAgvPort();
         shipmentContainerHeader = shipmentContainerHeaderService.getById(shipmentContainerHeader.getId());
         if (shipmentContainerHeader == null) {
             return Result.error("生成出库任务时, 出库组盘头" + "未找到,操作中止");
@@ -871,7 +873,6 @@ public class ShipmentCombinationServiceImpl implements IShipmentCombinationServi
         String fromLocationCode = shipmentContainerHeader.getFromLocationCode();
         String toLocationCode = shipmentContainerHeader.getToLocationCode();
         String containerCode = shipmentContainerHeader.getContainerCode();
-        String toPort = shipmentContainerHeader.getToPort();
         if (StringUtils.isEmpty(fromLocationCode)) {
             return Result.error("生成出库任务时, 出库组盘头没有起始库位编码");
         }
@@ -936,13 +937,16 @@ public class ShipmentCombinationServiceImpl implements IShipmentCombinationServi
             taskHeader.setInnernalTaskType(QuantityConstant.TASK_INTENERTYPE_SHIPMENT);
             taskHeader.setZoneCode(zoneCode);
             taskHeader.setShipmentOrder(shipmentOrder);
-            taskHeader.setToAgvPort(shipmentContainerHeader.getToAgvPort());
+            if (StringUtils.isNotEmpty(toAgvPort)) {
+                taskHeader.setToAgvPort(toAgvPort);
+                taskHeader.setCreateAgvTask(QuantityConstant.AGV_CREATE_NEED);
+            }
             taskHeader.setSequence(sequence);
             taskHeader.setSequenceNumber(sequenceNumber);
             taskHeader.setWarehouseCode(warehouseCode);
             taskHeader.setStatus(QuantityConstant.TASK_STATUS_BUILD);
             taskHeader.setContainerCode(containerCode);
-            taskHeader.setToPortCode(shipmentContainerHeader.getToPort());
+            taskHeader.setToPortCode(toPort);
             taskHeader.setFromLocationCode(fromLocationCode);
             if (taskType == QuantityConstant.TASK_TYPE_SORTINGSHIPMENT) {
                 taskHeader.setToLocationCode(toLocationCode);
diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/agvTask/service/IAgvTaskService.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/agvTask/service/IAgvTaskService.java
index 148c75d..173da6f 100644
--- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/agvTask/service/IAgvTaskService.java
+++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/agvTask/service/IAgvTaskService.java
@@ -16,30 +16,32 @@ public interface IAgvTaskService extends IService<AgvTask> {
     /**
      * 新建AGV任务
      */
-    public Result addAgvTask(AgvTask agvTask, String warehouseCode);
+    Result addAgvTask(AgvTask agvTask, String warehouseCode);
 
     /**
      * 下发AGV任务给ACS系统
      */
-    public Result sendAgvTaskToAcs(Integer taskId);
+    Result sendAgvTaskToAcs(Integer taskId);
 
     /**
      * 完成AGV任务
      */
-    public Result completeAgvTask(Integer taskId);
+    Result completeAgvTask(Integer taskId);
 
     /**
      * 取消AGV任务
      */
-    public Result cancelAgvTask(Integer taskId);
+    Result cancelAgvTask(Integer taskId);
 
-    public AgvTask getAgvTaskByPort(String portCode, String warehouseCode);
+    AgvTask getAgvTaskByPort(String portCode, String warehouseCode);
 
-    public AgvTask getAgvTaskBuFromPort(String fromPortCode, String warehouseCode);
+    AgvTask getAgvTaskBuContainerCode(String containerCode, String warehouseCode);
 
-    public AgvTask getAgvTaskBuToPort(String toPortCode, String warehouseCode);
+    AgvTask getAgvTaskBuFromPort(String fromPortCode, String warehouseCode);
 
-    public AgvTask getAgvTaskById(Integer agvTaskId, String warehouseCode);
+    AgvTask getAgvTaskBuToPort(String toPortCode, String warehouseCode);
 
-    public Result editAgvTask(AgvTask agvTask,String warehouseCode);
+    AgvTask getAgvTaskById(Integer agvTaskId, String warehouseCode);
+
+    Result editAgvTask(AgvTask agvTask, String warehouseCode);
 }
diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/agvTask/service/impl/AgvTaskServiceImpl.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/agvTask/service/impl/AgvTaskServiceImpl.java
index 59b32a0..b1ddd46 100644
--- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/agvTask/service/impl/AgvTaskServiceImpl.java
+++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/agvTask/service/impl/AgvTaskServiceImpl.java
@@ -43,6 +43,8 @@ public class AgvTaskServiceImpl extends ServiceImpl<AgvTaskMapper, AgvTask> impl
     private ITaskHeaderService taskHeaderService;
     @Resource
     private IInventoryDetailService inventoryDetailService;
+    @Resource
+    private IAgvTaskService agvTaskService;
 
     @Override
     public Result addAgvTask(AgvTask agvTask, String warehouseCode) {
@@ -54,16 +56,19 @@ public class AgvTaskServiceImpl extends ServiceImpl<AgvTaskMapper, AgvTask> impl
         if (container == null) {
             return Result.error("生成AGV任务,容器号:" + containerCode + "未找到");
         }
-        if (!container.getStatus().equals(QuantityConstant.STATUS_CONTAINER_LOCK)) {
-            if (!containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_LOCK, warehouseCode)) {
-                throw new JeecgBootException("生成AGV任务,锁定容器失败:" + containerCode);
-            }
+//        if (!container.getStatus().equals(QuantityConstant.STATUS_CONTAINER_LOCK)) {
+//            if (!containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_LOCK, warehouseCode)) {
+//                throw new JeecgBootException("生成AGV任务,锁定容器失败:" + containerCode);
+//            }
+//        }
+        if (agvTaskService.getAgvTaskBuContainerCode(containerCode, warehouseCode) != null) {
+            return Result.error("生成AGV任务失败,已经生成AGV任务");
         }
         agvTask.setWarehouseCode(warehouseCode);
         agvTask.setTaskType(QuantityConstant.AGV_TYPE_TAKE_AND_RELEASE);
         agvTask.setStatus(QuantityConstant.AGV_TASK_STATUS_BUILD);
         agvTask.setPriority(10);
-        boolean success = save(agvTask);
+        boolean success = agvTaskService.save(agvTask);
         if (!success) {
             return Result.OK("添加失败");
         }
@@ -182,20 +187,12 @@ public class AgvTaskServiceImpl extends ServiceImpl<AgvTaskMapper, AgvTask> impl
                 throw new JeecgBootException("取消AGV任务。 更新终点库位状态失败");
             }
         }
-        Container container = containerService.getContainerByCode(containerCode, warehouseCode);
-        if (container == null) {
-            throw new JeecgBootException("取消AGV任务。 根据容器编码没有找到容器");
-        }
         // 2023-04-11 托盘状态与填充状态分离
 //        String containerStatus = QuantityConstant.STATUS_CONTAINER_EMPTY;
 //        List<InventoryDetail> inventoryDetailList = inventoryDetailService.getInventoryDetailListByContainerCode(containerCode, warehouseCode);
 //        if (inventoryDetailList.size() != 0) {
 //            containerStatus = QuantityConstant.STATUS_CONTAINER_SOME;
 //        }
-        success = containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode);
-        if (!success) {
-            throw new JeecgBootException("取消AGV任务。 更新容器状态失败");
-        }
         int status = agvTask.getStatus();
         if (status != QuantityConstant.AGV_TASK_STATUS_BUILD) {
             Result result = acsService.cancelAGVTask(agvTask);
@@ -220,9 +217,19 @@ public class AgvTaskServiceImpl extends ServiceImpl<AgvTaskMapper, AgvTask> impl
     }
 
     @Override
+    public AgvTask getAgvTaskBuContainerCode(String containerCode, String warehouseCode) {
+        LambdaQueryWrapper<AgvTask> agvTaskLambdaQueryWrapper = Wrappers.lambdaQuery();
+        agvTaskLambdaQueryWrapper.eq(AgvTask::getContainerCode, containerCode).eq(AgvTask::getWarehouseCode, warehouseCode).lt(AgvTask::getStatus,
+            QuantityConstant.AGV_TASK_STATUS_COMPLETED);
+        AgvTask agvTask = getOne(agvTaskLambdaQueryWrapper);
+        return agvTask;
+    }
+
+    @Override
     public AgvTask getAgvTaskBuFromPort(String fromPortCode, String warehouseCode) {
         LambdaQueryWrapper<AgvTask> agvTaskLambdaQueryWrapper = Wrappers.lambdaQuery();
-        agvTaskLambdaQueryWrapper.eq(AgvTask::getFromPort, fromPortCode).eq(AgvTask::getWarehouseCode, warehouseCode);
+        agvTaskLambdaQueryWrapper.eq(AgvTask::getFromPort, fromPortCode).eq(AgvTask::getWarehouseCode, warehouseCode).lt(AgvTask::getStatus,
+            QuantityConstant.AGV_TASK_STATUS_COMPLETED);
         AgvTask agvTask = getOne(agvTaskLambdaQueryWrapper);
         return agvTask;
     }
@@ -230,7 +237,8 @@ public class AgvTaskServiceImpl extends ServiceImpl<AgvTaskMapper, AgvTask> impl
     @Override
     public AgvTask getAgvTaskBuToPort(String toPortCode, String warehouseCode) {
         LambdaQueryWrapper<AgvTask> agvTaskLambdaQueryWrapper = Wrappers.lambdaQuery();
-        agvTaskLambdaQueryWrapper.eq(AgvTask::getToPort, toPortCode).eq(AgvTask::getWarehouseCode, warehouseCode);
+        agvTaskLambdaQueryWrapper.eq(AgvTask::getToPort, toPortCode).eq(AgvTask::getWarehouseCode, warehouseCode).lt(AgvTask::getStatus,
+            QuantityConstant.AGV_TASK_STATUS_COMPLETED);
         AgvTask agvTask = getOne(agvTaskLambdaQueryWrapper);
         return agvTask;
     }
diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/entity/TaskHeader.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/entity/TaskHeader.java
index 8cbcf84..7f4d3c6 100644
--- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/entity/TaskHeader.java
+++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/entity/TaskHeader.java
@@ -123,7 +123,7 @@ public class TaskHeader implements Serializable {
     @ApiModelProperty(value = "AGV关联任务ID")
     private Integer agvTaskId;
     @ApiModelProperty(value = "生成agv任务")
-    private Integer sendAgv;
+    private Integer createAgvTask;
     @ApiModelProperty(value = "回传MES信息")
     private Integer backMes;
     @ApiModelProperty(value = "MES提交次数")
diff --git a/huaheng-wms-core/src/main/java/org/jeecg/utils/constant/QuantityConstant.java b/huaheng-wms-core/src/main/java/org/jeecg/utils/constant/QuantityConstant.java
index 1953625..c6e5833 100644
--- a/huaheng-wms-core/src/main/java/org/jeecg/utils/constant/QuantityConstant.java
+++ b/huaheng-wms-core/src/main/java/org/jeecg/utils/constant/QuantityConstant.java
@@ -487,12 +487,12 @@ public class QuantityConstant {
     // 待确认
     public static final String QUALITY_DISUSSED = "discussed";
 
+    // 需要发送AGV任务成功
+    public static final int AGV_CREATE_NEED = 1;
     // 发送AGV任务成功
-    public static final int AGV_NEED_SEND = 0;
-    // 发送AGV任务成功
-    public static final int AGV_SEND_OK = 1;
+    public static final int AGV_CREATE_OK = 2;
     // 发送AGV任务异常
-    public static final int AGV_SEND_ERROR = 2;
+    public static final int AGV_CREATE_ERROR = 3;
     // 回传MES成功
     public static final int MES_SEND_OK = 1;
     // 回传MES异常
--
libgit2 0.22.2