select d.depart_name 'departName', ss.sparepart_code,ss.sparepart_name, st.item_text as 'sparepart_type_name',sm.supp_name as 'supplier_name',ss.sparepart_name, ss.specification,ss.measuring_unit,
from erp_distribut_material dm , erp_purchase_material pm ,erp_purchase_contract pc
where dm.good_code = pm.good_code and pm.contract_id = pc.id and pc.use_flag = '0' and dm.del_flag = '0' and pm.del_flag = '0' and pc.start_time <= now() and pc.end_time >= now()
...
...
@@ -65,7 +71,23 @@
<if test="param.sparepartName != null and param.sparepartName !=''">and pm.sparepart_name like '%${param.sparepartName}%'</if>
) aaa
left join erp_distribut_contract dc on dc.id = aaa.distribut_contract_id
left join equipment_sparepart_type st on st.id = aaa.sparepart_type
left join equipment_sparepart_type st on st.id = aaa.sparepart_type-->
from erp_distribut_material dm , erp_purchase_material pm ,erp_purchase_contract pc
where dm.good_code = pm.good_code and pm.contract_id = pc.id and pc.use_flag = '0' and dm.del_flag = '0' and pm.del_flag = '0' and pc.start_time <= now() and pc.end_time >= now()
and dm.contract_id = #{param.distributContractId }
<iftest="param.sparepartCode != null and param.sparepartCode !=''">and pm.sparepart_code =#{param.sparepartCode}</if>
<iftest="param.sparepartType != null and param.sparepartType !=''">and pm.sparepart_type in (${param.sparepartType}) </if>
<iftest="param.sparepartName != null and param.sparepartName !=''">and pm.sparepart_name like '%${param.sparepartName}%'</if>
) aaa
left join equipment_sparepart_supplies ss on aaa.sparepart_id = ss.id
left join equipment_sparepart_type st on st.id = ss.sparepart_type
left join erp_distribut_contract dc on dc.id = aaa.distribut_contract_id
sql+=" left join (select aa.depart_id ,count(1) 'count' from "+view3a24Sql+" aa where aa.WNL is not null and aa.WNL <> '' and aa.DLHJ is not null and aa.DLHJ <> '' and aa.YSL is not null and aa.YSL <> '' group by aa.depart_id )aaa on aaa.depart_id = d.id ";
// 能耗日报 及时天数
sql+=" left join (select aa.depart_id ,count(1) 'count' from "+view3a24Sql+" aa where aa.WNL is not null and aa.WNL <> '' and aa.DLHJ is not null and aa.DLHJ <> '' and aa.YSL is not null and aa.YSL <> '' and DATEDIFF(aa.create_time , aa.time) < 2 group by aa.depart_id )aaaHH on aaaHH.depart_id = d.id ";
sql+=" left join ( select bb.depart_id ,count(1) 'count' from "+view2119Sql+" bb ";
sql+=" where bb.JSL is not null and bb.JSL <> '' and bb.CSL is not null and bb.CSL <> '' and bb.JSAD is not null and bb.JSAD <> '' and bb.CSAD is not null and bb.CSAD <> '' ";
sql+=" and bb.JSZD is not null and bb.JSZD <> '' and bb.CSTN is not null and bb.CSTN <> '' and bb.JSZL is not null and bb.JSZL <> '' and bb.CSZL is not null and bb.CSZL <> '' ";
sql+=" and bb.JSCOD is not null and bb.JSCOD <> '' and bb.CSCOD is not null and bb.CSCOD <> '' and bb.JSPH is not null and bb.JSPH <> '' and bb.CSPH is not null and bb.CSPH <> '' ";
sql+=" group by bb.depart_id )bbb on bbb.depart_id = d.id ";
Stringview2119Sql_where=" where bb.JSL is not null and bb.JSL <> '' and bb.CSL is not null and bb.CSL <> '' and bb.JSAD is not null and bb.JSAD <> '' and bb.CSAD is not null and bb.CSAD <> '' ";
view2119Sql_where+=" and bb.JSZD is not null and bb.JSZD <> '' and bb.CSTN is not null and bb.CSTN <> '' and bb.JSZL is not null and bb.JSZL <> '' and bb.CSZL is not null and bb.CSZL <> '' ";
view2119Sql_where+=" and bb.JSCOD is not null and bb.JSCOD <> '' and bb.CSCOD is not null and bb.CSCOD <> '' and bb.JSPH is not null and bb.JSPH <> '' and bb.CSPH is not null and bb.CSPH <> '' ";
sql+=" left join ( select bb.depart_id ,count(1) 'count' from "+view2119Sql+" bb "+view2119Sql_where+" group by bb.depart_id )bbb on bbb.depart_id = d.id";
//水质水量日报 及时天数
sql+=" left join ( select bb.depart_id ,count(1) 'count' from "+view2119Sql+" bb "+view2119Sql_where+" and DATEDIFF(bb.create_time , bb.time) < 2 group by bb.depart_id )bbbHH on bbbHH.depart_id = d.id";
sql+=" left join (select cc.depart_id ,count(1) 'count' from "+viewbffaSql+" cc ";
sql+=" where cc.JSPHHY is not null and cc.JSPHHY <> '' and cc.CSPHHY is not null and cc.CSPHHY <> '' and cc.JSCODHY is not null and cc.JSCODHY <> '' and cc.CSCODHY is not null and cc.CSCODHY <> '' ";
sql+=" and cc.JSZLHY is not null and cc.JSZLHY <> '' and cc.CSZLHY is not null and cc.CSZLHY <> '' and cc.CSTNHY is not null and cc.CSTNHY <> '' and cc.JSZDHY is not null and cc.JSZDHY <> '' ";
sql+=" and cc.JSADHY is not null and cc.JSADHY <> '' and cc.CSADHY is not null and cc.CSADHY <> '' ";
sql+=" group by cc.depart_id )ccc on ccc.depart_id = d.id ";
StringviewbffaSql_where=" where cc.JSPHHY is not null and cc.JSPHHY <> '' and cc.CSPHHY is not null and cc.CSPHHY <> '' and cc.JSCODHY is not null and cc.JSCODHY <> '' and cc.CSCODHY is not null and cc.CSCODHY <> '' ";
viewbffaSql_where+=" and cc.JSZLHY is not null and cc.JSZLHY <> '' and cc.CSZLHY is not null and cc.CSZLHY <> '' and cc.CSTNHY is not null and cc.CSTNHY <> '' and cc.JSZDHY is not null and cc.JSZDHY <> '' ";
viewbffaSql_where+=" and cc.JSADHY is not null and cc.JSADHY <> '' and cc.CSADHY is not null and cc.CSADHY <> '' ";
sql+=" left join (select cc.depart_id ,count(1) 'count' from "+viewbffaSql+" cc "+viewbffaSql_where+" group by cc.depart_id )ccc on ccc.depart_id = d.id ";
sql+=" left join (select cc.depart_id ,count(1) 'count' from "+viewbffaSql+" cc "+viewbffaSql_where+" and DATEDIFF(cc.create_time , cc.time) < 2 group by cc.depart_id )cccHH on cccHH.depart_id = d.id ";
//电费月报
sql+=" left join( select ec.depart_id , count(1) 'count' from report_electric_cost ec where ec.month = '"+month+"' and ec.cost is not null and ec.cost <> '' group by ec.depart_id ) ddd on ddd.depart_id = d.id ";