|
@@ -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 {
|
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
|
+
|
123
|
if err := transactionContext.CommitTransaction(); err != nil {
|
129
|
if err := transactionContext.CommitTransaction(); err != nil {
|
124
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
130
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
125
|
}
|
131
|
}
|
126
|
return productGroup, nil
|
132
|
return productGroup, nil
|
127
|
- }
|
|
|
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())
|