| | |
| | | continue; |
| | | } |
| | | |
| | | try { |
| | | // 访问 WMS 获取入库库位 |
| | | LocTypeDto locTypeDto = new LocTypeDto(staProtocol); |
| | | SearchLocParam param = new SearchLocParam(); |
| | | param.setWrkNo(wrkMast.getWrkNo()); |
| | | param.setIoType(wrkMast.getIoType()); |
| | | param.setSourceStaNo(pickSta.getStaNo()); |
| | | // param.setLocType1(locTypeDto.getLocType1()); |
| | | String response = new HttpHandler.Builder() |
| | | .setUri(wmsUrl) |
| | | .setPath("/rpc/pakin/loc/v1") |
| | | .setJson(JSON.toJSONString(param)) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, pickSta.getLed()); |
| | | Integer code = jsonObject.getInteger("code"); |
| | | if (code.equals(200)) { |
| | | StartupDto dto = jsonObject.getObject("data", StartupDto.class); |
| | | // 保存工作主档历史档 |
| | | if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) { |
| | | throw new CoolException(wrkMast.getWrkNo() + "保存工作主档历史档失败"); |
| | | } |
| | | |
| | | // // 获取目标站 |
| | | // Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() |
| | | // .eq("type_no", wrkMast.getIoType() - 50) |
| | | // .eq("stn_no", pickSta.getStaNo()) // 作业站点 = 拣料出库的目标站 |
| | | // .eq("crn_no", dto.getCrnNo()); // 堆垛机号 |
| | | // StaDesc staDesc = staDescService.selectOne(wrapper); |
| | | // if (Cools.isEmpty(staDesc)) { |
| | | // News.error("入库路径不存在!type_no={},stn_no={},crn_no={}", wrkMast.getIoType(), pickSta.getStaNo(), wrkMast.getCrnNo()); |
| | | // continue; |
| | | // } |
| | | // // 堆垛机站点(目标站) |
| | | // Integer staNo = staDesc.getCrnStn(); |
| | | String sourceLocNo = wrkMast.getSourceLocNo().trim(); |
| | | LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(pickSta.getLiftNo(), Utils.getLev(sourceLocNo));//获取回库提升机目标站 |
| | | if (liftStaProtocol == null) { |
| | | continue; |
| | | } |
| | | |
| | | // 保存工作明细档历史档 |
| | | // if (wrkMastMapper.saveWrkDetlLog(wrkMast.getWrkNo()) == 0) { |
| | | // throw new CoolException("保存工作明细档历史档失败"); |
| | | // } |
| | | // 保存工作主档历史档 |
| | | if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) { |
| | | throw new CoolException(wrkMast.getWrkNo() + "保存工作主档历史档失败"); |
| | | } |
| | | |
| | | String sourceLocNo = wrkMast.getSourceLocNo().trim(); |
| | | LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(pickSta.getLiftNo(), Utils.getLev(sourceLocNo));//获取回库提升机目标站 |
| | | if (liftStaProtocol == null) { |
| | | continue; |
| | | } |
| | | |
| | | // 更新工作档数据状态 |
| | | wrkMast.setIoType(wrkMast.getIoType() - 50); // 入出库类型: 103->53,104->54,107->57 |
| | | wrkMast.setWrkSts(2L); // 工作状态: 2.设备上走 |
| | | wrkMast.setSourceStaNo(pickSta.getStaNo()); // 源站 |
| | | // 更新工作档数据状态 |
| | | wrkMast.setIoType(wrkMast.getIoType() - 50); // 入出库类型: 103->53,104->54,107->57 |
| | | wrkMast.setWrkSts(2L); // 工作状态: 2.设备上走 |
| | | wrkMast.setSourceStaNo(pickSta.getStaNo()); // 源站 |
| | | // wrkMast.setStaNo(dto.getStaNo()); // 目标站 |
| | | // wrkMast.setCrnNo(dto.getCrnNo()); |
| | | wrkMast.setStaNo(liftStaProtocol.getStaNo());//目标站 |
| | | wrkMast.setLocNo(sourceLocNo); // 目标库位 = 出库时的源库位 |
| | | wrkMast.setShuttleNo(null); // 穿梭车清空 |
| | | wrkMast.setLiftNo(null);// 提升机清空 |
| | | wrkMast.setModiTime(new Date()); |
| | | if (wrkMastMapper.updateById(wrkMast) == 0) { |
| | | throw new CoolException(wrkMast.getWrkNo() + "更新工作档数据状态失败"); |
| | | } |
| | | if (wrkMastMapper.setSteEmpty(wrkMast.getWrkNo()) == 0) { |
| | | throw new CoolException(wrkMast.getWrkNo() + "更新工作档数据状态失败"); |
| | | } |
| | | |
| | | // 修改库位状态 Q.拣料/盘点/并板再入库 |
| | | LocMast locMast = locMastService.selectById(sourceLocNo); |
| | | locMast.setLocSts("Q"); |
| | | locMast.setModiTime(new Date()); |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException("修改库位状态失败"); |
| | | } |
| | | |
| | | // // 更新站点信息 且 下发plc命令 |
| | | // staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue()); |
| | | // staProtocol.setStaNo(wrkMast.getStaNo().shortValue()); |
| | | // devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | // boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | // if (!result) { |
| | | // News.error("发布命令至输送线队列失败!!! [plc编号:{}]", devp.getId()); |
| | | // } |
| | | |
| | | barcodeThread.setBarcode("");//清理条码 |
| | | |
| | | } else if (code == 500){ |
| | | if (ledThread != null) { |
| | | String errorMsg = jsonObject.getString("msg"); |
| | | if (!Cools.isEmpty(errorMsg)) { |
| | | MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg)); |
| | | } |
| | | } |
| | | News.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); |
| | | } else { |
| | | // staProtocol.setWorkNo((short) 32002); |
| | | // staProtocol.setStaNo(pickSta.getBackSta().shortValue()); |
| | | // devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | // MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | |
| | | // led 异常显示 |
| | | if (ledThread != null) { |
| | | String errorMsg = jsonObject.getString("msg"); |
| | | // String errorMsg = barcode + "托盘识别异常,请先进行组托!"; |
| | | MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg)); |
| | | } |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | wrkMast.setStaNo(liftStaProtocol.getStaNo());//目标站 |
| | | wrkMast.setLocNo(sourceLocNo); // 目标库位 = 出库时的源库位 |
| | | wrkMast.setShuttleNo(null); // 穿梭车清空 |
| | | wrkMast.setLiftNo(null);// 提升机清空 |
| | | wrkMast.setModiTime(new Date()); |
| | | if (wrkMastMapper.updateById(wrkMast) == 0) { |
| | | throw new CoolException(wrkMast.getWrkNo() + "更新工作档数据状态失败"); |
| | | } |
| | | if (wrkMastMapper.setSteEmpty(wrkMast.getWrkNo()) == 0) { |
| | | throw new CoolException(wrkMast.getWrkNo() + "更新工作档数据状态失败"); |
| | | } |
| | | |
| | | // 修改库位状态 Q.拣料/盘点/并板再入库 |
| | | LocMast locMast = locMastService.selectById(sourceLocNo); |
| | | locMast.setLocSts("Q"); |
| | | locMast.setModiTime(new Date()); |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException("修改库位状态失败"); |
| | | } |
| | | barcodeThread.setBarcode("");//清理条码 |
| | | |
| | | // try { |
| | | // // 访问 WMS 获取入库库位 |
| | | // LocTypeDto locTypeDto = new LocTypeDto(staProtocol); |
| | | // SearchLocParam param = new SearchLocParam(); |
| | | // param.setWrkNo(wrkMast.getWrkNo()); |
| | | // param.setIoType(wrkMast.getIoType()); |
| | | // param.setSourceStaNo(pickSta.getStaNo()); |
| | | //// param.setLocType1(locTypeDto.getLocType1()); |
| | | // String response = new HttpHandler.Builder() |
| | | // .setUri(wmsUrl) |
| | | // .setPath("/rpc/pakin/loc/v1") |
| | | // .setJson(JSON.toJSONString(param)) |
| | | // .build() |
| | | // .doPost(); |
| | | // JSONObject jsonObject = JSON.parseObject(response); |
| | | // LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, pickSta.getLed()); |
| | | // Integer code = jsonObject.getInteger("code"); |
| | | // if (code.equals(200)) { |
| | | // StartupDto dto = jsonObject.getObject("data", StartupDto.class); |
| | | // |
| | | //// // 获取目标站 |
| | | //// Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() |
| | | //// .eq("type_no", wrkMast.getIoType() - 50) |
| | | //// .eq("stn_no", pickSta.getStaNo()) // 作业站点 = 拣料出库的目标站 |
| | | //// .eq("crn_no", dto.getCrnNo()); // 堆垛机号 |
| | | //// StaDesc staDesc = staDescService.selectOne(wrapper); |
| | | //// if (Cools.isEmpty(staDesc)) { |
| | | //// News.error("入库路径不存在!type_no={},stn_no={},crn_no={}", wrkMast.getIoType(), pickSta.getStaNo(), wrkMast.getCrnNo()); |
| | | //// continue; |
| | | //// } |
| | | //// // 堆垛机站点(目标站) |
| | | //// Integer staNo = staDesc.getCrnStn(); |
| | | // |
| | | // // 保存工作明细档历史档 |
| | | //// if (wrkMastMapper.saveWrkDetlLog(wrkMast.getWrkNo()) == 0) { |
| | | //// throw new CoolException("保存工作明细档历史档失败"); |
| | | //// } |
| | | // // 保存工作主档历史档 |
| | | // if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) { |
| | | // throw new CoolException(wrkMast.getWrkNo() + "保存工作主档历史档失败"); |
| | | // } |
| | | // |
| | | // String sourceLocNo = wrkMast.getSourceLocNo().trim(); |
| | | // LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(pickSta.getLiftNo(), Utils.getLev(sourceLocNo));//获取回库提升机目标站 |
| | | // if (liftStaProtocol == null) { |
| | | // continue; |
| | | // } |
| | | // |
| | | // // 更新工作档数据状态 |
| | | // wrkMast.setIoType(wrkMast.getIoType() - 50); // 入出库类型: 103->53,104->54,107->57 |
| | | // wrkMast.setWrkSts(2L); // 工作状态: 2.设备上走 |
| | | // wrkMast.setSourceStaNo(pickSta.getStaNo()); // 源站 |
| | | //// wrkMast.setStaNo(dto.getStaNo()); // 目标站 |
| | | //// wrkMast.setCrnNo(dto.getCrnNo()); |
| | | // wrkMast.setStaNo(liftStaProtocol.getStaNo());//目标站 |
| | | // wrkMast.setLocNo(sourceLocNo); // 目标库位 = 出库时的源库位 |
| | | // wrkMast.setShuttleNo(null); // 穿梭车清空 |
| | | // wrkMast.setLiftNo(null);// 提升机清空 |
| | | // wrkMast.setModiTime(new Date()); |
| | | // if (wrkMastMapper.updateById(wrkMast) == 0) { |
| | | // throw new CoolException(wrkMast.getWrkNo() + "更新工作档数据状态失败"); |
| | | // } |
| | | // if (wrkMastMapper.setSteEmpty(wrkMast.getWrkNo()) == 0) { |
| | | // throw new CoolException(wrkMast.getWrkNo() + "更新工作档数据状态失败"); |
| | | // } |
| | | // |
| | | // // 修改库位状态 Q.拣料/盘点/并板再入库 |
| | | // LocMast locMast = locMastService.selectById(sourceLocNo); |
| | | // locMast.setLocSts("Q"); |
| | | // locMast.setModiTime(new Date()); |
| | | // if (!locMastService.updateById(locMast)) { |
| | | // throw new CoolException("修改库位状态失败"); |
| | | // } |
| | | // |
| | | //// // 更新站点信息 且 下发plc命令 |
| | | //// staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue()); |
| | | //// staProtocol.setStaNo(wrkMast.getStaNo().shortValue()); |
| | | //// devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | //// boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | //// if (!result) { |
| | | //// News.error("发布命令至输送线队列失败!!! [plc编号:{}]", devp.getId()); |
| | | //// } |
| | | // |
| | | // barcodeThread.setBarcode("");//清理条码 |
| | | // |
| | | // } else if (code == 500){ |
| | | // if (ledThread != null) { |
| | | // String errorMsg = jsonObject.getString("msg"); |
| | | // if (!Cools.isEmpty(errorMsg)) { |
| | | // MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg)); |
| | | // } |
| | | // } |
| | | // News.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); |
| | | // } else { |
| | | //// staProtocol.setWorkNo((short) 32002); |
| | | //// staProtocol.setStaNo(pickSta.getBackSta().shortValue()); |
| | | //// devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | //// MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | // |
| | | // // led 异常显示 |
| | | // if (ledThread != null) { |
| | | // String errorMsg = jsonObject.getString("msg"); |
| | | //// String errorMsg = barcode + "托盘识别异常,请先进行组托!"; |
| | | // MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg)); |
| | | // } |
| | | // } |
| | | // |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | // } |
| | | |
| | | } |
| | | } |
| | |
| | | */ |
| | | public synchronized void initRealtimeBasMap() { |
| | | for (int i = 1; i <= 10; i++) {//总共四层楼 |
| | | Object data = redisUtil.get("realtimeBasMap_" + i); |
| | | Object data = redisUtil.get(RedisKeyType.MAP.key + i); |
| | | if (data == null) {//redis地图数据为空,从数据库中获取 |
| | | BasMap basMap = basMapService.selectLatestMap(i); |
| | | if (basMap == null) { |
| | |
| | | } |
| | | |
| | | //将数据库地图数据存入redis |
| | | redisUtil.set("realtimeBasMap_" + i, JSON.toJSONString(basMap)); |
| | | redisUtil.set(RedisKeyType.MAP.key + i, JSON.toJSONString(basMap)); |
| | | } |
| | | } |
| | | } |
| | |
| | | public synchronized void restartTaskFromRedis() { |
| | | HashMap<Object, Object> map = redisUtil.getRedis(); |
| | | for (Object key : map.keySet()) { |
| | | if (key.toString().contains("lift_wrk_no_")) {//提升机任务 |
| | | if (key.toString().contains(RedisKeyType.LIFT.key)) {//提升机任务 |
| | | LiftRedisCommand redisCommand = JSON.parseObject(map.get(key).toString(), LiftRedisCommand.class); |
| | | if (redisCommand == null) { |
| | | continue; |
| | |
| | | liftProtocol.setTaskNo(redisCommand.getWrkNo());//将提升机线程分配任务号 |
| | | liftProtocol.setProtocolStatus(LiftProtocolStatusType.WORKING);//工作状态 |
| | | |
| | | }else if(key.toString().contains("shuttle_wrk_no_")){//四向穿梭车任务 |
| | | }else if(key.toString().contains(RedisKeyType.SHUTTLE.key)){//四向穿梭车任务 |
| | | ShuttleRedisCommand redisCommand = JSON.parseObject(map.get(key).toString(), ShuttleRedisCommand.class); |
| | | if (redisCommand == null) { |
| | | continue; |
| | |
| | | ledCommand.setStaNo(wrkMast.getStaNo()); |
| | | if (wrkMast.getIoType() != 110 && wrkMast.getIoType() != 10) { |
| | | List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo()); |
| | | wrkDetls.forEach(wrkDetl -> ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme(),wrkDetl.getSpecs()))); |
| | | for (WrkDetl wrkDetl : wrkDetls) { |
| | | LocDetl locDetl = locDetlService.selectOne(new EntityWrapper<LocDetl>().eq("zpallet", wrkDetl.getBarcode()).eq("matnr", wrkDetl.getMatnr())); |
| | | Double anfme = 0D; |
| | | if (locDetl != null) { |
| | | anfme = locDetl.getAnfme(); |
| | | } |
| | | ledCommand.getMatDtos() |
| | | .add(new MatDto(wrkDetl.getMatnr() |
| | | , wrkDetl.getMaktx() |
| | | , wrkDetl.getAnfme() |
| | | , anfme |
| | | , wrkDetl.getSpecs() |
| | | , wrkDetl.getSuppCode())); |
| | | } |
| | | } |
| | | commands.add(ledCommand); |
| | | } |
| | |
| | | } |
| | | // 命令下发 ------------------------------------------------------------------------------- |
| | | if (!commands.isEmpty()) { |
| | | if (led.getId()>3){ |
| | | if (!MessageQueue.offer(SlaveType.Led, led.getId()-3, new Task(1, commands))) { |
| | | log.error("{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId()-3, led.getIp(), led.getPort()); |
| | | continue; |
| | | }else { |
| | | ledThread.setLedMk(false); |
| | | } |
| | | if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(1, commands))) { |
| | | log.error("{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | continue; |
| | | }else { |
| | | if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(1, commands))) { |
| | | log.error("{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | continue; |
| | | }else { |
| | | ledThread.setLedMk(false); |
| | | } |
| | | ledThread.setLedMk(false); |
| | | } |
| | | } |
| | | |
| | |
| | | * 其他 ===>> LED显示器复位,显示默认信息 |
| | | */ |
| | | public void ledReset() { |
| | | for (LedSlave led : slaveProperties.getLed()) { |
| | | |
| | | // 获取输送线plc线程 |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId()); |
| | | // 命令集合 |
| | | boolean reset = true; |
| | | for (Integer staNo : led.getStaArr()) { |
| | | // 获取叉车站点 |
| | | StaProtocol staProtocol = devpThread.getStation().get(staNo); |
| | | if (staProtocol == null) { |
| | | continue; |
| | | } |
| | | if (staProtocol.getWorkNo() != 0 && staProtocol.isLoading()) { |
| | | reset = false; |
| | | break; |
| | | } |
| | | } |
| | | // 获取led线程 |
| | | LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId()); |
| | | // led显示默认内容 |
| | | if (reset && !ledThread.isLedMk()) { |
| | | ledThread.setLedMk(true); |
| | | if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(4, new ArrayList<>()))) { |
| | | News.error(" - {}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | } else { |
| | | |
| | | } |
| | | } |
| | | } |
| | | // for (LedSlave led : slaveProperties.getLed()) { |
| | | // |
| | | // // 获取输送线plc线程 |
| | | // DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId()); |
| | | // // 命令集合 |
| | | // boolean reset = true; |
| | | // for (Integer staNo : led.getStaArr()) { |
| | | // // 获取叉车站点 |
| | | // StaProtocol staProtocol = devpThread.getStation().get(staNo); |
| | | // if (staProtocol == null) { |
| | | // continue; |
| | | // } |
| | | // if (staProtocol.getWorkNo() != 0 && staProtocol.isLoading()) { |
| | | // reset = false; |
| | | // break; |
| | | // } |
| | | // } |
| | | // // 获取led线程 |
| | | // LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId()); |
| | | // // led显示默认内容 |
| | | // if (reset && !ledThread.isLedMk()) { |
| | | // ledThread.setLedMk(true); |
| | | // if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(4, new ArrayList<>()))) { |
| | | // News.error(" - {}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | // } else { |
| | | // News.error("{}号LED命令下发成功!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | // ledThread.setLedMk(false); |
| | | // } |
| | | // } |
| | | // } |
| | | for (LedSlave led : slaveProperties.getLed()) { |
| | | // 获取输送线plc线程 |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId()); |
| | |
| | | LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId()); |
| | | // led显示默认内容 |
| | | if (reset && !ledThread.isLedMk()) { |
| | | ledThread.setLedMk(true); |
| | | ledThread.setLedMk(false); |
| | | if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(2, new ArrayList<>()))) { |
| | | News.error("{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | }else { |
| | | // News.error("{}号LED命令下发成功!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | MessageQueue.offer(SlaveType.Led, led.getId(), new Task(4, new ArrayList<>())); |
| | | ledThread.setLedMk(false); |
| | | } |
| | | } |
| | | } |