自动化立体仓库 - WMS系统
whycq
2024-05-06 492ff19156b4b7b0d0af41a8ffe93f3c69248436
# 半成品单导入,生成调拨单
2个文件已修改
299 ■■■■■ 已修改文件
src/main/java/com/zy/asrs/controller/OrderController.java 143 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java 156 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/controller/OrderController.java
@@ -229,6 +229,7 @@
                list.add(dto);
                orderDetl.setOrderId(order.getId());
                orderDetl.setOrderNo(order.getOrderNo());
                orderDetl.setSource(param.getDocType().intValue());
                orderDetl.setCreateBy(getUserId());
                orderDetl.setCreateTime(now);
                orderDetl.setUpdateBy(getUserId());
@@ -240,6 +241,74 @@
                }
            }
        }
        if (param.getDocType().intValue() == 32) {
            order = new Order(
                    String.valueOf(snowflakeIdWorker.nextId()),    // 编号[非空]
                    "DB" + param.getOrderNo(),    // 订单编号
                    DateUtils.convert(now),    // 单据日期
                    33L,    // 单据类型
                    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,    // 状态
                    getUserId(),    // 添加人员
                    now,    // 添加时间
                    getUserId(),    // 修改人员
                    now,    // 修改时间
                    null    // 备注
            );
            if (!orderService.insert(order)) {
                throw new CoolException("生成半成品调拨单失败");
            }
            List<DetlDto> dbList = new ArrayList<>();
            for (OrderDetl orderDetl : param.getOrderDetlList()) {
                DetlDto dto = new DetlDto(orderDetl.getMatnr(), orderDetl.getBatch());
                if (DetlDto.has(dbList, dto)) {
                    OrderDetl item = orderDetlService.selectItem(order.getId(), orderDetl.getMatnr(), orderDetl.getBatch(),orderDetl.getThreeCode(),orderDetl.getDeadTime());
                    item.setAnfme(item.getAnfme() + orderDetl.getAnfme());
                    if (!orderDetlService.updateById(item)) {
                        throw new CoolException("生成半成品调拨单明细档失败");
                    }
                } else {
                    dbList.add(dto);
                    orderDetl.setOrderId(order.getId());
                    orderDetl.setOrderNo(order.getOrderNo());
                    orderDetl.setSource(param.getDocType().intValue());
                    orderDetl.setCreateBy(getUserId());
                    orderDetl.setCreateTime(now);
                    orderDetl.setUpdateBy(getUserId());
                    orderDetl.setUpdateTime(now);
                    orderDetl.setStatus(1);
                    orderDetl.setQty(0.0D);
                    if (!orderDetlService.insert(orderDetl)) {
                        throw new CoolException("生成半成品调拨单明细档失败");
                    }
                }
            }
        }
        return R.ok("订单添加成功");
    }
@@ -604,6 +673,80 @@
                    throw new CoolException("生成单据明细失败,请重新导入!");
                }
            }
            if (docType.getDocId().intValue() == 32) {
                String dbUuid = "DB" + uuid;
                Order order2 = orderService.selectByNo(dbUuid);
                if (null == order2) {
                    order2 = new Order(
                            String.valueOf(snowflakeIdWorker.nextId()),    // 编号[非空]
                            dbUuid,    // 订单编号
                            null,    // 单据日期
                            33L,    // 单据类型
                            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(order2)) {
                        throw new CoolException("生成单据主档失败,请重新导入!");
                    }
                }else {
                    order2.setSettle(order.getSettle() == 1L ? 1L : 2L );
                    orderService.updateById(order2);
                }
                OrderDetl orderDetl2 = orderDetlService.selectItem(order2.getId(), matnr, null,csocode,isocode);
                if (orderDetl2 == null) {
                    orderDetl2 = new OrderDetl();
                    orderDetl2.sync(mat);
                    orderDetl2.setSource(33);
                    orderDetl2.setBatch(null);
                    orderDetl2.setAnfme(anfme);
                    orderDetl2.setOrderId(order2.getId());
                    orderDetl2.setOrderNo(order2.getOrderNo());
                    orderDetl2.setCreateBy(userId);
                    orderDetl2.setCreateTime(now);
                    orderDetl2.setUpdateBy(userId);
                    orderDetl2.setUpdateTime(now);
                    orderDetl2.setThreeCode(csocode);
                    orderDetl2.setDeadTime(isocode);
                    orderDetl2.setStatus(1);
                    orderDetl2.setQty(0.0D);
                    if (!orderDetlService.insert(orderDetl2)) {
                        throw new CoolException("生成单据明细失败,请重新导入!");
                    }
                } else {
                    if(!orderDetlService.increaseAnfme(order2.getId(), matnr, null, anfme,csocode,isocode)) {
                        throw new CoolException("生成单据明细失败,请重新导入!");
                    }
                }
            }
        }
        return R.ok("导入成功");
    }
src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java
@@ -133,6 +133,7 @@
            orderDetl.setAnfme(detlDto.getAnfme());
            orderDetl.setOrderId(order.getId());
            orderDetl.setOrderNo(order.getOrderNo());
            orderDetl.setSource(docType.getDocId().intValue());
            orderDetl.setCreateBy(9527L);
            orderDetl.setCreateTime(now);
            orderDetl.setUpdateBy(9527L);
@@ -143,6 +144,84 @@
                throw new CoolException("生成单据明细失败,请联系管理员");
            }
        }
// 生成调拨单
        if (docType.getDocId().intValue() == 32) {
            order = new Order(
                    String.valueOf(snowflakeIdWorker.nextId()),    // 编号[非空]
                    "DB" + param.getOrderNo(),    // 订单编号
                    DateUtils.convert(now),    // 单据日期
                    33L,    // 单据类型
                    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,    // 状态
                    9527L,    // 添加人员
                    now,    // 添加时间
                    9527L,    // 修改人员
                    now,    // 修改时间
                    null    // 备注
            );
            if (!orderService.insert(order)) {
                throw new CoolException("生成半成品调拨单失败");
            }
            List<DetlDto> dbList = new ArrayList<>();
            List<DetlDto> dbOrderDetails = param.getOrderDetails();
            // 单据明细档
            for (DetlDto detail : orderDetails) {
                DetlDto dto = new DetlDto(detail.getMatnr(), detail.getBatch(), detail.getAnfme());
                if (DetlDto.has(dbList, dto)) {
                    DetlDto detlDto = DetlDto.find(dbList, dto.getMatnr(), dto.getBatch(),dto.getCsocode(),dto.getIsoseq(),null);
                    assert detlDto != null;
                    detlDto.setAnfme(detlDto.getAnfme() + detail.getAnfme());
                } else {
                    dbList.add(dto);
                }
            }
            for (DetlDto detlDto : dbList) {
                Mat mat = matService.selectByMatnr(detlDto.getMatnr());
                if (Cools.isEmpty(mat)) {
                    throw new CoolException(detlDto.getMatnr() + "编号商品检索失败,请先添加商品");
                }
                OrderDetl orderDetl = new OrderDetl();
                orderDetl.sync(mat);
                orderDetl.setBatch(detlDto.getBatch());
                orderDetl.setAnfme(detlDto.getAnfme());
                orderDetl.setOrderId(order.getId());
                orderDetl.setOrderNo(order.getOrderNo());
                orderDetl.setSource(docType.getDocId().intValue());
                orderDetl.setCreateBy(9527L);
                orderDetl.setCreateTime(now);
                orderDetl.setUpdateBy(9527L);
                orderDetl.setUpdateTime(now);
                orderDetl.setStatus(1);
                orderDetl.setQty(0.0D);
                if (!orderDetlService.insert(orderDetl)) {
                    throw new CoolException("生成半成品调拨单明细档失败,请联系管理员");
                }
            }
        }
    }
    @Override
@@ -268,6 +347,7 @@
            orderDetl.setAnfme(detlDto.getAnfme());
            orderDetl.setOrderId(order.getId());
            orderDetl.setOrderNo(order.getOrderNo());
            orderDetl.setSource(docType.getDocId().intValue());
            orderDetl.setCreateBy(9527L);
            orderDetl.setCreateTime(now);
            orderDetl.setUpdateBy(9527L);
@@ -278,6 +358,82 @@
                throw new CoolException("生成单据明细失败,请联系管理员");
            }
        }
        if (docType.getDocId().intValue() == 32) {
            order = new Order(
                    String.valueOf(snowflakeIdWorker.nextId()),    // 编号[非空]
                    "DB" + param.getOrderNo(),    // 订单编号
                    DateUtils.convert(now),    // 单据日期
                    33L,    // 单据类型
                    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,    // 状态
                    9527L,    // 添加人员
                    now,    // 添加时间
                    9527L,    // 修改人员
                    now,    // 修改时间
                    null    // 备注
            );
            if (!orderService.insert(order)) {
                throw new CoolException("生成半成品调拨单失败");
            }
            List<DetlDto> dbList = new ArrayList<>();
            List<DetlDto> dbOrderDetails = param.getOrderDetails();
            // 单据明细档
            for (DetlDto detail : orderDetails) {
                DetlDto dto = new DetlDto(detail.getMatnr(), detail.getBatch(), detail.getAnfme());
                if (DetlDto.has(dbList, dto)) {
                    DetlDto detlDto = DetlDto.find(dbList, dto.getMatnr(), dto.getBatch(),dto.getCsocode(),dto.getIsoseq(),null);
                    assert detlDto != null;
                    detlDto.setAnfme(detlDto.getAnfme() + detail.getAnfme());
                } else {
                    dbList.add(dto);
                }
            }
            for (DetlDto detlDto : dbList) {
                Mat mat = matService.selectByMatnr(detlDto.getMatnr());
                if (Cools.isEmpty(mat)) {
                    throw new CoolException(detlDto.getMatnr() + "编号商品检索失败,请先添加商品");
                }
                OrderDetl orderDetl = new OrderDetl();
                orderDetl.sync(mat);
                orderDetl.setBatch(detlDto.getBatch());
                orderDetl.setAnfme(detlDto.getAnfme());
                orderDetl.setOrderId(order.getId());
                orderDetl.setOrderNo(order.getOrderNo());
                orderDetl.setSource(docType.getDocId().intValue());
                orderDetl.setCreateBy(9527L);
                orderDetl.setCreateTime(now);
                orderDetl.setUpdateBy(9527L);
                orderDetl.setUpdateTime(now);
                orderDetl.setStatus(1);
                orderDetl.setQty(0.0D);
                if (!orderDetlService.insert(orderDetl)) {
                    throw new CoolException("生成半成品调拨单明细档失败,请联系管理员");
                }
            }
        }
    }
    @Override