| | |
| | | shuttleProtocol.setStatusSum(jsonObject.getObject("statusSum", NyShuttleProtocol.StatusSumClass.class)); |
| | | //非自动状态时间计时 |
| | | shuttleProtocol.setErrTime(jsonObject.getInteger("errTime")); |
| | | //最近一次在线时间 |
| | | shuttleProtocol.setLastOnlineTime(System.currentTimeMillis()); |
| | | |
| | | //小车处于运行中,将标记置为false |
| | | if (shuttleProtocol.getFree() == 0) { |
| | |
| | | basShuttle.setShuttleNo(slave.getId()); |
| | | shuttleService.insert(basShuttle); |
| | | } |
| | | //工作模式 |
| | | basShuttle.setWorkingMode(shuttleProtocol.getWorkingMode()); |
| | | //运行状态 |
| | | basShuttle.setFree(shuttleProtocol.getFree()); |
| | | //当前速度 |
| | | basShuttle.setSpeed(shuttleProtocol.getSpeed()); |
| | | //负载状态 |
| | | basShuttle.setLoadState(shuttleProtocol.getLoadState()); |
| | | //管制状态 |
| | | basShuttle.setSuspendState(shuttleProtocol.getSuspendState()); |
| | | //顶升位置 |
| | | basShuttle.setLiftPosition(shuttleProtocol.getLiftPosition()); |
| | | //运行方向 |
| | | basShuttle.setRunDir(shuttleProtocol.getRunDir()); |
| | | //运行方向 |
| | | basShuttle.setRunDir2(shuttleProtocol.getRunDir2()); |
| | | //充电状态 |
| | | basShuttle.setChargState(shuttleProtocol.getChargState()); |
| | | //电池电量 |
| | | basShuttle.setPowerPercent(shuttleProtocol.getPowerPercent()); |
| | | //最高电芯电压 |
| | | basShuttle.setMaxCellVoltage(shuttleProtocol.getMaxCellVoltage()); |
| | | //电池电压 |
| | | basShuttle.setVoltage(shuttleProtocol.getVoltage()); |
| | | //充放电循环次数 |
| | | basShuttle.setChargeCycleTimes(shuttleProtocol.getChargeCycleTimes()); |
| | | //剩余电量 |
| | | basShuttle.setSurplusQuantity(shuttleProtocol.getSurplusQuantity()); |
| | | //总电量 |
| | | basShuttle.setCountQuantity(shuttleProtocol.getCountQuantity()); |
| | | //实际库位 |
| | | basShuttle.setPoint(JSONObject.toJSONString(shuttleProtocol.getPoint())); |
| | | //实际坐标 |
| | | basShuttle.setCoord(JSONObject.toJSONString(shuttleProtocol.getCoord())); |
| | | //任务目的库位 |
| | | basShuttle.setTask(JSONObject.toJSONString(shuttleProtocol.getTask())); |
| | | //任务状态 |
| | | basShuttle.setTaskState(shuttleProtocol.getTaskState()); |
| | | //故障状态 |
| | | basShuttle.setErrState(shuttleProtocol.getErrState()); |
| | | //总里程数 |
| | | basShuttle.setStatusSum(JSONObject.toJSONString(shuttleProtocol.getStatusSum())); |
| | | //非自动状态时间计时 |
| | | basShuttle.setErrTime(shuttleProtocol.getErrTime()); |
| | | //任务号 |
| | | basShuttle.setWrkNo(shuttleProtocol.getTaskNo().intValue()); |
| | | //修改时间 |
| | | basShuttle.setUpdateTime(new Date()); |
| | | //作业标记 |
| | | basShuttle.setPakMk(shuttleProtocol.getPakMk()); |
| | | basShuttle.setDeviceStatus(JSON.toJSONString(basShuttle)); |
| | | if (shuttleService.updateById(basShuttle)) { |
| | | OutputQueue.SHUTTLE.offer(MessageFormat.format("【{0}】[id:{1}] <<<<< 实时数据更新成功",DateUtils.convert(new Date()), slave.getId())); |
| | | // log.info(MessageFormat.format("【{0}】[id:{1}] <<<<< 实时数据更新成功",DateUtils.convert(new Date()), slave.getId())); |
| | | } |
| | | // log.warn(JSON.toJSONString(shuttleProtocol));//输出小车状态 |
| | | |
| | | //保存数据记录 |
| | | DeviceDataLogService deviceDataLogService = SpringUtils.getBean(DeviceDataLogService.class); |
| | | DeviceDataLog deviceDataLog = new DeviceDataLog(); |
| | | deviceDataLog.setOriginData(JSON.toJSONString(jsonObject)); |
| | | deviceDataLog.setWcsData(JSON.toJSONString(shuttleProtocol)); |
| | | deviceDataLog.setType("shuttle"); |
| | | deviceDataLog.setDeviceNo(shuttleProtocol.getShuttleNo().intValue()); |
| | | deviceDataLog.setCreateTime(new Date()); |
| | | deviceDataLogService.insert(deviceDataLog); |
| | | if (System.currentTimeMillis() - shuttleProtocol.getDeviceDataLog() > 1000 * 5) { |
| | | //采集时间超过5s,保存一次数据记录 |
| | | //保存数据记录 |
| | | DeviceDataLogService deviceDataLogService = SpringUtils.getBean(DeviceDataLogService.class); |
| | | DeviceDataLog deviceDataLog = new DeviceDataLog(); |
| | | deviceDataLog.setOriginData(JSON.toJSONString(jsonObject)); |
| | | deviceDataLog.setWcsData(JSON.toJSONString(shuttleProtocol)); |
| | | deviceDataLog.setType("shuttle"); |
| | | deviceDataLog.setDeviceNo(shuttleProtocol.getShuttleNo().intValue()); |
| | | deviceDataLog.setCreateTime(new Date()); |
| | | deviceDataLogService.insert(deviceDataLog); |
| | | |
| | | //更新采集时间 |
| | | shuttleProtocol.setDeviceDataLog(System.currentTimeMillis()); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | |
| | | if (!(targetNode.getX() == node.getX() && targetNode.getY() == node.getY())) { |
| | | nodes.remove(nodes.size() - 1);//剔除尾节点 |
| | | } |
| | | boolean result = navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(shuttleProtocol.getCurrentLocNo()), nodes, false);//解锁路径 |
| | | boolean result = navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(shuttleProtocol.getCurrentLocNo()), shuttleProtocol.getShuttleNo().intValue(), nodes, false);//解锁路径 |
| | | if (!result) { |
| | | return false;//解锁失败 |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | }else {//跑库位 |
| | | } else if (shuttleProtocol.getMoveType() == 1) {//跑库位 |
| | | Integer xCurrent = shuttleProtocol.getXCurrent(); |
| | | if (xCurrent > shuttleProtocol.getXTarget()) {//当X值大于X目标值,进行归零且Y方向+1 |
| | | shuttleProtocol.setXCurrent(shuttleProtocol.getXStart()); |
| | |
| | | //调度去目标位置 |
| | | if (shuttleProtocol.getCurrentLocNo().equals(target.getLocNo())) { |
| | | shuttleProtocol.setXCurrent(shuttleProtocol.getXCurrent() + 1);//小车和目标位置一致,跳过 |
| | | }else { |
| | | } else { |
| | | boolean result = shuttleDispatchUtils.dispatchShuttle(commonService.getWorkNo(3), target.getLocNo()); |
| | | if (result) {//调度成功 |
| | | shuttleProtocol.setXCurrent(shuttleProtocol.getXCurrent() + 1); |
| | | } |
| | | } |
| | | } else if (shuttleProtocol.getMoveType() == 2) {//母轨道循环跑 |
| | | Integer xCurrent = shuttleProtocol.getXCurrent(); |
| | | Integer yCurrent = shuttleProtocol.getYCurrent(); |
| | | |
| | | String locNo = Utils.getLocNo(xCurrent, yCurrent, lev); |
| | | //调度去目标位置 |
| | | if (shuttleProtocol.getCurrentLocNo().equals(locNo)) { |
| | | if (yCurrent.equals(shuttleProtocol.getYStart())) { |
| | | shuttleProtocol.setYCurrent(shuttleProtocol.getYTarget());//小车和目标位置一致,切换库位 |
| | | }else { |
| | | shuttleProtocol.setYCurrent(shuttleProtocol.getYStart());//小车和目标位置一致,切换库位 |
| | | } |
| | | } else { |
| | | boolean result = shuttleDispatchUtils.dispatchShuttle(commonService.getWorkNo(3), locNo); |
| | | if (result) {//调度成功 |
| | | if (yCurrent.equals(shuttleProtocol.getYStart())) { |
| | | shuttleProtocol.setYCurrent(shuttleProtocol.getYTarget());//切换库位 |
| | | }else { |
| | | shuttleProtocol.setYCurrent(shuttleProtocol.getYStart());//切换库位 |
| | | } |
| | | } |
| | | } |
| | | } else if (shuttleProtocol.getMoveType() == 3) {//子轨道循环跑 |
| | | Integer xCurrent = shuttleProtocol.getXCurrent(); |
| | | Integer yCurrent = shuttleProtocol.getYCurrent(); |
| | | |
| | | String locNo = Utils.getLocNo(xCurrent, yCurrent, lev); |
| | | //调度去目标位置 |
| | | if (shuttleProtocol.getCurrentLocNo().equals(locNo)) { |
| | | if (xCurrent.equals(shuttleProtocol.getXStart())) { |
| | | shuttleProtocol.setXCurrent(shuttleProtocol.getXTarget());//小车和目标位置一致,切换库位 |
| | | }else { |
| | | shuttleProtocol.setXCurrent(shuttleProtocol.getXStart());//小车和目标位置一致,切换库位 |
| | | } |
| | | } else { |
| | | boolean result = shuttleDispatchUtils.dispatchShuttle(commonService.getWorkNo(3), locNo); |
| | | if (result) {//调度成功 |
| | | if (xCurrent.equals(shuttleProtocol.getXStart())) { |
| | | shuttleProtocol.setXCurrent(shuttleProtocol.getXTarget());//切换库位 |
| | | }else { |
| | | shuttleProtocol.setXCurrent(shuttleProtocol.getXStart());//切换库位 |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |