| | |
| | | import com.zy.core.thread.SiemensDevpThread; |
| | | import com.zy.system.entity.Config; |
| | | import com.zy.system.service.ConfigService; |
| | | import lombok.Synchronized; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | private CrnController crnController; |
| | | @Autowired |
| | | private SiteController siteController; |
| | | //出库站点至112循环站点 |
| | | public synchronized void shiftTargetToCyclePoint() throws IOException, InterruptedException{ |
| | | try{ |
| | | @Synchronized |
| | | public void shiftTargetToCyclePoint() throws IOException, InterruptedException { |
| | | try { |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | for (DevpSlave.Sta outSta : devp.getOutSta()) { |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | StaProtocol staProtocol = devpThread.getStation().get(outSta.getStaNo()); |
| | | StaProtocol staProtocol1 = devpThread.getStation().get(1001); |
| | | StaProtocol staProtocol2 = devpThread.getStation().get(1002); |
| | | StaProtocol staProtocol3 = devpThread.getStation().get(1003); |
| | | StaProtocol staProtocol4 = devpThread.getStation().get(1004); |
| | | if (devpThread == null) { |
| | | continue; |
| | | } |
| | | |
| | | StaProtocol staProtocol = getClonedStation(devpThread, outSta.getStaNo()); |
| | | if (staProtocol == null) { |
| | | continue; |
| | | } else { |
| | | staProtocol = staProtocol.clone(); |
| | | } |
| | | if (staProtocol1 == null) { |
| | | continue; |
| | | } else { |
| | | staProtocol1 = staProtocol1.clone(); |
| | | } |
| | | if (staProtocol2 == null) { |
| | | continue; |
| | | } else { |
| | | staProtocol2 = staProtocol2.clone(); |
| | | } |
| | | if (staProtocol3 == null) { |
| | | continue; |
| | | } else { |
| | | staProtocol3 = staProtocol3.clone(); |
| | | } |
| | | if (staProtocol4 == null) { |
| | | continue; |
| | | } else { |
| | | staProtocol4 = staProtocol4.clone(); |
| | | } |
| | | boolean result = false; |
| | | switch(outSta.getStaNo()){ |
| | | case 105: if (staProtocol1.isLoading()){ |
| | | result = true; |
| | | } |
| | | case 107: if (staProtocol2.isLoading()){ |
| | | result = true; |
| | | } |
| | | case 109: if (staProtocol3.isLoading()){ |
| | | result = true; |
| | | } |
| | | case 110: if (staProtocol4.isLoading()){ |
| | | result = true; |
| | | } |
| | | default: break; |
| | | |
| | | // 获取其他相关站点 |
| | | StaProtocol staProtocol1 = getClonedStation(devpThread, 1001); |
| | | StaProtocol staProtocol2 = getClonedStation(devpThread, 1002); |
| | | StaProtocol staProtocol3 = getClonedStation(devpThread, 1003); |
| | | StaProtocol staProtocol4 = getClonedStation(devpThread, 1004); |
| | | StaProtocol staProtocol6 = getClonedStation(devpThread, 111); |
| | | |
| | | boolean result = false; |
| | | switch (outSta.getStaNo()) { |
| | | case 105: |
| | | result = (staProtocol1 != null && staProtocol1.isLoading() && staProtocol.isLoading() && staProtocol.getStaNo() == 105); |
| | | break; |
| | | case 107: |
| | | result = (staProtocol2 != null && staProtocol2.isLoading()); |
| | | break; |
| | | case 109: |
| | | result = (staProtocol3 != null && staProtocol3.isLoading()); |
| | | break; |
| | | case 110: |
| | | result = ((staProtocol4 != null && staProtocol4.isLoading() && staProtocol.isLoading() && staProtocol.getStaNo() == 110) || |
| | | (staProtocol6 != null && staProtocol6.isLoading() && staProtocol.isLoading() && staProtocol.getStaNo() == 111)); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | if(result){ |
| | | staProtocol.setStaNo((short) 112); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | |
| | | if (result) { |
| | | if (staProtocol.getSiteId() == 107 || staProtocol.getSiteId() == 109) { |
| | | StaProtocol staProtocol5 = getClonedStation(devpThread, staProtocol.getSiteId() - 1); |
| | | if (staProtocol5 != null && (staProtocol5.isLoading() && (staProtocol5.getStaNo() == 107 || staProtocol5.getStaNo() == 109))) { |
| | | short workNo = staProtocol5.getWorkNo(); |
| | | staProtocol5.setWorkNo(workNo); |
| | | staProtocol5.setStaNo((short) 112); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(4, staProtocol5)); |
| | | } |
| | | } else { |
| | | if(staProtocol.isLoading() && (staProtocol.getStaNo() == 105 || staProtocol.getStaNo() == 110 || staProtocol.getStaNo() == 111)){ |
| | | short workNo = staProtocol.getWorkNo(); |
| | | staProtocol.setWorkNo(workNo); |
| | | staProtocol.setStaNo((short) 112); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(4, staProtocol)); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e) { |
| | | log.error("generateStoreWrkFile e", e); |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | } catch (Exception e) { |
| | | log.error("shiftTargetToCyclePoint error", e); |
| | | } |
| | | } |
| | | |
| | | //112循环站点至出库站 |
| | | public synchronized void shiftCyclePointToTarget() throws IOException, InterruptedException{ |
| | | try{ |
| | | /** |
| | | * 获取站点并克隆 |
| | | */ |
| | | private StaProtocol getClonedStation(DevpThread devpThread, int staNo) { |
| | | StaProtocol staProtocol = devpThread.getStation().get(staNo); |
| | | return (staProtocol != null) ? staProtocol.clone() : null; |
| | | } |
| | | |
| | | // 112循环站点至出库站 |
| | | public synchronized void shiftCyclePointToTarget() throws IOException, InterruptedException { |
| | | try { |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | StaProtocol staProtocol = devpThread.getStation().get(112); |
| | | if (staProtocol == null) { |
| | | if (devpThread == null) { |
| | | continue; |
| | | } else { |
| | | staProtocol = staProtocol.clone(); |
| | | } |
| | | WrkMast wrkMast = wrkMastMapper.selectById(staProtocol.getWorkNo()); |
| | | if(wrkMast != null && wrkMast.getWrkNo() < 9000 && wrkMast.getWrkNo() > 7000){ |
| | | staProtocol.setStaNo(wrkMast.getStaNo().shortValue()); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | |
| | | StaProtocol staProtocol = devpThread.getStation().get(112); |
| | | if (staProtocol.getStaNo() != 112 || staProtocol.getWorkNo() == 0 || !staProtocol.isLoading() || staProtocol.getWorkNo() > 9000 || staProtocol.getWorkNo() < 6000) { |
| | | continue; |
| | | } |
| | | // 查询任务信息 |
| | | TaskWrk taskWrk = taskWrkMapper.selectStaWorking(Integer.valueOf(staProtocol.getWorkNo())); |
| | | if (taskWrk == null || taskWrk.getWrkNo() < 6001 || taskWrk.getWrkNo() > 9000) { |
| | | continue; |
| | | } |
| | | |
| | | short workNo = staProtocol.getWorkNo(); |
| | | // 再写入目标站点 |
| | | staProtocol.setWorkNo(workNo); |
| | | staProtocol.setStaNo(Short.valueOf(taskWrk.getTargetPoint())); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(4, staProtocol)); |
| | | Thread.sleep(200); |
| | | |
| | | log.info("Shifted from cycle station 112 to target {}, workNo: {}", taskWrk.getTargetPoint(), workNo); |
| | | } |
| | | }catch (Exception e) { |
| | | log.error("generateStoreWrkFile e", e); |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | } catch (Exception e) { |
| | | log.error("shiftCyclePointToTarget error", e); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | |
| | | staProtocol.setStaNo((short)107); |
| | | }else if (staProtocol.getWorkNo()>=9851&&staProtocol.getWorkNo()<=9875) { |
| | | staProtocol.setStaNo((short)109); |
| | | }else{ |
| | | }else if (staProtocol.getWorkNo()>=9876 && staProtocol.getWorkNo() <= 9900){ |
| | | staProtocol.setStaNo((short)110); |
| | | } |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | |
| | | if (!crnProtocol.getStatusType().equals(CrnStatusType.IDLE) || crnProtocol.getTaskNo() != 0) { |
| | | break; |
| | | } |
| | | int storeCount = taskWrkService.getStoreCount(taskWrk.getCrnNo()); |
| | | int storeCount = basDevpService.getStoreCount(); |
| | | if(storeCount >= maxCount){ |
| | | log.error("{}号堆垛机暂存数已满!", taskWrk.getCrnNo()); |
| | | log.error("输送线暂存数达到上限{}",storeCount); |
| | | break; |
| | | } |
| | | |