| | |
| | | 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; |
| | | 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循环站点 |
| | | @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); |
| | | StaProtocol staProtocol6 = devpThread.getStation().get(111); |
| | | 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(); |
| | | } |
| | | if (staProtocol6 == null) { |
| | | continue; |
| | | } else { |
| | | staProtocol6 = staProtocol6.clone(); |
| | | } |
| | | boolean result = false; |
| | | switch(outSta.getStaNo()){ |
| | | case 105: if (staProtocol1.isLoading() && staProtocol.isLoading() && staProtocol.getStaNo() == 105){ |
| | | result = true; |
| | | } |
| | | case 107: if (staProtocol2.isLoading()){ |
| | | result = true; |
| | | } |
| | | case 109: if (staProtocol3.isLoading()){ |
| | | result = true; |
| | | } |
| | | case 110: if ((staProtocol4.isLoading() && staProtocol.isLoading() && staProtocol.getStaNo() == 110) || ((staProtocol6.isLoading() && staProtocol.isLoading() && staProtocol.getStaNo() == 111))){ |
| | | result = true; |
| | | } |
| | | default: break; |
| | | |
| | | } |
| | | if(result){ |
| | | if(staProtocol.getSiteId() == 107 || staProtocol.getSiteId() == 109){ |
| | | StaProtocol staProtocol5 = devpThread.getStation().get(staProtocol.getSiteId() - 1); |
| | | if (staProtocol5== null) { |
| | | continue; |
| | | } else { |
| | | staProtocol5 = staProtocol5.clone(); |
| | | } |
| | | if((staProtocol5.isLoading() && staProtocol5.getStaNo() == 107) || ((staProtocol5.isLoading() && staProtocol5.getStaNo() == 109))){ |
| | | staProtocol5.setStaNo((short) 112); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol5)); |
| | | } |
| | | }else{ |
| | | 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(); |
| | | } |
| | | if(staProtocol.getWorkNo() == 0){ |
| | | continue; |
| | | } |
| | | TaskWrk taskWrk = taskWrkMapper.selectStaWorking(Integer.valueOf(staProtocol.getWorkNo())); |
| | | if(taskWrk != null && taskWrk.getWrkNo() < 9001 && taskWrk.getWrkNo() > 6000){ |
| | | staProtocol.setStaNo(Short.valueOf(taskWrk.getTargetPoint())); |
| | | 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) { |
| | |
| | | // 修改工作档状态 11.生成出库ID => 12.吊车出库中 |
| | | Date now = new Date(); |
| | | taskWrk.setWrkSts(12); |
| | | taskWrk.setStatus(2); |
| | | taskWrk.setModiTime(now); |
| | | if (taskWrkMapper.updateById(taskWrk) == 0) { |
| | | log.error("修改工作档状态 11.生成出库ID => 12.吊车出库中 失败!!,工作号={}", taskWrk.getWrkNo()); |
| | | } |
| | | String response = ""; |
| | | Boolean bool=false; |
| | | HashMap<String, Object> headParam = new HashMap<>(); |
| | | headParam.put("TaskNo", taskWrk.getTaskNo()); |
| | | try { |
| | | HashMap<String, Object> headParam = new HashMap<>(); |
| | | headParam.put("TaskNo", taskWrk.getTaskNo()); |
| | | String response; |
| | | response = new HttpHandler.Builder() |
| | | // .setHeaders(headParam) |
| | | .setUri(wmsUrl) |
| | |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if(jsonObject.get("ReturnStatus").equals(0)){ |
| | | bool = true; |
| | | taskWrk.setStatus(2); |
| | | taskWrkMapper.updateById(taskWrk); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | log.error("wcs派发移库库任务上报wms失败", taskWrk); |
| | | // throw new CoolException("wcs派发移库库任务上报wms失败"); |
| | | }finally { |
| | | apiLogService.save("wcs派发移库任务上报wms" |
| | | , wmsUrl + taskStatusFeedbackPath |
| | | , null |
| | | , "127.0.0.1" |
| | | , JSON.toJSONString(headParam) |
| | | , response |
| | | , true |
| | | , bool |
| | | ); |
| | | } catch (Exception e) { |
| | | log.error("wcs派发移库库任务上报wms失败", taskWrk); |
| | | // throw new CoolException("wcs派发移库库任务上报wms失败"); |
| | | } |
| | | |
| | | } |