| | |
| | | @Autowired |
| | | private BasStationServiceImpl basStationService; |
| | | |
| | | @Autowired |
| | | private LocCacheDetlService locCacheDetlService; |
| | | |
| | | public ReturnT<String> start(WrkMast wrkMast) { |
| | | // 4.入库完成 |
| | | if (wrkMast.getWrkSts() == 4) { |
| | |
| | | } |
| | | } else { |
| | | locDetl = new LocDetl(); |
| | | locDetl.sync(wrkDetl); |
| | | BeanUtils.copyProperties(wrkDetl, locDetl); |
| | | // locDetl.sync(wrkDetl); |
| | | locDetl.setLocNo(wrkMast.getLocNo()); // 库位号 |
| | | locDetl.setAnfme(wrkDetl.getAnfme()); // 数量 |
| | | locDetl.setZpallet(wrkDetl.getZpallet()); // 托盘条码 |
| | |
| | | } |
| | | } else { |
| | | locDetl = new LocDetl(); |
| | | locDetl.sync(wrkDetl); |
| | | BeanUtils.copyProperties(wrkDetl, locDetl); |
| | | // locDetl.sync(wrkDetl); |
| | | locDetl.setLocNo(wrkMast.getLocNo()); // 库位号 |
| | | locDetl.setAnfme(wrkDetl.getAnfme()); // 数量 |
| | | locDetl.setZpallet(wrkDetl.getZpallet()); // 托盘条码 |
| | |
| | | } |
| | | } else { |
| | | locDetl = new LocDetl(); |
| | | locDetl.sync(wrkDetl); |
| | | BeanUtils.copyProperties(wrkDetl, locDetl); |
| | | // locDetl.sync(wrkDetl); |
| | | locDetl.setLocNo(wrkMast.getLocNo()); // 库位号 |
| | | locDetl.setAnfme(wrkDetl.getAnfme()); // 数量 |
| | | locDetl.setZpallet(wrkDetl.getZpallet()); // 托盘条码 |
| | |
| | | * @description: AGV出库任务 |
| | | * @version 1.0 |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public ReturnT<String> agvDoOut(Task task) { |
| | | if (task.getIoType().equals(101)) { |
| | | Date now = new Date(); |
| | |
| | | if (wrkDetls101.isEmpty()) { |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | return FAIL.setMsg("全板出库 ===>> 工作明细档为空; [workNo=" + task.getWrkNo() + "],[locNo=" + task.getSourceLocNo() + "]"); |
| | | } |
| | | for (TaskDetl wrkDetl : wrkDetls101) { |
| | | // 更新订单完成数量 |
| | | OrderDetlPakout orderDetlPakout = orderDetlPakoutService.selectItem(wrkDetl.getOrderNo(), wrkDetl.getMatnr(), wrkDetl.getBatch(), wrkDetl.getBrand(), wrkDetl.getStandby1(), wrkDetl.getStandby2(), wrkDetl.getStandby3(), |
| | | wrkDetl.getBoxType1(), wrkDetl.getBoxType2(), wrkDetl.getBoxType3()); |
| | | if (orderDetlPakout == null) { |
| | | orderDetlPakout = orderDetlPakoutService.selectItem(wrkDetl.getOrderNo(), wrkDetl.getMatnr(), wrkDetl.getBatch(), wrkDetl.getBrand(), wrkDetl.getStandby1(), wrkDetl.getStandby2(), wrkDetl.getStandby3(), |
| | | wrkDetl.getBoxType1(), wrkDetl.getBoxType2(), wrkDetl.getBoxType3()); |
| | | } |
| | | try { |
| | | if (!Cools.isEmpty(orderDetlPakout)) { |
| | | if (!orderDetlPakoutService.increaseQtyByOrderNo(wrkDetl.getOrderNo(), wrkDetl.getMatnr(), |
| | | orderDetlPakout.getBatch(), wrkDetl.getBrand(), wrkDetl.getStandby1(), wrkDetl.getStandby2(), wrkDetl.getStandby3(), |
| | | wrkDetl.getBoxType1(), wrkDetl.getBoxType2(), wrkDetl.getBoxType3(), wrkDetl.getAnfme())) { |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | return FAIL.setMsg("全板出库 ===>> 更新订单完成数量失败; [workNo=" + task.getWrkNo() + "],[locNo=" + task.getSourceLocNo() + "]"); |
| | | } |
| | | } |
| | | } catch (Exception ignore) { |
| | | } |
| | | } |
| | | // 删除工作档源库位的库存明细 |
| | | if (!locDetlService.delete(new EntityWrapper<LocDetl>().eq("loc_no", task.getSourceLocNo()))) { |
| | |
| | | } else { |
| | | throw new CoolException("当前库位状态" + locMast.getLocSts() + ", 无法执行出库操作!!"); |
| | | } |
| | | |
| | | BasStation devNo = basStationService.selectOne(new EntityWrapper<BasStation>().eq("dev_no", task.getStaNo())); |
| | | if (Objects.isNull(devNo)) { |
| | | throw new CoolException("站点:" + task.getSourceStaNo() + ", 不存在!!"); |
| | | } |
| | | devNo.setLocSts(LocStsType.LOC_STS_TYPE_F.type); |
| | | devNo.setModiTime(new Date()); |
| | | if (!basStationService.updateById(devNo)) { |
| | | throw new CoolException("站点信息修改失败!!"); |
| | | } |
| | | task.setWrkSts(15L); |
| | | if (!taskService.updateById(task)) { |
| | | throw new CoolException("任务状态修改失败!!"); |
| | | } |
| | | } else { |
| | | } else if(task.getIoType().equals(53) || task.getIoType().equals(54) || task.getIoType().equals(57)){ |
| | | LocCache locCache = locCacheService.selectOne(new EntityWrapper<LocCache>().eq("loc_no", task.getSourceLocNo())); |
| | | if (Objects.isNull(locCache)) { |
| | | throw new CoolException("数据错误,库位不存在!!"); |
| | | } |
| | | if (!locCache.getLocSts().equals(LocStsType.LOC_STS_TYPE_R.type)) { |
| | | throw new CoolException("当前库位状态为:" + LocStsType.LOC_STS_TYPE_R.type + "." + LocStsType.LOC_STS_TYPE_R.desc + ",不是出库预约状态"); |
| | | } |
| | | |
| | | locCache.setLocSts(LocStsType.LOC_STS_TYPE_O.type); |
| | | locCache.setModiTime(new Date()); |
| | | locCache.setBarcode(null); |
| | | locCache.setModiTime(new Date()); |
| | | locCache.setIoTime(new Date()); |
| | | if (!locCacheService.updateById(locCache)) { |
| | | throw new CoolException("库位状态修改失败!"); |
| | | } |
| | | |
| | | boolean deleted = locCacheDetlService.delete(new EntityWrapper<LocCacheDetl>().eq("loc_id", locCache.getId())); |
| | | |
| | | if (!deleted){ |
| | | throw new CoolException("库位明细删除失败!"); |
| | | } |
| | | |
| | | task.setWrkSts(15L); |
| | | task.setModiTime(new Date()); |
| | | if (!taskService.updateById(task)) { |
| | | throw new CoolException("任务状态修改失败!!"); |
| | | } |
| | | } |
| | | return SUCCESS; |
| | | } |
| | |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public ReturnT<String> agvDoIn(Task wrkMast) { |
| | | LocCache locCache = locCacheService.selectOne(new EntityWrapper<LocCache>().eq("loc_no", wrkMast.getLocNo())); |
| | | if (Objects.isNull(locCache)) { |
| | | throw new CoolException("数据错误,库位不存在!!"); |
| | | } |
| | | if (!locCache.getLocSts().equals(LocStsType.LOC_STS_TYPE_S.type)) { |
| | | throw new CoolException("当前库位状态为:" + LocStsType.LOC_STS_TYPE_S.type + "." + LocStsType.LOC_STS_TYPE_S.desc + ",不是出库预约状态"); |
| | | } |
| | | List<WaitPakin> apallet = waitPakinService.selectList(new EntityWrapper<WaitPakin>().eq("zpallet", wrkMast.getBarcode())); |
| | | if (Objects.isNull(apallet)) { |
| | | throw new CoolException("数据错误:组托数据不存在!!"); |
| | | } |
| | | apallet.forEach(pakin -> { |
| | | LocDetl detl = new LocDetl(); |
| | | BeanUtils.copyProperties(pakin, detl); |
| | | detl.setBarcode(pakin.getBarcode()) |
| | | .setAnfme(pakin.getAnfme()) |
| | | .setBrand(pakin.getBrand()) |
| | | .setAppeTime(new Date()) |
| | | .setSpecs(pakin.getSpecs()) |
| | | .setColor(pakin.getColor()) |
| | | .setLocId(locCache.getId()) |
| | | .setLocNo(locCache.getLocNo()) |
| | | .setAreaId(locCache.getAreaId()) |
| | | .setAreaName(locCache.getAreaName()) |
| | | .setUnit(pakin.getUnit()) |
| | | .setBatch(pakin.getBatch()); |
| | | if (!locDetlService.insert(detl)) { |
| | | throw new CoolException("库位明细保存失败!!"); |
| | | if (wrkMast.getIoType().equals(1)) { |
| | | LocCache locCache = locCacheService.selectOne(new EntityWrapper<LocCache>().eq("loc_no", wrkMast.getLocNo())); |
| | | if (Objects.isNull(locCache)) { |
| | | throw new CoolException("数据错误,库位不存在!!"); |
| | | } |
| | | }); |
| | | if (!locCache.getLocSts().equals(LocStsType.LOC_STS_TYPE_S.type)) { |
| | | throw new CoolException("当前库位状态为:" + LocStsType.LOC_STS_TYPE_S.type + "." + LocStsType.LOC_STS_TYPE_S.desc + ",不是出库预约状态"); |
| | | } |
| | | List<TaskDetl> taskDetls = taskDetlService.selectList(new EntityWrapper<TaskDetl>().eq("task_id", wrkMast.getId())); |
| | | if (Objects.isNull(taskDetls)) { |
| | | throw new CoolException("数据错误:组托数据不存在!!"); |
| | | } |
| | | taskDetls.forEach(pakin -> { |
| | | LocCacheDetl detl = new LocCacheDetl(); |
| | | BeanUtils.copyProperties(pakin, detl); |
| | | detl.setBarcode(pakin.getBarcode()) |
| | | .setLocId(locCache.getId()) |
| | | .setAnfme(pakin.getAnfme()) |
| | | .setBrand(pakin.getBrand()) |
| | | .setAppeTime(new Date()) |
| | | .setSpecs(pakin.getSpecs()) |
| | | .setColor(pakin.getColor()) |
| | | .setLocNo(locCache.getLocNo()) |
| | | .setAreaId(locCache.getAreaId()) |
| | | .setAreaName(locCache.getAreaName()) |
| | | .setUnit(pakin.getUnit()) |
| | | .setBatch(pakin.getBatch()); |
| | | if (!locCacheDetlService.insert(detl)) { |
| | | throw new CoolException("库位明细保存失败!!"); |
| | | } |
| | | }); |
| | | |
| | | locCache.setLocSts(LocStsType.LOC_STS_TYPE_F.type); |
| | | locCache.setModiTime(new Date()); |
| | | locCache.setBarcode(wrkMast.getBarcode()); |
| | | locCache.setModiTime(new Date()); |
| | | locCache.setIoTime(new Date()); |
| | | if (!locCacheService.updateById(locCache)) { |
| | | throw new CoolException("库位状态修改失败!"); |
| | | } |
| | | wrkMast.setWrkSts(5L); |
| | | wrkMast.setModiTime(new Date()); |
| | | if (!taskService.updateById(wrkMast)) { |
| | | throw new CoolException("任务状态修改失败!!"); |
| | | locCache.setLocSts(LocStsType.LOC_STS_TYPE_F.type); |
| | | locCache.setModiTime(new Date()); |
| | | locCache.setBarcode(wrkMast.getBarcode()); |
| | | locCache.setModiTime(new Date()); |
| | | locCache.setIoTime(new Date()); |
| | | if (!locCacheService.updateById(locCache)) { |
| | | throw new CoolException("库位状态修改失败!"); |
| | | } |
| | | wrkMast.setWrkSts(5L); |
| | | wrkMast.setModiTime(new Date()); |
| | | if (!taskService.updateById(wrkMast)) { |
| | | throw new CoolException("任务状态修改失败!!"); |
| | | } |
| | | }else { |
| | | throw new CoolException("数据错误:ioType不存在!!"); |
| | | } |
| | | |
| | | Set<Long> list = apallet.stream().map(WaitPakin::getOrderId).collect(Collectors.toSet()); |
| | | List<OrderPakin> pakins = orderPakinService.selectList(new EntityWrapper<OrderPakin>().in("id", list)); |
| | | if (Objects.isNull(pakins) || pakins.isEmpty()) { |
| | | throw new CoolException("单据不存在!!"); |
| | | } |
| | | |
| | | return SUCCESS; |
| | | } |