| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.*; |
| | | import java.util.concurrent.CompletableFuture; |
| | | |
| | | /** |
| | | * 立体仓库WCS系统主流程业务 |
| | |
| | | private ApiLogService apiLogService; |
| | | @Autowired |
| | | private CommonService commonService; |
| | | |
| | | @Value("${wms.count}") |
| | | private Integer maxCount; |
| | | @Autowired |
| | | private WrkMastService wrkMastService; |
| | | @Value("${wms.url}") |
| | | private String wmsUrl; |
| | | @Value("${wms.inboundTaskApplyPath}") |
| | |
| | | private CrnController crnController; |
| | | @Autowired |
| | | private SiteController siteController; |
| | | //出库站点至112循环站点 |
| | | public synchronized 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 (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; |
| | | |
| | | } |
| | | if(result){ |
| | | staProtocol.setStaNo((short) 112); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e) { |
| | | log.error("generateStoreWrkFile e", e); |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | } |
| | | } |
| | | |
| | | //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) { |
| | | 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)); |
| | | } |
| | | } |
| | | }catch (Exception e) { |
| | | log.error("generateStoreWrkFile e", e); |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | public synchronized void generateStoreWrkFile1() throws IOException, InterruptedException { |
| | |
| | | continue; |
| | | } |
| | | |
| | | |
| | | // 获取工作状态为2(设备上走)的入库工作档 |
| | | TaskWrk taskWrk = taskWrkMapper.selectPakIn(slave.getId(), staProtocol.getWorkNo().intValue(), staDesc.getStnNo().toString()); |
| | | if (null == taskWrk) { |
| | |
| | | if (!crnProtocol.getStatusType().equals(CrnStatusType.IDLE) || crnProtocol.getTaskNo() != 0) { |
| | | break; |
| | | } |
| | | int storeCount = taskWrkService.getStoreCount(taskWrk.getCrnNo()); |
| | | if(storeCount >= maxCount){ |
| | | log.error("{}号堆垛机暂存数已满!", taskWrk.getCrnNo()); |
| | | break; |
| | | } |
| | | |
| | | |
| | | // 已经存在吊车执行任务时,则过滤 |
| | | if (taskWrkMapper.selectCrnWorking(slave.getId()) != null) { |