| | |
| | | import com.zy.asrs.entity.param.LocDetlAdjustParam; |
| | | import com.zy.asrs.entity.param.StockOutParam; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.OutboundAllocationUtil; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.model.*; |
| | | import com.zy.common.model.enums.IoWorkType; |
| | |
| | | private MatService matService; |
| | | @Autowired |
| | | private WrkMastService wrkMastService; |
| | | @Autowired |
| | | private DocTypeService docTypeService; |
| | | @Autowired |
| | | private WrkDetlService wrkDetlService; |
| | | @Autowired |
| | |
| | | BasDevp sourceStaNo = basDevpService.checkSiteStatus(param.getDevpNo(), true); |
| | | // 检索库位 |
| | | LocTypeDto locTypeDto = new LocTypeDto(sourceStaNo); |
| | | List<String> matnrs = param.getList().stream().map(FullStoreParam.MatCodeStore::getMatnr).distinct().collect(Collectors.toList()); |
| | | StartupDto dto = commonService.getLocNo(DEFAULT_ROW_NO_TYPE, 1, param.getDevpNo(), matnrs, locTypeDto, 0); |
| | | // List<String> matnrs = param.getList().stream().map(FullStoreParam.MatCodeStore::getMatnr).distinct().collect(Collectors.toList()); |
| | | StartupDto dto = commonService.getLocNo(DEFAULT_ROW_NO_TYPE, 1, param.getDevpNo(), null, locTypeDto, 0); |
| | | // 生成工作号 |
| | | int workNo = dto.getWorkNo(); |
| | | // 生成工作档 |
| | |
| | | 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()); |
| | | if (null != one) locDetlDtos.add(new LocDetlDto(one, paramLocDetl.getCount())); |
| | | if (null != one) locDetlDtos.add(new LocDetlDto(one, paramLocDetl.getCount(), param.getOrderNo())); |
| | | } |
| | | } |
| | | if (!locDetlDtos.isEmpty()) { |
| | |
| | | throw new CoolException("库存不存在"); |
| | | } |
| | | } |
| | | @Override |
| | | @Transactional |
| | | public void startupFullTakeStoreOrder(StockOutParam param, Long userId) { |
| | | if (Cools.isEmpty(param) || Cools.isEmpty(param.getOrderNo()) || Cools.isEmpty(param.getLocDetls())){ |
| | | throw new CoolException("参数为空"); |
| | | } |
| | | DocType docType = docTypeService.selectOrAdd("手动出库单", Boolean.FALSE); |
| | | Order order = orderService.selectByNo(param.getOrderNo()); |
| | | if (Cools.isEmpty(order)){ |
| | | Date now = new Date(); |
| | | order = new Order( |
| | | String.valueOf(snowflakeIdWorker.nextId()), // 编号[非空] |
| | | param.getOrderNo(), // 订单编号 |
| | | DateUtils.convert(now), // 单据日期 |
| | | docType.getDocId(), // 单据类型 |
| | | null, // 项目编号 |
| | | null, // |
| | | null, // 调拨项目编号 |
| | | null, // 初始票据号 |
| | | null, // 票据号 |
| | | null, // 客户编号 |
| | | null, // 客户 |
| | | null, // 联系方式 |
| | | null, // 操作人员 |
| | | null, // 合计金额 |
| | | null, // 优惠率 |
| | | null, // 优惠金额 |
| | | null, // 销售或采购费用合计 |
| | | null, // 实付金额 |
| | | null, // 付款类型 |
| | | null, // 业务员 |
| | | null, // 结算天数 |
| | | null, // 邮费支付类型 |
| | | null, // 邮费 |
| | | null, // 付款时间 |
| | | null, // 发货时间 |
| | | null, // 物流名称 |
| | | null, // 物流单号 |
| | | 2L, // 订单状态 |
| | | 1, // 状态 |
| | | userId, // 添加人员 |
| | | now, // 添加时间 |
| | | userId, // 修改人员 |
| | | now, // 修改时间 |
| | | null // 备注 |
| | | ); |
| | | if (!orderService.insert(order)) { |
| | | throw new CoolException("保存订单主档失败"); |
| | | } |
| | | // 单据明细档 |
| | | List<DetlDto> list = new ArrayList<>(); |
| | | List<StockOutParam.LocDetl> locDetls = param.getLocDetls(); |
| | | int i=0; |
| | | for (StockOutParam.LocDetl locDetl : locDetls) { |
| | | i++; |
| | | Mat mat = matService.selectByMatnr(locDetl.getMatnr()); |
| | | if (Cools.isEmpty(mat)) { |
| | | throw new CoolException(locDetl.getMatnr() + "物料编码检索失败,请先添加商品"); |
| | | } |
| | | OrderDetl orderDetl = new OrderDetl(); |
| | | orderDetl.sync(mat); |
| | | orderDetl.setSuppCode(String.valueOf(i)); // 行号 |
| | | orderDetl.setManu(locDetl.getLocNo()); //库位号 |
| | | orderDetl.setBatch(locDetl.getBatch()); //木箱编码 |
| | | orderDetl.setAnfme(locDetl.getAnfme());//出库数量 |
| | | orderDetl.setModel(locDetl.getModel());//批次 |
| | | orderDetl.setSpecs(locDetl.getSpecs());//规格 |
| | | orderDetl.setBrand(locDetl.getBrand());//木箱类型 |
| | | orderDetl.setWorkQty(locDetl.getAnfme()); |
| | | orderDetl.setOrderId(order.getId()); |
| | | orderDetl.setOrderNo(order.getOrderNo()); |
| | | orderDetl.setCreateBy(userId); |
| | | orderDetl.setCreateTime(now); |
| | | orderDetl.setUpdateBy(userId); |
| | | orderDetl.setUpdateTime(now); |
| | | orderDetl.setStatus(1); |
| | | orderDetl.setQty(0.0D); |
| | | if (!orderDetlService.insert(orderDetl)) { |
| | | throw new CoolException("生成单据明细失败,请联系管理员"); |
| | | } |
| | | } |
| | | |
| | | List<StockOutParam> stockOutParams = OutboundAllocationUtil.OutboundClassification(param); |
| | | for (StockOutParam stockOutParam : stockOutParams){ |
| | | startupFullTakeStore(stockOutParam,userId); |
| | | } |
| | | |
| | | } else { |
| | | throw new CoolException("订单号重复,订单"+param.getOrderNo()+"已存在!!!"); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | if (detlDto.getCount()==null || detlDto.getCount() <= 0.0D) {continue;} |
| | | WrkDetl wrkDetl = new WrkDetl(); |
| | | wrkDetl.sync(detlDto.getLocDetl()); |
| | | wrkDetl.setOrderNo(""); // 手动出库不需要带出库存中的单据编号 |
| | | wrkDetl.setOrderNo(detlDto.getOrderNo()); // 手动出库不需要带出库存中的单据编号 |
| | | wrkDetl.setWrkNo(workNo); |
| | | wrkDetl.setIoTime(now); |
| | | Double anfme = ioType==101?detlDto.getLocDetl().getAnfme():detlDto.getCount(); |
| | |
| | | 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()); |
| | | if (null != one) locDetlDtos.add(new LocDetlDto(one, paramLocDetl.getCount())); |
| | | if (null != one) locDetlDtos.add(new LocDetlDto(one, paramLocDetl.getCount(),param.getOrderNo())); |
| | | } |
| | | } |
| | | if (!locDetlDtos.isEmpty()) { |
| | |
| | | waitPakin.setIoStatus("N"); |
| | | waitPakin.setLocNo(""); |
| | | waitPakinService.update(waitPakin, new EntityWrapper<WaitPakin>() |
| | | .eq("order_no", waitPakin.getOrderNo()) |
| | | // .eq("order_no", waitPakin.getOrderNo()) |
| | | .eq("zpallet",waitPakin.getZpallet()) |
| | | .eq("matnr", waitPakin.getMatnr()) |
| | | .eq("batch", waitPakin.getBatch())); |
| | | } |