unit_conversion.go
4.1 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package domain
import "time"
// 单位换算
type UnitConversion struct {
// 单位换算ID
UnitConversionId int `json:"unitConversionId,omitempty"`
// 企业id
CompanyId int `json:"companyId,omitempty"`
// 组织ID
OrgId int `json:"orgId,omitempty"`
// 工作位置
WorkStation *WorkStation `json:"workStation,omitempty"`
// material
Material *Material `json:"material,omitempty"`
// 转换前单位数量
FromUnitQuantity *UnitQuantity `json:"fromUnitQuantity,omitempty"`
// 转换后单位数量
ToUnitQuantity *UnitQuantity `json:"toUnitQuantity,omitempty"`
// 智能称重标识
IntelligentWeighingFlag bool `json:"intelligentWeighingFlag,omitempty"`
// 创建时间
CreatedAt time.Time `json:"createdAt,omitempty"`
// 更新时间
UpdatedAt time.Time `json:"updatedAt,omitempty"`
// 删除时间
DeletedAt time.Time `json:"deletedAt,omitempty"`
}
type UnitConversionRepository interface {
Save(unitConversion *UnitConversion) (*UnitConversion, error)
Remove(unitConversion *UnitConversion) (*UnitConversion, error)
FindOne(queryOptions map[string]interface{}) (*UnitConversion, error)
Find(queryOptions map[string]interface{}) (int64, []*UnitConversion, error)
}
func (unitConversion *UnitConversion) Identify() interface{} {
if unitConversion.UnitConversionId == 0 {
return nil
}
return unitConversion.UnitConversionId
}
func (unitConversion *UnitConversion) Update(data map[string]interface{}) error {
if unitConversionId, ok := data["unitConversionId"]; ok {
unitConversion.UnitConversionId = unitConversionId.(int)
}
if companyId, ok := data["companyId"]; ok {
unitConversion.CompanyId = companyId.(int)
}
if orgId, ok := data["orgId"]; ok {
unitConversion.OrgId = orgId.(int)
}
if workStationId, ok := data["workStationId"]; ok {
unitConversion.WorkStation.WorkStationId = workStationId.(string)
}
if workshopId, ok := data["workshopId"]; ok {
unitConversion.WorkStation.WorkshopId = workshopId.(int)
}
if workshopName, ok := data["workshopName"]; ok {
unitConversion.WorkStation.WorkshopName = workshopName.(string)
}
if lineId, ok := data["lineId"]; ok {
unitConversion.WorkStation.LineId = lineId.(int)
}
if lineName, ok := data["lineName"]; ok {
unitConversion.WorkStation.LineName = lineName.(string)
}
if sectionId, ok := data["sectionId"]; ok {
unitConversion.WorkStation.SectionId = sectionId.(int)
}
if sectionName, ok := data["sectionName"]; ok {
unitConversion.WorkStation.SectionName = sectionName.(string)
}
if materialName, ok := data["materialName"]; ok {
unitConversion.Material.MaterialName = materialName.(string)
}
if materialCategory, ok := data["materialCategory"]; ok {
unitConversion.Material.MaterialCategory = materialCategory.(string)
}
if quantity, ok := data["quantity"]; ok {
unitConversion.FromUnitQuantity.Quantity = quantity.(float64)
}
if unit, ok := data["unit"]; ok {
unitConversion.FromUnitQuantity.Unit = unit.(string)
}
if unitWeight, ok := data["unitWeight"]; ok {
unitConversion.FromUnitQuantity.UnitWeight = unitWeight.(float64)
}
if weight, ok := data["weight"]; ok {
unitConversion.FromUnitQuantity.Weight = weight.(float64)
}
//if quantity, ok := data["quantity"]; ok {
// unitConversion.ToUnitQuantity.FromUnitQuantity.Quantity = quantity.(float64)
//}
//if unit, ok := data["unit"]; ok {
// unitConversion.ToUnitQuantity.FromUnitQuantity.Unit = unit.(string)
//}
//if unitWeight, ok := data["unitWeight"]; ok {
// unitConversion.ToUnitQuantity.FromUnitQuantity.UnitWeight = unitWeight.(float64)
//}
//if weight, ok := data["weight"]; ok {
// unitConversion.ToUnitQuantity.FromUnitQuantity.Weight = weight.(float64)
//}
//if intelligentWeighingFlag, ok := data["intelligentWeighingFlag"]; ok {
// unitConversion.IntelligentWeighingFlag = intelligentWeighingFlag.(boolean)
//}
if createdAt, ok := data["createdAt"]; ok {
unitConversion.CreatedAt = createdAt.(time.Time)
}
if updatedAt, ok := data["updatedAt"]; ok {
unitConversion.UpdatedAt = updatedAt.(time.Time)
}
if deletedAt, ok := data["deletedAt"]; ok {
unitConversion.DeletedAt = deletedAt.(time.Time)
}
return nil
}