From 481e8eb97f833162ca4368e53b82938024e4245c Mon Sep 17 00:00:00 2001
From: youjie <272855983@qq.com>
Date: Fri, 30 Jun 2023 08:25:04 +0800
Subject: [PATCH] 增加任务各个状态时间

---
 ant-design-vue-jeecg/src/views/system/inventory/InventoryTransactionList.vue                                         |   5 +++++
 ant-design-vue-jeecg/src/views/system/task/CircleTaskHeaderList.vue                                                  |  20 ++++++++++++++++++++
 ant-design-vue-jeecg/src/views/system/task/ReceiptTaskHeaderList.vue                                                 |  20 ++++++++++++++++++++
 ant-design-vue-jeecg/src/views/system/task/ShipmentTaskHeaderList.vue                                                |  20 ++++++++++++++++++++
 ant-design-vue-jeecg/src/views/system/task/TransferTaskHeaderList.vue                                                |  20 ++++++++++++++++++++
 huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryTransaction/entity/InventoryTransaction.java |  18 +++++++++++-------
 huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/impl/TaskHeaderServiceImpl.java         | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------------------------------------
 7 files changed, 160 insertions(+), 48 deletions(-)

diff --git a/ant-design-vue-jeecg/src/views/system/inventory/InventoryTransactionList.vue b/ant-design-vue-jeecg/src/views/system/inventory/InventoryTransactionList.vue
index f927a06..44504e3 100644
--- a/ant-design-vue-jeecg/src/views/system/inventory/InventoryTransactionList.vue
+++ b/ant-design-vue-jeecg/src/views/system/inventory/InventoryTransactionList.vue
@@ -284,6 +284,11 @@ export default {
           dataIndex: 'qty'
         },
         {
+          title: '库存数量',
+          align: "center",
+          dataIndex: 'inventoryQty'
+        },
+        {
           title: '批次',
           align: "center",
           dataIndex: 'batch'
diff --git a/ant-design-vue-jeecg/src/views/system/task/CircleTaskHeaderList.vue b/ant-design-vue-jeecg/src/views/system/task/CircleTaskHeaderList.vue
index b3cc389..65ed38b 100644
--- a/ant-design-vue-jeecg/src/views/system/task/CircleTaskHeaderList.vue
+++ b/ant-design-vue-jeecg/src/views/system/task/CircleTaskHeaderList.vue
@@ -278,6 +278,26 @@ export default {
           dataIndex: 'updateTime'
         },
         {
+          title: '执行时间',
+          align: "center",
+          dataIndex: 'executeTime'
+        },
+        {
+          title: '库位分配时间',
+          align: "center",
+          dataIndex: 'allocationTime'
+        },
+        {
+          title: '到达分拣口时间',
+          align: "center",
+          dataIndex: 'arrivalTime'
+        },
+        {
+          title: '完成时间',
+          align: "center",
+          dataIndex: 'completeTime'
+        },
+        {
           title: '操作',
           dataIndex: 'action',
           align: "center",
diff --git a/ant-design-vue-jeecg/src/views/system/task/ReceiptTaskHeaderList.vue b/ant-design-vue-jeecg/src/views/system/task/ReceiptTaskHeaderList.vue
index 02039b1..8d7857a 100644
--- a/ant-design-vue-jeecg/src/views/system/task/ReceiptTaskHeaderList.vue
+++ b/ant-design-vue-jeecg/src/views/system/task/ReceiptTaskHeaderList.vue
@@ -273,6 +273,26 @@ export default {
           dataIndex: 'updateTime'
         },
         {
+          title: '执行时间',
+          align: "center",
+          dataIndex: 'executeTime'
+        },
+        {
+          title: '库位分配时间',
+          align: "center",
+          dataIndex: 'allocationTime'
+        },
+        {
+          title: '到达分拣口时间',
+          align: "center",
+          dataIndex: 'arrivalTime'
+        },
+        {
+          title: '完成时间',
+          align: "center",
+          dataIndex: 'completeTime'
+        },
+        {
           title: '操作',
           dataIndex: 'action',
           align: "center",
diff --git a/ant-design-vue-jeecg/src/views/system/task/ShipmentTaskHeaderList.vue b/ant-design-vue-jeecg/src/views/system/task/ShipmentTaskHeaderList.vue
index 8268406..2f06af2 100644
--- a/ant-design-vue-jeecg/src/views/system/task/ShipmentTaskHeaderList.vue
+++ b/ant-design-vue-jeecg/src/views/system/task/ShipmentTaskHeaderList.vue
@@ -273,6 +273,26 @@ export default {
           dataIndex: 'updateTime'
         },
         {
+          title: '执行时间',
+          align: "center",
+          dataIndex: 'executeTime'
+        },
+        {
+          title: '库位分配时间',
+          align: "center",
+          dataIndex: 'allocationTime'
+        },
+        {
+          title: '到达分拣口时间',
+          align: "center",
+          dataIndex: 'arrivalTime'
+        },
+        {
+          title: '完成时间',
+          align: "center",
+          dataIndex: 'completeTime'
+        },
+        {
           title: '操作',
           dataIndex: 'action',
           align: "center",
diff --git a/ant-design-vue-jeecg/src/views/system/task/TransferTaskHeaderList.vue b/ant-design-vue-jeecg/src/views/system/task/TransferTaskHeaderList.vue
index 25cf41d..32690fd 100644
--- a/ant-design-vue-jeecg/src/views/system/task/TransferTaskHeaderList.vue
+++ b/ant-design-vue-jeecg/src/views/system/task/TransferTaskHeaderList.vue
@@ -281,6 +281,26 @@ export default {
           dataIndex: 'updateTime'
         },
         {
+          title: '执行时间',
+          align: "center",
+          dataIndex: 'executeTime'
+        },
+        {
+          title: '库位分配时间',
+          align: "center",
+          dataIndex: 'allocationTime'
+        },
+        {
+          title: '到达分拣口时间',
+          align: "center",
+          dataIndex: 'arrivalTime'
+        },
+        {
+          title: '完成时间',
+          align: "center",
+          dataIndex: 'completeTime'
+        },
+        {
           title: '操作',
           dataIndex: 'action',
           align: "center",
diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryTransaction/entity/InventoryTransaction.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryTransaction/entity/InventoryTransaction.java
index 249b786..7ad6bbd 100644
--- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryTransaction/entity/InventoryTransaction.java
+++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryTransaction/entity/InventoryTransaction.java
@@ -1,19 +1,19 @@
 package org.jeecg.modules.wms.inventory.inventoryTransaction.entity;
 
 import java.io.Serializable;
-import java.io.UnsupportedEncodingException;
-import java.util.Date;
 import java.math.BigDecimal;
+import java.util.Date;
+
+import org.jeecg.common.aspect.annotation.Dict;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.Data;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import org.springframework.format.annotation.DateTimeFormat;
-import org.jeecgframework.poi.excel.annotation.Excel;
-import org.jeecg.common.aspect.annotation.Dict;
+
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
 
@@ -109,6 +109,10 @@ public class InventoryTransaction implements Serializable {
     @Excel(name = "数量", width = 15)
     @ApiModelProperty(value = "数量")
     private BigDecimal qty;
+    /** 库存数量 */
+    @Excel(name = "库存数量", width = 15)
+    @ApiModelProperty(value = "库存数量")
+    private BigDecimal inventoryQty;
     /** 批次 */
     @Excel(name = "批次", width = 15)
     @ApiModelProperty(value = "批次")
diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/impl/TaskHeaderServiceImpl.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/impl/TaskHeaderServiceImpl.java
index 1c9704b..1988b68 100644
--- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/impl/TaskHeaderServiceImpl.java
+++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/impl/TaskHeaderServiceImpl.java
@@ -66,7 +66,6 @@ import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
 import com.alibaba.fastjson.JSON;
-import com.aliyun.oss.ServiceException;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -1011,12 +1010,22 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea
         if (taskHeader.getStatus().equals(QuantityConstant.TASK_STATUS_COMPLETED)) {
             return Result.ok("入库任务(" + taskHeader.getId() + ")已经是完成的!");
         }
-//        if (taskDetailList.isEmpty()) {
-//            throw new JeecgBootException("完成入库任务时, 入库任务明细为空");
-//        }
+        if (taskDetailList.isEmpty()) {
+//            return Result.error("完成入库任务时, 入库任务明细为空");
+            Result result = taskHeaderService.completeTaskUnLockContainerAndLocation(taskHeader.getContainerFillStatus(), taskType, containerCode, fromLocationCode,
+                toLocationCode, warehouseCode);
+            if (!result.isSuccess()) {
+                throw new JeecgBootException(result.getMessage());
+            }
+            success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId());
+            if (!success) {
+                throw new JeecgBootException("完成入库任务时,保存任务头失败");
+            }
+            return Result.ok("完成入库任务");
+        }
         Location toLocation = locationService.getLocationByCode(toLocationCode, warehouseCode);
         if (toLocation == null) {
-            throw new JeecgBootException("完成入库任务时,没有找到目的库位");
+            return Result.error("完成入库任务时,没有找到目的库位");
         }
         InventoryHeader inventoryHeader = inventoryHeaderService.getInventoryHeaderByContainerCode(containerCode, warehouseCode);
         if (inventoryHeader != null) {
@@ -1035,7 +1044,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea
                         inventoryDetailList1.add(inventoryDetail1);
                     }
                     if (!inventoryDetailService.updateBatchById(inventoryDetailList1)) {
-                        throw new ServiceException("完成入库任务时,更新库存详情失败");
+                        throw new JeecgBootException("完成入库任务时,更新库存详情失败");
                     }
                 }
             }
@@ -1116,45 +1125,46 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea
             inventoryTransaction.setProject(taskDetail.getProject());
             inventoryTransaction.setInventoryStatus(taskDetail.getInventoryStatus());
             inventoryTransaction.setQty(receiptQty);
+            // 获得库存数量
+            BigDecimal inventoryQty = inventoryDetailService.getSumQty(inventoryDetail);
+            inventoryQty = inventoryQty.add(receiptQty);
+            inventoryTransaction.setInventoryQty(inventoryQty);
             inventoryTransactionList.add(inventoryTransaction);
         }
 
-        if (!taskDetailList.isEmpty()) {
-            success = receiptContainerHeaderService.updateStatusById(QuantityConstant.RECEIPT_CONTAINER_FINISHED, taskHeader.getReceiptContainerHeaderId());
-            if (!success) {
-                throw new JeecgBootException("完成入库任务时,更新入库组盘头表状态失败");
-            }
-            success = inventoryDetailService.saveBatch(inventoryDetailList);
-            if (!success) {
-                throw new JeecgBootException("完成入库任务时,保存库存详情失败");
-            }
-            success = inventoryTransactionService.saveBatch(inventoryTransactionList);
+        success = receiptContainerHeaderService.updateStatusById(QuantityConstant.RECEIPT_CONTAINER_FINISHED, taskHeader.getReceiptContainerHeaderId());
+        if (!success) {
+            throw new JeecgBootException("完成入库任务时,更新入库组盘头表状态失败");
+        }
+        success = inventoryDetailService.saveBatch(inventoryDetailList);
+        if (!success) {
+            throw new JeecgBootException("完成入库任务时,保存库存详情失败");
+        }
+        success = inventoryTransactionService.saveBatch(inventoryTransactionList);
+        if (!success) {
+            throw new JeecgBootException("完成入库任务时,保存库存交易失败");
+        }
+        if (!taskHeaderService.combineInventoryDetail(taskHeader)) {
+            throw new JeecgBootException("完成入库任务时, 合并入库库存失败");
+        }
+        if (!receiptDetailService.updateBatchById(receiptDetaiList)) {
+            throw new JeecgBootException("完成入库任务时,更新入库单详情失败");
+        }
+        List<Integer> receiptIdList = receiptDetaiList.stream().map(ReceiptDetail::getReceiptId).distinct().collect(Collectors.toList());
+        for (Integer receiptId : receiptIdList) {
+            success = receiptHeaderService.updateReceiptHeaderStatus(receiptId);
             if (!success) {
-                throw new JeecgBootException("完成入库任务时,保存库存交易失败");
-            }
-            if (!taskHeaderService.combineInventoryDetail(taskHeader)) {
-                throw new JeecgBootException("合并入库库存失败");
-            }
-            if (!receiptDetailService.updateBatchById(receiptDetaiList)) {
-                throw new JeecgBootException("完成入库任务时,更新入库单详情失败");
-            }
-            List<Integer> receiptIdList = receiptDetaiList.stream().map(ReceiptDetail::getReceiptId).distinct().collect(Collectors.toList());
-            for (Integer receiptId : receiptIdList) {
-                success = receiptHeaderService.updateReceiptHeaderStatus(receiptId);
-                if (!success) {
-                    throw new JeecgBootException("完成入库任务时,更新入库单头失败");
-                }
+                throw new JeecgBootException("完成入库任务时,更新入库单头失败");
             }
         }
-
+        if (!inventoryHeaderService.updateInventoryContainerStatusByContainerCode(containerCode, warehouseCode)) {
+            throw new JeecgBootException("完成入库任务时,更新托盘状态失败");
+        }
         Result result = taskHeaderService.completeTaskUnLockContainerAndLocation(taskHeader.getContainerFillStatus(), taskType, containerCode, fromLocationCode,
             toLocationCode, warehouseCode);
         if (!result.isSuccess()) {
             throw new JeecgBootException(result.getMessage());
         }
-        if (!inventoryHeaderService.updateInventoryContainerStatusByContainerCode(containerCode, warehouseCode)) {
-            throw new JeecgBootException("完成入库任务时,更新托盘状态失败");
-        }
         success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId());
         if (!success) {
             throw new JeecgBootException("完成入库任务时,保存任务头失败");
@@ -1198,9 +1208,20 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea
         if (taskHeader.getStatus().equals(QuantityConstant.TASK_STATUS_COMPLETED)) {
             return Result.ok("完成出库任务,(" + taskHeader.getId() + ")任务已经是完成的!");
         }
-//        if (taskDetailList.isEmpty()) {
+        // 如果任务详情为空,那么就是呼叫料盒,但是又没入库进去。
+        if (taskDetailList.isEmpty()) {
 //            return Result.error("完成出库任务,任务明细为空");
-//        }
+            Result result = taskHeaderService.completeTaskUnLockContainerAndLocation(taskHeader.getContainerFillStatus(), taskType, containerCode, fromLocationCode,
+                toLocationCode, warehouseCode);
+            if (!result.isSuccess()) {
+                throw new JeecgBootException(result.getMessage());
+            }
+            success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId());
+            if (!success) {
+                throw new JeecgBootException("完成出库任务,保存任务头失败");
+            }
+            return Result.ok("完成出库任务");
+        }
         if (StringUtils.isEmpty(fromLocationCode)) {
             return Result.error("完成出库任务" + taskHeader.getId() + "没有起始库位,执行中止");
         }
@@ -1285,6 +1306,8 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea
             inventoryTransaction.setLot(inventoryDetail.getLot());
             inventoryTransaction.setProject(inventoryDetail.getProject());
             inventoryTransaction.setQty(taskDetail.getQty());
+            BigDecimal inventoryQty = inventoryDetailService.getSumQty(inventoryDetail);
+            inventoryTransaction.setInventoryQty(inventoryQty);
             inventoryTransactionList.add(inventoryTransaction);
             shipmentIdList.add(taskDetail.getShipmentId());
         }
@@ -1309,11 +1332,6 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea
         if (!success) {
             throw new JeecgBootException("完成出库任务,保存库存详情失败");
         }
-        Result result = taskHeaderService.completeTaskUnLockContainerAndLocation(taskHeader.getContainerFillStatus(), taskType, containerCode, fromLocationCode,
-            toLocationCode, warehouseCode);
-        if (!result.isSuccess()) {
-            throw new JeecgBootException(result.getMessage());
-        }
         ShipmentContainerHeader shipmentContainerHeader = shipmentContainerHeaderService.getById(taskHeader.getShipmentContainerHeaderId());
         if (shipmentContainerHeader == null) {
             throw new JeecgBootException("完成出库任务,获取出库组盘头失败");
@@ -1344,6 +1362,11 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea
                 throw new JeecgBootException("完成出库任务,更新库存状态失败");
             }
         }
+        Result result = taskHeaderService.completeTaskUnLockContainerAndLocation(taskHeader.getContainerFillStatus(), taskType, containerCode, fromLocationCode,
+            toLocationCode, warehouseCode);
+        if (!result.isSuccess()) {
+            throw new JeecgBootException(result.getMessage());
+        }
         success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId());
         if (!success) {
             throw new JeecgBootException("完成出库任务,保存任务头失败");
--
libgit2 0.22.2