作者 Administrator

合并分支 'test' 到 'master'

Test



查看合并请求 !7
INSERT INTO "users"."menu"("menu_id", "parent_id", "menu_name", "code", "access_code", "menu_type", "icon", "sort", "remark", "category", "parent_path", "is_publish", "enable_status", "link") VALUES (274, 42, '同步考勤机', 'ADMIN_SYSTEM-MANAGE_BASE_USER_SYNC', 'w1-1-1-1-9', 'button', '', 9, '同步考勤机', '7', '37,39,40,42', 1, 0, NULL);
... ...
apiVersion: v1
kind: Service
metadata:
name: allied-creation-manufacture
namespace: mmm-suplus-test
labels:
k8s-app: allied-creation-manufacture
spec:
ports:
- name: "http"
port: 80
targetPort: 8082
selector:
k8s-app: allied-creation-manufacture
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: allied-creation-manufacture
namespace: mmm-suplus-test
labels:
k8s-app: allied-creation-manufacture
spec:
replicas: 1
template:
metadata:
labels:
k8s-app: allied-creation-manufacture
spec:
affinity:
nodeAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- preference: {}
weight: 100
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- cn-hangzhou.i-bp1djh1xn7taumbue1ze
- cn-hangzhou.i-bp1djh1xn7taumbue1zd
- cn-hangzhou.i-bp1euf5u1ph9kbhtndhb
- cn-hangzhou.i-bp1hyp5oips9cdwxxgxy
containers:
- name: allied-creation-manufacture
image: 192.168.0.243:5000/mmm/allied-creation-manufacture:dev
imagePullPolicy: Always
ports:
- containerPort: 8082
env:
- name: POSTGRESQL_DB_NAME
valueFrom:
configMapKeyRef:
name: suplus-config
key: postgresqlalliedcreation.dbname
- name: POSTGRESQL_USER
valueFrom:
configMapKeyRef:
name: suplus-config
key: postgresql.user
- name: POSTGRESQL_PASSWORD
valueFrom:
configMapKeyRef:
name: suplus-config
key: postgresql.password
- name: POSTGRESQL_HOST
valueFrom:
configMapKeyRef:
name: suplus-config
key: postgresql.host
- name: POSTGRESQL_PORT
valueFrom:
configMapKeyRef:
name: suplus-config
key: postgresql.port
- name: REDIS_HOST
valueFrom:
configMapKeyRef:
name: suplus-config
key: redis.ip
- name: REDIS_PORT
valueFrom:
configMapKeyRef:
name: suplus-config
key: redis.port
- name: REDIS_AUTH
value: ""
- name: LOG_LEVEL
value: "debug"
- name: ERROR_BASE_CODE
value: "1"
- name: ERROR_BASE_CODE_MULTIPLE
value: "2000"
- name: ENABLE_KAFKA_LOG
value: "true"
- name: HTTP_PORT
value: "8082"
- name: SERVICE_ENV
value: "test"
- name: SUPLUS_ADMIN_BASE_HOST
value: "http://suplus-admin-base-dev.fjmaimaimai.com"
- name: ALLIED_CREATION_GATEWAY_HOST
value: "https://allied-creation-gateway-test.fjmaimaimai.com"
- name: ALLIED_CREATION_USER_HOST
value: "https://allied-creation-user-test.fjmaimaimai.com"
- name: ALLIED_CREATION_COOPERATION_HOST
value: "https://allied-creation-cooperation-test.fjmaimaimai.com"
- name: ALLIED_CREATION_BASIC_HOST
value: "https://allied-creation-basic-test.fjmaimaimai.com"
- name: ALLIED_CREATION_MANUFACTURE_HOST
value: "http://allied-creation-manufacture-test.fjmaimaimai.com"
- name: SMS_SERVE_HOST
value: "https://sms.fjmaimaimai.com:9897"
- name: SUPLUS_SALE_APP
value: "http://suplus-sale-app-gateway-test.fjmaimaimai.com"
- name: MANUFACTURE_DEFAULT_COMPANYID
value: "23"
- name: MANUFACTURE_DEFAULT_ORGID
value: "487"
- name: MANUFACTURE_DEFAULT_WORKSHOPID
value: "28"
- name: MANUFACTURE_PRODUCT_TYPE
value: "SG,SG"
- name: MQTT_HOST
value: "47.97.5.102"
- name: MQTT_PORT
value: "6000"
\ No newline at end of file
... ...
... ... @@ -176,3 +176,12 @@ func (gateway HttpLibAlliedCreationUser) OrgSearch(param ReqOrgSearch) (int, []*
err := gateway.FastDoRequest(url, method, param, &data)
return data.Count, data.Orgs, err
}
// TerminalReport 终端汇报
func (gateway HttpLibAlliedCreationUser) TerminalReport(param ReqTerminalReport) (DataTerminalReport, error) {
url := gateway.Host() + "/terminal/report"
method := "post"
var data DataTerminalReport
err := gateway.FastDoRequest(url, method, param, &data)
return data, err
}
... ...
... ... @@ -163,3 +163,21 @@ type (
Orgs []*models.Organization `json:"orgs"`
}
)
//返回组织列表
type (
ReqTerminalReport struct {
TerminalType string `json:"terminalType"`
TerminalId string `json:"terminalId"`
Command string `json:"command"`
Content string `json:"content"`
Table string `json:"table"`
CompanyId int64 `json:"companyId"`
OrgId int64 `json:"orgId"`
}
DataTerminalReport struct {
Response string `json:"response"`
}
)
... ...
... ... @@ -8,7 +8,10 @@ import (
"github.com/bwmarrin/snowflake"
jsonlib "github.com/linmadan/egglib-go/utils/json"
"github.com/shopspring/decimal"
"golang.org/x/text/encoding/simplifiedchinese"
"golang.org/x/text/transform"
"io"
"io/ioutil"
"reflect"
"strconv"
"strings"
... ... @@ -422,3 +425,21 @@ func Truncate(value float64, places int32) float64 {
rsp, _ := quantity.Float64()
return rsp
}
func Utf8ToGbk(s []byte) ([]byte, error) {
reader := transform.NewReader(bytes.NewReader(s), simplifiedchinese.GBK.NewEncoder())
d, e := ioutil.ReadAll(reader)
if e != nil {
return nil, e
}
return d, nil
}
func GbkToUtf8(s []byte) ([]byte, error) {
reader := transform.NewReader(bytes.NewReader(s), simplifiedchinese.GBK.NewDecoder())
d, e := ioutil.ReadAll(reader)
if e != nil {
return nil, e
}
return d, nil
}
... ...
package controllers
import (
"fmt"
"github.com/beego/beego/v2/server/web/context"
"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/allied-lib/gateway/allied_creation_user"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/domainService"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log"
"strings"
"time"
"unicode/utf8"
)
type DeviceZKTecoController struct {
... ... @@ -21,7 +27,8 @@ func (controller *DeviceZKTecoController) PostCdata() {
data := &domain.DeviceZkTeco{
Sn: sn,
}
if len(bodyList) > 2 {
table := controller.Ctx.Input.Query("table")
if len(bodyList) > 2 && table == "ATTLOG" {
data.UserNo = bodyList[0]
//转成时间格式
mTime, err := time.ParseInLocation("2006-01-02 15:04:05", bodyList[1], time.Local)
... ... @@ -36,6 +43,7 @@ func (controller *DeviceZKTecoController) PostCdata() {
log.Logger.Debug(err.Error() + "data:" + bodyList[1])
}
}
RedirectToUserModule(controller.Ctx, false)
controller.Response(data, nil)
}
... ... @@ -46,9 +54,72 @@ func (controller *DeviceZKTecoController) GetCdata() {
func (controller *DeviceZKTecoController) GetRequest() {
//controller.Ctx.WriteString("C:11:DATA\tQUERY\tUSERINFO\tPIN=10086")
controller.Ctx.WriteString("OK")
//controller.Ctx.WriteString("C:7EceWxtHB6:DATA QUERY USERINFO PIN=3")
//controller.Ctx.WriteString("OK")
RedirectToUserModule(controller.Ctx, true)
}
func (controller *DeviceZKTecoController) Ping() {
controller.Ctx.WriteString("OK")
}
func RedirectToUserModule(ctx *context.Context, useResult bool) {
var svr = allied_creation_user.NewHttpLibAlliedCreationUser(constant.ALLIED_CREATION_USER_HOST)
data := ctx.Input.RequestBody
uri := ctx.Request.URL.Path
sn := ctx.Input.Query("SN")
table := ""
cmd := uri
switch uri {
case "/zkteco/iclock/getrequest": // 获取下行命令
cmd = "getrequest"
case "/zkteco/iclock/cdata": // 上报数据
cmd = "cdata"
table = ctx.Input.Query("table")
case "/zkteco/iclock/devicecmd":
cmd = "devicecmd"
}
content := string(data)
if !utf8.Valid(data) {
utf8Content, _ := utils.GbkToUtf8(data) //ConvertToString(content, "gbk", "utf-8")
content = string(utf8Content)
}
param := allied_creation_user.ReqTerminalReport{
TerminalType: "zkteco",
TerminalId: sn,
Command: cmd,
CompanyId: int64(constant.MANUFACTURE_DEFAULT_COMPANYID),
OrgId: int64(constant.MANUFACTURE_DEFAULT_ORGID),
Table: table,
Content: content,
}
if !useResult {
log.Logger.Debug(fmt.Sprintf("命令透传(sn:%v)-命令:%v 命令(内容):%v 成功", sn, cmd, content))
go func() {
defer func() {
if p := recover(); p != nil {
log.Logger.Error(fmt.Sprintf("%v", p))
}
}()
svr.TerminalReport(param)
}()
return
}
response, err := svr.TerminalReport(param)
if err != nil {
log.Logger.Debug(fmt.Sprintf("命令透传(sn:%v)-命令:%v 命令(内容):%v 应答:%v 错误:%v", sn, cmd, string(data), response.Response, err.Error()))
ctx.WriteString("OK")
return
}
log.Logger.Debug(fmt.Sprintf("命令透传(sn:%v)-命令:%v 命令(内容):%v 应答:%v 成功", sn, cmd, string(data), response.Response))
gbkData, _ := utils.Utf8ToGbk([]byte(response.Response))
ctx.Output.Header("Content-Type", "text/plain;charset=gbk")
ack := string(gbkData)
ctx.WriteString(ack)
}
func (controller *DeviceZKTecoController) DeviceCmd() {
//sn := controller.Ctx.Input.Query("SN")
RedirectToUserModule(controller.Ctx, false)
controller.Ctx.WriteString("OK")
}
... ...
... ... @@ -21,4 +21,5 @@ func init() {
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")
web.Router("/zkteco/iclock/devicecmd", &controllers.DeviceZKTecoController{}, "Post:DeviceCmd")
}
... ...