changhaoning 1 год назад
Родитель
Сommit
db2dc0ba7e

+ 33 - 3
src/main/java/com/dk/mdm/mapper/sale/OrderItemMapper.xml

@@ -336,8 +336,33 @@
                t.piece,
                sys.f_remove_zero(t.item_qty - t.outing_qty - t.out_qty)      as "canOutingQty",
                sys.f_remove_zero(t.item_qty - t.outing_qty - t.out_qty)      as outing_qty,
-               (t.item_qty - t.outing_qty - t.out_qty)/t.pack_box as "outingBox",
-                (t.item_qty - t.outing_qty - t.out_qty)%t.pack_box as "outingPiece",
+--                (t.item_qty - t.outing_qty - t.out_qty)/t.pack_box as "outingBox",
+--                 (t.item_qty - t.outing_qty - t.out_qty)%t.pack_box as "outingPiece",
+
+               case
+                   when t.sub_unit_id ISNULL
+	                then 0
+                   else
+                       floor((T.item_qty - T.outing_qty - T.out_qty) / T.pack_box)
+                   end AS "outingBox",
+
+               case
+                   when t.sub_unit_id ISNULL
+	                then floor(T.item_qty - T.outing_qty - T.out_qty)
+                   else
+                       floor((T.item_qty - T.outing_qty - T.out_qty) % T.pack_box)
+                   end AS "outingPiece",
+
+               case
+                   when t.sub_unit_id ISNULL
+	                then dkic_b.f_box_piece(u2.unit_name, ul.unit_name, 0,
+                                            floor(T.item_qty - T.outing_qty - T.out_qty)::INT)
+                   else
+                       dkic_b.f_box_piece(u2.unit_name, ul.unit_name,
+                                          floor((T.item_qty - T.outing_qty - T.out_qty) / T.pack_box)::INT,
+                                          floor((T.item_qty - T.outing_qty - T.out_qty) % T.pack_box)::INT)
+                   end AS "thisOutBoxPiece",
+
                t.price_sale                               as "priceOut",
                t.price_sale * (t.item_qty - t.outing_qty - t.out_qty) as outing_amt,
                t.non_std_code,
@@ -349,13 +374,18 @@
                tpi.inv_id                                 as "invId",
                sys.f_remove_zero(tpi.inv_qty)                                as "invQty",
                sys.f_remove_zero(tpi.usable_qty)                             as "usableQty"
-        ,(select ul.decimal_places from  dkic_b.t_mst_unit ul where dkic_b.t_psi_order_item.unit_id = ul.unit_id) as "decimalPlaces"
+        ,(select ul.decimal_places from  dkic_b.t_mst_unit ul where t.unit_id = ul.unit_id) as "decimalPlaces"
+        ,ul.unit_name as "unitName"
+        ,u2.unit_name as "subUnitName"
+        ,dkic_b.f_box_piece(u2.unit_name,ul.unit_name,t.box,t.piece) as "boxPiece"
         FROM dkic_b.t_psi_order_item as t
                  inner join dkic_b.t_mst_goods_sku tmgs on t.sku_id = tmgs.sku_id
                  left join dkic_b.t_mst_warehouse as tmw on tmw.wh_id = t.wh_id
                  left join dkic_b.t_psi_inventory as tpi
                            on tpi.sku_id = t.sku_id and tpi.non_std_code = t.non_std_code
                                and tpi.wh_id = t.wh_id and tpi.cp_id = t.cp_id
+            LEFT JOIN dkic_b.t_mst_unit AS ul ON t.unit_id = ul.unit_id
+            LEFT JOIN dkic_b.t_mst_unit AS u2 ON t.sub_unit_id = u2.unit_id
         where t.flg_valid
           and t.item_qty > t.outing_qty
           and t.order_id = #{orderId}::uuid

+ 7 - 0
src/main/java/com/dk/mdm/model/response/sale/OrderItemResponse.java

@@ -95,6 +95,13 @@ public class OrderItemResponse extends PageInfo<OrderItemResponse> implements Se
     private String boxPiece;
 
     /**
+     * 本次出库包装数量
+     */
+    @Excel(name = "本次出库包装数量")
+    @ApiModelProperty(value = "本次出库包装数量")
+    private String thisOutBoxPiece;
+
+    /**
      * 基本单位
      */
     @ApiModelProperty(value = "基本单位")