| | |
| | | @Transactional |
| | | public class MainServiceImpl { |
| | | |
| | | |
| | | public static final long COMMAND_TIMEOUT = 5 * 1000; |
| | | |
| | | @Autowired |
| | | private CommonService commonService; |
| | | @Autowired |
| | |
| | | for (DevpSlave.Sta inSta : devp.getInSta()) { |
| | | // 获取条码扫描仪信息 |
| | | BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, inSta.getBarcode()); |
| | | if (barcodeThread == null) { |
| | | continue; |
| | | } |
| | | String barcode = barcodeThread.getBarcode(); |
| | | if(!Cools.isEmpty(barcode)) { |
| | | log.info("{}号条码扫描器检测条码信息:{}", inSta.getBarcode(), barcode); |
| | |
| | | staProtocol = staProtocol.clone(); |
| | | } |
| | | // 判断是否满足入库条件 |
| | | if (staProtocol.isAutoing() && staProtocol.isLoading() |
| | | if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable() |
| | | && !staProtocol.isEmptyMk() && (staProtocol.getWorkNo() == 0 || staProtocol.getWorkNo() == 9999) |
| | | && staProtocol.isPakMk()) { |
| | | // 判断重复工作档 |
| | |
| | | } |
| | | } |
| | | } |
| | | try { |
| | | Thread.sleep(1500L); |
| | | } catch (InterruptedException ignore) {} |
| | | // 库位移转 |
| | | this.locToLoc(crn, crnProtocol); |
| | | } |
| | |
| | | // 获取工作状态为2(设备上走)的入库工作档 |
| | | WrkMast wrkMast = wrkMastMapper.selectPakInStep2(slave.getId(), staProtocol.getWorkNo().intValue(), crnStn.getStaNo()); |
| | | if(null == wrkMast) { |
| | | log.error("查询无待入库数据--wrk_sts=2, 工作号={}", staProtocol.getWorkNo()); |
| | | // log.error("查询无待入库数据--wrk_sts=2, 工作号={}", staProtocol.getWorkNo()); |
| | | continue; |
| | | } |
| | | // 获取库位信息 |
| | |
| | | if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) { |
| | | log.error("堆垛机命令下发失败,堆垛机号={},任务数据={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand)); |
| | | } else { |
| | | // 修改工作档状态 2.设备上走 => 3.吊车入库中 |
| | | // Date now = new Date(); |
| | | // wrkMast.setWrkSts(3L); |
| | | // wrkMast.setCrnStrTime(now); |
| | | // wrkMast.setModiTime(now); |
| | | // if (wrkMastMapper.updateById(wrkMast) == 0) { |
| | | // log.error("修改工作档状态 2.设备上走 => 3.吊车入库中 失败!!,工作号={}", wrkMast.getWrkNo()); |
| | | |
| | | // long startTime = System.currentTimeMillis(); |
| | | // while ((System.currentTimeMillis() - startTime) < COMMAND_TIMEOUT) { |
| | | // |
| | | // if (true) { |
| | | // break; |
| | | // } |
| | | // |
| | | // try{ |
| | | // Thread.sleep(500); |
| | | // }catch(Exception ignore){} |
| | | // } |
| | | |
| | | // 修改工作档状态 2.设备上走 => 3.吊车入库中 |
| | | Date now = new Date(); |
| | | wrkMast.setWrkSts(3L); |
| | | wrkMast.setCrnStrTime(now); |
| | | wrkMast.setModiTime(now); |
| | | if (wrkMastMapper.updateById(wrkMast) == 0) { |
| | | log.error("修改工作档状态 2.设备上走 => 3.吊车入库中 失败!!,工作号={}", wrkMast.getWrkNo()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | log.error("堆垛机命令下发失败,堆垛机号={},任务数据={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand)); |
| | | } else { |
| | | // 修改工作档状态 11.生成出库ID => 12.吊车出库中 |
| | | // Date now = new Date(); |
| | | // wrkMast.setWrkSts(12L); |
| | | // wrkMast.setCrnStrTime(now); |
| | | // wrkMast.setModiTime(now); |
| | | // if (wrkMastMapper.updateById(wrkMast) == 0) { |
| | | // log.error("修改工作档状态 11.生成出库ID => 12.吊车出库中 失败!!,工作号={}", wrkMast.getWrkNo()); |
| | | // } |
| | | Date now = new Date(); |
| | | wrkMast.setWrkSts(12L); |
| | | wrkMast.setCrnStrTime(now); |
| | | wrkMast.setModiTime(now); |
| | | if (wrkMastMapper.updateById(wrkMast) == 0) { |
| | | log.error("修改工作档状态 11.生成出库ID => 12.吊车出库中 失败!!,工作号={}", wrkMast.getWrkNo()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | log.error("堆垛机命令下发失败,堆垛机号={},任务数据={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand)); |
| | | } else { |
| | | // 修改工作档状态 11.生成出库ID => 12.吊车出库中 |
| | | // Date now = new Date(); |
| | | // wrkMast.setWrkSts(12L); |
| | | // wrkMast.setCrnStrTime(now); |
| | | // wrkMast.setModiTime(now); |
| | | // if (wrkMastMapper.updateById(wrkMast) == 0) { |
| | | // log.error("【库位移转】 修改工作档状态 11.生成出库ID => 12.吊车出库中 失败!!,工作号={}", wrkMast.getWrkNo()); |
| | | // } |
| | | Date now = new Date(); |
| | | wrkMast.setWrkSts(12L); |
| | | wrkMast.setCrnStrTime(now); |
| | | wrkMast.setModiTime(now); |
| | | if (wrkMastMapper.updateById(wrkMast) == 0) { |
| | | log.error("【库位移转】 修改工作档状态 11.生成出库ID => 12.吊车出库中 失败!!,工作号={}", wrkMast.getWrkNo()); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | Date now = new Date(); |
| | | // 堆垛机正在运行 |
| | | if (crnProtocol.getStatusType() != CrnStatusType.IDLE && crnProtocol.getTaskNo() != 0 && crnProtocol.getModeType() == CrnModeType.AUTO) { |
| | | log.warn("堆垛机非空闲情况下,开始修改工作档状态。[id:{},时间:{}] >>>>> 堆垛机当前状态为:{}。任务号:{}", crn.getId(), DateUtils.convert(now, DateUtils.yyyyMMddHHmmsssss_F), crnProtocol.getStatusType().desc, crnProtocol.getTaskNo()); |
| | | // 获取工作档 |
| | | WrkMast wrkMast = wrkMastMapper.selectById(crnProtocol.getTaskNo()); |
| | | if (wrkMast == null) { continue; } |
| | | // 入库 |
| | | if (wrkMast.getWrkSts() == 1 || wrkMast.getWrkSts() == 2) { |
| | | log.warn("堆垛机非空闲情况下,开始修改工作档状态。[id:{},时间:{}] >>>>> 堆垛机当前状态为:{}。任务号:{}", crn.getId(), DateUtils.convert(now, DateUtils.yyyyMMddHHmmsssss_F), crnProtocol.getStatusType().desc, crnProtocol.getTaskNo()); |
| | | // 修改工作档状态 2.设备上走 => 3.吊车入库中 |
| | | wrkMast.setWrkSts(3L); |
| | | wrkMast.setCrnStrTime(now); |
| | |
| | | if (wrkMastMapper.updateById(wrkMast) == 0) { |
| | | log.error("修改工作档状态 2.设备上走 => 3.吊车入库中 失败!!,工作号={}", wrkMast.getWrkNo()); |
| | | } |
| | | log.warn("修改工作档状态成功。[时间:{}] >>>>> 任务号:{}", DateUtils.convert(now, DateUtils.yyyyMMddHHmmsssss_F), wrkMast.getWrkNo()); |
| | | } |
| | | // 出库、移库 |
| | | if (wrkMast.getWrkSts() == 11) { |
| | | log.warn("堆垛机非空闲情况下,开始修改工作档状态。[id:{},时间:{}] >>>>> 堆垛机当前状态为:{}。任务号:{}", crn.getId(), DateUtils.convert(now, DateUtils.yyyyMMddHHmmsssss_F), crnProtocol.getStatusType().desc, crnProtocol.getTaskNo()); |
| | | // 修改工作档状态 11.生成出库ID => 12.吊车出库中 |
| | | wrkMast.setWrkSts(12L); |
| | | wrkMast.setCrnStrTime(now); |
| | |
| | | if (wrkMastMapper.updateById(wrkMast) == 0) { |
| | | log.error("修改工作档状态 11.生成出库ID => 12.吊车出库中 失败!!,工作号={}", wrkMast.getWrkNo()); |
| | | } |
| | | log.warn("修改工作档状态成功。[时间:{}] >>>>> 任务号:{}", DateUtils.convert(now, DateUtils.yyyyMMddHHmmsssss_F), wrkMast.getWrkNo()); |
| | | } |
| | | log.warn("修改工作档状态成功。[时间:{}] >>>>> 任务号:{}", DateUtils.convert(now, DateUtils.yyyyMMddHHmmsssss_F), wrkMast.getWrkNo()); |
| | | |
| | | |
| | | } |
| | | |