枚举改成中文
This commit is contained in:
57
docs/docs.go
57
docs/docs.go
@@ -1345,8 +1345,8 @@ const docTemplate = `{
|
|||||||
"models.DeviceCategory": {
|
"models.DeviceCategory": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
"actuator",
|
"执行器",
|
||||||
"sensor"
|
"传感器"
|
||||||
],
|
],
|
||||||
"x-enum-varnames": [
|
"x-enum-varnames": [
|
||||||
"CategoryActuator",
|
"CategoryActuator",
|
||||||
@@ -1356,8 +1356,8 @@ const docTemplate = `{
|
|||||||
"models.PlanContentType": {
|
"models.PlanContentType": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
"sub_plans",
|
"子计划",
|
||||||
"tasks"
|
"任务"
|
||||||
],
|
],
|
||||||
"x-enum-comments": {
|
"x-enum-comments": {
|
||||||
"PlanContentTypeSubPlans": "计划包含子计划",
|
"PlanContentTypeSubPlans": "计划包含子计划",
|
||||||
@@ -1375,8 +1375,8 @@ const docTemplate = `{
|
|||||||
"models.PlanExecutionType": {
|
"models.PlanExecutionType": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
"automatic",
|
"自动",
|
||||||
"manual"
|
"手动"
|
||||||
],
|
],
|
||||||
"x-enum-comments": {
|
"x-enum-comments": {
|
||||||
"PlanExecutionTypeAutomatic": "自动执行 (包含定时和循环)",
|
"PlanExecutionTypeAutomatic": "自动执行 (包含定时和循环)",
|
||||||
@@ -1392,19 +1392,18 @@ const docTemplate = `{
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"models.PlanStatus": {
|
"models.PlanStatus": {
|
||||||
"type": "integer",
|
"type": "string",
|
||||||
"format": "int32",
|
|
||||||
"enum": [
|
"enum": [
|
||||||
0,
|
"已禁用",
|
||||||
1,
|
"已启用",
|
||||||
2,
|
"执行完毕",
|
||||||
3
|
"执行失败"
|
||||||
],
|
],
|
||||||
"x-enum-comments": {
|
"x-enum-comments": {
|
||||||
"PlanStatusDisabled": "禁用计划",
|
"PlanStatusDisabled": "禁用计划",
|
||||||
"PlanStatusEnabled": "启用计划",
|
"PlanStatusEnabled": "启用计划",
|
||||||
"PlanStatusFailed": "执行失败",
|
"PlanStatusFailed": "执行失败",
|
||||||
"PlanStatusStopeed": "执行完毕"
|
"PlanStatusStopped": "执行完毕"
|
||||||
},
|
},
|
||||||
"x-enum-descriptions": [
|
"x-enum-descriptions": [
|
||||||
"禁用计划",
|
"禁用计划",
|
||||||
@@ -1415,18 +1414,18 @@ const docTemplate = `{
|
|||||||
"x-enum-varnames": [
|
"x-enum-varnames": [
|
||||||
"PlanStatusDisabled",
|
"PlanStatusDisabled",
|
||||||
"PlanStatusEnabled",
|
"PlanStatusEnabled",
|
||||||
"PlanStatusStopeed",
|
"PlanStatusStopped",
|
||||||
"PlanStatusFailed"
|
"PlanStatusFailed"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"models.SensorType": {
|
"models.SensorType": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
"signal_metrics",
|
"信号强度",
|
||||||
"battery_level",
|
"电池电量",
|
||||||
"temperature",
|
"温度",
|
||||||
"humidity",
|
"湿度",
|
||||||
"weight"
|
"重量"
|
||||||
],
|
],
|
||||||
"x-enum-comments": {
|
"x-enum-comments": {
|
||||||
"SensorTypeBatteryLevel": "电池电量",
|
"SensorTypeBatteryLevel": "电池电量",
|
||||||
@@ -1453,9 +1452,9 @@ const docTemplate = `{
|
|||||||
"models.TaskType": {
|
"models.TaskType": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
"plan_analysis",
|
"计划分析",
|
||||||
"waiting",
|
"等待",
|
||||||
"release_feed_weight"
|
"下料"
|
||||||
],
|
],
|
||||||
"x-enum-comments": {
|
"x-enum-comments": {
|
||||||
"TaskPlanAnalysis": "解析Plan的Task列表并添加到待执行队列的特殊任务",
|
"TaskPlanAnalysis": "解析Plan的Task列表并添加到待执行队列的特殊任务",
|
||||||
@@ -1514,7 +1513,7 @@ const docTemplate = `{
|
|||||||
"$ref": "#/definitions/models.PlanExecutionType"
|
"$ref": "#/definitions/models.PlanExecutionType"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"example": "automatic"
|
"example": "自动"
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@@ -1558,7 +1557,7 @@ const docTemplate = `{
|
|||||||
"$ref": "#/definitions/models.PlanContentType"
|
"$ref": "#/definitions/models.PlanContentType"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"example": "tasks"
|
"example": "任务"
|
||||||
},
|
},
|
||||||
"cron_expression": {
|
"cron_expression": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@@ -1582,7 +1581,7 @@ const docTemplate = `{
|
|||||||
"$ref": "#/definitions/models.PlanExecutionType"
|
"$ref": "#/definitions/models.PlanExecutionType"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"example": "automatic"
|
"example": "自动"
|
||||||
},
|
},
|
||||||
"id": {
|
"id": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
@@ -1598,7 +1597,7 @@ const docTemplate = `{
|
|||||||
"$ref": "#/definitions/models.PlanStatus"
|
"$ref": "#/definitions/models.PlanStatus"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"example": 0
|
"example": "已启用"
|
||||||
},
|
},
|
||||||
"sub_plans": {
|
"sub_plans": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
@@ -1663,7 +1662,7 @@ const docTemplate = `{
|
|||||||
"$ref": "#/definitions/models.TaskType"
|
"$ref": "#/definitions/models.TaskType"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"example": "waiting"
|
"example": "等待"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -1700,7 +1699,7 @@ const docTemplate = `{
|
|||||||
"$ref": "#/definitions/models.TaskType"
|
"$ref": "#/definitions/models.TaskType"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"example": "waiting"
|
"example": "等待"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -1725,7 +1724,7 @@ const docTemplate = `{
|
|||||||
"$ref": "#/definitions/models.PlanExecutionType"
|
"$ref": "#/definitions/models.PlanExecutionType"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"example": "automatic"
|
"example": "自动"
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|||||||
@@ -1334,8 +1334,8 @@
|
|||||||
"models.DeviceCategory": {
|
"models.DeviceCategory": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
"actuator",
|
"执行器",
|
||||||
"sensor"
|
"传感器"
|
||||||
],
|
],
|
||||||
"x-enum-varnames": [
|
"x-enum-varnames": [
|
||||||
"CategoryActuator",
|
"CategoryActuator",
|
||||||
@@ -1345,8 +1345,8 @@
|
|||||||
"models.PlanContentType": {
|
"models.PlanContentType": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
"sub_plans",
|
"子计划",
|
||||||
"tasks"
|
"任务"
|
||||||
],
|
],
|
||||||
"x-enum-comments": {
|
"x-enum-comments": {
|
||||||
"PlanContentTypeSubPlans": "计划包含子计划",
|
"PlanContentTypeSubPlans": "计划包含子计划",
|
||||||
@@ -1364,8 +1364,8 @@
|
|||||||
"models.PlanExecutionType": {
|
"models.PlanExecutionType": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
"automatic",
|
"自动",
|
||||||
"manual"
|
"手动"
|
||||||
],
|
],
|
||||||
"x-enum-comments": {
|
"x-enum-comments": {
|
||||||
"PlanExecutionTypeAutomatic": "自动执行 (包含定时和循环)",
|
"PlanExecutionTypeAutomatic": "自动执行 (包含定时和循环)",
|
||||||
@@ -1381,19 +1381,18 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"models.PlanStatus": {
|
"models.PlanStatus": {
|
||||||
"type": "integer",
|
"type": "string",
|
||||||
"format": "int32",
|
|
||||||
"enum": [
|
"enum": [
|
||||||
0,
|
"已禁用",
|
||||||
1,
|
"已启用",
|
||||||
2,
|
"执行完毕",
|
||||||
3
|
"执行失败"
|
||||||
],
|
],
|
||||||
"x-enum-comments": {
|
"x-enum-comments": {
|
||||||
"PlanStatusDisabled": "禁用计划",
|
"PlanStatusDisabled": "禁用计划",
|
||||||
"PlanStatusEnabled": "启用计划",
|
"PlanStatusEnabled": "启用计划",
|
||||||
"PlanStatusFailed": "执行失败",
|
"PlanStatusFailed": "执行失败",
|
||||||
"PlanStatusStopeed": "执行完毕"
|
"PlanStatusStopped": "执行完毕"
|
||||||
},
|
},
|
||||||
"x-enum-descriptions": [
|
"x-enum-descriptions": [
|
||||||
"禁用计划",
|
"禁用计划",
|
||||||
@@ -1404,18 +1403,18 @@
|
|||||||
"x-enum-varnames": [
|
"x-enum-varnames": [
|
||||||
"PlanStatusDisabled",
|
"PlanStatusDisabled",
|
||||||
"PlanStatusEnabled",
|
"PlanStatusEnabled",
|
||||||
"PlanStatusStopeed",
|
"PlanStatusStopped",
|
||||||
"PlanStatusFailed"
|
"PlanStatusFailed"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"models.SensorType": {
|
"models.SensorType": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
"signal_metrics",
|
"信号强度",
|
||||||
"battery_level",
|
"电池电量",
|
||||||
"temperature",
|
"温度",
|
||||||
"humidity",
|
"湿度",
|
||||||
"weight"
|
"重量"
|
||||||
],
|
],
|
||||||
"x-enum-comments": {
|
"x-enum-comments": {
|
||||||
"SensorTypeBatteryLevel": "电池电量",
|
"SensorTypeBatteryLevel": "电池电量",
|
||||||
@@ -1442,9 +1441,9 @@
|
|||||||
"models.TaskType": {
|
"models.TaskType": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
"plan_analysis",
|
"计划分析",
|
||||||
"waiting",
|
"等待",
|
||||||
"release_feed_weight"
|
"下料"
|
||||||
],
|
],
|
||||||
"x-enum-comments": {
|
"x-enum-comments": {
|
||||||
"TaskPlanAnalysis": "解析Plan的Task列表并添加到待执行队列的特殊任务",
|
"TaskPlanAnalysis": "解析Plan的Task列表并添加到待执行队列的特殊任务",
|
||||||
@@ -1503,7 +1502,7 @@
|
|||||||
"$ref": "#/definitions/models.PlanExecutionType"
|
"$ref": "#/definitions/models.PlanExecutionType"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"example": "automatic"
|
"example": "自动"
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@@ -1547,7 +1546,7 @@
|
|||||||
"$ref": "#/definitions/models.PlanContentType"
|
"$ref": "#/definitions/models.PlanContentType"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"example": "tasks"
|
"example": "任务"
|
||||||
},
|
},
|
||||||
"cron_expression": {
|
"cron_expression": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@@ -1571,7 +1570,7 @@
|
|||||||
"$ref": "#/definitions/models.PlanExecutionType"
|
"$ref": "#/definitions/models.PlanExecutionType"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"example": "automatic"
|
"example": "自动"
|
||||||
},
|
},
|
||||||
"id": {
|
"id": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
@@ -1587,7 +1586,7 @@
|
|||||||
"$ref": "#/definitions/models.PlanStatus"
|
"$ref": "#/definitions/models.PlanStatus"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"example": 0
|
"example": "已启用"
|
||||||
},
|
},
|
||||||
"sub_plans": {
|
"sub_plans": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
@@ -1652,7 +1651,7 @@
|
|||||||
"$ref": "#/definitions/models.TaskType"
|
"$ref": "#/definitions/models.TaskType"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"example": "waiting"
|
"example": "等待"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -1689,7 +1688,7 @@
|
|||||||
"$ref": "#/definitions/models.TaskType"
|
"$ref": "#/definitions/models.TaskType"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"example": "waiting"
|
"example": "等待"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -1714,7 +1713,7 @@
|
|||||||
"$ref": "#/definitions/models.PlanExecutionType"
|
"$ref": "#/definitions/models.PlanExecutionType"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"example": "automatic"
|
"example": "自动"
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|||||||
@@ -229,16 +229,16 @@ definitions:
|
|||||||
type: object
|
type: object
|
||||||
models.DeviceCategory:
|
models.DeviceCategory:
|
||||||
enum:
|
enum:
|
||||||
- actuator
|
- 执行器
|
||||||
- sensor
|
- 传感器
|
||||||
type: string
|
type: string
|
||||||
x-enum-varnames:
|
x-enum-varnames:
|
||||||
- CategoryActuator
|
- CategoryActuator
|
||||||
- CategorySensor
|
- CategorySensor
|
||||||
models.PlanContentType:
|
models.PlanContentType:
|
||||||
enum:
|
enum:
|
||||||
- sub_plans
|
- 子计划
|
||||||
- tasks
|
- 任务
|
||||||
type: string
|
type: string
|
||||||
x-enum-comments:
|
x-enum-comments:
|
||||||
PlanContentTypeSubPlans: 计划包含子计划
|
PlanContentTypeSubPlans: 计划包含子计划
|
||||||
@@ -251,8 +251,8 @@ definitions:
|
|||||||
- PlanContentTypeTasks
|
- PlanContentTypeTasks
|
||||||
models.PlanExecutionType:
|
models.PlanExecutionType:
|
||||||
enum:
|
enum:
|
||||||
- automatic
|
- 自动
|
||||||
- manual
|
- 手动
|
||||||
type: string
|
type: string
|
||||||
x-enum-comments:
|
x-enum-comments:
|
||||||
PlanExecutionTypeAutomatic: 自动执行 (包含定时和循环)
|
PlanExecutionTypeAutomatic: 自动执行 (包含定时和循环)
|
||||||
@@ -265,17 +265,16 @@ definitions:
|
|||||||
- PlanExecutionTypeManual
|
- PlanExecutionTypeManual
|
||||||
models.PlanStatus:
|
models.PlanStatus:
|
||||||
enum:
|
enum:
|
||||||
- 0
|
- 已禁用
|
||||||
- 1
|
- 已启用
|
||||||
- 2
|
- 执行完毕
|
||||||
- 3
|
- 执行失败
|
||||||
format: int32
|
type: string
|
||||||
type: integer
|
|
||||||
x-enum-comments:
|
x-enum-comments:
|
||||||
PlanStatusDisabled: 禁用计划
|
PlanStatusDisabled: 禁用计划
|
||||||
PlanStatusEnabled: 启用计划
|
PlanStatusEnabled: 启用计划
|
||||||
PlanStatusFailed: 执行失败
|
PlanStatusFailed: 执行失败
|
||||||
PlanStatusStopeed: 执行完毕
|
PlanStatusStopped: 执行完毕
|
||||||
x-enum-descriptions:
|
x-enum-descriptions:
|
||||||
- 禁用计划
|
- 禁用计划
|
||||||
- 启用计划
|
- 启用计划
|
||||||
@@ -284,15 +283,15 @@ definitions:
|
|||||||
x-enum-varnames:
|
x-enum-varnames:
|
||||||
- PlanStatusDisabled
|
- PlanStatusDisabled
|
||||||
- PlanStatusEnabled
|
- PlanStatusEnabled
|
||||||
- PlanStatusStopeed
|
- PlanStatusStopped
|
||||||
- PlanStatusFailed
|
- PlanStatusFailed
|
||||||
models.SensorType:
|
models.SensorType:
|
||||||
enum:
|
enum:
|
||||||
- signal_metrics
|
- 信号强度
|
||||||
- battery_level
|
- 电池电量
|
||||||
- temperature
|
- 温度
|
||||||
- humidity
|
- 湿度
|
||||||
- weight
|
- 重量
|
||||||
type: string
|
type: string
|
||||||
x-enum-comments:
|
x-enum-comments:
|
||||||
SensorTypeBatteryLevel: 电池电量
|
SensorTypeBatteryLevel: 电池电量
|
||||||
@@ -314,9 +313,9 @@ definitions:
|
|||||||
- SensorTypeWeight
|
- SensorTypeWeight
|
||||||
models.TaskType:
|
models.TaskType:
|
||||||
enum:
|
enum:
|
||||||
- plan_analysis
|
- 计划分析
|
||||||
- waiting
|
- 等待
|
||||||
- release_feed_weight
|
- 下料
|
||||||
type: string
|
type: string
|
||||||
x-enum-comments:
|
x-enum-comments:
|
||||||
TaskPlanAnalysis: 解析Plan的Task列表并添加到待执行队列的特殊任务
|
TaskPlanAnalysis: 解析Plan的Task列表并添加到待执行队列的特殊任务
|
||||||
@@ -355,7 +354,7 @@ definitions:
|
|||||||
execution_type:
|
execution_type:
|
||||||
allOf:
|
allOf:
|
||||||
- $ref: '#/definitions/models.PlanExecutionType'
|
- $ref: '#/definitions/models.PlanExecutionType'
|
||||||
example: automatic
|
example: 自动
|
||||||
name:
|
name:
|
||||||
example: 猪舍温度控制计划
|
example: 猪舍温度控制计划
|
||||||
type: string
|
type: string
|
||||||
@@ -386,7 +385,7 @@ definitions:
|
|||||||
content_type:
|
content_type:
|
||||||
allOf:
|
allOf:
|
||||||
- $ref: '#/definitions/models.PlanContentType'
|
- $ref: '#/definitions/models.PlanContentType'
|
||||||
example: tasks
|
example: 任务
|
||||||
cron_expression:
|
cron_expression:
|
||||||
example: 0 0 6 * * *
|
example: 0 0 6 * * *
|
||||||
type: string
|
type: string
|
||||||
@@ -402,7 +401,7 @@ definitions:
|
|||||||
execution_type:
|
execution_type:
|
||||||
allOf:
|
allOf:
|
||||||
- $ref: '#/definitions/models.PlanExecutionType'
|
- $ref: '#/definitions/models.PlanExecutionType'
|
||||||
example: automatic
|
example: 自动
|
||||||
id:
|
id:
|
||||||
example: 1
|
example: 1
|
||||||
type: integer
|
type: integer
|
||||||
@@ -412,7 +411,7 @@ definitions:
|
|||||||
status:
|
status:
|
||||||
allOf:
|
allOf:
|
||||||
- $ref: '#/definitions/models.PlanStatus'
|
- $ref: '#/definitions/models.PlanStatus'
|
||||||
example: 0
|
example: 已启用
|
||||||
sub_plans:
|
sub_plans:
|
||||||
items:
|
items:
|
||||||
$ref: '#/definitions/plan.SubPlanResponse'
|
$ref: '#/definitions/plan.SubPlanResponse'
|
||||||
@@ -456,7 +455,7 @@ definitions:
|
|||||||
type:
|
type:
|
||||||
allOf:
|
allOf:
|
||||||
- $ref: '#/definitions/models.TaskType'
|
- $ref: '#/definitions/models.TaskType'
|
||||||
example: waiting
|
example: 等待
|
||||||
type: object
|
type: object
|
||||||
plan.TaskResponse:
|
plan.TaskResponse:
|
||||||
properties:
|
properties:
|
||||||
@@ -481,7 +480,7 @@ definitions:
|
|||||||
type:
|
type:
|
||||||
allOf:
|
allOf:
|
||||||
- $ref: '#/definitions/models.TaskType'
|
- $ref: '#/definitions/models.TaskType'
|
||||||
example: waiting
|
example: 等待
|
||||||
type: object
|
type: object
|
||||||
plan.UpdatePlanRequest:
|
plan.UpdatePlanRequest:
|
||||||
properties:
|
properties:
|
||||||
@@ -497,7 +496,7 @@ definitions:
|
|||||||
execution_type:
|
execution_type:
|
||||||
allOf:
|
allOf:
|
||||||
- $ref: '#/definitions/models.PlanExecutionType'
|
- $ref: '#/definitions/models.PlanExecutionType'
|
||||||
example: automatic
|
example: 自动
|
||||||
name:
|
name:
|
||||||
example: 猪舍温度控制计划V2
|
example: 猪舍温度控制计划V2
|
||||||
type: string
|
type: string
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import (
|
|||||||
type CreatePlanRequest struct {
|
type CreatePlanRequest struct {
|
||||||
Name string `json:"name" binding:"required" example:"猪舍温度控制计划"`
|
Name string `json:"name" binding:"required" example:"猪舍温度控制计划"`
|
||||||
Description string `json:"description" example:"根据温度自动调节风扇和加热器"`
|
Description string `json:"description" example:"根据温度自动调节风扇和加热器"`
|
||||||
ExecutionType models.PlanExecutionType `json:"execution_type" binding:"required" example:"automatic"`
|
ExecutionType models.PlanExecutionType `json:"execution_type" binding:"required" example:"自动"`
|
||||||
ExecuteNum uint `json:"execute_num,omitempty" example:"10"`
|
ExecuteNum uint `json:"execute_num,omitempty" example:"10"`
|
||||||
CronExpression string `json:"cron_expression" example:"0 0 6 * * *"`
|
CronExpression string `json:"cron_expression" example:"0 0 6 * * *"`
|
||||||
SubPlanIDs []uint `json:"sub_plan_ids,omitempty"`
|
SubPlanIDs []uint `json:"sub_plan_ids,omitempty"`
|
||||||
@@ -31,12 +31,12 @@ type PlanResponse struct {
|
|||||||
ID uint `json:"id" example:"1"`
|
ID uint `json:"id" example:"1"`
|
||||||
Name string `json:"name" example:"猪舍温度控制计划"`
|
Name string `json:"name" example:"猪舍温度控制计划"`
|
||||||
Description string `json:"description" example:"根据温度自动调节风扇和加热器"`
|
Description string `json:"description" example:"根据温度自动调节风扇和加热器"`
|
||||||
ExecutionType models.PlanExecutionType `json:"execution_type" example:"automatic"`
|
ExecutionType models.PlanExecutionType `json:"execution_type" example:"自动"`
|
||||||
Status models.PlanStatus `json:"status" example:"0"`
|
Status models.PlanStatus `json:"status" example:"已启用"`
|
||||||
ExecuteNum uint `json:"execute_num" example:"10"`
|
ExecuteNum uint `json:"execute_num" example:"10"`
|
||||||
ExecuteCount uint `json:"execute_count" example:"0"`
|
ExecuteCount uint `json:"execute_count" example:"0"`
|
||||||
CronExpression string `json:"cron_expression" example:"0 0 6 * * *"`
|
CronExpression string `json:"cron_expression" example:"0 0 6 * * *"`
|
||||||
ContentType models.PlanContentType `json:"content_type" example:"tasks"`
|
ContentType models.PlanContentType `json:"content_type" example:"任务"`
|
||||||
SubPlans []SubPlanResponse `json:"sub_plans,omitempty"`
|
SubPlans []SubPlanResponse `json:"sub_plans,omitempty"`
|
||||||
Tasks []TaskResponse `json:"tasks,omitempty"`
|
Tasks []TaskResponse `json:"tasks,omitempty"`
|
||||||
}
|
}
|
||||||
@@ -51,7 +51,7 @@ type ListPlansResponse struct {
|
|||||||
type UpdatePlanRequest struct {
|
type UpdatePlanRequest struct {
|
||||||
Name string `json:"name" example:"猪舍温度控制计划V2"`
|
Name string `json:"name" example:"猪舍温度控制计划V2"`
|
||||||
Description string `json:"description" example:"更新后的描述"`
|
Description string `json:"description" example:"更新后的描述"`
|
||||||
ExecutionType models.PlanExecutionType `json:"execution_type" example:"automatic"`
|
ExecutionType models.PlanExecutionType `json:"execution_type" example:"自动"`
|
||||||
ExecuteNum uint `json:"execute_num,omitempty" example:"10"`
|
ExecuteNum uint `json:"execute_num,omitempty" example:"10"`
|
||||||
CronExpression string `json:"cron_expression" example:"0 0 6 * * *"`
|
CronExpression string `json:"cron_expression" example:"0 0 6 * * *"`
|
||||||
SubPlanIDs []uint `json:"sub_plan_ids,omitempty"`
|
SubPlanIDs []uint `json:"sub_plan_ids,omitempty"`
|
||||||
@@ -72,7 +72,7 @@ type TaskRequest struct {
|
|||||||
Name string `json:"name" example:"打开风扇"`
|
Name string `json:"name" example:"打开风扇"`
|
||||||
Description string `json:"description" example:"打开1号风扇"`
|
Description string `json:"description" example:"打开1号风扇"`
|
||||||
ExecutionOrder int `json:"execution_order" example:"1"`
|
ExecutionOrder int `json:"execution_order" example:"1"`
|
||||||
Type models.TaskType `json:"type" example:"waiting"`
|
Type models.TaskType `json:"type" example:"等待"`
|
||||||
Parameters map[string]interface{} `json:"parameters,omitempty"`
|
Parameters map[string]interface{} `json:"parameters,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ type TaskResponse struct {
|
|||||||
Name string `json:"name" example:"打开风扇"`
|
Name string `json:"name" example:"打开风扇"`
|
||||||
Description string `json:"description" example:"打开1号风扇"`
|
Description string `json:"description" example:"打开1号风扇"`
|
||||||
ExecutionOrder int `json:"execution_order" example:"1"`
|
ExecutionOrder int `json:"execution_order" example:"1"`
|
||||||
Type models.TaskType `json:"type" example:"waiting"`
|
Type models.TaskType `json:"type" example:"等待"`
|
||||||
Parameters map[string]interface{} `json:"parameters,omitempty"`
|
Parameters map[string]interface{} `json:"parameters,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -435,7 +435,7 @@ func (s *Scheduler) handlePlanCompletion(planLogID uint) {
|
|||||||
|
|
||||||
// 如果是自动计划且达到执行次数上限,或计划是手动类型,则更新计划状态为已停止
|
// 如果是自动计划且达到执行次数上限,或计划是手动类型,则更新计划状态为已停止
|
||||||
if (plan.ExecutionType == models.PlanExecutionTypeAutomatic && plan.ExecuteNum > 0 && newExecuteCount >= plan.ExecuteNum) || plan.ExecutionType == models.PlanExecutionTypeManual {
|
if (plan.ExecutionType == models.PlanExecutionTypeAutomatic && plan.ExecuteNum > 0 && newExecuteCount >= plan.ExecuteNum) || plan.ExecutionType == models.PlanExecutionTypeManual {
|
||||||
newStatus = models.PlanStatusStopeed
|
newStatus = models.PlanStatusStopped
|
||||||
s.logger.Infof("计划 %d 已完成执行,状态更新为 '执行完毕'。", topLevelPlanID)
|
s.logger.Infof("计划 %d 已完成执行,状态更新为 '执行完毕'。", topLevelPlanID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ func (app *Application) initializePendingTasks(
|
|||||||
if plan.ExecutionType == models.PlanExecutionTypeManual ||
|
if plan.ExecutionType == models.PlanExecutionTypeManual ||
|
||||||
(plan.ExecutionType == models.PlanExecutionTypeAutomatic && plan.ExecuteCount >= plan.ExecuteNum) {
|
(plan.ExecutionType == models.PlanExecutionTypeAutomatic && plan.ExecuteCount >= plan.ExecuteNum) {
|
||||||
// 更新计划状态为已停止
|
// 更新计划状态为已停止
|
||||||
plan.Status = models.PlanStatusStopeed
|
plan.Status = models.PlanStatusStopped
|
||||||
logger.Infof("计划 #%d 状态已更新为 '执行完毕'。", plan.ID)
|
logger.Infof("计划 #%d 状态已更新为 '执行完毕'。", plan.ID)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ type DeviceCategory string
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
// CategoryActuator 代表一个执行器,可以被控制(例如:风机、阀门)
|
// CategoryActuator 代表一个执行器,可以被控制(例如:风机、阀门)
|
||||||
CategoryActuator DeviceCategory = "actuator"
|
CategoryActuator DeviceCategory = "执行器"
|
||||||
// CategorySensor 代表一个传感器,用于报告测量值(例如:温度计)
|
// CategorySensor 代表一个传感器,用于报告测量值(例如:温度计)
|
||||||
CategorySensor DeviceCategory = "sensor"
|
CategorySensor DeviceCategory = "传感器"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ValueDescriptor 描述了传感器可以报告的单个数值。
|
// ValueDescriptor 描述了传感器可以报告的单个数值。
|
||||||
|
|||||||
@@ -17,11 +17,11 @@ const (
|
|||||||
type ExecutionStatus string
|
type ExecutionStatus string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ExecutionStatusStarted ExecutionStatus = "started" // 开始执行
|
ExecutionStatusStarted ExecutionStatus = "已开始" // 开始执行
|
||||||
ExecutionStatusCompleted ExecutionStatus = "completed" // 执行完成
|
ExecutionStatusCompleted ExecutionStatus = "已完成" // 执行完成
|
||||||
ExecutionStatusFailed ExecutionStatus = "failed" // 执行失败
|
ExecutionStatusFailed ExecutionStatus = "失败" // 执行失败
|
||||||
ExecutionStatusCancelled ExecutionStatus = "cancelled" // 执行取消
|
ExecutionStatusCancelled ExecutionStatus = "已取消" // 执行取消
|
||||||
ExecutionStatusWaiting ExecutionStatus = "waiting" // 等待执行 (用于预写日志)
|
ExecutionStatusWaiting ExecutionStatus = "等待中" // 等待执行 (用于预写日志)
|
||||||
)
|
)
|
||||||
|
|
||||||
// PlanExecutionLog 记录整个计划的一次执行历史
|
// PlanExecutionLog 记录整个计划的一次执行历史
|
||||||
@@ -92,9 +92,9 @@ func (log *TaskExecutionLog) AfterFind(tx *gorm.DB) (err error) {
|
|||||||
type PendingCollectionStatus string
|
type PendingCollectionStatus string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
PendingStatusPending PendingCollectionStatus = "pending" // 请求已发送,等待设备响应
|
PendingStatusPending PendingCollectionStatus = "等待中" // 请求已发送,等待设备响应
|
||||||
PendingStatusFulfilled PendingCollectionStatus = "fulfilled" // 已收到设备响应并成功处理
|
PendingStatusFulfilled PendingCollectionStatus = "已完成" // 已收到设备响应并成功处理
|
||||||
PendingStatusTimedOut PendingCollectionStatus = "timed_out" // 请求超时,未收到设备响应
|
PendingStatusTimedOut PendingCollectionStatus = "已超时" // 请求超时,未收到设备响应
|
||||||
)
|
)
|
||||||
|
|
||||||
// DeviceCommandLog 记录所有“发后即忘”的下行指令日志。
|
// DeviceCommandLog 记录所有“发后即忘”的下行指令日志。
|
||||||
@@ -160,8 +160,8 @@ func (PendingCollection) TableName() string {
|
|||||||
type AuditStatus string
|
type AuditStatus string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
AuditStatusSuccess AuditStatus = "success"
|
AuditStatusSuccess AuditStatus = "成功"
|
||||||
AuditStatusFailed AuditStatus = "failed"
|
AuditStatusFailed AuditStatus = "失败"
|
||||||
)
|
)
|
||||||
|
|
||||||
// --- 审计日志相关上下文键 ---
|
// --- 审计日志相关上下文键 ---
|
||||||
|
|||||||
5
internal/infra/models/feed.go
Normal file
5
internal/infra/models/feed.go
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
package models
|
||||||
|
|
||||||
|
/*
|
||||||
|
饲料和饲喂相关的模型
|
||||||
|
*/
|
||||||
5
internal/infra/models/pig.go
Normal file
5
internal/infra/models/pig.go
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
package models
|
||||||
|
|
||||||
|
/*
|
||||||
|
和猪只本身相关的模型
|
||||||
|
*/
|
||||||
@@ -15,25 +15,25 @@ import (
|
|||||||
type PlanExecutionType string
|
type PlanExecutionType string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
PlanExecutionTypeAutomatic PlanExecutionType = "automatic" // 自动执行 (包含定时和循环)
|
PlanExecutionTypeAutomatic PlanExecutionType = "自动" // 自动执行 (包含定时和循环)
|
||||||
PlanExecutionTypeManual PlanExecutionType = "manual" // 手动执行
|
PlanExecutionTypeManual PlanExecutionType = "手动" // 手动执行
|
||||||
)
|
)
|
||||||
|
|
||||||
// PlanContentType 定义了计划包含的内容类型
|
// PlanContentType 定义了计划包含的内容类型
|
||||||
type PlanContentType string
|
type PlanContentType string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
PlanContentTypeSubPlans PlanContentType = "sub_plans" // 计划包含子计划
|
PlanContentTypeSubPlans PlanContentType = "子计划" // 计划包含子计划
|
||||||
PlanContentTypeTasks PlanContentType = "tasks" // 计划包含任务
|
PlanContentTypeTasks PlanContentType = "任务" // 计划包含任务
|
||||||
)
|
)
|
||||||
|
|
||||||
// TaskType 定义了任务的类型,每个类型可以对应 task 包中的一个具体动作
|
// TaskType 定义了任务的类型,每个类型可以对应 task 包中的一个具体动作
|
||||||
type TaskType string
|
type TaskType string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
TaskPlanAnalysis TaskType = "plan_analysis" // 解析Plan的Task列表并添加到待执行队列的特殊任务
|
TaskPlanAnalysis TaskType = "计划分析" // 解析Plan的Task列表并添加到待执行队列的特殊任务
|
||||||
TaskTypeWaiting TaskType = "waiting" // 等待任务
|
TaskTypeWaiting TaskType = "等待" // 等待任务
|
||||||
TaskTypeReleaseFeedWeight TaskType = "release_feed_weight" // 下料口释放指定重量任务
|
TaskTypeReleaseFeedWeight TaskType = "下料" // 下料口释放指定重量任务
|
||||||
)
|
)
|
||||||
|
|
||||||
// -- Task Parameters --
|
// -- Task Parameters --
|
||||||
@@ -42,13 +42,14 @@ const (
|
|||||||
ParamsPlanID = "plan_id"
|
ParamsPlanID = "plan_id"
|
||||||
)
|
)
|
||||||
|
|
||||||
type PlanStatus uint8
|
// PlanStatus 定义了计划的状态
|
||||||
|
type PlanStatus string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
PlanStatusDisabled PlanStatus = 0 // 禁用计划
|
PlanStatusDisabled PlanStatus = "已禁用" // 禁用计划
|
||||||
PlanStatusEnabled PlanStatus = 1 // 启用计划
|
PlanStatusEnabled PlanStatus = "已启用" // 启用计划
|
||||||
PlanStatusStopeed PlanStatus = 2 // 执行完毕
|
PlanStatusStopped PlanStatus = "执行完毕" // 执行完毕
|
||||||
PlanStatusFailed PlanStatus = 3 // 执行失败
|
PlanStatusFailed PlanStatus = "执行失败" // 执行失败
|
||||||
)
|
)
|
||||||
|
|
||||||
// Plan 代表系统中的一个计划,可以包含子计划或任务
|
// Plan 代表系统中的一个计划,可以包含子计划或任务
|
||||||
@@ -58,9 +59,9 @@ type Plan struct {
|
|||||||
Name string `gorm:"not null" json:"name"`
|
Name string `gorm:"not null" json:"name"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
ExecutionType PlanExecutionType `gorm:"not null;index" json:"execution_type"`
|
ExecutionType PlanExecutionType `gorm:"not null;index" json:"execution_type"`
|
||||||
Status PlanStatus `gorm:"default:0;index" json:"status"` // 计划是否被启动
|
Status PlanStatus `gorm:"default:'已禁用';index" json:"status"` // 计划是否被启动
|
||||||
ExecuteNum uint `gorm:"default:0" json:"execute_num"` // 计划预期执行次数
|
ExecuteNum uint `gorm:"default:0" json:"execute_num"` // 计划预期执行次数
|
||||||
ExecuteCount uint `gorm:"default:0" json:"execute_count"` // 执行计数器
|
ExecuteCount uint `gorm:"default:0" json:"execute_count"` // 执行计数器
|
||||||
|
|
||||||
// 针对 PlanExecutionTypeAutomatic,使用 Cron 表达式定义调度规则
|
// 针对 PlanExecutionTypeAutomatic,使用 Cron 表达式定义调度规则
|
||||||
CronExpression string `json:"cron_expression"`
|
CronExpression string `json:"cron_expression"`
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ import (
|
|||||||
type SensorType string
|
type SensorType string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
SensorTypeSignalMetrics SensorType = "signal_metrics" // 信号强度
|
SensorTypeSignalMetrics SensorType = "信号强度" // 信号强度
|
||||||
SensorTypeBatteryLevel SensorType = "battery_level" // 电池电量
|
SensorTypeBatteryLevel SensorType = "电池电量" // 电池电量
|
||||||
SensorTypeTemperature SensorType = "temperature" // 温度
|
SensorTypeTemperature SensorType = "温度" // 温度
|
||||||
SensorTypeHumidity SensorType = "humidity" // 湿度
|
SensorTypeHumidity SensorType = "湿度" // 湿度
|
||||||
SensorTypeWeight SensorType = "weight" // 重量
|
SensorTypeWeight SensorType = "重量" // 重量
|
||||||
)
|
)
|
||||||
|
|
||||||
// SignalMetrics 存储信号强度数据
|
// SignalMetrics 存储信号强度数据
|
||||||
|
|||||||
Reference in New Issue
Block a user