| | |
| | | />, |
| | | }, |
| | | { |
| | | title: '命令', |
| | | dataIndex: 'command', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | ellipsis: true, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='command' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '系统状态', |
| | | dataIndex: 'systemStatus', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | ellipsis: true, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='systemStatus' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '下发状态', |
| | | dataIndex: 'send$', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <SelectFilter |
| | | name='send' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | data={[ |
| | | { label: '未下发', value: 0 }, |
| | | { label: '已下发', value: 1 }, |
| | | ]} |
| | | />, |
| | | }, |
| | | { |
| | | title: '请求响应', |
| | | dataIndex: 'response', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | ellipsis: true, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='response' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '设备工作号', |
| | | dataIndex: 'deviceWrk', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='deviceWrk' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '起点库位', |
| | | dataIndex: 'sourceLocNo', |
| | | valueType: 'text', |
| | |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='memo' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '命令', |
| | | dataIndex: 'command', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='command' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '系统状态', |
| | | dataIndex: 'systemStatus', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='systemStatus' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '下发状态', |
| | | dataIndex: 'send$', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <SelectFilter |
| | | name='send' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | data={[ |
| | | { label: '未下发', value: 0 }, |
| | | { label: '已下发', value: 1 }, |
| | | ]} |
| | | />, |
| | | }, |
| | | { |
| | | title: '请求响应', |
| | | dataIndex: 'response', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='response' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '设备工作号', |
| | | dataIndex: 'deviceWrk', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='deviceWrk' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | |
| | | import com.zy.asrs.wcs.rcs.News; |
| | | import com.zy.asrs.wcs.rcs.cache.SlaveConnection; |
| | | import com.zy.asrs.wcs.rcs.constant.DeviceRedisConstant; |
| | | import com.zy.asrs.wcs.rcs.entity.BasShuttleOpt; |
| | | import com.zy.asrs.wcs.rcs.entity.Device; |
| | | import com.zy.asrs.wcs.rcs.model.CommandResponse; |
| | | 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.service.BasShuttleOptService; |
| | | import com.zy.asrs.wcs.rcs.thread.ShuttleThread; |
| | | import com.zy.asrs.wcs.system.entity.Dict; |
| | | import com.zy.asrs.wcs.system.service.DictService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.Optional; |
| | | import java.util.*; |
| | | |
| | | @Component |
| | | public class ShuttleAction { |
| | |
| | | private DictService dictService; |
| | | @Autowired |
| | | private ConveyorDispatcher conveyorDispatcher; |
| | | @Autowired |
| | | private BasShuttleOptService basShuttleOptService; |
| | | |
| | | public synchronized boolean assignWork(Device device, ShuttleAssignCommand assignCommand) { |
| | | ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue()); |
| | |
| | | || assignCommand.getTaskMode() == ShuttleTaskModeType.MOVE_LOC_NO.id |
| | | || assignCommand.getTaskMode() == ShuttleTaskModeType.SHUTTLE_MOVE_LOC_NO.id) { |
| | | //下发行驶路径 |
| | | boolean result = shuttleThread.movePath(assignCommand.getNodes(), assignCommand.getDeviceTaskNo()); |
| | | CommandResponse response = shuttleThread.movePath(assignCommand.getNodes(), assignCommand.getDeviceTaskNo()); |
| | | Boolean result = response.getResult(); |
| | | if (!result) { |
| | | return false; |
| | | } |
| | |
| | | ShuttleCommand command = commands.get(commandStep); |
| | | |
| | | // 下发命令 |
| | | if (!write(command, device)) { |
| | | CommandResponse response = write(command, device); |
| | | |
| | | //保存命令日志 |
| | | BasShuttleOpt basShuttleOpt = new BasShuttleOpt(); |
| | | basShuttleOpt.setTaskNo(redisCommand.getTaskNo()); |
| | | basShuttleOpt.setShuttleNo(Integer.parseInt(device.getDeviceNo())); |
| | | |
| | | basShuttleOpt.setMode(ShuttleCommandModeType.get(command.getMode()).desc); |
| | | basShuttleOpt.setSourceLocNo(assignCommand.getSourceLocNo()); |
| | | basShuttleOpt.setDistLocNo(assignCommand.getLocNo()); |
| | | basShuttleOpt.setCommand(JSON.toJSONString(command)); |
| | | basShuttleOpt.setSystemStatus(JSON.toJSONString(shuttleProtocol)); |
| | | basShuttleOpt.setDeviceId(device.getId()); |
| | | basShuttleOpt.setDeviceWrk(String.valueOf(command.getTaskNo())); |
| | | basShuttleOpt.setResponse(response.getMessage());//获取响应 |
| | | basShuttleOpt.setSendTime(new Date());//指令下发时间 |
| | | basShuttleOpt.setSend(response.getResult() ? 1 : 0); |
| | | basShuttleOpt.setHostId(device.getHostId()); |
| | | //保存命令流水 |
| | | basShuttleOptService.save(basShuttleOpt); |
| | | |
| | | if (!response.getResult()) { |
| | | News.error("四向穿梭车命令下发失败,穿梭车号={},任务数据={}", shuttleProtocol.getShuttleNo(), JSON.toJSON(command)); |
| | | return false; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | private synchronized boolean write(ShuttleCommand command, Device device) { |
| | | private synchronized CommandResponse write(ShuttleCommand command, Device device) { |
| | | CommandResponse response = new CommandResponse(false); |
| | | if (null == command) { |
| | | News.error("四向穿梭车写入命令为空"); |
| | | return false; |
| | | response.setMessage("四向穿梭车写入命令为空"); |
| | | return response; |
| | | } |
| | | ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue()); |
| | | boolean result = false; |
| | | if (command.getMode() == ShuttleCommandModeType.MOVE.id |
| | | || command.getMode() == ShuttleCommandModeType.IN_LIFT.id |
| | | || command.getMode() == ShuttleCommandModeType.OUT_LIFT.id) {//移动 |
| | | result = shuttleThread.move(command); |
| | | response = shuttleThread.move(command); |
| | | } else if (command.getMode() == ShuttleCommandModeType.PALLET_LIFT.id |
| | | || command.getMode() == ShuttleCommandModeType.PALLET_DOWN.id) {//顶升 |
| | | result = shuttleThread.lift(command); |
| | | response = shuttleThread.lift(command); |
| | | } else if (command.getMode() == ShuttleCommandModeType.CHARGE_OPEN.id |
| | | || command.getMode() == ShuttleCommandModeType.CHARGE_CLOSE.id) {//充电 |
| | | result = shuttleThread.charge(command); |
| | | response = shuttleThread.charge(command); |
| | | } else if (command.getMode() == ShuttleCommandModeType.RESET.id) {//复位 |
| | | result = shuttleThread.reset(command); |
| | | response = shuttleThread.reset(command); |
| | | } else if (command.getMode() == ShuttleCommandModeType.UPDATE_LOCATION.id) {//更新坐标 |
| | | result = shuttleThread.updateLocation(command); |
| | | response = shuttleThread.updateLocation(command); |
| | | } |
| | | |
| | | News.info("四向穿梭车命令下发,穿梭车号={},任务数据={}", device.getDeviceNo(), JSON.toJSON(command)); |
| | | return result; |
| | | // News.info("四向穿梭车命令下发,穿梭车号={},任务数据={}", device.getDeviceNo(), JSON.toJSON(command)); |
| | | return response; |
| | | } |
| | | |
| | | } |
| | |
| | | this.desc = desc; |
| | | } |
| | | |
| | | public static ShuttleTaskModeType get(Short id) { |
| | | public static ShuttleTaskModeType get(Integer id) { |
| | | if (null == id) { |
| | | return null; |
| | | } |
| | | for (ShuttleTaskModeType type : ShuttleTaskModeType.values()) { |
| | | if (type.id.equals(id.intValue())) { |
| | | if (type.id.equals(id)) { |
| | | return type; |
| | | } |
| | | } |
| | |
| | | private String systemStatus; |
| | | |
| | | /** |
| | | * 下发状态 0: 未下发 1: 已下发 |
| | | * 下发状态 0: 失败 1: 成功 |
| | | */ |
| | | @ApiModelProperty(value= "下发状态 0: 未下发 1: 已下发 ") |
| | | @ApiModelProperty(value= "下发状态 0: 失败 1: 成功 ") |
| | | private Integer send; |
| | | |
| | | /** |
| | |
| | | if (null == this.send){ return null; } |
| | | switch (this.send){ |
| | | case 0: |
| | | return "未下发"; |
| | | return "失败"; |
| | | case 1: |
| | | return "已下发"; |
| | | return "成功"; |
| | | default: |
| | | return String.valueOf(this.send); |
| | | } |
New file |
| | |
| | | package com.zy.asrs.wcs.rcs.model; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class CommandResponse { |
| | | |
| | | private Boolean result; |
| | | |
| | | private String message; |
| | | |
| | | public CommandResponse() { |
| | | } |
| | | |
| | | public CommandResponse(Boolean result) { |
| | | this.result = result; |
| | | } |
| | | |
| | | public CommandResponse(Boolean result, String message) { |
| | | this.result = result; |
| | | this.message = message; |
| | | } |
| | | } |
| | |
| | | import com.zy.asrs.wcs.core.model.command.ShuttleCommand; |
| | | import com.zy.asrs.wcs.core.model.enums.MotionCtgType; |
| | | import com.zy.asrs.wcs.rcs.entity.Device; |
| | | import com.zy.asrs.wcs.rcs.model.CommandResponse; |
| | | import com.zy.asrs.wcs.rcs.model.enums.ShuttleProtocolStatusType; |
| | | import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol; |
| | | |
| | |
| | | |
| | | Device getDevice();//获取设备信息 |
| | | |
| | | boolean movePath(List<NavigateNode> nodes, Integer taskNo);//路径下发 |
| | | CommandResponse movePath(List<NavigateNode> nodes, Integer taskNo);//路径下发 |
| | | |
| | | boolean move(ShuttleCommand command);//移动 |
| | | CommandResponse move(ShuttleCommand command);//移动 |
| | | |
| | | boolean lift(ShuttleCommand command);//顶升 |
| | | CommandResponse lift(ShuttleCommand command);//顶升 |
| | | |
| | | boolean charge(ShuttleCommand command);//充电开关 |
| | | CommandResponse charge(ShuttleCommand command);//充电开关 |
| | | |
| | | boolean reset(ShuttleCommand command);//复位开关 |
| | | CommandResponse reset(ShuttleCommand command);//复位开关 |
| | | |
| | | boolean updateLocation(ShuttleCommand command);//更新坐标 |
| | | CommandResponse updateLocation(ShuttleCommand command);//更新坐标 |
| | | |
| | | boolean isIdle(); |
| | | |
| | |
| | | import com.zy.asrs.wcs.rcs.constant.DeviceRedisConstant; |
| | | import com.zy.asrs.wcs.rcs.entity.Device; |
| | | import com.zy.asrs.wcs.rcs.entity.DeviceDataLog; |
| | | import com.zy.asrs.wcs.rcs.model.CommandResponse; |
| | | import com.zy.asrs.wcs.rcs.model.command.NyShuttleHttpCommand; |
| | | import com.zy.asrs.wcs.rcs.model.enums.ShuttleProtocolStatusType; |
| | | import com.zy.asrs.wcs.rcs.model.enums.SlaveType; |
| | |
| | | |
| | | //小车空闲且有跑库程序 |
| | | shuttleAction.moveLoc(device); |
| | | |
| | | Thread.sleep(200); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public boolean movePath(List<NavigateNode> nodes, Integer taskNo) { |
| | | return true; |
| | | public CommandResponse movePath(List<NavigateNode> nodes, Integer taskNo) { |
| | | CommandResponse response = new CommandResponse(true); |
| | | return response; |
| | | } |
| | | |
| | | @Override |
| | | public boolean move(ShuttleCommand command) { |
| | | public CommandResponse move(ShuttleCommand command) { |
| | | CommandResponse response = new CommandResponse(false); |
| | | try { |
| | | //发出请求 |
| | | NyShuttleHttpCommand httpCommand = JSON.parseObject(command.getBody(), NyShuttleHttpCommand.class); |
| | |
| | | for (NyShuttleHttpCommand requestCommand : commandList) { |
| | | JSONObject result = requestCommand(requestCommand); |
| | | if (result == null) { |
| | | return false;//请求失败 |
| | | return response;//请求失败 |
| | | } |
| | | this.shuttleProtocol.setSendTime(System.currentTimeMillis());//指令下发时间 |
| | | response.setMessage(JSON.toJSONString(result)); |
| | | response.setResult(true); |
| | | } |
| | | return true; |
| | | return response; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return false; |
| | | response.setMessage(e.getMessage()); |
| | | return response; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public boolean lift(ShuttleCommand command) { |
| | | public CommandResponse lift(ShuttleCommand command) { |
| | | CommandResponse response = new CommandResponse(false); |
| | | try { |
| | | //发出请求 |
| | | NyShuttleHttpCommand httpCommand = JSON.parseObject(command.getBody(), NyShuttleHttpCommand.class); |
| | | JSONObject result = requestCommand(httpCommand); |
| | | if (result == null) { |
| | | return false;//请求失败 |
| | | return response;//请求失败 |
| | | } |
| | | this.shuttleProtocol.setSendTime(System.currentTimeMillis());//指令下发时间 |
| | | return true; |
| | | response.setMessage(JSON.toJSONString(result)); |
| | | response.setResult(true); |
| | | return response; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return false; |
| | | return response; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public boolean charge(ShuttleCommand command) { |
| | | public CommandResponse charge(ShuttleCommand command) { |
| | | CommandResponse response = new CommandResponse(false); |
| | | try { |
| | | //发出请求 |
| | | NyShuttleHttpCommand httpCommand = JSON.parseObject(command.getBody(), NyShuttleHttpCommand.class); |
| | | JSONObject result = requestCommand(httpCommand); |
| | | if (result == null) { |
| | | return false;//请求失败 |
| | | return response;//请求失败 |
| | | } |
| | | this.shuttleProtocol.setSendTime(System.currentTimeMillis());//指令下发时间 |
| | | return true; |
| | | response.setMessage(JSON.toJSONString(result)); |
| | | response.setResult(true); |
| | | return response; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return false; |
| | | return response; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public boolean reset(ShuttleCommand command) { |
| | | public CommandResponse reset(ShuttleCommand command) { |
| | | setSyncTaskNo(0); |
| | | setProtocolStatus(ShuttleProtocolStatusType.IDLE); |
| | | enableMoveLoc(null, false); |
| | | return true; |
| | | return new CommandResponse(true, JSON.toJSONString(command)); |
| | | } |
| | | |
| | | @Override |
| | | public boolean updateLocation(ShuttleCommand command) { |
| | | public CommandResponse updateLocation(ShuttleCommand command) { |
| | | CommandResponse response = new CommandResponse(false); |
| | | try { |
| | | //发出请求 |
| | | NyShuttleHttpCommand httpCommand = JSON.parseObject(command.getBody(), NyShuttleHttpCommand.class); |
| | | JSONObject result = requestCommand(httpCommand); |
| | | if (result == null) { |
| | | return false;//请求失败 |
| | | return response;//请求失败 |
| | | } |
| | | this.shuttleProtocol.setSendTime(System.currentTimeMillis());//指令下发时间 |
| | | return true; |
| | | response.setMessage(JSON.toJSONString(result)); |
| | | response.setResult(true); |
| | | return response; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return false; |
| | | return response; |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | ArrayList<HashMap<String, Object>> path = new ArrayList<>(); |
| | | |
| | | Integer taskId = getTaskId(); |
| | | HashMap<String, Object> body = new HashMap<>(); |
| | | body.put("requestType", "move");//移动命令 |
| | | body.put("taskId", getTaskId());//TaskID需要随机 |
| | | body.put("taskId", taskId);//TaskID需要随机 |
| | | // body.put("start", navigateNodeToNyPointNode(NavigatePositionConvert.codeToNode(startCodeNum, device.getHostId())));//起点 |
| | | // body.put("target", navigateNodeToNyPointNode(NavigatePositionConvert.codeToNode(distCodeNum, device.getHostId())));//终点 |
| | | body.put("path", path); |
| | |
| | | command.setBody(JSON.toJSONString(httpStandard)); |
| | | command.setMode(ShuttleCommandModeType.MOVE.id); |
| | | command.setTargetLocNo(loc.getLocNo()); |
| | | command.setTaskNo(taskId); |
| | | return command; |
| | | } |
| | | |
| | |
| | | NyShuttleHttpCommand httpStandard = getHttpStandard(Integer.parseInt(device.getDeviceNo()), taskNo); |
| | | NyShuttleHttpCommand.NyRequest request = httpStandard.getRequest(); |
| | | |
| | | Integer taskId = getTaskId();//TaskID需要随机 |
| | | HashMap<String, Object> body = new HashMap<>(); |
| | | body.put("requestType", lift ? "liftUp" : "liftDown");//顶升或下降命令 |
| | | body.put("taskId", getTaskId());//TaskID需要随机 |
| | | body.put("taskId", taskId); |
| | | request.setBody(body); |
| | | |
| | | httpStandard.setRequest(request); |
| | |
| | | command.setShuttleNo(Integer.parseInt(this.device.getDeviceNo())); |
| | | command.setBody(JSON.toJSONString(httpStandard)); |
| | | command.setMode(lift ? ShuttleCommandModeType.PALLET_LIFT.id : ShuttleCommandModeType.PALLET_DOWN.id); |
| | | command.setTaskNo(taskId); |
| | | return command; |
| | | } |
| | | |
| | |
| | | NyShuttleHttpCommand httpStandard = getHttpStandard(Integer.parseInt(device.getDeviceNo()), taskNo); |
| | | NyShuttleHttpCommand.NyRequest request = httpStandard.getRequest(); |
| | | |
| | | Integer taskId = getTaskId();//TaskID需要随机 |
| | | HashMap<String, Object> body = new HashMap<>(); |
| | | body.put("requestType", charge ? "charge" : "stopCharge");//充电或停止充电 |
| | | body.put("taskId", getTaskId());//TaskID需要随机 |
| | | body.put("taskId", taskId); |
| | | request.setBody(body); |
| | | |
| | | httpStandard.setRequest(request); |
| | |
| | | command.setShuttleNo(Integer.parseInt(this.device.getDeviceNo())); |
| | | command.setBody(JSON.toJSONString(httpStandard)); |
| | | command.setMode(charge ? ShuttleCommandModeType.CHARGE_OPEN.id : ShuttleCommandModeType.CHARGE_CLOSE.id); |
| | | command.setTaskNo(taskId); |
| | | return command; |
| | | } |
| | | |
| | |
| | | command.setShuttleNo(Integer.parseInt(this.device.getDeviceNo())); |
| | | command.setBody(JSON.toJSONString(httpStandard)); |
| | | command.setMode(ShuttleCommandModeType.UPDATE_LOCATION.id); |
| | | command.setTaskNo(taskNo); |
| | | return command; |
| | | } |
| | | |
| | |
| | | command.setShuttleNo(Integer.parseInt(this.device.getDeviceNo())); |
| | | command.setBody(JSON.toJSONString(httpStandard)); |
| | | command.setMode(ShuttleCommandModeType.RESET.id); |
| | | command.setTaskNo(taskNo); |
| | | return command; |
| | | } |
| | | |
| | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }else { |
| | | break; |
| | | } |
| | | } |
| | | return result;//返回Body结果集 |
| | | } |
| | | |
| | |
| | | import com.zy.asrs.wcs.rcs.cache.OutputQueue; |
| | | import com.zy.asrs.wcs.rcs.constant.DeviceRedisConstant; |
| | | import com.zy.asrs.wcs.rcs.entity.DeviceDataLog; |
| | | import com.zy.asrs.wcs.rcs.model.CommandResponse; |
| | | 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; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public synchronized boolean movePath(List<NavigateNode> nodes, Integer taskNo) { |
| | | public synchronized CommandResponse movePath(List<NavigateNode> nodes, Integer taskNo) { |
| | | CommandResponse response = new CommandResponse(false); |
| | | try { |
| | | //默认地图母轨方向x |
| | | String mapDirection = "x"; |
| | |
| | | |
| | | String loginToken = requestLoginToken(); |
| | | if (loginToken == null) { |
| | | return false; |
| | | return response; |
| | | } |
| | | |
| | | HashMap<String, Object> headers = new HashMap<>(); |
| | |
| | | param.put("taskId", taskNo); |
| | | param.put("nodeNum", nodes.size()); |
| | | param.put("modes", modes); |
| | | String response = new HttpHandler.Builder() |
| | | String responseStr = new HttpHandler.Builder() |
| | | .setUri(API_URL) |
| | | .setPath("/RDS/runRoute") |
| | | .setHeaders(headers) |
| | |
| | | .setTimeout(60, TimeUnit.SECONDS) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | JSONObject jsonObject = JSON.parseObject(responseStr); |
| | | Integer code = jsonObject.getInteger("code"); |
| | | System.out.println("路径下发" + taskNo); |
| | | System.out.println(JSON.toJSONString(jsonObject)); |
| | | System.out.println(JSON.toJSONString(param)); |
| | | if (code.equals(200)) { |
| | | System.out.println("路径下发" + taskNo); |
| | | return true; |
| | | response.setResult(true); |
| | | response.setMessage(responseStr); |
| | | return response; |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return false; |
| | | return response; |
| | | } |
| | | |
| | | @Override |
| | | public synchronized boolean move(ShuttleCommand command) { |
| | | public synchronized CommandResponse move(ShuttleCommand command) { |
| | | CommandResponse response = new CommandResponse(false); |
| | | try { |
| | | String loginToken = requestLoginToken(); |
| | | if (loginToken == null) { |
| | | return false; |
| | | return response; |
| | | } |
| | | |
| | | HashMap<String, Object> headers = new HashMap<>(); |
| | | headers.put("Authorization", "Bearer " + loginToken); |
| | | |
| | | String response = new HttpHandler.Builder() |
| | | String responseStr = new HttpHandler.Builder() |
| | | .setUri(API_URL) |
| | | .setPath("/RDS/runOrder") |
| | | .setHeaders(headers) |
| | |
| | | .setTimeout(60, TimeUnit.SECONDS) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | JSONObject jsonObject = JSON.parseObject(responseStr); |
| | | Integer code = jsonObject.getInteger("code"); |
| | | System.out.println(JSON.toJSONString(command.getBody())); |
| | | if (code.equals(200)) { |
| | | this.shuttleProtocol.setSendTime(System.currentTimeMillis());//指令下发时间 |
| | | return true; |
| | | response.setResult(true); |
| | | response.setMessage(responseStr); |
| | | return response; |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return false; |
| | | return response; |
| | | } |
| | | |
| | | @Override |
| | | public synchronized boolean lift(ShuttleCommand command) { |
| | | public synchronized CommandResponse lift(ShuttleCommand command) { |
| | | CommandResponse response = new CommandResponse(false); |
| | | try { |
| | | String loginToken = requestLoginToken(); |
| | | if (loginToken == null) { |
| | | return false; |
| | | return response; |
| | | } |
| | | |
| | | HashMap<String, Object> headers = new HashMap<>(); |
| | | headers.put("Authorization", "Bearer " + loginToken); |
| | | |
| | | String response = new HttpHandler.Builder() |
| | | String responseStr = new HttpHandler.Builder() |
| | | .setUri(API_URL) |
| | | .setPath("/RDS/actionOrder") |
| | | .setHeaders(headers) |
| | |
| | | .setTimeout(60, TimeUnit.SECONDS) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | JSONObject jsonObject = JSON.parseObject(responseStr); |
| | | Integer code = jsonObject.getInteger("code"); |
| | | if (code.equals(200)) { |
| | | this.shuttleProtocol.setSendTime(System.currentTimeMillis());//指令下发时间 |
| | | return true; |
| | | response.setResult(true); |
| | | response.setMessage(responseStr); |
| | | return response; |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return false; |
| | | return response; |
| | | } |
| | | |
| | | @Override |
| | | public synchronized boolean charge(ShuttleCommand command) { |
| | | public synchronized CommandResponse charge(ShuttleCommand command) { |
| | | CommandResponse response = new CommandResponse(false); |
| | | try { |
| | | String loginToken = requestLoginToken(); |
| | | if (loginToken == null) { |
| | | return false; |
| | | return response; |
| | | } |
| | | |
| | | HashMap<String, Object> headers = new HashMap<>(); |
| | | headers.put("Authorization", "Bearer " + loginToken); |
| | | |
| | | String response = new HttpHandler.Builder() |
| | | String responseStr = new HttpHandler.Builder() |
| | | .setUri(API_URL) |
| | | .setPath("/RDS/actionOrder") |
| | | .setHeaders(headers) |
| | |
| | | .setTimeout(60, TimeUnit.SECONDS) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | JSONObject jsonObject = JSON.parseObject(responseStr); |
| | | Integer code = jsonObject.getInteger("code"); |
| | | if (code.equals(200)) { |
| | | this.shuttleProtocol.setSendTime(System.currentTimeMillis());//指令下发时间 |
| | | return true; |
| | | response.setResult(true); |
| | | response.setMessage(responseStr); |
| | | return response; |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return false; |
| | | return response; |
| | | } |
| | | |
| | | @Override |
| | | public synchronized boolean reset(ShuttleCommand command) { |
| | | public synchronized CommandResponse reset(ShuttleCommand command) { |
| | | setSyncTaskNo(0); |
| | | setProtocolStatus(ShuttleProtocolStatusType.IDLE); |
| | | enableMoveLoc(null, false); |
| | | return true; |
| | | return new CommandResponse(true, JSON.toJSONString(command)); |
| | | } |
| | | |
| | | @Override |
| | | public boolean updateLocation(ShuttleCommand command) { |
| | | public CommandResponse updateLocation(ShuttleCommand command) { |
| | | CommandResponse response = new CommandResponse(false); |
| | | try { |
| | | String loginToken = requestLoginToken(); |
| | | if (loginToken == null) { |
| | | return false; |
| | | return response; |
| | | } |
| | | |
| | | HashMap<String, Object> headers = new HashMap<>(); |
| | | headers.put("Authorization", "Bearer " + loginToken); |
| | | |
| | | String response = new HttpHandler.Builder() |
| | | String responseStr = new HttpHandler.Builder() |
| | | .setUri(API_URL) |
| | | .setPath("/RDS/changeLocation") |
| | | .setHeaders(headers) |
| | |
| | | .setTimeout(60, TimeUnit.SECONDS) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | JSONObject jsonObject = JSON.parseObject(responseStr); |
| | | Integer code = jsonObject.getInteger("code"); |
| | | if (code.equals(200)) { |
| | | this.shuttleProtocol.setSendTime(System.currentTimeMillis());//指令下发时间 |
| | | return true; |
| | | response.setResult(true); |
| | | response.setMessage(responseStr); |
| | | return response; |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return false; |
| | | return response; |
| | | } |
| | | |
| | | @Override |
| | |
| | | command.setBody(JSON.toJSONString(body)); |
| | | command.setMode(ShuttleCommandModeType.MOVE.id); |
| | | command.setTargetLocNo(loc.getLocNo()); |
| | | command.setTaskNo(taskNo); |
| | | return command; |
| | | } |
| | | |
| | |
| | | command.setShuttleNo(Integer.parseInt(this.device.getDeviceNo())); |
| | | command.setBody(JSON.toJSONString(body)); |
| | | command.setMode(lift ? ShuttleCommandModeType.PALLET_LIFT.id : ShuttleCommandModeType.PALLET_DOWN.id); |
| | | command.setTaskNo(taskNo); |
| | | return command; |
| | | } |
| | | |
| | |
| | | command.setShuttleNo(Integer.parseInt(this.device.getDeviceNo())); |
| | | command.setBody(JSON.toJSONString(body)); |
| | | command.setMode(charge ? ShuttleCommandModeType.CHARGE_OPEN.id : ShuttleCommandModeType.CHARGE_CLOSE.id); |
| | | command.setTaskNo(taskNo); |
| | | return command; |
| | | } |
| | | |
| | |
| | | command.setShuttleNo(Integer.parseInt(this.device.getDeviceNo())); |
| | | command.setBody(JSON.toJSONString(body)); |
| | | command.setMode(ShuttleCommandModeType.UPDATE_LOCATION.id); |
| | | command.setTaskNo(taskNo); |
| | | return command; |
| | | } |
| | | |