仓库管理,查询统计-库存明细查询 库存汇总查询 字典 关联查询

This commit is contained in:
liuhanqing
2025-06-27 11:15:03 +08:00
parent b01cff21d9
commit 2736aa6fb4
12 changed files with 365 additions and 180 deletions

View File

@@ -3,7 +3,7 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.search.StockSummary.mapper.StockSummaryMapper">
<resultMap type="StockSummary" id="StockSummaryResult">
<result property="onlyIdentity" column="only_identity" />
<result property="productId" column="product_id" />
@@ -12,7 +12,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="unit" column="unit" />
<result property="lotNo" column="lot_no" />
<result property="warehouseId" column="warehouse_id" />
<result property="roadwayId" column="roadway_id" />
<result property="warehouseName" column="warehouse_name" />
<result property="quantity" column="quantity" />
<result property="price" column="price" />
<result property="spare1" column="spare1" />
@@ -22,10 +22,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="spare7" column="spare7" />
<result property="spare8" column="spare8" />
<result property="remark" column="remark" />
<result property="cargoSpaceId" column="cargo_space_id" />
<result property="cargoSpaceName" column="cargo_space_name" />
</resultMap>
<sql id="selectStockSummaryVo">
SELECT
SELECT
<choose>
<when test="groupByProductId != null and groupByProductId or groupByProductName != null and groupByProductName or groupBySpec != null and groupBySpec or groupByUnit != null and groupByUnit or groupByLotNo != null and groupByLotNo or groupByWarehouseId != null and groupByWarehouseId or groupByRoadwayId != null and groupByRoadwayId or groupByPrice != null and groupByPrice or groupBySpare1 != null and groupBySpare1 or groupBySpare2 != null and groupBySpare2 or groupBySpare5 != null and groupBySpare5 or groupBySpare6 != null and groupBySpare6 or groupBySpare7 != null and groupBySpare7 or groupBySpare8 != null and groupBySpare8">
<if test="groupByProductId != null and groupByProductId">p.product_id,</if>
@@ -41,10 +43,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="groupByUnit != null and groupByUnit">p.unit,</if>
<if test="groupByLotNo != null and groupByLotNo">s.lot_no,</if>
<if test="groupByWarehouseId != null and groupByWarehouseId">s.warehouse_id,</if>
<if test="groupByRoadwayId != null and groupByRoadwayId">s.cargo_space_id as roadway_id,</if>
<if test="groupByWarehouseId != null and groupByWarehouseId">bw.warehouse_name,</if>
<if test="groupByCargoSpaceId != null and groupByCargoSpaceId">s.cargo_space_id,</if>
<if test="groupByCargoSpaceId != null and groupByCargoSpaceId">bcs.cargo_space_name,</if>
SUM(CAST(s.quantity AS DECIMAL(18,2))) as quantity
FROM bas_stock s
LEFT JOIN bas_product p ON s.product_id = p.product_id
LEFT JOIN bas_warehouse bw ON bw.warehouse_id = s.warehouse_id
LEFT JOIN bas_cargo_space bcs ON bcs.cargo_space_id = s.cargo_space_id
<where>
<if test="productId != null and productId != ''"> AND p.product_id like concat('%', #{productId}, '%')</if>
<if test="productName != null and productName != ''"> AND p.product_name like concat('%', #{productName}, '%')</if>
@@ -60,7 +66,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remark != null and remark != ''"> AND p.spare7 like concat('%', #{remark}, '%')}</if>
<if test="lotNo != null and lotNo != ''"> AND s.lot_no like concat('%', #{lotNo}, '%')</if>
<if test="warehouseId != null and warehouseId != ''"> AND s.warehouse_id like concat('%', #{warehouseId}, '%')</if>
<if test="roadwayId != null and roadwayId != ''"> AND s.cargo_space_id like concat('%', #{roadwayId}, '%')</if>
<if test="cargoSpaceId != null and cargoSpaceId != ''"> AND s.cargo_space_id like concat('%', #{roadwayId}, '%')</if>
<if test="params.warehouseDataScope != null and params.warehouseDataScope !=''">
${params.warehouseDataScope}
</if>
@@ -80,7 +86,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="groupBySpare7 != null and groupBySpare7">,p.spare7</if>
<if test="groupByLotNo != null and groupByLotNo">,s.lot_no</if>
<if test="groupByWarehouseId != null and groupByWarehouseId">,s.warehouse_id</if>
<if test="groupByRoadwayId != null and groupByRoadwayId">,s.cargo_space_id</if>
<if test="groupByWarehouseId != null and groupByWarehouseId">,bw.warehouse_name</if>
<if test="groupByCargoSpaceId != null and groupByCargoSpaceId">,s.cargo_space_id</if>
<if test="groupByCargoSpaceId != null and groupByCargoSpaceId">,bcs.cargo_space_name</if>
</trim>
</when>
<otherwise>
@@ -115,12 +123,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectStockSummaryList" parameterType="StockSummary" resultMap="StockSummaryResult">
<include refid="selectStockSummaryVo"/>
</select>
<select id="selectStockSummaryByOnlyIdentity" parameterType="Long" resultMap="StockSummaryResult">
<include refid="selectStockSummaryVo"/>
where only_identity = #{onlyIdentity}
</select>
<insert id="insertStockSummary" parameterType="StockSummary">
insert into stock_summary
<trim prefix="(" suffix=")" suffixOverrides=",">
@@ -191,9 +199,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<delete id="deleteStockSummaryByOnlyIdentitys" parameterType="String">
delete from stock_summary where only_identity in
delete from stock_summary where only_identity in
<foreach item="onlyIdentity" collection="array" open="(" separator="," close=")">
#{onlyIdentity}
</foreach>
</delete>
</mapper>
</mapper>

View File

@@ -3,7 +3,7 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.search.ViewStockDetail.mapper.ViewStockDetailMapper">
<resultMap type="ViewStockDetail" id="ViewStockDetailResult">
<result property="onlyIdentity" column="only_identity" />
<result property="stockId" column="stock_id" />
@@ -32,15 +32,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="spare7" column="spare7" />
<result property="spare8" column="spare8" />
<result property="remark" column="remark" />
<result property="warehouseName" column="warehouse_name" />
<result property="stockStatus" column="stock_status" />
<result property="productStatus" column="product_status" />
</resultMap>
<sql id="selectViewStockDetailVo">
select only_identity, stock_id, cargo_space_id, tray_code, quantity, job_id, lot_no, stockin_detail_id, in_date, warehouse_id, stacking_id, cargo_space_name, roadway_id, cargo_space_status, locked, product_id, product_name, spec, unit, price, remark,spare1,spare2,spare5,spare6,spare7,spare8 from view_stock_detail
select only_identity,stock_status,product_status, stock_id, cargo_space_id, tray_code, quantity, job_id, lot_no, stockin_detail_id, in_date, warehouse_id, stacking_id, cargo_space_name, roadway_id, cargo_space_status, locked, product_id, product_name, spec, unit, price, remark,spare1,spare2,spare5,spare6,spare7,spare8,warehouse_name from view_stock_detail
</sql>
<select id="selectViewStockDetailList" parameterType="ViewStockDetail" resultMap="ViewStockDetailResult">
<include refid="selectViewStockDetailVo"/>
<where>
<where>
<if test="onlyIdentity != null "> and only_identity = #{onlyIdentity}</if>
<if test="stockId != null and stockId != ''"> and stock_id like concat('%', #{stockId}, '%')</if>
<if test="cargoSpaceId != null and cargoSpaceId != ''"> and cargo_space_id like concat('%', #{cargoSpaceId}, '%')</if>
@@ -67,12 +70,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="spare6 != null and spare6 != ''"> and spare6 like concat('%', #{spare6}, '%')</if>
<if test="spare7 != null and spare7 != ''"> and spare7 like concat('%', #{spare7}, '%')</if>
<if test="spare8 != null and spare8 != ''"> and spare8 like concat('%', #{spare8}, '%')</if>
<if test="warehouseName != null and warehouseName != ''"> and warehouse_name like concat('%', #{warehouseName}, '%')</if>
<if test="stockStatus != null and stockStatus != ''"> and stock_status like concat('%', #{stockStatus}, '%')</if>
<if test="productStatus != null and productStatus != ''"> and product_status like concat('%', #{productStatus}, '%')</if>
<if test="params.warehouseDataScope != null and params.warehouseDataScope !=''">
${params.warehouseDataScope}
</if>
</where>
</select>
<select id="selectViewStockDetailByOnlyIdentity" parameterType="Long" resultMap="ViewStockDetailResult">
<include refid="selectViewStockDetailVo"/>
where only_identity = #{onlyIdentity}
@@ -178,9 +184,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<delete id="deleteViewStockDetailByOnlyIdentitys" parameterType="String">
delete from view_stock_detail where only_identity in
delete from view_stock_detail where only_identity in
<foreach item="onlyIdentity" collection="array" open="(" separator="," close=")">
#{onlyIdentity}
</foreach>
</delete>
</mapper>
</mapper>

View File

@@ -53,8 +53,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="barCodeOldQuantity != null and barCodeOldQuantity != ''"> and bar_code_old_quantity = #{barCodeOldQuantity}</if>
<if test="barCodeQuantity != null and barCodeQuantity != ''"> and bar_code_quantity = #{barCodeQuantity}</if>
<if test="productGuid != null and productGuid != ''"> and product_guid = #{productGuid}</if>
order by create_time desc
</where>
order by create_time desc
</select>
<select id="selectBasStockMaintainRecordByWhGuid" parameterType="String" resultMap="BasStockMaintainRecordResult">