...
|
...
|
@@ -455,7 +455,7 @@ func (productRecordService *ProductRecordService) CancelProductRecord(cmd *comma |
|
|
return struct{}{}, nil
|
|
|
}
|
|
|
|
|
|
// BatchAddProductRecord 从文件导入的数据,批量添加生产记录
|
|
|
// BatchAddProductRecord 从文件导入的数据,批量添加生产记录,二级品数据
|
|
|
func (productRecordService *ProductRecordService) BatchAddProductRecord(operate *domain.OperateInfo, param []command.BatchAddProductRecordCommand) (
|
|
|
failRows []interface{}, err error) {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
...
|
...
|
@@ -499,18 +499,22 @@ func (productRecordService *ProductRecordService) BatchAddProductRecord(operate |
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
//车间名称+/+线别名称+/+工段名称 作为键名
|
|
|
workStationMap := map[string]*domain.WorkStation{}
|
|
|
//车间数据
|
|
|
workshopRepo, _ := factory.CreateWorkshopRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
|
|
|
//获取车间列表
|
|
|
_, workshopList, err := workshopRepo.Find(map[string]interface{}{
|
|
|
"companyId": operate.CompanyId,
|
|
|
"orgId": operate.OrgId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, "获取车间列表失败"+err.Error())
|
|
|
}
|
|
|
//车间名称+/+工人名 作为键名
|
|
|
workerMap := map[string][]*domain.User{}
|
|
|
//班组名称 作为键名
|
|
|
productGroupMap := map[string]*domain.ProductGroup{}
|
|
|
for _, v := range productGroupList {
|
|
|
workStationName := strings.Join([]string{
|
|
|
v.WorkStation.WorkshopName, v.WorkStation.LineName, v.WorkStation.SectionName,
|
|
|
}, "/")
|
|
|
workStationMap[workStationName] = v.WorkStation
|
|
|
productGroupMap[v.GroupName] = v
|
|
|
for _, vv := range v.GroupMembers {
|
|
|
k := v.WorkStation.WorkshopName + "/" + vv.UserName
|
|
|
isIn := false
|
...
|
...
|
@@ -526,6 +530,19 @@ func (productRecordService *ProductRecordService) BatchAddProductRecord(operate |
|
|
}
|
|
|
}
|
|
|
|
|
|
//车间名称+/+线别名称+/+工段名称 作为键名
|
|
|
workStationMap := map[string]*domain.WorkStation{}
|
|
|
for _, v := range workshopList {
|
|
|
for _, v2 := range v.ProductLines {
|
|
|
for _, v3 := range v2.ProductSections {
|
|
|
workStationName := strings.Join([]string{
|
|
|
v.WorkshopName, v2.LineName, v3.SectionName,
|
|
|
}, "/")
|
|
|
workStationMap[workStationName] = domain.NewWorkStation(v, v2, v3)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
productRecordList := []*domain.ProductRecord{}
|
|
|
nowTime := time.Now()
|
|
|
for i := range param {
|
...
|
...
|
@@ -545,7 +562,7 @@ func (productRecordService *ProductRecordService) BatchAddProductRecord(operate |
|
|
}
|
|
|
//检查工位
|
|
|
var workStation *domain.WorkStation
|
|
|
workStationName := param[i].WorkerName + "/" + param[i].LineName + "/" + param[i].SectionName
|
|
|
workStationName := param[i].WorkshopName + "/" + param[i].LineName + "/" + param[i].SectionName
|
|
|
if v, ok := workStationMap[workStationName]; ok {
|
|
|
workStation = v
|
|
|
} else {
|
...
|
...
|
|