| | |
| | | import com.core.common.SpringUtils; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.BasSte; |
| | | import com.zy.asrs.entity.BasSteOpt; |
| | | import com.zy.asrs.service.BasSteOptService; |
| | | import com.zy.asrs.service.BasSteService; |
| | | import com.zy.core.ThreadHandler; |
| | |
| | | OperateResult result = null; |
| | | // 开始任务 |
| | | if (!command.getComplete()) { |
| | | OperateResult result0 = siemensS7Net.Write("D0", command.getTaskNo()); |
| | | short[] array = new short[10]; |
| | | array[0] = command.getTaskMode(); |
| | | // array[1] = command.getTaskNo(); |
| | | // array[2] = command.getTaskMode(); |
| | | // array[3] = command.getSourcePosX(); |
| | | // array[4] = command.getSourcePosY(); |
| | | // array[5] = command.getSourcePosZ(); |
| | | // array[6] = command.getDestinationPosX(); |
| | | // array[7] = command.getDestinationPosY(); |
| | | // array[8] = command.getDestinationPosZ(); |
| | | // array[9] = command.getCommand(); |
| | | OperateResult result1 = siemensS7Net.Write("D0", array); |
| | | // 确认开始任务 |
| | | if (result0.IsSuccess) { |
| | | result = siemensS7Net.Write("D0", true); |
| | | |
| | | // 作业 |
| | | if (command.getTaskMode() != 0) { |
| | | // 1.任务号 |
| | | OperateResult result0 = siemensS7Net.Write("DB3", command.getTaskNo()); |
| | | // 2.作业 |
| | | short[] array = new short[10]; |
| | | array[0] = command.getTaskMode(); |
| | | OperateResult result1 = siemensS7Net.Write("D0", array); |
| | | // 3.确认开始任务 |
| | | if (result0.IsSuccess && result1.IsSuccess) { |
| | | result = siemensS7Net.Write("D0", true); |
| | | } |
| | | |
| | | // 其他指令 |
| | | } else { |
| | | // 控制模式 |
| | | if (command.getControlMode() != null) { |
| | | result = siemensS7Net.Write("DB3.20", command.getControlMode()); |
| | | // 复位信号 |
| | | } else if (command.getReset() != null) { |
| | | result = siemensS7Net.Write("DB3.26", command.getReset()); |
| | | // 删除指令 |
| | | } else if (command.getDelete() != null) { |
| | | result = siemensS7Net.Write("DB3.28", command.getDelete()); |
| | | // 无效指令 |
| | | } else { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | // 任务完成 |
| | | } else { |
| | | result = siemensS7Net.Write("D0", true); |
| | |
| | | |
| | | try { |
| | | // 日志记录 |
| | | BasSteOptService bean = SpringUtils.getBean(BasSteOptService.class); |
| | | // BasSteOpt basSteOpt = new BasSteOpt( |
| | | // command.getTaskNo(), // 任务号 |
| | | // command.getSteNo(), // 穿梭车[非空] |
| | | // new Date(), // 下发时间 |
| | | // command.getTaskModeType().desc, // 模式 |
| | | // command.getSourcePosX().intValue(), // 源排 |
| | | // command.getSourcePosY().intValue(), // 源列 |
| | | // command.getSourcePosZ().intValue(), // 源层 |
| | | // null, // 源站 |
| | | // command.getDestinationPosX().intValue(), // 目标排 |
| | | // command.getDestinationPosY().intValue(), // 目标列 |
| | | // command.getDestinationPosZ().intValue(), // 目标层 |
| | | // null, // 目标站 |
| | | // null, // 响应结果 |
| | | // null, // 修改时间 |
| | | // null // 修改人员 |
| | | // ); |
| | | // bean.insert(basSteOpt); |
| | | if (!command.getComplete() && command.getTaskMode() != 0) { |
| | | BasSteOptService bean = SpringUtils.getBean(BasSteOptService.class); |
| | | BasSteOpt basSteOpt = new BasSteOpt( |
| | | command.getTaskNo(), // 任务号 |
| | | command.getSteNo(), // 穿梭车 |
| | | new Date(), // 下发时间 |
| | | command.getTaskModeType().desc, // 作业 |
| | | null, // 源排 |
| | | null, // 源列 |
| | | null, // 源层 |
| | | null, // 源站 |
| | | null, // 目标排 |
| | | null, // 目标列 |
| | | null, // 目标层 |
| | | null, // 目标站 |
| | | null, // 响应结果 |
| | | null, // 修改时间 |
| | | null, // 修改人员 |
| | | null // 备注 |
| | | ); |
| | | bean.insert(basSteOpt); |
| | | } |
| | | |
| | | } catch (Exception ignore) {} |
| | | |
| | | if (result != null && result.IsSuccess) { |
| | |
| | | this.lastBay = command.getBay().intValue(); |
| | | this.lastLev = command.getLev().intValue(); |
| | | } |
| | | |
| | | |
| | | log.info("穿梭车命令下发[id:{}] >>>>> {}", slave.getId(), JSON.toJSON(command)); |
| | | OutputQueue.CRN.offer(MessageFormat.format("【{0}】[id:{1}] >>>>> 命令下发: {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(command))); |