作者 yangfu

Merge branch 'dev' of http://gitlab.fjmaimaimai.com/allied-creation/allied-creat…

…ion-manufacture into dev
... ... @@ -12,6 +12,8 @@ var (
REPOSITORY_CACHE_EXPIRE = 30 * 60
REDIS_ADDRESS = ""
// redis 考勤机打卡消息队列
REDIS_ZKTECO_KEY = "allied-creation-zkteco"
)
func init() {
... ...
package domain
import "time"
type DeviceZkTeco struct {
Sn string `json:"sn"` // 设备号
UserNo string `json:"userNo"` // 用户编码
ActionTime time.Time `json:"actionTime"` // 操作时间
}
... ...
package controllers
import (
"encoding/json"
"github.com/linmadan/egglib-go/web/beego"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/redis"
"strings"
"time"
)
type DeviceZKTecoController struct {
beego.BaseController
}
func (controller *DeviceZKTecoController) PostCdata() {
body := controller.Ctx.Input.RequestBody
sn := controller.Ctx.Input.Query("SN")
//table := controller.Ctx.Input.Query("table")
bodyList := strings.Split(string(body), "\t")
data := &domain.DeviceZkTeco{
Sn: sn,
}
if len(bodyList) > 2 {
data.UserNo = bodyList[0]
//转成时间格式
mTime, err := time.ParseInLocation("2006-01-02 15:04:05", bodyList[1], time.Local)
if err == nil {
data.ActionTime = mTime
mBytes, _ := json.Marshal(data)
redis.GetRedis().LPush(constant.REDIS_ZKTECO_KEY, mBytes)
}
}
controller.Response(data, nil)
}
func (controller *DeviceZKTecoController) GetCdata() {
//sn := controller.Ctx.Input.Query("SN")
}
func (controller *DeviceZKTecoController) GetRequest() {
}
func (controller *DeviceZKTecoController) Ping() {
controller.Ctx.WriteString("OK")
}
... ...
... ... @@ -14,4 +14,10 @@ func init() {
web.Router("/devices/", &controllers.DeviceController{}, "Get:ListDevice")
web.Router("/devices/search", &controllers.DeviceController{}, "Post:SearchDevice")
web.Router("/devices/batch-add", &controllers.DeviceController{}, "Post:BatchAddDevice")
//考勤机
web.Router("/zkteco/iclock/cdata", &controllers.DeviceZKTecoController{}, "Post:PostCdata")
web.Router("/zkteco/iclock/cdata", &controllers.DeviceZKTecoController{}, "Get:GetCdata")
web.Router("/zkteco/iclock/getrequest", &controllers.DeviceZKTecoController{}, "Get:GetRequest")
web.Router("/zkteco/iclock/ping",&controllers.DeviceZKTecoController{},"Get:Ping")
}
... ...