From 066a30751bdc20f9e83b34539de71ae392783e1b Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期六, 19 八月 2023 15:58:09 +0800
Subject: [PATCH] 网络配置获取和删除,品牌增删改查
---
service/task.go | 9
model/net_config.go | 217 +++++
nsq/msg_handler.go | 4
api/v1/config2.go | 66 +
model/common/common.go | 54 +
service/config.go | 27
model/plc_brand.go | 145 +++
model/procedures.go | 12
service/plc_brand.go | 73 +
model/request/plcBrand.go | 22
docs/swagger.yaml | 364 +++++++-
api/v1/config.go | 66 +
docs/docs.go | 564 +++++++++++-
pkg/contextx/contextx.go | 4
api/v1/task.go | 8
constvar/plcBrand.go | 12
docs/swagger.json | 564 +++++++++++-
api/v1/plc_brand.go | 110 ++
model/request/schedule_task.go | 53 -
model/index.go | 40
router/plc_brand.go | 17
model/response/common.go | 23
router/index.go | 16
model/work_order.go | 2
24 files changed, 2,218 insertions(+), 254 deletions(-)
diff --git a/api/v1/config.go b/api/v1/config.go
new file mode 100644
index 0000000..d14c0a6
--- /dev/null
+++ b/api/v1/config.go
@@ -0,0 +1,66 @@
+package v1
+
+import (
+ "apsClient/model"
+ _ "apsClient/model/response"
+ "apsClient/pkg/contextx"
+ "apsClient/pkg/ecode"
+ "apsClient/pkg/logx"
+ "apsClient/service"
+ "github.com/gin-gonic/gin"
+)
+
+type ConfigApi struct{}
+
+// GetNetConfig
+// @Tags Config
+// @Summary 鑾峰彇缃戠粶閰嶇疆
+// @Produce application/json
+// @Success 200 {object} contextx.Response{data=[]model.NetConfig} "鎴愬姛"
+// @Router /v1/config/net [get]
+func (slf *ConfigApi) GetNetConfig(c *gin.Context) {
+ ctx, ok := contextx.NewContext(c, nil)
+ if !ok {
+ return
+ }
+
+ ConfigData, err := service.NewConfigService().GetNetConfigList()
+ if err != nil {
+ logx.Errorf("get net config error: %v", err.Error())
+ ctx.FailWithMsg(ecode.UnknownErr, "鑾峰彇缃戠粶閰嶇疆澶辫触")
+ return
+ }
+
+ ctx.OkWithDetailed(ConfigData)
+}
+
+// SetNetConfig
+// @Tags Config
+// @Summary 璁剧疆缃戠粶閰嶇疆
+// @Produce application/json
+// @Param object body model.NetConfig true "鍙傛暟"
+// @Success 200 {object} contextx.Response{data=[]response.ProcessParams} "鎴愬姛"
+// @Router /v1/config/net [put]
+func (slf *ConfigApi) SetNetConfig(c *gin.Context) {
+ var params model.NetConfig
+ ctx, ok := contextx.NewContext(c, ¶ms)
+ if !ok {
+ return
+ }
+
+ _, err := service.NewConfigService().GetNetConfig(params.Id)
+
+ if err != nil {
+ logx.Errorf("get net config error: %v", err.Error())
+ ctx.FailWithMsg(ecode.UnknownErr, "鑾峰彇缃戠粶閰嶇疆澶辫触")
+ return
+ }
+
+ err = service.NewConfigService().SetNetConfig(params.Id, ¶ms)
+ if err != nil {
+ logx.Errorf("SetNetConfig error: %v", err.Error())
+ ctx.FailWithMsg(ecode.DBErr, "璁剧疆澶辫触")
+ return
+ }
+ ctx.Ok()
+}
diff --git a/api/v1/config2.go b/api/v1/config2.go
new file mode 100644
index 0000000..9fddc51
--- /dev/null
+++ b/api/v1/config2.go
@@ -0,0 +1,66 @@
+package v1
+
+import (
+ "apsClient/model"
+ _ "apsClient/model/response"
+ "apsClient/pkg/contextx"
+ "apsClient/pkg/ecode"
+ "apsClient/pkg/logx"
+ "apsClient/service"
+ "github.com/gin-gonic/gin"
+)
+
+type ConfigApi2 struct{}
+
+// GetNetConfig
+// @Tags Config
+// @Summary 鑾峰彇缃戠粶閰嶇疆
+// @Produce application/json
+// @Success 200 {object} contextx.Response{data=[]model.NetConfig} "鎴愬姛"
+// @Router /v1/cc/nn [get]
+func (slf *ConfigApi2) GetNetConfig(c *gin.Context) {
+ ctx, ok := contextx.NewContext(c, nil)
+ if !ok {
+ return
+ }
+
+ ConfigData, err := service.NewConfigService().GetNetConfigList()
+ if err != nil {
+ logx.Errorf("get net config error: %v", err.Error())
+ ctx.FailWithMsg(ecode.UnknownErr, "鑾峰彇缃戠粶閰嶇疆澶辫触")
+ return
+ }
+
+ ctx.OkWithDetailed(ConfigData)
+}
+
+// SetNetConfig
+// @Tags Config
+// @Summary 璁剧疆缃戠粶閰嶇疆
+// @Produce application/json
+// @Param object body model.NetConfig true "鍙傛暟"
+// @Success 200 {object} contextx.Response{data=[]response.ProcessParams} "鎴愬姛"
+// @Router /v1/cc/nn [put]
+func (slf *ConfigApi2) SetNetConfig(c *gin.Context) {
+ var params model.NetConfig
+ ctx, ok := contextx.NewContext(c, ¶ms)
+ if !ok {
+ return
+ }
+
+ _, err := service.NewConfigService().GetNetConfig(params.Id)
+
+ if err != nil {
+ logx.Errorf("get net config error: %v", err.Error())
+ ctx.FailWithMsg(ecode.UnknownErr, "鑾峰彇缃戠粶閰嶇疆澶辫触")
+ return
+ }
+
+ err = service.NewConfigService().SetNetConfig(params.Id, ¶ms)
+ if err != nil {
+ logx.Errorf("SetNetConfig error: %v", err.Error())
+ ctx.FailWithMsg(ecode.DBErr, "璁剧疆澶辫触")
+ return
+ }
+ ctx.Ok()
+}
diff --git a/api/v1/plc_brand.go b/api/v1/plc_brand.go
new file mode 100644
index 0000000..94ada0d
--- /dev/null
+++ b/api/v1/plc_brand.go
@@ -0,0 +1,110 @@
+package v1
+
+import (
+ "apsClient/model/request"
+ "apsClient/model/response"
+ "apsClient/pkg/contextx"
+ "apsClient/pkg/ecode"
+ "apsClient/service"
+ "github.com/gin-gonic/gin"
+ "strconv"
+)
+
+type PlcBrandApi struct{}
+
+// Add
+// @Tags plc鍝佺墝
+// @Summary 娣诲姞plc鍝佺墝
+// @Produce application/json
+// @Param object body request.AddPlcBrand true "鏌ヨ鍙傛暟"
+// @Success 200 {object} contextx.Response{}
+// @Router /v1/plcBrand/add [post]
+func (s *PlcBrandApi) Add(c *gin.Context) {
+ var params request.AddPlcBrand
+ ctx, ok := contextx.NewContext(c, ¶ms)
+ if !ok {
+ return
+ }
+
+ errCode := service.NewPlcBrandService().AddPlcBrand(¶ms.PlcBrand)
+ if errCode != ecode.OK {
+ ctx.Fail(errCode)
+ return
+ }
+
+ ctx.Ok()
+}
+
+// Delete
+// @Tags plc鍝佺墝
+// @Summary 鍒犻櫎plc鍝佺墝
+// @Produce application/json
+// @Param id path int true "鏌ヨ鍙傛暟"
+// @Success 200 {object} contextx.Response{}
+// @Router /v1/plcBrand/delete/{id} [delete]
+func (s *PlcBrandApi) Delete(c *gin.Context) {
+ ctx, ok := contextx.NewContext(c, nil)
+ if !ok {
+ return
+ }
+
+ id, _ := strconv.Atoi(c.Param("id"))
+ errCode := service.NewPlcBrandService().DeletePlcBrand(id)
+ if errCode != ecode.OK {
+ ctx.Fail(errCode)
+ return
+ }
+
+ ctx.Ok()
+}
+
+// Update
+// @Tags plc鍝佺墝
+// @Summary 鏇存柊plc鍝佺墝
+// @Produce application/json
+// @Param object body request.UpdatePlcBrand true "鏌ヨ鍙傛暟"
+// @Success 200 {object} contextx.Response{}
+// @Router /v1/plcBrand/update [put]
+func (s *PlcBrandApi) Update(c *gin.Context) {
+ var params request.UpdatePlcBrand
+ ctx, ok := contextx.NewContext(c, ¶ms)
+ if !ok {
+ return
+ }
+ if params.Id == 0 {
+ ctx.Fail(ecode.ParamsErr)
+ }
+ params.PlcBrand.Id = params.Id
+
+ errCode := service.NewPlcBrandService().UpdatePlcBrand(¶ms.PlcBrand)
+ if errCode != ecode.OK {
+ ctx.Fail(errCode)
+ return
+ }
+
+ ctx.Ok()
+}
+
+// List
+// @Tags plc鍝佺墝
+// @Summary 鑾峰彇plc鍝佺墝鍒楄〃
+// @Produce application/json
+// @Success 200 {object} response.ListResponse{data=[]model.PlcBrand}
+// @Router /v1/plcBrand/list [get]
+func (s *PlcBrandApi) List(c *gin.Context) {
+ ctx, ok := contextx.NewContext(c, nil)
+ if !ok {
+ return
+ }
+
+ plcBrand, total, errCode := service.NewPlcBrandService().GetPlcBrandList()
+ if errCode != ecode.OK {
+ ctx.Fail(errCode)
+ return
+ }
+
+ ctx.OkWithDetailed(response.ListResponse{
+ Data: plcBrand,
+ Count: total,
+ })
+}
diff --git a/api/v1/task.go b/api/v1/task.go
index 9915449..1278e5b 100644
--- a/api/v1/task.go
+++ b/api/v1/task.go
@@ -59,6 +59,12 @@
ctx.Fail(code)
return
}
+
+ if procedure.Status != model.ProcedureStatusUnFinished {
+ ctx.FailWithMsg(ecode.ParamsErr, "璇ュ伐搴忓凡缁撴潫")
+ return
+ }
+
order, err := service.NewTaskService().GetOrderByWorkOrderId(procedure.WorkOrderID)
if err != nil {
ctx.Fail(ecode.UnknownErr)
@@ -77,7 +83,7 @@
if err != nil {
logx.Errorf("TaskStart Notice GetProcessModel error: %v", err.Error())
- ctx.Fail(ecode.UnknownErr)
+ ctx.FailWithMsg(ecode.UnknownErr, "鏈幏鍙栧埌宸ヨ壓鍙傛暟")
return
}
processParamsArr := make([]*response.ProcessParams, 0, len(resp.ParamsMap))
diff --git a/constvar/plcBrand.go b/constvar/plcBrand.go
new file mode 100644
index 0000000..4db54b6
--- /dev/null
+++ b/constvar/plcBrand.go
@@ -0,0 +1,12 @@
+package constvar
+type PlcBrandQueryClass string
+
+const (
+ PlcBrandQueryClassExpireLessThen60Days PlcBrandQueryClass = ""
+)
+
+type PlcBrandKeywordType string
+
+const (
+ PlcBrandKeywordCustomerName PlcBrandKeywordType = ""
+)
diff --git a/docs/docs.go b/docs/docs.go
index c7aeffc..4b11609 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -16,6 +16,282 @@
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
+ "/v1/cc/nn": {
+ "get": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Config"
+ ],
+ "summary": "鑾峰彇缃戠粶閰嶇疆",
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/contextx.Response"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "data": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/model.NetConfig"
+ }
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ "put": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Config"
+ ],
+ "summary": "璁剧疆缃戠粶閰嶇疆",
+ "parameters": [
+ {
+ "description": "鍙傛暟",
+ "name": "object",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/model.NetConfig"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/contextx.Response"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "data": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/response.ProcessParams"
+ }
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "/v1/config/net": {
+ "get": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Config"
+ ],
+ "summary": "鑾峰彇缃戠粶閰嶇疆",
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/contextx.Response"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "data": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/model.NetConfig"
+ }
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ "put": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Config"
+ ],
+ "summary": "璁剧疆缃戠粶閰嶇疆",
+ "parameters": [
+ {
+ "description": "鍙傛暟",
+ "name": "object",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/model.NetConfig"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/contextx.Response"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "data": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/response.ProcessParams"
+ }
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "/v1/plcBrand/add": {
+ "post": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "plc鍝佺墝"
+ ],
+ "summary": "娣诲姞plc鍝佺墝",
+ "parameters": [
+ {
+ "description": "鏌ヨ鍙傛暟",
+ "name": "object",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/request.AddPlcBrand"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/contextx.Response"
+ }
+ }
+ }
+ }
+ },
+ "/v1/plcBrand/delete/{id}": {
+ "delete": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "plc鍝佺墝"
+ ],
+ "summary": "鍒犻櫎plc鍝佺墝",
+ "parameters": [
+ {
+ "type": "integer",
+ "description": "鏌ヨ鍙傛暟",
+ "name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/contextx.Response"
+ }
+ }
+ }
+ }
+ },
+ "/v1/plcBrand/list": {
+ "get": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "plc鍝佺墝"
+ ],
+ "summary": "鑾峰彇plc鍝佺墝鍒楄〃",
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/response.ListResponse"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "data": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/model.PlcBrand"
+ }
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "/v1/plcBrand/update": {
+ "put": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "plc鍝佺墝"
+ ],
+ "summary": "鏇存柊plc鍝佺墝",
+ "parameters": [
+ {
+ "description": "鏌ヨ鍙傛暟",
+ "name": "object",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/request.UpdatePlcBrand"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/contextx.Response"
+ }
+ }
+ }
+ }
+ },
"/v1/task/finish/{id}": {
"put": {
"produces": [
@@ -148,6 +424,90 @@
}
},
"definitions": {
+ "common.ProcedureMaterial": {
+ "type": "object",
+ "properties": {
+ "amount": {
+ "type": "number"
+ },
+ "materialId": {
+ "type": "string"
+ },
+ "materialName": {
+ "type": "string"
+ },
+ "unit": {
+ "type": "string"
+ }
+ }
+ },
+ "common.ProcedureWorker": {
+ "type": "object",
+ "properties": {
+ "endTime": {
+ "type": "integer"
+ },
+ "phoneNum": {
+ "type": "string"
+ },
+ "startTime": {
+ "type": "integer"
+ },
+ "workerId": {
+ "type": "string"
+ },
+ "workerName": {
+ "type": "string"
+ }
+ }
+ },
+ "common.ProductProcedure": {
+ "type": "object",
+ "properties": {
+ "deviceId": {
+ "type": "string"
+ },
+ "deviceName": {
+ "type": "string"
+ },
+ "endTime": {
+ "type": "integer"
+ },
+ "inputMaterials": {
+ "description": "杈撳叆鐗╂枡鍒楄〃",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/common.ProcedureMaterial"
+ }
+ },
+ "outputMaterials": {
+ "description": "杈撳嚭鐗╂枡鍒楄〃",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/common.ProcedureMaterial"
+ }
+ },
+ "procedureId": {
+ "type": "string"
+ },
+ "procedureName": {
+ "type": "string"
+ },
+ "startTime": {
+ "type": "integer"
+ },
+ "workHours": {
+ "type": "number"
+ },
+ "workers": {
+ "description": "浜哄憳鍒楄〃",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/common.ProcedureWorker"
+ }
+ }
+ }
+ },
"contextx.Response": {
"type": "object",
"properties": {
@@ -159,6 +519,63 @@
"type": "string"
}
}
+ },
+ "model.NetConfig": {
+ "type": "object",
+ "required": [
+ "gateway",
+ "ip",
+ "mask",
+ "networkCard"
+ ],
+ "properties": {
+ "dns": {
+ "description": "dns",
+ "type": "string"
+ },
+ "gateway": {
+ "description": "缃戝叧",
+ "type": "string"
+ },
+ "id": {
+ "type": "integer"
+ },
+ "ip": {
+ "description": "鏈満ip",
+ "type": "string"
+ },
+ "mask": {
+ "description": "瀛愮綉鎺╃爜",
+ "type": "string"
+ },
+ "networkCard": {
+ "description": "缃戝崱",
+ "type": "string"
+ },
+ "status": {
+ "description": "鐘舵�侊紙1鍚敤2绂佺敤锛�",
+ "allOf": [
+ {
+ "$ref": "#/definitions/model.NetConfigStatus"
+ }
+ ]
+ }
+ }
+ },
+ "model.NetConfigStatus": {
+ "type": "integer",
+ "enum": [
+ 1,
+ 2
+ ],
+ "x-enum-comments": {
+ "NetConfigStatusDisabled": "鍏抽棴",
+ "NetConfigStatusEnabled": "寮�鍚�"
+ },
+ "x-enum-varnames": [
+ "NetConfigStatusEnabled",
+ "NetConfigStatusDisabled"
+ ]
},
"model.Order": {
"type": "object",
@@ -194,6 +611,9 @@
"startTime": {
"type": "integer"
},
+ "status": {
+ "$ref": "#/definitions/model.OrderStatus"
+ },
"unit": {
"type": "string"
},
@@ -202,103 +622,98 @@
}
}
},
- "model.Procedures": {
+ "model.OrderStatus": {
+ "type": "integer",
+ "enum": [
+ 1,
+ 2
+ ],
+ "x-enum-varnames": [
+ "OrderStatusUnFinished",
+ "OrderStatusFinished"
+ ]
+ },
+ "model.PlcBrand": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
+ "name": {
+ "type": "string"
+ }
+ }
+ },
+ "model.ProcedureStatus": {
+ "type": "integer",
+ "enum": [
+ 1,
+ 2
+ ],
+ "x-enum-varnames": [
+ "ProcedureStatusUnFinished",
+ "ProcedureStatusFinished"
+ ]
+ },
+ "model.Procedures": {
+ "type": "object",
+ "properties": {
+ "endTime": {
+ "type": "integer"
+ },
+ "id": {
+ "type": "integer"
+ },
"procedure": {
- "description": "request.ProductProcedure 瀵硅薄",
+ "description": "common.ProductProcedure 瀵硅薄",
"allOf": [
{
- "$ref": "#/definitions/request.ProductProcedure"
+ "$ref": "#/definitions/common.ProductProcedure"
}
]
- }
- }
- },
- "request.ProcedureMaterial": {
- "type": "object",
- "properties": {
- "amount": {
- "type": "number"
- },
- "materialId": {
- "type": "string"
- },
- "materialName": {
- "type": "string"
- },
- "unit": {
- "type": "string"
- }
- }
- },
- "request.ProcedureWorker": {
- "type": "object",
- "properties": {
- "endTime": {
- "type": "integer"
- },
- "phoneNum": {
- "type": "string"
},
"startTime": {
"type": "integer"
},
- "workerId": {
- "type": "string"
+ "status": {
+ "$ref": "#/definitions/model.ProcedureStatus"
+ }
+ }
+ },
+ "request.AddPlcBrand": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "integer"
},
- "workerName": {
+ "name": {
"type": "string"
}
}
},
- "request.ProductProcedure": {
+ "request.UpdatePlcBrand": {
"type": "object",
"properties": {
- "deviceId": {
- "type": "string"
- },
- "deviceName": {
- "type": "string"
- },
- "endTime": {
+ "id": {
"type": "integer"
},
- "inputMaterials": {
- "description": "杈撳叆鐗╂枡鍒楄〃",
- "type": "array",
- "items": {
- "$ref": "#/definitions/request.ProcedureMaterial"
- }
- },
- "outputMaterials": {
- "description": "杈撳嚭鐗╂枡鍒楄〃",
- "type": "array",
- "items": {
- "$ref": "#/definitions/request.ProcedureMaterial"
- }
- },
- "procedureId": {
+ "name": {
"type": "string"
- },
- "procedureName": {
- "type": "string"
- },
- "startTime": {
+ }
+ }
+ },
+ "response.ListResponse": {
+ "type": "object",
+ "properties": {
+ "code": {
"type": "integer"
},
- "workHours": {
- "type": "number"
+ "count": {
+ "type": "integer"
},
- "workers": {
- "description": "浜哄憳鍒楄〃",
- "type": "array",
- "items": {
- "$ref": "#/definitions/request.ProcedureWorker"
- }
+ "data": {},
+ "msg": {
+ "type": "string"
}
}
},
@@ -314,6 +729,15 @@
"response.TaskData": {
"type": "object",
"properties": {
+ "deviceName": {
+ "type": "string"
+ },
+ "deviceStatus": {
+ "type": "string"
+ },
+ "nextProcedure": {
+ "$ref": "#/definitions/model.Procedures"
+ },
"order": {
"$ref": "#/definitions/model.Order"
},
diff --git a/docs/swagger.json b/docs/swagger.json
index ad30a37..d175615 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -4,6 +4,282 @@
"contact": {}
},
"paths": {
+ "/v1/cc/nn": {
+ "get": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Config"
+ ],
+ "summary": "鑾峰彇缃戠粶閰嶇疆",
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/contextx.Response"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "data": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/model.NetConfig"
+ }
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ "put": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Config"
+ ],
+ "summary": "璁剧疆缃戠粶閰嶇疆",
+ "parameters": [
+ {
+ "description": "鍙傛暟",
+ "name": "object",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/model.NetConfig"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/contextx.Response"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "data": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/response.ProcessParams"
+ }
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "/v1/config/net": {
+ "get": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Config"
+ ],
+ "summary": "鑾峰彇缃戠粶閰嶇疆",
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/contextx.Response"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "data": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/model.NetConfig"
+ }
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ "put": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Config"
+ ],
+ "summary": "璁剧疆缃戠粶閰嶇疆",
+ "parameters": [
+ {
+ "description": "鍙傛暟",
+ "name": "object",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/model.NetConfig"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/contextx.Response"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "data": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/response.ProcessParams"
+ }
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "/v1/plcBrand/add": {
+ "post": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "plc鍝佺墝"
+ ],
+ "summary": "娣诲姞plc鍝佺墝",
+ "parameters": [
+ {
+ "description": "鏌ヨ鍙傛暟",
+ "name": "object",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/request.AddPlcBrand"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/contextx.Response"
+ }
+ }
+ }
+ }
+ },
+ "/v1/plcBrand/delete/{id}": {
+ "delete": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "plc鍝佺墝"
+ ],
+ "summary": "鍒犻櫎plc鍝佺墝",
+ "parameters": [
+ {
+ "type": "integer",
+ "description": "鏌ヨ鍙傛暟",
+ "name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/contextx.Response"
+ }
+ }
+ }
+ }
+ },
+ "/v1/plcBrand/list": {
+ "get": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "plc鍝佺墝"
+ ],
+ "summary": "鑾峰彇plc鍝佺墝鍒楄〃",
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/response.ListResponse"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "data": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/model.PlcBrand"
+ }
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "/v1/plcBrand/update": {
+ "put": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "plc鍝佺墝"
+ ],
+ "summary": "鏇存柊plc鍝佺墝",
+ "parameters": [
+ {
+ "description": "鏌ヨ鍙傛暟",
+ "name": "object",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/request.UpdatePlcBrand"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/contextx.Response"
+ }
+ }
+ }
+ }
+ },
"/v1/task/finish/{id}": {
"put": {
"produces": [
@@ -136,6 +412,90 @@
}
},
"definitions": {
+ "common.ProcedureMaterial": {
+ "type": "object",
+ "properties": {
+ "amount": {
+ "type": "number"
+ },
+ "materialId": {
+ "type": "string"
+ },
+ "materialName": {
+ "type": "string"
+ },
+ "unit": {
+ "type": "string"
+ }
+ }
+ },
+ "common.ProcedureWorker": {
+ "type": "object",
+ "properties": {
+ "endTime": {
+ "type": "integer"
+ },
+ "phoneNum": {
+ "type": "string"
+ },
+ "startTime": {
+ "type": "integer"
+ },
+ "workerId": {
+ "type": "string"
+ },
+ "workerName": {
+ "type": "string"
+ }
+ }
+ },
+ "common.ProductProcedure": {
+ "type": "object",
+ "properties": {
+ "deviceId": {
+ "type": "string"
+ },
+ "deviceName": {
+ "type": "string"
+ },
+ "endTime": {
+ "type": "integer"
+ },
+ "inputMaterials": {
+ "description": "杈撳叆鐗╂枡鍒楄〃",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/common.ProcedureMaterial"
+ }
+ },
+ "outputMaterials": {
+ "description": "杈撳嚭鐗╂枡鍒楄〃",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/common.ProcedureMaterial"
+ }
+ },
+ "procedureId": {
+ "type": "string"
+ },
+ "procedureName": {
+ "type": "string"
+ },
+ "startTime": {
+ "type": "integer"
+ },
+ "workHours": {
+ "type": "number"
+ },
+ "workers": {
+ "description": "浜哄憳鍒楄〃",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/common.ProcedureWorker"
+ }
+ }
+ }
+ },
"contextx.Response": {
"type": "object",
"properties": {
@@ -147,6 +507,63 @@
"type": "string"
}
}
+ },
+ "model.NetConfig": {
+ "type": "object",
+ "required": [
+ "gateway",
+ "ip",
+ "mask",
+ "networkCard"
+ ],
+ "properties": {
+ "dns": {
+ "description": "dns",
+ "type": "string"
+ },
+ "gateway": {
+ "description": "缃戝叧",
+ "type": "string"
+ },
+ "id": {
+ "type": "integer"
+ },
+ "ip": {
+ "description": "鏈満ip",
+ "type": "string"
+ },
+ "mask": {
+ "description": "瀛愮綉鎺╃爜",
+ "type": "string"
+ },
+ "networkCard": {
+ "description": "缃戝崱",
+ "type": "string"
+ },
+ "status": {
+ "description": "鐘舵�侊紙1鍚敤2绂佺敤锛�",
+ "allOf": [
+ {
+ "$ref": "#/definitions/model.NetConfigStatus"
+ }
+ ]
+ }
+ }
+ },
+ "model.NetConfigStatus": {
+ "type": "integer",
+ "enum": [
+ 1,
+ 2
+ ],
+ "x-enum-comments": {
+ "NetConfigStatusDisabled": "鍏抽棴",
+ "NetConfigStatusEnabled": "寮�鍚�"
+ },
+ "x-enum-varnames": [
+ "NetConfigStatusEnabled",
+ "NetConfigStatusDisabled"
+ ]
},
"model.Order": {
"type": "object",
@@ -182,6 +599,9 @@
"startTime": {
"type": "integer"
},
+ "status": {
+ "$ref": "#/definitions/model.OrderStatus"
+ },
"unit": {
"type": "string"
},
@@ -190,103 +610,98 @@
}
}
},
- "model.Procedures": {
+ "model.OrderStatus": {
+ "type": "integer",
+ "enum": [
+ 1,
+ 2
+ ],
+ "x-enum-varnames": [
+ "OrderStatusUnFinished",
+ "OrderStatusFinished"
+ ]
+ },
+ "model.PlcBrand": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
+ "name": {
+ "type": "string"
+ }
+ }
+ },
+ "model.ProcedureStatus": {
+ "type": "integer",
+ "enum": [
+ 1,
+ 2
+ ],
+ "x-enum-varnames": [
+ "ProcedureStatusUnFinished",
+ "ProcedureStatusFinished"
+ ]
+ },
+ "model.Procedures": {
+ "type": "object",
+ "properties": {
+ "endTime": {
+ "type": "integer"
+ },
+ "id": {
+ "type": "integer"
+ },
"procedure": {
- "description": "request.ProductProcedure 瀵硅薄",
+ "description": "common.ProductProcedure 瀵硅薄",
"allOf": [
{
- "$ref": "#/definitions/request.ProductProcedure"
+ "$ref": "#/definitions/common.ProductProcedure"
}
]
- }
- }
- },
- "request.ProcedureMaterial": {
- "type": "object",
- "properties": {
- "amount": {
- "type": "number"
- },
- "materialId": {
- "type": "string"
- },
- "materialName": {
- "type": "string"
- },
- "unit": {
- "type": "string"
- }
- }
- },
- "request.ProcedureWorker": {
- "type": "object",
- "properties": {
- "endTime": {
- "type": "integer"
- },
- "phoneNum": {
- "type": "string"
},
"startTime": {
"type": "integer"
},
- "workerId": {
- "type": "string"
+ "status": {
+ "$ref": "#/definitions/model.ProcedureStatus"
+ }
+ }
+ },
+ "request.AddPlcBrand": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "integer"
},
- "workerName": {
+ "name": {
"type": "string"
}
}
},
- "request.ProductProcedure": {
+ "request.UpdatePlcBrand": {
"type": "object",
"properties": {
- "deviceId": {
- "type": "string"
- },
- "deviceName": {
- "type": "string"
- },
- "endTime": {
+ "id": {
"type": "integer"
},
- "inputMaterials": {
- "description": "杈撳叆鐗╂枡鍒楄〃",
- "type": "array",
- "items": {
- "$ref": "#/definitions/request.ProcedureMaterial"
- }
- },
- "outputMaterials": {
- "description": "杈撳嚭鐗╂枡鍒楄〃",
- "type": "array",
- "items": {
- "$ref": "#/definitions/request.ProcedureMaterial"
- }
- },
- "procedureId": {
+ "name": {
"type": "string"
- },
- "procedureName": {
- "type": "string"
- },
- "startTime": {
+ }
+ }
+ },
+ "response.ListResponse": {
+ "type": "object",
+ "properties": {
+ "code": {
"type": "integer"
},
- "workHours": {
- "type": "number"
+ "count": {
+ "type": "integer"
},
- "workers": {
- "description": "浜哄憳鍒楄〃",
- "type": "array",
- "items": {
- "$ref": "#/definitions/request.ProcedureWorker"
- }
+ "data": {},
+ "msg": {
+ "type": "string"
}
}
},
@@ -302,6 +717,15 @@
"response.TaskData": {
"type": "object",
"properties": {
+ "deviceName": {
+ "type": "string"
+ },
+ "deviceStatus": {
+ "type": "string"
+ },
+ "nextProcedure": {
+ "$ref": "#/definitions/model.Procedures"
+ },
"order": {
"$ref": "#/definitions/model.Order"
},
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index dd25e9c..b251b21 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -1,4 +1,60 @@
definitions:
+ common.ProcedureMaterial:
+ properties:
+ amount:
+ type: number
+ materialId:
+ type: string
+ materialName:
+ type: string
+ unit:
+ type: string
+ type: object
+ common.ProcedureWorker:
+ properties:
+ endTime:
+ type: integer
+ phoneNum:
+ type: string
+ startTime:
+ type: integer
+ workerId:
+ type: string
+ workerName:
+ type: string
+ type: object
+ common.ProductProcedure:
+ properties:
+ deviceId:
+ type: string
+ deviceName:
+ type: string
+ endTime:
+ type: integer
+ inputMaterials:
+ description: 杈撳叆鐗╂枡鍒楄〃
+ items:
+ $ref: '#/definitions/common.ProcedureMaterial'
+ type: array
+ outputMaterials:
+ description: 杈撳嚭鐗╂枡鍒楄〃
+ items:
+ $ref: '#/definitions/common.ProcedureMaterial'
+ type: array
+ procedureId:
+ type: string
+ procedureName:
+ type: string
+ startTime:
+ type: integer
+ workHours:
+ type: number
+ workers:
+ description: 浜哄憳鍒楄〃
+ items:
+ $ref: '#/definitions/common.ProcedureWorker'
+ type: array
+ type: object
contextx.Response:
properties:
code:
@@ -7,6 +63,46 @@
msg:
type: string
type: object
+ model.NetConfig:
+ properties:
+ dns:
+ description: dns
+ type: string
+ gateway:
+ description: 缃戝叧
+ type: string
+ id:
+ type: integer
+ ip:
+ description: 鏈満ip
+ type: string
+ mask:
+ description: 瀛愮綉鎺╃爜
+ type: string
+ networkCard:
+ description: 缃戝崱
+ type: string
+ status:
+ allOf:
+ - $ref: '#/definitions/model.NetConfigStatus'
+ description: 鐘舵�侊紙1鍚敤2绂佺敤锛�
+ required:
+ - gateway
+ - ip
+ - mask
+ - networkCard
+ type: object
+ model.NetConfigStatus:
+ enum:
+ - 1
+ - 2
+ type: integer
+ x-enum-comments:
+ NetConfigStatusDisabled: 鍏抽棴
+ NetConfigStatusEnabled: 寮�鍚�
+ x-enum-varnames:
+ - NetConfigStatusEnabled
+ - NetConfigStatusDisabled
model.Order:
properties:
amount:
@@ -30,75 +126,74 @@
type: string
startTime:
type: integer
+ status:
+ $ref: '#/definitions/model.OrderStatus'
unit:
type: string
workOrderId:
type: string
type: object
+ model.OrderStatus:
+ enum:
+ - 1
+ - 2
+ type: integer
+ x-enum-varnames:
+ - OrderStatusUnFinished
+ - OrderStatusFinished
+ model.PlcBrand:
+ properties:
+ id:
+ type: integer
+ name:
+ type: string
+ type: object
+ model.ProcedureStatus:
+ enum:
+ - 1
+ - 2
+ type: integer
+ x-enum-varnames:
+ - ProcedureStatusUnFinished
+ - ProcedureStatusFinished
model.Procedures:
properties:
+ endTime:
+ type: integer
id:
type: integer
procedure:
allOf:
- - $ref: '#/definitions/request.ProductProcedure'
- description: request.ProductProcedure 瀵硅薄
- type: object
- request.ProcedureMaterial:
- properties:
- amount:
- type: number
- materialId:
- type: string
- materialName:
- type: string
- unit:
- type: string
- type: object
- request.ProcedureWorker:
- properties:
- endTime:
- type: integer
- phoneNum:
- type: string
+ - $ref: '#/definitions/common.ProductProcedure'
+ description: common.ProductProcedure 瀵硅薄
startTime:
type: integer
- workerId:
- type: string
- workerName:
+ status:
+ $ref: '#/definitions/model.ProcedureStatus'
+ type: object
+ request.AddPlcBrand:
+ properties:
+ id:
+ type: integer
+ name:
type: string
type: object
- request.ProductProcedure:
+ request.UpdatePlcBrand:
properties:
- deviceId:
- type: string
- deviceName:
- type: string
- endTime:
+ id:
type: integer
- inputMaterials:
- description: 杈撳叆鐗╂枡鍒楄〃
- items:
- $ref: '#/definitions/request.ProcedureMaterial'
- type: array
- outputMaterials:
- description: 杈撳嚭鐗╂枡鍒楄〃
- items:
- $ref: '#/definitions/request.ProcedureMaterial'
- type: array
- procedureId:
+ name:
type: string
- procedureName:
- type: string
- startTime:
+ type: object
+ response.ListResponse:
+ properties:
+ code:
type: integer
- workHours:
- type: number
- workers:
- description: 浜哄憳鍒楄〃
- items:
- $ref: '#/definitions/request.ProcedureWorker'
- type: array
+ count:
+ type: integer
+ data: {}
+ msg:
+ type: string
type: object
response.ProcessParams:
properties:
@@ -108,6 +203,12 @@
type: object
response.TaskData:
properties:
+ deviceName:
+ type: string
+ deviceStatus:
+ type: string
+ nextProcedure:
+ $ref: '#/definitions/model.Procedures'
order:
$ref: '#/definitions/model.Order'
procedure:
@@ -116,6 +217,169 @@
info:
contact: {}
paths:
+ /v1/cc/nn:
+ get:
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: 鎴愬姛
+ schema:
+ allOf:
+ - $ref: '#/definitions/contextx.Response'
+ - properties:
+ data:
+ items:
+ $ref: '#/definitions/model.NetConfig'
+ type: array
+ type: object
+ summary: 鑾峰彇缃戠粶閰嶇疆
+ tags:
+ - Config
+ put:
+ parameters:
+ - description: 鍙傛暟
+ in: body
+ name: object
+ required: true
+ schema:
+ $ref: '#/definitions/model.NetConfig'
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: 鎴愬姛
+ schema:
+ allOf:
+ - $ref: '#/definitions/contextx.Response'
+ - properties:
+ data:
+ items:
+ $ref: '#/definitions/response.ProcessParams'
+ type: array
+ type: object
+ summary: 璁剧疆缃戠粶閰嶇疆
+ tags:
+ - Config
+ /v1/config/net:
+ get:
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: 鎴愬姛
+ schema:
+ allOf:
+ - $ref: '#/definitions/contextx.Response'
+ - properties:
+ data:
+ items:
+ $ref: '#/definitions/model.NetConfig'
+ type: array
+ type: object
+ summary: 鑾峰彇缃戠粶閰嶇疆
+ tags:
+ - Config
+ put:
+ parameters:
+ - description: 鍙傛暟
+ in: body
+ name: object
+ required: true
+ schema:
+ $ref: '#/definitions/model.NetConfig'
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: 鎴愬姛
+ schema:
+ allOf:
+ - $ref: '#/definitions/contextx.Response'
+ - properties:
+ data:
+ items:
+ $ref: '#/definitions/response.ProcessParams'
+ type: array
+ type: object
+ summary: 璁剧疆缃戠粶閰嶇疆
+ tags:
+ - Config
+ /v1/plcBrand/add:
+ post:
+ parameters:
+ - description: 鏌ヨ鍙傛暟
+ in: body
+ name: object
+ required: true
+ schema:
+ $ref: '#/definitions/request.AddPlcBrand'
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/contextx.Response'
+ summary: 娣诲姞plc鍝佺墝
+ tags:
+ - plc鍝佺墝
+ /v1/plcBrand/delete/{id}:
+ delete:
+ parameters:
+ - description: 鏌ヨ鍙傛暟
+ in: path
+ name: id
+ required: true
+ type: integer
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/contextx.Response'
+ summary: 鍒犻櫎plc鍝佺墝
+ tags:
+ - plc鍝佺墝
+ /v1/plcBrand/list:
+ get:
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ allOf:
+ - $ref: '#/definitions/response.ListResponse'
+ - properties:
+ data:
+ items:
+ $ref: '#/definitions/model.PlcBrand'
+ type: array
+ type: object
+ summary: 鑾峰彇plc鍝佺墝鍒楄〃
+ tags:
+ - plc鍝佺墝
+ /v1/plcBrand/update:
+ put:
+ parameters:
+ - description: 鏌ヨ鍙傛暟
+ in: body
+ name: object
+ required: true
+ schema:
+ $ref: '#/definitions/request.UpdatePlcBrand'
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/contextx.Response'
+ summary: 鏇存柊plc鍝佺墝
+ tags:
+ - plc鍝佺墝
/v1/task/finish/{id}:
put:
parameters:
diff --git a/model/common/common.go b/model/common/common.go
new file mode 100644
index 0000000..c953878
--- /dev/null
+++ b/model/common/common.go
@@ -0,0 +1,54 @@
+package common
+
+import "github.com/shopspring/decimal"
+
+// 鎺掔▼浠诲姟涓嬪彂
+type (
+ WorkOrder struct {
+ WorkOrderID string `json:"workOrderId"`
+ OrderID string `gorm:"index;type:varchar(191);not null;comment:璁㈠崟ID" json:"orderId"`
+ ProductID string `gorm:"type:varchar(191);comment:浜у搧ID" json:"productId"`
+ ProductName string `gorm:"type:varchar(191);comment:浜у搧鍚嶇О" json:"productName"`
+ Parameter string `gorm:"type:varchar(1024);comment:鍙傛暟闇�姹�" json:"parameter"`
+ Customer string `gorm:"type:varchar(191);comment:瀹㈡埛缂栫爜" json:"customer"`
+ DeliverDate string `gorm:"type:varchar(100);comment:浜よ揣鏃ユ湡" json:"deliverDate"`
+ OrderAttr string `json:"orderAttr"` // 璁㈠崟灞炴�ф嫾鎺ョ殑瀛楃涓诧紝鍗宠揣鐗╂弿杩�
+ Amount decimal.Decimal `gorm:"type:decimal(35,18);comment:鏁伴噺" json:"amount"`
+ Unit string `gorm:"type:varchar(100);comment:鍗曚綅" json:"unit"`
+ StartTime int64 `gorm:"comment:璁″垝寮�濮嬫椂闂�" json:"startTime"`
+ EndTime int64 `gorm:"comment:璁″垝缁撴潫鏃堕棿" json:"endTime"`
+ }
+
+ ProcedureMaterial struct {
+ MaterialID string `gorm:"type:varchar(191);comment:鐗╂枡缂栧彿" json:"materialId"`
+ MaterialName string `gorm:"unique;type:varchar(191);not null;comment:鐗╂枡鍚嶇О" json:"materialName"`
+ Amount decimal.Decimal `gorm:"type:decimal(35,18);comment:鏁伴噺" json:"amount"`
+ Unit string `gorm:"type:varchar(191);comment:鍗曚綅" json:"unit"`
+ }
+
+ ProcedureWorker struct {
+ WorkerID string `gorm:"type:varchar(2048);comment:浜哄憳ID" json:"workerId"`
+ WorkerName string `gorm:"unique;type:varchar(191);not null;comment:浜哄憳濮撳悕" json:"workerName"`
+ PhoneNum string `gorm:"type:varchar(191);comment:鎵嬫満鍙�" json:"phoneNum"`
+ StartTime int64 `gorm:"comment:寮�濮嬫椂闂�" json:"startTime"`
+ EndTime int64 `gorm:"comment:缁撴潫鏃堕棿" json:"endTime"`
+ }
+
+ ProductProcedure struct {
+ ProcedureID string `gorm:"uniqueIndex:idx_product_procedure;type:varchar(191);comment:宸ュ簭ID" json:"procedureId"`
+ ProcedureName string `gorm:"type:varchar(191);comment:宸ュ簭鍚嶇О锛屼粎鏌ヨ鐢�" json:"procedureName"`
+ DeviceID string `gorm:"type:varchar(191);not null;comment:璁惧ID" json:"deviceId"`
+ DeviceName string `gorm:"type:varchar(191);not null;comment:璁惧鍚嶇О" json:"deviceName"`
+ StartTime int64 `gorm:"comment:璁″垝寮�濮嬫椂闂�" json:"startTime"`
+ EndTime int64 `gorm:"comment:璁″垝缁撴潫鏃堕棿" json:"endTime"`
+ WorkHours decimal.Decimal `gorm:"type:decimal(35,18);comment:宸ユ椂" json:"workHours"`
+ InputMaterials []*ProcedureMaterial `json:"inputMaterials"` // 杈撳叆鐗╂枡鍒楄〃
+ OutputMaterials []*ProcedureMaterial `json:"outputMaterials"` // 杈撳嚭鐗╂枡鍒楄〃
+ Workers []*ProcedureWorker `json:"workers"` // 浜哄憳鍒楄〃
+ }
+
+ DeliverScheduleTask struct {
+ WorkOrder WorkOrder `json:"workOrder"`
+ Procedures []*ProductProcedure `json:"procedures"` // 宸ュ簭鍒楄〃
+ }
+)
diff --git a/model/index.go b/model/index.go
index 21552fb..12e013e 100644
--- a/model/index.go
+++ b/model/index.go
@@ -4,6 +4,7 @@
"apsClient/conf"
"apsClient/pkg/logx"
"apsClient/pkg/sqlitex"
+ "sync"
)
func Init() error {
@@ -14,11 +15,48 @@
if err := RegisterTables(); err != nil {
return err
}
+ InsertDefaultData()
return nil
}
func RegisterTables() error {
db := sqlitex.GetDB()
- err := db.AutoMigrate(Order{}, Procedures{})
+ err := db.AutoMigrate(
+ Order{},
+ Procedures{},
+ NetConfig{},
+ PlcBrand{},
+ )
return err
}
+
+type InitDefaultData interface {
+ InitDefaultData(errCh chan<- error, wg *sync.WaitGroup)
+}
+
+func InsertDefaultData() {
+ errCh := make(chan error, 2)
+ var wg sync.WaitGroup
+
+ models := []interface{}{
+ NewNetConfigSearch(nil),
+ }
+
+ for _, model := range models {
+ if id, ok := model.(InitDefaultData); ok {
+ wg.Add(1)
+ go id.InitDefaultData(errCh, &wg)
+ }
+ }
+
+ go func() {
+ wg.Wait() // 绛夊緟鎵�鏈塯oroutine瀹屾垚
+ close(errCh) // 鍏抽棴閿欒閫氶亾
+ }()
+
+ for err := range errCh {
+ if err != nil {
+ logx.Errorf("InitDefaultData err: %v", err.Error())
+ }
+ }
+}
diff --git a/model/net_config.go b/model/net_config.go
new file mode 100644
index 0000000..75a9fa5
--- /dev/null
+++ b/model/net_config.go
@@ -0,0 +1,217 @@
+package model
+
+import (
+ "apsClient/pkg/sqlitex"
+ "fmt"
+ "gorm.io/gorm"
+ "sync"
+)
+
+type (
+ NetConfig struct {
+ gorm.Model `json:"-"`
+ Id int `gorm:"primarykey;type:int;" json:"id"`
+ NetworkCard string `gorm:"type:varchar(100);not null;default '';comment:缃戝崱" json:"networkCard" binding:"required"` //缃戝崱
+ IP string `gorm:"type:varchar(100);not null;default '';comment:鏈満ip" json:"ip" binding:"required"` //鏈満ip
+ MASK string `gorm:"type:varchar(100);not null;default '';comment:瀛愮綉鎺╃爜" json:"mask" binding:"required"` //瀛愮綉鎺╃爜
+ Gateway string `gorm:"type:varchar(100);not null;default '';comment:缃戝叧" json:"gateway" binding:"required"` //缃戝叧
+ DNS string `gorm:"type:varchar(100);not null;default '';comment:DNS" json:"dns"` //dns
+ Status NetConfigStatus `gorm:"type:tinyint;not null;default 0;comment:鐘舵�侊紙1鍚姩2绂佺敤锛�" json:"status"` //鐘舵�侊紙1鍚敤2绂佺敤锛�
+ }
+
+ NetConfigSearch struct {
+ NetConfig
+ NetConfigBy string
+ PageNum int
+ PageSize int
+ Orm *gorm.DB
+ Preload bool
+ StartTimeMax int64
+ }
+)
+
+type NetConfigStatus int
+
+const (
+ NetConfigStatusEnabled NetConfigStatus = 1 //寮�鍚�
+ NetConfigStatusDisabled NetConfigStatus = 2 //鍏抽棴
+)
+
+func (slf *NetConfig) TableName() string {
+ return "net_config"
+}
+
+func NewNetConfigSearch(db *gorm.DB) *NetConfigSearch {
+ if db == nil {
+ db = sqlitex.GetDB()
+ }
+ return &NetConfigSearch{Orm: db}
+}
+
+func (slf *NetConfigSearch) SetOrm(tx *gorm.DB) *NetConfigSearch {
+ slf.Orm = tx
+ return slf
+}
+
+func (slf *NetConfigSearch) SetId(id int) *NetConfigSearch {
+ slf.Id = id
+ return slf
+}
+
+func (slf *NetConfigSearch) build() *gorm.DB {
+ var db = slf.Orm.Model(&NetConfig{})
+
+ return db
+}
+
+// Create 鍗曟潯鎻掑叆
+func (slf *NetConfigSearch) Create(record *NetConfig) error {
+ var db = slf.build()
+
+ if err := db.Create(record).Error; err != nil {
+ return fmt.Errorf("create err: %v, record: %+v", err, record)
+ }
+
+ return nil
+}
+
+func (slf *NetConfigSearch) Save(record *NetConfig) error {
+ var db = slf.build()
+
+ if err := db.Save(record).Error; err != nil {
+ return fmt.Errorf("save err: %v, record: %+v", err, record)
+ }
+
+ return nil
+}
+
+func (slf *NetConfigSearch) UpdateByMap(upMap map[string]interface{}) error {
+ var (
+ db = slf.build()
+ )
+
+ if err := db.Updates(upMap).Error; err != nil {
+ return fmt.Errorf("update by map err: %v, upMap: %+v", err, upMap)
+ }
+
+ return nil
+}
+
+func (slf *NetConfigSearch) UpdateByQuery(query string, args []interface{}, upMap map[string]interface{}) error {
+ var (
+ db = slf.Orm.Table(slf.TableName()).Where(query, args...)
+ )
+
+ if err := db.Updates(upMap).Error; err != nil {
+ return fmt.Errorf("update by query err: %v, query: %s, args: %+v, upMap: %+v", err, query, args, upMap)
+ }
+
+ return nil
+}
+
+func (slf *NetConfigSearch) Delete() error {
+ var db = slf.build()
+
+ if err := db.Unscoped().Delete(&NetConfig{}).Error; err != nil {
+ return err
+ }
+
+ return nil
+}
+
+func (slf *NetConfigSearch) First() (*NetConfig, error) {
+ var (
+ record = new(NetConfig)
+ db = slf.build()
+ )
+
+ if err := db.First(record).Error; err != nil {
+ return record, err
+ }
+
+ return record, nil
+}
+
+func (slf *NetConfigSearch) FindNotTotal() ([]*NetConfig, error) {
+ var (
+ records = make([]*NetConfig, 0)
+ db = slf.build()
+ )
+
+ if slf.PageNum*slf.PageSize > 0 {
+ db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize)
+ }
+ if err := db.Find(&records).Error; err != nil {
+ return records, fmt.Errorf("find records err: %v", err)
+ }
+
+ return records, nil
+}
+
+// FindByQuery 鎸囧畾鏉′欢鏌ヨ.
+func (slf *NetConfigSearch) FindByQuery(query string, args []interface{}) ([]*NetConfig, int64, error) {
+ var (
+ records = make([]*NetConfig, 0)
+ total int64
+ db = slf.Orm.Table(slf.TableName()).Where(query, args...)
+ )
+
+ if err := db.Count(&total).Error; err != nil {
+ return records, total, fmt.Errorf("find by query count err: %v", err)
+ }
+ if slf.PageNum*slf.PageSize > 0 {
+ db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize)
+ }
+ if err := db.Find(&records).Error; err != nil {
+ return records, total, fmt.Errorf("find by query records err: %v, query: %s, args: %+v", err, query, args)
+ }
+
+ return records, total, nil
+}
+
+func (slf *NetConfigSearch) CreateBatch(records []*NetConfig) error {
+ var db = slf.build()
+ return db.Create(records).Error
+}
+
+// InitDefaultData 鍒濆鍖栨暟鎹�
+func (slf *NetConfigSearch) InitDefaultData(errCh chan<- error, wg *sync.WaitGroup) {
+ var (
+ db = slf.Orm.Table(slf.TableName())
+ total int64 = 0
+ )
+ defer wg.Done()
+
+ if err := db.Count(&total).Error; err != nil {
+ errCh <- err
+ return
+ }
+ if total != 0 {
+ return
+ }
+ records := []*NetConfig{
+ {
+ Id: 1,
+ NetworkCard: "enp3s0",
+ IP: "",
+ MASK: "",
+ Gateway: "",
+ DNS: "",
+ Status: 0,
+ },
+ {
+ Id: 2,
+ NetworkCard: "",
+ IP: "",
+ MASK: "",
+ Gateway: "",
+ DNS: "",
+ Status: 0,
+ },
+ }
+ err := slf.CreateBatch(records)
+ if err != nil {
+ errCh <- err
+ return
+ }
+}
diff --git a/model/plc_brand.go b/model/plc_brand.go
new file mode 100644
index 0000000..a91bf44
--- /dev/null
+++ b/model/plc_brand.go
@@ -0,0 +1,145 @@
+package model
+
+import (
+ "apsClient/constvar"
+ "apsClient/pkg/sqlitex"
+ "errors"
+ "fmt"
+ "gorm.io/gorm"
+)
+
+type (
+ // PlcBrand plc鍝佺墝
+ PlcBrand struct {
+ Id int `json:"id" gorm:"column:id;type:int;primary_key;AUTO_INCREMENT"`
+ Name string `json:"name" gorm:"column:name;type:varchar(255);not null;default:'';comment:鍚嶇О"`
+ }
+
+ // PlcBrandSearch plc鍝佺墝鎼滅储鏉′欢
+ PlcBrandSearch struct {
+ PlcBrand
+ Orm *gorm.DB
+ QueryClass constvar.PlcBrandQueryClass
+ KeywordType constvar.PlcBrandKeywordType
+ Keyword string
+ PageNum int
+ PageSize int
+ }
+)
+
+func (PlcBrand) TableName() string {
+ return "plc_brand"
+}
+
+func NewPlcBrandSearch() *PlcBrandSearch {
+ return &PlcBrandSearch{
+ Orm: sqlitex.GetDB(),
+ }
+}
+
+func (slf *PlcBrandSearch) build() *gorm.DB {
+ var db = slf.Orm.Model(&PlcBrand{})
+ if slf.Id != 0 {
+ db = db.Where("id = ?", slf.Id)
+ }
+
+ return db
+}
+
+func (slf *PlcBrandSearch) Create(record *PlcBrand) error {
+ var db = slf.build()
+ return db.Create(record).Error
+}
+
+func (slf *PlcBrandSearch) CreateBatch(records []*PlcBrand) error {
+ var db = slf.build()
+ return db.Create(records).Error
+}
+
+func (slf *PlcBrandSearch) Delete() error {
+ var db = slf.build()
+ return db.Delete(&PlcBrand{}).Error
+}
+
+func (slf *PlcBrandSearch) Update(record *PlcBrand) error {
+ var db = slf.build()
+ return db.Updates(record).Error
+}
+
+func (slf *PlcBrandSearch) FindAll() ([]*PlcBrand, error) {
+ var db = slf.build()
+ var record = make([]*PlcBrand, 0)
+ err := db.Find(&record).Error
+ return record, err
+}
+
+func (slf *PlcBrandSearch) SetId(id int) *PlcBrandSearch {
+ slf.Id = id
+ return slf
+}
+
+func (slf *PlcBrandSearch) SetPage(page, size int) *PlcBrandSearch {
+ slf.PageNum, slf.PageSize = page, size
+ return slf
+}
+
+func (slf *PlcBrandSearch) SetOrm(tx *gorm.DB) *PlcBrandSearch {
+ slf.Orm = tx
+ return slf
+}
+
+func (slf *PlcBrandSearch) First() (*PlcBrand, error) {
+ var db = slf.build()
+ var record = new(PlcBrand)
+ err := db.First(record).Error
+ return record, err
+}
+
+func (slf *PlcBrandSearch) Updates(values interface{}) error {
+ var db = slf.build()
+ return db.Updates(values).Error
+}
+
+func (slf *PlcBrandSearch) Save(record *PlcBrand) error {
+ if record.Id == 0 {
+ return errors.New("id涓虹┖")
+ }
+ var db = slf.build()
+
+ if err := db.Save(record).Error; err != nil {
+ return fmt.Errorf("save err: %v, record: %+v", err, record)
+ }
+
+ return nil
+}
+
+func (slf *PlcBrandSearch) Find() ([]*PlcBrand, int64, error) {
+ var db = slf.build()
+ var records = make([]*PlcBrand, 0)
+ var total int64
+ if err := db.Count(&total).Error; err != nil {
+ return records, total, err
+ }
+ if slf.PageNum > 0 && slf.PageSize > 0 {
+ db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize)
+ }
+
+ err := db.Find(&records).Error
+ return records, total, err
+}
+
+// InitDefaultData 鍒濆鍖栨暟鎹�
+func (slf *PlcBrandSearch) InitDefaultData() error {
+ var (
+ db = slf.Orm.Table(slf.TableName())
+ total int64 = 0
+ )
+ if err := db.Count(&total).Error; err != nil {
+ return err
+ }
+ if total != 0 {
+ return nil
+ }
+ records := []*PlcBrand{}
+ return slf.CreateBatch(records)
+}
diff --git a/model/procedures.go b/model/procedures.go
index c2803d1..a1fb11b 100644
--- a/model/procedures.go
+++ b/model/procedures.go
@@ -1,7 +1,7 @@
package model
import (
- "apsClient/model/request"
+ "apsClient/model/common"
"apsClient/pkg/logx"
"apsClient/pkg/sqlitex"
"encoding/json"
@@ -18,8 +18,8 @@
StartTime int64 `gorm:"comment:璁″垝寮�濮嬫椂闂�" json:"startTime"`
EndTime int64 `gorm:"comment:璁″垝缁撴潫鏃堕棿" json:"endTime"`
Status ProcedureStatus
- ProcedureData string `json:"-"` //request.ProductProcedure json涓�
- ProceduresInfo request.ProductProcedure `json:"procedure" gorm:"-"` //request.ProductProcedure 瀵硅薄
+ ProcedureData string `json:"-"` //common.ProductProcedure json涓�
+ ProceduresInfo common.ProductProcedure `json:"procedure" gorm:"-"` //common.ProductProcedure 瀵硅薄
}
ProceduresSearch struct {
@@ -44,7 +44,7 @@
return "procedures"
}
func (slf *Procedures) AfterFind(db *gorm.DB) error {
- var proceduresInfo request.ProductProcedure
+ var proceduresInfo common.ProductProcedure
err := json.Unmarshal([]byte(slf.ProcedureData), &proceduresInfo)
if err != nil {
logx.Errorf("AfterFind Unmarshal err: %v", err.Error())
@@ -107,6 +107,10 @@
db = db.Order(slf.Order)
}
+ if slf.ID != 0 {
+ db = db.Where("id = ?", slf.ID)
+ }
+
if slf.WorkOrderID != "" {
db = db.Where("work_order_id = ?", slf.WorkOrderID)
}
diff --git a/model/request/plcBrand.go b/model/request/plcBrand.go
new file mode 100644
index 0000000..dde82ba
--- /dev/null
+++ b/model/request/plcBrand.go
@@ -0,0 +1,22 @@
+package request
+
+import (
+ "apsClient/constvar"
+ "apsClient/model"
+)
+
+type AddPlcBrand struct {
+ model.PlcBrand
+}
+
+type UpdatePlcBrand struct {
+ Id int `json:"id"`
+ model.PlcBrand
+}
+
+type GetPlcBrandList struct {
+ PageInfo
+ QueryClass constvar.PlcBrandQueryClass `json:"queryClass" form:"queryClass"`
+ KeywordType constvar.PlcBrandKeywordType `json:"keywordType" form:"keywordType"`
+ Keyword string `json:"keyword" form:"keyword"`
+}
diff --git a/model/request/schedule_task.go b/model/request/schedule_task.go
index dfe7a8e..725b8fc 100644
--- a/model/request/schedule_task.go
+++ b/model/request/schedule_task.go
@@ -1,54 +1 @@
package request
-
-import "github.com/shopspring/decimal"
-
-// 鎺掔▼浠诲姟涓嬪彂
-type (
- WorkOrder struct {
- WorkOrderID string `json:"workOrderId"`
- OrderID string `gorm:"index;type:varchar(191);not null;comment:璁㈠崟ID" json:"orderId"`
- ProductID string `gorm:"type:varchar(191);comment:浜у搧ID" json:"productId"`
- ProductName string `gorm:"type:varchar(191);comment:浜у搧鍚嶇О" json:"productName"`
- Parameter string `gorm:"type:varchar(1024);comment:鍙傛暟闇�姹�" json:"parameter"`
- Customer string `gorm:"type:varchar(191);comment:瀹㈡埛缂栫爜" json:"customer"`
- DeliverDate string `gorm:"type:varchar(100);comment:浜よ揣鏃ユ湡" json:"deliverDate"`
- OrderAttr string `json:"orderAttr"` // 璁㈠崟灞炴�ф嫾鎺ョ殑瀛楃涓诧紝鍗宠揣鐗╂弿杩�
- Amount decimal.Decimal `gorm:"type:decimal(35,18);comment:鏁伴噺" json:"amount"`
- Unit string `gorm:"type:varchar(100);comment:鍗曚綅" json:"unit"`
- StartTime int64 `gorm:"comment:璁″垝寮�濮嬫椂闂�" json:"startTime"`
- EndTime int64 `gorm:"comment:璁″垝缁撴潫鏃堕棿" json:"endTime"`
- }
-
- ProcedureMaterial struct {
- MaterialID string `gorm:"type:varchar(191);comment:鐗╂枡缂栧彿" json:"materialId"`
- MaterialName string `gorm:"unique;type:varchar(191);not null;comment:鐗╂枡鍚嶇О" json:"materialName"`
- Amount decimal.Decimal `gorm:"type:decimal(35,18);comment:鏁伴噺" json:"amount"`
- Unit string `gorm:"type:varchar(191);comment:鍗曚綅" json:"unit"`
- }
-
- ProcedureWorker struct {
- WorkerID string `gorm:"type:varchar(2048);comment:浜哄憳ID" json:"workerId"`
- WorkerName string `gorm:"unique;type:varchar(191);not null;comment:浜哄憳濮撳悕" json:"workerName"`
- PhoneNum string `gorm:"type:varchar(191);comment:鎵嬫満鍙�" json:"phoneNum"`
- StartTime int64 `gorm:"comment:寮�濮嬫椂闂�" json:"startTime"`
- EndTime int64 `gorm:"comment:缁撴潫鏃堕棿" json:"endTime"`
- }
-
- ProductProcedure struct {
- ProcedureID string `gorm:"uniqueIndex:idx_product_procedure;type:varchar(191);comment:宸ュ簭ID" json:"procedureId"`
- ProcedureName string `gorm:"type:varchar(191);comment:宸ュ簭鍚嶇О锛屼粎鏌ヨ鐢�" json:"procedureName"`
- DeviceID string `gorm:"type:varchar(191);not null;comment:璁惧ID" json:"deviceId"`
- DeviceName string `gorm:"type:varchar(191);not null;comment:璁惧鍚嶇О" json:"deviceName"`
- StartTime int64 `gorm:"comment:璁″垝寮�濮嬫椂闂�" json:"startTime"`
- EndTime int64 `gorm:"comment:璁″垝缁撴潫鏃堕棿" json:"endTime"`
- WorkHours decimal.Decimal `gorm:"type:decimal(35,18);comment:宸ユ椂" json:"workHours"`
- InputMaterials []*ProcedureMaterial `json:"inputMaterials"` // 杈撳叆鐗╂枡鍒楄〃
- OutputMaterials []*ProcedureMaterial `json:"outputMaterials"` // 杈撳嚭鐗╂枡鍒楄〃
- Workers []*ProcedureWorker `json:"workers"` // 浜哄憳鍒楄〃
- }
-
- DeliverScheduleTask struct {
- WorkOrder WorkOrder `json:"workOrder"`
- Procedures []*ProductProcedure `json:"procedures"` // 宸ュ簭鍒楄〃
- }
-)
diff --git a/model/response/common.go b/model/response/common.go
index 3d84bab..f162e49 100644
--- a/model/response/common.go
+++ b/model/response/common.go
@@ -11,12 +11,31 @@
PageSize int `json:"pageSize"`
}
+type ListResponse struct {
+ Code int `json:"code"`
+ Msg string `json:"msg"`
+ Data interface{} `json:"data"`
+ Count int64 `json:"count"`
+}
+
type TaskData struct {
- Order *model.Order
- Procedure *model.Procedures
+ Order *model.Order
+ Procedure *model.Procedures
+ NextProcedure *model.Procedures
+ Config
+}
+
+type Config struct {
+ DeviceName string
+ DeviceStatus string
}
type ProcessParams struct {
Key string
Value interface{}
}
+
+type NetConfig struct {
+ DeviceName string
+ DeviceStatus string
+}
diff --git a/model/work_order.go b/model/work_order.go
index 80a770b..ed4ca40 100644
--- a/model/work_order.go
+++ b/model/work_order.go
@@ -97,7 +97,7 @@
}
if slf.WorkOrderID != "" {
- db = db.Where("work_order_id = ?", slf.OrderID)
+ db = db.Where("work_order_id = ?", slf.WorkOrderID)
}
if slf.Status != 0 {
diff --git a/nsq/msg_handler.go b/nsq/msg_handler.go
index 7545fe7..9485653 100644
--- a/nsq/msg_handler.go
+++ b/nsq/msg_handler.go
@@ -3,7 +3,7 @@
import (
"apsClient/conf"
"apsClient/model"
- "apsClient/model/request"
+ "apsClient/model/common"
"apsClient/pkg/logx"
"apsClient/pkg/structx"
"encoding/json"
@@ -19,7 +19,7 @@
func (slf *ScheduleTask) HandleMessage(data []byte) (err error) {
logx.Infof("get an message :%s", data)
- var tasks = make([]*request.DeliverScheduleTask, 0)
+ var tasks = make([]*common.DeliverScheduleTask, 0)
err = json.Unmarshal(data, &tasks)
if err != nil {
logx.Errorf("ScheduleTask HandleMessage Unmarshal json err: %v", err.Error())
diff --git a/pkg/contextx/contextx.go b/pkg/contextx/contextx.go
index 5531fe7..aa450eb 100644
--- a/pkg/contextx/contextx.go
+++ b/pkg/contextx/contextx.go
@@ -96,6 +96,10 @@
slf.Result(errCode, map[string]interface{}{}, ecode.GetMsg(errCode))
}
+func (slf *Context) FailWithMsg(errCode int, msg string) {
+ slf.Result(errCode, map[string]interface{}{}, msg)
+}
+
func (slf *Context) FailWithDetailed(errCode int, data interface{}) {
slf.Result(errCode, data, ecode.GetMsg(errCode))
}
diff --git a/router/index.go b/router/index.go
index 8da5cc4..3ba1a70 100644
--- a/router/index.go
+++ b/router/index.go
@@ -41,5 +41,21 @@
taskGroup.POST("sendProcessParams/:id", taskApi.SendProcessParams) // 涓嬪彂宸ヨ壓鍙傛暟
}
+ configApi := new(v1.ConfigApi)
+ configGroup := v1Group.Group("config")
+ {
+ configGroup.GET("net", configApi.GetNetConfig) // 鑾峰彇缃戠粶閰嶇疆
+ configGroup.POST("net", configApi.SetNetConfig) // 璁剧疆缃戠粶
+ }
+
+ configApi1 := new(v1.ConfigApi2)
+ configGroup1 := v1Group.Group("cc")
+ {
+ configGroup1.GET("nn", configApi1.GetNetConfig) // 鑾峰彇缃戠粶閰嶇疆
+ configGroup1.POST("nn", configApi1.SetNetConfig) // 璁剧疆缃戠粶
+ }
+
+ InitPlcBrandRouter(v1Group)
+
return Router
}
diff --git a/router/plc_brand.go b/router/plc_brand.go
new file mode 100644
index 0000000..b2911b5
--- /dev/null
+++ b/router/plc_brand.go
@@ -0,0 +1,17 @@
+package router
+
+import (
+ v1 "apsClient/api/v1"
+ "github.com/gin-gonic/gin"
+)
+
+func InitPlcBrandRouter(router *gin.RouterGroup) {
+ PlcBrandRouter := router.Group("plcBrand")
+ PlcBrandApi := v1.PlcBrandApi{}
+ {
+ PlcBrandRouter.POST("add", PlcBrandApi.Add) // 娣诲姞plc鍝佺墝
+ PlcBrandRouter.DELETE("delete/:id", PlcBrandApi.Delete) // 鍒犻櫎plc鍝佺墝
+ PlcBrandRouter.PUT("update", PlcBrandApi.Update) // 鏇存柊plc鍝佺墝
+ PlcBrandRouter.GET("list", PlcBrandApi.List) // 鑾峰彇plc鍝佺墝鍒楄〃
+ }
+}
diff --git a/service/config.go b/service/config.go
new file mode 100644
index 0000000..3378b2a
--- /dev/null
+++ b/service/config.go
@@ -0,0 +1,27 @@
+package service
+
+import (
+ "apsClient/model"
+)
+
+type ConfigService struct {
+}
+
+func NewConfigService() *ConfigService {
+ return &ConfigService{}
+}
+
+// GetNetConfigList 鑾峰彇缃戠粶閰嶇疆鍒楄〃
+func (slf ConfigService) GetNetConfigList() (ConfigData []*model.NetConfig, err error) {
+ return model.NewNetConfigSearch(nil).FindNotTotal()
+}
+
+// GetNetConfig 鑾峰彇缃戠粶閰嶇疆
+func (slf ConfigService) GetNetConfig(id int) (ConfigData *model.NetConfig, err error) {
+ return model.NewNetConfigSearch(nil).SetId(id).First()
+}
+
+// SetNetConfig 璁剧疆缃戠粶閰嶇疆
+func (slf ConfigService) SetNetConfig(id int, config *model.NetConfig) error {
+ return model.NewNetConfigSearch(nil).SetId(id).Save(config)
+}
diff --git a/service/plc_brand.go b/service/plc_brand.go
new file mode 100644
index 0000000..36628cd
--- /dev/null
+++ b/service/plc_brand.go
@@ -0,0 +1,73 @@
+package service
+
+import (
+ "apsClient/model"
+ "apsClient/model/request"
+ "apsClient/pkg/ecode"
+)
+
+type PlcBrandService struct{}
+
+func NewPlcBrandService() PlcBrandService {
+ return PlcBrandService{}
+}
+
+func (PlcBrandService) AddPlcBrand(plcBrand *model.PlcBrand) int {
+ err := model.NewPlcBrandSearch().Create(plcBrand)
+ if err != nil {
+ return ecode.DBErr
+ }
+
+ return ecode.OK
+}
+
+func (PlcBrandService) GetPlcBrand(id int) (*model.PlcBrand, int) {
+ plcBrand, err := model.NewPlcBrandSearch().SetId(id).First()
+ if err != nil {
+ return nil, ecode.DBErr
+ }
+
+ return plcBrand, ecode.OK
+}
+
+func (PlcBrandService) DeletePlcBrand(id int) int {
+ err := model.NewPlcBrandSearch().SetId(id).Delete()
+ if err != nil {
+ return ecode.DBErr
+ }
+ return ecode.OK
+}
+
+func (PlcBrandService) GetPlcBrandList() ([]*model.PlcBrand, int64, int) {
+ list, total, err := model.NewPlcBrandSearch().Find()
+ if err != nil {
+ return nil, 0, ecode.DBErr
+ }
+
+ return list, total, ecode.OK
+}
+
+func (PlcBrandService) UpdatePlcBrands(PlcBrands []*request.UpdatePlcBrand) int {
+ for _, v := range PlcBrands {
+ // check PlcBrand exist
+ _, err := model.NewPlcBrandSearch().SetId(v.Id).First()
+ if err != nil {
+ return ecode.DBErr
+ }
+
+ err = model.NewPlcBrandSearch().SetId(v.Id).Updates(map[string]interface{}{})
+ if err != nil {
+ return ecode.DBErr
+ }
+ }
+
+ return ecode.OK
+}
+
+func (PlcBrandService) UpdatePlcBrand(plcBrand *model.PlcBrand) int {
+ err := model.NewPlcBrandSearch().SetId(plcBrand.Id).Save(plcBrand)
+ if err != nil {
+ return ecode.DBErr
+ }
+ return ecode.OK
+}
diff --git a/service/task.go b/service/task.go
index 3cb816f..e173964 100644
--- a/service/task.go
+++ b/service/task.go
@@ -52,9 +52,18 @@
if err != nil {
return nil, ecode.DBErr
}
+ nextProcedure := new(model.Procedures)
+ nextProcedure, err = model.NewProceduresSearch(nil).
+ SetWorkOrderId(order.WorkOrderID).
+ SetStatus(model.ProcedureStatusUnFinished).
+ SetId(procedure.ID + 1).First()
+ if err == nil {
+ nextProcedure.ProceduresInfo.ProcedureName = "--"
+ }
taskData = new(response.TaskData)
taskData.Order = order
taskData.Procedure = procedure
+ taskData.NextProcedure = nextProcedure
return taskData, ecode.OK
}
--
Gitblit v1.8.0