于继渤 1 år sedan
förälder
incheckning
f671189927
1 ändrade filer med 114 tillägg och 168 borttagningar
  1. 114 168
      src/main/java/com/dk/mdm/mapper/ivt/InboundItemMapper.xml

+ 114 - 168
src/main/java/com/dk/mdm/mapper/ivt/InboundItemMapper.xml

@@ -739,6 +739,38 @@
 
     <select id="selectCostCheckList" resultType="map">
         SELECT
+        A."skuModel",
+        A."skuName",
+        A."skuId",
+        A."costPrice",
+        A."costAmt",
+        A."brandId",
+        A."skuImages",
+        A."brandName",
+        A."shortName",
+        json_agg (
+        json_build_object (
+        'itemId', A."itemId",
+        'intoId', A."intoId",
+        'outId', A."outId",
+        'invId', A."invId",
+        'fromId', A."fromId",
+        'fromItemId', A."fromItemId",
+        'skuModel', A."skuModel",
+        'skuName', A."skuName",
+        'skuId', A."skuId",
+        'intoQty', A."intoQty",
+        'costPrice', A."costPrice",
+        'costAmt', A."costAmt",
+        'brandId', A."brandId",
+        'skuImages', A."skuImages",
+        'brandName', A."brandName",
+        'shortName', A."shortName"
+        )
+        ) AS "itemList"
+        FROM
+        (
+        SELECT
         tpii.sku_model AS "skuModel",
         tpii.sku_name AS "skuName",
         tpii.sku_id AS "skuId",
@@ -748,38 +780,13 @@
         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"
+        tpii.item_id AS "itemId",
+        tpii.into_id AS "intoId",
+        NULL AS "outId",
+        tpii.inv_id AS "invId",
+        tpii.from_id AS "fromId",
+        tpii.from_item_id AS "fromItemId",
+        tpii.into_qty AS "intoQty"
         FROM
         dkic_b.t_psi_inbound_item tpii
         LEFT JOIN dkic_b.t_psi_inbound tpi ON tpi.into_id = tpii.into_id
@@ -825,18 +832,9 @@
                 )
             </if>
         </where>
-        GROUP BY
-        tpii.sku_model,
-        tpii.sku_name,
-        tpii.sku_id,
-        tpii.cost_price,
-        tpii.cost_amt,
-        tmgs.brand_id,
-        tmgs.sku_images,
-        tmgb.brand_name,
-        tmgb.short_name
 
         UNION ALL
+
         SELECT
         tpoi.sku_model AS "skuModel",
         tpoi.sku_name AS "skuName",
@@ -847,44 +845,18 @@
         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"
+        tpoi.item_id AS "itemId",
+        NULL AS "intoId",
+        tpoi.out_id AS "outId",
+        tpoi.inv_id AS "invId",
+        tpoi.from_id AS "fromId",
+        tpoi.from_item_id AS "fromItemId",
+        tpoi.out_qty AS "intoQty"
         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
@@ -910,16 +882,17 @@
                 )
             </if>
         </where>
+        ) AS A
         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
+        A."skuModel",
+        A."skuName",
+        A."skuId",
+        A."costPrice",
+        A."costAmt",
+        A."brandId",
+        A."skuImages",
+        A."brandName",
+        A."shortName"
         <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
             limit #{end} offset #{start}
         </if>
@@ -930,6 +903,38 @@
         SELECT COUNT(1) from
         (
         SELECT
+        A."skuModel",
+        A."skuName",
+        A."skuId",
+        A."costPrice",
+        A."costAmt",
+        A."brandId",
+        A."skuImages",
+        A."brandName",
+        A."shortName",
+        json_agg (
+        json_build_object (
+        'itemId', A."itemId",
+        'intoId', A."intoId",
+        'outId', A."outId",
+        'invId', A."invId",
+        'fromId', A."fromId",
+        'fromItemId', A."fromItemId",
+        'skuModel', A."skuModel",
+        'skuName', A."skuName",
+        'skuId', A."skuId",
+        'intoQty', A."intoQty",
+        'costPrice', A."costPrice",
+        'costAmt', A."costAmt",
+        'brandId', A."brandId",
+        'skuImages', A."skuImages",
+        'brandName', A."brandName",
+        'shortName', A."shortName"
+        )
+        ) AS "itemList"
+        FROM
+        (
+        SELECT
         tpii.sku_model AS "skuModel",
         tpii.sku_name AS "skuName",
         tpii.sku_id AS "skuId",
@@ -939,38 +944,13 @@
         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"
+        tpii.item_id AS "itemId",
+        tpii.into_id AS "intoId",
+        NULL AS "outId",
+        tpii.inv_id AS "invId",
+        tpii.from_id AS "fromId",
+        tpii.from_item_id AS "fromItemId",
+        tpii.into_qty AS "intoQty"
         FROM
         dkic_b.t_psi_inbound_item tpii
         LEFT JOIN dkic_b.t_psi_inbound tpi ON tpi.into_id = tpii.into_id
@@ -1016,18 +996,9 @@
                 )
             </if>
         </where>
-        GROUP BY
-        tpii.sku_model,
-        tpii.sku_name,
-        tpii.sku_id,
-        tpii.cost_price,
-        tpii.cost_amt,
-        tmgs.brand_id,
-        tmgs.sku_images,
-        tmgb.brand_name,
-        tmgb.short_name
 
         UNION ALL
+
         SELECT
         tpoi.sku_model AS "skuModel",
         tpoi.sku_name AS "skuName",
@@ -1038,44 +1009,18 @@
         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"
+        tpoi.item_id AS "itemId",
+        NULL AS "intoId",
+        tpoi.out_id AS "outId",
+        tpoi.inv_id AS "invId",
+        tpoi.from_id AS "fromId",
+        tpoi.from_item_id AS "fromItemId",
+        tpoi.out_qty AS "intoQty"
         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
@@ -1101,16 +1046,17 @@
                 )
             </if>
         </where>
+        ) AS A
         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"
+        A."skuModel",
+        A."skuName",
+        A."skuId",
+        A."costPrice",
+        A."costAmt",
+        A."brandId",
+        A."skuImages",
+        A."brandName",
+        A."shortName") AS B
     </select>
 
 </mapper>