...
|
...
|
@@ -56,7 +56,7 @@ func (productRecordService *ProductRecordService) ApproveProductRecord(cmd *comm |
|
|
return struct{}{}, nil
|
|
|
}
|
|
|
|
|
|
// 创建生产记录服务
|
|
|
// 创建生产记录服务,二级品
|
|
|
func (productRecordService *ProductRecordService) CreateProductRecord(operateInfo *domain.OperateInfo, param *command.CreateProductRecordCommand) (interface{}, error) {
|
|
|
if err := param.ValidateCommand(); err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
...
|
...
|
@@ -117,13 +117,17 @@ func (productRecordService *ProductRecordService) CreateProductRecord(operateInf |
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, "获取车间工段数据失败"+err.Error())
|
|
|
}
|
|
|
|
|
|
productRecordIds := []int{}
|
|
|
for _, workerId := range param.WorkerId {
|
|
|
workerData, err := userService.User(workerId)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, "获取员工数据错误,"+err.Error())
|
|
|
}
|
|
|
productRecordData := &domain.ProductRecord{
|
|
|
ProductRecordId: param.ProductRecordId,
|
|
|
CompanyId: operateInfo.CompanyId,
|
|
|
OrgId: operateInfo.OrgId,
|
|
|
ProductRecordType: domain.RecordTypeSecondLevelWeigh,
|
|
|
ProductWorker: user,
|
|
|
ProductWorker: workerData,
|
|
|
WorkStation: workstation,
|
|
|
CreatedAt: dataTime,
|
|
|
UpdatedAt: time.Now(),
|
...
|
...
|
@@ -150,11 +154,13 @@ func (productRecordService *ProductRecordService) CreateProductRecord(operateInf |
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, "保存生产记录"+err.Error())
|
|
|
}
|
|
|
productRecordIds = append(productRecordIds, productRecordData.ProductRecordId)
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return map[string]interface{}{
|
|
|
"productRecordId": productRecordData.ProductRecordId,
|
|
|
"productRecordId": productRecordIds,
|
|
|
}, nil
|
|
|
}
|
|
|
|
...
|
...
|
|