| | |
| | | // 尺寸检测异常 |
| | | boolean back = false; |
| | | String errMsg = ""; |
| | | if (staProtocol.isFrontErr()) { |
| | | if ((staProtocol.getSiteId() == 101 && devpThread.ioModeOf101 == IoModeType.PAKOUT_MODE) |
| | | ||(staProtocol.getSiteId() == 103 && devpThread.ioModeOf103 == IoModeType.PAKOUT_MODE) |
| | | ||(staProtocol.getSiteId() == 305 && devpThread.ioModeOf305 == IoModeType.PAKOUT_MODE)) { |
| | | errMsg = "当前为出库模式"; |
| | | back = true; |
| | | } |
| | | if (!back && staProtocol.isFrontErr()) { |
| | | errMsg = "前超限"; |
| | | back = true; |
| | | } |
| | |
| | | } |
| | | |
| | | // // 入出库模式判断 |
| | | if (inSta.getStaNo() == 203 && devpThread.ioModeOf2F != IoModeType.PAKIN_MODE) { |
| | | if (inSta.getStaNo() == 203 && devpThread.ioModeOf101 != IoModeType.PAKIN_MODE) { |
| | | continue; |
| | | } |
| | | |
| | |
| | | |
| | | // 更新工作档状态为14失败 |
| | | wrkMast.setWrkSts(14L); |
| | | if (wrkMast.getStaNo() == 104 && wrkMast.getWrkSts() == 12L) { |
| | | wrkMast.setWrkSts(16L); |
| | | } |
| | | wrkMast.setCrnEndTime(new Date()); |
| | | if (wrkMastMapper.updateById(wrkMast) != 0) { |
| | | // 复位堆垛机 |
| | |
| | | continue; |
| | | } |
| | | // 获取工作状态为2(设备上走)的入库工作档 |
| | | WrkMast wrkMast = wrkMastMapper.selectPakInStep2(slave.getId(), staProtocol.getWorkNo().intValue(), crnStn.getStaNo()); |
| | | WrkMast wrkMast = wrkMastMapper.selectPakInStep2(slave.getId(), staProtocol.getWorkNo(), crnStn.getStaNo()); |
| | | if (null == wrkMast) { |
| | | News.infoNoLog(""+mark+" - 1"+" - 4"+" - 查询无待入库数据--wrk_sts=2, 工作号={}", staProtocol.getWorkNo()); |
| | | // log.error("查询无待入库数据--wrk_sts=2, 工作号={}", staProtocol.getWorkNo()); |
| | |
| | | // News.infoNoLog(""+mark+" - 2"+" - 4"+" - 入出库模式(此处出库方法,出库模式继续=="+devpThread.ioModeOf2F); |
| | | // continue; |
| | | // } |
| | | // 入出库模式判断 |
| | | if ((staProtocol.getSiteId() == 101 && devpThread.ioModeOf101 != IoModeType.PAKOUT_MODE) |
| | | || (staProtocol.getSiteId() == 103 && devpThread.ioModeOf103 != IoModeType.PAKOUT_MODE) |
| | | || (staProtocol.getSiteId() == 305 && devpThread.ioModeOf305 != IoModeType.PAKOUT_MODE)) { |
| | | continue; |
| | | } |
| | | |
| | | // 查询站点详细信息 |
| | | BasDevp staDetl = basDevpService.selectById(crnStn.getStaNo()); |
| | |
| | | if (wrkMastMapper.selectWorking(slave.getId()) != null) { |
| | | break; |
| | | // return; |
| | | } |
| | | if(crnStn.getStaNo() == 105) { |
| | | continue; |
| | | } |
| | | |
| | | News.warnNoLog(""+mark+" - 2"+" - 12"+" - 命令下发 : 工作号={},源排={},源列={},源层={},目标排={},目标列={},目标层={}",wrkMast.getWrkNo().shortValue() |
| | |
| | | // 根据输送线plc遍历 |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | |
| | | for (DevpSlave.Sta inSta : devp.getInSta()) { |
| | | if (inSta.getStaNo() == 2) { |
| | | continue; |
| | | } |
| | | WrkMast pakout = wrkMastMapper.selectWorkingPakout(inSta.getStaNo()); |
| | | switch (inSta.getStaNo()) { |
| | | case 203://1F |
| | | Integer[] staNos; |
| | | if (devp.getId() == 1) { |
| | | staNos = new Integer[]{101, 103}; |
| | | }else { |
| | | staNos = new Integer[]{305}; |
| | | } |
| | | for (Integer staNo : staNos) { |
| | | WrkMast pakout = wrkMastMapper.selectWorkingPakout(staNo); |
| | | switch (staNo) { |
| | | case 101://1F |
| | | if (pakout != null) { |
| | | if (devpThread.ioModeOf2F != IoModeType.PAKOUT_MODE) { |
| | | if (devpThread.ioModeOf101 != IoModeType.PAKOUT_MODE) { |
| | | // 出库切换中 |
| | | devpThread.ioModeOf2F = IoModeType.PAKOUT_BOOTING; |
| | | WrkMast pakin = wrkMastMapper.selectWorkingPakin(inSta.getStaNo()); |
| | | if (pakin == null && !devpThread.getStation().get(inSta.getStaNo()).isLoading() |
| | | && !devpThread.getStation().get(inSta.getStaNo() + 1).isLoading() |
| | | && devpThread.getStation().get(inSta.getStaNo() + 1).getWorkNo() == 0) { |
| | | devpThread.ioModeOf101 = IoModeType.PAKOUT_BOOTING; |
| | | WrkMast pakin = wrkMastMapper.selectWorkingPakin(staNo); |
| | | if (pakin == null) { |
| | | // 出库模式 |
| | | devpThread.ioModeOf2F = IoModeType.PAKOUT_MODE; |
| | | devpThread.ioModeOf101 = IoModeType.PAKOUT_MODE; |
| | | } |
| | | } |
| | | } else { |
| | | // 入库模式 |
| | | devpThread.ioModeOf2F = IoModeType.PAKIN_MODE; |
| | | devpThread.ioModeOf101 = IoModeType.PAKIN_MODE; |
| | | } |
| | | break; |
| | | case 401://1F |
| | | case 103://1F |
| | | if (pakout != null) { |
| | | if (devpThread.ioModeOf4F != IoModeType.PAKOUT_MODE) { |
| | | if (devpThread.ioModeOf103 != IoModeType.PAKOUT_MODE) { |
| | | // 出库切换中 |
| | | devpThread.ioModeOf4F = IoModeType.PAKOUT_BOOTING; |
| | | WrkMast pakin = wrkMastMapper.selectWorkingPakin(inSta.getStaNo()); |
| | | if (pakin == null && !devpThread.getStation().get(inSta.getStaNo()).isLoading() |
| | | && !devpThread.getStation().get(inSta.getStaNo() + 1).isLoading() |
| | | && devpThread.getStation().get(inSta.getStaNo() + 1).getWorkNo() == 0) { |
| | | devpThread.ioModeOf103 = IoModeType.PAKOUT_BOOTING; |
| | | WrkMast pakin = wrkMastMapper.selectWorkingPakin(staNo); |
| | | if (pakin == null) { |
| | | // 出库模式 |
| | | devpThread.ioModeOf4F = IoModeType.PAKOUT_MODE; |
| | | devpThread.ioModeOf103 = IoModeType.PAKOUT_MODE; |
| | | } |
| | | } |
| | | } else { |
| | | // 入库模式 |
| | | devpThread.ioModeOf4F = IoModeType.PAKIN_MODE; |
| | | devpThread.ioModeOf103 = IoModeType.PAKIN_MODE; |
| | | } |
| | | break; |
| | | case 305://1F |
| | | if (pakout != null) { |
| | | if (devpThread.ioModeOf305 != IoModeType.PAKOUT_MODE) { |
| | | // 出库切换中 |
| | | devpThread.ioModeOf305 = IoModeType.PAKOUT_BOOTING; |
| | | WrkMast pakin = wrkMastMapper.selectWorkingPakin(staNo); |
| | | if (pakin == null) { |
| | | // 出库模式 |
| | | devpThread.ioModeOf305 = IoModeType.PAKOUT_MODE; |
| | | } |
| | | } |
| | | } else { |
| | | // 入库模式 |
| | | devpThread.ioModeOf305 = IoModeType.PAKIN_MODE; |
| | | } |
| | | break; |
| | | } |
| | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 并板,拣料,盘点出库,状态为14.已出库未确认,更新ctnNo为Y |
| | | * @param mark 标识 |
| | | */ |
| | | public synchronized void outOfDevp(Integer mark) { |
| | | |
| | | List<WrkMast> wrkMasts = wrkMastMapper.selectPick(); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 判断106站点状态,有物+有任务号,则生成移库任务 |
| | | */ |
| | | public synchronized void generateOutbound() { |
| | | WrkMast wrkMast = wrkMastMapper.selectBy104(); |
| | | if (wrkMast == null) { |
| | | return; |
| | | } |
| | | BasCrnp basCrnp = basCrnpService.selectById(1); |
| | | if (!basCrnp.getInEnable().equals("Y") && !basCrnp.getOutEnable().equals("Y")) { |
| | | return; |
| | | } |
| | | CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, 1); |
| | | CrnProtocol crnProtocol = crnThread.getCrnProtocol(); |
| | | if (crnProtocol == null) { |
| | | return; |
| | | } |
| | | // 堆垛机控制过滤 |
| | | if (!crnProtocol.getStatusType().equals(CrnStatusType.IDLE) || crnProtocol.getTaskNo() != 0) { |
| | | return; |
| | | } |
| | | |
| | | // 已经存在吊车执行任务时,则过滤 |
| | | if (wrkMastMapper.selectWorking(1) != null) { |
| | | return; |
| | | } |
| | | |
| | | LocMast sourceSta = locMastService.selectById(wrkMast.getSourceLocNo()); |
| | | // 1.堆垛机开始移动 |
| | | CrnCommand crnCommand = new CrnCommand(); |
| | | crnCommand.setCrnNo(1); // 堆垛机编号 |
| | | crnCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); // 工作号 |
| | | // crnCommand.setAckFinish((short) 0); // 任务完成确认位 |
| | | crnCommand.setTaskMode(CrnTaskModeType.LOC_MOVE); // 任务模式: 库位移转 |
| | | crnCommand.setSourcePosX(sourceSta.getRow1().shortValue()); // 源库位排 |
| | | crnCommand.setSourcePosY(sourceSta.getBay1().shortValue()); // 源库位列 |
| | | crnCommand.setSourcePosZ(sourceSta.getLev1().shortValue()); // 源库位层 |
| | | crnCommand.setDestinationPosX((short) 3); // 目标库位排 |
| | | crnCommand.setDestinationPosY((short) 3); // 目标库位列 |
| | | crnCommand.setDestinationPosZ((short) 1); // 目标库位层 |
| | | crnCommand.setTraySize(sourceSta.getLocType1() == 2); //库位类型 |
| | | if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) { |
| | | News.error("到106站点堆垛机命令下发失败,堆垛机号={},任务数据={}", 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) { |
| | | News.error("到106站点修改工作档状态 11.生成出库ID => 12.吊车出库中 失败!!,工作号={}", wrkMast.getWrkNo()); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | public synchronized void autoMoveLoc() { |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_sts", 16L)); |
| | | |
| | | // 判断源站点情况 有任务号,有物,自动 |
| | | SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, 1); |
| | | StaProtocol staProtocol106 = devpThread.getStation().get(106); |
| | | StaProtocol staProtocol105 = devpThread.getStation().get(105); |
| | | if (staProtocol106 == null) { |
| | | return; |
| | | } else { |
| | | staProtocol106 = staProtocol106.clone(); |
| | | } |
| | | if (staProtocol105 == null) { |
| | | return; |
| | | } else { |
| | | staProtocol105 = staProtocol105.clone(); |
| | | } |
| | | |
| | | |
| | | // 判断出库站点情况 |
| | | |
| | | |
| | | // 获取堆垛机信息 并 判断是否可入出 |
| | | CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, 2); |
| | | CrnProtocol crnProtocol = crnThread.getCrnProtocol(); |
| | | if (crnProtocol == null) { |
| | | return; |
| | | } |
| | | BasCrnp basCrnp = basCrnpService.selectById(2); |
| | | if (!basCrnp.getInEnable().equals("Y") && !basCrnp.getOutEnable().equals("Y")) { |
| | | return; |
| | | } |
| | | |
| | | // 堆垛机控制过滤 |
| | | if (!crnProtocol.getStatusType().equals(CrnStatusType.IDLE) || crnProtocol.getTaskNo() != 0) { |
| | | return; |
| | | } |
| | | |
| | | // 已经存在吊车执行任务时,则过滤 |
| | | if (wrkMastMapper.selectWorking(2) != null) { |
| | | return; |
| | | } |
| | | // 命令下发区 -------------------------------------------------------------------------- |
| | | CrnCommand crnCommand = new CrnCommand(); |
| | | crnCommand.setCrnNo(2); // 堆垛机编号 |
| | | crnCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); // 工作号 |
| | | crnCommand.setAckFinish((short) 0); // 任务完成确认位 |
| | | crnCommand.setTaskMode(CrnTaskModeType.LOC_MOVE); // 任务模式: 库位移转 |
| | | crnCommand.setSourcePosX((short) 6); // 源库位排 |
| | | crnCommand.setSourcePosY((short) 3); // 源库位列 |
| | | crnCommand.setSourcePosZ((short) 1); // 源库位层 |
| | | crnCommand.setDestinationPosX((short) 7); // 目标库位排 |
| | | crnCommand.setDestinationPosY((short) 28); // 目标库位列 |
| | | crnCommand.setDestinationPosZ((short) 1); // 目标库位层 |
| | | crnCommand.setTraySize(true); //库位类型 |
| | | if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) { |
| | | News.error("106移库2号堆垛机命令下发失败,堆垛机号={},任务数据={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand)); |
| | | } |
| | | // else { |
| | | // wrkMast.setCrnNo(2); |
| | | // wrkMastMapper.updateById(wrkMast); |
| | | // } |
| | | News.infoNoLog("106移库2号堆垛机入出库作业下发:库位移转完成"); |
| | | } |
| | | } |