Merge branch 'dev' of http://gitlab.fjmaimaimai.com/allied-creation/allied-creat…
…ion-manufacture into dev
正在显示
4 个修改的文件
包含
66 行增加
和
0 行删除
pkg/domain/device_zkteco.go
0 → 100644
| 1 | +package controllers | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "encoding/json" | ||
| 5 | + "github.com/linmadan/egglib-go/web/beego" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/redis" | ||
| 9 | + "strings" | ||
| 10 | + "time" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +type DeviceZKTecoController struct { | ||
| 14 | + beego.BaseController | ||
| 15 | +} | ||
| 16 | + | ||
| 17 | +func (controller *DeviceZKTecoController) PostCdata() { | ||
| 18 | + body := controller.Ctx.Input.RequestBody | ||
| 19 | + sn := controller.Ctx.Input.Query("SN") | ||
| 20 | + //table := controller.Ctx.Input.Query("table") | ||
| 21 | + bodyList := strings.Split(string(body), "\t") | ||
| 22 | + data := &domain.DeviceZkTeco{ | ||
| 23 | + Sn: sn, | ||
| 24 | + } | ||
| 25 | + if len(bodyList) > 2 { | ||
| 26 | + data.UserNo = bodyList[0] | ||
| 27 | + //转成时间格式 | ||
| 28 | + mTime, err := time.ParseInLocation("2006-01-02 15:04:05", bodyList[1], time.Local) | ||
| 29 | + if err == nil { | ||
| 30 | + data.ActionTime = mTime | ||
| 31 | + mBytes, _ := json.Marshal(data) | ||
| 32 | + redis.GetRedis().LPush(constant.REDIS_ZKTECO_KEY, mBytes) | ||
| 33 | + } | ||
| 34 | + } | ||
| 35 | + controller.Response(data, nil) | ||
| 36 | +} | ||
| 37 | + | ||
| 38 | +func (controller *DeviceZKTecoController) GetCdata() { | ||
| 39 | + //sn := controller.Ctx.Input.Query("SN") | ||
| 40 | + | ||
| 41 | +} | ||
| 42 | + | ||
| 43 | +func (controller *DeviceZKTecoController) GetRequest() { | ||
| 44 | + | ||
| 45 | +} | ||
| 46 | + | ||
| 47 | +func (controller *DeviceZKTecoController) Ping() { | ||
| 48 | + controller.Ctx.WriteString("OK") | ||
| 49 | +} |
| @@ -14,4 +14,10 @@ func init() { | @@ -14,4 +14,10 @@ func init() { | ||
| 14 | web.Router("/devices/", &controllers.DeviceController{}, "Get:ListDevice") | 14 | web.Router("/devices/", &controllers.DeviceController{}, "Get:ListDevice") |
| 15 | web.Router("/devices/search", &controllers.DeviceController{}, "Post:SearchDevice") | 15 | web.Router("/devices/search", &controllers.DeviceController{}, "Post:SearchDevice") |
| 16 | web.Router("/devices/batch-add", &controllers.DeviceController{}, "Post:BatchAddDevice") | 16 | web.Router("/devices/batch-add", &controllers.DeviceController{}, "Post:BatchAddDevice") |
| 17 | + | ||
| 18 | + //考勤机 | ||
| 19 | + web.Router("/zkteco/iclock/cdata", &controllers.DeviceZKTecoController{}, "Post:PostCdata") | ||
| 20 | + web.Router("/zkteco/iclock/cdata", &controllers.DeviceZKTecoController{}, "Get:GetCdata") | ||
| 21 | + web.Router("/zkteco/iclock/getrequest", &controllers.DeviceZKTecoController{}, "Get:GetRequest") | ||
| 22 | + web.Router("/zkteco/iclock/ping",&controllers.DeviceZKTecoController{},"Get:Ping") | ||
| 17 | } | 23 | } |
-
请 注册 或 登录 后发表评论