From 375b2956a1130e7d4f759a798b1638fa7cb4815a Mon Sep 17 00:00:00 2001 From: "zangch@mesnac.com" Date: Wed, 13 Aug 2025 09:36:34 +0800 Subject: [PATCH] =?UTF-8?q?feat(wms):=20=E7=89=A9=E6=96=99=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E4=B8=AD=E6=B7=BB=E5=8A=A0=E6=98=AF=E5=90=A6=E9=AB=98?= =?UTF-8?q?=E4=BB=B7=E5=80=BC=E7=89=A9=E6=96=99=E5=92=8C=E8=B4=A8=E6=A3=80?= =?UTF-8?q?=E8=A6=81=E6=B1=82=E5=AD=97=E6=AE=B5=EF=BC=8C=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E7=89=A9=E6=96=99=E7=B1=BB=E5=9E=8B=E3=80=81=E7=89=A9=E6=96=99?= =?UTF-8?q?=E5=A4=A7=E7=B1=BB=E5=92=8C=E8=AE=A1=E9=87=8F=E5=8D=95=E4=BD=8D?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E7=9B=B8=E5=85=B3=E5=8A=9F=E8=83=BD=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=89=A9=E6=96=99=E4=BF=A1=E6=81=AF=E4=B8=8E?= =?UTF-8?q?=E4=B9=8B=E5=85=B3=E8=81=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增物料类型信息相关实体、控制器、服务、Mapper等 - 新增计量单位信息相关实体、控制器、服务、Mapper等 - 在基础物料信息中添加是否高价值物料和质检要求字段 --- .../BaseMaterialTypeController.java | 116 +++++++++++ .../BaseMeasurementUnitInfoController.java | 117 ++++++++++++ .../dromara/wms/domain/BaseMaterialInfo.java | 23 +++ .../dromara/wms/domain/BaseMaterialType.java | 100 ++++++++++ .../wms/domain/BaseMeasurementUnitInfo.java | 78 ++++++++ .../wms/domain/bo/BaseMaterialInfoBo.java | 9 + .../wms/domain/bo/BaseMaterialTypeBo.java | 79 ++++++++ .../domain/bo/BaseMeasurementUnitInfoBo.java | 71 +++++++ .../wms/domain/vo/BaseMaterialInfoVo.java | 20 ++ .../wms/domain/vo/BaseMaterialTypeVo.java | 141 ++++++++++++++ .../domain/vo/BaseMeasurementUnitInfoVo.java | 117 ++++++++++++ .../wms/mapper/BaseMaterialTypeMapper.java | 15 ++ .../mapper/BaseMeasurementUnitInfoMapper.java | 15 ++ .../wms/service/IBaseMaterialTypeService.java | 58 ++++++ .../IBaseMeasurementUnitInfoService.java | 58 ++++++ .../impl/BaseMaterialInfoServiceImpl.java | 16 +- .../impl/BaseMaterialTypeServiceImpl.java | 180 ++++++++++++++++++ .../BaseMeasurementUnitInfoServiceImpl.java | 154 +++++++++++++++ .../mapper/wms/BaseMaterialTypeMapper.xml | 7 + .../wms/BaseMeasurementUnitInfoMapper.xml | 7 + 20 files changed, 1375 insertions(+), 6 deletions(-) create mode 100644 ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/controller/BaseMaterialTypeController.java create mode 100644 ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/controller/BaseMeasurementUnitInfoController.java create mode 100644 ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/BaseMaterialType.java create mode 100644 ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/BaseMeasurementUnitInfo.java create mode 100644 ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/bo/BaseMaterialTypeBo.java create mode 100644 ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/bo/BaseMeasurementUnitInfoBo.java create mode 100644 ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/vo/BaseMaterialTypeVo.java create mode 100644 ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/vo/BaseMeasurementUnitInfoVo.java create mode 100644 ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/mapper/BaseMaterialTypeMapper.java create mode 100644 ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/mapper/BaseMeasurementUnitInfoMapper.java create mode 100644 ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/service/IBaseMaterialTypeService.java create mode 100644 ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/service/IBaseMeasurementUnitInfoService.java create mode 100644 ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/service/impl/BaseMaterialTypeServiceImpl.java create mode 100644 ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/service/impl/BaseMeasurementUnitInfoServiceImpl.java create mode 100644 ruoyi-modules/hwmom-wms/src/main/resources/mapper/wms/BaseMaterialTypeMapper.xml create mode 100644 ruoyi-modules/hwmom-wms/src/main/resources/mapper/wms/BaseMeasurementUnitInfoMapper.xml diff --git a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/controller/BaseMaterialTypeController.java b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/controller/BaseMaterialTypeController.java new file mode 100644 index 0000000..5640277 --- /dev/null +++ b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/controller/BaseMaterialTypeController.java @@ -0,0 +1,116 @@ +package org.dromara.wms.controller; + +import jakarta.servlet.http.HttpServletResponse; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; +import lombok.RequiredArgsConstructor; +import org.dromara.common.core.domain.R; +import org.dromara.common.core.validate.AddGroup; +import org.dromara.common.core.validate.EditGroup; +import org.dromara.common.excel.utils.ExcelUtil; +import org.dromara.common.idempotent.annotation.RepeatSubmit; +import org.dromara.common.log.annotation.Log; +import org.dromara.common.log.enums.BusinessType; +import org.dromara.common.web.core.BaseController; +import org.dromara.wms.domain.bo.BaseMaterialTypeBo; +import org.dromara.wms.domain.vo.BaseMaterialTypeVo; +import org.dromara.wms.service.IBaseMaterialTypeService; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 物料类型信息 + * 前端访问路由地址为:/mes/baseMaterialType + * + * @author zangch + * @date 2025-01-07 + */ +@Validated +@RequiredArgsConstructor +@RestController +@RequestMapping("/baseMaterialType") +public class BaseMaterialTypeController extends BaseController { + + private final IBaseMaterialTypeService baseMaterialTypeService; + + /** + * 查询物料类型信息列表 + */ + //@SaCheckPermission("mes:baseMaterialType:list") + @GetMapping("/list") + public R> list(BaseMaterialTypeBo bo) { + List list = baseMaterialTypeService.queryList(bo); + return R.ok(list); + } + + /** + * 导出物料类型信息列表 + */ + //@SaCheckPermission("mes:baseMaterialType:export") + @Log(title = "物料类型信息", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(BaseMaterialTypeBo bo, HttpServletResponse response) { + List list = baseMaterialTypeService.queryList(bo); + ExcelUtil.exportExcel(list, "物料类型信息", BaseMaterialTypeVo.class, response); + } + + /** + * 获取物料类型信息详细信息 + * + * @param matrialTypeId 主键 + */ + //@SaCheckPermission("mes:baseMaterialType:query") + @GetMapping("/{matrialTypeId}") + public R getInfo(@NotNull(message = "主键不能为空") + @PathVariable Long matrialTypeId) { + return R.ok(baseMaterialTypeService.queryById(matrialTypeId)); + } + + /** + * 新增物料类型信息 + */ + //@SaCheckPermission("mes:baseMaterialType:add") + @Log(title = "物料类型信息", businessType = BusinessType.INSERT) + @RepeatSubmit() + @PostMapping() + public R add(@Validated(AddGroup.class) @RequestBody BaseMaterialTypeBo bo) { + return toAjax(baseMaterialTypeService.insertByBo(bo)); + } + + /** + * 修改物料类型信息 + */ + //@SaCheckPermission("mes:baseMaterialType:edit") + @Log(title = "物料类型信息", businessType = BusinessType.UPDATE) + @RepeatSubmit() + @PutMapping() + public R edit(@Validated(EditGroup.class) @RequestBody BaseMaterialTypeBo bo) { + return toAjax(baseMaterialTypeService.updateByBo(bo)); + } + + /** + * 删除物料类型信息 + * + * @param matrialTypeIds 主键串 + */ + //@SaCheckPermission("mes:baseMaterialType:remove") + @Log(title = "物料类型信息", businessType = BusinessType.DELETE) + @DeleteMapping("/{matrialTypeIds}") + public R remove(@NotEmpty(message = "主键不能为空") + @PathVariable Long[] matrialTypeIds) { + return toAjax(baseMaterialTypeService.deleteWithValidByIds(List.of(matrialTypeIds), true)); + } + + + /** + * 下拉框查询物料类型信息列表 + */ + + @GetMapping("getBaseMaterialTypeList") + public R> getBaseMaterialTypelist(BaseMaterialTypeBo bo) { + List list = baseMaterialTypeService.queryList(bo); + return R.ok(list); + } +} diff --git a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/controller/BaseMeasurementUnitInfoController.java b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/controller/BaseMeasurementUnitInfoController.java new file mode 100644 index 0000000..6acbd5a --- /dev/null +++ b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/controller/BaseMeasurementUnitInfoController.java @@ -0,0 +1,117 @@ +package org.dromara.wms.controller; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; +import lombok.RequiredArgsConstructor; +import org.dromara.common.core.domain.R; +import org.dromara.common.core.validate.AddGroup; +import org.dromara.common.core.validate.EditGroup; +import org.dromara.common.excel.utils.ExcelUtil; +import org.dromara.common.idempotent.annotation.RepeatSubmit; +import org.dromara.common.log.annotation.Log; +import org.dromara.common.log.enums.BusinessType; +import org.dromara.common.web.core.BaseController; +import org.dromara.wms.domain.bo.BaseMeasurementUnitInfoBo; +import org.dromara.wms.domain.vo.BaseMeasurementUnitInfoVo; +import org.dromara.wms.service.IBaseMeasurementUnitInfoService; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 计量单位信息 + * 前端访问路由地址为:/mes/baseMeasurementUnitInfo + * + * @author zangch + * @date 2025-01-08 + */ +@Validated +@RequiredArgsConstructor +@RestController +@RequestMapping("/baseMeasurementUnitInfo") +public class BaseMeasurementUnitInfoController extends BaseController { + + private final IBaseMeasurementUnitInfoService baseMeasurementUnitInfoService; + + /** + * 查询计量单位信息列表 + */ + //@SaCheckPermission("mes:baseMeasurementUnitInfo:list") + @GetMapping("/list") + public R> list(BaseMeasurementUnitInfoBo bo) { + List list = baseMeasurementUnitInfoService.queryList(bo); + return R.ok(list); + } + + /** + * 导出计量单位信息列表 + */ + //@SaCheckPermission("mes:baseMeasurementUnitInfo:export") + @Log(title = "计量单位信息", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(BaseMeasurementUnitInfoBo bo, HttpServletResponse response) { + List list = baseMeasurementUnitInfoService.queryList(bo); + ExcelUtil.exportExcel(list, "计量单位信息", BaseMeasurementUnitInfoVo.class, response); + } + + /** + * 获取计量单位信息详细信息 + * + * @param unitId 主键 + */ + //@SaCheckPermission("mes:baseMeasurementUnitInfo:query") + @GetMapping("/{unitId}") + public R getInfo(@NotNull(message = "主键不能为空") + @PathVariable Long unitId) { + return R.ok(baseMeasurementUnitInfoService.queryById(unitId)); + } + + /** + * 新增计量单位信息 + */ + //@SaCheckPermission("mes:baseMeasurementUnitInfo:add") + @Log(title = "计量单位信息", businessType = BusinessType.INSERT) + @RepeatSubmit() + @PostMapping() + public R add(@Validated(AddGroup.class) @RequestBody BaseMeasurementUnitInfoBo bo) { + return toAjax(baseMeasurementUnitInfoService.insertByBo(bo)); + } + + /** + * 修改计量单位信息 + */ + //@SaCheckPermission("mes:baseMeasurementUnitInfo:edit") + @Log(title = "计量单位信息", businessType = BusinessType.UPDATE) + @RepeatSubmit() + @PutMapping() + public R edit(@Validated(EditGroup.class) @RequestBody BaseMeasurementUnitInfoBo bo) { + return toAjax(baseMeasurementUnitInfoService.updateByBo(bo)); + } + + /** + * 删除计量单位信息 + * + * @param unitIds 主键串 + */ + //@SaCheckPermission("mes:baseMeasurementUnitInfo:remove") + @Log(title = "计量单位信息", businessType = BusinessType.DELETE) + @DeleteMapping("/{unitIds}") + public R remove(@NotEmpty(message = "主键不能为空") + @PathVariable Long[] unitIds) { + return toAjax(baseMeasurementUnitInfoService.deleteWithValidByIds(List.of(unitIds), true)); + } + + + /** + * 下拉框查询计量单位信息列表 + */ + + @GetMapping("getBaseMeasurementUnitInfoList") + public R> getBaseMeasurementUnitInfolist(BaseMeasurementUnitInfoBo bo) { + List list = baseMeasurementUnitInfoService.queryList(bo); + return R.ok(list); + } +} diff --git a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/BaseMaterialInfo.java b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/BaseMaterialInfo.java index 2aa3bf2..dbd78b5 100644 --- a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/BaseMaterialInfo.java +++ b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/BaseMaterialInfo.java @@ -265,10 +265,33 @@ public class BaseMaterialInfo extends TenantEntity { */ private String remark; + /** + * 是否高价值物料(0否,1是) + */ + private String isHighValue; + + /** + * 质检要求(0必检,1免检) + */ + private String inspectionRequest; + /** * 大类名称 */ @TableField(exist = false) private String materialCategoryName;//join + /** + * 物料类型名称 + */ + @TableField(exist = false) + private String matrialTypeName;//JOIN + + /** + * 计量单位名称 + */ + @TableField(exist = false) + private String unitName;//JOIN + + } diff --git a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/BaseMaterialType.java b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/BaseMaterialType.java new file mode 100644 index 0000000..241506f --- /dev/null +++ b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/BaseMaterialType.java @@ -0,0 +1,100 @@ +package org.dromara.wms.domain; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.dromara.common.tenant.core.TenantEntity; + +import java.io.Serial; + +/** + * 物料类型信息对象 base_material_type + * + * @author zangch + * @date 2025-01-07 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("base_material_type") +public class BaseMaterialType extends TenantEntity { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 物料类型ID + */ + @TableId(value = "matrial_type_id", type = IdType.AUTO) + private Long matrialTypeId; + + /** + * 父级标识 + */ + private Long parentId; + + /** + * 物料类型编号 + */ + private String matrialTypeCode; + + /** + * 物料类型名称 + */ + private String matrialTypeName; + + /** + * 祖级列表 + */ + private String ancestors; + + /** + * 物料大类ID + */ +// private String materialCategories; + private Long materialCategoryId; + + /** + * 物料小类 + */ + private String materialSubclass; + + /** + * 工序ID + */ + private Long processId; + + /** + * 激活标识(1是 0否) + */ + private String activeFlag; + + /** + * 备注 + */ + private String remark; + + /** + * 删除标志(0代表存在 2代表删除) + */ + @TableLogic + private String delFlag; + + + /** + * 工序名称 + */ + @TableField(exist = false) + private String processName;//映射字段 + + /** + * 大类编号 + */ +/* @TableField(exist = false) + private String materialCategoryCode;//映射字段*/ + + /** + * 大类名称 + */ + @TableField(exist = false) + private String materialCategoryName;//映射字段 +} diff --git a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/BaseMeasurementUnitInfo.java b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/BaseMeasurementUnitInfo.java new file mode 100644 index 0000000..b9bdb48 --- /dev/null +++ b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/BaseMeasurementUnitInfo.java @@ -0,0 +1,78 @@ +package org.dromara.wms.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.dromara.common.mybatis.core.domain.BaseEntity; + +import java.io.Serial; + +/** + * 计量单位信息对象 base_measurement_unit_info + * + * @author zangch + * @date 2025-01-08 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("base_measurement_unit_info") +public class BaseMeasurementUnitInfo extends BaseEntity { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 主键标识 + */ + @TableId(value = "unit_id", type = IdType.AUTO) + private Long unitId; + + /** + * 父级标识 + */ + private Long parentId; + + /** + * 计量单位编号 + */ + private String unitCode; + + /** + * 计量单位名称 + */ + private String unitName; + + /** + * 计量单位转换(与最顶级转换关系,最顶级是1) + */ + private Long unitConversion; + + /** + * 祖级列表 + */ + private String ancestors; + + /** + * 单位类型(1长度 2质量 3时间 4面积 5体积) + */ + private String unitType; + + /** + * 备注 + */ + private String remark; + + /** + * 激活标识(1是 0否) + */ + private String activeFlag; + + /** + * 删除标志(0代表存在 2代表删除) + */ + @TableLogic + private String delFlag; +} diff --git a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/bo/BaseMaterialInfoBo.java b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/bo/BaseMaterialInfoBo.java index 67df2e6..db6745b 100644 --- a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/bo/BaseMaterialInfoBo.java +++ b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/bo/BaseMaterialInfoBo.java @@ -267,5 +267,14 @@ public class BaseMaterialInfoBo extends BaseEntity { */ private String remark; + /** + * 是否高价值物料(0否,1是) + */ + private String isHighValue; + + /** + * 质检要求(0必检,1免检) + */ + private String inspectionRequest; } diff --git a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/bo/BaseMaterialTypeBo.java b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/bo/BaseMaterialTypeBo.java new file mode 100644 index 0000000..bd539cf --- /dev/null +++ b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/bo/BaseMaterialTypeBo.java @@ -0,0 +1,79 @@ +package org.dromara.wms.domain.bo; + +import io.github.linpeilie.annotations.AutoMapper; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.dromara.common.core.validate.AddGroup; +import org.dromara.common.core.validate.EditGroup; +import org.dromara.common.mybatis.core.domain.BaseEntity; +import org.dromara.wms.domain.BaseMaterialType; + +/** + * 物料类型信息业务对象 base_material_type + * + * @author zangch + * @date 2025-01-07 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@AutoMapper(target = BaseMaterialType.class, reverseConvertGenerate = false) +public class BaseMaterialTypeBo extends BaseEntity { + + /** + * 物料类型ID + */ + private Long matrialTypeId; + + /** + * 父级标识 + */ + @NotNull(message = "父级标识不能为空", groups = { AddGroup.class, EditGroup.class }) + private Long parentId; + + /** + * 物料类型编号 + */ + @NotBlank(message = "物料类型编号不能为空", groups = { AddGroup.class, EditGroup.class }) + private String matrialTypeCode; + + /** + * 物料类型名称 + */ + @NotBlank(message = "物料类型名称不能为空", groups = { AddGroup.class, EditGroup.class }) + private String matrialTypeName; + + /** + * 祖级列表 + */ + private String ancestors; + + /** + * 物料大类ID + */ +// private String materialCategories; + private Long materialCategoryId; + + /** + * 物料小类 + */ + private String materialSubclass; + + /** + * 工序ID + */ + private Long processId; + + /** + * 激活标识(1是 0否) + */ + private String activeFlag; + + /** + * 备注 + */ + private String remark; + + +} diff --git a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/bo/BaseMeasurementUnitInfoBo.java b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/bo/BaseMeasurementUnitInfoBo.java new file mode 100644 index 0000000..45a5698 --- /dev/null +++ b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/bo/BaseMeasurementUnitInfoBo.java @@ -0,0 +1,71 @@ +package org.dromara.wms.domain.bo; + +import io.github.linpeilie.annotations.AutoMapper; +import jakarta.validation.constraints.NotBlank; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.dromara.common.core.validate.AddGroup; +import org.dromara.common.core.validate.EditGroup; +import org.dromara.common.mybatis.core.domain.BaseEntity; +import org.dromara.wms.domain.BaseMeasurementUnitInfo; + +/** + * 计量单位信息业务对象 base_measurement_unit_info + * + * @author zangch + * @date 2025-01-08 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@AutoMapper(target = BaseMeasurementUnitInfo.class, reverseConvertGenerate = false) +public class BaseMeasurementUnitInfoBo extends BaseEntity { + + /** + * 主键标识 + */ + private Long unitId; + + /** + * 父级标识 + */ + private Long parentId; + + /** + * 计量单位编号 + */ + @NotBlank(message = "计量单位编号不能为空", groups = { AddGroup.class, EditGroup.class }) + private String unitCode; + + /** + * 计量单位名称 + */ + @NotBlank(message = "计量单位名称不能为空", groups = { AddGroup.class, EditGroup.class }) + private String unitName; + + /** + * 计量单位转换(与最顶级转换关系,最顶级是1) + */ + private Long unitConversion; + + /** + * 祖级列表 + */ + private String ancestors; + + /** + * 单位类型(1长度 2质量 3时间 4面积 5体积) + */ + private String unitType; + + /** + * 备注 + */ + private String remark; + + /** + * 激活标识(1是 0否) + */ + private String activeFlag; + + +} diff --git a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/vo/BaseMaterialInfoVo.java b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/vo/BaseMaterialInfoVo.java index fed23a0..300d691 100644 --- a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/vo/BaseMaterialInfoVo.java +++ b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/vo/BaseMaterialInfoVo.java @@ -372,4 +372,24 @@ public class BaseMaterialInfoVo implements Serializable { */ private String materialCategoryName;//join + /** + * 物料类型名称 + */ + private String matrialTypeName;//JOIN + + /** + * 计量单位名称 + */ + private String unitName;//JOIN + + /** + * 是否高价值物料(0否,1是) + */ + private String isHighValue; + + /** + * 质检要求(0必检,1免检) + */ + private String inspectionRequest; + } diff --git a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/vo/BaseMaterialTypeVo.java b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/vo/BaseMaterialTypeVo.java new file mode 100644 index 0000000..547668d --- /dev/null +++ b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/vo/BaseMaterialTypeVo.java @@ -0,0 +1,141 @@ +package org.dromara.wms.domain.vo; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import io.github.linpeilie.annotations.AutoMapper; +import lombok.Data; +import org.dromara.common.excel.annotation.ExcelDictFormat; +import org.dromara.common.excel.convert.ExcelDictConvert; +import org.dromara.wms.domain.BaseMaterialType; + +import java.io.Serial; +import java.io.Serializable; +import java.util.Date; + + +/** + * 物料类型信息视图对象 base_material_type + * + * @author zangch + * @date 2025-01-07 + */ +@Data +@ExcelIgnoreUnannotated +@AutoMapper(target = BaseMaterialType.class) +public class BaseMaterialTypeVo implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 物料类型ID + */ + @ExcelProperty(value = "物料类型ID") + private Long matrialTypeId; + + /** + * 租户编号 + */ + @ExcelProperty(value = "租户编号") + private String tenantId; + + /** + * 父级标识 + */ + @ExcelProperty(value = "父级标识") + private Long parentId; + + /** + * 物料类型编号 + */ + @ExcelProperty(value = "物料类型编号") + private String matrialTypeCode; + + /** + * 物料类型名称 + */ + @ExcelProperty(value = "物料类型名称") + private String matrialTypeName; + + /** + * 祖级列表 + */ + @ExcelProperty(value = "祖级列表") + private String ancestors; + + /** + * 物料大类ID + */ +// @ExcelProperty(value = "物料大类(1原材料 2半成品 3成品)", converter = ExcelDictConvert.class) +// @ExcelDictFormat(dictType = "mes_material_categories") + private Long materialCategoryId; +// private String materialCategories; + + /** + * 物料小类 + */ + @ExcelProperty(value = "物料小类") + private String materialSubclass; + + /** + * 工序ID + */ + @ExcelProperty(value = "工序ID") + private Long processId; + + /** + * 激活标识(1是 0否) + */ + @ExcelProperty(value = "激活标识", converter = ExcelDictConvert.class) + @ExcelDictFormat(dictType = "active_flag") + private String activeFlag; + + /** + * 备注 + */ + @ExcelProperty(value = "备注") + private String remark; + + /** + * 创建部门 + */ + @ExcelProperty(value = "创建部门") + private Long createDept; + + /** + * 创建人 + */ + @ExcelProperty(value = "创建人") + private Long createBy; + + /** + * 创建时间 + */ + @ExcelProperty(value = "创建时间") + private Date createTime; + + /** + * 更新人 + */ + @ExcelProperty(value = "更新人") + private Long updateBy; + + /** + * 更新时间 + */ + @ExcelProperty(value = "更新时间") + private Date updateTime; + + + /** + * 工序名称 + */ +// @ExcelProperty(value = "工序名称") +// private String processName;//工序名称 + + /** + * 大类名称 + */ + @ExcelProperty(value = "工序名称") + private String materialCategoryName;//映射字段 +} diff --git a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/vo/BaseMeasurementUnitInfoVo.java b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/vo/BaseMeasurementUnitInfoVo.java new file mode 100644 index 0000000..a89e687 --- /dev/null +++ b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/domain/vo/BaseMeasurementUnitInfoVo.java @@ -0,0 +1,117 @@ +package org.dromara.wms.domain.vo; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import io.github.linpeilie.annotations.AutoMapper; +import lombok.Data; +import org.dromara.common.excel.annotation.ExcelDictFormat; +import org.dromara.common.excel.convert.ExcelDictConvert; +import org.dromara.wms.domain.BaseMeasurementUnitInfo; + +import java.io.Serial; +import java.io.Serializable; +import java.util.Date; + + +/** + * 计量单位信息视图对象 base_measurement_unit_info + * + * @author zangch + * @date 2025-01-08 + */ +@Data +@ExcelIgnoreUnannotated +@AutoMapper(target = BaseMeasurementUnitInfo.class) +public class BaseMeasurementUnitInfoVo implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 主键标识 + */ + @ExcelProperty(value = "主键标识") + private Long unitId; + + /** + * 父级标识 + */ + @ExcelProperty(value = "父级标识") + private Long parentId; + + /** + * 计量单位编号 + */ + @ExcelProperty(value = "计量单位编号") + private String unitCode; + + /** + * 计量单位名称 + */ + @ExcelProperty(value = "计量单位名称") + private String unitName; + + /** + * 计量单位转换(与最顶级转换关系,最顶级是1) + */ + @ExcelProperty(value = "计量单位转换", converter = ExcelDictConvert.class) + @ExcelDictFormat(readConverterExp = "与=最顶级转换关系,最顶级是1") + private Long unitConversion; + + /** + * 祖级列表 + */ + @ExcelProperty(value = "祖级列表") + private String ancestors; + + /** + * 单位类型(1长度 2质量 3时间 4面积 5体积) + */ + @ExcelProperty(value = "单位类型", converter = ExcelDictConvert.class) + @ExcelDictFormat(dictType = "unit_type") + private String unitType; + + /** + * 备注 + */ + @ExcelProperty(value = "备注") + private String remark; + + /** + * 激活标识(1是 0否) + */ + @ExcelProperty(value = "激活标识(1是 0否)") + private String activeFlag; + + /** + * 创建部门 + */ + @ExcelProperty(value = "创建部门") + private Long createDept; + + /** + * 创建人 + */ + @ExcelProperty(value = "创建人") + private Long createBy; + + /** + * 创建时间 + */ + @ExcelProperty(value = "创建时间") + private Date createTime; + + /** + * 更新人 + */ + @ExcelProperty(value = "更新人") + private Long updateBy; + + /** + * 更新时间 + */ + @ExcelProperty(value = "更新时间") + private Date updateTime; + + +} diff --git a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/mapper/BaseMaterialTypeMapper.java b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/mapper/BaseMaterialTypeMapper.java new file mode 100644 index 0000000..218b414 --- /dev/null +++ b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/mapper/BaseMaterialTypeMapper.java @@ -0,0 +1,15 @@ +package org.dromara.wms.mapper; + +import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; +import org.dromara.wms.domain.BaseMaterialType; +import org.dromara.wms.domain.vo.BaseMaterialTypeVo; + +/** + * 物料类型信息Mapper接口 + * + * @author zangch + * @date 2025-01-07 + */ +public interface BaseMaterialTypeMapper extends BaseMapperPlus { + +} diff --git a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/mapper/BaseMeasurementUnitInfoMapper.java b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/mapper/BaseMeasurementUnitInfoMapper.java new file mode 100644 index 0000000..b610896 --- /dev/null +++ b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/mapper/BaseMeasurementUnitInfoMapper.java @@ -0,0 +1,15 @@ +package org.dromara.wms.mapper; + +import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; +import org.dromara.wms.domain.BaseMeasurementUnitInfo; +import org.dromara.wms.domain.vo.BaseMeasurementUnitInfoVo; + +/** + * 计量单位信息Mapper接口 + * + * @author zangch + * @date 2025-01-08 + */ +public interface BaseMeasurementUnitInfoMapper extends BaseMapperPlus { + +} diff --git a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/service/IBaseMaterialTypeService.java b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/service/IBaseMaterialTypeService.java new file mode 100644 index 0000000..2542454 --- /dev/null +++ b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/service/IBaseMaterialTypeService.java @@ -0,0 +1,58 @@ +package org.dromara.wms.service; + +import org.dromara.wms.domain.bo.BaseMaterialTypeBo; +import org.dromara.wms.domain.vo.BaseMaterialTypeVo; + +import java.util.Collection; +import java.util.List; + +/** + * 物料类型信息Service接口 + * + * @author zangch + * @date 2025-01-07 + */ +public interface IBaseMaterialTypeService { + + /** + * 查询物料类型信息 + * + * @param matrialTypeId 主键 + * @return 物料类型信息 + */ + BaseMaterialTypeVo queryById(Long matrialTypeId); + + + /** + * 查询符合条件的物料类型信息列表 + * + * @param bo 查询条件 + * @return 物料类型信息列表 + */ + List queryList(BaseMaterialTypeBo bo); + + /** + * 新增物料类型信息 + * + * @param bo 物料类型信息 + * @return 是否新增成功 + */ + Boolean insertByBo(BaseMaterialTypeBo bo); + + /** + * 修改物料类型信息 + * + * @param bo 物料类型信息 + * @return 是否修改成功 + */ + Boolean updateByBo(BaseMaterialTypeBo bo); + + /** + * 校验并批量删除物料类型信息信息 + * + * @param ids 待删除的主键集合 + * @param isValid 是否进行有效性校验 + * @return 是否删除成功 + */ + Boolean deleteWithValidByIds(Collection ids, Boolean isValid); +} diff --git a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/service/IBaseMeasurementUnitInfoService.java b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/service/IBaseMeasurementUnitInfoService.java new file mode 100644 index 0000000..68f0e23 --- /dev/null +++ b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/service/IBaseMeasurementUnitInfoService.java @@ -0,0 +1,58 @@ +package org.dromara.wms.service; + +import org.dromara.wms.domain.bo.BaseMeasurementUnitInfoBo; +import org.dromara.wms.domain.vo.BaseMeasurementUnitInfoVo; + +import java.util.Collection; +import java.util.List; + +/** + * 计量单位信息Service接口 + * + * @author zangch + * @date 2025-01-08 + */ +public interface IBaseMeasurementUnitInfoService { + + /** + * 查询计量单位信息 + * + * @param unitId 主键 + * @return 计量单位信息 + */ + BaseMeasurementUnitInfoVo queryById(Long unitId); + + + /** + * 查询符合条件的计量单位信息列表 + * + * @param bo 查询条件 + * @return 计量单位信息列表 + */ + List queryList(BaseMeasurementUnitInfoBo bo); + + /** + * 新增计量单位信息 + * + * @param bo 计量单位信息 + * @return 是否新增成功 + */ + Boolean insertByBo(BaseMeasurementUnitInfoBo bo); + + /** + * 修改计量单位信息 + * + * @param bo 计量单位信息 + * @return 是否修改成功 + */ + Boolean updateByBo(BaseMeasurementUnitInfoBo bo); + + /** + * 校验并批量删除计量单位信息信息 + * + * @param ids 待删除的主键集合 + * @param isValid 是否进行有效性校验 + * @return 是否删除成功 + */ + Boolean deleteWithValidByIds(Collection ids, Boolean isValid); +} diff --git a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/service/impl/BaseMaterialInfoServiceImpl.java b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/service/impl/BaseMaterialInfoServiceImpl.java index 613044b..3c4f069 100644 --- a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/service/impl/BaseMaterialInfoServiceImpl.java +++ b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/service/impl/BaseMaterialInfoServiceImpl.java @@ -12,6 +12,8 @@ import org.dromara.common.mybatis.core.page.PageQuery; import org.dromara.common.mybatis.core.page.TableDataInfo; import org.dromara.wms.domain.BaseMaterialCategory; import org.dromara.wms.domain.BaseMaterialInfo; +import org.dromara.wms.domain.BaseMaterialType; +import org.dromara.wms.domain.BaseMeasurementUnitInfo; import org.dromara.wms.domain.bo.BaseMaterialInfoBo; import org.dromara.wms.domain.vo.BaseMaterialInfoVo; import org.dromara.wms.mapper.BaseMaterialInfoMapper; @@ -82,14 +84,14 @@ public class BaseMaterialInfoServiceImpl implements IBaseMaterialInfoService { // .select(ProdBaseFactoryInfo::getFactoryName) // .leftJoin(ProdBaseFactoryInfo.class, ProdBaseFactoryInfo::getFactoryId, BaseMaterialInfo::getFactoryId) // -// //关联查询物料类型名称 -// .select(BaseMaterialType::getMatrialTypeName) -// //注意"e":BaseMaterialType实体类中为matrialTypeId,BaseMaterialInfo实体类中为materialTypeId -// .leftJoin(BaseMaterialType.class, BaseMaterialType::getMatrialTypeId, BaseMaterialInfo::getMaterialTypeId) + //关联查询物料类型名称 + .select(BaseMaterialType::getMatrialTypeName) + //注意"e":BaseMaterialType实体类中为matrialTypeId,BaseMaterialInfo实体类中为materialTypeId + .leftJoin(BaseMaterialType.class, BaseMaterialType::getMatrialTypeId, BaseMaterialInfo::getMaterialTypeId) -/* //关联计量单位信息 + //关联计量单位信息 .select(BaseMeasurementUnitInfo::getUnitName) - .leftJoin(BaseMeasurementUnitInfo.class, BaseMeasurementUnitInfo::getUnitId, BaseMaterialInfo::getMaterialUnitId)*/ + .leftJoin(BaseMeasurementUnitInfo.class, BaseMeasurementUnitInfo::getUnitId, BaseMaterialInfo::getMaterialUnitId) //关联物料大类信息(物料大类从字典改为了数据库表) .select(BaseMaterialCategory::getMaterialCategoryName) @@ -100,6 +102,8 @@ public class BaseMaterialInfoServiceImpl implements IBaseMaterialInfoService { .between(params.get("beginApproveDate") != null && params.get("endApproveDate") != null, BaseMaterialInfo::getApproveDate ,params.get("beginApproveDate"), params.get("endApproveDate")) + .eq(StringUtils.isNotBlank(bo.getIsHighValue()), BaseMaterialInfo::getIsHighValue, bo.getIsHighValue()) + .eq(StringUtils.isNotBlank(bo.getInspectionRequest()), BaseMaterialInfo::getInspectionRequest, bo.getInspectionRequest()) .eq(bo.getMaterialId() != null, BaseMaterialInfo::getMaterialId, bo.getMaterialId()) .eq(StringUtils.isNotBlank(bo.getErpId()), BaseMaterialInfo::getErpId, bo.getErpId()) .like(StringUtils.isNotBlank(bo.getMaterialCode()), BaseMaterialInfo::getMaterialCode, bo.getMaterialCode()) diff --git a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/service/impl/BaseMaterialTypeServiceImpl.java b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/service/impl/BaseMaterialTypeServiceImpl.java new file mode 100644 index 0000000..f9f18b8 --- /dev/null +++ b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/service/impl/BaseMaterialTypeServiceImpl.java @@ -0,0 +1,180 @@ +package org.dromara.wms.service.impl; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.github.yulichang.toolkit.JoinWrappers; +import com.github.yulichang.wrapper.MPJLambdaWrapper; +import lombok.RequiredArgsConstructor; +import org.apache.commons.lang3.ObjectUtils; +import org.dromara.common.core.exception.ServiceException; +import org.dromara.common.core.utils.MapstructUtils; +import org.dromara.common.core.utils.StringUtils; +import org.dromara.wms.domain.BaseMaterialCategory; +import org.dromara.wms.domain.BaseMaterialType; +import org.dromara.wms.domain.bo.BaseMaterialTypeBo; +import org.dromara.wms.domain.vo.BaseMaterialTypeVo; +import org.dromara.wms.mapper.BaseMaterialTypeMapper; +import org.dromara.wms.service.IBaseMaterialTypeService; +import org.springframework.stereotype.Service; + +import java.util.Collection; +import java.util.List; +import java.util.Map; + +/** + * 物料类型信息Service业务层处理 + * + * @author zangch + * @date 2025-01-07 + */ +@RequiredArgsConstructor +@Service +public class BaseMaterialTypeServiceImpl implements IBaseMaterialTypeService { + + private final BaseMaterialTypeMapper baseMapper; + + /** + * 查询物料类型信息 + * + * @param matrialTypeId 主键 + * @return 物料类型信息 + */ + @Override + public BaseMaterialTypeVo queryById(Long matrialTypeId){ + return baseMapper.selectVoById(matrialTypeId); + } + + + /** + * 查询符合条件的物料类型信息列表 + * + * @param bo 查询条件 + * @return 物料类型信息列表 + */ + @Override + public List queryList(BaseMaterialTypeBo bo) { + MPJLambdaWrapper lqw = buildQueryWrapper(bo); + return baseMapper.selectVoList(lqw); + } + + private MPJLambdaWrapper buildQueryWrapper(BaseMaterialTypeBo bo) { + Map params = bo.getParams(); + MPJLambdaWrapper lqw = JoinWrappers.lambda(BaseMaterialType.class) + + // 关联查询工序名称 +// .select(ProdBaseProcessInfo::getProcessName) +// .leftJoin(ProdBaseProcessInfo.class, ProdBaseProcessInfo::getProcessId, BaseMaterialType::getProcessId) + + // 关联查询物料大类名称 + .select(BaseMaterialCategory::getMaterialCategoryName) + .leftJoin(BaseMaterialCategory.class, BaseMaterialCategory::getMaterialCategoryId, BaseMaterialType::getMaterialCategoryId) + + .selectAll(BaseMaterialType.class) + .eq(bo.getMatrialTypeId() != null, BaseMaterialType::getMatrialTypeId, bo.getMatrialTypeId()) + .eq(bo.getParentId() != null, BaseMaterialType::getParentId, bo.getParentId()) + .eq(StringUtils.isNotBlank(bo.getMatrialTypeCode()), BaseMaterialType::getMatrialTypeCode, bo.getMatrialTypeCode()) + .like(StringUtils.isNotBlank(bo.getMatrialTypeName()), BaseMaterialType::getMatrialTypeName, bo.getMatrialTypeName()) + .eq(StringUtils.isNotBlank(bo.getAncestors()), BaseMaterialType::getAncestors, bo.getAncestors()) + .eq(bo.getMaterialCategoryId()!=null, BaseMaterialType::getMaterialCategoryId, bo.getMaterialCategoryId()) + .eq(StringUtils.isNotBlank(bo.getMaterialSubclass()), BaseMaterialType::getMaterialSubclass, bo.getMaterialSubclass()) + .eq(bo.getProcessId() != null, BaseMaterialType::getProcessId, bo.getProcessId()) + .eq(StringUtils.isNotBlank(bo.getActiveFlag()), BaseMaterialType::getActiveFlag, bo.getActiveFlag()) + .orderByAsc(BaseMaterialType::getCreateTime); + return lqw; + } + + /** + * 新增物料类型信息 + * + * @param bo 物料类型信息 + * @return 是否新增成功 + */ + @Override + public Boolean insertByBo(BaseMaterialTypeBo bo) { + BaseMaterialType add = MapstructUtils.convert(bo, BaseMaterialType.class); + validEntityBeforeSave(add); + + //获取父节点信息 + BaseMaterialTypeVo query = baseMapper.selectVoById(bo.getParentId()); + if (ObjectUtils.isNotEmpty(query)) { + //若父节点不为空,则将父节点的ancestors拼接父节点id拼接成ancestors + add.setAncestors(query.getAncestors() + "," + bo.getParentId()); + }else{ + //若父节点为空,则ancestors仅有父节点id + add.setAncestors(bo.getParentId().toString()); + } + + boolean flag = baseMapper.insert(add) > 0; + if (flag) { + bo.setMatrialTypeId(add.getMatrialTypeId()); + } + return flag; + } + + /** + * 修改物料类型信息 + * + * @param bo 物料类型信息 + * @return 是否修改成功 + */ + @Override + public Boolean updateByBo(BaseMaterialTypeBo bo) { + BaseMaterialType update = MapstructUtils.convert(bo, BaseMaterialType.class); + validEntityBeforeSave(update); + return baseMapper.updateById(update) > 0; + } + + /** + * 保存前的数据校验 + */ + private void validEntityBeforeSave(BaseMaterialType entity){ + //TODO 做一些数据校验,如唯一约束 + + //编号校验 + if (StringUtils.isNotBlank(entity.getMatrialTypeCode())) { + BaseMaterialTypeBo query = new BaseMaterialTypeBo(); + query.setMatrialTypeCode(entity.getMatrialTypeCode()); + MPJLambdaWrapper lqw = buildQueryWrapper(query); + BaseMaterialType baseMaterialType = baseMapper.selectOne(lqw); + if (baseMaterialType != null && !baseMaterialType.getMatrialTypeId().equals(entity.getMatrialTypeId())) { + throw new ServiceException("编码已存在"); + } + } + + if (StringUtils.isNotBlank(entity.getMatrialTypeName())) { + BaseMaterialTypeBo query = new BaseMaterialTypeBo(); + query.setMatrialTypeName(entity.getMatrialTypeName()); + MPJLambdaWrapper lqw = JoinWrappers.lambda(BaseMaterialType.class) + .selectAll(BaseMaterialType.class) + .eq(StringUtils.isNotBlank(query.getMatrialTypeName()),BaseMaterialType::getMatrialTypeName, query.getMatrialTypeName()); + BaseMaterialType baseMaterialType = baseMapper.selectOne(lqw); + if (baseMaterialType != null + && !baseMaterialType.getMatrialTypeId().equals(entity.getMatrialTypeId())) { + throw new ServiceException("名称已存在"); + } + } + + } + + /** + * 校验并批量删除物料类型信息信息 + * + * @param ids 待删除的主键集合 + * @param isValid 是否进行有效性校验 + * @return 是否删除成功 + */ + @Override + public Boolean deleteWithValidByIds(Collection ids, Boolean isValid) { + if(isValid){ + //TODO 做一些业务上的校验,判断是否需要校验 + for (Long id : ids) { + //监测删除的节点是否有子节点 + BaseMaterialType query = new BaseMaterialType(); + query.setParentId(id); + if (baseMapper.selectCount(Wrappers.lambdaQuery(query)) > 0) { + throw new ServiceException("存在子节点,不允许删除"); + } + } + } + return baseMapper.deleteByIds(ids) > 0; + } +} diff --git a/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/service/impl/BaseMeasurementUnitInfoServiceImpl.java b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/service/impl/BaseMeasurementUnitInfoServiceImpl.java new file mode 100644 index 0000000..44e1ed3 --- /dev/null +++ b/ruoyi-modules/hwmom-wms/src/main/java/org/dromara/wms/service/impl/BaseMeasurementUnitInfoServiceImpl.java @@ -0,0 +1,154 @@ +package org.dromara.wms.service.impl; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.github.yulichang.toolkit.JoinWrappers; +import com.github.yulichang.wrapper.MPJLambdaWrapper; +import lombok.RequiredArgsConstructor; +import org.apache.commons.lang3.ObjectUtils; +import org.dromara.common.core.exception.ServiceException; +import org.dromara.common.core.utils.MapstructUtils; +import org.dromara.common.core.utils.StringUtils; +import org.dromara.wms.domain.BaseMeasurementUnitInfo; +import org.dromara.wms.domain.bo.BaseMeasurementUnitInfoBo; +import org.dromara.wms.domain.vo.BaseMeasurementUnitInfoVo; +import org.dromara.wms.mapper.BaseMeasurementUnitInfoMapper; +import org.dromara.wms.service.IBaseMeasurementUnitInfoService; +import org.springframework.stereotype.Service; + +import java.util.Collection; +import java.util.List; +import java.util.Map; + +/** + * 计量单位信息Service业务层处理 + * + * @author zangch + * @date 2025-01-08 + */ +@RequiredArgsConstructor +@Service +public class BaseMeasurementUnitInfoServiceImpl implements IBaseMeasurementUnitInfoService { + + private final BaseMeasurementUnitInfoMapper baseMapper; + + /** + * 查询计量单位信息 + * + * @param unitId 主键 + * @return 计量单位信息 + */ + @Override + public BaseMeasurementUnitInfoVo queryById(Long unitId){ + return baseMapper.selectVoById(unitId); + } + + + /** + * 查询符合条件的计量单位信息列表 + * + * @param bo 查询条件 + * @return 计量单位信息列表 + */ + @Override + public List queryList(BaseMeasurementUnitInfoBo bo) { + MPJLambdaWrapper lqw = buildQueryWrapper(bo); + return baseMapper.selectVoList(lqw); + } + + private MPJLambdaWrapper buildQueryWrapper(BaseMeasurementUnitInfoBo bo) { + Map params = bo.getParams(); + MPJLambdaWrapper lqw = JoinWrappers.lambda(BaseMeasurementUnitInfo.class) + .selectAll(BaseMeasurementUnitInfo.class) + .eq(bo.getUnitId() != null, BaseMeasurementUnitInfo::getUnitId, bo.getUnitId()) + .eq(bo.getParentId() != null, BaseMeasurementUnitInfo::getParentId, bo.getParentId()) + .eq(StringUtils.isNotBlank(bo.getUnitCode()), BaseMeasurementUnitInfo::getUnitCode, bo.getUnitCode()) + .like(StringUtils.isNotBlank(bo.getUnitName()), BaseMeasurementUnitInfo::getUnitName, bo.getUnitName()) + .eq(bo.getUnitConversion() != null, BaseMeasurementUnitInfo::getUnitConversion, bo.getUnitConversion()) + .eq(StringUtils.isNotBlank(bo.getAncestors()), BaseMeasurementUnitInfo::getAncestors, bo.getAncestors()) + .eq(StringUtils.isNotBlank(bo.getUnitType()), BaseMeasurementUnitInfo::getUnitType, bo.getUnitType()) + .eq(StringUtils.isNotBlank(bo.getActiveFlag()), BaseMeasurementUnitInfo::getActiveFlag, bo.getActiveFlag()) + .orderByDesc(BaseMeasurementUnitInfo::getCreateTime); + return lqw; + } + + /** + * 新增计量单位信息 + * + * @param bo 计量单位信息 + * @return 是否新增成功 + */ + @Override + public Boolean insertByBo(BaseMeasurementUnitInfoBo bo) { + BaseMeasurementUnitInfo add = MapstructUtils.convert(bo, BaseMeasurementUnitInfo.class); + validEntityBeforeSave(add); + + // 获取父节点信息 + BaseMeasurementUnitInfoVo query = baseMapper.selectVoById(bo.getParentId()); + if (ObjectUtils.isNotEmpty(query)) { + //若父节点不为空,则将父节点的ancestors拼接父节点id拼接成ancestors + add.setAncestors(query.getAncestors() + "," + bo.getParentId()); + }else{ + //若父节点为空,则ancestors仅有父节点id + add.setAncestors(bo.getParentId().toString()); + } + + boolean flag = baseMapper.insert(add) > 0; + if (flag) { + bo.setUnitId(add.getUnitId()); + } + return flag; + } + + /** + * 修改计量单位信息 + * + * @param bo 计量单位信息 + * @return 是否修改成功 + */ + @Override + public Boolean updateByBo(BaseMeasurementUnitInfoBo bo) { + BaseMeasurementUnitInfo update = MapstructUtils.convert(bo, BaseMeasurementUnitInfo.class); + validEntityBeforeSave(update); + return baseMapper.updateById(update) > 0; + } + + /** + * 保存前的数据校验 + */ + private void validEntityBeforeSave(BaseMeasurementUnitInfo entity){ + //TODO 做一些数据校验,如唯一约束 + // 校验编码是否重复 + if (StringUtils.isNotBlank(entity.getUnitCode())) { + BaseMeasurementUnitInfoBo query = new BaseMeasurementUnitInfoBo(); + query.setUnitCode(entity.getUnitCode()); + MPJLambdaWrapper lqw = buildQueryWrapper(query); + BaseMeasurementUnitInfo baseMeasurementUnitInfo = baseMapper.selectOne(lqw); + if (baseMeasurementUnitInfo != null && !baseMeasurementUnitInfo.getUnitId().equals(entity.getUnitId())) { + throw new ServiceException("编码已存在"); + } + } + } + + /** + * 校验并批量删除计量单位信息信息 + * + * @param ids 待删除的主键集合 + * @param isValid 是否进行有效性校验 + * @return 是否删除成功 + */ + @Override + public Boolean deleteWithValidByIds(Collection ids, Boolean isValid) { + if(isValid){ + //TODO 做一些业务上的校验,判断是否需要校验 + for (Long id : ids) { + // 判断是否存在子节点 + BaseMeasurementUnitInfo query = new BaseMeasurementUnitInfo(); + query.setParentId(id); + if (baseMapper.selectCount(Wrappers.lambdaQuery(query)) > 0) { + throw new ServiceException("存在子节点,不允许删除"); + } + } + } + return baseMapper.deleteByIds(ids) > 0; + } +} diff --git a/ruoyi-modules/hwmom-wms/src/main/resources/mapper/wms/BaseMaterialTypeMapper.xml b/ruoyi-modules/hwmom-wms/src/main/resources/mapper/wms/BaseMaterialTypeMapper.xml new file mode 100644 index 0000000..f18dafc --- /dev/null +++ b/ruoyi-modules/hwmom-wms/src/main/resources/mapper/wms/BaseMaterialTypeMapper.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/ruoyi-modules/hwmom-wms/src/main/resources/mapper/wms/BaseMeasurementUnitInfoMapper.xml b/ruoyi-modules/hwmom-wms/src/main/resources/mapper/wms/BaseMeasurementUnitInfoMapper.xml new file mode 100644 index 0000000..845d6fb --- /dev/null +++ b/ruoyi-modules/hwmom-wms/src/main/resources/mapper/wms/BaseMeasurementUnitInfoMapper.xml @@ -0,0 +1,7 @@ + + + + +