| | |
| | | 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.RequestMethod; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | 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 |
| | |
| | | // return R.ok(String.valueOf(list.size())).add(list); |
| | | // } |
| | | |
| | | // http://localhost:8088/demo/auto/go/standby |
| | | @GetMapping("/auto/go/standby") |
| | | public R autoGoStandby() { |
| | | |
| | |
| | | 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)); |
| | | |
| | | // 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); |
| | | int result = 0; |
| | | for (Agv agv : agvs) { |
| | | 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.selectByData("00001318") |
| | | , codeService.selectByData("00003447") |
| | | , true |
| | | , new ArrayList<>() |
| | | , segmentService.getById(1390)); |
| | | System.out.println("demo spend time: " + (System.currentTimeMillis() - startTime)); |
| | | return R.ok().add(path); |
| | | } |
| | | |
| | | } |