select t.* from HF_CUSTINFO t where $equal(t.cust_naem,cust_name) and spmc in (select item_name from HF_SP_SETTING where is_show=1) and $between(xsrq,searchbegindate,searchenddate) and (is_hf is null or is_hf !=1 or(is_hf=1 and (is_success is null or is_success!=1))) and del_flag!=1 order by t.spFl,t.id select org_name,cust_naem,cust_tax_code,spmc, is_hf,is_success,last_date,reflect_name, case when state='-1' then '' when state='0' then '待处理' when state='1' then '已处理' when state='2' then '处理中' else '' end as state from( select h.org_name,cust_naem,h.cust_tax_code, wmsys.wm_concat(spfl || '(' || spmc || ')' ) AS spmc, wmsys.wm_concat(distinct case when( is_hf is null or is_hf != 1) THEN '未回访' when(is_hf=1) then '已回访'end) as is_hf, wmsys.wm_concat(distinct case when(is_hf=1 and( is_success is null or is_success != 1)) THEN '回访不成功' when(is_hf=1 and is_success= 1) then '回访成功' when(is_hf!=1 or is_hf is null) then '' end) as is_success, max(r.update_date) as last_date,max(rf.reflect_name) as reflect_name, case when max(ex.state) is null or max(ex.state)='' then '-1' else max(ex.state) end as state from hf_custinfo h left join (select hr.log_id,hr.obj_id,hr.sp_id,hr.operate_date as update_date,row_number() OVER(PARTITION BY sp_id ORDER BY operate_date DESC) as rn from hf_log hr where hr.type='answer' ) r on r.sp_id = id and r.rn=1 left join (select hl.log_id,hl.obj_id,hl.reflect_type_id from hf_log hl where type='revisit') l on l.log_id=r.obj_id left join hf_excustomer_info ex on cust_naem =ex.cust_name left join revisit_reflect_type rf on rf.reflect_id=l.reflect_type_id where 1=1 and $like(h.org_name,org_name) and h.org_name not in(select code_desc from revisit_base_code where code_type = 'no_orgname') and $like(h.cust_naem,cust_name) and h.spmc in (select item_name from HF_SP_SETTING where is_show=1) and $like(h.spmc,sp_name) and (({hf_state}=-1 and (h.is_hf !=1 or h.is_success!=1 or h.is_hf is null or h.is_success is null)) OR ({hf_state}=0 and (h.is_hf is null or h.is_hf!=1)) OR ({hf_state}=1 and h.is_hf=1 and h.is_success =1) OR ({hf_state}=2 and h.is_hf=1 and h.is_success !=1)) and $equal(l.reflect_type_id,reflect) and $between(h.xsrq,searchbegindate,searchenddate) and (({type}='-1') OR ({type}='0' and (h.type is null or h.type = '')) OR ({type}='1' and (h.type='1')) OR ({type}='2' and (h.type='2'))) and h.del_flag!=1 group by h.org_name,cust_naem,h.cust_tax_code order by cust_naem) where 1=1 and $equal(state,extype) select max(RECORD_ID) AS rid from HF_RECORD where CUST_NAME={cust_name} and CUST_TAX_CODE={cust_tax_code} and SP_IDS={sp_ids} select count(1) from HF_RECORD where CUST_NAME={cust_name} and CUST_TAX_CODE={cust_tax_code} and SP_IDS={sp_ids} insert into hf_record (record_id,CUST_NAME,SP_IDS, CUST_TAX_CODE,CREATE_ID,CREATE_DATE,UPDATE_ID,UPDATE_DATE) values ({record_id},{cust_name},{sp_ids}, {cust_tax_code},{create_id},sysdate,{create_id},sysdate) insert into hf_log (log_id,obj_id,type, operate_id,operate_name,operate_date, ip,remark,reflect_type_id,is_success, satisfy,suggestion, video_path,sp_id,answers) values ({log_id},{obj_id},{type}, {operate_id},{operate_name},sysdate, {ip},{remark},{reflect_type_id},{is_success}, {satisfy},{suggestion}, {video_path},{sp_id},{answers}) update hf_custinfo set is_hf = {is_hf}, is_success = {is_success} where id = {spid} select v.hf_name as contact,v.phone as mobile,v.source as source,v.mobile_mark from V_HFCONTACT_test2 v where v.cust_name = {cust_name} select v.hf_name as contact,v.phone as mobile,v.source as source,v.mobile_mark,v.flag,v.operate_date from V_HFCONTACT_all v where v.cust_name = {cust_name} select distinct cust_naem as id,cust_naem as text from hf_custinfo where 1=1 and org_name not in(select code_desc from revisit_base_code where code_type = 'no_orgname') and spmc in (select item_name from HF_SP_SETTING where is_show=1) and (is_hf !=1 or is_success!=1 or is_hf is null or is_success is null) and $between(xsrq,searchbegindate,searchenddate) and $equal(hf_phone,dlphone) and cust_naem !={cust_name} and del_flag!=1 order by cust_naem insert into hf_contact(id,CUST_NAME,CONTACT,MOBILE, SOURCE,FLAG,OPERATOR_CODE,OPERATOR_NAME,VITAL,mobile_mark) values({id},{cust_name},{contact},{mobile},{source},{flag},{userId},{userName},{remark},{mobile_mark}) select * from hf_contact where cust_name = {cust_name} and mobile={mobile} select * from V_hfcontact_test2 where cust_name = {cust_name} and phone={mobile} update hf_contact set contact={contact}, flag={flag}, operator_code={operator_code}, operator_name={operator_name}, operate_date=sysdate, mobile_mark={mobile_mark}, source={source} where cust_name = {cust_name} and mobile={mobile} insert into HF_EXCUSTOMER_INFO (ID,CUSTOMER_ID,CUST_NAME,CUST_TAX_CODE,FEEDBACK,CONTACTS_INFO,END_DATE, CREATE_DATE,CUST_TYPE,ORG_ID,ORG_NAME,REVENUEID,REVENUENAME,INVOICE_ADDR, LEGAL_PERSON,CUTSTYPE,CUTSREMARK,RUSTYPE,DEALTIME,ISTAXATION,REMARK,HF_REMARK) values ({id},{customer_id},{cust_name},{cust_tax_code},{feedback},{contacts_info},{end_date}, {create_date},{cust_type},{org_id},{org_name},{revenueid},{revenuename},{invoice_addr}, {legal_person},{cutstype},{cutsremark},{rustype},{dealtime},{istaxation},{remark},{hf_remark}) update HF_EXCUSTOMER_INFO set feedback={feedback}, contacts_info={contacts_info}, hf_remark={hf_remark}, update_name={update_name}, update_date=sysdate, rustype={rustype}, cutsremark={cutsremark}, dealtime={dealtime}, cutstype={cutstype}, state={state} where 1=1 and id={id} select l.log_id,l.obj_id,l.type,l.operate_name,l.operate_date,l.remark||l.suggestion as remark, case when l.is_success='0' then '回访不成功' when l.is_success='1' then '回访成功' when l.is_success='2' then '不需要回访' end as is_success, e.reflect_name,r.cust_name,r.detail,lp.video_path,lp.remark as ph_remark,lp.log_id as logphone_id from hf_log l left join revisit_reflect_type e on l.reflect_type_id = e.reflect_id left join (select a.obj_id,b.cust_naem as cust_name, to_char(wm_concat(b.spfl||':'||b.spmc)) as detail from hf_custinfo b,hf_log a where a.sp_id=b.id and a.type='answer' group by a.obj_id,b.cust_naem) r on r.obj_id=l.log_id left join hf_log lp on lp.type='phone' and lp.obj_id=l.log_id where l.type='revisit' and l.is_success!='2' and ({searchbegindate} is null or l.operate_date>=to_date({searchbegindate},'yyyy-mm-dd hh24:mi:ss')) and ({searchenddate} is null or l.operate_date<=to_date({searchenddate},'yyyy-mm-dd hh24:mi:ss')) and ({hf_state}=-1 or ({hf_state}=0 and l.is_success='1') or ({hf_state}=2 and l.is_success='0')) and $like(r.cust_name,cust_name) and $like(r.detail,sp_name) and $equal(l.operate_id,operate_name) order by l.operate_date desc select l.log_id,l.operate_name,l.operate_date,s.detail, case when l.is_success='1' then '回访成功' when l.is_success='0' then '回访不成功' when l.is_success='2' then '不需要回访' end as is_success, e.reflect_name,l.suggestion from hf_log l left join (select r.record_id,r.cust_name,to_char(wm_concat(b.spfl||':'||b.spmc)) as detail from hf_record r,hf_custinfo b where r.cust_name={cust_name} and instr(r.sp_ids,b.id) > 0 and b.cust_naem = r.cust_name group by r.record_id,r.cust_name) s on s.record_id = l.obj_id left join revisit_reflect_type e on l.reflect_type_id = e.reflect_id where l.type='revisit' and l.obj_id=s.record_id order by operate_date desc select l.log_id,case when l.is_success='0' then '回访不成功' when l.is_success='1' then '回访成功' else l.is_success end as is_success, l.sp_id,c.spfl||':'||c.spmc as spmc,l.answers,l.remark from hf_log l left join hf_custinfo c on l.sp_id= c.id where l.type in('answer','noneed') and l.obj_id={log_id} select * from hf_log l where l.type='phone' and l.obj_id={log_id} select l.log_id,l.obj_id,l.type,l.operate_name,to_char(l.operate_date,'yyyy-mm-dd hh24:mi:ss') as operate_date, l.suggestion as remark, case when l.is_success='0' then '回访不成功' when l.is_success='1' then '回访成功' end as is_success, e.reflect_name,r.cust_name,r.detail,lp.phone_rec from hf_log l left join revisit_reflect_type e on l.reflect_type_id = e.reflect_id inner join (select a.obj_id,b.cust_naem as cust_name, to_char(wm_concat(b.spfl||':'||b.spmc)) as detail from hf_custinfo b,hf_log a where a.sp_id=b.id and a.type='answer' and $like(b.cust_naem,cust_name) and (({type}='-1') OR ({type}='0' and (b.type is null or b.type = '')) OR ({type}='1' and (b.type='1')) OR ({type}='2' and (b.type='2'))) group by a.obj_id,b.cust_naem) r on r.obj_id=l.log_id left join (select obj_id, '' as phone_rec from hf_log where type='phone' group by obj_id)lp on lp.obj_id=l.log_id where l.type='revisit' and $equal(l.reflect_type_id,reflect) and ({searchbegindate} is null or l.operate_date>=to_date({searchbegindate},'yyyy-mm-dd hh24:mi:ss')) and ({searchenddate} is null or l.operate_date<=to_date({searchenddate},'yyyy-mm-dd hh24:mi:ss')) and l.is_success !='2' and $equal(l.is_success,hf_state) order by l.operate_date desc select org_name,cust_naem as cust_name,cust_tax_code, spfl,xsrq,spmc,ywy,price,hf_name,hf_phone,prepare_name,prepare_phone, case when h.is_success='0' then '回访不成功' when h.is_success='1' then '回访成功' end as is_success, e.reflect_name, v.suggestion from hf_custinfo h left join (select * from (select l.*,ROW_NUMBER() OVER(PARTITION BY l.sp_id ORDER BY operate_date DESC) as rn from hf_log l where l.type='answer') where rn=1)r on r.sp_id = h.id left join (select * from hf_log where type='revisit')v on v.log_id=r.obj_id left join revisit_reflect_type e on v.reflect_type_id = e.reflect_id where 1=1 and h.is_hf=1 and $equal(h.org_name,org_name) and $like(h.cust_naem,cust_name) and $equal(h.is_success,hf_state) and $between(h.xsrq,searchbegindate,searchenddate) and h.del_flag!=1 and (({type}='-1') OR ({type}='0' and (h.type is null or h.type = '')) OR ({type}='1' and (h.type='1')) OR ({type}='2' and (h.type='2'))) and $equal(e.reflect_id,reflect) order by h.cust_naem,h.xsrq select count(1) from hf_custinfo h left join (select * from (select l.*,ROW_NUMBER() OVER(PARTITION BY l.sp_id ORDER BY operate_date DESC) as rn from hf_log l where l.type='answer') where rn=1)r on r.sp_id = h.id left join (select * from hf_log where type='revisit')v on v.log_id=r.obj_id left join revisit_reflect_type e on v.reflect_type_id = e.reflect_id where 1=1 and h.is_hf=1 and $equal(h.is_success,hf_state) and $between(h.xsrq,searchbegindate,searchenddate) and h.del_flag!=1 and (({type}='-1') OR ({type}='0' and (h.type is null or h.type = '')) OR ({type}='1' and (h.type='1')) OR ({type}='2' and (h.type='2'))) and (({ishy}='-1') OR ({ishy}='1' and (h.spmc like '%托管%' or h.spmc like '%51信享云台%')) OR ({ishy}='0' and (h.spmc not like '%培训费%' and h.spmc not like '%51信享云台%'))) order by h.cust_naem,h.xsrq select result_type, case when result_type='回访成功' then 1 when result_type='其他' then 3 else 2 end as rowtype from( select distinct case when h.is_success='1' then '回访成功' when h.is_success='0' and e.reflect_name is not null then e.reflect_name else '其他' end as result_type from hf_custinfo h left join (select * from (select l.*,ROW_NUMBER() OVER(PARTITION BY l.sp_id ORDER BY operate_date DESC) as rn from hf_log l where l.type='answer') where rn=1)r on r.sp_id = h.id left join (select * from hf_log where type='revisit')v on v.log_id=r.obj_id left join revisit_reflect_type e on v.reflect_type_id = e.reflect_id where 1=1 and h.is_hf=1 and $between(h.xsrq,searchbegindate,searchenddate) and h.del_flag!=1 and (({type}='-1') OR ({type}='0' and (h.type is null or h.type = '')) OR ({type}='1' and (h.type='1')) OR ({type}='2' and (h.type='2'))) group by r.operate_name,e.reflect_name,h.is_success) order by rowtype select question_id,question_name from REVISIT_QUESTION_DETAIL t where t.question_type_name='金融' order by question_id select h.org_name,h.cust_naem,h.cust_tax_code, h.spfl,h.xsrq,h.spmc,h.hf_name,h.hf_phone,h.dkjg,h.fkrq, h.fkje,h.ykqx,h.ywy,h.lilv,h.sdsj,h.ssqy,h.sxzt,h.sxed,h.sfyx, case when h.is_success='0' then '回访不成功' when h.is_success='1' then '回访成功' end as hf_result, e.reflect_name, v.suggestion, r.answers, to_char(r.operate_date,'yyyy/mm/dd hh24:mi:ss') as operate_date, r.sp_id from hf_custinfo h left join (select * from (select l.*,ROW_NUMBER() OVER(PARTITION BY l.sp_id ORDER BY operate_date DESC) as rn from hf_log l where l.type='answer') where rn=1)r on r.sp_id = h.id left join (select * from hf_log where type='revisit')v on v.log_id=r.obj_id left join revisit_reflect_type e on v.reflect_type_id = e.reflect_id where 1=1 and h.is_hf=1 and $equal(h.org_name,org_name) and $like(h.cust_naem,cust_name) and $equal(h.is_success,hf_state) and $between(h.xsrq,searchbegindate,searchenddate) and h.del_flag!=1 and h.type='1' and $equal(e.reflect_id,reflect) order by h.sdsj insert into HF_EX_LOG (ID,CREATE_DATE,CREATE_NAME,ACTION,REMARK,OBJ_ID, INFO,CUST_TYPE,MIAOSHU) values ({id},{create_date},{create_name},{action},{remark},{obj_id}, {info},{cust_type},{miaoshu})