zhangqian
2024-05-06 3abb522a610fa41a8d5570b643d88a23030e56db
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
package constvar
 
type BaseOperationType int
 
const (
    BaseOperationTypeIncoming BaseOperationType = iota + 1 //收货
    BaseOperationTypeOutgoing                              //交货
    BaseOperationTypeInternal                              //内部调拨
    BaseOperationTypeDisuse                                //报废
    BaseOperationTypeAdjust                                //库存盘点
)
 
func (slf BaseOperationType) IsValid() bool {
    return slf == BaseOperationTypeIncoming ||
        slf == BaseOperationTypeOutgoing ||
        slf == BaseOperationTypeInternal
}
 
type ReservationMethod int
 
const (
    ReservationMethodAtConfirm ReservationMethod = iota + 1 //在确认时
    ReservationMethodManual                                 //手动
    ReservationMethodByDate                                 //在预定日期之前
)
 
func (slf ReservationMethod) IsValid() bool {
    return slf == ReservationMethodAtConfirm ||
        slf == ReservationMethodManual ||
        slf == ReservationMethodByDate
}
 
type WhetherType int
 
const (
    WhetherTypeAsk    WhetherType = iota + 1 //询问
    WhetherTypeAlways                        //总是
    ReservationNever                         //从不
)
 
func (slf WhetherType) IsValid() bool {
    return slf == WhetherTypeAsk ||
        slf == WhetherTypeAlways ||
        slf == ReservationNever
}
 
// ProductType 产品类型
type ProductType int
 
const (
    Consumables   ProductType = iota + 1 // 消耗品
    Server                               // 服务
    StoredProduct                        // 可储存的产品
)
 
// MaterialMode 物料类型(字符串)
type MaterialMode string
 
const (
    MaterialModeRaw         MaterialMode = "原材料"
    MaterialModeSemi        MaterialMode = "半成品"
    MaterialModeFinished    MaterialMode = "成品"
    MaterialModeAuxiliary   MaterialMode = "辅料"  //辅料
    MaterialModeConsumables MaterialMode = "耗材"  //耗材
    MaterialModeOther       MaterialMode = "其他"  //其他
    MaterialModeVirtual     MaterialMode = "虚拟件" //虚拟件, 不能销售,不能出入库,不能采购
)
 
func (t MaterialMode) Valid() bool {
    if t != MaterialModeRaw &&
        t != MaterialModeSemi &&
        t != MaterialModeAuxiliary &&
        t != MaterialModeConsumables &&
        t != MaterialModeOther &&
        t != MaterialModeFinished &&
        t != MaterialModeVirtual {
        return false
    }
    return true
}
 
func (t MaterialMode) Type() MaterialType {
    switch t {
    case MaterialModeRaw:
        return MaterialTypeRaw
    case MaterialModeSemi:
        return MaterialTypeSemi
    case MaterialModeFinished:
        return MaterialTypeFinished
    case MaterialModeAuxiliary:
        return MaterialTypeAuxiliary
    case MaterialModeConsumables:
        return MaterialTypeConsumables
    case MaterialModeOther:
        return MaterialTypeOther
    case MaterialModeVirtual:
        return MaterialTypeVirtual
    }
    return MaterialType(0)
}
 
// MaterialType 物料类型(数字)
type MaterialType int
 
const (
    MaterialTypeRaw         = iota + 1 // 原材料
    MaterialTypeSemi                   // 半成品
    MaterialTypeFinished               // 成品
    MaterialTypeAuxiliary              //辅料
    MaterialTypeConsumables            //耗材
    MaterialTypeOther                  //其他
    MaterialTypeVirtual                //虚拟件
)
 
func (t MaterialType) Valid() bool {
    if t < MaterialTypeRaw ||
        t > MaterialTypeVirtual {
        return false
    }
    return true
}
 
type MaterialStatus int
 
const (
    MaterialStatusCreate   MaterialStatus = iota // 新建
    MaterialStatusActive                         // 启用
    MaterialStatusInactive = -1                  // 停用
)
 
// InvoicingStrategy 开票策略
type InvoicingStrategy int
 
const (
    IndentNumber       InvoicingStrategy = iota + 1 //订购数量
    DeliverNumber                                   //交付数量
    PrepaidPrice                                    //预付\固定价格
    Milestones                                      //基于里程碑
    BasedDeliverNumber                              //基于交付数量
)
 
// OrderCreation 订单创建
type OrderCreation int
 
const (
    Nothing       OrderCreation = iota + 1 //不操作
    Task                                   //任务
    Object                                 //项目
    TaskAndObject                          //任务和项目
)
 
type ProductStatus int
 
const (
    ProductStatusCreate   ProductStatus = iota // 新建
    ProductStatusActive                        // 启用
    ProductStatusInactive = -1                 // 停用
)
 
// PurchaseType 采购类型
type PurchaseType int
 
const (
    PurchaseTypeOutSource PurchaseType = iota + 1 // 采购
    PurchaseTypeSelf                              // 自制
    PurchaseTypeEntrust                           // 委外
)
 
func (t PurchaseType) Valid() bool {
    if t < PurchaseTypeOutSource ||
        t > PurchaseTypeEntrust {
        return false
    }
    return true
}
 
// LocationType 位置类型
type LocationType int
 
const (
    LocationTypeVendor        LocationType = iota + 1 // 供应商位置
    LocationTypeView                                  // 视图
    LocationTypeInternal                              // 内部位置
    LocationTypeCustomer                              // 客户位置
    LocationTypeInventoryLoss                         // 库存损失
    LocationTypeProduction                            // 生产
    LocationTypeTransit                               // 中转位置
    LocationTypeDisuse                                //报废位置
    LocationTypeAdjust                                //库存盘点
)
 
func (t LocationType) Valid() bool {
    return t >= LocationTypeVendor && t <= LocationTypeTransit
}
 
type ForceRemovalStrategy int
 
const (
    ForceRemovalStrategyFIFO ForceRemovalStrategy = iota + 1
    ForceRemovalStrategyLIFO
    ForceRemovalStrategyClosestLocation
)
 
func (t ForceRemovalStrategy) Valid() bool {
    return t >= ForceRemovalStrategyFIFO && t <= ForceRemovalStrategyClosestLocation
}
 
type CostingMethod int
 
const (
    CostingMethodStandardPrice CostingMethod = iota + 1 //标准价格
    CostingMethodFIFO                                   //先进先出
    CostingMethodAverageCost                            //平均成本
)
 
func (t CostingMethod) Valid() bool {
    return t >= CostingMethodStandardPrice && t <= CostingMethodAverageCost
}
 
type InventoryValuation int
 
const (
    InventoryValuationManual InventoryValuation = iota + 1 //手动
    InventoryValuationAuto                                 //自动
)
 
func (t InventoryValuation) Valid() bool {
    return t >= InventoryValuationManual && t <= InventoryValuationAuto
}
 
type OperationStatus int
 
const (
    OperationStatus_Draft   OperationStatus = iota + 1 //草稿
    OperationStatus_Waiting                            //正在等待
    OperationStatus_Ready                              //就绪
    OperationStatus_Finish                             //完成
    OperationStatus_Cancel                             //取消
)
 
type PostType int
 
const (
    PostType_Soon       PostType = iota + 1 //尽快
    PostType_AfterReady                     //当所有产品就绪时
)
 
type RuleType int
 
const (
    RuleType_Product         RuleType = iota + 1 //产品上架规则
    RuleType_ProductCategory                     //产品类别上架规则
)
 
type UserType int
 
const (
    UserTypeSuper   UserType = iota + 1 // 超级管理员
    UserTypePrimary                     // 主账户
    UserTypeSub                         // 子账户
)
 
type FileType string
 
const (
    FileType_File      FileType = "file"      //文件
    FileType_Picture   FileType = "picture"   //图片
    FileType_Thumbnail FileType = "thumbnail" //缩略图
)
 
var FileExtMap = map[string]FileType{
    "doc":  FileType_File,
    "docx": FileType_File,
    "xls":  FileType_File,
    "xlsx": FileType_File,
    "txt":  FileType_File,
}
 
var PicExtMap = map[string]FileType{
    "jpg":  FileType_Picture,
    "jpeg": FileType_Picture,
    "png":  FileType_Picture,
    "svg":  FileType_Picture,
}
 
type FileTemplateCategory int
 
const (
    FileTemplateCategory_Selfmade      FileTemplateCategory = iota + 1 //入库-自制
    FileTemplateCategory_Output                                        //出库
    FileTemplateCategory_JialianInput  = 14                            //嘉联入库
    FileTemplateCategory_JialianOutput = 15                            //嘉联出库
)
 
type CodeStandardType string
 
const (
    CodeStandardType_Material CodeStandardType = "物料编码"
    CodeStandardType_Incoming CodeStandardType = "入库编码"
    CodeStandardType_Outgoing CodeStandardType = "出库编码"
    CodeStandardType_Internal CodeStandardType = "调拨编码"
    CodeStandardType_Disuse   CodeStandardType = "仓库报废编码"
)
 
type OperationSource int
 
const (
    OperationSourcePurchase         OperationSource = 1 //采购入库
    OperationSourceProduction       OperationSource = 2 //生产入库
    OperationSourceOutsourcing      OperationSource = 3 //委外入库
    OperationSourceProductionApply  OperationSource = 4 //生产领料
    OperationSourceOutsourcingApply OperationSource = 5 //委外领料
    OperationSourceSaleDelivery     OperationSource = 6 //销售发货
)