|
|
|
|
@@ -6,239 +6,144 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
|
|
|
|
|
|
<resultMap type="StockSummary" id="StockSummaryResult">
|
|
|
|
|
<result property="onlyIdentity" column="only_identity" />
|
|
|
|
|
<result property="stockId" column="stock_id" />
|
|
|
|
|
<result property="cargoSpaceId" column="cargo_space_id" />
|
|
|
|
|
<result property="quantity" column="quantity" />
|
|
|
|
|
<result property="productId" column="product_id" />
|
|
|
|
|
<result property="productName" column="product_name" />
|
|
|
|
|
<result property="orderId" column="order_id" />
|
|
|
|
|
<result property="spec" column="spec" />
|
|
|
|
|
<result property="unit" column="unit" />
|
|
|
|
|
<result property="lotNo" column="lot_no" />
|
|
|
|
|
<result property="warehouseId" column="warehouse_id" />
|
|
|
|
|
<result property="warehouseName" column="warehouse_name" />
|
|
|
|
|
<result property="quantity" column="quantity" />
|
|
|
|
|
<result property="price" column="price" />
|
|
|
|
|
<result property="roadwayId" column="roadway_id" />
|
|
|
|
|
<result property="parentId" column="parent_id" />
|
|
|
|
|
<result property="price" column="price" />
|
|
|
|
|
<result property="cargoNo" column="cargo_no" />
|
|
|
|
|
<result property="unit" column="unit" />
|
|
|
|
|
<result property="spec" column="spec" />
|
|
|
|
|
<result property="remark" column="remark" />
|
|
|
|
|
<result property="spare1" column="spare1" />
|
|
|
|
|
<result property="spare2" column="spare2" />
|
|
|
|
|
<result property="spare3" column="spare3" />
|
|
|
|
|
<result property="spare4" column="spare4" />
|
|
|
|
|
<result property="spare5" column="spare5" />
|
|
|
|
|
<result property="spare6" column="spare6" />
|
|
|
|
|
<result property="spare7" column="spare7" />
|
|
|
|
|
<result property="spare8" column="spare8" />
|
|
|
|
|
<result property="spare9" column="spare9" />
|
|
|
|
|
<result property="spare10" column="spare10" />
|
|
|
|
|
<result property="spare11" column="spare11" />
|
|
|
|
|
<result property="spare12" column="spare12" />
|
|
|
|
|
<result property="spare13" column="spare13" />
|
|
|
|
|
<result property="spare14" column="spare14" />
|
|
|
|
|
<result property="spare15" column="spare15" />
|
|
|
|
|
<result property="spare16" column="spare16" />
|
|
|
|
|
<result property="spare17" column="spare17" />
|
|
|
|
|
<result property="spare18" column="spare18" />
|
|
|
|
|
<result property="spare19" column="spare19" />
|
|
|
|
|
<result property="spare20" column="spare20" />
|
|
|
|
|
<result property="spare21" column="spare21" />
|
|
|
|
|
<result property="spare22" column="spare22" />
|
|
|
|
|
<result property="spare23" column="spare23" />
|
|
|
|
|
<result property="spare24" column="spare24" />
|
|
|
|
|
<result property="spare25" column="spare25" />
|
|
|
|
|
<result property="spare26" column="spare26" />
|
|
|
|
|
<result property="spare27" column="spare27" />
|
|
|
|
|
<result property="spare28" column="spare28" />
|
|
|
|
|
<result property="spare29" column="spare29" />
|
|
|
|
|
<result property="spare30" column="spare30" />
|
|
|
|
|
<result property="spare31" column="spare31" />
|
|
|
|
|
<result property="spare32" column="spare32" />
|
|
|
|
|
<result property="spare33" column="spare33" />
|
|
|
|
|
<result property="spare34" column="spare34" />
|
|
|
|
|
<result property="spare35" column="spare35" />
|
|
|
|
|
<result property="spare36" column="spare36" />
|
|
|
|
|
<result property="spare37" column="spare37" />
|
|
|
|
|
<result property="spare38" column="spare38" />
|
|
|
|
|
<result property="spare39" column="spare39" />
|
|
|
|
|
<result property="remark" column="remark" />
|
|
|
|
|
<result property="cargoSpaceId" column="cargo_space_id" />
|
|
|
|
|
<result property="cargoSpaceName" column="cargo_space_name" />
|
|
|
|
|
<result property="status" column="status" />
|
|
|
|
|
<result property="locked" column="locked" />
|
|
|
|
|
|
|
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
|
|
<sql id="selectStockSummaryVo">
|
|
|
|
|
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 groupByCargoSpaceId != null and groupByCargoSpaceId or groupByPrice != null and groupByPrice or groupByParentId != null and groupByParentId or groupByCargoNo != null and groupByCargoNo or groupBySpare1 != null and groupBySpare1 or groupBySpare2 != null and groupBySpare2 or groupBySpare3 != null and groupBySpare3 or groupBySpare4 != null and groupBySpare4 or groupBySpare5 != null and groupBySpare5 or groupBySpare6 != null and groupBySpare6 or groupBySpare7 != null and groupBySpare7 or groupBySpare8 != null and groupBySpare8 or groupBySpare9 != null and groupBySpare9 or groupBySpare10 != null and groupBySpare10">
|
|
|
|
|
<if test="groupByProductId != null and groupByProductId">p.product_id,</if>
|
|
|
|
|
<if test="groupByProductName != null and groupByProductName">p.product_name,</if>
|
|
|
|
|
<if test="groupByOrderId != null and groupByOrderId">s.order_id,</if>
|
|
|
|
|
<if test="groupBySpec != null and groupBySpec">p.spec,</if>
|
|
|
|
|
<if test="groupByUnit != null and groupByUnit">p.unit,</if>
|
|
|
|
|
<if test="groupByPrice != null and groupByPrice">p.price,</if>
|
|
|
|
|
<when test="groupByCargoSpaceId != null and groupByCargoSpaceId or groupByProductId != null and groupByProductId or groupByProductName != null and groupByProductName or groupByParentId != null and groupByParentId or groupByPrice != null and groupByPrice or groupBycCargoNo != null and groupBycCargoNo or groupByUnit != null and groupByUnit or groupBySpec != null and groupBySpec or groupBySpare1 != null and groupBySpare1 or groupBySpare3 != null and groupBySpare3 or groupBySpare4 != null and groupBySpare4 or groupBySpare5 != null and groupBySpare5 or groupBySpare6 != null and groupBySpare6 or groupBySpare7 != null and groupBySpare7 or groupByCargoSpaceName != null and groupByCargoSpaceName or groupByStatus != null and groupByStatus or groupByLocked != null and groupByLocked ">
|
|
|
|
|
MIN(s.stock_id) as stock_id,
|
|
|
|
|
<if test="groupByCargoSpaceId != null and groupByCargoSpaceId">s.cargo_space_id,</if>
|
|
|
|
|
<if test="groupByProductId != null and groupByProductId">s.product_id,</if>
|
|
|
|
|
<if test="groupByProductName != null and groupByProductName">s.product_name,</if>
|
|
|
|
|
<if test="groupByParentId != null and groupByParentId">p.parent_id,</if>
|
|
|
|
|
<if test="groupByCargoNo != null and groupByCargoNo">p.cargo_no,</if>
|
|
|
|
|
<if test="groupByPrice != null and groupByPrice">p.price,</if>
|
|
|
|
|
<if test="groupBycCargoNo != null and groupBycCargoNo">p.cargo_no,</if>
|
|
|
|
|
<if test="groupByUnit != null and groupByUnit">p.unit,</if>
|
|
|
|
|
<if test="groupBySpec != null and groupBySpec">p.spec,</if>
|
|
|
|
|
<if test="groupBySpare1 != null and groupBySpare1">p.spare1,</if>
|
|
|
|
|
<if test="groupBySpare2 != null and groupBySpare2">p.spare2,</if>
|
|
|
|
|
<if test="groupBySpare3 != null and groupBySpare3">p.spare3,</if>
|
|
|
|
|
<if test="groupBySpare4 != null and groupBySpare4">p.spare4,</if>
|
|
|
|
|
<if test="groupBySpare5 != null and groupBySpare5">p.spare5,</if>
|
|
|
|
|
<if test="groupBySpare6 != null and groupBySpare6">p.spare6,</if>
|
|
|
|
|
<if test="groupBySpare7 != null and groupBySpare7">p.spare7,</if>
|
|
|
|
|
<if test="groupBySpare8 != null and groupBySpare8">p.spare8,</if>
|
|
|
|
|
<if test="groupBySpare9 != null and groupBySpare9">p.spare9,</if>
|
|
|
|
|
<if test="groupBySpare10 != null and groupBySpare10">p.spare10,</if>
|
|
|
|
|
<if test="groupByLotNo != null and groupByLotNo">s.lot_no,</if>
|
|
|
|
|
<if test="groupByWarehouseId != null and groupByWarehouseId">s.warehouse_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>
|
|
|
|
|
<if test="groupByRoadwayId != null and groupByRoadwayId">bcs.roadway_id,</if>
|
|
|
|
|
<if test="groupByCargoSpaceName != null and groupByCargoSpaceName">bcs.cargo_space_name,</if>
|
|
|
|
|
<if test="groupByStatus != null and groupByStatus">bcs.status,</if>
|
|
|
|
|
<if test="groupByLocked != null and groupByLocked">bcs.locked,</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>
|
|
|
|
|
AND p.product_id IS NOT NULL AND p.product_id != ''
|
|
|
|
|
<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>
|
|
|
|
|
<if test="orderId != null and orderId != ''"> AND s.order_id like concat('%', #{orderId}, '%')</if>
|
|
|
|
|
<if test="spec != null and spec != ''"> AND p.spec like concat('%', #{spec}, '%')</if>
|
|
|
|
|
<if test="unit != null and unit != ''"> AND p.unit like concat('%', #{unit}, '%')</if>
|
|
|
|
|
<if test="price != null and price != ''"> AND p.price like concat('%', #{price}, '%')</if>
|
|
|
|
|
<if test="spare1 != null and spare1 != ''"> AND p.spare1 like concat('%', #{spare1}, '%')</if>
|
|
|
|
|
<if test="spare2 != null and spare2 != ''"> AND p.spare2 like concat('%', #{spare2}, '%')</if>
|
|
|
|
|
<if test="spare5 != null and spare5 != ''"> AND p.spare5 like concat('%', #{spare5}, '%')</if>
|
|
|
|
|
<if test="spare6 != null and spare6 != ''"> AND p.spare6 like concat('%', #{spare6}, '%')</if>
|
|
|
|
|
<if test="spare8 != null and spare8 != ''"> AND p.spare8 like concat('%', #{spare8}, '%')</if>
|
|
|
|
|
<if test="spare7 != null and spare7 != ''"> AND p.spare7 like concat('%', #{spare7}, '%')</if>
|
|
|
|
|
<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="stockId != null and stockId != ''"> AND s.stock_id like concat('%', #{stockId}, '%')</if>
|
|
|
|
|
<if test="cargoSpaceId != null and cargoSpaceId != ''"> AND s.cargo_space_id like concat('%', #{cargoSpaceId}, '%')</if>
|
|
|
|
|
<if test="cargoSpaceName != null and cargoSpaceName != ''"> AND bcs.cargo_space_name like concat('%', #{cargoSpaceName}, '%')</if>
|
|
|
|
|
<if test="spare9 != null and spare9 != ''"> AND p.spare9 like concat('%', #{spare9}, '%')</if>
|
|
|
|
|
<if test="params.warehouseDataScope != null and params.warehouseDataScope !=''">
|
|
|
|
|
${params.warehouseDataScope}
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
GROUP BY
|
|
|
|
|
<trim prefixOverrides=",">
|
|
|
|
|
<if test="groupByProductId != null and groupByProductId">,p.product_id</if>
|
|
|
|
|
<if test="groupByProductName != null and groupByProductName">,p.product_name</if>
|
|
|
|
|
<if test="groupByOrderId != null and groupByOrderId">,s.order_id</if>
|
|
|
|
|
<if test="groupBySpec != null and groupBySpec">,p.spec</if>
|
|
|
|
|
<if test="groupByUnit != null and groupByUnit">,p.unit</if>
|
|
|
|
|
<if test="groupByPrice != null and groupByPrice">,p.price</if>
|
|
|
|
|
<if test="groupByParentId != null and groupByParentId">,p.parent_id</if>
|
|
|
|
|
<if test="groupByCargoNo != null and groupByCargoNo">,p.cargo_no</if>
|
|
|
|
|
<if test="groupBySpare1 != null and groupBySpare1">,p.spare1</if>
|
|
|
|
|
<if test="groupBySpare2 != null and groupBySpare2">,p.spare2</if>
|
|
|
|
|
<if test="groupBySpare3 != null and groupBySpare3">,p.spare3</if>
|
|
|
|
|
<if test="groupBySpare4 != null and groupBySpare4">,p.spare4</if>
|
|
|
|
|
<if test="groupBySpare5 != null and groupBySpare5">,p.spare5</if>
|
|
|
|
|
<if test="groupBySpare6 != null and groupBySpare6">,p.spare6</if>
|
|
|
|
|
<if test="groupBySpare7 != null and groupBySpare7">,p.spare7</if>
|
|
|
|
|
<if test="groupBySpare8 != null and groupBySpare8">,p.spare8</if>
|
|
|
|
|
<if test="groupBySpare9 != null and groupBySpare9">,p.spare9</if>
|
|
|
|
|
<if test="groupBySpare10 != null and groupBySpare10">,p.spare10</if>
|
|
|
|
|
<if test="groupBySpare11 != null and groupBySpare11">,p.spare11</if>
|
|
|
|
|
<if test="groupBySpare12 != null and groupBySpare12">,p.spare12</if>
|
|
|
|
|
<if test="groupBySpare13 != null and groupBySpare13">,p.spare13</if>
|
|
|
|
|
<if test="groupBySpare14 != null and groupBySpare14">,p.spare14</if>
|
|
|
|
|
<if test="groupBySpare15 != null and groupBySpare15">,p.spare15</if>
|
|
|
|
|
<if test="groupBySpare16 != null and groupBySpare16">,p.spare16</if>
|
|
|
|
|
<if test="groupBySpare17 != null and groupBySpare17">,p.spare17</if>
|
|
|
|
|
<if test="groupBySpare18 != null and groupBySpare18">,p.spare18</if>
|
|
|
|
|
<if test="groupBySpare19 != null and groupBySpare19">,p.spare19</if>
|
|
|
|
|
<if test="groupBySpare20 != null and groupBySpare20">,p.spare20</if>
|
|
|
|
|
<if test="groupBySpare21 != null and groupBySpare21">,p.spare21</if>
|
|
|
|
|
<if test="groupBySpare22 != null and groupBySpare22">,p.spare22</if>
|
|
|
|
|
<if test="groupBySpare23 != null and groupBySpare23">,p.spare23</if>
|
|
|
|
|
<if test="groupBySpare24 != null and groupBySpare24">,p.spare24</if>
|
|
|
|
|
<if test="groupBySpare25 != null and groupBySpare25">,p.spare25</if>
|
|
|
|
|
<if test="groupBySpare26 != null and groupBySpare26">,p.spare26</if>
|
|
|
|
|
<if test="groupBySpare27 != null and groupBySpare27">,p.spare27</if>
|
|
|
|
|
<if test="groupBySpare28 != null and groupBySpare28">,p.spare28</if>
|
|
|
|
|
<if test="groupBySpare29 != null and groupBySpare29">,p.spare29</if>
|
|
|
|
|
<if test="groupBySpare30 != null and groupBySpare30">,p.spare30</if>
|
|
|
|
|
<if test="groupBySpare31 != null and groupBySpare31">,p.spare31</if>
|
|
|
|
|
<if test="groupBySpare32 != null and groupBySpare32">,p.spare32</if>
|
|
|
|
|
<if test="groupBySpare33 != null and groupBySpare33">,p.spare33</if>
|
|
|
|
|
<if test="groupBySpare34 != null and groupBySpare34">,p.spare34</if>
|
|
|
|
|
<if test="groupBySpare35 != null and groupBySpare35">,p.spare35</if>
|
|
|
|
|
<if test="groupBySpare36 != null and groupBySpare36">,p.spare36</if>
|
|
|
|
|
<if test="groupBySpare37 != null and groupBySpare37">,p.spare37</if>
|
|
|
|
|
<if test="groupBySpare38 != null and groupBySpare38">,p.spare38</if>
|
|
|
|
|
<if test="groupBySpare39 != null and groupBySpare39">,p.spare39</if>
|
|
|
|
|
<if test="groupByLotNo != null and groupByLotNo">,s.lot_no</if>
|
|
|
|
|
<if test="groupByWarehouseId != null and groupByWarehouseId">,s.warehouse_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>
|
|
|
|
|
<if test="groupByRoadwayId != null and groupByRoadwayId">,bcs.roadway_id</if>
|
|
|
|
|
</trim>
|
|
|
|
|
</when>
|
|
|
|
|
<otherwise>
|
|
|
|
|
1 as group_all,
|
|
|
|
|
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
|
|
|
|
|
<where>
|
|
|
|
|
AND p.product_id IS NOT NULL AND p.product_id != ''
|
|
|
|
|
<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>
|
|
|
|
|
<if test="orderId != null and orderId != ''"> AND s.order_id like concat('%', #{orderId}, '%')</if>
|
|
|
|
|
<if test="spec != null and spec != ''"> AND p.spec like concat('%', #{spec}, '%')</if>
|
|
|
|
|
<if test="unit != null and unit != ''"> AND p.unit like concat('%', #{unit}, '%')</if>
|
|
|
|
|
<if test="price != null and price != ''"> AND p.price like concat('%', #{price}, '%')</if>
|
|
|
|
|
<if test="productId != null and productId != ''"> AND s.product_id like concat('%', #{productId}, '%')</if>
|
|
|
|
|
<if test="productName != null and productName != ''"> AND s.product_name like concat('%', #{productName}, '%')</if>
|
|
|
|
|
<if test="parentId != null and parentId != ''"> AND p.parent_id like concat('%', #{parentId}, '%')</if>
|
|
|
|
|
<if test="price != null and price != ''"> AND p.price like concat('%', #{price}, '%')</if>
|
|
|
|
|
<if test="cargoNo != null and cargoNo != ''"> AND p.cargo_no like concat('%', #{cargoNo}, '%')</if>
|
|
|
|
|
<if test="unit != null and unit != ''"> AND p.unit like concat('%', #{unit}, '%')</if>
|
|
|
|
|
<if test="spec != null and spec != ''"> AND p.spec like concat('%', #{spec}, '%')</if>
|
|
|
|
|
<if test="remark != null and remark != ''"> AND p.remark like concat('%', #{remark}, '%')</if>
|
|
|
|
|
<if test="spare1 != null and spare1 != ''"> AND p.spare1 like concat('%', #{spare1}, '%')</if>
|
|
|
|
|
<if test="spare2 != null and spare2 != ''"> AND p.spare2 like concat('%', #{spare2}, '%')</if>
|
|
|
|
|
<if test="spare3 != null and spare3 != ''"> AND p.spare3 like concat('%', #{spare3}, '%')</if>
|
|
|
|
|
<if test="spare4 != null and spare4 != ''"> AND p.spare4 like concat('%', #{spare4}, '%')</if>
|
|
|
|
|
<if test="spare5 != null and spare5 != ''"> AND p.spare5 like concat('%', #{spare5}, '%')</if>
|
|
|
|
|
<if test="spare6 != null and spare6 != ''"> AND p.spare6 like concat('%', #{spare6}, '%')</if>
|
|
|
|
|
<if test="spare7 != null and spare7 != ''"> AND p.spare7 like concat('%', #{spare7}, '%')</if>
|
|
|
|
|
<if test="spare8 != null and spare8 != ''"> AND p.spare8 like concat('%', #{spare8}, '%')</if>
|
|
|
|
|
<if test="spare9 != null and spare9 != ''"> AND p.spare9 like concat('%', #{spare9}, '%')</if>
|
|
|
|
|
<if test="spare10 != null and spare10 != ''"> AND p.spare10 like concat('%', #{spare10}, '%')</if>
|
|
|
|
|
<if test="spare11 != null and spare11 != ''"> AND p.spare11 like concat('%', #{spare11}, '%')</if>
|
|
|
|
|
<if test="spare12 != null and spare12 != ''"> AND p.spare12 like concat('%', #{spare12}, '%')</if>
|
|
|
|
|
<if test="spare13 != null and spare13 != ''"> AND p.spare13 like concat('%', #{spare13}, '%')</if>
|
|
|
|
|
<if test="spare14 != null and spare14 != ''"> AND p.spare14 like concat('%', #{spare14}, '%')</if>
|
|
|
|
|
<if test="spare15 != null and spare15 != ''"> AND p.spare15 like concat('%', #{spare15}, '%')</if>
|
|
|
|
|
<if test="spare16 != null and spare16 != ''"> AND p.spare16 like concat('%', #{spare16}, '%')</if>
|
|
|
|
|
<if test="spare17 != null and spare17 != ''"> AND p.spare17 like concat('%', #{spare17}, '%')</if>
|
|
|
|
|
<if test="spare18 != null and spare18 != ''"> AND p.spare18 like concat('%', #{spare18}, '%')</if>
|
|
|
|
|
<if test="spare19 != null and spare19 != ''"> AND p.spare19 like concat('%', #{spare19}, '%')</if>
|
|
|
|
|
<if test="spare20 != null and spare20 != ''"> AND p.spare20 like concat('%', #{spare20}, '%')</if>
|
|
|
|
|
<if test="spare21 != null and spare21 != ''"> AND p.spare21 like concat('%', #{spare21}, '%')</if>
|
|
|
|
|
<if test="spare22 != null and spare22 != ''"> AND p.spare22 like concat('%', #{spare22}, '%')</if>
|
|
|
|
|
<if test="spare23 != null and spare23 != ''"> AND p.spare23 like concat('%', #{spare23}, '%')</if>
|
|
|
|
|
<if test="spare24 != null and spare24 != ''"> AND p.spare24 like concat('%', #{spare24}, '%')</if>
|
|
|
|
|
<if test="spare25 != null and spare25 != ''"> AND p.spare25 like concat('%', #{spare25}, '%')</if>
|
|
|
|
|
<if test="spare26 != null and spare26 != ''"> AND p.spare26 like concat('%', #{spare26}, '%')</if>
|
|
|
|
|
<if test="spare27 != null and spare27 != ''"> AND p.spare27 like concat('%', #{spare27}, '%')</if>
|
|
|
|
|
<if test="spare28 != null and spare28 != ''"> AND p.spare28 like concat('%', #{spare28}, '%')</if>
|
|
|
|
|
<if test="spare29 != null and spare29 != ''"> AND p.spare29 like concat('%', #{spare29}, '%')</if>
|
|
|
|
|
<if test="spare30 != null and spare30 != ''"> AND p.spare30 like concat('%', #{spare30}, '%')</if>
|
|
|
|
|
<if test="spare31 != null and spare31 != ''"> AND p.spare31 like concat('%', #{spare31}, '%')</if>
|
|
|
|
|
<if test="spare32 != null and spare32 != ''"> AND p.spare32 like concat('%', #{spare32}, '%')</if>
|
|
|
|
|
<if test="spare33 != null and spare33 != ''"> AND p.spare33 like concat('%', #{spare33}, '%')</if>
|
|
|
|
|
<if test="spare34 != null and spare34 != ''"> AND p.spare34 like concat('%', #{spare34}, '%')</if>
|
|
|
|
|
<if test="spare35 != null and spare35 != ''"> AND p.spare35 like concat('%', #{spare35}, '%')</if>
|
|
|
|
|
<if test="spare36 != null and spare36 != ''"> AND p.spare36 like concat('%', #{spare36}, '%')</if>
|
|
|
|
|
<if test="spare37 != null and spare37 != ''"> AND p.spare37 like concat('%', #{spare37}, '%')</if>
|
|
|
|
|
<if test="spare38 != null and spare38 != ''"> AND p.spare38 like concat('%', #{spare38}, '%')</if>
|
|
|
|
|
<if test="spare39 != null and spare39 != ''"> AND p.spare39 like concat('%', #{spare39}, '%')</if>
|
|
|
|
|
<if test="remark != null and remark != ''"> AND p.remark 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="cargoSpaceId != null and cargoSpaceId != ''"> AND s.cargo_space_id like concat('%', #{cargoSpaceId}, '%')</if>
|
|
|
|
|
<if test="cargoSpaceName != null and cargoSpaceName != ''"> AND bcs.cargo_space_name like concat('%', #{cargoSpaceName}, '%')</if>
|
|
|
|
|
<if test="params.warehouseDataScope != null and params.warehouseDataScope !=''">
|
|
|
|
|
${params.warehouseDataScope}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="status != null and status != ''"> AND bcs.status like concat('%', #{status}, '%')</if>
|
|
|
|
|
<if test="locked != null and locked != ''"> AND bcs.locked like concat('%', #{locked}, '%')</if>
|
|
|
|
|
</where>
|
|
|
|
|
GROUP BY
|
|
|
|
|
<trim prefixOverrides=",">
|
|
|
|
|
<if test="groupByCargoSpaceId != null and groupByCargoSpaceId">,s.cargo_space_id</if>
|
|
|
|
|
<if test="groupByProductId != null and groupByProductId">,s.product_id</if>
|
|
|
|
|
<if test="groupByProductName != null and groupByProductName">,s.product_name</if>
|
|
|
|
|
<if test="groupByParentId != null and groupByParentId">,p.parent_id</if>
|
|
|
|
|
<if test="groupByPrice != null and groupByPrice">,p.price</if>
|
|
|
|
|
<if test="groupBycCargoNo != null and groupBycCargoNo">,p.cargo_no</if>
|
|
|
|
|
<if test="groupByUnit != null and groupByUnit">,p.unit</if>
|
|
|
|
|
<if test="groupBySpec != null and groupBySpec">,p.spec</if>
|
|
|
|
|
<if test="groupBySpare1 != null and groupBySpare1">,p.spare1</if>
|
|
|
|
|
<if test="groupBySpare3 != null and groupBySpare3">,p.spare3</if>
|
|
|
|
|
<if test="groupBySpare4 != null and groupBySpare4">,p.spare4</if>
|
|
|
|
|
<if test="groupBySpare5 != null and groupBySpare5">,p.spare5</if>
|
|
|
|
|
<if test="groupBySpare6 != null and groupBySpare6">,p.spare6</if>
|
|
|
|
|
<if test="groupBySpare7 != null and groupBySpare7">,p.spare7</if>
|
|
|
|
|
<if test="groupByCargoSpaceName != null and groupByCargoSpaceName">,bcs.cargo_space_name</if>
|
|
|
|
|
<if test="groupByStatus != null and groupByStatus">,bcs.status</if>
|
|
|
|
|
<if test="groupByLocked != null and groupByLocked">,bcs.locked</if>
|
|
|
|
|
</trim>
|
|
|
|
|
</when>
|
|
|
|
|
<otherwise>
|
|
|
|
|
s.stock_id,
|
|
|
|
|
s.cargo_space_id,
|
|
|
|
|
s.product_id,
|
|
|
|
|
s.product_name,
|
|
|
|
|
CAST(s.quantity AS DECIMAL(18,2)) as quantity,
|
|
|
|
|
p.parent_id,
|
|
|
|
|
p.price,
|
|
|
|
|
p.cargo_no,
|
|
|
|
|
p.unit,
|
|
|
|
|
p.spec,
|
|
|
|
|
p.remark,
|
|
|
|
|
p.spare1,
|
|
|
|
|
p.spare3,
|
|
|
|
|
p.spare4,
|
|
|
|
|
p.spare5,
|
|
|
|
|
p.spare6,
|
|
|
|
|
p.spare7,
|
|
|
|
|
bcs.cargo_space_name,
|
|
|
|
|
bcs.status,
|
|
|
|
|
bcs.locked
|
|
|
|
|
FROM bas_stock s
|
|
|
|
|
LEFT JOIN bas_product p ON s.product_id = p.product_id
|
|
|
|
|
LEFT JOIN bas_cargo_space bcs ON bcs.cargo_space_id = s.cargo_space_id
|
|
|
|
|
<where>
|
|
|
|
|
AND p.product_id IS NOT NULL AND p.product_id != ''
|
|
|
|
|
|
|
|
|
|
<if test="stockId != null and stockId != ''"> AND s.stock_id like concat('%', #{stockId}, '%')</if>
|
|
|
|
|
<if test="cargoSpaceId != null and cargoSpaceId != ''"> AND s.cargo_space_id like concat('%', #{cargoSpaceId}, '%')</if>
|
|
|
|
|
<if test="productId != null and productId != ''"> AND p.product_id like concat('%', #{productId}, '%')</if>
|
|
|
|
|
<if test="productName != null and productName != ''"> AND s.product_name like concat('%', #{productName}, '%')</if>
|
|
|
|
|
<if test="parentId != null and parentId != ''"> AND p.parent_id like concat('%', #{parentId}, '%')</if>
|
|
|
|
|
<if test="price != null and price != ''"> AND p.price like concat('%', #{price}, '%')</if>
|
|
|
|
|
<if test="cargoNo != null and cargoNo != ''"> AND p.cargo_no like concat('%', #{cargoNo}, '%')</if>
|
|
|
|
|
<if test="unit != null and unit != ''"> AND p.unit like concat('%', #{unit}, '%')</if>
|
|
|
|
|
<if test="spec != null and spec != ''"> AND p.spec like concat('%', #{spec}, '%')</if>
|
|
|
|
|
<if test="remark != null and remark != ''"> AND p.remark like concat('%', #{remark}, '%')</if>
|
|
|
|
|
<if test="spare1 != null and spare1 != ''"> AND p.spare1 like concat('%', #{spare1}, '%')</if>
|
|
|
|
|
<if test="spare3 != null and spare3 != ''"> AND p.spare3 like concat('%', #{spare3}, '%')</if>
|
|
|
|
|
<if test="spare4 != null and spare4 != ''"> AND p.spare4 like concat('%', #{spare4}, '%')</if>
|
|
|
|
|
<if test="spare5 != null and spare5 != ''"> AND p.spare5 like concat('%', #{spare5}, '%')</if>
|
|
|
|
|
<if test="spare6 != null and spare6 != ''"> AND p.spare6 like concat('%', #{spare6}, '%')</if>
|
|
|
|
|
<if test="spare7 != null and spare7 != ''"> AND p.spare7 like concat('%', #{spare7}, '%')</if>
|
|
|
|
|
<if test="cargoSpaceName != null and cargoSpaceName != ''"> AND bcs.cargo_space_name like concat('%', #{cargoSpaceName}, '%')</if>
|
|
|
|
|
<if test="status != null and status != ''"> AND bcs.status like concat('%', #{status}, '%')</if>
|
|
|
|
|
<if test="locked != null and locked != ''"> AND bcs.locked like concat('%', #{locked}, '%')</if>
|
|
|
|
|
</where>
|
|
|
|
|
</otherwise>
|
|
|
|
|
</choose>
|
|
|
|
|
@@ -253,184 +158,5 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
|
where only_identity = #{onlyIdentity}
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<insert id="insertStockSummary" parameterType="StockSummary">
|
|
|
|
|
insert into stock_summary
|
|
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
|
|
<if test="onlyIdentity != null">only_identity,</if>
|
|
|
|
|
<if test="productId != null and productId != ''">product_id,</if>
|
|
|
|
|
<if test="productName != null">product_name,</if>
|
|
|
|
|
<if test="spec != null">spec,</if>
|
|
|
|
|
<if test="unit != null">unit,</if>
|
|
|
|
|
<if test="price != null">price,</if>
|
|
|
|
|
<if test="parentId != null">parent_id,</if>
|
|
|
|
|
<if test="cargoNo != null">cargo_no,</if>
|
|
|
|
|
<if test="spare1 != null">spare1,</if>
|
|
|
|
|
<if test="spare2 != null">spare2,</if>
|
|
|
|
|
<if test="spare3 != null">spare3,</if>
|
|
|
|
|
<if test="spare4 != null">spare4,</if>
|
|
|
|
|
<if test="spare5 != null">spare5,</if>
|
|
|
|
|
<if test="spare6 != null">spare6,</if>
|
|
|
|
|
<if test="spare7 != null">spare7,</if>
|
|
|
|
|
<if test="spare8 != null">spare8,</if>
|
|
|
|
|
<if test="spare9 != null">spare9,</if>
|
|
|
|
|
<if test="spare10 != null">spare10,</if>
|
|
|
|
|
<if test="spare11 != null">spare11,</if>
|
|
|
|
|
<if test="spare12 != null">spare12,</if>
|
|
|
|
|
<if test="spare13 != null">spare13,</if>
|
|
|
|
|
<if test="spare14 != null">spare14,</if>
|
|
|
|
|
<if test="spare15 != null">spare15,</if>
|
|
|
|
|
<if test="spare16 != null">spare16,</if>
|
|
|
|
|
<if test="spare17 != null">spare17,</if>
|
|
|
|
|
<if test="spare18 != null">spare18,</if>
|
|
|
|
|
<if test="spare19 != null">spare19,</if>
|
|
|
|
|
<if test="spare20 != null">spare20,</if>
|
|
|
|
|
<if test="spare21 != null">spare21,</if>
|
|
|
|
|
<if test="spare22 != null">spare22,</if>
|
|
|
|
|
<if test="spare23 != null">spare23,</if>
|
|
|
|
|
<if test="spare24 != null">spare24,</if>
|
|
|
|
|
<if test="spare25 != null">spare25,</if>
|
|
|
|
|
<if test="spare26 != null">spare26,</if>
|
|
|
|
|
<if test="spare27 != null">spare27,</if>
|
|
|
|
|
<if test="spare28 != null">spare28,</if>
|
|
|
|
|
<if test="spare29 != null">spare29,</if>
|
|
|
|
|
<if test="spare30 != null">spare30,</if>
|
|
|
|
|
<if test="spare31 != null">spare31,</if>
|
|
|
|
|
<if test="spare32 != null">spare32,</if>
|
|
|
|
|
<if test="spare33 != null">spare33,</if>
|
|
|
|
|
<if test="spare34 != null">spare34,</if>
|
|
|
|
|
<if test="spare35 != null">spare35,</if>
|
|
|
|
|
<if test="spare36 != null">spare36,</if>
|
|
|
|
|
<if test="spare37 != null">spare37,</if>
|
|
|
|
|
<if test="spare38 != null">spare38,</if>
|
|
|
|
|
<if test="spare39 != null">spare39,</if>
|
|
|
|
|
<if test="remark != null">remark,</if>
|
|
|
|
|
<if test="lotNo != null">lot_no,</if>
|
|
|
|
|
<if test="warehouseId != null">warehouse_id,</if>
|
|
|
|
|
<if test="cargoSpaceId != null">cargo_space_id,</if>
|
|
|
|
|
<if test="quantity != null">quantity,</if>
|
|
|
|
|
</trim>
|
|
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
|
|
<if test="onlyIdentity != null">#{onlyIdentity},</if>
|
|
|
|
|
<if test="productId != null and productId != ''">#{productId},</if>
|
|
|
|
|
<if test="productName != null">#{productName},</if>
|
|
|
|
|
<if test="spec != null">#{spec},</if>
|
|
|
|
|
<if test="unit != null">#{unit},</if>
|
|
|
|
|
<if test="price != null">#{price},</if>
|
|
|
|
|
<if test="parentId != null">#{parentId},</if>
|
|
|
|
|
<if test="cargoNo != null">#{cargoNo},</if>
|
|
|
|
|
<if test="spare1 != null">#{spare1},</if>
|
|
|
|
|
<if test="spare2 != null">#{spare2},</if>
|
|
|
|
|
<if test="spare3 != null">#{spare3},</if>
|
|
|
|
|
<if test="spare4 != null">#{spare4},</if>
|
|
|
|
|
<if test="spare5 != null">#{spare5},</if>
|
|
|
|
|
<if test="spare6 != null">#{spare6},</if>
|
|
|
|
|
<if test="spare7 != null">#{spare7},</if>
|
|
|
|
|
<if test="spare8 != null">#{spare8},</if>
|
|
|
|
|
<if test="spare9 != null">#{spare9},</if>
|
|
|
|
|
<if test="spare10 != null">#{spare10},</if>
|
|
|
|
|
<if test="spare11 != null">#{spare11},</if>
|
|
|
|
|
<if test="spare12 != null">#{spare12},</if>
|
|
|
|
|
<if test="spare13 != null">#{spare13},</if>
|
|
|
|
|
<if test="spare14 != null">#{spare14},</if>
|
|
|
|
|
<if test="spare15 != null">#{spare15},</if>
|
|
|
|
|
<if test="spare16 != null">#{spare16},</if>
|
|
|
|
|
<if test="spare17 != null">#{spare17},</if>
|
|
|
|
|
<if test="spare18 != null">#{spare18},</if>
|
|
|
|
|
<if test="spare19 != null">#{spare19},</if>
|
|
|
|
|
<if test="spare20 != null">#{spare20},</if>
|
|
|
|
|
<if test="spare21 != null">#{spare21},</if>
|
|
|
|
|
<if test="spare22 != null">#{spare22},</if>
|
|
|
|
|
<if test="spare23 != null">#{spare23},</if>
|
|
|
|
|
<if test="spare24 != null">#{spare24},</if>
|
|
|
|
|
<if test="spare25 != null">#{spare25},</if>
|
|
|
|
|
<if test="spare26 != null">#{spare26},</if>
|
|
|
|
|
<if test="spare27 != null">#{spare27},</if>
|
|
|
|
|
<if test="spare28 != null">#{spare28},</if>
|
|
|
|
|
<if test="spare29 != null">#{spare29},</if>
|
|
|
|
|
<if test="spare30 != null">#{spare30},</if>
|
|
|
|
|
<if test="spare31 != null">#{spare31},</if>
|
|
|
|
|
<if test="spare32 != null">#{spare32},</if>
|
|
|
|
|
<if test="spare33 != null">#{spare33},</if>
|
|
|
|
|
<if test="spare34 != null">#{spare34},</if>
|
|
|
|
|
<if test="spare35 != null">#{spare35},</if>
|
|
|
|
|
<if test="spare36 != null">#{spare36},</if>
|
|
|
|
|
<if test="spare37 != null">#{spare37},</if>
|
|
|
|
|
<if test="spare38 != null">#{spare38},</if>
|
|
|
|
|
<if test="spare39 != null">#{spare39},</if>
|
|
|
|
|
<if test="remark != null">#{remark},</if>
|
|
|
|
|
<if test="lotNo != null">#{lotNo},</if>
|
|
|
|
|
<if test="warehouseId != null">#{warehouseId},</if>
|
|
|
|
|
<if test="cargoSpaceId != null">#{cargoSpaceId},</if>
|
|
|
|
|
<if test="quantity != null">#{quantity},</if>
|
|
|
|
|
</trim>
|
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
<update id="updateStockSummary" parameterType="StockSummary">
|
|
|
|
|
update stock_summary
|
|
|
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
|
|
|
<if test="productId != null and productId != ''">product_id = #{productId},</if>
|
|
|
|
|
<if test="productName != null">product_name = #{productName},</if>
|
|
|
|
|
<if test="spec != null">spec = #{spec},</if>
|
|
|
|
|
<if test="unit != null">unit = #{unit},</if>
|
|
|
|
|
<if test="price != null">price = #{price},</if>
|
|
|
|
|
<if test="parentId != null">parent_id = #{parentId},</if>
|
|
|
|
|
<if test="cargoNo != null">cargo_no = #{cargoNo},</if>
|
|
|
|
|
<if test="spare1 != null">spare1 = #{spare1},</if>
|
|
|
|
|
<if test="spare2 != null">spare2 = #{spare2},</if>
|
|
|
|
|
<if test="spare3 != null">spare3 = #{spare3},</if>
|
|
|
|
|
<if test="spare4 != null">spare4 = #{spare4},</if>
|
|
|
|
|
<if test="spare5 != null">spare5 = #{spare5},</if>
|
|
|
|
|
<if test="spare6 != null">spare6 = #{spare6},</if>
|
|
|
|
|
<if test="spare7 != null">spare7 = #{spare7},</if>
|
|
|
|
|
<if test="spare8 != null">spare8 = #{spare8},</if>
|
|
|
|
|
<if test="spare9 != null">spare9 = #{spare9},</if>
|
|
|
|
|
<if test="spare10 != null">spare10 = #{spare10},</if>
|
|
|
|
|
<if test="spare11 != null">spare11 = #{spare11},</if>
|
|
|
|
|
<if test="spare12 != null">spare12 = #{spare12},</if>
|
|
|
|
|
<if test="spare13 != null">spare13 = #{spare13},</if>
|
|
|
|
|
<if test="spare14 != null">spare14 = #{spare14},</if>
|
|
|
|
|
<if test="spare15 != null">spare15 = #{spare15},</if>
|
|
|
|
|
<if test="spare16 != null">spare16 = #{spare16},</if>
|
|
|
|
|
<if test="spare17 != null">spare17 = #{spare17},</if>
|
|
|
|
|
<if test="spare18 != null">spare18 = #{spare18},</if>
|
|
|
|
|
<if test="spare19 != null">spare19 = #{spare19},</if>
|
|
|
|
|
<if test="spare20 != null">spare20 = #{spare20},</if>
|
|
|
|
|
<if test="spare21 != null">spare21 = #{spare21},</if>
|
|
|
|
|
<if test="spare22 != null">spare22 = #{spare22},</if>
|
|
|
|
|
<if test="spare23 != null">spare23 = #{spare23},</if>
|
|
|
|
|
<if test="spare24 != null">spare24 = #{spare24},</if>
|
|
|
|
|
<if test="spare25 != null">spare25 = #{spare25},</if>
|
|
|
|
|
<if test="spare26 != null">spare26 = #{spare26},</if>
|
|
|
|
|
<if test="spare27 != null">spare27 = #{spare27},</if>
|
|
|
|
|
<if test="spare28 != null">spare28 = #{spare28},</if>
|
|
|
|
|
<if test="spare29 != null">spare29 = #{spare29},</if>
|
|
|
|
|
<if test="spare30 != null">spare30 = #{spare30},</if>
|
|
|
|
|
<if test="spare31 != null">spare31 = #{spare31},</if>
|
|
|
|
|
<if test="spare32 != null">spare32 = #{spare32},</if>
|
|
|
|
|
<if test="spare33 != null">spare33 = #{spare33},</if>
|
|
|
|
|
<if test="spare34 != null">spare34 = #{spare34},</if>
|
|
|
|
|
<if test="spare35 != null">spare35 = #{spare35},</if>
|
|
|
|
|
<if test="spare36 != null">spare36 = #{spare36},</if>
|
|
|
|
|
<if test="spare37 != null">spare37 = #{spare37},</if>
|
|
|
|
|
<if test="spare38 != null">spare38 = #{spare38},</if>
|
|
|
|
|
<if test="spare39 != null">spare39 = #{spare39},</if>
|
|
|
|
|
<if test="remark != null">remark = #{remark},</if>
|
|
|
|
|
<if test="lotNo != null">lot_no = #{lotNo},</if>
|
|
|
|
|
<if test="warehouseId != null">warehouse_id = #{warehouseId},</if>
|
|
|
|
|
<if test="cargoSpaceId != null">cargo_space_id = #{cargoSpaceId},</if>
|
|
|
|
|
<if test="quantity != null">quantity = #{quantity},</if>
|
|
|
|
|
</trim>
|
|
|
|
|
where only_identity = #{onlyIdentity}
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<delete id="deleteStockSummaryByOnlyIdentity" parameterType="Long">
|
|
|
|
|
delete from stock_summary where only_identity = #{onlyIdentity}
|
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
|
|
<delete id="deleteStockSummaryByOnlyIdentitys" parameterType="String">
|
|
|
|
|
delete from stock_summary where only_identity in
|
|
|
|
|
<foreach item="onlyIdentity" collection="array" open="(" separator="," close=")">
|
|
|
|
|
#{onlyIdentity}
|
|
|
|
|
</foreach>
|
|
|
|
|
</delete>
|
|
|
|
|
</mapper>
|
|
|
|
|
|