自动化立体仓库 - WMS系统
zhang
2025-06-12 f915165192845acd12aca37fecec6976eb1f870c
src/main/java/com/zy/asrs/task/handler/WorkMastHandler.java
@@ -2,6 +2,9 @@
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.Cools;
import com.core.common.DateUtils;
import com.core.common.SnowflakeIdWorker;
import com.core.exception.CoolException;
import com.zy.asrs.entity.*;
import com.zy.asrs.service.*;
import com.zy.asrs.task.AbstractHandler;
@@ -42,6 +45,13 @@
    private OrderDetlPakoutService orderDetlPakoutService;
    @Autowired
    private OrderService orderService;
    @Autowired
    private StoreTypeService storeTypeService;
    @Autowired
    private SnowflakeIdWorker snowflakeIdWorker;
    @Autowired
    private DocTypeService docTypeService;
    public ReturnT<String> start(WrkMast wrkMast) {
        // 4.入库完成
@@ -204,6 +214,66 @@
                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                        return FAIL.setMsg("拣料入库 ===>> 工作明细档为空; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getLocNo() + "]");
                    }
                    // 判断是否为转库出库
                    StoreType storeType = null;
                    Order order = null;
                    if (!Cools.isEmpty(wrkMast.getPacked())) {
                        storeType = storeTypeService.selectById(wrkMast.getPacked());
                        if (null != storeType) {
                            DocType docType = docTypeService.selectOne(new EntityWrapper<DocType>().eq("doc_name", "转库-出库"));
                            String convert = DateUtils.convert(now, DateUtils.yyyyMMdd);
                            order = new Order(
                                    String.valueOf(snowflakeIdWorker.nextId()),    // 编号[非空]
                                    convert + "_" + wrkMast.getPacked() + "_" + wrkMast.getWrkNo(),    // 订单编号
                                    DateUtils.convert(now),    // 单据日期
                                    docType.getDocId(),    // 单据类型
                                    storeType.getStoreId(),    // 项目编号
                                    storeType.getStoreName(),    //
                                    null,    // 调拨项目编号
                                    null,    // 初始票据号
                                    null,    // 票据号
                                    null,    // 客户编号
                                    null,    // 客户
                                    null,    // 联系方式
                                    wrkMast.getAppeUser$(),    // 操作人员
                                    null,    // 合计金额
                                    null,    // 优惠率
                                    null,    // 优惠金额
                                    null,    // 销售或采购费用合计
                                    null,    // 实付金额
                                    null,    // 付款类型
                                    null,    // 业务员
                                    null,    // 结算天数
                                    null,    // 邮费支付类型
                                    null,    // 邮费
                                    null,    // 付款时间
                                    null,    // 发货时间
                                    null,    // 物流名称
                                    null,    // 物流单号
                                    1L,    // 订单状态
                                    4,    // 状态
                                    wrkMast.getAppeUser(),    // 添加人员
                                    now,    // 添加时间
                                    wrkMast.getAppeUser(),    // 修改人员
                                    now,    // 修改时间
                                    null,    // 备注
                                    docType.getPakin() == 1 ? 1 : 2
                            );
                            if (!orderService.insert(order)) {
                                throw new CoolException("保存订单主档失败");
                            }
                        }
                    }
                    for (WrkDetl wrkDetl : wrkDetls53) {
                        LocDetl locDetl = locDetlService.selectItem(locMast.getLocNo(), wrkDetl.getMatnr(), wrkDetl.getBatch(), wrkDetl.getBrand(), wrkDetl.getStandby1(), wrkDetl.getStandby2(), wrkDetl.getStandby3(), wrkDetl.getBoxType1(), wrkDetl.getBoxType2(), wrkDetl.getBoxType3());
@@ -443,7 +513,73 @@
                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                        return FAIL.setMsg("全板出库 ===>> 工作明细档为空; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getSourceLocNo() + "]");
                    }
                    // 判断是否为转库出库
                    StoreType storeType = null;
                    Order order = null;
                    if (!Cools.isEmpty(wrkMast.getPacked())) {
                        storeType = storeTypeService.selectById(wrkMast.getPacked());
                        if (null != storeType) {
                            DocType docType = docTypeService.selectOne(new EntityWrapper<DocType>().eq("doc_name", "转库-出库"));
                            String convert = DateUtils.convert(now, DateUtils.yyyyMMdd);
                            order = new Order(
                                    String.valueOf(snowflakeIdWorker.nextId()),    // 编号[非空]
                                    convert + "_" + wrkMast.getPacked() + "_" + wrkMast.getWrkNo(),    // 订单编号
                                    DateUtils.convert(now),    // 单据日期
                                    docType.getDocId(),    // 单据类型
                                    storeType.getStoreId(),    // 项目编号
                                    storeType.getStoreName(),    //
                                    null,    // 调拨项目编号
                                    null,    // 初始票据号
                                    null,    // 票据号
                                    null,    // 客户编号
                                    null,    // 客户
                                    null,    // 联系方式
                                    wrkMast.getAppeUser$(),    // 操作人员
                                    null,    // 合计金额
                                    null,    // 优惠率
                                    null,    // 优惠金额
                                    null,    // 销售或采购费用合计
                                    null,    // 实付金额
                                    null,    // 付款类型
                                    null,    // 业务员
                                    null,    // 结算天数
                                    null,    // 邮费支付类型
                                    null,    // 邮费
                                    null,    // 付款时间
                                    null,    // 发货时间
                                    null,    // 物流名称
                                    null,    // 物流单号
                                    1L,    // 订单状态
                                    4,    // 状态
                                    wrkMast.getAppeUser(),    // 添加人员
                                    now,    // 添加时间
                                    wrkMast.getAppeUser(),    // 修改人员
                                    now,    // 修改时间
                                    null,    // 备注
                                    docType.getPakin() == 1 ? 1 : 2
                            );
                            if (!orderService.insert(order)) {
                                throw new CoolException("保存订单主档失败");
                            }
                        }
                    }
                    for (WrkDetl wrkDetl : wrkDetls101) {
                        if (storeType != null) {
                            OrderDetl orderDetl = new OrderDetl();
                            orderDetl.sync(wrkDetl);
                            orderDetl.setOrderId(order.getId());
                            orderDetl.setOrderNo(order.getOrderNo());
                            orderDetl.setCreateBy(order.getCreateBy());
                            orderDetl.setCreateTime(now);
                            orderDetl.setUpdateBy(order.getCreateBy());
                            orderDetl.setUpdateTime(now);
                            orderDetl.setStatus(1);
                            orderDetl.setQty(wrkDetl.getAnfme());
                            if (!orderDetlService.insert(orderDetl)) {
                                throw new CoolException("保存订单明细档失败");
                            }
                        } else {
                        // 更新订单完成数量
                        //addOrderDetlQty(wrkMast, wrkDetl);
                        OrderDetlPakout orderDetlPakout;
@@ -468,6 +604,8 @@
                        } catch (Exception ignore) {
                        }
                    }
                    }
                    // 删除工作档源库位的库存明细
                    if (!locDetlService.delete(new EntityWrapper<LocDetl>().eq("loc_no", wrkMast.getSourceLocNo()))) {
//                        exceptionHandle("全板出库 ===>> 删除库存明细失败;[workNo={0}],[sourceLocNo={1}]", wrkMast.getWrkNo(), wrkMast.getSourceLocNo());