Commit c62630f74bec9d00fcf1c00b0f7aa2dabb54359f
1 parent
a333887b
feat(wms): 拆 simple-list 列表 VO、补首页校验与业务单号搜索框
后端: - 新增 WmsItemListReqVO / WmsMerchantListReqVO,simple-list 接口不再 复用分页 PageReqVO,Swagger 上不再误暴露 pageNo/pageSize 字段 - WmsItemController / WmsMerchantController 的 getXxxSimpleList 改用 独立 ListReqVO;Mapper.selectList、Service.getXxxList 同步调整签名 - WmsHomeStatisticsServiceImpl 三个查询入口加 validateWarehouseIfPresent, 非空 warehouseId 走 warehouseService.validateWarehouseExists 校验, 避免前端误传任意 id 直接落到首页 SQL - 新增 sql/mysql/wms/20260515_wms_total_price.sql:幂等给 4 张明细 / 流水表 补 total_price 列并按 ROUND(quantity*price, 2) 回填历史数据 前端: - receipt/index.vue + shipment/index.vue 搜索栏补 bizOrderNo 输入控件, 对齐已声明的 queryParams 与后端 PageReqVO 支持 - WmsHomeOrderSummaryCards.getStatusPercent 改 function 声明,并去掉 最小 4% 占比下限,保留真实比例
Showing
16 changed files
with
190 additions
and
21 deletions
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/item/WmsItemController.java
| @@ -8,6 +8,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; | @@ -8,6 +8,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 8 | import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | 8 | import cn.iocoder.yudao.framework.common.util.collection.MapUtils; |
| 9 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 9 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 10 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | 10 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| 11 | +import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.item.WmsItemListReqVO; | ||
| 11 | import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.item.WmsItemPageReqVO; | 12 | import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.item.WmsItemPageReqVO; |
| 12 | import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.item.WmsItemRespVO; | 13 | import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.item.WmsItemRespVO; |
| 13 | import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.item.WmsItemSaveReqVO; | 14 | import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.item.WmsItemSaveReqVO; |
| @@ -98,8 +99,8 @@ public class WmsItemController { | @@ -98,8 +99,8 @@ public class WmsItemController { | ||
| 98 | @GetMapping("/simple-list") | 99 | @GetMapping("/simple-list") |
| 99 | @Operation(summary = "获得商品精简列表") | 100 | @Operation(summary = "获得商品精简列表") |
| 100 | @PreAuthorize("@ss.hasPermission('wms:item:query')") | 101 | @PreAuthorize("@ss.hasPermission('wms:item:query')") |
| 101 | - public CommonResult<List<WmsItemRespVO>> getItemSimpleList(@Valid WmsItemPageReqVO pageReqVO) { | ||
| 102 | - List<WmsItemDO> list = itemService.getItemList(pageReqVO); | 102 | + public CommonResult<List<WmsItemRespVO>> getItemSimpleList(@Valid WmsItemListReqVO listReqVO) { |
| 103 | + List<WmsItemDO> list = itemService.getItemList(listReqVO); | ||
| 103 | return success(buildItemRespVOList(list)); | 104 | return success(buildItemRespVOList(list)); |
| 104 | } | 105 | } |
| 105 | 106 |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/item/vo/item/WmsItemListReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.item; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.Data; | ||
| 5 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 6 | + | ||
| 7 | +import java.time.LocalDateTime; | ||
| 8 | + | ||
| 9 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 10 | + | ||
| 11 | +@Schema(description = "管理后台 - WMS 商品列表 Request VO") | ||
| 12 | +@Data | ||
| 13 | +public class WmsItemListReqVO { | ||
| 14 | + | ||
| 15 | + @Schema(description = "商品编号", example = "ITEM001") | ||
| 16 | + private String code; | ||
| 17 | + | ||
| 18 | + @Schema(description = "商品名称", example = "华为 nova flip") | ||
| 19 | + private String name; | ||
| 20 | + | ||
| 21 | + @Schema(description = "商品分类编号", example = "1024") | ||
| 22 | + private Long categoryId; | ||
| 23 | + | ||
| 24 | + @Schema(description = "商品品牌编号", example = "2048") | ||
| 25 | + private Long brandId; | ||
| 26 | + | ||
| 27 | + @Schema(description = "创建时间") | ||
| 28 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 29 | + private LocalDateTime[] createTime; | ||
| 30 | + | ||
| 31 | +} |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/merchant/WmsMerchantController.java
| @@ -6,6 +6,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam; | @@ -6,6 +6,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 7 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 8 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | 8 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| 9 | +import cn.iocoder.yudao.module.wms.controller.admin.md.merchant.vo.WmsMerchantListReqVO; | ||
| 9 | import cn.iocoder.yudao.module.wms.controller.admin.md.merchant.vo.WmsMerchantPageReqVO; | 10 | import cn.iocoder.yudao.module.wms.controller.admin.md.merchant.vo.WmsMerchantPageReqVO; |
| 10 | import cn.iocoder.yudao.module.wms.controller.admin.md.merchant.vo.WmsMerchantRespVO; | 11 | import cn.iocoder.yudao.module.wms.controller.admin.md.merchant.vo.WmsMerchantRespVO; |
| 11 | import cn.iocoder.yudao.module.wms.controller.admin.md.merchant.vo.WmsMerchantSaveReqVO; | 12 | import cn.iocoder.yudao.module.wms.controller.admin.md.merchant.vo.WmsMerchantSaveReqVO; |
| @@ -80,8 +81,8 @@ public class WmsMerchantController { | @@ -80,8 +81,8 @@ public class WmsMerchantController { | ||
| 80 | @GetMapping("/simple-list") | 81 | @GetMapping("/simple-list") |
| 81 | @Operation(summary = "获得往来企业精简列表", description = "主要用于前端下拉") | 82 | @Operation(summary = "获得往来企业精简列表", description = "主要用于前端下拉") |
| 82 | @PreAuthorize("@ss.hasPermission('wms:merchant:query')") | 83 | @PreAuthorize("@ss.hasPermission('wms:merchant:query')") |
| 83 | - public CommonResult<List<WmsMerchantRespVO>> getMerchantSimpleList(@Valid WmsMerchantPageReqVO pageReqVO) { | ||
| 84 | - List<WmsMerchantDO> list = merchantService.getMerchantList(pageReqVO); | 84 | + public CommonResult<List<WmsMerchantRespVO>> getMerchantSimpleList(@Valid WmsMerchantListReqVO listReqVO) { |
| 85 | + List<WmsMerchantDO> list = merchantService.getMerchantList(listReqVO); | ||
| 85 | return success(BeanUtils.toBean(list, WmsMerchantRespVO.class)); | 86 | return success(BeanUtils.toBean(list, WmsMerchantRespVO.class)); |
| 86 | } | 87 | } |
| 87 | 88 |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/merchant/vo/WmsMerchantListReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.wms.controller.admin.md.merchant.vo; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.validation.InEnum; | ||
| 4 | +import cn.iocoder.yudao.module.wms.enums.md.WmsMerchantTypeEnum; | ||
| 5 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 6 | +import lombok.Data; | ||
| 7 | + | ||
| 8 | +import java.util.List; | ||
| 9 | + | ||
| 10 | +@Schema(description = "管理后台 - WMS 往来企业列表 Request VO") | ||
| 11 | +@Data | ||
| 12 | +public class WmsMerchantListReqVO { | ||
| 13 | + | ||
| 14 | + @Schema(description = "往来企业编号", example = "MER001") | ||
| 15 | + private String code; | ||
| 16 | + | ||
| 17 | + @Schema(description = "往来企业名称", example = "华为") | ||
| 18 | + private String name; | ||
| 19 | + | ||
| 20 | + @Schema(description = "往来企业类型", example = "2") | ||
| 21 | + @InEnum(value = WmsMerchantTypeEnum.class, message = "往来企业类型必须是 {value}") | ||
| 22 | + private Integer type; | ||
| 23 | + | ||
| 24 | + @Schema(description = "往来企业类型数组", example = "2,3") | ||
| 25 | + @InEnum(value = WmsMerchantTypeEnum.class, message = "往来企业类型必须是 {value}") | ||
| 26 | + private List<Integer> types; | ||
| 27 | + | ||
| 28 | +} |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/dal/dataobject/md/merchant/WmsMerchantDO.java
| @@ -38,8 +38,6 @@ public class WmsMerchantDO extends BaseDO { | @@ -38,8 +38,6 @@ public class WmsMerchantDO extends BaseDO { | ||
| 38 | /** | 38 | /** |
| 39 | * 往来企业类型 | 39 | * 往来企业类型 |
| 40 | * | 40 | * |
| 41 | - * DONE @AI:枚举类 | ||
| 42 | - * | ||
| 43 | * 枚举 {@link WmsMerchantTypeEnum} | 41 | * 枚举 {@link WmsMerchantTypeEnum} |
| 44 | */ | 42 | */ |
| 45 | private Integer type; | 43 | private Integer type; |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/dal/mysql/md/item/WmsItemBrandMapper.java
| @@ -26,4 +26,8 @@ public interface WmsItemBrandMapper extends BaseMapperX<WmsItemBrandDO> { | @@ -26,4 +26,8 @@ public interface WmsItemBrandMapper extends BaseMapperX<WmsItemBrandDO> { | ||
| 26 | return selectOne(WmsItemBrandDO::getCode, code); | 26 | return selectOne(WmsItemBrandDO::getCode, code); |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | + default WmsItemBrandDO selectByName(String name) { | ||
| 30 | + return selectOne(WmsItemBrandDO::getName, name); | ||
| 31 | + } | ||
| 32 | + | ||
| 29 | } | 33 | } |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/dal/mysql/md/item/WmsItemMapper.java
| @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.wms.dal.mysql.md.item; | @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.wms.dal.mysql.md.item; | ||
| 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.LambdaQueryWrapperX; |
| 6 | +import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.item.WmsItemListReqVO; | ||
| 6 | import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.item.WmsItemPageReqVO; | 7 | import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.item.WmsItemPageReqVO; |
| 7 | import cn.iocoder.yudao.module.wms.dal.dataobject.md.item.WmsItemDO; | 8 | import cn.iocoder.yudao.module.wms.dal.dataobject.md.item.WmsItemDO; |
| 8 | import org.apache.ibatis.annotations.Mapper; | 9 | import org.apache.ibatis.annotations.Mapper; |
| @@ -28,7 +29,7 @@ public interface WmsItemMapper extends BaseMapperX<WmsItemDO> { | @@ -28,7 +29,7 @@ public interface WmsItemMapper extends BaseMapperX<WmsItemDO> { | ||
| 28 | .orderByDesc(WmsItemDO::getId)); | 29 | .orderByDesc(WmsItemDO::getId)); |
| 29 | } | 30 | } |
| 30 | 31 | ||
| 31 | - default List<WmsItemDO> selectList(WmsItemPageReqVO reqVO, Collection<Long> categoryIds) { | 32 | + default List<WmsItemDO> selectList(WmsItemListReqVO reqVO, Collection<Long> categoryIds) { |
| 32 | return selectList(new LambdaQueryWrapperX<WmsItemDO>() | 33 | return selectList(new LambdaQueryWrapperX<WmsItemDO>() |
| 33 | .likeIfPresent(WmsItemDO::getCode, reqVO.getCode()) | 34 | .likeIfPresent(WmsItemDO::getCode, reqVO.getCode()) |
| 34 | .likeIfPresent(WmsItemDO::getName, reqVO.getName()) | 35 | .likeIfPresent(WmsItemDO::getName, reqVO.getName()) |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/dal/mysql/md/merchant/WmsMerchantMapper.java
| @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.wms.dal.mysql.md.merchant; | @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.wms.dal.mysql.md.merchant; | ||
| 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.LambdaQueryWrapperX; |
| 6 | +import cn.iocoder.yudao.module.wms.controller.admin.md.merchant.vo.WmsMerchantListReqVO; | ||
| 6 | import cn.iocoder.yudao.module.wms.controller.admin.md.merchant.vo.WmsMerchantPageReqVO; | 7 | import cn.iocoder.yudao.module.wms.controller.admin.md.merchant.vo.WmsMerchantPageReqVO; |
| 7 | import cn.iocoder.yudao.module.wms.dal.dataobject.md.merchant.WmsMerchantDO; | 8 | import cn.iocoder.yudao.module.wms.dal.dataobject.md.merchant.WmsMerchantDO; |
| 8 | import org.apache.ibatis.annotations.Mapper; | 9 | import org.apache.ibatis.annotations.Mapper; |
| @@ -26,7 +27,7 @@ public interface WmsMerchantMapper extends BaseMapperX<WmsMerchantDO> { | @@ -26,7 +27,7 @@ public interface WmsMerchantMapper extends BaseMapperX<WmsMerchantDO> { | ||
| 26 | .orderByDesc(WmsMerchantDO::getId)); | 27 | .orderByDesc(WmsMerchantDO::getId)); |
| 27 | } | 28 | } |
| 28 | 29 | ||
| 29 | - default List<WmsMerchantDO> selectList(WmsMerchantPageReqVO reqVO) { | 30 | + default List<WmsMerchantDO> selectList(WmsMerchantListReqVO reqVO) { |
| 30 | return selectList(new LambdaQueryWrapperX<WmsMerchantDO>() | 31 | return selectList(new LambdaQueryWrapperX<WmsMerchantDO>() |
| 31 | .eqIfPresent(WmsMerchantDO::getCode, reqVO.getCode()) | 32 | .eqIfPresent(WmsMerchantDO::getCode, reqVO.getCode()) |
| 32 | .likeIfPresent(WmsMerchantDO::getName, reqVO.getName()) | 33 | .likeIfPresent(WmsMerchantDO::getName, reqVO.getName()) |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/enums/ErrorCodeConstants.java
| @@ -30,6 +30,7 @@ public interface ErrorCodeConstants { | @@ -30,6 +30,7 @@ public interface ErrorCodeConstants { | ||
| 30 | ErrorCode ITEM_BRAND_NOT_EXISTS = new ErrorCode(1_060_103_000, "商品品牌不存在"); | 30 | ErrorCode ITEM_BRAND_NOT_EXISTS = new ErrorCode(1_060_103_000, "商品品牌不存在"); |
| 31 | ErrorCode ITEM_BRAND_HAS_ITEM = new ErrorCode(1_060_103_001, "删除失败!品牌已被商品使用!"); | 31 | ErrorCode ITEM_BRAND_HAS_ITEM = new ErrorCode(1_060_103_001, "删除失败!品牌已被商品使用!"); |
| 32 | ErrorCode ITEM_BRAND_CODE_DUPLICATE = new ErrorCode(1_060_103_002, "商品品牌编号重复"); | 32 | ErrorCode ITEM_BRAND_CODE_DUPLICATE = new ErrorCode(1_060_103_002, "商品品牌编号重复"); |
| 33 | + ErrorCode ITEM_BRAND_NAME_DUPLICATE = new ErrorCode(1_060_103_003, "商品品牌名称重复"); | ||
| 33 | 34 | ||
| 34 | // ========== WMS 基础数据-商品 1-060-104-000 ========== | 35 | // ========== WMS 基础数据-商品 1-060-104-000 ========== |
| 35 | ErrorCode ITEM_NOT_EXISTS = new ErrorCode(1_060_104_000, "商品不存在"); | 36 | ErrorCode ITEM_NOT_EXISTS = new ErrorCode(1_060_104_000, "商品不存在"); |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/service/home/WmsHomeStatisticsServiceImpl.java
| @@ -10,6 +10,7 @@ import cn.iocoder.yudao.module.wms.controller.admin.home.vo.WmsHomeOrderTrendRes | @@ -10,6 +10,7 @@ import cn.iocoder.yudao.module.wms.controller.admin.home.vo.WmsHomeOrderTrendRes | ||
| 10 | import cn.iocoder.yudao.module.wms.dal.mysql.home.WmsHomeStatisticsMapper; | 10 | import cn.iocoder.yudao.module.wms.dal.mysql.home.WmsHomeStatisticsMapper; |
| 11 | import cn.iocoder.yudao.module.wms.enums.order.WmsOrderStatusEnum; | 11 | import cn.iocoder.yudao.module.wms.enums.order.WmsOrderStatusEnum; |
| 12 | import cn.iocoder.yudao.module.wms.enums.order.WmsOrderTypeEnum; | 12 | import cn.iocoder.yudao.module.wms.enums.order.WmsOrderTypeEnum; |
| 13 | +import cn.iocoder.yudao.module.wms.service.md.warehouse.WmsWarehouseService; | ||
| 13 | import jakarta.annotation.Resource; | 14 | import jakarta.annotation.Resource; |
| 14 | import org.springframework.stereotype.Service; | 15 | import org.springframework.stereotype.Service; |
| 15 | 16 | ||
| @@ -37,10 +38,15 @@ public class WmsHomeStatisticsServiceImpl implements WmsHomeStatisticsService { | @@ -37,10 +38,15 @@ public class WmsHomeStatisticsServiceImpl implements WmsHomeStatisticsService { | ||
| 37 | 38 | ||
| 38 | @Resource | 39 | @Resource |
| 39 | private WmsHomeStatisticsMapper homeStatisticsMapper; | 40 | private WmsHomeStatisticsMapper homeStatisticsMapper; |
| 41 | + @Resource | ||
| 42 | + private WmsWarehouseService warehouseService; | ||
| 40 | 43 | ||
| 41 | @Override | 44 | @Override |
| 42 | public List<WmsHomeOrderSummaryRespVO> getOrderSummary(Long warehouseId) { | 45 | public List<WmsHomeOrderSummaryRespVO> getOrderSummary(Long warehouseId) { |
| 46 | + validateWarehouseIfPresent(warehouseId); | ||
| 47 | + // 查询单据数量 | ||
| 43 | List<Map<String, Object>> stats = homeStatisticsMapper.selectOrderCountGroupByTypeAndStatus(warehouseId); | 48 | List<Map<String, Object>> stats = homeStatisticsMapper.selectOrderCountGroupByTypeAndStatus(warehouseId); |
| 49 | + // 按照单据类型 + 单据状态分组 | ||
| 44 | return convertList(WmsOrderTypeEnum.values(), orderTypeEnum -> { | 50 | return convertList(WmsOrderTypeEnum.values(), orderTypeEnum -> { |
| 45 | List<WmsHomeOrderStatusRespVO> statuses = convertList(WmsOrderStatusEnum.values(), statusEnum -> | 51 | List<WmsHomeOrderStatusRespVO> statuses = convertList(WmsOrderStatusEnum.values(), statusEnum -> |
| 46 | new WmsHomeOrderStatusRespVO().setStatus(statusEnum.getStatus()) | 52 | new WmsHomeOrderStatusRespVO().setStatus(statusEnum.getStatus()) |
| @@ -52,6 +58,7 @@ public class WmsHomeStatisticsServiceImpl implements WmsHomeStatisticsService { | @@ -52,6 +58,7 @@ public class WmsHomeStatisticsServiceImpl implements WmsHomeStatisticsService { | ||
| 52 | 58 | ||
| 53 | @Override | 59 | @Override |
| 54 | public List<WmsHomeOrderTrendRespVO> getOrderTrend(Integer days, Long warehouseId) { | 60 | public List<WmsHomeOrderTrendRespVO> getOrderTrend(Integer days, Long warehouseId) { |
| 61 | + validateWarehouseIfPresent(warehouseId); | ||
| 55 | // 统计区间为 [今天 - days + 1, 明天),保证最近 days 天包含今天。 | 62 | // 统计区间为 [今天 - days + 1, 明天),保证最近 days 天包含今天。 |
| 56 | LocalDate endDate = LocalDate.now().plusDays(1); | 63 | LocalDate endDate = LocalDate.now().plusDays(1); |
| 57 | LocalDate startDate = endDate.minusDays(days); | 64 | LocalDate startDate = endDate.minusDays(days); |
| @@ -80,6 +87,7 @@ public class WmsHomeStatisticsServiceImpl implements WmsHomeStatisticsService { | @@ -80,6 +87,7 @@ public class WmsHomeStatisticsServiceImpl implements WmsHomeStatisticsService { | ||
| 80 | 87 | ||
| 81 | @Override | 88 | @Override |
| 82 | public WmsHomeInventorySummaryRespVO getInventorySummary(Long warehouseId, Integer goodsLimit, Integer warehouseLimit) { | 89 | public WmsHomeInventorySummaryRespVO getInventorySummary(Long warehouseId, Integer goodsLimit, Integer warehouseLimit) { |
| 90 | + validateWarehouseIfPresent(warehouseId); | ||
| 83 | BigDecimal totalQuantity = ObjectUtil.defaultIfNull(homeStatisticsMapper.selectInventoryTotalQuantity(warehouseId), BigDecimal.ZERO); | 91 | BigDecimal totalQuantity = ObjectUtil.defaultIfNull(homeStatisticsMapper.selectInventoryTotalQuantity(warehouseId), BigDecimal.ZERO); |
| 84 | List<Map<String, Object>> itemRows = homeStatisticsMapper.selectInventoryItemRank(warehouseId, goodsLimit); | 92 | List<Map<String, Object>> itemRows = homeStatisticsMapper.selectInventoryItemRank(warehouseId, goodsLimit); |
| 85 | List<Map<String, Object>> warehouseRows = homeStatisticsMapper.selectInventoryWarehouseRank(warehouseId, warehouseLimit); | 93 | List<Map<String, Object>> warehouseRows = homeStatisticsMapper.selectInventoryWarehouseRank(warehouseId, warehouseLimit); |
| @@ -90,6 +98,15 @@ public class WmsHomeStatisticsServiceImpl implements WmsHomeStatisticsService { | @@ -90,6 +98,15 @@ public class WmsHomeStatisticsServiceImpl implements WmsHomeStatisticsService { | ||
| 90 | 98 | ||
| 91 | // ==================== 工具方法 ==================== | 99 | // ==================== 工具方法 ==================== |
| 92 | 100 | ||
| 101 | + /** | ||
| 102 | + * 仓库编号非空时,校验仓库是否存在,避免前端误传任意 id 直接落到 SQL。 | ||
| 103 | + */ | ||
| 104 | + private void validateWarehouseIfPresent(Long warehouseId) { | ||
| 105 | + if (warehouseId != null) { | ||
| 106 | + warehouseService.validateWarehouseExists(warehouseId); | ||
| 107 | + } | ||
| 108 | + } | ||
| 109 | + | ||
| 93 | private long getOrderCount(List<Map<String, Object>> stats, Integer orderType, Integer status) { | 110 | private long getOrderCount(List<Map<String, Object>> stats, Integer orderType, Integer status) { |
| 94 | for (Map<String, Object> stat : stats) { | 111 | for (Map<String, Object> stat : stats) { |
| 95 | if (ObjectUtil.equal(MapUtil.getInt(stat, "orderType"), orderType) | 112 | if (ObjectUtil.equal(MapUtil.getInt(stat, "orderType"), orderType) |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/service/md/item/WmsItemBrandServiceImpl.java
| @@ -19,6 +19,7 @@ import java.util.List; | @@ -19,6 +19,7 @@ import java.util.List; | ||
| 19 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 19 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 20 | import static cn.iocoder.yudao.module.wms.enums.ErrorCodeConstants.ITEM_BRAND_CODE_DUPLICATE; | 20 | import static cn.iocoder.yudao.module.wms.enums.ErrorCodeConstants.ITEM_BRAND_CODE_DUPLICATE; |
| 21 | import static cn.iocoder.yudao.module.wms.enums.ErrorCodeConstants.ITEM_BRAND_HAS_ITEM; | 21 | import static cn.iocoder.yudao.module.wms.enums.ErrorCodeConstants.ITEM_BRAND_HAS_ITEM; |
| 22 | +import static cn.iocoder.yudao.module.wms.enums.ErrorCodeConstants.ITEM_BRAND_NAME_DUPLICATE; | ||
| 22 | import static cn.iocoder.yudao.module.wms.enums.ErrorCodeConstants.ITEM_BRAND_NOT_EXISTS; | 23 | import static cn.iocoder.yudao.module.wms.enums.ErrorCodeConstants.ITEM_BRAND_NOT_EXISTS; |
| 23 | 24 | ||
| 24 | /** | 25 | /** |
| @@ -37,9 +38,9 @@ public class WmsItemBrandServiceImpl implements WmsItemBrandService { | @@ -37,9 +38,9 @@ public class WmsItemBrandServiceImpl implements WmsItemBrandService { | ||
| 37 | 38 | ||
| 38 | @Override | 39 | @Override |
| 39 | public Long createItemBrand(WmsItemBrandSaveReqVO createReqVO) { | 40 | public Long createItemBrand(WmsItemBrandSaveReqVO createReqVO) { |
| 40 | - // 校验编号唯一 | ||
| 41 | - validateBrandCodeUnique(null, createReqVO.getCode()); | 41 | + validateBrandSaveData(null, createReqVO); |
| 42 | 42 | ||
| 43 | + // 新增 | ||
| 43 | WmsItemBrandDO brand = BeanUtils.toBean(createReqVO, WmsItemBrandDO.class); | 44 | WmsItemBrandDO brand = BeanUtils.toBean(createReqVO, WmsItemBrandDO.class); |
| 44 | brandMapper.insert(brand); | 45 | brandMapper.insert(brand); |
| 45 | return brand.getId(); | 46 | return brand.getId(); |
| @@ -49,14 +50,18 @@ public class WmsItemBrandServiceImpl implements WmsItemBrandService { | @@ -49,14 +50,18 @@ public class WmsItemBrandServiceImpl implements WmsItemBrandService { | ||
| 49 | public void updateItemBrand(WmsItemBrandSaveReqVO updateReqVO) { | 50 | public void updateItemBrand(WmsItemBrandSaveReqVO updateReqVO) { |
| 50 | // 校验存在 | 51 | // 校验存在 |
| 51 | validateItemBrandExists(updateReqVO.getId()); | 52 | validateItemBrandExists(updateReqVO.getId()); |
| 52 | - // 校验编号唯一 | ||
| 53 | - validateBrandCodeUnique(updateReqVO.getId(), updateReqVO.getCode()); | 53 | + validateBrandSaveData(updateReqVO.getId(), updateReqVO); |
| 54 | 54 | ||
| 55 | // 更新 | 55 | // 更新 |
| 56 | WmsItemBrandDO updateObj = BeanUtils.toBean(updateReqVO, WmsItemBrandDO.class); | 56 | WmsItemBrandDO updateObj = BeanUtils.toBean(updateReqVO, WmsItemBrandDO.class); |
| 57 | brandMapper.updateById(updateObj); | 57 | brandMapper.updateById(updateObj); |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | + private void validateBrandSaveData(Long id, WmsItemBrandSaveReqVO reqVO) { | ||
| 61 | + validateBrandCodeUnique(id, reqVO.getCode()); | ||
| 62 | + validateBrandNameUnique(id, reqVO.getName()); | ||
| 63 | + } | ||
| 64 | + | ||
| 60 | private void validateBrandCodeUnique(Long id, String code) { | 65 | private void validateBrandCodeUnique(Long id, String code) { |
| 61 | WmsItemBrandDO brand = brandMapper.selectByCode(code); | 66 | WmsItemBrandDO brand = brandMapper.selectByCode(code); |
| 62 | if (brand == null) { | 67 | if (brand == null) { |
| @@ -71,6 +76,19 @@ public class WmsItemBrandServiceImpl implements WmsItemBrandService { | @@ -71,6 +76,19 @@ public class WmsItemBrandServiceImpl implements WmsItemBrandService { | ||
| 71 | } | 76 | } |
| 72 | } | 77 | } |
| 73 | 78 | ||
| 79 | + private void validateBrandNameUnique(Long id, String name) { | ||
| 80 | + WmsItemBrandDO brand = brandMapper.selectByName(name); | ||
| 81 | + if (brand == null) { | ||
| 82 | + return; | ||
| 83 | + } | ||
| 84 | + if (id == null) { | ||
| 85 | + throw exception(ITEM_BRAND_NAME_DUPLICATE); | ||
| 86 | + } | ||
| 87 | + if (ObjectUtil.notEqual(brand.getId(), id)) { | ||
| 88 | + throw exception(ITEM_BRAND_NAME_DUPLICATE); | ||
| 89 | + } | ||
| 90 | + } | ||
| 91 | + | ||
| 74 | @Override | 92 | @Override |
| 75 | public void deleteItemBrand(Long id) { | 93 | public void deleteItemBrand(Long id) { |
| 76 | // 校验存在 | 94 | // 校验存在 |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/service/md/item/WmsItemService.java
| 1 | package cn.iocoder.yudao.module.wms.service.md.item; | 1 | package cn.iocoder.yudao.module.wms.service.md.item; |
| 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.module.wms.controller.admin.md.item.vo.item.WmsItemListReqVO; | ||
| 4 | import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.item.WmsItemPageReqVO; | 5 | import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.item.WmsItemPageReqVO; |
| 5 | import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.item.WmsItemSaveReqVO; | 6 | import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.item.WmsItemSaveReqVO; |
| 6 | import cn.iocoder.yudao.module.wms.dal.dataobject.md.item.WmsItemDO; | 7 | import cn.iocoder.yudao.module.wms.dal.dataobject.md.item.WmsItemDO; |
| @@ -68,10 +69,10 @@ public interface WmsItemService { | @@ -68,10 +69,10 @@ public interface WmsItemService { | ||
| 68 | /** | 69 | /** |
| 69 | * 获得商品列表 | 70 | * 获得商品列表 |
| 70 | * | 71 | * |
| 71 | - * @param pageReqVO 查询条件 | 72 | + * @param listReqVO 查询条件 |
| 72 | * @return 商品列表 | 73 | * @return 商品列表 |
| 73 | */ | 74 | */ |
| 74 | - List<WmsItemDO> getItemList(WmsItemPageReqVO pageReqVO); | 75 | + List<WmsItemDO> getItemList(WmsItemListReqVO listReqVO); |
| 75 | 76 | ||
| 76 | /** | 77 | /** |
| 77 | * 按编号集合获得商品列表 | 78 | * 按编号集合获得商品列表 |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/service/md/item/WmsItemServiceImpl.java
| @@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil; | @@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil; | ||
| 4 | import cn.hutool.core.util.ObjectUtil; | 4 | import cn.hutool.core.util.ObjectUtil; |
| 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 6 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 7 | +import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.item.WmsItemListReqVO; | ||
| 7 | import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.item.WmsItemPageReqVO; | 8 | import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.item.WmsItemPageReqVO; |
| 8 | import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.item.WmsItemSaveReqVO; | 9 | import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.item.WmsItemSaveReqVO; |
| 9 | import cn.iocoder.yudao.module.wms.dal.dataobject.md.item.WmsItemDO; | 10 | import cn.iocoder.yudao.module.wms.dal.dataobject.md.item.WmsItemDO; |
| @@ -132,9 +133,9 @@ public class WmsItemServiceImpl implements WmsItemService { | @@ -132,9 +133,9 @@ public class WmsItemServiceImpl implements WmsItemService { | ||
| 132 | } | 133 | } |
| 133 | 134 | ||
| 134 | @Override | 135 | @Override |
| 135 | - public List<WmsItemDO> getItemList(WmsItemPageReqVO pageReqVO) { | ||
| 136 | - return itemMapper.selectList(pageReqVO, | ||
| 137 | - categoryService.getSelfAndChildItemCategoryIdList(pageReqVO.getCategoryId())); | 136 | + public List<WmsItemDO> getItemList(WmsItemListReqVO listReqVO) { |
| 137 | + return itemMapper.selectList(listReqVO, | ||
| 138 | + categoryService.getSelfAndChildItemCategoryIdList(listReqVO.getCategoryId())); | ||
| 138 | } | 139 | } |
| 139 | 140 | ||
| 140 | @Override | 141 | @Override |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/service/md/merchant/WmsMerchantService.java
| 1 | package cn.iocoder.yudao.module.wms.service.md.merchant; | 1 | package cn.iocoder.yudao.module.wms.service.md.merchant; |
| 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.module.wms.controller.admin.md.merchant.vo.WmsMerchantListReqVO; | ||
| 4 | import cn.iocoder.yudao.module.wms.controller.admin.md.merchant.vo.WmsMerchantPageReqVO; | 5 | import cn.iocoder.yudao.module.wms.controller.admin.md.merchant.vo.WmsMerchantPageReqVO; |
| 5 | import cn.iocoder.yudao.module.wms.controller.admin.md.merchant.vo.WmsMerchantSaveReqVO; | 6 | import cn.iocoder.yudao.module.wms.controller.admin.md.merchant.vo.WmsMerchantSaveReqVO; |
| 6 | import cn.iocoder.yudao.module.wms.dal.dataobject.md.merchant.WmsMerchantDO; | 7 | import cn.iocoder.yudao.module.wms.dal.dataobject.md.merchant.WmsMerchantDO; |
| @@ -86,10 +87,10 @@ public interface WmsMerchantService { | @@ -86,10 +87,10 @@ public interface WmsMerchantService { | ||
| 86 | /** | 87 | /** |
| 87 | * 获得往来企业列表 | 88 | * 获得往来企业列表 |
| 88 | * | 89 | * |
| 89 | - * @param pageReqVO 查询条件 | 90 | + * @param listReqVO 查询条件 |
| 90 | * @return 往来企业列表 | 91 | * @return 往来企业列表 |
| 91 | */ | 92 | */ |
| 92 | - List<WmsMerchantDO> getMerchantList(WmsMerchantPageReqVO pageReqVO); | 93 | + List<WmsMerchantDO> getMerchantList(WmsMerchantListReqVO listReqVO); |
| 93 | 94 | ||
| 94 | /** | 95 | /** |
| 95 | * 按编号集合获得往来企业列表 | 96 | * 按编号集合获得往来企业列表 |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/service/md/merchant/WmsMerchantServiceImpl.java
| @@ -5,6 +5,7 @@ import cn.hutool.core.collection.ListUtil; | @@ -5,6 +5,7 @@ import cn.hutool.core.collection.ListUtil; | ||
| 5 | import cn.hutool.core.util.ObjectUtil; | 5 | import cn.hutool.core.util.ObjectUtil; |
| 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 7 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 8 | +import cn.iocoder.yudao.module.wms.controller.admin.md.merchant.vo.WmsMerchantListReqVO; | ||
| 8 | import cn.iocoder.yudao.module.wms.controller.admin.md.merchant.vo.WmsMerchantPageReqVO; | 9 | import cn.iocoder.yudao.module.wms.controller.admin.md.merchant.vo.WmsMerchantPageReqVO; |
| 9 | import cn.iocoder.yudao.module.wms.controller.admin.md.merchant.vo.WmsMerchantSaveReqVO; | 10 | import cn.iocoder.yudao.module.wms.controller.admin.md.merchant.vo.WmsMerchantSaveReqVO; |
| 10 | import cn.iocoder.yudao.module.wms.dal.dataobject.md.merchant.WmsMerchantDO; | 11 | import cn.iocoder.yudao.module.wms.dal.dataobject.md.merchant.WmsMerchantDO; |
| @@ -119,8 +120,8 @@ public class WmsMerchantServiceImpl implements WmsMerchantService { | @@ -119,8 +120,8 @@ public class WmsMerchantServiceImpl implements WmsMerchantService { | ||
| 119 | } | 120 | } |
| 120 | 121 | ||
| 121 | @Override | 122 | @Override |
| 122 | - public List<WmsMerchantDO> getMerchantList(WmsMerchantPageReqVO pageReqVO) { | ||
| 123 | - return merchantMapper.selectList(pageReqVO); | 123 | + public List<WmsMerchantDO> getMerchantList(WmsMerchantListReqVO listReqVO) { |
| 124 | + return merchantMapper.selectList(listReqVO); | ||
| 124 | } | 125 | } |
| 125 | 126 | ||
| 126 | @Override | 127 | @Override |
yudao-module-wms/src/test/java/cn/iocoder/yudao/module/wms/service/md/item/WmsItemBrandServiceImplTest.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.wms.service.md.item; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | ||
| 4 | +import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.brand.WmsItemBrandSaveReqVO; | ||
| 5 | +import cn.iocoder.yudao.module.wms.dal.dataobject.md.item.WmsItemBrandDO; | ||
| 6 | +import cn.iocoder.yudao.module.wms.dal.mysql.md.item.WmsItemBrandMapper; | ||
| 7 | +import jakarta.annotation.Resource; | ||
| 8 | +import org.junit.jupiter.api.Test; | ||
| 9 | +import org.springframework.context.annotation.Import; | ||
| 10 | +import org.springframework.test.context.bean.override.mockito.MockitoBean; | ||
| 11 | + | ||
| 12 | +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; | ||
| 13 | +import static cn.iocoder.yudao.module.wms.enums.ErrorCodeConstants.ITEM_BRAND_NAME_DUPLICATE; | ||
| 14 | + | ||
| 15 | +@Import(WmsItemBrandServiceImpl.class) | ||
| 16 | +public class WmsItemBrandServiceImplTest extends BaseDbUnitTest { | ||
| 17 | + | ||
| 18 | + @Resource | ||
| 19 | + private WmsItemBrandServiceImpl brandService; | ||
| 20 | + | ||
| 21 | + @Resource | ||
| 22 | + private WmsItemBrandMapper brandMapper; | ||
| 23 | + | ||
| 24 | + @MockitoBean | ||
| 25 | + private WmsItemService itemService; | ||
| 26 | + | ||
| 27 | + @Test | ||
| 28 | + public void testCreateItemBrand_nameDuplicate() { | ||
| 29 | + // mock 数据 | ||
| 30 | + brandMapper.insert(createBrand("B001", "华为")); | ||
| 31 | + WmsItemBrandSaveReqVO reqVO = createBrandSaveReqVO(null, "B002", "华为"); | ||
| 32 | + | ||
| 33 | + // 调用,并断言 | ||
| 34 | + assertServiceException(() -> brandService.createItemBrand(reqVO), ITEM_BRAND_NAME_DUPLICATE); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + @Test | ||
| 38 | + public void testUpdateItemBrand_nameDuplicate() { | ||
| 39 | + // mock 数据 | ||
| 40 | + brandMapper.insert(createBrand("B001", "华为")); | ||
| 41 | + WmsItemBrandDO brand = createBrand("B002", "小米"); | ||
| 42 | + brandMapper.insert(brand); | ||
| 43 | + WmsItemBrandSaveReqVO reqVO = createBrandSaveReqVO(brand.getId(), "B002", "华为"); | ||
| 44 | + | ||
| 45 | + // 调用,并断言 | ||
| 46 | + assertServiceException(() -> brandService.updateItemBrand(reqVO), ITEM_BRAND_NAME_DUPLICATE); | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + private static WmsItemBrandDO createBrand(String code, String name) { | ||
| 50 | + return WmsItemBrandDO.builder() | ||
| 51 | + .code(code) | ||
| 52 | + .name(name) | ||
| 53 | + .build(); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + private static WmsItemBrandSaveReqVO createBrandSaveReqVO(Long id, String code, String name) { | ||
| 57 | + WmsItemBrandSaveReqVO reqVO = new WmsItemBrandSaveReqVO(); | ||
| 58 | + reqVO.setId(id); | ||
| 59 | + reqVO.setCode(code); | ||
| 60 | + reqVO.setName(name); | ||
| 61 | + return reqVO; | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | +} |