| | |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.framework.common.R; |
| | | import com.zy.acs.framework.common.SnowflakeIdWorker; |
| | | import com.zy.acs.manager.common.annotation.OperationLog; |
| | | import com.zy.acs.manager.common.domain.param.HandlerPublishParam; |
| | | import com.zy.acs.manager.common.exception.BusinessException; |
| | | import com.zy.acs.manager.core.service.*; |
| | | import com.zy.acs.manager.core.service.astart.MapDataDispatcher; |
| | | import com.zy.acs.manager.core.service.astart.domain.DynamicNode; |
| | | import com.zy.acs.manager.manager.entity.*; |
| | | import com.zy.acs.manager.manager.enums.*; |
| | | import com.zy.acs.manager.manager.service.*; |
| | |
| | | import java.util.List; |
| | | import java.util.concurrent.CompletableFuture; |
| | | import java.util.concurrent.ExecutionException; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * Created by vincent on 8/1/2024 |
| | |
| | | @Autowired |
| | | private PatrolService patrolService; |
| | | |
| | | @PreAuthorize("hasAuthority('manager:loc:update')") |
| | | @PostMapping("/rePositionAllAgv") |
| | | public synchronized R rePositionAllAgv() { |
| | | @PreAuthorize("hasAuthority('manager:agv:update')") |
| | | @OperationLog("Locate All Agv") |
| | | @PostMapping("/locateAllAgv") |
| | | public synchronized R locateAllAgv() { |
| | | final Integer MAP_DEFAULT_LEV = 1; |
| | | redis.deleteValue(RedisConstant.AGV_MAP_ASTAR_DYNAMIC_FLAG, String.valueOf(MAP_DEFAULT_LEV)); |
| | | // avoidWaveCalculator.calcDynamicNodeWhenBoot(); |
| | | avoidWaveCalculator.calcDynamicNodeWhenBoot(); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:agv:update')") |
| | | @PostMapping("/patrol/batch/startup") |
| | | public synchronized R patrolBatchStartup() { |
| | | List<Agv> list = agvService.list(new LambdaQueryWrapper<Agv>().eq(Agv::getStatus, StatusType.ENABLE.val)); |
| | | DynamicNode[][] dynamicMatrix = mapDataDispatcher.getDynamicMatrix(MapDataDispatcher.MAP_DEFAULT_LEV); |
| | | int result = 0; |
| | | for (Agv agv : list) { |
| | | String agvNo = agv.getUuid(); |
| | | |
| | | boolean inMap = false; |
| | | label: for (int i = 0; i < dynamicMatrix.length; i++) { |
| | | for (int j = 0; j < dynamicMatrix[i].length; j++) { |
| | | DynamicNode dynamicNode = dynamicMatrix[i][j]; |
| | | String vehicle = dynamicNode.getVehicle(); |
| | | if (agvNo.equals(vehicle)) { |
| | | inMap = true; |
| | | break label; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (inMap) { |
| | | patrolService.startupPatrol(agvNo); |
| | | result++; |
| | | } |
| | | } |
| | | return R.ok().add(result); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:agv:update')") |
| | | @PostMapping("/patrol/batch/shutdown") |
| | | public synchronized R patrolBatchShutdown() { |
| | | List<Agv> list = agvService.list(new LambdaQueryWrapper<Agv>()); |
| | | for (String agvNo : list.stream().map(Agv::getUuid).collect(Collectors.toList())) { |
| | | if (patrolService.isPatrolling(agvNo)) { |
| | | patrolService.shutdownPatrol(agvNo); |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/control/agv", method = {RequestMethod.GET, RequestMethod.POST}) |
| | | @Transactional |
| | |
| | | oriLoc = locService.getById(param.getStartLocNo()); |
| | | } |
| | | if (!Cools.isEmpty(param.getStartLocNoStr())) { |
| | | oriLoc = locService.selecatByLocNo(param.getStartLocNoStr()); |
| | | oriLoc = locService.selectByLocNo(param.getStartLocNoStr()); |
| | | } |
| | | if (null == oriLoc) { |
| | | return R.error(); |
| | |
| | | destLoc = locService.getById(param.getEndLocNo()); |
| | | } |
| | | if (!Cools.isEmpty(param.getEndLocNoStr())) { |
| | | destLoc = locService.selecatByLocNo(param.getEndLocNoStr()); |
| | | destLoc = locService.selectByLocNo(param.getEndLocNoStr()); |
| | | } |
| | | if (null == destLoc) { |
| | | return R.error(); |
| | |
| | | oriLoc = locService.getById(param.getStartLocNo()); |
| | | } |
| | | if (!Cools.isEmpty(param.getStartLocNoStr())) { |
| | | oriLoc = locService.selecatByLocNo(param.getStartLocNoStr()); |
| | | oriLoc = locService.selectByLocNo(param.getStartLocNoStr()); |
| | | } |
| | | if (null == oriLoc) { |
| | | return R.error(); |
| | |
| | | destLoc = locService.getById(param.getEndLocNo()); |
| | | } |
| | | if (!Cools.isEmpty(param.getEndLocNoStr())) { |
| | | destLoc = locService.selecatByLocNo(param.getEndLocNoStr()); |
| | | destLoc = locService.selectByLocNo(param.getEndLocNoStr()); |
| | | } |
| | | if (null == destLoc) { |
| | | return R.error(); |