| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.SpringUtils; |
| | | import com.zy.asrs.entity.BasLift; |
| | | import com.zy.asrs.entity.DeviceConfig; |
| | | import com.zy.asrs.entity.DeviceDataLog; |
| | | import com.zy.asrs.service.BasLiftService; |
| | | import com.zy.asrs.service.DeviceDataLogService; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.ExecuteSupport; |
| | |
| | | liftProtocol.setHasTray(data.getInteger("hasTray") == 1); |
| | | //有小车 |
| | | liftProtocol.setHasCar(data.getInteger("hasCar") == 1); |
| | | //出入库模式 |
| | | liftProtocol.setIOMode(data.getInteger("iOMode")); |
| | | //故障码 |
| | | liftProtocol.setErrorCode(data.getInteger("errorCode")); |
| | | //当前层 |
| | |
| | | |
| | | this.realtimeOriginData = JSON.toJSONString(data); |
| | | |
| | | if (System.currentTimeMillis() - liftProtocol.getDeviceDataLog() > 1000 * 5) { |
| | | if (System.currentTimeMillis() - liftProtocol.getDeviceDataLog() > 1000 * 2) { |
| | | //采集时间超过5s,保存一次数据记录 |
| | | //保存数据记录 |
| | | DeviceDataLogService deviceDataLogService = SpringUtils.getBean(DeviceDataLogService.class); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public CommandResponse switchIOMode(LiftCommand command) { |
| | | CommandResponse response = new CommandResponse(false); |
| | | try { |
| | | //发出请求 |
| | | String resultKey = requestCommand(command); |
| | | //查询请求结果 |
| | | JSONObject result = queryCommandStatus(resultKey); |
| | | if (result == null) { |
| | | return response;//请求失败 |
| | | } |
| | | if(!result.getString("result").equals("success")) { |
| | | return response;//请求失败 |
| | | } |
| | | |
| | | this.liftProtocol.setSendTime(System.currentTimeMillis());//指令下发时间 |
| | | response.setMessage(JSON.toJSONString(result)); |
| | | response.setResult(true); |
| | | return response; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | response.setMessage(e.getMessage()); |
| | | return response; |
| | | } |
| | | public CommandResponse switchIOMode(LiftIoModeType type) { |
| | | CommandResponse response = new CommandResponse(true); |
| | | liftProtocol.setIOMode(type); |
| | | return response; |
| | | } |
| | | |
| | | @Override |
| | |
| | | || this.liftProtocol.getPlcTaskNo() == null |
| | | || this.liftProtocol.getProtocolStatus() == null |
| | | || this.liftProtocol.getModel() == null |
| | | || this.liftProtocol.getDeviceStatus() == null |
| | | || this.liftProtocol.getErrorCode() == null |
| | | || this.liftProtocol.getExtend() == null |
| | | ) { |
| | |
| | | // && this.liftProtocol.getPlcTaskNo() == 0 |
| | | && this.liftProtocol.getTaskNo() == 0 |
| | | && this.liftProtocol.getModel() == 2 |
| | | && this.liftProtocol.getDeviceStatus() == LiftDeviceStatusType.IDLE.id |
| | | && this.liftProtocol.getErrorCode() == 0 |
| | | && !extend.getFrontOverrun() |
| | | && !extend.getBackOverrun() |
| | |
| | | |
| | | if (this.liftProtocol.getProtocolStatus() == null |
| | | || this.liftProtocol.getModel() == null |
| | | || this.liftProtocol.getDeviceStatus() == null |
| | | || this.liftProtocol.getErrorCode() == null |
| | | || this.liftProtocol.getExtend() == null |
| | | ) { |
| | |
| | | |
| | | boolean res = this.liftProtocol.getProtocolStatus() == LiftProtocolStatusType.IDLE.id |
| | | && this.liftProtocol.getModel() == 2 |
| | | && this.liftProtocol.getDeviceStatus() == LiftDeviceStatusType.IDLE.id |
| | | && this.liftProtocol.getErrorCode() == 0 |
| | | && !extend.getFrontOverrun() |
| | | && !extend.getBackOverrun() |
| | |
| | | command.setPick(pick); |
| | | command.setPut(put); |
| | | |
| | | LiftStaProtocol pickSta = findSta(pick); |
| | | LiftStaProtocol putSta = findSta(put); |
| | | command.setPickLev(pickSta.getLev()); |
| | | command.setPutLev(putSta.getLev()); |
| | | return command; |
| | | } |
| | | |
| | |
| | | command.setPick(pick); |
| | | command.setPut(put); |
| | | |
| | | LiftStaProtocol pickSta = findSta(pick); |
| | | LiftStaProtocol putSta = findSta(put); |
| | | command.setPickLev(pickSta.getLev()); |
| | | command.setPutLev(putSta.getLev()); |
| | | return command; |
| | | } |
| | | |
| | |
| | | command.setPick(pick); |
| | | command.setPut(put); |
| | | |
| | | LiftStaProtocol pickSta = findSta(pick); |
| | | LiftStaProtocol putSta = findSta(put); |
| | | command.setPickLev(pickSta.getLev()); |
| | | command.setPutLev(putSta.getLev()); |
| | | return command; |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | private LiftStaProtocol findSta(Integer staNo) { |
| | | for (LiftStaProtocol liftStaProtocol : this.liftStaProtocols) { |
| | | if (liftStaProtocol.getSiteId().equals(staNo)) { |
| | | return liftStaProtocol; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 扩展字段 |
| | | */ |