| | |
| | | import com.zy.acs.manager.core.service.*; |
| | | import com.zy.acs.manager.core.service.astart.MapDataDispatcher; |
| | | import com.zy.acs.manager.core.utils.RouteGenerator; |
| | | import com.zy.acs.manager.manager.entity.Agv; |
| | | import com.zy.acs.manager.manager.entity.AgvDetail; |
| | | import com.zy.acs.manager.manager.entity.Code; |
| | | import com.zy.acs.manager.manager.entity.FuncSta; |
| | | import com.zy.acs.manager.manager.entity.*; |
| | | import com.zy.acs.manager.manager.enums.FuncStaType; |
| | | import com.zy.acs.manager.manager.enums.StatusType; |
| | | import com.zy.acs.manager.manager.service.*; |
| | |
| | | import org.springframework.jdbc.core.JdbcTemplate; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * Created by vincent on 11/15/2024 |
| | |
| | | private RouteGenerator routeGenerator; |
| | | @Autowired |
| | | private FuncStaService funcStaService; |
| | | @Autowired |
| | | private AgvModelService agvModelService; |
| | | |
| | | @RequestMapping(value = "/system/info", method = {RequestMethod.GET, RequestMethod.POST}) |
| | | public R systemInfo() { |
| | | return R.ok("RCS-FLOW-1.0.0"); |
| | | } |
| | | |
| | | // {"msg":"Success","code":200,"data":[[38,2],[38,3],[38,4],[38,5],[38,6],[37,6],[36,6],[35,6],[34,6],[33,6],[32,6],[31,6],[30,6],[29,6],[28,6],[27,6],[26,6],[25,6]]} |
| | | // {"msg":"Success","code":200,"data":[[38,2],[38,3],[38,4],[38,5],[38,6],[37,6],[36,6],[35,6],[34,6],[33,6],[32,6],[31,6],[30,6],[29,6],[28,6],[27,6],[26,6],[25,6]]} |
| | | @RequestMapping(value = "/system/demo", method = {RequestMethod.GET, RequestMethod.POST}) |
| | | public R demo() { |
| | | long startTime = System.currentTimeMillis(); |
| | | for (int i = 0; i < 1000; i++) { |
| | | this.demo1(); |
| | | } |
| | | System.out.println(System.currentTimeMillis() - startTime); |
| | | return R.ok(); |
| | | } |
| | | |
| | | private R demo1() { |
| | | List<String> path = new ArrayList<>(); |
| | | path.add("00000035"); |
| | | path.add("00000085"); |
| | | path.add("00000135"); |
| | | path.add("00000185"); |
| | | path.add("00000235"); |
| | | path.add("00000234"); |
| | | path.add("00000233"); |
| | | path.add("00000232"); |
| | | path.add("00000231"); |
| | | path.add("00000230"); |
| | | path.add("00000229"); |
| | | path.add("00000228"); |
| | | path.add("00000227"); |
| | | path.add("00000226"); |
| | | path.add("00000225"); |
| | | path.add("00000224"); |
| | | path.add("00000223"); |
| | | path.add("00000222"); |
| | | |
| | | // List<int[]> codeMatrixIdxList = new ArrayList<>(); |
| | | // for (String pathStr : path) { |
| | | // int[] codeMatrixIdx = mapDataDispatcher.getCodeMatrixIdx(null, pathStr); |
| | | // codeMatrixIdxList.add(codeMatrixIdx); |
| | | // } |
| | | |
| | | // List<int[]> codeMatrixIdxList = mapDataDispatcher.getCodeMatrixIdxList(null, path); |
| | | |
| | | // System.out.println(codeMatrixIdxList.toString()); |
| | | |
| | | // return R.ok().add(codeMatrixIdxList); |
| | | |
| | | for (String codeData : path) { |
| | | Code code = codeService.getCacheByData(codeData); |
| | | Code byId = codeService.getCacheById(code.getId()); |
| | | } |
| | | |
| | | return R.ok(); |
| | | } |
| | | |
| | | // @RequestMapping(value = "/system/route/generate", method = {RequestMethod.GET, RequestMethod.POST}) |
| | |
| | | .eq(FuncSta::getType, FuncStaType.STANDBY.toString()) |
| | | .orderByAsc(FuncSta::getId)); |
| | | |
| | | List<Agv> agvList = agvService.list(new LambdaQueryWrapper<Agv>().orderByAsc(Agv::getId)); |
| | | List<Agv> agvList = agvService.list(new LambdaQueryWrapper<Agv>().eq(Agv::getStatus, StatusType.ENABLE.val). orderByAsc(Agv::getId)); |
| | | |
| | | for (int i = 0; i < standbyFunStaList.size(); i++) { |
| | | int size = Math.min(standbyFunStaList.size(), agvList.size()); |
| | | |
| | | for (int i = 0; i < size; i++) { |
| | | |
| | | FuncSta funcSta = standbyFunStaList.get(i); |
| | | Code code = codeService.getById(funcSta.getCode()); |
| | | Code code = codeService.getCacheById(funcSta.getCode()); |
| | | |
| | | Agv agv = agvList.get(i); |
| | | AgvDetail agvDetail = agvDetailService.selectByAgvId(agv.getId()); |
| | | AgvModel agvModel = agvModelService.getByAgvId(agv.getId()); |
| | | Double workDirection = agvModel.getWorkDirection(); |
| | | |
| | | agvDetail.setPos(1); |
| | | agvDetail.setCode(code.getId()); |
| | | agvDetail.setStatus(AgvStatusType.IDLE.val); |
| | | agvDetail.setAgvAngle(90D); |
| | | agvDetail.setAgvAngle(workDirection); |
| | | agvDetail.setVol(5000); |
| | | |
| | | agvDetailService.updateById(agvDetail); |
| | |
| | | avoidWaveCalculator.calcDynamicNodeWhenBoot(); |
| | | |
| | | // AgvDetail agvDetail11 = agvDetailService.selectByAgvNo("11"); |
| | | // agvDetail11.setCode(codeService.selectByData("00000251").getId()); |
| | | // agvDetail11.setCode(codeService.getCacheByData("00000251").getId()); |
| | | // agvDetailService.updateById(agvDetail11); |
| | | // |
| | | // AgvDetail agvDetail12 = agvDetailService.selectByAgvNo("12"); |
| | | // agvDetail12.setCode(codeService.selectByData("00000204").getId()); |
| | | // agvDetail12.setCode(codeService.getCacheByData("00000204").getId()); |
| | | // agvDetailService.updateById(agvDetail12); |
| | | // |
| | | // AgvDetail agvDetail14 = agvDetailService.selectByAgvNo("14"); |
| | | // agvDetail14.setCode(codeService.selectByData("00000101").getId()); |
| | | // agvDetail14.setCode(codeService.getCacheByData("00000101").getId()); |
| | | // agvDetailService.updateById(agvDetail14); |
| | | // |
| | | // avoidWaveCalculator.calcDynamicNodeWhenBoot(); |
| | | // |
| | | // mainLockWrapService.buildMinorTask(agvService.getById(agvDetail14.getAgvId()), TaskTypeType.MOVE, |
| | | // codeService.selectByData("00000303").getData(), null); |
| | | // codeService.getCacheByData("00000303").getData(), null); |
| | | // mainLockWrapService.buildMinorTask(agvService.getById(agvDetail11.getAgvId()), TaskTypeType.MOVE, |
| | | // codeService.selectByData("00000411").getData(), null); |
| | | // codeService.getCacheByData("00000411").getData(), null); |
| | | // mainLockWrapService.buildMinorTask(agvService.getById(agvDetail12.getAgvId()), TaskTypeType.MOVE, |
| | | // codeService.selectByData("00000403").getData(), null); |
| | | // codeService.getCacheByData("00000403").getData(), null); |
| | | |
| | | return R.ok(); |
| | | } |
| | |
| | | @GetMapping("/auto/go/patrol") |
| | | public R autoGoPatrol(@RequestParam(required = false, defaultValue = "5") Integer count) { |
| | | List<Agv> list = agvService.list(new LambdaQueryWrapper<Agv>().eq(Agv::getStatus, StatusType.ENABLE.val)); |
| | | |
| | | // stop |
| | | if (count == 0) { |
| | | for (String agvNo : list.stream().map(Agv::getUuid).collect(Collectors.toList())) { |
| | | if (patrolService.isPatrolling(agvNo)) { |
| | | patrolService.shutdownPatrol(agvNo); |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | // start |
| | | Collections.shuffle(list); |
| | | List<Agv> agvs = list.subList(0, count); |
| | | if (list.size() > count) { |
| | | list = list.subList(0, count); |
| | | } |
| | | int result = 0; |
| | | for (Agv agv : agvs) { |
| | | for (Agv agv : list) { |
| | | patrolService.startupPatrol(agv.getUuid()); |
| | | result++; |
| | | } |
| | | return R.ok().add(result); |
| | | } |
| | | |
| | | |
| | | @Autowired |
| | | private MapService mapService; |
| | | @Autowired |
| | | private SegmentService segmentService; |
| | | |
| | | @GetMapping("/astarDemo") // astar spend time: 3866, count:3855 |
| | | public R astarDemo() { |
| | | long startTime = System.currentTimeMillis(); |
| | | List<String> path = mapService.checkoutPath("18" |
| | | , codeService.getCacheByData("00001318") |
| | | , codeService.getCacheByData("00003447") |
| | | , true |
| | | , new ArrayList<>() |
| | | , segmentService.getById(1390)); |
| | | System.out.println("demo spend time: " + (System.currentTimeMillis() - startTime)); |
| | | return R.ok().add(path); |
| | | } |
| | | |
| | | } |