StringdrugStorage=getJdbcTemplate().queryForObject("select round(ifnull(sum(material_num),0),2) from erp_material_in where audit_status = '3' and arrive_time >='"+startDate+"' and arrive_time <= '"+endDate+"'",String.class);
StringpurchaseMoney=getJdbcTemplate().queryForObject("select round(ifnull(sum(purchase_money),0),2) from erp_purchase_contract where use_flag = 0 and status = 3 and project_time >='"+startDate+"' and project_time <= '"+endDate+"'",String.class);
StringdistributMoney=getJdbcTemplate().queryForObject("select round(ifnull(sum(distribut_money),0),2) from erp_distribut_contract where status = 3 and purchase_time >='"+startDate+"' and purchase_time <= '"+endDate+"' ",String.class);
StringsupplierMoneyByJs=getJdbcTemplate().queryForObject("select round(ifnull(sum(t.total_price_tax),0),2) from erp_settlement t where t.settlement_type = '0' and t.status = '1' and settlement_time >='"+startDate+"' and settlement_time<='"+endDate+"' ",String.class);
StringwaterDepartMoneyByJs=getJdbcTemplate().queryForObject("select round(ifnull(sum(t.total_price_tax),0),2) from erp_settlement t where t.settlement_type = '1' and t.status = '1' and settlement_time >='"+startDate+"' and settlement_time<='"+endDate+"' ",String.class);
select id from erp_distribut_contract where contract_code like CONCAT('%',#{contractCode},'%')
</select>
<!-- 修改分销合同的分销价格-->
<updateid="updateDistributMoney">
update erp_distribut_contract dc set distribut_money = (select sum(dm.distribut_total_price) from erp_distribut_material dm where dm.contract_id = dc.id ) where dc.id = #{contractId}
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 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 ";
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 ";
//电费月报
sql+=" left join( select ec.depart_id , ec.cost , count(1) 'count' from report_electric_cost ec where ec.month like '"+month+"%' and ec.cost > '0' group by ec.depart_id ) ddd on ddd.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 ";
sql+=" left join (select eee.depart_id ,count(1) 'count' from (select left(ee.time,7) time , ee.depart_id from "+view4411Sql+" ee where 1=1 group by ee.depart_id ,left(ee.time,7) HAVING ifnull(sum(ee.yyf),0) >0 and ifnull(sum(ee.ysfsl),0) > 0 )eee group by eee.depart_id )fff on fff.depart_id = d.id ";
sql+=" left join (select eee.depart_id ,count(1) 'count' from (select left(ee.time,7) time , ee.depart_id from "+view4411Sql+" ee where 1=1 and ee.yyf is not null and ee.yyf <> '' and ee.ysfsl is not null and ee.ysfsl <> '' group by ee.depart_id ,left(ee.time,7) )eee group by eee.depart_id )fff on fff.depart_id = d.id ";
sql+=" ";
//目标年报
sql+=" left join(select depart_id ,count(depart_id) 'count' from report_target_config where target_year = year('"+startTime+"') group by depart_id) ggg on ggg.depart_id = d.id ";
returnsql;
}
privateStringgetSelfDepartIds(){
Stringsql="select GROUP_CONCAT(id) 'departIds' from sys_depart where depart_type =1 and parent_id <> '1818215543140909056'";