|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void locCheckOut(StockOutParam param, Long userId, Long hostId) { | 
|---|
|  |  |  | // 目标站点状态检测 | 
|---|
|  |  |  | BasDevp staNo = basDevpService.checkSiteStatus(param.getOutSite(), false, hostId); | 
|---|
|  |  |  | // 获取库位明细 | 
|---|
|  |  |  | List<LocDetlDto> locDetlDtos = new ArrayList<>(); | 
|---|
|  |  |  | for (StockOutParam.LocDetl paramLocDetl : param.getLocDetls()) { | 
|---|
|  |  |  | if (!Cools.isEmpty(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getCount())) { | 
|---|
|  |  |  | LocDetl one = locDetlService.selectItem(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getBatch(), hostId); | 
|---|
|  |  |  | if (null != one) locDetlDtos.add(new LocDetlDto(one, paramLocDetl.getCount())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!locDetlDtos.isEmpty()) { | 
|---|
|  |  |  | // 启动出库开始 107.盘点出库 | 
|---|
|  |  |  | stockOut(param.getOutSite(), locDetlDtos, IoWorkType.CHECK_OUT, userId, hostId); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | throw new CoolException("库位物料不存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public void stockOut(Integer staNo, List<LocDetlDto> locDetlDtos, IoWorkType ioWorkType, Long userId, Long hostId) { | 
|---|
|  |  |  | Date now = new Date(); | 
|---|
|  |  |  | 
|---|
|  |  |  | // 获取库位 | 
|---|
|  |  |  | LocMast locMast = locMastService.getOne(new LambdaQueryWrapper<LocMast>().eq(LocMast::getLocNo, dto.getLocNo()).eq(LocMast::getHostId, hostId)); | 
|---|
|  |  |  | // 获取路径 | 
|---|
|  |  |  | StaDesc staDesc = staDescService.getOne(new LambdaQueryWrapper<StaDesc>().eq(StaDesc::getTypeNo, ioType).eq(StaDesc::getDeviceStn, staNo).eq(StaDesc::getHostId, hostId)); | 
|---|
|  |  |  | StaDesc staDesc = staDescService.getOne(new LambdaQueryWrapper<StaDesc>().eq(StaDesc::getTypeNo, ioType).eq(StaDesc::getStnNo, staNo).eq(StaDesc::getHostId, hostId)); | 
|---|
|  |  |  | // 生成工作号 | 
|---|
|  |  |  | int workNo = commonService.getWorkNo(WorkNoType.getWorkNoType(ioType)); | 
|---|
|  |  |  | // 生成工作档 | 
|---|
|  |  |  | 
|---|
|  |  |  | wrkMast.setModiUser(String.valueOf(userId)); | 
|---|
|  |  |  | wrkMast.setModiTime(now); | 
|---|
|  |  |  | wrkMast.setHostId(hostId); | 
|---|
|  |  |  | wrkMast.setCrnNo(staDesc.getDeviceNo()); | 
|---|
|  |  |  | if (!wrkMastService.save(wrkMast)) { | 
|---|
|  |  |  | throw new CoolException("保存工作档失败,出库库位号:" + dto.getLocNo()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | // 获取路径 | 
|---|
|  |  |  | int ioType = taskDto.isAll() ? 101 : 103; | 
|---|
|  |  |  | // 获取路径 | 
|---|
|  |  |  | StaDesc staDesc = staDescService.getOne(new LambdaQueryWrapper<StaDesc>().eq(StaDesc::getTypeNo, ioType).eq(StaDesc::getDeviceStn, staNo).eq(StaDesc::getHostId, hostId)); | 
|---|
|  |  |  | StaDesc staDesc = staDescService.getOne(new LambdaQueryWrapper<StaDesc>().eq(StaDesc::getTypeNo, ioType).eq(StaDesc::getStnNo, staNo).eq(StaDesc::getHostId, hostId)); | 
|---|
|  |  |  | // 生成工作号 | 
|---|
|  |  |  | int workNo = commonService.getWorkNo(WorkNoType.getWorkNoType(ioType)); | 
|---|
|  |  |  | // 生成工作档 | 
|---|
|  |  |  | 
|---|
|  |  |  | wrkMast.setPicking("N"); // 拣料 | 
|---|
|  |  |  | wrkMast.setExitMk("N"); // 退出 | 
|---|
|  |  |  | wrkMast.setEmptyMk("N"); // 空板 | 
|---|
|  |  |  | wrkMast.setCrnNo(locMast.getCrnNo()); | 
|---|
|  |  |  | wrkMast.setBarcode(locMast.getBarcode()); | 
|---|
|  |  |  | wrkMast.setAppeUser(String.valueOf(userId)); // 操作人员数据 | 
|---|
|  |  |  | wrkMast.setAppeTime(now); | 
|---|
|  |  |  | 
|---|
|  |  |  | Order order = orderService.getOne(new LambdaQueryWrapper<Order>() | 
|---|
|  |  |  | .eq(Order::getOrderNo, locDto.getOrderNo()) | 
|---|
|  |  |  | .eq(Order::getHostId, hostId)); | 
|---|
|  |  |  | OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), locDto.getMatnr(), locDto.getBatch()); | 
|---|
|  |  |  | OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), locDto.getMatnr(), locDto.getBatch(),hostId); | 
|---|
|  |  |  | if (orderDetl == null) { | 
|---|
|  |  |  | orderDetl = orderDetlService.selectItem(order.getId(), locDto.getMatnr(), null); | 
|---|
|  |  |  | orderDetl = orderDetlService.selectItem(order.getId(), locDto.getMatnr(), null,hostId); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | LocDetl locDetl = locDetlService.selectItem(locDto.getLocNo(), locDto.getMatnr(), locDto.getBatch(), hostId); | 
|---|
|  |  |  | if (locDetl == null || locDetl.getAnfme() < locDto.getAnfme()) { | 
|---|
|  |  |  | 
|---|
|  |  |  | throw new CoolException("保存工作档明细失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 修改订单明细 | 
|---|
|  |  |  | if (!orderDetlService.increase(orderDetl.getOrderId(), hostId, orderDetl.getMatnr(), orderDetl.getBatch(), locDto.getAnfme())) { | 
|---|
|  |  |  | if (!orderDetlService.increaseWorkQty(orderDetl.getOrderId(), orderDetl.getMatnr(), orderDetl.getBatch(), locDto.getAnfme(), hostId)) { | 
|---|
|  |  |  | throw new CoolException("修改订单明细数量失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | orderService.updateSettle(orderDetl.getOrderId(), 2L, userId, hostId); | 
|---|
|  |  |  | 
|---|
|  |  |  | if (Cools.isEmpty(wrkMast)) { | 
|---|
|  |  |  | throw new CoolException(workNo + "工作档不存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (wrkMast.getIoType() == 300) { | 
|---|
|  |  |  | //RGV调度任务 | 
|---|
|  |  |  | //删除工作档 | 
|---|
|  |  |  | wrkMastService.removeById(wrkMast.getId()); | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String locNo = ""; // 待修改目标库位 | 
|---|
|  |  |  | String locSts = ""; // 待修改目标库位状态 | 
|---|
|  |  |  | // 入库取消(修改目标库位) | 
|---|
|  |  |  | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | throw new CoolException("当前工作状态无法取消"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 订单关联 | 
|---|
|  |  |  | List<WrkDetl> wrkDetls = wrkDetlService.list(new LambdaQueryWrapper<WrkDetl>().eq(WrkDetl::getWrkNo, wrkMast.getWrkNo()).eq(WrkDetl::getHostId, hostId)); | 
|---|
|  |  |  | for (WrkDetl wrkDetl : wrkDetls) { | 
|---|
|  |  |  | 
|---|
|  |  |  | if (!orderDetlService.decrease(wrkDetl.getOrderNo(), hostId, wrkDetl.getMatnr(), wrkDetl.getBatch(), wrkDetl.getAnfme())) { | 
|---|
|  |  |  | throw new CoolException("订单数据回滚失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //修改订单主表状态,没有作业数量时才可以修改 | 
|---|
|  |  |  | boolean flag = true; | 
|---|
|  |  |  | List<OrderDetl> orderDetls = orderDetlService.list(new LambdaQueryWrapper<OrderDetl>() | 
|---|
|  |  |  | .eq(OrderDetl::getOrderNo, wrkDetl.getOrderNo()) | 
|---|
|  |  |  | .eq(OrderDetl::getHostId, hostId)); | 
|---|
|  |  |  | for(OrderDetl orderDetl : orderDetls){ | 
|---|
|  |  |  | if(orderDetl.getWorkQty() > 0){ | 
|---|
|  |  |  | flag = false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(flag){ | 
|---|
|  |  |  | Order order = orderService.getOne(new LambdaQueryWrapper<Order>() | 
|---|
|  |  |  | .eq(Order::getOrderNo, wrkDetl.getOrderNo()) | 
|---|
|  |  |  | .eq(Order::getHostId, hostId)); | 
|---|
|  |  |  | if(!Cools.isEmpty(order) && order.getSettle()==2){ | 
|---|
|  |  |  | order.setSettle(1L); | 
|---|
|  |  |  | order.setUpdateBy(userId); | 
|---|
|  |  |  | order.setUpdateTime(new Date()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(!orderService.updateById(order)){ | 
|---|
|  |  |  | throw new CoolException("修改订单状态失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 取消操作人员记录 | 
|---|