|  |  | 
 |  |  | import com.zy.common.utils.RedisUtil; | 
 |  |  | import com.zy.core.News; | 
 |  |  | import com.zy.core.action.ForkLiftAction; | 
 |  |  | import com.zy.core.action.ShuttleAction; | 
 |  |  | import com.zy.core.cache.OutputQueue; | 
 |  |  | import com.zy.core.enums.ForkLiftIoModeType; | 
 |  |  | import com.zy.core.enums.ForkLiftProtocolStatusType; | 
 |  |  | 
 |  |  | import lombok.extern.slf4j.Slf4j; | 
 |  |  |  | 
 |  |  | import java.text.MessageFormat; | 
 |  |  | import java.util.*; | 
 |  |  | import java.util.ArrayList; | 
 |  |  | import java.util.Base64; | 
 |  |  | import java.util.Date; | 
 |  |  | import java.util.List; | 
 |  |  |  | 
 |  |  | @Slf4j | 
 |  |  | @SuppressWarnings("all") | 
 |  |  | 
 |  |  |         siemensS7Net.setRack(slave.getRack().byteValue()); | 
 |  |  |         siemensS7Net.setSlot(slave.getSlot().byteValue()); | 
 |  |  |         OperateResult connect = siemensS7Net.ConnectServer(); | 
 |  |  |         if(connect.IsSuccess){ | 
 |  |  |         if (connect.IsSuccess) { | 
 |  |  |             result = true; | 
 |  |  |             OutputQueue.FORKLIFT.offer(MessageFormat.format( "【{0}】货叉提升机连接成功 ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot())); | 
 |  |  |             OutputQueue.FORKLIFT.offer(MessageFormat.format("【{0}】货叉提升机连接成功 ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot())); | 
 |  |  |             News.info("货叉提升机连接成功 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); | 
 |  |  |         } else { | 
 |  |  |             OutputQueue.FORKLIFT.offer(MessageFormat.format( "【{0}】货叉提升机连接失败!!! ===>> [id:{1}] [ip:{2}] [port:{3}]  [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot())); | 
 |  |  |             OutputQueue.FORKLIFT.offer(MessageFormat.format("【{0}】货叉提升机连接失败!!! ===>> [id:{1}] [ip:{2}] [port:{3}]  [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot())); | 
 |  |  |             News.error("货叉提升机连接失败!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); | 
 |  |  |         } | 
 |  |  |         // siemensS7Net.ConnectClose(); | 
 |  |  | 
 |  |  |                 InnerForkLiftExtend forkLiftExtend = (InnerForkLiftExtend) forkLiftProtocol.getExtend(); | 
 |  |  |                 forkLiftProtocol.setExtend(forkLiftExtend); | 
 |  |  |  | 
 |  |  |             }else { | 
 |  |  |             } else { | 
 |  |  |                 OutputQueue.FORKLIFT.offer(MessageFormat.format("【{0}】{1}读取货叉提升机状态信息失败", DateUtils.convert(new Date()), slave.getId())); | 
 |  |  |             } | 
 |  |  |  | 
 |  |  | 
 |  |  |             //设备状态 | 
 |  |  |             basLift.setDeviceStatus(JSON.toJSONString(forkLiftProtocol)); | 
 |  |  |             if (basLiftService.updateById(basLift)) { | 
 |  |  |                 OutputQueue.FORKLIFT.offer(MessageFormat.format("【{0}】[id:{1}] <<<<< 实时数据更新成功",DateUtils.convert(new Date()), forkLiftProtocol.getLiftNo())); | 
 |  |  |                 OutputQueue.FORKLIFT.offer(MessageFormat.format("【{0}】[id:{1}] <<<<< 实时数据更新成功", DateUtils.convert(new Date()), forkLiftProtocol.getLiftNo())); | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |         } catch (Exception e) { | 
 |  |  | 
 |  |  |         if (this.forkLiftProtocol.getTaskNo() == null | 
 |  |  |                 || this.forkLiftProtocol.getProtocolStatus() == null | 
 |  |  |                 || this.forkLiftProtocol.getModel() == null | 
 |  |  |                 || this.forkLiftProtocol.getErrorCode() == null | 
 |  |  |         ) { | 
 |  |  |             return false; | 
 |  |  |         } | 
 |  |  | 
 |  |  |         boolean res = this.forkLiftProtocol.getProtocolStatus() == ForkLiftProtocolStatusType.IDLE.id | 
 |  |  |                 && this.forkLiftProtocol.getWrkNo() == 0 | 
 |  |  |                 && this.forkLiftProtocol.getTaskNo() == 0 | 
 |  |  |                 && this.forkLiftProtocol.getModel() == 2; | 
 |  |  |                 && this.forkLiftProtocol.getModel() == 2 | 
 |  |  |                 && this.forkLiftProtocol.getErrorCode() == 0; | 
 |  |  |         return res; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |         if (this.forkLiftProtocol.getTaskNo() == null | 
 |  |  |                 || this.forkLiftProtocol.getProtocolStatus() == null | 
 |  |  |                 || this.forkLiftProtocol.getModel() == null | 
 |  |  |                 || this.forkLiftProtocol.getErrorCode() == null | 
 |  |  |         ) { | 
 |  |  |             return false; | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         boolean res = this.forkLiftProtocol.getProtocolStatus() == ForkLiftProtocolStatusType.IDLE.id | 
 |  |  |                 && this.forkLiftProtocol.getWrkNo() == 0 | 
 |  |  |                 && this.forkLiftProtocol.getModel() == 2; | 
 |  |  |                 && this.forkLiftProtocol.getModel() == 2 | 
 |  |  |                 && this.forkLiftProtocol.getErrorCode() == 0; | 
 |  |  |         return res; | 
 |  |  |     } | 
 |  |  |  |