| | |
| | | |
| | | public interface AgvDetailMapper extends BaseMapper<AgvDetail> { |
| | | |
| | | int updatePosCode(@Param("id") Long id, @Param("codeId") Long codeId); |
| | | int updatePosCodeByAgvId(@Param("agvId") Long agvId, @Param("codeId") Long codeId); |
| | | |
| | | int updateUnPosCode(@Param("id") Long id, @Param("lastCode") Long lastCode); |
| | | Boolean updateAngleByAgvId(@Param("agvId") Long agvId, @Param("angle") Double angle); |
| | | |
| | | } |
| | |
| | | |
| | | AgvDetail selectByAgvId(Long agvId); |
| | | |
| | | Boolean updatePosCodeByAgvId(Long agvId, Long codeId); |
| | | |
| | | Boolean updateAngleByAgvId(Long agvId, Double angle); |
| | | |
| | | } |
| | |
| | | return this.getOne(new LambdaQueryWrapper<AgvDetail>().eq(AgvDetail::getAgvId, agvId)); |
| | | } |
| | | |
| | | @Override |
| | | public Boolean updatePosCodeByAgvId(Long agvId, Long codeId) { |
| | | return this.baseMapper.updatePosCodeByAgvId(agvId, codeId) > 0; |
| | | } |
| | | |
| | | @Override |
| | | public Boolean updateAngleByAgvId(Long agvId, Double angle) { |
| | | return this.baseMapper.updateAngleByAgvId(agvId, angle); |
| | | } |
| | | |
| | | } |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.zy.acs.manager.fake.ActionStsMapper"> |
| | | <mapper namespace="com.zy.acs.fake.mapper.ActionStsMapper"> |
| | | |
| | | <!-- 关联查询sql --> |
| | | <sql id="selectSql"> |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.zy.acs.manager.fake.ActionTypeMapper"> |
| | | <mapper namespace="com.zy.acs.fake.mapper.ActionTypeMapper"> |
| | | |
| | | <!-- 关联查询sql --> |
| | | <sql id="selectSql"> |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.zy.acs.manager.fake.AgvDetailMapper"> |
| | | <mapper namespace="com.zy.acs.fake.mapper.AgvDetailMapper"> |
| | | |
| | | <!-- 关联查询sql --> |
| | | <sql id="selectSql"> |
| | |
| | | </where> |
| | | </sql> |
| | | |
| | | <update id="updatePosCode"> |
| | | <update id="updatePosCodeByAgvId"> |
| | | update man_agv_detail |
| | | set code = #{codeId}, |
| | | last_code = null, |
| | | pos = 1 |
| | | where 1=1 |
| | | and id = #{id} |
| | | and agv_id = #{agvId} |
| | | </update> |
| | | |
| | | <update id="updateUnPosCode"> |
| | | <update id="updateAngleByAgvId"> |
| | | update man_agv_detail |
| | | set last_code = #{lastCode}, |
| | | code = null, |
| | | pos = 0 |
| | | set agv_angle = #{angle} |
| | | where 1=1 |
| | | and id = #{id} |
| | | and agv_id = #{agvId} |
| | | </update> |
| | | |
| | | </mapper> |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.zy.acs.manager.fake.AgvMapper"> |
| | | <mapper namespace="com.zy.acs.fake.mapper.AgvMapper"> |
| | | |
| | | </mapper> |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.zy.acs.manager.fake.CodeMapper"> |
| | | <mapper namespace="com.zy.acs.fake.mapper.CodeMapper"> |
| | | |
| | | <!-- 关联查询sql --> |
| | | <sql id="selectSql"> |
| | |
| | | |
| | | List<String> actionGroupIds = actionService.selectPrepareGroup(); |
| | | for (String actionGroupId : actionGroupIds) { |
| | | long startTime = System.currentTimeMillis(); |
| | | mainService.publishAction(actionGroupId); |
| | | log.info("publish action calculation spend {} ms", System.currentTimeMillis() - startTime); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | |
| | | } |
| | | |
| | | private void processAction(Agv agv, Action action) throws InterruptedException { |
| | | AgvDetail agvDetail = agvDetailService.selectByAgvId(agv.getId()); |
| | | if (agvDetail == null) { |
| | | return; |
| | | } |
| | | |
| | | switch (Objects.requireNonNull(ActionTypeType.get(action.getActionTypeEl()))) { |
| | | case TurnCorner: |
| | | simulateWalking(agv, agvDetail, action); |
| | | simulateRotating(agv, agvDetail, action); |
| | | simulateWalking(agv, action); |
| | | simulateRotating(agv, action); |
| | | break; |
| | | case StraightBackUnturnable: |
| | | case StraightBackTurnable: |
| | |
| | | case StraightAheadTurnable: |
| | | case FinishPath: |
| | | case DockingCharge: |
| | | simulateWalking(agv, agvDetail, action); |
| | | simulateWalking(agv, action); |
| | | break; |
| | | case ReadyTakeFromShelvesLoc: |
| | | case ReadyReleaseToShelvesLoc: |
| | |
| | | } |
| | | |
| | | |
| | | private void simulateWalking(Agv agv, AgvDetail agvDetail, Action action) throws InterruptedException { |
| | | private void simulateWalking(Agv agv, Action action) throws InterruptedException { |
| | | Code code = codeService.selectByData(action.getCode()); |
| | | agvDetail.setPos(1); |
| | | agvDetail.setCode(code.getId()); |
| | | // agvDetail.setPos(1); |
| | | // agvDetail.setCode(code.getId()); |
| | | // 模拟电量消耗 |
| | | // agvDetail.setVol(agvDetail.getVol() - 0.1 * distanceToMove); // 根据距离消耗电量 |
| | | |
| | | Thread.sleep(MapDataWsScheduler.WEBSOCKET_BROADCAST_INTERVAL); |
| | | |
| | | agvDetailService.updateById(agvDetail); |
| | | agvDetailService.updatePosCodeByAgvId(agv.getId(), code.getId()); |
| | | // agvDetailService.updateById(agvDetail); |
| | | |
| | | mapService.unlockPath(agv.getUuid(), code.getData()); |
| | | jamService.checkIfFinish(agv.getId(), code.getData()); |
| | |
| | | * 模拟AGV旋转 |
| | | * |
| | | * @param agv 当前AGV |
| | | * @param agvDetail AGV详细信息 |
| | | * @param action 当前动作 |
| | | */ |
| | | private void simulateRotating(Agv agv, AgvDetail agvDetail, Action action) throws InterruptedException { |
| | | private void simulateRotating(Agv agv, Action action) throws InterruptedException { |
| | | double actionAngle = Double.parseDouble(action.getParams()); |
| | | agvDetail.setAgvAngle(actionAngle); |
| | | // agvDetail.setAgvAngle(actionAngle); |
| | | // 模拟电量消耗? |
| | | // agvDetail.setVol(agvDetail.getVol() - 0.05 * (angleToRotate / 15.0)); // 根据角度消耗电量 |
| | | |
| | | Thread.sleep(MapDataWsScheduler.WEBSOCKET_BROADCAST_INTERVAL); |
| | | agvDetailService.updateById(agvDetail); |
| | | agvDetailService.updateAngleByAgvId(agv.getId(), actionAngle); |
| | | action.setActionSts(ActionStsType.FINISH.val()); |
| | | actionService.updateById(action); |
| | | } |
| | |
| | | import com.zy.acs.manager.manager.entity.ActionSts; |
| | | import com.zy.acs.manager.manager.service.ActionStsService; |
| | | |
| | | import java.util.EnumMap; |
| | | import java.util.Map; |
| | | |
| | | public enum ActionStsType { |
| | | |
| | | PREPARE, |
| | |
| | | ActionStsType() { |
| | | } |
| | | |
| | | private static final Map<ActionStsType, Long> cache = new EnumMap<>(ActionStsType.class); |
| | | |
| | | public long val() { |
| | | ActionStsService service = SpringUtils.getBean(ActionStsService.class); |
| | | ActionSts actionSts = service.selectByUuid(this.toString()); |
| | | if (actionSts == null) { |
| | | throw new BusinessException("ActionStsType Error!"); |
| | | } |
| | | return actionSts.getId(); |
| | | return cache.computeIfAbsent(this, key -> { |
| | | ActionStsService service = SpringUtils.getBean(ActionStsService.class); |
| | | ActionSts actionSts = service.selectByUuid(this.toString()); |
| | | if (actionSts == null) { |
| | | throw new BusinessException("ActionStsType Error!"); |
| | | } |
| | | return actionSts.getId(); |
| | | }); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.zy.acs.manager.manager.entity.ActionType; |
| | | import com.zy.acs.manager.manager.service.ActionTypeService; |
| | | |
| | | import java.util.EnumMap; |
| | | import java.util.Map; |
| | | |
| | | public enum ActionTypeType { |
| | | |
| | | TurnCorner("转弯"), // 转弯 |
| | |
| | | } |
| | | public String desc; |
| | | |
| | | private static final Map<ActionTypeType, Long> cache = new EnumMap<>(ActionTypeType.class); |
| | | |
| | | public long val() { |
| | | ActionTypeService service = SpringUtils.getBean(ActionTypeService.class); |
| | | ActionType actionType = service.selectByUuid(this.toString()); |
| | | if (actionType == null) { |
| | | throw new BusinessException("ActionTypeType Error!"); |
| | | } |
| | | return actionType.getId(); |
| | | return cache.computeIfAbsent(this, key -> { |
| | | ActionTypeService service = SpringUtils.getBean(ActionTypeService.class); |
| | | ActionType actionType = service.selectByUuid(this.toString()); |
| | | if (actionType == null) { |
| | | throw new BusinessException("ActionTypeType Error!"); |
| | | } |
| | | return actionType.getId(); |
| | | }); |
| | | } |
| | | |
| | | public static ActionTypeType get(String el) { |
| | |
| | | import com.zy.acs.manager.manager.entity.AgvModel; |
| | | import com.zy.acs.manager.manager.service.AgvModelService; |
| | | |
| | | import java.util.EnumMap; |
| | | import java.util.Map; |
| | | |
| | | public enum AgvModelType { |
| | | |
| | | CTU_BOX_TRANSPORT_AGV, |
| | |
| | | AgvModelType() { |
| | | } |
| | | |
| | | private static final Map<AgvModelType, Long> cache = new EnumMap<>(AgvModelType.class); |
| | | |
| | | public long val() { |
| | | AgvModelService service = SpringUtils.getBean(AgvModelService.class); |
| | | AgvModel agvModel = service.selectByType(this.toString()); |
| | | if (agvModel == null) { |
| | | throw new BusinessException("AgvModelType Error!"); |
| | | } |
| | | return agvModel.getId(); |
| | | return cache.computeIfAbsent(this, key -> { |
| | | AgvModelService service = SpringUtils.getBean(AgvModelService.class); |
| | | AgvModel agvModel = service.selectByType(this.toString()); |
| | | if (agvModel == null) { |
| | | throw new BusinessException("AgvModelType Error!"); |
| | | } |
| | | return agvModel.getId(); |
| | | }); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.zy.acs.manager.manager.entity.AgvSts; |
| | | import com.zy.acs.manager.manager.service.AgvStsService; |
| | | |
| | | import java.util.EnumMap; |
| | | import java.util.Map; |
| | | |
| | | public enum AgvStsType { |
| | | |
| | | IDLE, |
| | |
| | | AgvStsType() { |
| | | } |
| | | |
| | | private static final Map<AgvStsType, Long> cache = new EnumMap<>(AgvStsType.class); |
| | | |
| | | public long val() { |
| | | AgvStsService service = SpringUtils.getBean(AgvStsService.class); |
| | | AgvSts agvSts = service.selectByUuid(this.toString()); |
| | | if (agvSts == null) { |
| | | throw new BusinessException("AgvStsType Error!"); |
| | | } |
| | | return agvSts.getId(); |
| | | return cache.computeIfAbsent(this, key -> { |
| | | AgvStsService service = SpringUtils.getBean(AgvStsService.class); |
| | | AgvSts agvSts = service.selectByUuid(this.toString()); |
| | | if (agvSts == null) { |
| | | throw new BusinessException("AgvStsType Error!"); |
| | | } |
| | | return agvSts.getId(); |
| | | }); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.zy.acs.manager.manager.service.BusStsService; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.EnumMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | public enum BusStsType implements DataFieldSortFunc { |
| | |
| | | this.dataSort = dataSort; |
| | | } |
| | | |
| | | private static final Map<BusStsType, Long> cache = new EnumMap<>(BusStsType.class); |
| | | |
| | | public long val() { |
| | | BusStsService service = SpringUtils.getBean(BusStsService.class); |
| | | BusSts busSts = service.selectByUuid(this.toString()); |
| | | if (busSts == null) { |
| | | throw new BusinessException("BusStsType Error!"); |
| | | } |
| | | return busSts.getId(); |
| | | return cache.computeIfAbsent(this, key -> { |
| | | BusStsService service = SpringUtils.getBean(BusStsService.class); |
| | | BusSts busSts = service.selectByUuid(this.toString()); |
| | | if (busSts == null) { |
| | | throw new BusinessException("BusStsType Error!"); |
| | | } |
| | | return busSts.getId(); |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | |
| | | import com.zy.acs.manager.manager.entity.LocSts; |
| | | import com.zy.acs.manager.manager.service.LocStsService; |
| | | |
| | | import java.util.EnumMap; |
| | | import java.util.Map; |
| | | |
| | | public enum LocStsType { |
| | | |
| | | IDLE, |
| | |
| | | LocStsType() { |
| | | } |
| | | |
| | | private static final Map<LocStsType, Long> cache = new EnumMap<>(LocStsType.class); |
| | | |
| | | public long val() { |
| | | LocStsService service = SpringUtils.getBean(LocStsService.class); |
| | | LocSts locSts = service.selectByUuid(this.toString()); |
| | | if (locSts == null) { |
| | | throw new BusinessException("LocStsType Error!"); |
| | | } |
| | | return locSts.getId(); |
| | | return cache.computeIfAbsent(this, key -> { |
| | | LocStsService service = SpringUtils.getBean(LocStsService.class); |
| | | LocSts locSts = service.selectByUuid(this.toString()); |
| | | if (locSts == null) { |
| | | throw new BusinessException("LocStsType Error!"); |
| | | } |
| | | return locSts.getId(); |
| | | }); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.zy.acs.manager.manager.entity.LocType; |
| | | import com.zy.acs.manager.manager.service.LocTypeService; |
| | | |
| | | import java.util.EnumMap; |
| | | import java.util.Map; |
| | | |
| | | public enum LocTypeType { |
| | | |
| | | ; |
| | |
| | | LocTypeType() { |
| | | } |
| | | |
| | | private static final Map<LocTypeType, Long> cache = new EnumMap<>(LocTypeType.class); |
| | | |
| | | public long val() { |
| | | LocTypeService service = SpringUtils.getBean(LocTypeService.class); |
| | | LocType locType = service.selectByUuid(this.toString()); |
| | | if (locType == null) { |
| | | throw new BusinessException("LocTypeType Error!"); |
| | | } |
| | | return locType.getId(); |
| | | return cache.computeIfAbsent(this, key -> { |
| | | LocTypeService service = SpringUtils.getBean(LocTypeService.class); |
| | | LocType locType = service.selectByUuid(this.toString()); |
| | | if (locType == null) { |
| | | throw new BusinessException("LocTypeType Error!"); |
| | | } |
| | | return locType.getId(); |
| | | }); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.zy.acs.manager.manager.entity.StaSts; |
| | | import com.zy.acs.manager.manager.service.StaStsService; |
| | | |
| | | import java.util.EnumMap; |
| | | import java.util.Map; |
| | | |
| | | public enum StaStsType { |
| | | |
| | | ; |
| | |
| | | StaStsType() { |
| | | } |
| | | |
| | | private static final Map<StaStsType, Long> cache = new EnumMap<>(StaStsType.class); |
| | | |
| | | |
| | | public long val() { |
| | | StaStsService service = SpringUtils.getBean(StaStsService.class); |
| | | StaSts staSts = service.selectByUuid(this.toString()); |
| | | if (staSts == null) { |
| | | throw new BusinessException("StaStsType Error!"); |
| | | } |
| | | return staSts.getId(); |
| | | return cache.computeIfAbsent(this, key -> { |
| | | StaStsService service = SpringUtils.getBean(StaStsService.class); |
| | | StaSts staSts = service.selectByUuid(this.toString()); |
| | | if (staSts == null) { |
| | | throw new BusinessException("StaStsType Error!"); |
| | | } |
| | | return staSts.getId(); |
| | | }); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.zy.acs.manager.manager.entity.StaType; |
| | | import com.zy.acs.manager.manager.service.StaTypeService; |
| | | |
| | | import java.util.EnumMap; |
| | | import java.util.Map; |
| | | |
| | | public enum StaTypeType { |
| | | |
| | | IDLE, |
| | |
| | | StaTypeType() { |
| | | } |
| | | |
| | | private static final Map<StaTypeType, Long> cache = new EnumMap<>(StaTypeType.class); |
| | | |
| | | public long val() { |
| | | StaTypeService service = SpringUtils.getBean(StaTypeService.class); |
| | | StaType staType = service.selectByUuid(this.toString()); |
| | | if (staType == null) { |
| | | throw new BusinessException("StaTypeType Error!"); |
| | | } |
| | | return staType.getId(); |
| | | return cache.computeIfAbsent(this, key -> { |
| | | StaTypeService service = SpringUtils.getBean(StaTypeService.class); |
| | | StaType staType = service.selectByUuid(this.toString()); |
| | | if (staType == null) { |
| | | throw new BusinessException("StaTypeType Error!"); |
| | | } |
| | | return staType.getId(); |
| | | }); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.zy.acs.manager.manager.service.TaskStsService; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.EnumMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | public enum TaskStsType implements DataFieldSortFunc { |
| | |
| | | this.dataSort = dataSort; |
| | | } |
| | | |
| | | private static final Map<TaskStsType, Long> cache = new EnumMap<>(TaskStsType.class); |
| | | |
| | | public long val() { |
| | | TaskStsService service = SpringUtils.getBean(TaskStsService.class); |
| | | TaskSts taskSts = service.selectByUuid(this.toString()); |
| | | if (taskSts == null) { |
| | | throw new BusinessException("TaskStsType Error!"); |
| | | } |
| | | return taskSts.getId(); |
| | | return cache.computeIfAbsent(this, key -> { |
| | | TaskStsService service = SpringUtils.getBean(TaskStsService.class); |
| | | TaskSts taskSts = service.selectByUuid(key.toString()); |
| | | if (taskSts == null) { |
| | | throw new BusinessException("TaskStsType Error for " + key); |
| | | } |
| | | return taskSts.getId(); |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | |
| | | import com.zy.acs.manager.manager.entity.TaskType; |
| | | import com.zy.acs.manager.manager.service.TaskTypeService; |
| | | |
| | | import java.util.EnumMap; |
| | | import java.util.Map; |
| | | |
| | | public enum TaskTypeType { |
| | | |
| | | MOVE, |
| | |
| | | TaskTypeType() { |
| | | } |
| | | |
| | | private static final Map<TaskTypeType, Long> cache = new EnumMap<>(TaskTypeType.class); |
| | | |
| | | public long val() { |
| | | TaskTypeService service = SpringUtils.getBean(TaskTypeService.class); |
| | | TaskType taskType = service.selectByUuid(this.toString()); |
| | | if (taskType == null) { |
| | | throw new BusinessException("TaskTypeType Error!"); |
| | | } |
| | | return taskType.getId(); |
| | | return cache.computeIfAbsent(this, key -> { |
| | | TaskTypeService service = SpringUtils.getBean(TaskTypeService.class); |
| | | TaskType taskType = service.selectByUuid(this.toString()); |
| | | if (taskType == null) { |
| | | throw new BusinessException("TaskTypeType Error!"); |
| | | } |
| | | return taskType.getId(); |
| | | }); |
| | | } |
| | | |
| | | public static TaskTypeType get(String el) { |
| | |
| | | |
| | | int updateUnPosCode(@Param("id") Long id, @Param("lastCode") Long lastCode); |
| | | |
| | | int updatePosCodeByAgvId(@Param("agvId") Long agvId, @Param("codeId") Long codeId); |
| | | |
| | | Boolean updateAngleByAgvId(@Param("agvId") Long agvId, @Param("angle") Double angle); |
| | | |
| | | } |
| | |
| | | |
| | | Boolean updatePosCode(Long id, Long codeId); |
| | | |
| | | Boolean updatePosCodeByAgvId(Long agvId, Long codeId); |
| | | |
| | | Boolean updateUnPosCode(Long id, Long codeId); |
| | | |
| | | Boolean updateAngleByAgvId(Long agvId, Double angle); |
| | | |
| | | Boolean removeByAgvId(Long agvId); |
| | | |
| | | Boolean isPowerLoss(Agv agv, AgvDetail agvDetail, AgvModel agvModel); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Boolean updatePosCodeByAgvId(Long agvId, Long codeId) { |
| | | return this.baseMapper.updatePosCodeByAgvId(agvId, codeId) > 0; |
| | | } |
| | | |
| | | @Override |
| | | public Boolean updateUnPosCode(Long id, Long codeId) { |
| | | return this.baseMapper.updateUnPosCode(id, codeId) > 0; |
| | | } |
| | | |
| | | @Override |
| | | public Boolean updateAngleByAgvId(Long agvId, Double angle) { |
| | | return this.baseMapper.updateAngleByAgvId(agvId, angle); |
| | | } |
| | | |
| | | @Override |
| | | public Boolean removeByAgvId(Long agvId) { |
| | | return baseMapper.delete(new LambdaQueryWrapper<AgvDetail>().eq(AgvDetail::getAgvId, agvId)) > 0; |
| | | } |
| | |
| | | and id = #{id} |
| | | </update> |
| | | |
| | | <update id="updatePosCodeByAgvId"> |
| | | update man_agv_detail |
| | | set code = #{codeId}, |
| | | pos = 1 |
| | | where 1=1 |
| | | and agv_id = #{agvId} |
| | | </update> |
| | | |
| | | <update id="updateAngleByAgvId"> |
| | | update man_agv_detail |
| | | set agv_angle = #{angle} |
| | | where 1=1 |
| | | and agv_id = #{agvId} |
| | | </update> |
| | | |
| | | </mapper> |