├── .gitignore ├── README.md ├── pom.xml ├── sql └── employee.sql ├── src ├── main │ ├── java │ │ └── com │ │ │ └── suny │ │ │ ├── controller │ │ │ ├── ApproveController.java │ │ │ ├── AttendController.java │ │ │ ├── CodeController.java │ │ │ ├── EmployeeController.java │ │ │ ├── FileSourceController.java │ │ │ ├── LoginController.java │ │ │ ├── ManagerController.java │ │ │ └── PasswordController.java │ │ │ ├── dao │ │ │ └── impl │ │ │ │ ├── ApproveDao.java │ │ │ │ ├── AttendDao.java │ │ │ │ ├── AttendTypeDao.java │ │ │ │ ├── EmployeeDao.java │ │ │ │ └── ManagerDao.java │ │ │ ├── entity │ │ │ ├── Application.java │ │ │ ├── Attend.java │ │ │ ├── AttendType.java │ │ │ ├── CheckBack.java │ │ │ ├── Employee.java │ │ │ └── Manager.java │ │ │ ├── exception │ │ │ └── PasswordNotMatchException.java │ │ │ ├── filter │ │ │ └── LoginCheckFilter.java │ │ │ ├── interceptor │ │ │ └── UserInterceptor.java │ │ │ ├── service │ │ │ ├── ApproveService.java │ │ │ ├── AttendService.java │ │ │ ├── EmpManagerService.java │ │ │ ├── EmployeeService.java │ │ │ └── impl │ │ │ │ ├── ApproveServiceImpl.java │ │ │ │ ├── AttendServiceImpl.java │ │ │ │ ├── EmpManagerServiceImpl.java │ │ │ │ └── EmployeeServiceImpl.java │ │ │ └── utils │ │ │ ├── AttendJobUtils.java │ │ │ ├── ExcelUtils.java │ │ │ ├── Page.java │ │ │ └── RandomIDUtils.java │ └── resources │ │ ├── applicationContext-SpringMvc.xml │ │ ├── applicationContext.xml │ │ └── log4j.properties └── rebel.xml └── web ├── WEB-INF ├── login.jsp ├── pages │ ├── adminView │ │ ├── admin.jsp │ │ ├── approveList.jsp │ │ ├── attendanceRecord.jsp │ │ ├── changePassword.jsp │ │ ├── employeeList.jsp │ │ ├── manageEmployee.jsp │ │ ├── update.jsp │ │ ├── upload.jsp │ │ ├── uploadExcel.jsp │ │ └── viewEmployee.jsp │ └── userView │ │ ├── changePassword.jsp │ │ ├── studentDetail.jsp │ │ └── user_index.jsp ├── success.jsp └── web.xml ├── common ├── common.jsp ├── footer.jsp └── welcome.jsp ├── css ├── bootstrap.min.css └── error.css ├── error.jsp ├── fonts ├── glyphicons-halflings-regular.ttf └── glyphicons-halflings-regular.woff ├── images ├── 3.jpg ├── attend.png ├── banner - Copy.jpg ├── banner.jpg ├── error │ ├── 404.png │ ├── 404_msg.png │ ├── 404_to_index.png │ ├── error_bg.jpg │ └── error_cloud.png ├── manage.png ├── user.png └── view.png ├── index.jsp └── script ├── bootstrap.min.js └── jquery-3.1.1.min.js /.gitignore: -------------------------------------------------------------------------------- 1 | # BlueJ files 2 | *.ctxt 3 | 4 | # Mobile Tools for Java (J2ME) 5 | .mtj.tmp/ 6 | 7 | # Package Files # 8 | # *.jar 9 | *.war 10 | *.ear 11 | *.class 12 | *.iml 13 | # NOt show in github 14 | /src/rebel.xml 15 | # virtual machine crash logs, see http://www.java.com/en/do 16 | ~ 17 | /d/workspace/employeeManager/.gitignore[+] [unix] (22:06 17/12/2016) 14,31 Bot 18 | .idea/ 19 | web/WEB-INF/classes/ 20 | 21 | /target/ 22 | /.idea/ 23 | /employeeManager.iml 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 简单的考勤管理系统,实现了考勤管理,管理员审批,成员信息管理功能 2 | 3 | ------ 4 | ## 项目环境 5 | - 系统:`Windows7 X64位系统` 6 | - IDE:`Intellij IDEA 14.0` 7 | ### 后端技术选型 8 | 9 | - J D K 版 本:`JDK 1.8` 10 | - 数 据 库:`Mysql 5.7` 11 | - WEB容器:`Tomcat 7.0` 12 | - 视图框架:`SpringMVC 4.3.6.RELEASE` 13 | - 核心框架:`Spring Framework 4.3.6.RELEASE` 14 | - 持久层框架:`Hibernate4.3.11.Final` 15 | - 数据库连接池:`C3P0` 16 | 17 | ### 工具类 18 | 19 | - `Apache fileupload 文件上传组件` 20 | - `Apache commons-collections 封装好的各种集合类和集合工具类` 21 | - `Apache commons-io Apache基金会创建并维护的Java函数库` 22 | - `Apache commons-logging 通用的日志接口` 23 | - `dom4j 优秀的JavaXML API 主要用于解析XML文档` 24 | - `poi组件 主要用于读取以及写入Microsoft Office格式档案 ` 25 | - `JSR 303 为实体验证定义了一个元数据模型和API` 26 | ### 前端技术选型 27 | - JS框架:`jQuery 1.8` 28 | - CSS框架:`Twitter Bootstrap` 29 | 30 | *** ** * ** *** 31 | 32 | ### 项目所需jar包列表 33 | 34 | - `antlr-2.7.7.jar` 35 | - `classmate-1.0.0.jar` 36 | - `com.springsource.net.sf.cglib-2.2.0.jar ` 37 | - `com.springsource.org.aopalliance-1.0.0.jar ` 38 | - `com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar ` 39 | - `commons-collections4-4.0.jar ` 40 | - `commons-fileupload-1.2.2.jar ` 41 | - `commons-io-2.0.1.jar ` 42 | - `commons-logging-1.1.3.jar ` 43 | - `dom4j-1.6.1.jar ` 44 | - `hibernate-commons-annotations-4.0.5.Final.jar ` 45 | - `hibernate-core-4.3.11.Final.jar ` 46 | - `hibernate-entitymanager-4.3.11.Final.jar ` 47 | - `hibernate-jpa-2.1-api-1.0.0.Final.jar ` 48 | - `hibernate-validator-5.1.3.Final.jar ` 49 | - `hibernate-validator-annotation-processor-5.1.3.Final.jar ` 50 | - `jandex-1.1.0.Final.jar javassist-3.18.1-GA.jar ` 51 | - `jboss-logging-3.1.3.GA.jar ` 52 | - `jboss-logging-annotations-1.2.0.Beta1.jar ` 53 | - `jboss-transaction-api_1.2_spec-1.0.0.Final.jar ` 54 | - `jstl-1.2.jar ` 55 | - `mysql-connector-java-5.1.7-bin.jar ` 56 | - `poi-3.15.jar ` 57 | - `poi-examples-3.15.jar ` 58 | - `poi-excelant-3.15.jar ` 59 | - `poi-ooxml-3.15.jar ` 60 | - `poi-ooxml-schemas-3.15.jar ` 61 | - `poi-scratchpad-3.15.jar ` 62 | - `spring-aop-4.0.0.RELEASE.jar 使用Spring 的AOP 特性时所需的类和源码级元数据支持` 63 | - `spring-aspects-4.0.0.RELEASE.jar 提供对AspectJ的支持,以便可以方便的将面向方面的功能集成进IDE中` 64 | - `spring-beans-4.0.0.RELEASE.jar 所有应用都要用到的,它包含访问配置文件、创建和管理bean` 65 | - `spring-context-4.0.0.RELEASE.jar Spring 核心提供了大量扩展 ` 66 | - `spring-core-4.0.0.RELEASE.jar Spring 框架基本的核心工具类,是其它组件的基本核心` 67 | - `spring-expression-4.0.0.RELEASE.jar Spring表达式语言` 68 | - `spring-jdbc-4.0.0.RELEASE.jar 对Spring 对JDBC 数据访问进行封装的所有类` 69 | - `spring-orm-4.0.0.RELEASE.jar Spring对DAO特性集进行了扩展` 70 | - `spring-tx-4.0.0.RELEASE.jar 事务相关的类` 71 | - `spring-web-4.0.0.RELEASE.jar Web 应用开发时,用到Spring 框架时所需的核心类` 72 | - `spring-webmvc-4.0.0.RELEASE.jar 包含Spring MVC 框架相关的所有类` 73 | - `validation-api-1.1.0.Final.jar ` 74 | - `xmlbeans-2.6.0.jar` 75 | 76 | 77 | ### 项目数据库 78 | 79 | 默认`JDBC`连接的数据库为本地`MYSQL`数据库,数据库名为`employeeManager`,自行建立该数据库或者是更改`JDBC`连接的数据库地址 80 | 81 | 总共分为5张数据库表,SQL初始化文件 [emoloyee.sql](sql/emoloyee.sql),执行后可以查看效果 82 | ---------- 83 | 84 | 85 | 86 | ## 注意事项 87 | 88 | - 【emp_type】值为1登录则进入普通账号页面,如果值大于2则登录会进入管理员页面,请注意登录框的勾选 89 | 90 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.suny.manager 8 | employeeManager 9 | 1.0-SNAPSHOT 10 | 11 | 12 | 13 | 14 | org.springframework 15 | spring-aop 16 | 4.3.6.RELEASE 17 | 18 | 19 | org.springframework 20 | spring-context 21 | 4.3.6.RELEASE 22 | 23 | 24 | org.springframework 25 | spring-core 26 | 4.3.6.RELEASE 27 | 28 | 29 | org.springframework 30 | spring-orm 31 | 4.2.7.RELEASE 32 | 33 | 34 | org.springframework 35 | spring-tx 36 | 4.3.6.RELEASE 37 | 38 | 39 | org.springframework 40 | spring-web 41 | 4.3.6.RELEASE 42 | 43 | 44 | org.springframework 45 | spring-webmvc 46 | 4.3.7.RELEASE 47 | 48 | 49 | org.springframework 50 | spring-context-support 51 | 4.2.7.RELEASE 52 | 53 | 54 | 55 | net.sourceforge.cglib 56 | com.springsource.net.sf.cglib 57 | 2.1.3 58 | 59 | 60 | org.aopalliance 61 | com.springsource.org.aopalliance 62 | 1.0.0 63 | 64 | 65 | org.aspectj 66 | com.springsource.org.aspectj.weaver 67 | 1.6.8.RELEASE 68 | 69 | 70 | 71 | 72 | org.hibernate 73 | hibernate-core 74 | 4.3.11.Final 75 | 76 | 77 | org.hibernate 78 | hibernate-commons-annotations 79 | 4.3.11 80 | 81 | 82 | 83 | org.hibernate 84 | hibernate-entitymanager 85 | 4.3.11.Final 86 | 87 | 88 | org.hibernate.javax.persistence 89 | hibernate-jpa-2.1-api 90 | 1.0.0.Final 91 | 92 | 93 | org.hibernate 94 | hibernate-validator 95 | 5.1.1.Final 96 | 97 | 98 | org.hibernate 99 | hibernate-validator-annotation-processor 100 | 5.1.3.Final 101 | 102 | 103 | javax.validation 104 | validation-api 105 | 1.1.0.Final 106 | 107 | 108 | 109 | org.jboss.logging 110 | jboss-logging 111 | 3.3.0.Final 112 | 113 | 114 | org.jboss.logging 115 | jboss-logging-annotations 116 | 1.2.0.Beta1 117 | 118 | 119 | org.jboss.spec.javax.transaction 120 | jboss-transaction-api_1.2_spec 121 | 1.0.0.Final 122 | 123 | 124 | 125 | org.slf4j 126 | slf4j-api 127 | 1.7.21 128 | 129 | 130 | org.slf4j 131 | slf4j-log4j12 132 | 1.7.16 133 | 134 | 135 | log4j 136 | log4j 137 | 1.2.17 138 | 139 | 140 | 141 | mysql 142 | mysql-connector-java 143 | 5.1.39 144 | 145 | 146 | 147 | 148 | org.quartz-scheduler 149 | quartz 150 | 2.2.1 151 | 152 | 153 | 154 | 155 | org.apache.poi 156 | poi 157 | 3.14 158 | 159 | 160 | org.apache.poi 161 | poi-examples 162 | 3.10-FINAL 163 | 164 | 165 | org.apache.poi 166 | poi-excelant 167 | 3.14 168 | 169 | 170 | org.apache.poi 171 | poi-ooxml 172 | 3.14 173 | 174 | 175 | org.apache.poi 176 | poi-ooxml-schemas 177 | 3.14 178 | 179 | 180 | org.apache.poi 181 | poi-scratchpad 182 | 3.14 183 | 184 | 185 | 186 | jstl 187 | jstl 188 | 1.2 189 | 190 | 191 | 192 | org.jboss 193 | jandex 194 | 2.0.1.Final 195 | 196 | 197 | 198 | org.apache.xmlbeans 199 | xmlbeans 200 | 2.6.0 201 | 202 | 203 | 204 | dom4j 205 | dom4j 206 | 1.6.1 207 | 208 | 209 | 210 | org.apache.commons 211 | commons-collections4 212 | 4.1 213 | 214 | 215 | 216 | commons-fileupload 217 | commons-fileupload 218 | 1.3.1 219 | 220 | 221 | 222 | commons-io 223 | commons-io 224 | 2.4 225 | 226 | 227 | commons-logging 228 | commons-logging 229 | 1.1.1 230 | 231 | 232 | 233 | com.fasterxml 234 | classmate 235 | 1.3.3 236 | 237 | 238 | org.antlr 239 | antlr 240 | 3.5.2 241 | 242 | 243 | 244 | javax.servlet 245 | javax.servlet-api 246 | 3.1.0 247 | 248 | 249 | 250 | junit 251 | junit 252 | 4.12 253 | 254 | 255 | 256 | 257 | com.fasterxml.jackson.core 258 | jackson-core 259 | 2.9.2 260 | 261 | 262 | com.fasterxml.jackson.core 263 | jackson-annotations 264 | 2.9.2 265 | 266 | 267 | com.fasterxml.jackson.core 268 | jackson-databind 269 | 2.9.2 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | maven-compiler-plugin 278 | 279 | 1.8 280 | 1.8 281 | UTF-8 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | -------------------------------------------------------------------------------- /sql/employee.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat Premium Data Transfer 3 | 4 | Source Server : Localhost Mysql 5 | Source Server Type : MySQL 6 | Source Server Version : 50720 7 | Source Host : localhost:3306 8 | Source Schema : employeemanager 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50720 12 | File Encoding : 65001 13 | 14 | Date: 26/04/2018 09:47:58 15 | */ 16 | 17 | SET NAMES utf8mb4; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for application 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `application`; 24 | CREATE TABLE `application` ( 25 | `app_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID', 26 | `app_reason` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '申请修改考勤理由', 27 | `app_result` tinyint(1) DEFAULT 0 COMMENT '审批结果 0为未通过 1为通过', 28 | `attend_id` int(11) NOT NULL COMMENT '对应的考勤记录ID', 29 | `type_id` int(11) NOT NULL COMMENT '希望修改的考勤类型', 30 | PRIMARY KEY (`app_id`) USING BTREE, 31 | INDEX `FK_9wx0gm9e04sxa4spsnnvshr2v`(`attend_id`) USING BTREE, 32 | INDEX `FK_ncy74ck30mee5rdkk2uhl76r4`(`type_id`) USING BTREE, 33 | CONSTRAINT `FK_9wx0gm9e04sxa4spsnnvshr2v` FOREIGN KEY (`attend_id`) REFERENCES `attend` (`attend_id`) ON DELETE RESTRICT ON UPDATE RESTRICT, 34 | CONSTRAINT `FK_ncy74ck30mee5rdkk2uhl76r4` FOREIGN KEY (`type_id`) REFERENCES `attend_type` (`type_id`) ON DELETE RESTRICT ON UPDATE RESTRICT 35 | ) ENGINE = InnoDB AUTO_INCREMENT = 13 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; 36 | 37 | -- ---------------------------- 38 | -- Records of application 39 | -- ---------------------------- 40 | INSERT INTO `application` VALUES (8, '我迟到了', 0, 378, 6); 41 | INSERT INTO `application` VALUES (9, '我迟到了', 0, 380, 6); 42 | INSERT INTO `application` VALUES (10, '我迟到了', 0, 381, 6); 43 | INSERT INTO `application` VALUES (11, '我迟到了', 0, 382, 6); 44 | INSERT INTO `application` VALUES (12, '我迟到了', 0, 383, 6); 45 | 46 | -- ---------------------------- 47 | -- Table structure for attend 48 | -- ---------------------------- 49 | DROP TABLE IF EXISTS `attend`; 50 | CREATE TABLE `attend` ( 51 | `attend_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID', 52 | `emp_id` int(11) DEFAULT NULL COMMENT '对应的考勤人', 53 | `duty_day` datetime(0) NOT NULL COMMENT '考勤的开始时间点', 54 | `is_come` tinyint(1) DEFAULT NULL COMMENT '是否考勤 0为没有 1为签到', 55 | `punch_time` datetime(0) DEFAULT NULL COMMENT '考勤的时间', 56 | `type_id` int(11) NOT NULL COMMENT '考勤的类型', 57 | PRIMARY KEY (`attend_id`) USING BTREE, 58 | INDEX `FK_sxsglsafwbl3kjyu20pulbv7`(`type_id`) USING BTREE, 59 | INDEX `FK_e5w782m7lqroclf83divt40iv`(`emp_id`) USING BTREE, 60 | CONSTRAINT `FK_e5w782m7lqroclf83divt40iv` FOREIGN KEY (`emp_id`) REFERENCES `employee` (`emp_id`) ON DELETE RESTRICT ON UPDATE RESTRICT, 61 | CONSTRAINT `FK_sxsglsafwbl3kjyu20pulbv7` FOREIGN KEY (`type_id`) REFERENCES `attend_type` (`type_id`) ON DELETE RESTRICT ON UPDATE RESTRICT 62 | ) ENGINE = InnoDB AUTO_INCREMENT = 388 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; 63 | 64 | -- ---------------------------- 65 | -- Records of attend 66 | -- ---------------------------- 67 | INSERT INTO `attend` VALUES (378, 101, '2018-04-26 09:35:51', 0, NULL, 6); 68 | INSERT INTO `attend` VALUES (379, 102, '2018-04-25 09:38:04', 1, '2018-04-26 09:38:11', 6); 69 | INSERT INTO `attend` VALUES (380, 101, '2018-04-26 09:35:51', 0, NULL, 7); 70 | INSERT INTO `attend` VALUES (381, 102, '2018-04-26 09:35:51', 0, NULL, 7); 71 | INSERT INTO `attend` VALUES (382, 103, '2018-04-26 09:35:51', 0, NULL, 7); 72 | INSERT INTO `attend` VALUES (383, 104, '2018-04-26 09:35:51', 0, NULL, 7); 73 | INSERT INTO `attend` VALUES (384, 102, '2018-04-25 09:38:04', 1, '2018-04-26 09:38:11', 6); 74 | INSERT INTO `attend` VALUES (385, 103, '2018-04-25 09:38:04', 1, '2018-04-26 09:38:11', 6); 75 | INSERT INTO `attend` VALUES (386, 104, '2018-04-25 09:38:04', 1, '2018-04-26 09:38:11', 6); 76 | INSERT INTO `attend` VALUES (387, 105, '2018-04-25 09:38:04', 1, '2018-04-26 09:38:11', 6); 77 | 78 | -- ---------------------------- 79 | -- Table structure for attend_type 80 | -- ---------------------------- 81 | DROP TABLE IF EXISTS `attend_type`; 82 | CREATE TABLE `attend_type` ( 83 | `type_id` int(11) NOT NULL AUTO_INCREMENT, 84 | `type_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, 85 | PRIMARY KEY (`type_id`) USING BTREE 86 | ) ENGINE = InnoDB AUTO_INCREMENT = 10 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; 87 | 88 | -- ---------------------------- 89 | -- Records of attend_type 90 | -- ---------------------------- 91 | INSERT INTO `attend_type` VALUES (6, '正常'); 92 | INSERT INTO `attend_type` VALUES (7, '缺勤'); 93 | INSERT INTO `attend_type` VALUES (8, '迟到'); 94 | INSERT INTO `attend_type` VALUES (9, '请假'); 95 | 96 | -- ---------------------------- 97 | -- Table structure for check_back 98 | -- ---------------------------- 99 | DROP TABLE IF EXISTS `check_back`; 100 | CREATE TABLE `check_back` ( 101 | `check_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID', 102 | `check_reason` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '审批理由', 103 | `check_result` tinyint(1) NOT NULL COMMENT '审批结果 0为不通过 1为通过', 104 | `app_id` int(11) DEFAULT NULL COMMENT '审批记录ID', 105 | `mgr_id` int(11) NOT NULL COMMENT '审批的管理员ID', 106 | PRIMARY KEY (`check_id`) USING BTREE, 107 | INDEX `FK_939cwdph0r4ia2okhjqn7f92y`(`app_id`) USING BTREE, 108 | INDEX `FK_cfkusgfp28so2n7lyvat4byju`(`mgr_id`) USING BTREE, 109 | CONSTRAINT `FK_939cwdph0r4ia2okhjqn7f92y` FOREIGN KEY (`app_id`) REFERENCES `application` (`app_id`) ON DELETE RESTRICT ON UPDATE RESTRICT, 110 | CONSTRAINT `FK_cfkusgfp28so2n7lyvat4byju` FOREIGN KEY (`mgr_id`) REFERENCES `employee` (`emp_id`) ON DELETE RESTRICT ON UPDATE RESTRICT 111 | ) ENGINE = InnoDB AUTO_INCREMENT = 47 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; 112 | 113 | -- ---------------------------- 114 | -- Records of check_back 115 | -- ---------------------------- 116 | INSERT INTO `check_back` VALUES (42, '不同意', 0, 8, 101); 117 | INSERT INTO `check_back` VALUES (44, '不同意', 0, 9, 101); 118 | INSERT INTO `check_back` VALUES (45, '不同意', 0, 10, 101); 119 | INSERT INTO `check_back` VALUES (46, '不同意', 0, 11, 101); 120 | 121 | -- ---------------------------- 122 | -- Table structure for employee 123 | -- ---------------------------- 124 | DROP TABLE IF EXISTS `employee`; 125 | CREATE TABLE `employee` ( 126 | `emp_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID', 127 | `emp_account` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '账号名', 128 | `emp_password` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '123456' COMMENT '密码 ', 129 | `emp_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '中文名字', 130 | `emp_className` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '班级名字', 131 | `emp_tel` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '电话号码', 132 | `emp_bedroom` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '寝室号', 133 | `dept_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '部门名字', 134 | `mgr_id` int(11) DEFAULT NULL COMMENT '管理员ID,引用的是本张表中的emp_Id', 135 | `emp_type` int(11) NOT NULL DEFAULT 1 COMMENT '身份类型', 136 | PRIMARY KEY (`emp_id`) USING BTREE, 137 | UNIQUE INDEX `UK_5tltp1u3mevdum1ilp1ft71rg`(`emp_account`) USING BTREE, 138 | INDEX `FK_5f44y8jo1j00uhenw2naboii8`(`mgr_id`) USING BTREE, 139 | CONSTRAINT `FK_5f44y8jo1j00uhenw2naboii8` FOREIGN KEY (`mgr_id`) REFERENCES `employee` (`emp_id`) ON DELETE RESTRICT ON UPDATE RESTRICT 140 | ) ENGINE = InnoDB AUTO_INCREMENT = 106 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; 141 | 142 | -- ---------------------------- 143 | -- Records of employee 144 | -- ---------------------------- 145 | INSERT INTO `employee` VALUES (101, '10000', '123456', 'name', '测试班级', '10086', '1#101', 'deptName', NULL, 1); 146 | INSERT INTO `employee` VALUES (102, 'admin', 'admin', 'name', '测试班级', '10086', '1#101', 'deptName', NULL, 2); 147 | INSERT INTO `employee` VALUES (103, 'super', 'super', 'superName', '测试班级', '10086', '1#101', 'deptName', NULL, 1); 148 | INSERT INTO `employee` VALUES (104, 'student', 'student', 'studentName', '测试班级', '10086', '1#101', 'deptName', NULL, 1); 149 | INSERT INTO `employee` VALUES (105, 'teacher', 'teacher', 'teacherName', '测试班级', '10086', '1#101', 'deptName', NULL, 1); 150 | 151 | SET FOREIGN_KEY_CHECKS = 1; 152 | -------------------------------------------------------------------------------- /src/main/java/com/suny/controller/ApproveController.java: -------------------------------------------------------------------------------- 1 | package com.suny.controller; 2 | 3 | import com.suny.service.ApproveService; 4 | import com.suny.utils.Page; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Controller; 7 | import org.springframework.ui.ModelMap; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | 10 | import javax.servlet.http.HttpServletRequest; 11 | import java.io.UnsupportedEncodingException; 12 | 13 | /** 14 | * 对成员的考勤记录存在有异议的申请进行处理 15 | * 孙建荣 16 | * 2016/12/13 17:27 17 | */ 18 | @Controller 19 | @RequestMapping("/approve") 20 | public class ApproveController { 21 | 22 | 23 | @Autowired 24 | private ApproveService approveServiceImpl; 25 | 26 | private Page page; 27 | 28 | public Page getPage() { 29 | return page; 30 | } 31 | 32 | public void setPage(Page page) { 33 | this.page = page; 34 | } 35 | 36 | 37 | /** 38 | * 对申请进行处理 39 | * @param request 包含同意或者拒绝的参数 40 | * @return 返回到原页面 41 | * @throws Exception 42 | */ 43 | @RequestMapping("/checkApprove") 44 | public String checkApprove(HttpServletRequest request) throws Exception { 45 | String mgrName = (String) request.getSession().getAttribute("username"); //获取session中保存的管理员的名字 46 | String result = request.getParameter("result"); //审批的结果 47 | Integer appid = Integer.valueOf(request.getParameter("appid")); //获取要修改的考勤申请id 48 | //通过申请时的处理 49 | if (result.equals("pass")) { 50 | approveServiceImpl.handleApply(appid, mgrName, true); 51 | } else if (result.equals("deny")) { 52 | approveServiceImpl.handleApply(appid, mgrName, false); 53 | } else { 54 | throw new Exception("参数丢失"); 55 | } 56 | return "redirect:/approve/approveList"; //重定向到待申请修改考勤记录列表 57 | 58 | } 59 | 60 | /** 61 | * 考勤审批页面 62 | * 63 | * @return 64 | */ 65 | @RequestMapping("/approveList") 66 | public String approveList(ModelMap modelMap, HttpServletRequest request) throws UnsupportedEncodingException { 67 | int pageCount = 5; //分页每页显示的行数 68 | String currentPage = request.getParameter("currentPage"); //获取当前页页码 69 | if (currentPage == null || currentPage.equals("0")) { //如果当前页为空或者为0的话默认为第1页 70 | currentPage = "1"; 71 | } 72 | if (Integer.valueOf(currentPage) > approveServiceImpl.getMaxPage(pageCount)) { //如果当前页大于总页数则跳转到最大分页数 73 | page = approveServiceImpl.getTodoApplyList(approveServiceImpl.getMaxPage(pageCount), pageCount); 74 | } else { 75 | page = approveServiceImpl.getTodoApplyList(Integer.valueOf(currentPage), pageCount); //把当前页跟每页行数传到service里面进行分页查询 76 | } 77 | modelMap.addAttribute("approveList", page.getPageDate()); //添加分页对象到modelMap里面 78 | return "/pages/adminView/approveList"; 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/com/suny/controller/AttendController.java: -------------------------------------------------------------------------------- 1 | package com.suny.controller; 2 | 3 | import com.suny.service.AttendService; 4 | import com.suny.utils.Page; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Controller; 7 | import org.springframework.ui.ModelMap; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | 10 | import javax.servlet.http.HttpServletRequest; 11 | import java.io.UnsupportedEncodingException; 12 | import java.util.List; 13 | 14 | /** 15 | * 显示考勤记录 16 | * 孙建荣 17 | * 2016/12/12 22:23 18 | */ 19 | @Controller 20 | @RequestMapping("/attend") 21 | public class AttendController { 22 | 23 | @Autowired 24 | private AttendService attendServiceImpl; 25 | 26 | private Page page; 27 | 28 | 29 | /** 30 | * 使用关键字进行查询考勤记录 31 | * 32 | * @param request request对象,用户请求相关 33 | * @param modelMap 用于保存属性 34 | * @return 返回通过关键词查询出来的数据并展现在考勤记录列表里面 35 | * @throws UnsupportedEncodingException 处理不支持设置指定编码的异常 36 | */ 37 | @RequestMapping("/getByName") 38 | public String getByName(HttpServletRequest request, ModelMap modelMap) throws UnsupportedEncodingException { 39 | int pageCount = 5; //设置每一页行数 40 | String currentPage = request.getParameter("currentPage"); //获取当前页 41 | if (currentPage == null || currentPage.equals("0")) { //默认为第一页 42 | currentPage = "1"; 43 | } 44 | request.setCharacterEncoding("UTF-8"); //设置编码 45 | String username = request.getParameter("name"); //获取请求参数 46 | Page page = attendServiceImpl.getByName(username, pageCount, Integer.valueOf(currentPage)); //返回分页后的page对象 47 | List attendRecordList = page.getPageDate(); //获取分页数据 48 | modelMap.addAttribute("attendRecordList", attendRecordList); //添加查询的数据到modelMap中 49 | modelMap.addAttribute("value", username); //添加name到modelMap中 50 | modelMap.addAttribute("page", page); //添加page对象到modelMpa 51 | return "/pages/adminView/attendanceRecord"; 52 | } 53 | 54 | /** 55 | * 进入考勤记录列表 56 | * 57 | * @param modelMap 向页面传送考勤记录值 58 | * @return 考勤记录页面 59 | */ 60 | @RequestMapping("/attendRecord") 61 | public String attendRecord(HttpServletRequest request, ModelMap modelMap) throws UnsupportedEncodingException { 62 | int pageCount = 5; //分页每页显示的行数 63 | String currentPage = request.getParameter("currentPage"); //获取当前页页码 64 | if (currentPage == null || currentPage.equals("0")) { //如果当前页为空或者为0的话默认为第1页 65 | currentPage = "1"; 66 | } 67 | if (Integer.valueOf(currentPage) > attendServiceImpl.getMaxPage(pageCount)) { //如果当前页大于总页数则跳转到最大分页数 68 | page = attendServiceImpl.getAllRecord(attendServiceImpl.getMaxPage(pageCount), pageCount); 69 | } else { 70 | page = attendServiceImpl.getAllRecord(Integer.valueOf(currentPage), pageCount); //把当前页跟每页行数传到service里面进行分页查询 71 | } 72 | modelMap.addAttribute("page", page); //添加分页对象到modelMap里面 73 | List attendRecordList = page.getPageDate(); //获取page对象里面的考勤记录数据 74 | modelMap.addAttribute("attendRecordList", attendRecordList); //把考勤记录数据吧保存到session中 75 | return "/pages/adminView/attendanceRecord"; //考勤记录列表 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/com/suny/controller/CodeController.java: -------------------------------------------------------------------------------- 1 | package com.suny.controller; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | 6 | import javax.imageio.ImageIO; 7 | import javax.servlet.ServletOutputStream; 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | import javax.servlet.http.HttpSession; 11 | import java.awt.*; 12 | import java.awt.image.BufferedImage; 13 | import java.io.IOException; 14 | import java.util.Random; 15 | 16 | /** 17 | * 对前端页面产生验证码,防止恶意点击连接 18 | * 孙建荣 19 | * 2016/12/16 21:43 20 | */ 21 | @RequestMapping("/code") 22 | @Controller 23 | public class CodeController { 24 | char[] codeSequence = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 25 | 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 26 | 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }; 27 | 28 | /** 29 | * 处理生成验证码相关的请求 30 | * @param req 包含用户请求的数据 31 | * @param resp 服务器向页面的响应请求 32 | * @throws IOException 处理IO流异常 33 | */ 34 | @RequestMapping("/verifyCode") 35 | public void getCode(HttpServletRequest req, HttpServletResponse resp) 36 | throws IOException { 37 | 38 | // 定义图像buffer 39 | int width = 90; //验证码的宽度 40 | int height = 20; //验证码的高度 41 | BufferedImage buffImg = new BufferedImage(width, height, 42 | BufferedImage.TYPE_INT_RGB); 43 | Graphics gd = buffImg.getGraphics(); 44 | // 创建一个随机数生成器类 45 | Random random = new Random(); 46 | // 将图像填充为白色 47 | gd.setColor(Color.WHITE); 48 | gd.fillRect(0, 0, width, height); 49 | 50 | // 创建字体,字体的大小应该根据图片的高度来定。 51 | int fontHeight = 18; 52 | Font font = new Font("Fixedsys", Font.BOLD, fontHeight); 53 | // 设置字体。 54 | gd.setFont(font); 55 | 56 | // 画边框。 57 | gd.setColor(Color.BLACK); 58 | gd.drawRect(0, 0, width - 1, height - 1); 59 | 60 | // 随机产生40条干扰线,使图象中的认证码不易被其它程序探测到。 61 | gd.setColor(Color.BLACK); 62 | for (int i = 0; i < 40; i++) { 63 | int x = random.nextInt(width); 64 | int y = random.nextInt(height); 65 | int xl = random.nextInt(12); 66 | int yl = random.nextInt(12); 67 | gd.drawLine(x, y, x + xl, y + yl); 68 | } 69 | 70 | // randomCode用于保存随机产生的验证码,以便用户登录后进行验证。 71 | StringBuffer randomCode = new StringBuffer(); 72 | int red, green, blue; 73 | 74 | // 随机产生codeCount数字的验证码。 75 | int codeCount = 4; 76 | for (int i = 0; i < codeCount; i++) { 77 | // 得到随机产生的验证码数字。 78 | String code = String.valueOf(codeSequence[random.nextInt(36)]); 79 | // 产生随机的颜色分量来构造颜色值,这样输出的每位数字的颜色值都将不同。 80 | red = random.nextInt(255); 81 | green = random.nextInt(255); 82 | blue = random.nextInt(255); 83 | 84 | // 用随机产生的颜色将验证码绘制到图像中。 85 | gd.setColor(new Color(red, green, blue)); 86 | int xx = 15; 87 | int codeY = 16; 88 | gd.drawString(code, (i + 1) * xx, codeY); 89 | 90 | // 将产生的四个随机数组合在一起。 91 | randomCode.append(code); 92 | } 93 | // 将四位数字的验证码保存到Session中。 94 | HttpSession session = req.getSession(); 95 | System.out.print(randomCode); 96 | session.setAttribute("code", randomCode.toString()); 97 | 98 | // 禁止图像缓存。 99 | resp.setHeader("Pragma", "no-cache"); 100 | resp.setHeader("Cache-Control", "no-cache"); 101 | resp.setDateHeader("Expires", 0); 102 | 103 | resp.setContentType("image/jpeg"); 104 | 105 | // 将图像输出到Servlet输出流中。 106 | ServletOutputStream sos = resp.getOutputStream(); 107 | ImageIO.write(buffImg, "jpeg", sos); 108 | sos.close(); 109 | } 110 | 111 | 112 | } 113 | -------------------------------------------------------------------------------- /src/main/java/com/suny/controller/EmployeeController.java: -------------------------------------------------------------------------------- 1 | package com.suny.controller; 2 | 3 | import com.suny.entity.Employee; 4 | import com.suny.service.EmployeeService; 5 | import com.suny.utils.ExcelUtils; 6 | import com.suny.utils.Page; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.ui.ModelMap; 10 | import org.springframework.web.bind.annotation.*; 11 | 12 | import javax.servlet.http.HttpServletRequest; 13 | import javax.servlet.http.HttpServletResponse; 14 | import java.io.IOException; 15 | import java.io.PrintWriter; 16 | import java.io.UnsupportedEncodingException; 17 | import java.nio.file.Files; 18 | import java.nio.file.Path; 19 | import java.nio.file.Paths; 20 | import java.util.List; 21 | 22 | /** 23 | * 操作成员信息 24 | * 孙建荣 25 | * 2016/11/14 12:33 26 | */ 27 | @Controller 28 | @RequestMapping("/employee") 29 | public class EmployeeController { 30 | 31 | @Autowired 32 | private EmployeeService employeeServiceImpl; 33 | 34 | 35 | /** 36 | * 成员签到 37 | * 38 | * @param request 用户的request请求 39 | * @param response 服务器对用户的response响应 40 | * @throws IOException 向客户端响应的时候可能发生的异常 41 | */ 42 | @RequestMapping("/punch") 43 | public void punch(HttpServletRequest request, HttpServletResponse response) throws IOException { 44 | PrintWriter printWriter = response.getWriter(); 45 | String username = (String) request.getSession().getAttribute("username"); //获取要签到的用户名 46 | int status = employeeServiceImpl.punch(username); // 得到一个状态码,进行判断各种结果 47 | switch (status) { 48 | case 0: 49 | printWriter.write("null"); 50 | break; // 发生了错误,不能进行签到 51 | case 1: 52 | printWriter.write("notPunch"); 53 | break; // 可以签到,但是还没有签到 54 | case 2: 55 | printWriter.write("repeatPunch"); 56 | break; // 已经签到了,重复签到 57 | case 3: 58 | printWriter.write("successPunch"); 59 | break; // 签到成功 60 | } 61 | printWriter.close(); //关闭输出流 62 | } 63 | 64 | /** 65 | * 成员在个人中心查看个人信息请求 66 | * 67 | * @param modelMap 包含属性的map 68 | * @return 返回查看个人信息页面 69 | */ 70 | @RequestMapping("detail/{id}") 71 | public String detail(@PathVariable("id") Integer id, ModelMap modelMap) { 72 | Employee employee = employeeServiceImpl.getById(id); //通过当前用户的id进行查询当前用户的信息 73 | modelMap.addAttribute("employee", employee); //保存成员要查看的个人信息 74 | return "/pages/userView/viewEmployee"; 75 | } 76 | 77 | 78 | /** 79 | * 提交修改成员信息操作 80 | * 81 | * @param id 用户对应的主键标示id 82 | * @param employee 一个包含属性的employee对象集合 83 | * @return 操作经过处理后重定向到成员信息管理页面 84 | */ 85 | @RequestMapping(value = "/update/{id}", method = RequestMethod.POST) 86 | public String update(@PathVariable("id") Integer id, Employee employee) { 87 | employeeServiceImpl.update(employee, id); //把要修改的成员信息页面提交给service 88 | return "redirect:/manageEmployeeAction/manageEmployee"; //重定向到成员管理页面 89 | } 90 | 91 | /** 92 | * 进入修改成员页面 93 | * 94 | * @param id 要修改的用户主键标识id 95 | * @param modelMap 包含属性的模型 96 | * @return 进入对应成员的修改资料页面 97 | */ 98 | @RequestMapping(value = "updatePage/{id}") 99 | public String updatePage(@PathVariable("id") Integer id, ModelMap modelMap) { 100 | Employee employee = employeeServiceImpl.getById(id); //获取要修改的成员信息 101 | modelMap.addAttribute("employee", employee); //把获取到的成员信息放到modelMap里面 102 | return "pages/adminView/update"; //进入修改成员信息页面 103 | } 104 | 105 | /** 106 | * 删除成员操作 107 | * 108 | * @param id 要删除的成员主键标识id 109 | * @return 操作成功后重定向到成员管理页面 110 | */ 111 | @RequestMapping(value = "/delete/{id}", method = RequestMethod.GET) 112 | public String delete(@PathVariable("id") Integer id) { 113 | employeeServiceImpl.del(id); //传入要删除的成员的id 114 | return "redirect:/employee/manageEmployeeList"; 115 | } 116 | 117 | /** 118 | * 增加成员数据操作 119 | * 120 | * @param employee 包含成员信息的集合 121 | * @return 重定向到成员管理页面 122 | */ 123 | @RequestMapping("/add") 124 | public String add(Employee employee) { 125 | employeeServiceImpl.add(employee); //把employee对象传到数据操作层进行保存 126 | return "redirect:/employee/manageEmployeeList"; 127 | } 128 | 129 | 130 | 131 | 132 | /** 133 | * 管理员查看某个成员详情页面 134 | * 135 | * @param id 要查看的成员的主键标识id 136 | * @return 查看成员属性的页面 137 | */ 138 | @RequestMapping(value = "/{id}", method = RequestMethod.GET) 139 | @ResponseBody 140 | public Employee personDetail(@PathVariable("id") int id) { 141 | return employeeServiceImpl.getById(id); 142 | } 143 | 144 | /** 145 | * 使用关键字进行查询 146 | * 147 | * @param request request请求,包含用户请求信息 148 | * @param modelMap 包含属性的模型 149 | * @return 通过关键字进行查询成员信息后的页面 150 | * @throws UnsupportedEncodingException 抛出不知道编码的异常 151 | */ 152 | @RequestMapping("/getByName") 153 | public String getByName(@RequestParam(value = "currentPage", defaultValue = "1") String stringCurPage, 154 | @RequestParam(value = "pageCount", defaultValue = "5", required = false) String stringPageCount, 155 | @RequestParam(value = "name") String username, 156 | HttpServletRequest request, ModelMap modelMap) throws UnsupportedEncodingException { 157 | Integer curPage = Integer.valueOf(stringCurPage); 158 | Integer pageCount = Integer.valueOf(stringPageCount); 159 | if (curPage == 0) { //默认为第一页 160 | curPage = 1; 161 | } 162 | request.setCharacterEncoding("UTF-8"); //设置编码 163 | Page page = employeeServiceImpl.getByName(username, pageCount, curPage); //返回分页后的page对象 164 | modelMap.addAttribute("value", username); //添加name到modelMap中 165 | modelMap.addAttribute("page", page); //添加page对象到modelMpa 166 | return "pages/adminView/employeeList"; 167 | } 168 | 169 | /** 170 | * 访问成员信息管理页面 171 | * 172 | * @param request request请求,包含用户请求信息 173 | * @param modelMap 包含数据的模型 174 | * @return 带分页数据后的成员信息管理页面 175 | */ 176 | @RequestMapping("/manageEmployeeList") 177 | public String manageEmployee(HttpServletRequest request, ModelMap modelMap) { 178 | Page page = new Page(); 179 | int pageCount = 5; //设置每页显示的行数 180 | String currentPage = request.getParameter("stringCurPage"); //获取当前页 181 | if (currentPage == null || currentPage.equals("0")) { //设置默认页为1 182 | currentPage = "1"; 183 | } 184 | if (Integer.valueOf(currentPage) > employeeServiceImpl.getMaxPage(pageCount)) { //当前页超过最大页时设置当前页为最大页 185 | page = employeeServiceImpl.getAll(employeeServiceImpl.getMaxPage(pageCount), pageCount); 186 | } else { 187 | page = employeeServiceImpl.getAll(Integer.valueOf(currentPage), pageCount); //获取分页数据 188 | } 189 | modelMap.addAttribute("page", page); //添加page对象到modelMap中 190 | List employeeList = page.getPageDate(); //获取page对象中的分页数据 191 | modelMap.addAttribute("employeeList", employeeList); //把分页数据集合保存到session中 192 | return "pages/adminView/manageEmployee"; 193 | } 194 | 195 | /** 196 | * 查看成员信息页面 197 | * 198 | * @param modelMap 向页面传送参数的集合 199 | * @return 进入管理成员信息页面 200 | */ 201 | @RequestMapping("/employeeDetail") 202 | public String employee_view(@RequestParam(value = "currentPage", defaultValue = "1") String stringCurPage, 203 | @RequestParam(value = "pageCount", defaultValue = "5", required = false) String stringPageCount, 204 | ModelMap modelMap) { 205 | 206 | Page page; 207 | if (stringCurPage.equals("0")) { //如果当前页为空或者为0的话默认为第1页 208 | stringCurPage = "1"; 209 | } 210 | Integer curPage = Integer.valueOf(stringCurPage); 211 | Integer pageCount = Integer.valueOf(stringPageCount); 212 | if (curPage > employeeServiceImpl.getMaxPage(pageCount)) { //如果当前页大于总页数则跳转到最大分页数 213 | page = employeeServiceImpl.getAll(employeeServiceImpl.getMaxPage(pageCount), pageCount); 214 | } else { 215 | page = employeeServiceImpl.getAll(curPage, pageCount); //把当前页跟每页行数传到service里面进行分页查询 216 | } 217 | modelMap.addAttribute("page", page); //添加分页对象到modelMap里面 218 | 219 | return "pages/adminView/employeeList"; //进行成员信息列表页面 220 | } 221 | 222 | /** 223 | * 下载数据库中的成员信息,然后保存到excel表格中 224 | * 225 | * @param request 用户请求相关 226 | * @param response 服务器对用户请求的响应 227 | * @throws IOException 抛出IO流异常 228 | */ 229 | @RequestMapping("/downloadExcel") 230 | public void downloadExcel(HttpServletRequest request, HttpServletResponse response) throws IOException { 231 | /** 232 | * 如果文件名有中文的话,进行URL编码,让中文正常显示 233 | response.addHeader("Content-Disposition","attachment; filename=" + URLEncoder.encode(fileName, "UTF-8")); 234 | */ 235 | String fileName = System.currentTimeMillis() + ".xlsx"; //系统生成的文件名 236 | String FileDir = request.getServletContext().getRealPath("/files/" + fileName); 237 | List list = employeeServiceImpl.getAllStudentDetails();//构建一个Excel文件 238 | ExcelUtils.buildExcel(FileDir, list); //传入service 239 | String dataDirectory = request.getServletContext().getRealPath("/files"); //获取要下载的文件文件目录 240 | Path file = Paths.get(dataDirectory, fileName); //获取一个文件 241 | if (Files.exists(file)) { //如果文件存在的情况下 242 | response.setContentType("application/octet-stream"); //响应请求添加类型 243 | response.addHeader("Content-Disposition", "attachment; filename=" + fileName); //添加响应头,发送给客户端的文件名 244 | try { 245 | Files.copy(file, response.getOutputStream()); 246 | } catch (IOException ignored) { 247 | } 248 | } 249 | } 250 | 251 | 252 | } 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | -------------------------------------------------------------------------------- /src/main/java/com/suny/controller/FileSourceController.java: -------------------------------------------------------------------------------- 1 | package com.suny.controller; 2 | 3 | 4 | import com.suny.service.EmployeeService; 5 | import com.suny.utils.ExcelUtils; 6 | import org.apache.commons.fileupload.disk.DiskFileItem; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RequestMethod; 11 | import org.springframework.web.bind.annotation.RequestParam; 12 | import org.springframework.web.context.ServletContextAware; 13 | import org.springframework.web.multipart.MultipartFile; 14 | import org.springframework.web.multipart.commons.CommonsMultipartFile; 15 | 16 | import javax.servlet.ServletContext; 17 | import javax.servlet.http.HttpServletRequest; 18 | import javax.servlet.http.HttpServletResponse; 19 | import java.io.File; 20 | import java.io.IOException; 21 | import java.nio.file.Files; 22 | import java.nio.file.Path; 23 | import java.nio.file.Paths; 24 | import java.util.List; 25 | 26 | /** 27 | * 文件操作相关控制层 28 | * 孙建荣 29 | * 2016/11/10 22:15 30 | */ 31 | @Controller 32 | @RequestMapping("/files") 33 | public class FileSourceController implements ServletContextAware { 34 | 35 | //自动装配 36 | 37 | @Autowired 38 | private EmployeeService employeeServiceImpl; 39 | 40 | public void setServletContext(ServletContext servletContext) { 41 | 42 | } 43 | 44 | /** 45 | * 下载数据库中的成员信息,然后保存到excel表格中 46 | * 47 | * @param request 用户请求相关 48 | * @param response 服务器对用户请求的响应 49 | * @throws IOException 抛出IO流异常 50 | *//* 51 | @RequestMapping("/databaseDownload") 52 | public void databaseDownload(HttpServletRequest request, HttpServletResponse response) throws IOException { 53 | *//** 54 | * 如果文件名有中文的话,进行URL编码,让中文正常显示 55 | response.addHeader("Content-Disposition","attachment; filename=" + URLEncoder.encode(fileName, "UTF-8")); 56 | *//* 57 | String fileName = System.currentTimeMillis() + ".xlsx"; //系统生成的文件名 58 | String FileDir = request.getServletContext().getRealPath("/files/" + fileName); 59 | List list = employeeServiceImpl.getAllStudentDetails();//构建一个Excel文件 60 | ExcelUtils.buildExcel(FileDir, list); //传入service 61 | String dataDirectory = request.getServletContext().getRealPath("/files"); //获取要下载的文件文件目录 62 | Path file = Paths.get(dataDirectory, fileName); //获取一个文件 63 | if (Files.exists(file)) { //如果文件存在的情况下 64 | response.setContentType("application/octet-stream"); //响应请求添加类型 65 | response.addHeader("Content-Disposition", "attachment; filename=" + fileName); //添加响应头,发送给客户端的文件名 66 | try { 67 | Files.copy(file, response.getOutputStream()); 68 | } catch (IOException ignored) { 69 | } 70 | } 71 | }*/ 72 | 73 | /** 74 | * 下载Excel数据文件模板,给管理员一个数据上传的模板,在模板的基础上进行修改 75 | * 76 | * @param response 服务器对用户请求的响应 77 | * @param request 用户的请求相关 78 | */ 79 | @RequestMapping("downloadExcelTemplate") 80 | public void downloadExcelTemplate(HttpServletResponse response, HttpServletRequest request) { 81 | String dataDirectory = request.getServletContext().getRealPath("/files"); //获取要下载的文件文件目录 82 | Path file = Paths.get(dataDirectory, "student.xlsx"); //获取一个文件 83 | if (Files.exists(file)) { //如果文件存在的情况下 84 | response.setContentType("application/octet-stream"); //响应请求添加类型 85 | String fileName = "student.xlsx"; //发送给客户端的文件名 86 | response.addHeader("Content-Disposition", "attachment; filename=" + fileName); //添加响应头 87 | try { 88 | Files.copy(file, response.getOutputStream()); //使用Files类中的copy方法 89 | } catch (IOException ignored) { 90 | } 91 | } 92 | } 93 | 94 | /** 95 | * 进行上传学生Excel数据的页面 96 | * 97 | * @return 上传Excel数据的页面 98 | */ 99 | @RequestMapping(value = "viewUploadExcel") 100 | public String viewUploadExcel() { 101 | return "pages/adminView/uploadExcel"; //返回到上传Excel数据页面 102 | } 103 | 104 | /** 105 | * 对表单上传的Excel表格进行解析,并把成员数据保存到数据库中 106 | * 107 | * @param multipartFile 上传的文件 108 | * @return 上传成功的页面 109 | * @throws IOException 抛出处理IO流异常 110 | */ 111 | @RequestMapping(value = "uploadDatabase", method = RequestMethod.POST) 112 | public String uploadDatabase(@RequestParam("files") MultipartFile multipartFile) throws IOException { 113 | CommonsMultipartFile Cfile = (CommonsMultipartFile) multipartFile; //获取表单上传的文件 114 | DiskFileItem diskFileItem = (DiskFileItem) Cfile.getFileItem(); //获取文件条目 115 | File file = diskFileItem.getStoreLocation(); //获取文件数据 116 | List excelData = ExcelUtils.getExcelData(file);//把文件数据传送到处理Excel数据的service 117 | employeeServiceImpl.saveBatch(excelData); 118 | return "success"; 119 | } 120 | 121 | 122 | } 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /src/main/java/com/suny/controller/LoginController.java: -------------------------------------------------------------------------------- 1 | package com.suny.controller; 2 | 3 | import com.suny.entity.Employee; 4 | import com.suny.service.EmpManagerService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Controller; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | import org.springframework.web.bind.annotation.RequestMethod; 9 | import org.springframework.web.bind.annotation.RequestParam; 10 | import org.springframework.web.servlet.ModelAndView; 11 | import org.springframework.web.servlet.view.RedirectView; 12 | 13 | import javax.servlet.http.HttpServletRequest; 14 | import javax.servlet.http.HttpServletResponse; 15 | import java.io.IOException; 16 | import java.io.PrintWriter; 17 | 18 | /** 19 | * 主要处理用户登陆登出请求 20 | * 孙建荣 21 | * 2016/12/12 13:03 22 | */ 23 | @Controller 24 | public class LoginController { 25 | 26 | @Autowired 27 | private EmpManagerService empManagerServiceImpl; 28 | 29 | 30 | /** 31 | * 处理用户的注销登陆请求,在注销的同时讲保存在session中的用户名进行注销处理 32 | * @param request 包含用户请求的相关信息 33 | */ 34 | @RequestMapping("logout") 35 | public String logout(HttpServletRequest request) { 36 | request.getSession().removeAttribute("username"); //移除session用户名 37 | return "login"; //返回登陆 38 | } 39 | 40 | 41 | /** 42 | * 当用户登陆成功,身份为普通成员身份后的请求 43 | * 44 | * @return 普通用户界面 45 | */ 46 | @RequestMapping("userWeb") 47 | public String user_index() { 48 | return "pages/userView/user_index"; 49 | } 50 | 51 | /** 52 | * 管理员用户登陆成功后,进入管理员页面 53 | * 54 | * @param request request请求,包含用户页面相关的属性 55 | * @return 管理员页面 56 | */ 57 | @RequestMapping(value = {"/adminWeb", "", "/", "/index", "/index.jsp", "/login"}) 58 | public String index(HttpServletRequest request) { 59 | String uri; //定义一个跳转地址变量 60 | if (request.getSession().getAttribute("username") == null) { //判断session中是否有记录,否则就重定向到登陆界面 61 | uri = "login"; //重定向到loginPage请求 62 | } else { 63 | uri = "pages/adminView/admin"; //找到session中username值时跳转地址 64 | } 65 | return uri; 66 | } 67 | 68 | /** 69 | * 处理ajax验证用户名的正确性 70 | * 71 | * @param request request请求 72 | * @param response response请求 73 | * @return 对用户输入的用户名进行判断。正确就返回true,错误就返回false 74 | * @throws IOException 在进行向用户输出流的时候可能会发生IO流异常 75 | */ 76 | @RequestMapping("checkLogin.action") 77 | public String checkLogin(HttpServletRequest request, HttpServletResponse response) throws IOException { 78 | PrintWriter printWriter = response.getWriter(); //得到一个response输出对象 79 | String account = request.getParameter("account"); //获取表单ajax传来的用户账号 80 | Employee employee = empManagerServiceImpl.getByEmployeeAccount(account); //得到通过账号查询的user对象 81 | if (employee == null) { //当通过账号没有查询到user对象时 82 | printWriter.print("false"); //向页面发送字符串"false" 83 | return null; 84 | } else { 85 | printWriter.write("true"); //向前端页面发送字符串 "true" 86 | return null; 87 | } 88 | } 89 | 90 | /** 91 | * 处理用户的登陆请求 92 | * 93 | * @param account 登陆用户的账号名 94 | * @param password 登陆用户的密码 95 | * @param request request请求 96 | * @param modelAndView Springmvc的模型和视图模型 97 | * @return 对应不同的用户角色进入不同的界面 98 | */ 99 | @RequestMapping(value = "login.action", method = RequestMethod.POST) 100 | public ModelAndView login(@RequestParam(value = "account", required = true, defaultValue = "0") String account, 101 | @RequestParam(value = "password", required = true, defaultValue = "0") String password, 102 | HttpServletRequest request, ModelAndView modelAndView) { 103 | String verifyCode = (String) request.getSession().getAttribute("code"); //服务器向登陆页面发送的验证码 104 | String checkCode = request.getParameter("checkCode"); //用户填写的验证码 105 | if (!verifyCode.equals(checkCode) || checkCode.equals("")) { 106 | modelAndView.setView(new RedirectView("loginPage")); //重定向到查看用户登陆页面 107 | } else { 108 | int status = empManagerServiceImpl.validLogin(account, password); //获取service判断用户名返回的状态值 109 | if (status == 0) { //当查询到的数据为空时的操作 110 | modelAndView.setView(new RedirectView("login")); //重定向到查看用户登陆页面 111 | } else { 112 | Employee employee = empManagerServiceImpl.getByManagerAccount(account); //查询id所对应的用户信息 113 | request.getSession().setAttribute("username", employee.getEmpName()); //把用户名保存到session里面 114 | request.getSession().setAttribute("role", "admin"); //保存用户角色到session中 115 | modelAndView.setView(new RedirectView("adminWeb")); //重定向到管理员的主页面 116 | } 117 | } 118 | 119 | return modelAndView; 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /src/main/java/com/suny/controller/ManagerController.java: -------------------------------------------------------------------------------- 1 | package com.suny.controller; 2 | 3 | import com.suny.service.EmpManagerService; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | 8 | import javax.servlet.http.HttpServletResponse; 9 | import java.io.IOException; 10 | import java.io.PrintWriter; 11 | 12 | /** 13 | * 管理员工类 14 | * 孙建荣 15 | * 2016/12/12 13:02 16 | */ 17 | @RequestMapping("/manager") 18 | @Controller 19 | public class ManagerController { 20 | 21 | @Autowired 22 | private EmpManagerService empManagerServiceImpl; 23 | 24 | /** 25 | * 响应ajax请求为所有普通成员添加缺勤记录 26 | */ 27 | @RequestMapping("/punch") 28 | public void punch(HttpServletResponse response) throws IOException { 29 | PrintWriter printWriter = response.getWriter(); 30 | empManagerServiceImpl.autoPunch(); 31 | printWriter.write("true"); 32 | printWriter.close(); 33 | } 34 | } 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/main/java/com/suny/controller/PasswordController.java: -------------------------------------------------------------------------------- 1 | package com.suny.controller; 2 | 3 | import com.suny.service.EmployeeService; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.servlet.ModelAndView; 8 | import org.springframework.web.servlet.view.RedirectView; 9 | 10 | import javax.servlet.http.HttpServletRequest; 11 | import javax.servlet.http.HttpServletResponse; 12 | import java.io.IOException; 13 | import java.io.PrintWriter; 14 | 15 | /** 16 | * 密码相关的类 17 | * 孙建荣 18 | * 2016/12/12 22:24 19 | */ 20 | @Controller 21 | @RequestMapping("/password") 22 | public class PasswordController { 23 | 24 | @Autowired 25 | private EmployeeService employeeServiceImpl; 26 | 27 | 28 | /** 29 | * 进入修改密码页面 30 | * 31 | * @return 密码修改页面 32 | */ 33 | @RequestMapping("/viewChangePassword") 34 | public String ViewChangePassword() { 35 | return "pages/adminView/changePassword"; //进入到修改密码页面 36 | } 37 | 38 | /** 39 | * ajax请求修改密码 40 | * 41 | * @param request 用户请求相关 42 | * @param response 服务器响应相关 43 | * @throws IOException 抛出IO流异常 44 | */ 45 | @RequestMapping("/changePasswordByAjax") 46 | public void changePasswordByAjax(HttpServletRequest request, HttpServletResponse response) throws IOException { 47 | PrintWriter printWriter = response.getWriter(); //实例化一个输出对象 48 | String username = (String) request.getSession().getAttribute("username"); //获取请求中的username 49 | String oldPassword = request.getParameter("oldPassword"); //获取请求中的原始密码 50 | String newPassword = request.getParameter("newPassword"); //获取请求中的新密码 51 | String repeatPassword = request.getParameter("repeatPassword"); //获取请求中的再次输入新密码 52 | if (!newPassword.equals(repeatPassword)) { //如果新密码不等于等于再次输入新密码 53 | printWriter.write("false"); //向页面发出响应 54 | } else { 55 | employeeServiceImpl.checkPassword(username, oldPassword, newPassword); //发送修改密码请求 56 | printWriter.write("true"); //向页面发送响应 57 | } 58 | } 59 | 60 | 61 | /** 62 | * 页面点击修改密码按钮修改密码controller请求 63 | * @param request request请求 64 | * @param modelAndView 模型和视图对象 65 | * @return 返回处理结果 66 | */ 67 | @RequestMapping("/changePassword") 68 | public ModelAndView changePassword(HttpServletRequest request, ModelAndView modelAndView) { 69 | String username = (String) request.getSession().getAttribute("username"); //获取请求中的用户名 70 | String oldPassword = request.getParameter("oldPassword"); //获取请求中的原始密码 71 | String newPassword = request.getParameter("newPassword"); //获取请求中的新密码 72 | String repeatPassword = request.getParameter("repeatPassword"); //获取请求中的再次输入新密码 73 | if (!newPassword.equals(repeatPassword)) { //如果新密码跟再次输入新密码不相等的话 74 | modelAndView.setView(new RedirectView("viewChangePassword")); //重定向到修改密码页面 75 | modelAndView.addObject("error", "两次新密码不匹配"); 76 | } else { 77 | employeeServiceImpl.checkPassword(username, oldPassword, newPassword); //两次密码相等就发送请求修改密码请求 78 | modelAndView.setView(new RedirectView("viewChangePassword")); 79 | } 80 | return modelAndView; //重定向到ViewChangePassword请求 81 | } 82 | 83 | 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/com/suny/dao/impl/ApproveDao.java: -------------------------------------------------------------------------------- 1 | package com.suny.dao.impl; 2 | 3 | import com.suny.entity.Employee; 4 | import org.hibernate.Query; 5 | import org.hibernate.Session; 6 | import org.hibernate.SessionFactory; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Repository; 9 | 10 | import java.io.Serializable; 11 | import java.util.List; 12 | 13 | /** 14 | * 对考勤有异议的申请数据库操作层 15 | * 孙建荣 16 | * 2016/12/13 17:30 17 | */ 18 | @Repository 19 | public class ApproveDao { 20 | 21 | @Autowired 22 | private SessionFactory sessionFactory; 23 | 24 | public Session getSession() { 25 | return sessionFactory.getCurrentSession(); //返回session 26 | } 27 | 28 | /** 29 | * 保存一个实体类对象 30 | * 31 | * @param entity 要保存的实体类对象 32 | */ 33 | public void save(T entity) { 34 | getSession().save(entity); //保存该实体类对象 35 | getSession().flush(); //刷新缓存 36 | } 37 | 38 | 39 | /** 40 | * 更新某个实体类对象 41 | * @param tClass 要被更新的实体类对象 42 | */ 43 | public void update(T tClass) { 44 | getSession().update(tClass); //更新实体类对象 45 | } 46 | 47 | 48 | /** 49 | * 根据用户名查询处理申请的管理员 50 | * @param userName 查询的用户名 51 | * @return 通过某用户名查询出来的管理员信息 52 | */ 53 | public Employee findByName(String userName) { 54 | String hql = "select m from Manager as m where m.username = ?0"; //构建通过管理员用户名查询的语句 55 | Query query = getSession().createQuery(hql); //构建查询集合 56 | query.setParameter("0", userName); //为第一个占位符复制用户名属性 57 | return (Employee) query.uniqueResult(); //返回唯一性结果 58 | } 59 | 60 | 61 | /** 62 | * 获取某个实体类对象 63 | * @param entityClazz 实体类对象 64 | * @param id 主键标示id 65 | * @return 返回得到的一个实体类对象 66 | */ 67 | public T get(Class entityClazz, Serializable id) { 68 | return (T) getSession().get(entityClazz, id); 69 | } 70 | 71 | /** 72 | * 获取所有待审批列表的数据 73 | * @param startCount 获取数据库数据的起始行 74 | * @param pageCount 设置要查询的总个数 75 | * @return 分页查询后的呆审批列表的数据 76 | */ 77 | public List getApproveList(int startCount, int pageCount) { 78 | String hql = "from Application as a where a.result = false "; //创建hql语句 79 | Query query = getSession().createQuery(hql); //创建query查询 80 | query.setFirstResult(startCount); //设置查询起始行数 81 | query.setMaxResults(pageCount); //设置查询最大结果数 82 | return query.list(); //返回集合 83 | } 84 | 85 | 86 | /** 87 | * 获取申请修改考勤记录总记录数 88 | * @return 待审批列表的总记录数 89 | */ 90 | public int TotalApproveListCount() { 91 | String hql = "select count(*) from Application"; //构建查询申请列表表总记录数 92 | Query query = getSession().createQuery(hql); //返回结果集 93 | return (int) ((long) query.uniqueResult()); //uniqueResult()返回的是一个long类型的数 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/com/suny/dao/impl/AttendDao.java: -------------------------------------------------------------------------------- 1 | package com.suny.dao.impl; 2 | 3 | import com.suny.entity.Attend; 4 | import com.suny.entity.Employee; 5 | import org.hibernate.Query; 6 | import org.hibernate.Session; 7 | import org.hibernate.SessionFactory; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Repository; 10 | 11 | import java.util.List; 12 | 13 | /** 14 | * 查询考勤记录数据库操作 15 | * 孙建荣 16 | * 2016/12/13 15:30 17 | */ 18 | @Repository 19 | public class AttendDao { 20 | 21 | @Autowired 22 | private SessionFactory sessionFactory; 23 | 24 | public Session getSession() { 25 | return sessionFactory.getCurrentSession(); //返回session 26 | } 27 | 28 | 29 | /** 30 | * 成员签到时修改数据库里面的考勤状态 31 | * @param attend 要更新的实体对象 32 | */ 33 | public void update(Attend attend){ 34 | getSession().update(attend); 35 | getSession().flush(); 36 | } 37 | 38 | 39 | /** 40 | * 通过员工对象以及当前的时间来查找是否有可签到记录 41 | * @param employee 员工对象 42 | * @param dutyDay 当天的时间 43 | * @return 44 | */ 45 | public List findByEmployeeDutyDay(Employee employee, String dutyDay){ 46 | String hql="from Attend as a where a.employee =?0 and dutyDay = ?1"; 47 | Query query = getSession().createQuery(hql); 48 | query.setParameter("0",employee); 49 | query.setParameter("1",dutyDay); 50 | return query.list(); 51 | 52 | } 53 | 54 | 55 | /** 56 | * 通过学生姓名进行查询考勤记录 57 | * 58 | * @param username 要查询考勤记录的用户名 59 | * @return 返回通过用户名进行查询的查询集 60 | */ 61 | public Query getByName(String username) { 62 | String hql = "from Attend where employee.username like ?0"; //构建通过名字查询 63 | Query query = getSession().createQuery(hql); //构建集合 64 | query.setParameter("0", "%" + username + "%"); //设置参数,hibernate中模糊查询拼接%号 65 | return query; 66 | } 67 | 68 | /** 69 | * 获取所有的考勤数据 70 | * 71 | * @param startCount 查询考勤数据的起始行 72 | * @param pageCount 吗每一页显示的个数 73 | * @return 分页后的考勤数据 74 | */ 75 | public List getAllRecord(int startCount, int pageCount) { 76 | String hql = "from Attend"; //创建hql语句 77 | Query query = getSession().createQuery(hql); //创建query查询 78 | query.setFirstResult(startCount); //设置查询起始行数 79 | query.setMaxResults(pageCount); //设置查询最大结果数 80 | return query.list(); //返回集合 81 | } 82 | 83 | 84 | /** 85 | * 获取考勤记录数据库总记录数 86 | * 87 | * @return 数据库中考勤记录的总记录数 88 | */ 89 | public int TotalCount() { 90 | String hql = "select count(*) from Attend"; //构建查询Student表总记录数 91 | Query query = getSession().createQuery(hql); //返回结果集 92 | return (int) ((long) query.uniqueResult()); //uniqueResult()返回的是一个long类型的数 93 | } 94 | 95 | 96 | } 97 | 98 | 99 | 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /src/main/java/com/suny/dao/impl/AttendTypeDao.java: -------------------------------------------------------------------------------- 1 | package com.suny.dao.impl; 2 | 3 | import com.suny.entity.Attend; 4 | import org.hibernate.Session; 5 | import org.hibernate.SessionFactory; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import java.io.Serializable; 10 | 11 | /** 12 | * 考勤类型数据库操作 13 | * 孙建荣 14 | * 2016/12/18 19:43 15 | */ 16 | @Repository 17 | public class AttendTypeDao { 18 | 19 | @Autowired 20 | private SessionFactory sessionFactory; 21 | 22 | public Session getSession() { 23 | return sessionFactory.getCurrentSession(); 24 | } 25 | 26 | /** 27 | * 保存一个新的考勤记录 28 | * @param attend 要保存的对象 29 | */ 30 | public void save(Attend attend){ 31 | getSession().save(attend); 32 | } 33 | 34 | /** 35 | * 获取一条对应状态的考勤状态 36 | * @param clazz 考勤状态类 37 | * @param id 对应的考勤状态id 38 | * @return 一条对应考勤状态的对象 39 | */ 40 | public T get(Class clazz,Serializable id){ 41 | return (T) getSession().get(clazz,id); 42 | } 43 | 44 | } 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /src/main/java/com/suny/dao/impl/EmployeeDao.java: -------------------------------------------------------------------------------- 1 | package com.suny.dao.impl; 2 | 3 | import com.suny.entity.Employee; 4 | import org.hibernate.Query; 5 | import org.hibernate.Session; 6 | import org.hibernate.SessionFactory; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Repository; 9 | import org.springframework.transaction.annotation.Transactional; 10 | 11 | import java.util.List; 12 | 13 | /** 14 | * 普通员工的数据库操作层 15 | * 孙建荣 16 | * 2016/11/11 13:42 17 | */ 18 | @Repository 19 | public class EmployeeDao{ 20 | 21 | @Autowired 22 | private SessionFactory sessionFactory; 23 | 24 | public Session getSession() { 25 | return sessionFactory.getCurrentSession(); //返回session 26 | } 27 | 28 | 29 | 30 | 31 | /** 32 | * 保存需要进行持久化的实体类对象 33 | * @param employee 需要进行保存的实体类对象 34 | */ 35 | public void addOperation(Employee employee) { 36 | getSession().save(employee); 37 | } 38 | 39 | 40 | /** 41 | * 对需要进行修改的实体类对象进行修改 42 | * @param employee 需要被修改的对象 43 | * @param id 主键标示id 44 | */ 45 | public void modifyOperation(Employee employee, Integer id) { 46 | Employee employee1 = (Employee) getSession().get(Employee.class, id); //获取要更改的对象类 47 | employee1.setBedroom(employee.getBedroom()); //设置寝室号 48 | employee1.setClassName(employee.getClassName()); //设置班级名字 49 | employee1.setEmpName(employee.getEmpName()); //设置姓名 50 | employee1.setTel(employee.getTel()); //设置电话号码 51 | getSession().update(employee1); //更新数据 52 | getSession().flush(); //刷新session 53 | 54 | } 55 | 56 | /** 57 | * 删除一个成员的操作 58 | * @param id 主键标示id,每个id对应着一个用户 59 | */ 60 | @Transactional 61 | public void deleteOperation(Integer id) { 62 | String hql = "delete Employee where id= ?0"; //构建删除学生信息列表中某一的语句 63 | Query query = getSession().createQuery(hql); //构建Query 64 | query.setParameter("0", id); //设置参数 65 | query.executeUpdate(); //执行更改 66 | } 67 | 68 | /** 69 | * 对一个对象进行更新操作 70 | * @param clazz 需要被更新的实体类 71 | */ 72 | public void update(T clazz){ 73 | getSession().update(clazz); //更新要被修改的实体类对象 74 | getSession().flush(); //对一个回话进行刷新 75 | } 76 | 77 | /** 78 | * 对用户的密码进行修改 79 | * @param id 要修改密码的用户的主键标示id 80 | * @param password 需要被更新的密码 81 | */ 82 | public void changePassword(Integer id,String password) { 83 | String hql = "update Employee set password =?0 where id=?1"; //构建通过名字查询 84 | Query query = getSession().createQuery(hql); //构建集合 85 | query.setParameter("0",password); //传入密码 86 | query.setParameter("1",id ); //设置参数 87 | query.executeUpdate(); //执行更新 88 | getSession().flush(); //刷新缓存 89 | } 90 | 91 | 92 | /** 93 | * 通过学生姓名进行查询 94 | * @param username 要被查询的用户名对象 95 | * @return 一个employee对象,对应的是一个用户的信息 96 | */ 97 | public Employee findByEmpName(String username) { 98 | String hql = "from Employee where empName= ?0"; //构建通过名字查询 99 | Query query = getSession().createQuery(hql); //构建集合 100 | query.setParameter("0",username ); //设置参数 101 | return (Employee) query.uniqueResult(); //返回查询用户名的唯一结果 102 | } 103 | 104 | /** 105 | * 模糊查询用户名 106 | * @param username 要被查询的用户名 107 | * @return 返回模糊查询出来的一个集合对象 108 | */ 109 | public Query getByName(String username) { 110 | String hql = "from Employee where empName like ?0"; //构建通过名字进行模糊查询 111 | Query query = getSession().createQuery(hql); //构建集合 112 | query.setParameter("0", "%" + username + "%"); //设置参数 113 | return query; //返回查询集合给service进行判断 114 | } 115 | 116 | /** 117 | * 对数据库进行查询全部操作 118 | * @param startCount 要查询的数据库资料的起始行 119 | * @param pageCount 要查询数据库资料的总个数 120 | * @return 查询出来的数据分页后的结果集 121 | */ 122 | public List getAll(int startCount, int pageCount) { 123 | String hql = "from Employee"; //创建hql语句 124 | Query query = getSession().createQuery(hql); //创建query查询 125 | query.setFirstResult(startCount); //设置查询起始行数 126 | query.setMaxResults(pageCount); //设置查询最大结果数 127 | return query.list(); //返回集合 128 | } 129 | 130 | /** 131 | * 获取所有的成员数据 132 | * 133 | * @return 所有成员的信息 134 | */ 135 | public List getAllStudentDetails() { 136 | String hql = "from Employee"; //创建hql语句 137 | Query query = getSession().createQuery(hql); //创建query查询 138 | return query.list(); 139 | } 140 | 141 | /** 142 | * 查询某个数据库表中总行数 143 | * @return 返回employee数据库表中的数据库总行数 144 | */ 145 | public int TotalCount() { 146 | String hql = "select count(*) from Employee"; //构建查询Student表总记录数 147 | Query query = getSession().createQuery(hql); //返回结果集 148 | return (int) ((long) query.uniqueResult()); //uniqueResult()返回的是一个long类型的数 149 | } 150 | 151 | /** 152 | * 通过一个id进行查询一个度一箱 153 | * @param id 要被查询的一个对象的主键标示id 154 | * @return 通过该主键标示id查询出来的employee对象 155 | */ 156 | @Transactional 157 | public Employee getById(Integer id) { 158 | String hql = "from Employee where id= ?0 "; //创建hql查询语句 159 | Query query = getSession().createQuery(hql); //创建一个查询 160 | query.setParameter("0", id); //给第一个参数id赋值,值为表单传过来的用户名 161 | Object uniqueResult = query.uniqueResult(); //返回查询中的唯一结果,对应着账户名不能重复 162 | return (Employee) uniqueResult; //返回查询到的账号信息给service 163 | } 164 | 165 | 166 | /** 167 | * 往数据库employee表中批量插入用户信息 168 | * @param employeeList 传过来的一个employee对象集合 169 | */ 170 | public void saveBatch(List employeeList) { 171 | for (int i = 0; i < employeeList.size(); i++) { //对传过来的employee集合进行循环遍历操作 172 | getSession().save(employeeList.get(i)); //批量插入数据 173 | System.out.println("开始插入第" + i + "条数据"); //在控制台输出插入的用户数据信息 174 | } 175 | } 176 | 177 | /** 178 | * 根据用户名和密码查询账号是否存在 179 | * @param account 查询的账号 180 | * @param password 查询的密码 181 | * @return 符合账号密码的成员资料 182 | */ 183 | public List findByNameAndPass(String account, String password) { 184 | String hql="select e from Employee as e where e.account = ?0 and e.password = ?1"; //构建查询用户账号密码是否匹配语句 185 | Query query=getSession().createQuery(hql); //构建查询集合 186 | query.setParameter("0",account); //第一个参数赋值为账号 187 | query.setParameter("1",password); //第二个参数赋值为密码 188 | return query.list(); //返回查询集合的结果集 189 | } 190 | 191 | /** 192 | * 查询普通成员账号对应的用户信息 193 | * @param account 查询的账号 194 | * @return 返回一个对应的用户信息 195 | */ 196 | public Employee getByAccount(String account) { 197 | String hql = "from Employee where account= ?0 "; //创建hql查询语句 198 | Query query=getSession().createQuery(hql); //创建一个查询 199 | query.setParameter("0", account); //给第一个参数Student_id赋值,值为表单传过来的用户名 200 | Object uniqueResult = query.uniqueResult(); //返回查询中的唯一结果,对应着账户名不能重复 201 | return (Employee) uniqueResult; //返回查询到的一个唯一账号信息给service 202 | } 203 | } 204 | -------------------------------------------------------------------------------- /src/main/java/com/suny/dao/impl/ManagerDao.java: -------------------------------------------------------------------------------- 1 | package com.suny.dao.impl; 2 | 3 | import com.suny.entity.Employee; 4 | import org.hibernate.Query; 5 | import org.hibernate.Session; 6 | import org.hibernate.SessionFactory; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Repository; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * 管理员相关的数据库操作层 14 | * 孙建荣 15 | * 2016/12/12 13:00 16 | */ 17 | @Repository 18 | public class ManagerDao { 19 | @Autowired 20 | private SessionFactory sessionFactory; 21 | 22 | public Session getSession() { 23 | return sessionFactory.getCurrentSession(); //返回session 24 | } 25 | 26 | /** 27 | * 查询所有普通成员的信息 28 | * @return 所有普通成员的信息 29 | */ 30 | public List findAll(){ 31 | String hql="from Employee "; 32 | Query query = getSession().createQuery(hql); 33 | return query.list(); 34 | } 35 | 36 | 37 | /** 38 | * 查询账号对应的用户信息 39 | * @param account 查询的账号 40 | * @return 返回一个对应的用户信息 41 | */ 42 | public Employee getByAccount(String account) { 43 | String hql = "from Manager where account= ?0 "; //创建hql查询语句 44 | Query query=getSession().createQuery(hql); //创建一个查询 45 | query.setParameter("0", account); //给第一个参数Student_id赋值,值为表单传过来的用户名 46 | Object uniqueResult = query.uniqueResult(); //返回查询中的唯一结果,对应着账户名不能重复 47 | return (Employee) uniqueResult; //返回查询到的账号信息给service 48 | } 49 | 50 | } 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/main/java/com/suny/entity/Application.java: -------------------------------------------------------------------------------- 1 | package com.suny.entity; 2 | 3 | import javax.persistence.*; 4 | import java.io.Serializable; 5 | 6 | /** 7 | * 孙建荣 8 | * 2016/12/11 21:46 9 | */ 10 | @Entity 11 | @Table(name = "application") 12 | public class Application implements Serializable { 13 | private static final long serialVersionUID = 48L; 14 | 15 | @Id 16 | @Column(name = "app_id") 17 | @GeneratedValue(strategy = GenerationType.IDENTITY) 18 | private Integer id; //标示属性 19 | 20 | //申请的理由 21 | @Column(name = "app_reason") 22 | private String reason; 23 | 24 | //是否处理 25 | @Column(name = "app_result") 26 | private boolean result; 27 | 28 | 29 | //关联的出勤记录 30 | @ManyToOne(targetEntity = Attend.class) 31 | @JoinColumn(name = "attend_id",nullable = false) 32 | private Attend attend; 33 | 34 | //想要更改的出勤结果 35 | @ManyToOne(targetEntity = AttendType.class) 36 | @JoinColumn(name = "type_id",nullable = false) 37 | private AttendType attendType; 38 | 39 | //申请的结果 40 | @OneToOne(targetEntity = CheckBack.class,mappedBy = "app") 41 | private CheckBack checkBack; 42 | 43 | public Application() { 44 | } 45 | 46 | public Application(String reason, Boolean result, Attend attend, AttendType attendType, CheckBack checkBack) { 47 | this.reason = reason; 48 | this.result = result; 49 | this.attend = attend; 50 | this.attendType = attendType; 51 | this.checkBack = checkBack; 52 | } 53 | 54 | public Integer getId() { 55 | return id; 56 | } 57 | 58 | public void setId(Integer id) { 59 | this.id = id; 60 | } 61 | 62 | public String getReason() { 63 | return reason; 64 | } 65 | 66 | public void setReason(String reason) { 67 | this.reason = reason; 68 | } 69 | 70 | public Boolean getResult() { 71 | return result; 72 | } 73 | 74 | public void setResult(Boolean result) { 75 | this.result = result; 76 | } 77 | 78 | public Attend getAttend() { 79 | return attend; 80 | } 81 | 82 | public void setAttend(Attend attend) { 83 | this.attend = attend; 84 | } 85 | 86 | public AttendType getAttendType() { 87 | return attendType; 88 | } 89 | 90 | public void setAttendType(AttendType attendType) { 91 | this.attendType = attendType; 92 | } 93 | 94 | public CheckBack getCheckBack() { 95 | return checkBack; 96 | } 97 | 98 | public void setCheckBack(CheckBack checkBack) { 99 | this.checkBack = checkBack; 100 | } 101 | 102 | @Override 103 | public String toString() { 104 | return "Application{" + 105 | "id=" + id + 106 | ", reason='" + reason + '\'' + 107 | ", result=" + result + 108 | ", attend=" + attend + 109 | ", attendType=" + attendType + 110 | ", checkBack=" + checkBack + 111 | '}'; 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /src/main/java/com/suny/entity/Attend.java: -------------------------------------------------------------------------------- 1 | package com.suny.entity; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | 5 | import javax.persistence.*; 6 | import java.io.Serializable; 7 | import java.util.Date; 8 | 9 | /** 10 | * 孙建荣 11 | * 2016/12/11 21:00 12 | */ 13 | @Entity 14 | @Table(name = "attend") 15 | public class Attend implements Serializable{ 16 | private static final long serialVersionUID = 48L; 17 | 18 | @Id 19 | @GeneratedValue(strategy = GenerationType.IDENTITY) 20 | @Column(name = "attend_id") 21 | private Integer id; //标示对象 22 | 23 | //考勤日期 24 | @Column(name = "duty_day",nullable = false,length =50 ) 25 | private Date dutyDay; 26 | 27 | //签到时间 28 | @Column(name = "punch_time") 29 | private java.util.Date punchTime; 30 | 31 | //是否在规定时间签到 0为没有 1为签到 32 | @Column(name = "is_come") 33 | private boolean isCome; 34 | 35 | //本次考勤的类型 36 | @ManyToOne(targetEntity = AttendType.class) 37 | @JoinColumn(name = "type_id",nullable = false) 38 | private AttendType attendType; 39 | 40 | 41 | //本次考勤的员工 42 | @ManyToOne(targetEntity = Employee.class) 43 | @JoinColumn(name = "emp_id") 44 | @JsonIgnore 45 | private Employee employee; 46 | 47 | public Attend() { 48 | } 49 | 50 | public Attend(Date dutyDay, Date punchTime, boolean isCome, AttendType attendType, Employee employee) { 51 | this.dutyDay = dutyDay; 52 | this.punchTime = punchTime; 53 | this.isCome = isCome; 54 | this.attendType = attendType; 55 | this.employee = employee; 56 | } 57 | 58 | public Integer getId() { 59 | return id; 60 | } 61 | 62 | public void setId(Integer id) { 63 | this.id = id; 64 | } 65 | 66 | public Date getDutyDay() { 67 | return dutyDay; 68 | } 69 | 70 | public void setDutyDay(Date dutyDay) { 71 | this.dutyDay = dutyDay; 72 | } 73 | 74 | public Date getPunchTime() { 75 | return punchTime; 76 | } 77 | 78 | public void setPunchTime(Date punchTime) { 79 | this.punchTime = punchTime; 80 | } 81 | 82 | public boolean isCome() { 83 | return isCome; 84 | } 85 | 86 | public void setCome(boolean isCome) { 87 | this.isCome = isCome; 88 | } 89 | 90 | public AttendType getAttendType() { 91 | return attendType; 92 | } 93 | 94 | public void setAttendType(AttendType attendType) { 95 | this.attendType = attendType; 96 | } 97 | 98 | public Employee getEmployee() { 99 | return employee; 100 | } 101 | 102 | public void setEmployee(Employee employee) { 103 | this.employee = employee; 104 | } 105 | 106 | @Override 107 | public String toString() { 108 | return "Attend{" + 109 | "id=" + id + 110 | ", dutyDay=" + dutyDay + 111 | ", punchTime=" + punchTime + 112 | ", isCome=" + isCome + 113 | ", attendType=" + attendType + 114 | '}'; 115 | } 116 | } 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /src/main/java/com/suny/entity/AttendType.java: -------------------------------------------------------------------------------- 1 | package com.suny.entity; 2 | 3 | import javax.persistence.*; 4 | import java.io.Serializable; 5 | 6 | /** 7 | * 孙建荣 8 | * 2016/12/11 21:36 9 | */ 10 | @Entity 11 | @Table(name = "attend_type") 12 | public class AttendType implements Serializable{ 13 | private static final long serialVersionUID = 48L; 14 | 15 | @Id 16 | @GeneratedValue(strategy = GenerationType.IDENTITY) 17 | @Column(name = "type_id") 18 | private Integer id; //标示属性 19 | 20 | @Column(name = "type_name",nullable = false,length = 50) 21 | private String name; 22 | 23 | public AttendType() { 24 | } 25 | 26 | public AttendType(Integer id, String name) { 27 | this.name = name; 28 | this.id=id; 29 | } 30 | 31 | public Integer getId() { 32 | return id; 33 | } 34 | 35 | public void setId(Integer id) { 36 | this.id = id; 37 | } 38 | 39 | public String getName() { 40 | return name; 41 | } 42 | 43 | public void setName(String name) { 44 | this.name = name; 45 | } 46 | 47 | @Override 48 | public String toString() { 49 | return "AttendType{" + 50 | "id=" + id + 51 | ", name='" + name + '\'' + 52 | '}'; 53 | } 54 | } 55 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /src/main/java/com/suny/entity/CheckBack.java: -------------------------------------------------------------------------------- 1 | package com.suny.entity; 2 | 3 | 4 | import javax.persistence.*; 5 | import java.io.Serializable; 6 | 7 | /** 8 | * 孙建荣 9 | * 2016/12/11 20:38 10 | */ 11 | @Entity 12 | @Table(name = "check_back") 13 | public class CheckBack implements Serializable { 14 | private static final long serialVersionUID = 48L; 15 | 16 | @Id 17 | @Column(name = "check_id") 18 | @GeneratedValue(strategy = GenerationType.IDENTITY) 19 | private Integer id; 20 | 21 | //是否同意申请 22 | @Column(name = "check_result", nullable = false) 23 | private boolean result; 24 | 25 | //批复理由 26 | @Column(name = "check_reason",length = 255) 27 | private String reason; 28 | 29 | //批复对应的申请 30 | @OneToOne(targetEntity = Application.class) 31 | @JoinColumn(name = "app_id") 32 | private Application app; 33 | 34 | //审批的部长 35 | @ManyToOne(targetEntity = Manager.class) 36 | @JoinColumn(name="mgr_id",nullable = false) 37 | private Manager manager; 38 | 39 | public CheckBack() { 40 | } 41 | 42 | public CheckBack(Manager manager, boolean result, String reason, Application app) { 43 | this.manager = manager; 44 | this.result = result; 45 | this.reason = reason; 46 | this.app = app; 47 | } 48 | 49 | public Integer getId() { 50 | return id; 51 | } 52 | 53 | public void setId(Integer id) { 54 | this.id = id; 55 | } 56 | 57 | public boolean isResult() { 58 | return result; 59 | } 60 | 61 | public void setResult(boolean result) { 62 | this.result = result; 63 | } 64 | 65 | public String getReason() { 66 | return reason; 67 | } 68 | 69 | public void setReason(String reason) { 70 | this.reason = reason; 71 | } 72 | 73 | public Application getApp() { 74 | return app; 75 | } 76 | 77 | public void setApp(Application app) { 78 | this.app = app; 79 | } 80 | 81 | public Manager getManager() { 82 | return manager; 83 | } 84 | 85 | public void setManager(Manager manager) { 86 | this.manager = manager; 87 | } 88 | 89 | 90 | @Override 91 | public String toString() { 92 | return "CheckBack{" + 93 | "id=" + id + 94 | ", result=" + result + 95 | ", reason='" + reason + '\'' + 96 | ", app=" + app + 97 | ", manager=" + manager + 98 | '}'; 99 | } 100 | } 101 | 102 | 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /src/main/java/com/suny/entity/Employee.java: -------------------------------------------------------------------------------- 1 | package com.suny.entity; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | 5 | import javax.persistence.*; 6 | import java.io.Serializable; 7 | import java.util.HashSet; 8 | import java.util.Set; 9 | 10 | /** 11 | * 孙建荣 12 | * 2016/12/11 20:46 13 | */ 14 | @Entity 15 | @Table(name = "employee") 16 | @DiscriminatorColumn(name = "emp_type",discriminatorType =DiscriminatorType.INTEGER ) 17 | @DiscriminatorValue(value = "1") 18 | public class Employee implements Serializable{ 19 | private static final long serialVersionUID = 48L; 20 | 21 | //标示属性 22 | @Id 23 | @Column(name = "emp_id") 24 | @GeneratedValue(strategy= GenerationType.IDENTITY) 25 | private Integer id; 26 | 27 | @Column(name = "emp_account",nullable=false, length=50 , unique=true) //登陆账号 28 | private String account; 29 | 30 | @Column(name = "emp_password", nullable=false, length=50) //登录密码 31 | private String password; 32 | 33 | @Column(name = "emp_name") 34 | private String empName; //姓名 35 | 36 | @Column(name = "emp_className") 37 | private String className; //班级 38 | 39 | 40 | 41 | @Column(name = "emp_tel") 42 | private String tel; //个人电话号码 43 | 44 | @Column(name = "emp_bedroom") 45 | private String bedroom; //宿舍 46 | 47 | //成员对应的部长 48 | @ManyToOne(targetEntity = Manager.class) 49 | @JoinColumn(name="mgr_id") 50 | @JsonIgnoreProperties 51 | private Manager manager; 52 | 53 | //成员对应的签到记录 54 | @OneToMany(targetEntity = Attend.class,mappedBy = "employee") 55 | private Set attends=new HashSet<>(); 56 | 57 | public Employee() { 58 | } 59 | 60 | public Employee(String account, String password, String empName, String className, String tel, String bedroom) { 61 | this.account = account; 62 | this.password = password; 63 | this.empName = empName; 64 | this.className = className; 65 | this.tel = tel; 66 | this.bedroom = bedroom; 67 | // this.manager = manager; 68 | // this.attends = attends; 69 | } 70 | 71 | public Integer getId() { 72 | return id; 73 | } 74 | 75 | public void setId(Integer id) { 76 | this.id = id; 77 | } 78 | 79 | public String getAccount() { 80 | return account; 81 | } 82 | 83 | public void setAccount(String account) { 84 | this.account = account; 85 | } 86 | 87 | public String getPassword() { 88 | return password; 89 | } 90 | 91 | public void setPassword(String password) { 92 | this.password = password; 93 | } 94 | 95 | public String getEmpName() { 96 | return empName; 97 | } 98 | 99 | public void setEmpName(String empName) { 100 | this.empName = empName; 101 | } 102 | 103 | 104 | 105 | public String getClassName() { 106 | return className; 107 | } 108 | 109 | public void setClassName(String className) { 110 | this.className = className; 111 | } 112 | 113 | 114 | public String getTel() { 115 | return tel; 116 | } 117 | 118 | public void setTel(String tel) { 119 | this.tel = tel; 120 | } 121 | 122 | public String getBedroom() { 123 | return bedroom; 124 | } 125 | 126 | public void setBedroom(String bedroom) { 127 | this.bedroom = bedroom; 128 | } 129 | 130 | public Manager getManager() { 131 | return manager; 132 | } 133 | 134 | public void setManager(Manager manager) { 135 | this.manager = manager; 136 | } 137 | 138 | public Set getAttends() { 139 | return attends; 140 | } 141 | 142 | public void setAttends(Set attends) { 143 | this.attends = attends; 144 | } 145 | 146 | @Override 147 | public String toString() { 148 | return "Employee{" + 149 | "id=" + id + 150 | ", password='" + password + '\'' + 151 | ", empName='" + empName + '\'' + 152 | ", className='" + className + '\'' + 153 | ", tel='" + tel + '\'' + 154 | ", bedroom='" + bedroom + '\'' + 155 | ", attends=" + attends + 156 | '}'; 157 | } 158 | } 159 | -------------------------------------------------------------------------------- /src/main/java/com/suny/entity/Manager.java: -------------------------------------------------------------------------------- 1 | package com.suny.entity; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.DiscriminatorValue; 5 | import javax.persistence.Entity; 6 | import javax.persistence.OneToMany; 7 | import java.io.Serializable; 8 | import java.util.HashSet; 9 | import java.util.Set; 10 | 11 | /** 12 | * 孙建荣 13 | * 2016/12/11 20:31 14 | * 部长实体类 15 | */ 16 | @Entity 17 | @DiscriminatorValue(value = "2") 18 | public class Manager extends Employee implements Serializable { 19 | 20 | private static final long serialVersionUID = 48L; 21 | 22 | 23 | //该部长可以管理的部门 24 | @Column(name="dept_name",length = 50) 25 | private String dept; 26 | 27 | //该部长管理的成员 28 | @OneToMany(targetEntity = Employee.class,mappedBy = "manager") 29 | private Set employees=new HashSet<>(); 30 | 31 | //该部长审批的所有批复 32 | @OneToMany(targetEntity = CheckBack.class,mappedBy = "manager") 33 | private Set checkBacks=new HashSet<>(); 34 | 35 | public Manager() { 36 | } 37 | 38 | public Manager(Set checkBacks, String dept, Set employees) { 39 | this.checkBacks = checkBacks; 40 | this.dept = dept; 41 | this.employees = employees; 42 | } 43 | 44 | public String getDept() { 45 | return dept; 46 | } 47 | 48 | public void setDept(String dept) { 49 | this.dept = dept; 50 | } 51 | 52 | public Set getEmployees() { 53 | return employees; 54 | } 55 | 56 | public void setEmployees(Set employees) { 57 | this.employees = employees; 58 | } 59 | 60 | public Set getCheckBacks() { 61 | return checkBacks; 62 | } 63 | 64 | public void setCheckBacks(Set checkBacks) { 65 | this.checkBacks = checkBacks; 66 | } 67 | 68 | @Override 69 | public String toString() { 70 | return "Manager{" + 71 | "dept='" + dept + '\'' + 72 | ", checkBacks=" + checkBacks + 73 | '}'; 74 | } 75 | } 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /src/main/java/com/suny/exception/PasswordNotMatchException.java: -------------------------------------------------------------------------------- 1 | package com.suny.exception; 2 | 3 | /** 4 | * 孙建荣 5 | * 2016/11/14 13:58 6 | */ 7 | public class PasswordNotMatchException extends RuntimeException{ 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/com/suny/filter/LoginCheckFilter.java: -------------------------------------------------------------------------------- 1 | package com.suny.filter; 2 | 3 | import javax.servlet.*; 4 | import javax.servlet.http.HttpServletRequest; 5 | import javax.servlet.http.HttpServletResponse; 6 | import javax.servlet.http.HttpSession; 7 | import java.io.IOException; 8 | 9 | /** 10 | * 原生Filter拦截未登陆用户请求 11 | * 孙建荣 12 | * 2016/12/16 13:17 13 | */ 14 | public class LoginCheckFilter implements Filter { 15 | @Override 16 | public void init(FilterConfig filterConfig) throws ServletException { 17 | 18 | } 19 | 20 | /** 21 | * 判断是否有session中的username属性,如果没有泽判定为未登陆 22 | * @param servletRequest request请求 23 | * @param servletResponse 服务器的响应 24 | * @param filterChain 下一拦截请求 25 | * @throws IOException 抛出IO流异常 26 | * @throws ServletException 抛出Servlet异常 27 | */ 28 | @Override 29 | public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { 30 | HttpServletRequest request = (HttpServletRequest) servletRequest; //强转为HttpServletRequest 31 | HttpServletResponse response = (HttpServletResponse) servletResponse; //强转为HttpServletResponse 32 | HttpSession session = request.getSession(); //获取sessioni对象 33 | String username = (String) session.getAttribute("username"); //获取session中的username 34 | if (username != null) { 35 | filterChain.doFilter(request,response); //为空则重定向到登陆页面 36 | } 37 | else{ 38 | response.sendRedirect("index.jsp"); 39 | } 40 | 41 | } 42 | 43 | @Override 44 | public void destroy() { 45 | 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/suny/interceptor/UserInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.suny.interceptor; 2 | 3 | import org.springframework.web.servlet.HandlerInterceptor; 4 | import org.springframework.web.servlet.ModelAndView; 5 | 6 | import javax.servlet.http.HttpServletRequest; 7 | import javax.servlet.http.HttpServletResponse; 8 | 9 | /** 10 | * 用户权限拦截器,对未登陆的用户进行拦截 11 | * 孙建荣 12 | * 2016/12/15 22:47 13 | */ 14 | public class UserInterceptor implements HandlerInterceptor { 15 | 16 | 17 | /** 18 | * 还没有进行处理请求的时候的回调 19 | * @param httpServletRequest request对象相关属性 20 | * @param httpServletResponse response对象,服务器对用户得到响应请求 21 | * @param o Object对象,在被类中为username对象 22 | * @return 对象用户登陆请求进行判断,有session就放行,没有session就拦截,不进行下一操作 23 | * @throws Exception 24 | */ 25 | @Override 26 | public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o) throws Exception { 27 | Object username=httpServletRequest.getSession().getAttribute("username"); //判断session中是否存在username 28 | if(username==null){ //为空则重定向到登陆页面 29 | httpServletResponse.sendRedirect(httpServletRequest.getContextPath() + "/login"); 30 | return false; //返回false则不提交给下一处理 31 | } 32 | return true; //判断成功的话就返回true,交由下一处理器进行处理 33 | } 34 | 35 | /** 36 | * 处理完用户请求,但是还没有进行页面渲染 37 | * @param httpServletRequest 38 | * @param httpServletResponse 39 | * @param o 40 | * @param modelAndView 41 | * @throws Exception 42 | */ 43 | @Override 44 | public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception { 45 | 46 | } 47 | 48 | /** 49 | * 整个请求完毕的回调,视图也已经渲染的时候 50 | * @param httpServletRequest 51 | * @param httpServletResponse 52 | * @param o 53 | * @param e 54 | * @throws Exception 55 | */ 56 | @Override 57 | public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception { 58 | 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/suny/service/ApproveService.java: -------------------------------------------------------------------------------- 1 | package com.suny.service; 2 | 3 | import com.suny.utils.Page; 4 | 5 | public interface ApproveService { 6 | int getMaxPage(int pageCount); 7 | 8 | void handleApply(Integer applicationId, String mgrName, boolean result) throws Exception; 9 | 10 | Page getTodoApplyList(int currentPage, int pageCount); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/suny/service/AttendService.java: -------------------------------------------------------------------------------- 1 | package com.suny.service; 2 | 3 | import com.suny.entity.Employee; 4 | import com.suny.utils.Page; 5 | 6 | public interface AttendService { 7 | Page getByName(String username, int pageCount, int currentPage); 8 | 9 | Page getAllRecord(int currentPage, int pageCount); 10 | 11 | int getMaxPage(int pageCount); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/suny/service/EmpManagerService.java: -------------------------------------------------------------------------------- 1 | package com.suny.service; 2 | 3 | import com.suny.entity.Employee; 4 | 5 | public interface EmpManagerService { 6 | void autoPunch(); 7 | 8 | Employee getByEmployeeAccount(String account); 9 | 10 | Employee getByManagerAccount(String account); 11 | 12 | int validLogin(String account, String password); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/suny/service/EmployeeService.java: -------------------------------------------------------------------------------- 1 | package com.suny.service; 2 | 3 | import com.suny.entity.Employee; 4 | import com.suny.utils.Page; 5 | 6 | import java.util.List; 7 | 8 | public interface EmployeeService { 9 | int punch(String username); 10 | 11 | void checkPassword(String username, String oldPassword, String newPassword); 12 | 13 | void update(Employee employee, Integer id); 14 | 15 | void add(Employee employee); 16 | 17 | List getAllStudentDetails(); 18 | 19 | void saveBatch(List employeeList); 20 | 21 | Page getAll(int currentPage, int pageCount); 22 | 23 | Page getByName(String username, int pageCount, int currentPage); 24 | 25 | Employee getById(Integer id); 26 | 27 | void del(Integer id); 28 | 29 | int getMaxPage(int pageCount); 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/suny/service/impl/ApproveServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.suny.service.impl; 2 | 3 | import com.suny.dao.impl.ApproveDao; 4 | import com.suny.entity.Application; 5 | import com.suny.entity.Attend; 6 | import com.suny.entity.CheckBack; 7 | import com.suny.entity.Manager; 8 | import com.suny.service.ApproveService; 9 | import com.suny.utils.Page; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Service; 12 | 13 | import java.util.List; 14 | 15 | /** 16 | * 孙建荣 17 | * 2016/12/13 17:28 18 | */ 19 | @Service 20 | public class ApproveServiceImpl implements ApproveService { 21 | 22 | @Autowired 23 | private ApproveDao approveDao; 24 | 25 | /** 26 | * 获取对申请修改考勤列表的最大页数 27 | * @param pageCount 每页显示的记录个数 28 | * @return 申请列表中的记录数除以每页显示的个数的出来的最大页数 29 | */ 30 | @Override 31 | public int getMaxPage(int pageCount) { 32 | int MaxPage; 33 | int totalCount = approveDao.TotalApproveListCount(); //数据库总页数 34 | if (totalCount % pageCount == 0) { 35 | MaxPage = totalCount / pageCount; 36 | } else { 37 | MaxPage = totalCount / pageCount + 1; 38 | } 39 | return MaxPage; 40 | } 41 | 42 | /** 43 | * 对管理员的审批进行处理 44 | * 45 | * @param applicationId 成员提出的申请列表对应的主键标示id 46 | * @param mgrName 处理申请的管理员名字 47 | * @param result 管理员处理的结果,true或者false 48 | * @throws Exception 要进行处理的异常 49 | */ 50 | @Override 51 | public void handleApply(Integer applicationId, String mgrName, boolean result) throws Exception { 52 | Application application = (Application) approveDao.get(Application.class, applicationId); //获取申请修改考勤结果的申请id 53 | CheckBack checkBack = new CheckBack(); //实例化一个审批结果类,新建一条处理结果 54 | checkBack.setApp(application); //审批结果设置对应的申请修改考勤记录 55 | Manager manager = (Manager) approveDao.findByName(mgrName); //查询当前修改考勤记录的管理员姓名 56 | if (manager == null) { //判断是否用户恶意冒充管理员进行审批 57 | throw new Exception("你是不是部长哦"); 58 | } 59 | checkBack.setManager(manager); //审批结果设置审批人 60 | //如果同意申请 61 | if (result) { 62 | checkBack.setResult(true); //审批结果表设置审批结果为1,同意申请 63 | application.setResult(true); //审批表里面设置已处理 64 | approveDao.update(application); //更新那条申请表里面数据的申请结果 65 | Attend attend = application.getAttend(); //从申请修改那条数据中获取想要修改的考勤类型 66 | attend.setAttendType(application.getAttendType()); //设置考勤情况列表里面的考勤数据 67 | approveDao.update(attend); //更新考勤状态中某成员的考勤状况 68 | } 69 | //没有通过申请 70 | else { 71 | application.setResult(true); //设置申请列表中的是否处理申请结果,true为已经处理,false为默认的未处理 72 | checkBack.setResult(false); //设置审批结果表中的是否同意该成员对某条考勤记录的异议申请 73 | approveDao.update(application); //更新申请列表中的某条记录 74 | } 75 | approveDao.save(checkBack); //保存最终的审批结果 76 | } 77 | 78 | /** 79 | * 获取审批列表的待审批信息 80 | * @param currentPage 当前页页码 81 | * @param pageCount 每一个的显示的行数 82 | * @return 分页后的待审批列表数据 83 | */ 84 | @Override 85 | public Page getTodoApplyList(int currentPage, int pageCount) { 86 | Page page = new Page(); //实例化page 87 | int totalCount = approveDao.TotalApproveListCount(); //查询总记录数 88 | page.setPageCount(pageCount); //设置总页数 89 | page.setTotalCount(totalCount); //设置总行数 90 | page.setCurrentPage(currentPage); //设置当前页 91 | int startCount = page.StartCount(currentPage, pageCount); //查询当前页开始行数 92 | List approveList = approveDao.getApproveList(startCount, pageCount); //获取分页查询结果集 93 | page.setPageDate(approveList); //开始设置page相关参数 94 | return page; 95 | } 96 | 97 | 98 | } 99 | -------------------------------------------------------------------------------- /src/main/java/com/suny/service/impl/AttendServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.suny.service.impl; 2 | 3 | import com.suny.dao.impl.AttendDao; 4 | import com.suny.entity.Employee; 5 | import com.suny.service.AttendService; 6 | import com.suny.utils.Page; 7 | import org.hibernate.Query; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Service; 10 | 11 | import java.util.List; 12 | 13 | /** 14 | * 考勤记录逻辑层 15 | * 孙建荣 16 | * 2016/12/13 15:26 17 | */ 18 | @Service 19 | public class AttendServiceImpl implements AttendService { 20 | 21 | @Autowired 22 | private AttendDao attendDao; 23 | 24 | 25 | /** 26 | * 通过用户名进行查询考勤数据 27 | * @param username 要被查询的用户名 28 | * @param pageCount 每一页显示的记录数 29 | * @param currentPage 前端页面传过来的当前页页码 30 | * @return 通过用户名查询到的分页后考勤数据 31 | */ 32 | @Override 33 | public Page getByName(String username, int pageCount, int currentPage) { 34 | Page page = new Page<>(); //实例化page工具类 35 | Query query = attendDao.getByName(username); //得到一个查询的集合 36 | int totalCount = query.list().size(); //得到返回集合的大小 37 | page.setCurrentPage(currentPage); //设置当前页页码 38 | page.setPageCount(pageCount); //设置每一页显示的行数 39 | page.setTotalCount(totalCount); //设置查询出来的总记录数 40 | List attendRecordList = query.list(); //得到数据集合 41 | page.setPageDate(attendRecordList); //设置分页的数据 42 | return page; 43 | } 44 | 45 | /** 46 | * 获取所有考勤记录信息 47 | * @param currentPage 前端页面传过来的当前页页码 48 | * @param pageCount 每页显示的记录数 49 | * @return 返回分页后的考勤记录 50 | */ 51 | @Override 52 | public Page getAllRecord(int currentPage, int pageCount) { 53 | Page page = new Page(); //实例化page 54 | int totalCount = attendDao.TotalCount(); //查询总记录数 55 | page.setPageCount(pageCount); //设置总页数 56 | page.setTotalCount(totalCount); //设置总行数 57 | page.setCurrentPage(currentPage); //设置当前页 58 | int startCount = page.StartCount(currentPage, pageCount); //查询当前页开始行数 59 | List attendRecordList = attendDao.getAllRecord(startCount, pageCount); //获取分页查询结果集 60 | page.setPageDate(attendRecordList); //开始设置page相关参数 61 | return page; 62 | } 63 | 64 | /** 65 | * 获取考勤记录总共分页的页数 66 | * @param pageCount 每一页显示的行数 67 | * @return 考勤记录分页后的总页数 68 | */ 69 | @Override 70 | public int getMaxPage(int pageCount) { 71 | int MaxPage; //最多可以分多少页 72 | int totalCount = attendDao.TotalCount(); //数据库总页数 73 | if (totalCount % pageCount == 0) { //如果最大记录数除以每一页记录数后不存在余数的话,直接是相除 74 | MaxPage = totalCount / pageCount; 75 | } else { 76 | MaxPage = totalCount / pageCount + 1; //如果有余数则最大页数加1 77 | } 78 | return MaxPage; 79 | } 80 | 81 | } 82 | 83 | 84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /src/main/java/com/suny/service/impl/EmpManagerServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.suny.service.impl; 2 | 3 | import com.suny.dao.impl.AttendTypeDao; 4 | import com.suny.dao.impl.EmployeeDao; 5 | import com.suny.dao.impl.ManagerDao; 6 | import com.suny.entity.Attend; 7 | import com.suny.entity.AttendType; 8 | import com.suny.entity.Employee; 9 | import com.suny.service.EmpManagerService; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Service; 12 | 13 | import java.util.Date; 14 | import java.util.List; 15 | 16 | /** 17 | * 成员管理相关的代码 18 | * 孙建荣 19 | * 2016/12/12 13:01 20 | */ 21 | @Service 22 | public class EmpManagerServiceImpl implements EmpManagerService { 23 | @Autowired 24 | private ManagerDao managerDao; 25 | @Autowired 26 | private EmployeeDao employeeDao; 27 | @Autowired 28 | private AttendTypeDao attendTypeDao; 29 | 30 | @Override 31 | public void autoPunch() { 32 | System.out.println("自动插入缺勤记录"); 33 | List employeeList = managerDao.findAll(); //获取数据库中所有的普通成员 34 | //获取当前的时间 35 | // String dutyDay =new java.sql.Date(System.currentTimeMillis()).toString(); 36 | for (Employee employee : employeeList) { //遍历list对象 37 | //获取旷工对应的考勤类型 38 | AttendType attendType = attendTypeDao.get(AttendType.class, 1); 39 | Attend attend = new Attend(); //实例化一条考勤记录 40 | attend.setDutyDay(new Date()); //设置自动添加考勤记录的时间 41 | attend.setAttendType(attendType); //设置考勤类型 42 | attend.setEmployee(employee); //设置考勤记录对应着的成员 43 | attendTypeDao.save(attend); //保存一条考勤记录 44 | } 45 | } 46 | 47 | 48 | /** 49 | * 查询普通成员账号对应的信息 50 | * 51 | * @param account 要查询普通成员详细信息的账号 52 | * @return 返回普通成员对应账号的信息 53 | */ 54 | @Override 55 | public Employee getByEmployeeAccount(String account) { 56 | return employeeDao.getByAccount(account); 57 | } 58 | 59 | 60 | /** 61 | * 查询管理员账号对应的信息 62 | * 63 | * @param account 要查询管理员的账号 64 | * @return 返回对应账号的信息 65 | */ 66 | @Override 67 | public Employee getByManagerAccount(String account) { 68 | return managerDao.getByAccount(account); 69 | } 70 | 71 | 72 | /** 73 | * 对前端传来的用户账号跟用户密码进行验证,判断登陆用户的登陆角色 74 | * 75 | * @param account 登陆用户的账号 76 | * @param password 登陆用户的密码 77 | * @return 返回进行逻辑判断后的验证状态 78 | */ 79 | @Override 80 | public int validLogin(String account, String password) { 81 | Employee employee = employeeDao.getByAccount(account); 82 | if (employee == null) { 83 | return 0; 84 | } else { 85 | if (employee.getPassword().equals(password)) { 86 | return 1; 87 | } 88 | } 89 | return 0; 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/main/java/com/suny/service/impl/EmployeeServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.suny.service.impl; 2 | 3 | import com.suny.dao.impl.AttendDao; 4 | import com.suny.dao.impl.AttendTypeDao; 5 | import com.suny.dao.impl.EmployeeDao; 6 | import com.suny.entity.Attend; 7 | import com.suny.entity.AttendType; 8 | import com.suny.entity.Employee; 9 | import com.suny.service.EmployeeService; 10 | import com.suny.utils.Page; 11 | import org.hibernate.Query; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.stereotype.Service; 14 | 15 | import java.sql.Timestamp; 16 | import java.util.List; 17 | 18 | /** 19 | * employeeService实现类 20 | * 孙建荣 21 | * 2016/11/11 13:44 22 | */ 23 | @Service 24 | public class EmployeeServiceImpl implements EmployeeService { 25 | @Autowired 26 | private EmployeeDao employeeDao; //注入employeeDao 27 | 28 | @Autowired 29 | private AttendDao attendDao; 30 | 31 | @Autowired 32 | private AttendTypeDao attendTypeDao; 33 | 34 | 35 | /** 36 | * 执行签到 37 | * 38 | * @param username 要签到的用户名 39 | * @return 是否可以签到 40 | */ 41 | @Override 42 | public int punch(String username) { 43 | Employee employee = employeeDao.findByEmpName(username); 44 | if (employee == null) { 45 | return 0; //失败 46 | } 47 | String dutyDay = new java.sql.Date(System.currentTimeMillis()).toString(); // 生成一个当前日期 48 | List attendList = attendDao.findByEmployeeDutyDay(employee, dutyDay); //获取当前缺勤的那条记录 49 | if (attendList == null || attendList.size() > 1) { // 如果没有那条记录的话 50 | System.out.println("现在还不能签到"); 51 | return 1; //现在还不能签到 52 | } 53 | if (attendList.get(0).getPunchTime() != null) { //如果已经有了签到时间 54 | System.out.println("已经签到过了"); 55 | return 2; 56 | } else { 57 | //接下来就是可以开始签到的时候了 58 | java.util.Date date = new java.util.Date(); // 获取一个Date对象 59 | Timestamp timeStamp = new Timestamp(date.getTime()); // 讲日期时间转换为数据库中的timestamp类型 60 | attendList.get(0).setPunchTime(timeStamp); //设置签到的时间 61 | //这里就不对签到时间进行各种考勤情况的判定了,要么是正常,要么是缺勤 62 | attendList.get(0).setAttendType((AttendType) attendTypeDao.get(AttendType.class, 5)); 63 | attendDao.update(attendList.get(0)); 64 | return 3; //签到成功 65 | } 66 | 67 | } 68 | 69 | /** 70 | * 发送修改密码请求 71 | * 72 | * @param username 要修改密码的用户名 73 | * @param oldPassword 老密码 74 | * @param newPassword 新密码 75 | */ 76 | @Override 77 | public void checkPassword(String username, String oldPassword, String newPassword) { 78 | Employee employee = employeeDao.findByEmpName(username); // 通过当前的用户名去查询一个对应的对象 79 | if (employee == null) { 80 | System.out.println("用户不存在,恶意修改密码"); 81 | } else if (employee.getPassword().equals(oldPassword)) { 82 | employee.setPassword(newPassword); // 设置要修改的新密码 83 | employeeDao.update(employee); //提交修改密码请求 84 | } 85 | } 86 | 87 | /** 88 | * 修改成员数据 89 | * 90 | * @param employee 要修改数据的employee对象 91 | * @param id 要修改数据的employee的主键标示id 92 | */ 93 | @Override 94 | public void update(Employee employee, Integer id) { 95 | employeeDao.modifyOperation(employee, id); //向employeeDao传递要修改的成员数据跟id 96 | } 97 | 98 | /** 99 | * 增加成员信息 100 | * 101 | * @param employee 要增加的成员信息对象 102 | */ 103 | @Override 104 | public void add(Employee employee) { 105 | employeeDao.addOperation(employee); //向employeeDao传递要增加的成员数据 106 | } 107 | 108 | /** 109 | * 获取所有的成员数据 110 | * 111 | * @return 所有成员的信息 112 | */ 113 | @Override 114 | public List getAllStudentDetails() { 115 | return employeeDao.getAllStudentDetails(); 116 | } 117 | 118 | /** 119 | * 往数据库employee表中批量插入用户信息 120 | * 121 | * @param employeeList 传过来的一个employee对象集合 122 | */ 123 | @Override 124 | public void saveBatch(List employeeList) { 125 | employeeDao.saveBatch(employeeList); 126 | } 127 | 128 | 129 | /** 130 | * 获取所有成员信息 131 | * 132 | * @param currentPage 前端传来的当前页页码 133 | * @param pageCount 每一页显示的记录数 134 | * @return 分页后的数据 135 | */ 136 | @Override 137 | public Page getAll(int currentPage, int pageCount) { 138 | Page page = new Page(); //实例化page 139 | int totalCount = employeeDao.TotalCount(); //查询总记录数 140 | page.setPageCount(pageCount); //设置总页数 141 | page.setTotalCount(totalCount); //设置总行数 142 | page.setCurrentPage(currentPage); //设置当前页 143 | int startCount = page.StartCount(currentPage, pageCount); //查询当前页开始行数 144 | List employeeList = employeeDao.getAll(startCount, pageCount); //获取分页查询结果集 145 | page.setPageDate(employeeList); //开始设置page相关参数 146 | return page; 147 | } 148 | 149 | /** 150 | * 通过用户名查询 151 | * 152 | * @param username 要被查询的用户名 153 | * @param pageCount 每一页显示的记录数 154 | * @param currentPage 前端传来的当前页页码 155 | * @return 通过用户名查询的记录,然后再进行分页后的数据 156 | */ 157 | @SuppressWarnings("Duplicates") 158 | @Override 159 | public Page getByName(String username, int pageCount, int currentPage) { 160 | Page page = new Page<>(); //实例化page工具类 161 | Query query = employeeDao.getByName(username); //得到一个查询的集合 162 | int totalCount = query.list().size(); //得到返回集合的大小 163 | page.setCurrentPage(currentPage); //设置当前页页码 164 | page.setPageCount(pageCount); //设置每一页显示的行数 165 | page.setTotalCount(totalCount); //设置查询出来的总记录数 166 | List employeeList = query.list(); //得到数据集合 167 | page.setPageDate(employeeList); //设置分页的数据 168 | return page; 169 | } 170 | 171 | 172 | /** 173 | * 通过id获取单个成员信息 174 | * 175 | * @param id 要获取成员信息的主键标识id 176 | * @return 通过该id查询出来的employee对象 177 | */ 178 | @Override 179 | public Employee getById(Integer id) { 180 | return employeeDao.getById(id); 181 | } 182 | 183 | /** 184 | * 删除一个成员信息 185 | * 186 | * @param id 要删除的成员的主键标识id 187 | */ 188 | @Override 189 | public void del(Integer id) { 190 | employeeDao.deleteOperation(id); //给dao层传递删除的成员id 191 | } 192 | 193 | 194 | /** 195 | * 获取总共分页的页数 196 | * 197 | * @param pageCount 每一页显示的记录数 198 | * @return employee表中的最大可以分页数 199 | */ 200 | @Override 201 | public int getMaxPage(int pageCount) { 202 | int MaxPage; 203 | int totalCount = employeeDao.TotalCount(); //数据库总页数 204 | if (totalCount % pageCount == 0) { 205 | MaxPage = totalCount / pageCount; //数据库中总记录数除以每一页显示的记录数。除的尽就直接是最大页 206 | } else { 207 | MaxPage = totalCount / pageCount + 1; //除不尽就是要增加一页 208 | } 209 | return MaxPage; 210 | } 211 | 212 | 213 | } 214 | -------------------------------------------------------------------------------- /src/main/java/com/suny/utils/AttendJobUtils.java: -------------------------------------------------------------------------------- 1 | package com.suny.utils; 2 | 3 | import com.suny.service.impl.EmpManagerServiceImpl; 4 | import org.quartz.Job; 5 | import org.quartz.JobExecutionContext; 6 | import org.quartz.JobExecutionException; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.scheduling.annotation.Scheduled; 9 | 10 | /** 11 | * 自动调度任务执行类 12 | * 孙建荣 13 | * 2016/12/18 18:56 14 | */ 15 | public class AttendJobUtils implements Job { 16 | 17 | @Autowired 18 | private EmpManagerServiceImpl empManagerServiceImpl; 19 | 20 | //判断作业是否执行的旗标 21 | private boolean isRunning =false; 22 | 23 | /** 24 | * 执行自动添加考勤方法 25 | * @param jobExecutionContext 26 | * @throws JobExecutionException 27 | */ 28 | @Scheduled(cron = "0 0 7,12 ? * MON-FRI") 29 | @Override 30 | public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { 31 | if(!isRunning){ 32 | System.out.println("开始自动添加缺勤"); 33 | isRunning=true; 34 | //调用业务逻辑方法 35 | empManagerServiceImpl.autoPunch(); 36 | isRunning=false; 37 | } 38 | 39 | } 40 | 41 | 42 | } 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /src/main/java/com/suny/utils/ExcelUtils.java: -------------------------------------------------------------------------------- 1 | package com.suny.utils; 2 | 3 | import com.suny.entity.Employee; 4 | import org.apache.poi.ss.usermodel.*; 5 | import org.apache.poi.xssf.usermodel.XSSFSheet; 6 | import org.apache.poi.xssf.usermodel.XSSFWorkbook; 7 | 8 | import java.io.File; 9 | import java.io.FileInputStream; 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | import java.text.DecimalFormat; 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | 16 | public class ExcelUtils { 17 | 18 | /** 19 | * 下载学生数据模板 20 | * 21 | * @param fileDir 要生成的模板的文件地址 22 | * @throws IOException 抛出IO流异常 23 | */ 24 | public static void buildExcel(String fileDir, List employeeList) throws IOException { 25 | Workbook workbook = new XSSFWorkbook(); //创建一个表格 26 | Sheet sheet1 = workbook.createSheet("students"); //创建一张工作表 27 | setTitles(sheet1); //设置标题行 28 | setStudentDetails(sheet1, employeeList); //填充数值 29 | FileOutputStream fileOutputStream = new FileOutputStream(fileDir); //输出文件 30 | workbook.write(fileOutputStream); //写入文件 31 | fileOutputStream.close(); //关闭 32 | } 33 | 34 | /** 35 | * 填充表格数据 36 | * 37 | * @param sheet1 Excel数据表 38 | */ 39 | public static void setStudentDetails(Sheet sheet1, List employeeList) { 40 | Cell cell; 41 | for (int i = 0; i < employeeList.size(); i++) { 42 | //"序列号","姓名","班级","电话号码","寝室号","部门编号" 43 | Row row1 = sheet1.createRow(i + 1); //因为前面已经创建了标题行,所以从第2行开始 44 | Employee employee = (Employee) employeeList.get(i); //从第一个开始读取 45 | //序列号 46 | cell = row1.createCell(0); 47 | cell.setCellValue("" + i); 48 | //中间空缺账号密码,为不提供下载信息 49 | //成员姓名 50 | cell = row1.createCell(3); 51 | cell.setCellValue(employee.getEmpName()); 52 | //所在班级 53 | cell = row1.createCell(4); 54 | cell.setCellValue(employee.getClassName()); 55 | //电话号码 56 | cell = row1.createCell(5); 57 | cell.setCellValue(employee.getTel()); 58 | //寝室号 59 | cell = row1.createCell(6); 60 | cell.setCellValue(employee.getBedroom()); 61 | //部门名字 62 | cell = row1.createCell(7); 63 | cell.setCellValue(employee.getManager().getDept()); 64 | } 65 | } 66 | 67 | //保存标题数组,用于构建下载数据库数据时Excel表格的标题 68 | private final static String[] titles = new String[]{"序列号", "姓名", "班级", "电话号码", "寝室号", "部门编号"}; 69 | 70 | /** 71 | * 设置表格标题 72 | * 73 | * @param sheet1 传入的要设置的Excel数据库表 74 | */ 75 | public static void setTitles(Sheet sheet1) { 76 | 77 | Row row1 = sheet1.createRow(0); //创建一行 78 | //循环读取插入数据 79 | for (int i = 0; i < titles.length; i++) { 80 | Cell cell = row1.createCell(i); //创建每一个小格子 81 | cell.setCellValue(titles[i]); //为每一个小格子设置值 82 | } 83 | } 84 | 85 | 86 | /** 87 | * 读取Excel学生数据 88 | * 89 | * @param file 要读取的数据的Excel数据表格 90 | * @throws IOException 抛出Io流异常 91 | */ 92 | public static List getExcelData(File file) throws IOException { 93 | //此为poi的核心对象,通过构造方法中的InputStream生成HSSWorkbook对象。 94 | XSSFWorkbook workbook = new XSSFWorkbook(new FileInputStream(file)); 95 | //这里得到第一张表格(sheet),因为只有一张表在这里 96 | XSSFSheet sheetAt = workbook.getSheetAt(0); 97 | //创建一个student集合来存放每一行的student对象 98 | List employeeList = new ArrayList<>(); 99 | // for (Row row : sheetAt) { //使用增强for循环遍历 100 | for (int i = 1; i <= sheetAt.getLastRowNum(); i++) { //获取Excel中第一张表格sheetAt最大的行数 101 | Row row = sheetAt.getRow(i); //迭代Excel数据的每一行row,第1行,第2行...... 102 | //数据库中的主键,采用自动生成的方式,所以留空 103 | // Integer value1 = Integer.valueOf(row.getCell(0).getStringCellValue()); 104 | //传入getCellValue方法中进行判断取出来的值是什么类型的 105 | //"序列号", "姓名", "班级", "电话号码", "寝室号", "部门编号" 106 | String value1 = RandomIDUtils.generateShortUuid(); 107 | //密码数据库默认为123456,留空 108 | String value3 = getCellValue(row.getCell(3)); //姓名 109 | String value4 = getCellValue(row.getCell(4)); //班级 110 | String value5 = getCellValue(row.getCell(5)); //电话号码 111 | String value6 = getCellValue(row.getCell(6)); //寝室号 112 | //传入参数顺序为 :序列号,账号,密码,姓名,班级,电话号码,寝室号,部门名字,管理员id,员工类型,传参数到employee对象 113 | Employee employee = new Employee(value1, "123456", value3, value4, value5, value6); 114 | employeeList.add(employee); //把遍历的每一行学生数据添加到一个student集合中 115 | } 116 | return employeeList; 117 | } 118 | 119 | 120 | /** 121 | * 判断Excel中取出数据类型 122 | * 123 | * @param cell 每一行的数据 124 | * @return 判断取出的类型,并进行相应的转换 125 | */ 126 | @SuppressWarnings("deprecation") 127 | public static String getCellValue(Cell cell) { 128 | switch (cell.getCellType()) { 129 | //取出来的值是String类型的时候 130 | case Cell.CELL_TYPE_STRING: 131 | return cell.getRichStringCellValue().getString(); 132 | //取出来的值是数字的时候 133 | case Cell.CELL_TYPE_NUMERIC: 134 | //是日期字符型的时候 135 | if (DateUtil.isCellDateFormatted(cell)) { 136 | return cell.getDateCellValue() + ""; 137 | //否则就是数字 138 | } else { 139 | // 这种就是格式化数字 return cell.getNumericCellValue()+""; 140 | DecimalFormat df = new DecimalFormat("0"); 141 | return df.format(cell.getNumericCellValue()); 142 | } 143 | //取出来的值是布尔值的时候 144 | case Cell.CELL_TYPE_BOOLEAN: 145 | return cell.getBooleanCellValue() + ""; 146 | //取出来的值是Formula的时候 147 | case Cell.CELL_TYPE_FORMULA: 148 | return cell.getCellFormula() + ""; 149 | } 150 | return null; 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /src/main/java/com/suny/utils/Page.java: -------------------------------------------------------------------------------- 1 | package com.suny.utils; 2 | 3 | 4 | import java.util.List; 5 | 6 | /** 7 | * 数据分页 8 | * 孙建荣 9 | * 2016/11/26 11:01 10 | */ 11 | public class Page { 12 | private int totalCount; //查询总记录数 13 | private int pageCount=5; //每页的显示行数数 14 | private int totalPage; //总页数 15 | private int currentPage; //用户想看的页数 16 | private List pageDate; //封装页面数据 17 | 18 | 19 | /** 20 | * 计算开始行数 21 | * @return 22 | */ 23 | public int StartCount(int currentPage,int pageCount) { 24 | return pageCount * (currentPage - 1); 25 | } 26 | 27 | /** 28 | * 获取首页页码 29 | * @return 30 | */ 31 | public int getTopPageNo(){ 32 | return 1; 33 | } 34 | 35 | /** 36 | * 获取上一页的页码 37 | * @return 38 | */ 39 | public int getPrevious(){ 40 | if(currentPage<1){ 41 | return 1; 42 | } 43 | return currentPage-1; 44 | } 45 | 46 | /** 47 | * 获取下一页页码 48 | * @return 49 | */ 50 | public int getNext(){ 51 | if(Integer.valueOf(currentPage)>=totalPage){ 52 | currentPage=totalPage; 53 | } 54 | return currentPage+1; 55 | } 56 | 57 | /** 58 | * 获取末页 59 | * @return 60 | */ 61 | public int getBottom(){ 62 | return getTotalPage(); 63 | } 64 | 65 | /** 66 | * 获取总记录数 67 | * @return 68 | */ 69 | public int getTotalCount() { 70 | return totalCount; 71 | } 72 | 73 | /** 74 | * 设置总记录数 75 | * @param totalCount 76 | */ 77 | public void setTotalCount(int totalCount) { 78 | this.totalCount = totalCount; 79 | } 80 | 81 | /** 82 | * 获取分页后每一个行数 83 | * @return 84 | */ 85 | public int getPageCount() { 86 | return pageCount; 87 | } 88 | 89 | /** 90 | * 设置每一页显示的行数 91 | * @param pageCount 92 | */ 93 | public void setPageCount(int pageCount) { 94 | this.pageCount = pageCount; 95 | } 96 | 97 | /** 98 | * 获取分页总页数 99 | * @return 100 | */ 101 | public int getTotalPage() { 102 | if(totalCount%pageCount==0){ 103 | totalPage=totalCount/pageCount; 104 | }else{ 105 | totalPage=totalCount/pageCount+1; 106 | } 107 | return totalPage; 108 | } 109 | 110 | /** 111 | * 设置总页数 112 | * @param totalPage 113 | */ 114 | 115 | public void setTotalPage(int totalPage) { 116 | 117 | this.totalPage = totalPage; 118 | } 119 | 120 | 121 | /** 122 | * 获取当前页页码 123 | * @return 124 | */ 125 | public int getCurrentPage() { 126 | if(currentPage<=0){ 127 | currentPage=1; 128 | } 129 | else if(currentPage>totalPage){ 130 | currentPage=totalPage; 131 | } 132 | return currentPage; 133 | } 134 | 135 | /** 136 | * 设置当前页页码 137 | * @param currentPage 138 | */ 139 | public void setCurrentPage(int currentPage) { 140 | 141 | this.currentPage = currentPage; 142 | } 143 | 144 | /** 145 | * 得到分页数据 146 | * @return 147 | */ 148 | public List getPageDate() { 149 | return pageDate; 150 | } 151 | 152 | 153 | /** 154 | * 设置分页数据 155 | * @param pageDate 156 | */ 157 | public void setPageDate(List pageDate) { 158 | this.pageDate = pageDate; 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 | -------------------------------------------------------------------------------- /src/main/java/com/suny/utils/RandomIDUtils.java: -------------------------------------------------------------------------------- 1 | package com.suny.utils; 2 | 3 | import java.util.UUID; 4 | 5 | /** 6 | * 生成一个随机数的工具 7 | * 孙建荣 8 | * 2016/12/17 14:02 9 | */ 10 | public class RandomIDUtils { 11 | public static String[] chars = new String[] { "a", "b", "c", "d", "e", "f", 12 | "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", 13 | "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", 14 | "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", 15 | "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", 16 | "W", "X", "Y", "Z" }; 17 | 18 | 19 | /** 20 | * 生成随机的11位数 21 | * @return 22 | */ 23 | public static String generateShortUuid() { 24 | StringBuffer shortBuffer = new StringBuffer(); 25 | String uuid = UUID.randomUUID().toString().replace("-", ""); 26 | for (int i = 0; i < 11; i++) { 27 | String str = uuid.substring(i * 4, i * 4 + 4); 28 | int x = Integer.parseInt(str, 16); 29 | shortBuffer.append(chars[x % 0x3E]); 30 | } 31 | return shortBuffer.toString(); 32 | 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/resources/applicationContext-SpringMvc.xml: -------------------------------------------------------------------------------- 1 | 2 | 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 | 52 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 68 | 69 | 70 | text/html;charset=UTF-8 71 | application/json;charset=utf-8 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | application/json;charset=UTF-8 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /src/main/resources/applicationContext.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 42 | 43 | 44 | 45 | 46 | 47 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 57 | 58 | 59 | 60 | 61 | com.suny.entity 62 | 63 | 64 | 65 | 66 | true 67 | true 68 | update 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | # Configure logging for testing: optionally with log file 2 | log4j.rootLogger=info, stdout 3 | # log4j.rootLogger=WARN, stdout, logfile 4 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 5 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 6 | log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n 7 | log4j.appender.logfile=org.apache.log4j.FileAppender 8 | log4j.appender.logfile.File=target/spring.log 9 | log4j.appender.logfile.layout=org.apache.log4j.PatternLayout 10 | log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n 11 | 12 | -------------------------------------------------------------------------------- /src/rebel.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /web/WEB-INF/login.jsp: -------------------------------------------------------------------------------- 1 | <%--@elvariable id="error" type=""--%> 2 | <%-- 3 | Created by IntelliJ IDEA. 4 | User: 孙建荣 5 | Date: 2016/11/14/014 6 | Time: 13:25 7 | To change this template use File | Settings | File Templates. 8 | --%> 9 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 10 | <% 11 | String path = request.getContextPath(); 12 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path; 13 | %> 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 用户登陆页面 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 64 | 85 | 86 | 87 | 88 | 89 | 154 | 155 | 156 | 157 | 158 | 159 | -------------------------------------------------------------------------------- /web/WEB-INF/pages/adminView/admin.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: 孙建荣 4 | Date: 2016/12/1/001 5 | Time: 18:08 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <%@include file="/common/common.jsp" %> 10 | 11 | 12 | 13 | 14 | 16 | 17 | 114 | 115 | 116 | 117 | 118 | 119 | 137 | 138 | 139 |
140 | 141 |
142 | 181 |
182 | 183 | 184 |
185 | 186 |
187 | --%> 192 |
193 | 194 |
195 | <%@include file="/common/footer.jsp" %> 196 | 197 | 198 | 204 | -------------------------------------------------------------------------------- /web/WEB-INF/pages/adminView/approveList.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | <%-- 3 | Created by IntelliJ IDEA. 4 | User: 孙建荣 5 | Date: 2016/12/10/010 6 | Time: 16:39 7 | To change this template use File | Settings | File Templates. 8 | --%> 9 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 10 | <% 11 | String path = request.getContextPath(); 12 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path; 13 | %> 14 | 15 | 16 | 17 | 18 | 19 | 考勤审批页面 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 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 | 87 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 |
考勤序号考勤时间签到时间考勤类型考勤人姓名申请修改类型申请理由操作
暂无申请修改考勤信息
${employee.id}${employee.attend.dutyDay}${employee.attend.punchTime}${employee.attend.attendType.name}${employee.attend.employee.userName}${employee.attendType.name}${employee.reason} 82 | 同意 85 | 86 | 88 | 拒绝 91 | 92 |
103 | 104 |
105 | 106 | 107 | -------------------------------------------------------------------------------- /web/WEB-INF/pages/adminView/attendanceRecord.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | <%-- 3 | Created by IntelliJ IDEA. 4 | User: 孙建荣 5 | Date: 2016/12/8/008 6 | Time: 13:07 7 | To change this template use File | Settings | File Templates. 8 | --%> 9 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 10 | <% 11 | String path = request.getContextPath(); 12 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path; 13 | %> 14 | 15 | 16 | 17 | 18 | 19 | 考勤记录信息页面 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 67 | 68 | 69 | 70 |
71 | 点击开启考勤 72 | 输入姓名查询     73 |
74 | 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 |
考勤序号考勤时间签到时间考勤类型家长电话考勤人姓名
考勤数据为空
${employee.id}${employee.dutyDay}${employee.punchTime}${employee.attendType.name}${employee.employee.empName}
118 | 119 | 首页 121 | 上一页下一页 125 | 末页 127 | 128 | 129 | 首页 131 | 上一页 133 | 下一页 135 | 末页 137 | 138 | 139 | 总记录数${page.totalCount} 140 | 141 | 当前 142 | 143 | 150 | 页/${page.getTotalPage()} 151 | 152 | 153 |
154 | 155 | 156 | -------------------------------------------------------------------------------- /web/WEB-INF/pages/adminView/changePassword.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: 孙建荣 4 | Date: 2016/12/5/005 5 | Time: 20:21 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <% 10 | String path = request.getContextPath(); 11 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path; 12 | %> 13 | 14 | 15 | 16 | 修改密码 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 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 | 73 |
74 |
75 | 76 | 77 |
78 |
79 | 80 |
81 |
82 |
83 | 84 | 85 |
86 | 87 | 88 | -------------------------------------------------------------------------------- /web/WEB-INF/pages/adminView/employeeList.jsp: -------------------------------------------------------------------------------- 1 | <%--@elvariable id="page" type="com.suny.utils.Page"--%> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | <%-- 4 | Created by IntelliJ IDEA. 5 | User: 孙建荣 6 | Date: 2016/11/16/016 7 | Time: 17:22 8 | To change this template use File | Settings | File Templates. 9 | --%> 10 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 11 | <% 12 | String path = request.getContextPath(); 13 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path; 14 | %> 15 | 16 | 17 | 18 | 19 | 20 | 学生信息页面 21 | 22 | 23 | 24 | 25 | 26 | 27 | 66 | 83 | 84 | 85 | 86 |
87 | 88 |
89 |
91 |
92 | 93 | 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 |
序号姓名班级电话号码寝室部长
成员数据为空
${employee.id}${employee.empName}${employee.className}${employee.tel}${employee.bedroom}${employee.manager.userName}
139 | 140 | 首页 142 | 上一页下一页 146 | 末页 148 | 149 | 150 | 首页 152 | 上一页 154 | 下一页 156 | 末页 158 | 159 | 160 | 总记录数${page.totalCount} 161 | 162 | 当前 163 | 164 | 171 | 页/${page.getTotalPage()} 172 | 173 | 174 | 下载为Excel数据 175 |
176 | 177 | 178 | -------------------------------------------------------------------------------- /web/WEB-INF/pages/adminView/manageEmployee.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: 孙建荣 4 | Date: 2016/12/2/002 5 | Time: 22:23 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 10 | <% 11 | String path = request.getContextPath(); 12 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path; 13 | %> 14 | 15 | 16 | 17 | 18 | 19 | 学生信息管理页面 20 | 21 | 22 | 23 | 24 | 25 | 26 | 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 | 108 | <%-- 110 | <%-- 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 |
序号姓名班级部门操作
成员数据为空
${employee.id}${employee.empName}${employee.className}${employee.manager.dept}修改 107 | 109 | 删除查看--%> 111 |
123 | 124 | 首页 126 | 上一页下一页 130 | 末页 132 | 133 | 134 | 首页 136 | 上一页 138 | 下一页 140 | 末页 142 | 143 | 144 | 总记录数${page.totalCount} 145 | 146 | 当前 147 | 154 | 页/${page.getTotalPage()} 155 | 156 | 157 | 158 |
159 | 160 | 161 | 162 |
163 | 164 | 165 | 184 | 185 | <%--修改资料拟态框--%> 186 | 235 | 236 | <%--添加信息框--%> 237 | 289 |
290 | 291 | 433 | 434 | 435 | -------------------------------------------------------------------------------- /web/WEB-INF/pages/adminView/update.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: 孙建荣 4 | Date: 2016/11/17/017 5 | Time: 19:48 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <% 10 | String path = request.getContextPath(); 11 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path; 12 | %> 13 | 14 | 15 | 16 | 17 | 18 | 19 | 修改学生信息 20 | 21 | 22 | 23 | 24 | 25 | 26 | 75 | 76 | 77 |
78 | <%----%> 79 |
80 | 81 |
82 | 83 |
85 | 86 | 87 | 88 |
90 | 91 | 92 | 93 | 94 |
96 | 97 | 98 | 99 |
100 | 101 | 102 |
103 | 104 | 105 | 返回学生信息列表 106 |
107 |
108 | 109 | 110 | -------------------------------------------------------------------------------- /web/WEB-INF/pages/adminView/upload.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: 孙建荣 4 | Date: 2016/11/10/010 5 | Time: 22:10 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 11 | 网盘文件管理页面 12 | 13 | 14 |

文件上传页面

15 |
16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /web/WEB-INF/pages/adminView/uploadExcel.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: 孙建荣 4 | Date: 2016/11/11/011 5 | Time: 12:51 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 11 | 12 | 28 | 上传学生资料 29 | 30 | 31 |

请注意,不要随意上传Excel文件,按照模板的格式进行编辑,然后再上传

32 | 33 | 下载模板 34 | 下载学生数据 35 | 36 | 37 |
38 | 39 | 40 | 41 |
42 | 43 |
44 | 45 | 46 | 47 |
48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /web/WEB-INF/pages/adminView/viewEmployee.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> 2 | <%-- 3 | Created by IntelliJ IDEA. 4 | User: 孙建荣 5 | Date: 2016/11/14/014 6 | Time: 13:25 7 | To change this template use File | Settings | File Templates. 8 | --%> 9 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 10 | <% 11 | String path = request.getContextPath(); 12 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path; 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 |
序号${employee.id}
姓名 ${employee.userName}
班级 ${employee.className}
联系方式 ${employee.tel}
寝室号 ${employee.bedroom}
电话${student.tel}
寝室号${student.bedroom}
64 | 返回学生信息列表 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /web/WEB-INF/pages/userView/changePassword.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: 孙建荣 4 | Date: 2016/12/5/005 5 | Time: 20:21 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <% 10 | String path = request.getContextPath(); 11 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path; 12 | %> 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 46 | 47 | 54 | 55 | 56 | 57 | <%--
--%> 58 | <%----%> 59 | <%----%> 60 | <%----%> 61 | <%----%> 62 | <%----%> 63 | 64 | <%--
--%> 65 | 79 | 80 | 点击查看 81 | 82 | 83 | 84 |

创建模态框(Modal)

85 | 86 | 87 | 88 | 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /web/WEB-INF/pages/userView/studentDetail.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> 2 | <%-- 3 | Created by IntelliJ IDEA. 4 | User: 孙建荣 5 | Date: 2016/11/14/014 6 | Time: 13:25 7 | To change this template use File | Settings | File Templates. 8 | --%> 9 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 10 | <% 11 | String path = request.getContextPath(); 12 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path; 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 |
序号${employee.id}
姓名 ${employee.userName}
班级 ${employee.className}
联系方式 ${employee.tel}
寝室号 ${employee.bedroom}
电话${student.tel}
寝室号${student.bedroom}
64 | 返回个人主页 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /web/WEB-INF/pages/userView/user_index.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: 孙建荣 4 | Date: 2016/12/5/005 5 | Time: 12:47 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <% 10 | String path = request.getContextPath(); 11 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path; 12 | %> 13 | 14 | 15 | 用户主页 16 | 17 | 18 | 19 | 20 | 21 | 22 | 74 | 75 | 76 | 现在是

77 |
78 |

${userName}

,欢迎您 安全退出 79 |
80 | 个人中心 81 | 签到 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /web/WEB-INF/success.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: 孙建荣 4 | Date: 2016/11/12/012 5 | Time: 8:49 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 11 | 成功 12 | 13 | 14 |

成功

15 | 16 | 17 | -------------------------------------------------------------------------------- /web/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 404 10 | /error.jsp 11 | 12 | 13 | 14 | 15 | contextConfigLocation 16 | classpath:applicationContext*.xml 17 | 18 | 19 | 20 | org.springframework.web.context.ContextLoaderListener 21 | 22 | 23 | 24 | 25 | 26 | 27 | encodingFilter 28 | org.springframework.web.filter.CharacterEncodingFilter 29 | 30 | encoding 31 | UTF-8 32 | 33 | 34 | forceEncoding 35 | true 36 | 37 | 38 | 39 | 40 | encodingFilter 41 | /* 42 | 43 | 44 | 45 | 46 | DispatcherServlet 47 | org.springframework.web.servlet.DispatcherServlet 48 | 49 | contextConfigLocation 50 | classpath:applicationContext-SpringMvc.xml 51 | 52 | 1 53 | 54 | 55 | 56 | 57 | DispatcherServlet 58 | / 59 | 60 | 61 | 62 | 63 | 64 | 65 | openSession 66 | org.springframework.orm.hibernate4.support.OpenSessionInViewFilter 67 | 68 | 69 | openSession 70 | /* 71 | 72 | 73 | 74 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /web/common/common.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: 孙建荣 4 | Date: 2016/12/1/001 5 | Time: 21:04 6 | 这是一个包含头的jsp文件 7 | --%> 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /web/common/footer.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: 孙建荣 4 | Date: 2016/12/1/001 5 | Time: 19:36 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | html 10 | 11 | 12 | 13 | 15 | 16 | Foot 17 | 18 | 19 | 20 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /web/common/welcome.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: 孙建荣 4 | Date: 2016/12/1/001 5 | Time: 19:37 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <% 10 | String path = request.getContextPath(); 11 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path; 12 | %> 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /web/css/error.css: -------------------------------------------------------------------------------- 1 | /* 搜集整理 www.198zone.com */ 2 | body, div { 3 | margin: 0; 4 | padding: 0; 5 | } 6 | body { 7 | background: url("../images/error_bg.jpg") repeat-x scroll 0 0 #67ACE4; 8 | } 9 | #container { 10 | margin: 0 auto; 11 | padding-top: 50px; 12 | text-align: center; 13 | width: 560px; 14 | } 15 | #container img { 16 | border: medium none; 17 | margin-bottom: 50px; 18 | } 19 | #container .error { 20 | height: 200px; 21 | position: relative; 22 | } 23 | #container .error img { 24 | bottom: -50px; 25 | position: absolute; 26 | right: -50px; 27 | } 28 | #container .msg { 29 | margin-bottom: 65px; 30 | } 31 | #cloud { 32 | background: url("../images/error_cloud.png") repeat-x scroll 0 0 transparent; 33 | bottom: 0; 34 | height: 170px; 35 | position: absolute; 36 | width: 100%; 37 | } -------------------------------------------------------------------------------- /web/error.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: 孙建荣 4 | Date: 2016/11/10/010 5 | Time: 22:48 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 11 | 错误页面 12 | 13 | 14 | 15 | 16 | 17 | 18 |
20 | 21 |

22 | 24 |

25 |
26 |
27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /web/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sjr7/employeeManager/f4dc765473c23e2dd458fbce1c53a84f791ccec0/web/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /web/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sjr7/employeeManager/f4dc765473c23e2dd458fbce1c53a84f791ccec0/web/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /web/images/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sjr7/employeeManager/f4dc765473c23e2dd458fbce1c53a84f791ccec0/web/images/3.jpg -------------------------------------------------------------------------------- /web/images/attend.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sjr7/employeeManager/f4dc765473c23e2dd458fbce1c53a84f791ccec0/web/images/attend.png -------------------------------------------------------------------------------- /web/images/banner - Copy.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sjr7/employeeManager/f4dc765473c23e2dd458fbce1c53a84f791ccec0/web/images/banner - Copy.jpg -------------------------------------------------------------------------------- /web/images/banner.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sjr7/employeeManager/f4dc765473c23e2dd458fbce1c53a84f791ccec0/web/images/banner.jpg -------------------------------------------------------------------------------- /web/images/error/404.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sjr7/employeeManager/f4dc765473c23e2dd458fbce1c53a84f791ccec0/web/images/error/404.png -------------------------------------------------------------------------------- /web/images/error/404_msg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sjr7/employeeManager/f4dc765473c23e2dd458fbce1c53a84f791ccec0/web/images/error/404_msg.png -------------------------------------------------------------------------------- /web/images/error/404_to_index.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sjr7/employeeManager/f4dc765473c23e2dd458fbce1c53a84f791ccec0/web/images/error/404_to_index.png -------------------------------------------------------------------------------- /web/images/error/error_bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sjr7/employeeManager/f4dc765473c23e2dd458fbce1c53a84f791ccec0/web/images/error/error_bg.jpg -------------------------------------------------------------------------------- /web/images/error/error_cloud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sjr7/employeeManager/f4dc765473c23e2dd458fbce1c53a84f791ccec0/web/images/error/error_cloud.png -------------------------------------------------------------------------------- /web/images/manage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sjr7/employeeManager/f4dc765473c23e2dd458fbce1c53a84f791ccec0/web/images/manage.png -------------------------------------------------------------------------------- /web/images/user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sjr7/employeeManager/f4dc765473c23e2dd458fbce1c53a84f791ccec0/web/images/user.png -------------------------------------------------------------------------------- /web/images/view.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sjr7/employeeManager/f4dc765473c23e2dd458fbce1c53a84f791ccec0/web/images/view.png -------------------------------------------------------------------------------- /web/index.jsp: -------------------------------------------------------------------------------- 1 | <%--@elvariable id="error" type=""--%> 2 | <%-- 3 | Created by IntelliJ IDEA. 4 | User: 孙建荣 5 | Date: 2016/11/14/014 6 | Time: 13:25 7 | To change this template use File | Settings | File Templates. 8 | --%> 9 | --------------------------------------------------------------------------------