Merge branch 'dev' of http://gitlab.fjmaimaimai.com/allied-creation/allied-creat…
…ion-manufacture into dev
正在显示
14 个修改的文件
包含
81 行增加
和
20 行删除
@@ -11,7 +11,7 @@ require ( | @@ -11,7 +11,7 @@ require ( | ||
11 | github.com/go-pg/pg/v10 v10.9.0 | 11 | github.com/go-pg/pg/v10 v10.9.0 |
12 | github.com/go-redis/redis v6.15.7+incompatible | 12 | github.com/go-redis/redis v6.15.7+incompatible |
13 | github.com/google/go-querystring v1.1.0 // indirect | 13 | github.com/google/go-querystring v1.1.0 // indirect |
14 | - github.com/google/uuid v1.3.0 // indirect | 14 | + github.com/google/uuid v1.3.0 |
15 | github.com/imkira/go-interpol v1.1.0 // indirect | 15 | github.com/imkira/go-interpol v1.1.0 // indirect |
16 | github.com/linmadan/egglib-go v0.0.0-20210313060205-8b5e456b11f7 | 16 | github.com/linmadan/egglib-go v0.0.0-20210313060205-8b5e456b11f7 |
17 | github.com/moul/http2curl v1.0.0 // indirect | 17 | github.com/moul/http2curl v1.0.0 // indirect |
@@ -20,7 +20,7 @@ require ( | @@ -20,7 +20,7 @@ require ( | ||
20 | github.com/sergi/go-diff v1.2.0 // indirect | 20 | github.com/sergi/go-diff v1.2.0 // indirect |
21 | github.com/smartystreets/goconvey v1.7.2 // indirect | 21 | github.com/smartystreets/goconvey v1.7.2 // indirect |
22 | github.com/stretchr/testify v1.7.0 | 22 | github.com/stretchr/testify v1.7.0 |
23 | - github.com/tidwall/gjson v1.13.0 // indirect | 23 | + github.com/tidwall/gjson v1.13.0 |
24 | github.com/valyala/fasthttp v1.32.0 // indirect | 24 | github.com/valyala/fasthttp v1.32.0 // indirect |
25 | github.com/xeipuuv/gojsonschema v1.2.0 // indirect | 25 | github.com/xeipuuv/gojsonschema v1.2.0 // indirect |
26 | github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 // indirect | 26 | github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 // indirect |
@@ -160,7 +160,6 @@ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/ | @@ -160,7 +160,6 @@ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/ | ||
160 | github.com/google/gops v0.3.7/go.mod h1:bj0cwMmX1X4XIJFTjR99R5sCxNssNJ8HebFNvoQlmgY= | 160 | github.com/google/gops v0.3.7/go.mod h1:bj0cwMmX1X4XIJFTjR99R5sCxNssNJ8HebFNvoQlmgY= |
161 | github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= | 161 | github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= |
162 | github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | 162 | github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= |
163 | -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= | ||
164 | github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | 163 | github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= |
165 | github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= | 164 | github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= |
166 | github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | 165 | github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= |
@@ -28,11 +28,14 @@ type CreateDeviceCommand struct { | @@ -28,11 +28,14 @@ type CreateDeviceCommand struct { | ||
28 | // 工段ID | 28 | // 工段ID |
29 | SectionId int `cname:"工段ID" json:"sectionId" valid:"Required"` | 29 | SectionId int `cname:"工段ID" json:"sectionId" valid:"Required"` |
30 | // 品牌 | 30 | // 品牌 |
31 | - Brand string `cname:"品牌" json:"brand" valid:"Required"` | 31 | + Brand string `cname:"品牌" json:"brand"` |
32 | // 设备状态 1:正常 2:封存 3:报废 | 32 | // 设备状态 1:正常 2:封存 3:报废 |
33 | DeviceStatus int `cname:"设备状态 1:正常 2:封存 3:报废" json:"deviceStatus" valid:"Required"` | 33 | DeviceStatus int `cname:"设备状态 1:正常 2:封存 3:报废" json:"deviceStatus" valid:"Required"` |
34 | // 风险等级 1:高 2:中 3:低 | 34 | // 风险等级 1:高 2:中 3:低 |
35 | RiskLevel int `cname:"风险等级 1:高 2:中 3:低" json:"riskLevel" valid:"Required"` | 35 | RiskLevel int `cname:"风险等级 1:高 2:中 3:低" json:"riskLevel" valid:"Required"` |
36 | + | ||
37 | + // 标准工时 生产单个产品的时间(单位:秒) | ||
38 | + UnitProductionSecTime int `cname:"标准工时" json:"unitProductionSecTime"` | ||
36 | } | 39 | } |
37 | 40 | ||
38 | func (createDeviceCommand *CreateDeviceCommand) Valid(validation *validation.Validation) { | 41 | func (createDeviceCommand *CreateDeviceCommand) Valid(validation *validation.Validation) { |
@@ -31,6 +31,8 @@ type UpdateDeviceCommand struct { | @@ -31,6 +31,8 @@ type UpdateDeviceCommand struct { | ||
31 | DeviceStatus int `cname:"设备状态 1:正常 2:封存 3:报废" json:"deviceStatus" valid:"Required"` | 31 | DeviceStatus int `cname:"设备状态 1:正常 2:封存 3:报废" json:"deviceStatus" valid:"Required"` |
32 | // 风险等级 1:高 2:中 3:低 | 32 | // 风险等级 1:高 2:中 3:低 |
33 | RiskLevel int `cname:"风险等级 1:高 2:中 3:低" json:"riskLevel" valid:"Required"` | 33 | RiskLevel int `cname:"风险等级 1:高 2:中 3:低" json:"riskLevel" valid:"Required"` |
34 | + // 标准工时 | ||
35 | + UnitProductionSecTime int `cname:"标准工时" json:"unitProductionSecTime"` | ||
34 | } | 36 | } |
35 | 37 | ||
36 | func (updateDeviceCommand *UpdateDeviceCommand) Valid(validation *validation.Validation) { | 38 | func (updateDeviceCommand *UpdateDeviceCommand) Valid(validation *validation.Validation) { |
@@ -23,6 +23,8 @@ type DeviceDto struct { | @@ -23,6 +23,8 @@ type DeviceDto struct { | ||
23 | RiskLevel int `json:"riskLevel,omitempty"` | 23 | RiskLevel int `json:"riskLevel,omitempty"` |
24 | // 所属位置 | 24 | // 所属位置 |
25 | *domain.WorkStation | 25 | *domain.WorkStation |
26 | + // 生产单个产品的时间(单位:秒) | ||
27 | + UnitProductionSecTime int `json:"unitProductionSecTime"` | ||
26 | 28 | ||
27 | // 组织名称 | 29 | // 组织名称 |
28 | OrgName string `json:"orgName"` | 30 | OrgName string `json:"orgName"` |
@@ -43,5 +45,8 @@ func (d *DeviceDto) LoadDto(m *domain.Device, orgId int) *DeviceDto { | @@ -43,5 +45,8 @@ func (d *DeviceDto) LoadDto(m *domain.Device, orgId int) *DeviceDto { | ||
43 | if m.Ext != nil { | 45 | if m.Ext != nil { |
44 | d.OrgName = m.Ext.OrgName | 46 | d.OrgName = m.Ext.OrgName |
45 | } | 47 | } |
48 | + if m.Ext != nil && m.Ext.DeviceExt != nil { | ||
49 | + d.UnitProductionSecTime = m.Ext.DeviceExt.UnitProductionSecTime | ||
50 | + } | ||
46 | return d | 51 | return d |
47 | } | 52 | } |
@@ -63,7 +63,7 @@ func (deviceService *DeviceService) CreateDevice(operateInfo *domain.OperateInfo | @@ -63,7 +63,7 @@ func (deviceService *DeviceService) CreateDevice(operateInfo *domain.OperateInfo | ||
63 | RiskLevel: cmd.RiskLevel, | 63 | RiskLevel: cmd.RiskLevel, |
64 | CreatedAt: time.Now(), | 64 | CreatedAt: time.Now(), |
65 | UpdatedAt: time.Now(), | 65 | UpdatedAt: time.Now(), |
66 | - Ext: domain.NewExt(org.OrgName), | 66 | + Ext: domain.NewExt(org.OrgName).WithDeviceExt(&domain.DeviceExt{UnitProductionSecTime: cmd.UnitProductionSecTime}), |
67 | } | 67 | } |
68 | deviceRepository, _, _ := factory.FastPgDevice(transactionContext, 0) | 68 | deviceRepository, _, _ := factory.FastPgDevice(transactionContext, 0) |
69 | 69 | ||
@@ -334,18 +334,20 @@ func (deviceService *DeviceService) SearchDevice(operateInfo *domain.OperateInfo | @@ -334,18 +334,20 @@ func (deviceService *DeviceService) SearchDevice(operateInfo *domain.OperateInfo | ||
334 | if err != nil { | 334 | if err != nil { |
335 | return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 335 | return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
336 | } | 336 | } |
337 | - | ||
338 | - if err := transactionContext.CommitTransaction(); err != nil { | ||
339 | - return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
340 | - } | 337 | + workshops, _ := factory.FastPgWorkshops(transactionContext, operateInfo.CompanyId) |
341 | 338 | ||
342 | var result = make([]*dto.DeviceDto, 0) | 339 | var result = make([]*dto.DeviceDto, 0) |
343 | for i := range devices { | 340 | for i := range devices { |
344 | item := devices[i] | 341 | item := devices[i] |
345 | newJobDto := &dto.DeviceDto{} | 342 | newJobDto := &dto.DeviceDto{} |
343 | + item.WorkStation = workshops.FindWorkStation(item.WorkStation.WorkshopId, item.WorkStation.LineId, item.WorkStation.SectionId) | ||
346 | newJobDto.LoadDto(item, operateInfo.OrgId) | 344 | newJobDto.LoadDto(item, operateInfo.OrgId) |
347 | result = append(result, newJobDto) | 345 | result = append(result, newJobDto) |
348 | } | 346 | } |
347 | + | ||
348 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
349 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
350 | + } | ||
349 | return count, result, nil | 351 | return count, result, nil |
350 | } | 352 | } |
351 | 353 |
@@ -119,12 +119,17 @@ func (productGroupService *ProductGroupService) GetProductGroup(getProductGroupQ | @@ -119,12 +119,17 @@ func (productGroupService *ProductGroupService) GetProductGroup(getProductGroupQ | ||
119 | } | 119 | } |
120 | if productGroup == nil { | 120 | if productGroup == nil { |
121 | return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getProductGroupQuery.ProductGroupId))) | 121 | return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getProductGroupQuery.ProductGroupId))) |
122 | - } else { | ||
123 | - if err := transactionContext.CommitTransaction(); err != nil { | ||
124 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
125 | - } | ||
126 | - return productGroup, nil | ||
127 | } | 122 | } |
123 | + _, workshop, err := factory.FastPgWorkshop(transactionContext, productGroup.WorkStation.WorkshopId) | ||
124 | + if err != nil { | ||
125 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
126 | + } | ||
127 | + productGroup.WorkStation, _ = workshop.FindWorkStation(productGroup.WorkStation.WorkshopId, productGroup.WorkStation.LineId, productGroup.WorkStation.SectionId) | ||
128 | + | ||
129 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
130 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
131 | + } | ||
132 | + return productGroup, nil | ||
128 | } | 133 | } |
129 | 134 | ||
130 | // 返回生产班组服务列表 | 135 | // 返回生产班组服务列表 |
@@ -323,8 +328,8 @@ func (productGroupService *ProductGroupService) UpdateProductGroup(cmd *command. | @@ -323,8 +328,8 @@ func (productGroupService *ProductGroupService) UpdateProductGroup(cmd *command. | ||
323 | } | 328 | } |
324 | 329 | ||
325 | // 返回生产班组服务列表 | 330 | // 返回生产班组服务列表 |
326 | -func (productGroupService *ProductGroupService) SearchProductGroup(operateInfo *domain.OperateInfo, q *query.SearchProductGroupQuery) (int64, interface{}, error) { | ||
327 | - if err := q.ValidateQuery(); err != nil { | 331 | +func (productGroupService *ProductGroupService) SearchProductGroup(operateInfo *domain.OperateInfo, cmd *query.SearchProductGroupQuery) (int64, interface{}, error) { |
332 | + if err := cmd.ValidateQuery(); err != nil { | ||
328 | return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 333 | return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
329 | } | 334 | } |
330 | transactionContext, err := factory.CreateTransactionContext(nil) | 335 | transactionContext, err := factory.CreateTransactionContext(nil) |
@@ -337,16 +342,24 @@ func (productGroupService *ProductGroupService) SearchProductGroup(operateInfo * | @@ -337,16 +342,24 @@ func (productGroupService *ProductGroupService) SearchProductGroup(operateInfo * | ||
337 | defer func() { | 342 | defer func() { |
338 | transactionContext.RollbackTransaction() | 343 | transactionContext.RollbackTransaction() |
339 | }() | 344 | }() |
345 | + | ||
346 | + workshops, _ := factory.FastPgWorkshops(transactionContext, operateInfo.CompanyId) | ||
347 | + queryOptions := utils.ObjectToMap(cmd) | ||
348 | + queryOptions = workshops.FindByNameWithQuery(queryOptions, cmd.WorkshopName, cmd.LineName, "") | ||
349 | + | ||
340 | var productGroupRepository domain.ProductGroupRepository | 350 | var productGroupRepository domain.ProductGroupRepository |
341 | productGroupRepository, _, _ = factory.FastPgProductGroup(transactionContext, 0) | 351 | productGroupRepository, _, _ = factory.FastPgProductGroup(transactionContext, 0) |
342 | - count, productGroups, err := productGroupRepository.Find(utils.ObjectToMap(q)) | 352 | + count, productGroups, err := productGroupRepository.Find(queryOptions) |
343 | if err != nil { | 353 | if err != nil { |
344 | return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 354 | return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
345 | } | 355 | } |
346 | var results = make([]*dto.ProductGroupDto, 0) | 356 | var results = make([]*dto.ProductGroupDto, 0) |
347 | for i := range productGroups { | 357 | for i := range productGroups { |
358 | + item := productGroups[i] | ||
348 | newItem := &dto.ProductGroupDto{} | 359 | newItem := &dto.ProductGroupDto{} |
349 | - results = append(results, newItem.LoadDto(productGroups[i], operateInfo.OrgId)) | 360 | + newItem.LoadDto(productGroups[i], operateInfo.OrgId) |
361 | + item.WorkStation = workshops.FindWorkStation(item.WorkStation.WorkshopId, item.WorkStation.LineId, item.WorkStation.SectionId) | ||
362 | + results = append(results, newItem) | ||
350 | } | 363 | } |
351 | if err := transactionContext.CommitTransaction(); err != nil { | 364 | if err := transactionContext.CommitTransaction(); err != nil { |
352 | return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 365 | return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
@@ -6,6 +6,8 @@ import ( | @@ -6,6 +6,8 @@ import ( | ||
6 | ) | 6 | ) |
7 | 7 | ||
8 | type ProductPlanDto struct { | 8 | type ProductPlanDto struct { |
9 | + // 生产计划ID | ||
10 | + ProductPlanId int `json:"productPlanId,omitempty"` | ||
9 | // 批号 | 11 | // 批号 |
10 | BatchNumber string `json:"batchNumber,omitempty"` | 12 | BatchNumber string `json:"batchNumber,omitempty"` |
11 | // 生产日期 | 13 | // 生产日期 |
@@ -41,6 +43,7 @@ type ProductPlanDto struct { | @@ -41,6 +43,7 @@ type ProductPlanDto struct { | ||
41 | } | 43 | } |
42 | 44 | ||
43 | func (d *ProductPlanDto) LoadDto(m *domain.ProductPlan, orgId int) *ProductPlanDto { | 45 | func (d *ProductPlanDto) LoadDto(m *domain.ProductPlan, orgId int) *ProductPlanDto { |
46 | + d.ProductPlanId = m.ProductPlanId | ||
44 | d.BatchNumber = m.BatchNumber | 47 | d.BatchNumber = m.BatchNumber |
45 | d.ProductDate = m.ProductDate.Format("2006/01/02") | 48 | d.ProductDate = m.ProductDate.Format("2006/01/02") |
46 | d.WorkshopId = m.Workshop.WorkshopId | 49 | d.WorkshopId = m.Workshop.WorkshopId |
@@ -305,7 +305,7 @@ func (productPlanService *ProductPlanService) SubmitProductRecord(submitProductR | @@ -305,7 +305,7 @@ func (productPlanService *ProductPlanService) SubmitProductRecord(submitProductR | ||
305 | } | 305 | } |
306 | 306 | ||
307 | // 换单 | 307 | // 换单 |
308 | -func (productPlanService *ProductPlanService) Switch(switchCommand *command.SwitchCommand) (interface{}, error) { | 308 | +func (productPlanService *ProductPlanService) Exchange(switchCommand *command.SwitchCommand) (interface{}, error) { |
309 | if err := switchCommand.ValidateCommand(); err != nil { | 309 | if err := switchCommand.ValidateCommand(); err != nil { |
310 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 310 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
311 | } | 311 | } |
@@ -103,10 +103,16 @@ func (device *Device) Update(data map[string]interface{}) error { | @@ -103,10 +103,16 @@ func (device *Device) Update(data map[string]interface{}) error { | ||
103 | } | 103 | } |
104 | if device.Ext == nil { | 104 | if device.Ext == nil { |
105 | device.Ext = &Ext{} | 105 | device.Ext = &Ext{} |
106 | + if device.Ext.DeviceExt == nil { | ||
107 | + device.Ext.DeviceExt = &DeviceExt{} | ||
108 | + } | ||
106 | } | 109 | } |
107 | if orgName, ok := data["orgName"]; ok { | 110 | if orgName, ok := data["orgName"]; ok { |
108 | device.Ext.OrgName = orgName.(string) | 111 | device.Ext.OrgName = orgName.(string) |
109 | } | 112 | } |
113 | + if unitProductionSecTime, ok := data["unitProductionSecTime"]; ok { | ||
114 | + device.Ext.DeviceExt.UnitProductionSecTime = unitProductionSecTime.(int) | ||
115 | + } | ||
110 | device.UpdatedAt = time.Now() | 116 | device.UpdatedAt = time.Now() |
111 | return nil | 117 | return nil |
112 | } | 118 | } |
pkg/domain/device_ext.go
0 → 100644
@@ -4,6 +4,9 @@ package domain | @@ -4,6 +4,9 @@ package domain | ||
4 | type Ext struct { | 4 | type Ext struct { |
5 | // 组织名称 | 5 | // 组织名称 |
6 | OrgName string `json:"orgName,omitempty"` | 6 | OrgName string `json:"orgName,omitempty"` |
7 | + | ||
8 | + // 设备扩展数据 | ||
9 | + DeviceExt *DeviceExt `json:"deviceExt"` | ||
7 | } | 10 | } |
8 | 11 | ||
9 | func NewExt(orgName string) *Ext { | 12 | func NewExt(orgName string) *Ext { |
@@ -11,3 +14,8 @@ func NewExt(orgName string) *Ext { | @@ -11,3 +14,8 @@ func NewExt(orgName string) *Ext { | ||
11 | OrgName: orgName, | 14 | OrgName: orgName, |
12 | } | 15 | } |
13 | } | 16 | } |
17 | + | ||
18 | +func (e *Ext) WithDeviceExt(deviceExt *DeviceExt) *Ext { | ||
19 | + e.DeviceExt = deviceExt | ||
20 | + return e | ||
21 | +} |
@@ -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" |
@@ -153,6 +154,18 @@ func (repository *ProductGroupRepository) Find(queryOptions map[string]interface | @@ -153,6 +154,18 @@ func (repository *ProductGroupRepository) Find(queryOptions map[string]interface | ||
153 | if v, ok := queryOptions["inOrgIds"]; ok && len(v.([]int)) > 0 { | 154 | if v, ok := queryOptions["inOrgIds"]; ok && len(v.([]int)) > 0 { |
154 | query.Where(`org_id in (?)`, pg.In(v)) | 155 | query.Where(`org_id in (?)`, pg.In(v)) |
155 | } | 156 | } |
157 | + if v, ok := queryOptions["inWorkshopIds"]; ok && len(v.([]int)) > 0 { | ||
158 | + query.Where(`work_station->>'workshopId' in (?)`, pg.In(utils.ToArrayString(v.([]int)))) | ||
159 | + } | ||
160 | + if v, ok := queryOptions["inLineIds"]; ok && len(v.([]int)) > 0 { | ||
161 | + query.Where(`work_station->>'lineId' in (?)`, pg.In(utils.ToArrayString(v.([]int)))) | ||
162 | + } | ||
163 | + if v, ok := queryOptions["inSectionIds"]; ok && len(v.([]int)) > 0 { | ||
164 | + query.Where(`work_station->>'sectionId' in (?)`, pg.In(utils.ToArrayString(v.([]int)))) | ||
165 | + } | ||
166 | + if v, ok := queryOptions["groupName"]; ok && len(v.(string)) > 0 { | ||
167 | + query.Where(fmt.Sprintf(`group_name like '%%%v%%'`, v)) | ||
168 | + } | ||
156 | query.SetOffsetAndLimit(20) | 169 | query.SetOffsetAndLimit(20) |
157 | query.SetOrderDirect("product_group_id", "DESC") | 170 | query.SetOrderDirect("product_group_id", "DESC") |
158 | if count, err := query.SelectAndCount(); err != nil { | 171 | if count, err := query.SelectAndCount(); err != nil { |
@@ -90,7 +90,7 @@ func (controller *ProductPlanController) Switch() { | @@ -90,7 +90,7 @@ func (controller *ProductPlanController) Switch() { | ||
90 | productPlanService := service.NewProductPlanService(nil) | 90 | productPlanService := service.NewProductPlanService(nil) |
91 | switchCommand := &command.SwitchCommand{} | 91 | switchCommand := &command.SwitchCommand{} |
92 | Must(controller.Unmarshal(switchCommand)) | 92 | Must(controller.Unmarshal(switchCommand)) |
93 | - data, err := productPlanService.Switch(switchCommand) | 93 | + data, err := productPlanService.Exchange(switchCommand) |
94 | controller.Response(data, err) | 94 | controller.Response(data, err) |
95 | } | 95 | } |
96 | 96 |
-
请 注册 或 登录 后发表评论