device_collection.go
2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package domain
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant"
"time"
)
// 设备采集数据
type DeviceCollection struct {
// 数据采集ID
DeviceCollectionId int64 `json:"deviceCollectionId,string"`
// 车间名
WorkShopName string `json:"workShopName"`
// 采集时间
CollectionTime time.Time `json:"collectionTime"`
// 设备名
DeviceSn string `json:"deviceSn"`
// 设备类型
DeviceType string `json:"deviceType"`
// 启动状态 1-启动 0-停止
StartupStatus int64 `json:"startupStatus"`
// 通讯状态 1-通讯正常 0-设备未上电或与采集端通讯故障
ComStatus int64 `json:"comStatus"`
// 设备数据值
Values interface{} `json:"values"`
}
var (
// 包馅机
DeviceTypeBaoXianJi = "BXJ"
// 打浆机
DeviceTypeDaJiangJi = "DJJ"
// 面包屑机
DeviceTypeMianBaoXieJi = "MBXJ"
// 油炸机
DeviceTypeYouZhaJi = "YZJ"
// 串串机
DeviceTypeChuanChuanJi = "CCJ"
// 速冻线
DeviceTypeSuDongXian = "SDX"
// 封口机
DeviceTypeFengKouJi = "FKJ"
// 封箱机
DeviceTypeFengXiangJi = "FXJ"
)
type DeviceCollectionRepository interface {
Save(deviceCollection *DeviceCollection) (*DeviceCollection, error)
Remove(deviceCollection *DeviceCollection) (*DeviceCollection, error)
FindOne(queryOptions map[string]interface{}) (*DeviceCollection, error)
Find(queryOptions map[string]interface{}) (int64, []*DeviceCollection, error)
}
func (deviceCollection *DeviceCollection) Identify() interface{} {
if deviceCollection.DeviceCollectionId == 0 {
return nil
}
return deviceCollection.DeviceCollectionId
}
func (deviceCollection *DeviceCollection) Update(data map[string]interface{}) error {
if workShopName, ok := data["workShopName"]; ok {
deviceCollection.WorkShopName = workShopName.(string)
}
if deviceSn, ok := data["deviceSn"]; ok {
deviceCollection.DeviceSn = deviceSn.(string)
}
if deviceType, ok := data["deviceType"]; ok {
deviceCollection.DeviceSn = deviceType.(string)
}
if startupStatus, ok := data["startupStatus"]; ok {
deviceCollection.StartupStatus = startupStatus.(int64)
}
if comStatus, ok := data["comStatus"]; ok {
deviceCollection.ComStatus = comStatus.(int64)
}
if values, ok := data["values"]; ok {
deviceCollection.Values = values
}
return nil
}
func TaskDeviceCollection() string {
return fmt.Sprintf("%v:task:device-collection:report", constant.CACHE_PREFIX)
}