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.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.RequestMethod; import org.springframework.web.bind.annotation.RestController; import java.util.List; /** * Created by vincent on 11/15/2024 */ @RestController @RequestMapping("/demo") public class DemoController extends BaseController { @Autowired private AgvService agvService; @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 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"); } // @RequestMapping(value = "/system/route/generate", method = {RequestMethod.GET, RequestMethod.POST}) // public R generate() { // String[][] codeMatrix = mapDataDispatcher.getCodeMatrix(null); // List list = routeGenerator.generateRoutes(codeMatrix); // return R.ok(String.valueOf(list.size())).add(list); // } // http://localhost:8088/demo/auto/go/standby @GetMapping("/auto/go/standby") public R autoGoStandby() { List standbyFunStaList = funcStaService.list(new LambdaQueryWrapper() .eq(FuncSta::getStatus, StatusType.ENABLE.val) .eq(FuncSta::getType, FuncStaType.STANDBY.toString()) .orderByAsc(FuncSta::getId)); List agvList = agvService.list(new LambdaQueryWrapper().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(); // 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(); } }