unit_conversion.go
2.3 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
package domain
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils"
"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"`
// 智能称重标识 1:是 2:否
IntelligentWeighingFlag int `json:"intelligentWeighingFlag,omitempty"`
// 创建时间
CreatedAt time.Time `json:"createdAt,omitempty"`
// 更新时间
UpdatedAt time.Time `json:"updatedAt,omitempty"`
// 删除时间
DeletedAt time.Time `json:"deletedAt,omitempty"`
// 扩展数据
Ext *Ext `json:"ext,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 materialName, ok := data["materialName"]; ok {
// unitConversion.Material.MaterialName = materialName.(string)
//}
//if materialCategory, ok := data["materialCategory"]; ok {
// unitConversion.Material.MaterialCategory = materialCategory.(string)
//}
//if intelligentWeighingFlag, ok := data["intelligentWeighingFlag"]; ok {
// unitConversion.IntelligentWeighingFlag = intelligentWeighingFlag.(bool)
//}
unitConversion.UpdatedAt = time.Now()
return nil
}
type UnitConversions []*UnitConversion
func (unitConversions UnitConversions) ProductMaterialIds() []int {
set := utils.NewSet()
for i := range unitConversions {
if unitConversions[i].Material.ProductMaterialId == 0 {
continue
}
set.Add(unitConversions[i].Material.ProductMaterialId)
}
return set.KeysInt()
}