| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.acs.common.constant.RedisConstant; |
| | | import com.zy.acs.common.utils.RedisSupport; |
| | | import com.zy.acs.common.utils.Utils; |
| | | 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 lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.jdbc.core.JdbcTemplate; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | 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 |
| | |
| | | @RestController |
| | | @RequestMapping("/api/handler") |
| | | public class HandlerController extends BaseController { |
| | | |
| | | private final RedisSupport redis = RedisSupport.defaultRedisSupport; |
| | | |
| | | public static final String APP_KEY = "xltys1995"; |
| | | |
| | |
| | | @Autowired |
| | | private PatrolService patrolService; |
| | | |
| | | @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(); |
| | | 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)); |
| | | int result = 0; |
| | | for (Agv agv : list) { |
| | | patrolService.startupPatrol(agv.getUuid()); |
| | | 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 |
| | | public R controlAgv(@RequestHeader String appKey, |