declare
-- lsql varchar2(2000);
bureausn varchar2(50);
internal_no varchar2(100);
org_id varchar2(100);
item_id varchar2(100);
user_name varchar2(50);
info_type varchar2(10) ;
description varchar2(4000);
no varchar2(50);
status varchar2(10);
department_guids varchar2(50);
count number(10);
begin
 --如果是行政许可
if :new.BUTEAUTYPE = 1 then
select i.internal_no ,i.org_id ,i.item_id ,d.personname ,d.status ,d.notifycontent  ,e.department_guid into internal_no,org_id,item_id,user_name,info_type,description,department_guids from inf_user_duban d,risenet_employee e,inf_apply i where d.clerkguid = e.employee_guid and d.workflowinstance_guid = i.workflowinstance_guid and i.workflowinstance_guid =:NEW.WORKFLOWINSTANCE_GUID;--and rownum<2;
--如果是行政处罚
else
select i.internal_no internal_no,i.org_id org_id,i.item_id item_id,d.personname user_name,d.status info_type,d.notifycontent  DESCRIPTION,e.department_guid into internal_no,org_id,item_id,user_name,info_type,description,department_guids from inf_user_duban d,risenet_employee e,inf_punish i where d.clerkguid = e.employee_guid and d.workflowinstance_guid = i.workflowinstance_guid and i.workflowinstance_guid =:NEW.WORKFLOWINSTANCE_GUID ;--and rownum<2;--execute immediate lsql;
end if;
select sq_inf_supervise.nextval into no from dual;
select bureausn into bureausn from spm_bureau where department_guids= (select distinct department_guid from risenet_department where department_guid in(select distinct y.superior_guid from risenet_department y where y.department_guid in (select e.department_guid  from inf_user_duban d,risenet_employee e,inf_apply i where d.clerkguid = e.employee_guid and d.workflowinstance_guid = i.workflowinstance_guid and d.workflowinstance_guid =:NEW.WORKFLOWINSTANCE_GUID)));
bureausn:=bureausn||no;
case info_type when '1' then status:='2' ; else status:='4' ; end case;
insert into inf_supervise(no,internal_no,org_id,item_id,user_name,info_type,description) values(bureausn,internal_no,org_id,item_id,user_name,info_type,description);exception
     when no_data_found then
        count := 1;end;