Selaa lähdekoodia

任务管理-增加取卸货完成按钮

k 1 vuosi sitten
vanhempi
commit
87c6022de9

+ 26 - 4
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warewms/ams/WcsTaskController.java

@@ -9,6 +9,9 @@ import com.ruoyi.ams.task.form.AddTaskForm;
 import com.ruoyi.base.constant.Constant;
 import com.ruoyi.base.utils.IdSequenceUtils;
 import com.ruoyi.common.core.domain.model.LoginUser;
+import com.ruoyi.common.utils.StringUtils;
+import io.swagger.annotations.ApiModelProperty;
+import io.swagger.annotations.ApiOperation;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
@@ -102,15 +105,34 @@ public class WcsTaskController extends BaseController {
         return toAjax(wcsTaskService.deleteWcsTaskByTaskNos(taskNos));
     }
 
-    @Log(title = "任务完成", businessType = BusinessType.INSERT)
+    @Log(title = "取货任务完成", businessType = BusinessType.INSERT)
+    @PutMapping(value = "/taskPickupComplete/{taskNo}")
+    public AjaxResult taskPickupComplete(@PathVariable("taskNo") String taskNo) {
+        int agvNo = 9999;
+        WcsTask wcsTask = wcsTaskService.selectWcsTaskByTaskNo(taskNo);
+        if (wcsTask == null) {
+            return AjaxResult.error("任务回调失败");
+        }
+        if (StringUtils.isNotEmpty(wcsTask.getAgvNo())) {
+            agvNo = Integer.parseInt(wcsTask.getAgvNo());
+        }
+        AjaxResult ajaxResult = wcsTaskService.callBack(wcsTask.getTaskNo(), 4, agvNo);
+        return AjaxResult.error(ajaxResult.getMsg());
+    }
+
+    @Log(title = "卸货任务完成", businessType = BusinessType.INSERT)
     @PutMapping(value = "/taskComplete/{taskNo}")
     public AjaxResult taskComplete(@PathVariable("taskNo") String taskNo) {
+        int agvNo = 9999;
         WcsTask wcsTask = wcsTaskService.selectWcsTaskByTaskNo(taskNo);
         if (wcsTask == null) {
-            AjaxResult.error("任务回调失败");
+           return AjaxResult.error("任务回调失败");
+        }
+        if (StringUtils.isNotEmpty(wcsTask.getAgvNo())) {
+            agvNo = Integer.parseInt(wcsTask.getAgvNo());
         }
-        wcsTaskService.callBackTaskComplete(wcsTask);
-        return AjaxResult.success("任务回调完成");
+        AjaxResult ajaxResult = wcsTaskService.callBack(wcsTask.getTaskNo(),2,agvNo);
+        return AjaxResult.error(ajaxResult.getMsg());
     }
 
     @Log(title = "任务取消", businessType = BusinessType.INSERT)

+ 1 - 2
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warewms/test/WcsTaskResponseController.java

@@ -31,8 +31,7 @@ public class WcsTaskResponseController {
     @ApiOperation("WcsTask任务反馈")
     @PostMapping("/responseState")
     public AjaxResult responseState(String taskNo, Integer state, Integer carNo) {
-        iWcsTaskService.callBack(taskNo, state, carNo);
-        return AjaxResult.success();
+        return iWcsTaskService.callBack(taskNo, state, carNo);
     }
 
 

+ 9 - 1
ruoyi-ui/src/api/ams/wcsTask.js

@@ -43,7 +43,15 @@ export function delWcsTask(taskNo) {
   })
 }
 
-//完成任务
+//取货完成任务
+export function pickupCompleteWcsTask(taskNo) {
+  return request({
+    url: '/ams/wcsTask/taskPickupComplete/' + taskNo,
+    method: 'put'
+  })
+}
+
+//卸货完成任务
 export function completeWcsTask(taskNo) {
   return request({
     url: '/ams/wcsTask/taskComplete/' + taskNo,

+ 35 - 9
ruoyi-ui/src/views/ams/task/index.vue

@@ -233,11 +233,17 @@
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
         <template slot-scope="scope">
           <el-button
-            v-if="scope.row.state !== 7 && scope.row.state !== 2 && scope.row.state !== 11 && scope.row.state !== 12"
+            v-if="scope.row.state !== 4 && scope.row.state !== 2 && scope.row.state !== 11 && scope.row.state !== 12"
             size="mini"
             type="text"
             icon="el-icon-edit"
-            @click="handleComplete(scope.row)">完成</el-button>
+            @click="handlePickupCompleted(scope.row)">取货完成</el-button>
+          <el-button
+            v-if="(scope.row.state == 4) || (scope.row.state !== 2 && scope.row.state !== 11 && scope.row.state !== 12)"
+            size="mini"
+            type="text"
+            icon="el-icon-edit"
+            @click="handleComplete(scope.row)">卸货完成</el-button>
           <el-button
             v-if="scope.row.state !== 7 && scope.row.state !== 2 && scope.row.state !== 11 && scope.row.state !== 12"
             size="mini"
@@ -424,7 +430,7 @@
     <!--充电-->
     <el-dialog :title="title" :visible.sync="chaegeOpen" width="500px" append-to-body>
       <el-form ref="form" :model="form" :rules="rules" label-width="80px">
-        <el-form-item label="车号" prop="businessType">
+        <el-form-item label="车号" prop="agvNo">
           <el-select v-model="form.agvNo" placeholder="请选择车辆" clearable size="small" style="width: 100%">
             <el-option
               v-for="dict in chargeCombo"
@@ -452,6 +458,7 @@ import {
   updateWcsTask,
   addTestTask,
   completeWcsTask,
+  pickupCompleteWcsTask,
   taskCancel,
   invDisposition,
   addChargeTask
@@ -718,14 +725,33 @@ export default {
         ...this.queryParams
       }, `wcsTask_${new Date().getTime()}.xlsx`)
     },
+    handlePickupCompleted (row) {
+      const taskNos = row.taskNo
+      this.$modal.confirm('是否确认取货完成"' + taskNos + '"的任务?').then(function() {
+        pickupCompleteWcsTask(taskNos).then(response => {
+          if (response.code === 200) {
+            this.getList();
+            this.$modal.msgSuccess(response.msg);
+          } else {
+            this.getList();
+            this.$modal.msgError(response.msg);
+          }
+        });
+      });
+    },
     handleComplete (row) {
       const taskNos = row.taskNo
-      this.$modal.confirm('是否确认要完成"' + taskNos + '"的任务?').then(function() {
-        return completeWcsTask(taskNos);
-      }).then(() => {
-        this.getList();
-        this.$modal.msgSuccess("执行成功");
-      }).catch(() => {});
+      this.$modal.confirm('是否确认卸货完成"' + taskNos + '"的任务?').then(function() {
+        completeWcsTask(taskNos).then(response => {
+          if (response.code === 200) {
+            this.getList();
+            this.$modal.msgSuccess(response.msg);
+          } else {
+            this.getList();
+            this.$modal.msgError(response.msg);
+          }
+        });
+      });
     },
     handleCancel (row) {
       const taskNos = row.taskNo

+ 1 - 1
warewms-ams/src/main/java/com/ruoyi/ams/task/service/IWcsTaskService.java

@@ -150,7 +150,7 @@ public interface IWcsTaskService {
      * @param state
      * @param carNo
      */
-    void callBack(String taskNo, Integer state, Integer carNo);
+    AjaxResult callBack(String taskNo, Integer state, Integer carNo);
 
     /**
      * 将起点库存放到中间缓存位置

+ 56 - 41
warewms-ams/src/main/java/com/ruoyi/ams/task/service/impl/WcsTaskServiceImpl.java

@@ -266,7 +266,7 @@ public class WcsTaskServiceImpl implements IWcsTaskService {
         // 任务状态: 队列等待 直接删除即可 其他状态 需要请求AMS删除
         if (wcsTask.getState() == Constant.TASK_STS.TASK9.getValue().longValue()
                 || wcsTask.getState() == Constant.TASK_STS.TASK10.getValue().longValue()) {
-            callBack(wcsTask.getTaskNo(), 7, null);
+            return callBack(wcsTask.getTaskNo(), 7, null);
         } else {
             //请求ams 取消任务
             AmsTask amsTaskQuery = new AmsTask();
@@ -344,24 +344,24 @@ public class WcsTaskServiceImpl implements IWcsTaskService {
 
     @Transactional
     @Override
-    public void callBack(String taskNo, Integer state, Integer carNo) {
+    public synchronized AjaxResult callBack(String taskNo, Integer state, Integer carNo) {
         String updateBy = "NDC";
         log.info("agv回传------------->" + taskNo + "," + state);
         WcsTask wcsTask = wcsTaskService.selectWcsTaskByTaskNo(taskNo);
         if (wcsTask == null) {
             log.info("agv回传没有任务记录------------->");
-            return;
+            return AjaxResult.error("agv回传没有任务记录------------->");
         }
 
         if (state > 1 && state != 7) {
             wcsTask.setAgvNo(carNo + "");
         }
 
-        if (wcsTask.getState() == 2 || wcsTask.getState() == 7) {
+        if (wcsTask.getState() == 2) {
             log.info("已完成的任务无需反馈");
-            return;
+            return AjaxResult.error("已完成的任务无需反馈");
         }
-        //todo 转发类型任务才回调
+        //转发类型任务才回调
         if (wcsTask.getTaskType().equals(Constant.TASK_TYPE.FORWARD.getValue())) {
             try {
                 switch (state) {
@@ -369,23 +369,27 @@ public class WcsTaskServiceImpl implements IWcsTaskService {
                         wcsTask.setStartTime(new Date());
                         break;
                     case 2://完成
-                        if (wcsTask.getState() != 6) {
-                            if (wcsTask.getState() == 2) {
-                                log.info("不能重复放货," + taskNo);
-                                return;
-                            }
-                            wcsTask.setEndTime(new Date());
-                            // 解锁终点库位
-                            baseLocationInfoService.unLockLocationStockStatus(Long.parseLong(wcsTask.getLocationTo())
-                                    , Constant.WAREHOUSE_ID, updateBy);
-                            // 将中间缓存位库存移动到终点
-                            moveMiddleCacheToDestination(wcsTask);
-                            // 修改库存标识标识 因为接驳位可以出库也可以入库 所以需要标识当前接驳位的库存是入库还是出库
-//                            updateInvAsnSoMarking(wcsTask);
-                            //释放redis锁
-                            if (!StringUtils.isEmpty(wcsTask.getExt8())) {
-                                redisCache.unlockCacheObject(Long.parseLong(wcsTask.getExt8()));
-                            }
+                        if (wcsTask.getState() != 4
+                                && (StringUtils.isEmpty(wcsTask.getBeforeTask()) || !wcsTask.getBeforeTask().equals("1"))) {
+                            log.info("任务未取货,不能直接完成!" + taskNo);
+                            return AjaxResult.error("任务未取货,不能直接完成!" + taskNo);
+                        }
+                        if (wcsTask.getState() == 2) {
+                            log.info("不能重复放货," + taskNo);
+                            return AjaxResult.error("不能重复放货," + taskNo);
+                        }
+                        if (wcsTask.getState() == 6) {
+                            return AjaxResult.error("不能重复放货," + taskNo);
+                        }
+                        wcsTask.setEndTime(new Date());
+                        // 解锁终点库位
+                        baseLocationInfoService.unLockLocationStockStatus(Long.parseLong(wcsTask.getLocationTo())
+                                , Constant.WAREHOUSE_ID, updateBy);
+                        // 将中间缓存位库存移动到终点
+                        moveMiddleCacheToDestination(wcsTask);
+                        //释放redis锁
+                        if (!StringUtils.isEmpty(wcsTask.getExt8())) {
+                            redisCache.unlockCacheObject(Long.parseLong(wcsTask.getExt8()));
                         }
                         break;
                     case 3:
@@ -393,8 +397,14 @@ public class WcsTaskServiceImpl implements IWcsTaskService {
                     case 4:
                         if (wcsTask.getState() == 4) {
                             log.info("不能重复取货," + taskNo);
-                            return;
+                            return AjaxResult.error("不能重复取货," + taskNo);
                         }
+                        if (wcsTask.getBeforeTask() != null && wcsTask.getBeforeTask().equals("1")) {
+                            log.info("不能重复取货," + taskNo);
+                            return AjaxResult.error("不能重复取货," + taskNo);
+                        }
+                        // 标记已经取货完成
+                        wcsTask.setBeforeTask("1");
                         // 解锁起始库位
                         baseLocationInfoService.unLockLocationStockStatus(Long.parseLong(wcsTask.getLocationFrom())
                                 , Constant.WAREHOUSE_ID, updateBy);
@@ -409,23 +419,27 @@ public class WcsTaskServiceImpl implements IWcsTaskService {
                     case 5:
                         break;
                     case 6://卸货
-                        if (wcsTask.getState() != 2) {
-                            if (wcsTask.getState() == 6) {
-                                log.info("不能重复放货," + taskNo);
-                                return;
-                            }
-                            wcsTask.setEndTime(new Date());
-                            // 解锁终点库位
-                            baseLocationInfoService.unLockLocationStockStatus(Long.parseLong(wcsTask.getLocationTo())
-                                    , Constant.WAREHOUSE_ID, updateBy);
-                            // 将中间缓存位库存移动到终点
-                            moveMiddleCacheToDestination(wcsTask);
-                            // 修改库存标识标识 因为接驳位可以出库也可以入库 所以需要标识当前接驳位的库存是入库还是出库
-//                            updateInvAsnSoMarking(wcsTask);
-                            //释放redis锁
-                            if (!StringUtils.isEmpty(wcsTask.getExt8())) {
-                                redisCache.unlockCacheObject(Long.parseLong(wcsTask.getExt8()));
-                            }
+                        if (wcsTask.getState() != 4
+                                && (StringUtils.isEmpty(wcsTask.getBeforeTask())|| !wcsTask.getBeforeTask().equals("1"))) {
+                            log.info("任务未取货,不能直接完成!" + taskNo);
+                            return AjaxResult.error("任务未取货,不能直接完成!" + taskNo);
+                        }
+                        if (wcsTask.getState() == 2) {
+                            log.info("不能重复放货," + taskNo);
+                            return AjaxResult.error("不能重复放货," + taskNo);
+                        }
+                        if (wcsTask.getState() == 6) {
+                            return AjaxResult.error("不能重复放货," + taskNo);
+                        }
+                        wcsTask.setEndTime(new Date());
+                        // 解锁终点库位
+                        baseLocationInfoService.unLockLocationStockStatus(Long.parseLong(wcsTask.getLocationTo())
+                                , Constant.WAREHOUSE_ID, updateBy);
+                        // 将中间缓存位库存移动到终点
+                        moveMiddleCacheToDestination(wcsTask);
+                        //释放redis锁
+                        if (!StringUtils.isEmpty(wcsTask.getExt8())) {
+                            redisCache.unlockCacheObject(Long.parseLong(wcsTask.getExt8()));
                         }
                         break;
                     case 7://取消
@@ -468,6 +482,7 @@ public class WcsTaskServiceImpl implements IWcsTaskService {
         wcsTask.setState(state.longValue());
         wcsTask.setUpdateDate(new Date());
         wcsTaskService.updateWcsTask(wcsTask);
+        return AjaxResult.error("操作成功!");
     }
 
     /**