From 03ecc489a4dd5871de867bbb856bd83affdc0ebe Mon Sep 17 00:00:00 2001 From: siontion Date: Tue, 16 Jan 2024 12:48:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=87=BA=E5=85=A5=E5=BA=93=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=20=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 出入库接口 修改 --- .../module/heli/enums/ErrorCodeConstants.java | 2 +- .../admin/storage/vo/StoragePageReqVO.java | 46 ++---- .../admin/storage/vo/StorageRespVO.java | 73 ++++----- .../admin/storage/vo/StorageSaveReqVO.java | 55 +++---- .../dal/dataobject/storage/StorageDO.java | 67 +++----- .../heli/dal/mysql/storage/StorageMapper.java | 15 +- .../service/storage/StorageServiceImpl.java | 148 +++++++++--------- 7 files changed, 168 insertions(+), 238 deletions(-) diff --git a/mes-module-heli/mes-module-heli-api/src/main/java/com/chanko/yunxi/mes/module/heli/enums/ErrorCodeConstants.java b/mes-module-heli/mes-module-heli-api/src/main/java/com/chanko/yunxi/mes/module/heli/enums/ErrorCodeConstants.java index 42a9d5fe..f3863eaf 100644 --- a/mes-module-heli/mes-module-heli-api/src/main/java/com/chanko/yunxi/mes/module/heli/enums/ErrorCodeConstants.java +++ b/mes-module-heli/mes-module-heli-api/src/main/java/com/chanko/yunxi/mes/module/heli/enums/ErrorCodeConstants.java @@ -36,6 +36,6 @@ public interface ErrorCodeConstants { ErrorCode WAREHOUSE_NOT_EXISTS = new ErrorCode(1_003_001, "仓库不存在"); ErrorCode RG_NOT_EXISTS = new ErrorCode(1_003_002, "库区不存在"); ErrorCode PN_NOT_EXISTS = new ErrorCode(1_003_003, "库位不存在"); - ErrorCode Storage_NOT_EXISTS = new ErrorCode(1_003_004,"库存不存在"); + ErrorCode STORAGE_NOT_EXISTS = new ErrorCode(1_003_004,"库存不存在"); } diff --git a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/controller/admin/storage/vo/StoragePageReqVO.java b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/controller/admin/storage/vo/StoragePageReqVO.java index dc0a9ac4..faa79859 100644 --- a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/controller/admin/storage/vo/StoragePageReqVO.java +++ b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/controller/admin/storage/vo/StoragePageReqVO.java @@ -4,7 +4,6 @@ import lombok.*; import java.util.*; import io.swagger.v3.oas.annotations.media.Schema; import com.chanko.yunxi.mes.framework.common.pojo.PageParam; -import java.math.BigDecimal; import org.springframework.format.annotation.DateTimeFormat; import java.time.LocalDateTime; @@ -16,8 +15,14 @@ import static com.chanko.yunxi.mes.framework.common.util.date.DateUtils.FORMAT_Y @ToString(callSuper = true) public class StoragePageReqVO extends PageParam { - @Schema(description = "入库出库类型:1为入库,2为出库", example = "2") - private Boolean stockType; + @Schema(description = "入库出库大类型:1为入库,2为出库", example = "2") + private Integer stockType; + + @Schema(description = "入库类型(字典):1为采购入库,2为盘盈入库,3为其他入库", example = "1") + private Integer stockInType; + + @Schema(description = "出库类型(字典):1为领料出库,2为销售出库,3为盘亏出库,4为其他出库", example = "2") + private Integer stockOutType; @Schema(description = "入/出库单号") private String stockNo; @@ -25,36 +30,15 @@ public class StoragePageReqVO extends PageParam { @Schema(description = "上游单号") private Long headerNo; - @Schema(description = "物料 Id,对应 base_material表中的 Id 列", example = "651") - private Long materialId; + @Schema(description = "备注", example = "你说的对") + private String description; - @Schema(description = "批次号") - private String lotNo; + @Schema(description = "状态:1为保存;2为提交;3为作废", example = "1") + private Integer status; - @Schema(description = "仓库 Id,对应 wms_wh 表中的Id", example = "17136") + @Schema(description = "仓库Id,对应 wms_wh 表中的Id", example = "28079") private Long whId; - @Schema(description = "库区 Id,对应 wms_rg 表中的Id", example = "24171") - private Long rgId; - - @Schema(description = "库区 Id,对应 wms_rg 表中的Id", example = "3031") - private Long pnId; - - @Schema(description = "库存良品数量") - private BigDecimal storageOkQty; - - @Schema(description = "库存不良品数量") - private BigDecimal storageNgQty; - - @Schema(description = "库存报废数量") - private BigDecimal storageSpQty; - - @Schema(description = "备注", example = "随便") - private String description; - - @Schema(description = "状态:1为保存;2为提交;3为作废", example = "2") - private Boolean status; - @Schema(description = "记录的创建人,对应员工表中的 Id") private String creator; @@ -77,11 +61,11 @@ public class StoragePageReqVO extends PageParam { private LocalDateTime[] keeperTime; @Schema(description = "出库人") - private Long outer; + private Long outbound; @Schema(description = "出库时间") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] outerTime; + private LocalDateTime[] outboundTime; @Schema(description = "作废人") private Long cancel; diff --git a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/controller/admin/storage/vo/StorageRespVO.java b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/controller/admin/storage/vo/StorageRespVO.java index 6ace18b7..d76592ab 100644 --- a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/controller/admin/storage/vo/StorageRespVO.java +++ b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/controller/admin/storage/vo/StorageRespVO.java @@ -4,23 +4,35 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import java.util.*; import java.util.*; -import java.math.BigDecimal; import org.springframework.format.annotation.DateTimeFormat; import java.time.LocalDateTime; import com.alibaba.excel.annotation.*; +import com.chanko.yunxi.mes.framework.excel.core.annotations.DictFormat; +import com.chanko.yunxi.mes.framework.excel.core.convert.DictConvert; @Schema(description = "管理后台 - 入/出库 Response VO") @Data @ExcelIgnoreUnannotated public class StorageRespVO { - @Schema(description = "出库时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "1806") - @ExcelProperty("出库时间") + @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "24890") + @ExcelProperty("主键id") private Long id; - @Schema(description = "入库出库类型:1为入库,2为出库", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @ExcelProperty("入库出库类型:1为入库,2为出库") - private Boolean stockType; + @Schema(description = "入库出库大类型:1为入库,2为出库", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") + @ExcelProperty(value = "入库出库大类型:1为入库,2为出库", converter = DictConvert.class) + @DictFormat("heli_storage_type") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 + private Integer stockType; + + @Schema(description = "入库类型(字典):1为采购入库,2为盘盈入库,3为其他入库", example = "1") + @ExcelProperty(value = "入库类型(字典):1为采购入库,2为盘盈入库,3为其他入库", converter = DictConvert.class) + @DictFormat("heli_storage_in_type") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 + private Integer stockInType; + + @Schema(description = "出库类型(字典):1为领料出库,2为销售出库,3为盘亏出库,4为其他出库", example = "2") + @ExcelProperty(value = "出库类型(字典):1为领料出库,2为销售出库,3为盘亏出库,4为其他出库", converter = DictConvert.class) + @DictFormat("heli_storage_out_type") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 + private Integer stockOutType; @Schema(description = "入/出库单号", requiredMode = Schema.RequiredMode.REQUIRED) @ExcelProperty("入/出库单号") @@ -30,45 +42,18 @@ public class StorageRespVO { @ExcelProperty("上游单号") private Long headerNo; - @Schema(description = "物料 Id,对应 base_material表中的 Id 列", requiredMode = Schema.RequiredMode.REQUIRED, example = "651") - @ExcelProperty("物料 Id,对应 base_material表中的 Id 列") - private Long materialId; - - @Schema(description = "批次号") - @ExcelProperty("批次号") - private String lotNo; - - @Schema(description = "仓库 Id,对应 wms_wh 表中的Id", requiredMode = Schema.RequiredMode.REQUIRED, example = "17136") - @ExcelProperty("仓库 Id,对应 wms_wh 表中的Id") - private Long whId; - - @Schema(description = "库区 Id,对应 wms_rg 表中的Id", requiredMode = Schema.RequiredMode.REQUIRED, example = "24171") - @ExcelProperty("库区 Id,对应 wms_rg 表中的Id") - private Long rgId; - - @Schema(description = "库区 Id,对应 wms_rg 表中的Id", requiredMode = Schema.RequiredMode.REQUIRED, example = "3031") - @ExcelProperty("库区 Id,对应 wms_rg 表中的Id") - private Long pnId; - - @Schema(description = "库存良品数量") - @ExcelProperty("库存良品数量") - private BigDecimal storageOkQty; - - @Schema(description = "库存不良品数量") - @ExcelProperty("库存不良品数量") - private BigDecimal storageNgQty; - - @Schema(description = "库存报废数量") - @ExcelProperty("库存报废数量") - private BigDecimal storageSpQty; - - @Schema(description = "备注", example = "随便") + @Schema(description = "备注", example = "你说的对") @ExcelProperty("备注") private String description; - @Schema(description = "状态:1为保存;2为提交;3为作废", example = "2") - @ExcelProperty("状态:1为保存;2为提交;3为作废") - private Boolean status; + @Schema(description = "状态:1为保存;2为提交;3为作废", example = "1") + @ExcelProperty(value = "状态:1为保存;2为提交;3为作废", converter = DictConvert.class) + @DictFormat("heli_common_status") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 + private Integer status; + + @Schema(description = "仓库Id,对应 wms_wh 表中的Id", requiredMode = Schema.RequiredMode.REQUIRED, example = "28079") + @ExcelProperty("仓库Id,对应 wms_wh 表中的Id") + private Long whId; @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) @ExcelProperty("创建时间") @@ -84,11 +69,11 @@ public class StorageRespVO { @Schema(description = "出库人") @ExcelProperty("出库人") - private Long outer; + private Long outbound; @Schema(description = "出库时间") @ExcelProperty("出库时间") - private LocalDateTime outerTime; + private LocalDateTime outboundTime; @Schema(description = "作废人") @ExcelProperty("作废人") diff --git a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/controller/admin/storage/vo/StorageSaveReqVO.java b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/controller/admin/storage/vo/StorageSaveReqVO.java index 56cbe111..d64efb6f 100644 --- a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/controller/admin/storage/vo/StorageSaveReqVO.java +++ b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/controller/admin/storage/vo/StorageSaveReqVO.java @@ -5,7 +5,6 @@ import lombok.*; import java.util.*; import javax.validation.constraints.*; import java.util.*; -import java.math.BigDecimal; import org.springframework.format.annotation.DateTimeFormat; import java.time.LocalDateTime; @@ -13,12 +12,18 @@ import java.time.LocalDateTime; @Data public class StorageSaveReqVO { - @Schema(description = "出库时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "1806") + @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "24890") private Long id; - @Schema(description = "入库出库类型:1为入库,2为出库", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @NotNull(message = "入库出库类型:1为入库,2为出库不能为空") - private Boolean stockType; + @Schema(description = "入库出库大类型:1为入库,2为出库", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") + @NotNull(message = "入库出库大类型:1为入库,2为出库不能为空") + private Integer stockType; + + @Schema(description = "入库类型(字典):1为采购入库,2为盘盈入库,3为其他入库", example = "1") + private Integer stockInType; + + @Schema(description = "出库类型(字典):1为领料出库,2为销售出库,3为盘亏出库,4为其他出库", example = "2") + private Integer stockOutType; @Schema(description = "入/出库单号", requiredMode = Schema.RequiredMode.REQUIRED) @NotEmpty(message = "入/出库单号不能为空") @@ -27,40 +32,16 @@ public class StorageSaveReqVO { @Schema(description = "上游单号") private Long headerNo; - @Schema(description = "物料 Id,对应 base_material表中的 Id 列", requiredMode = Schema.RequiredMode.REQUIRED, example = "651") - @NotNull(message = "物料 Id,对应 base_material表中的 Id 列不能为空") - private Long materialId; + @Schema(description = "备注", example = "你说的对") + private String description; - @Schema(description = "批次号") - private String lotNo; + @Schema(description = "状态:1为保存;2为提交;3为作废", example = "1") + private Integer status; - @Schema(description = "仓库 Id,对应 wms_wh 表中的Id", requiredMode = Schema.RequiredMode.REQUIRED, example = "17136") - @NotNull(message = "仓库 Id,对应 wms_wh 表中的Id不能为空") + @Schema(description = "仓库Id,对应 wms_wh 表中的Id", requiredMode = Schema.RequiredMode.REQUIRED, example = "28079") + @NotNull(message = "仓库Id,对应 wms_wh 表中的Id不能为空") private Long whId; - @Schema(description = "库区 Id,对应 wms_rg 表中的Id", requiredMode = Schema.RequiredMode.REQUIRED, example = "24171") - @NotNull(message = "库区 Id,对应 wms_rg 表中的Id不能为空") - private Long rgId; - - @Schema(description = "库区 Id,对应 wms_rg 表中的Id", requiredMode = Schema.RequiredMode.REQUIRED, example = "3031") - @NotNull(message = "库区 Id,对应 wms_rg 表中的Id不能为空") - private Long pnId; - - @Schema(description = "库存良品数量") - private BigDecimal storageOkQty; - - @Schema(description = "库存不良品数量") - private BigDecimal storageNgQty; - - @Schema(description = "库存报废数量") - private BigDecimal storageSpQty; - - @Schema(description = "备注", example = "随便") - private String description; - - @Schema(description = "状态:1为保存;2为提交;3为作废", example = "2") - private Boolean status; - @Schema(description = "入库人") private Long keeper; @@ -68,10 +49,10 @@ public class StorageSaveReqVO { private LocalDateTime keeperTime; @Schema(description = "出库人") - private Long outer; + private Long outbound; @Schema(description = "出库时间") - private LocalDateTime outerTime; + private LocalDateTime outboundTime; @Schema(description = "作废人") private Long cancel; diff --git a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/dal/dataobject/storage/StorageDO.java b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/dal/dataobject/storage/StorageDO.java index ed0dd0cd..d84ac270 100644 --- a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/dal/dataobject/storage/StorageDO.java +++ b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/dal/dataobject/storage/StorageDO.java @@ -2,9 +2,6 @@ package com.chanko.yunxi.mes.module.heli.dal.dataobject.storage; import lombok.*; import java.util.*; -import java.math.BigDecimal; -import java.math.BigDecimal; -import java.math.BigDecimal; import java.time.LocalDateTime; import java.time.LocalDateTime; import java.time.LocalDateTime; @@ -29,62 +26,50 @@ import com.chanko.yunxi.mes.framework.mybatis.core.dataobject.BaseDO; public class StorageDO extends BaseDO { /** - * 出库时间 + * 主键id */ @TableId private Long id; /** - * 入库出库类型:1为入库,2为出库 + * 入库出库大类型:1为入库,2为出库 + * + * 枚举 {@link TODO heli_storage_type 对应的类} */ - private Boolean stockType; + private Integer stockType; /** - * 入/出库单号 + * 入库类型(字典):1为采购入库,2为盘盈入库,3为其他入库 + * + * 枚举 {@link TODO heli_storage_in_type 对应的类} */ - private String stockNo; - /** - * 上游单号 - */ - private Long headerNo; + private Integer stockInType; /** - * 物料 Id,对应 base_material表中的 Id 列 + * 出库类型(字典):1为领料出库,2为销售出库,3为盘亏出库,4为其他出库 + * + * 枚举 {@link TODO heli_storage_out_type 对应的类} */ - private Long materialId; + private Integer stockOutType; /** - * 批次号 - */ - private String lotNo; - /** - * 仓库 Id,对应 wms_wh 表中的Id - */ - private Long whId; - /** - * 库区 Id,对应 wms_rg 表中的Id - */ - private Long rgId; - /** - * 库区 Id,对应 wms_rg 表中的Id - */ - private Long pnId; - /** - * 库存良品数量 - */ - private BigDecimal storageOkQty; - /** - * 库存不良品数量 + * 入/出库单号 */ - private BigDecimal storageNgQty; + private String stockNo; /** - * 库存报废数量 + * 上游单号 */ - private BigDecimal storageSpQty; + private Long headerNo; /** * 备注 */ private String description; /** * 状态:1为保存;2为提交;3为作废 + * + * 枚举 {@link TODO heli_common_status 对应的类} */ - private Boolean status; + private Integer status; + /** + * 仓库Id,对应 wms_wh 表中的Id + */ + private Long whId; /** * 入库人 */ @@ -96,11 +81,11 @@ public class StorageDO extends BaseDO { /** * 出库人 */ - private Long outer; + private Long outbound; /** * 出库时间 */ - private LocalDateTime outerTime; + private LocalDateTime outboundTime; /** * 作废人 */ diff --git a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/dal/mysql/storage/StorageMapper.java b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/dal/mysql/storage/StorageMapper.java index 352a71a1..f673819c 100644 --- a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/dal/mysql/storage/StorageMapper.java +++ b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/dal/mysql/storage/StorageMapper.java @@ -20,26 +20,21 @@ public interface StorageMapper extends BaseMapperX { default PageResult selectPage(StoragePageReqVO reqVO) { return selectPage(reqVO, new LambdaQueryWrapperX() .eqIfPresent(StorageDO::getStockType, reqVO.getStockType()) + .eqIfPresent(StorageDO::getStockInType, reqVO.getStockInType()) + .eqIfPresent(StorageDO::getStockOutType, reqVO.getStockOutType()) .eqIfPresent(StorageDO::getStockNo, reqVO.getStockNo()) .eqIfPresent(StorageDO::getHeaderNo, reqVO.getHeaderNo()) - .eqIfPresent(StorageDO::getMaterialId, reqVO.getMaterialId()) - .eqIfPresent(StorageDO::getLotNo, reqVO.getLotNo()) - .eqIfPresent(StorageDO::getWhId, reqVO.getWhId()) - .eqIfPresent(StorageDO::getRgId, reqVO.getRgId()) - .eqIfPresent(StorageDO::getPnId, reqVO.getPnId()) - .eqIfPresent(StorageDO::getStorageOkQty, reqVO.getStorageOkQty()) - .eqIfPresent(StorageDO::getStorageNgQty, reqVO.getStorageNgQty()) - .eqIfPresent(StorageDO::getStorageSpQty, reqVO.getStorageSpQty()) .eqIfPresent(StorageDO::getDescription, reqVO.getDescription()) .eqIfPresent(StorageDO::getStatus, reqVO.getStatus()) + .eqIfPresent(StorageDO::getWhId, reqVO.getWhId()) .eqIfPresent(StorageDO::getCreator, reqVO.getCreator()) .betweenIfPresent(StorageDO::getCreateTime, reqVO.getCreateTime()) .eqIfPresent(StorageDO::getUpdater, reqVO.getUpdater()) .betweenIfPresent(StorageDO::getUpdateTime, reqVO.getUpdateTime()) .eqIfPresent(StorageDO::getKeeper, reqVO.getKeeper()) .betweenIfPresent(StorageDO::getKeeperTime, reqVO.getKeeperTime()) - .eqIfPresent(StorageDO::getOuter, reqVO.getOuter()) - .betweenIfPresent(StorageDO::getOuterTime, reqVO.getOuterTime()) + .eqIfPresent(StorageDO::getOutbound, reqVO.getOutbound()) + .betweenIfPresent(StorageDO::getOutboundTime, reqVO.getOutboundTime()) .eqIfPresent(StorageDO::getCancel, reqVO.getCancel()) .betweenIfPresent(StorageDO::getCancelTime, reqVO.getCancelTime()) .orderByDesc(StorageDO::getId)); diff --git a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/service/storage/StorageServiceImpl.java b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/service/storage/StorageServiceImpl.java index 40dd17e8..4393d948 100644 --- a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/service/storage/StorageServiceImpl.java +++ b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/service/storage/StorageServiceImpl.java @@ -1,74 +1,74 @@ -package com.chanko.yunxi.mes.module.heli.service.storage; - -import org.springframework.stereotype.Service; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.transaction.annotation.Transactional; - -import java.util.*; -import com.chanko.yunxi.mes.module.heli.controller.admin.storage.vo.*; -import com.chanko.yunxi.mes.module.heli.dal.dataobject.storage.StorageDO; -import com.chanko.yunxi.mes.framework.common.pojo.PageResult; -import com.chanko.yunxi.mes.framework.common.pojo.PageParam; -import com.chanko.yunxi.mes.framework.common.util.object.BeanUtils; - -import com.chanko.yunxi.mes.module.heli.dal.mysql.storage.StorageMapper; - -import static com.chanko.yunxi.mes.framework.common.exception.util.ServiceExceptionUtil.exception; -import static com.chanko.yunxi.mes.module.heli.enums.ErrorCodeConstants.*; - -/** - * 入/出库 Service 实现类 - * - * @author 管理员 - */ -@Service -@Validated -public class StorageServiceImpl implements StorageService { - - @Resource - private StorageMapper storageMapper; - - @Override - public Long createStorage(StorageSaveReqVO createReqVO) { - // 插入 - StorageDO storage = BeanUtils.toBean(createReqVO, StorageDO.class); - storageMapper.insert(storage); - // 返回 - return storage.getId(); - } - - @Override - public void updateStorage(StorageSaveReqVO updateReqVO) { - // 校验存在 - validateStorageExists(updateReqVO.getId()); - // 更新 - StorageDO updateObj = BeanUtils.toBean(updateReqVO, StorageDO.class); - storageMapper.updateById(updateObj); - } - - @Override - public void deleteStorage(Long id) { - // 校验存在 - validateStorageExists(id); - // 删除 - storageMapper.deleteById(id); - } - - private void validateStorageExists(Long id) { - if (storageMapper.selectById(id) == null) { - throw exception(Storage_NOT_EXISTS); - } - } - - @Override - public StorageDO getStorage(Long id) { - return storageMapper.selectById(id); - } - - @Override - public PageResult getStoragePage(StoragePageReqVO pageReqVO) { - return storageMapper.selectPage(pageReqVO); - } - -} +package com.chanko.yunxi.mes.module.heli.service.storage; + +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import com.chanko.yunxi.mes.module.heli.controller.admin.storage.vo.*; +import com.chanko.yunxi.mes.module.heli.dal.dataobject.storage.StorageDO; +import com.chanko.yunxi.mes.framework.common.pojo.PageResult; +import com.chanko.yunxi.mes.framework.common.pojo.PageParam; +import com.chanko.yunxi.mes.framework.common.util.object.BeanUtils; + +import com.chanko.yunxi.mes.module.heli.dal.mysql.storage.StorageMapper; + +import static com.chanko.yunxi.mes.framework.common.exception.util.ServiceExceptionUtil.exception; +import static com.chanko.yunxi.mes.module.heli.enums.ErrorCodeConstants.*; + +/** + * 入/出库 Service 实现类 + * + * @author 管理员 + */ +@Service +@Validated +public class StorageServiceImpl implements StorageService { + + @Resource + private StorageMapper storageMapper; + + @Override + public Long createStorage(StorageSaveReqVO createReqVO) { + // 插入 + StorageDO storage = BeanUtils.toBean(createReqVO, StorageDO.class); + storageMapper.insert(storage); + // 返回 + return storage.getId(); + } + + @Override + public void updateStorage(StorageSaveReqVO updateReqVO) { + // 校验存在 + validateStorageExists(updateReqVO.getId()); + // 更新 + StorageDO updateObj = BeanUtils.toBean(updateReqVO, StorageDO.class); + storageMapper.updateById(updateObj); + } + + @Override + public void deleteStorage(Long id) { + // 校验存在 + validateStorageExists(id); + // 删除 + storageMapper.deleteById(id); + } + + private void validateStorageExists(Long id) { + if (storageMapper.selectById(id) == null) { + throw exception(STORAGE_NOT_EXISTS); + } + } + + @Override + public StorageDO getStorage(Long id) { + return storageMapper.selectById(id); + } + + @Override + public PageResult getStoragePage(StoragePageReqVO pageReqVO) { + return storageMapper.selectPage(pageReqVO); + } + +} \ No newline at end of file