Merge branch 'Four-Way-Rack' of http://47.97.1.152:5880/r/zy-asrs-master into Four-Way-Rack
Conflicts:
zy-asrs-wcs/src/main/resources/application.yml
New file |
| | |
| | | package com.zy.asrs.wcs.common; |
| | | |
| | | public interface ExecuteSupport { |
| | | |
| | | Boolean judgement(); |
| | | |
| | | } |
| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.asrs.wcs.common.ExecuteSupport; |
| | | import com.zy.asrs.wcs.core.entity.BasShuttle; |
| | | import com.zy.asrs.wcs.core.entity.Loc; |
| | | import com.zy.asrs.wcs.core.entity.Task; |
| | |
| | | import com.zy.asrs.wcs.core.model.command.ShuttleCommand; |
| | | import com.zy.asrs.wcs.core.model.command.ShuttleRedisCommand; |
| | | import com.zy.asrs.wcs.core.model.enums.ShuttleCommandModeType; |
| | | import com.zy.asrs.wcs.core.model.enums.ShuttleTaskModeType; |
| | | import com.zy.asrs.wcs.core.service.BasShuttleService; |
| | | import com.zy.asrs.wcs.core.service.LocService; |
| | | import com.zy.asrs.wcs.core.utils.NavigateMapUtils; |
| | |
| | | redisCommand.setAssignCommand(assignCommand);//命令 |
| | | //任务数据保存到redis |
| | | if (redisUtil.set(DeviceRedisConstant.SHUTTLE_WORK_FLAG + assignCommand.getTaskNo(), JSON.toJSONString(redisCommand))) { |
| | | //下发行驶路径 |
| | | boolean result = shuttleThread.movePath(assignCommand.getNodes(), assignCommand.getTaskNo().intValue()); |
| | | if (!result) { |
| | | return false; |
| | | if (assignCommand.getTaskMode() == ShuttleTaskModeType.PAK_IN.id |
| | | || assignCommand.getTaskMode() == ShuttleTaskModeType.PAK_OUT.id |
| | | || assignCommand.getTaskMode() == ShuttleTaskModeType.MOVE_LOC_NO.id |
| | | || assignCommand.getTaskMode() == ShuttleTaskModeType.SHUTTLE_MOVE_LOC_NO.id) { |
| | | //下发行驶路径 |
| | | boolean result = shuttleThread.movePath(assignCommand.getNodes(), assignCommand.getTaskNo()); |
| | | if (!result) { |
| | | return false; |
| | | } |
| | | } |
| | | shuttleProtocol.setTaskNo(assignCommand.getTaskNo().intValue()); |
| | | shuttleProtocol.setTaskNo(assignCommand.getTaskNo()); |
| | | return true; |
| | | } |
| | | return false; |
| | |
| | | } |
| | | |
| | | //判断设备是否空闲 |
| | | if (!shuttleThread.isIdle()) { |
| | | if (!shuttleThread.isIdle(() -> { |
| | | return shuttleProtocol.getTaskNo().equals(taskNo); |
| | | })) { |
| | | return false; |
| | | } |
| | | |
| | |
| | | import com.zy.asrs.wcs.core.entity.Task; |
| | | import com.zy.asrs.wcs.core.entity.TaskCtg; |
| | | import com.zy.asrs.wcs.core.kernel.AnalyzeService; |
| | | import com.zy.asrs.wcs.core.model.enums.DeviceCtgType; |
| | | import com.zy.asrs.wcs.core.model.enums.TaskStsType; |
| | | import com.zy.asrs.wcs.core.service.BasShuttleService; |
| | | import com.zy.asrs.wcs.core.service.MotionService; |
| | |
| | | import com.zy.asrs.wcs.rcs.model.enums.SlaveType; |
| | | import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceService; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceTypeService; |
| | | import com.zy.asrs.wcs.rcs.thread.ShuttleThread; |
| | | import com.zy.asrs.wcs.system.controller.BaseController; |
| | | import com.zy.asrs.wcs.utils.ExcelUtil; |
| | |
| | | private MotionService motionService; |
| | | @Autowired |
| | | private DeviceService deviceService; |
| | | @Autowired |
| | | private DeviceTypeService deviceTypeService; |
| | | |
| | | @PreAuthorize("hasAuthority('core:basShuttle:list')") |
| | | @PostMapping("/basShuttle/page") |
| | |
| | | @PostMapping("/basShuttle/moveLoc") |
| | | @Transactional |
| | | public synchronized R shuttleMoveLoc(@RequestBody ShuttleMoveLocParam param) { |
| | | DeviceType deviceType = deviceTypeService.getOne(new LambdaQueryWrapper<DeviceType>() |
| | | .eq(DeviceType::getFlag, String.valueOf(SlaveType.Shuttle)) |
| | | .eq(DeviceType::getStatus, 1) |
| | | .eq(DeviceType::getHostId, getHostId())); |
| | | if (deviceType == null) { |
| | | return R.error(); |
| | | } |
| | | |
| | | Device device = deviceService.getOne(new LambdaQueryWrapper<Device>() |
| | | .eq(Device::getDeviceType, deviceType.getId()) |
| | | .eq(Device::getDeviceType, DeviceCtgType.SHUTTLE.val()) |
| | | .eq(Device::getStatus, 1) |
| | | .eq(Device::getHostId, getHostId()) |
| | | .eq(Device::getDeviceNo, param.getShuttleNo())); |
| | |
| | | |
| | | import com.zy.asrs.wcs.core.BuildSupport; |
| | | import com.zy.asrs.wcs.core.model.enums.MotionStsType; |
| | | import com.zy.asrs.wcs.core.service.DeviceCtgService; |
| | | import com.zy.asrs.wcs.core.service.MotionCtgService; |
| | | import com.zy.asrs.wcs.core.service.MotionStsService; |
| | | import com.zy.asrs.wcs.rcs.entity.DeviceType; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceTypeService; |
| | | import com.zy.asrs.wcs.system.entity.Host; |
| | | import com.zy.asrs.wcs.system.entity.User; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | |
| | | } |
| | | |
| | | public String getDeviceType$(){ |
| | | DeviceCtgService service = SpringUtils.getBean(DeviceCtgService.class); |
| | | DeviceCtg deviceCtg = service.getById(this.deviceCtg); |
| | | DeviceTypeService service = SpringUtils.getBean(DeviceTypeService.class); |
| | | DeviceType deviceCtg = service.getById(this.deviceCtg); |
| | | if (!Cools.isEmpty(deviceCtg)){ |
| | | return String.valueOf(deviceCtg.getName()); |
| | | } |
| | |
| | | } |
| | | |
| | | public String getDeviceCtgEl(){ |
| | | DeviceCtgService service = SpringUtils.getBean(DeviceCtgService.class); |
| | | DeviceCtg entity = service.getById(this.deviceCtg); |
| | | DeviceTypeService service = SpringUtils.getBean(DeviceTypeService.class); |
| | | DeviceType entity = service.getById(this.deviceCtg); |
| | | if (!Cools.isEmpty(entity)){ |
| | | return String.valueOf(entity.getFlag()); |
| | | } |
| | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | |
| | | import com.zy.asrs.wcs.core.entity.DeviceCtg; |
| | | import com.zy.asrs.wcs.core.service.DeviceCtgService; |
| | | import com.zy.asrs.wcs.rcs.entity.DeviceType; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceTypeService; |
| | | import com.zy.asrs.wcs.system.entity.Host; |
| | | import com.zy.asrs.wcs.system.entity.User; |
| | |
| | | // ); |
| | | |
| | | public String getDeviceCtg$(){ |
| | | DeviceCtgService service = SpringUtils.getBean(DeviceCtgService.class); |
| | | DeviceCtg deviceCtg = service.getById(this.deviceCtg); |
| | | DeviceTypeService service = SpringUtils.getBean(DeviceTypeService.class); |
| | | DeviceType deviceCtg = service.getById(this.deviceCtg); |
| | | if (!Cools.isEmpty(deviceCtg)){ |
| | | return String.valueOf(deviceCtg.getId()); |
| | | } |
| | |
| | | import com.zy.asrs.wcs.rcs.cache.SlaveConnection; |
| | | import com.zy.asrs.wcs.core.entity.Motion; |
| | | import com.zy.asrs.wcs.rcs.entity.Device; |
| | | import com.zy.asrs.wcs.rcs.entity.DeviceType; |
| | | import com.zy.asrs.wcs.rcs.model.enums.SlaveType; |
| | | import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol; |
| | | import com.zy.asrs.wcs.core.service.MotionService; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceService; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceTypeService; |
| | | import com.zy.asrs.wcs.rcs.thread.ShuttleThread; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | private ShuttleDispatcher shuttleDispatcher; |
| | | @Autowired |
| | | private LiftDispatcher liftDispatcher; |
| | | // @Autowired |
| | | // @Autowired |
| | | // private ConveyorDispatcher conveyorDispatcher; |
| | | @Autowired |
| | | private DeviceService deviceService; |
| | | @Autowired |
| | | private DeviceTypeService deviceTypeService; |
| | | |
| | | public List<Motion> generateMotion(Task task) { |
| | | List<Motion> motionList = new ArrayList<>(); |
| | |
| | | // locNo |
| | | String locNo = task.getDestLoc(); |
| | | |
| | | //获取穿梭车类型 |
| | | DeviceType deviceType = deviceTypeService.getOne(new LambdaQueryWrapper<DeviceType>() |
| | | .eq(DeviceType::getFlag, String.valueOf(SlaveType.Shuttle)) |
| | | .eq(DeviceType::getStatus, 1)); |
| | | if (deviceType == null) { |
| | | return motionList; |
| | | } |
| | | |
| | | Device device = deviceService.getOne(new LambdaQueryWrapper<Device>() |
| | | .eq(Device::getDeviceNo, task.getShuttleNo()) |
| | | .eq(Device::getDeviceType, deviceType.getId()) |
| | | .eq(Device::getDeviceType, DeviceCtgType.SHUTTLE.val()) |
| | | .eq(Device::getHostId, task.getHostId()) |
| | | .eq(Device::getStatus, 1)); |
| | | if (device == null) { |
| | |
| | | String targetLoc = task.getDestLoc();//任务目标(借用字段) |
| | | String targetSite = task.getDestSite();//任务类型(借用字段) |
| | | |
| | | //获取穿梭车类型 |
| | | DeviceType deviceType = deviceTypeService.getOne(new LambdaQueryWrapper<DeviceType>() |
| | | .eq(DeviceType::getFlag, String.valueOf(SlaveType.Shuttle)) |
| | | .eq(DeviceType::getStatus, 1)); |
| | | if (deviceType == null) { |
| | | return motionList; |
| | | } |
| | | |
| | | Device device = deviceService.getOne(new LambdaQueryWrapper<Device>() |
| | | .eq(Device::getDeviceNo, task.getShuttleNo()) |
| | | .eq(Device::getDeviceType, deviceType.getId()) |
| | | .eq(Device::getDeviceType, DeviceCtgType.SHUTTLE.val()) |
| | | .eq(Device::getHostId, task.getHostId()) |
| | | .eq(Device::getStatus, 1)); |
| | | if (device == null) { |
| | |
| | | // 穿梭车走行至目标库位 |
| | | motionList.addAll(kernelService.shuttleMove( |
| | | MotionDto.build((dto -> { |
| | | dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue()); |
| | | dto.setShuttleNo(device.getId().intValue()); |
| | | dto.setLocNo(shuttleLocNo); |
| | | })), |
| | | MotionDto.build((dto -> { |
| | | dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue()); |
| | | dto.setShuttleNo(device.getId().intValue()); |
| | | dto.setLocNo(targetLoc); |
| | | })), |
| | | MotionCtgType.SHUTTLE_MOVE |
| | |
| | | //托盘顶升 |
| | | motionList.add(Motion.build(motion -> { |
| | | motion.setDeviceCtg(DeviceCtgType.SHUTTLE.val()); |
| | | motion.setDevice(String.valueOf(task.getShuttleNo())); |
| | | motion.setDevice(String.valueOf(device.getId())); |
| | | motion.setMotionCtg(MotionCtgType.SHUTTLE_PALLET_LIFT.val()); |
| | | })); |
| | | } else if (targetSite.equals("palletDown")) { |
| | | //托盘下降 |
| | | motionList.add(Motion.build(motion -> { |
| | | motion.setDeviceCtg(DeviceCtgType.SHUTTLE.val()); |
| | | motion.setDevice(String.valueOf(task.getShuttleNo())); |
| | | motion.setDevice(String.valueOf(device.getId())); |
| | | motion.setMotionCtg(MotionCtgType.SHUTTLE_PALLET_DOWN.val()); |
| | | })); |
| | | } else if (targetSite.equals("chargeOpen")) { |
| | | //充电开 |
| | | motionList.add(Motion.build(motion -> { |
| | | motion.setDeviceCtg(DeviceCtgType.SHUTTLE.val()); |
| | | motion.setDevice(String.valueOf(task.getShuttleNo())); |
| | | motion.setDevice(String.valueOf(device.getId())); |
| | | motion.setMotionCtg(MotionCtgType.SHUTTLE_CHARGE_ON.val()); |
| | | })); |
| | | } else if (targetSite.equals("chargeClose")) { |
| | | //充电关 |
| | | motionList.add(Motion.build(motion -> { |
| | | motion.setDeviceCtg(DeviceCtgType.SHUTTLE.val()); |
| | | motion.setDevice(String.valueOf(task.getShuttleNo())); |
| | | motion.setDevice(String.valueOf(device.getId())); |
| | | motion.setMotionCtg(MotionCtgType.SHUTTLE_CHARGE_OFF.val()); |
| | | })); |
| | | } else if (targetSite.equals("reset")) { |
| | |
| | | return true; |
| | | } |
| | | |
| | | if (!shuttleProtocol.getProtocolStatusType().equals(ShuttleProtocolStatusType.WAITING) |
| | | && !shuttleProtocol.getProtocolStatusType().equals(ShuttleProtocolStatusType.CHARGING_WAITING) |
| | | ) { |
| | | return false; |
| | | } |
| | | // if (!shuttleProtocol.getProtocolStatusType().equals(ShuttleProtocolStatusType.WAITING) |
| | | // && !shuttleProtocol.getProtocolStatusType().equals(ShuttleProtocolStatusType.CHARGING_WAITING) |
| | | // ) { |
| | | // return false; |
| | | // } |
| | | |
| | | //判断设备是否空闲 |
| | | if (!shuttleThread.isIdle()) { |
| | |
| | | package com.zy.asrs.wcs.core.model; |
| | | |
| | | import com.zy.asrs.wcs.rcs.model.protocol.StaProtocol; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 地图数据节点 |
| | | */ |
| | | @Data |
| | | public class MapNode { |
| | | public class MapNode implements Cloneable { |
| | | |
| | | /** |
| | | * -1 禁用 |
| | |
| | | |
| | | private Integer bay; |
| | | |
| | | @Override |
| | | public MapNode clone() { |
| | | try { |
| | | return (MapNode) super.clone(); |
| | | } catch (CloneNotSupportedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | import com.zy.asrs.framework.common.SpringUtils; |
| | | import com.zy.asrs.framework.exception.CoolException; |
| | | import com.zy.asrs.wcs.core.entity.DeviceCtg; |
| | | import com.zy.asrs.wcs.core.service.DeviceCtgService; |
| | | import com.zy.asrs.wcs.rcs.entity.DeviceType; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceTypeService; |
| | | |
| | | public enum DeviceCtgType { |
| | | |
| | |
| | | } |
| | | |
| | | public long val() { |
| | | DeviceCtgService service = SpringUtils.getBean(DeviceCtgService.class); |
| | | DeviceCtg entity = service.selectByFlag(this.toString()); |
| | | DeviceTypeService service = SpringUtils.getBean(DeviceTypeService.class); |
| | | DeviceType entity = service.selectByFlag(this.toString()); |
| | | if (entity == null) { |
| | | throw new CoolException("DeviceCtgType Error!"); |
| | | } |
| | |
| | | import com.zy.asrs.wcs.rcs.cache.SlaveConnection; |
| | | import com.zy.asrs.wcs.rcs.constant.DeviceRedisConstant; |
| | | import com.zy.asrs.wcs.rcs.entity.Device; |
| | | import com.zy.asrs.wcs.rcs.entity.DeviceType; |
| | | import com.zy.asrs.wcs.rcs.model.enums.ShuttleProtocolStatusType; |
| | | import com.zy.asrs.wcs.rcs.model.enums.SlaveType; |
| | | import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol; |
| | | import com.zy.asrs.wcs.rcs.model.protocol.StaProtocol; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceService; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceTypeService; |
| | | import com.zy.asrs.wcs.rcs.thread.DevpThread; |
| | | import com.zy.asrs.wcs.rcs.thread.ShuttleThread; |
| | | import com.zy.asrs.wcs.system.entity.Dict; |
| | |
| | | private MotionService motionService; |
| | | @Autowired |
| | | private DeviceService deviceService; |
| | | @Autowired |
| | | private DeviceTypeService deviceTypeService; |
| | | @Autowired |
| | | private LocCtgService locCtgService; |
| | | @Autowired |
| | |
| | | ArrayList<MapNode> nodes = new ArrayList<>(); |
| | | for (JSONObject object : entry.getValue()) { |
| | | MapNode mapNode = new MapNode(); |
| | | mapNode.setValue(object.getInteger("value")); |
| | | mapNode.setValue(object.getInteger("shelfType")); |
| | | mapNode.setTop(object.getInteger("top")); |
| | | mapNode.setBottom(object.getInteger("bottom")); |
| | | mapNode.setLeft(object.getInteger("left")); |
| | |
| | | |
| | | for (Map.Entry<Integer, ArrayList<ArrayList<MapNode>>> entry : levData.entrySet()) { |
| | | ArrayList<ArrayList<MapNode>> lists = entry.getValue();//获取地图 |
| | | |
| | | MapNode mapNode = new MapNode(); |
| | | mapNode.setValue(-1); |
| | | mapNode.setTop(1000); |
| | | mapNode.setBottom(1000); |
| | | mapNode.setLeft(1000); |
| | | mapNode.setRight(1000); |
| | | mapNode.setRow(0); |
| | | mapNode.setBay(0); |
| | | mapNode.setNo("0-0"); |
| | | |
| | | //获取最长row |
| | | int row = 0; |
| | | //给每个row首尾增加-1节点 |
| | | for (ArrayList<MapNode> list : lists) { |
| | | if (list.size() > row) { |
| | | row = list.size(); |
| | | } |
| | | |
| | | list.add(0, mapNode.clone()); |
| | | list.add(mapNode.clone()); |
| | | } |
| | | |
| | | ArrayList<MapNode> headNodes = new ArrayList<>(); |
| | | ArrayList<MapNode> footerNodes = new ArrayList<>(); |
| | | for (int i = 0; i < row+2; i++) { |
| | | headNodes.add(mapNode.clone()); |
| | | footerNodes.add(mapNode.clone()); |
| | | } |
| | | |
| | | lists.add(0, headNodes); |
| | | lists.add(footerNodes); |
| | | |
| | | Integer lev = entry.getKey(); |
| | | Date now = new Date(); |
| | |
| | | return; |
| | | } |
| | | |
| | | DeviceType deviceType = deviceTypeService.getOne(new LambdaQueryWrapper<DeviceType>() |
| | | .eq(DeviceType::getFlag, String.valueOf(SlaveType.Shuttle)) |
| | | .eq(DeviceType::getStatus, 1)); |
| | | if (deviceType == null) { |
| | | return; |
| | | } |
| | | |
| | | List<Device> list = deviceService.list(new LambdaQueryWrapper<Device>() |
| | | .eq(Device::getDeviceType, deviceType.getId()) |
| | | .eq(Device::getDeviceType, DeviceCtgType.SHUTTLE.val()) |
| | | .eq(Device::getStatus, 1)); |
| | | for (Device device : list) { |
| | | //获取四向穿梭车线程 |
| | |
| | | } |
| | | |
| | | if (!shuttleProtocol.getProtocolStatusType().equals(ShuttleProtocolStatusType.IDLE)) { |
| | | continue; |
| | | } |
| | | |
| | | if (!shuttleThread.isRequireCharge()) { |
| | | continue; |
| | | } |
| | | |
| | |
| | | return; |
| | | } |
| | | |
| | | DeviceType deviceType = deviceTypeService.getOne(new LambdaQueryWrapper<DeviceType>() |
| | | .eq(DeviceType::getFlag, String.valueOf(SlaveType.Shuttle)) |
| | | .eq(DeviceType::getStatus, 1)); |
| | | if (deviceType == null) { |
| | | return; |
| | | } |
| | | |
| | | List<Device> list = deviceService.list(new LambdaQueryWrapper<Device>() |
| | | .eq(Device::getDeviceType, deviceType.getId()) |
| | | .eq(Device::getDeviceType, DeviceCtgType.SHUTTLE.val()) |
| | | .eq(Device::getStatus, 1)); |
| | | for (Device device : list) { |
| | | //获取四向穿梭车线程 |
| | |
| | | import com.zy.asrs.framework.exception.CoolException; |
| | | import com.zy.asrs.wcs.core.model.enums.DeviceCtgType; |
| | | import com.zy.asrs.wcs.core.model.enums.MotionStsType; |
| | | import com.zy.asrs.wcs.core.service.DeviceCtgService; |
| | | import com.zy.asrs.wcs.core.mapper.MotionMapper; |
| | | import com.zy.asrs.wcs.core.entity.Motion; |
| | | import com.zy.asrs.wcs.core.service.MotionService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.zy.asrs.wcs.core.service.MotionStsService; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceTypeService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | public class MotionServiceImpl extends ServiceImpl<MotionMapper, Motion> implements MotionService { |
| | | |
| | | @Autowired |
| | | private DeviceCtgService deviceCtgService; |
| | | private DeviceTypeService deviceTypeService; |
| | | @Autowired |
| | | private MotionStsService motionStsService; |
| | | |
| | |
| | | public List<Motion> selectUnCompleteByUuidAndDeviceCtg(String uuid, DeviceCtgType deviceCtgType) { |
| | | return this.list(new LambdaQueryWrapper<Motion>() |
| | | .eq(Motion::getUuid, uuid) |
| | | .eq(Motion::getDeviceCtg, deviceCtgService.selectByFlag(deviceCtgType.toString()).getId()) |
| | | .eq(Motion::getDeviceCtg, deviceTypeService.selectByFlag(deviceCtgType.toString()).getId()) |
| | | .lt(Motion::getMotionSts, motionStsService.selectByFlag(MotionStsType.COMPLETE.toString()).getId()) |
| | | .orderByDesc(Motion::getPriority) |
| | | ); |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.asrs.wcs.core.action.LiftAction; |
| | | import com.zy.asrs.wcs.core.action.ShuttleAction; |
| | | import com.zy.asrs.wcs.core.model.enums.DeviceCtgType; |
| | | import com.zy.asrs.wcs.core.utils.RedisUtil; |
| | | import com.zy.asrs.wcs.rcs.cache.SlaveConnection; |
| | | import com.zy.asrs.wcs.rcs.constant.DeviceRedisConstant; |
| | | import com.zy.asrs.wcs.rcs.entity.Device; |
| | | import com.zy.asrs.wcs.rcs.entity.DeviceType; |
| | | import com.zy.asrs.wcs.rcs.model.enums.SlaveType; |
| | | import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceService; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceTypeService; |
| | | import com.zy.asrs.wcs.rcs.thread.ShuttleThread; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | |
| | | @Autowired |
| | | private DeviceService deviceService; |
| | | @Autowired |
| | | private DeviceTypeService deviceTypeService; |
| | | @Autowired |
| | | private ShuttleAction shuttleAction; |
| | | @Autowired |
| | | private LiftAction liftAction; |
| | | |
| | | @Scheduled(cron = "0/1 * * * * ? ") |
| | | public synchronized void executeShuttle() { |
| | | DeviceType deviceType = deviceTypeService.getOne(new LambdaQueryWrapper<DeviceType>() |
| | | .eq(DeviceType::getFlag, String.valueOf(SlaveType.Shuttle)) |
| | | .eq(DeviceType::getStatus, 1)); |
| | | if (deviceType == null) { |
| | | return; |
| | | } |
| | | |
| | | List<Device> list = deviceService.list(new LambdaQueryWrapper<Device>() |
| | | .eq(Device::getStatus, 1) |
| | | .eq(Device::getDeviceType, deviceType.getId())); |
| | | .eq(Device::getDeviceType, DeviceCtgType.SHUTTLE.val())); |
| | | for (Device device : list) { |
| | | //小车空闲且有跑库程序 |
| | | shuttleAction.moveLoc(device); |
| | |
| | | |
| | | @Scheduled(cron = "0/1 * * * * ? ") |
| | | public synchronized void executeLift() { |
| | | DeviceType deviceType = deviceTypeService.getOne(new LambdaQueryWrapper<DeviceType>() |
| | | .eq(DeviceType::getFlag, String.valueOf(SlaveType.Lift)) |
| | | .eq(DeviceType::getStatus, 1)); |
| | | if (deviceType == null) { |
| | | return; |
| | | } |
| | | |
| | | List<Device> list = deviceService.list(new LambdaQueryWrapper<Device>() |
| | | .eq(Device::getStatus, 1) |
| | | .eq(Device::getDeviceType, deviceType.getId())); |
| | | .eq(Device::getDeviceType, DeviceCtgType.LIFT.val())); |
| | | for (Device device : list) { |
| | | Object object = redisUtil.get(DeviceRedisConstant.LIFT_FLAG + device.getDeviceNo()); |
| | | if (object == null) { |
| | |
| | | import com.zy.asrs.wcs.core.entity.TaskCtg; |
| | | import com.zy.asrs.wcs.core.kernel.AnalyzeService; |
| | | import com.zy.asrs.wcs.core.model.NavigateNode; |
| | | import com.zy.asrs.wcs.core.model.enums.DeviceCtgType; |
| | | import com.zy.asrs.wcs.core.model.enums.LiftCodeType; |
| | | import com.zy.asrs.wcs.core.model.enums.NavigationMapType; |
| | | import com.zy.asrs.wcs.core.model.enums.TaskStsType; |
| | |
| | | import com.zy.asrs.wcs.rcs.News; |
| | | import com.zy.asrs.wcs.rcs.cache.SlaveConnection; |
| | | import com.zy.asrs.wcs.rcs.entity.Device; |
| | | import com.zy.asrs.wcs.rcs.entity.DeviceType; |
| | | import com.zy.asrs.wcs.rcs.model.enums.SlaveType; |
| | | import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceService; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceTypeService; |
| | | import com.zy.asrs.wcs.core.service.MotionService; |
| | | import com.zy.asrs.wcs.rcs.thread.ShuttleThread; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | private LiftDispatcher liftDispatcher; |
| | | @Autowired |
| | | private SnowflakeIdWorker snowflakeIdWorker; |
| | | // @Autowired |
| | | // private CommonService commonService; |
| | | @Autowired |
| | | private AnalyzeService analyzeService; |
| | | @Autowired |
| | | private MotionService motionService; |
| | | @Autowired |
| | | private DeviceService deviceService; |
| | | @Autowired |
| | | private DeviceTypeService deviceTypeService; |
| | | @Autowired |
| | | private BasShuttleService basShuttleService; |
| | | @Autowired |
| | |
| | | ShuttleThread resThread = null; |
| | | Integer finalDistance = ShuttleDispatcher.INF; |
| | | |
| | | DeviceType deviceType = deviceTypeService.getOne(new LambdaQueryWrapper<DeviceType>() |
| | | .eq(DeviceType::getHostId, task.getHostId()) |
| | | .eq(DeviceType::getStatus, 1) |
| | | .eq(DeviceType::getFlag, String.valueOf(SlaveType.Shuttle))); |
| | | if (deviceType == null) { |
| | | throw new CoolException("设备类型不存在"); |
| | | } |
| | | |
| | | List<Device> list = deviceService.list(new LambdaQueryWrapper<Device>() |
| | | .eq(Device::getDeviceType, deviceType.getId()) |
| | | .eq(Device::getDeviceType, DeviceCtgType.SHUTTLE.val()) |
| | | .eq(Device::getHostId, task.getHostId()) |
| | | .eq(Device::getStatus, 1)); |
| | | |
| | |
| | | import com.zy.asrs.framework.exception.CoolException; |
| | | import com.zy.asrs.wcs.core.entity.Task; |
| | | import com.zy.asrs.wcs.core.entity.TaskSerialNo; |
| | | import com.zy.asrs.wcs.core.model.enums.DeviceCtgType; |
| | | import com.zy.asrs.wcs.core.service.TaskSerialNoService; |
| | | import com.zy.asrs.wcs.core.service.TaskService; |
| | | import com.zy.asrs.wcs.rcs.cache.SlaveConnection; |
| | | import com.zy.asrs.wcs.rcs.entity.Device; |
| | | import com.zy.asrs.wcs.rcs.entity.DeviceType; |
| | | import com.zy.asrs.wcs.rcs.model.enums.SlaveType; |
| | | import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceService; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceTypeService; |
| | | import com.zy.asrs.wcs.rcs.thread.ShuttleThread; |
| | | |
| | | import java.util.ArrayList; |
| | |
| | | } |
| | | |
| | | public static boolean hasShuttleInLoc(String locNo, Long deviceId) { |
| | | DeviceTypeService deviceTypeService = SpringUtils.getBean(DeviceTypeService.class); |
| | | DeviceService deviceService = SpringUtils.getBean(DeviceService.class); |
| | | |
| | | DeviceType deviceType = deviceTypeService.getOne(new LambdaQueryWrapper<DeviceType>() |
| | | .eq(DeviceType::getFlag, String.valueOf(SlaveType.Shuttle)) |
| | | .eq(DeviceType::getStatus, 1)); |
| | | if (deviceType == null) { |
| | | return false; |
| | | } |
| | | |
| | | List<Device> list = deviceService.list(new LambdaQueryWrapper<Device>() |
| | | .eq(Device::getDeviceType, deviceType.getId()) |
| | | .eq(Device::getDeviceType, DeviceCtgType.SHUTTLE.val()) |
| | | .eq(Device::getStatus, 1)); |
| | | |
| | | for (Device device : list) { |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.asrs.framework.common.R; |
| | | import com.zy.asrs.wcs.core.model.enums.DeviceCtgType; |
| | | import com.zy.asrs.wcs.rcs.cache.SlaveConnection; |
| | | import com.zy.asrs.wcs.rcs.entity.Device; |
| | | import com.zy.asrs.wcs.rcs.entity.DeviceType; |
| | | import com.zy.asrs.wcs.rcs.model.enums.SlaveType; |
| | | import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceService; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceTypeService; |
| | | import com.zy.asrs.wcs.rcs.thread.LiftThread; |
| | | import com.zy.asrs.wcs.system.controller.BaseController; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | @Autowired |
| | | private DeviceService deviceService; |
| | | @Autowired |
| | | private DeviceTypeService deviceTypeService; |
| | | |
| | | @GetMapping("/lift/status/list") |
| | | public R getLiftStatusList() { |
| | | DeviceType deviceType = deviceTypeService.getOne(new LambdaQueryWrapper<DeviceType>() |
| | | .eq(DeviceType::getHostId, getHostId()) |
| | | .eq(DeviceType::getStatus, 1) |
| | | .eq(DeviceType::getFlag, String.valueOf(SlaveType.Lift))); |
| | | if (deviceType == null) { |
| | | return R.error("设备类型不存在"); |
| | | } |
| | | |
| | | ArrayList<LiftProtocol> data = new ArrayList<>(); |
| | | List<Device> list = deviceService.list(new LambdaQueryWrapper<Device>() |
| | | .eq(Device::getHostId, getHostId()) |
| | | .eq(Device::getStatus, 1) |
| | | .eq(Device::getDeviceType, deviceType.getId())); |
| | | .eq(Device::getDeviceType, DeviceCtgType.LIFT.val())); |
| | | for (Device device : list) { |
| | | LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, device.getId().intValue()); |
| | | LiftProtocol status = liftThread.getStatus(); |
| | |
| | | |
| | | @GetMapping("/lift/status/one/{deviceNo}") |
| | | public R getLiftStatus(@PathVariable String deviceNo) { |
| | | DeviceType deviceType = deviceTypeService.getOne(new LambdaQueryWrapper<DeviceType>() |
| | | .eq(DeviceType::getHostId, getHostId()) |
| | | .eq(DeviceType::getStatus, 1) |
| | | .eq(DeviceType::getFlag, String.valueOf(SlaveType.Lift))); |
| | | if (deviceType == null) { |
| | | return R.error("设备类型不存在"); |
| | | } |
| | | |
| | | Device device = deviceService.getOne(new LambdaQueryWrapper<Device>() |
| | | .eq(Device::getHostId, getHostId()) |
| | | .eq(Device::getStatus, 1) |
| | | .eq(Device::getDeviceType, deviceType.getId()) |
| | | .eq(Device::getDeviceType, DeviceCtgType.LIFT.val()) |
| | | .eq(Device::getDeviceNo, deviceNo)); |
| | | |
| | | LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, device.getId().intValue()); |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.asrs.framework.common.R; |
| | | import com.zy.asrs.wcs.core.model.enums.DeviceCtgType; |
| | | import com.zy.asrs.wcs.rcs.cache.SlaveConnection; |
| | | import com.zy.asrs.wcs.rcs.entity.Device; |
| | | import com.zy.asrs.wcs.rcs.entity.DeviceType; |
| | | import com.zy.asrs.wcs.rcs.model.enums.SlaveType; |
| | | import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceService; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceTypeService; |
| | | import com.zy.asrs.wcs.rcs.service.ShuttleService; |
| | | import com.zy.asrs.wcs.rcs.thread.ShuttleThread; |
| | | import com.zy.asrs.wcs.system.controller.BaseController; |
| | |
| | | @Autowired |
| | | private DeviceService deviceService; |
| | | @Autowired |
| | | private DeviceTypeService deviceTypeService; |
| | | @Autowired |
| | | private ShuttleService shuttleService; |
| | | |
| | | @GetMapping("/shuttle/status/list") |
| | |
| | | |
| | | @GetMapping("/shuttle/status/one/{deviceNo}") |
| | | public R getShuttleStatus(@PathVariable String deviceNo) { |
| | | DeviceType deviceType = deviceTypeService.getOne(new LambdaQueryWrapper<DeviceType>() |
| | | .eq(DeviceType::getHostId, getHostId()) |
| | | .eq(DeviceType::getStatus, 1) |
| | | .eq(DeviceType::getFlag, String.valueOf(SlaveType.Shuttle))); |
| | | if (deviceType == null) { |
| | | return R.error("设备类型不存在"); |
| | | } |
| | | |
| | | Device device = deviceService.getOne(new LambdaQueryWrapper<Device>() |
| | | .eq(Device::getHostId, getHostId()) |
| | | .eq(Device::getStatus, 1) |
| | | .eq(Device::getDeviceType, deviceType.getId()) |
| | | .eq(Device::getDeviceType, DeviceCtgType.SHUTTLE.val()) |
| | | .eq(Device::getDeviceNo, deviceNo)); |
| | | |
| | | ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue()); |
| | |
| | | |
| | | public interface DeviceTypeService extends IService<DeviceType> { |
| | | |
| | | DeviceType selectByFlag(String flag); |
| | | |
| | | } |
| | |
| | | package com.zy.asrs.wcs.rcs.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.asrs.wcs.rcs.mapper.DeviceTypeMapper; |
| | | import com.zy.asrs.wcs.rcs.entity.DeviceType; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceTypeService; |
| | |
| | | @Service("deviceTypeService") |
| | | public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceType> implements DeviceTypeService { |
| | | |
| | | @Override |
| | | public DeviceType selectByFlag(String flag) { |
| | | return this.getOne(new LambdaQueryWrapper<DeviceType>().eq(DeviceType::getFlag, flag)); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.asrs.framework.common.R; |
| | | import com.zy.asrs.framework.exception.CoolException; |
| | | import com.zy.asrs.wcs.core.model.enums.DeviceCtgType; |
| | | import com.zy.asrs.wcs.rcs.cache.SlaveConnection; |
| | | import com.zy.asrs.wcs.rcs.entity.Device; |
| | | import com.zy.asrs.wcs.rcs.entity.DeviceType; |
| | | import com.zy.asrs.wcs.rcs.model.enums.SlaveType; |
| | | import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceService; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceTypeService; |
| | | import com.zy.asrs.wcs.rcs.service.ShuttleService; |
| | | import com.zy.asrs.wcs.rcs.thread.ShuttleThread; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | @Autowired |
| | | private DeviceService deviceService; |
| | | @Autowired |
| | | private DeviceTypeService deviceTypeService; |
| | | |
| | | @Override |
| | | public List<ShuttleProtocol> getShuttleStatusList(Long hostId) { |
| | | DeviceType deviceType = deviceTypeService.getOne(new LambdaQueryWrapper<DeviceType>() |
| | | .eq(DeviceType::getHostId, hostId) |
| | | .eq(DeviceType::getStatus, 1) |
| | | .eq(DeviceType::getFlag, String.valueOf(SlaveType.Shuttle))); |
| | | if (deviceType == null) { |
| | | throw new CoolException("设备类型不存在"); |
| | | } |
| | | |
| | | ArrayList<ShuttleProtocol> data = new ArrayList<>(); |
| | | List<Device> list = deviceService.list(new LambdaQueryWrapper<Device>() |
| | | .eq(Device::getHostId, hostId) |
| | | .eq(Device::getStatus, 1) |
| | | .eq(Device::getDeviceType, deviceType.getId())); |
| | | .eq(Device::getDeviceType, DeviceCtgType.SHUTTLE.val())); |
| | | for (Device device : list) { |
| | | ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue()); |
| | | ShuttleProtocol status = shuttleThread.getStatus(); |
| | |
| | | package com.zy.asrs.wcs.rcs.thread; |
| | | |
| | | import com.zy.asrs.wcs.common.ExecuteSupport; |
| | | import com.zy.asrs.wcs.core.model.NavigateNode; |
| | | import com.zy.asrs.wcs.core.model.command.ShuttleCommand; |
| | | import com.zy.asrs.wcs.rcs.entity.Device; |
| | |
| | | |
| | | boolean reset(ShuttleCommand command);//复位开关 |
| | | |
| | | boolean isIdle();//是否空闲 |
| | | boolean isIdle(); |
| | | |
| | | boolean isIdle(ExecuteSupport support);//是否空闲 |
| | | |
| | | boolean isRequireCharge();//是否满足充电状态 |
| | | |
| | |
| | | import com.zy.asrs.framework.common.DateUtils; |
| | | import com.zy.asrs.framework.common.SpringUtils; |
| | | import com.zy.asrs.framework.exception.CoolException; |
| | | import com.zy.asrs.wcs.common.ExecuteSupport; |
| | | import com.zy.asrs.wcs.core.entity.BasShuttle; |
| | | import com.zy.asrs.wcs.core.entity.Loc; |
| | | import com.zy.asrs.wcs.core.model.NavigateNode; |
| | |
| | | shuttleProtocol.setCurrentCode(data.getString("groundCode") == null ? "0" : data.getString("groundCode")); |
| | | //电池电量 |
| | | shuttleProtocol.setBatteryPower(data.getString("battery") == null ? "0%" : data.getString("battery")); |
| | | |
| | | //故障 |
| | | shuttleProtocol.setErrorCode(deviceStatus == 6 ? "1" : "0"); |
| | | |
| | | //是否顶升 |
| | | shuttleProtocol.setHasLift(data.getInteger("palletStatus") == 1 ? true : false); |
| | |
| | | |
| | | @Override |
| | | public boolean isIdle() { |
| | | return this.isIdle(null); |
| | | } |
| | | |
| | | @Override |
| | | public boolean isIdle(ExecuteSupport support) { |
| | | if (null != support) { |
| | | if (!support.judgement()) { |
| | | return false; |
| | | } |
| | | } |
| | | if (this.shuttleProtocol.getIdle() == null |
| | | || this.shuttleProtocol.getPakMk() == null |
| | | || this.shuttleProtocol.getErrorCode() == null |
| | | || this.shuttleProtocol.getProtocolStatus() == null |
| | | || this.shuttleProtocol.getTaskNo() == null |
| | | ) { |
| | | return false; |
| | | } |
| | |
| | | && this.shuttleProtocol.getPakMk() |
| | | && this.shuttleProtocol.getErrorCode().equals("0") |
| | | && this.shuttleProtocol.getProtocolStatus() == ShuttleProtocolStatusType.IDLE.id |
| | | && this.shuttleProtocol.getTaskNo() == 0 |
| | | ; |
| | | return res; |
| | | } |
| | |
| | | # url: jdbc:mysql://47.97.1.152:3306/asrs?useUnicode=trKue&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai |
| | | # username: root |
| | | # password: zy@123 |
| | | url: jdbc:mysql://192.168.2.95:3306/asrs?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai |
| | | url: jdbc:mysql://127.0.0.1:3306/asrs?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai |
| | | username: root |
| | | password: root |
| | | password: xltys1995 |
| | | # driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver |
| | | # url: jdbc:sqlserver://47.97.1.152:51433;databasename=jkasrs |
| | | # username: sa |