select c.username,c.businessname ywlx,c.acceptname hj, count(*) bll
from (select d.zllb businessname,
b.name_ acceptname,
(select t.staff_name
from platform.bt_user t
where t.username = b.assignee_) username,
cast(b.start_time_ as date) dealtime
from gisqbpm.act_hi_procinst a
inner join gisqbpm.act_hi_taskinst b
on a.proc_inst_id_ = b.proc_inst_id_
and b.assignee_ <> \'-1\'
inner join bdcdj.slsq d
on d.ywh = a.business_key_) c
where c.dealtime between
to_date(\'2016/1/1 00:00:00\', \'yyyy-mm-dd hh24:mi:ss\') and
to_date(\'2016/8/9 23:59:59\', \'yyyy-mm-dd hh24:mi:ss\')
and c.username not in (\'zscs\', \'开平住建\') ${if(isnull(username),\" \",\" and c.username=\'\"+username+\"\' \")}group by c.username, c.businessname, c.acceptname
order by c.username
c.username not in (\'zscs\', \'开平住建\') ${if(isnull(username),\" \",\" and c.username=\'\"+username+\"\' \")}group by c.username, c.businessname, c.acceptname
相当于拼接sql语句,当参数username为空(null或者“”)时,上面一句=c.username not in (\'zscs\', \'开平住建\')+\" \"+ group by c.username, c.businessname, c.acceptname
当参数username非空时,上面一句=c.username not in (\'zscs\', \'开平住建\') +\" and c.username=\'\"+username参数的值+\"\' \"+group by c.username, c.businessname, c.acceptname