当前位置:编程学习 > asp >>

簽核流程設置

 /*
---游標處理批量流程---------
---步驟1,建立表--檢查ProjectCode是否帶有特殊字符
---步驟2---檢查所有簽核人帳號是否存在---
--檢查導入簽核人是否正確(主要判斷數據是否為NULL)
select distinct [級數] from dbo.[zlq_PCO1107]
select *  from dbo.[zlq_PCO1107] where [級數]=1 and ([一級簽核] is NULL)
select *  from dbo.[zlq_PCO1107] where [級數]=2 and ([二級簽核] is NULL or [一級簽核] is NULL)
select *  from dbo.[zlq_PCO1107] where [級數]=3 and ([三級簽核] is NULL or [二級簽核] is NULL or [一級簽核] is NULL)
select *  from dbo.[zlq_PCO1107] where [級數]=4 and ([四級簽核] is NULL or [三級簽核] is NULL or [二級簽核] is NULL or [一級簽核] is NULL)
select *  from dbo.[zlq_PCO1107] where [級數]=5 and ([五級簽核] is NULL or [四級簽核] is NULL or [三級簽核] is NULL or [二級簽核] is NULL or [一級簽核] is NULL)
select *  from dbo.[zlq_PCO1107] where [級數]=6 and ([六級簽核] is NULL or [五級簽核] is NULL or [四級簽核] is NULL or [三級簽核] is NULL or [二級簽核] is NULL or [一級簽核] is NULL)
select *  from dbo.[zlq_PCO1107] where [級數]=7 and ([七級簽核] is NULL or [六級簽核] is NULL or [五級簽核] is NULL or [四級簽核] is NULL or [三級簽核] is NULL or [二級簽核] is NULL or [一級簽核] is NULL)
select *  from dbo.[zlq_PCO1107] where [級數]=8 and ([八級簽核] is NULL or [七級簽核] is NULL or [六級簽核] is NULL or [五級簽核] is NULL or [四級簽核] is NULL or [三級簽核] is NULL or [二級簽核] is NULL or [一級簽核] is NULL)
---檢查是否存在于表dbo.PCO_CheckMan中-----     

----首先帳號是否存在于表dbo.PCO_CheckMan中---
----其次真實帳號是否存在于表dbo.Ac_BRM_User中---
select a.[一級簽核],b.Username,c.CheckManID from (select distinct [一級簽核] from dbo.[zlq_PCO1107]) a left join dbo.Ac_BRM_User  b on b.realname=a.[一級簽核] left join dbo.PCO_CheckMan c on c.UserName=b.Username
select a.[二級簽核],b.Username,c.CheckManID from (select distinct [二級簽核] from dbo.[zlq_PCO1107]) a left join dbo.Ac_BRM_User  b on b.realname=a.[二級簽核] left join dbo.PCO_CheckMan c on c.UserName=b.Username
select a.[三級簽核],b.Username,c.CheckManID from (select distinct [三級簽核] from dbo.[zlq_PCO1107]) a left join dbo.Ac_BRM_User  b on b.realname=a.[三級簽核] left join dbo.PCO_CheckMan c on c.UserName=b.Username
select a.[四級簽核],b.Username,c.CheckManID from (select distinct [四級簽核] from dbo.[zlq_PCO1107]) a left join dbo.Ac_BRM_User  b on b.realname=a.[四級簽核] left join dbo.PCO_CheckMan c on c.UserName=b.Username
select a.[五級簽核],b.Username,c.CheckManID from (select distinct [五級簽核] from dbo.[zlq_PCO1107]) a left join dbo.Ac_BRM_User  b on b.realname=a.[五級簽核] left join dbo.PCO_CheckMan c on c.UserName=b.Username
select a.[六級簽核],b.Username,c.CheckManID from (select distinct [六級簽核] from dbo.[zlq_PCO1107]) a left join dbo.Ac_BRM_User  b on b.realname=a.[六級簽核] left join dbo.PCO_CheckMan c on c.UserName=b.Username
select a.[七級簽核],b.Username,c.CheckManID from (select distinct [七級簽核] from dbo.[zlq_PCO1107]) a left join dbo.Ac_BRM_User  b on b.realname=a.[七級簽核] left join dbo.PCO_CheckMan c on c.UserName=b.Username
select a.[八級簽核],b.Username,c.CheckManID from (select distinct [八級簽核] from dbo.[zlq_PCO1107]) a left join dbo.Ac_BRM_User  b on b.realname=a.[八級簽核] left join dbo.PCO_CheckMan c on c.UserName=b.Username
以上語句執行結果中,在簽核人,UserName,CheckManID不同時為空的情況下,有以下兩種情況:
如果UserName欄位為空,說明對應的簽核人在系統中不存在帳號,則暫停設置流程,請相關簽核人申請帳號后再做處理
如果UserName不為空,而CheckManID欄位為空,則說明對應的簽核人在系統中存在帳號,但是在表PCO_CheckMan中不存在帳號,則需要將帳號放入PCO_CheckMan中


--步驟3---建立游標----------
declare Step_cur scroll cursor for
select [流程號],[級數] from [zlq_PCO1107]
open Step_cur
declare @StartID int,@Step int
fetch first from Step_cur into @StartID,@Step
while @@fetch_status=0
begin
 print convert(varchar(30),@StartID)+','+convert(varchar(30),@Step)
 exec dbo.ljj_SetWorkFlow @StartID,@Step
 fetch next from Step_cur into @StartID,@Step
end
close Step_cur
deallocate Step_cur
------------------------------------------
--delete dbo.PCO_WorkFlowStep where stepid in(select distinct StepID from dbo.PCO_WorkFlowStep where StepID>=219320 and StepID<=229543)
select a.StepID,b.[流程號]
from dbo.PCO_WorkFlowStep a
left join dbo.[zlq_PCO1107] b on a.StepID=b.[流程號]
where StepID>=229540 and StepID<=229549
exec dbo.ljj_SetWorkFlow 229540,4
以上這些語句是在導入數據且執行建立游標后,在設置簽核條件這一步驟時出現錯誤的補救方法
--步驟4---設置簽核條件----------
select * from dbo.zlq_PCO1107 where uprange='+∞'

update [zlq_PCO1107]
set [UpRange]=8888 where uprange='+∞'

select * from dbo.zlq_PCO1107 where downrange='-∞'

update [zlq_PCO1107]
set [DownRange]=-8888 where downrange='-∞'


INSERT INTO [QBRClient].[dbo].[PCO_CheckCondition]
   ([ProjectCode], [CommodityCode], [UpRange], [DownRange], [SupplierFlag], [StepID], [Remark])
SELECT [ProjectCode], [Commoditycode],convert(decimal(38,6),[UpRange]),convert(decimal(38,6),[DownRange]), [內外交或其它],[流程號], [級數]
FROM [QBRClient].[dbo].[zlq_PCO1107]

select * from dbo.PCO_Checkcondition where UpRange=8888
update dbo.PCO_Checkcondition
set UpRange=99999999999999999999999999999999
where UpRange=8888

select * from dbo.PCO_Checkcondition where DownRange=-8888
update dbo.PCO_Checkcondition
set DownRange=-99999999999999999999999999999999
where DownRange=-8888

--步驟5---設置簽核帳號----------
INSERT INTO [QBRClient].[dbo].[PCO_WorkFlowChecker]([StepID]  , [CheckManID])
 select [流程號],(select CheckmanID from dbo.PCO_CheckMan
                     where UserName=(select UserName from dbo.member where  Isvalid=1 and Realname=[一級簽核]))
  from dbo.[zlq_PCO1107] where  [一級簽核] is not null

INSERT INTO [QBRClient].[dbo].[PCO_WorkFlowChecker]([StepID]  , [CheckManID])
 select [流程號]+1,(select CheckmanID from dbo.PCO_CheckMan
                     where UserName=(select UserName from dbo.member where  Isvalid=1 and Realname=[二級簽核]))
  from dbo.[zlq_PCO1107] where  [二級簽核] is not null


INSERT INTO [QBRClient].[dbo].[PCO_WorkFlowChecker]([StepID]  , [CheckManID])
 select [流程號]+2,(select CheckmanID from dbo.PCO_CheckMan
                     where UserName=(select UserName from dbo.member where  Isvalid=1 and Realname=[三級簽核]))
  from dbo.[zlq_PCO1107] where  [三級簽核] is not null

INSERT INTO [QBRClient].[dbo].[PCO_WorkFlowChecker]([StepID]  , [CheckManID])
 select [流程號]+3,(select CheckmanID from dbo.PCO_CheckMan
                     where UserName=(select UserName from dbo.member where  Isvalid=1 and Realname=[四級簽核]))
  from dbo.[zlq_PCO1107] where  [四級簽核] is not null

INSERT INTO [QBRClient].[dbo].[PCO_WorkFlowChecker]([StepID]  , [CheckManID])
 select [流程號]+4,(select Check

补充:Web开发 , ASP.Net ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,