diff --git a/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/item/WmsItemBrandController.java b/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/item/WmsItemBrandController.java new file mode 100644 index 0000000..6094e11 --- /dev/null +++ b/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/item/WmsItemBrandController.java @@ -0,0 +1,100 @@ +package cn.iocoder.yudao.module.wms.controller.admin.md.item; + +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; +import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.brand.WmsItemBrandPageReqVO; +import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.brand.WmsItemBrandRespVO; +import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.brand.WmsItemBrandSaveReqVO; +import cn.iocoder.yudao.module.wms.dal.dataobject.md.item.WmsItemBrandDO; +import cn.iocoder.yudao.module.wms.service.md.item.WmsItemBrandService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.Resource; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.validation.Valid; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.io.IOException; +import java.util.List; + +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +@Tag(name = "管理后台 - WMS 商品品牌") +@RestController +@RequestMapping("/wms/item-brand") +@Validated +public class WmsItemBrandController { + + @Resource + private WmsItemBrandService brandService; + + @PostMapping("/create") + @Operation(summary = "创建商品品牌") + @PreAuthorize("@ss.hasPermission('wms:item-brand:create')") + public CommonResult createItemBrand(@Valid @RequestBody WmsItemBrandSaveReqVO createReqVO) { + return success(brandService.createItemBrand(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新商品品牌") + @PreAuthorize("@ss.hasPermission('wms:item-brand:update')") + public CommonResult updateItemBrand(@Valid @RequestBody WmsItemBrandSaveReqVO updateReqVO) { + brandService.updateItemBrand(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除商品品牌") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('wms:item-brand:delete')") + public CommonResult deleteItemBrand(@RequestParam("id") Long id) { + brandService.deleteItemBrand(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得商品品牌") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('wms:item-brand:query')") + public CommonResult getItemBrand(@RequestParam("id") Long id) { + WmsItemBrandDO brand = brandService.getItemBrand(id); + return success(BeanUtils.toBean(brand, WmsItemBrandRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得商品品牌分页") + @PreAuthorize("@ss.hasPermission('wms:item-brand:query')") + public CommonResult> getItemBrandPage(@Valid WmsItemBrandPageReqVO pageReqVO) { + PageResult pageResult = brandService.getItemBrandPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, WmsItemBrandRespVO.class)); + } + + @GetMapping("/simple-list") + @Operation(summary = "获得商品品牌精简列表", description = "主要用于前端下拉") + @PreAuthorize("@ss.hasPermission('wms:item-brand:query')") + public CommonResult> getItemBrandSimpleList() { + List list = brandService.getItemBrandList(); + return success(BeanUtils.toBean(list, WmsItemBrandRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出商品品牌 Excel") + @PreAuthorize("@ss.hasPermission('wms:item-brand:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportItemBrandExcel(@Valid WmsItemBrandPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = brandService.getItemBrandPage(pageReqVO).getList(); + ExcelUtils.write(response, "商品品牌.xls", "数据", WmsItemBrandRespVO.class, + BeanUtils.toBean(list, WmsItemBrandRespVO.class)); + } + +} diff --git a/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/item/WmsItemCategoryController.java b/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/item/WmsItemCategoryController.java new file mode 100644 index 0000000..d30edfa --- /dev/null +++ b/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/item/WmsItemCategoryController.java @@ -0,0 +1,81 @@ +package cn.iocoder.yudao.module.wms.controller.admin.md.item; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.category.WmsItemCategoryListReqVO; +import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.category.WmsItemCategoryRespVO; +import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.category.WmsItemCategorySaveReqVO; +import cn.iocoder.yudao.module.wms.dal.dataobject.md.item.WmsItemCategoryDO; +import cn.iocoder.yudao.module.wms.service.md.item.WmsItemCategoryService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.Resource; +import jakarta.validation.Valid; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +@Tag(name = "管理后台 - WMS 商品分类") +@RestController +@RequestMapping("/wms/item-category") +@Validated +public class WmsItemCategoryController { + + @Resource + private WmsItemCategoryService categoryService; + + @PostMapping("/create") + @Operation(summary = "创建商品分类") + @PreAuthorize("@ss.hasPermission('wms:item-category:create')") + public CommonResult createItemCategory(@Valid @RequestBody WmsItemCategorySaveReqVO createReqVO) { + return success(categoryService.createItemCategory(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新商品分类") + @PreAuthorize("@ss.hasPermission('wms:item-category:update')") + public CommonResult updateItemCategory(@Valid @RequestBody WmsItemCategorySaveReqVO updateReqVO) { + categoryService.updateItemCategory(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除商品分类") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('wms:item-category:delete')") + public CommonResult deleteItemCategory(@RequestParam("id") Long id) { + categoryService.deleteItemCategory(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得商品分类") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('wms:item-category:query')") + public CommonResult getItemCategory(@RequestParam("id") Long id) { + WmsItemCategoryDO category = categoryService.getItemCategory(id); + return success(BeanUtils.toBean(category, WmsItemCategoryRespVO.class)); + } + + @GetMapping("/list") + @Operation(summary = "获得商品分类列表") + @PreAuthorize("@ss.hasPermission('wms:item-category:query')") + public CommonResult> getItemCategoryList(@Valid WmsItemCategoryListReqVO listReqVO) { + List list = categoryService.getItemCategoryList(listReqVO); + return success(BeanUtils.toBean(list, WmsItemCategoryRespVO.class)); + } + + @GetMapping("/simple-list") + @Operation(summary = "获得商品分类精简列表", description = "主要用于前端下拉") + @PreAuthorize("@ss.hasPermission('wms:item-category:query')") + public CommonResult> getItemCategorySimpleList() { + List list = categoryService.getItemCategoryList(new WmsItemCategoryListReqVO()); + return success(BeanUtils.toBean(list, WmsItemCategoryRespVO.class)); + } + +} diff --git a/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/item/vo/brand/WmsItemBrandPageReqVO.java b/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/item/vo/brand/WmsItemBrandPageReqVO.java new file mode 100644 index 0000000..1946cf4 --- /dev/null +++ b/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/item/vo/brand/WmsItemBrandPageReqVO.java @@ -0,0 +1,18 @@ +package cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.brand; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@Schema(description = "管理后台 - WMS 商品品牌分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class WmsItemBrandPageReqVO extends PageParam { + + @Schema(description = "品牌名称", example = "华为") + private String name; + +} diff --git a/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/item/vo/brand/WmsItemBrandRespVO.java b/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/item/vo/brand/WmsItemBrandRespVO.java new file mode 100644 index 0000000..b87a0ed --- /dev/null +++ b/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/item/vo/brand/WmsItemBrandRespVO.java @@ -0,0 +1,27 @@ +package cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.brand; + +import cn.idev.excel.annotation.ExcelIgnoreUnannotated; +import cn.idev.excel.annotation.ExcelProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - WMS 商品品牌 Response VO") +@Data +@ExcelIgnoreUnannotated +public class WmsItemBrandRespVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @ExcelProperty("编号") + private Long id; + + @Schema(description = "品牌名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "华为") + @ExcelProperty("品牌名称") + private String name; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} diff --git a/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/item/vo/brand/WmsItemBrandSaveReqVO.java b/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/item/vo/brand/WmsItemBrandSaveReqVO.java new file mode 100644 index 0000000..3112abe --- /dev/null +++ b/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/item/vo/brand/WmsItemBrandSaveReqVO.java @@ -0,0 +1,20 @@ +package cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.brand; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.Size; +import lombok.Data; + +@Schema(description = "管理后台 - WMS 商品品牌新增/修改 Request VO") +@Data +public class WmsItemBrandSaveReqVO { + + @Schema(description = "编号", example = "1024") + private Long id; + + @Schema(description = "品牌名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "华为") + @NotEmpty(message = "品牌名称不能为空") + @Size(max = 30, message = "品牌名称长度不能超过 30 个字符") + private String name; + +} diff --git a/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/item/vo/category/WmsItemCategoryListReqVO.java b/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/item/vo/category/WmsItemCategoryListReqVO.java new file mode 100644 index 0000000..2329aa1 --- /dev/null +++ b/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/item/vo/category/WmsItemCategoryListReqVO.java @@ -0,0 +1,22 @@ +package cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.category; + +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; +import cn.iocoder.yudao.framework.common.validation.InEnum; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Schema(description = "管理后台 - WMS 商品分类列表 Request VO") +@Data +public class WmsItemCategoryListReqVO { + + @Schema(description = "父级编号", example = "1") + private Long parentId; + + @Schema(description = "分类名称", example = "原料") + private String name; + + @Schema(description = "状态", example = "0") + @InEnum(value = CommonStatusEnum.class, message = "状态必须是 {value}") + private Integer status; + +} diff --git a/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/item/vo/category/WmsItemCategoryRespVO.java b/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/item/vo/category/WmsItemCategoryRespVO.java new file mode 100644 index 0000000..593b5f2 --- /dev/null +++ b/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/item/vo/category/WmsItemCategoryRespVO.java @@ -0,0 +1,30 @@ +package cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.category; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - WMS 商品分类 Response VO") +@Data +public class WmsItemCategoryRespVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + private Long id; + + @Schema(description = "父级编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") + private Long parentId; + + @Schema(description = "分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "原料") + private String name; + + @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + private Integer sort; + + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") + private Integer status; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + private LocalDateTime createTime; + +} diff --git a/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/item/vo/category/WmsItemCategorySaveReqVO.java b/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/item/vo/category/WmsItemCategorySaveReqVO.java new file mode 100644 index 0000000..a26db9a --- /dev/null +++ b/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/item/vo/category/WmsItemCategorySaveReqVO.java @@ -0,0 +1,36 @@ +package cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.category; + +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; +import cn.iocoder.yudao.framework.common.validation.InEnum; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; +import lombok.Data; + +@Schema(description = "管理后台 - WMS 商品分类新增/修改 Request VO") +@Data +public class WmsItemCategorySaveReqVO { + + @Schema(description = "编号", example = "1024") + private Long id; + + @Schema(description = "父级编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") + @NotNull(message = "父级编号不能为空") + private Long parentId; + + @Schema(description = "分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "原料") + @NotEmpty(message = "分类名称不能为空") + @Size(max = 30, message = "分类名称长度不能超过 30 个字符") + private String name; + + @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @NotNull(message = "排序不能为空") + private Integer sort; + + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") + @NotNull(message = "状态不能为空") + @InEnum(value = CommonStatusEnum.class, message = "状态必须是 {value}") + private Integer status; + +} diff --git a/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/warehouse/WmsWarehouseAreaController.java b/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/warehouse/WmsWarehouseAreaController.java index 809814d..b8eec34 100644 --- a/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/warehouse/WmsWarehouseAreaController.java +++ b/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/warehouse/WmsWarehouseAreaController.java @@ -1,10 +1,13 @@ package cn.iocoder.yudao.module.wms.controller.admin.md.warehouse; import cn.hutool.core.collection.CollUtil; +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.collection.MapUtils; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.module.wms.controller.admin.md.warehouse.vo.area.WmsWarehouseAreaPageReqVO; import cn.iocoder.yudao.module.wms.controller.admin.md.warehouse.vo.area.WmsWarehouseAreaRespVO; import cn.iocoder.yudao.module.wms.controller.admin.md.warehouse.vo.area.WmsWarehouseAreaSaveReqVO; @@ -16,15 +19,18 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; +import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.Valid; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import java.io.IOException; import java.util.Collections; import java.util.List; import java.util.Map; +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getFirst; @@ -90,6 +96,18 @@ public class WmsWarehouseAreaController { return success(buildWarehouseAreaRespVOList(list)); } + @GetMapping("/export-excel") + @Operation(summary = "导出库区 Excel") + @PreAuthorize("@ss.hasPermission('wms:warehouse-area:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportWarehouseAreaExcel(@Valid WmsWarehouseAreaPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = warehouseAreaService.getWarehouseAreaPage(pageReqVO).getList(); + ExcelUtils.write(response, "库区.xls", "数据", WmsWarehouseAreaRespVO.class, + buildWarehouseAreaRespVOList(list)); + } + // ==================== 拼接 VO ==================== private WmsWarehouseAreaRespVO buildWarehouseAreaRespVO(WmsWarehouseAreaDO area) { diff --git a/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/warehouse/WmsWarehouseController.java b/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/warehouse/WmsWarehouseController.java index b473137..fcb1981 100644 --- a/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/warehouse/WmsWarehouseController.java +++ b/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/warehouse/WmsWarehouseController.java @@ -1,8 +1,11 @@ package cn.iocoder.yudao.module.wms.controller.admin.md.warehouse; +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.module.wms.controller.admin.md.warehouse.vo.WmsWarehousePageReqVO; import cn.iocoder.yudao.module.wms.controller.admin.md.warehouse.vo.WmsWarehouseRespVO; import cn.iocoder.yudao.module.wms.controller.admin.md.warehouse.vo.WmsWarehouseSaveReqVO; @@ -12,13 +15,16 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; +import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.Valid; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import java.io.IOException; import java.util.List; +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @Tag(name = "管理后台 - WMS 仓库") @@ -79,4 +85,16 @@ public class WmsWarehouseController { return success(BeanUtils.toBean(list, WmsWarehouseRespVO.class)); } + @GetMapping("/export-excel") + @Operation(summary = "导出仓库 Excel") + @PreAuthorize("@ss.hasPermission('wms:warehouse:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportWarehouseExcel(@Valid WmsWarehousePageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = warehouseService.getWarehousePage(pageReqVO).getList(); + ExcelUtils.write(response, "仓库.xls", "数据", WmsWarehouseRespVO.class, + BeanUtils.toBean(list, WmsWarehouseRespVO.class)); + } + } diff --git a/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/dal/dataobject/md/item/WmsItemBrandDO.java b/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/dal/dataobject/md/item/WmsItemBrandDO.java new file mode 100644 index 0000000..996edc4 --- /dev/null +++ b/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/dal/dataobject/md/item/WmsItemBrandDO.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.wms.dal.dataobject.md.item; + +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.*; + +/** + * WMS 商品品牌 DO + * + * @author 芋道源码 + */ +@TableName("wms_item_brand") +@KeySequence("wms_item_brand_seq") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WmsItemBrandDO extends BaseDO { + + /** + * 主键编号 + */ + @TableId + private Long id; + /** + * 品牌名称 + */ + private String name; + +} diff --git a/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/dal/dataobject/md/item/WmsItemCategoryDO.java b/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/dal/dataobject/md/item/WmsItemCategoryDO.java new file mode 100644 index 0000000..fdb3a78 --- /dev/null +++ b/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/dal/dataobject/md/item/WmsItemCategoryDO.java @@ -0,0 +1,56 @@ +package cn.iocoder.yudao.module.wms.dal.dataobject.md.item; + +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.*; + +/** + * WMS 商品分类 DO + * + * @author 芋道源码 + */ +@TableName("wms_item_category") +@KeySequence("wms_item_category_seq") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WmsItemCategoryDO extends BaseDO { + + /** + * 父级编号 - 根节点 + */ + public static final Long PARENT_ID_ROOT = 0L; + + /** + * 主键编号 + */ + @TableId + private Long id; + /** + * 父级编号 + * + * 关联 {@link #id} + */ + private Long parentId; + /** + * 分类名称 + */ + private String name; + /** + * 排序 + */ + private Integer sort; + /** + * 状态 + * + * 枚举 {@link CommonStatusEnum} + */ + private Integer status; + +} diff --git a/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/dal/mysql/md/item/WmsItemBrandMapper.java b/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/dal/mysql/md/item/WmsItemBrandMapper.java new file mode 100644 index 0000000..4b9bc2d --- /dev/null +++ b/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/dal/mysql/md/item/WmsItemBrandMapper.java @@ -0,0 +1,24 @@ +package cn.iocoder.yudao.module.wms.dal.mysql.md.item; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.brand.WmsItemBrandPageReqVO; +import cn.iocoder.yudao.module.wms.dal.dataobject.md.item.WmsItemBrandDO; +import org.apache.ibatis.annotations.Mapper; + +/** + * WMS 商品品牌 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface WmsItemBrandMapper extends BaseMapperX { + + default PageResult selectPage(WmsItemBrandPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .likeIfPresent(WmsItemBrandDO::getName, reqVO.getName()) + .orderByDesc(WmsItemBrandDO::getId)); + } + +} diff --git a/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/dal/mysql/md/item/WmsItemCategoryMapper.java b/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/dal/mysql/md/item/WmsItemCategoryMapper.java new file mode 100644 index 0000000..7080ed1 --- /dev/null +++ b/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/dal/mysql/md/item/WmsItemCategoryMapper.java @@ -0,0 +1,36 @@ +package cn.iocoder.yudao.module.wms.dal.mysql.md.item; + +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.category.WmsItemCategoryListReqVO; +import cn.iocoder.yudao.module.wms.dal.dataobject.md.item.WmsItemCategoryDO; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * WMS 商品分类 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface WmsItemCategoryMapper extends BaseMapperX { + + default List selectList(WmsItemCategoryListReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .eqIfPresent(WmsItemCategoryDO::getParentId, reqVO.getParentId()) + .likeIfPresent(WmsItemCategoryDO::getName, reqVO.getName()) + .eqIfPresent(WmsItemCategoryDO::getStatus, reqVO.getStatus()) + .orderByAsc(WmsItemCategoryDO::getSort) + .orderByAsc(WmsItemCategoryDO::getId)); + } + + default WmsItemCategoryDO selectByParentIdAndName(Long parentId, String name) { + return selectOne(WmsItemCategoryDO::getParentId, parentId, WmsItemCategoryDO::getName, name); + } + + default Long selectCountByParentId(Long parentId) { + return selectCount(WmsItemCategoryDO::getParentId, parentId); + } + +} diff --git a/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/enums/ErrorCodeConstants.java b/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/enums/ErrorCodeConstants.java index bcc047c..363e015 100644 --- a/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/enums/ErrorCodeConstants.java +++ b/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/enums/ErrorCodeConstants.java @@ -23,4 +23,15 @@ public interface ErrorCodeConstants { ErrorCode WAREHOUSE_AREA_NAME_DUPLICATE = new ErrorCode(1_060_101_001, "库区名称重复"); ErrorCode WAREHOUSE_AREA_CODE_DUPLICATE = new ErrorCode(1_060_101_002, "库区编号重复"); + // ========== WMS 基础数据-商品分类 1-060-102-000 ========== + ErrorCode ITEM_CATEGORY_NOT_EXISTS = new ErrorCode(1_060_102_000, "商品分类不存在"); + ErrorCode ITEM_CATEGORY_NAME_DUPLICATE = new ErrorCode(1_060_102_001, "商品分类名称重复"); + ErrorCode ITEM_CATEGORY_PARENT_NOT_EXISTS = new ErrorCode(1_060_102_002, "父商品分类不存在"); + ErrorCode ITEM_CATEGORY_PARENT_ERROR = new ErrorCode(1_060_102_003, "不能设置自己为父商品分类"); + ErrorCode ITEM_CATEGORY_PARENT_IS_CHILD = new ErrorCode(1_060_102_004, "不能设置自己的子商品分类为父商品分类"); + ErrorCode ITEM_CATEGORY_HAS_CHILDREN = new ErrorCode(1_060_102_005, "删除失败!请先删除该分类下的子分类!"); + + // ========== WMS 基础数据-商品品牌 1-060-103-000 ========== + ErrorCode ITEM_BRAND_NOT_EXISTS = new ErrorCode(1_060_103_000, "商品品牌不存在"); + } diff --git a/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/service/md/item/WmsItemBrandService.java b/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/service/md/item/WmsItemBrandService.java new file mode 100644 index 0000000..1400672 --- /dev/null +++ b/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/service/md/item/WmsItemBrandService.java @@ -0,0 +1,71 @@ +package cn.iocoder.yudao.module.wms.service.md.item; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.brand.WmsItemBrandPageReqVO; +import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.brand.WmsItemBrandSaveReqVO; +import cn.iocoder.yudao.module.wms.dal.dataobject.md.item.WmsItemBrandDO; +import jakarta.validation.Valid; + +import java.util.List; + +/** + * WMS 商品品牌 Service 接口 + * + * @author 芋道源码 + */ +public interface WmsItemBrandService { + + /** + * 创建商品品牌 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createItemBrand(@Valid WmsItemBrandSaveReqVO createReqVO); + + /** + * 更新商品品牌 + * + * @param updateReqVO 更新信息 + */ + void updateItemBrand(@Valid WmsItemBrandSaveReqVO updateReqVO); + + /** + * 删除商品品牌 + * + * @param id 编号 + */ + void deleteItemBrand(Long id); + + /** + * 校验商品品牌存在 + * + * @param id 编号 + * @return 商品品牌 + */ + WmsItemBrandDO validateItemBrandExists(Long id); + + /** + * 获得商品品牌 + * + * @param id 编号 + * @return 商品品牌 + */ + WmsItemBrandDO getItemBrand(Long id); + + /** + * 获得商品品牌分页 + * + * @param pageReqVO 分页查询 + * @return 商品品牌分页 + */ + PageResult getItemBrandPage(WmsItemBrandPageReqVO pageReqVO); + + /** + * 获得商品品牌列表 + * + * @return 商品品牌列表 + */ + List getItemBrandList(); + +} diff --git a/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/service/md/item/WmsItemBrandServiceImpl.java b/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/service/md/item/WmsItemBrandServiceImpl.java new file mode 100644 index 0000000..f81921d --- /dev/null +++ b/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/service/md/item/WmsItemBrandServiceImpl.java @@ -0,0 +1,80 @@ +package cn.iocoder.yudao.module.wms.service.md.item; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.brand.WmsItemBrandPageReqVO; +import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.brand.WmsItemBrandSaveReqVO; +import cn.iocoder.yudao.module.wms.dal.dataobject.md.item.WmsItemBrandDO; +import cn.iocoder.yudao.module.wms.dal.mysql.md.item.WmsItemBrandMapper; +import jakarta.annotation.Resource; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import java.util.List; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.wms.enums.ErrorCodeConstants.ITEM_BRAND_NOT_EXISTS; + +/** + * WMS 商品品牌 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +public class WmsItemBrandServiceImpl implements WmsItemBrandService { + + @Resource + private WmsItemBrandMapper brandMapper; + + @Override + public Long createItemBrand(WmsItemBrandSaveReqVO createReqVO) { + WmsItemBrandDO brand = BeanUtils.toBean(createReqVO, WmsItemBrandDO.class); + brandMapper.insert(brand); + return brand.getId(); + } + + @Override + public void updateItemBrand(WmsItemBrandSaveReqVO updateReqVO) { + // 校验存在 + validateItemBrandExists(updateReqVO.getId()); + + // 更新 + WmsItemBrandDO updateObj = BeanUtils.toBean(updateReqVO, WmsItemBrandDO.class); + brandMapper.updateById(updateObj); + } + + @Override + public void deleteItemBrand(Long id) { + // 校验存在 + validateItemBrandExists(id); + + // 删除 + brandMapper.deleteById(id); + } + + @Override + public WmsItemBrandDO validateItemBrandExists(Long id) { + WmsItemBrandDO brand = brandMapper.selectById(id); + if (brand == null) { + throw exception(ITEM_BRAND_NOT_EXISTS); + } + return brand; + } + + @Override + public WmsItemBrandDO getItemBrand(Long id) { + return brandMapper.selectById(id); + } + + @Override + public PageResult getItemBrandPage(WmsItemBrandPageReqVO pageReqVO) { + return brandMapper.selectPage(pageReqVO); + } + + @Override + public List getItemBrandList() { + return brandMapper.selectList(); + } + +} diff --git a/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/service/md/item/WmsItemCategoryService.java b/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/service/md/item/WmsItemCategoryService.java new file mode 100644 index 0000000..b19be99 --- /dev/null +++ b/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/service/md/item/WmsItemCategoryService.java @@ -0,0 +1,63 @@ +package cn.iocoder.yudao.module.wms.service.md.item; + +import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.category.WmsItemCategoryListReqVO; +import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.category.WmsItemCategorySaveReqVO; +import cn.iocoder.yudao.module.wms.dal.dataobject.md.item.WmsItemCategoryDO; +import jakarta.validation.Valid; + +import java.util.List; + +/** + * WMS 商品分类 Service 接口 + * + * @author 芋道源码 + */ +public interface WmsItemCategoryService { + + /** + * 创建商品分类 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createItemCategory(@Valid WmsItemCategorySaveReqVO createReqVO); + + /** + * 更新商品分类 + * + * @param updateReqVO 更新信息 + */ + void updateItemCategory(@Valid WmsItemCategorySaveReqVO updateReqVO); + + /** + * 删除商品分类 + * + * @param id 编号 + */ + void deleteItemCategory(Long id); + + /** + * 校验商品分类存在 + * + * @param id 编号 + * @return 商品分类 + */ + WmsItemCategoryDO validateItemCategoryExists(Long id); + + /** + * 获得商品分类 + * + * @param id 编号 + * @return 商品分类 + */ + WmsItemCategoryDO getItemCategory(Long id); + + /** + * 获得商品分类列表 + * + * @param listReqVO 查询条件 + * @return 商品分类列表 + */ + List getItemCategoryList(WmsItemCategoryListReqVO listReqVO); + +} diff --git a/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/service/md/item/WmsItemCategoryServiceImpl.java b/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/service/md/item/WmsItemCategoryServiceImpl.java new file mode 100644 index 0000000..83ce487 --- /dev/null +++ b/yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/service/md/item/WmsItemCategoryServiceImpl.java @@ -0,0 +1,139 @@ +package cn.iocoder.yudao.module.wms.service.md.item; + +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.category.WmsItemCategoryListReqVO; +import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.category.WmsItemCategorySaveReqVO; +import cn.iocoder.yudao.module.wms.dal.dataobject.md.item.WmsItemCategoryDO; +import cn.iocoder.yudao.module.wms.dal.mysql.md.item.WmsItemCategoryMapper; +import jakarta.annotation.Resource; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import java.util.List; +import java.util.Objects; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.wms.enums.ErrorCodeConstants.*; + +/** + * WMS 商品分类 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +public class WmsItemCategoryServiceImpl implements WmsItemCategoryService { + + @Resource + private WmsItemCategoryMapper categoryMapper; + + @Override + public Long createItemCategory(WmsItemCategorySaveReqVO createReqVO) { + // 校验数据 + validateCategorySaveData(createReqVO); + + // 插入 + WmsItemCategoryDO category = BeanUtils.toBean(createReqVO, WmsItemCategoryDO.class); + categoryMapper.insert(category); + return category.getId(); + } + + @Override + public void updateItemCategory(WmsItemCategorySaveReqVO updateReqVO) { + // 校验存在 + validateItemCategoryExists(updateReqVO.getId()); + // 校验数据 + validateCategorySaveData(updateReqVO); + + // 更新 + WmsItemCategoryDO updateObj = BeanUtils.toBean(updateReqVO, WmsItemCategoryDO.class); + categoryMapper.updateById(updateObj); + } + + private void validateCategorySaveData(WmsItemCategorySaveReqVO reqVO) { + validateCategoryNameUnique(reqVO.getId(), reqVO.getParentId(), reqVO.getName()); + validateParentCategory(reqVO.getId(), reqVO.getParentId()); + } + + private void validateCategoryNameUnique(Long id, Long parentId, String name) { + WmsItemCategoryDO category = categoryMapper.selectByParentIdAndName(parentId, name); + if (category == null) { + return; + } + // 如果 id 为空,说明不用比较是否为相同 id 的商品分类 + if (id == null) { + throw exception(ITEM_CATEGORY_NAME_DUPLICATE); + } + if (!Objects.equals(category.getId(), id)) { + throw exception(ITEM_CATEGORY_NAME_DUPLICATE); + } + } + + private void validateParentCategory(Long id, Long parentId) { + if (parentId == null || WmsItemCategoryDO.PARENT_ID_ROOT.equals(parentId)) { + return; + } + // 1. 不能设置自己为父分类 + if (Objects.equals(parentId, id)) { + throw exception(ITEM_CATEGORY_PARENT_ERROR); + } + // 2. 父分类不存在 + WmsItemCategoryDO parentCategory = categoryMapper.selectById(parentId); + if (parentCategory == null) { + throw exception(ITEM_CATEGORY_PARENT_NOT_EXISTS); + } + // 3. 递归校验父分类,如果父分类是自己的子分类,则报错,避免形成环路 + if (id == null) { // id 为空,说明新增,不需要考虑环路 + return; + } + for (int i = 0; i < Short.MAX_VALUE; i++) { + // 3.1 校验环路 + parentId = parentCategory.getParentId(); + if (Objects.equals(id, parentId)) { + throw exception(ITEM_CATEGORY_PARENT_IS_CHILD); + } + // 3.2 继续递归上级父分类 + if (parentId == null || WmsItemCategoryDO.PARENT_ID_ROOT.equals(parentId)) { + break; + } + parentCategory = categoryMapper.selectById(parentId); + if (parentCategory == null) { + break; + } + } + } + + @Override + public void deleteItemCategory(Long id) { + // 校验存在 + validateItemCategoryExists(id); + // 有子分类不能删 + if (categoryMapper.selectCountByParentId(id) > 0) { + throw exception(ITEM_CATEGORY_HAS_CHILDREN); + } + // TODO 商品管理实现后,校验分类下不存在商品后再删除 + + // 删除 + categoryMapper.deleteById(id); + } + + @Override + public WmsItemCategoryDO validateItemCategoryExists(Long id) { + WmsItemCategoryDO category = categoryMapper.selectById(id); + if (category == null) { + throw exception(ITEM_CATEGORY_NOT_EXISTS); + } + return category; + } + + @Override + public WmsItemCategoryDO getItemCategory(Long id) { + return categoryMapper.selectById(id); + } + + @Override + public List getItemCategoryList(WmsItemCategoryListReqVO listReqVO) { + return categoryMapper.selectList(listReqVO); + } + +}