| | |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.BasLift; |
| | | import com.zy.asrs.entity.BasLiftOpt; |
| | | import com.zy.asrs.entity.DeviceDataLog; |
| | | import com.zy.asrs.mapper.WrkMastMapper; |
| | | import com.zy.asrs.service.BasLiftOptService; |
| | | import com.zy.asrs.service.BasLiftService; |
| | | import com.zy.asrs.service.DeviceDataLogService; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.utils.RedisUtil; |
| | | import com.zy.core.News; |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.text.MessageFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 提升机线程 |
| | |
| | | liftProtocol.setErrorCode(siemensS7Net.getByteTransform().TransInt16(result3.Content, 0));//错误码 |
| | | } |
| | | |
| | | if (System.currentTimeMillis() - liftProtocol.getDeviceDataLog() > 1000 * 5) { |
| | | //采集时间超过5s,保存一次数据记录 |
| | | //保存数据记录 |
| | | DeviceDataLogService deviceDataLogService = SpringUtils.getBean(DeviceDataLogService.class); |
| | | DeviceDataLog deviceDataLog = new DeviceDataLog(); |
| | | deviceDataLog.setOriginData(Base64.getEncoder().encodeToString(result1.Content)); |
| | | deviceDataLog.setWcsData(JSON.toJSONString(liftProtocol)); |
| | | deviceDataLog.setType("lift"); |
| | | deviceDataLog.setDeviceNo(liftProtocol.getLiftNo().intValue()); |
| | | deviceDataLog.setCreateTime(new Date()); |
| | | deviceDataLogService.insert(deviceDataLog); |
| | | |
| | | //更新采集时间 |
| | | liftProtocol.setDeviceDataLog(System.currentTimeMillis()); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | OutputQueue.LIFT.offer(MessageFormat.format("【{0}】提升机plc状态信息失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort())); |
| | | } |
| | |
| | | return false; |
| | | } |
| | | |
| | | WrkMastMapper wrkMastMapper = SpringUtils.getBean(WrkMastMapper.class); |
| | | if (wrkNo >= 20000 && wrkNo <= 30000) { |
| | | //提升机设备工作号,需要查询对应任务号 |
| | | BasLiftOptService basLiftOptService = SpringUtils.getBean(BasLiftOptService.class); |
| | | BasLiftOpt basLiftOpt = basLiftOptService.selectByDeviceWrk(liftProtocol.getTaskNo().toString(), liftProtocol.getLiftNo().intValue()); |
| | | if (basLiftOpt != null) { |
| | | wrkNo = basLiftOpt.getWrkNo().shortValue(); |
| | | } |
| | | } |
| | | |
| | | Object o = redisUtil.get(RedisKeyType.LIFT.key + wrkNo); |
| | | if (o == null) { |
| | | return false; |
| | |
| | | liftProtocol.setProtocolStatus(LiftProtocolStatusType.WAITING); |
| | | News.info("提升机任务执行下发完成执行结束,提升机号={},任务数据={}", redisCommand.getLiftNo(), JSON.toJSON(redisCommand)); |
| | | } |
| | | |
| | | } |
| | | |
| | | //取出命令 |