-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathattendsys.sql
299 lines (258 loc) · 17.5 KB
/
attendsys.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
/*
Navicat Premium Data Transfer
Source Server : localhost
Source Server Type : MySQL
Source Server Version : 50642
Source Host : 127.0.0.1
Source Database : attendsys
Target Server Type : MySQL
Target Server Version : 50642
File Encoding : utf-8
Date: 07/08/2019 20:45:33 PM
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for `attend`
-- ----------------------------
DROP TABLE IF EXISTS `attend`;
CREATE TABLE `attend` (
`Id` int(10) NOT NULL AUTO_INCREMENT,
`EarlyTime` varchar(255) DEFAULT NULL,
`LateTime` varchar(255) DEFAULT NULL,
`EmpName` varchar(255) DEFAULT NULL,
`ClassId` varchar(255) DEFAULT NULL,
`attendStatus` varchar(255) DEFAULT NULL,
PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=1688 DEFAULT CHARSET=utf8mb4;
-- ----------------------------
-- Records of `attend`
-- ----------------------------
BEGIN;
INSERT INTO `attend` VALUES ('1682', '2019-07-08 09:00:00.000000', '2019-07-08 20:00:00.000000', '游开钰', '2', '正常'), ('1683', '2019-07-08 08:00:00.000000', '2019-07-08 20:00:00.000000', '林煊鸿', '2', '正常'), ('1684', '2019-07-08 08:00:00.000000', '2019-07-08 21:00:00.000000', '林善凯', '2', '正常'), ('1685', '2019-07-08 08:00:00.000000', '2019-07-08 21:00:00.000000', '肖腾跃', '2', '正常'), ('1686', '缺勤', '2019-07-08 17:52:33.000000', '新晋员工', '2', '旷工'), ('1687', '2019-07-08 09:30:00', '2019-07-08 18:00:17', '小小', '2', '迟到');
COMMIT;
-- ----------------------------
-- Table structure for `classes`
-- ----------------------------
DROP TABLE IF EXISTS `classes`;
CREATE TABLE `classes` (
`Id` int(10) NOT NULL AUTO_INCREMENT,
`ClassId` varchar(10) DEFAULT NULL,
`Cname` varchar(15) DEFAULT NULL,
`Mtime` time(6) DEFAULT NULL,
`Atime` time(6) DEFAULT NULL,
`Descri` varchar(255) DEFAULT NULL,
PRIMARY KEY (`Id`),
KEY `ClassId` (`ClassId`)
) ENGINE=InnoDB AUTO_INCREMENT=667 DEFAULT CHARSET=utf8mb4;
-- ----------------------------
-- Records of `classes`
-- ----------------------------
BEGIN;
INSERT INTO `classes` VALUES ('22', '1', '管理', '09:00:00.000000', '15:00:00.000000', null), ('214', '2', 'JUnitTest2', '09:00:00.000000', '16:00:00.000000', null), ('666', '3', '测试', '08:58:00.000000', '17:58:03.000000', null);
COMMIT;
-- ----------------------------
-- Table structure for `department`
-- ----------------------------
DROP TABLE IF EXISTS `department`;
CREATE TABLE `department` (
`Id` int(10) NOT NULL AUTO_INCREMENT,
`departmentId` varchar(10) DEFAULT NULL,
`Dname` varchar(15) DEFAULT NULL,
`Dprincipal` varchar(10) DEFAULT NULL,
`Dability` varchar(255) DEFAULT NULL,
`Sdepartment` varchar(10) DEFAULT NULL,
PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8mb4;
-- ----------------------------
-- Records of `department`
-- ----------------------------
BEGIN;
INSERT INTO `department` VALUES ('22', '1', '销售部门', '游开钰', '销售', '销售'), ('23', '2', '开发部门', '游开钰', '开发', '开发');
COMMIT;
-- ----------------------------
-- Table structure for `employ`
-- ----------------------------
DROP TABLE IF EXISTS `employ`;
CREATE TABLE `employ` (
`Id` int(10) NOT NULL AUTO_INCREMENT,
`employId` varchar(20) DEFAULT NULL,
`UserName` varchar(15) DEFAULT NULL,
`Nation` varchar(10) DEFAULT NULL,
`IDNumber` varchar(255) DEFAULT NULL,
`salary` decimal(10,0) DEFAULT NULL,
`Phone` varchar(255) DEFAULT NULL,
`EmeContact` varchar(20) DEFAULT NULL,
`Job` varchar(20) DEFAULT NULL,
`Describle` varchar(255) DEFAULT NULL,
`Age` int(11) DEFAULT NULL,
`Gender` varchar(10) DEFAULT NULL,
`ClassId` varchar(10) DEFAULT NULL,
PRIMARY KEY (`Id`),
KEY `ClassId` (`ClassId`)
) ENGINE=InnoDB AUTO_INCREMENT=83 DEFAULT CHARSET=utf8mb4;
-- ----------------------------
-- Records of `employ`
-- ----------------------------
BEGIN;
INSERT INTO `employ` VALUES ('36', '3', '林善凯', '汉', '3501', '10000', '183', '183', '销售', '无', '20', '男', '2'), ('37', '4', '肖腾跃', '汉', '3501', '10000', '10086', '10086', '销售', '无', '30', '男', '2'), ('50', '22', '小小', '11', '11', '11', '11', '11', '开发', '11', '33', '男', '2'), ('51', '5', '小程', '汉', '3501', '1000', '137', '137', '开发', '无', '20', '男', '2'), ('52', '7', '新晋员工', '汉', '137', '1000', '137', '137', '开发', '无', '20', '男', '2'), ('53', '8', 'Aimer', '汉', '350122', '10000', '137', '无', '管理', '无', '18', '女', '2'), ('54', '9', 'Alpha', '汉', '35011', '2000', '137', '137', '管理', '无', '22', '男', '2'), ('56', '11', '程序猿', '汉', '350122', '10000', '137', '137', '开发', '无', '18', '男', '2'), ('57', '1', '游开钰修改1', '汉', '350122', '1000', '137', '137', '测试', '无', '20', '男', '3'), ('58', '2', '林煊鸿', '汉', '350111', '10000', '137', '137', '销售', '无', '20', '男', '3'), ('59', '3', '林善凯1', '汉', '3501', '10000', '183', '183', '销售', '无', '20', '男', '3'), ('60', '4', '肖腾跃1', '汉', '3501', '10000', '10086', '10086', '销售', '无', '30', '男', '3'), ('63', '7', '新晋员工1', '汉', '137', '1000', '137', '137', '开发', '无', '20', '男', '2'), ('64', '8', 'Aimer1', '汉', '350122', '10000', '137', '无', '管理', '无', '18', '女', '2'), ('65', '9', 'Alpha1', '汉', '35011', '2000', '137', '137', '管理', '无', '22', '男', '2'), ('66', '10', 'Beta', '汉', '350122', '1000', '137', '137', '管理', '无', '19', '男', '2'), ('67', '11', '程序猿1', '汉', '350122', '10000', '137', '137', '开发', '无', '18', '男', '2'), ('70', '1', '游开钰', '汉', '350122', '1000', '137', '137', '销售', '为空', '22', '男', '3'), ('71', '1', '游开钰1', '汉', '350122', '1000', '137', '137', '销售', '为空', '22', '男', '3'), ('72', '2', '林煊鸿1', '汉', '350111', '10000', '137', '137', '销售', '无', '20', '男', '3'), ('73', '3', '林善凯2', '汉', '3501', '10000', '183', '183', '销售', '无', '20', '男', '3'), ('74', '4', '肖腾跃2', '汉', '3501', '10000', '10086', '10086', '销售', '无', '30', '男', '3'), ('77', '7', '新晋员工2', '汉', '137', '1000', '137', '137', '开发', '无', '20', '男', '2'), ('78', '8', 'Aimer2', '汉', '350122', '10000', '137', '无', '管理', '无', '18', '女', '2'), ('79', '9', 'Alpha2', '汉', '35011', '2000', '137', '137', '管理', '无', '22', '男', '2'), ('80', '10', 'Beta1', '汉', '350122', '1000', '137', '137', '管理', '无', '19', '男', '2');
COMMIT;
-- ----------------------------
-- Table structure for `myleave`
-- ----------------------------
DROP TABLE IF EXISTS `myleave`;
CREATE TABLE `myleave` (
`LeaveId` varchar(10) DEFAULT NULL,
`LeaveName` varchar(15) DEFAULT NULL,
`BeginDate` datetime(6) DEFAULT NULL,
`EndDate` datetime(6) DEFAULT NULL,
`LeaveReason` varchar(255) DEFAULT NULL,
`Id` int(10) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4;
-- ----------------------------
-- Records of `myleave`
-- ----------------------------
BEGIN;
INSERT INTO `myleave` VALUES ('1', '小小', '2019-07-11 08:00:00.000000', '2019-07-11 20:00:00.000000', '看病', '8');
COMMIT;
-- ----------------------------
-- Table structure for `paysalary`
-- ----------------------------
DROP TABLE IF EXISTS `paysalary`;
CREATE TABLE `paysalary` (
`PSId` varchar(10) DEFAULT NULL,
`PSName` varchar(15) DEFAULT NULL,
`Salary` decimal(6,0) DEFAULT NULL,
`BeginDate` datetime(6) DEFAULT NULL,
`EndDate` datetime(6) DEFAULT NULL,
`Id` int(10) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4;
-- ----------------------------
-- Records of `paysalary`
-- ----------------------------
BEGIN;
INSERT INTO `paysalary` VALUES ('1', 'Joker', '10', '2019-06-22 00:07:04.000000', '2019-06-22 00:07:07.000000', '1');
COMMIT;
-- ----------------------------
-- Table structure for `punch`
-- ----------------------------
DROP TABLE IF EXISTS `punch`;
CREATE TABLE `punch` (
`punchId` varchar(10) DEFAULT NULL,
`ClassId` varchar(10) DEFAULT NULL,
`UserName` varchar(15) DEFAULT NULL,
`punchDate` datetime(6) DEFAULT NULL,
`Remarks` varchar(255) DEFAULT NULL,
`Id` int(10) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=36 DEFAULT CHARSET=utf8mb4;
-- ----------------------------
-- Records of `punch`
-- ----------------------------
BEGIN;
INSERT INTO `punch` VALUES ('1', '2', '游开钰', '2019-07-08 09:00:00.000000', '无', '22'), ('2', '2', '游开钰', '2019-07-08 20:00:00.000000', '无', '23'), ('4', '2', '肖腾跃', '2019-07-08 21:00:00.000000', '无', '25'), ('5', '2', '林煊鸿', '2019-07-08 08:00:00.000000', '无', '26'), ('6', '2', '林煊鸿', '2019-07-08 20:00:00.000000', '无', '27'), ('7', '2', '林善凯', '2019-07-08 08:00:00.000000', '无', '28'), ('8', '2', '林善凯', '2019-07-08 21:00:00.000000', '无', '29'), ('9', '2', '小小', '2019-07-08 09:30:00.000000', '无', '32'), ('10', '2', '小小', '2019-07-08 18:00:17.000000', '无', '33'), ('11', '2', '新晋员工', '2019-07-08 17:52:33.000000', '无', '35');
COMMIT;
-- ----------------------------
-- Table structure for `repair`
-- ----------------------------
DROP TABLE IF EXISTS `repair`;
CREATE TABLE `repair` (
`repairId` varchar(10) DEFAULT NULL,
`ClassId` varchar(10) DEFAULT NULL,
`UserName` varchar(15) DEFAULT NULL,
`repairDate` datetime(6) DEFAULT NULL,
`Reason` varchar(255) DEFAULT NULL,
`Id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4;
-- ----------------------------
-- Records of `repair`
-- ----------------------------
BEGIN;
INSERT INTO `repair` VALUES ('3', '2', '肖腾跃', '2019-07-08 08:00:00.000000', '无', '8');
COMMIT;
-- ----------------------------
-- Table structure for `station`
-- ----------------------------
DROP TABLE IF EXISTS `station`;
CREATE TABLE `station` (
`Id` int(10) NOT NULL AUTO_INCREMENT,
`JobId` varchar(10) DEFAULT NULL,
`Pname` varchar(15) DEFAULT NULL,
`Adepartment` varchar(20) DEFAULT NULL,
`Isuperior` varchar(10) DEFAULT NULL,
`Jcategory` enum('管理类','我就是董事长','技术类') DEFAULT NULL,
PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=29 DEFAULT CHARSET=utf8mb4;
-- ----------------------------
-- Records of `station`
-- ----------------------------
BEGIN;
INSERT INTO `station` VALUES ('24', '', '销售前台', '销售', '三无软件董事', '我就是董事长'), ('25', '2', '技术顾问', '管理', '三无软件技术总监', '管理类'), ('28', '66', '运营', '销售', '三无软件CEO', '技术类');
COMMIT;
-- ----------------------------
-- Table structure for `tLogin`
-- ----------------------------
DROP TABLE IF EXISTS `tLogin`;
CREATE TABLE `tLogin` (
`Id` int(20) NOT NULL,
`UserName` varchar(255) DEFAULT NULL,
`PassWord` varchar(255) DEFAULT NULL,
`UserId` varchar(20) DEFAULT NULL,
`LoginCount` int(20) DEFAULT NULL,
PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- ----------------------------
-- Records of `tLogin`
-- ----------------------------
BEGIN;
INSERT INTO `tLogin` VALUES ('1', 'root', '49c032802743b23f39b1304eb9414951cf0ad21389290f22', '1', '1');
COMMIT;
-- ----------------------------
-- View structure for `realacard`
-- ----------------------------
DROP VIEW IF EXISTS `realacard`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `realacard` AS select `punch`.`punchId` AS `punchId`,`punch`.`UserName` AS `UserName`,`punch`.`punchDate` AS `punchDate`,cast(`punch`.`punchDate` as date) AS `DaypunchDate`,`punch`.`ClassId` AS `ClassId` from `punch` where (cast(`punch`.`punchDate` as time(6)) > '12:00:00') union select `repair`.`repairId` AS `repairId`,`repair`.`UserName` AS `UserName`,`repair`.`repairDate` AS `repairDate`,cast(`repair`.`repairDate` as date) AS `DayrepairDate`,`repair`.`ClassId` AS `ClassId` from `repair` where (cast(`repair`.`repairDate` as time(6)) > '12:00:00');
-- ----------------------------
-- View structure for `realmcard`
-- ----------------------------
DROP VIEW IF EXISTS `realmcard`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `realmcard` AS select `punch`.`punchId` AS `punchId`,`punch`.`UserName` AS `UserName`,`punch`.`punchDate` AS `punchDate`,cast(`punch`.`punchDate` as date) AS `DaypunchDate`,`punch`.`ClassId` AS `ClassId` from `punch` where (cast(`punch`.`punchDate` as time(6)) < '12:00:00') union select `repair`.`repairId` AS `repairId`,`repair`.`UserName` AS `UserName`,`repair`.`repairDate` AS `repairDate`,cast(`repair`.`repairDate` as date) AS `DayrepairDate`,`repair`.`ClassId` AS `ClassId` from `repair` where (cast(`repair`.`repairDate` as time(6)) < '12:00:00');
-- ----------------------------
-- View structure for `realall`
-- ----------------------------
DROP VIEW IF EXISTS `realall`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `realall` AS select `realmcard`.`UserName` AS `UserName`,if((`realmcard`.`DaypunchDate` = `realacard`.`DaypunchDate`),`realmcard`.`punchDate`,`realmcard`.`punchDate`) AS `EarlyTime`,if((`realacard`.`DaypunchDate` = `realmcard`.`DaypunchDate`),`realacard`.`punchDate`,'缺勤') AS `LatTime`,`realmcard`.`ClassId` AS `ClassId` from (`realmcard` left join `realacard` on((`realmcard`.`UserName` = `realacard`.`UserName`))) union select `realacard`.`UserName` AS `UserName`,if((`realmcard`.`DaypunchDate` = `realacard`.`DaypunchDate`),`realmcard`.`punchDate`,'缺勤') AS `EarlyTime`,if((`realacard`.`DaypunchDate` = `realmcard`.`DaypunchDate`),`realacard`.`punchDate`,`realacard`.`punchDate`) AS `LatTime`,`realacard`.`ClassId` AS `ClassId` from (`realacard` left join `realmcard` on((`realmcard`.`UserName` = `realacard`.`UserName`)));
-- ----------------------------
-- View structure for `realsalary`
-- ----------------------------
DROP VIEW IF EXISTS `realsalary`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `realsalary` AS select `attend`.`Id` AS `idx`,`attend`.`EarlyTime` AS `EarlyTime`,`attend`.`LateTime` AS `LateTime`,`attend`.`EmpName` AS `EmpName`,`attend`.`ClassId` AS `ClassId`,`attend`.`attendStatus` AS `attendStatus`,`myleave`.`LeaveId` AS `LeaveId`,`myleave`.`BeginDate` AS `BeginDate`,`myleave`.`EndDate` AS `EndDate`,`myleave`.`LeaveReason` AS `LeaveReason`,`myleave`.`Id` AS `Id`,timestampdiff(HOUR,`myleave`.`BeginDate`,`myleave`.`EndDate`) AS `LeaveTime` from (`attend` left join `myleave` on((`attend`.`EmpName` = `myleave`.`LeaveName`)));
-- ----------------------------
-- View structure for `absday`
-- ----------------------------
DROP VIEW IF EXISTS `absday`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `absday` AS select `realall`.`UserName` AS `UserName`,`realall`.`EarlyTime` AS `EarlyTime`,`realall`.`LatTime` AS `LatTime`,`realall`.`ClassId` AS `ClassId` from `realall` where (isnull(`realall`.`EarlyTime`) or isnull(`realall`.`LatTime`));
-- ----------------------------
-- View structure for `earlyafternoon`
-- ----------------------------
DROP VIEW IF EXISTS `earlyafternoon`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `earlyafternoon` AS select `realacard`.`punchId` AS `punchId`,`realacard`.`UserName` AS `UserName`,`realmcard`.`punchDate` AS `t1`,`realacard`.`punchDate` AS `t2`,`realacard`.`ClassId` AS `ClassId` from (`realacard` join `realmcard`) where ((cast(`realacard`.`punchDate` as time(6)) < (select `classes`.`Atime` from `classes` where (`realacard`.`ClassId` = `classes`.`ClassId`))) and (cast(`realmcard`.`punchDate` as date) = cast(`realacard`.`punchDate` as date)) and (`realmcard`.`UserName` = `realacard`.`UserName`));
-- ----------------------------
-- View structure for `intw`
-- ----------------------------
DROP VIEW IF EXISTS `intw`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `intw` AS select `realmcard`.`punchId` AS `punchId`,`realmcard`.`UserName` AS `UserName`,`realmcard`.`punchDate` AS `t1`,`realacard`.`punchDate` AS `t2`,`realmcard`.`ClassId` AS `ClassId` from (`realmcard` join `realacard`) where ((`realacard`.`UserName` = `realmcard`.`UserName`) and (cast(`realacard`.`punchDate` as date) = cast(`realmcard`.`punchDate` as date)));
-- ----------------------------
-- View structure for `latemorning`
-- ----------------------------
DROP VIEW IF EXISTS `latemorning`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `latemorning` AS select `realmcard`.`punchId` AS `punchId`,`realmcard`.`UserName` AS `UserName`,`realmcard`.`punchDate` AS `t1`,`realacard`.`punchDate` AS `t2`,`realmcard`.`ClassId` AS `ClassId` from (`realmcard` join `realacard`) where ((cast(`realmcard`.`punchDate` as time(6)) > (select `classes`.`Mtime` from `classes` where (`realmcard`.`ClassId` = `classes`.`ClassId`))) and (cast(`realmcard`.`punchDate` as date) = cast(`realacard`.`punchDate` as date)) and (`realmcard`.`UserName` = `realacard`.`UserName`));
-- ----------------------------
-- View structure for `pay`
-- ----------------------------
DROP VIEW IF EXISTS `pay`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `pay` AS select `realsalary`.`ClassId` AS `ClassId`,`realsalary`.`EmpName` AS `EmpName`,sum((case `realsalary`.`attendStatus` when '正常' then 100 when '旷工' then -(100) when '迟到' then -(20) else (`realsalary`.`LeaveTime` * -(20)) end)) AS `Salary`,min(`realall`.`EarlyTime`) AS `BeginTime`,max(`realall`.`LatTime`) AS `EndTime` from (`realsalary` join `realall`) where (`realall`.`UserName` = `realsalary`.`EmpName`) group by `realsalary`.`EmpName`;
SET FOREIGN_KEY_CHECKS = 1;