From 3ced8e35df3b67a8e22a63bb1f330030e67fde4c Mon Sep 17 00:00:00 2001 From: "zangch@mesnac.com" Date: Thu, 21 Aug 2025 14:12:12 +0800 Subject: [PATCH] =?UTF-8?q?refactor(wms):=20=E4=BC=98=E5=8C=96=E5=AE=9E?= =?UTF-8?q?=E4=BD=93=E7=B1=BB=E5=AE=9A=E4=B9=89=E5=92=8C=E7=9B=98=E7=82=B9?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -为多个实体类添加或修正@TableId注解,明确主键字段 - 移除不必要的导入和注解,简化代码结构 - 优化盘点任务创建逻辑,处理空值情况 - 调整入库单生成逻辑,优化代码顺序 --- .../org/dromara/wms/domain/WmsCheckTask.java | 22 ++++++++++++++++++- .../dromara/wms/domain/WmsInstockDetail.java | 2 +- .../dromara/wms/domain/WmsInstockOrder.java | 5 ++--- .../dromara/wms/domain/WmsInstockPrint.java | 2 +- .../org/dromara/wms/domain/WmsInventory.java | 2 +- .../dromara/wms/domain/WmsInventoryCheck.java | 3 +++ .../wms/domain/WmsInventoryCheckRecord.java | 9 +++----- .../dromara/wms/domain/WmsOutstockDetail.java | 2 +- .../dromara/wms/domain/WmsOutstockOrder.java | 7 ++---- .../RemoteInventoryCheckServiceImpl.java | 2 +- .../service/impl/WmsCheckTaskServiceImpl.java | 17 +++++++++----- .../impl/WmsInstockOrderServiceImpl.java | 13 +++++------ 12 files changed, 53 insertions(+), 33 deletions(-) diff --git a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/WmsCheckTask.java b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/WmsCheckTask.java index a4e3354..ed61677 100644 --- a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/WmsCheckTask.java +++ b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/WmsCheckTask.java @@ -28,7 +28,7 @@ public class WmsCheckTask extends TenantEntity { /** * 任务主键 */ - @TableId(type = IdType.ASSIGN_ID) + @TableId(value = "task_id", type = IdType.ASSIGN_ID) private Long taskId; /** @@ -95,5 +95,25 @@ public class WmsCheckTask extends TenantEntity { @TableField(exist = false) private Integer executeMonth; + /** + * 物料类型名称 + */ + @TableField(exist = false) + private String matrialTypeName; + + + /** + * 仓库编码 + */ + @TableField(exist = false) + private String warehouseCode; + + /** + * 仓库名称 + */ + @TableField(exist = false) + private String warehouseName; + + } diff --git a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/WmsInstockDetail.java b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/WmsInstockDetail.java index 41fc6ed..7fe0886 100644 --- a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/WmsInstockDetail.java +++ b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/WmsInstockDetail.java @@ -24,7 +24,7 @@ public class WmsInstockDetail{ /** * 入库单子表主键 */ - @TableId(type = IdType.AUTO) + @TableId(value = "instock_detail_id", type = IdType.AUTO) private Long instockDetailId; /** diff --git a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/WmsInstockOrder.java b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/WmsInstockOrder.java index a684490..1828aa3 100644 --- a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/WmsInstockOrder.java +++ b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/WmsInstockOrder.java @@ -1,8 +1,6 @@ package org.dromara.wms.domain; -import com.baomidou.mybatisplus.annotation.FieldFill; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.*; import lombok.Data; import java.io.Serial; @@ -25,6 +23,7 @@ public class WmsInstockOrder{ /** * 入库单 主键 */ + @TableId(value = "instock_id", type = IdType.AUTO) private Long instockId; /** diff --git a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/WmsInstockPrint.java b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/WmsInstockPrint.java index cc4d6d1..4ecb5cf 100644 --- a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/WmsInstockPrint.java +++ b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/WmsInstockPrint.java @@ -24,7 +24,7 @@ public class WmsInstockPrint{ /** * 入库单子表主键 */ - @TableId(type = IdType.AUTO) + @TableId(value = "instock_print_id", type = IdType.AUTO) private Long instockPrintId; /** diff --git a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/WmsInventory.java b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/WmsInventory.java index e798d33..0d9af2d 100644 --- a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/WmsInventory.java +++ b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/WmsInventory.java @@ -23,7 +23,7 @@ public class WmsInventory { /** * 表主键 */ - @TableId(type = IdType.AUTO) + @TableId(value = "inventory_id", type = IdType.AUTO) private Long inventoryId; /** diff --git a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/WmsInventoryCheck.java b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/WmsInventoryCheck.java index c69a4bf..19d6b37 100644 --- a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/WmsInventoryCheck.java +++ b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/WmsInventoryCheck.java @@ -1,6 +1,8 @@ package org.dromara.wms.domain; +import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import org.dromara.common.tenant.core.TenantEntity; @@ -24,6 +26,7 @@ public class WmsInventoryCheck extends TenantEntity { /** * 表主键 */ + @TableId(value = "inventory_check_id", type = IdType.AUTO) private Long inventoryCheckId; /** diff --git a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/WmsInventoryCheckRecord.java b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/WmsInventoryCheckRecord.java index ca7edd0..57da70f 100644 --- a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/WmsInventoryCheckRecord.java +++ b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/WmsInventoryCheckRecord.java @@ -1,15 +1,11 @@ package org.dromara.wms.domain; -import org.dromara.common.mybatis.core.domain.BaseEntity; import com.baomidou.mybatisplus.annotation.*; import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.math.BigDecimal; -import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; import java.io.Serial; +import java.math.BigDecimal; +import java.util.Date; /** * 盘点记录和调整工单对象 wms_inventory_check_record @@ -27,6 +23,7 @@ public class WmsInventoryCheckRecord { /** * 盘点记录主键 */ + @TableId(value = "ic_record_id", type = IdType.AUTO) private Long icRecordId; /** diff --git a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/WmsOutstockDetail.java b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/WmsOutstockDetail.java index c439424..26c9104 100644 --- a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/WmsOutstockDetail.java +++ b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/WmsOutstockDetail.java @@ -23,7 +23,7 @@ public class WmsOutstockDetail { /** * 表主键 */ - @TableId(type = IdType.AUTO) + @TableId(value = "outstock_detail_id", type = IdType.AUTO) private Long outstockDetailId; /** diff --git a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/WmsOutstockOrder.java b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/WmsOutstockOrder.java index ddd53df..629612d 100644 --- a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/WmsOutstockOrder.java +++ b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/WmsOutstockOrder.java @@ -1,13 +1,10 @@ package org.dromara.wms.domain; -import org.dromara.common.tenant.core.TenantEntity; import com.baomidou.mybatisplus.annotation.*; import lombok.Data; -import lombok.EqualsAndHashCode; -import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; import java.io.Serial; +import java.util.Date; /** * 出库单对象 wms_outstock_order @@ -25,7 +22,7 @@ public class WmsOutstockOrder { /** * 出库单 主键 */ - @TableId(type = IdType.AUTO) + @TableId(value = "outstock_id", type = IdType.AUTO) private Long outstockId; /** diff --git a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/dubbo/RemoteInventoryCheckServiceImpl.java b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/dubbo/RemoteInventoryCheckServiceImpl.java index 7117670..29186b2 100644 --- a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/dubbo/RemoteInventoryCheckServiceImpl.java +++ b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/dubbo/RemoteInventoryCheckServiceImpl.java @@ -76,7 +76,7 @@ public class RemoteInventoryCheckServiceImpl implements RemoteInventoryCheckServ checkBo.setPlanWarehouseId(task.getWarehouseId()); checkBo.setCheckType(task.getWmsCheckTaskType()); checkBo.setCheckStatus("0"); // 盘点状态(0计划,2盘点中,3盘点完成) - checkBo.setBeginTime(new Date()); +// checkBo.setBeginTime(new Date());// 盘点开始时间 checkBo.setCheckCode(generateOrderCode());// 私有方法根据规则生成盘点单号 wmsInventoryCheckService.insertByBo(checkBo); String checkCode = checkBo.getCheckCode(); // 已生成 diff --git a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/service/impl/WmsCheckTaskServiceImpl.java b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/service/impl/WmsCheckTaskServiceImpl.java index 7a36824..cacff6b 100644 --- a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/service/impl/WmsCheckTaskServiceImpl.java +++ b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/service/impl/WmsCheckTaskServiceImpl.java @@ -13,6 +13,7 @@ import org.apache.dubbo.config.annotation.DubboReference; import org.dromara.common.core.domain.R; import org.dromara.common.core.exception.ServiceException; import org.dromara.common.core.utils.MapstructUtils; +import org.dromara.common.core.utils.ObjectUtils; import org.dromara.common.core.utils.StringUtils; import org.dromara.common.mybatis.Utils.UniqueCodeUtils; import org.dromara.common.mybatis.core.page.PageQuery; @@ -93,9 +94,10 @@ public class WmsCheckTaskServiceImpl implements IWmsCheckTaskService { MPJLambdaWrapper lqw = JoinWrappers.lambda(WmsCheckTask.class) .selectAll(WmsCheckTask.class) + //获取物料类型名称 .select(BaseMaterialType::getMatrialTypeName) .leftJoin(BaseMaterialType.class,BaseMaterialType::getMatrialTypeId, WmsCheckTask::getMaterialTypeId) - + //获取仓库名称 .select(WmsBaseWarehouse::getWarehouseCode, WmsBaseWarehouse::getWarehouseName) .leftJoin(WmsBaseWarehouse.class,WmsBaseWarehouse::getWarehouseId, WmsCheckTask::getWarehouseId) @@ -142,12 +144,15 @@ public class WmsCheckTaskServiceImpl implements IWmsCheckTaskService { R jobResp = remoteJobService.addClusterJob(job); Long jobId = jobResp != null ? jobResp.getData() : null;//任务ID add.setJobId(jobId); - - boolean flag = baseMapper.insert(add) > 0; - if (flag) { - bo.setTaskId(add.getTaskId()); + if(ObjectUtils.isNotEmpty(jobId)){ + boolean flag = baseMapper.insert(add) > 0; + if (flag) { + bo.setTaskId(add.getTaskId()); + } + return flag; + } else { + return false; } - return flag; } /** diff --git a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/service/impl/WmsInstockOrderServiceImpl.java b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/service/impl/WmsInstockOrderServiceImpl.java index 8a706b9..5cd4109 100644 --- a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/service/impl/WmsInstockOrderServiceImpl.java +++ b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/service/impl/WmsInstockOrderServiceImpl.java @@ -194,28 +194,27 @@ public class WmsInstockOrderServiceImpl implements IWmsInstockOrderService { bo.setAuditComments("即入即出自动通过"); } String inStockOrder = order + orderDate + orderLast; + bo.setInstockCode(inStockOrder); WmsInstockOrder add = MapstructUtils.convert(bo, WmsInstockOrder.class); validEntityBeforeSave(add); - add.setInstockCode(inStockOrder); add.setCreateBy(username); // 保存入库单主表 boolean flag = baseMapper.insert(add) > 0; - if (!flag) { - throw new ServiceException("入库单主表保存失败"); + if (flag) { + bo.setInstockId(add.getInstockId()); } MPJLambdaWrapper addOne = buildQueryWrapper(bo); WmsInstockOrderVo orderVo = baseMapper.selectVoOne(addOne); - // 设置生成的主键ID - bo.setInstockId(orderVo.getInstockId()); - bo.setInstockCode(inStockOrder); +// // 设置生成的主键ID +// bo.setInstockId(orderVo.getInstockId()); // 处理入库单子表 if (bo.getDetailListBo() != null && !bo.getDetailListBo().isEmpty()) { // 为每个明细设置入库单信息 for (WmsInstockDetailBo detail : bo.getDetailListBo()) { - detail.setInstockId(orderVo.getInstockId()); + detail.setInstockId(detail.getInstockId()); detail.setInstockCode(inStockOrder); }