Commit bfe3dc95fe7c6b428c91012782adff5ae43a38c4
1 parent
46d26659
✨ ERP:增加供应商的实现
Showing
17 changed files
with
650 additions
and
11 deletions
yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/ErrorCodeConstants.java
| @@ -9,12 +9,16 @@ import cn.iocoder.yudao.framework.common.exception.ErrorCode; | @@ -9,12 +9,16 @@ import cn.iocoder.yudao.framework.common.exception.ErrorCode; | ||
| 9 | */ | 9 | */ |
| 10 | public interface ErrorCodeConstants { | 10 | public interface ErrorCodeConstants { |
| 11 | 11 | ||
| 12 | - // ========== 销售订单(1-020-000-000) ========== | ||
| 13 | - ErrorCode SALE_ORDER_NOT_EXISTS = new ErrorCode(1_020_000_000, "销售订单不存在"); | 12 | + // ========== ERP 供应商(1-030-100-000) ========== |
| 13 | + ErrorCode SUPPLIER_NOT_EXISTS = new ErrorCode(1_030_100_000, "供应商不存在"); | ||
| 14 | + ErrorCode SUPPLIER_NOT_ENABLE = new ErrorCode(1_030_100_000, "供应商({})未启用"); | ||
| 15 | + | ||
| 16 | + // ========== 销售订单(1-030-200-000) ========== | ||
| 17 | + ErrorCode SALE_ORDER_NOT_EXISTS = new ErrorCode(1_020_200_000, "销售订单不存在"); | ||
| 14 | 18 | ||
| 15 | // ========== ERP 仓库 1-030-400-000 ========== | 19 | // ========== ERP 仓库 1-030-400-000 ========== |
| 16 | ErrorCode WAREHOUSE_NOT_EXISTS = new ErrorCode(1_030_400_000, "仓库不存在"); | 20 | ErrorCode WAREHOUSE_NOT_EXISTS = new ErrorCode(1_030_400_000, "仓库不存在"); |
| 17 | - ErrorCode WAREHOUSE_NOT_ENABLE = new ErrorCode(1_030_500_001, "仓库({})未启用"); | 21 | + ErrorCode WAREHOUSE_NOT_ENABLE = new ErrorCode(1_030_400_001, "仓库({})未启用"); |
| 18 | 22 | ||
| 19 | // ========== ERP 其它入库单 1-030-401-000 ========== | 23 | // ========== ERP 其它入库单 1-030-401-000 ========== |
| 20 | ErrorCode STOCK_IN_NOT_EXISTS = new ErrorCode(1_030_401_000, "其它入库单不存在"); | 24 | ErrorCode STOCK_IN_NOT_EXISTS = new ErrorCode(1_030_401_000, "其它入库单不存在"); |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/ErpSupplierController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.controller.admin.purchase; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 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.object.BeanUtils; | ||
| 8 | +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | ||
| 9 | +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | ||
| 10 | +import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierPageReqVO; | ||
| 11 | +import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierRespVO; | ||
| 12 | +import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierSaveReqVO; | ||
| 13 | +import cn.iocoder.yudao.module.erp.dal.dataobject.supplier.ErpSupplierDO; | ||
| 14 | +import cn.iocoder.yudao.module.erp.service.purchase.ErpSupplierService; | ||
| 15 | +import io.swagger.v3.oas.annotations.Operation; | ||
| 16 | +import io.swagger.v3.oas.annotations.Parameter; | ||
| 17 | +import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 18 | +import jakarta.annotation.Resource; | ||
| 19 | +import jakarta.servlet.http.HttpServletResponse; | ||
| 20 | +import jakarta.validation.Valid; | ||
| 21 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 22 | +import org.springframework.validation.annotation.Validated; | ||
| 23 | +import org.springframework.web.bind.annotation.*; | ||
| 24 | + | ||
| 25 | +import java.io.IOException; | ||
| 26 | +import java.util.List; | ||
| 27 | + | ||
| 28 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 29 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; | ||
| 30 | +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; | ||
| 31 | + | ||
| 32 | +@Tag(name = "管理后台 - ERP 供应商") | ||
| 33 | +@RestController | ||
| 34 | +@RequestMapping("/erp/supplier") | ||
| 35 | +@Validated | ||
| 36 | +public class ErpSupplierController { | ||
| 37 | + | ||
| 38 | + @Resource | ||
| 39 | + private ErpSupplierService supplierService; | ||
| 40 | + | ||
| 41 | + @PostMapping("/create") | ||
| 42 | + @Operation(summary = "创建供应商") | ||
| 43 | + @PreAuthorize("@ss.hasPermission('erp:supplier:create')") | ||
| 44 | + public CommonResult<Long> createSupplier(@Valid @RequestBody ErpSupplierSaveReqVO createReqVO) { | ||
| 45 | + return success(supplierService.createSupplier(createReqVO)); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + @PutMapping("/update") | ||
| 49 | + @Operation(summary = "更新供应商") | ||
| 50 | + @PreAuthorize("@ss.hasPermission('erp:supplier:update')") | ||
| 51 | + public CommonResult<Boolean> updateSupplier(@Valid @RequestBody ErpSupplierSaveReqVO updateReqVO) { | ||
| 52 | + supplierService.updateSupplier(updateReqVO); | ||
| 53 | + return success(true); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + @DeleteMapping("/delete") | ||
| 57 | + @Operation(summary = "删除供应商") | ||
| 58 | + @Parameter(name = "id", description = "编号", required = true) | ||
| 59 | + @PreAuthorize("@ss.hasPermission('erp:supplier:delete')") | ||
| 60 | + public CommonResult<Boolean> deleteSupplier(@RequestParam("id") Long id) { | ||
| 61 | + supplierService.deleteSupplier(id); | ||
| 62 | + return success(true); | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + @GetMapping("/get") | ||
| 66 | + @Operation(summary = "获得供应商") | ||
| 67 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | ||
| 68 | + @PreAuthorize("@ss.hasPermission('erp:supplier:query')") | ||
| 69 | + public CommonResult<ErpSupplierRespVO> getSupplier(@RequestParam("id") Long id) { | ||
| 70 | + ErpSupplierDO supplier = supplierService.getSupplier(id); | ||
| 71 | + return success(BeanUtils.toBean(supplier, ErpSupplierRespVO.class)); | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + @GetMapping("/page") | ||
| 75 | + @Operation(summary = "获得供应商分页") | ||
| 76 | + @PreAuthorize("@ss.hasPermission('erp:supplier:query')") | ||
| 77 | + public CommonResult<PageResult<ErpSupplierRespVO>> getSupplierPage(@Valid ErpSupplierPageReqVO pageReqVO) { | ||
| 78 | + PageResult<ErpSupplierDO> pageResult = supplierService.getSupplierPage(pageReqVO); | ||
| 79 | + return success(BeanUtils.toBean(pageResult, ErpSupplierRespVO.class)); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + @GetMapping("/simple-list") | ||
| 83 | + @Operation(summary = "获得供应商精简列表", description = "只包含被开启的供应商,主要用于前端的下拉选项") | ||
| 84 | + public CommonResult<List<ErpSupplierRespVO>> getSupplierSimpleList() { | ||
| 85 | + List<ErpSupplierDO> list = supplierService.getSupplierListByStatus(CommonStatusEnum.ENABLE.getStatus()); | ||
| 86 | + return success(convertList(list, supplier -> new ErpSupplierRespVO().setId(supplier.getId()).setName(supplier.getName()))); | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + @GetMapping("/export-excel") | ||
| 90 | + @Operation(summary = "导出供应商 Excel") | ||
| 91 | + @PreAuthorize("@ss.hasPermission('erp:supplier:export')") | ||
| 92 | + @OperateLog(type = EXPORT) | ||
| 93 | + public void exportSupplierExcel(@Valid ErpSupplierPageReqVO pageReqVO, | ||
| 94 | + HttpServletResponse response) throws IOException { | ||
| 95 | + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | ||
| 96 | + List<ErpSupplierDO> list = supplierService.getSupplierPage(pageReqVO).getList(); | ||
| 97 | + // 导出 Excel | ||
| 98 | + ExcelUtils.write(response, "供应商.xls", "数据", ErpSupplierRespVO.class, | ||
| 99 | + BeanUtils.toBean(list, ErpSupplierRespVO.class)); | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | +} | ||
| 0 | \ No newline at end of file | 103 | \ No newline at end of file |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/supplier/ErpSupplierPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier; | ||
| 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 ErpSupplierPageReqVO extends PageParam { | ||
| 14 | + | ||
| 15 | + @Schema(description = "供应商名称", example = "芋道源码") | ||
| 16 | + private String name; | ||
| 17 | + | ||
| 18 | + @Schema(description = "手机号码", example = "15601691300") | ||
| 19 | + private String mobile; | ||
| 20 | + | ||
| 21 | + @Schema(description = "联系电话", example = "18818288888") | ||
| 22 | + private String telephone; | ||
| 23 | + | ||
| 24 | +} | ||
| 0 | \ No newline at end of file | 25 | \ No newline at end of file |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/supplier/ErpSupplierRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier; | ||
| 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.system.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 ErpSupplierRespVO { | ||
| 18 | + | ||
| 19 | + @Schema(description = "供应商编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17791") | ||
| 20 | + @ExcelProperty("供应商编号") | ||
| 21 | + private Long id; | ||
| 22 | + | ||
| 23 | + @Schema(description = "供应商名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") | ||
| 24 | + @ExcelProperty("供应商名称") | ||
| 25 | + private String name; | ||
| 26 | + | ||
| 27 | + @Schema(description = "联系人", example = "芋艿") | ||
| 28 | + @ExcelProperty("联系人") | ||
| 29 | + private String contact; | ||
| 30 | + | ||
| 31 | + @Schema(description = "手机号码", example = "15601691300") | ||
| 32 | + @ExcelProperty("手机号码") | ||
| 33 | + private String mobile; | ||
| 34 | + | ||
| 35 | + @Schema(description = "联系电话", example = "18818288888") | ||
| 36 | + @ExcelProperty("联系电话") | ||
| 37 | + private String telephone; | ||
| 38 | + | ||
| 39 | + @Schema(description = "电子邮箱", example = "76853@qq.com") | ||
| 40 | + @ExcelProperty("电子邮箱") | ||
| 41 | + private String email; | ||
| 42 | + | ||
| 43 | + @Schema(description = "传真", example = "20 7123 4567") | ||
| 44 | + @ExcelProperty("传真") | ||
| 45 | + private String fax; | ||
| 46 | + | ||
| 47 | + @Schema(description = "备注", example = "你猜") | ||
| 48 | + @ExcelProperty("备注") | ||
| 49 | + private String remark; | ||
| 50 | + | ||
| 51 | + @Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 52 | + @ExcelProperty(value = "开启状态", converter = DictConvert.class) | ||
| 53 | + @DictFormat(DictTypeConstants.COMMON_STATUS) | ||
| 54 | + private Integer status; | ||
| 55 | + | ||
| 56 | + @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") | ||
| 57 | + @ExcelProperty("排序") | ||
| 58 | + private Integer sort; | ||
| 59 | + | ||
| 60 | + @Schema(description = "纳税人识别号", example = "91130803MA098BY05W") | ||
| 61 | + @ExcelProperty("纳税人识别号") | ||
| 62 | + private String taxNo; | ||
| 63 | + | ||
| 64 | + @Schema(description = "税率", example = "10") | ||
| 65 | + @ExcelProperty("税率") | ||
| 66 | + private BigDecimal taxPercent; | ||
| 67 | + | ||
| 68 | + @Schema(description = "开户行", example = "张三") | ||
| 69 | + @ExcelProperty("开户行") | ||
| 70 | + private String bankName; | ||
| 71 | + | ||
| 72 | + @Schema(description = "开户账号", example = "622908212277228617") | ||
| 73 | + @ExcelProperty("开户账号") | ||
| 74 | + private String bankAccount; | ||
| 75 | + | ||
| 76 | + @Schema(description = "开户地址", example = "兴业银行浦东支行") | ||
| 77 | + @ExcelProperty("开户地址") | ||
| 78 | + private String bankAddress; | ||
| 79 | + | ||
| 80 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 81 | + @ExcelProperty("创建时间") | ||
| 82 | + private LocalDateTime createTime; | ||
| 83 | + | ||
| 84 | +} | ||
| 0 | \ No newline at end of file | 85 | \ No newline at end of file |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/supplier/ErpSupplierSaveReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 4 | +import cn.iocoder.yudao.framework.common.validation.InEnum; | ||
| 5 | +import cn.iocoder.yudao.framework.common.validation.Mobile; | ||
| 6 | +import cn.iocoder.yudao.framework.common.validation.Telephone; | ||
| 7 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 8 | +import jakarta.validation.constraints.Email; | ||
| 9 | +import jakarta.validation.constraints.NotEmpty; | ||
| 10 | +import jakarta.validation.constraints.NotNull; | ||
| 11 | +import lombok.Data; | ||
| 12 | + | ||
| 13 | +import java.math.BigDecimal; | ||
| 14 | + | ||
| 15 | +@Schema(description = "管理后台 - ERP 供应商新增/修改 Request VO") | ||
| 16 | +@Data | ||
| 17 | +public class ErpSupplierSaveReqVO { | ||
| 18 | + | ||
| 19 | + @Schema(description = "供应商编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17791") | ||
| 20 | + private Long id; | ||
| 21 | + | ||
| 22 | + @Schema(description = "供应商名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") | ||
| 23 | + @NotEmpty(message = "供应商名称不能为空") | ||
| 24 | + private String name; | ||
| 25 | + | ||
| 26 | + @Schema(description = "联系人", example = "芋艿") | ||
| 27 | + private String contact; | ||
| 28 | + | ||
| 29 | + @Schema(description = "手机号码", example = "15601691300") | ||
| 30 | + @Mobile | ||
| 31 | + private String mobile; | ||
| 32 | + | ||
| 33 | + @Schema(description = "联系电话", example = "18818288888") | ||
| 34 | + @Telephone | ||
| 35 | + private String telephone; | ||
| 36 | + | ||
| 37 | + @Schema(description = "电子邮箱", example = "76853@qq.com") | ||
| 38 | |||
| 39 | + private String email; | ||
| 40 | + | ||
| 41 | + @Schema(description = "传真", example = "20 7123 4567") | ||
| 42 | + private String fax; | ||
| 43 | + | ||
| 44 | + @Schema(description = "备注", example = "你猜") | ||
| 45 | + private String remark; | ||
| 46 | + | ||
| 47 | + @Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 48 | + @NotNull(message = "开启状态不能为空") | ||
| 49 | + @InEnum(value = CommonStatusEnum.class) | ||
| 50 | + private Integer status; | ||
| 51 | + | ||
| 52 | + @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") | ||
| 53 | + @NotNull(message = "排序不能为空") | ||
| 54 | + private Integer sort; | ||
| 55 | + | ||
| 56 | + @Schema(description = "纳税人识别号", example = "91130803MA098BY05W") | ||
| 57 | + private String taxNo; | ||
| 58 | + | ||
| 59 | + @Schema(description = "税率", example = "10") | ||
| 60 | + private BigDecimal taxPercent; | ||
| 61 | + | ||
| 62 | + @Schema(description = "开户行", example = "张三") | ||
| 63 | + private String bankName; | ||
| 64 | + | ||
| 65 | + @Schema(description = "开户账号", example = "622908212277228617") | ||
| 66 | + private String bankAccount; | ||
| 67 | + | ||
| 68 | + @Schema(description = "开户地址", example = "兴业银行浦东支行") | ||
| 69 | + private String bankAddress; | ||
| 70 | + | ||
| 71 | +} | ||
| 0 | \ No newline at end of file | 72 | \ No newline at end of file |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockInController.java
| @@ -15,7 +15,9 @@ import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.in.ErpStockInSaveRe | @@ -15,7 +15,9 @@ import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.in.ErpStockInSaveRe | ||
| 15 | import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO; | 15 | import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO; |
| 16 | import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockInDO; | 16 | import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockInDO; |
| 17 | import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockInItemDO; | 17 | import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockInItemDO; |
| 18 | +import cn.iocoder.yudao.module.erp.dal.dataobject.supplier.ErpSupplierDO; | ||
| 18 | import cn.iocoder.yudao.module.erp.service.product.ErpProductService; | 19 | import cn.iocoder.yudao.module.erp.service.product.ErpProductService; |
| 20 | +import cn.iocoder.yudao.module.erp.service.purchase.ErpSupplierService; | ||
| 19 | import cn.iocoder.yudao.module.erp.service.stock.ErpStockInService; | 21 | import cn.iocoder.yudao.module.erp.service.stock.ErpStockInService; |
| 20 | import cn.iocoder.yudao.module.erp.service.stock.ErpStockService; | 22 | import cn.iocoder.yudao.module.erp.service.stock.ErpStockService; |
| 21 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | 23 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| @@ -52,6 +54,8 @@ public class ErpStockInController { | @@ -52,6 +54,8 @@ public class ErpStockInController { | ||
| 52 | private ErpStockService stockService; | 54 | private ErpStockService stockService; |
| 53 | @Resource | 55 | @Resource |
| 54 | private ErpProductService productService; | 56 | private ErpProductService productService; |
| 57 | + @Resource | ||
| 58 | + private ErpSupplierService supplierService; | ||
| 55 | 59 | ||
| 56 | @Resource | 60 | @Resource |
| 57 | private AdminUserApi adminUserApi; | 61 | private AdminUserApi adminUserApi; |
| @@ -90,7 +94,7 @@ public class ErpStockInController { | @@ -90,7 +94,7 @@ public class ErpStockInController { | ||
| 90 | return success(null); | 94 | return success(null); |
| 91 | } | 95 | } |
| 92 | List<ErpStockInItemDO> stockInItems = stockInService.getStockInItemListByInId(id); | 96 | List<ErpStockInItemDO> stockInItems = stockInService.getStockInItemListByInId(id); |
| 93 | - | 97 | + // TODO 芋艿:有个锤子; |
| 94 | return success(BeanUtils.toBean(stockIn, ErpStockInRespVO.class, stockInVO -> | 98 | return success(BeanUtils.toBean(stockIn, ErpStockInRespVO.class, stockInVO -> |
| 95 | stockInVO.setItems(BeanUtils.toBean(stockInItems, ErpStockInRespVO.Item.class, item -> { | 99 | stockInVO.setItems(BeanUtils.toBean(stockInItems, ErpStockInRespVO.Item.class, item -> { |
| 96 | ErpStockDO stock = stockService.getStock(item.getProductId(), item.getWarehouseId()); | 100 | ErpStockDO stock = stockService.getStock(item.getProductId(), item.getWarehouseId()); |
| @@ -129,7 +133,10 @@ public class ErpStockInController { | @@ -129,7 +133,10 @@ public class ErpStockInController { | ||
| 129 | // 1.2 商品信息 | 133 | // 1.2 商品信息 |
| 130 | Map<Long, ErpProductRespVO> productMap = productService.getProductVOMap( | 134 | Map<Long, ErpProductRespVO> productMap = productService.getProductVOMap( |
| 131 | convertSet(stockInItemList, ErpStockInItemDO::getProductId)); | 135 | convertSet(stockInItemList, ErpStockInItemDO::getProductId)); |
| 132 | - // 1.3 管理员信息 | 136 | + // 1.3 供应商信息 |
| 137 | + Map<Long, ErpSupplierDO> supplierMap = supplierService.getSupplierMap( | ||
| 138 | + convertSet(pageResult.getList(), ErpStockInDO::getSupplierId)); | ||
| 139 | + // 1.4 管理员信息 | ||
| 133 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( | 140 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( |
| 134 | convertSet(pageResult.getList(), erpStockRecordDO -> Long.parseLong(erpStockRecordDO.getCreator()))); | 141 | convertSet(pageResult.getList(), erpStockRecordDO -> Long.parseLong(erpStockRecordDO.getCreator()))); |
| 135 | // 2. 开始拼接 | 142 | // 2. 开始拼接 |
| @@ -138,6 +145,7 @@ public class ErpStockInController { | @@ -138,6 +145,7 @@ public class ErpStockInController { | ||
| 138 | item -> MapUtils.findAndThen(productMap, item.getProductId(), | 145 | item -> MapUtils.findAndThen(productMap, item.getProductId(), |
| 139 | product -> item.setProductName(product.getName()).setProductUnitName(product.getUnitName())))); | 146 | product -> item.setProductName(product.getName()).setProductUnitName(product.getUnitName())))); |
| 140 | stockIn.setProductNames(CollUtil.join(stockIn.getItems(), ",", ErpStockInRespVO.Item::getProductName)); | 147 | stockIn.setProductNames(CollUtil.join(stockIn.getItems(), ",", ErpStockInRespVO.Item::getProductName)); |
| 148 | + MapUtils.findAndThen(supplierMap, stockIn.getSupplierId(), supplier -> stockIn.setSupplierName(supplier.getName())); | ||
| 141 | MapUtils.findAndThen(userMap, Long.parseLong(stockIn.getCreator()), user -> stockIn.setCreatorName(user.getNickname())); | 149 | MapUtils.findAndThen(userMap, Long.parseLong(stockIn.getCreator()), user -> stockIn.setCreatorName(user.getNickname())); |
| 142 | }); | 150 | }); |
| 143 | } | 151 | } |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/in/ErpStockInPageReqVO.java
| @@ -39,4 +39,10 @@ public class ErpStockInPageReqVO extends PageParam { | @@ -39,4 +39,10 @@ public class ErpStockInPageReqVO extends PageParam { | ||
| 39 | @Schema(description = "创建者") | 39 | @Schema(description = "创建者") |
| 40 | private String creator; | 40 | private String creator; |
| 41 | 41 | ||
| 42 | + @Schema(description = "产品编号", example = "1") | ||
| 43 | + private Long productId; | ||
| 44 | + | ||
| 45 | + @Schema(description = "仓库编号", example = "1") | ||
| 46 | + private Long warehouseId; | ||
| 47 | + | ||
| 42 | } | 48 | } |
| 43 | \ No newline at end of file | 49 | \ 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/in/ErpStockInRespVO.java
| @@ -27,8 +27,10 @@ public class ErpStockInRespVO { | @@ -27,8 +27,10 @@ public class ErpStockInRespVO { | ||
| 27 | private String no; | 27 | private String no; |
| 28 | 28 | ||
| 29 | @Schema(description = "供应商编号", example = "3113") | 29 | @Schema(description = "供应商编号", example = "3113") |
| 30 | - @ExcelProperty("供应商编号") | ||
| 31 | private Long supplierId; | 30 | private Long supplierId; |
| 31 | + @Schema(description = "供应商名称", example = "芋道") | ||
| 32 | + @ExcelProperty("供应商名称") | ||
| 33 | + private String supplierName; | ||
| 32 | 34 | ||
| 33 | @Schema(description = "入库时间", requiredMode = Schema.RequiredMode.REQUIRED) | 35 | @Schema(description = "入库时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| 34 | @ExcelProperty("入库时间") | 36 | @ExcelProperty("入库时间") |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/supplier/ErpSupplierDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.dal.dataobject.supplier; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||
| 4 | +import com.baomidou.mybatisplus.annotation.KeySequence; | ||
| 5 | +import com.baomidou.mybatisplus.annotation.TableId; | ||
| 6 | +import com.baomidou.mybatisplus.annotation.TableName; | ||
| 7 | +import lombok.*; | ||
| 8 | + | ||
| 9 | +import java.math.BigDecimal; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * ERP 供应商 DO | ||
| 13 | + * | ||
| 14 | + * @author 芋道源码 | ||
| 15 | + */ | ||
| 16 | +@TableName("erp_supplier") | ||
| 17 | +@KeySequence("erp_supplier_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | ||
| 18 | +@Data | ||
| 19 | +@EqualsAndHashCode(callSuper = true) | ||
| 20 | +@ToString(callSuper = true) | ||
| 21 | +@Builder | ||
| 22 | +@NoArgsConstructor | ||
| 23 | +@AllArgsConstructor | ||
| 24 | +public class ErpSupplierDO extends BaseDO { | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * 供应商编号 | ||
| 28 | + */ | ||
| 29 | + @TableId | ||
| 30 | + private Long id; | ||
| 31 | + /** | ||
| 32 | + * 供应商名称 | ||
| 33 | + */ | ||
| 34 | + private String name; | ||
| 35 | + /** | ||
| 36 | + * 联系人 | ||
| 37 | + */ | ||
| 38 | + private String contact; | ||
| 39 | + /** | ||
| 40 | + * 手机号码 | ||
| 41 | + */ | ||
| 42 | + private String mobile; | ||
| 43 | + /** | ||
| 44 | + * 联系电话 | ||
| 45 | + */ | ||
| 46 | + private String telephone; | ||
| 47 | + /** | ||
| 48 | + * 电子邮箱 | ||
| 49 | + */ | ||
| 50 | + private String email; | ||
| 51 | + /** | ||
| 52 | + * 传真 | ||
| 53 | + */ | ||
| 54 | + private String fax; | ||
| 55 | + /** | ||
| 56 | + * 备注 | ||
| 57 | + */ | ||
| 58 | + private String remark; | ||
| 59 | + /** | ||
| 60 | + * 开启状态 | ||
| 61 | + * | ||
| 62 | + * 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum} | ||
| 63 | + */ | ||
| 64 | + private Integer status; | ||
| 65 | + /** | ||
| 66 | + * 排序 | ||
| 67 | + */ | ||
| 68 | + private Integer sort; | ||
| 69 | + /** | ||
| 70 | + * 纳税人识别号 | ||
| 71 | + */ | ||
| 72 | + private String taxNo; | ||
| 73 | + /** | ||
| 74 | + * 税率 | ||
| 75 | + */ | ||
| 76 | + private BigDecimal taxPercent; | ||
| 77 | + /** | ||
| 78 | + * 开户行 | ||
| 79 | + */ | ||
| 80 | + private String bankName; | ||
| 81 | + /** | ||
| 82 | + * 开户账号 | ||
| 83 | + */ | ||
| 84 | + private String bankAccount; | ||
| 85 | + /** | ||
| 86 | + * 开户地址 | ||
| 87 | + */ | ||
| 88 | + private String bankAddress; | ||
| 89 | + | ||
| 90 | +} | ||
| 0 | \ No newline at end of file | 91 | \ No newline at end of file |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpSupplierMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.dal.mysql.purchase; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 6 | +import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierPageReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.erp.dal.dataobject.supplier.ErpSupplierDO; | ||
| 8 | +import org.apache.ibatis.annotations.Mapper; | ||
| 9 | + | ||
| 10 | +import java.util.List; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * ERP 供应商 Mapper | ||
| 14 | + * | ||
| 15 | + * @author 芋道源码 | ||
| 16 | + */ | ||
| 17 | +@Mapper | ||
| 18 | +public interface ErpSupplierMapper extends BaseMapperX<ErpSupplierDO> { | ||
| 19 | + | ||
| 20 | + default PageResult<ErpSupplierDO> selectPage(ErpSupplierPageReqVO reqVO) { | ||
| 21 | + return selectPage(reqVO, new LambdaQueryWrapperX<ErpSupplierDO>() | ||
| 22 | + .likeIfPresent(ErpSupplierDO::getName, reqVO.getName()) | ||
| 23 | + .likeIfPresent(ErpSupplierDO::getMobile, reqVO.getMobile()) | ||
| 24 | + .likeIfPresent(ErpSupplierDO::getTelephone, reqVO.getTelephone()) | ||
| 25 | + .orderByDesc(ErpSupplierDO::getId)); | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + default List<ErpSupplierDO> selectListByStatus(Integer status) { | ||
| 29 | + return selectList(ErpSupplierDO::getStatus, status); | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | +} | ||
| 0 | \ No newline at end of file | 33 | \ No newline at end of file |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockInMapper.java
| @@ -2,9 +2,10 @@ package cn.iocoder.yudao.module.erp.dal.mysql.stock; | @@ -2,9 +2,10 @@ package cn.iocoder.yudao.module.erp.dal.mysql.stock; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; |
| 6 | import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.in.ErpStockInPageReqVO; | 6 | import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.in.ErpStockInPageReqVO; |
| 7 | import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockInDO; | 7 | import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockInDO; |
| 8 | +import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockInItemDO; | ||
| 8 | import org.apache.ibatis.annotations.Mapper; | 9 | import org.apache.ibatis.annotations.Mapper; |
| 9 | 10 | ||
| 10 | /** | 11 | /** |
| @@ -16,14 +17,21 @@ import org.apache.ibatis.annotations.Mapper; | @@ -16,14 +17,21 @@ import org.apache.ibatis.annotations.Mapper; | ||
| 16 | public interface ErpStockInMapper extends BaseMapperX<ErpStockInDO> { | 17 | public interface ErpStockInMapper extends BaseMapperX<ErpStockInDO> { |
| 17 | 18 | ||
| 18 | default PageResult<ErpStockInDO> selectPage(ErpStockInPageReqVO reqVO) { | 19 | default PageResult<ErpStockInDO> selectPage(ErpStockInPageReqVO reqVO) { |
| 19 | - return selectPage(reqVO, new LambdaQueryWrapperX<ErpStockInDO>() | 20 | + MPJLambdaWrapperX<ErpStockInDO> query = new MPJLambdaWrapperX<ErpStockInDO>() |
| 20 | .eqIfPresent(ErpStockInDO::getNo, reqVO.getNo()) | 21 | .eqIfPresent(ErpStockInDO::getNo, reqVO.getNo()) |
| 21 | .eqIfPresent(ErpStockInDO::getSupplierId, reqVO.getSupplierId()) | 22 | .eqIfPresent(ErpStockInDO::getSupplierId, reqVO.getSupplierId()) |
| 22 | .betweenIfPresent(ErpStockInDO::getInTime, reqVO.getInTime()) | 23 | .betweenIfPresent(ErpStockInDO::getInTime, reqVO.getInTime()) |
| 23 | .eqIfPresent(ErpStockInDO::getStatus, reqVO.getStatus()) | 24 | .eqIfPresent(ErpStockInDO::getStatus, reqVO.getStatus()) |
| 24 | .likeIfPresent(ErpStockInDO::getRemark, reqVO.getRemark()) | 25 | .likeIfPresent(ErpStockInDO::getRemark, reqVO.getRemark()) |
| 25 | .eqIfPresent(ErpStockInDO::getCreator, reqVO.getCreator()) | 26 | .eqIfPresent(ErpStockInDO::getCreator, reqVO.getCreator()) |
| 26 | - .orderByDesc(ErpStockInDO::getId)); | 27 | + .orderByDesc(ErpStockInDO::getId); |
| 28 | + if (reqVO.getWarehouseId() != null || reqVO.getProductId() != null) { | ||
| 29 | + query.leftJoin(ErpStockInItemDO.class, ErpStockInItemDO::getInId, ErpStockInDO::getId) | ||
| 30 | + .eq(reqVO.getWarehouseId() != null, ErpStockInItemDO::getWarehouseId, reqVO.getWarehouseId()) | ||
| 31 | + .eq(reqVO.getProductId() != null, ErpStockInItemDO::getProductId, reqVO.getProductId()) | ||
| 32 | + .groupBy(ErpStockInDO::getId); // 避免 1 对多查询,产生相同的 1 | ||
| 33 | + } | ||
| 34 | + return selectJoinPage(reqVO, ErpStockInDO.class, query); | ||
| 27 | } | 35 | } |
| 28 | 36 | ||
| 29 | } | 37 | } |
| 30 | \ No newline at end of file | 38 | \ No newline at end of file |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductServiceImpl.java
| @@ -41,6 +41,7 @@ public class ErpProductServiceImpl implements ErpProductService { | @@ -41,6 +41,7 @@ public class ErpProductServiceImpl implements ErpProductService { | ||
| 41 | 41 | ||
| 42 | @Override | 42 | @Override |
| 43 | public Long createProduct(ProductSaveReqVO createReqVO) { | 43 | public Long createProduct(ProductSaveReqVO createReqVO) { |
| 44 | + // TODO 芋艿:校验分类 | ||
| 44 | // 插入 | 45 | // 插入 |
| 45 | ErpProductDO product = BeanUtils.toBean(createReqVO, ErpProductDO.class); | 46 | ErpProductDO product = BeanUtils.toBean(createReqVO, ErpProductDO.class); |
| 46 | productMapper.insert(product); | 47 | productMapper.insert(product); |
| @@ -50,6 +51,7 @@ public class ErpProductServiceImpl implements ErpProductService { | @@ -50,6 +51,7 @@ public class ErpProductServiceImpl implements ErpProductService { | ||
| 50 | 51 | ||
| 51 | @Override | 52 | @Override |
| 52 | public void updateProduct(ProductSaveReqVO updateReqVO) { | 53 | public void updateProduct(ProductSaveReqVO updateReqVO) { |
| 54 | + // TODO 芋艿:校验分类 | ||
| 53 | // 校验存在 | 55 | // 校验存在 |
| 54 | validateProductExists(updateReqVO.getId()); | 56 | validateProductExists(updateReqVO.getId()); |
| 55 | // 更新 | 57 | // 更新 |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpSupplierService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.service.purchase; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierPageReqVO; | ||
| 5 | +import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierSaveReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.erp.dal.dataobject.supplier.ErpSupplierDO; | ||
| 7 | +import jakarta.validation.Valid; | ||
| 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 | + | ||
| 15 | +/** | ||
| 16 | + * ERP 供应商 Service 接口 | ||
| 17 | + * | ||
| 18 | + * @author 芋道源码 | ||
| 19 | + */ | ||
| 20 | +public interface ErpSupplierService { | ||
| 21 | + | ||
| 22 | + /** | ||
| 23 | + * 创建供应商 | ||
| 24 | + * | ||
| 25 | + * @param createReqVO 创建信息 | ||
| 26 | + * @return 编号 | ||
| 27 | + */ | ||
| 28 | + Long createSupplier(@Valid ErpSupplierSaveReqVO createReqVO); | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * 更新供应商 | ||
| 32 | + * | ||
| 33 | + * @param updateReqVO 更新信息 | ||
| 34 | + */ | ||
| 35 | + void updateSupplier(@Valid ErpSupplierSaveReqVO updateReqVO); | ||
| 36 | + | ||
| 37 | + /** | ||
| 38 | + * 删除供应商 | ||
| 39 | + * | ||
| 40 | + * @param id 编号 | ||
| 41 | + */ | ||
| 42 | + void deleteSupplier(Long id); | ||
| 43 | + | ||
| 44 | + /** | ||
| 45 | + * 获得供应商 | ||
| 46 | + * | ||
| 47 | + * @param id 编号 | ||
| 48 | + * @return 供应商 | ||
| 49 | + */ | ||
| 50 | + ErpSupplierDO getSupplier(Long id); | ||
| 51 | + | ||
| 52 | + /** | ||
| 53 | + * 校验供应商 | ||
| 54 | + * | ||
| 55 | + * @param id 编号 | ||
| 56 | + * @return 供应商 | ||
| 57 | + */ | ||
| 58 | + ErpSupplierDO validateSupplier(Long id); | ||
| 59 | + | ||
| 60 | + /** | ||
| 61 | + * 获得供应商列表 | ||
| 62 | + * | ||
| 63 | + * @param ids 编号列表 | ||
| 64 | + * @return 供应商列表 | ||
| 65 | + */ | ||
| 66 | + List<ErpSupplierDO> getSupplierList(Collection<Long> ids); | ||
| 67 | + | ||
| 68 | + /** | ||
| 69 | + * 获得供应商 Map | ||
| 70 | + * | ||
| 71 | + * @param ids 编号列表 | ||
| 72 | + * @return 供应商 Map | ||
| 73 | + */ | ||
| 74 | + default Map<Long, ErpSupplierDO> getSupplierMap(Collection<Long> ids) { | ||
| 75 | + return convertMap(getSupplierList(ids), ErpSupplierDO::getId); | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + /** | ||
| 79 | + * 获得供应商分页 | ||
| 80 | + * | ||
| 81 | + * @param pageReqVO 分页查询 | ||
| 82 | + * @return 供应商分页 | ||
| 83 | + */ | ||
| 84 | + PageResult<ErpSupplierDO> getSupplierPage(ErpSupplierPageReqVO pageReqVO); | ||
| 85 | + | ||
| 86 | + /** | ||
| 87 | + * 获得指定状态的供应商列表 | ||
| 88 | + * | ||
| 89 | + * @param status 状态 | ||
| 90 | + * @return 供应商列表 | ||
| 91 | + */ | ||
| 92 | + List<ErpSupplierDO> getSupplierListByStatus(Integer status); | ||
| 93 | + | ||
| 94 | +} | ||
| 0 | \ No newline at end of file | 95 | \ No newline at end of file |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpSupplierServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.erp.service.purchase; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 5 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 6 | +import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierPageReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierSaveReqVO; | ||
| 8 | +import cn.iocoder.yudao.module.erp.dal.dataobject.supplier.ErpSupplierDO; | ||
| 9 | +import cn.iocoder.yudao.module.erp.dal.mysql.purchase.ErpSupplierMapper; | ||
| 10 | +import jakarta.annotation.Resource; | ||
| 11 | +import org.springframework.stereotype.Service; | ||
| 12 | +import org.springframework.validation.annotation.Validated; | ||
| 13 | + | ||
| 14 | +import java.util.Collection; | ||
| 15 | +import java.util.List; | ||
| 16 | + | ||
| 17 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 18 | +import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; | ||
| 19 | + | ||
| 20 | +/** | ||
| 21 | + * ERP 供应商 Service 实现类 | ||
| 22 | + * | ||
| 23 | + * @author 芋道源码 | ||
| 24 | + */ | ||
| 25 | +@Service | ||
| 26 | +@Validated | ||
| 27 | +public class ErpSupplierServiceImpl implements ErpSupplierService { | ||
| 28 | + | ||
| 29 | + @Resource | ||
| 30 | + private ErpSupplierMapper supplierMapper; | ||
| 31 | + | ||
| 32 | + @Override | ||
| 33 | + public Long createSupplier(ErpSupplierSaveReqVO createReqVO) { | ||
| 34 | + ErpSupplierDO supplier = BeanUtils.toBean(createReqVO, ErpSupplierDO.class); | ||
| 35 | + supplierMapper.insert(supplier); | ||
| 36 | + return supplier.getId(); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + @Override | ||
| 40 | + public void updateSupplier(ErpSupplierSaveReqVO updateReqVO) { | ||
| 41 | + // 校验存在 | ||
| 42 | + validateSupplierExists(updateReqVO.getId()); | ||
| 43 | + // 更新 | ||
| 44 | + ErpSupplierDO updateObj = BeanUtils.toBean(updateReqVO, ErpSupplierDO.class); | ||
| 45 | + supplierMapper.updateById(updateObj); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + @Override | ||
| 49 | + public void deleteSupplier(Long id) { | ||
| 50 | + // 校验存在 | ||
| 51 | + validateSupplierExists(id); | ||
| 52 | + // 删除 | ||
| 53 | + supplierMapper.deleteById(id); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + private void validateSupplierExists(Long id) { | ||
| 57 | + if (supplierMapper.selectById(id) == null) { | ||
| 58 | + throw exception(SUPPLIER_NOT_EXISTS); | ||
| 59 | + } | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + @Override | ||
| 63 | + public ErpSupplierDO getSupplier(Long id) { | ||
| 64 | + return supplierMapper.selectById(id); | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + @Override | ||
| 68 | + public ErpSupplierDO validateSupplier(Long id) { | ||
| 69 | + ErpSupplierDO supplier = supplierMapper.selectById(id); | ||
| 70 | + if (supplier == null) { | ||
| 71 | + throw exception(WAREHOUSE_NOT_EXISTS); | ||
| 72 | + } | ||
| 73 | + if (CommonStatusEnum.isDisable(supplier.getStatus())) { | ||
| 74 | + throw exception(WAREHOUSE_NOT_ENABLE, supplier.getName()); | ||
| 75 | + } | ||
| 76 | + return supplier; | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + @Override | ||
| 80 | + public List<ErpSupplierDO> getSupplierList(Collection<Long> ids) { | ||
| 81 | + return supplierMapper.selectBatchIds(ids); | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + @Override | ||
| 85 | + public PageResult<ErpSupplierDO> getSupplierPage(ErpSupplierPageReqVO pageReqVO) { | ||
| 86 | + return supplierMapper.selectPage(pageReqVO); | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + @Override | ||
| 90 | + public List<ErpSupplierDO> getSupplierListByStatus(Integer status) { | ||
| 91 | + return supplierMapper.selectListByStatus(status); | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | +} | ||
| 0 | \ No newline at end of file | 95 | \ No newline at end of file |
yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockInServiceImpl.java
| @@ -12,6 +12,7 @@ import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpStockInItemMapper; | @@ -12,6 +12,7 @@ import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpStockInItemMapper; | ||
| 12 | import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpStockInMapper; | 12 | import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpStockInMapper; |
| 13 | import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; | 13 | import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; |
| 14 | import cn.iocoder.yudao.module.erp.service.product.ErpProductService; | 14 | import cn.iocoder.yudao.module.erp.service.product.ErpProductService; |
| 15 | +import cn.iocoder.yudao.module.erp.service.purchase.ErpSupplierService; | ||
| 15 | import jakarta.annotation.Resource; | 16 | import jakarta.annotation.Resource; |
| 16 | import org.springframework.stereotype.Service; | 17 | import org.springframework.stereotype.Service; |
| 17 | import org.springframework.transaction.annotation.Transactional; | 18 | import org.springframework.transaction.annotation.Transactional; |
| @@ -46,13 +47,16 @@ public class ErpStockInServiceImpl implements ErpStockInService { | @@ -46,13 +47,16 @@ public class ErpStockInServiceImpl implements ErpStockInService { | ||
| 46 | private ErpProductService productService; | 47 | private ErpProductService productService; |
| 47 | @Resource | 48 | @Resource |
| 48 | private ErpWarehouseService warehouseService; | 49 | private ErpWarehouseService warehouseService; |
| 50 | + @Resource | ||
| 51 | + private ErpSupplierService supplierService; | ||
| 49 | 52 | ||
| 50 | @Override | 53 | @Override |
| 51 | @Transactional(rollbackFor = Exception.class) | 54 | @Transactional(rollbackFor = Exception.class) |
| 52 | public Long createStockIn(ErpStockInSaveReqVO createReqVO) { | 55 | public Long createStockIn(ErpStockInSaveReqVO createReqVO) { |
| 53 | // 1.1 校验入库项的有效性 | 56 | // 1.1 校验入库项的有效性 |
| 54 | List<ErpStockInItemDO> stockInItems = validateStockInItems(createReqVO.getItems()); | 57 | List<ErpStockInItemDO> stockInItems = validateStockInItems(createReqVO.getItems()); |
| 55 | - // 1.2 TODO 芋艿:校验供应商 | 58 | + // 1.2 校验供应商 |
| 59 | + supplierService.validateSupplier(createReqVO.getSupplierId()); | ||
| 56 | 60 | ||
| 57 | // 2.1 插入入库单 | 61 | // 2.1 插入入库单 |
| 58 | ErpStockInDO stockIn = BeanUtils.toBean(createReqVO, ErpStockInDO.class, in -> in | 62 | ErpStockInDO stockIn = BeanUtils.toBean(createReqVO, ErpStockInDO.class, in -> in |
| @@ -71,7 +75,8 @@ public class ErpStockInServiceImpl implements ErpStockInService { | @@ -71,7 +75,8 @@ public class ErpStockInServiceImpl implements ErpStockInService { | ||
| 71 | public void updateStockIn(ErpStockInSaveReqVO updateReqVO) { | 75 | public void updateStockIn(ErpStockInSaveReqVO updateReqVO) { |
| 72 | // 1.1 校验存在 | 76 | // 1.1 校验存在 |
| 73 | validateStockInExists(updateReqVO.getId()); | 77 | validateStockInExists(updateReqVO.getId()); |
| 74 | - // 1.2 TODO 芋艿:校验供应商 | 78 | + // 1.2 校验供应商 |
| 79 | + supplierService.validateSupplier(updateReqVO.getSupplierId()); | ||
| 75 | // 1.3 校验入库项的有效性 | 80 | // 1.3 校验入库项的有效性 |
| 76 | List<ErpStockInItemDO> stockInItems = validateStockInItems(updateReqVO.getItems()); | 81 | List<ErpStockInItemDO> stockInItems = validateStockInItems(updateReqVO.getItems()); |
| 77 | 82 |
yudao-module-erp/yudao-module-erp-biz/src/main/resources/mapper/supplier/ErpSupplierMapper.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | ||
| 3 | +<mapper namespace="cn.iocoder.yudao.module.erp.dal.mysql.purchase.ErpSupplierMapper"> | ||
| 4 | + | ||
| 5 | + <!-- | ||
| 6 | + 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。 | ||
| 7 | + 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。 | ||
| 8 | + 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。 | ||
| 9 | + 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/ | ||
| 10 | + --> | ||
| 11 | + | ||
| 12 | +</mapper> | ||
| 0 | \ No newline at end of file | 13 | \ No newline at end of file |
yudao-server/src/main/resources/application-local.yaml
| @@ -188,6 +188,7 @@ logging: | @@ -188,6 +188,7 @@ logging: | ||
| 188 | cn.iocoder.yudao.module.promotion.dal.mysql: debug | 188 | cn.iocoder.yudao.module.promotion.dal.mysql: debug |
| 189 | cn.iocoder.yudao.module.statistics.dal.mysql: debug | 189 | cn.iocoder.yudao.module.statistics.dal.mysql: debug |
| 190 | cn.iocoder.yudao.module.crm.dal.mysql: debug | 190 | cn.iocoder.yudao.module.crm.dal.mysql: debug |
| 191 | + cn.iocoder.yudao.module.erp.dal.mysql: debug | ||
| 191 | org.springframework.context.support.PostProcessorRegistrationDelegate: ERROR # TODO 芋艿:先禁用,Spring Boot 3.X 存在部分错误的 WARN 提示 | 192 | org.springframework.context.support.PostProcessorRegistrationDelegate: ERROR # TODO 芋艿:先禁用,Spring Boot 3.X 存在部分错误的 WARN 提示 |
| 192 | 193 | ||
| 193 | debug: false | 194 | debug: false |