于继渤 1 rok pred
rodič
commit
7feca0b390

+ 142 - 9
src/main/java/com/dk/mdm/mapper/ivt/InboundItemMapper.xml

@@ -815,6 +815,10 @@
                 AND tpii.into_status =
                 any(#{intoStatusList, typeHandler= StringListTypeHandler})
             </if>
+            <if test="skuIdFlag !=null and skuIdFlag == true">
+                AND tpii.sku_id is null
+            </if>
+
             <if test="searchText !=null">
                 AND  (tpii.sku_model LIKE concat('%',my_ex.likequery(#{searchText}), '%')
                 OR   tpii.sku_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
@@ -897,6 +901,9 @@
             <if test="intoDateEnd != null">
                 AND tpo.out_date &lt; #{intoDateEnd}::timestamp with time zone + interval '1 day'
             </if>
+            <if test="skuIdFlag !=null and skuIdFlag == true">
+                AND tpoi.sku_id is null
+            </if>
             <if test="searchText !=null">
                 AND  (tpii.sku_model LIKE concat('%',my_ex.likequery(#{searchText}), '%')
                 OR   tpii.sku_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
@@ -920,20 +927,60 @@
     </select>
 
     <select id="countByCondList" resultType="Long">
-        SELECT COUNT
-        ( 1 )
-        FROM (
-        SELECT COUNT
-        ( 1 )
+        SELECT COUNT(1) from
+        (
+        SELECT
+        tpii.sku_model AS "skuModel",
+        tpii.sku_name AS "skuName",
+        tpii.sku_id AS "skuId",
+        tpii.cost_price AS "costPrice",
+        tpii.cost_amt AS "costAmt",
+        tmgs.brand_id AS "brandId",
+        tmgs.sku_images AS "skuImages",
+        tmgb.brand_name AS "brandName",
+        tmgb.short_name AS "shortName",
+        json_agg (
+        json_build_object (
+        'itemId',
+        tpii.item_id,
+        'intoId',
+        tpii.into_id,
+        'outId',
+        NULL,
+        'invId',
+        tpii.inv_id,
+        'fromId',
+        tpii.from_id,
+        'fromItemId',
+        tpii.from_item_id,
+        'skuModel',
+        tpii.sku_model,
+        'skuName',
+        tpii.sku_name,
+        'skuId',
+        tpii.sku_id,
+        'intoQty',
+        tpii.into_qty,
+        'costPrice',
+        tpii.cost_price,
+        'costAmt',
+        tpii.cost_amt,
+        'brandId',
+        tmgs.brand_id,
+        'fromItemId',
+        tpii.from_item_id
+        )
+        ) AS "itemList"
         FROM
         dkic_b.t_psi_inbound_item tpii
         LEFT JOIN dkic_b.t_psi_inbound tpi ON tpi.into_id = tpii.into_id
         LEFT JOIN dkic_b.t_mst_goods_sku tmgs ON tmgs.sku_id = tpii.sku_id
-        left join dkic_b.t_mst_goods_brand tmgb on tmgb.brand_id = tmgs.brand_id
+        LEFT JOIN dkic_b.t_mst_goods_brand tmgb ON tmgb.brand_id = tmgs.brand_id
         <where>
             tpii.cost_price = 0
             AND tpii.into_qty != 0
-            AND tpii.sku_model is not null
+            AND tpii.sku_model IS NOT NULL
+            AND tpii.into_type != '入库类型-采退入库'
             <if test="intoId != null and intoId != ''">
                 AND tpii.into_id = #{intoId}::uuid
             </if>
@@ -955,11 +1002,14 @@
             <if test="staffName !=null">
                 AND tmss.staff_name  LIKE concat('%',my_ex.likequery(#{staffName}),'%')
             </if>
-
             <if test="intoStatusList != null and intoStatusList.size()>0">
                 AND tpii.into_status =
                 any(#{intoStatusList, typeHandler= StringListTypeHandler})
             </if>
+            <if test="skuIdFlag !=null and skuIdFlag == true">
+                AND tpii.sku_id is null
+            </if>
+
             <if test="searchText !=null">
                 AND  (tpii.sku_model LIKE concat('%',my_ex.likequery(#{searchText}), '%')
                 OR   tpii.sku_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
@@ -975,9 +1025,92 @@
         tmgs.brand_id,
         tmgs.sku_images,
         tmgb.brand_name,
-        tmgb.short_name ) AS "a"
+        tmgb.short_name
 
+        UNION ALL
+        SELECT
+        tpoi.sku_model AS "skuModel",
+        tpoi.sku_name AS "skuName",
+        tpoi.sku_id AS "skuId",
+        tpoi.cost_price AS "costPrice",
+        tpoi.cost_amt AS "costAmt",
+        tmgs.brand_id AS "brandId",
+        tmgs.sku_images AS "skuImages",
+        tmgb.brand_name AS "brandName",
+        tmgb.short_name AS "shortName",
+        json_agg (
+        json_build_object (
+        'itemId',
+        tpoi.item_id,
+        'intoId',
+        NULL,
+        'outId',
+        tpoi.out_id,
+        'invId',
+        tpoi.inv_id,
+        'fromId',
+        tpoi.from_id,
+        'fromItemId',
+        tpoi.from_item_id,
+        'skuModel',
+        tpoi.sku_model,
+        'skuName',
+        tpoi.sku_name,
+        'skuId',
+        tpoi.sku_id,
+        'intoQty',
+        tpoi.out_qty,
+        'costPrice',
+        tpoi.cost_price,
+        'costAmt',
+        tpoi.cost_amt,
+        'brandId',
+        tmgs.brand_id,
+        'fromItemId',
+        tpoi.from_item_id
+        )
+        ) AS "itemList"
+        FROM
+        dkic_b.t_psi_outbound_item tpoi
+        LEFT JOIN dkic_b.t_psi_outbound tpo ON tpo.out_id = tpoi.out_id
+        LEFT JOIN dkic_b.t_mst_goods_sku tmgs ON tmgs.sku_id = tpoi.sku_id
+        LEFT JOIN dkic_b.t_mst_goods_brand tmgb ON tmgb.brand_id = tmgs.brand_id
 
+        <where>
+            tpoi.cost_price = 0
+            AND tpoi.out_qty != 0
+            AND tpoi.sku_model IS NOT NULL
+            <if test="outId != null and outId != ''">
+                AND tpoi.out_id = #{outId}::uuid
+            </if>
+            <if test="cpId != null">
+                AND tpoi.cp_id = #{cpId}
+            </if>
+            <if test="intoDateStart != null">
+                AND tpo.out_date &gt;= #{intoDateStart}::timestamp with time zone
+            </if>
+            <if test="intoDateEnd != null">
+                AND tpo.out_date &lt; #{intoDateEnd}::timestamp with time zone + interval '1 day'
+            </if>
+            <if test="skuIdFlag !=null and skuIdFlag == true">
+                AND tpoi.sku_id is null
+            </if>
+            <if test="searchText !=null">
+                AND  (tpii.sku_model LIKE concat('%',my_ex.likequery(#{searchText}), '%')
+                OR   tpii.sku_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
+                )
+            </if>
+        </where>
+        GROUP BY
+        tpoi.sku_model,
+        tpoi.sku_name,
+        tpoi.sku_id,
+        tpoi.cost_price,
+        tpoi.cost_amt,
+        tmgs.brand_id,
+        tmgs.sku_images,
+        tmgb.brand_name,
+        tmgb.short_name) AS "a"
     </select>
 
 </mapper>

+ 1 - 0
src/main/java/com/dk/mdm/model/query/ivt/InboundItemQuery.java

@@ -337,6 +337,7 @@ public class InboundItemQuery extends PageInfo<InboundItemQuery>  {
     @ApiModelProperty(value = "品牌ID")
     private String brandId;
 
+    private Boolean skuIdFlag;
     private static final long serialVersionUID = 1L;
 
 }