| | |
| | | package com.zy.acs.manager.core; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.acs.common.enums.AgvStatusType; |
| | | import com.zy.acs.framework.common.R; |
| | | import com.zy.acs.framework.common.SnowflakeIdWorker; |
| | | 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.enums.TaskTypeType; |
| | | import com.zy.acs.manager.manager.entity.Code; |
| | | import com.zy.acs.manager.manager.entity.FuncSta; |
| | | import com.zy.acs.manager.manager.enums.FuncStaType; |
| | | import com.zy.acs.manager.manager.enums.StatusType; |
| | | import com.zy.acs.manager.manager.service.*; |
| | | import com.zy.acs.manager.system.controller.BaseController; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.jdbc.core.JdbcTemplate; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Created by vincent on 11/15/2024 |
| | |
| | | private AvoidWaveCalculator avoidWaveCalculator; |
| | | @Autowired |
| | | private PatrolService patrolService; |
| | | @Autowired |
| | | private RouteGenerator routeGenerator; |
| | | @Autowired |
| | | private FuncStaService funcStaService; |
| | | |
| | | @RequestMapping(value = "/system/info", method = {RequestMethod.GET, RequestMethod.POST}) |
| | | public R systemInfo() { |
| | | return R.ok("RCS-FLOW-1.0.0"); |
| | | } |
| | | |
| | | @GetMapping("/dead/lock") |
| | | public R aaa() { |
| | | AgvDetail agvDetail11 = agvDetailService.selectByAgvNo("11"); |
| | | agvDetail11.setCode(codeService.selectByData("00000251").getId()); |
| | | agvDetailService.updateById(agvDetail11); |
| | | // @RequestMapping(value = "/system/route/generate", method = {RequestMethod.GET, RequestMethod.POST}) |
| | | // public R generate() { |
| | | // String[][] codeMatrix = mapDataDispatcher.getCodeMatrix(null); |
| | | // List<String> list = routeGenerator.generateRoutes(codeMatrix); |
| | | // return R.ok(String.valueOf(list.size())).add(list); |
| | | // } |
| | | |
| | | AgvDetail agvDetail12 = agvDetailService.selectByAgvNo("12"); |
| | | agvDetail12.setCode(codeService.selectByData("00000204").getId()); |
| | | agvDetailService.updateById(agvDetail12); |
| | | // http://localhost:8088/demo/auto/go/standby |
| | | @GetMapping("/auto/go/standby") |
| | | public R autoGoStandby() { |
| | | |
| | | AgvDetail agvDetail14 = agvDetailService.selectByAgvNo("14"); |
| | | agvDetail14.setCode(codeService.selectByData("00000101").getId()); |
| | | agvDetailService.updateById(agvDetail14); |
| | | List<FuncSta> standbyFunStaList = funcStaService.list(new LambdaQueryWrapper<FuncSta>() |
| | | .eq(FuncSta::getStatus, StatusType.ENABLE.val) |
| | | .eq(FuncSta::getType, FuncStaType.STANDBY.toString()) |
| | | .orderByAsc(FuncSta::getId)); |
| | | |
| | | List<Agv> agvList = agvService.list(new LambdaQueryWrapper<Agv>().orderByAsc(Agv::getId)); |
| | | |
| | | for (int i = 0; i < standbyFunStaList.size(); i++) { |
| | | |
| | | FuncSta funcSta = standbyFunStaList.get(i); |
| | | Code code = codeService.getById(funcSta.getCode()); |
| | | |
| | | Agv agv = agvList.get(i); |
| | | AgvDetail agvDetail = agvDetailService.selectByAgvId(agv.getId()); |
| | | |
| | | agvDetail.setPos(1); |
| | | agvDetail.setCode(code.getId()); |
| | | agvDetail.setStatus(AgvStatusType.IDLE.val); |
| | | agvDetail.setAgvAngle(90D); |
| | | agvDetail.setVol(5000); |
| | | |
| | | agvDetailService.updateById(agvDetail); |
| | | } |
| | | |
| | | avoidWaveCalculator.calcDynamicNodeWhenBoot(); |
| | | |
| | | |
| | | mainLockWrapService.buildMinorTask(agvService.getById(agvDetail14.getAgvId()), TaskTypeType.MOVE, |
| | | codeService.selectByData("00000303").getData(), null); |
| | | mainLockWrapService.buildMinorTask(agvService.getById(agvDetail11.getAgvId()), TaskTypeType.MOVE, |
| | | codeService.selectByData("00000411").getData(), null); |
| | | mainLockWrapService.buildMinorTask(agvService.getById(agvDetail12.getAgvId()), TaskTypeType.MOVE, |
| | | codeService.selectByData("00000403").getData(), null); |
| | | // AgvDetail agvDetail11 = agvDetailService.selectByAgvNo("11"); |
| | | // agvDetail11.setCode(codeService.selectByData("00000251").getId()); |
| | | // agvDetailService.updateById(agvDetail11); |
| | | // |
| | | // AgvDetail agvDetail12 = agvDetailService.selectByAgvNo("12"); |
| | | // agvDetail12.setCode(codeService.selectByData("00000204").getId()); |
| | | // agvDetailService.updateById(agvDetail12); |
| | | // |
| | | // AgvDetail agvDetail14 = agvDetailService.selectByAgvNo("14"); |
| | | // agvDetail14.setCode(codeService.selectByData("00000101").getId()); |
| | | // agvDetailService.updateById(agvDetail14); |
| | | // |
| | | // avoidWaveCalculator.calcDynamicNodeWhenBoot(); |
| | | // |
| | | // mainLockWrapService.buildMinorTask(agvService.getById(agvDetail14.getAgvId()), TaskTypeType.MOVE, |
| | | // codeService.selectByData("00000303").getData(), null); |
| | | // mainLockWrapService.buildMinorTask(agvService.getById(agvDetail11.getAgvId()), TaskTypeType.MOVE, |
| | | // codeService.selectByData("00000411").getData(), null); |
| | | // mainLockWrapService.buildMinorTask(agvService.getById(agvDetail12.getAgvId()), TaskTypeType.MOVE, |
| | | // codeService.selectByData("00000403").getData(), null); |
| | | |
| | | return R.ok(); |
| | | } |
| | | |
| | | // http://localhost:8088/demo/auto/go/patrol?count=10 |
| | | @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)); |
| | | Collections.shuffle(list); |
| | | List<Agv> agvs = list.subList(0, count); |
| | | int result = 0; |
| | | for (Agv agv : agvs) { |
| | | patrolService.startupPatrol(agv.getUuid()); |
| | | result++; |
| | | } |
| | | return R.ok().add(result); |
| | | } |
| | | } |