| | |
| | | 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.manager.entity.AgvDetail; |
| | | import com.zy.acs.manager.manager.enums.TaskTypeType; |
| | | import com.zy.acs.manager.core.integrate.conveyor.ConveyorStationService; |
| | | import com.zy.acs.manager.core.service.AvoidWaveCalculator; |
| | | import com.zy.acs.manager.core.service.MapService; |
| | | import com.zy.acs.manager.core.service.PatrolService; |
| | | import com.zy.acs.manager.manager.entity.*; |
| | | import com.zy.acs.manager.manager.enums.FuncStaType; |
| | | import com.zy.acs.manager.manager.enums.StaReserveType; |
| | | 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.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * Created by vincent on 11/15/2024 |
| | |
| | | @Autowired |
| | | private AgvDetailService agvDetailService; |
| | | @Autowired |
| | | private TaskService taskService; |
| | | @Autowired |
| | | private MainService mainService; |
| | | @Autowired |
| | | private MainLockWrapService mainLockWrapService; |
| | | @Autowired |
| | | private SnowflakeIdWorker snowflakeIdWorker; |
| | | @Autowired |
| | | private CodeService codeService; |
| | | @Autowired |
| | | private JdbcTemplate jdbcTemplate; |
| | | @Autowired |
| | | private LocService locService; |
| | | @Autowired |
| | | private TrafficService trafficService; |
| | | @Autowired |
| | | private ThreadPoolRegulator threadPoolRegulator; |
| | | @Autowired |
| | | private MapDataDispatcher mapDataDispatcher; |
| | | @Autowired |
| | | private AvoidWaveCalculator avoidWaveCalculator; |
| | | @Autowired |
| | | private PatrolService patrolService; |
| | | @Autowired |
| | | private FuncStaService funcStaService; |
| | | @Autowired |
| | | private AgvModelService agvModelService; |
| | | @Autowired |
| | | private StaService staService; |
| | | // @Autowired |
| | | // private ConveyorStationService siemensConveyorStationService; |
| | | @Autowired |
| | | private ConveyorStationService siemensConveyorStationService; |
| | | |
| | | @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/demo", method = {RequestMethod.GET, RequestMethod.POST}) |
| | | public R demo() { |
| | | Sta sta = staService.selectByStaNo("1006"); |
| | | boolean b = siemensConveyorStationService.allowAgvWork(sta, null, null, StaReserveType.IN); |
| | | return R.ok().add(b); |
| | | } |
| | | |
| | | 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>().eq(Agv::getStatus, StatusType.ENABLE.val). orderByAsc(Agv::getId)); |
| | | |
| | | int size = Math.min(standbyFunStaList.size(), agvList.size()); |
| | | |
| | | for (int i = 0; i < size; i++) { |
| | | |
| | | FuncSta funcSta = standbyFunStaList.get(i); |
| | | 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(workDirection); |
| | | agvDetail.setVol(5000); |
| | | agvDetail.setSoc(80); |
| | | |
| | | 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.getCacheByData("00000251").getId()); |
| | | // agvDetailService.updateById(agvDetail11); |
| | | // |
| | | // AgvDetail agvDetail12 = agvDetailService.selectByAgvNo("12"); |
| | | // agvDetail12.setCode(codeService.getCacheByData("00000204").getId()); |
| | | // agvDetailService.updateById(agvDetail12); |
| | | // |
| | | // AgvDetail agvDetail14 = agvDetailService.selectByAgvNo("14"); |
| | | // agvDetail14.setCode(codeService.getCacheByData("00000101").getId()); |
| | | // agvDetailService.updateById(agvDetail14); |
| | | // |
| | | // avoidWaveCalculator.calcDynamicNodeWhenBoot(); |
| | | // |
| | | // mainLockWrapService.buildMinorTask(agvService.getById(agvDetail14.getAgvId()), TaskTypeType.MOVE, |
| | | // codeService.getCacheByData("00000303").getData(), null); |
| | | // mainLockWrapService.buildMinorTask(agvService.getById(agvDetail11.getAgvId()), TaskTypeType.MOVE, |
| | | // codeService.getCacheByData("00000411").getData(), null); |
| | | // mainLockWrapService.buildMinorTask(agvService.getById(agvDetail12.getAgvId()), TaskTypeType.MOVE, |
| | | // codeService.getCacheByData("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)); |
| | | |
| | | // 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); |
| | | if (list.size() > count) { |
| | | list = list.subList(0, count); |
| | | } |
| | | int result = 0; |
| | | 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); |
| | | } |
| | | |
| | | } |