work_station.go
1.5 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
package domain
import "fmt"
// 工作位置(车间、生产线、工段组成),唯一标识工作位置
type WorkStation struct {
// 工作位置键值 (车间ID+'.'+生产线ID+'.'+工段ID)
WorkStationId string `json:"workStationId,omitempty"`
// 车间ID
WorkshopId int `json:"workshopId,omitempty"`
// 车间名称
WorkshopName string `json:"workshopName,omitempty"`
// 生产线ID
LineId int `json:"lineId,omitempty"`
// 生产线名称
LineName string `json:"lineName,omitempty"`
// 工段ID
SectionId int `json:"sectionId,omitempty"`
// 工段名称
SectionName string `json:"sectionName,omitempty"`
// 负责人 (用户对象)
Principal *User `json:"principal,omitempty"`
}
func NewWorkStation(w *Workshop, l *ProductLine, s *ProductSection) *WorkStation {
item := &WorkStation{
//WorkshopId: w.WorkshopId,
//WorkshopName: w.WorkshopName,
//LineId: l.LineId,
//LineName: l.LineName,
//SectionId: s.SectionId,
//SectionName: s.SectionName,
//Principal: w.Principal,
}
if w != nil && l != nil && s != nil {
item.WorkStationId = WorkstationKey(w.WorkshopId, l.LineId, s.SectionId)
}
if w != nil {
item.WorkshopId = w.WorkshopId
item.WorkshopName = w.WorkshopName
}
if l != nil {
item.LineId = l.LineId
item.LineName = l.LineName
}
if s != nil {
item.SectionId = s.SectionId
item.SectionName = s.SectionName
}
return item
}
func WorkstationKey(workshopId, lineId, sectionId int) string {
return fmt.Sprintf("%v.%v.%v", workshopId, lineId, sectionId)
}