正在显示
35 个修改的文件
包含
615 行增加
和
94 行删除
1 | -FROM 192.168.0.243:5000/mmm/allied-creation-manufacture:20210809 | 1 | +FROM 192.168.0.243:5000/mmm/allied-creation-user:20210809 |
2 | ENV APP_DIR $GOPATH/src/project-20211220 | 2 | ENV APP_DIR $GOPATH/src/project-20211220 |
3 | RUN mkdir -p $APP_DIR | 3 | RUN mkdir -p $APP_DIR |
4 | WORKDIR $APP_DIR/ | 4 | WORKDIR $APP_DIR/ |
@@ -52,12 +52,54 @@ spec: | @@ -52,12 +52,54 @@ spec: | ||
52 | - mountPath: /opt/logs | 52 | - mountPath: /opt/logs |
53 | name: accesslogs | 53 | name: accesslogs |
54 | env: | 54 | env: |
55 | + - name: POSTGRESQL_DB_NAME | ||
56 | + valueFrom: | ||
57 | + configMapKeyRef: | ||
58 | + name: suplus-config | ||
59 | + key: postgresqlalliedcreation.dbname | ||
60 | + - name: POSTGRESQL_USER | ||
61 | + valueFrom: | ||
62 | + configMapKeyRef: | ||
63 | + name: suplus-config | ||
64 | + key: postgresql.user | ||
65 | + - name: POSTGRESQL_PASSWORD | ||
66 | + valueFrom: | ||
67 | + configMapKeyRef: | ||
68 | + name: suplus-config | ||
69 | + key: postgresql.password | ||
70 | + - name: POSTGRESQL_HOST | ||
71 | + valueFrom: | ||
72 | + configMapKeyRef: | ||
73 | + name: suplus-config | ||
74 | + key: postgresql.host | ||
75 | + - name: POSTGRESQL_PORT | ||
76 | + valueFrom: | ||
77 | + configMapKeyRef: | ||
78 | + name: suplus-config | ||
79 | + key: postgresql.port | ||
80 | + - name: REDIS_HOST | ||
81 | + valueFrom: | ||
82 | + configMapKeyRef: | ||
83 | + name: suplus-config | ||
84 | + key: redis.ip | ||
85 | + - name: REDIS_PORT | ||
86 | + valueFrom: | ||
87 | + configMapKeyRef: | ||
88 | + name: suplus-config | ||
89 | + key: redis.port | ||
90 | + - name: REDIS_AUTH | ||
91 | + value: "" | ||
55 | - name: LOG_LEVEL | 92 | - name: LOG_LEVEL |
56 | value: "debug" | 93 | value: "debug" |
57 | - name: ERROR_BASE_CODE | 94 | - name: ERROR_BASE_CODE |
58 | value: "1" | 95 | value: "1" |
59 | - name: ERROR_BASE_CODE_MULTIPLE | 96 | - name: ERROR_BASE_CODE_MULTIPLE |
60 | - value: "1000" | ||
61 | - volumes: | 97 | + value: "2000" |
98 | + - name: ENABLE_KAFKA_LOG | ||
99 | + value: "true" | ||
100 | + - name: HTTP_PORT | ||
101 | + value: "8082" | ||
102 | + - name: SERVICE_ENV | ||
103 | + value: "dev" | ||
62 | - name: accesslogs | 104 | - name: accesslogs |
63 | emptyDir: {} | 105 | emptyDir: {} |
@@ -34,6 +34,31 @@ func FastPgWorkshop(transactionContext application.TransactionContext, id int, o | @@ -34,6 +34,31 @@ func FastPgWorkshop(transactionContext application.TransactionContext, id int, o | ||
34 | return rep, mod, err | 34 | return rep, mod, err |
35 | } | 35 | } |
36 | 36 | ||
37 | +// FastPgWorkshop 快速返回车间对象 | ||
38 | +// | ||
39 | +// transactionContext 事务 | ||
40 | +// id 对象唯一标识 | ||
41 | +func FastPgWorkshops(transactionContext application.TransactionContext, companyId int, options ...option) (domain.Workshops, error) { | ||
42 | + var rep domain.WorkshopRepository | ||
43 | + //var mod *domain.Workshop | ||
44 | + var err error | ||
45 | + if value, err := CreateWorkshopRepository(map[string]interface{}{ | ||
46 | + "transactionContext": transactionContext, | ||
47 | + }); err != nil { | ||
48 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
49 | + } else { | ||
50 | + rep = value | ||
51 | + } | ||
52 | + _, workshops, err := rep.Find(map[string]interface{}{"companyId": companyId}) | ||
53 | + if err != nil { | ||
54 | + return nil, err | ||
55 | + } | ||
56 | + if len(workshops) == 0 { | ||
57 | + workshops = make([]*domain.Workshop, 0) | ||
58 | + } | ||
59 | + return workshops, err | ||
60 | +} | ||
61 | + | ||
37 | // FastPgWorkstation 快速返回工作定位对象 | 62 | // FastPgWorkstation 快速返回工作定位对象 |
38 | // | 63 | // |
39 | // transactionContext 事务 | 64 | // transactionContext 事务 |
@@ -91,11 +91,19 @@ func (productJobService *ProductJobService) GetProductJob(getProductJobQuery *qu | @@ -91,11 +91,19 @@ func (productJobService *ProductJobService) GetProductJob(getProductJobQuery *qu | ||
91 | if err != nil { | 91 | if err != nil { |
92 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 92 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
93 | } | 93 | } |
94 | - if err := transactionContext.CommitTransaction(); err != nil { | ||
95 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 94 | + |
95 | + _, workshop, err := factory.FastPgWorkshop(transactionContext, productJob.WorkStation.WorkshopId) | ||
96 | + if err != nil { | ||
97 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
96 | } | 98 | } |
99 | + productJob.WorkStation, _ = workshop.FindWorkStation(productJob.WorkStation.WorkshopId, productJob.WorkStation.LineId, productJob.WorkStation.SectionId) | ||
97 | newJobDto := &dto.ProductJobDto{} | 100 | newJobDto := &dto.ProductJobDto{} |
98 | newJobDto.LoadDto(productJob, 0) | 101 | newJobDto.LoadDto(productJob, 0) |
102 | + | ||
103 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
104 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
105 | + } | ||
106 | + | ||
99 | return newJobDto, nil | 107 | return newJobDto, nil |
100 | } | 108 | } |
101 | 109 | ||
@@ -279,8 +287,8 @@ func (productJobService *ProductJobService) UpdateProductJob(cmd *command.Update | @@ -279,8 +287,8 @@ func (productJobService *ProductJobService) UpdateProductJob(cmd *command.Update | ||
279 | } | 287 | } |
280 | 288 | ||
281 | // 搜索工位服务列表 | 289 | // 搜索工位服务列表 |
282 | -func (productJobService *ProductJobService) SearchProductJob(operateInfo *domain.OperateInfo, listProductJobQuery *query.SearchProductJobQuery) (int64, interface{}, error) { | ||
283 | - if err := listProductJobQuery.ValidateQuery(); err != nil { | 290 | +func (productJobService *ProductJobService) SearchProductJob(operateInfo *domain.OperateInfo, cmd *query.SearchProductJobQuery) (int64, interface{}, error) { |
291 | + if err := cmd.ValidateQuery(); err != nil { | ||
284 | return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 292 | return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
285 | } | 293 | } |
286 | transactionContext, err := factory.CreateTransactionContext(nil) | 294 | transactionContext, err := factory.CreateTransactionContext(nil) |
@@ -301,14 +309,18 @@ func (productJobService *ProductJobService) SearchProductJob(operateInfo *domain | @@ -301,14 +309,18 @@ func (productJobService *ProductJobService) SearchProductJob(operateInfo *domain | ||
301 | } else { | 309 | } else { |
302 | productJobRepository = value | 310 | productJobRepository = value |
303 | } | 311 | } |
304 | - | ||
305 | - count, productJobs, err := productJobRepository.Find(utils.ObjectToMap(listProductJobQuery)) | 312 | + workshops, _ := factory.FastPgWorkshops(transactionContext, operateInfo.CompanyId) |
313 | + queryOptions := utils.ObjectToMap(cmd) | ||
314 | + queryOptions = workshops.FindByNameWithQuery(queryOptions, cmd.WorkshopName, cmd.LineName, cmd.SectionName) | ||
315 | + count, productJobs, err := productJobRepository.Find(queryOptions) | ||
306 | if err != nil { | 316 | if err != nil { |
307 | return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 317 | return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
308 | } | 318 | } |
319 | + | ||
309 | var result = make([]*dto.ProductJobDto, 0) | 320 | var result = make([]*dto.ProductJobDto, 0) |
310 | for i := range productJobs { | 321 | for i := range productJobs { |
311 | item := productJobs[i] | 322 | item := productJobs[i] |
323 | + item.WorkStation = workshops.FindWorkStation(item.WorkStation.WorkshopId, item.WorkStation.LineId, item.WorkStation.SectionId) | ||
312 | newJobDto := &dto.ProductJobDto{} | 324 | newJobDto := &dto.ProductJobDto{} |
313 | newJobDto.LoadDto(item, operateInfo.OrgId) | 325 | newJobDto.LoadDto(item, operateInfo.OrgId) |
314 | result = append(result, newJobDto) | 326 | result = append(result, newJobDto) |
@@ -13,6 +13,8 @@ type UpdateProductLineCommand struct { | @@ -13,6 +13,8 @@ type UpdateProductLineCommand struct { | ||
13 | WorkshopId int `cname:"车间ID" json:"workshopId" valid:"Required"` | 13 | WorkshopId int `cname:"车间ID" json:"workshopId" valid:"Required"` |
14 | // 生产线ID | 14 | // 生产线ID |
15 | LineId int `cname:"生产线ID" json:"lineId" valid:"Required"` | 15 | LineId int `cname:"生产线ID" json:"lineId" valid:"Required"` |
16 | + // 旧生产线ID | ||
17 | + //OldWorkshopId int `cname:"生产线ID" json:"-" valid:"Required"` | ||
16 | // 生产线名称 | 18 | // 生产线名称 |
17 | LineName string `cname:"生产线名称" json:"lineName" valid:"Required"` | 19 | LineName string `cname:"生产线名称" json:"lineName" valid:"Required"` |
18 | } | 20 | } |
@@ -57,7 +57,7 @@ func (productLineService *ProductLineService) CreateProductLine(createProductLin | @@ -57,7 +57,7 @@ func (productLineService *ProductLineService) CreateProductLine(createProductLin | ||
57 | if err := transactionContext.CommitTransaction(); err != nil { | 57 | if err := transactionContext.CommitTransaction(); err != nil { |
58 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 58 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
59 | } | 59 | } |
60 | - return newProductLine, nil | 60 | + return createProductLineCommand, nil |
61 | } | 61 | } |
62 | 62 | ||
63 | // 返回生产线 | 63 | // 返回生产线 |
@@ -2,11 +2,11 @@ package command | @@ -2,11 +2,11 @@ package command | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | + "github.com/beego/beego/v2/core/validation" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
5 | "reflect" | 7 | "reflect" |
6 | "strings" | 8 | "strings" |
7 | "time" | 9 | "time" |
8 | - | ||
9 | - "github.com/beego/beego/v2/core/validation" | ||
10 | ) | 10 | ) |
11 | 11 | ||
12 | type CreateProductPlanCommand struct { | 12 | type CreateProductPlanCommand struct { |
@@ -19,7 +19,7 @@ type CreateProductPlanCommand struct { | @@ -19,7 +19,7 @@ type CreateProductPlanCommand struct { | ||
19 | // 批号 | 19 | // 批号 |
20 | BatchNumber string `cname:"批号" json:"batchNumber" valid:"Required"` | 20 | BatchNumber string `cname:"批号" json:"batchNumber" valid:"Required"` |
21 | // 生产日期 | 21 | // 生产日期 |
22 | - ProductDate time.Time `cname:"生产日期" json:"productDate" valid:"Required"` | 22 | + ProductDate string `cname:"生产日期" json:"productDate" valid:"Required"` |
23 | // 上班班次 1:全天 2:白班 4:中班 8:夜班 | 23 | // 上班班次 1:全天 2:白班 4:中班 8:夜班 |
24 | WorkOn int `cname:"上班班次 1:全天 2:白班 4:中班 8:夜班" json:"workOn" valid:"Required"` | 24 | WorkOn int `cname:"上班班次 1:全天 2:白班 4:中班 8:夜班" json:"workOn" valid:"Required"` |
25 | // 机台 (A、B、C、D 区分机器大小) | 25 | // 机台 (A、B、C、D 区分机器大小) |
@@ -31,15 +31,28 @@ type CreateProductPlanCommand struct { | @@ -31,15 +31,28 @@ type CreateProductPlanCommand struct { | ||
31 | // 单位 | 31 | // 单位 |
32 | Unit string `cname:"单位" json:"unit" valid:"Required"` | 32 | Unit string `cname:"单位" json:"unit" valid:"Required"` |
33 | // 单份重量(原材料) | 33 | // 单份重量(原材料) |
34 | - UnitWeight float64 `cname:"单份重量(原材料)" json:"unitWeight" valid:"Required"` | 34 | + //nitWeight float64 `cname:"单份重量(原材料)" json:"unitWeight" valid:"Required"` |
35 | // 重量 | 35 | // 重量 |
36 | Weight float64 `cname:"重量" json:"weight" valid:"Required"` | 36 | Weight float64 `cname:"重量" json:"weight" valid:"Required"` |
37 | // 备注 | 37 | // 备注 |
38 | - Remark string `cname:"备注" json:"remark" valid:"Required"` | 38 | + Remark string `cname:"备注" json:"remark"` |
39 | + | ||
40 | + // 生产日期 | ||
41 | + ProductDateTime time.Time `cname:"生产日期" json:"-" ` | ||
39 | } | 42 | } |
40 | 43 | ||
41 | func (createProductPlanCommand *CreateProductPlanCommand) Valid(validation *validation.Validation) { | 44 | func (createProductPlanCommand *CreateProductPlanCommand) Valid(validation *validation.Validation) { |
42 | - validation.SetError("CustomValid", "未实现的自定义认证") | 45 | + //validation.SetError("CustomValid", "未实现的自定义认证") |
46 | + if err := domain.ValidWorkOn(createProductPlanCommand.WorkOn); err != nil { | ||
47 | + validation.Error(err.Error()) | ||
48 | + return | ||
49 | + } | ||
50 | + if t, err := time.Parse("2006/01/02", createProductPlanCommand.ProductDate); err != nil { | ||
51 | + validation.Error("时间格式有误 2006/01/02") | ||
52 | + return | ||
53 | + } else { | ||
54 | + createProductPlanCommand.ProductDateTime = t | ||
55 | + } | ||
43 | } | 56 | } |
44 | 57 | ||
45 | func (createProductPlanCommand *CreateProductPlanCommand) ValidateCommand() error { | 58 | func (createProductPlanCommand *CreateProductPlanCommand) ValidateCommand() error { |
@@ -14,7 +14,7 @@ type ReceiveMaterialCommand struct { | @@ -14,7 +14,7 @@ type ReceiveMaterialCommand struct { | ||
14 | } | 14 | } |
15 | 15 | ||
16 | func (receiveMaterialCommand *ReceiveMaterialCommand) Valid(validation *validation.Validation) { | 16 | func (receiveMaterialCommand *ReceiveMaterialCommand) Valid(validation *validation.Validation) { |
17 | - validation.SetError("CustomValid", "未实现的自定义认证") | 17 | + //validation.SetError("CustomValid", "未实现的自定义认证") |
18 | } | 18 | } |
19 | 19 | ||
20 | func (receiveMaterialCommand *ReceiveMaterialCommand) ValidateCommand() error { | 20 | func (receiveMaterialCommand *ReceiveMaterialCommand) ValidateCommand() error { |
@@ -14,7 +14,7 @@ type RemoveProductPlanCommand struct { | @@ -14,7 +14,7 @@ type RemoveProductPlanCommand struct { | ||
14 | } | 14 | } |
15 | 15 | ||
16 | func (removeProductPlanCommand *RemoveProductPlanCommand) Valid(validation *validation.Validation) { | 16 | func (removeProductPlanCommand *RemoveProductPlanCommand) Valid(validation *validation.Validation) { |
17 | - validation.SetError("CustomValid", "未实现的自定义认证") | 17 | + //validation.SetError("CustomValid", "未实现的自定义认证") |
18 | } | 18 | } |
19 | 19 | ||
20 | func (removeProductPlanCommand *RemoveProductPlanCommand) ValidateCommand() error { | 20 | func (removeProductPlanCommand *RemoveProductPlanCommand) ValidateCommand() error { |
@@ -14,7 +14,7 @@ type ReturnMaterialCommand struct { | @@ -14,7 +14,7 @@ type ReturnMaterialCommand struct { | ||
14 | } | 14 | } |
15 | 15 | ||
16 | func (returnMaterialCommand *ReturnMaterialCommand) Valid(validation *validation.Validation) { | 16 | func (returnMaterialCommand *ReturnMaterialCommand) Valid(validation *validation.Validation) { |
17 | - validation.SetError("CustomValid", "未实现的自定义认证") | 17 | + //validation.SetError("CustomValid", "未实现的自定义认证") |
18 | } | 18 | } |
19 | 19 | ||
20 | func (returnMaterialCommand *ReturnMaterialCommand) ValidateCommand() error { | 20 | func (returnMaterialCommand *ReturnMaterialCommand) ValidateCommand() error { |
@@ -14,7 +14,7 @@ type SetOfflineCommand struct { | @@ -14,7 +14,7 @@ type SetOfflineCommand struct { | ||
14 | } | 14 | } |
15 | 15 | ||
16 | func (setOfflineCommand *SetOfflineCommand) Valid(validation *validation.Validation) { | 16 | func (setOfflineCommand *SetOfflineCommand) Valid(validation *validation.Validation) { |
17 | - validation.SetError("CustomValid", "未实现的自定义认证") | 17 | + //validation.SetError("CustomValid", "未实现的自定义认证") |
18 | } | 18 | } |
19 | 19 | ||
20 | func (setOfflineCommand *SetOfflineCommand) ValidateCommand() error { | 20 | func (setOfflineCommand *SetOfflineCommand) ValidateCommand() error { |
@@ -20,7 +20,7 @@ type SetOnlineCommand struct { | @@ -20,7 +20,7 @@ type SetOnlineCommand struct { | ||
20 | } | 20 | } |
21 | 21 | ||
22 | func (setOnlineCommand *SetOnlineCommand) Valid(validation *validation.Validation) { | 22 | func (setOnlineCommand *SetOnlineCommand) Valid(validation *validation.Validation) { |
23 | - validation.SetError("CustomValid", "未实现的自定义认证") | 23 | + //validation.SetError("CustomValid", "未实现的自定义认证") |
24 | } | 24 | } |
25 | 25 | ||
26 | func (setOnlineCommand *SetOnlineCommand) ValidateCommand() error { | 26 | func (setOnlineCommand *SetOnlineCommand) ValidateCommand() error { |
@@ -14,7 +14,7 @@ type SubmitProductRecordCommand struct { | @@ -14,7 +14,7 @@ type SubmitProductRecordCommand struct { | ||
14 | } | 14 | } |
15 | 15 | ||
16 | func (submitProductRecordCommand *SubmitProductRecordCommand) Valid(validation *validation.Validation) { | 16 | func (submitProductRecordCommand *SubmitProductRecordCommand) Valid(validation *validation.Validation) { |
17 | - validation.SetError("CustomValid", "未实现的自定义认证") | 17 | + //validation.SetError("CustomValid", "未实现的自定义认证") |
18 | } | 18 | } |
19 | 19 | ||
20 | func (submitProductRecordCommand *SubmitProductRecordCommand) ValidateCommand() error { | 20 | func (submitProductRecordCommand *SubmitProductRecordCommand) ValidateCommand() error { |
@@ -16,7 +16,7 @@ type SwitchCommand struct { | @@ -16,7 +16,7 @@ type SwitchCommand struct { | ||
16 | } | 16 | } |
17 | 17 | ||
18 | func (switchCommand *SwitchCommand) Valid(validation *validation.Validation) { | 18 | func (switchCommand *SwitchCommand) Valid(validation *validation.Validation) { |
19 | - validation.SetError("CustomValid", "未实现的自定义认证") | 19 | + //validation.SetError("CustomValid", "未实现的自定义认证") |
20 | } | 20 | } |
21 | 21 | ||
22 | func (switchCommand *SwitchCommand) ValidateCommand() error { | 22 | func (switchCommand *SwitchCommand) ValidateCommand() error { |
@@ -2,11 +2,11 @@ package command | @@ -2,11 +2,11 @@ package command | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | + "github.com/beego/beego/v2/core/validation" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
5 | "reflect" | 7 | "reflect" |
6 | "strings" | 8 | "strings" |
7 | "time" | 9 | "time" |
8 | - | ||
9 | - "github.com/beego/beego/v2/core/validation" | ||
10 | ) | 10 | ) |
11 | 11 | ||
12 | type UpdateProductPlanCommand struct { | 12 | type UpdateProductPlanCommand struct { |
@@ -21,7 +21,7 @@ type UpdateProductPlanCommand struct { | @@ -21,7 +21,7 @@ type UpdateProductPlanCommand struct { | ||
21 | // 批号 | 21 | // 批号 |
22 | BatchNumber string `cname:"批号" json:"batchNumber" valid:"Required"` | 22 | BatchNumber string `cname:"批号" json:"batchNumber" valid:"Required"` |
23 | // 生产日期 | 23 | // 生产日期 |
24 | - ProductDate time.Time `cname:"生产日期" json:"productDate" valid:"Required"` | 24 | + ProductDate string `cname:"生产日期" json:"productDate" valid:"Required"` |
25 | // 上班班次 1:全天 2:白班 4:中班 8:夜班 | 25 | // 上班班次 1:全天 2:白班 4:中班 8:夜班 |
26 | WorkOn int `cname:"上班班次 1:全天 2:白班 4:中班 8:夜班" json:"workOn" valid:"Required"` | 26 | WorkOn int `cname:"上班班次 1:全天 2:白班 4:中班 8:夜班" json:"workOn" valid:"Required"` |
27 | // 机台 (A、B、C、D 区分机器大小) | 27 | // 机台 (A、B、C、D 区分机器大小) |
@@ -33,15 +33,26 @@ type UpdateProductPlanCommand struct { | @@ -33,15 +33,26 @@ type UpdateProductPlanCommand struct { | ||
33 | // 单位 | 33 | // 单位 |
34 | Unit string `cname:"单位" json:"unit" valid:"Required"` | 34 | Unit string `cname:"单位" json:"unit" valid:"Required"` |
35 | // 单份重量(原材料) | 35 | // 单份重量(原材料) |
36 | - UnitWeight float64 `cname:"单份重量(原材料)" json:"unitWeight" valid:"Required"` | 36 | + //UnitWeight float64 `cname:"单份重量(原材料)" json:"unitWeight" valid:"Required"` |
37 | // 重量 | 37 | // 重量 |
38 | Weight float64 `cname:"重量" json:"weight" valid:"Required"` | 38 | Weight float64 `cname:"重量" json:"weight" valid:"Required"` |
39 | // 备注 | 39 | // 备注 |
40 | Remark string `cname:"备注" json:"remark" valid:"Required"` | 40 | Remark string `cname:"备注" json:"remark" valid:"Required"` |
41 | + // 生产日期 | ||
42 | + ProductDateTime time.Time `cname:"生产日期" json:"-" ` | ||
41 | } | 43 | } |
42 | 44 | ||
43 | func (updateProductPlanCommand *UpdateProductPlanCommand) Valid(validation *validation.Validation) { | 45 | func (updateProductPlanCommand *UpdateProductPlanCommand) Valid(validation *validation.Validation) { |
44 | - validation.SetError("CustomValid", "未实现的自定义认证") | 46 | + if err := domain.ValidWorkOn(updateProductPlanCommand.WorkOn); err != nil { |
47 | + validation.Error(err.Error()) | ||
48 | + return | ||
49 | + } | ||
50 | + if t, err := time.Parse("2006/01/02", updateProductPlanCommand.ProductDate); err != nil { | ||
51 | + validation.Error("时间格式有误 2006/01/02") | ||
52 | + return | ||
53 | + } else { | ||
54 | + updateProductPlanCommand.ProductDateTime = t | ||
55 | + } | ||
45 | } | 56 | } |
46 | 57 | ||
47 | func (updateProductPlanCommand *UpdateProductPlanCommand) ValidateCommand() error { | 58 | func (updateProductPlanCommand *UpdateProductPlanCommand) ValidateCommand() error { |
1 | +package dto | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
5 | + "strings" | ||
6 | +) | ||
7 | + | ||
8 | +type ProductPlanDto struct { | ||
9 | + // 批号 | ||
10 | + BatchNumber string `json:"batchNumber,omitempty"` | ||
11 | + // 生产日期 | ||
12 | + ProductDate string `json:"productDate,omitempty"` | ||
13 | + // 车间 | ||
14 | + //*domain.Workshop | ||
15 | + // 车间ID | ||
16 | + WorkshopId int `json:"workshopId,omitempty"` | ||
17 | + // 车间名称 | ||
18 | + WorkshopName string `json:"workshopName,omitempty"` | ||
19 | + // 上班班次 1:全天 2:白班 4:中班 8:夜班 | ||
20 | + WorkOn int `json:"workOn,omitempty"` | ||
21 | + // 上班班次描述 | ||
22 | + WorkOnDescription string `json:"workOnDescription"` | ||
23 | + // 机台 (A、B、C、D 区分机器大小) | ||
24 | + Machine string `json:"machine,omitempty"` | ||
25 | + // 计划的产品名称 | ||
26 | + PlanProductName string `json:"planProductName,omitempty"` | ||
27 | + // 计划投入 | ||
28 | + *domain.UnitQuantity | ||
29 | + // 计划状态 (1:上线 2:下线 默认下线) | ||
30 | + PlanStatus int `json:"planStatus,omitempty"` | ||
31 | + // 工作位置 | ||
32 | + //WorkStation *WorkStation `json:"workStation,omitempty"` | ||
33 | + // 总产能 | ||
34 | + TotalProduct float64 `json:"totalProduct"` | ||
35 | + // 备注 | ||
36 | + Remark string `json:"remark,omitempty"` | ||
37 | + // 组织名称 | ||
38 | + OrgName string `json:"orgName"` | ||
39 | + // 权限标识 (当前登录组织匹配为true,否则false) | ||
40 | + AuthFlag bool `json:"authFlag"` | ||
41 | +} | ||
42 | + | ||
43 | +func (d *ProductPlanDto) LoadDto(m *domain.ProductPlan, orgId int) *ProductPlanDto { | ||
44 | + d.BatchNumber = m.BatchNumber | ||
45 | + d.ProductDate = m.ProductDate.Format("2006/01/02") | ||
46 | + d.WorkshopId = m.Workshop.WorkshopId | ||
47 | + d.WorkshopName = m.Workshop.WorkshopName | ||
48 | + d.WorkOn = m.WorkOn | ||
49 | + d.PlanProductName = m.PlanProductName | ||
50 | + d.UnitQuantity = m.PlanDevoted | ||
51 | + d.PlanStatus = m.PlanStatus | ||
52 | + d.TotalProduct = 0 | ||
53 | + d.Remark = m.Remark | ||
54 | + d.AuthFlag = domain.CheckOrgAuth(orgId, m.OrgId) | ||
55 | + if m.Ext != nil { | ||
56 | + d.OrgName = m.Ext.OrgName | ||
57 | + } | ||
58 | + workOnDesc := domain.WorkOnDescription(m.WorkOn) | ||
59 | + d.WorkOnDescription = strings.Join(workOnDesc, ",") | ||
60 | + return d | ||
61 | +} |
@@ -14,7 +14,7 @@ type GetProductPlanQuery struct { | @@ -14,7 +14,7 @@ type GetProductPlanQuery struct { | ||
14 | } | 14 | } |
15 | 15 | ||
16 | func (getProductPlanQuery *GetProductPlanQuery) Valid(validation *validation.Validation) { | 16 | func (getProductPlanQuery *GetProductPlanQuery) Valid(validation *validation.Validation) { |
17 | - validation.SetError("CustomValid", "未实现的自定义认证") | 17 | + //validation.SetError("CustomValid", "未实现的自定义认证") |
18 | } | 18 | } |
19 | 19 | ||
20 | func (getProductPlanQuery *GetProductPlanQuery) ValidateQuery() error { | 20 | func (getProductPlanQuery *GetProductPlanQuery) ValidateQuery() error { |
@@ -16,7 +16,7 @@ type ListProductPlanQuery struct { | @@ -16,7 +16,7 @@ type ListProductPlanQuery struct { | ||
16 | } | 16 | } |
17 | 17 | ||
18 | func (listProductPlanQuery *ListProductPlanQuery) Valid(validation *validation.Validation) { | 18 | func (listProductPlanQuery *ListProductPlanQuery) Valid(validation *validation.Validation) { |
19 | - validation.SetError("CustomValid", "未实现的自定义认证") | 19 | + //validation.SetError("CustomValid", "未实现的自定义认证") |
20 | } | 20 | } |
21 | 21 | ||
22 | func (listProductPlanQuery *ListProductPlanQuery) ValidateQuery() error { | 22 | func (listProductPlanQuery *ListProductPlanQuery) ValidateQuery() error { |
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
6 | + "reflect" | ||
7 | + "strings" | ||
8 | + | ||
9 | + "github.com/beego/beego/v2/core/validation" | ||
10 | +) | ||
11 | + | ||
12 | +type SearchProductPlanQuery struct { | ||
13 | + // 查询偏离量 | ||
14 | + Offset int `cname:"查询偏离量" json:"offset"` | ||
15 | + // 查询限制 | ||
16 | + Limit int `cname:"查询限制" json:"limit"` | ||
17 | + // 当前公司 | ||
18 | + CompanyId int `cname:"当前公司" json:"companyId,omitempty" valid:"Required"` | ||
19 | + // 当前登录的组织 | ||
20 | + OrgId int `cname:"当前登录的组织" json:"orgId,omitempty"` | ||
21 | + // 匹配多个组织 | ||
22 | + InOrgIds []int `cname:"匹配多个组织" json:"inOrgIds,omitempty" valid:"Required"` | ||
23 | + // 页码 | ||
24 | + PageNumber int `cname:"页码" json:"pageNumber,omitempty"` | ||
25 | + // 页数 | ||
26 | + PageSize int `cname:"页数" json:"pageSize,omitempty"` | ||
27 | + // 批号 | ||
28 | + BatchNumber string `cname:"批号" json:"batchNumber"` | ||
29 | + // 车间名称 | ||
30 | + WorkshopName string `cname:"车间名称" json:"workshopName"` | ||
31 | +} | ||
32 | + | ||
33 | +func (cmd *SearchProductPlanQuery) Valid(validation *validation.Validation) { | ||
34 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
35 | + cmd.Offset, cmd.Limit = domain.Pagination(cmd.PageNumber, cmd.PageSize) | ||
36 | +} | ||
37 | + | ||
38 | +func (cmd *SearchProductPlanQuery) ValidateQuery() error { | ||
39 | + valid := validation.Validation{} | ||
40 | + b, err := valid.Valid(cmd) | ||
41 | + if err != nil { | ||
42 | + return err | ||
43 | + } | ||
44 | + if !b { | ||
45 | + elem := reflect.TypeOf(cmd).Elem() | ||
46 | + for _, validErr := range valid.Errors { | ||
47 | + field, isExist := elem.FieldByName(validErr.Field) | ||
48 | + if isExist { | ||
49 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
50 | + } else { | ||
51 | + return fmt.Errorf(validErr.Message) | ||
52 | + } | ||
53 | + } | ||
54 | + } | ||
55 | + return nil | ||
56 | +} |
@@ -6,8 +6,12 @@ import ( | @@ -6,8 +6,12 @@ import ( | ||
6 | "github.com/linmadan/egglib-go/utils/tool_funs" | 6 | "github.com/linmadan/egglib-go/utils/tool_funs" |
7 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory" | 7 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory" |
8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productPlan/command" | 8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productPlan/command" |
9 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productPlan/dto" | ||
9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productPlan/query" | 10 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productPlan/query" |
10 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | 11 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" |
12 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/domainService" | ||
13 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils" | ||
14 | + "time" | ||
11 | ) | 15 | ) |
12 | 16 | ||
13 | // 生产计划服务 | 17 | // 生产计划服务 |
@@ -15,8 +19,8 @@ type ProductPlanService struct { | @@ -15,8 +19,8 @@ type ProductPlanService struct { | ||
15 | } | 19 | } |
16 | 20 | ||
17 | // 创建生产计划服务 | 21 | // 创建生产计划服务 |
18 | -func (productPlanService *ProductPlanService) CreateProductPlan(createProductPlanCommand *command.CreateProductPlanCommand) (interface{}, error) { | ||
19 | - if err := createProductPlanCommand.ValidateCommand(); err != nil { | 22 | +func (productPlanService *ProductPlanService) CreateProductPlan(cmd *command.CreateProductPlanCommand) (interface{}, error) { |
23 | + if err := cmd.ValidateCommand(); err != nil { | ||
20 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 24 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
21 | } | 25 | } |
22 | transactionContext, err := factory.CreateTransactionContext(nil) | 26 | transactionContext, err := factory.CreateTransactionContext(nil) |
@@ -29,34 +33,55 @@ func (productPlanService *ProductPlanService) CreateProductPlan(createProductPla | @@ -29,34 +33,55 @@ func (productPlanService *ProductPlanService) CreateProductPlan(createProductPla | ||
29 | defer func() { | 33 | defer func() { |
30 | transactionContext.RollbackTransaction() | 34 | transactionContext.RollbackTransaction() |
31 | }() | 35 | }() |
32 | - newProductPlan := &domain.ProductPlan{ | ||
33 | - CompanyId: createProductPlanCommand.CompanyId, | ||
34 | - OrgId: createProductPlanCommand.OrgId, | ||
35 | - //WorkshopId: createProductPlanCommand.WorkshopId, | ||
36 | - BatchNumber: createProductPlanCommand.BatchNumber, | ||
37 | - ProductDate: createProductPlanCommand.ProductDate, | ||
38 | - WorkOn: createProductPlanCommand.WorkOn, | ||
39 | - Machine: createProductPlanCommand.Machine, | ||
40 | - PlanProductName: createProductPlanCommand.PlanProductName, | ||
41 | - //PlanDevoted: createProductPlanCommand.PlanDevoted, | ||
42 | - Remark: createProductPlanCommand.Remark, | ||
43 | - } | ||
44 | var productPlanRepository domain.ProductPlanRepository | 36 | var productPlanRepository domain.ProductPlanRepository |
45 | - if value, err := factory.CreateProductPlanRepository(map[string]interface{}{ | ||
46 | - "transactionContext": transactionContext, | ||
47 | - }); err != nil { | 37 | + var productPlan *domain.ProductPlan |
38 | + productPlanRepository, _, _ = factory.FastPgProductPlan(transactionContext, 0) | ||
39 | + // 检查批次号是否有重复的 | ||
40 | + if item, err := productPlanRepository.FindOne(map[string]interface{}{"companyId": cmd.CompanyId, "orgId": cmd.OrgId, "batchNumber": cmd.BatchNumber}); err == nil && item != nil { | ||
41 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "批次号重复") | ||
42 | + } | ||
43 | + | ||
44 | + _, workshop, err := factory.FastPgWorkshop(transactionContext, cmd.WorkshopId) | ||
45 | + if err != nil { | ||
46 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
47 | + } | ||
48 | + | ||
49 | + var userService = domainService.NewUserService() | ||
50 | + var org *domain.Org | ||
51 | + org, err = userService.Organization(cmd.OrgId) | ||
52 | + if err != nil { | ||
48 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 53 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
49 | - } else { | ||
50 | - productPlanRepository = value | ||
51 | } | 54 | } |
52 | - if productPlan, err := productPlanRepository.Save(newProductPlan); err != nil { | 55 | + |
56 | + newProductPlan := &domain.ProductPlan{ | ||
57 | + CompanyId: cmd.CompanyId, | ||
58 | + OrgId: cmd.OrgId, | ||
59 | + BatchNumber: cmd.BatchNumber, | ||
60 | + ProductDate: cmd.ProductDateTime, | ||
61 | + Workshop: workshop.CloneSample(), | ||
62 | + WorkOn: cmd.WorkOn, | ||
63 | + Machine: cmd.Machine, | ||
64 | + PlanProductName: cmd.PlanProductName, | ||
65 | + PlanDevoted: &domain.UnitQuantity{ | ||
66 | + Unit: cmd.Unit, | ||
67 | + Quantity: cmd.Quantity, | ||
68 | + Weight: cmd.Weight, | ||
69 | + }, | ||
70 | + PlanStatus: domain.PlanOffline, | ||
71 | + WorkStation: &domain.WorkStation{}, | ||
72 | + Remark: cmd.Remark, | ||
73 | + CreatedAt: time.Now(), | ||
74 | + UpdatedAt: time.Now(), | ||
75 | + Ext: domain.NewExt(org.OrgName), | ||
76 | + } | ||
77 | + if productPlan, err = productPlanRepository.Save(newProductPlan); err != nil { | ||
53 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 78 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
54 | - } else { | 79 | + } |
55 | if err := transactionContext.CommitTransaction(); err != nil { | 80 | if err := transactionContext.CommitTransaction(); err != nil { |
56 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 81 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
57 | } | 82 | } |
58 | return productPlan, nil | 83 | return productPlan, nil |
59 | - } | 84 | + |
60 | } | 85 | } |
61 | 86 | ||
62 | // 返回生产计划服务 | 87 | // 返回生产计划服务 |
@@ -92,7 +117,9 @@ func (productPlanService *ProductPlanService) GetProductPlan(getProductPlanQuery | @@ -92,7 +117,9 @@ func (productPlanService *ProductPlanService) GetProductPlan(getProductPlanQuery | ||
92 | if err := transactionContext.CommitTransaction(); err != nil { | 117 | if err := transactionContext.CommitTransaction(); err != nil { |
93 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 118 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
94 | } | 119 | } |
95 | - return productPlan, nil | 120 | + result := &dto.ProductPlanDto{} |
121 | + result.LoadDto(productPlan, 0) | ||
122 | + return result, nil | ||
96 | } | 123 | } |
97 | } | 124 | } |
98 | 125 | ||
@@ -341,6 +368,46 @@ func (productPlanService *ProductPlanService) UpdateProductPlan(updateProductPla | @@ -341,6 +368,46 @@ func (productPlanService *ProductPlanService) UpdateProductPlan(updateProductPla | ||
341 | } | 368 | } |
342 | } | 369 | } |
343 | 370 | ||
371 | +// 搜索生产计划服务列表 | ||
372 | +func (productPlanService *ProductPlanService) SearchProductPlan(operateInfo *domain.OperateInfo, cmd *query.SearchProductPlanQuery) (int64, interface{}, error) { | ||
373 | + if err := cmd.ValidateQuery(); err != nil { | ||
374 | + return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
375 | + } | ||
376 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
377 | + if err != nil { | ||
378 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
379 | + } | ||
380 | + if err := transactionContext.StartTransaction(); err != nil { | ||
381 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
382 | + } | ||
383 | + defer func() { | ||
384 | + transactionContext.RollbackTransaction() | ||
385 | + }() | ||
386 | + var productPlanRepository domain.ProductPlanRepository | ||
387 | + if value, err := factory.CreateProductPlanRepository(map[string]interface{}{ | ||
388 | + "transactionContext": transactionContext, | ||
389 | + }); err != nil { | ||
390 | + return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
391 | + } else { | ||
392 | + productPlanRepository = value | ||
393 | + } | ||
394 | + count, productPlans, err := productPlanRepository.Find(utils.ObjectToMap(cmd)) | ||
395 | + if err != nil { | ||
396 | + return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
397 | + } | ||
398 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
399 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
400 | + } | ||
401 | + var result = make([]*dto.ProductPlanDto, 0) | ||
402 | + for i := range productPlans { | ||
403 | + item := productPlans[i] | ||
404 | + newItem := &dto.ProductPlanDto{} | ||
405 | + newItem.LoadDto(item, operateInfo.OrgId) | ||
406 | + result = append(result, newItem) | ||
407 | + } | ||
408 | + return count, result, nil | ||
409 | +} | ||
410 | + | ||
344 | func NewProductPlanService(options map[string]interface{}) *ProductPlanService { | 411 | func NewProductPlanService(options map[string]interface{}) *ProductPlanService { |
345 | newProductPlanService := &ProductPlanService{} | 412 | newProductPlanService := &ProductPlanService{} |
346 | return newProductPlanService | 413 | return newProductPlanService |
@@ -103,3 +103,20 @@ func ValidWorkOn(workOn int) error { | @@ -103,3 +103,20 @@ func ValidWorkOn(workOn int) error { | ||
103 | } | 103 | } |
104 | return nil | 104 | return nil |
105 | } | 105 | } |
106 | + | ||
107 | +func WorkOnDescription(workOn int) []string { | ||
108 | + result := make([]string, 0) | ||
109 | + if workOn&WorkOnFullDay > 0 { | ||
110 | + result = append(result, "全天") | ||
111 | + } | ||
112 | + if workOn&WorkOnDay > 0 { | ||
113 | + result = append(result, "白班") | ||
114 | + } | ||
115 | + if workOn&WorkOnMidDay > 0 { | ||
116 | + result = append(result, "中班") | ||
117 | + } | ||
118 | + if workOn&WorkOnNight > 0 { | ||
119 | + result = append(result, "夜班") | ||
120 | + } | ||
121 | + return result | ||
122 | +} |
@@ -31,5 +31,6 @@ func NewWorkStation(w *Workshop, l *ProductLine, s *ProductSection) *WorkStation | @@ -31,5 +31,6 @@ func NewWorkStation(w *Workshop, l *ProductLine, s *ProductSection) *WorkStation | ||
31 | LineName: l.LineName, | 31 | LineName: l.LineName, |
32 | SectionId: s.SectionId, | 32 | SectionId: s.SectionId, |
33 | SectionName: s.SectionName, | 33 | SectionName: s.SectionName, |
34 | + Principal: w.Principal, | ||
34 | } | 35 | } |
35 | } | 36 | } |
@@ -85,10 +85,10 @@ func (workshop *Workshop) RemoveLine(lineId int) (*ProductLine, error) { | @@ -85,10 +85,10 @@ func (workshop *Workshop) RemoveLine(lineId int) (*ProductLine, error) { | ||
85 | if err != nil { | 85 | if err != nil { |
86 | return nil, err | 86 | return nil, err |
87 | } | 87 | } |
88 | - if line.Removed == 1 { | 88 | + if line.Removed == Deleted { |
89 | return nil, fmt.Errorf("生产线:%v已删除", line.LineName) | 89 | return nil, fmt.Errorf("生产线:%v已删除", line.LineName) |
90 | } | 90 | } |
91 | - line.Removed = 1 | 91 | + line.Removed = Deleted |
92 | return line, nil | 92 | return line, nil |
93 | } | 93 | } |
94 | 94 | ||
@@ -98,7 +98,7 @@ func (workshop *Workshop) UpdateLine(lineId int, lineName string) error { | @@ -98,7 +98,7 @@ func (workshop *Workshop) UpdateLine(lineId int, lineName string) error { | ||
98 | if err != nil { | 98 | if err != nil { |
99 | return err | 99 | return err |
100 | } | 100 | } |
101 | - if line.Removed == 1 { | 101 | + if line.Removed == Deleted { |
102 | return fmt.Errorf("生产线:%v已删除", line.LineName) | 102 | return fmt.Errorf("生产线:%v已删除", line.LineName) |
103 | } | 103 | } |
104 | line.LineName = lineName | 104 | line.LineName = lineName |
@@ -133,7 +133,7 @@ func (workshop *Workshop) AddSection(lineId int, section *ProductSection) error | @@ -133,7 +133,7 @@ func (workshop *Workshop) AddSection(lineId int, section *ProductSection) error | ||
133 | if err != nil { | 133 | if err != nil { |
134 | return err | 134 | return err |
135 | } | 135 | } |
136 | - if line.Removed == 1 { | 136 | + if line.Removed == Deleted { |
137 | return fmt.Errorf("生产线:%v已删除", line.LineName) | 137 | return fmt.Errorf("生产线:%v已删除", line.LineName) |
138 | } | 138 | } |
139 | for i := range line.ProductSections { | 139 | for i := range line.ProductSections { |
@@ -155,10 +155,10 @@ func (workshop *Workshop) RemoveSection(lineId, sectionId int) error { | @@ -155,10 +155,10 @@ func (workshop *Workshop) RemoveSection(lineId, sectionId int) error { | ||
155 | if err != nil { | 155 | if err != nil { |
156 | return err | 156 | return err |
157 | } | 157 | } |
158 | - if section.Removed == 1 { | 158 | + if section.Removed == Deleted { |
159 | return fmt.Errorf("工段:%v已删除", section.SectionName) | 159 | return fmt.Errorf("工段:%v已删除", section.SectionName) |
160 | } | 160 | } |
161 | - section.Removed = 1 | 161 | + section.Removed = Deleted |
162 | return nil | 162 | return nil |
163 | } | 163 | } |
164 | 164 | ||
@@ -168,7 +168,7 @@ func (workshop *Workshop) UpdateSection(lineId, sectionId int, sectionName strin | @@ -168,7 +168,7 @@ func (workshop *Workshop) UpdateSection(lineId, sectionId int, sectionName strin | ||
168 | if err != nil { | 168 | if err != nil { |
169 | return err | 169 | return err |
170 | } | 170 | } |
171 | - if section.Removed == 1 { | 171 | + if section.Removed == Deleted { |
172 | return fmt.Errorf("工段:%v已删除", section.SectionName) | 172 | return fmt.Errorf("工段:%v已删除", section.SectionName) |
173 | } | 173 | } |
174 | section.SectionName = sectionName | 174 | section.SectionName = sectionName |
@@ -219,3 +219,10 @@ func (workshop *Workshop) GetProductLines(removed int) []*ProductLine { | @@ -219,3 +219,10 @@ func (workshop *Workshop) GetProductLines(removed int) []*ProductLine { | ||
219 | } | 219 | } |
220 | return result | 220 | return result |
221 | } | 221 | } |
222 | + | ||
223 | +func (workshop *Workshop) CloneSample() *Workshop { | ||
224 | + return &Workshop{ | ||
225 | + WorkshopId: workshop.WorkshopId, | ||
226 | + WorkshopName: workshop.WorkshopName, | ||
227 | + } | ||
228 | +} |
pkg/domain/workshops.go
0 → 100644
1 | +package domain | ||
2 | + | ||
3 | +import "strings" | ||
4 | + | ||
5 | +/*车间列表*/ | ||
6 | +type Workshops []*Workshop | ||
7 | + | ||
8 | +func (m Workshops) FindWorkStation(workshopId, lineId, sectionId int) *WorkStation { | ||
9 | + for i := range m { | ||
10 | + item := m[i] | ||
11 | + workstation, err := item.FindWorkStation(workshopId, lineId, sectionId) | ||
12 | + if err == nil && workstation != nil { | ||
13 | + return workstation | ||
14 | + } | ||
15 | + } | ||
16 | + return &WorkStation{} //返回空的对象 | ||
17 | +} | ||
18 | + | ||
19 | +func (m Workshops) FindWorkshopsByName(workshopName string) []int { | ||
20 | + result := make([]int, 0) | ||
21 | + if len(workshopName) == 0 { | ||
22 | + return result | ||
23 | + } | ||
24 | + for i := range m { | ||
25 | + item := m[i] | ||
26 | + if strings.Contains(item.WorkshopName, workshopName) { | ||
27 | + result = append(result, item.WorkshopId) | ||
28 | + } | ||
29 | + } | ||
30 | + return result | ||
31 | +} | ||
32 | + | ||
33 | +func (m Workshops) FindProductLinesByName(lineName string) []int { | ||
34 | + result := make([]int, 0) | ||
35 | + if len(lineName) == 0 { | ||
36 | + return result | ||
37 | + } | ||
38 | + for i := range m { | ||
39 | + item := m[i] | ||
40 | + for j := range item.ProductLines { | ||
41 | + line := item.ProductLines[j] | ||
42 | + if line.Removed == Deleted { | ||
43 | + continue | ||
44 | + } | ||
45 | + if strings.Contains(line.LineName, lineName) { | ||
46 | + result = append(result, line.LineId) | ||
47 | + } | ||
48 | + } | ||
49 | + } | ||
50 | + return result | ||
51 | +} | ||
52 | + | ||
53 | +func (m Workshops) FindProductSectionsByName(sectionName string) []int { | ||
54 | + result := make([]int, 0) | ||
55 | + if len(sectionName) == 0 { | ||
56 | + return result | ||
57 | + } | ||
58 | + for i := range m { | ||
59 | + item := m[i] | ||
60 | + for j := range item.ProductLines { | ||
61 | + line := item.ProductLines[j] | ||
62 | + if line.Removed == Deleted { | ||
63 | + continue | ||
64 | + } | ||
65 | + for z := range line.ProductSections { | ||
66 | + section := line.ProductSections[z] | ||
67 | + if section.Removed == Deleted { | ||
68 | + continue | ||
69 | + } | ||
70 | + if strings.Contains(section.SectionName, sectionName) { | ||
71 | + result = append(result, section.SectionId) | ||
72 | + } | ||
73 | + } | ||
74 | + } | ||
75 | + } | ||
76 | + return result | ||
77 | +} | ||
78 | + | ||
79 | +func (m Workshops) FindByName(workshopName, lineName, sectionName string) (workshops []int, lines []int, sections []int) { | ||
80 | + workshops = m.FindWorkshopsByName(workshopName) | ||
81 | + lines = m.FindProductLinesByName(lineName) | ||
82 | + sections = m.FindProductSectionsByName(sectionName) | ||
83 | + return | ||
84 | +} | ||
85 | + | ||
86 | +func (m Workshops) FindByNameWithQuery(query map[string]interface{}, workshopName, lineName, sectionName string) map[string]interface{} { | ||
87 | + var workshops, lines, sections []int | ||
88 | + workshops = m.FindWorkshopsByName(workshopName) | ||
89 | + lines = m.FindProductLinesByName(lineName) | ||
90 | + sections = m.FindProductSectionsByName(sectionName) | ||
91 | + defaultValue := []int{0} | ||
92 | + if len(workshops) > 0 { | ||
93 | + query["inWorkshopIds"] = workshops | ||
94 | + } else { | ||
95 | + if len(workshopName) > 0 { | ||
96 | + query["inWorkshopIds"] = defaultValue | ||
97 | + } | ||
98 | + } | ||
99 | + | ||
100 | + if len(lines) > 0 { | ||
101 | + query["inLineIds"] = lines | ||
102 | + } else { | ||
103 | + if len(lineName) > 0 { | ||
104 | + query["inLineIds"] = defaultValue | ||
105 | + } | ||
106 | + } | ||
107 | + if len(sections) > 0 { | ||
108 | + query["inSectionIds"] = sections | ||
109 | + } else { | ||
110 | + if len(sectionName) > 0 { | ||
111 | + query["inSectionIds"] = defaultValue | ||
112 | + } | ||
113 | + } | ||
114 | + return query | ||
115 | +} |
1 | +package domainService | ||
2 | + | ||
3 | +//import ( | ||
4 | +// "fmt" | ||
5 | +// pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
6 | +// "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | ||
7 | +// "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/repository" | ||
8 | +//) | ||
9 | +// | ||
10 | +//type PGWorkshopService struct { | ||
11 | +// transactionContext *pgTransaction.TransactionContext | ||
12 | +//} | ||
13 | +// | ||
14 | +//func(ptr *PGWorkshopService)CompanyWorkshops(companyId int)(domain.Workshops,error){ | ||
15 | +// workshopRepository,_:= repository.NewWorkshopRepository(ptr.transactionContext) | ||
16 | +// _,workshops,err:= workshopRepository.Find(map[string]interface{}{"companyId":companyId}) | ||
17 | +// if err!=nil{ | ||
18 | +// return nil,err | ||
19 | +// } | ||
20 | +// if len(workshops)==0{ | ||
21 | +// workshops = make([]*domain.Workshop,0) | ||
22 | +// } | ||
23 | +// return workshops,nil | ||
24 | +//} | ||
25 | +// | ||
26 | +//func NewPGWorkshopService(transactionContext *pgTransaction.TransactionContext) (*PGWorkshopService, error) { | ||
27 | +// if transactionContext == nil { | ||
28 | +// return nil, fmt.Errorf("transactionContext参数不能为nil") | ||
29 | +// } else { | ||
30 | +// return &PGWorkshopService{ | ||
31 | +// transactionContext: transactionContext, | ||
32 | +// }, nil | ||
33 | +// } | ||
34 | +//} |
@@ -6,7 +6,7 @@ import ( | @@ -6,7 +6,7 @@ import ( | ||
6 | ) | 6 | ) |
7 | 7 | ||
8 | type ProductPlan struct { | 8 | type ProductPlan struct { |
9 | - tableName string `comment:"生产计划" pg:"product_plans,alias:manufacture.product_plan"` | 9 | + tableName string `comment:"生产计划" pg:"manufacture.product_plan"` |
10 | // 生产计划ID | 10 | // 生产计划ID |
11 | ProductPlanId int `comment:"生产计划ID" pg:"pk:product_plan_id"` | 11 | ProductPlanId int `comment:"生产计划ID" pg:"pk:product_plan_id"` |
12 | // 企业id | 12 | // 企业id |
@@ -6,6 +6,7 @@ import ( | @@ -6,6 +6,7 @@ import ( | ||
6 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | 6 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" |
7 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/pg/models" | 7 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/pg/models" |
8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/pg/transform" | 8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/pg/transform" |
9 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils" | ||
9 | 10 | ||
10 | "github.com/linmadan/egglib-go/persistent/pg/sqlbuilder" | 11 | "github.com/linmadan/egglib-go/persistent/pg/sqlbuilder" |
11 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | 12 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" |
@@ -154,18 +155,28 @@ func (repository *ProductJobRepository) Find(queryOptions map[string]interface{} | @@ -154,18 +155,28 @@ func (repository *ProductJobRepository) Find(queryOptions map[string]interface{} | ||
154 | query.SetWhereByQueryOption("work_station->>'workshopId'='?'", "workshopId") | 155 | query.SetWhereByQueryOption("work_station->>'workshopId'='?'", "workshopId") |
155 | query.SetWhereByQueryOption("work_station->>'lineId'='?'", "lineId") | 156 | query.SetWhereByQueryOption("work_station->>'lineId'='?'", "lineId") |
156 | query.SetWhereByQueryOption("work_station->>'sectionId'='?'", "sectionId") | 157 | query.SetWhereByQueryOption("work_station->>'sectionId'='?'", "sectionId") |
157 | - if v, ok := queryOptions["jobName"]; ok && len(v.(string)) > 0 { | ||
158 | - query.Where(fmt.Sprintf(`job_name like '%%%v%%'`, v)) | 158 | + if v, ok := queryOptions["inWorkshopIds"]; ok && len(v.([]int)) > 0 { |
159 | + query.Where(`work_station->>'workshopId' in (?)`, pg.In(utils.ToArrayString(v.([]int)))) | ||
159 | } | 160 | } |
160 | - if v, ok := queryOptions["workshopName"]; ok && len(v.(string)) > 0 { | ||
161 | - query.Where(fmt.Sprintf(`work_station->>'workshopName' like '%%%v%%'`, v)) | 161 | + if v, ok := queryOptions["inLineIds"]; ok && len(v.([]int)) > 0 { |
162 | + query.Where(`work_station->>'lineId' in (?)`, pg.In(utils.ToArrayString(v.([]int)))) | ||
162 | } | 163 | } |
163 | - if v, ok := queryOptions["lineName"]; ok && len(v.(string)) > 0 { | ||
164 | - query.Where(fmt.Sprintf(`work_station->>'lineName' like '%%%v%%'`, v)) | 164 | + if v, ok := queryOptions["inSectionIds"]; ok && len(v.([]int)) > 0 { |
165 | + query.Where(`work_station->>'sectionId' in (?)`, pg.In(utils.ToArrayString(v.([]int)))) | ||
165 | } | 166 | } |
166 | - if v, ok := queryOptions["sectionName"]; ok && len(v.(string)) > 0 { | ||
167 | - query.Where(fmt.Sprintf(`work_station->>'sectionName' like '%%%v%%'`, v)) | 167 | + |
168 | + if v, ok := queryOptions["jobName"]; ok && len(v.(string)) > 0 { | ||
169 | + query.Where(fmt.Sprintf(`job_name like '%%%v%%'`, v)) | ||
168 | } | 170 | } |
171 | + //if v, ok := queryOptions["workshopName"]; ok && len(v.(string)) > 0 { | ||
172 | + // query.Where(fmt.Sprintf(`work_station->>'workshopName' like '%%%v%%'`, v)) | ||
173 | + //} | ||
174 | + //if v, ok := queryOptions["lineName"]; ok && len(v.(string)) > 0 { | ||
175 | + // query.Where(fmt.Sprintf(`work_station->>'lineName' like '%%%v%%'`, v)) | ||
176 | + //} | ||
177 | + //if v, ok := queryOptions["sectionName"]; ok && len(v.(string)) > 0 { | ||
178 | + // query.Where(fmt.Sprintf(`work_station->>'sectionName' like '%%%v%%'`, v)) | ||
179 | + //} | ||
169 | query.SetOffsetAndLimit(domain.MaxQueryRow) | 180 | query.SetOffsetAndLimit(domain.MaxQueryRow) |
170 | query.SetOrderDirect("product_job_id", "DESC") | 181 | query.SetOrderDirect("product_job_id", "DESC") |
171 | if count, err := query.SelectAndCount(); err != nil { | 182 | if count, err := query.SelectAndCount(); err != nil { |
@@ -44,19 +44,13 @@ func (repository *ProductPlanRepository) Save(productPlan *domain.ProductPlan) ( | @@ -44,19 +44,13 @@ func (repository *ProductPlanRepository) Save(productPlan *domain.ProductPlan) ( | ||
44 | "deleted_at", | 44 | "deleted_at", |
45 | "ext", | 45 | "ext", |
46 | } | 46 | } |
47 | - insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlBuildFields) | ||
48 | - insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlBuildFields) | 47 | + insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlbuilder.RemoveSqlFields(sqlBuildFields, "product_plan_id", "deleted_at")) |
48 | + insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlbuilder.RemoveSqlFields(sqlBuildFields, "product_plan_id", "deleted_at")) | ||
49 | returningFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlBuildFields) | 49 | returningFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlBuildFields) |
50 | - updateFields := sqlbuilder.RemoveSqlFields(sqlBuildFields, "productPlan_id") | 50 | + updateFields := sqlbuilder.RemoveSqlFields(sqlBuildFields, "product_plan_id", "deleted_at") |
51 | updateFieldsSnippet := sqlbuilder.SqlUpdateFieldsSnippet(updateFields) | 51 | updateFieldsSnippet := sqlbuilder.SqlUpdateFieldsSnippet(updateFields) |
52 | tx := repository.transactionContext.PgTx | 52 | tx := repository.transactionContext.PgTx |
53 | if productPlan.Identify() == nil { | 53 | if productPlan.Identify() == nil { |
54 | - productPlanId, err := repository.nextIdentify() | ||
55 | - if err != nil { | ||
56 | - return productPlan, err | ||
57 | - } else { | ||
58 | - productPlan.ProductPlanId = int(productPlanId) | ||
59 | - } | ||
60 | if _, err := tx.QueryOne( | 54 | if _, err := tx.QueryOne( |
61 | pg.Scan( | 55 | pg.Scan( |
62 | &productPlan.ProductPlanId, | 56 | &productPlan.ProductPlanId, |
@@ -77,8 +71,7 @@ func (repository *ProductPlanRepository) Save(productPlan *domain.ProductPlan) ( | @@ -77,8 +71,7 @@ func (repository *ProductPlanRepository) Save(productPlan *domain.ProductPlan) ( | ||
77 | &productPlan.DeletedAt, | 71 | &productPlan.DeletedAt, |
78 | &productPlan.Ext, | 72 | &productPlan.Ext, |
79 | ), | 73 | ), |
80 | - fmt.Sprintf("INSERT INTO product_plans (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet), | ||
81 | - productPlan.ProductPlanId, | 74 | + fmt.Sprintf("INSERT INTO manufacture.product_plan (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet), |
82 | productPlan.CompanyId, | 75 | productPlan.CompanyId, |
83 | productPlan.OrgId, | 76 | productPlan.OrgId, |
84 | productPlan.BatchNumber, | 77 | productPlan.BatchNumber, |
@@ -93,7 +86,6 @@ func (repository *ProductPlanRepository) Save(productPlan *domain.ProductPlan) ( | @@ -93,7 +86,6 @@ func (repository *ProductPlanRepository) Save(productPlan *domain.ProductPlan) ( | ||
93 | productPlan.Remark, | 86 | productPlan.Remark, |
94 | productPlan.CreatedAt, | 87 | productPlan.CreatedAt, |
95 | productPlan.UpdatedAt, | 88 | productPlan.UpdatedAt, |
96 | - productPlan.DeletedAt, | ||
97 | productPlan.Ext, | 89 | productPlan.Ext, |
98 | ); err != nil { | 90 | ); err != nil { |
99 | return productPlan, err | 91 | return productPlan, err |
@@ -119,8 +111,7 @@ func (repository *ProductPlanRepository) Save(productPlan *domain.ProductPlan) ( | @@ -119,8 +111,7 @@ func (repository *ProductPlanRepository) Save(productPlan *domain.ProductPlan) ( | ||
119 | &productPlan.DeletedAt, | 111 | &productPlan.DeletedAt, |
120 | &productPlan.Ext, | 112 | &productPlan.Ext, |
121 | ), | 113 | ), |
122 | - fmt.Sprintf("UPDATE product_plans SET %s WHERE product_plan_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet), | ||
123 | - productPlan.ProductPlanId, | 114 | + fmt.Sprintf("UPDATE manufacture.product_plan SET %s WHERE product_plan_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet), |
124 | productPlan.CompanyId, | 115 | productPlan.CompanyId, |
125 | productPlan.OrgId, | 116 | productPlan.OrgId, |
126 | productPlan.BatchNumber, | 117 | productPlan.BatchNumber, |
@@ -135,7 +126,6 @@ func (repository *ProductPlanRepository) Save(productPlan *domain.ProductPlan) ( | @@ -135,7 +126,6 @@ func (repository *ProductPlanRepository) Save(productPlan *domain.ProductPlan) ( | ||
135 | productPlan.Remark, | 126 | productPlan.Remark, |
136 | productPlan.CreatedAt, | 127 | productPlan.CreatedAt, |
137 | productPlan.UpdatedAt, | 128 | productPlan.UpdatedAt, |
138 | - productPlan.DeletedAt, | ||
139 | productPlan.Ext, | 129 | productPlan.Ext, |
140 | productPlan.Identify(), | 130 | productPlan.Identify(), |
141 | ); err != nil { | 131 | ); err != nil { |
@@ -157,7 +147,10 @@ func (repository *ProductPlanRepository) FindOne(queryOptions map[string]interfa | @@ -157,7 +147,10 @@ func (repository *ProductPlanRepository) FindOne(queryOptions map[string]interfa | ||
157 | tx := repository.transactionContext.PgTx | 147 | tx := repository.transactionContext.PgTx |
158 | productPlanModel := new(models.ProductPlan) | 148 | productPlanModel := new(models.ProductPlan) |
159 | query := sqlbuilder.BuildQuery(tx.Model(productPlanModel), queryOptions) | 149 | query := sqlbuilder.BuildQuery(tx.Model(productPlanModel), queryOptions) |
160 | - query.SetWhereByQueryOption("product_plan.product_plan_id = ?", "productPlanId") | 150 | + query.SetWhereByQueryOption("product_plan_id = ?", "productPlanId") |
151 | + query.SetWhereByQueryOption("company_id = ?", "companyId") | ||
152 | + query.SetWhereByQueryOption("org_id = ?", "orgId") | ||
153 | + query.SetWhereByQueryOption("batch_number=?", "batchNumber") | ||
161 | if v, ok := queryOptions["includeDeleted"]; ok && v.(bool) { | 154 | if v, ok := queryOptions["includeDeleted"]; ok && v.(bool) { |
162 | query.AllWithDeleted() | 155 | query.AllWithDeleted() |
163 | } | 156 | } |
@@ -48,6 +48,15 @@ func ObjectToMap(o interface{}) map[string]interface{} { | @@ -48,6 +48,15 @@ func ObjectToMap(o interface{}) map[string]interface{} { | ||
48 | return m | 48 | return m |
49 | } | 49 | } |
50 | 50 | ||
51 | +func DeleteMapKeys(options map[string]interface{}, keys ...string) map[string]interface{} { | ||
52 | + for i := range keys { | ||
53 | + if _, ok := options[keys[i]]; ok { | ||
54 | + delete(options, keys[i]) | ||
55 | + } | ||
56 | + } | ||
57 | + return options | ||
58 | +} | ||
59 | + | ||
51 | // AssertString convert v to string value | 60 | // AssertString convert v to string value |
52 | func AssertString(v interface{}) string { | 61 | func AssertString(v interface{}) string { |
53 | if v == nil { | 62 | if v == nil { |
@@ -315,3 +324,11 @@ func ComputeTimeDuration(t1, t2 string) (result time.Duration, err error) { | @@ -315,3 +324,11 @@ func ComputeTimeDuration(t1, t2 string) (result time.Duration, err error) { | ||
315 | ts := t2t.Sub(t1t) | 324 | ts := t2t.Sub(t1t) |
316 | return ts, nil | 325 | return ts, nil |
317 | } | 326 | } |
327 | + | ||
328 | +func ToArrayString(inputs []int) []string { | ||
329 | + result := make([]string, 0) | ||
330 | + for i := range inputs { | ||
331 | + result = append(result, strconv.Itoa(inputs[i])) | ||
332 | + } | ||
333 | + return result | ||
334 | +} |
@@ -24,7 +24,9 @@ func (controller *ProductLineController) UpdateProductLine() { | @@ -24,7 +24,9 @@ func (controller *ProductLineController) UpdateProductLine() { | ||
24 | updateProductLineCommand := &command.UpdateProductLineCommand{} | 24 | updateProductLineCommand := &command.UpdateProductLineCommand{} |
25 | Must(controller.Unmarshal(updateProductLineCommand)) | 25 | Must(controller.Unmarshal(updateProductLineCommand)) |
26 | lineId, _ := controller.GetInt(":lineId") | 26 | lineId, _ := controller.GetInt(":lineId") |
27 | + workshopId, _ := controller.GetInt("workshopId") | ||
27 | updateProductLineCommand.LineId = lineId | 28 | updateProductLineCommand.LineId = lineId |
29 | + updateProductLineCommand.WorkshopId = workshopId | ||
28 | data, err := productLineService.UpdateProductLine(updateProductLineCommand) | 30 | data, err := productLineService.UpdateProductLine(updateProductLineCommand) |
29 | controller.Response(data, err) | 31 | controller.Response(data, err) |
30 | } | 32 | } |
@@ -13,16 +13,19 @@ type ProductPlanController struct { | @@ -13,16 +13,19 @@ type ProductPlanController struct { | ||
13 | 13 | ||
14 | func (controller *ProductPlanController) CreateProductPlan() { | 14 | func (controller *ProductPlanController) CreateProductPlan() { |
15 | productPlanService := service.NewProductPlanService(nil) | 15 | productPlanService := service.NewProductPlanService(nil) |
16 | - createProductPlanCommand := &command.CreateProductPlanCommand{} | ||
17 | - controller.Unmarshal(createProductPlanCommand) | ||
18 | - data, err := productPlanService.CreateProductPlan(createProductPlanCommand) | 16 | + cmd := &command.CreateProductPlanCommand{} |
17 | + Must(controller.Unmarshal(cmd)) | ||
18 | + operateInfo := ParseOperateInfo(controller.BaseController) | ||
19 | + cmd.CompanyId = operateInfo.CompanyId | ||
20 | + cmd.OrgId = operateInfo.OrgId | ||
21 | + data, err := productPlanService.CreateProductPlan(cmd) | ||
19 | controller.Response(data, err) | 22 | controller.Response(data, err) |
20 | } | 23 | } |
21 | 24 | ||
22 | func (controller *ProductPlanController) UpdateProductPlan() { | 25 | func (controller *ProductPlanController) UpdateProductPlan() { |
23 | productPlanService := service.NewProductPlanService(nil) | 26 | productPlanService := service.NewProductPlanService(nil) |
24 | updateProductPlanCommand := &command.UpdateProductPlanCommand{} | 27 | updateProductPlanCommand := &command.UpdateProductPlanCommand{} |
25 | - controller.Unmarshal(updateProductPlanCommand) | 28 | + Must(controller.Unmarshal(updateProductPlanCommand)) |
26 | productPlanId, _ := controller.GetInt(":productPlanId") | 29 | productPlanId, _ := controller.GetInt(":productPlanId") |
27 | updateProductPlanCommand.ProductPlanId = productPlanId | 30 | updateProductPlanCommand.ProductPlanId = productPlanId |
28 | data, err := productPlanService.UpdateProductPlan(updateProductPlanCommand) | 31 | data, err := productPlanService.UpdateProductPlan(updateProductPlanCommand) |
@@ -62,7 +65,7 @@ func (controller *ProductPlanController) ListProductPlan() { | @@ -62,7 +65,7 @@ func (controller *ProductPlanController) ListProductPlan() { | ||
62 | func (controller *ProductPlanController) ReceiveMaterial() { | 65 | func (controller *ProductPlanController) ReceiveMaterial() { |
63 | productPlanService := service.NewProductPlanService(nil) | 66 | productPlanService := service.NewProductPlanService(nil) |
64 | receiveMaterialCommand := &command.ReceiveMaterialCommand{} | 67 | receiveMaterialCommand := &command.ReceiveMaterialCommand{} |
65 | - controller.Unmarshal(receiveMaterialCommand) | 68 | + Must(controller.Unmarshal(receiveMaterialCommand)) |
66 | data, err := productPlanService.ReceiveMaterial(receiveMaterialCommand) | 69 | data, err := productPlanService.ReceiveMaterial(receiveMaterialCommand) |
67 | controller.Response(data, err) | 70 | controller.Response(data, err) |
68 | } | 71 | } |
@@ -70,7 +73,7 @@ func (controller *ProductPlanController) ReceiveMaterial() { | @@ -70,7 +73,7 @@ func (controller *ProductPlanController) ReceiveMaterial() { | ||
70 | func (controller *ProductPlanController) ReturnMaterial() { | 73 | func (controller *ProductPlanController) ReturnMaterial() { |
71 | productPlanService := service.NewProductPlanService(nil) | 74 | productPlanService := service.NewProductPlanService(nil) |
72 | returnMaterialCommand := &command.ReturnMaterialCommand{} | 75 | returnMaterialCommand := &command.ReturnMaterialCommand{} |
73 | - controller.Unmarshal(returnMaterialCommand) | 76 | + Must(controller.Unmarshal(returnMaterialCommand)) |
74 | data, err := productPlanService.ReturnMaterial(returnMaterialCommand) | 77 | data, err := productPlanService.ReturnMaterial(returnMaterialCommand) |
75 | controller.Response(data, err) | 78 | controller.Response(data, err) |
76 | } | 79 | } |
@@ -78,7 +81,7 @@ func (controller *ProductPlanController) ReturnMaterial() { | @@ -78,7 +81,7 @@ func (controller *ProductPlanController) ReturnMaterial() { | ||
78 | func (controller *ProductPlanController) SetOnline() { | 81 | func (controller *ProductPlanController) SetOnline() { |
79 | productPlanService := service.NewProductPlanService(nil) | 82 | productPlanService := service.NewProductPlanService(nil) |
80 | setOnlineCommand := &command.SetOnlineCommand{} | 83 | setOnlineCommand := &command.SetOnlineCommand{} |
81 | - controller.Unmarshal(setOnlineCommand) | 84 | + Must(controller.Unmarshal(setOnlineCommand)) |
82 | data, err := productPlanService.SetOnline(setOnlineCommand) | 85 | data, err := productPlanService.SetOnline(setOnlineCommand) |
83 | controller.Response(data, err) | 86 | controller.Response(data, err) |
84 | } | 87 | } |
@@ -86,7 +89,7 @@ func (controller *ProductPlanController) SetOnline() { | @@ -86,7 +89,7 @@ func (controller *ProductPlanController) SetOnline() { | ||
86 | func (controller *ProductPlanController) Switch() { | 89 | func (controller *ProductPlanController) Switch() { |
87 | productPlanService := service.NewProductPlanService(nil) | 90 | productPlanService := service.NewProductPlanService(nil) |
88 | switchCommand := &command.SwitchCommand{} | 91 | switchCommand := &command.SwitchCommand{} |
89 | - controller.Unmarshal(switchCommand) | 92 | + Must(controller.Unmarshal(switchCommand)) |
90 | data, err := productPlanService.Switch(switchCommand) | 93 | data, err := productPlanService.Switch(switchCommand) |
91 | controller.Response(data, err) | 94 | controller.Response(data, err) |
92 | } | 95 | } |
@@ -94,7 +97,19 @@ func (controller *ProductPlanController) Switch() { | @@ -94,7 +97,19 @@ func (controller *ProductPlanController) Switch() { | ||
94 | func (controller *ProductPlanController) SubmitProductRecord() { | 97 | func (controller *ProductPlanController) SubmitProductRecord() { |
95 | productPlanService := service.NewProductPlanService(nil) | 98 | productPlanService := service.NewProductPlanService(nil) |
96 | submitProductRecordCommand := &command.SubmitProductRecordCommand{} | 99 | submitProductRecordCommand := &command.SubmitProductRecordCommand{} |
97 | - controller.Unmarshal(submitProductRecordCommand) | 100 | + Must(controller.Unmarshal(submitProductRecordCommand)) |
98 | data, err := productPlanService.SubmitProductRecord(submitProductRecordCommand) | 101 | data, err := productPlanService.SubmitProductRecord(submitProductRecordCommand) |
99 | controller.Response(data, err) | 102 | controller.Response(data, err) |
100 | } | 103 | } |
104 | + | ||
105 | +func (controller *ProductPlanController) SearchProductPlan() { | ||
106 | + productPlanService := service.NewProductPlanService(nil) | ||
107 | + cmd := &query.SearchProductPlanQuery{} | ||
108 | + Must(controller.Unmarshal(cmd)) | ||
109 | + operateInfo := ParseOperateInfo(controller.BaseController) | ||
110 | + //cmd.OrgId = operateInfo.OrgId | ||
111 | + cmd.CompanyId = operateInfo.CompanyId | ||
112 | + cmd.InOrgIds = operateInfo.OrgIds | ||
113 | + total, data, err := productPlanService.SearchProductPlan(ParseOperateInfo(controller.BaseController), cmd) | ||
114 | + ResponseGrid(controller.BaseController, total, data, err) | ||
115 | +} |
@@ -24,7 +24,11 @@ func (controller *ProductSectionController) UpdateProductSection() { | @@ -24,7 +24,11 @@ func (controller *ProductSectionController) UpdateProductSection() { | ||
24 | updateProductSectionCommand := &command.UpdateProductSectionCommand{} | 24 | updateProductSectionCommand := &command.UpdateProductSectionCommand{} |
25 | Must(controller.Unmarshal(updateProductSectionCommand)) | 25 | Must(controller.Unmarshal(updateProductSectionCommand)) |
26 | sectionId, _ := controller.GetInt(":sectionId") | 26 | sectionId, _ := controller.GetInt(":sectionId") |
27 | + lineId, _ := controller.GetInt("lineId") | ||
28 | + workshopId, _ := controller.GetInt("workshopId") | ||
27 | updateProductSectionCommand.SectionId = sectionId | 29 | updateProductSectionCommand.SectionId = sectionId |
30 | + updateProductSectionCommand.WorkshopId = workshopId | ||
31 | + updateProductSectionCommand.LineId = lineId | ||
28 | data, err := productSectionService.UpdateProductSection(updateProductSectionCommand) | 32 | data, err := productSectionService.UpdateProductSection(updateProductSectionCommand) |
29 | controller.Response(data, err) | 33 | controller.Response(data, err) |
30 | } | 34 | } |
pkg/port/beego/routers/logger_router.go
0 → 100644
@@ -16,4 +16,5 @@ func init() { | @@ -16,4 +16,5 @@ func init() { | ||
16 | web.Router("/product-plans/set-online", &controllers.ProductPlanController{}, "Post:SetOnline") | 16 | web.Router("/product-plans/set-online", &controllers.ProductPlanController{}, "Post:SetOnline") |
17 | web.Router("/product-plans/switch", &controllers.ProductPlanController{}, "Post:Switch") | 17 | web.Router("/product-plans/switch", &controllers.ProductPlanController{}, "Post:Switch") |
18 | web.Router("/product-plans/submit-product-record", &controllers.ProductPlanController{}, "Post:SubmitProductRecord") | 18 | web.Router("/product-plans/submit-product-record", &controllers.ProductPlanController{}, "Post:SubmitProductRecord") |
19 | + web.Router("/product-plans/search", &controllers.ProductPlanController{}, "Post:SearchProductPlan") | ||
19 | } | 20 | } |
-
请 注册 或 登录 后发表评论