1 create table a_stat_card
2 (
3 ng_id varchar(20) not null comment '主键,自增加,用于表间的数据关联和唯一索引一条数据,无业务意义'
4 primary key,
5 st_kind int default 0 null comment '0:从考勤机取得,1:手动添加',
6 ng_user_id bigint not null comment '用户ID',
7 ng_dev_id bigint not null comment '设备ID',
8 ts_card datetime not null comment '打卡时间',
9 st_card_type bigint default 0 null comment '保留字段: 打卡类型 0:一般卡; 1:上班; 2:下班; 3:加班上班; 4:加班下班; 5:外出; 6:回来',
10 st_dev_class int default 0 null comment '设备类型 0:考勤机 1:门禁机',
11 sz_verify varchar(127) null comment '验证字段,是EmployeeID,CardTime的校验和,防止手动添加【废弃字段】',
12 bt_validate int default 1 null comment '卡点是否有效 0:无效;1:有效',
13 ng_forget_id bigint null comment '漏打卡申请单',
14 ng_modify_id bigint default 0 null comment '0:未修改; >0:修改该卡点的管理员ID',
15 st_modify_type int default 0 null comment '0:未赋值; 1:删除;2:修改时间; 3:修改类型;4:添加',
16 ts_modify datetime default '0000-00-00 00:00:00' null comment '修改时间',
17 bt_native int default 1 null comment '打卡地点标识:0=异地,1=本地',
18 sz_photo_path varchar(200) null comment '卡点照片存储路径',
19 ng_creator bigint null comment '条目创建者ID',
20 ts_create datetime not null comment '条目创建时间'
21 );
22
23 create index index_ts_card
24 on a_stat_card (ts_card);
25
26 create index ng_forget_id
27 on a_stat_card (ng_forget_id);
28
29 create index ng_modify_id
30 on a_stat_card (ng_modify_id);
31
32 create index ng_user_id
33 on a_stat_card (ng_user_id);
34
35 create index stat_card_query_user_i
36 on a_stat_card (ng_user_id, ts_card);
37
38 grant select on table a_stat_card to jabilit;
39
40 create table dev_device
41 (
42 ng_id bigint auto_increment comment '主键,自增加,用于表间的数据关联和唯一索引一条数据,无业务意义'
43 primary key,
44 sz_name varchar(255) not null comment '考勤机名称',
45 sz_type varchar(50) null comment '考勤机类型,如C330,C226',
46 sz_algorithm_edition varchar(50) null comment '考勤机识别算法版本,用于判断模板兼容性',
47 st_dev_class int default 0 null comment '设备类型 0:考勤机 1:门禁机',
48 sz_ip_addr varchar(127) null comment '考勤机ip地址 ',
49 ts_last_rcd datetime null comment '最后一次下载记录的时间 ',
50 sz_dev_pwd varchar(63) null comment '通信密码',
51 sz_mask varchar(127) null comment '子网掩码',
52 sz_gateway varchar(127) null comment '网关',
53 sz_mac varchar(127) null comment 'MAC地址',
54 sz_serial varchar(127) not null comment '设备序列号 ',
55 sz_rom_edition varchar(127) null comment '考勤机软件版本号',
56 sz_volume varchar(31) null comment '音量',
57 sz_place varchar(255) null comment '安装位置',
58 nt_user_capacity int default 0 null comment '用户总容量 ,程序自动更新',
59 nt_user_used int default 0 null comment '用户容量的使用量,程序自动维护',
60 nt_rcd_capacity int default 0 null comment '记录总容量 ,程序自动维护',
61 dev_monitor_id bigint null comment '设备监控程序ID',
62 nt_rcd_used int default 0 null comment '记录已经使用的容量,程序自动维护',
63 ts_last_active datetime null comment '考勤机的最后活动时间,程序自动维护',
64 nt_state int default 1 not null comment ' 1=设备启用;0=设备停用',
65 tx_comment text null comment '备注',
66 nt_rcd_fresh int default 0 null comment '未上传卡点数量',
67 sz_server_ip varchar(200) null comment '设备Web服务器IP地址',
68 nt_server_port int null comment '设备Web服务器端口号',
69 sz_admin_pwd varchar(100) null comment '设备管理员密码',
70 ng_creator bigint null comment '创建人',
71 ts_create datetime null comment '创建时间',
72 constraint UQ_dev_device_sz_name
73 unique (sz_name),
74 constraint UQ_dev_device_sz_serial
75 unique (sz_serial),
76 constraint FK_dev_device_dev_monitor
77 foreign key (dev_monitor_id) references dev_monitor (ng_id)
78 )
79 comment '考勤机';
80
81 create index dev_monitor_id
82 on dev_device (dev_monitor_id);
83
84 grant select on table dev_device to jabilit;
85
86 create table sys_branch
87 (
88 ng_id bigint auto_increment comment '主键,自增加,用于表间的数据关联和唯一索引一条数据,无业务意义'
89 primary key,
90 sz_name varchar(255) not null comment '部门名称 DESCR',
91 ng_parent_id bigint null comment '父部门ID',
92 bt_is_agency bigint default 0 null comment '是否是机构 0:否 1:是',
93 sz_set_id varchar(50) not null comment '部门表中的:SETID 机构表中的:BUSINESS_UNIT,如果存储的是机构,则sz_code为固定值:__NO_VALUE__',
94 sz_code varchar(50) not null comment '部门代码,DEPTID',
95 nt_order int default 9 not null comment '显示次序',
96 sz_branch_type varchar(3) null comment '保留字段:部门类型',
97 ng_rule_id bigint null comment '本部门采用的考勤规则,可以为空。 该规则计算优先顺序如下: 1.班次规则 2.部门规则 3.父部门规则',
98 bt_inherit int default 1 not null comment '是否继承父部门的规则 0:否 1:是',
99 bt_alllow_neutralize bigint default 0 null comment '是否允许加班与请假-调休工时相抵',
100 nt_state int default 1 null comment '1:正常,0:未定义,-1:删除',
101 sz_branch_path varchar(255) not null comment '部门的路径,如果某个部门为: 总部门1->子部门15->子部门22->该部门39,则: sz_branch_path=,1,15,22,39, 根部门为 sz_branch_path=,1,',
102 nt_branch_level int default 99 null comment '部门的层级; 根部门的层级为1,根部门的子部门层级为2,根部门的子部门层级为3,以此类推。',
103 nt_source int default 0 null comment '来源: 0:系统中添加 1:从人力系统导入',
104 nt_child_count int default 0 null comment '保留字段:子部门个数,不含孙子部门',
105 sz_country_code varchar(15) null comment '国家代码',
106 sz_state_code varchar(15) null comment '州/省代码',
107 sz_city_name varchar(255) null comment '城市名称',
108 nt_irregular int default 0 null comment '0:排班规律 1:排班不规律,需要灵活排班',
109 ng_creator bigint null comment '创建人ID',
110 ts_create datetime null comment '创建时间',
111 constraint UQ_sys_branch_sz_code
112 unique (sz_code),
113 constraint UQ_sys_branch_sz_set_id
114 unique (sz_set_id)
115 )
116 comment '部门表';
117
118 create index index_sz_branch_path
119 on sys_branch (sz_branch_path);
120
121 grant select on table sys_branch to jabilit;
122
123 create table sys_user
124 (
125 ng_id bigint auto_increment comment '主键,自增加,用于表间的数据关联和唯一索引一条数据,无业务意义'
126 primary key,
127 sz_user_name varchar(255) not null comment '用户名,用户登录系统。必须有一个用户的user_name是【admin】,请手动添加。',
128 sz_employ_id varchar(100) not null comment '员工ID EMPLID',
129 sz_name varchar(255) not null comment '员工真实姓名 NAME',
130 sz_card_id varchar(100) null comment '卡号',
131 nt_card_change_count int default 0 null comment '换卡次数',
132 sz_email varchar(255) null comment '邮箱',
133 sz_nick_name varchar(255) null comment '昵称,用户在考勤机上显示',
134 sz_password varchar(255) not null comment '加密后的密码',
135 nt_gender int default -1 null comment '-1未知 0:女 1男',
136 sz_telephone varchar(255) null comment '电话',
137 sz_mobile varchar(255) null comment '手机',
138 nt_user_state int default 1 not null comment '1:正常,0:离职,-1:删除',
139 nt_overtime_count decimal(10, 4) default 0.0000 null comment '剩余的加班工时',
140 bt_blacklist int default 0 null comment '是否黑名单人员 0:否 1:是',
141 ng_last_card_id bigint null comment '最后卡点id,用于标示有新卡点来了从哪一个卡点开始计算 ',
142 bt_is_check int default 1 null comment '保留:是否参与考勤 0:否 1:是',
143 nt_begin_check int null comment '保留: 上班签到规则 0:根据相应时段判断 1:必须签到 ',
144 nt_end_check int null comment '保留: 下班签到规则 0:根据相应时段判断 1:必须签到 ',
145 bt_have_holiday int default 1 null comment '保留:是否有节日: 0:否 1:是',
146 sz_pwd_question varchar(255) null comment '找回密码问题',
147 sz_pwd_answer varchar(255) null comment '找回密码答案',
148 dt_entry date not null comment '入职日期',
149 dt_start_work date not null comment '开始上班时间',
150 bt_outbound int default 0 null comment '是否外派人员',
151 nt_source int default 0 null comment '来源,0:系统中添加,1:从人力系统导入',
152 nt_feature_count int default 0 null comment '用户登记的模版数量',
153 sz_education varchar(255) null comment '学历',
154 sz_nation varchar(255) null comment '民族',
155 nm_work_factor decimal(10, 2) default 0.00 null comment '工作年限调整',
156 nt_sync_state int default 0 null comment '用于在考勤机删除(离职/黑名单)人员模板后该字段标识模板已经清除,下次同步时对该人员不做处理',
157 bt_sync int default 1 null comment '是否与HR数据同步人员',
158 sz_photo_path varchar(150) null comment '人员照片数据存储路径',
159 dt_leave_date date null comment '离职日期',
160 tx_leave_reason text null comment '离职原因',
161 sz_card_num varchar(100) null comment '刷卡卡号',
162 ng_creator bigint null comment '创建者ID',
163 ts_create datetime null comment '创建时间',
164 constraint UQ_sys_user_sz_employ_id
165 unique (sz_employ_id),
166 constraint UQ_sys_user_sz_user_name
167 unique (sz_user_name)
168 )
169 comment '系统用户表';
170
171 create table stat_card
172 (
173 ng_id bigint auto_increment comment '主键,自增加,用于表间的数据关联和唯一索引一条数据,无业务意义'
174 primary key,
175 st_kind int default 0 null comment '0:从考勤机取得,1:手动添加',
176 ng_user_id bigint not null comment '用户ID',
177 ng_dev_id bigint not null comment '设备ID',
178 ts_card datetime not null comment '打卡时间',
179 st_card_type bigint default 0 null comment '保留字段: 打卡类型 0:一般卡; 1:上班; 2:下班; 3:加班上班; 4:加班下班; 5:外出; 6:回来',
180 st_dev_class int default 0 null comment '设备类型 0:考勤机 1:门禁机',
181 sz_verify varchar(127) null comment '验证字段,是EmployeeID,CardTime的校验和,防止手动添加【废弃字段】',
182 bt_validate int default 1 null comment '卡点是否有效 0:无效;1:有效',
183 ng_forget_id bigint null comment '漏打卡申请单',
184 ng_modify_id bigint default 0 null comment '0:未修改; >0:修改该卡点的管理员ID',
185 st_modify_type int default 0 null comment '0:未赋值; 1:删除;2:修改时间; 3:修改类型;4:添加',
186 ts_modify datetime default '0000-00-00 00:00:00' null comment '修改时间',
187 bt_native int default 1 null comment '打卡地点标识:0=异地,1=本地',
188 sz_photo_path varchar(200) null comment '卡点照片存储路径',
189 ng_creator bigint null comment '条目创建者ID',
190 ts_create datetime not null comment '条目创建时间',
191 constraint FK_stat_card_wf_forget_request
192 foreign key (ng_forget_id) references wf_forget_request (ng_id),
193 constraint stat_card__user__fk
194 foreign key (ng_user_id) references sys_user (ng_id)
195 )
196 comment '考勤记录表';
197
198 create index index_ts_card
199 on stat_card (ts_card);
200
201 create index ng_forget_id
202 on stat_card (ng_forget_id);
203
204 create index ng_modify_id
205 on stat_card (ng_modify_id);
206
207 create index ng_user_id
208 on stat_card (ng_user_id);
209
210 create index stat_card_query_user_i
211 on stat_card (ng_user_id, ts_card);
212
213 grant select on table stat_card to jabilit;
214
215 grant select on table sys_user to jabilit;
216
217 create table sys_user_branch
218 (
219 ng_id bigint auto_increment comment '主键,自增加,用于表间的数据关联和唯一索引一条数据,无业务意义'
220 primary key,
221 ng_user_id bigint not null comment '用户ID',
222 ng_branch_id bigint not null comment '部门ID',
223 ng_post_id bigint not null comment '职务ID',
224 nt_empley_rcd int null comment 'EMPL_RCD 岗位序号-多岗位标识',
225 dt_start_date date null comment '任职时间',
226 bt_is_primary int default 0 not null comment '是否是首要职务 0:否,1:是',
227 sz_post_type varchar(127) null comment '职务类别',
228 nt_order int default 9 null comment '权重,即显示次序',
229 ng_creator bigint null comment '创建人ID',
230 ts_create datetime null comment '创建时间',
231 constraint FK_sys_user_branch_sys_branch
232 foreign key (ng_branch_id) references sys_branch (ng_id),
233 constraint FK_sys_user_branch_sys_post
234 foreign key (ng_post_id) references sys_post (ng_id),
235 constraint FK_sys_user_branch_sys_user
236 foreign key (ng_user_id) references sys_user (ng_id)
237 )
238 comment '用户、部门、职务对应表';
239
240 create index ng_branch_id
241 on sys_user_branch (ng_branch_id);
242
243 create index ng_post_id
244 on sys_user_branch (ng_post_id);
245
246 create index ng_user_id
247 on sys_user_branch (ng_user_id);
248
249 grant select on table sys_user_branch to jabilit;