| | |
| | | |
| | | import java.text.MessageFormat; |
| | | import java.util.Date; |
| | | import com.zy.asrs.entity.BasCrnpErrLog; |
| | | import com.zy.asrs.service.BasCrnpErrLogService; |
| | | |
| | | /** |
| | | * 堆垛机线程 |
| | |
| | | crnProtocol.setWalkPos(0); |
| | | crnProtocol.setLoaded(0); |
| | | crnProtocol.setAlarm(0); |
| | | crnProtocol.setXSpeed(0); |
| | | crnProtocol.setYSpeed(0); |
| | | crnProtocol.setZSpeed(0); |
| | | crnProtocol.setXDistance(0); |
| | | crnProtocol.setYDistance(0); |
| | | crnProtocol.setXDuration(0); |
| | | crnProtocol.setYDuration(0); |
| | | crnProtocol.setXSpeed(0D); |
| | | crnProtocol.setYSpeed(0D); |
| | | crnProtocol.setZSpeed(0D); |
| | | crnProtocol.setXDistance(0D); |
| | | crnProtocol.setYDistance(0D); |
| | | crnProtocol.setXDuration(0D); |
| | | crnProtocol.setYDuration(0D); |
| | | |
| | | BasCrnpService basCrnpService = null; |
| | | try { |
| | | basCrnpService = SpringUtils.getBean(BasCrnpService.class); |
| | | }catch (Exception e){ |
| | | |
| | | } |
| | | if (basCrnpService != null) { |
| | | BasCrnp basCrnp = basCrnpService.selectOne(new EntityWrapper<BasCrnp>().eq("crn_no", deviceConfig.getDeviceNo())); |
| | | if(basCrnp == null) { |
| | | basCrnp = new BasCrnp(); |
| | | basCrnp.setCrnNo(deviceConfig.getDeviceNo()); |
| | | basCrnp.setStatus(1); |
| | | basCrnp.setInEnable("N"); |
| | | basCrnp.setOutEnable("N"); |
| | | basCrnp.setMaxInTask(5); |
| | | basCrnp.setMaxOutTask(5); |
| | | basCrnp.setCreateTime(new Date()); |
| | | basCrnpService.insert(basCrnp); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | OutputQueue.CRN.offer(MessageFormat.format("【{0}】[id:{1}] <<<<< 实时数据更新成功",DateUtils.convert(new Date()), deviceConfig.getDeviceNo())); |
| | | |
| | | // // 复位信号 |
| | | // if (!Cools.isEmpty(crnProtocol.getStatusType()) && crnProtocol.getStatusType().equals(CrnStatusType.WAITING)) { |
| | | // if (resetFlag) { |
| | | // if(crnProtocol.getTaskNo()==9999){ |
| | | // backHpFlag = false; |
| | | // } |
| | | // CrnCommand crnCommand = new CrnCommand(); |
| | | // crnCommand.setAckFinish((short)1); |
| | | // if (write(crnCommand)) { |
| | | // resetFlag = false; |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | if (crnProtocol.getAlarm() > 0) { |
| | | crnProtocol.setLastCommandTime(-1L); |
| | | } |
| | |
| | | //更新采集时间 |
| | | crnProtocol.setDeviceDataLog(System.currentTimeMillis()); |
| | | } |
| | | |
| | | BasCrnpService basCrnpService = null; |
| | | |
| | | try { |
| | | basCrnpService = SpringUtils.getBean(BasCrnpService.class); |
| | | }catch (Exception e){ |
| | | |
| | | } |
| | | if (basCrnpService != null) { |
| | | BasCrnp basCrnp = basCrnpService.selectOne(new EntityWrapper<BasCrnp>().eq("crn_no", deviceConfig.getDeviceNo())); |
| | | if(basCrnp == null) { |
| | | basCrnp = new BasCrnp(); |
| | | basCrnp.setCrnNo(deviceConfig.getDeviceNo()); |
| | | basCrnp.setStatus(1); |
| | | basCrnp.setInEnable("N"); |
| | | basCrnp.setOutEnable("N"); |
| | | basCrnp.setMaxInTask(5); |
| | | basCrnp.setMaxOutTask(5); |
| | | basCrnp.setCreateTime(new Date()); |
| | | basCrnpService.insert(basCrnp); |
| | | 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 |