add sa docs
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 259 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 344 KiB |
@@ -0,0 +1,2 @@
|
||||
|
||||
https://github.com/bosscheng/vue-draggable-workflow
|
||||
@@ -0,0 +1,457 @@
|
||||
|
||||
/*
|
||||
(ok)bpmm01 簽核設定
|
||||
(ok)bpmm02 表單簽核流程
|
||||
-- 如果某一關有多人待簽, 如何實作一個 主管派工 的關卡?
|
||||
bpmm11 簽核同意
|
||||
bpmm12 簽核駁回
|
||||
bpmm13 簽核作廢
|
||||
-- 作廢的 SOP
|
||||
1.(ok)必須先駁回到原申請人(駁回可以指定前面曾經簽過的人)
|
||||
2.(ok)申請人才能作廢
|
||||
|
||||
-- 考慮用 Tab 三合一, bpm 的登入預設頁面
|
||||
(ok)bpmq01 待簽核表單
|
||||
(ok)bpmq02 已簽核表單 - aside 選單別(只能加在 page, 所以改為 picker 查詢)
|
||||
(ok)bpmq03 已結案表單
|
||||
|
||||
(ok)bpmq11 簽核歷程
|
||||
(ok)bpmq12 後續簽核人
|
||||
|
||||
todo:
|
||||
1.(ok)assign_to 要注意駁回及作廢時要如何 update (檢查並測試相關的 sp)
|
||||
2.(ok)已簽核表單要加 aside 查詢機制
|
||||
3.
|
||||
|
||||
(ok)整理一下 users 的相關資料,劃出組織架構(方便說明) -> 編號要易記
|
||||
(ok)並設定群組內含多人, 流程關卡可以在複雜一點
|
||||
(xx)是否要加入會簽可以考慮一下
|
||||
|
||||
(ok)Azure 紀錄的一定是格林威治時間, 和台北時間差 8 hours
|
||||
考慮寫一支 udf(cloud_addtime), 只要是含時間的欄位, 就 +8 hrs 再傳出(TBD) --> 僅顯示時用
|
||||
測試 ok, 目前先用此法解決, 所有 sql 語法, 只要是要顯示時間, 該欄位就要呼叫本 udf
|
||||
列出所有需要顯示出時間的 sp 並測試
|
||||
======================== ================
|
||||
bpm_sign_todo OK
|
||||
bpm_sign_pass OK
|
||||
bpm_sign_history OK
|
||||
bpm_sign_finish OK
|
||||
bpm_sign_signers OK
|
||||
|
||||
eip_getCalendar OK
|
||||
get_Schedule 應已不使用
|
||||
get_gantt_data OK
|
||||
|
||||
orm_api 底層的 select 是否要加入(傾向 no)
|
||||
*/
|
||||
|
||||
0.key-value 定義
|
||||
-- [sign_status] [varchar](2) not null, -- N:待簽核 P:簽核中 R:拒絶 A:同意 C:作廢
|
||||
insert into zen_keyvalue (tablename,fieldname,keyid,keyvalue) values ('xxxx','sign_status','N','待簽核');
|
||||
insert into zen_keyvalue (tablename,fieldname,keyid,keyvalue) values ('xxxx','sign_status','P','簽核中');
|
||||
insert into zen_keyvalue (tablename,fieldname,keyid,keyvalue) values ('xxxx','sign_status','R','拒絕');
|
||||
insert into zen_keyvalue (tablename,fieldname,keyid,keyvalue) values ('xxxx','sign_status','A','同意');
|
||||
insert into zen_keyvalue (tablename,fieldname,keyid,keyvalue) values ('xxxx','sign_status','C','作廢');
|
||||
|
||||
-- [flow_status] [varchar](2) not null, -- N:待簽核 P:簽核中 Z:結案 C:作廢
|
||||
insert into zen_keyvalue (tablename,fieldname,keyid,keyvalue) values ('xxxx','flow_status','N','待簽核');
|
||||
insert into zen_keyvalue (tablename,fieldname,keyid,keyvalue) values ('xxxx','flow_status','P','簽核中');
|
||||
insert into zen_keyvalue (tablename,fieldname,keyid,keyvalue) values ('xxxx','flow_status','Z','結案');
|
||||
insert into zen_keyvalue (tablename,fieldname,keyid,keyvalue) values ('xxxx','flow_status','C','作廢');
|
||||
|
||||
|
||||
1.先將 flow 的 json 寫到 db, 注意有單引號
|
||||
|
||||
2.再將 json 解析後, 寫到 flow setup 的相關 tables
|
||||
|
||||
/*
|
||||
訊光系統資料表 SYS_TODOHIS(SYS_TODOLIST)的STATUS欄位新增寫入狀態的功能, 如下:
|
||||
結案時: 寫入 'Z',
|
||||
前進(上呈)時: 寫入 'N',
|
||||
退回時: 寫入 'NR',
|
||||
取回時: 寫入 'NF'
|
||||
作廢時: 寫入 'X',
|
||||
加簽時: 寫入 'A'。
|
||||
任意加簽:'AA'
|
||||
檢核(Validate)寫入: 'V'
|
||||
'F':通知
|
||||
暫停時:寫入'NP'
|
||||
============================
|
||||
flowflag
|
||||
N:新起,
|
||||
P:進行中
|
||||
Z:結案
|
||||
X:作廢
|
||||
N:取回 ??
|
||||
*/
|
||||
|
||||
-- flow 列表
|
||||
/*
|
||||
alter table bpm_list add source_table varchar(100);
|
||||
alter table bpm_list add source_pk varchar(100);
|
||||
*/
|
||||
create table bpm_list (
|
||||
flow_id varchar(100) not null,
|
||||
flow_name nvarchar(100),
|
||||
functiontag varchar(100), -- 對應的功能, 如請假單 (hrsm11 ?)
|
||||
-- New fields
|
||||
source_table varchar(100), -- 來源單主 Tables
|
||||
source_pk varchar(100), -- 來源單 pk, 如果是複合主鍵, 用逗號區隔
|
||||
source_note varchar(100), -- 來源單的主旨欄位名稱
|
||||
source_applicant varchar(20), -- 來源單的上呈人欄位名稱(預設 personid)
|
||||
--
|
||||
flow_json nvarchar(max),
|
||||
flow_json_org nvarchar(max)
|
||||
primary key (flow_id)
|
||||
)
|
||||
|
||||
-- flow 內容設定
|
||||
/*
|
||||
insert into zen_keyvalue (tablename,fieldname,keyid,keyvalue) values ('xxxx','elementId','startNode','startNode');
|
||||
insert into zen_keyvalue (tablename,fieldname,keyid,keyvalue) values ('xxxx','elementId','nodeNode','nodeNode');
|
||||
insert into zen_keyvalue (tablename,fieldname,keyid,keyvalue) values ('xxxx','elementId','conditionNode','conditionNode');
|
||||
insert into zen_keyvalue (tablename,fieldname,keyid,keyvalue) values ('xxxx','elementId','switchNode','switchNode');
|
||||
insert into zen_keyvalue (tablename,fieldname,keyid,keyvalue) values ('xxxx','elementId','stopNode','stopNode');
|
||||
|
||||
alter table bpm_setup add typeName varchar(10);
|
||||
|
||||
FlowStatus as 簽核中,拒絶/同意
|
||||
*/
|
||||
create table bpm_setup (
|
||||
flow_id varchar(100) not null,
|
||||
elementId varchar(20) not null, -- startNode,nodeNode,conditionNode,switchNode,stopNode
|
||||
stepId varchar(100), -- 識別代號
|
||||
filterSet varchar(1000), -- 條件(condition only)
|
||||
nextStep varchar(1000),
|
||||
nextStep_false varchar(100),
|
||||
stepName nvarchar(100),
|
||||
-- new
|
||||
typeName varchar(10), -- 類型 fields / users / roles ==> SignerType as 部門主管,指定欄位,指定角色,指定用戶,用戶主管
|
||||
roleName varchar(100)
|
||||
primary key (flow_id,stepId)
|
||||
)
|
||||
|
||||
-- sign 步驟(spread from bpm_setup) 上呈時寫入(bpmm02_spread)
|
||||
create table [dbo].[bpm_flow_sign](
|
||||
[id] int identity(1,1) not null,
|
||||
[flow_id] [varchar](100) not null,
|
||||
[sourceid] [varchar](100) not null, -- 原單的 pk(請假單-單號)
|
||||
[stepName] [nvarchar](30) not null,
|
||||
[flow_level] [smallint] not null, -- 次序
|
||||
--[totallevel] [smallint] not null, -- 沒有用(count 即可)
|
||||
[signerid] [varchar](10) not null,
|
||||
--[signername] [nvarchar](20) not null,
|
||||
[sign_note] [nvarchar](600) null, -- 主旨(請假原因)
|
||||
[sign_status] [varchar](2) not null, -- N:待簽核 P:簽核中 R:拒絶 A:同意 C:作廢
|
||||
--[signtime] [datetime] null, -- 建檔日期
|
||||
create_date datetime null, -- 上呈日期
|
||||
-- 考慮加入 3 個欄位(已加入), 在 同意/駁回 UX 上新增下一關的人員的選項, 如果下一關是多人, 就可以在此指派
|
||||
assign_to char(1), -- 如果某一關指定的 group 有多人, 用此欄位紀錄指派給誰(多人 default=N, 單人=Y)
|
||||
estimate_date datetime null, -- 預計處理日(暫未使用)
|
||||
real_date datetime null, -- 實際處理日(暫未使用)
|
||||
-- the end
|
||||
primary key (id)
|
||||
)
|
||||
|
||||
-- 暫存 spread 時 condition 的 nextStep (內容應僅保留最近 7 天資料即可)
|
||||
create table [dbo].[bpm_flow_spread_log](
|
||||
[id] int identity(1,1) not null,
|
||||
[flow_id] [varchar](100) not null,
|
||||
[sourceid] [varchar](100) not null,
|
||||
stepId varchar(100),
|
||||
nextStep varchar(1000),
|
||||
create_date datetime null, -- 寫入日期
|
||||
primary key (id)
|
||||
)
|
||||
|
||||
-- sign 紀錄 log
|
||||
create table bpm_flow_sign_log (
|
||||
id int identity(1,1) not null,
|
||||
flow_id varchar(100) not null, -- 關連到原單(請假單)
|
||||
sourceid varchar(100) not null, -- 同上
|
||||
create_date datetime null, -- 寫入日期
|
||||
signerid varchar(10) not null,
|
||||
sign_status [varchar](1) not null, -- R:拒絶 A:同意
|
||||
sign_note nvarchar(600) null, -- 簽核意見(同意或拒絕意見)
|
||||
create_date datetime null, -- 寫入日期
|
||||
primary key (id)
|
||||
)
|
||||
|
||||
/*
|
||||
-- 發送 mail 機制(master 的 zen_mail_list)
|
||||
use master;
|
||||
create table zen_mail_list (
|
||||
id int identity(1,1) not null,
|
||||
corp_db varchar(20) null, -- 公司代號(統編)
|
||||
recipient varchar(100) null, -- mail 收件人
|
||||
mail_subject datetime null, -- 主旨
|
||||
content varchar(10) null, -- 內容
|
||||
mail_status smallint null, -- 0:未發送 1:已發送
|
||||
create_date datetime null, -- 寫入日期
|
||||
primary key (id)
|
||||
)
|
||||
*/
|
||||
|
||||
|
||||
3.請假單相關 Tables
|
||||
/*
|
||||
hrs_leave 請假單
|
||||
hrs_leave_date 請假日期(by date)
|
||||
hrs_leavetype 假別
|
||||
*/
|
||||
create table [dbo].[hrs_leave](
|
||||
[billdate] [datetime] not null, -- 申請日
|
||||
[billno] [varchar](20) not null,
|
||||
[personid] [varchar](10) not null, -- 關聯 basperson
|
||||
[agentid] [varchar](10) not null, -- 同上
|
||||
[leavetype] [char](10) not null, -- 關聯 hrs_leavetype
|
||||
[starttime] [datetime] not null,
|
||||
[endtime] [datetime] not null,
|
||||
[days] [decimal](5, 1),
|
||||
[hours] [decimal](5, 1),
|
||||
[filename] [nvarchar](100),
|
||||
[leave_status] [char](1), -- y/n 有效/無效 ??
|
||||
[leave_note] [nvarchar](200) null, -- 請假原因
|
||||
[create_user] [nvarchar](20) null,
|
||||
[create_date] [datetime] null,
|
||||
[update_user] [nvarchar](20) null,
|
||||
[update_date] [datetime] null,
|
||||
-- 暫時觀察
|
||||
--[flow_step] [int] not null, -- bpm_flow_sign.id (目前卡在哪一關) => 最終決定取消
|
||||
[flow_status] [varchar](2) not null, -- N:待簽核 P:簽核中 Z:結案 C:作廢
|
||||
flow_signer varchar(200), -- 目前簽到誰? 系統控制, 並在簽核過程中使用
|
||||
primary key(billno)
|
||||
)
|
||||
|
||||
-- 將區間的請假, 展開到以天為單位
|
||||
create table [dbo].[hrs_leave_date](
|
||||
[billno] [varchar](12) not null,
|
||||
[billdate] [datetime] not null,
|
||||
[stime] [varchar](10) not null,
|
||||
[etime] [varchar](10) null,
|
||||
[leaveday] [decimal](5, 1) null,
|
||||
[leavehour] [decimal](5, 1) null,
|
||||
primary key(billno,billdate)
|
||||
)
|
||||
|
||||
create table [dbo].[hrs_leavetype](
|
||||
[leavetype_id] [varchar](10) not null,
|
||||
[leavetype_name] [nvarchar](10) null,
|
||||
[leavetype_desc] [varchar](20) null,
|
||||
[isyearage] [varchar](1) null,
|
||||
[ispayed] [varchar](1) null,
|
||||
[descrate] [decimal](12, 2) null,
|
||||
[isdescfullentry] [varchar](1) null,
|
||||
[type] [smallint] null,
|
||||
[maxtimes_month] [int] null,
|
||||
[maxtimes_year] [int] null,
|
||||
[showoffwork] [varchar](1) null,
|
||||
[sex] [varchar](2) null,
|
||||
[permitsex] [varchar](2) null,
|
||||
[isdelay] [char](1) null,
|
||||
primary key(leavetype_id)
|
||||
)
|
||||
|
||||
--
|
||||
insert into zen_keyvalue (tablename,fieldname,keyid,keyvalue) values ('xxxx','sa_category','ON','上班');
|
||||
insert into zen_keyvalue (tablename,fieldname,keyid,keyvalue) values ('xxxx','sa_category','OFF','下班');
|
||||
|
||||
-- 打卡調整單(hrsm12)
|
||||
create table [dbo].[hrs_swipecard_adjustment](
|
||||
[billdate] [datetime] not null, -- 出勤日期
|
||||
[billno] [varchar](20) not null,
|
||||
[personid] [varchar](10) not null, -- 申請人(關聯 basperson)
|
||||
--
|
||||
sa_title [nvarchar](200) null, -- 主旨
|
||||
sa_category [varchar](10) null, -- 打卡調整類型(on:上班/off:下班)
|
||||
sa_description [nvarchar](max) null, -- 打卡調整原因
|
||||
--
|
||||
[create_user] [nvarchar](20) null,
|
||||
[create_date] [datetime] null,
|
||||
[update_user] [nvarchar](20) null,
|
||||
[update_date] [datetime] null,
|
||||
-- flow system fields
|
||||
[flow_status] [varchar](2) not null, -- N:待簽核 P:簽核中 Z:結案 C:作廢
|
||||
flow_signer varchar(200), -- 目前簽到誰? 系統控制, 並在簽核過程中使用
|
||||
primary key(billno)
|
||||
)
|
||||
GO
|
||||
|
||||
|
||||
/*
|
||||
資訊處理單及
|
||||
系統變更需求確認書
|
||||
*/
|
||||
-- ok
|
||||
insert into zen_keyvalue (tablename,fieldname,keyid,keyvalue) values ('xxxx','sr_category','net','網路問題');
|
||||
insert into zen_keyvalue (tablename,fieldname,keyid,keyvalue) values ('xxxx','sr_category','permission','權限問題');
|
||||
insert into zen_keyvalue (tablename,fieldname,keyid,keyvalue) values ('xxxx','sr_category','report','BI 報表問題');
|
||||
insert into zen_keyvalue (tablename,fieldname,keyid,keyvalue) values ('xxxx','sr_category','bpm','簽核表單');
|
||||
insert into zen_keyvalue (tablename,fieldname,keyid,keyvalue) values ('xxxx','sr_category','erp','企業管理軟體');
|
||||
insert into zen_keyvalue (tablename,fieldname,keyid,keyvalue) values ('xxxx','sr_category','others','其他');
|
||||
|
||||
-- 資訊問題處理單(eipm21)
|
||||
-- 上呈 -> 直屬主管 -> IT主管 -> 派工 -> 驗收測試 -> 原提案人 -> 結案
|
||||
create table [dbo].[eip_service_request](
|
||||
[billdate] [datetime] not null, -- 申請日
|
||||
[billno] [varchar](20) not null,
|
||||
[personid] [varchar](10) not null, -- 申請人(關聯 basperson)
|
||||
--
|
||||
sr_title [nvarchar](200) null, -- 主旨
|
||||
sr_category [varchar](10) null, -- 問題類別(根據類別跑不同的 Group), 派工時根據相關設定判斷 Group, 派工設定流程要如何設定
|
||||
sr_description [nvarchar](max) null, -- 問題和用途描述
|
||||
[filename] [nvarchar](100),
|
||||
--
|
||||
[create_user] [nvarchar](20) null,
|
||||
[create_date] [datetime] null,
|
||||
[update_user] [nvarchar](20) null,
|
||||
[update_date] [datetime] null,
|
||||
-- flow system fields
|
||||
[flow_status] [varchar](2) not null, -- N:待簽核 P:簽核中 Z:結案 C:作廢
|
||||
flow_signer varchar(200), -- 目前簽到誰? 系統控制, 並在簽核過程中使用
|
||||
primary key(billno)
|
||||
)
|
||||
GO
|
||||
|
||||
-- 系統變更需求確認書(eipm22)
|
||||
create table [dbo].[eip_change_requirement](
|
||||
[billdate] [datetime] not null, -- 申請日
|
||||
[billno] [varchar](20) not null,
|
||||
[personid] [varchar](10) not null, -- 申請人(關聯 basperson)
|
||||
--
|
||||
cr_title [nvarchar](200) null, -- 主旨
|
||||
cr_module [varchar](10) null, -- 系統模組(hrs, eip, pms ...), 根據 module 跑不同的 Group --> 關聯 sys_module
|
||||
cr_description [nvarchar](max) null, -- 需求說明
|
||||
[filename] [nvarchar](100),
|
||||
--
|
||||
[create_user] [nvarchar](20) null,
|
||||
[create_date] [datetime] null,
|
||||
[update_user] [nvarchar](20) null,
|
||||
[update_date] [datetime] null,
|
||||
-- flow system fields
|
||||
[flow_status] [varchar](2) not null, -- N:待簽核 P:簽核中 Z:結案 C:作廢
|
||||
flow_signer varchar(200), -- 目前簽到誰? 系統控制, 並在簽核過程中使用
|
||||
primary key(billno)
|
||||
)
|
||||
GO
|
||||
|
||||
-- 辦公用品請領(eipm23)
|
||||
create table [dbo].[eip_apply_receive](
|
||||
[billdate] [datetime] not null, -- 申請日
|
||||
[billno] [varchar](20) not null,
|
||||
[personid] [varchar](10) not null, -- 申請人(關聯 basperson)
|
||||
--
|
||||
ar_title [nvarchar](200) null, -- 主旨
|
||||
ar_category [varchar](10) null, -- 需求類別(根據類別跑不同的 Group), 派工時根據相關設定判斷 Group, 派工設定流程要如何設定
|
||||
ar_description [nvarchar](max) null, -- 需求說明
|
||||
--
|
||||
[create_user] [nvarchar](20) null,
|
||||
[create_date] [datetime] null,
|
||||
[update_user] [nvarchar](20) null,
|
||||
[update_date] [datetime] null,
|
||||
-- flow system fields
|
||||
[flow_status] [varchar](2) not null, -- N:待簽核 P:簽核中 Z:結案 C:作廢
|
||||
flow_signer varchar(200), -- 目前簽到誰? 系統控制, 並在簽核過程中使用
|
||||
primary key(billno)
|
||||
)
|
||||
GO
|
||||
|
||||
-- 產品測試紀錄表(crmm21)
|
||||
/*
|
||||
insert into zen_keyvalue (tablename,fieldname,keyid,keyvalue) values ('xxxx','package_method','Normal','正常包裝');
|
||||
insert into zen_keyvalue (tablename,fieldname,keyid,keyvalue) values ('xxxx','package_method','Others','其他');
|
||||
insert into zen_keyvalue (tablename,fieldname,keyid,keyvalue) values ('xxxx','final_process','Finished','成品銷售');
|
||||
insert into zen_keyvalue (tablename,fieldname,keyid,keyvalue) values ('xxxx','final_process','Sample','樣品');
|
||||
insert into zen_keyvalue (tablename,fieldname,keyid,keyvalue) values ('xxxx','final_process','Others','其他');
|
||||
*/
|
||||
create table [dbo].[crm_product_testing](
|
||||
[billdate] [datetime] not null, -- 申請日
|
||||
[billno] [varchar](20) not null,
|
||||
[personid] [varchar](10) not null, -- 申請人(關聯 basperson)
|
||||
--
|
||||
custid varchar(10) not null, -- 客戶編號(關聯 bascustomer)
|
||||
productid varchar(20), -- 產品編號
|
||||
-- prodcname nvarchar(100), -- 產品名稱
|
||||
purpose nvarchar(600), -- 目的
|
||||
test_date datetime null, -- 試做日期
|
||||
need_qty decimal(10,2), -- 需求量
|
||||
package_method varchar(10), -- 包裝方式(正常包裝/其他)
|
||||
Package_desc nvarchar(200), -- 包裝描述
|
||||
final_process varchar(10), -- 最終處理(成品銷售/樣品/其他)
|
||||
final_desc nvarchar(200), -- 最終處理描述
|
||||
purpose_desc nvarchar(max), -- 製程需求/訴求
|
||||
spec_desc1 nvarchar(100), -- 巧克力 型態(軟質、硬質)
|
||||
spec_desc2 nvarchar(100), -- 巧克力 融點(℃)
|
||||
spec_desc3 nvarchar(100), -- 乳酪 融解性(高融點、可融)
|
||||
spec_desc4 nvarchar(100), -- 乳酪 型態(片、丁、塊、絲等)
|
||||
real_desc nvarchar(max), -- 試作情形說明
|
||||
response_desc nvarchar(max), -- 意見回覆
|
||||
followup_work nvarchar(max), -- 後續作業
|
||||
--
|
||||
[create_user] [nvarchar](20) null,
|
||||
[create_date] [datetime] null,
|
||||
[update_user] [nvarchar](20) null,
|
||||
[update_date] [datetime] null,
|
||||
close_date datetime null, -- 結案日期
|
||||
-- flow system fields
|
||||
[flow_status] [varchar](2) not null, -- N:待簽核 P:簽核中 Z:結案 C:作廢
|
||||
flow_signer varchar(200), -- 目前簽到誰? 系統控制, 並在簽核過程中使用
|
||||
primary key(billno)
|
||||
)
|
||||
GO
|
||||
|
||||
|
||||
4.加入上呈 sp 機制, 新增簽核紀錄檔
|
||||
exec bpmm02_spread @flod_id,@signerid,@billno;
|
||||
|
||||
5.加入同意(核可) sp 機制
|
||||
exec bpmm02_sign_active @token,'A','hrsm11','221030-001','gm ok'
|
||||
|
||||
6.加入駁回(reject) sp 機制
|
||||
exec bpmm02_sign_active @token,'R','hrsm11','221030-001','gm ok'
|
||||
|
||||
7.加入作廢 sp 機制
|
||||
exec bpmm02_sign_active @token,'C','hrsm11','221030-001','gm ok'
|
||||
|
||||
|
||||
A.待簽核表單
|
||||
A.1 (List)
|
||||
表單名稱 表單編號 主旨 申請人部門 申請人 進行步驟 填單時間
|
||||
======== ============ ========== ========== ====== =========== ===================
|
||||
請假單 2022-08-0018 請假 資訊處 Michael 代理人 2022-08-22 14:20:54
|
||||
|
||||
select
|
||||
b.flow_name,a.sourceid,a.sign_note,d.departmentcname,p.personcname,a.stepName,a.signtime
|
||||
from bpm_flow_sign A
|
||||
left join bpm_list B on A.flow_id = B.flow_id
|
||||
left join basperson P on A.signerid = P.personid
|
||||
left join basdepartment D on D.departmentid = P.departmentid
|
||||
where a.signerid = @login_user and a.sign_status = 'P' -- 目前簽核關卡
|
||||
|
||||
A.2 (單筆顯示)
|
||||
Form
|
||||
[原單]
|
||||
[簽核意見]
|
||||
[簽核歷程]
|
||||
|
||||
[同意] [駁回] [檢視後續簽核人]
|
||||
|
||||
B.已簽核表單(List)
|
||||
表單編號 主旨 申請人部門 申請人 簽核步驟 表單送達時間 簽核結果 簽核時間 表單目前狀況
|
||||
============ ======= ========== ====== =========== =================== ========== =================== ============
|
||||
2022-08-0018 請假 資訊處 Michael 代理人 2022-08-22 14:20:54 同意 2022-08-22 14:20:54 同意結束
|
||||
|
||||
select
|
||||
b.flow_name,a.sourceid,a.sign_note,d.departmentcname,p.personcname,a.stepName,a.signtime
|
||||
from bpm_flow_sign A
|
||||
left join bpm_list B on A.flow_id = B.flow_id
|
||||
left join basperson P on A.signerid = P.personid
|
||||
left join basdepartment D on D.departmentid = P.departmentid
|
||||
-- where a.signerid = xxx and a.sign_status = 'New' -- 待確認
|
||||
|
||||
|
||||
C.已結案表單(List)
|
||||
表單編號 主旨 申請時間 簽核完成時間 歸檔資訊
|
||||
============ ======= =================== ============================ ==========
|
||||
2022-08-0018 請假 2022-08-22 14:20:54 2022-08-22 14:20:54(駁回結束) 自動歸檔
|
||||
|
||||
@@ -0,0 +1,272 @@
|
||||
|
||||
這是一份為企業級系統的簽核流程引擎系統規格書。這套架構充分利用了關聯式資料庫處理動態邏輯與交易(Transaction)的優勢,並將非同步任務(如寄發郵件)完美切割給後端服務處理。
|
||||
|
||||
# SQL 預存程序驅動之簽核流程引擎系統規格書
|
||||
|
||||
## 1. 系統架構概述
|
||||
|
||||
本簽核流程引擎(BPM)以關聯式資料庫為核心,透過前端(如 Vue + amis)定義流程 JSON,並由後端資料庫的預存程序(Stored Procedures)負責解析、展開與狀態驅動 。引擎具備高度擴展性,能與各式營運表單(如請假單、資訊處理單、系統變更需求單等)無縫綁定 。信件通知機制則採解耦設計,由資料庫寫入佇列後,交由 Node.js 排程服務發送 。
|
||||
|
||||
---
|
||||
|
||||
## 2. 核心狀態與代碼定義
|
||||
|
||||
系統透過標準化代碼控制節點與表單的生命週期。
|
||||
|
||||
### 2.1 節點類型 (Element ID)
|
||||
|
||||
*
|
||||
**startNode**: 流程起點 。
|
||||
|
||||
|
||||
*
|
||||
**nodeNode**: 一般簽核節點 。
|
||||
|
||||
|
||||
*
|
||||
**conditionNode**: 條件判斷節點 。
|
||||
|
||||
|
||||
*
|
||||
**switchNode**: 分支節點 。
|
||||
|
||||
|
||||
*
|
||||
**stopNode**: 流程終點 。
|
||||
|
||||
|
||||
|
||||
### 2.2 關卡簽核狀態 (`sign_status`)
|
||||
|
||||
*
|
||||
**N**: 待簽核 。
|
||||
|
||||
|
||||
*
|
||||
**P**: 簽核中 。
|
||||
|
||||
|
||||
*
|
||||
**R**: 拒絕(駁回) 。
|
||||
|
||||
|
||||
*
|
||||
**A**: 同意 。
|
||||
|
||||
|
||||
*
|
||||
**C**: 作廢 。
|
||||
|
||||
|
||||
|
||||
### 2.3 來源表單總體狀態 (`flow_status`)
|
||||
|
||||
*
|
||||
**N**: 待簽核 。
|
||||
|
||||
|
||||
*
|
||||
**P**: 簽核中 。
|
||||
|
||||
|
||||
*
|
||||
**Z**: 結案 。
|
||||
|
||||
|
||||
*
|
||||
**C**: 作廢 。
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
## 3. 資料庫結構 (Schema Design)
|
||||
|
||||
### 3.1 流程定義與設定檔
|
||||
|
||||
*
|
||||
**`bpm_list`**: 存放流程的原始 JSON 定義與來源表單關聯設定 。
|
||||
|
||||
|
||||
* 包含欄位:`flow_id`、`flow_name`、`functiontag`(如 hrsm11) 。
|
||||
|
||||
|
||||
* 關聯設定:`source_table`(來源表名)、`source_pk`(主鍵)、`source_note`(主旨欄位) 。
|
||||
|
||||
|
||||
* 定義檔:`flow_json`、`flow_json_org` 。
|
||||
|
||||
|
||||
|
||||
|
||||
*
|
||||
**`bpm_setup`**: 儲存 JSON 解析後展開的節點明細 。
|
||||
|
||||
|
||||
* 包含欄位:`elementId`、`stepId`、`filterSet`(條件公式)、`nextStep`、`nextStep_false` 。
|
||||
|
||||
|
||||
* 簽核人設定:`typeName`(簽核人類型,如部門主管、指定角色)、`roleName` 。
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### 3.2 流程運作與紀錄檔
|
||||
|
||||
*
|
||||
**`bpm_flow_sign`**: 紀錄實際簽核關卡與處理狀態的核心資料表 。
|
||||
|
||||
|
||||
* 包含欄位:`sourceid`、`stepName`、`flow_level`(關卡次序)、`signerid`、`sign_status` 。
|
||||
|
||||
|
||||
* 派工作業:`assign_to`(若關卡有多人,紀錄指派給誰的註記,單人或指定人為 Y,其餘為 N) 。
|
||||
|
||||
|
||||
|
||||
|
||||
*
|
||||
**`bpm_flow_spread_log`**: 暫存展開流程時 condition 節點判斷的 nextStep 。
|
||||
|
||||
|
||||
* 資料僅保留最近 7 天,以節省空間 。
|
||||
|
||||
|
||||
|
||||
|
||||
*
|
||||
**`bpm_flow_sign_log`**: 簽核動作的歷史軌跡稽核檔 。
|
||||
|
||||
|
||||
* 紀錄 `sign_status`(同意/拒絕)與 `sign_note`(簽核意見) 。
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### 3.3 系統整合檔
|
||||
|
||||
*
|
||||
**`zen_mail_list`**: 跨庫整合的郵件發送佇列(位於 `zenclouddb` 或 `master`) 。
|
||||
|
||||
|
||||
* 包含收件人、主旨、內容與 `mail_status`(0: 未發送,1: 已發送) 。
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
## 4. 預存程序 (Stored Procedures) 規格清單
|
||||
|
||||
### 4.1 流程定義管理 (Setup & Parsing)
|
||||
|
||||
*
|
||||
**`bpmm01_crud`**: 將前端設計好的流程 JSON 寫入或更新至 `bpm_list` 資料表中 。
|
||||
|
||||
|
||||
*
|
||||
**`bpmm01_get`**: 透過 `flow_id` 取出 `bpm_list` 中保存的原始 JSON 內容供前端編輯器渲染 。
|
||||
|
||||
|
||||
*
|
||||
**`bpmm01_spread`**: 將 JSON 格式的流程定義解析成關聯式資料寫入 `bpm_setup` 。
|
||||
|
||||
|
||||
*
|
||||
**邏輯**: 透過字串分割迴圈處理,辨識 `elementId` 並萃取 `filterSet`、條件分支(`nextStep`、`nextStep_false`)與多分支(`switchNode` 最高支援 10 個 branch) 。寫入前會先清空舊的定義以防止重複 。
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### 4.2 流程引擎驅動 (Engine Execution)
|
||||
|
||||
*
|
||||
**`bpmm02_spread`**: 表單「上呈」時觸發,負責將流程範本展開為實際的簽核關卡 。
|
||||
|
||||
|
||||
*
|
||||
**邏輯**: 寫入申請人節點(flow_level = 0),並一路往下推演直到遇到 `stopNode` 。
|
||||
|
||||
|
||||
*
|
||||
**動態條件**: 遇到 `conditionNode` 時,會動態組裝 SQL 去查詢來源表單(如 `hrs_leave`),根據條件公式(`filterSet`)的檢驗結果決定走 `nextStep` 或 `nextStep_false` 。
|
||||
|
||||
|
||||
*
|
||||
**初始派工**: 將第一關簽核人的 `assign_to` 設為 'Y',並更新來源表單狀態為 'P' 。同時將通知信件寫入佇列交由 Node.js 發送 。
|
||||
|
||||
|
||||
|
||||
|
||||
*
|
||||
**`bpmm02_sign_active`**: 處理核心的簽核動作(同意 A、駁回 R、作廢 C) 。
|
||||
|
||||
|
||||
*
|
||||
**交易安全**: 全程包覆於 `BEGIN TRANSACTION` 與 `TRY...CATCH` 中,確保異動的一致性 。
|
||||
|
||||
|
||||
*
|
||||
**同意 (A)**: 推進至下一關卡(`flow_level + 1`);若為最後一關,則將原單狀態轉為結案 ('Z') 。
|
||||
|
||||
|
||||
*
|
||||
**駁回 (R)**: 退回上一關(`flow_level - 1`)或依據傳入的 `@next_signer` 指定退回至之前曾經簽核過的特定人員 。
|
||||
|
||||
|
||||
*
|
||||
**作廢 (C)**: 直接中止流程,狀態設為 'C' 。
|
||||
|
||||
|
||||
*
|
||||
**狀態回寫**: 利用動態 SQL(`sys_sql_debug`)回寫來源表單(如將 `hrs_leave` 的 `flow_status` 更新) 。寫入軌跡紀錄至 `bpm_flow_sign_log` 。
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### 4.3 介面查詢與輔助 (UI & Helpers)
|
||||
|
||||
*
|
||||
**`bpm_sign_todo`**: 查詢當前登入使用者的「待簽核」清單(狀態為 'P' 且 `assign_to` 為 'Y') 。
|
||||
|
||||
|
||||
*
|
||||
**`bpm_sign_pass`**: 查詢使用者曾經參與簽核但「尚未結案」的「已簽核」表單清單 。
|
||||
|
||||
|
||||
*
|
||||
**`bpm_sign_signers`**: 列出單一表單完整的「簽核歷程」與所有參與過的簽核人狀態 。
|
||||
|
||||
|
||||
*
|
||||
**`bpmm02_sign_assign`**: 提供前端 UI 在同意或駁回時的「指定簽核人」下拉選單資料來源 。
|
||||
|
||||
|
||||
* 同意時,列出下一關(`flow_level + 1`)的人員供主管派工 。
|
||||
|
||||
|
||||
* 駁回時,列出歷史關卡(`flow_level < @flow_level`)中曾實際處理過的人員供指定退回 。
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
## 5. 跨環境時區處理架構
|
||||
|
||||
由於資料庫部署於雲端(如 Azure),系統底層紀錄的皆為 UTC (格林威治時間) 。為確保前端報表與列表的顯示一致性,實作了專屬 UDF 解決:
|
||||
|
||||
*
|
||||
**`dbo.cloud_addtime`**: 查詢端(如 `bpm_sign_todo`, `bpm_sign_pass`, `bpm_sign_signers`)在輸出 `create_date` 等時間欄位時,必須呼叫此函式動態加上 8 小時轉換為台北時間 。此設計確保了底層資料的時區純淨度,僅在展示層進行轉換。
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
這套規格已涵蓋了您提供的所有簽核引擎底層細節。需要我為您進一步深入分析其中「動態 SQL 條件引擎的防禦機制」,或是針對「後端 API 呼叫這些 SP 的架構」進行探討嗎?
|
||||
Reference in New Issue
Block a user