Commit db79926c31b9756dc40dc754a1ab62fdc764b3c7
1 parent
4f236c62
✨ ERP:完成 stock 产品库存、库存明细的实现
Showing
31 changed files
with
953 additions
and
100 deletions
yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/ErrorCodeConstants.java deleted
| 1 | -package cn.iocoder.yudao.module.erp; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.common.exception.ErrorCode; | |
| 4 | - | |
| 5 | -/** | |
| 6 | - * ERP 错误码枚举类 | |
| 7 | - * <p> | |
| 8 | - * erp 系统,使用 1-030-000-000 段 | |
| 9 | - */ | |
| 10 | -public interface ErrorCodeConstants { | |
| 11 | - | |
| 12 | - // ========== ERP 仓库 1-030-400-000 ========== | |
| 13 | - ErrorCode WAREHOUSE_NOT_EXISTS = new ErrorCode(1_030_400_000, "仓库不存在"); | |
| 14 | - | |
| 15 | - // ========== ERP 产品 1-030-500-000 ========== | |
| 16 | - ErrorCode PRODUCT_NOT_EXISTS = new ErrorCode(1_030_500_000, "产品不存在"); | |
| 17 | - | |
| 18 | - // ========== ERP 产品分类 1-030-501-000 ========== | |
| 19 | - ErrorCode PRODUCT_CATEGORY_NOT_EXISTS = new ErrorCode(1_030_501_000, "产品分类不存在"); | |
| 20 | - ErrorCode PRODUCT_CATEGORY_EXITS_CHILDREN = new ErrorCode(1_030_501_001, "存在存在子产品分类,无法删除"); | |
| 21 | - ErrorCode PRODUCT_CATEGORY_PARENT_NOT_EXITS = new ErrorCode(1_030_501_002,"父级产品分类不存在"); | |
| 22 | - ErrorCode PRODUCT_CATEGORY_PARENT_ERROR = new ErrorCode(1_030_501_003, "不能设置自己为父产品分类"); | |
| 23 | - ErrorCode PRODUCT_CATEGORY_NAME_DUPLICATE = new ErrorCode(1_030_501_004, "已经存在该分类名称的产品分类"); | |
| 24 | - ErrorCode PRODUCT_CATEGORY_PARENT_IS_CHILD = new ErrorCode(1_030_501_005, "不能设置自己的子分类为父分类"); | |
| 25 | - ErrorCode PRODUCT_CATEGORY_EXITS_PRODUCT = new ErrorCode(1_030_502_002, "存在产品使用该分类,无法删除"); | |
| 26 | - | |
| 27 | - // ========== ERP 产品单位 1-030-502-000 ========== | |
| 28 | - ErrorCode PRODUCT_UNIT_NOT_EXISTS = new ErrorCode(1_030_502_000, "产品单位不存在"); | |
| 29 | - ErrorCode PRODUCT_UNIT_NAME_DUPLICATE = new ErrorCode(1_030_502_001, "已存在该名字的产品单位"); | |
| 30 | - ErrorCode PRODUCT_UNIT_EXITS_PRODUCT = new ErrorCode(1_030_502_002, "存在产品使用该单位,无法删除"); | |
| 31 | - | |
| 32 | -} |
yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/DictTypeConstants.java
yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/ErrorCodeConstants.java
| ... | ... | @@ -9,7 +9,27 @@ import cn.iocoder.yudao.framework.common.exception.ErrorCode; |
| 9 | 9 | */ |
| 10 | 10 | public interface ErrorCodeConstants { |
| 11 | 11 | |
| 12 | - // ========== 销售订单(1-030-000-000) ========== | |
| 13 | - ErrorCode SALE_ORDER_NOT_EXISTS = new ErrorCode(1_030_000_000, "销售订单不存在"); | |
| 12 | + // ========== 销售订单(1-020-000-000) ========== | |
| 13 | + ErrorCode SALE_ORDER_NOT_EXISTS = new ErrorCode(1_020_000_000, "销售订单不存在"); | |
| 14 | + | |
| 15 | + // ========== ERP 仓库 1-030-400-000 ========== | |
| 16 | + ErrorCode WAREHOUSE_NOT_EXISTS = new ErrorCode(1_030_400_000, "仓库不存在"); | |
| 17 | + | |
| 18 | + // ========== ERP 产品 1-030-500-000 ========== | |
| 19 | + ErrorCode PRODUCT_NOT_EXISTS = new ErrorCode(1_030_500_000, "产品不存在"); | |
| 20 | + | |
| 21 | + // ========== ERP 产品分类 1-030-501-000 ========== | |
| 22 | + ErrorCode PRODUCT_CATEGORY_NOT_EXISTS = new ErrorCode(1_030_501_000, "产品分类不存在"); | |
| 23 | + ErrorCode PRODUCT_CATEGORY_EXITS_CHILDREN = new ErrorCode(1_030_501_001, "存在存在子产品分类,无法删除"); | |
| 24 | + ErrorCode PRODUCT_CATEGORY_PARENT_NOT_EXITS = new ErrorCode(1_030_501_002,"父级产品分类不存在"); | |
| 25 | + ErrorCode PRODUCT_CATEGORY_PARENT_ERROR = new ErrorCode(1_030_501_003, "不能设置自己为父产品分类"); | |
| 26 | + ErrorCode PRODUCT_CATEGORY_NAME_DUPLICATE = new ErrorCode(1_030_501_004, "已经存在该分类名称的产品分类"); | |
| 27 | + ErrorCode PRODUCT_CATEGORY_PARENT_IS_CHILD = new ErrorCode(1_030_501_005, "不能设置自己的子分类为父分类"); | |
| 28 | + ErrorCode PRODUCT_CATEGORY_EXITS_PRODUCT = new ErrorCode(1_030_502_002, "存在产品使用该分类,无法删除"); | |
| 29 | + | |
| 30 | + // ========== ERP 产品单位 1-030-502-000 ========== | |
| 31 | + ErrorCode PRODUCT_UNIT_NOT_EXISTS = new ErrorCode(1_030_502_000, "产品单位不存在"); | |
| 32 | + ErrorCode PRODUCT_UNIT_NAME_DUPLICATE = new ErrorCode(1_030_502_001, "已存在该名字的产品单位"); | |
| 33 | + ErrorCode PRODUCT_UNIT_EXITS_PRODUCT = new ErrorCode(1_030_502_002, "存在产品使用该单位,无法删除"); | |
| 14 | 34 | |
| 15 | 35 | } | ... | ... |
yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/stock/ErpStockRecordBizTypeEnum.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.enums.stock; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.core.IntArrayValuable; | |
| 4 | +import lombok.Getter; | |
| 5 | +import lombok.RequiredArgsConstructor; | |
| 6 | + | |
| 7 | +import java.util.Arrays; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * ERP 库存明细 - 业务类型枚举 | |
| 11 | + * | |
| 12 | + * @author 芋道源码 | |
| 13 | + */ | |
| 14 | +@RequiredArgsConstructor | |
| 15 | +@Getter | |
| 16 | +public enum ErpStockRecordBizTypeEnum implements IntArrayValuable { | |
| 17 | + | |
| 18 | + OTHER_IN(10, "其它入库"), | |
| 19 | + OTHER_IN_CANCEL(11, "其它入库(作废)"), | |
| 20 | + | |
| 21 | + OTHER_OUT(20, "其它出库"), | |
| 22 | + OTHER_OUT_CANCEL(21, "其它出库(作废)"), | |
| 23 | + ; | |
| 24 | + | |
| 25 | + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ErpStockRecordBizTypeEnum::getType).toArray(); | |
| 26 | + | |
| 27 | + /** | |
| 28 | + * 类型 | |
| 29 | + */ | |
| 30 | + private final Integer type; | |
| 31 | + /** | |
| 32 | + * 名字 | |
| 33 | + */ | |
| 34 | + private final String name; | |
| 35 | + | |
| 36 | + @Override | |
| 37 | + public int[] array() { | |
| 38 | + return ARRAYS; | |
| 39 | + } | |
| 40 | + | |
| 41 | +} | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/ErpProductController.java
| 1 | 1 | package cn.iocoder.yudao.module.erp.controller.admin.product; |
| 2 | 2 | |
| 3 | -import cn.hutool.core.collection.CollUtil; | |
| 3 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 6 | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | |
| 8 | 7 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 9 | 8 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| 10 | 9 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; |
| 11 | -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ProductPageReqVO; | |
| 12 | -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ProductRespVO; | |
| 10 | +import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductPageReqVO; | |
| 11 | +import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; | |
| 13 | 12 | import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ProductSaveReqVO; |
| 14 | -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductCategoryDO; | |
| 15 | 13 | import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; |
| 16 | -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductUnitDO; | |
| 17 | -import cn.iocoder.yudao.module.erp.service.product.ErpProductCategoryService; | |
| 18 | 14 | import cn.iocoder.yudao.module.erp.service.product.ErpProductService; |
| 19 | -import cn.iocoder.yudao.module.erp.service.product.ErpProductUnitService; | |
| 20 | 15 | import io.swagger.v3.oas.annotations.Operation; |
| 21 | 16 | import io.swagger.v3.oas.annotations.Parameter; |
| 22 | 17 | import io.swagger.v3.oas.annotations.tags.Tag; |
| ... | ... | @@ -28,10 +23,9 @@ import org.springframework.validation.annotation.Validated; |
| 28 | 23 | import org.springframework.web.bind.annotation.*; |
| 29 | 24 | |
| 30 | 25 | import java.io.IOException; |
| 31 | -import java.util.Map; | |
| 26 | +import java.util.List; | |
| 32 | 27 | |
| 33 | 28 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 34 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | |
| 35 | 29 | import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; |
| 36 | 30 | |
| 37 | 31 | @Tag(name = "管理后台 - ERP 产品") |
| ... | ... | @@ -42,10 +36,6 @@ public class ErpProductController { |
| 42 | 36 | |
| 43 | 37 | @Resource |
| 44 | 38 | private ErpProductService productService; |
| 45 | - @Resource | |
| 46 | - private ErpProductCategoryService productCategoryService; | |
| 47 | - @Resource | |
| 48 | - private ErpProductUnitService productUnitService; | |
| 49 | 39 | |
| 50 | 40 | @PostMapping("/create") |
| 51 | 41 | @Operation(summary = "创建产品") |
| ... | ... | @@ -75,46 +65,36 @@ public class ErpProductController { |
| 75 | 65 | @Operation(summary = "获得产品") |
| 76 | 66 | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| 77 | 67 | @PreAuthorize("@ss.hasPermission('erp:product:query')") |
| 78 | - public CommonResult<ProductRespVO> getProduct(@RequestParam("id") Long id) { | |
| 68 | + public CommonResult<ErpProductRespVO> getProduct(@RequestParam("id") Long id) { | |
| 79 | 69 | ErpProductDO product = productService.getProduct(id); |
| 80 | - return success(BeanUtils.toBean(product, ProductRespVO.class)); | |
| 70 | + return success(BeanUtils.toBean(product, ErpProductRespVO.class)); | |
| 81 | 71 | } |
| 82 | 72 | |
| 83 | 73 | @GetMapping("/page") |
| 84 | 74 | @Operation(summary = "获得产品分页") |
| 85 | 75 | @PreAuthorize("@ss.hasPermission('erp:product:query')") |
| 86 | - public CommonResult<PageResult<ProductRespVO>> getProductPage(@Valid ProductPageReqVO pageReqVO) { | |
| 87 | - PageResult<ErpProductDO> pageResult = productService.getProductPage(pageReqVO); | |
| 88 | - return success(buildProductDetailPage(pageResult)); | |
| 76 | + public CommonResult<PageResult<ErpProductRespVO>> getProductPage(@Valid ErpProductPageReqVO pageReqVO) { | |
| 77 | + return success(productService.getProductVOPage(pageReqVO)); | |
| 78 | + } | |
| 79 | + | |
| 80 | + @GetMapping("/simple-list") | |
| 81 | + @Operation(summary = "获得产品精简列表", description = "只包含被开启的产品,主要用于前端的下拉选项") | |
| 82 | + public CommonResult<List<ErpProductRespVO>> getProductSimpleList() { | |
| 83 | + List<ErpProductDO> list = productService.getProductListByStatus(CommonStatusEnum.ENABLE.getStatus()); | |
| 84 | + return success(BeanUtils.toBean(list, ErpProductRespVO.class)); | |
| 89 | 85 | } |
| 90 | 86 | |
| 91 | 87 | @GetMapping("/export-excel") |
| 92 | 88 | @Operation(summary = "导出产品 Excel") |
| 93 | 89 | @PreAuthorize("@ss.hasPermission('erp:product:export')") |
| 94 | 90 | @OperateLog(type = EXPORT) |
| 95 | - public void exportProductExcel(@Valid ProductPageReqVO pageReqVO, | |
| 91 | + public void exportProductExcel(@Valid ErpProductPageReqVO pageReqVO, | |
| 96 | 92 | HttpServletResponse response) throws IOException { |
| 97 | 93 | pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); |
| 98 | - PageResult<ErpProductDO> pageResult = productService.getProductPage(pageReqVO); | |
| 94 | + PageResult<ErpProductRespVO> pageResult = productService.getProductVOPage(pageReqVO); | |
| 99 | 95 | // 导出 Excel |
| 100 | - ExcelUtils.write(response, "产品.xls", "数据", ProductRespVO.class, | |
| 101 | - buildProductDetailPage(pageResult).getList()); | |
| 102 | - } | |
| 103 | - | |
| 104 | - private PageResult<ProductRespVO> buildProductDetailPage(PageResult<ErpProductDO> pageResult) { | |
| 105 | - if (CollUtil.isEmpty(pageResult.getList())) { | |
| 106 | - return PageResult.empty(pageResult.getTotal()); | |
| 107 | - } | |
| 108 | - Map<Long, ErpProductCategoryDO> categoryMap = productCategoryService.getProductCategoryMap( | |
| 109 | - convertSet(pageResult.getList(), ErpProductDO::getCategoryId)); | |
| 110 | - Map<Long, ErpProductUnitDO> unitMap = productUnitService.getProductUnitMap( | |
| 111 | - convertSet(pageResult.getList(), ErpProductDO::getUnitId)); | |
| 112 | - return BeanUtils.toBean(pageResult, ProductRespVO.class, product -> { | |
| 113 | - MapUtils.findAndThen(categoryMap, product.getCategoryId(), | |
| 114 | - category -> product.setCategoryName(category.getName())); | |
| 115 | - MapUtils.findAndThen(unitMap, product.getUnitId(), | |
| 116 | - unit -> product.setUnitName(unit.getName())); | |
| 117 | - }); | |
| 96 | + ExcelUtils.write(response, "产品.xls", "数据", ErpProductRespVO.class, | |
| 97 | + pageResult.getList()); | |
| 118 | 98 | } |
| 119 | 99 | |
| 120 | 100 | } |
| 121 | 101 | \ No newline at end of file | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/product/ProductPageReqVO.java renamed to yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/product/ErpProductPageReqVO.java
| 1 | 1 | package cn.iocoder.yudao.module.erp.controller.admin.product.vo.product; |
| 2 | 2 | |
| 3 | 3 | import lombok.*; |
| 4 | -import java.util.*; | |
| 5 | 4 | import io.swagger.v3.oas.annotations.media.Schema; |
| 6 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 7 | -import java.math.BigDecimal; | |
| 8 | 6 | import org.springframework.format.annotation.DateTimeFormat; |
| 9 | 7 | import java.time.LocalDateTime; |
| 10 | 8 | |
| ... | ... | @@ -14,7 +12,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ |
| 14 | 12 | @Data |
| 15 | 13 | @EqualsAndHashCode(callSuper = true) |
| 16 | 14 | @ToString(callSuper = true) |
| 17 | -public class ProductPageReqVO extends PageParam { | |
| 15 | +public class ErpProductPageReqVO extends PageParam { | |
| 18 | 16 | |
| 19 | 17 | @Schema(description = "产品名称", example = "李四") |
| 20 | 18 | private String name; | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/product/ProductRespVO.java renamed to yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/product/ErpProductRespVO.java
| ... | ... | @@ -11,7 +11,7 @@ import java.time.LocalDateTime; |
| 11 | 11 | @Schema(description = "管理后台 - ERP 产品 Response VO") |
| 12 | 12 | @Data |
| 13 | 13 | @ExcelIgnoreUnannotated |
| 14 | -public class ProductRespVO { | |
| 14 | +public class ErpProductRespVO { | |
| 15 | 15 | |
| 16 | 16 | @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15672") |
| 17 | 17 | @ExcelProperty("产品编号") | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.controller.admin.stock; | |
| 2 | + | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 6 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 7 | +import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | |
| 8 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 9 | +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | |
| 10 | +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | |
| 11 | +import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; | |
| 12 | +import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.stock.ErpStockPageReqVO; | |
| 13 | +import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.stock.ErpStockRespVO; | |
| 14 | +import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO; | |
| 15 | +import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpWarehouseDO; | |
| 16 | +import cn.iocoder.yudao.module.erp.service.product.ErpProductService; | |
| 17 | +import cn.iocoder.yudao.module.erp.service.stock.ErpStockService; | |
| 18 | +import cn.iocoder.yudao.module.erp.service.stock.ErpWarehouseService; | |
| 19 | +import io.swagger.v3.oas.annotations.Operation; | |
| 20 | +import io.swagger.v3.oas.annotations.Parameter; | |
| 21 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 22 | +import jakarta.annotation.Resource; | |
| 23 | +import jakarta.servlet.http.HttpServletResponse; | |
| 24 | +import jakarta.validation.Valid; | |
| 25 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 26 | +import org.springframework.validation.annotation.Validated; | |
| 27 | +import org.springframework.web.bind.annotation.GetMapping; | |
| 28 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 29 | +import org.springframework.web.bind.annotation.RequestParam; | |
| 30 | +import org.springframework.web.bind.annotation.RestController; | |
| 31 | + | |
| 32 | +import java.io.IOException; | |
| 33 | +import java.util.List; | |
| 34 | +import java.util.Map; | |
| 35 | + | |
| 36 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 37 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | |
| 38 | +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; | |
| 39 | + | |
| 40 | +@Tag(name = "管理后台 - ERP 产品库存") | |
| 41 | +@RestController | |
| 42 | +@RequestMapping("/erp/stock") | |
| 43 | +@Validated | |
| 44 | +public class ErpStockController { | |
| 45 | + | |
| 46 | + @Resource | |
| 47 | + private ErpStockService stockService; | |
| 48 | + @Resource | |
| 49 | + private ErpProductService productService; | |
| 50 | + @Resource | |
| 51 | + private ErpWarehouseService warehouseService; | |
| 52 | + | |
| 53 | + @GetMapping("/get") | |
| 54 | + @Operation(summary = "获得产品库存") | |
| 55 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | |
| 56 | + @PreAuthorize("@ss.hasPermission('erp:stock:query')") | |
| 57 | + public CommonResult<ErpStockRespVO> getStock(@RequestParam("id") Long id) { | |
| 58 | + ErpStockDO stock = stockService.getStock(id); | |
| 59 | + return success(BeanUtils.toBean(stock, ErpStockRespVO.class)); | |
| 60 | + } | |
| 61 | + | |
| 62 | + @GetMapping("/page") | |
| 63 | + @Operation(summary = "获得产品库存分页") | |
| 64 | + @PreAuthorize("@ss.hasPermission('erp:stock:query')") | |
| 65 | + public CommonResult<PageResult<ErpStockRespVO>> getStockPage(@Valid ErpStockPageReqVO pageReqVO) { | |
| 66 | + PageResult<ErpStockDO> pageResult = stockService.getStockPage(pageReqVO); | |
| 67 | + return success(buildStockVOPageResult(pageResult)); | |
| 68 | + } | |
| 69 | + | |
| 70 | + @GetMapping("/export-excel") | |
| 71 | + @Operation(summary = "导出产品库存 Excel") | |
| 72 | + @PreAuthorize("@ss.hasPermission('erp:stock:export')") | |
| 73 | + @OperateLog(type = EXPORT) | |
| 74 | + public void exportStockExcel(@Valid ErpStockPageReqVO pageReqVO, | |
| 75 | + HttpServletResponse response) throws IOException { | |
| 76 | + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | |
| 77 | + List<ErpStockRespVO> list = buildStockVOPageResult(stockService.getStockPage(pageReqVO)).getList(); | |
| 78 | + // 导出 Excel | |
| 79 | + ExcelUtils.write(response, "产品库存.xls", "数据", ErpStockRespVO.class, list); | |
| 80 | + } | |
| 81 | + | |
| 82 | + private PageResult<ErpStockRespVO> buildStockVOPageResult(PageResult<ErpStockDO> pageResult) { | |
| 83 | + if (CollUtil.isEmpty(pageResult.getList())) { | |
| 84 | + return PageResult.empty(pageResult.getTotal()); | |
| 85 | + } | |
| 86 | + Map<Long, ErpProductRespVO> productMap = productService.getProductVOMap( | |
| 87 | + convertSet(pageResult.getList(), ErpStockDO::getProductId)); | |
| 88 | + Map<Long, ErpWarehouseDO> warehouseMap = warehouseService.getWarehouseMap( | |
| 89 | + convertSet(pageResult.getList(), ErpStockDO::getWarehouseId)); | |
| 90 | + return BeanUtils.toBean(pageResult, ErpStockRespVO.class, stock -> { | |
| 91 | + MapUtils.findAndThen(productMap, stock.getProductId(), product -> stock.setProductName(product.getName()) | |
| 92 | + .setCategoryName(product.getCategoryName()).setUnitName(product.getUnitName())); | |
| 93 | + MapUtils.findAndThen(warehouseMap, stock.getWarehouseId(), warehouse -> stock.setWarehouseName(warehouse.getName())); | |
| 94 | + }); | |
| 95 | + } | |
| 96 | + | |
| 97 | +} | |
| 0 | 98 | \ No newline at end of file | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockRecordController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.controller.admin.stock; | |
| 2 | + | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 6 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 7 | +import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | |
| 8 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 9 | +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | |
| 10 | +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | |
| 11 | +import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; | |
| 12 | +import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.stockrecord.ErpStockRecordPageReqVO; | |
| 13 | +import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.stockrecord.ErpStockRecordRespVO; | |
| 14 | +import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockRecordDO; | |
| 15 | +import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpWarehouseDO; | |
| 16 | +import cn.iocoder.yudao.module.erp.service.product.ErpProductService; | |
| 17 | +import cn.iocoder.yudao.module.erp.service.stock.ErpStockRecordService; | |
| 18 | +import cn.iocoder.yudao.module.erp.service.stock.ErpWarehouseService; | |
| 19 | +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | |
| 20 | +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; | |
| 21 | +import io.swagger.v3.oas.annotations.Operation; | |
| 22 | +import io.swagger.v3.oas.annotations.Parameter; | |
| 23 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 24 | +import jakarta.annotation.Resource; | |
| 25 | +import jakarta.servlet.http.HttpServletResponse; | |
| 26 | +import jakarta.validation.Valid; | |
| 27 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 28 | +import org.springframework.validation.annotation.Validated; | |
| 29 | +import org.springframework.web.bind.annotation.GetMapping; | |
| 30 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 31 | +import org.springframework.web.bind.annotation.RequestParam; | |
| 32 | +import org.springframework.web.bind.annotation.RestController; | |
| 33 | + | |
| 34 | +import java.io.IOException; | |
| 35 | +import java.util.List; | |
| 36 | +import java.util.Map; | |
| 37 | + | |
| 38 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 39 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | |
| 40 | +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; | |
| 41 | + | |
| 42 | +@Tag(name = "管理后台 - ERP 产品库存明细") | |
| 43 | +@RestController | |
| 44 | +@RequestMapping("/erp/stock-record") | |
| 45 | +@Validated | |
| 46 | +public class ErpStockRecordController { | |
| 47 | + | |
| 48 | + @Resource | |
| 49 | + private ErpStockRecordService stockRecordService; | |
| 50 | + @Resource | |
| 51 | + private ErpProductService productService; | |
| 52 | + @Resource | |
| 53 | + private ErpWarehouseService warehouseService; | |
| 54 | + | |
| 55 | + @Resource | |
| 56 | + private AdminUserApi adminUserApi; | |
| 57 | + | |
| 58 | + @GetMapping("/get") | |
| 59 | + @Operation(summary = "获得产品库存明细") | |
| 60 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | |
| 61 | + @PreAuthorize("@ss.hasPermission('erp:stock-record:query')") | |
| 62 | + public CommonResult<ErpStockRecordRespVO> getStockRecord(@RequestParam("id") Long id) { | |
| 63 | + ErpStockRecordDO stockRecord = stockRecordService.getStockRecord(id); | |
| 64 | + return success(BeanUtils.toBean(stockRecord, ErpStockRecordRespVO.class)); | |
| 65 | + } | |
| 66 | + | |
| 67 | + @GetMapping("/page") | |
| 68 | + @Operation(summary = "获得产品库存明细分页") | |
| 69 | + @PreAuthorize("@ss.hasPermission('erp:stock-record:query')") | |
| 70 | + public CommonResult<PageResult<ErpStockRecordRespVO>> getStockRecordPage(@Valid ErpStockRecordPageReqVO pageReqVO) { | |
| 71 | + PageResult<ErpStockRecordDO> pageResult = stockRecordService.getStockRecordPage(pageReqVO); | |
| 72 | + return success(buildStockRecrodVOPageResult(pageResult)); | |
| 73 | + } | |
| 74 | + | |
| 75 | + @GetMapping("/export-excel") | |
| 76 | + @Operation(summary = "导出产品库存明细 Excel") | |
| 77 | + @PreAuthorize("@ss.hasPermission('erp:stock-record:export')") | |
| 78 | + @OperateLog(type = EXPORT) | |
| 79 | + public void exportStockRecordExcel(@Valid ErpStockRecordPageReqVO pageReqVO, | |
| 80 | + HttpServletResponse response) throws IOException { | |
| 81 | + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | |
| 82 | + List<ErpStockRecordRespVO> list = buildStockRecrodVOPageResult(stockRecordService.getStockRecordPage(pageReqVO)).getList(); | |
| 83 | + // 导出 Excel | |
| 84 | + ExcelUtils.write(response, "产品库存明细.xls", "数据", ErpStockRecordRespVO.class, list); | |
| 85 | + } | |
| 86 | + | |
| 87 | + private PageResult<ErpStockRecordRespVO> buildStockRecrodVOPageResult(PageResult<ErpStockRecordDO> pageResult) { | |
| 88 | + if (CollUtil.isEmpty(pageResult.getList())) { | |
| 89 | + return PageResult.empty(pageResult.getTotal()); | |
| 90 | + } | |
| 91 | + Map<Long, ErpProductRespVO> productMap = productService.getProductVOMap( | |
| 92 | + convertSet(pageResult.getList(), ErpStockRecordDO::getProductId)); | |
| 93 | + Map<Long, ErpWarehouseDO> warehouseMap = warehouseService.getWarehouseMap( | |
| 94 | + convertSet(pageResult.getList(), ErpStockRecordDO::getWarehouseId)); | |
| 95 | + Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( | |
| 96 | + convertSet(pageResult.getList(), erpStockRecordDO -> Long.parseLong(erpStockRecordDO.getCreator()))); | |
| 97 | + return BeanUtils.toBean(pageResult, ErpStockRecordRespVO.class, stock -> { | |
| 98 | + MapUtils.findAndThen(productMap, stock.getProductId(), product -> stock.setProductName(product.getName()) | |
| 99 | + .setCategoryName(product.getCategoryName()).setUnitName(product.getUnitName())); | |
| 100 | + MapUtils.findAndThen(warehouseMap, stock.getWarehouseId(), warehouse -> stock.setWarehouseName(warehouse.getName())); | |
| 101 | + MapUtils.findAndThen(userMap, Long.parseLong(stock.getCreator()), user -> stock.setCreatorName(user.getNickname())); | |
| 102 | + }); | |
| 103 | + } | |
| 104 | + | |
| 105 | +} | |
| 0 | 106 | \ No newline at end of file | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpWarehouseController.java
| 1 | 1 | package cn.iocoder.yudao.module.erp.controller.admin.stock; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | |
| 3 | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 5 | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| ... | ... | @@ -90,6 +91,13 @@ public class ErpWarehouseController { |
| 90 | 91 | return success(BeanUtils.toBean(pageResult, ErpWarehouseRespVO.class)); |
| 91 | 92 | } |
| 92 | 93 | |
| 94 | + @GetMapping("/simple-list") | |
| 95 | + @Operation(summary = "获得仓库精简列表", description = "只包含被开启的仓库,主要用于前端的下拉选项") | |
| 96 | + public CommonResult<List<ErpWarehouseRespVO>> getWarehouseSimpleList() { | |
| 97 | + List<ErpWarehouseDO> list = warehouseService.getWarehouseListByStatus(CommonStatusEnum.ENABLE.getStatus()); | |
| 98 | + return success(BeanUtils.toBean(list, ErpWarehouseRespVO.class)); | |
| 99 | + } | |
| 100 | + | |
| 93 | 101 | @GetMapping("/export-excel") |
| 94 | 102 | @Operation(summary = "导出仓库 Excel") |
| 95 | 103 | @PreAuthorize("@ss.hasPermission('erp:warehouse:export')") | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/stock/ErpStockPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.stock; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 5 | +import lombok.Data; | |
| 6 | +import lombok.EqualsAndHashCode; | |
| 7 | +import lombok.ToString; | |
| 8 | + | |
| 9 | +@Schema(description = "管理后台 - ERP 库存分页 Request VO") | |
| 10 | +@Data | |
| 11 | +@EqualsAndHashCode(callSuper = true) | |
| 12 | +@ToString(callSuper = true) | |
| 13 | +public class ErpStockPageReqVO extends PageParam { | |
| 14 | + | |
| 15 | + @Schema(description = "产品编号", example = "19614") | |
| 16 | + private Long productId; | |
| 17 | + | |
| 18 | + @Schema(description = "仓库编号", example = "2802") | |
| 19 | + private Long warehouseId; | |
| 20 | + | |
| 21 | +} | |
| 0 | 22 | \ No newline at end of file | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/stock/ErpStockRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.stock; | |
| 2 | + | |
| 3 | +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; | |
| 4 | +import com.alibaba.excel.annotation.ExcelProperty; | |
| 5 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 6 | +import lombok.Data; | |
| 7 | + | |
| 8 | +import java.math.BigDecimal; | |
| 9 | + | |
| 10 | +@Schema(description = "管理后台 - ERP 库存 Response VO") | |
| 11 | +@Data | |
| 12 | +@ExcelIgnoreUnannotated | |
| 13 | +public class ErpStockRespVO { | |
| 14 | + | |
| 15 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17086") | |
| 16 | + @ExcelProperty("编号") | |
| 17 | + private Long id; | |
| 18 | + | |
| 19 | + @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "19614") | |
| 20 | + private Long productId; | |
| 21 | + | |
| 22 | + @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2802") | |
| 23 | + private Long warehouseId; | |
| 24 | + | |
| 25 | + @Schema(description = "库存数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "21935") | |
| 26 | + @ExcelProperty("库存数量") | |
| 27 | + private BigDecimal count; | |
| 28 | + | |
| 29 | + // ========== 产品信息 ========== | |
| 30 | + | |
| 31 | + @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "苹果") | |
| 32 | + @ExcelProperty("产品名称") | |
| 33 | + private String productName; | |
| 34 | + | |
| 35 | + @Schema(description = "产品分类", requiredMode = Schema.RequiredMode.REQUIRED, example = "水果") | |
| 36 | + @ExcelProperty("产品分类") | |
| 37 | + private String categoryName; | |
| 38 | + | |
| 39 | + @Schema(description = "单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "个") | |
| 40 | + @ExcelProperty("单位") | |
| 41 | + private String unitName; | |
| 42 | + | |
| 43 | + // ========== 仓库信息 ========== | |
| 44 | + | |
| 45 | + @Schema(description = "仓库名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") | |
| 46 | + @ExcelProperty("仓库名称") | |
| 47 | + private String warehouseName; | |
| 48 | + | |
| 49 | +} | |
| 0 | 50 | \ No newline at end of file | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/stockrecord/ErpStockRecordPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.stockrecord; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 5 | +import lombok.Data; | |
| 6 | +import lombok.EqualsAndHashCode; | |
| 7 | +import lombok.ToString; | |
| 8 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 9 | + | |
| 10 | +import java.time.LocalDateTime; | |
| 11 | + | |
| 12 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 13 | + | |
| 14 | +@Schema(description = "管理后台 - ERP 产品库存明细分页 Request VO") | |
| 15 | +@Data | |
| 16 | +@EqualsAndHashCode(callSuper = true) | |
| 17 | +@ToString(callSuper = true) | |
| 18 | +public class ErpStockRecordPageReqVO extends PageParam { | |
| 19 | + | |
| 20 | + @Schema(description = "产品编号", example = "10625") | |
| 21 | + private Long productId; | |
| 22 | + | |
| 23 | + @Schema(description = "仓库编号", example = "32407") | |
| 24 | + private Long warehouseId; | |
| 25 | + | |
| 26 | + @Schema(description = "业务类型", example = "10") | |
| 27 | + private Integer bizType; | |
| 28 | + | |
| 29 | + @Schema(description = "业务单号", example = "Z110") | |
| 30 | + private String bizNo; | |
| 31 | + | |
| 32 | + @Schema(description = "创建时间") | |
| 33 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 34 | + private LocalDateTime[] createTime; | |
| 35 | + | |
| 36 | +} | |
| 0 | 37 | \ No newline at end of file | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/stockrecord/ErpStockRecordRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.stockrecord; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; | |
| 4 | +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; | |
| 5 | +import cn.iocoder.yudao.module.erp.enums.DictTypeConstants; | |
| 6 | +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; | |
| 7 | +import com.alibaba.excel.annotation.ExcelProperty; | |
| 8 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 9 | +import lombok.Data; | |
| 10 | + | |
| 11 | +import java.math.BigDecimal; | |
| 12 | +import java.time.LocalDateTime; | |
| 13 | + | |
| 14 | +@Schema(description = "管理后台 - ERP 产品库存明细 Response VO") | |
| 15 | +@Data | |
| 16 | +@ExcelIgnoreUnannotated | |
| 17 | +public class ErpStockRecordRespVO { | |
| 18 | + | |
| 19 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18909") | |
| 20 | + @ExcelProperty("编号") | |
| 21 | + private Long id; | |
| 22 | + | |
| 23 | + @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10625") | |
| 24 | + private Long productId; | |
| 25 | + | |
| 26 | + @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "32407") | |
| 27 | + private Long warehouseId; | |
| 28 | + | |
| 29 | + @Schema(description = "出入库数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "11084") | |
| 30 | + @ExcelProperty("出入库数量") | |
| 31 | + private BigDecimal count; | |
| 32 | + | |
| 33 | + @Schema(description = "总库存量", requiredMode = Schema.RequiredMode.REQUIRED, example = "4307") | |
| 34 | + @ExcelProperty("总库存量") | |
| 35 | + private BigDecimal totalCount; | |
| 36 | + | |
| 37 | + @Schema(description = "业务类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") | |
| 38 | + @ExcelProperty(value = "业务类型", converter = DictConvert.class) | |
| 39 | + @DictFormat(DictTypeConstants.STOCK_RECORD_BIZ_TYPE) | |
| 40 | + private Integer bizType; | |
| 41 | + | |
| 42 | + @Schema(description = "业务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "27093") | |
| 43 | + @ExcelProperty("业务编号") | |
| 44 | + private Long bizId; | |
| 45 | + | |
| 46 | + @Schema(description = "业务项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23516") | |
| 47 | + @ExcelProperty("业务项编号") | |
| 48 | + private Long bizItemId; | |
| 49 | + | |
| 50 | + @Schema(description = "业务单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "Z110") | |
| 51 | + @ExcelProperty("业务单号") | |
| 52 | + private String bizNo; | |
| 53 | + | |
| 54 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 55 | + @ExcelProperty("创建时间") | |
| 56 | + private LocalDateTime createTime; | |
| 57 | + | |
| 58 | + @Schema(description = "创建人", requiredMode = Schema.RequiredMode.REQUIRED, example = "25682") | |
| 59 | + private String creator; | |
| 60 | + | |
| 61 | + // ========== 产品信息 ========== | |
| 62 | + | |
| 63 | + @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "苹果") | |
| 64 | + @ExcelProperty("产品名称") | |
| 65 | + private String productName; | |
| 66 | + | |
| 67 | + @Schema(description = "产品分类", requiredMode = Schema.RequiredMode.REQUIRED, example = "水果") | |
| 68 | + @ExcelProperty("产品分类") | |
| 69 | + private String categoryName; | |
| 70 | + | |
| 71 | + @Schema(description = "单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "个") | |
| 72 | + @ExcelProperty("单位") | |
| 73 | + private String unitName; | |
| 74 | + | |
| 75 | + // ========== 仓库信息 ========== | |
| 76 | + | |
| 77 | + @Schema(description = "仓库名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") | |
| 78 | + @ExcelProperty("仓库名称") | |
| 79 | + private String warehouseName; | |
| 80 | + | |
| 81 | + // ========== 用户信息 ========== | |
| 82 | + | |
| 83 | + @Schema(description = "创建人", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") | |
| 84 | + @ExcelProperty("创建人") | |
| 85 | + private String creatorName; | |
| 86 | + | |
| 87 | +} | |
| 0 | 88 | \ No newline at end of file | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.dal.dataobject.stock; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 4 | +import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; | |
| 5 | +import com.baomidou.mybatisplus.annotation.KeySequence; | |
| 6 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 7 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 8 | +import lombok.*; | |
| 9 | + | |
| 10 | +import java.math.BigDecimal; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * ERP 产品库存 DO | |
| 14 | + * | |
| 15 | + * @author 芋道源码 | |
| 16 | + */ | |
| 17 | +@TableName("erp_stock") | |
| 18 | +@KeySequence("erp_stock_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | |
| 19 | +@Data | |
| 20 | +@EqualsAndHashCode(callSuper = true) | |
| 21 | +@ToString(callSuper = true) | |
| 22 | +@Builder | |
| 23 | +@NoArgsConstructor | |
| 24 | +@AllArgsConstructor | |
| 25 | +public class ErpStockDO extends BaseDO { | |
| 26 | + | |
| 27 | + /** | |
| 28 | + * 编号 | |
| 29 | + */ | |
| 30 | + @TableId | |
| 31 | + private Long id; | |
| 32 | + /** | |
| 33 | + * 产品编号 | |
| 34 | + * | |
| 35 | + * 关联 {@link ErpProductDO#getId()} | |
| 36 | + */ | |
| 37 | + private Long productId; | |
| 38 | + /** | |
| 39 | + * 仓库编号 | |
| 40 | + * | |
| 41 | + * 关联 {@link ErpWarehouseDO#getId()} | |
| 42 | + */ | |
| 43 | + private Long warehouseId; | |
| 44 | + /** | |
| 45 | + * 库存数量 | |
| 46 | + */ | |
| 47 | + private BigDecimal count; | |
| 48 | + | |
| 49 | +} | |
| 0 | 50 | \ No newline at end of file | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockRecordDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.dal.dataobject.stock; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 4 | +import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; | |
| 5 | +import com.baomidou.mybatisplus.annotation.KeySequence; | |
| 6 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 7 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 8 | +import lombok.*; | |
| 9 | + | |
| 10 | +import java.math.BigDecimal; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * ERP 产品库存明细 DO | |
| 14 | + * | |
| 15 | + * @author 芋道源码 | |
| 16 | + */ | |
| 17 | +@TableName("erp_stock_record") | |
| 18 | +@KeySequence("erp_stock_record_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | |
| 19 | +@Data | |
| 20 | +@EqualsAndHashCode(callSuper = true) | |
| 21 | +@ToString(callSuper = true) | |
| 22 | +@Builder | |
| 23 | +@NoArgsConstructor | |
| 24 | +@AllArgsConstructor | |
| 25 | +public class ErpStockRecordDO extends BaseDO { | |
| 26 | + | |
| 27 | + /** | |
| 28 | + * 编号 | |
| 29 | + */ | |
| 30 | + @TableId | |
| 31 | + private Long id; | |
| 32 | + /** | |
| 33 | + * 产品编号 | |
| 34 | + * | |
| 35 | + * 关联 {@link ErpProductDO#getId()} | |
| 36 | + */ | |
| 37 | + private Long productId; | |
| 38 | + /** | |
| 39 | + * 仓库编号 | |
| 40 | + * | |
| 41 | + * 关联 {@link ErpWarehouseDO#getId()} | |
| 42 | + */ | |
| 43 | + private Long warehouseId; | |
| 44 | + /** | |
| 45 | + * 出入库数量 | |
| 46 | + * | |
| 47 | + * 正数,表示入库;负数,表示出库 | |
| 48 | + */ | |
| 49 | + private BigDecimal count; | |
| 50 | + /** | |
| 51 | + * 总库存量 | |
| 52 | + * | |
| 53 | + * 出入库之后,目前的库存量 | |
| 54 | + */ | |
| 55 | + private BigDecimal totalCount; | |
| 56 | + /** | |
| 57 | + * 业务类型 | |
| 58 | + * | |
| 59 | + * 枚举 {@link cn.iocoder.yudao.module.erp.enums.stock.ErpStockRecordBizTypeEnum} | |
| 60 | + */ | |
| 61 | + private Integer bizType; | |
| 62 | + /** | |
| 63 | + * 业务编号 | |
| 64 | + * | |
| 65 | + * 例如说:TODO | |
| 66 | + */ | |
| 67 | + private Long bizId; | |
| 68 | + /** | |
| 69 | + * 业务项编号 | |
| 70 | + * | |
| 71 | + * 例如说:TODO | |
| 72 | + */ | |
| 73 | + private Long bizItemId; | |
| 74 | + /** | |
| 75 | + * 业务单号 | |
| 76 | + * | |
| 77 | + * 例如说:TODO | |
| 78 | + */ | |
| 79 | + private String bizNo; | |
| 80 | + | |
| 81 | +} | |
| 0 | 82 | \ No newline at end of file | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/product/ErpProductMapper.java
| ... | ... | @@ -3,10 +3,12 @@ package cn.iocoder.yudao.module.erp.dal.mysql.product; |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 4 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 5 | 5 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 6 | -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ProductPageReqVO; | |
| 6 | +import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductPageReqVO; | |
| 7 | 7 | import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; |
| 8 | 8 | import org.apache.ibatis.annotations.Mapper; |
| 9 | 9 | |
| 10 | +import java.util.List; | |
| 11 | + | |
| 10 | 12 | /** |
| 11 | 13 | * ERP 产品 Mapper |
| 12 | 14 | * |
| ... | ... | @@ -15,7 +17,7 @@ import org.apache.ibatis.annotations.Mapper; |
| 15 | 17 | @Mapper |
| 16 | 18 | public interface ErpProductMapper extends BaseMapperX<ErpProductDO> { |
| 17 | 19 | |
| 18 | - default PageResult<ErpProductDO> selectPage(ProductPageReqVO reqVO) { | |
| 20 | + default PageResult<ErpProductDO> selectPage(ErpProductPageReqVO reqVO) { | |
| 19 | 21 | return selectPage(reqVO, new LambdaQueryWrapperX<ErpProductDO>() |
| 20 | 22 | .likeIfPresent(ErpProductDO::getName, reqVO.getName()) |
| 21 | 23 | .eqIfPresent(ErpProductDO::getCategoryId, reqVO.getCategoryId()) |
| ... | ... | @@ -31,4 +33,8 @@ public interface ErpProductMapper extends BaseMapperX<ErpProductDO> { |
| 31 | 33 | return selectCount(ErpProductDO::getUnitId, unitId); |
| 32 | 34 | } |
| 33 | 35 | |
| 36 | + default List<ErpProductDO> selectListByStatus(Integer status) { | |
| 37 | + return selectList(ErpProductDO::getStatus, status); | |
| 38 | + } | |
| 39 | + | |
| 34 | 40 | } |
| 35 | 41 | \ No newline at end of file | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.dal.mysql.stock; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | |
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 6 | +import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.stock.ErpStockPageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO; | |
| 8 | +import org.apache.ibatis.annotations.Mapper; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * ERP 产品库存 Mapper | |
| 12 | + * | |
| 13 | + * @author 芋道源码 | |
| 14 | + */ | |
| 15 | +@Mapper | |
| 16 | +public interface ErpStockMapper extends BaseMapperX<ErpStockDO> { | |
| 17 | + | |
| 18 | + default PageResult<ErpStockDO> selectPage(ErpStockPageReqVO reqVO) { | |
| 19 | + return selectPage(reqVO, new LambdaQueryWrapperX<ErpStockDO>() | |
| 20 | + .eqIfPresent(ErpStockDO::getProductId, reqVO.getProductId()) | |
| 21 | + .eqIfPresent(ErpStockDO::getWarehouseId, reqVO.getWarehouseId()) | |
| 22 | + .orderByDesc(ErpStockDO::getId)); | |
| 23 | + } | |
| 24 | + | |
| 25 | +} | |
| 0 | 26 | \ No newline at end of file | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockRecordMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.dal.mysql.stock; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | |
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 6 | +import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.stockrecord.ErpStockRecordPageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockRecordDO; | |
| 8 | +import org.apache.ibatis.annotations.Mapper; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * ERP 产品库存明细 Mapper | |
| 12 | + * | |
| 13 | + * @author 芋道源码 | |
| 14 | + */ | |
| 15 | +@Mapper | |
| 16 | +public interface ErpStockRecordMapper extends BaseMapperX<ErpStockRecordDO> { | |
| 17 | + | |
| 18 | + default PageResult<ErpStockRecordDO> selectPage(ErpStockRecordPageReqVO reqVO) { | |
| 19 | + return selectPage(reqVO, new LambdaQueryWrapperX<ErpStockRecordDO>() | |
| 20 | + .eqIfPresent(ErpStockRecordDO::getProductId, reqVO.getProductId()) | |
| 21 | + .eqIfPresent(ErpStockRecordDO::getWarehouseId, reqVO.getWarehouseId()) | |
| 22 | + .eqIfPresent(ErpStockRecordDO::getBizType, reqVO.getBizType()) | |
| 23 | + .likeIfPresent(ErpStockRecordDO::getBizNo, reqVO.getBizNo()) | |
| 24 | + .betweenIfPresent(ErpStockRecordDO::getCreateTime, reqVO.getCreateTime()) | |
| 25 | + .orderByDesc(ErpStockRecordDO::getId)); | |
| 26 | + } | |
| 27 | + | |
| 28 | +} | |
| 0 | 29 | \ No newline at end of file | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpWarehouseMapper.java
| ... | ... | @@ -7,6 +7,8 @@ import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse.ErpWareho |
| 7 | 7 | import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpWarehouseDO; |
| 8 | 8 | import org.apache.ibatis.annotations.Mapper; |
| 9 | 9 | |
| 10 | +import java.util.List; | |
| 11 | + | |
| 10 | 12 | /** |
| 11 | 13 | * ERP 仓库 Mapper |
| 12 | 14 | * |
| ... | ... | @@ -26,4 +28,8 @@ public interface ErpWarehouseMapper extends BaseMapperX<ErpWarehouseDO> { |
| 26 | 28 | return selectOne(ErpWarehouseDO::getDefaultStatus, true); |
| 27 | 29 | } |
| 28 | 30 | |
| 31 | + default List<ErpWarehouseDO> selectListByStatus(Integer status) { | |
| 32 | + return selectList(ErpWarehouseDO::getStatus, status); | |
| 33 | + } | |
| 34 | + | |
| 29 | 35 | } |
| 30 | 36 | \ No newline at end of file | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductCategoryServiceImpl.java
| ... | ... | @@ -15,7 +15,7 @@ import java.util.List; |
| 15 | 15 | import java.util.Objects; |
| 16 | 16 | |
| 17 | 17 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 18 | -import static cn.iocoder.yudao.module.erp.ErrorCodeConstants.*; | |
| 18 | +import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; | |
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | 21 | * ERP 产品分类 Service 实现类 | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductService.java
| 1 | 1 | package cn.iocoder.yudao.module.erp.service.product; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ProductPageReqVO; | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductPageReqVO; | |
| 5 | +import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; | |
| 4 | 6 | import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ProductSaveReqVO; |
| 5 | -import jakarta.validation.*; | |
| 6 | 7 | import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; |
| 7 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 8 | +import jakarta.validation.Valid; | |
| 9 | + | |
| 10 | +import java.util.Collection; | |
| 11 | +import java.util.List; | |
| 12 | +import java.util.Map; | |
| 13 | + | |
| 14 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; | |
| 8 | 15 | |
| 9 | 16 | /** |
| 10 | 17 | * ERP 产品 Service 接口 |
| ... | ... | @@ -44,12 +51,38 @@ public interface ErpProductService { |
| 44 | 51 | ErpProductDO getProduct(Long id); |
| 45 | 52 | |
| 46 | 53 | /** |
| 47 | - * 获得产品分页 | |
| 54 | + * 获得指定状态的产品列表 | |
| 55 | + * | |
| 56 | + * @param status 状态 | |
| 57 | + * @return 产品列表 | |
| 58 | + */ | |
| 59 | + List<ErpProductDO> getProductListByStatus(Integer status); | |
| 60 | + | |
| 61 | + /** | |
| 62 | + * 获得产品 VO 列表 | |
| 63 | + * | |
| 64 | + * @param ids 编号数组 | |
| 65 | + * @return 产品 VO 列表 | |
| 66 | + */ | |
| 67 | + List<ErpProductRespVO> getProductVOList(Collection<Long> ids); | |
| 68 | + | |
| 69 | + /** | |
| 70 | + * 获得产品 VO Map | |
| 71 | + * | |
| 72 | + * @param ids 编号数组 | |
| 73 | + * @return 产品 VO Map | |
| 74 | + */ | |
| 75 | + default Map<Long, ErpProductRespVO> getProductVOMap(Collection<Long> ids) { | |
| 76 | + return convertMap(getProductVOList(ids), ErpProductRespVO::getId); | |
| 77 | + } | |
| 78 | + | |
| 79 | + /** | |
| 80 | + * 获得产品 VO 分页 | |
| 48 | 81 | * |
| 49 | 82 | * @param pageReqVO 分页查询 |
| 50 | 83 | * @return 产品分页 |
| 51 | 84 | */ |
| 52 | - PageResult<ErpProductDO> getProductPage(ProductPageReqVO pageReqVO); | |
| 85 | + PageResult<ErpProductRespVO> getProductVOPage(ErpProductPageReqVO pageReqVO); | |
| 53 | 86 | |
| 54 | 87 | /** |
| 55 | 88 | * 基于产品分类编号,获得产品数量 | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.erp.service.product; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ProductPageReqVO; | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 5 | +import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | |
| 6 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 7 | +import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductPageReqVO; | |
| 8 | +import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; | |
| 4 | 9 | import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ProductSaveReqVO; |
| 5 | -import org.springframework.stereotype.Service; | |
| 10 | +import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductCategoryDO; | |
| 11 | +import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; | |
| 12 | +import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductUnitDO; | |
| 13 | +import cn.iocoder.yudao.module.erp.dal.mysql.product.ErpProductMapper; | |
| 6 | 14 | import jakarta.annotation.Resource; |
| 15 | +import org.springframework.stereotype.Service; | |
| 7 | 16 | import org.springframework.validation.annotation.Validated; |
| 8 | 17 | |
| 9 | -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; | |
| 10 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 11 | -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 12 | - | |
| 13 | -import cn.iocoder.yudao.module.erp.dal.mysql.product.ErpProductMapper; | |
| 18 | +import java.util.Collection; | |
| 19 | +import java.util.Collections; | |
| 20 | +import java.util.List; | |
| 21 | +import java.util.Map; | |
| 14 | 22 | |
| 15 | 23 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 16 | -import static cn.iocoder.yudao.module.erp.ErrorCodeConstants.PRODUCT_NOT_EXISTS; | |
| 24 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | |
| 25 | +import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.PRODUCT_NOT_EXISTS; | |
| 17 | 26 | |
| 18 | 27 | /** |
| 19 | 28 | * ERP 产品 Service 实现类 |
| ... | ... | @@ -27,6 +36,11 @@ public class ErpProductServiceImpl implements ErpProductService { |
| 27 | 36 | @Resource |
| 28 | 37 | private ErpProductMapper productMapper; |
| 29 | 38 | |
| 39 | + @Resource | |
| 40 | + private ErpProductCategoryService productCategoryService; | |
| 41 | + @Resource | |
| 42 | + private ErpProductUnitService productUnitService; | |
| 43 | + | |
| 30 | 44 | @Override |
| 31 | 45 | public Long createProduct(ProductSaveReqVO createReqVO) { |
| 32 | 46 | // 插入 |
| ... | ... | @@ -65,8 +79,36 @@ public class ErpProductServiceImpl implements ErpProductService { |
| 65 | 79 | } |
| 66 | 80 | |
| 67 | 81 | @Override |
| 68 | - public PageResult<ErpProductDO> getProductPage(ProductPageReqVO pageReqVO) { | |
| 69 | - return productMapper.selectPage(pageReqVO); | |
| 82 | + public List<ErpProductDO> getProductListByStatus(Integer status) { | |
| 83 | + return productMapper.selectListByStatus(status); | |
| 84 | + } | |
| 85 | + | |
| 86 | + @Override | |
| 87 | + public List<ErpProductRespVO> getProductVOList(Collection<Long> ids) { | |
| 88 | + List<ErpProductDO> list = productMapper.selectBatchIds(ids); | |
| 89 | + return buildProductVOList(list); | |
| 90 | + } | |
| 91 | + | |
| 92 | + @Override | |
| 93 | + public PageResult<ErpProductRespVO> getProductVOPage(ErpProductPageReqVO pageReqVO) { | |
| 94 | + PageResult<ErpProductDO> pageResult = productMapper.selectPage(pageReqVO); | |
| 95 | + return new PageResult<>(buildProductVOList(pageResult.getList()), pageResult.getTotal()); | |
| 96 | + } | |
| 97 | + | |
| 98 | + private List<ErpProductRespVO> buildProductVOList(List<ErpProductDO> list) { | |
| 99 | + if (CollUtil.isEmpty(list)) { | |
| 100 | + return Collections.emptyList(); | |
| 101 | + } | |
| 102 | + Map<Long, ErpProductCategoryDO> categoryMap = productCategoryService.getProductCategoryMap( | |
| 103 | + convertSet(list, ErpProductDO::getCategoryId)); | |
| 104 | + Map<Long, ErpProductUnitDO> unitMap = productUnitService.getProductUnitMap( | |
| 105 | + convertSet(list, ErpProductDO::getUnitId)); | |
| 106 | + return BeanUtils.toBean(list, ErpProductRespVO.class, product -> { | |
| 107 | + MapUtils.findAndThen(categoryMap, product.getCategoryId(), | |
| 108 | + category -> product.setCategoryName(category.getName())); | |
| 109 | + MapUtils.findAndThen(unitMap, product.getUnitId(), | |
| 110 | + unit -> product.setUnitName(unit.getName())); | |
| 111 | + }); | |
| 70 | 112 | } |
| 71 | 113 | |
| 72 | 114 | @Override | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductUnitServiceImpl.java
| ... | ... | @@ -16,7 +16,7 @@ import java.util.Collection; |
| 16 | 16 | import java.util.List; |
| 17 | 17 | |
| 18 | 18 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 19 | -import static cn.iocoder.yudao.module.erp.ErrorCodeConstants.*; | |
| 19 | +import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; | |
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * ERP 产品单位 Service 实现类 | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockRecordService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.service.stock; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.stockrecord.ErpStockRecordPageReqVO; | |
| 5 | +import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockRecordDO; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * ERP 产品库存明细 Service 接口 | |
| 9 | + * | |
| 10 | + * @author 芋道源码 | |
| 11 | + */ | |
| 12 | +public interface ErpStockRecordService { | |
| 13 | + | |
| 14 | + /** | |
| 15 | + * 获得产品库存明细 | |
| 16 | + * | |
| 17 | + * @param id 编号 | |
| 18 | + * @return 产品库存明细 | |
| 19 | + */ | |
| 20 | + ErpStockRecordDO getStockRecord(Long id); | |
| 21 | + | |
| 22 | + /** | |
| 23 | + * 获得产品库存明细分页 | |
| 24 | + * | |
| 25 | + * @param pageReqVO 分页查询 | |
| 26 | + * @return 产品库存明细分页 | |
| 27 | + */ | |
| 28 | + PageResult<ErpStockRecordDO> getStockRecordPage(ErpStockRecordPageReqVO pageReqVO); | |
| 29 | + | |
| 30 | +} | |
| 0 | 31 | \ No newline at end of file | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockRecordServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.service.stock; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.stockrecord.ErpStockRecordPageReqVO; | |
| 5 | +import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockRecordDO; | |
| 6 | +import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpStockRecordMapper; | |
| 7 | +import jakarta.annotation.Resource; | |
| 8 | +import org.springframework.stereotype.Service; | |
| 9 | +import org.springframework.validation.annotation.Validated; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * ERP 产品库存明细 Service 实现类 | |
| 13 | + * | |
| 14 | + * @author 芋道源码 | |
| 15 | + */ | |
| 16 | +@Service | |
| 17 | +@Validated | |
| 18 | +public class ErpStockRecordServiceImpl implements ErpStockRecordService { | |
| 19 | + | |
| 20 | + @Resource | |
| 21 | + private ErpStockRecordMapper stockRecordMapper; | |
| 22 | + | |
| 23 | + @Override | |
| 24 | + public ErpStockRecordDO getStockRecord(Long id) { | |
| 25 | + return stockRecordMapper.selectById(id); | |
| 26 | + } | |
| 27 | + | |
| 28 | + @Override | |
| 29 | + public PageResult<ErpStockRecordDO> getStockRecordPage(ErpStockRecordPageReqVO pageReqVO) { | |
| 30 | + return stockRecordMapper.selectPage(pageReqVO); | |
| 31 | + } | |
| 32 | + | |
| 33 | +} | |
| 0 | 34 | \ No newline at end of file | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.service.stock; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.stock.ErpStockPageReqVO; | |
| 5 | +import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * ERP 产品库存 Service 接口 | |
| 9 | + * | |
| 10 | + * @author 芋道源码 | |
| 11 | + */ | |
| 12 | +public interface ErpStockService { | |
| 13 | + | |
| 14 | + /** | |
| 15 | + * 获得产品库存 | |
| 16 | + * | |
| 17 | + * @param id 编号 | |
| 18 | + * @return 库存 | |
| 19 | + */ | |
| 20 | + ErpStockDO getStock(Long id); | |
| 21 | + | |
| 22 | + /** | |
| 23 | + * 获得产品库存分页 | |
| 24 | + * | |
| 25 | + * @param pageReqVO 分页查询 | |
| 26 | + * @return 库存分页 | |
| 27 | + */ | |
| 28 | + PageResult<ErpStockDO> getStockPage(ErpStockPageReqVO pageReqVO); | |
| 29 | + | |
| 30 | +} | |
| 0 | 31 | \ No newline at end of file | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.service.stock; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.stock.ErpStockPageReqVO; | |
| 5 | +import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO; | |
| 6 | +import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpStockMapper; | |
| 7 | +import jakarta.annotation.Resource; | |
| 8 | +import org.springframework.stereotype.Service; | |
| 9 | +import org.springframework.validation.annotation.Validated; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * ERP 产品库存 Service 实现类 | |
| 13 | + * | |
| 14 | + * @author 芋道源码 | |
| 15 | + */ | |
| 16 | +@Service | |
| 17 | +@Validated | |
| 18 | +public class ErpStockServiceImpl implements ErpStockService { | |
| 19 | + | |
| 20 | + @Resource | |
| 21 | + private ErpStockMapper stockMapper; | |
| 22 | + | |
| 23 | + @Override | |
| 24 | + public ErpStockDO getStock(Long id) { | |
| 25 | + return stockMapper.selectById(id); | |
| 26 | + } | |
| 27 | + | |
| 28 | + @Override | |
| 29 | + public PageResult<ErpStockDO> getStockPage(ErpStockPageReqVO pageReqVO) { | |
| 30 | + return stockMapper.selectPage(pageReqVO); | |
| 31 | + } | |
| 32 | + | |
| 33 | +} | |
| 0 | 34 | \ No newline at end of file | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpWarehouseService.java
| ... | ... | @@ -6,6 +6,12 @@ import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse.ErpWareho |
| 6 | 6 | import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpWarehouseDO; |
| 7 | 7 | import jakarta.validation.Valid; |
| 8 | 8 | |
| 9 | +import java.util.Collection; | |
| 10 | +import java.util.List; | |
| 11 | +import java.util.Map; | |
| 12 | + | |
| 13 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; | |
| 14 | + | |
| 9 | 15 | /** |
| 10 | 16 | * ERP 仓库 Service 接口 |
| 11 | 17 | * |
| ... | ... | @@ -52,6 +58,32 @@ public interface ErpWarehouseService { |
| 52 | 58 | ErpWarehouseDO getWarehouse(Long id); |
| 53 | 59 | |
| 54 | 60 | /** |
| 61 | + * 获得指定状态的仓库列表 | |
| 62 | + * | |
| 63 | + * @param status 状态 | |
| 64 | + * @return 仓库列表 | |
| 65 | + */ | |
| 66 | + List<ErpWarehouseDO> getWarehouseListByStatus(Integer status); | |
| 67 | + | |
| 68 | + /** | |
| 69 | + * 获得仓库列表 | |
| 70 | + * | |
| 71 | + * @param ids 编号数组 | |
| 72 | + * @return 仓库列表 | |
| 73 | + */ | |
| 74 | + List<ErpWarehouseDO> getWarehouseList(Collection<Long> ids); | |
| 75 | + | |
| 76 | + /** | |
| 77 | + * 获得仓库 Map | |
| 78 | + * | |
| 79 | + * @param ids 编号数组 | |
| 80 | + * @return 仓库 Map | |
| 81 | + */ | |
| 82 | + default Map<Long, ErpWarehouseDO> getWarehouseMap(Collection<Long> ids) { | |
| 83 | + return convertMap(getWarehouseList(ids), ErpWarehouseDO::getId); | |
| 84 | + } | |
| 85 | + | |
| 86 | + /** | |
| 55 | 87 | * 获得仓库分页 |
| 56 | 88 | * |
| 57 | 89 | * @param pageReqVO 分页查询 | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpWarehouseServiceImpl.java
| ... | ... | @@ -11,8 +11,11 @@ import org.springframework.stereotype.Service; |
| 11 | 11 | import org.springframework.transaction.annotation.Transactional; |
| 12 | 12 | import org.springframework.validation.annotation.Validated; |
| 13 | 13 | |
| 14 | +import java.util.Collection; | |
| 15 | +import java.util.List; | |
| 16 | + | |
| 14 | 17 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 15 | -import static cn.iocoder.yudao.module.erp.ErrorCodeConstants.WAREHOUSE_NOT_EXISTS; | |
| 18 | +import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.WAREHOUSE_NOT_EXISTS; | |
| 16 | 19 | |
| 17 | 20 | /** |
| 18 | 21 | * ERP 仓库 Service 实现类 |
| ... | ... | @@ -81,6 +84,16 @@ public class ErpWarehouseServiceImpl implements ErpWarehouseService { |
| 81 | 84 | } |
| 82 | 85 | |
| 83 | 86 | @Override |
| 87 | + public List<ErpWarehouseDO> getWarehouseListByStatus(Integer status) { | |
| 88 | + return warehouseMapper.selectListByStatus(status); | |
| 89 | + } | |
| 90 | + | |
| 91 | + @Override | |
| 92 | + public List<ErpWarehouseDO> getWarehouseList(Collection<Long> ids) { | |
| 93 | + return warehouseMapper.selectBatchIds(ids); | |
| 94 | + } | |
| 95 | + | |
| 96 | + @Override | |
| 84 | 97 | public PageResult<ErpWarehouseDO> getWarehousePage(ErpWarehousePageReqVO pageReqVO) { |
| 85 | 98 | return warehouseMapper.selectPage(pageReqVO); |
| 86 | 99 | } | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/test/java/cn/iocoder/yudao/module/erp/service/product/ProductServiceImplTest.java
| 1 | 1 | package cn.iocoder.yudao.module.erp.service.product; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ProductPageReqVO; | |
| 3 | +import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductPageReqVO; | |
| 4 | 4 | import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ProductSaveReqVO; |
| 5 | 5 | import org.junit.jupiter.api.Disabled; |
| 6 | 6 | import org.junit.jupiter.api.Test; |
| ... | ... | @@ -115,13 +115,13 @@ public class ProductServiceImplTest extends BaseDbUnitTest { |
| 115 | 115 | // 测试 createTime 不匹配 |
| 116 | 116 | productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setCreateTime(null))); |
| 117 | 117 | // 准备参数 |
| 118 | - ProductPageReqVO reqVO = new ProductPageReqVO(); | |
| 118 | + ErpProductPageReqVO reqVO = new ErpProductPageReqVO(); | |
| 119 | 119 | reqVO.setName(null); |
| 120 | 120 | reqVO.setCategoryId(null); |
| 121 | 121 | reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
| 122 | 122 | |
| 123 | 123 | // 调用 |
| 124 | - PageResult<ErpProductDO> pageResult = productService.getProductPage(reqVO); | |
| 124 | + PageResult<ErpProductDO> pageResult = productService.getProductVOPage(reqVO); | |
| 125 | 125 | // 断言 |
| 126 | 126 | assertEquals(1, pageResult.getTotal()); |
| 127 | 127 | assertEquals(1, pageResult.getList().size()); | ... | ... |