zkteco

package module
v0.0.0-...-66bc961 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2018 License: MIT Imports: 8 Imported by: 0

README

zkteco

Build Status Go Report Card GoDoc

Package zkteco parses the XLS files outputted from zkteco device(KQ803) and update the employee attendance data in Redis.

Data in Redis
  • The attendance data of each emplyee are stored in a Redis Hash.

  • Key is kaoqin:EmplyeeName. e.g. kaoqin:Jack.

      redis-cli --raw
      127.0.0.1:6379> keys *
      kaoqin:Jack
      kaoqin:Bob
      kaoqin:Mary 
    
  • Field of the Redis Hash has two type.

    • date:in represents the clock in time of the date. Date format is YYYY-MM-DD.

    • date:out represents the clock out time of the date.

        127.0.0.1:6379> HGETALL kaoqin:Jack
        2017-07-01:in
        18:02
        2017-07-02:in
        16:59
        2017-07-03:in
        18:17
        2017-07-04:in
        08:58
        2017-07-07:in
        11:56
        2017-07-07:out
        20:36
      
    • If there's only one clock time for a date, it will be recognized as clock in time.

  • Value of each field is the clock in / out time. Time format: HH:MM.

Examples
    // Open a DB by given Redis address and password.
    db := zkteco.Open(":6379", "")

    // Get absolute path of example attendance xls file.
    f := "/home/xx/campus-a.xls"

    // Update attendance.
    db.UpdateAttendance(f)
Documentation
Requirements
License

Documentation

Overview

Package zkteco parses the XLS files outputted from zkteco device(KQ803) and update the employee attendance data in Redis.

Example
package main

import (
	"log"
	"path"

	"github.com/northbright/pathhelper"
	"github.com/northbright/zkteco"
)

func main() {
	// Set debug mode to true.
	zkteco.SetDebugMode(true)

	// Open a DB by given Redis address and password.
	db := zkteco.Open(":6379", "")

	// Get absolute path of example attendance xls file.
	f, _ := pathhelper.GetCurrentExecDir()
	f = path.Join(f, "files/campus-a.xls")

	// Update attendance.
	err := db.UpdateAttendance(f)
	if err != nil {
		log.Printf("db.UpdateAttendance() failed: %v", err)
		return
	}

	log.Printf("db.UpdateAttendance ok")
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRedisConn

func GetRedisConn(redisAddr, redisPassword string) (redis.Conn, error)

GetRedisConn gets the Redis connection.

func IsDebugMode

func IsDebugMode() bool

IsDebugMode returns if it's in debug mode or not.

func SetDebugMode

func SetDebugMode(f bool)

SetDebugMode sets debug mode.

Types

type DB

type DB struct {
	// RedisAddr is Redis address. e.g. ":6379".
	RedisAddr string
	// RedisPassword is Redis password.
	RedisPassword string
}

DB represents zkteco attendance database.

func Open

func Open(redisAddr, redisPassword string) *DB

Open opens a DB which contains zkteco attendance data.

func (*DB) UpdateAttendance

func (db *DB) UpdateAttendance(xlsFile string) error

UpdateAttendance updates employees' attendance data by XLS file which is outputted by zkteco device.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL