| | |
| | | // 判断是否满足入库条件 |
| | | if (staProtocol.isAutoing() && staProtocol.isLoading() |
| | | && staProtocol.isInEnable() |
| | | && !staProtocol.isEmptyMk() && (workNo >= 0) |
| | | && !staProtocol.isEmptyMk() && (workNo == 9991 ) |
| | | && staProtocol.isPakMk()) { |
| | | // 获取条码扫描仪信息 |
| | | BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, inSta.getBarcode()); |
| | |
| | | continue; |
| | | } |
| | | String barcode = barcodeThread.getBarcode(); |
| | | if(!Cools.isEmpty(barcode)) { |
| | | if(!Cools.isEmpty(barcode) && !barcode.equals("99999999")) { |
| | | // 请求wms接口,获取工作号和目标库位 |
| | | ToWmsDTO toWmsDTO = new ToWmsDTO(barcode,staProtocol.getSiteId(),staProtocol.isHigh() ? 2 : 1); |
| | | TaskWrk taskWrk1=taskWrkService.selectOne(new EntityWrapper<TaskWrk>().eq("barcode",barcode)); |
| | | if(!Cools.isEmpty(taskWrk1)){ |
| | | log.info("托盘码:"+barcode+"任务档存在"); |
| | | continue; |
| | | if (taskWrk1.getIoType()==1 && taskWrk1.getStartPoint().equals(staProtocol.getSiteId().toString())){ |
| | | StaDesc staDesc = staDescService.selectOne(new EntityWrapper<StaDesc>() |
| | | .eq("crn_no", taskWrk1.getCrnNo()).eq("type_no",1).eq("stn_no",staProtocol.getSiteId())); |
| | | if (Cools.isEmpty(staDesc)){ |
| | | log.info("托盘码:"+barcode+"任务档存在"); |
| | | return; |
| | | }else { |
| | | staProtocol.setWorkNo(taskWrk1.getWrkNo().shortValue()); |
| | | staProtocol.setStaNo(staDesc.getCrnStn().shortValue()); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | } |
| | | } |
| | | return; |
| | | } |
| | | HashMap<String, Object> headParam = new HashMap<>(); |
| | | headParam.put("Content-Type","application/json"); |
| | |
| | | log.info("入库请求参数{}" + JSON.toJSONString(toWmsDTO)); |
| | | if (jsonObject.getInteger("code").equals(200) && !Cools.isEmpty(jsonObject.get("data").toString())) { |
| | | GetWmsDto getWmsDto = JSON.parseObject(jsonObject.get("data").toString(), GetWmsDto.class); |
| | | |
| | | //查看该库位是否为空库位 |
| | | LocMast locMast=locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .eq("loc_sts","O") |
| | | .eq("loc_no",getWmsDto.getLocNo())); |
| | | if(Cools.isEmpty(locMast)){ |
| | | try{ |
| | | HashMap<String, Object> headParam1 = new HashMap<>(); |
| | | headParam1.put("taskNo",getWmsDto.getTaskNo()); |
| | | headParam1.put("status",6); |
| | | headParam1.put("ioType",1); |
| | | headParam1.put("barcode",barcode); |
| | | String response2; |
| | | response2 = new HttpHandler.Builder() |
| | | // .setHeaders(headParam) |
| | | .setUri(wmsUrl) |
| | | .setPath(taskStatusFeedbackPath) |
| | | .setJson(JSON.toJSONString(headParam1)) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject1 = JSON.parseObject(response2); |
| | | apiLogService.save("wcs派发库位不为空上报wms" |
| | | ,wmsUrl+taskStatusFeedbackPath |
| | | ,null |
| | | ,"127.0.0.1" |
| | | ,JSON.toJSONString(headParam1) |
| | | ,response |
| | | ,true |
| | | ); |
| | | }catch (Exception e){ |
| | | log.error("wcs派发库位不为空上报wms", getWmsDto.getWrkNo()); |
| | | throw new CoolException("wcs派发入库任务上报wms失败"); |
| | | } |
| | | } |
| | | |
| | | // 创新一个入库工作档 |
| | | TaskWrk taskWrk = taskWrkService.selectByTaskNo(getWmsDto.getWrkNo()); |
| | | if(Cools.isEmpty(taskWrk)) { |
| | |
| | | // } |
| | | // } |
| | | |
| | | } else { |
| | | // 退回 |
| | | log.error("扫码入库失败,{}入库站因{}异常,托盘已被退回", inSta.getStaNo(), errMsg); |
| | | // staProtocol.setWorkNo((short)0); |
| | | // staProtocol.setStaNo(inSta.getStaNo().shortValue()); |
| | | // MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | // |
| | | // Thread.sleep(500); |
| | | |
| | | staProtocol.setWorkNo((short)9999); |
| | | staProtocol.setStaNo(inSta.getStaNo().shortValue()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | TaskWrk taskWrk = taskWrkMapper.selectByWrkNo(Integer.valueOf(workNo)); |
| | | if (taskWrk != null) { |
| | | taskWrk.setMemo(errMsg);//将错误码存入备注字段进行展示 |
| | | taskWrkMapper.updateById(taskWrk); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | headParam.put("ioType",taskWrk.getIoType()); |
| | | headParam.put("barcode",taskWrk.getBarcode()); |
| | | String response; |
| | | log.error("wcs完结任务上报wms==》", headParam); |
| | | |
| | | response = new HttpHandler.Builder() |
| | | // .setHeaders(headParam) |
| | | .setUri(wmsUrl) |
| | |
| | | .setJson(JSON.toJSONString(headParam)) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | log.error("wcs完结任务上报wms==》", response); |
| | | |
| | | // JSONObject jsonObject = JSON.parseObject(response); |
| | | // log.error("wcs完结任务上报wms==》", jsonObject); |
| | | |
| | | apiLogService.save("wcs派发入库任务上报wms" |
| | | ,wmsUrl+taskStatusFeedbackPath |
| | | ,null |
| | |
| | | ); |
| | | }catch (Exception e){ |
| | | log.error("wcs完结任务上报wms失败", taskWrk); |
| | | throw new CoolException("wcs派发入库任务上报wms失败"); |
| | | log.error("wcs完结任务上报wms失败,报错信息:", e); |
| | | // throw new CoolException("wcs派发入库任务上报wms失败"); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | //自动完成任务 |
| | | //agv取放货任务完成 |
| | | public synchronized void autoCompleteAGV() { |
| | | List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<>()); |
| | | try{ |
| | | Thread.sleep(500); |
| | | }catch (Exception e){ |
| | | |
| | | } |
| | | |
| | | for (BasDevp basDevp:basDevps){ |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, 1); |
| | | StaProtocol staProtocol = devpThread.getStation().get(basDevp.getDevNo()); |
| | | if (staProtocol == null) { |
| | | continue; |
| | | } else { |
| | | staProtocol = staProtocol.clone(); |
| | | } |
| | | if (basDevp.getWrkNo()!=0){ |
| | | if (basDevp.getAgvTargetPick()!=0){//取货 |
| | | staProtocol.setAgvTypeSign((short)0); |
| | | staProtocol.setStaNo(basDevp.getDevNo().shortValue()); |
| | | MessageQueue.offer(SlaveType.Devp, 1, new Task(4, staProtocol)); |
| | | } |
| | | boolean sign = true; |
| | | if (basDevp.getAgvTargetPlace()!=0){ |
| | | sign = false; |
| | | basDevp.setAgvTargetPlace(0); |
| | | basDevpService.updateById(basDevp); |
| | | staProtocol.setAgvTypeSign((short)3);//1 |
| | | staProtocol.setStaNo(basDevp.getDevNo().shortValue()); |
| | | MessageQueue.offer(SlaveType.Devp, 1, new Task(4, staProtocol)); |
| | | } |
| | | }else { |
| | | if (basDevp.getAgvTargetPlace()!=0){ |
| | | if (basDevp.getLoading().equals("Y")){ |
| | | staProtocol.setAgvTypeSign((short)1); |
| | | staProtocol.setStaNo(basDevp.getDevNo().shortValue()); |
| | | MessageQueue.offer(SlaveType.Devp, 1, new Task(4, staProtocol)); |
| | | }else { |
| | | log.error("AGV放货完成但输送线无物,复位信号 ===>> [staNo:{}] [basDevp:{}]", basDevp.getDevNo(), basDevp); |
| | | basDevp.setAgvTargetPlace(0); |
| | | basDevpService.updateById(basDevp); |
| | | staProtocol.setAgvTypeSign((short)3);//1 |
| | | staProtocol.setStaNo(basDevp.getDevNo().shortValue()); |
| | | MessageQueue.offer(SlaveType.Devp, 1, new Task(4, staProtocol)); |
| | | } |
| | | |
| | | } |
| | | if (basDevp.getAgvTargetPick()!=0){ |
| | | basDevp.setAgvTargetPick(0); |
| | | basDevpService.updateById(basDevp); |
| | | staProtocol.setAgvTypeSign((short)2);//0 |
| | | staProtocol.setStaNo(basDevp.getDevNo().shortValue()); |
| | | MessageQueue.offer(SlaveType.Devp, 1, new Task(4, staProtocol)); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | public synchronized void autoCompleteTask() { |
| | | List<TaskWrk> taskWrks = taskWrkMapper.selectWorkingTask(); |
| | | for (TaskWrk taskWrk : taskWrks) { |