自动化立体仓库 - WMS系统
LSH
2023-09-08 257888003e8a485d13891490a912f1547f10dca6
src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java
@@ -46,6 +46,8 @@
    @Autowired
    private WrkMastService wrkMastService;
    @Autowired
    private DocTypeService docTypeService;
    @Autowired
    private WrkDetlService wrkDetlService;
    @Autowired
    private BasDevpService basDevpService;
@@ -179,6 +181,92 @@
            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,    // 物流单号
                    1L,    // 订单状态
                    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.getCount());//出库数量
                orderDetl.setModel(locDetl.getModel());//批次
                orderDetl.setSpecs(locDetl.getSpecs());//规格
                orderDetl.setBrand(locDetl.getBrand());//木箱类型
                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("生成单据明细失败,请联系管理员");
                }
            }
        } else {
            throw new CoolException("订单号重复,订单"+param.getOrderNo()+"已存在!!!");
        }
    }
    @Override
    @Transactional