出库单据数量验证

This commit is contained in:
刘汗青
2026-08-17 09:53:12 +08:00
parent 826b8e5a10
commit 9ea2345963
5 changed files with 351 additions and 136 deletions

View File

@@ -21,6 +21,7 @@ import com.ruoyi.project.out.outStock.mapper.OutStockoutMapper;
import com.ruoyi.project.out.outStockDetail.domain.OutStockoutDetail;
import com.ruoyi.project.out.outStockDetail.mapper.OutStockoutDetailMapper;
import com.ruoyi.project.out.productAndStock.domain.ViewProductAndStock;
import com.ruoyi.project.out.productAndStock.mapper.ViewProductAndStockMapper;
import com.ruoyi.project.out.productAndStock.service.IViewProductAndStockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -52,6 +53,8 @@ public class MesOutorderMiddleServiceImpl implements IMesOutorderMiddleService
private OutStockoutDetailMapper outStockoutDetailMapper;
@Autowired
private IViewProductAndStockService viewProductAndStockService;
@Autowired
private ViewProductAndStockMapper viewProductAndStockMapper;
/**
* 查询mes出库单中间表
@@ -130,6 +133,28 @@ public class MesOutorderMiddleServiceImpl implements IMesOutorderMiddleService
@Override
public AjaxResult insertMesOutorder(MesOutorderMiddleVo mesOutorderMiddleVo,String createType) {
try {
List<MesOutorderDetailMiddle> mesOutorderDetailMiddleList1 = mesOutorderMiddleVo.getMesOutorderDetailMiddleList();
for (MesOutorderDetailMiddle mesOutorderDetailMiddle : mesOutorderDetailMiddleList1) {
Integer planInQuantity = mesOutorderDetailMiddle.getPlanInQuantity().intValue();
String productBatch = mesOutorderDetailMiddle.getProductBatch();
String materialCode = mesOutorderDetailMiddle.getMaterialCode();
ViewProductAndStock param = new ViewProductAndStock();
param.setOutType("15");
param.setLotNo(productBatch);
param.setClassgroupNumber(materialCode);
List<ViewProductAndStock> viewProductAndStocks = viewProductAndStockMapper.selectViewProductAndStockList(param);
int stockCount = 0;
for (ViewProductAndStock viewProductAndStock : viewProductAndStocks) {
stockCount = stockCount + viewProductAndStock.getQuantity().intValue();
}
int djCount = mesOutorderDetailMiddleMapper.selectCountByBatchAndMaterialCode(productBatch, materialCode);
if (stockCount - djCount < planInQuantity){
return AjaxResult.error("牌号:"+materialCode+"批次:"+productBatch+",剩余库存数量:"+(stockCount - djCount)+",当前计划数量:"+planInQuantity+",库存不足,请检查");
}
}
MesOutorderMiddle mesOutorderMiddle = mesOutorderMiddleVo.getMesOutorderMiddle();
mesOutorderMiddle.setId(UUID.randomUUID().toString());
String bl = basJobIdService.getJobId("BH");

View File

@@ -3,6 +3,7 @@ package com.ruoyi.project.middle.mesOutorderDetail.mapper;
import java.util.HashMap;
import java.util.List;
import com.ruoyi.project.middle.mesOutorderDetail.domain.MesOutorderDetailMiddle;
import org.apache.ibatis.annotations.Param;
/**
* mes出库子单中间表Mapper接口
@@ -87,4 +88,6 @@ public interface MesOutorderDetailMiddleMapper
String selectUrlByLineNoChildTwo(String stockOutDetailId);
String selectUrlByLineNoMother(String stockOutDetailId);
int selectCountByBatchAndMaterialCode(@Param("productBatch") String productBatch,@Param("materialCode") String materialCode);
}

View File

@@ -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 &gt;= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>
<if test="endDate != null and endDate != ''"> and mjf.finish_time &lt;= #{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 &gt;= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>
<if test="endDate != null and endDate != ''"> and mjf.finish_time &lt;= #{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 &gt;= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>
<if test="endDate != null and endDate != ''"> and mjf.finish_time &lt;= #{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 &gt;= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>
<if test="endDate != null and endDate != ''"> and mjf.finish_time &lt;= #{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 &lt;= #{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 &lt;= #{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 &lt;= #{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 &gt;= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>
<if test="endDate != null and endDate != ''"> and mjf.finish_time &lt;= #{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 &gt;= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>
<if test="endDate != null and endDate != ''"> and mjf.finish_time &lt;= #{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 &gt;= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>
<if test="endDate != null and endDate != ''"> and mjf.finish_time &lt;= #{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 &gt;= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>
<if test="endDate != null and endDate != ''"> and mjf.finish_time &lt;= #{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 &gt;= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>
<if test="endDate != null and endDate != ''"> and mjf.finish_time &lt;= #{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 (-->
<!--&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;生产汇总-&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;-->
<!--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 &gt;= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>-->
<!-- <if test="endDate != null and endDate != ''"> and mjf.finish_time &lt;= #{endDate}</if>-->
<!-- <if test="lotNo != null and lotNo != ''"> and mjdf.lot_no like concat('%', #{lotNo}, '%')</if>-->
<!--group by mjdf.length-->
<!--union-->
<!--&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;采购汇总-&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;-->
<!--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 &gt;= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>-->
<!-- <if test="endDate != null and endDate != ''"> and mjf.finish_time &lt;= #{endDate}</if>-->
<!-- <if test="lotNo != null and lotNo != ''"> and mjdf.lot_no like concat('%', #{lotNo}, '%')</if>-->
<!--group by mjdf.length-->
<!--union-->
<!--&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;移入汇总-&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;-->
<!--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 &gt;= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>-->
<!-- <if test="endDate != null and endDate != ''"> and mjf.finish_time &lt;= #{endDate}</if>-->
<!-- <if test="lotNo != null and lotNo != ''"> and mjdf.lot_no like concat('%', #{lotNo}, '%')</if>-->
<!--group by mjdf.length-->
<!--union-->
<!--&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;入库汇总-&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;-->
<!--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 &gt;= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>-->
<!-- <if test="endDate != null and endDate != ''"> and mjf.finish_time &lt;= #{endDate}</if>-->
<!-- <if test="lotNo != null and lotNo != ''"> and mjdf.lot_no like concat('%', #{lotNo}, '%')</if>-->
<!--group by mjdf.length-->
<!--union-->
<!--&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;备货库存汇总-&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;-->
<!--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 &lt;= #{endDate1}</if>-->
<!-- <if test="lotNo != null and lotNo != ''"> and bs.lot_no like concat('%', #{lotNo}, '%')</if>-->
<!--group by bs.classgroup_number-->
<!--union-->
<!--&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;未备货库存汇总-&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;-->
<!--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 &lt;= #{endDate1}</if>-->
<!-- <if test="lotNo != null and lotNo != ''"> and bs.lot_no like concat('%', #{lotNo}, '%')</if>-->
<!--group by bs.classgroup_number-->
<!--union-->
<!--&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;总库存汇总-&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;-->
<!--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 &lt;= #{endDate1}</if>-->
<!-- <if test="lotNo != null and lotNo != ''"> and bs.lot_no like concat('%', #{lotNo}, '%')</if>-->
<!--group by bs.classgroup_number-->
<!--union-->
<!--&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;销售出库汇总-&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;-->
<!--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 &gt;= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>-->
<!-- <if test="endDate != null and endDate != ''"> and mjf.finish_time &lt;= #{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-->
<!--&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;领料出库汇总-&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;-->
<!--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 &gt;= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>-->
<!-- <if test="endDate != null and endDate != ''"> and mjf.finish_time &lt;= #{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-->
<!--&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;移库出库汇总-&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;-->
<!--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 &gt;= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>-->
<!-- <if test="endDate != null and endDate != ''"> and mjf.finish_time &lt;= #{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-->
<!--&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;其他出库汇总-&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;-->
<!--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 &gt;= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>-->
<!-- <if test="endDate != null and endDate != ''"> and mjf.finish_time &lt;= #{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 &gt;= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>-->
<!-- <if test="endDate != null and endDate != ''"> and mjf.finish_time &lt;= #{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 &gt;= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>
<if test="endDate != null and endDate != ''"> and mjf.finish_time &lt;= #{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 &gt;= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>
<if test="endDate != null and endDate != ''"> and mjf.finish_time &lt;= #{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 &gt;= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>
<if test="endDate != null and endDate != ''"> and mjf.finish_time &lt;= #{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 &gt;= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>
<if test="endDate != null and endDate != ''"> and mjf.finish_time &lt;= #{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 &lt;= #{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 &lt;= #{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 &lt;= #{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 &gt;= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>
<if test="endDate != null and endDate != ''"> and mjf.finish_time &lt;= #{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 &gt;= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>
<if test="endDate != null and endDate != ''"> and mjf.finish_time &lt;= #{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 &gt;= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>
<if test="endDate != null and endDate != ''"> and mjf.finish_time &lt;= #{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 &gt;= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>
<if test="endDate != null and endDate != ''"> and mjf.finish_time &lt;= #{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 &gt;= #{beginDate} and mjf.finish_time not like concat('%', #{beginDate}, '%')</if>
<if test="endDate != null and endDate != ''"> and mjf.finish_time &lt;= #{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"/>

View File

@@ -398,6 +398,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from mes_outorder_detail_middle
where line_no = #{stockOutDetailId}
</select>
<select id="selectCountByBatchAndMaterialCode" resultType="java.lang.Integer">
select isnull(sum(plan_in_quantity-allot_num),0)
from mes_outorder_detail_middle
where product_batch = #{productBatch}
and material_code = #{materialCode}
</select>
</mapper>

View File

@@ -927,7 +927,7 @@
title: '销售单位',
align: 'center'
},
{
/*{
field: 'createType',
title: '建单类型',
align: 'center',
@@ -939,7 +939,7 @@
return "自动建单"
}
}
},
},*/
{
field: 'createTime',