Przeglądaj źródła

Merge branch 'master' of http://git.dongkesoft.com:9001/iBOSS-2.0-Mini/iboss-server-mdm

zhoux 1 rok temu
rodzic
commit
cbb1758ea5

+ 16 - 3
src/main/java/com/dk/mdm/mapper/ivt/OutboundItemMapper.xml

@@ -124,10 +124,8 @@ sys.f_remove_zero(out_qty) as out_qty, out_amt, sys.f_remove_zero(return_qty) as
         <result column="out_piece" property="outPiece"/>
         <result column="unit_id" property="unitId"/>
         <result column="unit_code" property="unitCode"/>
-        <result column="unit_name" property="unitName"/>
         <result column="sub_unit_id" property="subUnitId"/>
         <result column="sub_unit_code" property="subUnitCode"/>
-        <result column="sub_unit_name" property="subUnitName"/>
         <result column="pack_box" property="packBox"/>
         <result column="flgSubUnit" property="flgSubUnit"/>
         <result column="subUnitName" property="subUnitName"/>
@@ -258,7 +256,11 @@ 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",
         ul.decimal_places    as "decimalPlaces",
         tpoi.sup_id,
-        tms.sup_name
+        tms.sup_name,
+        tpoi.unit_id,
+        tpoi.sub_unit_id,
+        ul.unit_name as "unitName",
+        u2.unit_name as "subUnitName"
         FROM dkic_b.t_psi_outbound_item as tpoi
         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
@@ -469,11 +471,22 @@ sys.f_remove_zero(out_qty) as out_qty, out_amt, sys.f_remove_zero(return_qty) as
                sys.f_remove_zero(tpi.usable_qty)           as "usableQty",
                tmw.wh_name              as "whName"
                 ,tmgu.decimal_places    as "decimalPlaces"
+               ,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.outing_box,t.outing_piece) AS "outingBoxPiece"
+               ,dkic_b.f_box_piece(u2.unit_name,ul.unit_name,t.out_box,t.out_piece) AS "outBoxPiece"
+                ,sys.f_get_name_i18n(tdk.kind_name_i18n, #{i18n}) as "outStatusName"
+                ,t.out_status
         FROM dkic_b.t_psi_outbound_item as t
                  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_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 u2 ON t.sub_unit_id = u2.unit_id
+                 left join sys.t_data_kind as tdk on tdk.kind_code = t.out_status
         where t.flg_valid
           and t.out_id = #{id}::uuid
         order by t.item_index

+ 226 - 21
src/main/java/com/dk/mdm/mapper/report/ReportMapper.xml

@@ -292,9 +292,17 @@
     <!-- 出库明细报表明细条件列 -->
     <sql id="Condition_OutboundDetailReport">
         <where>
+            t.flg_valid
             <if test="cpId != null">
                 AND t.cp_id = #{cpId}
             </if>
+            <if test="outTypeRList != null and outTypeRList.size()>0">
+                AND t.out_type =any(#{outTypeRList,typeHandler=StringListTypeHandler})
+            </if>
+            <if test="outTypeRList == null || outTypeRList.size()==0">
+                AND (t.out_type = '出库类型-其他出库'
+                    or t.out_type =  '出库类型-销售出库')
+            </if>
             <if test="outNo != null and outNo != ''">
                 AND t.out_no LIKE concat('%',my_ex.likequery(#{outNo}),'%')
             </if>
@@ -348,12 +356,116 @@
             <if test="skuModel != null and skuModel != ''">
                 AND tmgs.sku_model like concat('%', my_ex.likequery(#{skuModel}) , '%')
             </if>
+            <if test="brandName != null and brandName != ''">
+                AND tmgb.brand_name like concat('%', my_ex.likequery(#{brandName}) , '%')
+            </if>
+            <if test="whName != null and whName != ''">
+                AND tmw.wh_name like concat('%', my_ex.likequery(#{whName}) , '%')
+            </if>
+            <if test="nonStdCode != null and nonStdCode != ''">
+                AND tpi.non_std_code like concat('%', my_ex.likequery(#{nonStdCode}) , '%')
+            </if>
+            <if test="searchText !=null and searchText != ''">
+                AND (
+                t.out_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>
             <if test="whList != null  and whList.size()>0">
                 AND tpi.wh_id =
                 any(#{whList,typeHandler=UuidListTypeHandler})
             </if>
         </where>
     </sql>
+
+    <!-- 出库明细报表明细条件列-入库类型-采退入库 -->
+    <sql id="Condition_OutInboundDetailReport">
+        <where>
+            tpi.flg_valid
+            <if test="cpId != null">
+                AND tpi.cp_id = #{cpId}
+            </if>
+            <if test="outTypeRList != null and outTypeRList.size()>0">
+                AND tpi.into_type =any(#{outTypeRList,typeHandler=StringListTypeHandler})
+            </if>
+            <if test="outTypeRList == null || outTypeRList.size()==0">
+                AND tpi.into_type = '入库类型-采退入库'
+            </if>
+            <if test="outNo != null and outNo != ''">
+                AND tpi.into_no LIKE concat('%',my_ex.likequery(#{outNo}),'%')
+            </if>
+            <if test="supIdlist != null and supIdlist.size()>0">
+                AND tpi.sup_id = any(#{supIdlist,typeHandler=UuidListTypeHandler})
+            </if>
+
+            <if test="outTypeList != null and outTypeList.size()>0">
+                AND tpi.into_type =any(#{outTypeList,typeHandler=StringListTypeHandler})
+            </if>
+            <if test="fromNo != null and fromNo != ''">
+                AND tpi.from_no LIKE concat('%',my_ex.likequery(#{fromNo}),'%')
+            </if>
+            <if test="cusName != null and cusName != ''">
+                AND tmc.cus_name LIKE concat('%',my_ex.likequery(#{cusName}),'%')
+            </if>
+            <if test="orgIdList != null and orgIdList.size() > 0">
+                AND tpi.org_id =any(#{orgIdList, typeHandler=uuidListTypeHandler})
+            </if>
+            <if test="staffIdList != null and staffIdList.size() > 0">
+                AND tpi.staff_id =any(#{staffIdList, typeHandler=uuidListTypeHandler})
+            </if>
+            <if test="outStatusList != null and outStatusList.size() > 0">
+                AND tpi.into_status =any(#{outStatusList, typeHandler=StringListTypeHandler})
+            </if>
+            <if test="outDateStart != null and outDateEnd != null">
+                AND tpi.out_date &gt;= #{outDateStart}::timestamp with time zone
+                AND tpi.out_date &lt; #{outDateEnd}::timestamp with time zone + interval '1 day'
+            </if>
+            <if test="makeTimeStart != null and makeTimeEnd != null">
+                AND tpi.make_time &gt;= #{makeTimeStart}::timestamp with time zone
+                AND tpi.make_time &lt; #{makeTimeEnd}::timestamp with time zone + interval '1 day'
+            </if>
+            <if test="goodsSeriesList != null  and goodsSeriesList.size()>0">
+                AND tmgs.series_id =
+                any(#{goodsSeriesList,typeHandler=UuidListTypeHandler})
+            </if>
+            <if test="goodsCategoryList != null  and goodsCategoryList.size()>0">
+                AND tmgs.category_id =
+                any(#{goodsCategoryList,typeHandler=UuidListTypeHandler})
+            </if>
+            <if test="goodsBrandList != null  and goodsBrandList.size()>0">
+                AND tmgs.brand_id =
+                any(#{goodsBrandList,typeHandler=UuidListTypeHandler})
+            </if>
+            <if test="skuName != null and skuName != ''">
+                AND tmgs.sku_name like concat('%', my_ex.likequery(#{skuName}) , '%')
+            </if>
+            <if test="skuModel != null and skuModel != ''">
+                AND tmgs.sku_model like concat('%', my_ex.likequery(#{skuModel}) , '%')
+            </if>
+            <if test="brandName != null and brandName != ''">
+                AND tmgb.brand_name like concat('%', my_ex.likequery(#{brandName}) , '%')
+            </if>
+            <if test="whName != null and whName != ''">
+                AND tmw.wh_name like concat('%', my_ex.likequery(#{whName}) , '%')
+            </if>
+            <if test="nonStdCode != null and nonStdCode != ''">
+                AND tpii.non_std_code like concat('%', my_ex.likequery(#{nonStdCode}) , '%')
+            </if>
+            <if test="searchText !=null and searchText != ''">
+                AND (
+                tpi.into_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>
+            <if test="whList != null  and whList.size()>0">
+                AND tpii.wh_id =
+                any(#{whList,typeHandler=UuidListTypeHandler})
+            </if>
+        </where>
+    </sql>
+
     <!-- 出库明细报表主表条件列 -->
     <sql id="Condition_OutboundReport">
         <where>
@@ -900,6 +1012,7 @@
     </select>
     <!-- 出库明细报表明细 -->
     <select id="getOutboundDetailReport" resultType="java.util.Map">
+        select * from (
         select
         t.out_id as "outId"
         ,t.out_no as "outNo"
@@ -935,15 +1048,16 @@
         ,tmgc.cat_name as "catName"
         ,series.series_name as "seriesName"
         ,sys.f_remove_zero(tpoi.outing_qty) as "outingQty"
-        ,concat(sys.f_remove_zero(tpoi.outing_qty),tmgu.unit_name)  as "outingQtyPiece"
+        ,concat(sys.f_remove_zero(tpoi.outing_qty),tmgu.unit_name) as "outingQtyPiece"
         ,tpoi.outing_amt as "outingAmt"
-        ,concat(sys.f_remove_zero(tpoi.out_qty),tmgu.unit_name)   as "outQtyPiece"
+        ,concat(sys.f_remove_zero(tpoi.out_qty),tmgu.unit_name) as "outQtyPiece"
         ,sys.f_remove_zero(tpoi.out_qty) as "outQty"
         ,tpoi.out_amt as "outAmt"
         ,sys.f_remove_zero(tpoi.return_qty) as "returnQty"
         ,tpoi.return_amt as "returnAmt"
         ,dkic_b.f_box_piece(tmgus.unit_name,tmgu.unit_name,tpoi.outing_box,tpoi.outing_piece) as "outingBoxPiece"
         ,dkic_b.f_box_piece(tmgus.unit_name,tmgu.unit_name,tpoi.out_box,tpoi.out_piece) as "outBoxPiece"
+        ,t.op_update_time
         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
@@ -963,31 +1077,122 @@
         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"/>
-        order by tpoi.op_create_time desc
+        union all
+        select
+        tpi.into_id as "outId"
+        ,tpi.into_no as "outNo"
+        ,tpi.from_no as "fromNo"
+        ,tmo.org_name as "orgName"
+        ,tms.staff_name as "staffName"
+        ,tmc.cus_id as "cusId"
+        ,tmc.cus_name as "cusName"
+        ,tmc.cus_phone as "cusPhone"
+        ,tmc.cus_from as "cusFrom"
+        ,tmc.contact_phone as "contactPhone"
+        ,tmc.address_full as "addressFull"
+        ,tmdd.data_value as cus_from_name
+        ,tmp.sup_name as "supplierName"
+        ,sys.f_get_name_i18n(tdk1.kind_name_i18n, #{i18n}) as "outStatusName"
+        ,sys.f_get_name_i18n(tdktype.kind_name_i18n, #{i18n}) as "outTypeName"
+        ,sys.f_remove_zero(tpi.intoing_qty) as "outingQtySum"
+        ,tpi.intoing_amt as "outingAmtSum"
+        ,sys.f_remove_zero(tpi.into_qty) as "outQtySum"
+        ,tpi.into_amt as "outAmtSum"
+        ,sys.f_remove_zero(tpi.return_qty) as "returnOutQtySum"
+        ,tpi.return_amt as "returnOutAmtSum"
+        ,tpi.into_date as "outDate"
+        ,tpi.remarks
+        ,makestaff.staff_name as "makeStaffName"
+        ,tmgs.sku_name as "skuName"
+        ,tmgs.sku_model as "skuModel"
+        ,tmgs.sku_spec as "skuSpec"
+        ,tpii.non_std_code as "nonStdCode"
+        ,tmgb.short_name as "shortName"
+        ,tmgb.brand_name as "brandName"
+        ,tmw.wh_name as "whName"
+        ,tmgc.cat_name as "catName"
+        ,series.series_name as "seriesName"
+        ,sys.f_remove_zero(tpii.intoing_qty) as "outingQty"
+        ,concat(sys.f_remove_zero(abs(tpii.intoing_qty)),tmgu.unit_name) as "outingQtyPiece"
+        ,tpii.intoing_amt as "outingAmt"
+        ,concat(sys.f_remove_zero(abs(tpii.into_qty)),tmgu.unit_name) as "outQtyPiece"
+        ,sys.f_remove_zero(tpii.into_qty) as "outQty"
+        ,tpii.into_amt as "outAmt"
+        ,sys.f_remove_zero(tpii.return_qty) as "returnQty"
+        ,tpii.return_amt as "returnAmt"
+        ,dkic_b.f_box_piece(tmgus.unit_name,tmgu.unit_name,abs(tpii.intoing_box),abs(tpii.intoing_piece)) as "outingBoxPiece"
+        ,dkic_b.f_box_piece(tmgus.unit_name,tmgu.unit_name,abs(tpii.into_box),abs(tpii.into_piece)) as "outBoxPiece"
+        ,tpi.op_update_time
+        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
+        <include refid="Condition_OutInboundDetailReport"/>
+        ) tt
+        order by tt.op_update_time desc
         <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
             limit #{end} offset #{start}
         </if>
     </select>
     <!-- 出库明细报表明细Count-->
     <select id="getOutboundDetailReportCount" resultType="java.lang.Long">
-        SELECT count(1)
-        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
-        <include refid="Condition_OutboundDetailReport"/>
+        SELECT
+        count(1) from (
+            SELECT 1
+            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
+            <include refid="Condition_OutboundDetailReport"/>
+            union all
+            select
+            1
+            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
+            <include refid="Condition_OutInboundDetailReport"/>
+        )
     </select>
     <!-- 入库明细报表主表 -->
     <select id="getInboundlReport" resultType="java.util.Map">