把内层的${...}改成+...+,还有字符串用双引号
${switch(factory,"ARRAY","
select f_get_date_timekey(to_char(t.time,'yyyymmddhh24miss')) as date_timekey,
decode(substr(t.eqp_id,1,2),'HD','TOUCH','ARRAY') as factory,
.
.
.
where t.value_id>=replace('"+date_start+"','-','')||'000...'
..."+if(len(factory)==0,"...","...")+if...+"..."
}