| | |
| | | |
| | | import java.text.MessageFormat; |
| | | import java.util.Date; |
| | | import com.zy.asrs.entity.BasCrnpErrLog; |
| | | import com.zy.asrs.service.BasCrnpErrLogService; |
| | | |
| | | /** |
| | | * 堆垛机线程 |
| | |
| | | //更新采集时间 |
| | | crnProtocol.setDeviceDataLog(System.currentTimeMillis()); |
| | | } |
| | | |
| | | try { |
| | | BasCrnpErrLogService errLogService = SpringUtils.getBean(BasCrnpErrLogService.class); |
| | | if (errLogService != null) { |
| | | String errFlagKey = RedisKeyType.DEVICE_ERR_ACTIVE_CRN.key + crnProtocol.getCrnNo(); |
| | | Object active = redisUtil.get(errFlagKey); |
| | | if (crnProtocol.getAlarm() != null && crnProtocol.getAlarm() > 0) { |
| | | if (active == null) { |
| | | BasCrnpErrLog log = new BasCrnpErrLog(); |
| | | log.setWrkNo(crnProtocol.getTaskNo()); |
| | | log.setStartTime(new Date()); |
| | | log.setCrnNo(crnProtocol.getCrnNo()); |
| | | log.setBarcode(crnProtocol.getBarcode()); |
| | | log.setErrCode(crnProtocol.getAlarm()); |
| | | log.setStatus(1); |
| | | log.setCreateTime(new Date()); |
| | | log.setSystemStatus(JSON.toJSONString(crnProtocol)); |
| | | errLogService.insert(log); |
| | | if (log.getId() != null) { |
| | | redisUtil.set(errFlagKey, log.getId(), 60 * 60 * 24); |
| | | } |
| | | } |
| | | } else { |
| | | if (active != null) { |
| | | Long id = Long.valueOf(String.valueOf(active)); |
| | | BasCrnpErrLog update = new BasCrnpErrLog(); |
| | | update.setId(id); |
| | | update.setEndTime(new Date()); |
| | | update.setStatus(2); |
| | | update.setUpdateTime(new Date()); |
| | | errLogService.updateById(update); |
| | | redisUtil.del(errFlagKey); |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception ignore) {} |
| | | } |
| | | |
| | | @Override |