正在显示
4 个修改的文件
包含
108 行增加
和
35 行删除
@@ -127,15 +127,23 @@ func (srv ExcelDataService) BatchAddAttendance(operate domain.OperateInfo, param | @@ -127,15 +127,23 @@ func (srv ExcelDataService) BatchAddAttendance(operate domain.OperateInfo, param | ||
127 | if err != nil { | 127 | if err != nil { |
128 | return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | 128 | return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) |
129 | } | 129 | } |
130 | - //车间名称+/+线别名称+/+工段名称 作为键名 | ||
131 | - workStationMap := map[string]*domain.WorkStation{} | 130 | + |
131 | + //车间数据 | ||
132 | + workshopRepo, _ := factory.CreateWorkshopRepository(map[string]interface{}{ | ||
133 | + "transactionContext": transactionContext, | ||
134 | + }) | ||
135 | + | ||
136 | + //获取车间列表 | ||
137 | + _, workshopList, err := workshopRepo.Find(map[string]interface{}{ | ||
138 | + "companyId": operate.CompanyId, | ||
139 | + "orgId": operate.OrgId, | ||
140 | + }) | ||
141 | + if err != nil { | ||
142 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "获取车间列表失败"+err.Error()) | ||
143 | + } | ||
132 | //车间名称+/+工人名 作为键名 | 144 | //车间名称+/+工人名 作为键名 |
133 | workerMap := map[string][]*domain.User{} | 145 | workerMap := map[string][]*domain.User{} |
134 | for _, v := range productGroupList { | 146 | for _, v := range productGroupList { |
135 | - workStationName := strings.Join([]string{ | ||
136 | - v.WorkStation.WorkshopName, v.WorkStation.LineName, v.WorkStation.SectionName, | ||
137 | - }, "/") | ||
138 | - workStationMap[workStationName] = v.WorkStation | ||
139 | for _, vv := range v.GroupMembers { | 147 | for _, vv := range v.GroupMembers { |
140 | k := v.WorkStation.WorkshopName + "/" + vv.UserName | 148 | k := v.WorkStation.WorkshopName + "/" + vv.UserName |
141 | isIn := false | 149 | isIn := false |
@@ -150,6 +158,19 @@ func (srv ExcelDataService) BatchAddAttendance(operate domain.OperateInfo, param | @@ -150,6 +158,19 @@ func (srv ExcelDataService) BatchAddAttendance(operate domain.OperateInfo, param | ||
150 | } | 158 | } |
151 | } | 159 | } |
152 | } | 160 | } |
161 | + | ||
162 | + //车间名称+/+线别名称+/+工段名称 作为键名 | ||
163 | + workStationMap := map[string]*domain.WorkStation{} | ||
164 | + for _, v := range workshopList { | ||
165 | + for _, v2 := range v.ProductLines { | ||
166 | + for _, v3 := range v2.ProductSections { | ||
167 | + workStationName := strings.Join([]string{ | ||
168 | + v.WorkshopName, v2.LineName, v3.SectionName, | ||
169 | + }, "/") | ||
170 | + workStationMap[workStationName] = domain.NewWorkStation(v, v2, v3) | ||
171 | + } | ||
172 | + } | ||
173 | + } | ||
153 | var attendanceList []*domain.ProductAttendanceRecord | 174 | var attendanceList []*domain.ProductAttendanceRecord |
154 | nowTime := time.Now() | 175 | nowTime := time.Now() |
155 | //检查导入的数据 | 176 | //检查导入的数据 |
@@ -384,18 +384,23 @@ func (srv *ProductRecordService) BatchAddProductCapacities(operate *domain.Opera | @@ -384,18 +384,23 @@ func (srv *ProductRecordService) BatchAddProductCapacities(operate *domain.Opera | ||
384 | if err != nil { | 384 | if err != nil { |
385 | return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | 385 | return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) |
386 | } | 386 | } |
387 | - //车间名称+/+线别名称+/+工段名称 作为键名 | ||
388 | - workStationMap := map[string]*domain.WorkStation{} | 387 | + //车间数据 |
388 | + workshopRepo, _ := factory.CreateWorkshopRepository(map[string]interface{}{ | ||
389 | + "transactionContext": transactionContext, | ||
390 | + }) | ||
391 | + | ||
392 | + //获取车间列表 | ||
393 | + _, workshopList, err := workshopRepo.Find(map[string]interface{}{ | ||
394 | + "companyId": operate.CompanyId, | ||
395 | + "orgId": operate.OrgId, | ||
396 | + }) | ||
397 | + if err != nil { | ||
398 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "获取车间列表失败"+err.Error()) | ||
399 | + } | ||
400 | + | ||
389 | //车间名称+/+工人名 作为键名 | 401 | //车间名称+/+工人名 作为键名 |
390 | workerMap := map[string][]*domain.User{} | 402 | workerMap := map[string][]*domain.User{} |
391 | - //班组名称 作为键名 | ||
392 | - productGroupMap := map[string]*domain.ProductGroup{} | ||
393 | for _, v := range productGroupList { | 403 | for _, v := range productGroupList { |
394 | - workStationName := strings.Join([]string{ | ||
395 | - v.WorkStation.WorkshopName, v.WorkStation.LineName, v.WorkStation.SectionName, | ||
396 | - }, "/") | ||
397 | - workStationMap[workStationName] = v.WorkStation | ||
398 | - productGroupMap[v.GroupName] = v | ||
399 | for _, vv := range v.GroupMembers { | 404 | for _, vv := range v.GroupMembers { |
400 | k := v.WorkStation.WorkshopName + "/" + vv.UserName | 405 | k := v.WorkStation.WorkshopName + "/" + vv.UserName |
401 | isIn := false | 406 | isIn := false |
@@ -410,7 +415,18 @@ func (srv *ProductRecordService) BatchAddProductCapacities(operate *domain.Opera | @@ -410,7 +415,18 @@ func (srv *ProductRecordService) BatchAddProductCapacities(operate *domain.Opera | ||
410 | } | 415 | } |
411 | } | 416 | } |
412 | } | 417 | } |
413 | - | 418 | + //车间名称+/+线别名称+/+工段名称 作为键名 |
419 | + workStationMap := map[string]*domain.WorkStation{} | ||
420 | + for _, v := range workshopList { | ||
421 | + for _, v2 := range v.ProductLines { | ||
422 | + for _, v3 := range v2.ProductSections { | ||
423 | + workStationName := strings.Join([]string{ | ||
424 | + v.WorkshopName, v2.LineName, v3.SectionName, | ||
425 | + }, "/") | ||
426 | + workStationMap[workStationName] = domain.NewWorkStation(v, v2, v3) | ||
427 | + } | ||
428 | + } | ||
429 | + } | ||
414 | productRecordList := []*domain.ProductRecord{} | 430 | productRecordList := []*domain.ProductRecord{} |
415 | 431 | ||
416 | nowTime := time.Now() | 432 | nowTime := time.Now() |
@@ -455,7 +455,7 @@ func (productRecordService *ProductRecordService) CancelProductRecord(cmd *comma | @@ -455,7 +455,7 @@ func (productRecordService *ProductRecordService) CancelProductRecord(cmd *comma | ||
455 | return struct{}{}, nil | 455 | return struct{}{}, nil |
456 | } | 456 | } |
457 | 457 | ||
458 | -// BatchAddProductRecord 从文件导入的数据,批量添加生产记录 | 458 | +// BatchAddProductRecord 从文件导入的数据,批量添加生产记录,二级品数据 |
459 | func (productRecordService *ProductRecordService) BatchAddProductRecord(operate *domain.OperateInfo, param []command.BatchAddProductRecordCommand) ( | 459 | func (productRecordService *ProductRecordService) BatchAddProductRecord(operate *domain.OperateInfo, param []command.BatchAddProductRecordCommand) ( |
460 | failRows []interface{}, err error) { | 460 | failRows []interface{}, err error) { |
461 | transactionContext, err := factory.CreateTransactionContext(nil) | 461 | transactionContext, err := factory.CreateTransactionContext(nil) |
@@ -499,18 +499,22 @@ func (productRecordService *ProductRecordService) BatchAddProductRecord(operate | @@ -499,18 +499,22 @@ func (productRecordService *ProductRecordService) BatchAddProductRecord(operate | ||
499 | if err != nil { | 499 | if err != nil { |
500 | return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | 500 | return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) |
501 | } | 501 | } |
502 | - //车间名称+/+线别名称+/+工段名称 作为键名 | ||
503 | - workStationMap := map[string]*domain.WorkStation{} | 502 | + //车间数据 |
503 | + workshopRepo, _ := factory.CreateWorkshopRepository(map[string]interface{}{ | ||
504 | + "transactionContext": transactionContext, | ||
505 | + }) | ||
506 | + | ||
507 | + //获取车间列表 | ||
508 | + _, workshopList, err := workshopRepo.Find(map[string]interface{}{ | ||
509 | + "companyId": operate.CompanyId, | ||
510 | + "orgId": operate.OrgId, | ||
511 | + }) | ||
512 | + if err != nil { | ||
513 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "获取车间列表失败"+err.Error()) | ||
514 | + } | ||
504 | //车间名称+/+工人名 作为键名 | 515 | //车间名称+/+工人名 作为键名 |
505 | workerMap := map[string][]*domain.User{} | 516 | workerMap := map[string][]*domain.User{} |
506 | - //班组名称 作为键名 | ||
507 | - productGroupMap := map[string]*domain.ProductGroup{} | ||
508 | for _, v := range productGroupList { | 517 | for _, v := range productGroupList { |
509 | - workStationName := strings.Join([]string{ | ||
510 | - v.WorkStation.WorkshopName, v.WorkStation.LineName, v.WorkStation.SectionName, | ||
511 | - }, "/") | ||
512 | - workStationMap[workStationName] = v.WorkStation | ||
513 | - productGroupMap[v.GroupName] = v | ||
514 | for _, vv := range v.GroupMembers { | 518 | for _, vv := range v.GroupMembers { |
515 | k := v.WorkStation.WorkshopName + "/" + vv.UserName | 519 | k := v.WorkStation.WorkshopName + "/" + vv.UserName |
516 | isIn := false | 520 | isIn := false |
@@ -526,6 +530,19 @@ func (productRecordService *ProductRecordService) BatchAddProductRecord(operate | @@ -526,6 +530,19 @@ func (productRecordService *ProductRecordService) BatchAddProductRecord(operate | ||
526 | } | 530 | } |
527 | } | 531 | } |
528 | 532 | ||
533 | + //车间名称+/+线别名称+/+工段名称 作为键名 | ||
534 | + workStationMap := map[string]*domain.WorkStation{} | ||
535 | + for _, v := range workshopList { | ||
536 | + for _, v2 := range v.ProductLines { | ||
537 | + for _, v3 := range v2.ProductSections { | ||
538 | + workStationName := strings.Join([]string{ | ||
539 | + v.WorkshopName, v2.LineName, v3.SectionName, | ||
540 | + }, "/") | ||
541 | + workStationMap[workStationName] = domain.NewWorkStation(v, v2, v3) | ||
542 | + } | ||
543 | + } | ||
544 | + } | ||
545 | + | ||
529 | productRecordList := []*domain.ProductRecord{} | 546 | productRecordList := []*domain.ProductRecord{} |
530 | nowTime := time.Now() | 547 | nowTime := time.Now() |
531 | for i := range param { | 548 | for i := range param { |
@@ -545,7 +562,7 @@ func (productRecordService *ProductRecordService) BatchAddProductRecord(operate | @@ -545,7 +562,7 @@ func (productRecordService *ProductRecordService) BatchAddProductRecord(operate | ||
545 | } | 562 | } |
546 | //检查工位 | 563 | //检查工位 |
547 | var workStation *domain.WorkStation | 564 | var workStation *domain.WorkStation |
548 | - workStationName := param[i].WorkerName + "/" + param[i].LineName + "/" + param[i].SectionName | 565 | + workStationName := param[i].WorkshopName + "/" + param[i].LineName + "/" + param[i].SectionName |
549 | if v, ok := workStationMap[workStationName]; ok { | 566 | if v, ok := workStationMap[workStationName]; ok { |
550 | workStation = v | 567 | workStation = v |
551 | } else { | 568 | } else { |
@@ -333,7 +333,19 @@ func (srv ProductTroubleService) BatchAddProductTrouble(operateInfo *domain.Oper | @@ -333,7 +333,19 @@ func (srv ProductTroubleService) BatchAddProductTrouble(operateInfo *domain.Oper | ||
333 | if err != nil { | 333 | if err != nil { |
334 | return nil, application.ThrowError(application.TRANSACTION_ERROR, "查询操作人数据失败。"+err.Error()) | 334 | return nil, application.ThrowError(application.TRANSACTION_ERROR, "查询操作人数据失败。"+err.Error()) |
335 | } | 335 | } |
336 | + //车间数据 | ||
337 | + workshopRepo, _ := factory.CreateWorkshopRepository(map[string]interface{}{ | ||
338 | + "transactionContext": transactionContext, | ||
339 | + }) | ||
336 | 340 | ||
341 | + //获取车间列表 | ||
342 | + _, workshopList, err := workshopRepo.Find(map[string]interface{}{ | ||
343 | + "companyId": operateInfo.CompanyId, | ||
344 | + "orgId": operateInfo.OrgId, | ||
345 | + }) | ||
346 | + if err != nil { | ||
347 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "获取车间列表失败"+err.Error()) | ||
348 | + } | ||
337 | //生产班组 数据 | 349 | //生产班组 数据 |
338 | productGroupRepo, _ := factory.CreateProductGroupRepository(map[string]interface{}{ | 350 | productGroupRepo, _ := factory.CreateProductGroupRepository(map[string]interface{}{ |
339 | "transactionContext": transactionContext, | 351 | "transactionContext": transactionContext, |
@@ -345,18 +357,13 @@ func (srv ProductTroubleService) BatchAddProductTrouble(operateInfo *domain.Oper | @@ -345,18 +357,13 @@ func (srv ProductTroubleService) BatchAddProductTrouble(operateInfo *domain.Oper | ||
345 | if err != nil { | 357 | if err != nil { |
346 | return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | 358 | return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) |
347 | } | 359 | } |
348 | - //车间名称+/+线别名称+/+工段名称 作为键名 | ||
349 | - workStationMap := map[string]*domain.WorkStation{} | 360 | + |
350 | //车间名称+/+工人名 作为键名 | 361 | //车间名称+/+工人名 作为键名 |
351 | workerMap := map[string][]*domain.User{} | 362 | workerMap := map[string][]*domain.User{} |
352 | //班组名称 作为键名 | 363 | //班组名称 作为键名 |
353 | - productGroupMap := map[string]*domain.ProductGroup{} | 364 | + // productGroupMap := map[string]*domain.ProductGroup{} |
354 | for _, v := range productGroupList { | 365 | for _, v := range productGroupList { |
355 | - workStationName := strings.Join([]string{ | ||
356 | - v.WorkStation.WorkshopName, v.WorkStation.LineName, v.WorkStation.SectionName, | ||
357 | - }, "/") | ||
358 | - workStationMap[workStationName] = v.WorkStation | ||
359 | - productGroupMap[v.GroupName] = v | 366 | + // productGroupMap[v.GroupName] = v |
360 | for _, vv := range v.GroupMembers { | 367 | for _, vv := range v.GroupMembers { |
361 | k := v.WorkStation.WorkshopName + "/" + vv.UserName | 368 | k := v.WorkStation.WorkshopName + "/" + vv.UserName |
362 | isIn := false | 369 | isIn := false |
@@ -371,6 +378,18 @@ func (srv ProductTroubleService) BatchAddProductTrouble(operateInfo *domain.Oper | @@ -371,6 +378,18 @@ func (srv ProductTroubleService) BatchAddProductTrouble(operateInfo *domain.Oper | ||
371 | } | 378 | } |
372 | } | 379 | } |
373 | } | 380 | } |
381 | + //车间名称+/+线别名称+/+工段名称 作为键名 | ||
382 | + workStationMap := map[string]*domain.WorkStation{} | ||
383 | + for _, v := range workshopList { | ||
384 | + for _, v2 := range v.ProductLines { | ||
385 | + for _, v3 := range v2.ProductSections { | ||
386 | + workStationName := strings.Join([]string{ | ||
387 | + v.WorkshopName, v2.LineName, v3.SectionName, | ||
388 | + }, "/") | ||
389 | + workStationMap[workStationName] = domain.NewWorkStation(v, v2, v3) | ||
390 | + } | ||
391 | + } | ||
392 | + } | ||
374 | 393 | ||
375 | troubleDataList := make([]*domain.ProductTrouble, 0, len(param)) | 394 | troubleDataList := make([]*domain.ProductTrouble, 0, len(param)) |
376 | nowTime := time.Now() | 395 | nowTime := time.Now() |
-
请 注册 或 登录 后发表评论