优化进销存统计报表的查询逻辑
This commit is contained in:
@@ -237,16 +237,13 @@
|
||||
<select id="findByAll" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="ResultByMaterial">
|
||||
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, u.name unit_name,
|
||||
(select ifnull(purchase_decimal,0) from jsh_material_extend me
|
||||
where me.material_id=m.id and me.default_flag=1 and ifnull(me.delete_Flag,'0') !='1' limit 0,1)
|
||||
purchase_decimal
|
||||
concat_ws('', m.unit, u.basic_unit) MaterialUnit, m.color MColor, u.name unit_name, ifnull(me.purchase_decimal,0) purchase_decimal
|
||||
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_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
|
||||
where 1=1 and me.default_flag=1
|
||||
<if test="materialParam != null and materialParam !=''">
|
||||
<bind name="bindKey" value="'%'+materialParam+'%'"/>
|
||||
and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
|
||||
@@ -265,10 +262,10 @@
|
||||
<select id="findByAllCount" resultType="java.lang.Integer">
|
||||
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_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
|
||||
where 1=1 and me.default_flag=1
|
||||
<if test="materialParam != null and materialParam !=''">
|
||||
<bind name="bindKey" value="'%'+materialParam+'%'"/>
|
||||
and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
|
||||
@@ -276,7 +273,7 @@
|
||||
<if test="endTime != null">
|
||||
and dh.oper_time <= #{endTime}
|
||||
</if>
|
||||
and ifnull(di.delete_flag,'0') !='1'
|
||||
and ifnull(m.delete_flag,'0') !='1'
|
||||
group by m.id) cc
|
||||
</select>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user