feat(stock): 增加顶级父产品id查询入库、出库记录功能
| | |
| | | package com.ruoyi.stock.dto; |
| | | |
| | | import com.ruoyi.stock.pojo.StockInRecord; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | |
| | |
| | | //现存量 |
| | | private String currentStock; |
| | | |
| | | @Schema(description = "顶部父产品id") |
| | | private Long topParentProductId; |
| | | |
| | | } |
| | |
| | | package com.ruoyi.stock.dto; |
| | | |
| | | import com.ruoyi.stock.pojo.StockOutRecord; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | |
| | | private String timeStr; |
| | | |
| | | private String createBy; |
| | | |
| | | @Schema(description = "顶部父产品id") |
| | | private Long topParentProductId; |
| | | } |
| | |
| | | <mapper namespace="com.ruoyi.stock.mapper.StockInRecordMapper"> |
| | | |
| | | <select id="listPage" resultType="com.ruoyi.stock.dto.StockInRecordDto"> |
| | | WITH RECURSIVE product_tree AS ( |
| | | SELECT id |
| | | FROM product |
| | | WHERE id = #{params.topParentProductId} |
| | | |
| | | UNION ALL |
| | | |
| | | SELECT p.id |
| | | FROM product p |
| | | INNER JOIN product_tree pt ON p.parent_id = pt.id |
| | | ) |
| | | SELECT |
| | | sir.*, |
| | | p.product_name as product_name, |
| | |
| | | <if test="params.recordType != null and params.recordType != ''"> |
| | | and sir.record_type = #{params.recordType} |
| | | </if> |
| | | <if test="params.topParentProductId != null and params.topParentProductId > 0"> |
| | | and p.id in (select id from product_tree) |
| | | </if> |
| | | </where> |
| | | order by sir.id desc |
| | | </select> |
| | |
| | | </resultMap> |
| | | |
| | | <select id="listPage" resultType="com.ruoyi.stock.dto.StockOutRecordDto"> |
| | | WITH RECURSIVE product_tree AS ( |
| | | SELECT id |
| | | FROM product |
| | | WHERE id = #{params.topParentProductId} |
| | | |
| | | UNION ALL |
| | | |
| | | SELECT p.id |
| | | FROM product p |
| | | INNER JOIN product_tree pt ON p.parent_id = pt.id |
| | | ) |
| | | SELECT |
| | | sor.*, |
| | | p.product_name as productName, |
| | |
| | | <if test="params.recordType != null and params.recordType != ''"> |
| | | and sor.record_type = #{params.recordType} |
| | | </if> |
| | | <if test="params.topParentProductId != null and params.topParentProductId > 0"> |
| | | and p.id in (select id from product_tree) |
| | | </if> |
| | | </where> |
| | | order by sor.id desc |
| | | </select> |