From 906a10ce0722894f85281c8ed1d5cb2d8d05dcc9 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期二, 12 十一月 2024 10:56:20 +0800
Subject: [PATCH] #

---
 zy-acs-manager/src/main/java/com/zy/acs/manager/core/TestController.java |  744 ++++++++++++++++++++++++++++----------------------------
 1 files changed, 372 insertions(+), 372 deletions(-)

diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/TestController.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/TestController.java
index 07b3c4e..0888b3c 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/TestController.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/TestController.java
@@ -1,372 +1,372 @@
-package com.zy.acs.manager.core;
-
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.zy.acs.manager.common.domain.TaskDto;
-import com.zy.acs.manager.core.service.MainService;
-import com.zy.acs.manager.core.service.MapService;
-import com.zy.acs.manager.manager.controller.param.OpenBusSubmitParam;
-import com.zy.acs.manager.manager.entity.*;
-import com.zy.acs.manager.manager.enums.BusStsType;
-import com.zy.acs.manager.manager.enums.LocStsType;
-import com.zy.acs.manager.manager.enums.TaskStsType;
-import com.zy.acs.manager.manager.enums.TaskTypeType;
-import com.zy.acs.manager.manager.service.*;
-import com.zy.acs.manager.system.controller.BaseController;
-import com.zy.acs.manager.system.service.ConfigService;
-import com.zy.acs.framework.common.Cools;
-import com.zy.acs.framework.common.R;
-import com.zy.acs.framework.common.SnowflakeIdWorker;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * Created by vincent on 2023/6/20
- */
-@RestController
-@RequestMapping("/test")
-public class TestController extends BaseController {
-
-    @Autowired
-    private BusService busService;
-    @Autowired
-    private MainService mainService;
-    @Autowired
-    private SnowflakeIdWorker snowflakeIdWorker;
-    @Autowired
-    private AgvModelService agvModelService;
-    @Autowired
-    private AgvService agvService;
-    @Autowired
-    private AgvDetailService agvDetailService;
-    @Autowired
-    private TaskService taskService;
-    @Autowired
-    private CodeService codeService;
-    @Autowired
-    private MapService mapService;
-
-
-/*
-TRUNCATE man_bus;
-TRUNCATE man_task;
-TRUNCATE man_action;
-UPDATE man_loc SET loc_sts = 16 WHERE loc_sts = 18;
-UPDATE man_loc SET loc_sts = 15 WHERE loc_sts = 17;
-*/
-
-    @Value("${auto.move}")
-    private Boolean autoMove;
-    @Value("${auto.demo}")
-    private Boolean autoDemo;
-    @Value("${auto.demo1}")
-    private Boolean autoDemo1;
-    @Value("${auto.demo2}")
-    private Boolean autoDemo2;
-    @Value("${auto.size}")
-    private Integer autoSize;
-    @Autowired
-    private LocService locService;
-    @Autowired
-    private ConfigService configService;
-
-    // http://localhost:9090/test/auto/move
-    @GetMapping("/auto/move")
-    public R autoMove() {
-        this.autoMove = !this.autoMove;
-        return R.ok().add(Cools.add("autoMove", this.autoMove));
-    }
-
-    @Scheduled(cron = "0/1 * * * * ? ")
-    private void move1() throws InterruptedException {
-        if (!this.autoMove) { return; }
-        Agv agv = agvService.selectByUuid("1");
-        AgvDetail agvDetail = agvDetailService.selectByAgvId(agv.getId());
-        if (taskService.count(new LambdaQueryWrapper<Task>()
-                .eq(Task::getAgvId, agv.getId())
-                .and(i -> {
-                    i.eq(Task::getTaskSts, TaskStsType.WAITING.val())
-                            .or().eq(Task::getTaskSts, TaskStsType.ASSIGN.val())
-                            .or().eq(Task::getTaskSts, TaskStsType.PROGRESS.val());
-                })) > 0) {
-            return;
-        }
-        if (!agvService.judgeEnable(agv.getId())) {
-            return;
-        }
-        Code randomCode = this.getRandomCode(agvDetail);
-        if (null == randomCode) {
-            return;
-        }
-        if (mainService.buildMinorTask(agv, agvDetail, TaskTypeType.MOVE, randomCode.getData())) {
-            System.out.println(agv.getUuid() + "寮�濮嬭蛋琛屾紨绀�...");
-        }
-    }
-//    @Scheduled(cron = "0 */3 * * * ? ")
-    @Scheduled(cron = "0/1 * * * * ? ")
-    private void move2() throws InterruptedException {
-        if (!this.autoMove) { return; }
-        Agv agv = agvService.selectByUuid("2");
-        AgvDetail agvDetail = agvDetailService.selectByAgvId(agv.getId());
-        if (taskService.count(new LambdaQueryWrapper<Task>()
-                .eq(Task::getAgvId, agv.getId())
-                .and(i -> {
-                    i.eq(Task::getTaskSts, TaskStsType.WAITING.val())
-                            .or().eq(Task::getTaskSts, TaskStsType.ASSIGN.val())
-                            .or().eq(Task::getTaskSts, TaskStsType.PROGRESS.val());
-                })) > 0) {
-            return;
-        }
-        if (!agvService.judgeEnable(agv.getId())) {
-            return;
-        }
-        Code randomCode = this.getRandomCode(agvDetail);
-        if (null == randomCode) {
-            return;
-        }
-        if (mainService.buildMinorTask(agv, agvDetail, TaskTypeType.MOVE, randomCode.getData())) {
-            System.out.println(agv.getUuid() + "寮�濮嬭蛋琛屾紨绀�...");
-        }
-    }
-
-    public Code getRandomCode(AgvDetail agvDetail) {
-        Code startCode = codeService.getById(agvDetail.getRecentCode());
-        List<String> notInCodeList = new ArrayList<>();
-        notInCodeList.add("00000024");
-        notInCodeList.add("00000025");
-        notInCodeList.add("00000026");
-        notInCodeList.add("00000027");
-        notInCodeList.add("00000028");
-        notInCodeList.add("00000029");
-        notInCodeList.add("00000023");
-        notInCodeList.add("00000035");
-        List<Code> list = codeService.list(new LambdaQueryWrapper<Code>().notIn(Code::getData, notInCodeList));
-        Collections.shuffle(list);
-        for (Code endCode : list) {
-            List<String> pathList = mapService.validFeasibility(startCode, endCode);
-            if (pathList.size() >= 5) {
-                return endCode;
-            }
-        }
-        return list.stream().findFirst().orElse(null);
-    }
-
-    // http://localhost:9090/test/auto?size=1
-    @GetMapping("/auto")
-    public R auto(@RequestParam(value = "size", required = false) Integer size) {
-        if (null != size) {
-            this.autoSize = size;
-        }
-        this.autoDemo = !this.autoDemo;
-        return R.ok(Cools.add("autoDemo", this.autoDemo));
-    }
-
-    @Scheduled(cron = "0/1 * * * * ? ")
-    private void demo() throws InterruptedException {
-        if (!this.autoDemo) { return; }
-        int busLimit = configService.getVal("busLimit", Integer.class);
-        if (autoSize != null) {
-            busLimit = autoSize;
-        }
-        busLimit = 2;
-        AgvModel agvModel = agvModelService.list(new LambdaQueryWrapper<>()).stream().findFirst().orElse(null);
-        if (null != agvModel) {
-            busLimit = agvModel.getBackpack() * 2;
-        }
-        // 鍦ㄥ簱
-        int stock = 0;
-        List<Loc> stockList = locService.list(new LambdaQueryWrapper<Loc>()
-                .eq(Loc::getLocSts, LocStsType.STOCK.val())
-                .ge(Loc::getRow, 1)
-                .le(Loc::getRow, 2)
-        );
-        Collections.shuffle(stockList);
-        if (stockList.size() > busLimit) {
-            stockList = stockList.subList(0, busLimit);
-        }
-        stock = stockList.size();
-        if (stock == 0) { return;}
-
-        // 绌洪棽
-        List<Loc> idleList = locService.list(new LambdaQueryWrapper<Loc>()
-                .eq(Loc::getLocSts, LocStsType.IDLE.val())
-                .ge(Loc::getRow, 1)
-                .le(Loc::getRow, 2)
-        );
-        Collections.shuffle(idleList);
-        if (idleList.size() > stock) {
-            idleList = idleList.subList(0, stock);
-        }
-
-        if (stockList.size() == idleList.size()) {
-            OpenBusSubmitParam param = new OpenBusSubmitParam();
-            param.setBatch("batchNo");
-            for (int i = 0; i < stock; i++) {
-                Loc stockLoc = stockList.get(i);
-                Loc idleLoc = idleList.get(i);
-
-                TaskDto taskDto = new TaskDto();
-                taskDto.setOriLoc(stockLoc.getLocNo());
-                taskDto.setDestLoc(idleLoc.getLocNo());
-                taskDto.setSeqNum(String.valueOf(snowflakeIdWorker.nextId()).substring(15, 19));
-
-                param.getTaskList().add(taskDto);
-
-            }
-
-            if (Cools.isEmpty(busService.selectBySts(BusStsType.RECEIVE, "autoDemo"))
-                    && Cools.isEmpty(busService.selectBySts(BusStsType.PROGRESS, "autoDemo"))
-            ) {
-                mainService.generateBusAndTask(param, "autoDemo");
-            }
-
-        }
-
-    }
-
-
-    // http://localhost:9090/test/auto1?size=1
-    @GetMapping("/auto1")
-    public R auto1(@RequestParam(value = "size", required = false) Integer size) {
-       if (null != size) {
-           this.autoSize = size;
-       }
-       this.autoDemo1 = !this.autoDemo1;
-        return R.ok(Cools.add("autoDemo", this.autoDemo1));
-    }
-
-    @Scheduled(cron = "0/3 * * * * ? ")
-    private void demo1() throws InterruptedException {
-        if (!this.autoDemo1) { return; }
-        int busLimit = configService.getVal("busLimit", Integer.class);
-        if (autoSize != null) {
-            busLimit = autoSize;
-        }
-        // 鍦ㄥ簱
-        int stock = 0;
-        List<Loc> stockList = locService.list(new LambdaQueryWrapper<Loc>()
-                .eq(Loc::getLocSts, LocStsType.STOCK.val())
-                .ge(Loc::getRow, 1)
-                .le(Loc::getRow, 2)
-        );
-        Collections.shuffle(stockList);
-        if (stockList.size() > busLimit) {
-            stockList = stockList.subList(0, busLimit);
-        }
-        stock = stockList.size();
-        if (stock == 0) { return;}
-
-        // 绌洪棽
-        List<Loc> idleList = locService.list(new LambdaQueryWrapper<Loc>()
-                .eq(Loc::getLocSts, LocStsType.IDLE.val())
-                .ge(Loc::getRow, 1)
-                .le(Loc::getRow, 2)
-        );
-        Collections.shuffle(idleList);
-        if (idleList.size() > stock) {
-            idleList = idleList.subList(0, stock);
-        }
-
-        if (stockList.size() == idleList.size()) {
-            OpenBusSubmitParam param = new OpenBusSubmitParam();
-            param.setBatch("batchNo");
-            for (int i = 0; i < stock; i++) {
-                Loc stockLoc = stockList.get(i);
-                Loc idleLoc = idleList.get(i);
-
-                TaskDto taskDto = new TaskDto();
-                taskDto.setOriLoc(stockLoc.getLocNo());
-                taskDto.setDestLoc(idleLoc.getLocNo());
-                taskDto.setSeqNum(String.valueOf(snowflakeIdWorker.nextId()).substring(15, 19));
-
-                param.getTaskList().add(taskDto);
-
-            }
-
-            if (Cools.isEmpty(busService.selectBySts(BusStsType.RECEIVE, "autoDemo1"))
-                    && Cools.isEmpty(busService.selectBySts(BusStsType.PROGRESS, "autoDemo1"))
-            ) {
-                mainService.generateBusAndTask(param, "autoDemo1");
-            }
-
-        }
-
-    }
-
-    // http://localhost:9090/test/auto2?size=1
-    @GetMapping("/auto2")
-    public R auto2(@RequestParam(value = "size", required = false) Integer size) {
-        if (null != size) {
-            this.autoSize = size;
-        }
-        this.autoDemo2 = !this.autoDemo2;
-        return R.ok(Cools.add("autoDemo", this.autoDemo2));
-    }
-
-    @Scheduled(cron = "0/3 * * * * ? ")
-    private void demo2() throws InterruptedException {
-        if (!this.autoDemo2) { return; }
-        int busLimit = configService.getVal("busLimit", Integer.class);
-        if (autoSize != null) {
-            busLimit = autoSize;
-        }
-        // 鍦ㄥ簱
-        int stock = 0;
-        List<Loc> stockList = locService.list(new LambdaQueryWrapper<Loc>()
-                .eq(Loc::getLocSts, LocStsType.STOCK.val())
-                .ge(Loc::getRow, 3)
-                .le(Loc::getRow, 4)
-        );
-        Collections.shuffle(stockList);
-        if (stockList.size() > busLimit) {
-            stockList = stockList.subList(0, busLimit);
-        }
-        stock = stockList.size();
-        if (stock == 0) { return;}
-
-        // 绌洪棽
-        List<Loc> idleList = locService.list(new LambdaQueryWrapper<Loc>()
-                .eq(Loc::getLocSts, LocStsType.IDLE.val())
-                .ge(Loc::getRow, 3)
-                .le(Loc::getRow, 4)
-        );
-        Collections.shuffle(idleList);
-        if (idleList.size() > stock) {
-            idleList = idleList.subList(0, stock);
-        }
-
-        if (stockList.size() == idleList.size()) {
-            OpenBusSubmitParam param = new OpenBusSubmitParam();
-            param.setBatch("batchNo");
-            for (int i = 0; i < stock; i++) {
-                Loc stockLoc = stockList.get(i);
-                Loc idleLoc = idleList.get(i);
-
-                TaskDto taskDto = new TaskDto();
-                taskDto.setOriLoc(stockLoc.getLocNo());
-                taskDto.setDestLoc(idleLoc.getLocNo());
-                taskDto.setSeqNum(String.valueOf(snowflakeIdWorker.nextId()).substring(15, 19));
-
-                param.getTaskList().add(taskDto);
-
-            }
-
-            if (Cools.isEmpty(busService.selectBySts(BusStsType.RECEIVE, "autoDemo2"))
-                    && Cools.isEmpty(busService.selectBySts(BusStsType.PROGRESS, "autoDemo2"))
-            ) {
-                mainService.generateBusAndTask(param, "autoDemo2");
-            }
-
-        }
-
-    }
-
-}
+//package com.zy.acs.manager.core;
+//
+//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+//import com.zy.acs.manager.common.domain.TaskDto;
+//import com.zy.acs.manager.core.service.MainService;
+//import com.zy.acs.manager.core.service.MapService;
+//import com.zy.acs.manager.manager.controller.param.OpenBusSubmitParam;
+//import com.zy.acs.manager.manager.entity.*;
+//import com.zy.acs.manager.manager.enums.BusStsType;
+//import com.zy.acs.manager.manager.enums.LocStsType;
+//import com.zy.acs.manager.manager.enums.TaskStsType;
+//import com.zy.acs.manager.manager.enums.TaskTypeType;
+//import com.zy.acs.manager.manager.service.*;
+//import com.zy.acs.manager.system.controller.BaseController;
+//import com.zy.acs.manager.system.service.ConfigService;
+//import com.zy.acs.framework.common.Cools;
+//import com.zy.acs.framework.common.R;
+//import com.zy.acs.framework.common.SnowflakeIdWorker;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.beans.factory.annotation.Value;
+//import org.springframework.scheduling.annotation.Scheduled;
+//import org.springframework.web.bind.annotation.GetMapping;
+//import org.springframework.web.bind.annotation.RequestMapping;
+//import org.springframework.web.bind.annotation.RequestParam;
+//import org.springframework.web.bind.annotation.RestController;
+//
+//import java.util.ArrayList;
+//import java.util.Collections;
+//import java.util.List;
+//
+///**
+// * Created by vincent on 2023/6/20
+// */
+//@RestController
+//@RequestMapping("/test")
+//public class TestController extends BaseController {
+//
+//    @Autowired
+//    private BusService busService;
+//    @Autowired
+//    private MainService mainService;
+//    @Autowired
+//    private SnowflakeIdWorker snowflakeIdWorker;
+//    @Autowired
+//    private AgvModelService agvModelService;
+//    @Autowired
+//    private AgvService agvService;
+//    @Autowired
+//    private AgvDetailService agvDetailService;
+//    @Autowired
+//    private TaskService taskService;
+//    @Autowired
+//    private CodeService codeService;
+//    @Autowired
+//    private MapService mapService;
+//
+//
+///*
+//TRUNCATE man_bus;
+//TRUNCATE man_task;
+//TRUNCATE man_action;
+//UPDATE man_loc SET loc_sts = 16 WHERE loc_sts = 18;
+//UPDATE man_loc SET loc_sts = 15 WHERE loc_sts = 17;
+//*/
+//
+//    @Value("${auto.move}")
+//    private Boolean autoMove;
+//    @Value("${auto.demo}")
+//    private Boolean autoDemo;
+//    @Value("${auto.demo1}")
+//    private Boolean autoDemo1;
+//    @Value("${auto.demo2}")
+//    private Boolean autoDemo2;
+//    @Value("${auto.size}")
+//    private Integer autoSize;
+//    @Autowired
+//    private LocService locService;
+//    @Autowired
+//    private ConfigService configService;
+//
+//    // http://localhost:9090/test/auto/move
+//    @GetMapping("/auto/move")
+//    public R autoMove() {
+//        this.autoMove = !this.autoMove;
+//        return R.ok().add(Cools.add("autoMove", this.autoMove));
+//    }
+//
+//    @Scheduled(cron = "0/1 * * * * ? ")
+//    private void move1() throws InterruptedException {
+//        if (!this.autoMove) { return; }
+//        Agv agv = agvService.selectByUuid("1");
+//        AgvDetail agvDetail = agvDetailService.selectByAgvId(agv.getId());
+//        if (taskService.count(new LambdaQueryWrapper<Task>()
+//                .eq(Task::getAgvId, agv.getId())
+//                .and(i -> {
+//                    i.eq(Task::getTaskSts, TaskStsType.WAITING.val())
+//                            .or().eq(Task::getTaskSts, TaskStsType.ASSIGN.val())
+//                            .or().eq(Task::getTaskSts, TaskStsType.PROGRESS.val());
+//                })) > 0) {
+//            return;
+//        }
+//        if (!agvService.judgeEnable(agv.getId())) {
+//            return;
+//        }
+//        Code randomCode = this.getRandomCode(agvDetail);
+//        if (null == randomCode) {
+//            return;
+//        }
+//        if (mainService.buildMinorTask(agv, agvDetail, TaskTypeType.MOVE, randomCode.getData())) {
+//            System.out.println(agv.getUuid() + "寮�濮嬭蛋琛屾紨绀�...");
+//        }
+//    }
+////    @Scheduled(cron = "0 */3 * * * ? ")
+//    @Scheduled(cron = "0/1 * * * * ? ")
+//    private void move2() throws InterruptedException {
+//        if (!this.autoMove) { return; }
+//        Agv agv = agvService.selectByUuid("2");
+//        AgvDetail agvDetail = agvDetailService.selectByAgvId(agv.getId());
+//        if (taskService.count(new LambdaQueryWrapper<Task>()
+//                .eq(Task::getAgvId, agv.getId())
+//                .and(i -> {
+//                    i.eq(Task::getTaskSts, TaskStsType.WAITING.val())
+//                            .or().eq(Task::getTaskSts, TaskStsType.ASSIGN.val())
+//                            .or().eq(Task::getTaskSts, TaskStsType.PROGRESS.val());
+//                })) > 0) {
+//            return;
+//        }
+//        if (!agvService.judgeEnable(agv.getId())) {
+//            return;
+//        }
+//        Code randomCode = this.getRandomCode(agvDetail);
+//        if (null == randomCode) {
+//            return;
+//        }
+//        if (mainService.buildMinorTask(agv, agvDetail, TaskTypeType.MOVE, randomCode.getData())) {
+//            System.out.println(agv.getUuid() + "寮�濮嬭蛋琛屾紨绀�...");
+//        }
+//    }
+//
+//    public Code getRandomCode(AgvDetail agvDetail) {
+//        Code startCode = codeService.getById(agvDetail.getRecentCode());
+//        List<String> notInCodeList = new ArrayList<>();
+//        notInCodeList.add("00000024");
+//        notInCodeList.add("00000025");
+//        notInCodeList.add("00000026");
+//        notInCodeList.add("00000027");
+//        notInCodeList.add("00000028");
+//        notInCodeList.add("00000029");
+//        notInCodeList.add("00000023");
+//        notInCodeList.add("00000035");
+//        List<Code> list = codeService.list(new LambdaQueryWrapper<Code>().notIn(Code::getData, notInCodeList));
+//        Collections.shuffle(list);
+//        for (Code endCode : list) {
+//            List<String> pathList = mapService.validFeasibility(startCode, endCode);
+//            if (pathList.size() >= 5) {
+//                return endCode;
+//            }
+//        }
+//        return list.stream().findFirst().orElse(null);
+//    }
+//
+//    // http://localhost:9090/test/auto?size=1
+//    @GetMapping("/auto")
+//    public R auto(@RequestParam(value = "size", required = false) Integer size) {
+//        if (null != size) {
+//            this.autoSize = size;
+//        }
+//        this.autoDemo = !this.autoDemo;
+//        return R.ok(Cools.add("autoDemo", this.autoDemo));
+//    }
+//
+//    @Scheduled(cron = "0/1 * * * * ? ")
+//    private void demo() throws InterruptedException {
+//        if (!this.autoDemo) { return; }
+//        int busLimit = configService.getVal("busLimit", Integer.class);
+//        if (autoSize != null) {
+//            busLimit = autoSize;
+//        }
+//        busLimit = 2;
+//        AgvModel agvModel = agvModelService.list(new LambdaQueryWrapper<>()).stream().findFirst().orElse(null);
+//        if (null != agvModel) {
+//            busLimit = agvModel.getBackpack() * 2;
+//        }
+//        // 鍦ㄥ簱
+//        int stock = 0;
+//        List<Loc> stockList = locService.list(new LambdaQueryWrapper<Loc>()
+//                .eq(Loc::getLocSts, LocStsType.STOCK.val())
+//                .ge(Loc::getRow, 1)
+//                .le(Loc::getRow, 2)
+//        );
+//        Collections.shuffle(stockList);
+//        if (stockList.size() > busLimit) {
+//            stockList = stockList.subList(0, busLimit);
+//        }
+//        stock = stockList.size();
+//        if (stock == 0) { return;}
+//
+//        // 绌洪棽
+//        List<Loc> idleList = locService.list(new LambdaQueryWrapper<Loc>()
+//                .eq(Loc::getLocSts, LocStsType.IDLE.val())
+//                .ge(Loc::getRow, 1)
+//                .le(Loc::getRow, 2)
+//        );
+//        Collections.shuffle(idleList);
+//        if (idleList.size() > stock) {
+//            idleList = idleList.subList(0, stock);
+//        }
+//
+//        if (stockList.size() == idleList.size()) {
+//            OpenBusSubmitParam param = new OpenBusSubmitParam();
+//            param.setBatch("batchNo");
+//            for (int i = 0; i < stock; i++) {
+//                Loc stockLoc = stockList.get(i);
+//                Loc idleLoc = idleList.get(i);
+//
+//                TaskDto taskDto = new TaskDto();
+//                taskDto.setOriLoc(stockLoc.getLocNo());
+//                taskDto.setDestLoc(idleLoc.getLocNo());
+//                taskDto.setSeqNum(String.valueOf(snowflakeIdWorker.nextId()).substring(15, 19));
+//
+//                param.getTaskList().add(taskDto);
+//
+//            }
+//
+//            if (Cools.isEmpty(busService.selectBySts(BusStsType.RECEIVE, "autoDemo"))
+//                    && Cools.isEmpty(busService.selectBySts(BusStsType.PROGRESS, "autoDemo"))
+//            ) {
+//                mainService.generateBusAndTask(param, "autoDemo");
+//            }
+//
+//        }
+//
+//    }
+//
+//
+//    // http://localhost:9090/test/auto1?size=1
+//    @GetMapping("/auto1")
+//    public R auto1(@RequestParam(value = "size", required = false) Integer size) {
+//       if (null != size) {
+//           this.autoSize = size;
+//       }
+//       this.autoDemo1 = !this.autoDemo1;
+//        return R.ok(Cools.add("autoDemo", this.autoDemo1));
+//    }
+//
+//    @Scheduled(cron = "0/3 * * * * ? ")
+//    private void demo1() throws InterruptedException {
+//        if (!this.autoDemo1) { return; }
+//        int busLimit = configService.getVal("busLimit", Integer.class);
+//        if (autoSize != null) {
+//            busLimit = autoSize;
+//        }
+//        // 鍦ㄥ簱
+//        int stock = 0;
+//        List<Loc> stockList = locService.list(new LambdaQueryWrapper<Loc>()
+//                .eq(Loc::getLocSts, LocStsType.STOCK.val())
+//                .ge(Loc::getRow, 1)
+//                .le(Loc::getRow, 2)
+//        );
+//        Collections.shuffle(stockList);
+//        if (stockList.size() > busLimit) {
+//            stockList = stockList.subList(0, busLimit);
+//        }
+//        stock = stockList.size();
+//        if (stock == 0) { return;}
+//
+//        // 绌洪棽
+//        List<Loc> idleList = locService.list(new LambdaQueryWrapper<Loc>()
+//                .eq(Loc::getLocSts, LocStsType.IDLE.val())
+//                .ge(Loc::getRow, 1)
+//                .le(Loc::getRow, 2)
+//        );
+//        Collections.shuffle(idleList);
+//        if (idleList.size() > stock) {
+//            idleList = idleList.subList(0, stock);
+//        }
+//
+//        if (stockList.size() == idleList.size()) {
+//            OpenBusSubmitParam param = new OpenBusSubmitParam();
+//            param.setBatch("batchNo");
+//            for (int i = 0; i < stock; i++) {
+//                Loc stockLoc = stockList.get(i);
+//                Loc idleLoc = idleList.get(i);
+//
+//                TaskDto taskDto = new TaskDto();
+//                taskDto.setOriLoc(stockLoc.getLocNo());
+//                taskDto.setDestLoc(idleLoc.getLocNo());
+//                taskDto.setSeqNum(String.valueOf(snowflakeIdWorker.nextId()).substring(15, 19));
+//
+//                param.getTaskList().add(taskDto);
+//
+//            }
+//
+//            if (Cools.isEmpty(busService.selectBySts(BusStsType.RECEIVE, "autoDemo1"))
+//                    && Cools.isEmpty(busService.selectBySts(BusStsType.PROGRESS, "autoDemo1"))
+//            ) {
+//                mainService.generateBusAndTask(param, "autoDemo1");
+//            }
+//
+//        }
+//
+//    }
+//
+//    // http://localhost:9090/test/auto2?size=1
+//    @GetMapping("/auto2")
+//    public R auto2(@RequestParam(value = "size", required = false) Integer size) {
+//        if (null != size) {
+//            this.autoSize = size;
+//        }
+//        this.autoDemo2 = !this.autoDemo2;
+//        return R.ok(Cools.add("autoDemo", this.autoDemo2));
+//    }
+//
+//    @Scheduled(cron = "0/3 * * * * ? ")
+//    private void demo2() throws InterruptedException {
+//        if (!this.autoDemo2) { return; }
+//        int busLimit = configService.getVal("busLimit", Integer.class);
+//        if (autoSize != null) {
+//            busLimit = autoSize;
+//        }
+//        // 鍦ㄥ簱
+//        int stock = 0;
+//        List<Loc> stockList = locService.list(new LambdaQueryWrapper<Loc>()
+//                .eq(Loc::getLocSts, LocStsType.STOCK.val())
+//                .ge(Loc::getRow, 3)
+//                .le(Loc::getRow, 4)
+//        );
+//        Collections.shuffle(stockList);
+//        if (stockList.size() > busLimit) {
+//            stockList = stockList.subList(0, busLimit);
+//        }
+//        stock = stockList.size();
+//        if (stock == 0) { return;}
+//
+//        // 绌洪棽
+//        List<Loc> idleList = locService.list(new LambdaQueryWrapper<Loc>()
+//                .eq(Loc::getLocSts, LocStsType.IDLE.val())
+//                .ge(Loc::getRow, 3)
+//                .le(Loc::getRow, 4)
+//        );
+//        Collections.shuffle(idleList);
+//        if (idleList.size() > stock) {
+//            idleList = idleList.subList(0, stock);
+//        }
+//
+//        if (stockList.size() == idleList.size()) {
+//            OpenBusSubmitParam param = new OpenBusSubmitParam();
+//            param.setBatch("batchNo");
+//            for (int i = 0; i < stock; i++) {
+//                Loc stockLoc = stockList.get(i);
+//                Loc idleLoc = idleList.get(i);
+//
+//                TaskDto taskDto = new TaskDto();
+//                taskDto.setOriLoc(stockLoc.getLocNo());
+//                taskDto.setDestLoc(idleLoc.getLocNo());
+//                taskDto.setSeqNum(String.valueOf(snowflakeIdWorker.nextId()).substring(15, 19));
+//
+//                param.getTaskList().add(taskDto);
+//
+//            }
+//
+//            if (Cools.isEmpty(busService.selectBySts(BusStsType.RECEIVE, "autoDemo2"))
+//                    && Cools.isEmpty(busService.selectBySts(BusStsType.PROGRESS, "autoDemo2"))
+//            ) {
+//                mainService.generateBusAndTask(param, "autoDemo2");
+//            }
+//
+//        }
+//
+//    }
+//
+//}

--
Gitblit v1.9.1