create or replace procedure p_hfb_jcdw_hjhd_jcrd_add( v_dwzh varchar, v_jsnyvarchar, v_blqdvarchar, v_ywlshvarchar, v_userid int, v_msgin out varchar, v_ret in out smallint ) as v_jgbmvarchar(50); v_zxgjbmvarchar(50); v_jcydvarchar(6); v_hdrqdate:=trunc(sysdate); v_errorcode number; v_errormsgvarchar(200); v_iddecimal(20); v_cntsmallint; begin select jzny into v_jcyd from gjzf_dw_zz where dwzh=v_dwzh; v_jgbm:=f_hfsc_get_user_jgbm(v_userid); v_zxgjbm:=f_hfsc_get_user_zxjgbm(v_userid); select count(*) into v_cnt from gjzf_gr_jcbz where jgbm=v_zxgjbm and v_jsny between ksqyny and jsqyny; if v_cnt=0 then v_msg:=v_jsny||'月度的缴存限额未设置,请联系系统管理员!'; return; -------跳出存储过程,return下面的都不执行。 end if; while v_jcyd<=v_jsny loop p_hfb_jcdw_hjhd_jcrd_add_1(v_dwzh,v_jcyd,v_hdrq,v_blqd,v_userid,v_msg); if trim(v_msg) is not null then rollback ; v_ret:=99; return ; end if ; update gjzf_dw_jcrd set ywlsh=v_ywlsh where dwzh=v_dwzh and jcyd=v_jcyd; v_jcyd:=to_char(add_months(to_date(v_jcyd||'01','yyyymmdd'),1),'yyyymm'); end loop; p_sys_optlog_add(v_zxjgbm,v_jgbm,' ',' ','01','01','010101',v_ywlsh,'汇缴核定',1,0,v_userid,v_blqd,v_msg); if trim(v_msg) is not null then v_ret :=99; rollback; return; end if; p_hfsc_mess_ts(v_jgbm,'010101',v_blqd,v_userid,v_userid,v_ywlsh,v_ywlsh,v_ywlsh,v_msg,v_ret); p_act_noprocess('01','01',v_userid,v_blqd,v_ret); commit; v_msg:='核定办理成功!'; v_ret:=0; exception when others then v_errorcode:=sqlcode; v_errormsg :=sqlerrm; rollback; insert into t_wa_sys_log_err(err_date,name_proc,err_code,err_msg) values(sysdate,'p_hfb_jcdw_hjhd_jcrd_add',v_errorcode,v_errormsg); v_msg:='核定办理失败!'; v_ret:=99; commit; end; create or replace procedure p_hfb_jcdw_hjhd_jcrd_add_1( v_dwzhvarchar, v_rqvarchar, v_hdrqdate, v_blqdvarchar, v_useridint, v_msgin out varchar ) as v_jgbm varchar(50), v_errorcode number; v_errormsgvarchar(200); v_cnt smallint:=0; v_hjrs1 int; v_hjje1 decimal(18,2); v_hjrs2 int; v_hjje2 decimal(18,2); v_czy_1 varchar(100); v_dwmc varchar2(255); v_docunid varchar2(36); v_spjd varchar2(200); v_spczy varchar2(2000); begin select dwmc into v_dwmc from cr_dw where dwbh=(select dwbh from gjzf_dw_zz where dwzh=v_dwzh); select count(grzh) into v_cnt from gjzf_gr_zz where dwzh=v_dwzh and grzhzt='01'; if v_cnt=0 then rollback; v_msg:=v_dwzh||'('||v_dwmc||')单位没有正常的缴存人!'; return; end if; select nvl(sum(1),0) into v_cnt from dual where exists(select a.grzh from gjzf_gr_zz a,gjzf_gr_tq b where a.grzh=b.grzh and a.dwzh=v_dwzh and b.dwzh=v_dwzh and a.grzhzt='01' and (b.tqyybm like '02%' or b.tqyybm like '03%') and b.tqrq is null); if v_cnt<>0 then rollback; v_msg:=v_dwzh||'('||v_dwmc||')存在已录入销户提取或转出提取清册但个人账户状态为正常的缴存人!'; return; end if; select nvl(sum(1),0) into v_cnt from dual where exists(select a.grzh from gjzf_gr_zz a,gjzf_gr_zzbg_qc b where a.grzh=b.grzh and a.dwzh=v_dwzh and a.grzhzt='01' and b.dwzh=v_dwzh and b.bglbbm='06'); if v_cnt <> 0 then rollback; v_msg:=v_dwzh||'('||v_dwmc||')存在已录入单位调整转移清册但个人账户状态为正常的缴存人!' ; return ; end if; select nvl(sum(1),0) into v_cnt from dual where exists(select a.dwzh from gjzf_dw_jcrd a where a.dwzh=v_dwzh and a.jcyd = v_rq and a.hdrq is not null and a.hjrq is null); if v_cnt <> 0 then rollback; v_msg:=v_dwzh||'('||v_dwmc||')单位已核定!' ; return ; end if; v_czy_1:=f_hfsc_get_user_name(v_userid); v_jgbm:=f_hfsc_get_user_jgbm(v_userid); select nvl(max(hjrs,0)),nvl(sum(hjje,0)) into v_hjrs1,v_hjje1 from gjzf_dw_jcrd where dwzh=v_dwzh and grzhzt='01' and jzny=v_rq; select count(*) ,nvl(sum(gryjce+dwyjce+bcyjce+czybte),0) into v_hjrs2,v_hjje2 from gjzf_gr_zz where dwzh=v_dwzh and grzhzt='01' and jzny=v_rq; if v_hjrs1<>v_hjrs2 or v_hjje1<>v_hjje2 then rollback; v_msg:=v_dwzh||'('||v_dwmc||')汇缴人数或汇缴金额发生变化,请重新核定!'; return; end if; p_hfb_jcdw_ywbl_chk(v_dwzh,'汇缴核定',v_msg); if trim(v_msg) is not null then rollback; v_msg:=v_dwzh||'('||v_dwmc||')'||v_msg; return; end if; select count(grzh) into v_cnt from gjzf_gr_zzbg_jc_qc where dwzh=v_dwzh and bgyd<=v_rq and spzt=0; if v_cnt>0 then rollback; v_msg:=v_dwzh||'('||v_dwmc||')存在未提交审批的基数变更清册!' end if; select count(grzh) into v_cnt from gjzf_gr_zzbg_jc_qc where dwzh=v_dwzh and bgyd<=v_rq and spzt>1; if v_cnt>0 then select max(wf_docunid) into v_docunid from gjzf_gr_zzbg_jc_qc where dwzh=v_dwzh and bgyd<=v_rq and spzt>1; select max(name_),to_char(wm_concat(to_char(last_))) into v_spjd,v_spczy from act_ru_identitylink a left join act_id_user b on a.user_id_=b.id_ left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; rollback; v_msg:=v_dwzh||'('||v_dwmc||')存在未审批完成的基数变更清册(当前节点:'||v_spjd||')!' ; return ; end if; delete from gjzf_gr_jcrd where bgrq=v_rq and exists(select grzh from gjzf_gr_zz where grzh=gjzf_gr_jcrd.grzh and dwzh=v_dwzh and grzhzt in('01','02') and jzny=v_rq); update gjzf_dw_jcrd set hdrq=v_hdrq,hdczyid=v_userid,hdczy = v_czy_1,sfhj=1,jgbm=v_jgbm,hdqd=v_blqd where dwzh=v_dwzh and jcyd=v_rq; insert into gjzf_gr_jchd (id,grzh,dwzh,jcblbm,grjcjs,gryjce,dwyjce,bcyjce,czybte,grzhzt,bgyd,jgbm) select f_newid,grzh,dwzh,jcblbm,grjcjs,gryjce,dwyjce,bcyjce,czybte,grzhzt,v_rq,v_jgbm from gjzf_gr_zz where dwzh=v_dwzh and grzhzt in ('01','02') and jzny=v_rq; update gjzf_gw_zz set jzny=to_char(add_months(to_date(jzny||'01','yyyymmdd'),1),'yyyymm') where dwzh=v_dwzh and jzny=v_rq; update gjzf_gr_zz set jzny=to_char(add_months(to_date(jzny||'01','yyyymmdd'),1),'yyyymm') where dwzh=v_dwzh and grzhzt in('01','02') and jzny=v_rq; v_msg=' '; exception when others then v_errorcode:=sqlcode; v_errormsg:=sqlerrm; rollback; insert into t_wa_sys_log_err(err_date,name_proc,err_code,err_msg) values(sysdate,'p_hfb_jcdw_hjhd_jcrd_add_1',v_errorcode,v_errormsg); v_msg:='核定办理失败!'; commit; end; create or replace procedure p_hfb_jcdw_ywbl_chk (--单位业务办理有效性检查 v_dwzh varchar, --单位账号 v_ywlx varchar, --业务类型:单位合并转出、单位合并转入、单位转出、单位销户、启封、封存、冻结、解冻、复议、缴存变更 --内部转移转出、内部转移转入、账户合并转出、账户合并转入、汇缴核定、网点变更、属性变更,缓缴,解除缓缴 --汇缴办理、个人补缴、部分提取、销户提取、外部转出、外部转入、个人调账、暂存款退回、缴暂存款 --托收签约、托收变更 、单位超限--缴存人登记、批量提取 v_msg in out varchar --返回错误信息 ) --加密 as v_dwzt varchar(4) ; v_wbzcbz smallint:=0; v_cnt smallint:=0 ; v_zwdate date:=trunc(sysdate) ; v_a097 varchar(4) ; v_zcje decimal(16,2); v_sf smallint:=0 ; v_splb varchar(2); v_docunid varchar2(36); v_spjd varchar2(200); v_spczy varchar2(1000); v_dwbh varchar2(50); v_dwmc varchar2(100); begin select nvl(sum(1),0) into v_cnt from dual where exists(select begindate from gjzf_nd where jgbm=(select substr(jgbm,1,2) from gjzf_dw_zz where dwzh=v_dwzh) and nd='当前年度' and v_zwdate not between begindate and enddate); if v_cnt <> 0 then v_msg:='业务日期不在系统当前年度范围内!'; return; end if; select nvl(sum(1),0) into v_cnt from dual where exists(select dwzh from gjzf_dw_jz where dwzh=v_dwzh and jxrq is not null) ; if v_cnt <> 0 then v_msg:='此单位已完成年度结息,尚未年终结转!'; return; end if; if trim(v_ywlx) is null then v_msg:='未知业务类型!'; return; end if; select nvl(sum(1),0) into v_cnt from dual where not exists(select dwzh from gjzf_dw_zz where dwzh = v_dwzh ); if v_cnt <> 0 then v_msg:='本中心不存在此单位账号!'; return; end if; select dwzhzt,dwbh into v_dwzt,v_dwbh from gjzf_dw_zz where dwzh = v_dwzh ; if v_dwzt='99' then v_msg:='此单位账户状态存在异常,请确认!'; return ; end if; if v_dwzt='04' then v_msg:='此单位已注销!'; return ; end if; if v_dwzt='00' then v_msg:='此单位账户为登记状态!'; return ; end if; if v_dwzt='05' then if v_ywlx = '暂存款退回' or v_ywlx = '缴暂存款' or v_ywlx = '单位缓缴/解除缓缴' then v_msg:='此单位账户为封存状态!'; return ; end if; end if; select count(*) into v_cnt from gjzf_dw_zzbg where dwzh=v_dwzh and bglb='单位销户' and spzt<>'1'; select max(wf_docunid) into v_docunid from gjzf_dw_zzbg where dwzh=v_dwzh and bglb='单位销户' and spzt<>'1'; if v_cnt <> 0 then select max(name_) into v_spjd from act_ru_identitylink a left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; v_msg:='存在未审批完成的单位注销业务(当前节点:'||v_spjd||')!'; return; end if; --单位合并转出、单位合并转入、单位转出、单位销户、启封、封存、冻结、解冻、复议、 --内部转移转出、内部转移转入、账户合并转出、账户合并转入、汇缴核定、 --汇缴办理、个人补缴、部分提取、销户提取、外部转出、外部转入、个人调账、暂存款退回、缴暂存款 if v_ywlx = '网点变更' then p_hfb_jcdw_ywfh_chk(v_dwzh,v_msg); if trim(v_msg) is not null then return ; end if; elsif v_ywlx = '单位销户' then if v_wbzcbz <> 3 and v_sf = 1 then v_msg:='此单位账户销户尚未批准!'; return ; end if; p_hfb_jcdw_ywfh_chk(v_dwzh,v_msg); if trim(v_msg) is not null then return ; end if; select zckye into v_zcje from gjzf_dw_zz where dwzh=v_dwzh; if v_zcje <> 0 then v_msg:='此单位账户存在未分配金额!'; return ; end if; select dwzhye into v_zcje from gjzf_dw_zz where dwzh = v_dwzh ; if v_zcje <> 0 then v_msg:='此单位账户存在余额!'; return ; end if; select nvl(sum(1),0) into v_cnt from dual where exists (select dwzh from gjzf_gr_zz where dwzh=v_dwzh and grzhzt in('01','02')); if v_cnt <>0 then v_msg:='此单位存在非销户缴存人!'; return; end if; select count(*) into v_cnt from cr_jbxx_bg where crzh=v_dwzh and spzt<>'1' and bgxmdm = 'jzny'; if v_cnt <> 0 then select max(wf_docunid) into v_docunid from cr_jbxx_bg where crzh=v_dwzh and spzt<>'1' and bgxmdm = 'jzny'; select max(name_) into v_spjd from act_ru_identitylink a left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; v_msg:='存在未审批完成的缴存单位应缴年月调整业务(当前节点:'||v_spjd||')!'; return; end if; select count(*) into v_cnt from cr_jbxx_bg where crzh=v_dwzh and spzt<>'1' and bgxmdm not in ('jcblbm','jzny'); if v_cnt <> 0 then select max(wf_docunid) into v_docunid from cr_jbxx_bg where crzh=v_dwzh and spzt<>'1' and bgxmdm not in ('jcblbm','jzny'); select max(name_) into v_spjd from act_ru_identitylink a left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; v_msg:='存在未审批完成的缴存单位信息变更业务(当前节点:'||v_spjd||')!'; return; end if; select nvl(sum(1),0) into v_cnt from dual where exists(select dwzh from gjzf_dw_wtxy_qc where dwzh = v_dwzh and spzt<>1); if v_cnt <> 0 then select splb into v_splb from gjzf_dw_wtxy_qc where dwzh = v_dwzh and spzt<>1; select max(wf_docunid) into v_docunid from gjzf_dw_wtxy_qc where dwzh=v_dwzh and spzt<>'1'; select max(name_) into v_spjd from act_ru_identitylink a left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; if v_splb='01' then v_msg:='此单位存在未审批完成的单位托收签约业务(当前节点:'||v_spjd||')!'; return; elsif v_splb='02' then v_msg:='此单位存在未审批完成的单位托收解约业务(当前节点:'||v_spjd||')!'; return; else v_msg:='此单位存在未审批完成的单位托收变更业务(当前节点:'||v_spjd||')!'; return; end if; end if; select nvl(sum(1),0) into v_cnt from dual where exists(select dwzh from gjzf_dw_wtxy where dwzh = v_dwzh and qyzt<>'03'); if v_cnt <> 0 then v_msg:='此单位已办理单位托收签约业务!'; return; end if; select nvl(sum(1),0) into v_cnt from dual where exists(select crbh from cr_jbxx_bg where crbh=v_dwbh and spzt='0' and bgxmdm='jcblbm'); if v_cnt<>0 then v_msg:='此单位已录入单位缴存比例批量调整清册!'; return ; end if; select count(*) into v_cnt from cr_jbxx_bg where crbh=v_dwbh and spzt<>'1' and bgxmdm='jcblbm'; if v_cnt <> 0 then select max(wf_docunid) into v_docunid from cr_jbxx_bg where crbh=v_dwbh and spzt<>'1' and bgxmdm='jcblbm'; select max(name_) into v_spjd from act_ru_identitylink a left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; v_msg:='存在未审批完成的单位缴存比例批量调整业务(当前节点:'||v_spjd||')!'; return; end if; select count(*) into v_cnt from gjzf_dw_jcbg where dwzh=v_dwzh and bglbmc='单位超上限' and spzt<>'1'; if v_cnt <> 0 then select max(wf_docunid) into v_docunid from gjzf_dw_jcbg where dwzh=v_dwzh and bglbmc='单位超上限' and spzt<>'1'; select max(name_) into v_spjd from act_ru_identitylink a left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; v_msg:='存在未审批完成的超上限业务(当前节点:'||v_spjd||')!'; return; end if; select count(*) into v_cnt from gjzf_dw_jcbg where dwzh=v_dwzh and bglbmc='单位超下限' and spzt<>'1'; if v_cnt <> 0 then select max(wf_docunid) into v_docunid from gjzf_dw_jcbg where dwzh=v_dwzh and bglbmc='单位超下限' and spzt<>'1'; select max(name_) into v_spjd from act_ru_identitylink a left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; v_msg:='存在未审批完成的超下限业务(当前节点:'||v_spjd||')!'; return; end if; elsif v_ywlx ='单位销户申请' then p_hfb_jcdw_ywfh_chk(v_dwzh,v_msg); if trim(v_msg) is not null then return ; end if; select zckye into v_zcje from gjzf_dw_zz where dwzh=v_dwzh; if v_zcje <> 0 then v_msg:='此单位账户存在未分配金额!'; return ; end if; select dwzhye into v_zcje from gjzf_dw_zz where dwzh = v_dwzh ; if v_zcje <> 0 then v_msg:='此单位账户存在余额!'; return ; end if; select nvl(sum(1),0) into v_cnt from dual where exists (select grzh from gjzf_gr_zz where dwzh=v_dwzh and grzhzt in('01','02')); if v_cnt <>0 then v_msg:='此单位存在非销户职工!'; return; end if; select nvl(sum(1),0) into v_cnt from dual where exists (select id from gjzf_dw_mx where dwzh=v_dwzh and ywmxlx='70' and jzrq is null ); if v_cnt <>0 then v_msg:='此单位存在未到账的未分配金额!'; return; end if; select nvl(sum(1),0) into v_cnt from dual where exists ( select dwzh from gjzf_dw_zz where dwzh=v_dwzh and dwzhzt='00'); if v_cnt<>0 then v_msg:='此单位处于开户登记状态!'; return; end if; elsif v_ywlx = '启封' then if v_dwzt <> '05' then v_msg:='此单位账户未封存!'; return ; end if; elsif v_ywlx = '缓缴' then if v_dwzt = '05' then v_msg:='此单位账户已封存!'; return ; end if; if v_dwzt = '03' then v_msg:='此单位已办理缓缴!'; return ; end if; select nvl(sum(1),0) into v_cnt from dual where exists (select dwzh from gjzf_gr_mx where dwzh = v_dwzh and trim(jzrq) is null and gjhtqywlx in ('01','02')); if v_cnt <> 0 then v_msg:='此单位有职工未到账不允许核定'; return; end if; select nvl(sum(1),0) into v_cnt from dual where exists(select dwzh from gjzf_dw_jcrd where dwzh = v_dwzh and trim(hdrq) is not null and trim(hjrq) is null); if v_cnt <> 0 then v_msg:='此单位存在已核定未分配业务!'; return; end if; elsif v_ywlx = '解除缓缴' then if v_dwzt <> '03' then v_msg:='此单位未办理缓缴!'; return ; end if; elsif v_ywlx = '内部转移转入' then select nvl(sum(1),0) into v_cnt from dual where exists (select dwzh from gjzf_dw_jcbg where bglb='09' and dwzh=v_dwzh ); if v_cnt <>0 then v_msg:='此单位存在注销记录!'; return; end if; elsif v_ywlx = '汇缴核定' then if v_dwzt = '05' then v_msg:='单位账户已封存!'; return ; end if; if v_dwzt = '03' then v_msg:='单位已办理缓缴!'; return ; end if; select count(*) into v_cnt from gjzf_dw_jcbg where dwzh=v_dwzh and spzt<>'1' and bglbmc='缓缴'; select max(wf_docunid) into v_docunid from gjzf_dw_jcbg where dwzh=v_dwzh and spzt<>'1' and bglbmc='缓缴'; select max(name_) into v_spjd from act_ru_identitylink a left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; if v_cnt <>0 then v_msg:='存在未审批完成的缓缴申请记录(当前节点:'||v_spjd||')!'; return; end if; select nvl(sum(1),0) into v_cnt from dual where exists (select dwzh from gjzf_gr_mx where dwzh = v_dwzh and trim(jzrq) is null and gjhtqywlx in ('01','02')); if v_cnt <> 0 then v_msg:='单位有职工未到账不允许核定!'; return; end if; /* select nvl(sum(1),0) into v_cnt from dual where exists(select dwzh from gjzf_dw_jcrd where dwzh = v_dwzh and trim(hdrq) is not null and trim(hjrq) is null); if v_cnt <> 0 then v_msg:='单位存在已核定未分配业务!'; return; end if;*/ select nvl(sum(1),0) into v_cnt from dual where exists(select dwzh from gjzf_gr_zz where dwzh = v_dwzh and grzhzt='01'); if v_cnt = 0 then v_msg:='单位无账户状态正常职工!'; return; end if; select nvl(sum(1),0) into v_cnt from dual where exists(select grzh from gjzf_gr_zzbg_qc where dwzh = v_dwzh and bglbbm='04') ; if v_cnt<>0 then v_msg:='单位账户存在未复核的个人账户启封业务!'; return ; end if; select nvl(sum(1),0) into v_cnt from dual where exists(select grzh from gjzf_gr_zzbg_qc where dwzh = v_dwzh and bglbbm='05') ; if v_cnt<>0 then v_msg:='单位账户存在未复核的个人账户封存业务!'; return ; end if; select nvl(sum(1),0) into v_cnt from dual where exists(select crbh from cr_jbxx_bg where crbh=v_dwbh and spzt='0' and bgxm='缴存比例编码'); if v_cnt<>0 then v_msg:='单位已录入单位缴存比例批量调整清册!'; return ; end if; select count(*) into v_cnt from cr_jbxx_bg where crbh=v_dwbh and spzt<>'1' and bgxm='缴存比例编码'; if v_cnt <> 0 then select max(wf_docunid) into v_docunid from cr_jbxx_bg where crbh=v_dwbh and spzt<>'1' and bgxm='缴存比例编码'; select max(name_) into v_spjd from act_ru_identitylink a left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; v_msg:='存在未审批完成的单位缴存比例批量调整业务(当前节点:'||v_spjd||')!'; return; end if; select count(grzh) into v_cnt from gjzf_gr_tq where dwzh=v_dwzh and trim(tqrq) is null and spzt = 0 and tqyybm='0301' ; if v_cnt > 0 then v_msg:='存在外部转出清册!'; return; end if; select count(grzh) into v_cnt from gjzf_gr_tq where dwzh=v_dwzh and trim(tqrq) is null and spzt >1 and tqyybm='0301' ; if v_cnt > 0 then select max(wf_docunid) into v_docunid from gjzf_gr_tq where dwzh=v_dwzh and trim(tqrq) is null and spzt >1 and tqyybm='0301' ; select max(name_) into v_spjd from act_ru_identitylink a left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; v_msg:='单位存在未审批完成的外部转出业务(当前节点:'||v_spjd||')!' ; return ; end if; select count(grzh) into v_cnt from gjzf_gr_tq where dwzh=v_dwzh and trim(tqrq) is null and spzt = 0 and substr(tqyybm,0,2)='02' ; if v_cnt > 0 then v_msg:='存在销户提取清册!'; return; end if; select count(grzh) into v_cnt from gjzf_gr_tq where dwzh=v_dwzh and trim(tqrq) is null and spzt >1 and substr(tqyybm,0,2)='02' ; if v_cnt > 0 then select max(wf_docunid) into v_docunid from gjzf_gr_tq where dwzh=v_dwzh and trim(tqrq) is null and spzt >1 and substr(tqyybm,0,2)='02' ; select max(name_) into v_spjd from act_ru_identitylink a left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; v_msg:='单位存在未审批完成的销户提取业务(当前节点:'||v_spjd||')!' ; return ; end if; select count(grzh) into v_cnt from gjzf_gr_zz where dwzh=v_dwzh and trim(khrq) is null and spzt=0 ; if v_cnt > 0 then v_msg:='存在缴存人开户登记清册!'; return; end if; select count(grzh) into v_cnt from gjzf_gr_zz where dwzh=v_dwzh and trim(khrq) is null and spzt >1 ; if v_cnt > 0 then select max(wf_docunid) into v_docunid from gjzf_gr_zz where dwzh=v_dwzh and trim(khrq) is null and spzt >1 ; select max(name_) into v_spjd from act_ru_identitylink a left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; v_msg:='单位存在未审批完成的缴存人开户业务(当前节点:'||v_spjd||')!' ; return ; end if; elsif v_ywlx = '汇缴办理' then if v_dwzt = '03' then v_msg:='此单位已办理缓缴!'; return ; end if; select nvl(sum(1),0) into v_cnt from dual where exists(select id from gjzf_dw_zcktq where trim(zqrq) is null and dwzh = v_dwzh and spzt<>1 ); if v_cnt<>0 then select max(wf_docunid) into v_docunid from gjzf_dw_zcktq where trim(zqrq) is null and dwzh = v_dwzh and spzt<>1; select max(name_) into v_spjd from act_ru_identitylink a left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; v_msg:='此单位存在未审批完成退未分配金额业务(当前节点:'||v_spjd||')!' ; return ; end if; select nvl(sum(1),0) into v_cnt from dual where exists(select id from gjzf_dw_zcktq where trim(zqrq) is null and dwzh = v_dwzh and spzt=1); if v_cnt<>0 then v_msg:='此单位存在未划款退未分配金额业务!' ; return ; end if; elsif v_ywlx = '个人调账' then if v_dwzt = '05' then v_msg:='此单位账户已封存!'; return ; end if; elsif v_ywlx = '缴存变更' then if v_dwzt = '03' then v_msg:='此单位账户已缓缴!'; return ; end if; select nvl(sum(1),0) into v_cnt from dual where exists(select jcyd from gjzf_dw_jcrd where dwzh = v_dwzh and trim(ywlsh) is null and hdrq is not null); if v_cnt <> 0 then v_msg := '此单位已核定未缴款,不允许办理此业务!'; return; end if; select nvl(sum(1),0) into v_cnt from dual where exists(select grzh from gjzf_gr_zzbg_qc where dwzh = v_dwzh or zydwzh = v_dwzh and bglbbm in('06','12')); if v_cnt <> 0 then v_msg := '此单位存在职工已录入个人调动清册,不允许办理此业务!'; return; end if; elsif v_ywlx = '缴存人开户' then select jcblbm into v_a097 from gjzf_dw_zz where dwzh = v_dwzh; if v_a097 = '0099' then v_msg:='此单位为自由比例,请做比例变更!'; return; end if; elsif v_ywlx = '汇缴变更' then select jcblbm into v_a097 from gjzf_dw_zz where dwzh = v_dwzh; if v_a097 = '0099' then v_msg:='此单位为自由比例,请做比例变更!'; return; end if; elsif v_ywlx = '基数变更' then select jcblbm into v_a097 from gjzf_dw_zz where dwzh = v_dwzh; if v_a097 = '0099' then v_msg:='此单位为自由比例,请做比例变更!'; return; end if; -- select nvl(sum(1),0) into v_cnt from dual where exists(select dwzh,distinct(hjxz) b from gjzf_dw_jcrd where -- dwzh = v_dwzh and trim(hdrq) is not null and trim(hjrq) is null ) ; --王威调整判断,如果存在单位、个人同时已核定未汇缴的月度,才弹出该控制 select sum(b) into v_cnt from (select count(dwzh) b from gjzf_dw_jcrd where dwzh = v_dwzh and trim(hdrq) is not null and trim(hjrq) is null group by jcyd) where b>'1'; if v_cnt <> 0 then v_msg:='此单位存在已核定未分配业务!'; return; end if; select nvl(sum(1),0) into v_cnt from dual where exists(select crbh from cr_jbxx_bg where crbh=v_dwbh and spzt='0' and bgxm='缴存比例编码'); if v_cnt<>0 then v_msg:='此单位已录入单位缴存比例批量调整清册!'; return ; end if; select count(*) into v_cnt from cr_jbxx_bg where crbh=v_dwbh and spzt<>'1' and bgxm='缴存比例编码'; if v_cnt <> 0 then select max(wf_docunid) into v_docunid from cr_jbxx_bg where crbh=v_dwbh and spzt<>'1' and bgxm='缴存比例编码'; select max(name_) into v_spjd from act_ru_identitylink a left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; v_msg:='存在未审批完成的单位缴存比例批量调整业务(当前节点:'||v_spjd||')!'; return; end if; select count(*) into v_cnt from cr_jbxx_bg where crzh=v_dwzh and spzt<>'1' and bgxm<>'缴存比例编码'; if v_cnt <> 0 then select max(wf_docunid) into v_docunid from cr_jbxx_bg where crzh=v_dwzh and spzt<>'1' and bgxm<>'缴存比例编码'; select max(name_) into v_spjd from act_ru_identitylink a left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; v_msg:='存在未审批完成的缴存单位信息变更业务(当前节点:'||v_spjd||')!'; return; end if; elsif v_ywlx = '单位交款' then if v_dwzt = '05' then v_msg:='此单位账户已封存!'; return ; end if; select nvl(sum(1),0) into v_cnt from dual where exists (select dwzh from gjzf_dw_jcbg where bglb='09' and dwzh=v_dwzh ); if v_cnt <>0 then v_msg:='此单位存在注销记录!'; return; end if; elsif v_ywlx = '缴存比例一致性设定' then select jcblbm into v_a097 from gjzf_dw_zz where dwzh = v_dwzh; if v_a097 = '0099' then v_msg:='此单位为自由比例,请做比例变更!'; return; end if; elsif v_ywlx = '单位缴存比例批量调整' then select dwmc into v_dwmc from cr_dw where dwbh = (select dwbh from gjzf_dw_zz where dwzh = v_dwzh); select nvl(sum(1),0) into v_cnt from dual where exists(select grzh from gjzf_gr_zz where dwzh = v_dwzh and grzhzt='00' and spzt=0) ; if v_cnt<>0 then v_msg:='【'||v_dwzh||' ' ||v_dwmc||'】'||'此单位存在缴存人登记清册业务!'; return ; end if; select count(*) into v_cnt from gjzf_gr_zz where dwzh = v_dwzh and grzhzt='00' and spzt<>0; if v_cnt <> 0 then select max(wf_docunid) into v_docunid from gjzf_gr_zz where dwzh = v_dwzh and grzhzt='00' and spzt<>0; select max(name_) into v_spjd from act_ru_identitylink a left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; v_msg:='【'||v_dwzh||' ' ||v_dwmc||'】'||'存在未审批完成的缴存人登记业务(当前节点:'||v_spjd||')!'; return; end if; elsif v_ywlx = '单位缓缴/解除缓缴' then select count(*) into v_cnt from gjzf_dw_jcbg where dwzh=v_dwzh and spzt<>'1' and (bglbmc='缓缴' or bglbmc='解除缓缴') ; select max(wf_docunid) into v_docunid from gjzf_dw_jcbg where dwzh=v_dwzh and spzt<>'1' and (bglbmc='缓缴' or bglbmc='解除缓缴') ; select max(name_) into v_spjd from act_ru_identitylink a left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; if v_cnt <>0 then v_msg:='存在未审批完成的缓缴/解除缓缴业务(当前节点:'||v_spjd||')!'; return; end if; select nvl(sum(1),0) into v_cnt from dual where exists (select dwzh from gjzf_gr_mx where dwzh = v_dwzh and trim(jzrq) is null and gjhtqywlx in ('01','02')); if v_cnt <> 0 then v_msg:='此单位有职工未到账不允许核定'; return; end if; select nvl(sum(1),0) into v_cnt from dual where exists(select dwzh from gjzf_dw_jcrd where dwzh = v_dwzh and trim(hdrq) is not null and trim(hjrq) is null); if v_cnt <> 0 then v_msg:='此单位存在已核定未分配业务!'; return; end if; elsif v_ywlx = '缴存单位信息变更' then select nvl(sum(1),0) into v_cnt from dual where exists (select dwzh from gjzf_gr_zz where dwzh = v_dwzh and grzhzt='00'); if v_cnt <>0 then v_msg:='此单位存在登记状态的职工,不允许办理此业务!'; return; end if; select count(*) into v_cnt from cr_jbxx_bg where crzh=v_dwzh and spzt<>'1' and bgxmdm = 'jzny'; if v_cnt <> 0 then select max(wf_docunid) into v_docunid from cr_jbxx_bg where crzh=v_dwzh and spzt<>'1' and bgxmdm = 'jzny'; select max(name_) into v_spjd from act_ru_identitylink a left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; v_msg:='存在未审批完成的缴存单位应缴年月调整业务(当前节点:'||v_spjd||')!'; return; end if; select count(*) into v_cnt from cr_jbxx_bg where crzh=v_dwzh and spzt<>'1' and bgxmdm not in ('jcblbm','jzny'); if v_cnt <> 0 then select max(wf_docunid) into v_docunid from cr_jbxx_bg where crzh=v_dwzh and spzt<>'1' and bgxmdm not in ('jcblbm','jzny'); select max(name_) into v_spjd from act_ru_identitylink a left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; v_msg:='存在未审批完成的缴存单位信息变更业务(当前节点:'||v_spjd||')!'; return; end if; select nvl(sum(1),0) into v_cnt from dual where exists(select crbh from cr_jbxx_bg where crbh=v_dwbh and spzt='0' and bgxmdm='jcblbm'); if v_cnt<>0 then v_msg:='此单位已录入单位缴存比例批量调整清册!'; return ; end if; select count(*) into v_cnt from cr_jbxx_bg where crbh=v_dwbh and spzt<>'1' and bgxmdm='jcblbm'; if v_cnt <> 0 then select max(wf_docunid) into v_docunid from cr_jbxx_bg where crbh=v_dwbh and spzt<>'1' and bgxmdm='jcblbm'; select max(name_) into v_spjd from act_ru_identitylink a left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; v_msg:='存在未审批完成的单位缴存比例批量调整业务(当前节点:'||v_spjd||')!'; return; end if; select nvl(sum(1),0) into v_cnt from dual where exists(select id from gjzf_dw_zzbg where trim(sprq) is null and dwzh = v_dwzh and spzt<>1 and bglbbm = '79'); if v_cnt<>0 then select max(wf_docunid) into v_docunid from gjzf_dw_zzbg where trim(sprq) is null and dwzh = v_dwzh and spzt<>1 and bglbbm = '79'; select max(name_) into v_spjd from act_ru_identitylink a left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; v_msg:='此单位存在未审批完成单位注销业务(当前节点:'||v_spjd||')!' ; return ; end if; select count(*) into v_cnt from gjzf_gr_zzbg_jc_qc where dwzh=v_dwzh and spzt=0; if v_cnt <> 0 then v_msg:='此单位存在缴存基数调整清册业务!'; rollback; return; end if; select nvl(sum(1),0) into v_cnt from dual where exists(select grzh from gjzf_gr_zzbg_jc_qc where dwzh = v_dwzh and spzt<>0 ); if v_cnt > 0 then select max(wf_docunid) into v_docunid from gjzf_gr_zzbg_jc_qc where dwzh = v_dwzh and spzt<>0; select max(name_) into v_spjd from act_ru_identitylink a left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; v_msg:='存在未审批通过的缴存人基数调整业务(当前节点:'||v_spjd||')!'; rollback; return; end if; elsif v_ywlx = '缴存单位应缴年月变更' then select nvl(sum(1),0) into v_cnt from dual where exists(select dwzh from gjzf_dw_jcrd where dwzh = v_dwzh and trim(hdrq) is not null and trim(hjrq) is null); if v_cnt <> 0 then v_msg:='此单位存在已核定未分配业务!'; return; end if; select nvl(sum(1),0) into v_cnt from dual where exists (select dwzh from gjzf_gr_zz where dwzh = v_dwzh and grzhzt='00'); if v_cnt <>0 then v_msg:='此单位存在登记状态的职工,不允许办理此业务!'; return; end if; select count(*) into v_cnt from cr_jbxx_bg where crbh=v_dwbh and spzt<>'1' and bgxm='缴至年月'; if v_cnt <> 0 then select max(wf_docunid) into v_docunid from cr_jbxx_bg where crbh=v_dwbh and spzt<>'1' and bgxm='缴至年月'; select max(name_),to_char(wm_concat(to_char(last_))) into v_spjd,v_spczy from act_ru_identitylink a left join act_id_user b on a.user_id_=b.id_ left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; v_msg:='存在未审批完成的单位缴至年月调整业务(当前节点:'||v_spjd||')!'; rollback; return; end if; select count(*) into v_cnt from cr_jbxx_bg where crbh=v_dwbh and spzt<>'1' and bgxm='缴存比例编码'; if v_cnt <> 0 then select max(wf_docunid) into v_docunid from cr_jbxx_bg where crbh=v_dwbh and spzt<>'1' and bgxm='缴存比例编码'; select max(name_) into v_spjd from act_ru_identitylink a left join act_id_user b on a.user_id_=b.id_ left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; v_msg:='存在未审批完成的单位缴存比例批量调整业务(当前节点:'||v_spjd||')!'; rollback; return; end if; select count(*) into v_cnt from cr_jbxx_bg where crbh=v_dwbh and spzt<>'1' and bgxm<>'缴存比例编码'; if v_cnt <> 0 then select max(wf_docunid) into v_docunid from cr_jbxx_bg where crbh=v_dwbh and spzt<>'1' and bgxm<>'缴存比例编码'; select max(name_) into v_spjd from act_ru_identitylink a left join act_id_user b on a.user_id_=b.id_ left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; v_msg:='存在未审批完成的缴存单位信息变更业务(当前节点:'||v_spjd||')!'; rollback; return; end if; elsif v_ywlx = '封存' then if v_dwzt = '05' then v_msg:='此单位账户已封存!'; return ; end if; select nvl(sum(1),0) into v_cnt from dual where exists(select distinct(hjxz) , dwzh from gjzf_dw_jcrd where dwzh = v_dwzh and trim(hdrq) is not null and trim(hjrq) is null ) ; if v_cnt <> 0 then v_msg:='此单位存在已核定未分配业务!'; return; end if; select nvl(sum(1),0) into v_cnt from dual where exists(select dwzh from gjzf_dw_wtxy_qc where dwzh = v_dwzh and spzt<>1); if v_cnt <> 0 then select splb into v_splb from gjzf_dw_wtxy_qc where dwzh = v_dwzh and spzt<>1; select max(wf_docunid) into v_docunid from gjzf_dw_wtxy_qc where dwzh=v_dwzh and spzt<>'1'; select max(name_) into v_spjd from act_ru_identitylink a left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; if v_splb='01' then v_msg:='此单位存在未审批完成的单位托收签约业务(当前节点:'||v_spjd||')!'; return; elsif v_splb='02' then v_msg:='此单位存在未审批完成的单位托收解约业务(当前节点:'||v_spjd||')!'; return; else v_msg:='此单位存在未审批完成的单位托收变更业务(当前节点:'||v_spjd||')!'; return; end if; end if; select nvl(sum(1),0) into v_cnt from dual where exists(select dwzh from gjzf_dw_wtxy where dwzh = v_dwzh and qyzt<>'03'); if v_cnt <> 0 then v_msg:='此单位已办理单位托收业务,不允许办理缴存单位封存业务!'; return; end if; /* select nvl(sum(1),0) into v_cnt from dual where exists(select id from gjzf_dw_zcktq where trim(zqrq) is null and dwzh = v_dwzh and spzt<>1 ); if v_cnt<>0 then select max(wf_docunid) into v_docunid from gjzf_dw_zcktq where trim(zqrq) is null and dwzh = v_dwzh and spzt<>1; select max(name_),to_char(wm_concat(to_char(last_))) into v_spjd,v_spczy from act_ru_identitylink a left join act_id_user b on a.user_id_=b.id_ left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; v_msg:='此单位存在未审批完成退未分配金额业务(当前节点:'||v_spjd||')!' ; return ; end if; select nvl(sum(1),0) into v_cnt from dual where exists(select id from gjzf_dw_zcktq where trim(zqrq) is null and dwzh = v_dwzh and spzt=1); if v_cnt<>0 then v_msg:='此单位存在未划款退未分配金额业务!' ; return ; end if;*/ select nvl(sum(1),0) into v_cnt from dual where exists(select grzh from gjzf_gr_zzbg_qc where (dwzh = v_dwzh or zydwzh = v_dwzh) and bglbbm='06' and spzt=0) ; if v_cnt<>0 then v_msg:='此单位账户存在未复核的单位调整业务!'; return ; end if; /* select nvl(sum(1),0) into v_cnt from dual where exists(select grzh from gjzf_gr_zzbg_qc where (dwzh = v_dwzh or zydwzh = v_dwzh) and bglbbm='06' and spzt<>0) ; if v_cnt <> 0 then select max(wf_docunid) into v_docunid from gjzf_gr_zzbg_qc where (dwzh = v_dwzh or zydwzh = v_dwzh) and bglbbm='06' and spzt<>0; select max(name_),to_char(wm_concat(to_char(last_))) into v_spjd,v_spczy from act_ru_identitylink a left join act_id_user b on a.user_id_=b.id_ left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; v_msg:='存在未审批完成的缴存人单位调整业务(当前节点:'||v_spjd||')!'; return; end if;*/ select count(*) into v_cnt from gjzf_dw_jcbg where dwzh=v_dwzh and spzt<>'1' and (bglbmc='缓缴' or bglbmc='解除缓缴') ; select max(wf_docunid) into v_docunid from gjzf_dw_jcbg where dwzh=v_dwzh and spzt<>'1' and (bglbmc='缓缴' or bglbmc='解除缓缴') ; select max(name_) into v_spjd from act_ru_identitylink a left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; if v_cnt <>0 then v_msg:='存在未审批完成的缓缴/解除缓缴业务(当前节点:'||v_spjd||')!'; return; end if; elsif v_ywlx = '缴存单位托收' then select nvl(sum(1),0) into v_cnt from dual where exists(select dwzh from gjzf_dw_zz where dwzh = v_dwzh and jzfcbz=3); if v_cnt <> 0 then v_msg:='此单位是自由职业者单位,不允许办理缴存单位托收业务!'; return; end if; select nvl(sum(1),0) into v_cnt from dual where exists(select dwzh from gjzf_dw_wtxy_qc where dwzh = v_dwzh and spzt<>1); if v_cnt <> 0 then select splb into v_splb from gjzf_dw_wtxy_qc where dwzh = v_dwzh and spzt<>1; select max(wf_docunid) into v_docunid from gjzf_dw_wtxy_qc where dwzh=v_dwzh and spzt<>'1'; select max(name_) into v_spjd from act_ru_identitylink a left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; if v_splb='01' then v_msg:='此单位存在未审批完成的单位托收签约业务(当前节点:'||v_spjd||')!'; return; elsif v_splb='02' then v_msg:='此单位存在未审批完成的单位托收解约业务(当前节点:'||v_spjd||')!'; return; else v_msg:='此单位存在未审批完成的单位托收变更业务(当前节点:'||v_spjd||')!'; return; end if; end if; select count(*) into v_cnt from cr_jbxx_bg where crbh=v_dwbh and spzt<>'1' and bgxmdm='dwjclx'; if v_cnt <> 0 then select max(wf_docunid) into v_docunid from cr_jbxx_bg where crbh=v_dwbh and spzt<>'1' and bgxmdm='dwjclx'; select max(name_) into v_spjd from act_ru_identitylink a left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; v_msg:='存在未审批完成的单位信息变更业务(当前节点:'||v_spjd||')!'; return; end if; elsif v_ywlx = '缴存人托收' then select nvl(sum(1),0) into v_cnt from dual where exists(select dwzh from gjzf_dw_zz where dwzh = v_dwzh and jzfcbz<>3); if v_cnt <> 0 then v_msg:='此单位非自由职业者单位,不允许办理缴存人托收业务!'; return; end if; select nvl(sum(1),0) into v_cnt from dual where exists(select dwzh from gjzf_dw_wtxy_qc where dwzh = v_dwzh and spzt<>1); if v_cnt <> 0 then select splb into v_splb from gjzf_dw_wtxy_qc where dwzh = v_dwzh and spzt<>1; select max(wf_docunid) into v_docunid from gjzf_dw_wtxy_qc where dwzh=v_dwzh and spzt<>'1'; select max(name_) into v_spjd from act_ru_identitylink a left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; if v_splb='01' then v_msg:='此单位存在未审批完成的单位托收签约业务(当前节点:'||v_spjd||')!'; return; elsif v_splb='02' then v_msg:='此单位存在未审批完成的单位托收解约业务(当前节点:'||v_spjd||')!'; return; else v_msg:='此单位存在未审批完成的单位托收变更业务(当前节点:'||v_spjd||')!'; return; end if; end if; select nvl(sum(1),0) into v_cnt from dual where exists(select dwzh from gjzf_dw_wtxy where dwzh = v_dwzh and qyzt<>'03'); if v_cnt <> 0 then v_msg:='此单位已办理单位托收业务,不允许办理缴存人托收业务!'; return; end if; elsif v_ywlx = '外部转入' then select nvl(sum(1),0) into v_cnt from dual where exists(select id from gjzf_dw_zcktq where trim(zqrq) is null and dwzh = v_dwzh and spzt<>1 ); if v_cnt<>0 then select max(wf_docunid) into v_docunid from gjzf_dw_zcktq where trim(zqrq) is null and dwzh = v_dwzh and spzt<>1; select max(name_) into v_spjd from act_ru_identitylink a left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; v_msg:='此单位存在未审批完成退未分配金额业务(当前节点:'||v_spjd||')!' ; return ; end if; select nvl(sum(1),0) into v_cnt from dual where exists(select id from gjzf_dw_zcktq where trim(zqrq) is null and dwzh = v_dwzh and spzt=1); if v_cnt<>0 then v_msg:='此单位存在未划款退未分配金额业务!' ; return ; end if; -- select nvl(sum(1),0) into v_cnt from dual where exists(select dwzh,distinct(hjxz) b from gjzf_dw_jcrd where -- dwzh = v_dwzh and trim(hdrq) is not null and trim(hjrq) is null ) ; --王威调整判断,如果存在单位、个人同时已核定未汇缴的月度,才弹出该控制 select sum(b) into v_cnt from (select count(dwzh) b from gjzf_dw_jcrd where dwzh = v_dwzh and trim(hdrq) is not null and trim(hjrq) is null group by jcyd) where b>'1'; if v_cnt <> 0 then v_msg:='此单位存在已核定未分配业务!'; return; end if; elsif v_ywlx = '暂存款退回' then select zckye into v_zcje from gjzf_dw_zz where dwzh=v_dwzh; if v_zcje = 0 then v_msg:='此单位账户未分配金额为0!'; return ; end if; select nvl(sum(1),0) into v_cnt from dual where exists(select id from gjzf_dw_zcktq where trim(zqrq) is null and dwzh = v_dwzh and spzt<>1 ); if v_cnt<>0 then select max(wf_docunid) into v_docunid from gjzf_dw_zcktq where trim(zqrq) is null and dwzh = v_dwzh and spzt<>1; select max(name_) into v_spjd from act_ru_identitylink a left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; v_msg:='此单位存在未审批完成退未分配金额业务(当前节点:'||v_spjd||')!' ; return ; end if; select nvl(sum(1),0) into v_cnt from dual where exists(select id from gjzf_dw_zcktq where trim(zqrq) is null and dwzh = v_dwzh and spzt=1); if v_cnt<>0 then v_msg:='此单位存在未划款退未分配金额业务!' ; return ; end if; select nvl(sum(1),0) into v_cnt from dual where exists(select dwzh from gjzf_dw_jcrd where dwzh = v_dwzh and trim(hdrq) is not null and trim(hjrq) is null); if v_cnt <> 0 then v_msg:='此单位存在已核定未分配业务!'; return; end if; elsif v_ywlx = '缴存单位封存/启封' or v_ywlx = '单位超限' then if v_dwzt = '04' then v_msg:='此单位账户已注销!'; return ; end if; select nvl(sum(1),0) into v_cnt from dual where exists(select id from gjzf_dw_zzbg where trim(sprq) is null and dwzh = v_dwzh and spzt<>1 and bglbbm = '79'); if v_cnt<>0 then select max(wf_docunid) into v_docunid from gjzf_dw_zzbg where trim(sprq) is null and dwzh = v_dwzh and spzt<>1 and bglbbm = '79'; select max(name_) into v_spjd from act_ru_identitylink a left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; v_msg:='此单位存在未审批完成单位注销业务(当前节点:'||v_spjd||')!' ; return ; end if; select nvl(sum(1),0) into v_cnt from dual where exists(select dwzh from gjzf_dw_jcrd where dwzh = v_dwzh and trim(hdrq) is not null and trim(hjrq) is null); if v_cnt <> 0 then v_msg:='此单位存在已核定未分配业务!'; return; end if; elsif v_ywlx = '冲个人缴存' then if v_dwzt = '05' then v_msg:='此单位账户已封存!'; return ; end if; elsif v_ywlx = '缴存人单位调整' then if v_dwzt = '04' then v_msg:='此单位账户已注销!'; return ; end if; if v_dwzt = '05' then v_msg:='此单位账户已封存!'; return ; end if; select nvl(sum(1),0) into v_cnt from dual where exists(select id from gjzf_dw_zzbg where trim(sprq) is null and dwzh = v_dwzh and spzt<>1 and bglbbm = '79'); if v_cnt<>0 then select max(wf_docunid) into v_docunid from gjzf_dw_zzbg where trim(sprq) is null and dwzh = v_dwzh and spzt<>1 and bglbbm = '79'; select max(name_) into v_spjd from act_ru_identitylink a left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; if trim(v_spjd) is null then v_msg:='此单位存在未审批完成单位注销业务!' ; else v_msg:='此单位存在未审批完成单位注销业务(当前节点:'||v_spjd||')!' ; end if; return ; end if; select count(*) into v_cnt from cr_jbxx_bg where crbh=v_dwbh and spzt<>'1' and bgxm='缴存比例编码'; if v_cnt <> 0 then select max(wf_docunid) into v_docunid from cr_jbxx_bg where crbh=v_dwbh and spzt<>'1' and bgxm='缴存比例编码'; select max(name_) into v_spjd from act_ru_identitylink a left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; if trim(v_spjd) is null then v_msg:='此单位已录入单位缴存比例批量调整清册!'; else v_msg:='存在未审批的单位缴存比例批量调整业务(当前节点:'||v_spjd||')!'; end if; rollback; return; end if; select nvl(sum(1),0) into v_cnt from dual where exists(select dwzh from gjzf_dw_jcrd where dwzh = v_dwzh and trim(hdrq) is not null and trim(hjrq) is null); if v_cnt <> 0 then v_msg:='此单位存在已核定未分配业务!'; return; end if; elsif v_ywlx ='缴存人登记' then if v_dwzt = '04' then v_msg:='此单位账户已注销!'; return ; end if; if v_dwzt = '05' then v_msg:='此单位账户已封存!'; return ; end if; select nvl(sum(1),0) into v_cnt from dual where exists(select id from gjzf_dw_zzbg where trim(sprq) is null and dwzh = v_dwzh and spzt<>1 and bglbbm = '79'); if v_cnt<>0 then select max(wf_docunid) into v_docunid from gjzf_dw_zzbg where trim(sprq) is null and dwzh = v_dwzh and spzt<>1 and bglbbm = '79'; select max(name_) into v_spjd from act_ru_identitylink a left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; if trim(v_spjd) is null then v_msg:='此单位存在未审批完成单位注销业务!' ; else v_msg:='此单位存在未审批完成单位注销业务(当前节点:'||v_spjd||')!' ; end if; return ; end if; select count(*) into v_cnt from cr_jbxx_bg where crbh=v_dwbh and spzt<>'1' and bgxm='缴存比例编码'; if v_cnt <> 0 then select max(wf_docunid) into v_docunid from cr_jbxx_bg where crbh=v_dwbh and spzt<>'1' and bgxm='缴存比例编码'; select max(name_) into v_spjd from act_ru_identitylink a left join act_ru_task c on a.task_id_=c.id_ where c.proc_inst_id_=v_docunid; if trim(v_spjd) is null then v_msg:='此单位已录入单位缴存比例批量调整清册!'; else v_msg:='存在未审批的单位缴存比例批量调整业务(当前节点:'||v_spjd||')!'; end if; rollback; return; end if; -- select nvl(sum(1),0) into v_cnt from dual where exists(select dwzh,distinct(hjxz) b from gjzf_dw_jcrd where -- dwzh = v_dwzh and trim(hdrq) is not null and trim(hjrq) is null ) ; --王威调整判断,如果存在单位、个人同时已核定未汇缴的月度,才弹出该控制 select sum(b) into v_cnt from (select count(dwzh) b from gjzf_dw_jcrd where dwzh = v_dwzh and trim(hdrq) is not null and trim(hjrq) is null group by jcyd) where b>'1'; if v_cnt <> 0 then v_msg:='此单位存在已核定未分配业务!'; return; end if; elsif v_ywlx = '外部转出' then select nvl(sum(1),0) into v_cnt from dual where exists(select dwzh from gjzf_dw_jcrd where dwzh = v_dwzh and trim(hdrq) is not null and trim(hjrq) is null); if v_cnt <> 0 then v_msg:='此单位存在已核定未分配业务!'; return; end if; elsif v_ywlx = '批量提取' then select nvl(sum(1),0) into v_cnt from dual where exists(select dwzh from gjzf_dw_zz where dwzh = v_dwzh and jzfcbz=3); if v_cnt <> 0 then v_msg:='此单位是自由职业者单位,不允许办理批量提取业务!'; return; end if; end if; v_msg := ' '; end;