|
@@ -312,8 +312,8 @@
|
|
|
FROM dkic_b.t_psi_inventory tpi
|
|
FROM dkic_b.t_psi_inventory tpi
|
|
|
<include refid="Join_Table"/>
|
|
<include refid="Join_Table"/>
|
|
|
<where>
|
|
<where>
|
|
|
- (tmgs.warning_lower_limit <> 0 OR tmgs.warning_upper_limit <> 0)
|
|
|
|
|
- AND (tpi.inv_qty > tmgs.warning_lower_limit OR tpi.inv_qty > tmgs.warning_upper_limit)
|
|
|
|
|
|
|
+ (tmgs.warning_lower_limit <> 0 AND tpi.inv_qty < tmgs.warning_lower_limit)
|
|
|
|
|
+ OR (tmgs.warning_upper_limit <> 0 AND tpi.inv_qty > tmgs.warning_upper_limit)
|
|
|
<if test="whId != null and whId != ''">
|
|
<if test="whId != null and whId != ''">
|
|
|
AND tpi.wh_id = #{whId}::UUID
|
|
AND tpi.wh_id = #{whId}::UUID
|
|
|
</if>
|
|
</if>
|
|
@@ -374,64 +374,25 @@
|
|
|
|
|
|
|
|
<select id="warningSelectByCond" resultType="com.dk.mdm.model.response.ivt.InventoryResponse">
|
|
<select id="warningSelectByCond" resultType="com.dk.mdm.model.response.ivt.InventoryResponse">
|
|
|
SELECT
|
|
SELECT
|
|
|
- <include refid="Base_Column_List_Response"/>
|
|
|
|
|
- ,tmgs.sku_code
|
|
|
|
|
- ,tmgs.sku_model
|
|
|
|
|
|
|
+ SUM(sys.f_remove_zero(tpi.inv_qty)) as inv_qty
|
|
|
,tmgs.sku_name
|
|
,tmgs.sku_name
|
|
|
,tmgs.sku_spec
|
|
,tmgs.sku_spec
|
|
|
- ,tmgs.price_purchase
|
|
|
|
|
- ,tmgs.price_standard
|
|
|
|
|
- ,tmgs.price_wholesale
|
|
|
|
|
- ,tmgs.price_other
|
|
|
|
|
- ,tmgs.price_limited
|
|
|
|
|
- ,tmgs.sku_images
|
|
|
|
|
,tmgs.unit_id
|
|
,tmgs.unit_id
|
|
|
|
|
+ ,tmgs.sku_model
|
|
|
,tmgs.sub_unit_id
|
|
,tmgs.sub_unit_id
|
|
|
,tmgs.warning_upper_limit
|
|
,tmgs.warning_upper_limit
|
|
|
,tmgs.warning_lower_limit
|
|
,tmgs.warning_lower_limit
|
|
|
,tmgs.pack_box
|
|
,tmgs.pack_box
|
|
|
,tmu.unit_name AS "unitName"
|
|
,tmu.unit_name AS "unitName"
|
|
|
,subtmu.unit_name AS "subUnitName"
|
|
,subtmu.unit_name AS "subUnitName"
|
|
|
- ,tmgs.flg_sub_unit
|
|
|
|
|
- ,tmgb.brand_name
|
|
|
|
|
- ,tmgb.short_name
|
|
|
|
|
- ,tmw.wh_name
|
|
|
|
|
- ,tmgc.cat_name as "catName"
|
|
|
|
|
- ,tmgseries.series_name as "seriesName"
|
|
|
|
|
,tmu.decimal_places as "decimalPlaces"
|
|
,tmu.decimal_places as "decimalPlaces"
|
|
|
FROM dkic_b.t_psi_inventory tpi
|
|
FROM dkic_b.t_psi_inventory tpi
|
|
|
- <include refid="Join_Table"/>
|
|
|
|
|
|
|
+ left join dkic_b.t_mst_goods_sku tmgs on tmgs.sku_id = tpi.sku_id
|
|
|
|
|
+ LEFT JOIN dkic_b.t_mst_unit tmu ON tmu.unit_id = tmgs.unit_id
|
|
|
|
|
+ LEFT JOIN dkic_b.t_mst_unit subtmu ON subtmu.unit_id = tmgs.sub_unit_id
|
|
|
<where>
|
|
<where>
|
|
|
- (tmgs.warning_lower_limit <> 0 OR tmgs.warning_upper_limit <> 0)
|
|
|
|
|
- AND (tpi.inv_qty > tmgs.warning_lower_limit OR tpi.inv_qty > tmgs.warning_upper_limit)
|
|
|
|
|
- <if test="whId != null and whId != ''">
|
|
|
|
|
- AND tpi.wh_id = #{whId}::UUID
|
|
|
|
|
- </if>
|
|
|
|
|
- <if test="whIds != null and whIds.size()>0">
|
|
|
|
|
- AND tpi.wh_id =
|
|
|
|
|
- any(#{whIds, typeHandler=UuidListTypeHandler})
|
|
|
|
|
- </if>
|
|
|
|
|
- <if test="skuId != null and skuId != ''">
|
|
|
|
|
- AND tpi.sku_id = #{skuId}
|
|
|
|
|
- </if>
|
|
|
|
|
- <if test="nonStdCode != null and nonStdCode != ''">
|
|
|
|
|
- AND tpi.non_std_code = #{nonStdCode}
|
|
|
|
|
- </if>
|
|
|
|
|
- <if test="invQty != null">
|
|
|
|
|
- AND tpi.inv_qty = #{invQty}
|
|
|
|
|
- </if>
|
|
|
|
|
- <if test="outingQty != null">
|
|
|
|
|
- AND tpi.outing_qty = #{outingQty}
|
|
|
|
|
- </if>
|
|
|
|
|
- <if test="usableQty != null">
|
|
|
|
|
- AND tpi.usable_qty = #{usableQty}
|
|
|
|
|
- </if>
|
|
|
|
|
- <if test="costPrice != null">
|
|
|
|
|
- AND tpi.cost_price = #{costPrice}
|
|
|
|
|
- </if>
|
|
|
|
|
- <if test="costAmt != null">
|
|
|
|
|
- AND tpi.cost_amt = #{costAmt}
|
|
|
|
|
- </if>
|
|
|
|
|
|
|
+ (tmgs.warning_lower_limit <> 0 AND tpi.inv_qty < tmgs.warning_lower_limit)
|
|
|
|
|
+ OR (tmgs.warning_upper_limit <> 0 AND tpi.inv_qty > tmgs.warning_upper_limit)
|
|
|
<if test="flgValid != null">
|
|
<if test="flgValid != null">
|
|
|
AND tpi.flg_valid = #{flgValid}
|
|
AND tpi.flg_valid = #{flgValid}
|
|
|
</if>
|
|
</if>
|
|
@@ -441,9 +402,6 @@
|
|
|
<if test="cpId != null">
|
|
<if test="cpId != null">
|
|
|
AND tpi.cp_id = #{cpId}
|
|
AND tpi.cp_id = #{cpId}
|
|
|
</if>
|
|
</if>
|
|
|
- <if test="freezeQty != null">
|
|
|
|
|
- AND tpi.freeze_qty = #{freezeQty}
|
|
|
|
|
- </if>
|
|
|
|
|
<if test="categoryId != null and categoryId != ''">
|
|
<if test="categoryId != null and categoryId != ''">
|
|
|
AND tmgs.category_id = #{categoryId}::UUID
|
|
AND tmgs.category_id = #{categoryId}::UUID
|
|
|
</if>
|
|
</if>
|
|
@@ -460,12 +418,19 @@
|
|
|
and tpi.inv_qty != 0
|
|
and tpi.inv_qty != 0
|
|
|
</if>
|
|
</if>
|
|
|
</where>
|
|
</where>
|
|
|
- <if test="desc != null and desc != ''">
|
|
|
|
|
- order by tpi.usable_qty desc
|
|
|
|
|
- </if>
|
|
|
|
|
- <if test="desc == null or desc == ''">
|
|
|
|
|
- order by tpi.usable_qty
|
|
|
|
|
- </if>
|
|
|
|
|
|
|
+ group by
|
|
|
|
|
+ tmgs.sku_name
|
|
|
|
|
+ ,tmgs.sku_spec
|
|
|
|
|
+ ,tmgs.unit_id
|
|
|
|
|
+ ,tmgs.sku_model
|
|
|
|
|
+ ,tmgs.sub_unit_id
|
|
|
|
|
+ ,tmgs.warning_upper_limit
|
|
|
|
|
+ ,tmgs.warning_lower_limit
|
|
|
|
|
+ ,tmgs.pack_box
|
|
|
|
|
+ ,tmu.unit_name
|
|
|
|
|
+ ,subtmu.unit_name
|
|
|
|
|
+ ,tmgs.flg_sub_unit
|
|
|
|
|
+ ,tmu.decimal_places
|
|
|
<if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
|
|
<if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
|
|
|
limit #{end} offset #{start}
|
|
limit #{end} offset #{start}
|
|
|
</if>
|
|
</if>
|