...
|
...
|
@@ -119,12 +119,17 @@ func (productGroupService *ProductGroupService) GetProductGroup(getProductGroupQ |
|
|
}
|
|
|
if productGroup == nil {
|
|
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getProductGroupQuery.ProductGroupId)))
|
|
|
} else {
|
|
|
}
|
|
|
_, workshop, err := factory.FastPgWorkshop(transactionContext, productGroup.WorkStation.WorkshopId)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
productGroup.WorkStation, _ = workshop.FindWorkStation(productGroup.WorkStation.WorkshopId, productGroup.WorkStation.LineId, productGroup.WorkStation.SectionId)
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return productGroup, nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 返回生产班组服务列表
|
...
|
...
|
@@ -323,8 +328,8 @@ func (productGroupService *ProductGroupService) UpdateProductGroup(cmd *command. |
|
|
}
|
|
|
|
|
|
// 返回生产班组服务列表
|
|
|
func (productGroupService *ProductGroupService) SearchProductGroup(operateInfo *domain.OperateInfo, q *query.SearchProductGroupQuery) (int64, interface{}, error) {
|
|
|
if err := q.ValidateQuery(); err != nil {
|
|
|
func (productGroupService *ProductGroupService) SearchProductGroup(operateInfo *domain.OperateInfo, cmd *query.SearchProductGroupQuery) (int64, interface{}, error) {
|
|
|
if err := cmd.ValidateQuery(); err != nil {
|
|
|
return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
|
|
}
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
...
|
...
|
@@ -337,16 +342,24 @@ func (productGroupService *ProductGroupService) SearchProductGroup(operateInfo * |
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
workshops, _ := factory.FastPgWorkshops(transactionContext, operateInfo.CompanyId)
|
|
|
queryOptions := utils.ObjectToMap(cmd)
|
|
|
queryOptions = workshops.FindByNameWithQuery(queryOptions, cmd.WorkshopName, cmd.LineName, "")
|
|
|
|
|
|
var productGroupRepository domain.ProductGroupRepository
|
|
|
productGroupRepository, _, _ = factory.FastPgProductGroup(transactionContext, 0)
|
|
|
count, productGroups, err := productGroupRepository.Find(utils.ObjectToMap(q))
|
|
|
count, productGroups, err := productGroupRepository.Find(queryOptions)
|
|
|
if err != nil {
|
|
|
return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
var results = make([]*dto.ProductGroupDto, 0)
|
|
|
for i := range productGroups {
|
|
|
item := productGroups[i]
|
|
|
newItem := &dto.ProductGroupDto{}
|
|
|
results = append(results, newItem.LoadDto(productGroups[i], operateInfo.OrgId))
|
|
|
newItem.LoadDto(productGroups[i], operateInfo.OrgId)
|
|
|
item.WorkStation = workshops.FindWorkStation(item.WorkStation.WorkshopId, item.WorkStation.LineId, item.WorkStation.SectionId)
|
|
|
results = append(results, newItem)
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
...
|
...
|
|