|
|
|
|
@@ -49,141 +49,322 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
|
</where>
|
|
|
|
|
</select>
|
|
|
|
|
<select id="selectViewInOrOutList" parameterType="ViewInOrOut" resultMap="ViewInOrOutResult">
|
|
|
|
|
select bp.product_id,bp.product_name,b.*,bcs.cy * model as cy,'' as begin_date,'' as end_date,'' as lot_no from (select a.classgroup_number,sum(xs_quantity) as sc_in_qty,sum(cg_quantity) as cg_in_qty,sum(ll_quantity) as ll_in_qty ,sum(quantity) as quantity,sum(xs_out_qty) as xs_out_qty,sum(ll_out_qty) as ll_out_qty,sum(yi_out_qty) as yi_out_qty,sum(qt_out_qty) as qt_out_qty,sum(out_qty) as out_qty,sum(stock_qty) as stock_qty,sum(bh_qty) as bh_qty,sum(wbh_qty) as wbh_qty from (
|
|
|
|
|
----------生产汇总-----------
|
|
|
|
|
select mjdf.length as classgroup_number,sum(in_quantity * spec) as xs_quantity,0 as cg_quantity ,0 as ll_quantity ,0 as quantity ,0 as xs_out_qty,0 as ll_out_qty,0 as yi_out_qty,0 as qt_out_qty,0 as out_qty,0 as stock_qty,0 as bh_qty,0 as wbh_qty from mydo_job_detail_finish mjdf
|
|
|
|
|
inner join mydo_job_finish mjf on mjf.job_id = mjdf.job_id
|
|
|
|
|
inner join in_stockin_finish isi on mjdf.in_or_out_id = isi.stockin_id
|
|
|
|
|
where mjf.status = 4 and isi.in_type in (4) and mjf.in_or_out != 2 and mjf.job_id like'RK%'
|
|
|
|
|
<if test="beginDate != null and beginDate != ''"> and mjf.finish_time >= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>
|
|
|
|
|
<if test="endDate != null and endDate != ''"> and mjf.finish_time <= #{endDate}</if>
|
|
|
|
|
<if test="lotNo != null and lotNo != ''"> and mjdf.lot_no like concat('%', #{lotNo}, '%')</if>
|
|
|
|
|
group by mjdf.length
|
|
|
|
|
union
|
|
|
|
|
----------采购汇总-----------
|
|
|
|
|
select mjdf.length as classgroup_number,0 as xs_quantity,sum(in_quantity * spec) as cg_quantity ,0 as ll_quantity ,0 as quantity ,0 as xs_out_qty,0 as ll_out_qty,0 as yi_out_qty,0 as qt_out_qty,0 as out_qty,0 as stock_qty,0 as bh_qty,0 as wbh_qty from mydo_job_detail_finish mjdf
|
|
|
|
|
inner join mydo_job_finish mjf on mjf.job_id = mjdf.job_id
|
|
|
|
|
inner join in_stockin_finish isi on mjdf.in_or_out_id = isi.stockin_id
|
|
|
|
|
where mjf.status = 4 and isi.in_type in (1) and mjf.in_or_out != 2 and mjf.job_id like'RK%'
|
|
|
|
|
<if test="beginDate != null and beginDate != ''"> and mjf.finish_time >= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>
|
|
|
|
|
<if test="endDate != null and endDate != ''"> and mjf.finish_time <= #{endDate}</if>
|
|
|
|
|
<if test="lotNo != null and lotNo != ''"> and mjdf.lot_no like concat('%', #{lotNo}, '%')</if>
|
|
|
|
|
group by mjdf.length
|
|
|
|
|
union
|
|
|
|
|
----------移入汇总-----------
|
|
|
|
|
select mjdf.length as classgroup_number,0 as xs_quantity,0 as cg_quantity ,sum(in_quantity * spec) as ll_quantity ,0 as quantity ,0 as xs_out_qty,0 as ll_out_qty,0 as yi_out_qty,0 as qt_out_qty,0 as out_qty,0 as stock_qty,0 as bh_qty,0 as wbh_qty from mydo_job_detail_finish mjdf
|
|
|
|
|
inner join mydo_job_finish mjf on mjf.job_id = mjdf.job_id
|
|
|
|
|
inner join in_stockin_finish isi on mjdf.in_or_out_id = isi.stockin_id
|
|
|
|
|
where mjf.status = 4 and isi.in_type in (2) and mjf.in_or_out != 2 and mjf.job_id like'RK%'
|
|
|
|
|
<if test="beginDate != null and beginDate != ''"> and mjf.finish_time >= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>
|
|
|
|
|
<if test="endDate != null and endDate != ''"> and mjf.finish_time <= #{endDate}</if>
|
|
|
|
|
<if test="lotNo != null and lotNo != ''"> and mjdf.lot_no like concat('%', #{lotNo}, '%')</if>
|
|
|
|
|
group by mjdf.length
|
|
|
|
|
union
|
|
|
|
|
----------入库汇总-----------
|
|
|
|
|
select mjdf.length as classgroup_number,0 as xs_quantity,0 as cg_quantity ,0 as ll_quantity ,sum(in_quantity * spec) as quantity ,0 as xs_out_qty,0 as ll_out_qty,0 as yi_out_qty,0 as qt_out_qty,0 as out_qty,0 as stock_qty,0 as bh_qty,0 as wbh_qty from mydo_job_detail_finish mjdf
|
|
|
|
|
inner join mydo_job_finish mjf on mjf.job_id = mjdf.job_id
|
|
|
|
|
inner join in_stockin_finish isi on mjdf.in_or_out_id = isi.stockin_id
|
|
|
|
|
where mjf.status = 4 and isi.in_type in (1,2,6,4) and mjf.in_or_out != 2 and mjf.job_id like'RK%'
|
|
|
|
|
<if test="beginDate != null and beginDate != ''"> and mjf.finish_time >= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>
|
|
|
|
|
<if test="endDate != null and endDate != ''"> and mjf.finish_time <= #{endDate}</if>
|
|
|
|
|
<if test="lotNo != null and lotNo != ''"> and mjdf.lot_no like concat('%', #{lotNo}, '%')</if>
|
|
|
|
|
group by mjdf.length
|
|
|
|
|
union
|
|
|
|
|
----------备货库存汇总-----------
|
|
|
|
|
select bs.classgroup_number,0 as xs_quantity,0 as cg_quantity ,0 as ll_quantity,0 as quantity ,0 as xs_out_qty,0 as ll_out_qty,0 as yi_out_qty,0 as qt_out_qty,0 as out_qty,0 as stock_qty,sum(bs.quantity * in_class_name) as bh_qty,0 as wbh_qty from bas_stock bs
|
|
|
|
|
inner join bas_cargo_space bcs on bcs.cargo_space_id = bs.cargo_space_id and bcs.tray_code = bs.tray_code
|
|
|
|
|
where bcs.status = 2 and bs.class_now_date_time = '1'
|
|
|
|
|
<if test="endDate != null and endDate != ''"> and bs.in_date <= #{endDate1}</if>
|
|
|
|
|
<if test="lotNo != null and lotNo != ''"> and bs.lot_no like concat('%', #{lotNo}, '%')</if>
|
|
|
|
|
group by bs.classgroup_number
|
|
|
|
|
union
|
|
|
|
|
----------未备货库存汇总-----------
|
|
|
|
|
select bs.classgroup_number,0 as xs_quantity,0 as cg_quantity ,0 as ll_quantity,0 as quantity ,0 as xs_out_qty,0 as ll_out_qty,0 as yi_out_qty,0 as qt_out_qty,0 as out_qty,0 as stock_qty,0 as bh_qty,sum(bs.quantity * in_class_name) as wbh_qty from bas_stock bs
|
|
|
|
|
inner join bas_cargo_space bcs on bcs.cargo_space_id = bs.cargo_space_id and bcs.tray_code = bs.tray_code
|
|
|
|
|
where bcs.status = 2 and bs.class_now_date_time = '0'
|
|
|
|
|
<if test="endDate != null and endDate != ''"> and bs.in_date <= #{endDate1}</if>
|
|
|
|
|
<if test="lotNo != null and lotNo != ''"> and bs.lot_no like concat('%', #{lotNo}, '%')</if>
|
|
|
|
|
group by bs.classgroup_number
|
|
|
|
|
union
|
|
|
|
|
----------总库存汇总-----------
|
|
|
|
|
select bs.classgroup_number,0 as xs_quantity,0 as cg_quantity ,0 as ll_quantity,0 as quantity ,0 as xs_out_qty,0 as ll_out_qty,0 as yi_out_qty,0 as qt_out_qty,0 as out_qty,sum(bs.quantity * in_class_name) as stock_qty,0 as bh_qty,0 as wbh_qty from bas_stock bs
|
|
|
|
|
inner join bas_cargo_space bcs on bcs.cargo_space_id = bs.cargo_space_id and bcs.tray_code = bs.tray_code
|
|
|
|
|
where bcs.status = 2
|
|
|
|
|
<if test="endDate != null and endDate != ''"> and bs.in_date <= #{endDate1}</if>
|
|
|
|
|
<if test="lotNo != null and lotNo != ''"> and bs.lot_no like concat('%', #{lotNo}, '%')</if>
|
|
|
|
|
group by bs.classgroup_number
|
|
|
|
|
union
|
|
|
|
|
----------销售出库汇总-----------
|
|
|
|
|
select length as classgroup_number,0 as xs_quantity,0 as cg_quantity ,0 as ll_quantity,0 as quantity ,sum(out_quantity * spec) as xs_out_qty,0 as ll_out_qty,0 as yi_out_qty,0 as qt_out_qty,sum(out_quantity * spec) as out_qty,0 as stock_qty,0 as bh_qty,0 as wbh_qty from mydo_job_detail_finish
|
|
|
|
|
where job_detail_id in (
|
|
|
|
|
select mjdf.job_detail_id from mydo_job_detail_finish mjdf
|
|
|
|
|
inner join mydo_job_finish mjf on mjf.job_id = mjdf.job_id
|
|
|
|
|
inner join out_stockout_detail_finish osdf on mjdf.in_or_out_id = osdf.stockout_id
|
|
|
|
|
inner join out_stockout_finish osf on mjdf.in_or_out_id = osf.stockout_id
|
|
|
|
|
where mjf.status = 4 and osf.out_type = 10 and mjf.in_or_out > 9
|
|
|
|
|
<if test="beginDate != null and beginDate != ''"> and mjf.finish_time >= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>
|
|
|
|
|
<if test="endDate != null and endDate != ''"> and mjf.finish_time <= #{endDate}</if>
|
|
|
|
|
<if test="lotNo != null and lotNo != ''"> and mjdf.lot_no like concat('%', #{lotNo}, '%')</if>
|
|
|
|
|
group by mjdf.job_detail_id
|
|
|
|
|
)group by length
|
|
|
|
|
union
|
|
|
|
|
----------领料出库汇总-----------
|
|
|
|
|
select length as classgroup_number,0 as xs_quantity,0 as cg_quantity ,0 as ll_quantity,0 as quantity ,0 as xs_out_qty,sum(out_quantity * spec) as ll_out_qty,0 as yi_out_qty,0 as qt_out_qty,sum(out_quantity * spec) as out_qty,0 as stock_qty,0 as bh_qty,0 as wbh_qty from mydo_job_detail_finish
|
|
|
|
|
where job_detail_id in (
|
|
|
|
|
select mjdf.job_detail_id from mydo_job_detail_finish mjdf
|
|
|
|
|
inner join mydo_job_finish mjf on mjf.job_id = mjdf.job_id
|
|
|
|
|
inner join out_stockout_detail_finish osdf on mjdf.in_or_out_id = osdf.stockout_id
|
|
|
|
|
inner join out_stockout_finish osf on mjdf.in_or_out_id = osf.stockout_id
|
|
|
|
|
where mjf.status = 4 and osf.out_type = 12 and mjf.in_or_out > 9
|
|
|
|
|
<if test="beginDate != null and beginDate != ''"> and mjf.finish_time >= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>
|
|
|
|
|
<if test="endDate != null and endDate != ''"> and mjf.finish_time <= #{endDate}</if>
|
|
|
|
|
<if test="lotNo != null and lotNo != ''"> and mjdf.lot_no like concat('%', #{lotNo}, '%')</if>
|
|
|
|
|
group by mjdf.job_detail_id
|
|
|
|
|
)group by length
|
|
|
|
|
union
|
|
|
|
|
----------移库出库汇总-----------
|
|
|
|
|
select length as classgroup_number,0 as xs_quantity,0 as cg_quantity ,0 as ll_quantity,0 as quantity ,0 as xs_out_qty,0 as ll_out_qty,sum(out_quantity * spec) as yi_out_qty,0 as qt_out_qty,sum(out_quantity * spec) as out_qty,0 as stock_qty,0 as bh_qty,0 as wbh_qty from mydo_job_detail_finish
|
|
|
|
|
where job_detail_id in (
|
|
|
|
|
select mjdf.job_detail_id from mydo_job_detail_finish mjdf
|
|
|
|
|
inner join mydo_job_finish mjf on mjf.job_id = mjdf.job_id
|
|
|
|
|
inner join out_stockout_detail_finish osdf on mjdf.in_or_out_id = osdf.stockout_id
|
|
|
|
|
inner join out_stockout_finish osf on mjdf.in_or_out_id = osf.stockout_id
|
|
|
|
|
where mjf.status = 4 and osf.out_type = 11 and mjf.in_or_out > 9
|
|
|
|
|
<if test="beginDate != null and beginDate != ''"> and mjf.finish_time >= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>
|
|
|
|
|
<if test="endDate != null and endDate != ''"> and mjf.finish_time <= #{endDate}</if>
|
|
|
|
|
<if test="lotNo != null and lotNo != ''"> and mjdf.lot_no like concat('%', #{lotNo}, '%')</if>
|
|
|
|
|
group by mjdf.job_detail_id
|
|
|
|
|
)group by length
|
|
|
|
|
union
|
|
|
|
|
----------其他出库汇总-----------
|
|
|
|
|
select length as classgroup_number,0 as xs_quantity,0 as cg_quantity ,0 as ll_quantity,0 as quantity ,0 as xs_out_qty,0 as ll_out_qty,0 as yi_out_qty,sum(out_quantity * spec) as qt_out_qty,sum(out_quantity * spec) as out_qty,0 as stock_qty,0 as bh_qty,0 as wbh_qty from mydo_job_detail_finish
|
|
|
|
|
where job_detail_id in (
|
|
|
|
|
select mjdf.job_detail_id from mydo_job_detail_finish mjdf
|
|
|
|
|
inner join mydo_job_finish mjf on mjf.job_id = mjdf.job_id
|
|
|
|
|
inner join out_stockout_detail_finish osdf on mjdf.in_or_out_id = osdf.stockout_id
|
|
|
|
|
inner join out_stockout_finish osf on mjdf.in_or_out_id = osf.stockout_id
|
|
|
|
|
where mjf.status = 4 and osf.out_type not in (10,11,12) and mjf.in_or_out > 9 and mjf.floor = 1
|
|
|
|
|
<if test="beginDate != null and beginDate != ''"> and mjf.finish_time >= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>
|
|
|
|
|
<if test="endDate != null and endDate != ''"> and mjf.finish_time <= #{endDate}</if>
|
|
|
|
|
<if test="lotNo != null and lotNo != ''"> and mjdf.lot_no like concat('%', #{lotNo}, '%')</if>
|
|
|
|
|
group by mjdf.job_detail_id
|
|
|
|
|
)group by length
|
|
|
|
|
union
|
|
|
|
|
select mjdf.length as classgroup_number,0 as xs_quantity,0 as cg_quantity ,0 as ll_quantity,0 as quantity ,0 as xs_out_qty,0 as ll_out_qty,0 as yi_out_qty,sum(out_quantity * spec) as qt_out_qty,sum(out_quantity * spec) as out_qty,0 as stock_qty,0 as bh_qty,0 as wbh_qty from mydo_job_detail_finish mjdf
|
|
|
|
|
inner join mydo_job_finish mjf on mjf.job_id = mjdf.job_id
|
|
|
|
|
where mjf.status = 4 and ( mjf.in_or_out = 50 or mjf.job_id like 'ZDC%')
|
|
|
|
|
<if test="beginDate != null and beginDate != ''"> and mjf.finish_time >= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>
|
|
|
|
|
<if test="endDate != null and endDate != ''"> and mjf.finish_time <= #{endDate}</if>
|
|
|
|
|
<if test="lotNo != null and lotNo != ''"> and mjdf.lot_no like concat('%', #{lotNo}, '%')</if>
|
|
|
|
|
group by mjdf.length
|
|
|
|
|
) a
|
|
|
|
|
<!--select bp.product_id,bp.product_name,b.*,bcs.cy * model as cy,'' as begin_date,'' as end_date,'' as lot_no from (select a.classgroup_number,sum(xs_quantity) as sc_in_qty,sum(cg_quantity) as cg_in_qty,sum(ll_quantity) as ll_in_qty ,sum(quantity) as quantity,sum(xs_out_qty) as xs_out_qty,sum(ll_out_qty) as ll_out_qty,sum(yi_out_qty) as yi_out_qty,sum(qt_out_qty) as qt_out_qty,sum(out_qty) as out_qty,sum(stock_qty) as stock_qty,sum(bh_qty) as bh_qty,sum(wbh_qty) as wbh_qty from (-->
|
|
|
|
|
<!------------生产汇总------------->
|
|
|
|
|
<!--select mjdf.length as classgroup_number,sum(in_quantity * spec) as xs_quantity,0 as cg_quantity ,0 as ll_quantity ,0 as quantity ,0 as xs_out_qty,0 as ll_out_qty,0 as yi_out_qty,0 as qt_out_qty,0 as out_qty,0 as stock_qty,0 as bh_qty,0 as wbh_qty from mydo_job_detail_finish mjdf-->
|
|
|
|
|
<!--inner join mydo_job_finish mjf on mjf.job_id = mjdf.job_id-->
|
|
|
|
|
<!--inner join in_stockin_finish isi on mjdf.in_or_out_id = isi.stockin_id-->
|
|
|
|
|
<!--where mjf.status = 4 and isi.in_type in (4) and mjf.in_or_out != 2 and mjf.job_id like'RK%'-->
|
|
|
|
|
<!-- <if test="beginDate != null and beginDate != ''"> and mjf.finish_time >= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>-->
|
|
|
|
|
<!-- <if test="endDate != null and endDate != ''"> and mjf.finish_time <= #{endDate}</if>-->
|
|
|
|
|
<!-- <if test="lotNo != null and lotNo != ''"> and mjdf.lot_no like concat('%', #{lotNo}, '%')</if>-->
|
|
|
|
|
<!--group by mjdf.length-->
|
|
|
|
|
<!--union-->
|
|
|
|
|
<!------------采购汇总------------->
|
|
|
|
|
<!--select mjdf.length as classgroup_number,0 as xs_quantity,sum(in_quantity * spec) as cg_quantity ,0 as ll_quantity ,0 as quantity ,0 as xs_out_qty,0 as ll_out_qty,0 as yi_out_qty,0 as qt_out_qty,0 as out_qty,0 as stock_qty,0 as bh_qty,0 as wbh_qty from mydo_job_detail_finish mjdf-->
|
|
|
|
|
<!--inner join mydo_job_finish mjf on mjf.job_id = mjdf.job_id-->
|
|
|
|
|
<!--inner join in_stockin_finish isi on mjdf.in_or_out_id = isi.stockin_id-->
|
|
|
|
|
<!--where mjf.status = 4 and isi.in_type in (1) and mjf.in_or_out != 2 and mjf.job_id like'RK%'-->
|
|
|
|
|
<!-- <if test="beginDate != null and beginDate != ''"> and mjf.finish_time >= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>-->
|
|
|
|
|
<!-- <if test="endDate != null and endDate != ''"> and mjf.finish_time <= #{endDate}</if>-->
|
|
|
|
|
<!-- <if test="lotNo != null and lotNo != ''"> and mjdf.lot_no like concat('%', #{lotNo}, '%')</if>-->
|
|
|
|
|
<!--group by mjdf.length-->
|
|
|
|
|
<!--union-->
|
|
|
|
|
<!------------移入汇总------------->
|
|
|
|
|
<!--select mjdf.length as classgroup_number,0 as xs_quantity,0 as cg_quantity ,sum(in_quantity * spec) as ll_quantity ,0 as quantity ,0 as xs_out_qty,0 as ll_out_qty,0 as yi_out_qty,0 as qt_out_qty,0 as out_qty,0 as stock_qty,0 as bh_qty,0 as wbh_qty from mydo_job_detail_finish mjdf-->
|
|
|
|
|
<!--inner join mydo_job_finish mjf on mjf.job_id = mjdf.job_id-->
|
|
|
|
|
<!--inner join in_stockin_finish isi on mjdf.in_or_out_id = isi.stockin_id-->
|
|
|
|
|
<!--where mjf.status = 4 and isi.in_type in (2) and mjf.in_or_out != 2 and mjf.job_id like'RK%'-->
|
|
|
|
|
<!-- <if test="beginDate != null and beginDate != ''"> and mjf.finish_time >= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>-->
|
|
|
|
|
<!-- <if test="endDate != null and endDate != ''"> and mjf.finish_time <= #{endDate}</if>-->
|
|
|
|
|
<!-- <if test="lotNo != null and lotNo != ''"> and mjdf.lot_no like concat('%', #{lotNo}, '%')</if>-->
|
|
|
|
|
<!--group by mjdf.length-->
|
|
|
|
|
<!--union-->
|
|
|
|
|
<!------------入库汇总------------->
|
|
|
|
|
<!--select mjdf.length as classgroup_number,0 as xs_quantity,0 as cg_quantity ,0 as ll_quantity ,sum(in_quantity * spec) as quantity ,0 as xs_out_qty,0 as ll_out_qty,0 as yi_out_qty,0 as qt_out_qty,0 as out_qty,0 as stock_qty,0 as bh_qty,0 as wbh_qty from mydo_job_detail_finish mjdf-->
|
|
|
|
|
<!--inner join mydo_job_finish mjf on mjf.job_id = mjdf.job_id-->
|
|
|
|
|
<!--inner join in_stockin_finish isi on mjdf.in_or_out_id = isi.stockin_id-->
|
|
|
|
|
<!--where mjf.status = 4 and isi.in_type in (1,2,6,4) and mjf.in_or_out != 2 and mjf.job_id like'RK%'-->
|
|
|
|
|
<!-- <if test="beginDate != null and beginDate != ''"> and mjf.finish_time >= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>-->
|
|
|
|
|
<!-- <if test="endDate != null and endDate != ''"> and mjf.finish_time <= #{endDate}</if>-->
|
|
|
|
|
<!-- <if test="lotNo != null and lotNo != ''"> and mjdf.lot_no like concat('%', #{lotNo}, '%')</if>-->
|
|
|
|
|
<!--group by mjdf.length-->
|
|
|
|
|
<!--union-->
|
|
|
|
|
<!------------备货库存汇总------------->
|
|
|
|
|
<!--select bs.classgroup_number,0 as xs_quantity,0 as cg_quantity ,0 as ll_quantity,0 as quantity ,0 as xs_out_qty,0 as ll_out_qty,0 as yi_out_qty,0 as qt_out_qty,0 as out_qty,0 as stock_qty,sum(bs.quantity * in_class_name) as bh_qty,0 as wbh_qty from bas_stock bs-->
|
|
|
|
|
<!--inner join bas_cargo_space bcs on bcs.cargo_space_id = bs.cargo_space_id and bcs.tray_code = bs.tray_code-->
|
|
|
|
|
<!--where bcs.status = 2 and bs.class_now_date_time = '1'-->
|
|
|
|
|
<!-- <if test="endDate != null and endDate != ''"> and bs.in_date <= #{endDate1}</if>-->
|
|
|
|
|
<!-- <if test="lotNo != null and lotNo != ''"> and bs.lot_no like concat('%', #{lotNo}, '%')</if>-->
|
|
|
|
|
<!--group by bs.classgroup_number-->
|
|
|
|
|
<!--union-->
|
|
|
|
|
<!------------未备货库存汇总------------->
|
|
|
|
|
<!--select bs.classgroup_number,0 as xs_quantity,0 as cg_quantity ,0 as ll_quantity,0 as quantity ,0 as xs_out_qty,0 as ll_out_qty,0 as yi_out_qty,0 as qt_out_qty,0 as out_qty,0 as stock_qty,0 as bh_qty,sum(bs.quantity * in_class_name) as wbh_qty from bas_stock bs-->
|
|
|
|
|
<!--inner join bas_cargo_space bcs on bcs.cargo_space_id = bs.cargo_space_id and bcs.tray_code = bs.tray_code-->
|
|
|
|
|
<!--where bcs.status = 2 and bs.class_now_date_time = '0'-->
|
|
|
|
|
<!-- <if test="endDate != null and endDate != ''"> and bs.in_date <= #{endDate1}</if>-->
|
|
|
|
|
<!-- <if test="lotNo != null and lotNo != ''"> and bs.lot_no like concat('%', #{lotNo}, '%')</if>-->
|
|
|
|
|
<!--group by bs.classgroup_number-->
|
|
|
|
|
<!--union-->
|
|
|
|
|
<!------------总库存汇总------------->
|
|
|
|
|
<!--select bs.classgroup_number,0 as xs_quantity,0 as cg_quantity ,0 as ll_quantity,0 as quantity ,0 as xs_out_qty,0 as ll_out_qty,0 as yi_out_qty,0 as qt_out_qty,0 as out_qty,sum(bs.quantity * in_class_name) as stock_qty,0 as bh_qty,0 as wbh_qty from bas_stock bs-->
|
|
|
|
|
<!--inner join bas_cargo_space bcs on bcs.cargo_space_id = bs.cargo_space_id and bcs.tray_code = bs.tray_code-->
|
|
|
|
|
<!--where bcs.status = 2-->
|
|
|
|
|
<!-- <if test="endDate != null and endDate != ''"> and bs.in_date <= #{endDate1}</if>-->
|
|
|
|
|
<!-- <if test="lotNo != null and lotNo != ''"> and bs.lot_no like concat('%', #{lotNo}, '%')</if>-->
|
|
|
|
|
<!--group by bs.classgroup_number-->
|
|
|
|
|
<!--union-->
|
|
|
|
|
<!------------销售出库汇总------------->
|
|
|
|
|
<!--select length as classgroup_number,0 as xs_quantity,0 as cg_quantity ,0 as ll_quantity,0 as quantity ,sum(out_quantity * spec) as xs_out_qty,0 as ll_out_qty,0 as yi_out_qty,0 as qt_out_qty,sum(out_quantity * spec) as out_qty,0 as stock_qty,0 as bh_qty,0 as wbh_qty from mydo_job_detail_finish-->
|
|
|
|
|
<!--where job_detail_id in (-->
|
|
|
|
|
<!--select mjdf.job_detail_id from mydo_job_detail_finish mjdf-->
|
|
|
|
|
<!--inner join mydo_job_finish mjf on mjf.job_id = mjdf.job_id-->
|
|
|
|
|
<!--inner join out_stockout_detail_finish osdf on mjdf.in_or_out_id = osdf.stockout_id-->
|
|
|
|
|
<!--inner join out_stockout_finish osf on mjdf.in_or_out_id = osf.stockout_id-->
|
|
|
|
|
<!--where mjf.status = 4 and osf.out_type = 10 and mjf.in_or_out > 9-->
|
|
|
|
|
<!-- <if test="beginDate != null and beginDate != ''"> and mjf.finish_time >= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>-->
|
|
|
|
|
<!-- <if test="endDate != null and endDate != ''"> and mjf.finish_time <= #{endDate}</if>-->
|
|
|
|
|
<!-- <if test="lotNo != null and lotNo != ''"> and mjdf.lot_no like concat('%', #{lotNo}, '%')</if>-->
|
|
|
|
|
<!--group by mjdf.job_detail_id-->
|
|
|
|
|
<!--)group by length-->
|
|
|
|
|
<!--union-->
|
|
|
|
|
<!------------领料出库汇总------------->
|
|
|
|
|
<!--select length as classgroup_number,0 as xs_quantity,0 as cg_quantity ,0 as ll_quantity,0 as quantity ,0 as xs_out_qty,sum(out_quantity * spec) as ll_out_qty,0 as yi_out_qty,0 as qt_out_qty,sum(out_quantity * spec) as out_qty,0 as stock_qty,0 as bh_qty,0 as wbh_qty from mydo_job_detail_finish-->
|
|
|
|
|
<!--where job_detail_id in (-->
|
|
|
|
|
<!--select mjdf.job_detail_id from mydo_job_detail_finish mjdf-->
|
|
|
|
|
<!--inner join mydo_job_finish mjf on mjf.job_id = mjdf.job_id-->
|
|
|
|
|
<!--inner join out_stockout_detail_finish osdf on mjdf.in_or_out_id = osdf.stockout_id-->
|
|
|
|
|
<!--inner join out_stockout_finish osf on mjdf.in_or_out_id = osf.stockout_id-->
|
|
|
|
|
<!--where mjf.status = 4 and osf.out_type = 12 and mjf.in_or_out > 9-->
|
|
|
|
|
<!-- <if test="beginDate != null and beginDate != ''"> and mjf.finish_time >= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>-->
|
|
|
|
|
<!-- <if test="endDate != null and endDate != ''"> and mjf.finish_time <= #{endDate}</if>-->
|
|
|
|
|
<!-- <if test="lotNo != null and lotNo != ''"> and mjdf.lot_no like concat('%', #{lotNo}, '%')</if>-->
|
|
|
|
|
<!--group by mjdf.job_detail_id-->
|
|
|
|
|
<!--)group by length-->
|
|
|
|
|
<!--union-->
|
|
|
|
|
<!------------移库出库汇总------------->
|
|
|
|
|
<!--select length as classgroup_number,0 as xs_quantity,0 as cg_quantity ,0 as ll_quantity,0 as quantity ,0 as xs_out_qty,0 as ll_out_qty,sum(out_quantity * spec) as yi_out_qty,0 as qt_out_qty,sum(out_quantity * spec) as out_qty,0 as stock_qty,0 as bh_qty,0 as wbh_qty from mydo_job_detail_finish-->
|
|
|
|
|
<!--where job_detail_id in (-->
|
|
|
|
|
<!--select mjdf.job_detail_id from mydo_job_detail_finish mjdf-->
|
|
|
|
|
<!--inner join mydo_job_finish mjf on mjf.job_id = mjdf.job_id-->
|
|
|
|
|
<!--inner join out_stockout_detail_finish osdf on mjdf.in_or_out_id = osdf.stockout_id-->
|
|
|
|
|
<!--inner join out_stockout_finish osf on mjdf.in_or_out_id = osf.stockout_id-->
|
|
|
|
|
<!--where mjf.status = 4 and osf.out_type = 11 and mjf.in_or_out > 9-->
|
|
|
|
|
<!-- <if test="beginDate != null and beginDate != ''"> and mjf.finish_time >= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>-->
|
|
|
|
|
<!-- <if test="endDate != null and endDate != ''"> and mjf.finish_time <= #{endDate}</if>-->
|
|
|
|
|
<!-- <if test="lotNo != null and lotNo != ''"> and mjdf.lot_no like concat('%', #{lotNo}, '%')</if>-->
|
|
|
|
|
<!--group by mjdf.job_detail_id-->
|
|
|
|
|
<!--)group by length-->
|
|
|
|
|
<!--union-->
|
|
|
|
|
<!------------其他出库汇总------------->
|
|
|
|
|
<!--select length as classgroup_number,0 as xs_quantity,0 as cg_quantity ,0 as ll_quantity,0 as quantity ,0 as xs_out_qty,0 as ll_out_qty,0 as yi_out_qty,sum(out_quantity * spec) as qt_out_qty,sum(out_quantity * spec) as out_qty,0 as stock_qty,0 as bh_qty,0 as wbh_qty from mydo_job_detail_finish-->
|
|
|
|
|
<!--where job_detail_id in (-->
|
|
|
|
|
<!--select mjdf.job_detail_id from mydo_job_detail_finish mjdf-->
|
|
|
|
|
<!--inner join mydo_job_finish mjf on mjf.job_id = mjdf.job_id-->
|
|
|
|
|
<!--inner join out_stockout_detail_finish osdf on mjdf.in_or_out_id = osdf.stockout_id-->
|
|
|
|
|
<!--inner join out_stockout_finish osf on mjdf.in_or_out_id = osf.stockout_id-->
|
|
|
|
|
<!--where mjf.status = 4 and osf.out_type not in (10,11,12) and mjf.in_or_out > 9 and mjf.floor = 1-->
|
|
|
|
|
<!-- <if test="beginDate != null and beginDate != ''"> and mjf.finish_time >= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>-->
|
|
|
|
|
<!-- <if test="endDate != null and endDate != ''"> and mjf.finish_time <= #{endDate}</if>-->
|
|
|
|
|
<!-- <if test="lotNo != null and lotNo != ''"> and mjdf.lot_no like concat('%', #{lotNo}, '%')</if>-->
|
|
|
|
|
<!--group by mjdf.job_detail_id-->
|
|
|
|
|
<!--)group by length-->
|
|
|
|
|
<!--union-->
|
|
|
|
|
<!--select mjdf.length as classgroup_number,0 as xs_quantity,0 as cg_quantity ,0 as ll_quantity,0 as quantity ,0 as xs_out_qty,0 as ll_out_qty,0 as yi_out_qty,sum(out_quantity * spec) as qt_out_qty,sum(out_quantity * spec) as out_qty,0 as stock_qty,0 as bh_qty,0 as wbh_qty from mydo_job_detail_finish mjdf-->
|
|
|
|
|
<!--inner join mydo_job_finish mjf on mjf.job_id = mjdf.job_id-->
|
|
|
|
|
<!--where mjf.status = 4 and ( mjf.in_or_out = 50 or mjf.job_id like 'ZDC%')-->
|
|
|
|
|
<!-- <if test="beginDate != null and beginDate != ''"> and mjf.finish_time >= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>-->
|
|
|
|
|
<!-- <if test="endDate != null and endDate != ''"> and mjf.finish_time <= #{endDate}</if>-->
|
|
|
|
|
<!-- <if test="lotNo != null and lotNo != ''"> and mjdf.lot_no like concat('%', #{lotNo}, '%')</if>-->
|
|
|
|
|
<!--group by mjdf.length-->
|
|
|
|
|
<!--) a-->
|
|
|
|
|
|
|
|
|
|
group by a.classgroup_number) b
|
|
|
|
|
inner join bas_product bp on bp.spare1 = b.classgroup_number
|
|
|
|
|
inner join bas_cq_stock bcs on bcs.classgroup_number = b.classgroup_number
|
|
|
|
|
where b.classgroup_number !='KTP' <if test="beginDate1 != null and beginDate1 != ''"> and bcs.begin_date = #{beginDate1}</if>
|
|
|
|
|
<if test="classgroupNumber != null and classgroupNumber != ''"> and b.classgroup_number like concat('%', #{classgroupNumber}, '%')</if>
|
|
|
|
|
<!--group by a.classgroup_number) b-->
|
|
|
|
|
<!--inner join bas_product bp on bp.spare1 = b.classgroup_number-->
|
|
|
|
|
<!--inner join bas_cq_stock bcs on bcs.classgroup_number = b.classgroup_number-->
|
|
|
|
|
<!--where b.classgroup_number !='KTP' <if test="beginDate1 != null and beginDate1 != ''"> and bcs.begin_date = #{beginDate1}</if>-->
|
|
|
|
|
<!-- <if test="classgroupNumber != null and classgroupNumber != ''"> and b.classgroup_number like concat('%', #{classgroupNumber}, '%')</if>-->
|
|
|
|
|
<!-- -->
|
|
|
|
|
SELECT
|
|
|
|
|
bp.product_id,
|
|
|
|
|
bp.product_name,
|
|
|
|
|
bp.spare1 AS classgroup_number,
|
|
|
|
|
IsNULL(bcs.cy, 0) * bp.model AS cy,
|
|
|
|
|
'' AS begin_date,
|
|
|
|
|
'' AS end_date,
|
|
|
|
|
'' AS lot_no,
|
|
|
|
|
b.sc_in_qty,
|
|
|
|
|
b.cg_in_qty,
|
|
|
|
|
b.ll_in_qty,
|
|
|
|
|
b.quantity,
|
|
|
|
|
b.xs_out_qty,
|
|
|
|
|
b.ll_out_qty,
|
|
|
|
|
b.yi_out_qty,
|
|
|
|
|
b.qt_out_qty,
|
|
|
|
|
b.out_qty,
|
|
|
|
|
b.stock_qty,
|
|
|
|
|
b.bh_qty,
|
|
|
|
|
b.wbh_qty
|
|
|
|
|
FROM bas_product bp
|
|
|
|
|
LEFT JOIN (
|
|
|
|
|
SELECT classgroup_number, IsNULL(cy, 0) AS cy
|
|
|
|
|
FROM bas_cq_stock a
|
|
|
|
|
WHERE 1=1
|
|
|
|
|
<if test="beginDate1 != null and beginDate1 != ''">
|
|
|
|
|
AND a.begin_date = #{beginDate1}
|
|
|
|
|
</if>
|
|
|
|
|
) bcs ON bp.spare1 = bcs.classgroup_number
|
|
|
|
|
LEFT JOIN (
|
|
|
|
|
SELECT
|
|
|
|
|
a.classgroup_number,
|
|
|
|
|
SUM(a.xs_quantity) AS sc_in_qty,
|
|
|
|
|
SUM(a.cg_quantity) AS cg_in_qty,
|
|
|
|
|
SUM(a.ll_quantity) AS ll_in_qty,
|
|
|
|
|
SUM(a.quantity) AS quantity,
|
|
|
|
|
SUM(a.xs_out_qty) AS xs_out_qty,
|
|
|
|
|
SUM(a.ll_out_qty) AS ll_out_qty,
|
|
|
|
|
SUM(a.yi_out_qty) AS yi_out_qty,
|
|
|
|
|
SUM(a.qt_out_qty) AS qt_out_qty,
|
|
|
|
|
SUM(a.out_qty) AS out_qty,
|
|
|
|
|
SUM(a.stock_qty) AS stock_qty,
|
|
|
|
|
SUM(a.bh_qty) AS bh_qty,
|
|
|
|
|
SUM(a.wbh_qty) AS wbh_qty
|
|
|
|
|
FROM (
|
|
|
|
|
----------生产汇总-----------
|
|
|
|
|
select mjdf.length as classgroup_number,sum(in_quantity * spec) as xs_quantity,0 as cg_quantity ,0 as ll_quantity ,0 as quantity ,0 as xs_out_qty,0 as ll_out_qty,0 as yi_out_qty,0 as qt_out_qty,0 as out_qty,0 as stock_qty,0 as bh_qty,0 as wbh_qty from mydo_job_detail_finish mjdf
|
|
|
|
|
inner join mydo_job_finish mjf on mjf.job_id = mjdf.job_id
|
|
|
|
|
inner join in_stockin_finish isi on mjdf.in_or_out_id = isi.stockin_id
|
|
|
|
|
where mjf.status = 4 and isi.in_type in (4) and mjf.in_or_out != 2 and mjf.job_id like'RK%'
|
|
|
|
|
<if test="beginDate != null and beginDate != ''"> and mjf.finish_time >= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>
|
|
|
|
|
<if test="endDate != null and endDate != ''"> and mjf.finish_time <= #{endDate}</if>
|
|
|
|
|
<if test="lotNo != null and lotNo != ''"> and mjdf.lot_no like concat('%', #{lotNo}, '%')</if>
|
|
|
|
|
group by mjdf.length
|
|
|
|
|
union
|
|
|
|
|
----------采购汇总-----------
|
|
|
|
|
select mjdf.length as classgroup_number,0 as xs_quantity,sum(in_quantity * spec) as cg_quantity ,0 as ll_quantity ,0 as quantity ,0 as xs_out_qty,0 as ll_out_qty,0 as yi_out_qty,0 as qt_out_qty,0 as out_qty,0 as stock_qty,0 as bh_qty,0 as wbh_qty from mydo_job_detail_finish mjdf
|
|
|
|
|
inner join mydo_job_finish mjf on mjf.job_id = mjdf.job_id
|
|
|
|
|
inner join in_stockin_finish isi on mjdf.in_or_out_id = isi.stockin_id
|
|
|
|
|
where mjf.status = 4 and isi.in_type in (1) and mjf.in_or_out != 2 and mjf.job_id like'RK%'
|
|
|
|
|
<if test="beginDate != null and beginDate != ''"> and mjf.finish_time >= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>
|
|
|
|
|
<if test="endDate != null and endDate != ''"> and mjf.finish_time <= #{endDate}</if>
|
|
|
|
|
<if test="lotNo != null and lotNo != ''"> and mjdf.lot_no like concat('%', #{lotNo}, '%')</if>
|
|
|
|
|
group by mjdf.length
|
|
|
|
|
union
|
|
|
|
|
----------移入汇总-----------
|
|
|
|
|
select mjdf.length as classgroup_number,0 as xs_quantity,0 as cg_quantity ,sum(in_quantity * spec) as ll_quantity ,0 as quantity ,0 as xs_out_qty,0 as ll_out_qty,0 as yi_out_qty,0 as qt_out_qty,0 as out_qty,0 as stock_qty,0 as bh_qty,0 as wbh_qty from mydo_job_detail_finish mjdf
|
|
|
|
|
inner join mydo_job_finish mjf on mjf.job_id = mjdf.job_id
|
|
|
|
|
inner join in_stockin_finish isi on mjdf.in_or_out_id = isi.stockin_id
|
|
|
|
|
where mjf.status = 4 and isi.in_type in (2) and mjf.in_or_out != 2 and mjf.job_id like'RK%'
|
|
|
|
|
<if test="beginDate != null and beginDate != ''"> and mjf.finish_time >= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>
|
|
|
|
|
<if test="endDate != null and endDate != ''"> and mjf.finish_time <= #{endDate}</if>
|
|
|
|
|
<if test="lotNo != null and lotNo != ''"> and mjdf.lot_no like concat('%', #{lotNo}, '%')</if>
|
|
|
|
|
group by mjdf.length
|
|
|
|
|
union
|
|
|
|
|
----------入库汇总-----------
|
|
|
|
|
select mjdf.length as classgroup_number,0 as xs_quantity,0 as cg_quantity ,0 as ll_quantity ,sum(in_quantity * spec) as quantity ,0 as xs_out_qty,0 as ll_out_qty,0 as yi_out_qty,0 as qt_out_qty,0 as out_qty,0 as stock_qty,0 as bh_qty,0 as wbh_qty from mydo_job_detail_finish mjdf
|
|
|
|
|
inner join mydo_job_finish mjf on mjf.job_id = mjdf.job_id
|
|
|
|
|
inner join in_stockin_finish isi on mjdf.in_or_out_id = isi.stockin_id
|
|
|
|
|
where mjf.status = 4 and isi.in_type in (1,2,6,4) and mjf.in_or_out != 2 and mjf.job_id like'RK%'
|
|
|
|
|
<if test="beginDate != null and beginDate != ''"> and mjf.finish_time >= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>
|
|
|
|
|
<if test="endDate != null and endDate != ''"> and mjf.finish_time <= #{endDate}</if>
|
|
|
|
|
<if test="lotNo != null and lotNo != ''"> and mjdf.lot_no like concat('%', #{lotNo}, '%')</if>
|
|
|
|
|
group by mjdf.length
|
|
|
|
|
union
|
|
|
|
|
----------备货库存汇总-----------
|
|
|
|
|
select bs.classgroup_number,0 as xs_quantity,0 as cg_quantity ,0 as ll_quantity,0 as quantity ,0 as xs_out_qty,0 as ll_out_qty,0 as yi_out_qty,0 as qt_out_qty,0 as out_qty,0 as stock_qty,sum(bs.quantity * in_class_name) as bh_qty,0 as wbh_qty from bas_stock bs
|
|
|
|
|
inner join bas_cargo_space bcs on bcs.cargo_space_id = bs.cargo_space_id and bcs.tray_code = bs.tray_code
|
|
|
|
|
where bcs.status = 2 and bs.class_now_date_time = '1'
|
|
|
|
|
<if test="endDate != null and endDate != ''"> and bs.in_date <= #{endDate1}</if>
|
|
|
|
|
<if test="lotNo != null and lotNo != ''"> and bs.lot_no like concat('%', #{lotNo}, '%')</if>
|
|
|
|
|
group by bs.classgroup_number
|
|
|
|
|
union
|
|
|
|
|
----------未备货库存汇总-----------
|
|
|
|
|
select bs.classgroup_number,0 as xs_quantity,0 as cg_quantity ,0 as ll_quantity,0 as quantity ,0 as xs_out_qty,0 as ll_out_qty,0 as yi_out_qty,0 as qt_out_qty,0 as out_qty,0 as stock_qty,0 as bh_qty,sum(bs.quantity * in_class_name) as wbh_qty from bas_stock bs
|
|
|
|
|
inner join bas_cargo_space bcs on bcs.cargo_space_id = bs.cargo_space_id and bcs.tray_code = bs.tray_code
|
|
|
|
|
where bcs.status = 2 and bs.class_now_date_time = '0'
|
|
|
|
|
<if test="endDate != null and endDate != ''"> and bs.in_date <= #{endDate1}</if>
|
|
|
|
|
<if test="lotNo != null and lotNo != ''"> and bs.lot_no like concat('%', #{lotNo}, '%')</if>
|
|
|
|
|
group by bs.classgroup_number
|
|
|
|
|
union
|
|
|
|
|
----------总库存汇总-----------
|
|
|
|
|
select bs.classgroup_number,0 as xs_quantity,0 as cg_quantity ,0 as ll_quantity,0 as quantity ,0 as xs_out_qty,0 as ll_out_qty,0 as yi_out_qty,0 as qt_out_qty,0 as out_qty,sum(bs.quantity * in_class_name) as stock_qty,0 as bh_qty,0 as wbh_qty from bas_stock bs
|
|
|
|
|
inner join bas_cargo_space bcs on bcs.cargo_space_id = bs.cargo_space_id and bcs.tray_code = bs.tray_code
|
|
|
|
|
where bcs.status = 2
|
|
|
|
|
<if test="endDate != null and endDate != ''"> and bs.in_date <= #{endDate1}</if>
|
|
|
|
|
<if test="lotNo != null and lotNo != ''"> and bs.lot_no like concat('%', #{lotNo}, '%')</if>
|
|
|
|
|
group by bs.classgroup_number
|
|
|
|
|
union
|
|
|
|
|
----------销售出库汇总-----------
|
|
|
|
|
select length as classgroup_number,0 as xs_quantity,0 as cg_quantity ,0 as ll_quantity,0 as quantity ,sum(out_quantity * spec) as xs_out_qty,0 as ll_out_qty,0 as yi_out_qty,0 as qt_out_qty,sum(out_quantity * spec) as out_qty,0 as stock_qty,0 as bh_qty,0 as wbh_qty from mydo_job_detail_finish
|
|
|
|
|
where job_detail_id in (
|
|
|
|
|
select mjdf.job_detail_id from mydo_job_detail_finish mjdf
|
|
|
|
|
inner join mydo_job_finish mjf on mjf.job_id = mjdf.job_id
|
|
|
|
|
inner join out_stockout_detail_finish osdf on mjdf.in_or_out_id = osdf.stockout_id
|
|
|
|
|
inner join out_stockout_finish osf on mjdf.in_or_out_id = osf.stockout_id
|
|
|
|
|
where mjf.status = 4 and osf.out_type = 10 and mjf.in_or_out > 9
|
|
|
|
|
<if test="beginDate != null and beginDate != ''"> and mjf.finish_time >= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>
|
|
|
|
|
<if test="endDate != null and endDate != ''"> and mjf.finish_time <= #{endDate}</if>
|
|
|
|
|
<if test="lotNo != null and lotNo != ''"> and mjdf.lot_no like concat('%', #{lotNo}, '%')</if>
|
|
|
|
|
group by mjdf.job_detail_id
|
|
|
|
|
)group by length
|
|
|
|
|
union
|
|
|
|
|
----------领料出库汇总-----------
|
|
|
|
|
select length as classgroup_number,0 as xs_quantity,0 as cg_quantity ,0 as ll_quantity,0 as quantity ,0 as xs_out_qty,sum(out_quantity * spec) as ll_out_qty,0 as yi_out_qty,0 as qt_out_qty,sum(out_quantity * spec) as out_qty,0 as stock_qty,0 as bh_qty,0 as wbh_qty from mydo_job_detail_finish
|
|
|
|
|
where job_detail_id in (
|
|
|
|
|
select mjdf.job_detail_id from mydo_job_detail_finish mjdf
|
|
|
|
|
inner join mydo_job_finish mjf on mjf.job_id = mjdf.job_id
|
|
|
|
|
inner join out_stockout_detail_finish osdf on mjdf.in_or_out_id = osdf.stockout_id
|
|
|
|
|
inner join out_stockout_finish osf on mjdf.in_or_out_id = osf.stockout_id
|
|
|
|
|
where mjf.status = 4 and osf.out_type = 12 and mjf.in_or_out > 9
|
|
|
|
|
<if test="beginDate != null and beginDate != ''"> and mjf.finish_time >= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>
|
|
|
|
|
<if test="endDate != null and endDate != ''"> and mjf.finish_time <= #{endDate}</if>
|
|
|
|
|
<if test="lotNo != null and lotNo != ''"> and mjdf.lot_no like concat('%', #{lotNo}, '%')</if>
|
|
|
|
|
group by mjdf.job_detail_id
|
|
|
|
|
)group by length
|
|
|
|
|
union
|
|
|
|
|
----------移库出库汇总-----------
|
|
|
|
|
select length as classgroup_number,0 as xs_quantity,0 as cg_quantity ,0 as ll_quantity,0 as quantity ,0 as xs_out_qty,0 as ll_out_qty,sum(out_quantity * spec) as yi_out_qty,0 as qt_out_qty,sum(out_quantity * spec) as out_qty,0 as stock_qty,0 as bh_qty,0 as wbh_qty from mydo_job_detail_finish
|
|
|
|
|
where job_detail_id in (
|
|
|
|
|
select mjdf.job_detail_id from mydo_job_detail_finish mjdf
|
|
|
|
|
inner join mydo_job_finish mjf on mjf.job_id = mjdf.job_id
|
|
|
|
|
inner join out_stockout_detail_finish osdf on mjdf.in_or_out_id = osdf.stockout_id
|
|
|
|
|
inner join out_stockout_finish osf on mjdf.in_or_out_id = osf.stockout_id
|
|
|
|
|
where mjf.status = 4 and osf.out_type = 11 and mjf.in_or_out > 9
|
|
|
|
|
<if test="beginDate != null and beginDate != ''"> and mjf.finish_time >= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>
|
|
|
|
|
<if test="endDate != null and endDate != ''"> and mjf.finish_time <= #{endDate}</if>
|
|
|
|
|
<if test="lotNo != null and lotNo != ''"> and mjdf.lot_no like concat('%', #{lotNo}, '%')</if>
|
|
|
|
|
group by mjdf.job_detail_id
|
|
|
|
|
)group by length
|
|
|
|
|
union
|
|
|
|
|
----------其他出库汇总-----------
|
|
|
|
|
select length as classgroup_number,0 as xs_quantity,0 as cg_quantity ,0 as ll_quantity,0 as quantity ,0 as xs_out_qty,0 as ll_out_qty,0 as yi_out_qty,sum(out_quantity * spec) as qt_out_qty,sum(out_quantity * spec) as out_qty,0 as stock_qty,0 as bh_qty,0 as wbh_qty from mydo_job_detail_finish
|
|
|
|
|
where job_detail_id in (
|
|
|
|
|
select mjdf.job_detail_id from mydo_job_detail_finish mjdf
|
|
|
|
|
inner join mydo_job_finish mjf on mjf.job_id = mjdf.job_id
|
|
|
|
|
inner join out_stockout_detail_finish osdf on mjdf.in_or_out_id = osdf.stockout_id
|
|
|
|
|
inner join out_stockout_finish osf on mjdf.in_or_out_id = osf.stockout_id
|
|
|
|
|
where mjf.status = 4 and osf.out_type not in (10,11,12) and mjf.in_or_out > 9 and mjf.floor = 1
|
|
|
|
|
<if test="beginDate != null and beginDate != ''"> and mjf.finish_time >= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>
|
|
|
|
|
<if test="endDate != null and endDate != ''"> and mjf.finish_time <= #{endDate}</if>
|
|
|
|
|
<if test="lotNo != null and lotNo != ''"> and mjdf.lot_no like concat('%', #{lotNo}, '%')</if>
|
|
|
|
|
group by mjdf.job_detail_id
|
|
|
|
|
)group by length
|
|
|
|
|
union
|
|
|
|
|
select mjdf.length as classgroup_number,0 as xs_quantity,0 as cg_quantity ,0 as ll_quantity,0 as quantity ,0 as xs_out_qty,0 as ll_out_qty,0 as yi_out_qty,sum(out_quantity * spec) as qt_out_qty,sum(out_quantity * spec) as out_qty,0 as stock_qty,0 as bh_qty,0 as wbh_qty from mydo_job_detail_finish mjdf
|
|
|
|
|
inner join mydo_job_finish mjf on mjf.job_id = mjdf.job_id
|
|
|
|
|
where mjf.status = 4 and ( mjf.in_or_out = 50 or mjf.job_id like 'ZDC%')
|
|
|
|
|
<if test="beginDate != null and beginDate != ''"> and mjf.finish_time >= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>
|
|
|
|
|
<if test="endDate != null and endDate != ''"> and mjf.finish_time <= #{endDate}</if>
|
|
|
|
|
<if test="lotNo != null and lotNo != ''"> and mjdf.lot_no like concat('%', #{lotNo}, '%')</if>
|
|
|
|
|
group by mjdf.length
|
|
|
|
|
) a
|
|
|
|
|
GROUP BY a.classgroup_number
|
|
|
|
|
) b ON bp.spare1 = b.classgroup_number
|
|
|
|
|
WHERE 1=1
|
|
|
|
|
AND b.classgroup_number != 'KTP'
|
|
|
|
|
<if test="classgroupNumber != null and classgroupNumber != ''">
|
|
|
|
|
AND b.classgroup_number LIKE CONCAT('%', #{classgroupNumber}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
</select>
|
|
|
|
|
<select id="selectViewInOrOutByProductId" parameterType="String" resultMap="ViewInOrOutResult">
|
|
|
|
|
<include refid="selectViewInOrOutVo"/>
|
|
|
|
|
|