|
|
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")
|
|
|
} |
...
|
...
|
|