select *
FROM jsh_depot_item
where 1=1
and name like #{bindName}
and type = #{type}
and remark like #{bindRemark}
and ifnull(delete_flag,'0') !='1'
limit #{offset},#{rows}
SELECT
COUNT(id)
FROM jsh_depot_item
WHERE 1=1
and name like #{bindName}
and type = #{type}
and remark like #{bindRemark}
and ifnull(delete_flag,'0') !='1'
select tb.number, tb.bar_code, tb.material_name, tb.type, tb.sub_type, tb.b_num, tb.unit_price,
ifnull(tb.b_num*tb.unit_price,0) as all_price, tb.material_unit, tb.depotName, tb.oTime from
(select dh.number,me.bar_code,m.name material_name,dh.type,dh.sub_type,
case
when type='入库' then ifnull(di.basic_number,0)
when type='出库' then 0-ifnull(di.basic_number,0)
when dh.sub_type='组装单' and di.material_type='组合件' then ifnull(di.basic_number,0)
when dh.sub_type='组装单' and di.material_type='普通子件' then 0-ifnull(di.basic_number,0)
when dh.sub_type='拆卸单' and di.material_type='普通子件' then ifnull(di.basic_number,0)
when dh.sub_type='拆卸单' and di.material_type='组合件' then 0-ifnull(di.basic_number,0)
when dh.sub_type='盘点复盘' then ifnull(di.basic_number,0)
else 0
end
as b_num, di.unit_price, di.material_unit,
(select name from jsh_depot d where d.id=di.depot_id and ifnull(d.delete_flag,'0') !='1') as depotName,
date_format(dh.oper_time,'%Y-%m-%d %H:%i:%S') as oTime
from jsh_depot_head dh
left join jsh_depot_item di on dh.id=di.header_id and ifnull(di.delete_flag,'0') !='1'
left join jsh_material m on di.material_id=m.id and ifnull(m.delete_flag,'0') !='1'
left join jsh_material_extend me on me.id=di.material_extend_id and ifnull(me.delete_Flag,'0') !='1'
where (dh.type!='其它'
or (dh.type='其它' and dh.sub_type='组装单')
or (dh.type='其它' and dh.sub_type='拆卸单')
or (dh.type='其它' and dh.sub_type='盘点复盘'))
and (dh.sub_type!='采购' and dh.sub_type!='采购退货' and dh.sub_type!='销售' and dh.sub_type!='销售退货')
and di.depot_id in (
#{depotId}
)
and dh.status = '1'
and di.sku = #{sku}
and di.batch_number = #{batchNumber}
and dh.number like #{bindNumber}
and dh.oper_time >= #{beginTime}
and dh.oper_time <= #{endTime}
and di.material_id = #{mId}
and ifnull(dh.delete_flag,'0') !='1'
union all
--单独构造记录:调拨入库
select dh.number,me.bar_code,m.name material_name,dh.type,dh.sub_type,
ifnull(di.basic_number,0) as b_num, di.unit_price, di.material_unit,
(select concat(name,'[调入]') from jsh_depot d where d.id=di.another_depot_id and ifnull(d.delete_flag,'0') !='1') as depotName,
date_format(dh.oper_time,'%Y-%m-%d %H:%i:%S') as oTime
from jsh_depot_head dh
left join jsh_depot_item di on dh.id=di.header_id and ifnull(di.delete_flag,'0') !='1'
left join jsh_material m on di.material_id=m.id and ifnull(m.delete_flag,'0') !='1'
left join jsh_material_extend me on me.id=di.material_extend_id and ifnull(me.delete_Flag,'0') !='1'
where dh.type='出库' and dh.sub_type='调拨'
and di.another_depot_id in (
#{depotId}
)
and dh.status = '1'
and di.sku = #{sku}
and di.batch_number = #{batchNumber}
and dh.number like #{bindNumber}
and dh.oper_time >= #{beginTime}
and dh.oper_time <= #{endTime}
and di.material_id = #{mId}
and ifnull(dh.delete_flag,'0') !='1') tb
order by tb.oTime desc
limit #{offset},#{rows}
select count(tb.number) from
(select dh.number from jsh_depot_head dh
left JOIN jsh_depot_item di on dh.id=di.header_id and ifnull(di.delete_flag,'0') !='1'
where (dh.type!='其它'
or (dh.type='其它' and dh.sub_type='组装单')
or (dh.type='其它' and dh.sub_type='拆卸单')
or (dh.type='其它' and dh.sub_type='盘点复盘'))
and (dh.sub_type!='采购' and dh.sub_type!='采购退货' and dh.sub_type!='销售' and dh.sub_type!='销售退货')
and di.depot_id in (
#{depotId}
)
and dh.status = '1'
and di.sku = #{sku}
and di.batch_number = #{batchNumber}
and dh.number like #{bindNumber}
and dh.oper_time >= #{beginTime}
and dh.oper_time <= #{endTime}
and di.material_id =#{mId}
and ifnull(dh.delete_flag,'0') !='1'
union all
--单独构造记录:调拨入库
select dh.number from jsh_depot_head dh
left join jsh_depot_item di on dh.id=di.header_id and ifnull(di.delete_flag,'0') !='1'
where dh.type='出库' and dh.sub_type='调拨'
and di.another_depot_id in (
#{depotId}
)
and dh.status = '1'
and di.sku = #{sku}
and di.batch_number = #{batchNumber}
and dh.number like #{bindNumber}
and dh.oper_time >= #{beginTime}
and dh.oper_time <= #{endTime}
and di.material_id = #{mId}
and ifnull(dh.delete_flag,'0') !='1') tb
select di.*,m.name MName,m.model MModel,m.unit MaterialUnit,m.color MColor,m.standard MStandard,m.mfrs MMfrs,m.weight, m.position, m.img_name,
m.other_field1 MOtherField1,m.other_field2 MOtherField2,m.other_field3 MOtherField3,m.enable_serial_number, m.enable_batch_number,
m.brand, dp1.name DepotName,dp2.name AnotherDepotName, me.bar_code barCode, me.purchase_decimal
from jsh_depot_item di
left join jsh_material m on di.material_id=m.id and ifnull(m.delete_flag,'0') !='1'
left join jsh_material_extend me on me.id=di.material_extend_id and ifnull(me.delete_Flag,'0') !='1'
left join jsh_depot dp1 on di.depot_id=dp1.id and ifnull(dp1.delete_Flag,'0') !='1'
left join jsh_depot dp2 on di.another_depot_id=dp2.id and ifnull(dp2.delete_Flag,'0') !='1'
where di.header_id = #{headerId}
and ifnull(di.delete_flag,'0') !='1'
order by di.id asc
select di.*,m.name MName,m.model MModel,m.unit MaterialUnit,m.color MColor,m.standard MStandard,m.mfrs MMfrs,m.weight, m.position, m.img_name,
m.other_field1 MOtherField1,m.other_field2 MOtherField2,m.other_field3 MOtherField3,m.enable_serial_number, m.enable_batch_number,
m.brand, dp1.name DepotName,dp2.name AnotherDepotName, me.bar_code barCode, me.purchase_decimal
from jsh_depot_item di
left join jsh_material m on di.material_id=m.id and ifnull(m.delete_flag,'0') !='1'
left join jsh_material_extend me on me.id=di.material_extend_id and ifnull(me.delete_Flag,'0') !='1'
left join jsh_depot dp1 on di.depot_id=dp1.id and ifnull(dp1.delete_Flag,'0') !='1'
left join jsh_depot dp2 on di.another_depot_id=dp2.id and ifnull(dp2.delete_Flag,'0') !='1'
where ifnull(di.delete_flag,'0') !='1'
and di.header_id in
#{item}
order by di.header_id desc, di.id asc
select m.id MId, me.bar_code, m.name MName, m.mfrs MMfrs, m.model MModel, m.standard MStandard, m.brand,
m.other_field1 MOtherField1,m.other_field2 MOtherField2,m.other_field3 MOtherField3,
concat_ws('', m.unit, u.basic_unit) MaterialUnit, m.color MColor, m.unit_id, u.name unit_name,
ifnull(me.purchase_decimal,0) purchase_decimal, ifnull(mcs.current_unit_price,0) currentUnitPrice
from jsh_material m
left join jsh_material_extend me on me.material_id=m.id and ifnull(me.delete_Flag,'0') !='1'
left join jsh_material_current_stock mcs on m.id = mcs.material_id and ifnull(mcs.delete_flag,'0') !='1'
left join jsh_depot_item di on di.material_id=m.id and ifnull(di.delete_Flag,'0') !='1'
left join jsh_depot_head dh on di.header_id=dh.id and ifnull(dh.delete_flag,'0') !='1'
left join jsh_unit u on m.unit_id=u.id and ifnull(u.delete_Flag,'0') !='1'
where 1=1 and me.default_flag=1
and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.mnemonic like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey}
or m.color like #{bindKey} or m.mfrs like #{bindKey} or m.brand like #{bindKey} or m.other_field1 like #{bindKey}
or m.other_field2 like #{bindKey} or m.other_field3 like #{bindKey})
and m.category_id in
#{item}
and dh.oper_time <= #{endTime}
and ifnull(m.delete_flag,'0') !='1'
group by m.id
order by m.id desc
limit #{offset},#{rows}
select count(1) from (select m.id
from jsh_material m
left join jsh_material_extend me on me.material_id=m.id and ifnull(me.delete_Flag,'0') !='1'
left join jsh_depot_item di on di.material_id=m.id and ifnull(di.delete_Flag,'0') !='1'
left join jsh_depot_head dh on di.header_id=dh.id and ifnull(dh.delete_flag,'0') !='1'
where 1=1 and me.default_flag=1
and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.mnemonic like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey}
or m.color like #{bindKey} or m.mfrs like #{bindKey} or m.brand like #{bindKey} or m.other_field1 like #{bindKey}
or m.other_field2 like #{bindKey} or m.other_field3 like #{bindKey})
and m.category_id in
#{item}
and dh.oper_time <= #{endTime}
and ifnull(m.delete_flag,'0') !='1'
group by m.id) cc
select m.id MId, me.bar_code, m.name MName, m.mfrs MMfrs, m.model MModel, m.standard MStandard,
m.other_field1 MOtherField1,m.other_field2 MOtherField2,m.other_field3 MOtherField3,
concat_ws('', m.unit, u.basic_unit) MaterialUnit, m.color MColor, m.brand, u.name unit_name
from jsh_material m
left join jsh_depot_item di on di.material_id=m.id and ifnull(di.delete_Flag,'0') !='1'
left join jsh_material_extend me on me.id=di.material_extend_id and ifnull(me.delete_Flag,'0') !='1'
left join jsh_depot_head dh on di.header_id=dh.id and ifnull(dh.delete_flag,'0') !='1'
left join jsh_unit u on m.unit_id=u.id and ifnull(u.delete_Flag,'0') !='1'
where 1=1
and m.category_id in
#{item}
and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.mnemonic like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey}
or m.color like #{bindKey} or m.mfrs like #{bindKey} or m.brand like #{bindKey} or m.other_field1 like #{bindKey}
or m.other_field2 like #{bindKey} or m.other_field3 like #{bindKey})
and (dh.sub_type = '采购' or dh.sub_type = '采购退货')
and (dh.sub_type = '销售' or dh.sub_type = '销售退货')
and (dh.sub_type = '零售' or dh.sub_type = '零售退货')
and dh.oper_time >= #{beginTime}
and dh.oper_time <= #{endTime}
and dh.creator in (
#{creator}
)
and dh.organ_id = #{organId}
and dh.organ_id in (
#{organId}
)
and di.depot_id in
#{item}
and (dh.status = '1' or dh.status = '2' or dh.status = '3')
and ifnull(m.delete_flag,'0') !='1'
group by m.id
order by m.id desc
limit #{offset},#{rows}
select count(1) from (select m.id
from jsh_material m
left join jsh_depot_item di on di.material_id=m.id and ifnull(m.delete_Flag,'0') !='1'
left join jsh_material_extend me on me.id=di.material_extend_id and ifnull(me.delete_Flag,'0') !='1'
left join jsh_depot_head dh on di.header_id=dh.id and ifnull(dh.delete_flag,'0') !='1'
where 1=1
and m.category_id in
#{item}
and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.mnemonic like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey}
or m.color like #{bindKey} or m.mfrs like #{bindKey} or m.brand like #{bindKey} or m.other_field1 like #{bindKey}
or m.other_field2 like #{bindKey} or m.other_field3 like #{bindKey})
and (dh.sub_type = '采购' or dh.sub_type = '采购退货')
and (dh.sub_type = '销售' or dh.sub_type = '销售退货')
and (dh.sub_type = '零售' or dh.sub_type = '零售退货')
and dh.oper_time >= #{beginTime}
and dh.oper_time <= #{endTime}
and dh.creator in (
#{creator}
)
and dh.organ_id = #{organId}
and dh.organ_id in (
#{organId}
)
and di.depot_id in
#{item}
and (dh.status = '1' or dh.status = '2' or dh.status = '3')
and ifnull(di.delete_flag,'0') !='1'
group by m.id) cc
select ifnull(sum(basic_number),0) as BasicNumber from jsh_depot_item di,jsh_depot_head dh
where di.header_id = dh.id
and dh.type=#{type} and dh.sub_type=#{subType}
and dh.oper_time >= #{beginTime}
and dh.oper_time <= #{endTime}
and di.material_id =#{MId}
and dh.creator in (
#{creator}
)
and dh.organ_id = #{organId}
and dh.organ_id in (
#{organId}
)
and di.depot_id in
#{item}
and (dh.status = '1' or dh.status = '2' or dh.status = '3')
and ifnull(dh.delete_flag,'0') !='1'
and ifnull(di.delete_flag,'0') !='1'
select ifnull(sum(all_price),0) as AllPrice from jsh_depot_item di,jsh_depot_head dh
where di.header_id = dh.id
and dh.type=#{type} and dh.sub_type=#{subType}
and dh.oper_time >= #{beginTime}
and dh.oper_time <= #{endTime}
and di.material_id =#{MId}
and dh.creator in (
#{creator}
)
and dh.organ_id = #{organId}
and dh.organ_id in (
#{organId}
)
and di.depot_id in
#{item}
and (dh.status = '1' or dh.status = '2' or dh.status = '3')
and ifnull(dh.delete_flag,'0') !='1'
and ifnull(di.delete_flag,'0') !='1'
select ifnull(sum(di.all_price),0) as AllPrice
from jsh_depot_item di
left join jsh_depot_head dh on dh.id=di.header_id and ifnull(dh.delete_flag,'0') !='1'
left join jsh_material_extend me on me.id=di.material_extend_id and ifnull(me.delete_Flag,'0') !='1'
left join jsh_material m on m.id=di.material_id and ifnull(m.delete_Flag,'0') !='1'
where ifnull(di.delete_flag,'0') !='1'
and dh.type=#{type} and dh.sub_type=#{subType}
and dh.oper_time >= #{beginTime}
and dh.oper_time <= #{endTime}
and m.category_id in
#{item}
and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.mnemonic like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
and dh.creator in (
#{creator}
)
and dh.organ_id = #{organId}
and dh.organ_id in (
#{organId}
)
and di.depot_id in
#{item}
and (dh.status = '1' or dh.status = '2' or dh.status = '3')
select distinct dh.id, dh.discount_last_money, dh.total_price, dh.type, dh.sub_type, dh.oper_time
from jsh_depot_head dh
left join jsh_depot_item di on dh.id = di.header_id and ifnull(di.delete_flag,'0') != '1'
where di.id is not null
and (dh.type='入库' or dh.type='出库')
and dh.oper_time >= #{beginTime}
and dh.oper_time <= #{endTime}
and (dh.status = '1' or dh.status = '2' or dh.status = '3')
and dh.creator in (
#{creator}
)
and ifnull(dh.delete_flag,'0') != '1'
select ifnull(sum(di.basic_number),0) stockCheckSum from jsh_depot_head dh
left JOIN jsh_depot_item di on dh.id=di.header_id
where 1=1
and di.material_extend_id=#{meId}
and dh.sub_type='盘点复盘'
and di.depot_id in
#{item}
and dh.status = '1'
and dh.oper_time >= #{beginTime}
and dh.oper_time <= #{endTime}
and ifnull(dh.delete_flag,'0') !='1'
and ifnull(di.delete_flag,'0') !='1'
select ifnull(sum(di.basic_number),0) stockCheckSum from jsh_depot_head dh
left JOIN jsh_depot_item di on dh.id=di.header_id
where 1=1
and di.material_id=#{mId}
and dh.sub_type='盘点复盘'
and di.depot_id in
#{item}
and dh.status = '1'
and dh.oper_time >= #{beginTime}
and dh.oper_time <= #{endTime}
and ifnull(dh.delete_flag,'0') !='1'
and ifnull(di.delete_flag,'0') !='1'
select
sum(case when dh.type='入库' then di.basic_number else 0 end) as inTotal,
sum(case when dh.type='出库' and dh.sub_type!='调拨' then di.basic_number else 0 end) as outTotal,
sum(case when dh.sub_type='调拨' then di.basic_number else 0 end) as transfInTotal,
sum(case when dh.sub_type='调拨' then di.basic_number else 0 end) as transfOutTotal,
sum(case when dh.sub_type='组装单' and di.material_type='组合件' then di.basic_number else 0 end) as assemInTotal,
sum(case when dh.sub_type='组装单' and di.material_type='普通子件' then di.basic_number else 0 end) as assemOutTotal,
sum(case when dh.sub_type='拆卸单' and di.material_type='普通子件' then di.basic_number else 0 end) as disAssemInTotal,
sum(case when dh.sub_type='拆卸单' and di.material_type='组合件' then di.basic_number else 0 end) as disAssemOutTotal
from
jsh_depot_head dh
left join jsh_depot_item di on dh.id=di.header_id and ifnull(di.delete_flag,'0') !='1'
where 1=1
and ifnull(dh.delete_flag,'0') !='1'
and di.material_extend_id=#{meId}
and ifnull(di.sku,'') !=''
and dh.status = '1'
and dh.oper_time >= #{beginTime}
and dh.oper_time <= #{endTime}
select
sum(case when dh.type='入库' then di.basic_number else 0 end) as inTotal,
sum(case when dh.type='出库' and dh.sub_type!='调拨' then di.basic_number else 0 end) as outTotal,
sum(case when dh.sub_type='调拨' then di.basic_number else 0 end) as transfInTotal,
sum(case when dh.sub_type='调拨' then di.basic_number else 0 end) as transfOutTotal,
sum(case when dh.sub_type='组装单' and di.material_type='组合件' then di.basic_number else 0 end) as assemInTotal,
sum(case when dh.sub_type='组装单' and di.material_type='普通子件' then di.basic_number else 0 end) as assemOutTotal,
sum(case when dh.sub_type='拆卸单' and di.material_type='普通子件' then di.basic_number else 0 end) as disAssemInTotal,
sum(case when dh.sub_type='拆卸单' and di.material_type='组合件' then di.basic_number else 0 end) as disAssemOutTotal
from
jsh_depot_head dh
left join jsh_depot_item di on dh.id=di.header_id and ifnull(di.delete_flag,'0') !='1'
where 1=1
and ifnull(dh.delete_flag,'0') !='1'
and di.material_id=#{mId}
and dh.status = '1'
and dh.oper_time >= #{beginTime}
and dh.oper_time <= #{endTime}
and (dh.sub_type!='采购' and dh.sub_type!='采购退货' and dh.sub_type!='销售' and dh.sub_type!='销售退货')
and di.depot_id in #{item}
and di.another_depot_id in #{item}
select
dep.id,dep.header_id,dep.material_id,dep.material_unit,dep.oper_number,
dep.basic_number,dep.unit_price,dep.tax_unit_price,dep.all_price,dep.remark,
dep.depot_id,dep.another_depot_id,dep.tax_rate,
dep.tax_money,dep.tax_last_money,dep.material_type
from jsh_depot_item dep,jsh_material mat
where 1=1
and dep.header_id = #{depotheadId}
and dep.material_id=mat.id
and mat.enable_serial_number = #{enableSerialNumber}
and ifnull(dep.delete_flag,'0') !='1'
and ifnull(mat.delete_flag,'0') !='1'
update jsh_depot_item
set delete_flag='1'
where 1=1
and header_id in
(
#{depotheadId}
)
update jsh_depot_item
set delete_flag='1'
where 1=1
and id in (
#{id}
)
select
from jsh_depot_item
where 1=1
and depot_id in (
#{depotId}
)
and ifnull(delete_flag,'0') !='1'
select
from jsh_depot_item
where 1=1
and material_id in (
#{materialId}
)
and ifnull(delete_flag,'0') !='1'
select m.id MId, m.name MName, me.bar_code, m.mfrs MMfrs, m.model MModel, m.standard MStandard,m.color MColor, m.brand,
m.other_field1 MOtherField1,m.other_field2 MOtherField2,m.other_field3 MOtherField3,d.name depotName,
m.unit MaterialUnit, u.basic_unit unit_name,mcs.current_number,
mis.low_safe_stock, mis.high_safe_stock
from jsh_material m
left join jsh_material_extend me on me.material_id=m.id and ifnull(me.delete_Flag,'0') !='1'
left join jsh_material_initial_stock mis on mis.material_id=m.id and ifnull(mis.delete_Flag,'0') !='1'
left join jsh_material_current_stock mcs on mcs.material_id=m.id and ifnull(mcs.delete_Flag,'0') !='1'
left join jsh_unit u on m.unit_id=u.id and ifnull(u.delete_Flag,'0') !='1'
left join jsh_depot d on d.id=mis.depot_id and ifnull(u.delete_flag,'0') !='1'
where 1=1
and me.default_flag=1
and ifnull(m.delete_flag,'0') !='1'
and mis.depot_id=mcs.depot_id
and ((ifnull(mis.low_safe_stock,0)!=0 and mcs.current_number < ifnull(mis.low_safe_stock,0))
or (ifnull(mis.high_safe_stock,0)!=0 and mcs.current_number > ifnull(mis.high_safe_stock,0)))
and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.mnemonic like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey}
or m.color like #{bindKey} or m.mfrs like #{bindKey} or m.brand like #{bindKey} or m.other_field1 like #{bindKey}
or m.other_field2 like #{bindKey} or m.other_field3 like #{bindKey})
and mis.depot_id in
#{item}
and m.category_id in
#{item}
order by depotName asc
limit #{offset},#{rows}
select count(1) from
(select m.id
from jsh_material m
left join jsh_material_extend me on me.material_id=m.id and ifnull(me.delete_Flag,'0') !='1'
left join jsh_material_initial_stock mis on mis.material_id=m.id and ifnull(mis.delete_Flag,'0') !='1'
left join jsh_material_current_stock mcs on mcs.material_id=m.id and ifnull(mcs.delete_Flag,'0') !='1'
left join jsh_unit u on m.unit_id=u.id and ifnull(u.delete_Flag,'0') !='1'
left join jsh_depot d on d.id=mis.depot_id and ifnull(u.delete_flag,'0') !='1'
where 1=1
and me.default_flag=1
and ifnull(m.delete_flag,'0') !='1'
and mis.depot_id=mcs.depot_id
and ((ifnull(mis.low_safe_stock,0)!=0 and mcs.current_number < ifnull(mis.low_safe_stock,0))
or (ifnull(mis.high_safe_stock,0)!=0 and mcs.current_number > ifnull(mis.high_safe_stock,0)))
and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.mnemonic like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey}
or m.color like #{bindKey} or m.mfrs like #{bindKey} or m.brand like #{bindKey} or m.other_field1 like #{bindKey}
or m.other_field2 like #{bindKey} or m.other_field3 like #{bindKey})
and mis.depot_id in
#{item}
and m.category_id in
#{item}
) tb
select ifnull(sum(di.basic_number),0) from jsh_depot_item di
where di.material_extend_id=#{meId}
and di.link_id=#{linkId}
and ifnull(di.delete_flag,'0') !='1'
and di.header_id
in
(
select dh.id from jsh_depot_head dh
where 1=1
and dh.link_number=#{linkStr}
and dh.link_apply=#{linkStr}
and ifnull(dh.delete_flag,'0') !='1'
and dh.sub_type=#{goToType}
)
select ifnull(sum(di.basic_number),0) from jsh_depot_item di
where di.material_extend_id=#{meId}
and di.link_id=#{linkId}
and ifnull(di.delete_flag,'0') !='1'
and di.header_id
in
(
select dh.id from jsh_depot_head dh
where
dh.id!=#{currentHeaderId}
and dh.link_number=#{linkStr}
and dh.link_apply=#{linkStr}
and ifnull(dh.delete_flag,'0') !='1'
and dh.sub_type=#{goToType}
)
select id, bar_code, name, standard, model, unit_id,
commodity_unit, batch_number, expiration_date, sum(basic_number) total_num from
(select di.batch_number id, me.bar_code, m.name, m.standard, m.model, m.unit_id,
me.commodity_unit, di.batch_number,di.expiration_date,
di.basic_number*(case dh.type when '入库' then 1 when '出库' then -1 end) as basic_number
from jsh_depot_head dh
left join jsh_depot_item di on dh.id=di.header_id
left join jsh_material m on m.id=di.material_id and ifnull(m.delete_flag, '0') != '1'
left join jsh_material_extend me on me.material_id=m.id and ifnull(me.delete_flag,'0') !='1'
where me.bar_code= #{barCode}
and di.batch_number like #{bindName}
and di.depot_id= #{depotId}
and di.batch_number= #{batchNumber}
and dh.number!= #{number}
and dh.status = '1'
and (dh.sub_type!='采购' and dh.sub_type!='采购退货' and dh.sub_type!='销售' and dh.sub_type!='销售退货')
and m.enable_batch_number =1
and di.delete_flag!=1) tb
group by batch_number
order by expiration_date asc
select count(1) from jsh_depot_item di
where di.material_id=#{mId} and di.depot_id=#{depotId}
and ifnull(di.delete_flag,'0') !='1'
select di.material_extend_id, sum(di.oper_number) oper_number from jsh_depot_head dh
left join jsh_depot_item di on dh.id=di.header_id and ifnull(di.delete_flag,'0') !='1'
where dh.number=#{linkStr}
and ifnull(dh.delete_flag,'0') !='1'
group by di.material_extend_id
select di.material_extend_id, sum(di.oper_number) oper_number from jsh_depot_head dh
left join jsh_depot_item di on dh.id=di.header_id and ifnull(di.delete_flag,'0') !='1'
where dh.type=#{type}
and dh.link_number=#{linkStr}
and dh.link_apply=#{linkStr}
and ifnull(dh.delete_flag,'0') !='1'
group by di.material_extend_id
select count(di.id) from
jsh_depot_head dh
left join jsh_depot_item di on dh.id=di.header_id and ifnull(di.delete_flag,'0') !='1'
where 1=1
and ifnull(dh.delete_flag,'0') !='1'
and di.material_extend_id=#{meId}
and di.batch_number=#{batchNumber}
select di.* from jsh_depot_head dh
left join jsh_depot_item di on dh.id=di.header_id and ifnull(di.delete_flag,'0') !='1'
where 1=1
and ifnull(dh.delete_flag,'0') !='1'
and di.material_extend_id = #{materialExtendId}
and di.batch_number = #{batchNumber}
and dh.type = '入库'
select m.id, m.name, m.standard, m.model, me.id meId,me.commodity_unit commodityUnit,
me.purchase_decimal purchaseDecimal, me.wholesale_decimal wholesaleDecimal, me.bar_code mBarCode, me.sku
from jsh_material m
left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1'
where 1=1
and me.bar_code in (${barCodes})
and ifnull(m.delete_flag,'0') !='1'
order by m.id desc
select sum(ifnull(current_number,0))
from jsh_material_current_stock
where 1=1
and depot_id = ${depotId}
and material_id = ${mId}
and ifnull(delete_flag,'0') !='1'
select di.unit_price from jsh_depot_head dh
left join jsh_depot_item di on dh.id=di.header_id and ifnull(di.delete_flag,'0') !='1'
where dh.organ_id = #{organId}
and di.material_extend_id = #{meId}
and dh.type = #{type} and dh.sub_type = #{subType}
and ifnull(dh.delete_flag,'0') !='1'
order by dh.id desc, di.id desc
limit 0,1