(1)大体界面如下,主要包括了关键词搜索,分页查询功能,设备的增删改查
前端界面主要是用bootstrap框架开发的。表格的自动刷新和模态框
(2)这个过程中建数据库,
/*
SQLyog Ultimate v12.5.0 (64 bit)
MySQL - 5.7.20-log : Database - fingerdb
*********************************************************************
*/
/*!40101 SET NAMES utf8 */;
/*!40101 SET SQL_MODE=''*/;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/`fingerdb` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin */;
USE `fingerdb`;
/*Table structure for table `attendance_records` */
DROP TABLE IF EXISTS `attendance_records`;
CREATE TABLE `attendance_records` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`enroll_id` int(11) DEFAULT NULL,
`records_time` datetime DEFAULT NULL,
`mode` int(11) DEFAULT NULL,
`intOut` int(11) DEFAULT NULL,
`event` int(11) DEFAULT NULL,
`device_serial_num` varchar(50) COLLATE utf8mb4_bin DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=40 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
/*Data for the table `attendance_records` */
insert into `attendance_records`(`id`,`enroll_id`,`records_time`,`mode`,`intOut`,`event`,`device_serial_num`) values
(1,1,'2019-09-23 14:16:13',6,0,0,'ZX0066827779'),
(2,1,'2019-09-23 14:16:19',6,0,0,'ZX0066827779'),
(3,2,'2019-09-23 15:01:32',1,0,0,'ZXNG0729369'),
(4,2,'2019-09-23 15:01:35',1,0,0,'ZXNG0729369'),
(5,1,'2019-09-23 15:01:40',1,0,0,'ZXNG0729369'),
(6,1,'2019-09-23 15:13:45',1,0,0,'ZXNG0729369'),
(7,1,'2019-09-23 15:15:26',1,0,0,'ZXNG0729369'),
(8,1,'2019-09-23 15:15:26',1,0,0,'ZXNG0729369'),
(9,1,'2019-09-23 15:16:53',1,0,0,'ZXNG0729369'),
(10,3,'2019-09-23 15:16:55',1,0,0,'ZXNG0729369'),
(11,1,'2019-09-23 15:17:48',1,0,0,'ZXNG0729369'),
(12,1,'2019-09-23 15:17:50',1,0,0,'ZXNG0729369'),
(13,1,'2019-09-23 15:17:52',1,0,0,'ZXNG0729369'),
(14,3,'2019-09-23 15:17:56',1,0,0,'ZXNG0729369'),
(15,3,'2019-09-23 15:17:58',1,0,0,'ZXNG0729369'),
(16,1,'2019-09-23 15:18:01',1,0,0,'ZXNG0729369'),
(17,1,'2019-09-23 15:18:03',1,0,0,'ZXNG0729369'),
(18,3,'2019-09-23 15:18:05',1,0,0,'ZXNG0729369'),
(19,3,'2019-09-23 15:18:08',1,0,0,'ZXNG0729369'),
(20,1,'2019-09-23 15:18:24',1,0,0,'ZXNG0729369'),
(21,1,'2019-09-23 15:18:24',1,0,0,'ZXNG0729369'),
(22,1,'2019-09-23 15:18:27',1,0,0,'ZXNG0729369'),
(23,1,'2019-09-23 15:18:27',1,0,0,'ZXNG0729369'),
(24,1,'2019-09-23 15:18:32',1,0,0,'ZXNG0729369'),
(25,1,'2019-09-23 15:18:36',1,0,0,'ZXNG0729369'),
(26,1,'2019-09-23 15:18:36',1,0,0,'ZXNG0729369'),
(27,1,'2019-09-23 15:18:39',1,0,0,'ZXNG0729369'),
(28,1,'2019-09-23 15:18:41',1,0,0,'ZXNG0729369'),
(29,1,'2019-09-23 15:18:43',1,0,0,'ZXNG0729369'),
(30,1,'2019-09-23 15:18:43',1,0,0,'ZXNG0729369'),
(31,3,'2019-09-23 15:18:48',1,0,0,'ZXNG0729369'),
(32,1,'2019-09-23 15:18:54',1,0,0,'ZXNG0729369'),
(33,1,'2019-09-23 15:18:57',1,0,0,'ZXNG0729369'),
(34,4,'2019-09-23 15:19:26',1,0,0,'ZXNG0729369'),
(35,1,'2019-09-23 15:19:31',1,0,0,'ZXNG0729369'),
(36,3,'2019-09-23 15:19:35',1,0,0,'ZXNG0729369'),
(37,2,'2019-09-23 15:19:42',1,0,0,'ZXNG0729369'),
(38,1,'2019-09-23 16:17:27',1,0,0,'ZXNG0729369'),
(39,1,'2019-09-23 16:17:35',6,0,0,'ZX0066827779');
/*Table structure for table `device` */
DROP TABLE IF EXISTS `device`;
CREATE TABLE `device` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`serial_num` varchar(50) COLLATE utf8mb4_bin DEFAULT NULL,
`device_name` varchar(50) COLLATE utf8mb4_bin DEFAULT NULL,
`area` varchar(50) COLLATE utf8mb4_bin DEFAULT NULL,
`status` int(11) DEFAULT NULL,
`province` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
/*Data for the table `device` */
insert into `device`(`id`,`serial_num`,`device_name`,`area`,`status`,`province`) values
(1,'ZX0066827779',NULL,NULL,0,NULL),
(2,'ZXNG0729369',NULL,NULL,0,NULL),
(4,'ZX656477889','ee','ee',0,0),
(5,'ZXLD88888889',NULL,NULL,0,NULL),
(6,'ZXLD897988533',NULL,NULL,1,NULL);
/*Table structure for table `enrollinfo` */
DROP TABLE IF EXISTS `enrollinfo`;
CREATE TABLE `enrollinfo` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`enroll_id` int(11) DEFAULT NULL,
`backupnum` int(11) DEFAULT NULL,
`signatures` text COLLATE utf8mb4_bin,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
/*Data for the table `enrollinfo` */
insert into `enrollinfo`(`id`,`enroll_id`,`backupnum`,`signatures`) values
(9,1,0,'c5355b1694f84a6d0fc3c6039a89831517ffd90431f62b91e16a360830f7238ae070148632f7e3c1e07415041fe93b9af90308453cf5d3d1e0ea35472ff8bc11d8b9d702b6f5fc4d0f0996863af72446e0742505bd8d1c92ffc5fb42c08ce529fffe0f4440f8153df8b699081c88ad51ffd1fe08eaf4524d0eb2484776f53a59004da6075ef43aca18cfb6c702f50ae5ecee764c7de5ab5a705347e126f68b5de9ac35c74bf403add84dc887a2f6e3a62807948542f4cbd9d8d5d747a5a8e4211fffd7c2bcf51cc6d81bc846c8f67d89e90db7c7be8d14daffffff421dc73a66ff761648b0f4ace5e8e0298d7df579c1e88bb6c40ef5d1e906b64684c033cbfd1f364743a5718c51ffffce026ec3f232d849a7c6e2f2f236eeb638c563f3d276004bc705c1920b3df8b24ad5a261f379facffb8d9478094de7c3c681e67705e9affbc8c4dfd5e5e1d87fb7c57046c609fdb9d904cc48b6220ffffec56e7298eee7c7c9c7eb4240dafebe29c45fd1ea45e887d9c2a94133c1f9fff8c3b440829df9fffe83a84062c1fffffdc25071747dc87a190546719ceed887f8cada4002adff3e1bc23f41852aefc9fa08(56)26db332987a13e13577338529436345218551695f8a525667140f052f7ff6f1f463f5bf48334756372342387b6331497fa9944c95855f2af74fff6f552f281f8ff87df352cf98ffffff26334f323594c51f3f2ffffff3f3fff8f8a6fffffffffffff22ffff0f(10)1e5b2333001512517b2300808862ae502030e741a346110005414a0002719e78f02a2130635142161203b751481d32b4ae51ef3021237361761e31c2ad712b571282bc63323762043162572624b278704e1a5031ba81895f7275ce709a6662928781f2695208ab60ba2663607681800024450461435f0627119301186502bd61ad0d3240dd7172094460c192094714714571b26e047789e2530d3515cca5882546e1aeb38c1524019c816b6421655391892f24457d9013021503120604090816111b0714170500181e1c1d210c190d242527292db46e'),
(10,2,0,'c53557038cb86aeae847b58483e79b41084bb50502f64b4e06ae460724ba1341ff76064299ea036d07c3c6c276f6cb9e108f958957b4e3a91fcdb5c5e9f603f6ee6e66496df69c2a5055870d9c7ad42d17d7dac5cfe48c5dff3e26c629f9b455e036070354e5645d200fb5c699f8048a2049768648e53cf6c80bc58445f664fdc89bb6d82ef73529e9220608c4bb653aaff1fb45a06aed1d0fcfdb55a56b05620fcbcb943ee5ad59d0cdc586c2eb4599bffe2ac4ba74a579fefe2802a9f78576083b6601aad7fdaa0749b74434e96dbd2f7806c43ef8e5d1e6b49685b5e87dfdd6d9b7489a8b0bf10fffd802a37b3cb507ffcd9d32e70619104377c3a7e7fe1d0820090bb3684e2de77fc90e38e65619e041c7c3cc8b7ca197e9f943c68b74dda7effa044ea8c64afdaff8c9a7876671f93e08453e756669d7fb96426e45832de7fff847cf444c2eff3e3745c243f4ddff7e3982c543e525febe1cc247442d71dfc3f643bb4a6e05efffd811aa4a462d67ffd70a3c4a7636f935fa5179485e91fbfeba0a09478ea557d77a199c4766b1fb7e4a941f49c249ff3e0502974a72b6efffd44007469266ff3e37c3(56)38c2146683242f257370687516616a573554172328399952f25b226431d678446727ac63262635364e32f6f601f2f223f21c1fff1f5289286fffff5ffd30461294326543f332829ffffff8f2cf383531f403fffff351f2f8fffff1f4ffff6517f32540784f1ff6fff133f1127f08(2)1e57da64442396617b4103347073b05e10338762fa0e2261c266af4440201760714d12020052aa1b2073d762b2504402c570400d12123051c248100116718f0e2322d6512d0a2241ea51491a12949851506d133150616b1d0160906111530212e361f96934858a60b8562082dba1471055c2ca511c2701518392802f12047e81ec20017136930e60543288609b5b056002b5602633309d80a438004123821b760504e9a1010a1020bab1d15d012616a281012120eda10d08100f1705070b0c18010e14021a190409001f272003121c2423112f152354'),
(11,3,0,'c5256406d0f9ebaae738284353f91bede883d8824bf9ccc5e043d74354f8451dd07bba4243fa3525e10406c343f9a5cdd04228c44088de19f887f64358e78ac9e7fe198459f71c09e7fbfb42b84a7545198a26c64686ddc107c7f6c4d0e8429aff43f9c255e8a29107fe1a04d1f7031df83fd9c25cbadb89cf7fb7c450dadbc1004bc684426ac545f885f6433eb7d60d17cbfb424eab6bf2104fc6063eabccc5d08dd745b9da35aa26c42884b74a1e0dfffe1ac4b749365e2ffe27c46b4b2ad9dfff97866b4b62eddfff96c7664be35d07ff9686e84c4be9e46df54c6e4d1429707f57a22b4d3c81f921f6de364ca4d9f8d5d6c7ac4d84f50fff3a83ac4ccd390ffe6881397aade5d8c5c886ae45153dfffff6c1364badf5f905f805344a56a1f949f8465847da7deffe1ac3(184)424fb229a56726a59343f2872732f72126f542f5f5ff210a66ffffff9ff5f6ff49425fb2ff3fe3153fbf5fff5f3793f464a4f280ffffff6fff256933582264ff4f04f4f494642f0f(40)1e647b0e5471e7709a0f1675ed806f1a1220c8607b2145458da05339420140612c7111615180ac2e01636560ea1d3190bd61c36510e08b81431565e7ceb0567620b18a617a6731708d817a154371b071cc152161bd718a180092c781204d0140e1a1d22e200173602b5b1172ab53151e52d2bcb0af521131d561c41556c2ce61fc5e2242b36132532004c071556642c579810f6b1135718077751460b0782f5b114041670f160139ca913b571268d1a1252822e58b81020104030900100f14081205130e2015061a111d0a1916221f1b1c070c232a16'),
(12,4,0,'c50d6a010cb84be5ff39f68102b61c06ff32284484b9042aeffe054178b6744de747b78301b5fc61eef218c47cb7bc82e083d8c484b97caae7ffc74375b6ccd2e087ca846eb765b5e849b9c3edb7c5d906f229440ab91c55ff41f54067877e4df84bf90703862399ff7e1705(376)e155223343444231369028926858743a63(95)096ac20832032581581e22a5a8a1971695b2c890ca2130829c706b30a17265504b4f2179c0700a19a270c181ad08315604604c1d0561b081(126)050708030a06040001(21)e554');
/*Table structure for table `machine_command` */
DROP TABLE IF EXISTS `machine_command`;
CREATE TABLE `machine_command` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`command_name` varchar(50) COLLATE utf8mb4_bin DEFAULT NULL,
`params` varchar(50) COLLATE utf8mb4_bin DEFAULT NULL,
`device_sn` varchar(50) COLLATE utf8mb4_bin DEFAULT NULL,
`status` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
/*Data for the table `machine_command` */
/*Table structure for table `person` */
DROP TABLE IF EXISTS `person`;
CREATE TABLE `person` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) COLLATE utf8mb4_bin DEFAULT NULL,
`rollid` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
/*Data for the table `person` */
insert into `person`(`id`,`name`,`rollid`) values
(1,'',0),
(2,'WL',0),
(3,'',0),
(4,'',0);
/*Table structure for table `province` */
DROP TABLE IF EXISTS `province`;
CREATE TABLE `province` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`province` varchar(50) COLLATE utf8mb4_bin DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
/*Data for the table `province` */
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
新建数据库表结构之后,必须编写mybatis的mapper文件,attendanceRecords的mapper文件。
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.timmy.mapper.AttandenceRecordsMapper" >
<resultMap id="BaseResultMap" type="com.timmy.entity.AttandenceRecords" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="enroll_id" property="enrollId" jdbcType="INTEGER" />
<result column="records_time" property="recordsTime" jdbcType="TIMESTAMP" />
<result column="mode" property="mode" jdbcType="INTEGER" />
<result column="intOut" property="intout" jdbcType="INTEGER" />
<result column="event" property="event" jdbcType="INTEGER" />
<result column="device_serial_num" property="deviceSerialNum" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, enroll_id, records_time, mode, intOut, event, device_serial_num
</sql>
<select id="selectAll" resultMap="BaseResultMap">
select id, enroll_id, records_time, mode, intOut, event,
device_serial_num from attendance_records order by records_time desc
</select>
<select id="selectByEnrollId" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select id, enroll_id, records_time, mode, intOut, event,
device_serial_num from attendance_records where enroll_id=#{enrollId,jdbcType=INTEGER}
</select>
<select id="selectByTime" resultMap="BaseResultMap">
select id, enroll_id, records_time, mode, intOut, event,
device_serial_num from attendance_records where records_time between #{startTime,jdbcType=TIMESTAMP} and #{toTime,jdbcType=TIMESTAMP}
</select>
<select id="selectLogByEnrollIdAndTime" resultMap="BaseResultMap">
select id, enroll_id, records_time, mode, intOut, event,
device_serial_num from attendance_records where enroll_id=#{enrollId,jdbcType=INTEGER}
and records_time = #{recordsTime,jdbcType=TIMESTAMP}
</select>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from attendance_records
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from attendance_records
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.timmy.entity.AttandenceRecords" >
insert into attendance_records (enroll_id, records_time,
mode, intOut, event,
device_serial_num)
values ( #{enrollId,jdbcType=INTEGER}, #{recordsTime,jdbcType=TIMESTAMP},
#{mode,jdbcType=INTEGER}, #{intout,jdbcType=INTEGER}, #{event,jdbcType=INTEGER},
#{deviceSerialNum,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.timmy.entity.AttandenceRecords" >
insert into attendance_records
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="enrollId != null" >
enroll_id,
</if>
<if test="recordsTime != null" >
records_time,
</if>
<if test="mode != null" >
mode,
</if>
<if test="intout != null" >
intOut,
</if>
<if test="event != null" >
event,
</if>
<if test="deviceSerialNum != null" >
device_serial_num,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="enrollId != null" >
#{enrollId,jdbcType=INTEGER},
</if>
<if test="recordsTime != null" >
#{recordsTime,jdbcType=TIMESTAMP},
</if>
<if test="mode != null" >
#{mode,jdbcType=INTEGER},
</if>
<if test="intout != null" >
#{intout,jdbcType=INTEGER},
</if>
<if test="event != null" >
#{event,jdbcType=INTEGER},
</if>
<if test="deviceSerialNum != null" >
#{deviceSerialNum,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.timmy.entity.AttandenceRecords" >
update attendance_records
<set >
<if test="enrollId != null" >
enroll_id = #{enrollId,jdbcType=INTEGER},
</if>
<if test="recordsTime != null" >
records_time = #{recordsTime,jdbcType=TIMESTAMP},
</if>
<if test="mode != null" >
mode = #{mode,jdbcType=INTEGER},
</if>
<if test="intout != null" >
intOut = #{intout,jdbcType=INTEGER},
</if>
<if test="event != null" >
event = #{event,jdbcType=INTEGER},
</if>
<if test="deviceSerialNum != null" >
device_serial_num = #{deviceSerialNum,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.timmy.entity.AttandenceRecords" >
update attendance_records
set enroll_id = #{enrollId,jdbcType=INTEGER},
records_time = #{recordsTime,jdbcType=TIMESTAMP},
mode = #{mode,jdbcType=INTEGER},
intOut = #{intout,jdbcType=INTEGER},
event = #{event,jdbcType=INTEGER},
device_serial_num = #{deviceSerialNum,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
对应的映射接口类
package com.timmy.mapper;
import com.timmy.entity.AttandenceRecords;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface AttandenceRecordsMapper {
int deleteByPrimaryKey(Integer id);
int insert(AttandenceRecords record);
int insertSelective(AttandenceRecords record);
AttandenceRecords selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(AttandenceRecords record);
int updateByPrimaryKey(AttandenceRecords record);
List<AttandenceRecords> selectAll();
List<AttandenceRecords> selectLogByEnrollIdAndTime(@Param("enrollId")int enrollId,@Param("recordsTime")String recordsTime);
List<AttandenceRecords> selectByEnrollId(int enrollId);
List<AttandenceRecords> selectByTime(@Param("startTime")String startTime,@Param("toTime")String toTime);
}
service
package com.timmy.service;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.timmy.entity.AttandenceRecords;
public interface AttandenceRecordsService {
int deleteByPrimaryKey(Integer id);
int insert(AttandenceRecords record);
int insertSelective(AttandenceRecords record);
AttandenceRecords selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(AttandenceRecords record);
int updateByPrimaryKey(AttandenceRecords record);
List<AttandenceRecords> selectAll();
List<AttandenceRecords> selectLogByEnrollIdAndTime(int enrollId,String recordsTime);
List<AttandenceRecords> selectByEnrollId(int enrollId);
List<AttandenceRecords> selectByTime(String startTime,String toTime);
}
package com.timmy.serviceImpl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.timmy.entity.AttandenceRecords;
import com.timmy.mapper.AttandenceRecordsMapper;
import com.timmy.service.AttandenceRecordsService;
@Service
public class AttandenceRecordsServiceImpl implements AttandenceRecordsService{
@Autowired
AttandenceRecordsMapper attandenceRecordsMapper;
@Override
public int deleteByPrimaryKey(Integer id) {
// TODO Auto-generated method stub
return attandenceRecordsMapper.deleteByPrimaryKey(id);
}
@Override
public int insert(AttandenceRecords record) {
// TODO Auto-generated method stub
return attandenceRecordsMapper.insert(record);
}
@Override
public int insertSelective(AttandenceRecords record) {
// TODO Auto-generated method stub
return attandenceRecordsMapper.insertSelective(record);
}
@Override
public AttandenceRecords selectByPrimaryKey(Integer id) {
// TODO Auto-generated method stub
return attandenceRecordsMapper.selectByPrimaryKey(id);
}
@Override
public int updateByPrimaryKeySelective(AttandenceRecords record) {
// TODO Auto-generated method stub
return attandenceRecordsMapper.updateByPrimaryKey(record);
}
@Override
public int updateByPrimaryKey(AttandenceRecords record) {
// TODO Auto-generated method stub
return attandenceRecordsMapper.updateByPrimaryKey(record);
}
@Override
public List<AttandenceRecords> selectAll() {
// TODO Auto-generated method stub
return attandenceRecordsMapper.selectAll();
}
@Override
public List<AttandenceRecords> selectLogByEnrollIdAndTime(int enrollId,
String recordsTime) {
// TODO Auto-generated method stub
return attandenceRecordsMapper.selectLogByEnrollIdAndTime(enrollId, recordsTime);
}
@Override
public List<AttandenceRecords> selectByEnrollId(int enrollId) {
// TODO Auto-generated method stub
return attandenceRecordsMapper.selectByEnrollId(enrollId);
}
@Override
public List<AttandenceRecords> selectByTime(String startTime, String toTime) {
// TODO Auto-generated method stub
return attandenceRecordsMapper.selectByTime(startTime, toTime);
}
}
controller,
package com.timmy.controller;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.timmy.entity.AttandenceRecords;
import com.timmy.entity.Device;
import com.timmy.entity.DeviceStatus;
import com.timmy.entity.MachineCommand;
import com.timmy.entity.Msg;
import com.timmy.service.AttandenceRecordsService;
import com.timmy.service.MachineCommandService;
import com.timmy.websocket.WebSocketPool;
@Controller
@RequestMapping("log")
public class LogController {
@Autowired
AttandenceRecordsService attandenceRecordsService;
@Autowired
MachineCommandService machineCommandService;
/*@RequestMapping(value = "queryLog", method = RequestMethod.GET)
public String queryLog(
@RequestParam(value = "pn", defaultValue = "1") Integer pn,
Model model) {
PageHelper.startPage(pn, 10);
List<AttandenceRecords> list = attandenceRecordsService.selectAll();
// System.out.println("打卡记录" + list);
PageInfo<AttandenceRecords> pageInfo = new PageInfo<AttandenceRecords>(
list, 10);
model.addAttribute("pageInfo", pageInfo);
return "loglist";
}*/
@RequestMapping("/queryLogs")
public String queryDevice() {
return "loglist2";
}
/*刷新设备列表*/
@RequestMapping(value="/logList")
@ResponseBody
public Msg refreshList(@RequestParam(value="pn",defaultValue="1") Integer pn) {
PageHelper.startPage(pn, 15);
List<AttandenceRecords> list = attandenceRecordsService.selectAll();
PageInfo page= new PageInfo(list,5);
return Msg.success().add("pageInfo", page);
}
@ResponseBody
@RequestMapping(value = "getLogData", method = RequestMethod.GET)
public Msg getAllLog(@RequestParam("deviceSn") String deviceSn,@RequestParam("beginTime")String beginTime,@RequestParam("endTime")String endTime) {
Boolean stn=true;
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
String time = sdf1.format(new Date());
String str ="{\"from\":\"" + beginTime + "\""+",\"to\":\"" + endTime + "\""+"}";
System.out.println("shuju"+str);
String from="2019-09-1";
String message="{\"cmd\":\"getalllog\",\"stn\":true,\"from\":\"" +beginTime+"\",\"to\":\""+endTime+"\"}";
String message1="{\"cmd\":\"getalllog\",\"stn\":true}";
DeviceStatus deviceStatus1=WebSocketPool.getDeviceStatus(deviceSn);
if(deviceStatus1!=null&&deviceStatus1.getStatus()==1){
deviceStatus1.setStatus(0);
updateDevice(deviceSn, deviceStatus1);
WebSocketPool.sendMessageToDeviceStatus(deviceSn, message);
return Msg.success();
}else{
MachineCommand command=new MachineCommand();
command.setCommandName("getalllog");
command.setDeviceSn(deviceSn);
command.setParams(str);
command.setStatus(0);
machineCommandService.insert(command);
return Msg.waitRun();
}
}
@RequestMapping(value = "/searchParameter", method = RequestMethod.GET)
public String searchByKeyword(@RequestParam(value="pn",defaultValue="1")Integer pn,@RequestParam(value="enrollId",defaultValue="0")int enrollId,
@RequestParam("starttime")String startTime,@RequestParam("totime")String toTime,Model model) {
System.out.println("shen"+enrollId);
PageHelper.startPage(pn, 15);
List<AttandenceRecords>list=new ArrayList<AttandenceRecords>();
if(enrollId!=0){
list=attandenceRecordsService.selectByEnrollId(enrollId);
System.out.println("shen4"+list);
}else if(enrollId==0){
System.out.println("开始时间"+startTime+"......结束时间"+toTime);
list=attandenceRecordsService.selectByTime(startTime, toTime);
System.out.println("shen5"+list);
}
PageInfo<AttandenceRecords>pageInfo=new PageInfo<AttandenceRecords>(list,10);
model.addAttribute("pageInfo", pageInfo);
return "loglist";
}
public void updateDevice(String sn, DeviceStatus deviceStatus) {
if (WebSocketPool.getDeviceStatus(sn) != null) {
WebSocketPool.removeDeviceStatus(sn);
WebSocketPool.addDeviceAndStatus(sn, deviceStatus);
} else {
WebSocketPool.addDeviceAndStatus(sn, deviceStatus);
}
}
}
前端页面
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
//response.setHeader("refresh","30");
%>
<!DOCTYPE html>
<html lang="en">
<head>
<base href="<%=basePath%>">
<title>Fingerprint Device Auto Data Manage System</title>
<link rel="stylesheet" href="css/bootstrap.min.css" />
<link rel="stylesheet" href="css/bootstrap-datetimepicker.min.css" />
<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript"
src="js/bootstrap-datetimepicker.zh-CN.js"></script>
</head>
<body>
<nav class="navbar navbar-inverse" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#" style="height: 92px;"> </a>
</div>
<div class="collapse navbar-collapse" id="example-navbar-collapse">
<ul class="nav navbar-nav navbar" style="margin: 1% 0 1% 34%;">
<li class="active"><a class="icon-bar" href="#"
style="background-color: #087b71"> <font
style="font-size: 31px; font-weight: bold; font-style: italic;">Welcome
to Fingerprint Device ADMS</font></a></li>
</ul>
<ul class="nav navbar-nav navbar-right" style="margin: 1% 0 1% 0%;">
</ul>
</div>
</div>
</nav>
<div class="container-fluid">
<div class="row">
<div class="col-sm-2">
<a href="#" class="list-group-item active"><span
class="glyphicon glyphicon-home"></span> Menu </a> <a
href="${pageContext.request.contextPath}/log/queryLogs"
class="list-group-item"> <span
class="glyphicon glyphicon-search" aria-hidden="true"> </span> Attendance
Log
</a> <a href="${pageContext.request.contextPath}/device/queryDevices"
class="list-group-item"> <span class="glyphicon glyphicon-user"
aria-hidden="true"> </span> Device Management
</a>
</div>
<!--左边菜单栏-->
<div class="col-sm-10">
<ol class="breadcrumb">
<li class="active">Menu</li>
<li class="active">Attendance Log</li>
</ol>
<div class="panel panel-default">
<div class="panel-heading">Operation</div>
<div class="panel-body">
<form role="form" class="form-inline"
action="${pageContext.request.contextPath }/log/searchParameter">
<div class="form-group">
<label for="name">Enrollid</label> <input type="text"
class="form-control" name="enrollId" id="idsearch"
placeholder="Input enrollId">
</div>
<div class="form-group">
<label>StartTime</label> <input type="text"
class="form-control form_datetime" id="startTime"
name="starttime">
</div>
<div class="form-group">
<label>EndTime</label>
<input type="text" class="form-control form_datetime"
id="toTime" name="totime" >
</div>
<div class="form-group">
<button type="submit" id="search_btn" class="btn btn-default">Start Search</button>
</div>
</form>
<div class="row">
<div class="col-md-6 col-md-offset-10">
<button class="btn btn-primary" id="getLogData_btn">Get_All_Log</button>
</div>
</div>
</div>
</div>
<!-- 列表展示 -->
<div class="table-responsive">
<form action="${pageContext.request.contextPath }/person/addCar"
method="post">
<table class="table table-hover table-striped" id="emps_table">
<thead>
<tr>
<th>UserID</th>
<th>RecordsTime</th>
<th>Mode</th>
<th>InOut</th>
<th>Event</th>
<th>DeviceID</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</form>
</div>
</div>
</div>
<!-- 分页 -->
<div class="row">
<!-- 显示分页文字信息 -->
<div class="col-md-6" id="page_info_area"></div>
<!-- 显示分页条信息 -->
<div class="col-md-4 col-md-offset-2" id="page_nav_area"></div>
</div>
</div>
<!-- 手动采集记录-->
<div class="modal fade" id="selectDeviceModal" tabindex="-1"
role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title">GetLogData</h4>
</div>
<div class="modal-body">
<form class="form-horizontal" id="form1">
<div class="form-group">
<label class="control-label col-xs-3">DeviceId</label>
<div class="col-sm-5">
<select class="form-control" name="deviceSn" id="getDeviceSn">
</select>
</div>
</div>
<div class="form-group">
<label for="lastname" class="col-sm-3 control-label">BeginTime:</label>
<div class="col-sm-5">
<input type="text" class="form-control form_datetime"
id="beginTime" name="createtime">
</div>
</div>
<div class="form-group">
<label for="lastname" class="col-sm-3 control-label">EndTime:</label>
<div class="col-sm-5">
<input type="text" class="form-control form_datetime"
id="endTime" name="createtime">
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">return</button>
<button type="button" class="btn btn-primary"
id="getDeviceSn_button">save</button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
<!-- 添加模态框(Modal)插件 -->
var totalRecord,currentPage;
$(function() {
to_page(1);
setInterval("to_page(1)", 10000);
$(".form_datetime").datetimepicker({
format : "yyyy-mm-dd",
autoclose : true,
todayBtn : true,
todayHighlight : true,
showMeridian : true,
pickerPosition : "bottom-left",
startView : 2,//月视图
minView : 2
//日期时间选择器所能够提供的最精确的时间选择视图
});
});
function to_page(pn) {
$.ajax({
url : "${pageContext.request.contextPath}/log/logList",
data : "pn=" + pn,
type : "GET",
success : function(result) {
//console.log(result);
// 1. 解析并显示员工数据
build_emp_table(result);
// 2. 解析并显示分类信息
buid_page_info(result);
// 3. 解析并显示分页条信息
build_page_nav(result);
}
});
}
//解析显示员工信息
function build_emp_table(result) {
$("#emps_table tbody").empty();
var emps = result.extend.pageInfo.list;
var i = result.extend.pageInfo.startRow;
$.each(emps, function(index, item) {
//alert(item.empName);
var idTd = $("<td></td>").append(item.enrollId);
var deviceSnTd = $("<td></td>").append(item.recordsTime);
var nameTd = $("<td></td>").append(item.mode);
var parameterTd = $("<td></td>").append(item.intout);
var provinceTd = $("<td></td>").append(item.event);
var statusTd = $("<td></td>").append(item.deviceSerialNum);
var uploadBtu = $("<button></button>").addClass(
"btn btn-info btn-sm upload_btu").append(
"<span></span>").append("uploadPersonToDevice");
//为编辑按钮添加一个自定义的属性,来表示当前的员工id
uploadBtu.attr("upload-id", item.id);
var delBtu = $("<button></button>").addClass(
"btn btn-danger btn-sm delete_btu").append(
"<span></span>").append("delete");
//为删除按钮添加一个自定义的属性,来表示当前的员工id
delBtu.attr("delete-id", item.id);
var btuTd = $("<td></td>").append(delBtu);
//append方法执行完后仍返回原来的元素
$("<tr></tr>").append(idTd).append(deviceSnTd).append(nameTd)
.append(parameterTd).append(provinceTd)
.append(statusTd).appendTo(
"#emps_table tbody");
})
}
//解析显示分页信息
function buid_page_info(result) {
$("#page_info_area").empty();
var pageH = $("<h4 style=\"margin: 0 0 0 38%;\"></h4>").append(
"Current Page:" + result.extend.pageInfo.pageNum
+ ", Count Page:" + result.extend.pageInfo.pages
+ ", All Records:" + result.extend.pageInfo.total);
$("#page_info_area").append(pageH);
totalRecord = result.extend.pageInfo.pages;
currentPage = result.extend.pageInfo.pageNum;
}
//解析显示分页条信息
function build_page_nav(result) {
$("#page_nav_area").empty();
var ul = $("<ul></ul>").addClass("pagination");
var firstPageLi = $("<li></li>").append(
$("<a></a>").append("FirstPage"));
var prePageLi = $("<li></li>").append(
$("<a></a>").append("«"));
if (result.extend.pageInfo.hasPreviousPage == false) {
prePageLi.addClass("disabled");
} else {
//添加单击事件
prePageLi.click(function() {
to_page(result.extend.pageInfo.pageNum - 1);
});
firstPageLi.click(function() {
to_page(1);
});
}
var nextPageLi = $("<li></li>").append(
$("<a></a>").append("»"));
var lastPageLi = $("<li></li>").append(
$("<a></a>").append("LastPage"));
if (result.extend.pageInfo.hasNextPage == false) {
nextPageLi.addClass("disabled");
} else {
//添加单击事件
nextPageLi.click(function() {
to_page(result.extend.pageInfo.pageNum + 1);
});
lastPageLi.click(function() {
to_page(result.extend.pageInfo.pages);
});
}
//添加首页和前一页
ul.append(firstPageLi).append(prePageLi);
$.each(result.extend.pageInfo.navigatepageNums, function(index,
item) {
var numLi = $("<li></li>").append($("<a></a>").append(item));
//添加每一个遍历出来的页码
if (item == result.extend.pageInfo.pageNum) {
numLi.addClass("active");
}
numLi.click(function() {
to_page(item);
});
ul.append(numLi);
});
//添加最后一页和末页
ul.append(nextPageLi).append(lastPageLi);
//把 ul 添加到 navElv 中去
var navElv = $("<nav></nav>").append(ul);
navElv.appendTo("#page_nav_area");
}
//手动采集记录
$("#getLogData_btn")
.click(
function() {
//初始化模态框
//也可以这么做
getDevice("#selectDeviceModal #getDeviceSn");
$("#selectDeviceModal").modal({
backdrop : "static"
});
//获取用户id列表
$("#getDeviceSn_button")
.click(
function() {
var deviceSn = document
.getElementById('getDeviceSn').value;
var beginTime = document
.getElementById('beginTime').value;
var endTime = document
.getElementById('endTime').value;
$
.ajax({
url : "${pageContext.request.contextPath}/log/getLogData?deviceSn="
+ deviceSn
+ "&beginTime="
+ beginTime
+ "&endTime="
+ endTime,
type : "GET",
success : function(
result) {
if (result.code == 100) {
$(
"#selectDeviceModal")
.modal(
'hide');
alert(result.msg);
//回到当前页
window.location.href = "${pageContext.request.contextPath}/log/queryLogs";
} else {
alert("Has been insert into DB,waiting execute!");
}
}
});
});
});
function getDevice(ele) {
//alert("shebei")
$(ele).empty();
$.ajax({
url : "${pageContext.request.contextPath}/device/deviceSn",
type : "GET",
success : function(result) {
$.each(result.extend.device, function() {
var optionEle = $("<option></option>").append(
this.serialNum).attr("value", this.serialNum);
optionEle.appendTo(ele);
})
}
});
}
</script>
<!-- 底部页脚部分 -->
<div class="footer">
<p class="text-center">2019 © Timmy.</p>
</div>
</body>
</html>
先到这里,下一篇继续