| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.Cools; |
| | | import com.core.common.R; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.controller.CrnController; |
| | | import com.zy.asrs.controller.OpenController; |
| | |
| | | } |
| | | // News.warn("扫码入库失败,{}入库站因{}异常,托盘已被退回", inSta.getStaNo(), errMsg); |
| | | staProtocol.setWorkNo(workNo); |
| | | staProtocol.setStaNo(inSta.getBackSta().shortValue()); |
| | | staProtocol.setStaNo(inSta.getStaNo().shortValue()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, staProtocol)); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | TaskWrk taskWrk = taskWrkMapper.selectByWrkNo(Integer.valueOf(workNo)); |
| | | if (taskWrk != null) { |
| | | taskWrk.setMemo(errMsg);//将错误码存入备注字段进行展示 |
| | |
| | | // 判断是否满足入库条件 |
| | | 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()); |
| | |
| | | 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"); |
| | | String response; |
| | | response = new HttpHandler.Builder() |
| | | // .setHeaders(headParam) |
| | | .setUri(wmsUrl) |
| | | .setPath(inboundTaskApplyPath) |
| | | .setJson(JSON.toJSONString(toWmsDTO)) |
| | | .build() |
| | | .doPost(); |
| | | try{ |
| | | response = new HttpHandler.Builder() |
| | | // .setHeaders(headParam) |
| | | .setUri(wmsUrl) |
| | | .setPath(inboundTaskApplyPath) |
| | | .setJson(JSON.toJSONString(toWmsDTO)) |
| | | .build() |
| | | .doPost(); |
| | | }catch (Exception e){ |
| | | log.error("请求入库调用接口失败"); |
| | | log.error("异常信息打印:"+e); |
| | | try{ |
| | | BasDevp basDevp = basDevpService.selectById(inSta.getStaNo()); |
| | | if (Cools.isEmpty(basDevp)){ |
| | | log.error("站点号异常"+inSta.getStaNo()); |
| | | } else if (basDevp.getStaErr()!=0){ |
| | | basDevp.setStaErr(2); |
| | | basDevpService.updateById(basDevp); |
| | | } |
| | | }catch (Exception e1){ |
| | | // 退回 |
| | | log.error("扫码检测程序异常"+inSta.getStaNo()+"异常信息"+e1); |
| | | } |
| | | 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); |
| | | // } |
| | | continue; |
| | | } |
| | | |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | apiLogService.save("wms请求入库货位接口" |
| | |
| | | ,true |
| | | ); |
| | | log.info("入库请求参数{}" + JSON.toJSONString(toWmsDTO)); |
| | | log.info("入库请求返回参数{}" + JSON.toJSONString(response)); |
| | | if (jsonObject.getInteger("code").equals(200) && !Cools.isEmpty(jsonObject.get("data").toString())) { |
| | | GetWmsDto getWmsDto = JSON.parseObject(jsonObject.get("data").toString(), GetWmsDto.class); |
| | | try{ |
| | | BasDevp basDevp = basDevpService.selectById(inSta.getStaNo()); |
| | | if (Cools.isEmpty(basDevp)){ |
| | | log.error("站点号异常1"+inSta.getStaNo()); |
| | | throw new CoolException("站点号异常1,未查询到站点信息"+inSta.getStaNo()); |
| | | } |
| | | Integer staNoCrnNo = Utils.StaNoCrnNo(inSta.getStaNo()); |
| | | if (staNoCrnNo==0){ |
| | | basDevp.setStaErr(1); |
| | | basDevpService.updateById(basDevp); |
| | | log.error("站点号异常2"+inSta.getStaNo()); |
| | | throw new CoolException("站点号异常2,站点号不存在"+inSta.getStaNo()); |
| | | }else { |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .eq("crn_no", staNoCrnNo.longValue()) |
| | | .eq("loc_no", getWmsDto.getLocNo())); |
| | | if (Cools.isEmpty(locMast)){ |
| | | basDevp.setStaErr(1); |
| | | basDevpService.updateById(basDevp); |
| | | log.error("站点号异常3"+inSta.getStaNo()); |
| | | throw new CoolException("站点号异常3:此巷道不存在目标库位"+inSta.getStaNo()); |
| | | } |
| | | } |
| | | } catch (Exception e){ |
| | | // log.error("扫码检测程序异常"+inSta.getStaNo()+"异常信息"+e); |
| | | // 退回 |
| | | log.error("扫码检测程序异常"+inSta.getStaNo()+errMsg); |
| | | log.error("扫码检测程序异常,异常信息"+e); |
| | | |
| | | 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); |
| | | // } |
| | | continue; |
| | | } |
| | | //查看该库位是否为空库位 |
| | | LocMast locMast=locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .eq("loc_sts","O") |
| | |
| | | ); |
| | | }catch (Exception e){ |
| | | log.error("wcs派发库位不为空上报wms", getWmsDto.getWrkNo()); |
| | | throw new CoolException("wcs派发入库任务上报wms失败"); |
| | | throw new CoolException("wcs派发入库任务上报wms失败,异常信息:"+e); |
| | | } |
| | | } |
| | | |
| | |
| | | continue; |
| | | } |
| | | |
| | | // StaDescService staDescService = SpringUtils.getBean(StaDescService.class); |
| | | // |
| | | // ToWmsDTO toWmsDTO = new ToWmsDTO(); |
| | | // Map<String, Object> map = new HashMap<>(); |
| | | // map.put("x-api-key","7a15b5db-29b6-552c-8cff-0cfec3756da2"); |
| | | // List<Integer> list = openServiceImpl.getInEnableRoadway(); |
| | | // TaskWrk taskWrk = taskWrkService.selectOne(new EntityWrapper<TaskWrk>().eq("barcode", barcode)); |
| | | // |
| | | // if (Cools.isEmpty(taskWrk)){ |
| | | // continue; |
| | | // } |
| | | // //StaDesc staDesc1 = staDescService.selectOne(new EntityWrapper<StaDesc>().eq("stn_no",inSta.getBackSta())); |
| | | // if (taskWrk.getTargetPoint() != null && taskWrk.getStartPoint() != null){ |
| | | // if ( taskWrk.getWrkNo() != null && taskWrk.getWrkNo().shortValue() == workNo ){ |
| | | // continue; |
| | | // } |
| | | // //获取堆垛机站点 |
| | | // StaDesc staDesc = new StaDesc(); |
| | | // if (devp.getId() <= 1){ |
| | | // staDesc = staDescService.selectOne(new EntityWrapper<StaDesc>() |
| | | // .eq("crn_no", taskWrk.getCrnNo()).eq("type_no",1).lt("stn_no", 200)); |
| | | // }else { |
| | | // staDesc = staDescService.selectOne(new EntityWrapper<StaDesc>() |
| | | // .eq("crn_no", taskWrk.getCrnNo()).eq("type_no",1).lt("stn_no", 400).ge("stn_no", 250)); |
| | | // } |
| | | // staProtocol.setWorkNo(taskWrk.getWrkNo().shortValue()); |
| | | // staProtocol.setStaNo(staDesc.getCrnStn().shortValue()); |
| | | // MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, staProtocol)); |
| | | // Thread.sleep(500); |
| | | // }else { |
| | | // //TaskWrk taskWrk = taskWrkService.selectByTaskNo(param.getTaskNo()); |
| | | // toWmsDTO.setWarehouseId("1688469798893297665"); |
| | | // toWmsDTO.setContainerCode(barcode); |
| | | // toWmsDTO.setApplyType("TUNNEL_LOCATION"); |
| | | // toWmsDTO.setTaskTunnel(taskWrk.getCrnNo()); |
| | | // toWmsDTO.setCanInboundTunnels(list); |
| | | // String response = null; |
| | | // try { |
| | | // response = new HttpHandler.Builder() |
| | | // .setHeaders(map) |
| | | // .setUri(wmsUrl) |
| | | // .setPath(inboundTaskApplyPath) |
| | | // .setJson(JSON.toJSONString(toWmsDTO)) |
| | | // .build() |
| | | // .doPost(); |
| | | // }catch (Exception e){ |
| | | // log.error("wms通讯失败,"+e.getMessage()); |
| | | // continue; |
| | | // } |
| | | // apiLogService.save("wms请求入库货位接口" |
| | | // ,wmsUrl+"wcsManager/wcsInterface/inboundTaskApply" |
| | | // ,null |
| | | // ,"127.0.0.1" |
| | | // ,JSON.toJSONString(toWmsDTO) |
| | | // ,response |
| | | // ,true |
| | | // ); |
| | | // JSONObject jsonObject = JSON.parseObject(response); |
| | | // if (jsonObject.getInteger("code").equals(200)) { |
| | | // GetWmsDto getWmsDto = JSON.parseObject(jsonObject.get("data").toString(), GetWmsDto.class); |
| | | // taskWrk.setOriginTargetPoint(getWmsDto.getTargetLocationCode()); |
| | | // taskWrk.setTargetPoint(Utils.getWcsLocNo(getWmsDto.getTargetLocationCode())); |
| | | // taskWrk.setStartPoint(String.valueOf(inSta.getBackSta())); |
| | | // if (!taskWrkService.updateById(taskWrk)){ |
| | | // log.error("保存wms库位号失败"); |
| | | // } |
| | | // |
| | | // }else { |
| | | // log.error("wms通讯失败,"+jsonObject.get("msg")); |
| | | // |
| | | // } |
| | | // } |
| | | } else { |
| | | // 退回 |
| | | log.error("扫码入库失败,{}入库站因{}异常,托盘已被退回", inSta.getStaNo(), errMsg); |
| | | |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | for (CrnSlave.CrnStn crnStn : crnSlave.getCrnOutStn()) { |
| | | List<StaDesc> staDescs = staDescMapper.selectList(new EntityWrapper<StaDesc>().eq("crn_no", crnSlave.getId()).eq("crn_stn", crnStn.getStaNo())); |
| | | for (StaDesc staDesc : staDescs){ |
| | | // 获取堆垛机出库站信息 |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, crnStn.getDevpPlcId()); |
| | | StaProtocol staProtocol = devpThread.getStation().get(crnStn.getStaNo()); |
| | | if (staProtocol == null) { |
| | | continue; |
| | | } else { |
| | | staProtocol = staProtocol.clone(); |
| | | } |
| | | if (staProtocol.isAutoing() && staProtocol.isLoading() && (staProtocol.getWorkNo() == 0 || staProtocol.getStaNo() == 0)) { |
| | | // 查询工作档 |
| | | TaskWrk taskWrk = taskWrkMapper.selectCrnStaWorking(crnSlave.getId(), staDesc.getStnNo().toString()); |
| | | if (taskWrk == null) { |
| | | try{ |
| | | // 获取堆垛机出库站信息 |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, crnStn.getDevpPlcId()); |
| | | StaProtocol staProtocol = devpThread.getStation().get(crnStn.getStaNo()); |
| | | if (staProtocol == null) { |
| | | continue; |
| | | } else { |
| | | staProtocol = staProtocol.clone(); |
| | | } |
| | | siteController.siteDetlUpdate(Integer.valueOf(taskWrk.getTargetPoint()),taskWrk.getWrkNo().shortValue(),(short)0,"Y",false,false); |
| | | taskWrk.setStatus(5); |
| | | taskWrk.setWrkSts(14); |
| | | taskWrkService.updateById(taskWrk); |
| | | if (staProtocol.isAutoing() && staProtocol.isLoading() && (staProtocol.getWorkNo() == 0 || staProtocol.getStaNo() == 0)) { |
| | | // 查询工作档 |
| | | TaskWrk taskWrk = taskWrkMapper.selectCrnStaWorking(crnSlave.getId(), staDesc.getStnNo().toString()); |
| | | if (taskWrk == null) { |
| | | continue; |
| | | } |
| | | log.info("下发输送线任务:taskWrk:"+JSON.toJSONString(taskWrk)); |
| | | R r = siteController.siteDetlUpdate(Integer.valueOf(taskWrk.getTargetPoint()), taskWrk.getWrkNo().shortValue(), (short) 0, "Y", false, false); |
| | | JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(r)); |
| | | if (jsonObject.getInteger("code").equals(200)){ |
| | | log.info("下发输送线任务成功:taskWrk:"+JSON.toJSONString(taskWrk)); |
| | | taskWrk.setStatus(5); |
| | | taskWrk.setWrkSts(14); |
| | | taskWrkService.updateById(taskWrk); |
| | | }else { |
| | | log.error("下发输送线任务失败:taskWrk:"+JSON.toJSONString(taskWrk)); |
| | | log.error("下发输送线任务失败:异常信息:"+JSON.toJSONString(r)); |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | log.error("出库到出库站异常:异常信息:"+e); |
| | | } |
| | | } |
| | | |
| | |
| | | log.error("{}号堆垛机尚未在数据库进行维护!", crn.getId()); |
| | | continue; |
| | | } |
| | | |
| | | // 库位移转 |
| | | this.locToLoc(crn, crnProtocol); |
| | | |
| | | // 只有当堆垛机空闲 并且 无任务时才继续执行 |
| | | if (crnProtocol.getStatusType() == CrnStatusType.IDLE && crnProtocol.getTaskNo() == 0 && crnProtocol.getModeType() == CrnModeType.AUTO |
| | |
| | | } |
| | | } |
| | | } |
| | | // 库位移转 |
| | | this.locToLoc(crn, crnProtocol); |
| | | |
| | | } |
| | | } |
| | |
| | | |
| | | crnController.crnTaskComplete(crnOperatorParam); |
| | | if(!Cools.isEmpty(taskWrk)){ |
| | | if(taskWrk.getIoType()==1&&taskWrk.getWrkSts()==3){ |
| | | if(taskWrk.getIoType()==1 && taskWrk.getWrkSts()==3){ |
| | | taskWrk.setWrkSts(4);//入库完成 |
| | | taskWrk.setStatus(5);//完结 |
| | | //更新库位状态 |
| | |
| | | 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) { |