Преглед изворни кода

Merge branch 'master' of http://s.dev01.dkiboss.com:9001/iBOSS-2.0-Mini/iboss-server-mdm

liuyao пре 1 година
родитељ
комит
e9d74e3e6c

+ 11 - 6
src/main/java/com/dk/mdm/mapper/common/CommonMapper.xml

@@ -1049,7 +1049,6 @@
                tmgs.category_id       as "categoryId",
                tmgs.category_id       as "categoryId",
                tmgc.cat_name          as "categoryName",
                tmgc.cat_name          as "categoryName",
                tmgs.unit_id           as "unitId",
                tmgs.unit_id           as "unitId",
-               tmgu.unit_name         as "unitName",
                tmgs.sub_unit_id       as "subUnitId",
                tmgs.sub_unit_id       as "subUnitId",
                tmgs.conversion_factor as "conversionFactor",
                tmgs.conversion_factor as "conversionFactor",
                tmgs.series_id         as "seriesId",
                tmgs.series_id         as "seriesId",
@@ -1071,6 +1070,8 @@
                tmgs.pack_box          as "packBox",
                tmgs.pack_box          as "packBox",
                tmgs.unit_id           as "unitId",
                tmgs.unit_id           as "unitId",
                tmgs.sub_unit_id       as "subUnitId",
                tmgs.sub_unit_id       as "subUnitId",
+               ul.unit_name           as "unitName",
+               u2.unit_name           as "subUnitName",
                dkic_b.f_get_last_ivt_price(tpi.inv_id,null,null,null) as "priceInto",
                dkic_b.f_get_last_ivt_price(tpi.inv_id,null,null,null) as "priceInto",
                tpi.remarks
                tpi.remarks
         from dkic_b.t_psi_inventory as tpi
         from dkic_b.t_psi_inventory as tpi
@@ -1079,7 +1080,8 @@
                  left join dkic_b.t_mst_goods_brand as tmgb on tmgs.brand_id = tmgb.brand_id
                  left join dkic_b.t_mst_goods_brand as tmgb on tmgs.brand_id = tmgb.brand_id
                  left join dkic_b.t_mst_goods_category as tmgc on tmgs.category_id = tmgc.cat_id
                  left join dkic_b.t_mst_goods_category as tmgc on tmgs.category_id = tmgc.cat_id
                  left join dkic_b.t_mst_goods_series as tmgseries on tmgs.series_id = tmgseries.series_id
                  left join dkic_b.t_mst_goods_series as tmgseries on tmgs.series_id = tmgseries.series_id
-                 left join dkic_b.t_mst_unit as tmgu on tmgs.unit_id = tmgu.unit_id
+                 left join dkic_b.t_mst_unit as ul on tmgs.unit_id = ul.unit_id
+                 left join dkic_b.t_mst_unit as u2 on tmgs.sub_unit_id = u2.unit_id
         where tpi.flg_valid
         where tpi.flg_valid
           AND tpi.cp_id = #{cpId}
           AND tpi.cp_id = #{cpId}
         <if test="skuId != null">
         <if test="skuId != null">
@@ -1862,9 +1864,6 @@
         tmgb.brand_name        as "brandName",
         tmgb.brand_name        as "brandName",
         tmgs.category_id       as "categoryId",
         tmgs.category_id       as "categoryId",
         tmgc.cat_name          as "categoryName",
         tmgc.cat_name          as "categoryName",
-        tmgs.unit_id           as "unitId",
-        tmgu.unit_name         as "unitName",
-        tmgs.sub_unit_id       as "subUnitId",
         tmgs.conversion_factor as "conversionFactor",
         tmgs.conversion_factor as "conversionFactor",
         tmgs.series_id         as "seriesId",
         tmgs.series_id         as "seriesId",
         tmgseries.series_name  as "seriesName",
         tmgseries.series_name  as "seriesName",
@@ -1874,12 +1873,18 @@
         tmgs.price_wholesale   as "priceWholesale",
         tmgs.price_wholesale   as "priceWholesale",
         tmgs.price_limited     as "priceLimited",
         tmgs.price_limited     as "priceLimited",
         tmgs.sku_images        as "skuImages",
         tmgs.sku_images        as "skuImages",
+        tmgs.pack_box          as "packBox",
+        tmgs.unit_id           as "unitId",
+        tmgs.sub_unit_id       as "subUnitId",
+        ul.unit_name           as "unitName",
+        u2.unit_name           as "subUnitName",
         tmgs.remarks
         tmgs.remarks
         from dkic_b.t_mst_goods_sku as tmgs
         from dkic_b.t_mst_goods_sku as tmgs
         left join dkic_b.t_mst_goods_brand as tmgb on tmgs.brand_id = tmgb.brand_id
         left join dkic_b.t_mst_goods_brand as tmgb on tmgs.brand_id = tmgb.brand_id
         left join dkic_b.t_mst_goods_category as tmgc on tmgs.category_id = tmgc.cat_id
         left join dkic_b.t_mst_goods_category as tmgc on tmgs.category_id = tmgc.cat_id
         left join dkic_b.t_mst_goods_series as tmgseries on tmgs.series_id = tmgseries.series_id
         left join dkic_b.t_mst_goods_series as tmgseries on tmgs.series_id = tmgseries.series_id
-        left join dkic_b.t_mst_unit as tmgu on tmgs.unit_id = tmgu.unit_id
+        left join dkic_b.t_mst_unit as ul on tmgs.unit_id = ul.unit_id
+        left join dkic_b.t_mst_unit as u2 on tmgs.sub_unit_id = u2.unit_id
         where tmgs.flg_valid
         where tmgs.flg_valid
         AND tmgs.cp_id = #{cpId}
         AND tmgs.cp_id = #{cpId}
         <if test="skuCode != null">
         <if test="skuCode != null">

+ 9 - 8
src/main/java/com/dk/mdm/mapper/ivt/OutboundItemMapper.xml

@@ -12,7 +12,7 @@ sys.f_remove_zero(out_qty) as out_qty, out_amt, sys.f_remove_zero(return_qty) as
         inv_id, cost_price, cost_amt, flg_valid, cp_id, op_create_time, op_create_user_id,
         inv_id, cost_price, cost_amt, flg_valid, cp_id, op_create_time, op_create_user_id,
         op_update_time, op_update_user_id, op_app_code, op_timestamp, op_db_user,
         op_update_time, op_update_user_id, op_app_code, op_timestamp, op_db_user,
         s_out_id,s_out_item_id,s_order_id,s_order_item_id,outing_box,outing_piece,out_box,out_piece,
         s_out_id,s_out_item_id,s_order_id,s_order_item_id,outing_box,outing_piece,out_box,out_piece,
-        unit_id,sub_unit_id, pack_box,sku_name,sku_model,sup_id
+        unit_id,sub_unit_id, pack_box,sku_name,sku_model,sup_id,wh_id
     </sql>
     </sql>
 
 
     <sql id="Base_Column_List_Response">
     <sql id="Base_Column_List_Response">
@@ -22,7 +22,7 @@ sys.f_remove_zero(out_qty) as out_qty, out_amt, sys.f_remove_zero(return_qty) as
         tpoi.cost_price, tpoi.cost_amt, tpoi.flg_valid, tpoi.cp_id,
         tpoi.cost_price, tpoi.cost_amt, tpoi.flg_valid, tpoi.cp_id,
         tpoi.s_out_id,tpoi.s_out_item_id,tpoi.s_order_id,tpoi.s_order_item_id,
         tpoi.s_out_id,tpoi.s_out_item_id,tpoi.s_order_id,tpoi.s_order_item_id,
         tpoi.outing_box,tpoi.outing_piece,tpoi.out_box,tpoi.out_piece,
         tpoi.outing_box,tpoi.outing_piece,tpoi.out_box,tpoi.out_piece,
-        tpoi.unit_id,tpoi.sub_unit_id,tpoi.pack_box,sku_name,sku_model,sup_id
+        tpoi.unit_id,tpoi.sub_unit_id,tpoi.pack_box,sku_name,sku_model,sup_id,wh_id
     </sql>
     </sql>
 
 
     <!-- 通用查询映射结果 -->
     <!-- 通用查询映射结果 -->
@@ -71,6 +71,7 @@ sys.f_remove_zero(out_qty) as out_qty, out_amt, sys.f_remove_zero(return_qty) as
         <result column="sku_model" property="skuModel"/>
         <result column="sku_model" property="skuModel"/>
         <result column="decimalPlaces" property="decimalPlaces"/>
         <result column="decimalPlaces" property="decimalPlaces"/>
         <result column="sup_id" property="supId"/>
         <result column="sup_id" property="supId"/>
+        <result column="wh_id" property="whId" typeHandler="UuidTypeHandler"/>
     </resultMap>
     </resultMap>
 
 
     <!-- 通用查询映射结果 -->
     <!-- 通用查询映射结果 -->
@@ -262,12 +263,12 @@ sys.f_remove_zero(out_qty) as out_qty, out_amt, sys.f_remove_zero(return_qty) as
         ul.unit_name as "unitName",
         ul.unit_name as "unitName",
         u2.unit_name as "subUnitName"
         u2.unit_name as "subUnitName"
         FROM dkic_b.t_psi_outbound_item as tpoi
         FROM dkic_b.t_psi_outbound_item as tpoi
+        left join dkic_b.t_mst_warehouse as tmw on tmw.wh_id = tpoi.wh_id
         LEFT JOIN dkic_b.t_mst_supplier as tms ON tpoi.sup_id = tms.sup_id
         LEFT JOIN dkic_b.t_mst_supplier as tms ON tpoi.sup_id = tms.sup_id
         LEFT JOIN dkic_b.t_mst_unit AS ul ON tpoi.unit_id = ul.unit_id
         LEFT JOIN dkic_b.t_mst_unit AS ul ON tpoi.unit_id = ul.unit_id
         LEFT JOIN dkic_b.t_mst_unit AS u2 ON tpoi.sub_unit_id = u2.unit_id
         LEFT JOIN dkic_b.t_mst_unit AS u2 ON tpoi.sub_unit_id = u2.unit_id
         left join dkic_b.t_mst_goods_sku tmgs on tmgs.sku_id = tpoi.sku_id
         left join dkic_b.t_mst_goods_sku tmgs on tmgs.sku_id = tpoi.sku_id
         left join dkic_b.t_psi_inventory as tpi on tpi.inv_id = tpoi.inv_id
         left join dkic_b.t_psi_inventory as tpi on tpi.inv_id = tpoi.inv_id
-        left join dkic_b.t_mst_warehouse as tmw on tmw.wh_id = tpi.wh_id
         left join sys.t_data_kind as tdk on tdk.kind_code = tpoi.out_status
         left join sys.t_data_kind as tdk on tdk.kind_code = tpoi.out_status
         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
         <include refid="Condition"/>
         <include refid="Condition"/>
@@ -281,9 +282,9 @@ sys.f_remove_zero(out_qty) as out_qty, out_amt, sys.f_remove_zero(return_qty) as
         SELECT
         SELECT
         count(1)
         count(1)
         FROM dkic_b.t_psi_outbound_item as tpoi
         FROM dkic_b.t_psi_outbound_item as tpoi
+        left join dkic_b.t_mst_warehouse as tmw on tmw.wh_id = tpoi.wh_id
         left join dkic_b.t_mst_goods_sku tmgs on tmgs.sku_id = tpoi.sku_id
         left join dkic_b.t_mst_goods_sku tmgs on tmgs.sku_id = tpoi.sku_id
         left join dkic_b.t_psi_inventory as tpi on tpi.inv_id = tpoi.inv_id
         left join dkic_b.t_psi_inventory as tpi on tpi.inv_id = tpoi.inv_id
-        left join dkic_b.t_mst_warehouse as tmw on tmw.wh_id = tpi.wh_id
         left join sys.t_data_kind as tdk on tdk.kind_code = tpoi.out_status
         left join sys.t_data_kind as tdk on tdk.kind_code = tpoi.out_status
         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
         <include refid="Condition"/>
         <include refid="Condition"/>
@@ -431,6 +432,7 @@ sys.f_remove_zero(out_qty) as out_qty, out_amt, sys.f_remove_zero(return_qty) as
                tms.sup_name
                tms.sup_name
                ,t.out_status
                ,t.out_status
         FROM dkic_b.t_psi_outbound_item as t
         FROM dkic_b.t_psi_outbound_item as t
+                 left join dkic_b.t_mst_warehouse as tmw on tmw.wh_id = t.wh_id
                  left join dkic_b.t_mst_supplier as tms on t.sup_id = tms.sup_id
                  left join dkic_b.t_mst_supplier as tms on t.sup_id = tms.sup_id
                  left join dkic_b.t_psi_order_item as tpoi on tpoi.item_id = t.from_item_id
                  left join dkic_b.t_psi_order_item as tpoi on tpoi.item_id = t.from_item_id
                  left join dkic_b.t_psi_order as tpo on tpo.order_id = t.from_id
                  left join dkic_b.t_psi_order as tpo on tpo.order_id = t.from_id
@@ -438,7 +440,6 @@ sys.f_remove_zero(out_qty) as out_qty, out_amt, sys.f_remove_zero(return_qty) as
                  left join dkic_b.t_mst_unit as tmgu on t.unit_id = tmgu.unit_id
                  left join dkic_b.t_mst_unit as tmgu on t.unit_id = tmgu.unit_id
                  left join dkic_b.t_mst_unit as tmgus on t.sub_unit_id = tmgus.unit_id
                  left join dkic_b.t_mst_unit as tmgus on t.sub_unit_id = tmgus.unit_id
                  left join dkic_b.t_psi_inventory as tpi on tpi.inv_id = t.inv_id
                  left join dkic_b.t_psi_inventory as tpi on tpi.inv_id = t.inv_id
-                 left join dkic_b.t_mst_warehouse as tmw on tmw.wh_id = tpi.wh_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 t.flg_valid
         where t.flg_valid
           and t.out_id = #{id}::uuid
           and t.out_id = #{id}::uuid
@@ -481,10 +482,10 @@ sys.f_remove_zero(out_qty) as out_qty, out_amt, sys.f_remove_zero(return_qty) as
                 ,sys.f_get_name_i18n(tdk.kind_name_i18n, #{i18n}) as "outStatusName"
                 ,sys.f_get_name_i18n(tdk.kind_name_i18n, #{i18n}) as "outStatusName"
                 ,t.out_status
                 ,t.out_status
         FROM dkic_b.t_psi_outbound_item as t
         FROM dkic_b.t_psi_outbound_item as t
+                 left join dkic_b.t_mst_warehouse as tmw on tmw.wh_id = t.wh_id
                  left join dkic_b.t_mst_goods_sku tmgs on tmgs.sku_id = t.sku_id
                  left join dkic_b.t_mst_goods_sku tmgs on tmgs.sku_id = t.sku_id
                  left join dkic_b.t_mst_unit as tmgu on t.unit_id = tmgu.unit_id
                  left join dkic_b.t_mst_unit as tmgu on t.unit_id = tmgu.unit_id
                  left join dkic_b.t_psi_inventory as tpi on tpi.inv_id = t.inv_id
                  left join dkic_b.t_psi_inventory as tpi on tpi.inv_id = t.inv_id
-                 left join dkic_b.t_mst_warehouse as tmw on tmw.wh_id = tpi.wh_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 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
                  LEFT JOIN dkic_b.t_mst_unit AS u2 ON t.sub_unit_id = u2.unit_id
                  left join sys.t_data_kind as tdk on tdk.kind_code = t.out_status
                  left join sys.t_data_kind as tdk on tdk.kind_code = t.out_status
@@ -561,12 +562,12 @@ sys.f_remove_zero(out_qty) as out_qty, out_amt, sys.f_remove_zero(return_qty) as
                 ,t.out_piece
                 ,t.out_piece
                 ,t.out_status
                 ,t.out_status
         FROM dkic_b.t_psi_outbound_item as t
         FROM dkic_b.t_psi_outbound_item as t
+                 left join dkic_b.t_mst_warehouse tmw on tmw.wh_id = t.wh_id
                  left join dkic_b.t_mst_unit as tmgu on t.unit_id = tmgu.unit_id
                  left join dkic_b.t_mst_unit as tmgu on t.unit_id = tmgu.unit_id
                  left join dkic_b.t_mst_unit as tmgus on t.sub_unit_id = tmgus.unit_id
                  left join dkic_b.t_mst_unit as tmgus on t.sub_unit_id = tmgus.unit_id
                  left join dkic_b.t_mst_goods_sku tmgs on tmgs.sku_id = t.sku_id
                  left join dkic_b.t_mst_goods_sku tmgs on tmgs.sku_id = t.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
                  left join dkic_b.t_psi_inventory tpi on tpi.inv_id = t.inv_id
                  left join dkic_b.t_psi_inventory tpi on tpi.inv_id = t.inv_id
-                 left join dkic_b.t_mst_warehouse tmw on tmw.wh_id = tpi.wh_id
                  left join dkic_b.t_psi_outbound_item as tpobi on tpobi.item_id = t.s_out_item_id
                  left join dkic_b.t_psi_outbound_item as tpobi on tpobi.item_id = t.s_out_item_id
         where t.flg_valid
         where t.flg_valid
           and t.out_id = #{id}::uuid
           and t.out_id = #{id}::uuid
@@ -615,12 +616,12 @@ sys.f_remove_zero(out_qty) as out_qty, out_amt, sys.f_remove_zero(return_qty) as
                 ,t.out_piece
                 ,t.out_piece
         ,t.out_status
         ,t.out_status
         FROM dkic_b.t_psi_outbound_item as t
         FROM dkic_b.t_psi_outbound_item as t
+                 left join dkic_b.t_mst_warehouse tmw on tmw.wh_id = t.wh_id
                  left join dkic_b.t_mst_goods_sku tmgs on tmgs.sku_id = t.sku_id
                  left join dkic_b.t_mst_goods_sku tmgs on tmgs.sku_id = t.sku_id
                  left join dkic_b.t_mst_unit as tmgu on t.unit_id = tmgu.unit_id
                  left join dkic_b.t_mst_unit as tmgu on t.unit_id = tmgu.unit_id
                  left join dkic_b.t_mst_unit as tmgus on t.sub_unit_id = tmgus.unit_id
                  left join dkic_b.t_mst_unit as tmgus on t.sub_unit_id = tmgus.unit_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
                  left join dkic_b.t_psi_inventory tpi on tpi.inv_id = t.inv_id
                  left join dkic_b.t_psi_inventory tpi on tpi.inv_id = t.inv_id
-                 left join dkic_b.t_mst_warehouse tmw on tmw.wh_id = tpi.wh_id
                  left join dkic_b.t_psi_outbound_item as tpobi on tpobi.item_id = t.s_out_item_id
                  left join dkic_b.t_psi_outbound_item as tpobi on tpobi.item_id = t.s_out_item_id
         where t.flg_valid
         where t.flg_valid
           and t.out_id = #{id}::uuid
           and t.out_id = #{id}::uuid

+ 22 - 0
src/main/java/com/dk/mdm/mapper/ivt/OutboundMapper.xml

@@ -158,6 +158,7 @@
 
 
     <resultMap id="itemListMap" type="java.util.Map">
     <resultMap id="itemListMap" type="java.util.Map">
         <id column="item_id" property="itemId"/>
         <id column="item_id" property="itemId"/>
+        <result column="sup_id" property="supId" typeHandler="UuidTypeHandler"/>
         <result column="out_id" property="outId" typeHandler="UuidTypeHandler"/>
         <result column="out_id" property="outId" typeHandler="UuidTypeHandler"/>
         <result column="out_no" property="outNo" />
         <result column="out_no" property="outNo" />
         <result column="out_type" property="outType"/>
         <result column="out_type" property="outType"/>
@@ -340,6 +341,9 @@
             <if test="flgValid != null">
             <if test="flgValid != null">
                 AND t.flg_valid = #{flgValid}
                 AND t.flg_valid = #{flgValid}
             </if>
             </if>
+            <if test="flgFilterReturn != null">
+                AND tpoi.out_qty - tpoi.return_qty > 0
+            </if>
         </where>
         </where>
     </sql>
     </sql>
 
 
@@ -1089,6 +1093,7 @@
     <sql id="Base_Column_List_Item_Response_Detail_Join">
     <sql id="Base_Column_List_Item_Response_Detail_Join">
         tpoi.item_id  AS "list_item_id",
         tpoi.item_id  AS "list_item_id",
         tpoi.out_id  AS "list_out_id",
         tpoi.out_id  AS "list_out_id",
+        tpoi.sup_id AS "list_sup_id",
         t.out_no  AS "list_out_no",
         t.out_no  AS "list_out_no",
                     tpoi.out_type  AS "list_out_type",
                     tpoi.out_type  AS "list_out_type",
                     tpoi.from_id  AS "list_from_id",
                     tpoi.from_id  AS "list_from_id",
@@ -1141,6 +1146,23 @@
         SELECT
         SELECT
         count(1)
         count(1)
         FROM dkic_b.t_psi_outbound as t
         FROM dkic_b.t_psi_outbound as t
+        left join dkic_b.t_mst_customer tmc on tmc.cus_id = t.cus_id
+        left join dkic_b.t_mst_sale_channel tmsc on tmsc.channel_id = tmc.channel_id
+        left join dkic_b.t_mst_org tmo on tmo.org_id = t.org_id
+        left join dkic_b.t_mst_staff tms on tms.staff_id = t.staff_id
+        left join dkic_b.t_mst_staff as makestaff on makestaff.staff_id = t.make_staff
+        left join dkic_b.t_mst_dictionary_data tmdd on tmdd.data_id = tmc.cus_from
+        left join sys.t_data_kind as tdk1 on tdk1.kind_code = t.out_status
+        left join dkic_b.t_mst_dictionary_data tmd on tmd.data_id = t.out_reason
+        Left join dkic_b.t_mst_supplier tmp on tmp.sup_id = t.sup_id
+        left join  dkic_b.t_psi_outbound_item  tpoi  on tpoi.out_id = t.out_id
+        left join dkic_b.t_psi_inventory tpi on tpi.inv_id = tpoi.inv_id
+        left join dkic_b.t_mst_unit as tmgu on tpoi.unit_id = tmgu.unit_id
+        left join dkic_b.t_mst_unit as tmgus on tpoi.sub_unit_id = tmgus.unit_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
+        left join dkic_b.t_psi_inventory tpity on tpity.inv_id  = tpoi.inv_id
+        left join dkic_b.t_mst_warehouse as tmw on tpity.wh_id = tmw.wh_id
         <include refid="Condition"/>
         <include refid="Condition"/>
     </select>
     </select>
 
 

+ 58 - 36
src/main/java/com/dk/mdm/mapper/report/ReportMapper.xml

@@ -327,6 +327,12 @@
             <if test="staffIdList != null and staffIdList.size() > 0">
             <if test="staffIdList != null and staffIdList.size() > 0">
                 AND t.staff_id =any(#{staffIdList, typeHandler=uuidListTypeHandler})
                 AND t.staff_id =any(#{staffIdList, typeHandler=uuidListTypeHandler})
             </if>
             </if>
+            <if test="staffName != null and staffName != ''">
+                AND tms.staff_name LIKE concat('%',my_ex.likequery(#{staffName}),'%')
+            </if>
+            <if test="orgName != null and orgName != ''">
+                AND tmo.org_name LIKE concat('%',my_ex.likequery(#{orgName}),'%')
+            </if>
             <if test="outStatusList != null and outStatusList.size() > 0">
             <if test="outStatusList != null and outStatusList.size() > 0">
                 AND t.out_status =any(#{outStatusList, typeHandler=StringListTypeHandler})
                 AND t.out_status =any(#{outStatusList, typeHandler=StringListTypeHandler})
             </if>
             </if>
@@ -643,6 +649,12 @@
             <if test="staffIdList != null and staffIdList.size() > 0">
             <if test="staffIdList != null and staffIdList.size() > 0">
                 AND t.staff_id =any(#{staffIdList, typeHandler=uuidListTypeHandler})
                 AND t.staff_id =any(#{staffIdList, typeHandler=uuidListTypeHandler})
             </if>
             </if>
+            <if test="staffName != null and staffName != ''">
+                AND tms.staff_name LIKE concat('%',my_ex.likequery(#{staffName}),'%')
+            </if>
+            <if test="orgName != null and orgName != ''">
+                AND tmo.org_name LIKE concat('%',my_ex.likequery(#{orgName}),'%')
+            </if>
             <if test="accDateStart != null and accDateEnd != null">
             <if test="accDateStart != null and accDateEnd != null">
                 AND t.acc_date &gt;= #{accDateStart}::timestamp with time zone
                 AND t.acc_date &gt;= #{accDateStart}::timestamp with time zone
                 AND t.acc_date &lt; #{accDateEnd}::timestamp with time zone + interval '1 day'
                 AND t.acc_date &lt; #{accDateEnd}::timestamp with time zone + interval '1 day'
@@ -651,6 +663,13 @@
                 AND t.make_time &gt;= #{makeTimeStart}::timestamp with time zone
                 AND t.make_time &gt;= #{makeTimeStart}::timestamp with time zone
                 AND t.make_time &lt; #{makeTimeEnd}::timestamp with time zone + interval '1 day'
                 AND t.make_time &lt; #{makeTimeEnd}::timestamp with time zone + interval '1 day'
             </if>
             </if>
+            <if test="searchText !=null and searchText != ''">
+                AND (
+                t.rp_no   LIKE concat('%',my_ex.likequery(#{searchText}),'%')
+                or tmc.cus_phone LIKE concat('%',my_ex.likequery(#{searchText}),'%')
+                or tmc.cus_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
+                )
+            </if>
         </where>
         </where>
     </sql>
     </sql>
     <!-- 采购明细报表主表 -->
     <!-- 采购明细报表主表 -->
@@ -1038,13 +1057,13 @@
         ,t.out_date as "outDate"
         ,t.out_date as "outDate"
         ,t.remarks
         ,t.remarks
         ,makestaff.staff_name as "makeStaffName"
         ,makestaff.staff_name as "makeStaffName"
-        ,tmgs.sku_name as "skuName"
-        ,tmgs.sku_model as "skuModel"
+        ,tpoi.sku_name as "skuName"
+        ,tpoi.sku_model as "skuModel"
         ,tmgs.sku_spec as "skuSpec"
         ,tmgs.sku_spec as "skuSpec"
         ,tpi.non_std_code as "nonStdCode"
         ,tpi.non_std_code as "nonStdCode"
         ,tmgb.short_name as "shortName"
         ,tmgb.short_name as "shortName"
         ,tmgb.brand_name as "brandName"
         ,tmgb.brand_name as "brandName"
-        ,tmw.wh_name as "whName"
+        ,CASE WHEN tpoi.sku_id IS NULL THEN tmsp.sup_name || '(外协)' ELSE tmw.wh_name end as "whName"
         ,tmgc.cat_name as "catName"
         ,tmgc.cat_name as "catName"
         ,series.series_name as "seriesName"
         ,series.series_name as "seriesName"
         ,sys.f_remove_zero(tpoi.outing_qty) as "outingQty"
         ,sys.f_remove_zero(tpoi.outing_qty) as "outingQty"
@@ -1068,6 +1087,7 @@
         left join sys.t_data_kind as tdk1 on tdk1.kind_code = t.out_status
         left join sys.t_data_kind as tdk1 on tdk1.kind_code = t.out_status
         left join sys.t_data_kind tdktype ON tdktype.kind_code = t.out_type
         left join sys.t_data_kind tdktype ON tdktype.kind_code = t.out_type
         left join dkic_b.t_psi_outbound_item as tpoi on tpoi.out_id = t.out_id
         left join dkic_b.t_psi_outbound_item as tpoi on tpoi.out_id = t.out_id
+        left join dkic_b.t_mst_supplier tmsp on tpoi.sup_id = tmsp.sup_id
         left join dkic_b.t_mst_goods_sku as tmgs on tmgs.sku_id = tpoi.sku_id
         left join dkic_b.t_mst_goods_sku as tmgs on tmgs.sku_id = tpoi.sku_id
         left join dkic_b.t_mst_goods_brand as tmgb on tmgb.brand_id = tmgs.brand_id
         left join dkic_b.t_mst_goods_brand as tmgb on tmgb.brand_id = tmgs.brand_id
         left join dkic_b.t_mst_goods_category as tmgc on tmgc.cat_id = tmgs.category_id
         left join dkic_b.t_mst_goods_category as tmgc on tmgc.cat_id = tmgs.category_id
@@ -1154,45 +1174,47 @@
         count(1) from (
         count(1) from (
             SELECT 1
             SELECT 1
             FROM dkic_b.t_psi_outbound as t
             FROM dkic_b.t_psi_outbound as t
-            left join dkic_b.t_mst_org tmo on tmo.org_id = t.org_id
-            Left join dkic_b.t_mst_supplier tmp on tmp.sup_id = t.sup_id
-            left join dkic_b.t_mst_staff tms on tms.staff_id = t.staff_id
-            left join dkic_b.t_mst_staff as makestaff on makestaff.staff_id = t.make_staff
-            left join dkic_b.t_mst_customer tmc on tmc.cus_id = t.cus_id
-            left join dkic_b.t_mst_dictionary_data tmdd on tmdd.data_id = tmc.cus_from
-            left join sys.t_data_kind as tdk1 on tdk1.kind_code = t.out_status
-            left join sys.t_data_kind tdktype ON tdktype.kind_code = t.out_type
-            left join dkic_b.t_psi_outbound_item as tpoi on tpoi.out_id = t.out_id
-            left join dkic_b.t_mst_goods_sku as tmgs on tmgs.sku_id = tpoi.sku_id
-            left join dkic_b.t_mst_goods_brand as tmgb on tmgb.brand_id = tmgs.brand_id
-            left join dkic_b.t_mst_goods_category as tmgc on tmgc.cat_id = tmgs.category_id
-            left join dkic_b.t_mst_goods_series as series on series.series_id = tmgs.series_id
-            left join dkic_b.t_psi_inventory as tpi on tpi.inv_id = tpoi.inv_id
-            left join dkic_b.t_mst_warehouse as tmw on tmw.wh_id = tpi.wh_id
+        left join dkic_b.t_mst_org tmo on tmo.org_id = t.org_id
+        Left join dkic_b.t_mst_supplier tmp on tmp.sup_id = t.sup_id
+        left join dkic_b.t_mst_staff tms on tms.staff_id = t.staff_id
+        left join dkic_b.t_mst_staff as makestaff on makestaff.staff_id = t.make_staff
+        left join dkic_b.t_mst_customer tmc on tmc.cus_id = t.cus_id
+        left join dkic_b.t_mst_dictionary_data tmdd on tmdd.data_id = tmc.cus_from
+        left join sys.t_data_kind as tdk1 on tdk1.kind_code = t.out_status
+        left join sys.t_data_kind tdktype ON tdktype.kind_code = t.out_type
+        left join dkic_b.t_psi_outbound_item as tpoi on tpoi.out_id = t.out_id
+        left join dkic_b.t_mst_goods_sku as tmgs on tmgs.sku_id = tpoi.sku_id
+        left join dkic_b.t_mst_goods_brand as tmgb on tmgb.brand_id = tmgs.brand_id
+        left join dkic_b.t_mst_goods_category as tmgc on tmgc.cat_id = tmgs.category_id
+        left join dkic_b.t_mst_goods_series as series on series.series_id = tmgs.series_id
+        left join dkic_b.t_psi_inventory as tpi on tpi.inv_id = tpoi.inv_id
+        left join dkic_b.t_mst_warehouse as tmw on tmw.wh_id = tpi.wh_id
+        left join dkic_b.t_mst_unit as tmgu on tmgs.unit_id = tmgu.unit_id
+        left join dkic_b.t_mst_unit as tmgus on tmgs.sub_unit_id = tmgus.unit_id
             <include refid="Condition_OutboundDetailReport"/>
             <include refid="Condition_OutboundDetailReport"/>
             union all
             union all
             select
             select
             1
             1
             FROM dkic_b.t_psi_inbound as tpi
             FROM dkic_b.t_psi_inbound as tpi
-            left join dkic_b.t_mst_org tmo on tmo.org_id = tpi.org_id
-            Left join dkic_b.t_mst_supplier tmp on tmp.sup_id = tpi.sup_id
-            left join dkic_b.t_mst_staff tms on tms.staff_id = tpi.staff_id
-            left join dkic_b.t_mst_staff as makestaff on makestaff.staff_id = tpi.make_staff
-            left join dkic_b.t_mst_customer tmc on tmc.cus_id = tpi.cus_id
-            left join dkic_b.t_mst_dictionary_data tmdd on tmdd.data_id = tmc.cus_from
-            left join sys.t_data_kind as tdk1 on tdk1.kind_code = tpi.into_status
-            left join sys.t_data_kind tdktype ON tdktype.kind_code = tpi.into_type
-            left join dkic_b.t_psi_inbound_item as tpii on tpii.into_id = tpi.into_id
-            left join dkic_b.t_mst_goods_sku as tmgs on tmgs.sku_id = tpii.sku_id
-            left join dkic_b.t_mst_goods_brand as tmgb on tmgb.brand_id = tmgs.brand_id
-            left join dkic_b.t_mst_goods_category as tmgc on tmgc.cat_id = tmgs.category_id
-            left join dkic_b.t_mst_goods_series as series on series.series_id = tmgs.series_id
-            left join dkic_b.t_psi_inventory as tpin on tpin.inv_id = tpii.inv_id
-            left join dkic_b.t_mst_warehouse as tmw on tmw.wh_id = tpi.wh_id
-            left join dkic_b.t_mst_unit as tmgu on tmgs.unit_id = tmgu.unit_id
-            left join dkic_b.t_mst_unit as tmgus on tmgs.sub_unit_id = tmgus.unit_id
+        left join dkic_b.t_mst_org tmo on tmo.org_id = tpi.org_id
+        Left join dkic_b.t_mst_supplier tmp on tmp.sup_id = tpi.sup_id
+        left join dkic_b.t_mst_staff tms on tms.staff_id = tpi.staff_id
+        left join dkic_b.t_mst_staff as makestaff on makestaff.staff_id = tpi.make_staff
+        left join dkic_b.t_mst_customer tmc on tmc.cus_id = tpi.cus_id
+        left join dkic_b.t_mst_dictionary_data tmdd on tmdd.data_id = tmc.cus_from
+        left join sys.t_data_kind as tdk1 on tdk1.kind_code = tpi.into_status
+        left join sys.t_data_kind tdktype ON tdktype.kind_code = tpi.into_type
+        left join dkic_b.t_psi_inbound_item as tpii on tpii.into_id = tpi.into_id
+        left join dkic_b.t_mst_goods_sku as tmgs on tmgs.sku_id = tpii.sku_id
+        left join dkic_b.t_mst_goods_brand as tmgb on tmgb.brand_id = tmgs.brand_id
+        left join dkic_b.t_mst_goods_category as tmgc on tmgc.cat_id = tmgs.category_id
+        left join dkic_b.t_mst_goods_series as series on series.series_id = tmgs.series_id
+        left join dkic_b.t_psi_inventory as tpin on tpin.inv_id = tpii.inv_id
+        left join dkic_b.t_mst_warehouse as tmw on tmw.wh_id = tpi.wh_id
+        left join dkic_b.t_mst_unit as tmgu on tmgs.unit_id = tmgu.unit_id
+        left join dkic_b.t_mst_unit as tmgus on tmgs.sub_unit_id = tmgus.unit_id
             <include refid="Condition_OutInboundDetailReport"/>
             <include refid="Condition_OutInboundDetailReport"/>
-        )
+        ) t
     </select>
     </select>
     <!-- 入库明细报表主表 -->
     <!-- 入库明细报表主表 -->
     <select id="getInboundlReport" resultType="java.util.Map">
     <select id="getInboundlReport" resultType="java.util.Map">

+ 11 - 1
src/main/java/com/dk/mdm/mapper/sale/OrderItemMapper.xml

@@ -602,10 +602,20 @@
         t.return_amt,
         t.return_amt,
         t.remarks,
         t.remarks,
         t.item_qty - coalesce(sumQty,0) as "transferableQuantity"
         t.item_qty - coalesce(sumQty,0) as "transferableQuantity"
-        ,(select ul.decimal_places from  dkic_b.t_mst_unit ul where t.unit_id = ul.unit_id) as "decimalPlaces"
+        ,ul.decimal_places as "decimalPlaces"
+        ,t.box
+        ,t.piece
+        ,t.pack_box
+        ,t.unit_id
+        ,t.sub_unit_id
+        ,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
         FROM dkic_b.t_psi_order_item as t
         left join dkic_b.t_psi_order as tpo on tpo.order_id = t.order_id
         left join dkic_b.t_psi_order as tpo on tpo.order_id = t.order_id
         inner join dkic_b.t_mst_goods_sku tmgs on t.sku_id = tmgs.sku_id
         inner join dkic_b.t_mst_goods_sku tmgs on t.sku_id = tmgs.sku_id
+        left join dkic_b.t_mst_unit ul on t.unit_id = ul.unit_id
+        left join dkic_b.t_mst_unit u2 on t.sub_unit_id = u2.unit_id
         left join(select from_item_id,sum(item_qty) as sumQty from dkic_b.t_psi_purchase_item
         left join(select from_item_id,sum(item_qty) as sumQty from dkic_b.t_psi_purchase_item
             group by from_item_id) as pi on pi.from_item_id = t.item_id
             group by from_item_id) as pi on pi.from_item_id = t.item_id
         <where>
         <where>

+ 5 - 0
src/main/java/com/dk/mdm/model/pojo/ivt/OutboundItem.java

@@ -365,6 +365,11 @@ public class OutboundItem extends PageInfo<OutboundItem> implements Serializable
     @TableField(typeHandler = UuidTypeHandler.class)
     @TableField(typeHandler = UuidTypeHandler.class)
     private String supId;
     private String supId;
 
 
+    @Excel(name = "仓库ID")
+    @ApiModelProperty(value = "仓库ID")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String whId;
+
     private static final long serialVersionUID = 1L;
     private static final long serialVersionUID = 1L;
 
 
 }
 }

+ 5 - 0
src/main/java/com/dk/mdm/model/query/ivt/OutboundItemQuery.java

@@ -237,6 +237,11 @@ public class OutboundItemQuery extends PageInfo<OutboundItemQuery>{
     @TableField(typeHandler = UuidTypeHandler.class)
     @TableField(typeHandler = UuidTypeHandler.class)
     private String supId;
     private String supId;
 
 
+    @Excel(name = "仓库ID")
+    @ApiModelProperty(value = "仓库ID")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String whId;
+
 
 
     private static final long serialVersionUID = 1L;
     private static final long serialVersionUID = 1L;
 
 

+ 3 - 0
src/main/java/com/dk/mdm/model/query/ivt/OutboundQuery.java

@@ -282,6 +282,9 @@ public class OutboundQuery extends PageInfo<OutboundQuery> {
     @TableField(typeHandler = StringListTypeHandler.class)
     @TableField(typeHandler = StringListTypeHandler.class)
     private List<String> outTypes;
     private List<String> outTypes;
 
 
+    @ApiModelProperty(value = "是否过滤退货")
+    private Boolean flgFilterReturn;
+
 
 
 
 
     /*
     /*

+ 2 - 0
src/main/java/com/dk/mdm/model/response/ivt/OutboundItemResponse.java

@@ -298,7 +298,9 @@ public class OutboundItemResponse {
     @ApiModelProperty(value = "可出库数量")
     @ApiModelProperty(value = "可出库数量")
     private BigDecimal canOutingQty;
     private BigDecimal canOutingQty;
 
 
+    @Excel(name = "仓库ID")
     @ApiModelProperty(value = "仓库ID")
     @ApiModelProperty(value = "仓库ID")
+    @TableField(typeHandler = UuidTypeHandler.class)
     private String whId;
     private String whId;
 
 
     @Excel(name = "库存数量")
     @Excel(name = "库存数量")

+ 3 - 0
src/main/java/com/dk/mdm/model/vo/ivt/InOutRecordVO.java

@@ -222,6 +222,9 @@ public class InOutRecordVO  {
     @ApiModelProperty(value = "存货批次明细ID")
     @ApiModelProperty(value = "存货批次明细ID")
     private String batchId;
     private String batchId;
 
 
+    @ApiModelProperty(value = "外协供应商Id")
+    private String supId;
+
 
 
 
 
 
 

+ 5 - 3
src/main/java/com/dk/mdm/model/vo/ivt/OutboundItemVO.java

@@ -256,9 +256,6 @@ public class OutboundItemVO {
     @ApiModelProperty(value = "已出库金额编辑之前")
     @ApiModelProperty(value = "已出库金额编辑之前")
     private BigDecimal amtBeforeUpdate;
     private BigDecimal amtBeforeUpdate;
 
 
-    @ApiModelProperty(value = "仓库")
-    private String whId;
-
     @ApiModelProperty(value = "新建编辑标识true:新建,false:编辑")
     @ApiModelProperty(value = "新建编辑标识true:新建,false:编辑")
     private Boolean addOrEditFlag;
     private Boolean addOrEditFlag;
 
 
@@ -280,6 +277,11 @@ public class OutboundItemVO {
     @ApiModelProperty(value = "包装")
     @ApiModelProperty(value = "包装")
     private BigDecimal packBox;
     private BigDecimal packBox;
 
 
+    @Excel(name = "仓库ID")
+    @ApiModelProperty(value = "仓库ID")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String whId;
+
 
 
 
 
 
 

+ 61 - 40
src/main/java/com/dk/mdm/service/ivt/inventory/InventoryService.java

@@ -213,13 +213,21 @@ public class InventoryService extends BaseService<Inventory> {
             throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.DETAIL_LIST_IS_NUL.getMessage());
             throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.DETAIL_LIST_IS_NUL.getMessage());
         }
         }
         for (InOutRecordVO inventoryBatchVO : inOutRecordVOList) {
         for (InOutRecordVO inventoryBatchVO : inOutRecordVOList) {
-            //商品ID
-            if (inventoryBatchVO.getSkuId() == null || "".equals(inventoryBatchVO.getSkuId())) {
-                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.SKU_IS_NULL.getMessage());
-            }
-            //仓库ID
-            if (!inventoryBatchVO.getCanNegativeFlag() && (inventoryBatchVO.getWhId() == null || "".equals(inventoryBatchVO.getWhId()))) {
-                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.WAREHOUSE_IS_NULL.getMessage());
+            // 外协供应商ID 不进行判断商品Id和库存ID
+            if(inventoryBatchVO.getSupId() == null) {
+                //商品ID
+                if (inventoryBatchVO.getSkuId() == null || "".equals(inventoryBatchVO.getSkuId())) {
+                    throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.SKU_IS_NULL.getMessage());
+                }
+                //存货ID
+                if (Constant.InventoryType.OUTBOUND.equals(inventoryBatchVO.getInventoryType())
+                        && (inventoryBatchVO.getInvId() == null || "".equals(inventoryBatchVO.getInvId()))) {
+                    throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.SKU_IS_NOT_IN_INVENTORY.getMessage());
+                }
+                //仓库ID
+                if (!inventoryBatchVO.getCanNegativeFlag() && (inventoryBatchVO.getWhId() == null || "".equals(inventoryBatchVO.getWhId()))) {
+                    throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.WAREHOUSE_IS_NULL.getMessage());
+                }
             }
             }
 //			//单价不可为空
 //			//单价不可为空
 //			if(inventoryBatchVO.getCostPrice()==null || inventoryBatchVO.getCostPrice().compareTo(BigDecimal.ZERO)==0 ){
 //			if(inventoryBatchVO.getCostPrice()==null || inventoryBatchVO.getCostPrice().compareTo(BigDecimal.ZERO)==0 ){
@@ -508,10 +516,13 @@ public class InventoryService extends BaseService<Inventory> {
     public InventoryResponse checkInventoryNumber(InOutRecordVO inOutRecordVO) {
     public InventoryResponse checkInventoryNumber(InOutRecordVO inOutRecordVO) {
         //存在标识
         //存在标识
         //根据sku,仓库,非标号查询
         //根据sku,仓库,非标号查询
-        InventoryResponse inventoryResponse = inventoryMapper.selectByOther(new InventoryQuery()
-                .setSkuId(inOutRecordVO.getSkuId())
-                .setWhId(inOutRecordVO.getWhId())
-                .setNonStdCode(inOutRecordVO.getNonStdCode()));
+        InventoryResponse inventoryResponse = null ;
+        if(inOutRecordVO.getSkuId() != null){
+            inventoryResponse = inventoryMapper.selectByOther(new InventoryQuery()
+                    .setSkuId(inOutRecordVO.getSkuId())
+                    .setWhId(inOutRecordVO.getWhId())
+                    .setNonStdCode(inOutRecordVO.getNonStdCode()));
+        }
         return inventoryResponse;
         return inventoryResponse;
     }
     }
 
 
@@ -588,46 +599,50 @@ public class InventoryService extends BaseService<Inventory> {
             else if (Constant.InventoryType.OUTBOUND.getName().equals(inOutRecordVO.getInventoryType())) {
             else if (Constant.InventoryType.OUTBOUND.getName().equals(inOutRecordVO.getInventoryType())) {
                 //region  库存不存在  再判断销售退货出库和其他类型出库
                 //region  库存不存在  再判断销售退货出库和其他类型出库
                 if (inventoryResponse == null) {
                 if (inventoryResponse == null) {
-                    //region  根据源出库单明细Id存在  去出库成本里去查价格
-                    if (inOutRecordVO.getSOutItemId() != null) {
+                    //region  根据源出库单明细Id存在  去出库成本里去查价格  todo 增加判断 为了解决销售退货的问题
+                    if (inOutRecordVO.getSOutItemId() != null && Constant.InventoryDocCode.SALE_ORDER.getValue().equals(inOutRecordVO.getInventoryDocCode())) {
                         List<OutboundItemCostResponse> outboundItemCostResponses = outboundItemCostMapper.selectByCond(new OutboundItemCostQuery().setOutItemId(inOutRecordVO.getSOutItemId()));
                         List<OutboundItemCostResponse> outboundItemCostResponses = outboundItemCostMapper.selectByCond(new OutboundItemCostQuery().setOutItemId(inOutRecordVO.getSOutItemId()));
                         if (outboundItemCostResponses.size() > 0) {
                         if (outboundItemCostResponses.size() > 0) {
                             //出库单价
                             //出库单价
                             inOutRecordVO.setPriceInto(outboundItemCostResponses.get(0).getCostPrice());
                             inOutRecordVO.setPriceInto(outboundItemCostResponses.get(0).getCostPrice());
                             //金额
                             //金额
                             inOutRecordVO.setIntoAmt(outboundItemCostResponses.get(0).getCostPrice().multiply(inOutRecordVO.getIntoQty()).abs());
                             inOutRecordVO.setIntoAmt(outboundItemCostResponses.get(0).getCostPrice().multiply(inOutRecordVO.getIntoQty()).abs());
-                        } else {
-                            //当前销售退货单无法获取源出库单数据
-                            throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.UNABLE_TO_OBTAIN_SOURCE_DATA.getMessage());
                         }
                         }
+                        //todo 2024年5月31日16:00:21 编辑的情况 先删后加  所以此处查不到数据 在删除的时候赋值
+//                        else {
+//                            //当前销售退货单无法获取源出库单数据
+//                            throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.UNABLE_TO_OBTAIN_SOURCE_DATA.getMessage());
+//                        }
                     }
                     }
                     //endregion
                     //endregion
 
 
                     //region 销售退货出库  (负向出库相当于入库)
                     //region 销售退货出库  (负向出库相当于入库)
-                    if (Constant.InventoryDocCode.SALE_RETURN.getValue().equals(inOutRecordVO.getInventoryDocCode())) {
-                        //region  新建库存
-                        inOutRecordVO = this.insertInventory(inOutRecordVO);
-                        //endregion
-
-                        //region 库存批次
-                        this.insertInventoryBatch(inOutRecordVO);
-                        //endregion
-
-                        //region 库存流水
-                        this.insertInboundRecord(inOutRecordVO);
+                    if(inOutRecordVO.getSkuId() != null) {
+                        if (Constant.InventoryDocCode.SALE_RETURN.getValue().equals(inOutRecordVO.getInventoryDocCode())) {
+                            //region  新建库存
+                            inOutRecordVO = this.insertInventory(inOutRecordVO);
+                            //endregion
+
+                            //region 库存批次
+                            this.insertInventoryBatch(inOutRecordVO);
+                            //endregion
+
+                            //region 库存流水
+                            this.insertInboundRecord(inOutRecordVO);
+                            //endregion
+                        }
                         //endregion
                         //endregion
 
 
-                    }
-                    //endregion
-
-                    //region 其他类型出库  没有库存不允许进行出库
-                    else {
-                        throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.SKU_IS_NOT_IN_INVENTORY.getMessage());
+                        //region 其他类型出库  没有库存不允许进行出库
+                        else {
+                            throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.SKU_IS_NOT_IN_INVENTORY.getMessage());
+                        }
                     }
                     }
                     //endregion
                     //endregion
                 }
                 }
                 //region  库存存在
                 //region  库存存在
                 else {
                 else {
+                    //todo 2024年5月31日16:00:21 编辑的情况 先删后加  所以此处查不到数据 在删除的时候赋值
                     //region  根据源出库单明细Id 去出库成本里去查价格
                     //region  根据源出库单明细Id 去出库成本里去查价格
                     if (inOutRecordVO.getSOutItemId() != null) {
                     if (inOutRecordVO.getSOutItemId() != null) {
                         List<OutboundItemCostResponse> outboundItemCostResponses = outboundItemCostMapper.selectByCond(new OutboundItemCostQuery().setOutItemId(inOutRecordVO.getSOutItemId()));
                         List<OutboundItemCostResponse> outboundItemCostResponses = outboundItemCostMapper.selectByCond(new OutboundItemCostQuery().setOutItemId(inOutRecordVO.getSOutItemId()));
@@ -637,10 +652,12 @@ public class InventoryService extends BaseService<Inventory> {
                             //金额
                             //金额
                             inOutRecordVO.setIntoAmt(outboundItemCostResponses.get(0).getCostPrice().multiply(inOutRecordVO.getIntoQty()).abs());
                             inOutRecordVO.setIntoAmt(outboundItemCostResponses.get(0).getCostPrice().multiply(inOutRecordVO.getIntoQty()).abs());
 
 
-                        } else {
-                            //当前销售退货单无法获取源出库单数据
-                            throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.UNABLE_TO_OBTAIN_SOURCE_DATA.getMessage());
                         }
                         }
+                        //todo 2024年5月31日16:00:21 编辑的情况 先删后加  所以此处查不到数据 在删除的时候赋值
+//                        else {
+//                            //当前销售退货单无法获取源出库单数据
+//                            throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.UNABLE_TO_OBTAIN_SOURCE_DATA.getMessage());
+//                        }
                     }
                     }
                     //endregion
                     //endregion
 
 
@@ -690,7 +707,7 @@ public class InventoryService extends BaseService<Inventory> {
     )
     )
     public void operatingUpdateInventory(List<InOutRecordVO> inOutRecordVOList) {
     public void operatingUpdateInventory(List<InOutRecordVO> inOutRecordVOList) {
         //先删后加
         //先删后加
-        this.deleteInventory(inOutRecordVOList);
+        inOutRecordVOList = this.deleteInventory(inOutRecordVOList);
         //新建
         //新建
         inOutRecordVOList = this.operatingInsertInventory(inOutRecordVOList);
         inOutRecordVOList = this.operatingInsertInventory(inOutRecordVOList);
         //入库
         //入库
@@ -800,7 +817,7 @@ public class InventoryService extends BaseService<Inventory> {
         //存货资产
         //存货资产
         inventory.setCostAmt(costAmt);
         inventory.setCostAmt(costAmt);
         //存货单价
         //存货单价
-        inventory.setCostPrice(costAmt.compareTo(BigDecimal.ZERO) > 0 ?
+        inventory.setCostPrice(costAmt.compareTo(BigDecimal.ZERO) > 0 &&  inventory.getInvQty().compareTo(BigDecimal.ZERO) > 0 ?
                costAmt.divide(inventory.getInvQty(),BigDecimal.ROUND_HALF_UP) : BigDecimal.ZERO);
                costAmt.divide(inventory.getInvQty(),BigDecimal.ROUND_HALF_UP) : BigDecimal.ZERO);
         inventoryMapper.updateAmtAndQty(inventory);
         inventoryMapper.updateAmtAndQty(inventory);
         //endregion
         //endregion
@@ -1095,7 +1112,7 @@ public class InventoryService extends BaseService<Inventory> {
     @Transactional(
     @Transactional(
             rollbackFor = {Exception.class}
             rollbackFor = {Exception.class}
     )
     )
-    public void deleteInventory(List<InOutRecordVO> inOutRecordVOList) {
+    public List<InOutRecordVO> deleteInventory(List<InOutRecordVO> inOutRecordVOList) {
         for (InOutRecordVO inOutRecordVO : inOutRecordVOList) {
         for (InOutRecordVO inOutRecordVO : inOutRecordVOList) {
             //region  校验库存  根据sku,仓库,非标号查询
             //region  校验库存  根据sku,仓库,非标号查询
             InventoryResponse inventoryResponse = inventoryMapper.selectByOther(new InventoryQuery()
             InventoryResponse inventoryResponse = inventoryMapper.selectByOther(new InventoryQuery()
@@ -1153,6 +1170,10 @@ public class InventoryService extends BaseService<Inventory> {
                     inventoryBatch.setCostAmt(inventoryBatchResponse.getInvQty().multiply(outboundItemCostResponse.getCostPrice()));
                     inventoryBatch.setCostAmt(inventoryBatchResponse.getInvQty().multiply(outboundItemCostResponse.getCostPrice()));
                     inventoryBatchMapper.updateAmtAndQty(inventoryBatch);
                     inventoryBatchMapper.updateAmtAndQty(inventoryBatch);
                 }
                 }
+                //出库单价
+                inOutRecordVO.setPriceInto(outboundItemCostResponses.get(0).getCostPrice());
+                //金额
+                inOutRecordVO.setIntoAmt(outboundItemCostResponses.get(0).getCostPrice().multiply(inOutRecordVO.getIntoQty()).abs());
             }
             }
             //endregion
             //endregion
 
 
@@ -1182,8 +1203,8 @@ public class InventoryService extends BaseService<Inventory> {
                 outboundItemCostMapper.deleteData(inOutRecordVO.getBiznisItemId());
                 outboundItemCostMapper.deleteData(inOutRecordVO.getBiznisItemId());
             }
             }
             //endregion
             //endregion
-
         }
         }
+        return inOutRecordVOList;
     }
     }
 
 
     /**
     /**

+ 18 - 17
src/main/java/com/dk/mdm/service/ivt/outbound/OutboundSaleOrderService.java

@@ -184,8 +184,8 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
                 //供应商
                 //供应商
                 inboundVO.setSupId(outboundItemVOListGroup.get(0).getSupId());
                 inboundVO.setSupId(outboundItemVOListGroup.get(0).getSupId());
                 //入库状态等于已入库
                 //入库状态等于已入库
-                inboundVO.setIntoQty(sumIntoAmt)
-                        .setIntoAmt(sumIntoQty)
+                inboundVO.setIntoQty(sumIntoQty)
+                        .setIntoAmt(sumIntoAmt)
                         .setIntoingQty(BigDecimal.ZERO)
                         .setIntoingQty(BigDecimal.ZERO)
                         .setIntoingAmt(BigDecimal.ZERO);
                         .setIntoingAmt(BigDecimal.ZERO);
                 //来源id
                 //来源id
@@ -475,9 +475,10 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
     public ResponseResultVO<?> saleOrderOutboundInsertCollection(OutboundVO outboundVO) {
     public ResponseResultVO<?> saleOrderOutboundInsertCollection(OutboundVO outboundVO) {
         //新建销售出库
         //新建销售出库
         saleOrderOutboundInsert(outboundVO);
         saleOrderOutboundInsert(outboundVO);
-        //新建退款
+        //新建收款退款
         RecPayVO recPayVO = new RecPayVO();
         RecPayVO recPayVO = new RecPayVO();
         recPayVO.setObjectId(outboundVO.getObjectId());
         recPayVO.setObjectId(outboundVO.getObjectId());
+        recPayVO.setCusPhone(outboundVO.getCusPhone());
         recPayVO.setOrgId(outboundVO.getOrgId());
         recPayVO.setOrgId(outboundVO.getOrgId());
         recPayVO.setStaffId(outboundVO.getStaffId());
         recPayVO.setStaffId(outboundVO.getStaffId());
         recPayVO.setAccDate(outboundVO.getAccDate());
         recPayVO.setAccDate(outboundVO.getAccDate());
@@ -531,9 +532,8 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
             BigDecimal sumAmt = outboundVO.getItemList().stream().map(OutboundItemVO::getOutingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
             BigDecimal sumAmt = outboundVO.getItemList().stream().map(OutboundItemVO::getOutingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
             //endregion
             //endregion
 
 
-            //region  自动办理参数为true  已入库编辑
-            //自动办理参数为true
-            if (Constant.FlgHandleSetting.TRUE.getValue().equals(outboundVO.getFlgHandleSetting())) {
+            //region  已入库编辑
+            if (Constant.OutStatus.YICHUKU.getName().equals(outboundVO.getOutStatus())) {
                 //region 应收反记账
                 //region 应收反记账
                 if (outboundVO.getReceivableId() != null) {
                 if (outboundVO.getReceivableId() != null) {
                     accountService.reverseReceivable(outboundVO.getOutId(), Constant.InventoryDocCode.OUTBOUND.getTableName());
                     accountService.reverseReceivable(outboundVO.getOutId(), Constant.InventoryDocCode.OUTBOUND.getTableName());
@@ -719,15 +719,20 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
                 this.deleteOutsideGoodsInto(outboundVO, outsideGoods);
                 this.deleteOutsideGoodsInto(outboundVO, outsideGoods);
                 //新建外协品生产外协入库单
                 //新建外协品生产外协入库单
                 this.insertOutsideGoodsInto(outboundVO, outsideGoods);
                 this.insertOutsideGoodsInto(outboundVO, outsideGoods);
-                List<OutboundItemVO> delOutsideGoods = outboundVO.getDeleteItemList().stream().filter(it -> it.getSkuId() == null).collect(Collectors.toList());
-                //删除外协品生产外协入库单
-                this.deleteOutsideGoodsInto(outboundVO, delOutsideGoods);
+                if(outboundVO.getDeleteItemList() != null){
+                    List<OutboundItemVO> delOutsideGoods = outboundVO.getDeleteItemList().stream().filter(it -> it.getSkuId() == null).collect(Collectors.toList());
+                    //删除外协品生产外协入库单
+                    this.deleteOutsideGoodsInto(outboundVO, delOutsideGoods);
+                }
                 //endregion
                 //endregion
 
 
                 //region 修改库存
                 //region 修改库存
                 //筛选出skuId不为空的 走库存
                 //筛选出skuId不为空的 走库存
                 List<OutboundItemVO> invList = outboundVO.getItemList().stream().filter(it -> it.getSkuId() != null).collect(Collectors.toList());
                 List<OutboundItemVO> invList = outboundVO.getItemList().stream().filter(it -> it.getSkuId() != null).collect(Collectors.toList());
-                List<OutboundItemVO> invDelList = outboundVO.getDeleteItemList().stream().filter(it -> it.getSkuId() != null).collect(Collectors.toList());
+                List<OutboundItemVO> invDelList = null;
+                if(outboundVO.getDeleteItemList() != null){
+                    invDelList = outboundVO.getDeleteItemList().stream().filter(it -> it.getSkuId() != null).collect(Collectors.toList());
+                }
                 if ((invList != null && invList.size() > 0) || (invDelList != null && invDelList.size() > 0)) {
                 if ((invList != null && invList.size() > 0) || (invDelList != null && invDelList.size() > 0)) {
                     Map<String, Object> invMap = new HashMap<>();
                     Map<String, Object> invMap = new HashMap<>();
                     invMap.put("outDetail", invList);
                     invMap.put("outDetail", invList);
@@ -735,14 +740,12 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
                     inventoryService.operatingInventoryInformation(invMap);
                     inventoryService.operatingInventoryInformation(invMap);
                 }
                 }
                 //endregion
                 //endregion
-            } else {
-                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.FLG_HANDLE_SETTING_NOT_ENABLED_OUT.getMessage());
             }
             }
             //endregion
             //endregion
 
 
-            //region 自动办理参数false  入库中编辑
-            //自动办理标识为false 并且 自动办理参数为false  入库中
-            if (!outboundVO.getFlgAutoHandle() && Constant.FlgHandleSetting.FALSE.getValue().equals(outboundVO.getFlgHandleSetting())) {
+            //region 入库中编辑
+            if (Constant.OutStatus.CHUKUZHONG.getName().equals(outboundVO.getOutStatus()) ||
+                    Constant.OutStatus.DAICHUKU.getName().equals(outboundVO.getOutStatus())) {
                 //region 修改明细
                 //region 修改明细
                 List<OutboundItemVO> itemList = outboundVO.getItemList();
                 List<OutboundItemVO> itemList = outboundVO.getItemList();
                 for (OutboundItemVO outboundItemVO : itemList) {
                 for (OutboundItemVO outboundItemVO : itemList) {
@@ -877,8 +880,6 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
                     }
                     }
                 }
                 }
                 //endregion
                 //endregion
-            } else {
-                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.FLG_HANDLE_SETTING_NOT_ENABLED_OUT.getMessage());
             }
             }
             //endregion
             //endregion
         }
         }

+ 2 - 1
src/main/java/com/dk/mdm/service/ivt/outbound/OutboundSaleReturnService.java

@@ -296,7 +296,8 @@ public class OutboundSaleReturnService extends BaseService<Outbound> {
         saleReturnOutboundInsert(outboundVO);
         saleReturnOutboundInsert(outboundVO);
       //新建退款
       //新建退款
         RecPayVO recPayVO = new RecPayVO();
         RecPayVO recPayVO = new RecPayVO();
-        recPayVO.setObjectId(outboundVO.getObjectId());
+        recPayVO.setObjectId(outboundVO.getCusId());
+        recPayVO.setCusPhone(outboundVO.getCusPhone());
         recPayVO.setOrgId(outboundVO.getOrgId());
         recPayVO.setOrgId(outboundVO.getOrgId());
         recPayVO.setStaffId(outboundVO.getStaffId());
         recPayVO.setStaffId(outboundVO.getStaffId());
         recPayVO.setAccDate(outboundVO.getAccDate());
         recPayVO.setAccDate(outboundVO.getAccDate());

+ 14 - 5
src/main/java/com/dk/mdm/service/mac/ReceiptService.java

@@ -26,10 +26,12 @@ import com.dk.mdm.model.pojo.mst.MoneyAccountItem;
 import com.dk.mdm.model.query.mac.RecPayHandleItemQuery;
 import com.dk.mdm.model.query.mac.RecPayHandleItemQuery;
 import com.dk.mdm.model.query.mac.RecPayItemQuery;
 import com.dk.mdm.model.query.mac.RecPayItemQuery;
 import com.dk.mdm.model.query.mac.RecPayQuery;
 import com.dk.mdm.model.query.mac.RecPayQuery;
+import com.dk.mdm.model.query.mst.CustomerQuery;
 import com.dk.mdm.model.query.mst.SaleChannelQuery;
 import com.dk.mdm.model.query.mst.SaleChannelQuery;
 import com.dk.mdm.model.response.mac.RecPayHandleItemResponse;
 import com.dk.mdm.model.response.mac.RecPayHandleItemResponse;
 import com.dk.mdm.model.response.mac.RecPayItemResponse;
 import com.dk.mdm.model.response.mac.RecPayItemResponse;
 import com.dk.mdm.model.response.mac.RecPayResponse;
 import com.dk.mdm.model.response.mac.RecPayResponse;
+import com.dk.mdm.model.response.mst.CustomerResponse;
 import com.dk.mdm.model.response.mst.SaleChannelResponse;
 import com.dk.mdm.model.response.mst.SaleChannelResponse;
 import com.dk.mdm.model.vo.mac.RecPayHandleItemVO;
 import com.dk.mdm.model.vo.mac.RecPayHandleItemVO;
 import com.dk.mdm.model.vo.mac.RecPayItemVO;
 import com.dk.mdm.model.vo.mac.RecPayItemVO;
@@ -192,7 +194,7 @@ public class ReceiptService extends BaseService<RecPay> {
 //        客户的新增和更新跟进人
 //        客户的新增和更新跟进人
         // 如果没有客户id,要新建
         // 如果没有客户id,要新建
         if (recPay.getObjectId() == null) {
         if (recPay.getObjectId() == null) {
-            List<Customer> listCustomer = customerMapper.selectByCond(new Customer().setCpId(recPay.getCpId()).setCusPhone(recPayVO.getCusPhone()));
+            List<CustomerResponse> listCustomer = customerMapper.selectByCond(new CustomerQuery().setCpId(recPay.getCpId()).setCusPhone(recPayVO.getCusPhone()));
             // 如果客户电话已存在
             // 如果客户电话已存在
             if (listCustomer == null || listCustomer.size() == 0) {
             if (listCustomer == null || listCustomer.size() == 0) {
                 String channelId;
                 String channelId;
@@ -338,10 +340,17 @@ public class ReceiptService extends BaseService<RecPay> {
 
 
         // 更新账款总表上收款的相关字段
         // 更新账款总表上收款的相关字段
         Account accountUpdate = new Account();
         Account accountUpdate = new Account();
-        accountUpdate.setReceipt(accountForUpdate.getReceipt().add(recPayVO.getSumAmtRec()))// 总收款金额
-                .setReceiptResidue(accountForUpdate.getReceiptResidue().add(recPayVO.getSumAmtRec()))//  可退金额
-                .setObjectId(accountForUpdate.getObjectId());
-        accountService.updateByUuid(accountUpdate);
+        // 新建
+        if(accountForUpdate == null ){
+            // TODO 退货新客户插入的问题
+        }else{
+            // 说明已经存在
+            accountUpdate.setReceipt(accountForUpdate.getReceipt().add(recPayVO.getSumAmtRec()))// 总收款金额
+                    .setReceiptResidue(accountForUpdate.getReceiptResidue().add(recPayVO.getSumAmtRec()))//  可退金额
+                    .setObjectId(accountForUpdate.getObjectId());
+            accountService.updateByUuid(accountUpdate);
+        }
+
         return ResponseResultUtil.success();
         return ResponseResultUtil.success();
     }
     }
 
 

+ 1 - 1
src/main/java/com/dk/mdm/service/report/ReportService.java

@@ -135,7 +135,7 @@ public class ReportService {
             dataList= reportMapper.getOutboundDetailReport(param);
             dataList= reportMapper.getOutboundDetailReport(param);
         }
         }
         data.setList(dataList);
         data.setList(dataList);
-        data.setTotal(reportMapper.getSalesTrackingReportCount(param));
+        data.setTotal(reportMapper.getOutboundDetailReportCount(param));
         data.setPageSize((Integer) param.get("pageSize"));
         data.setPageSize((Integer) param.get("pageSize"));
         data.setCurrentPage((Integer) param.get("currentPage"));
         data.setCurrentPage((Integer) param.get("currentPage"));
         return ResponseResultUtil.success(data);
         return ResponseResultUtil.success(data);

+ 12 - 9
src/main/java/com/dk/mdm/service/sale/OrderService.java

@@ -405,18 +405,21 @@ public class OrderService extends BaseService<Order> {
         // 转化实体
         // 转化实体
         Order order = orderConvert.convertToPo(orderVO);
         Order order = orderConvert.convertToPo(orderVO);
         //删除的
         //删除的
-        List<OrderItemVO> deleteOrderItemVOList = orderVO.getDeleteItemList().stream().filter(it -> it.getItemId() != null).collect(Collectors.toList());
-        if (deleteOrderItemVOList.size() > 0) {
-            for (OrderItemVO orderItemVO : deleteOrderItemVOList) {
-                orderItemForUpdate = orderItemMapper.selectByIdForUpdate(orderItemVO.getItemId());
-                // 非待出库单据不能删除
-                if (!Constant.OutStatus.DAICHUKU.getName().equals(orderItemForUpdate.getOutStatus())) {
-                    throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.NO_WAIT_INTO.getMessage());
-                } else {
-                    orderItemMapper.deleteById(orderItemVO.getItemId());
+        if(orderVO.getDeleteItemList() != null){
+            List<OrderItemVO> deleteOrderItemVOList = orderVO.getDeleteItemList().stream().filter(it -> it.getItemId() != null).collect(Collectors.toList());
+            if (deleteOrderItemVOList.size() > 0) {
+                for (OrderItemVO orderItemVO : deleteOrderItemVOList) {
+                    orderItemForUpdate = orderItemMapper.selectByIdForUpdate(orderItemVO.getItemId());
+                    // 非待出库单据不能删除
+                    if (!Constant.OutStatus.DAICHUKU.getName().equals(orderItemForUpdate.getOutStatus())) {
+                        throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.NO_WAIT_INTO.getMessage());
+                    } else {
+                        orderItemMapper.deleteById(orderItemVO.getItemId());
+                    }
                 }
                 }
             }
             }
         }
         }
+
         // 新增的
         // 新增的
         List<OrderItemVO> insertOrderItemVOList = orderVO.getItemList().stream().filter(it -> it.getItemId() == null).collect(Collectors.toList());
         List<OrderItemVO> insertOrderItemVOList = orderVO.getItemList().stream().filter(it -> it.getItemId() == null).collect(Collectors.toList());
         for (OrderItemVO orderItemVO : insertOrderItemVOList) {
         for (OrderItemVO orderItemVO : insertOrderItemVOList) {