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;