Commit 3a38a69fa549ea645219ef9f098aedf9f6e3c822
1 parent
d8f9f0d0
feat(wms):调整 check 的实现
Showing
4 changed files
with
227 additions
and
0 deletions
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/item/WmsItemSkuController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.wms.controller.admin.md.item; | |
| 2 | + | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 6 | +import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | |
| 7 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 8 | +import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.sku.WmsItemSkuPageReqVO; | |
| 9 | +import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.sku.WmsItemSkuRespVO; | |
| 10 | +import cn.iocoder.yudao.module.wms.dal.dataobject.md.item.WmsItemBrandDO; | |
| 11 | +import cn.iocoder.yudao.module.wms.dal.dataobject.md.item.WmsItemCategoryDO; | |
| 12 | +import cn.iocoder.yudao.module.wms.dal.dataobject.md.item.WmsItemDO; | |
| 13 | +import cn.iocoder.yudao.module.wms.dal.dataobject.md.item.WmsItemSkuDO; | |
| 14 | +import cn.iocoder.yudao.module.wms.service.md.item.WmsItemBrandService; | |
| 15 | +import cn.iocoder.yudao.module.wms.service.md.item.WmsItemCategoryService; | |
| 16 | +import cn.iocoder.yudao.module.wms.service.md.item.WmsItemService; | |
| 17 | +import cn.iocoder.yudao.module.wms.service.md.item.WmsItemSkuService; | |
| 18 | +import io.swagger.v3.oas.annotations.Operation; | |
| 19 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 20 | +import jakarta.annotation.Resource; | |
| 21 | +import jakarta.validation.Valid; | |
| 22 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 23 | +import org.springframework.validation.annotation.Validated; | |
| 24 | +import org.springframework.web.bind.annotation.GetMapping; | |
| 25 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 26 | +import org.springframework.web.bind.annotation.RestController; | |
| 27 | + | |
| 28 | +import java.util.Collections; | |
| 29 | +import java.util.List; | |
| 30 | +import java.util.Map; | |
| 31 | + | |
| 32 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 33 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | |
| 34 | + | |
| 35 | +/** | |
| 36 | + * WMS 商品 SKU Controller。 | |
| 37 | + * | |
| 38 | + * <p>SKU 维度的查询入口:弹窗 / 选择器场景使用,按 SKU 一行展开,支持商品 / 品牌 / 分类多表联查筛选。 | |
| 39 | + * 复用商品权限 {@code wms:item:query},不单独建权限点(lite 也是商品/SKU 共用 {@code wms:item:list})。 | |
| 40 | + * | |
| 41 | + * <p>SKU 的新增 / 修改 / 删除仍随商品弹窗一并维护,不在本 Controller 暴露。 | |
| 42 | + */ | |
| 43 | +@Tag(name = "管理后台 - WMS 商品 SKU") | |
| 44 | +@RestController | |
| 45 | +@RequestMapping("/wms/item-sku") | |
| 46 | +@Validated | |
| 47 | +public class WmsItemSkuController { | |
| 48 | + | |
| 49 | + @Resource | |
| 50 | + private WmsItemSkuService itemSkuService; | |
| 51 | + @Resource | |
| 52 | + private WmsItemService itemService; | |
| 53 | + @Resource | |
| 54 | + private WmsItemCategoryService categoryService; | |
| 55 | + @Resource | |
| 56 | + private WmsItemBrandService brandService; | |
| 57 | + | |
| 58 | + @GetMapping("/page") | |
| 59 | + @Operation(summary = "获得商品 SKU 分页", description = "按 SKU 维度分页,支持商品 / 品牌 / 分类多表联查筛选") | |
| 60 | + @PreAuthorize("@ss.hasPermission('wms:item:query')") | |
| 61 | + public CommonResult<PageResult<WmsItemSkuRespVO>> getItemSkuPage(@Valid WmsItemSkuPageReqVO pageReqVO) { | |
| 62 | + PageResult<WmsItemSkuDO> pageResult = itemSkuService.getItemSkuPage(pageReqVO); | |
| 63 | + return success(new PageResult<>(buildItemSkuRespVOList(pageResult.getList()), pageResult.getTotal())); | |
| 64 | + } | |
| 65 | + | |
| 66 | + // ==================== 拼接 VO ==================== | |
| 67 | + | |
| 68 | + private List<WmsItemSkuRespVO> buildItemSkuRespVOList(List<WmsItemSkuDO> list) { | |
| 69 | + if (CollUtil.isEmpty(list)) { | |
| 70 | + return Collections.emptyList(); | |
| 71 | + } | |
| 72 | + // 查询关联数据 | |
| 73 | + Map<Long, WmsItemDO> itemMap = itemService.getItemMap(convertSet(list, WmsItemSkuDO::getItemId)); | |
| 74 | + Map<Long, WmsItemCategoryDO> categoryMap = categoryService.getItemCategoryMap( | |
| 75 | + convertSet(itemMap.values(), WmsItemDO::getCategoryId)); | |
| 76 | + Map<Long, WmsItemBrandDO> brandMap = brandService.getItemBrandMap( | |
| 77 | + convertSet(itemMap.values(), WmsItemDO::getBrandId)); | |
| 78 | + // 拼接 VO | |
| 79 | + return BeanUtils.toBean(list, WmsItemSkuRespVO.class, vo -> MapUtils.findAndThen(itemMap, vo.getItemId(), item -> { | |
| 80 | + vo.setItemCode(item.getCode()).setItemName(item.getName()).setUnit(item.getUnit()) | |
| 81 | + .setCategoryId(item.getCategoryId()).setBrandId(item.getBrandId()); | |
| 82 | + MapUtils.findAndThen(categoryMap, item.getCategoryId(), category -> | |
| 83 | + vo.setCategoryName(category.getName())); | |
| 84 | + MapUtils.findAndThen(brandMap, item.getBrandId(), brand -> | |
| 85 | + vo.setBrandName(brand.getName())); | |
| 86 | + })); | |
| 87 | + } | |
| 88 | + | |
| 89 | +} | ... | ... |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/controller/admin/md/item/vo/sku/WmsItemSkuPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.sku; | |
| 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 = "管理后台 - WMS 商品 SKU 分页 Request VO") | |
| 10 | +@Data | |
| 11 | +@EqualsAndHashCode(callSuper = true) | |
| 12 | +@ToString(callSuper = true) | |
| 13 | +public class WmsItemSkuPageReqVO extends PageParam { | |
| 14 | + | |
| 15 | + @Schema(description = "商品编号", example = "I00000001") | |
| 16 | + private String itemCode; | |
| 17 | + | |
| 18 | + @Schema(description = "商品名称", example = "华为 nova flip") | |
| 19 | + private String itemName; | |
| 20 | + | |
| 21 | + @Schema(description = "商品分类编号", example = "1") | |
| 22 | + private Long categoryId; | |
| 23 | + | |
| 24 | + @Schema(description = "商品品牌编号", example = "1") | |
| 25 | + private Long brandId; | |
| 26 | + | |
| 27 | + @Schema(description = "规格编号", example = "S00000001") | |
| 28 | + private String code; | |
| 29 | + | |
| 30 | + @Schema(description = "规格名称", example = "黑色") | |
| 31 | + private String name; | |
| 32 | + | |
| 33 | + @Schema(description = "条码", example = "12345678") | |
| 34 | + private String barCode; | |
| 35 | + | |
| 36 | +} | ... | ... |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/dal/mysql/md/item/WmsItemSkuMapper.java
| 1 | 1 | package cn.iocoder.yudao.module.wms.dal.mysql.md.item; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | 5 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | 6 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 7 | +import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; | |
| 8 | +import cn.iocoder.yudao.module.wms.controller.admin.md.item.vo.sku.WmsItemSkuPageReqVO; | |
| 9 | +import cn.iocoder.yudao.module.wms.dal.dataobject.md.item.WmsItemDO; | |
| 6 | 10 | import cn.iocoder.yudao.module.wms.dal.dataobject.md.item.WmsItemSkuDO; |
| 7 | 11 | import org.apache.ibatis.annotations.Mapper; |
| 8 | 12 | |
| ... | ... | @@ -18,6 +22,27 @@ import java.util.List; |
| 18 | 22 | @Mapper |
| 19 | 23 | public interface WmsItemSkuMapper extends BaseMapperX<WmsItemSkuDO> { |
| 20 | 24 | |
| 25 | + /** | |
| 26 | + * 按 SKU 维度分页查询,支持商品 / 品牌 / 分类多表联查筛选。 | |
| 27 | + * | |
| 28 | + * 使用 {@link MPJLambdaWrapperX} 替代 lite 的手写 XML JOIN(见 lite | |
| 29 | + * {@code ItemSkuMapper.selectByBo}),范式参照本模块 {@code WmsInventoryMapper.selectPage}。 | |
| 30 | + */ | |
| 31 | + default PageResult<WmsItemSkuDO> selectPage(WmsItemSkuPageReqVO reqVO) { | |
| 32 | + MPJLambdaWrapperX<WmsItemSkuDO> query = new MPJLambdaWrapperX<WmsItemSkuDO>() | |
| 33 | + .selectAll(WmsItemSkuDO.class) | |
| 34 | + .innerJoin(WmsItemDO.class, WmsItemDO::getId, WmsItemSkuDO::getItemId) | |
| 35 | + .likeIfPresent(WmsItemDO::getCode, reqVO.getItemCode()) | |
| 36 | + .likeIfPresent(WmsItemDO::getName, reqVO.getItemName()) | |
| 37 | + .eqIfPresent(WmsItemDO::getCategoryId, reqVO.getCategoryId()) | |
| 38 | + .eqIfPresent(WmsItemDO::getBrandId, reqVO.getBrandId()) | |
| 39 | + .likeIfPresent(WmsItemSkuDO::getCode, reqVO.getCode()) | |
| 40 | + .likeIfPresent(WmsItemSkuDO::getName, reqVO.getName()) | |
| 41 | + .likeIfPresent(WmsItemSkuDO::getBarCode, reqVO.getBarCode()) | |
| 42 | + .orderByDesc(WmsItemSkuDO::getId); | |
| 43 | + return selectJoinPage(reqVO, WmsItemSkuDO.class, query); | |
| 44 | + } | |
| 45 | + | |
| 21 | 46 | default List<WmsItemSkuDO> selectListByItemId(Long itemId) { |
| 22 | 47 | return selectList(new LambdaQueryWrapperX<WmsItemSkuDO>() |
| 23 | 48 | .eq(WmsItemSkuDO::getItemId, itemId) | ... | ... |
yudao-module-wms/src/main/java/cn/iocoder/yudao/module/wms/service/inventory/dto/WmsInventoryCheckReqDTO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.wms.service.inventory.dto; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.wms.enums.order.WmsOrderTypeEnum; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +import java.math.BigDecimal; | |
| 7 | +import java.util.List; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * WMS 库存盘点请求 DTO | |
| 11 | + * | |
| 12 | + * @author 芋道源码 | |
| 13 | + */ | |
| 14 | +@Data | |
| 15 | +public class WmsInventoryCheckReqDTO { | |
| 16 | + | |
| 17 | + /** | |
| 18 | + * 单据编号 | |
| 19 | + */ | |
| 20 | + private Long orderId; | |
| 21 | + /** | |
| 22 | + * 单据号 | |
| 23 | + */ | |
| 24 | + private String orderNo; | |
| 25 | + /** | |
| 26 | + * 单据类型 | |
| 27 | + * | |
| 28 | + * 枚举 {@link WmsOrderTypeEnum#getType()} | |
| 29 | + */ | |
| 30 | + private Integer orderType; | |
| 31 | + | |
| 32 | + /** | |
| 33 | + * 库存盘点明细 | |
| 34 | + */ | |
| 35 | + private List<Item> items; | |
| 36 | + | |
| 37 | + /** | |
| 38 | + * WMS 库存盘点明细 | |
| 39 | + */ | |
| 40 | + @Data | |
| 41 | + public static class Item { | |
| 42 | + | |
| 43 | + /** | |
| 44 | + * 库存编号 | |
| 45 | + */ | |
| 46 | + private Long inventoryId; | |
| 47 | + /** | |
| 48 | + * SKU 编号 | |
| 49 | + */ | |
| 50 | + private Long skuId; | |
| 51 | + /** | |
| 52 | + * 仓库编号 | |
| 53 | + */ | |
| 54 | + private Long warehouseId; | |
| 55 | + /** | |
| 56 | + * 账面数量 | |
| 57 | + */ | |
| 58 | + private BigDecimal quantity; | |
| 59 | + /** | |
| 60 | + * 实盘数量 | |
| 61 | + */ | |
| 62 | + private BigDecimal checkQuantity; | |
| 63 | + | |
| 64 | + // ========= 单价备注相关字段 ========= | |
| 65 | + | |
| 66 | + /** | |
| 67 | + * 单价 | |
| 68 | + */ | |
| 69 | + private BigDecimal price; | |
| 70 | + /** | |
| 71 | + * 备注 | |
| 72 | + */ | |
| 73 | + private String remark; | |
| 74 | + | |
| 75 | + } | |
| 76 | + | |
| 77 | +} | ... | ... |