Преглед изворни кода

任务列表-增加取卸货完成按钮

k пре 1 година
родитељ
комит
750c6cb463

+ 13 - 5
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warewms/ams/WcsTaskController.java

@@ -12,6 +12,7 @@ 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;
@@ -110,24 +111,31 @@ public class WcsTaskController extends BaseController {
     @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("任务回调失败");
         }
-        wcsTaskService.callBack(wcsTask.getTaskNo(), 4, Integer.parseInt(wcsTask.getAgvNo()));
-        return AjaxResult.success("执行成功");
-
+        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) {
            return AjaxResult.error("任务回调失败");
         }
-        wcsTaskService.callBack(wcsTask.getTaskNo(),2,Integer.parseInt(wcsTask.getAgvNo()));
-        return AjaxResult.success("执行成功");
+        if (StringUtils.isNotEmpty(wcsTask.getAgvNo())) {
+            agvNo = Integer.parseInt(wcsTask.getAgvNo());
+        }
+        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);
     }
 
 

+ 5 - 0
ruoyi-ui/src/views/ams/task/index.vue

@@ -458,6 +458,7 @@ import {
   updateWcsTask,
   addTestTask,
   completeWcsTask,
+  pickupCompleteWcsTask,
   taskCancel,
   invDisposition,
   addChargeTask
@@ -729,8 +730,10 @@ export default {
       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);
           }
         });
@@ -741,8 +744,10 @@ export default {
       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);
           }
         });

+ 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);
 
     /**
      * 将起点库存放到中间缓存位置

+ 25 - 16
warewms-ams/src/main/java/com/ruoyi/ams/task/service/impl/WcsTaskServiceImpl.java

@@ -269,7 +269,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();
@@ -347,13 +347,13 @@ 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) {
@@ -362,7 +362,7 @@ public class WcsTaskServiceImpl implements IWcsTaskService {
 
         if (wcsTask.getState() == 2) {
             log.info("已完成的任务无需反馈");
-            return;
+            return AjaxResult.error("已完成的任务无需反馈");
         }
         //转发类型任务才回调
         if (wcsTask.getTaskType().equals(Constant.TASK_TYPE.FORWARD.getValue())) {
@@ -372,16 +372,17 @@ public class WcsTaskServiceImpl implements IWcsTaskService {
                         wcsTask.setStartTime(new Date());
                         break;
                     case 2://完成
-                        if (wcsTask.getState() != 4 && wcsTask.getState() != 7) {
+                        if (wcsTask.getState() != 4
+                                && (StringUtils.isEmpty(wcsTask.getBeforeTask()) || !wcsTask.getBeforeTask().equals("1"))) {
                             log.info("任务未取货,不能直接完成!" + taskNo);
-                            return;
+                            return AjaxResult.error("任务未取货,不能直接完成!" + taskNo);
                         }
                         if (wcsTask.getState() == 2) {
                             log.info("不能重复放货," + taskNo);
-                            return;
+                            return AjaxResult.error("不能重复放货," + taskNo);
                         }
                         if (wcsTask.getState() == 6) {
-                            return;
+                            return AjaxResult.error("不能重复放货," + taskNo);
                         }
                         wcsTask.setEndTime(new Date());
                         // 解锁终点库位
@@ -399,8 +400,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);
@@ -415,16 +422,17 @@ public class WcsTaskServiceImpl implements IWcsTaskService {
                     case 5:
                         break;
                     case 6://卸货
-                        if (wcsTask.getState() != 4 && wcsTask.getState() != 7) {
-                            log.info("任务未取货,不能直接完成!");
-                            return;
+                        if (wcsTask.getState() != 4
+                                && (StringUtils.isEmpty(wcsTask.getBeforeTask())|| !wcsTask.getBeforeTask().equals("1"))) {
+                            log.info("任务未取货,不能直接完成!" + taskNo);
+                            return AjaxResult.error("任务未取货,不能直接完成!" + taskNo);
                         }
-                        if (wcsTask.getState() == 6) {
+                        if (wcsTask.getState() == 2) {
                             log.info("不能重复放货," + taskNo);
-                            return;
+                            return AjaxResult.error("不能重复放货," + taskNo);
                         }
-                        if (wcsTask.getState() == 2) {
-                            return;
+                        if (wcsTask.getState() == 6) {
+                            return AjaxResult.error("不能重复放货," + taskNo);
                         }
                         wcsTask.setEndTime(new Date());
                         // 解锁终点库位
@@ -477,6 +485,7 @@ public class WcsTaskServiceImpl implements IWcsTaskService {
         wcsTask.setState(state.longValue());
         wcsTask.setUpdateDate(new Date());
         wcsTaskService.updateWcsTask(wcsTask);
+        return AjaxResult.error("操作成功!");
     }
 
     /**