基于ssm的考勤设备和考勤记录管理系统------(二)

 

(1)大体界面如下,主要包括了关键词搜索,分页查询功能,设备的增删改查

基于ssm的考勤设备和考勤记录管理系统------(二)_第1张图片

 

基于ssm的考勤设备和考勤记录管理系统------(二)_第2张图片

前端界面主要是用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文件。




  
    
    
    
    
    
    
    
  
 
 
  
    id, enroll_id, records_time, mode, intOut, event, device_serial_num
  
 
 
 
 
 
 
 
 
 
  
  
    delete from attendance_records
    where id = #{id,jdbcType=INTEGER}
  
 
  
    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 into attendance_records
    
     
      
        enroll_id,
      
      
        records_time,
      
      
        mode,
      
      
        intOut,
      
      
        event,
      
      
        device_serial_num,
      
    
    
    
      
        #{enrollId,jdbcType=INTEGER},
      
      
        #{recordsTime,jdbcType=TIMESTAMP},
      
      
        #{mode,jdbcType=INTEGER},
      
      
        #{intout,jdbcType=INTEGER},
      
      
        #{event,jdbcType=INTEGER},
      
      
        #{deviceSerialNum,jdbcType=VARCHAR},
      
    
  
  
 
  
    update attendance_records
    
      
        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 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}
  

对应的映射接口类

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 selectAll();
    
    List selectLogByEnrollIdAndTime(@Param("enrollId")int enrollId,@Param("recordsTime")String recordsTime);
    
    List selectByEnrollId(int enrollId);
    
    List 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 selectAll();
    
    List selectLogByEnrollIdAndTime(int enrollId,String recordsTime);
    
    List selectByEnrollId(int enrollId);
    
    List 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 selectAll() {
		// TODO Auto-generated method stub
		return attandenceRecordsMapper.selectAll();
	}

	@Override
	public List selectLogByEnrollIdAndTime(int enrollId,
			String recordsTime) {
		// TODO Auto-generated method stub
		return attandenceRecordsMapper.selectLogByEnrollIdAndTime(enrollId, recordsTime);
	}

	@Override
	public List selectByEnrollId(int enrollId) {
		// TODO Auto-generated method stub
		return attandenceRecordsMapper.selectByEnrollId(enrollId);
	}

	@Override
	public List 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 list = attandenceRecordsService.selectAll();
	//	System.out.println("打卡记录" + list);
		PageInfo pageInfo = new PageInfo(
				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 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);
		Listlist=new ArrayList();
		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);
		}
		PageInfopageInfo=new PageInfo(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");
%>




Fingerprint Device Auto Data Manage System












	

	
Operation
    
UserID RecordsTime Mode InOut Event DeviceID

先到这里,下一篇继续

你可能感兴趣的:(spring,Mybatis)