device_zkteco_controller.go
1.2 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
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"
"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.SenDeviceZkTecoReportJob(data)
}
}
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")
}