| | |
| | | package com.zy.core.thread.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.SpringUtils; |
| | | import com.zy.asrs.entity.*; |
| | |
| | | import com.zy.core.network.DeviceConnectPool; |
| | | import com.zy.core.network.ZyCrnV2ConnectDriver; |
| | | import com.zy.core.network.entity.ZyCrnStatusEntity; |
| | | import com.zy.core.service.WrkCommandRollbackService; |
| | | import com.zy.core.thread.CrnThread; |
| | | import lombok.Data; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | |
| | | } |
| | | if (basCrnpService != null) { |
| | | BasCrnp basCrnp = basCrnpService.selectOne(new EntityWrapper<BasCrnp>().eq("crn_no", deviceConfig.getDeviceNo())); |
| | | BasCrnp basCrnp = basCrnpService.getOne(new QueryWrapper<BasCrnp>().eq("crn_no", deviceConfig.getDeviceNo())); |
| | | if(basCrnp == null) { |
| | | basCrnp = new BasCrnp(); |
| | | basCrnp.setCrnNo(deviceConfig.getDeviceNo()); |
| | |
| | | basCrnp.setMaxInTask(5); |
| | | basCrnp.setMaxOutTask(5); |
| | | basCrnp.setCreateTime(new Date()); |
| | | basCrnpService.insert(basCrnp); |
| | | basCrnpService.save(basCrnp); |
| | | } |
| | | } |
| | | } |
| | |
| | | log.setStatus(1); |
| | | log.setCreateTime(new Date()); |
| | | log.setSystemStatus(JSON.toJSONString(crnProtocol)); |
| | | errLogService.insert(log); |
| | | errLogService.save(log); |
| | | if (log.getId() != null) { |
| | | redisUtil.set(errFlagKey, log.getId(), 60 * 60 * 24); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public CrnCommand getResetCommand(Integer crnNo) { |
| | | public CrnCommand getResetCommand(Integer taskNo, Integer crnNo) { |
| | | CrnCommand crnCommand = new CrnCommand(); |
| | | crnCommand.setCrnNo(crnNo); // 堆垛机编号 |
| | | crnCommand.setTaskNo(0); // 工作号 |
| | | crnCommand.setTaskNo(taskNo); // 工作号 |
| | | crnCommand.setAckFinish(1); // 任务完成确认位 |
| | | crnCommand.setTaskMode(CrnTaskModeType.RESET.id); // 任务模式 |
| | | crnCommand.setSourcePosX(0); // 源库位排 |
| | |
| | | response = zyCrnConnectDriver.sendCommand(command); |
| | | return response; |
| | | } finally { |
| | | String sourceLocNo = Utils.getLocNo(command.getSourcePosX(), command.getSourcePosY(), command.getSourcePosZ()); |
| | | String targetLocNo = Utils.getLocNo(command.getDestinationPosX(), command.getDestinationPosY(), command.getDestinationPosZ()); |
| | | BasCrnpOptService bean = SpringUtils.getBean(BasCrnpOptService.class); |
| | | ZyCrnStatusEntity statusEntity = zyCrnConnectDriver.getStatus(); |
| | | BasCrnpOpt basCrnpOpt = new BasCrnpOpt( |
| | | command.getTaskNo().intValue(), |
| | | command.getCrnNo(), |
| | | new Date(), |
| | | String.valueOf(command.getTaskMode()), |
| | | sourceLocNo, |
| | | targetLocNo, |
| | | null, |
| | | null, |
| | | null, |
| | | JSON.toJSONString(command), |
| | | JSON.toJSONString(statusEntity), |
| | | 1, |
| | | JSON.toJSONString(response) |
| | | ); |
| | | if (bean != null) { |
| | | bean.insert(basCrnpOpt); |
| | | if (command != null) { |
| | | String sourceLocNo = Utils.getLocNo(command.getSourcePosX(), command.getSourcePosY(), command.getSourcePosZ()); |
| | | String targetLocNo = Utils.getLocNo(command.getDestinationPosX(), command.getDestinationPosY(), command.getDestinationPosZ()); |
| | | BasCrnpOptService bean = SpringUtils.getBean(BasCrnpOptService.class); |
| | | ZyCrnStatusEntity statusEntity = zyCrnConnectDriver.getStatus(); |
| | | BasCrnpOpt basCrnpOpt = new BasCrnpOpt( |
| | | command.getTaskNo(), |
| | | command.getCrnNo(), |
| | | new Date(), |
| | | String.valueOf(command.getTaskMode()), |
| | | sourceLocNo, |
| | | targetLocNo, |
| | | null, |
| | | null, |
| | | null, |
| | | JSON.toJSONString(command), |
| | | JSON.toJSONString(statusEntity), |
| | | 1, |
| | | JSON.toJSONString(response) |
| | | ); |
| | | bean.save(basCrnpOpt); |
| | | try { |
| | | WrkCommandRollbackService rollbackService = SpringUtils.getBean(WrkCommandRollbackService.class); |
| | | if (rollbackService != null) { |
| | | rollbackService.handleSingleCrnSendResult(command, response, "单工位堆垛机V2"); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("处理单工位V2命令下发结果失败, wrkNo={}", command.getTaskNo(), e); |
| | | } |
| | | } |
| | | } |
| | | } |