From 60edff747d52eb42aadb036e3fbd580252de4c05 Mon Sep 17 00:00:00 2001
From: zhang <zc857179121@qq.com>
Date: 星期四, 28 八月 2025 08:15:54 +0800
Subject: [PATCH] 1

---
 zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/OpenController.java |  170 +++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 129 insertions(+), 41 deletions(-)

diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/OpenController.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/OpenController.java
index 6c11241..e744f97 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/OpenController.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/OpenController.java
@@ -6,13 +6,19 @@
 import com.zy.acs.manager.common.annotation.OperationLog;
 import com.zy.acs.manager.common.domain.BaseParam;
 import com.zy.acs.manager.common.domain.PageParam;
+import com.zy.acs.manager.common.domain.TaskDto;
 import com.zy.acs.manager.core.constant.LocGroupConstant;
 import com.zy.acs.manager.core.service.MainService;
 import com.zy.acs.manager.manager.controller.param.OpenBusSubmitParam;
 import com.zy.acs.manager.manager.entity.Loc;
-import com.zy.acs.manager.manager.enums.LocStsType;
+import com.zy.acs.manager.manager.entity.Sta;
+import com.zy.acs.manager.manager.entity.Task;
+import com.zy.acs.manager.manager.enums.StaStsType;
 import com.zy.acs.manager.manager.service.LocService;
+import com.zy.acs.manager.manager.service.StaService;
+import com.zy.acs.manager.manager.service.TaskService;
 import com.zy.acs.manager.system.controller.BaseController;
+import com.zy.acs.manager.system.service.ConfigService;
 import io.swagger.annotations.Api;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -20,9 +26,7 @@
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * Created by vincent on 2023/6/12
@@ -38,60 +42,144 @@
     @Autowired
     private LocService locService;
 
+    @Autowired
+    private StaService staService;
+
+    @Autowired
+    private ConfigService configService;
+
+
+    @Autowired
+    private TaskService taskService;
+
+
     //@PreAuthorize("hasAuthority('open:bus:submit')")
     @PostMapping("/bus/submit")
     @OperationLog("generate task from open api")
     public R save(@RequestBody OpenBusSubmitParam param) {
-        mainService.generateBusAndTask(param, null);
-        return R.ok("generate tasks success");
+        if (!configService.getVal("TaskAssignMode", Boolean.class)) {
+            if (configService.getVal("InAndOutMode", Boolean.class, false)) {
+                mainService.generateBusAndTask(param, null);
+                return R.ok("generate tasks success");
+            }
+        }
+        return R.error("generate tasks error");
     }
 
-    //@PreAuthorize("hasAuthority('open:bus:submit')")
+
+    @OperationLog("Cancel Task")
+    @PostMapping("/task/cancel")
+    public R cancel(@RequestBody List<String> taskIds) {
+        if (Cools.isEmpty(taskIds)) {
+            return R.error("task cancel error");
+        }
+        List<Boolean> data = new ArrayList<>();
+        for (String id : taskIds) {
+            data.add(taskService.cancelCheckTaskSts(taskService.selectBySeqNum(id).getId(), 9527L));
+        }
+        return R.ok().add(data);
+    }
+
+
+    @OperationLog("updateTaskPriority")
+    @PostMapping("/task/updateTaskPriority")
+    public R update(@RequestBody List<TaskDto> taskDtos) {
+        if (Cools.isEmpty(taskDtos)) {
+            return R.error("task update error");
+        }
+        List<Boolean> data = new ArrayList<>();
+        for (TaskDto taskDto : taskDtos) {
+            Task task = taskService.selectBySeqNum(taskDto.getSeqNum());
+            task.setPriority(taskDto.getPriority());
+            task.setUpdateBy(9527L);
+            task.setUpdateTime(new Date());
+            data.add(taskService.updateById(task));
+        }
+        return R.ok("Update Success").add(data);
+    }
+
+
     @PostMapping("/loc/sync")
     @OperationLog("sync loc")
-    public R loc(@RequestBody Map<String, Object> map) {
+    public R loc(@RequestBody(required = false) Map<String, Object> map) {
+        if (map.get("current") == null) {
+            map.put("current", 1);
+        }
+        if (map.get("pageSize") == null) {
+            map.put("pageSize", 100);
+        }
         BaseParam baseParam = buildParam(map, BaseParam.class);
         PageParam<Loc, BaseParam> pageParam = new PageParam<>(baseParam, Loc.class);
         return R.ok().add(locService.page(pageParam, pageParam.buildWrapper(true)));
     }
 
+
+    @PostMapping("/sta/update")
+    @OperationLog("sync sta")
+    public R updateLoc(@RequestBody Map<String, Object> map) {
+        if (!configService.getVal("TaskAssignMode", Boolean.class)) {
+            if (configService.getVal("InAndOutMode", Boolean.class, false)) {
+                String staNo = map.get("staNo").toString();
+                Sta loc = staService.selectByStaNo(staNo);
+                if (staNo.equals("1001")) {
+                    if (loc.getStaSts() == StaStsType.STOCK.val()) {
+                        loc.setStaSts(Long.parseLong(map.get("sts").toString()));
+                        return staService.updateById(loc) ? R.ok() : R.error("update loc fail");
+                    }
+                } else if (staNo.equals("1007")) {
+                    if (loc.getStaSts() == StaStsType.IDLE.val()) {
+                        loc.setStaSts(Long.parseLong(map.get("sts").toString()));
+                        return staService.updateById(loc) ? R.ok() : R.error("update loc fail");
+                    }
+                }
+            }
+        }
+        return R.error("update loc fail");
+    }
+
+
     @PostMapping("/loc/one")
     @OperationLog("one loc")
     public R emptyLoc(@RequestBody Map<String, Object> map) {
-        String staNo = map.get("staNo").toString();
-        Integer startRow = null;
-        Integer endRow = null;
-        if (staNo.equals("101-2")||staNo.equals("101-3")||staNo.equals("102-2")||staNo.equals("102-3")){
-             startRow = Collections.min(LocGroupConstant.FAR_RIGHT_LOC_ROW_LIST);
-             endRow = Collections.max(LocGroupConstant.FAR_RIGHT_LOC_ROW_LIST);
-        } else if (staNo.equals("103-2")||staNo.equals("103-3")||staNo.equals("104-2")||staNo.equals("104-3")) {
-             startRow = Collections.min(LocGroupConstant.RIGHT_LOC_ROW_LIST);
-             endRow = Collections.max(LocGroupConstant.RIGHT_LOC_ROW_LIST);
-        }else if (staNo.equals("105-2")||staNo.equals("105-3")||staNo.equals("106-2")||staNo.equals("106-3")) {
-             startRow = Collections.min(LocGroupConstant.MIDDLE_LOC_ROW_LIST);
-             endRow = Collections.max(LocGroupConstant.MIDDLE_LOC_ROW_LIST);
-        }else if (staNo.equals("107-2")||staNo.equals("107-3")||staNo.equals("108-2")||staNo.equals("108-3")) {
-             startRow = Collections.min(LocGroupConstant.LEFT_LOC_ROW_LIST);
-             endRow = Collections.max(LocGroupConstant.LEFT_LOC_ROW_LIST);
-        }else if (staNo.equals("1007")){
-             startRow = Collections.min(LocGroupConstant.FAR_LEFT_LOC_ROW_LIST);
-             endRow = Collections.max(LocGroupConstant.FAR_LEFT_LOC_ROW_LIST);
-        }else {
-            return R.error("staNo is not support");
+        if (!configService.getVal("TaskAssignMode", Boolean.class)) {
+            if (configService.getVal("InAndOutMode", Boolean.class, false)) {
+                String staNo = map.get("staNo").toString();
+                Integer startRow = null;
+                Integer endRow = null;
+                if (staNo.equals("101-2") || staNo.equals("101-3") || staNo.equals("102-2") || staNo.equals("102-3")) {
+                    startRow = Collections.min(LocGroupConstant.FAR_RIGHT_LOC_ROW_LIST);
+                    endRow = Collections.max(LocGroupConstant.FAR_RIGHT_LOC_ROW_LIST);
+                } else if (staNo.equals("103-2") || staNo.equals("103-3") || staNo.equals("104-2") || staNo.equals("104-3")) {
+                    startRow = Collections.min(LocGroupConstant.RIGHT_LOC_ROW_LIST);
+                    endRow = Collections.max(LocGroupConstant.RIGHT_LOC_ROW_LIST);
+                } else if (staNo.equals("105-2") || staNo.equals("105-3") || staNo.equals("106-2") || staNo.equals("106-3")) {
+                    startRow = Collections.min(LocGroupConstant.MIDDLE_LOC_ROW_LIST);
+                    endRow = Collections.max(LocGroupConstant.MIDDLE_LOC_ROW_LIST);
+                } else if (staNo.equals("107-2") || staNo.equals("107-3") || staNo.equals("108-2") || staNo.equals("108-3")) {
+                    startRow = Collections.min(LocGroupConstant.LEFT_LOC_ROW_LIST);
+                    endRow = Collections.max(LocGroupConstant.LEFT_LOC_ROW_LIST);
+                } else if (staNo.equals("1007") || staNo.equals("1001")) {
+                    startRow = Collections.min(LocGroupConstant.FAR_LEFT_LOC_ROW_LIST);
+                    endRow = Collections.max(LocGroupConstant.FAR_LEFT_LOC_ROW_LIST);
+                } else {
+                    return R.error("staNo is not support");
+                }
+                LambdaQueryWrapper<Loc> idleWrapper = new LambdaQueryWrapper<Loc>().eq(Loc::getLocSts, Long.parseLong(map.get("sts").toString()));
+                if (null != startRow) {
+                    idleWrapper.ge(Loc::getRow, startRow);
+                }
+                if (null != endRow) {
+                    idleWrapper.le(Loc::getRow, endRow);
+                }
+                List<Loc> idleList = locService.list(idleWrapper);
+                if (Cools.isEmpty(idleList)) {
+                    return R.error("娌$┖搴撲綅");
+                }
+                Collections.shuffle(idleList);
+                return R.ok().add(idleList.get(0));
+            }
         }
-        LambdaQueryWrapper<Loc> idleWrapper = new LambdaQueryWrapper<Loc>().eq(Loc::getLocSts, LocStsType.IDLE.val());
-        if (null != startRow) {
-            idleWrapper.ge(Loc::getRow, startRow);
-        }
-        if (null != endRow) {
-            idleWrapper.le(Loc::getRow, endRow);
-        }
-        List<Loc> idleList = locService.list(idleWrapper);
-        if (Cools.isEmpty(idleList)) {
-            return R.error("娌$┖搴撲綅");
-        }
-        Collections.shuffle(idleList);
-        return R.ok().add(idleList.get(0));
+        return R.error("鏈紑鍚妯″紡");
     }
 
 }

--
Gitblit v1.9.1