device_zkteco_controller.go
1.6 KB
1
2
3
4
5
6
7
8
9
10
11
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
49
50
51
52
53
54
package controllers
import (
"github.com/linmadan/egglib-go/web/beego"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/domainService"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log"
"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(domain.TaskDeviceZkTecoReport(), mBytes)
domainService.SendDeviceZkTecoReportJob(data)
} else {
data.ActionTime = time.Now()
domainService.SendDeviceZkTecoReportJob(data)
log.Logger.Debug(err.Error() + "data:" + bodyList[1])
}
}
controller.Response(data, nil)
}
func (controller *DeviceZKTecoController) GetCdata() {
//sn := controller.Ctx.Input.Query("SN")
controller.Ctx.WriteString("OK")
}
func (controller *DeviceZKTecoController) GetRequest() {
//controller.Ctx.WriteString("C:11:DATA\tQUERY\tUSERINFO\tPIN=10086")
controller.Ctx.WriteString("OK")
}
func (controller *DeviceZKTecoController) Ping() {
controller.Ctx.WriteString("OK")
}