作者 Your Name

更新导入逻辑

@@ -19,7 +19,7 @@ func (srv ExcelDataService) ImportProductRecord(importDataCommand *command.Impor @@ -19,7 +19,7 @@ func (srv ExcelDataService) ImportProductRecord(importDataCommand *command.Impor
19 {EnName: "lineName", CnName: "线别"}, 19 {EnName: "lineName", CnName: "线别"},
20 {EnName: "sectionName", CnName: "工段"}, 20 {EnName: "sectionName", CnName: "工段"},
21 {EnName: "workerName", CnName: "姓名"}, 21 {EnName: "workerName", CnName: "姓名"},
22 - {EnName: "productGroupName", CnName: "班组"}, 22 + {EnName: "batchNumber", CnName: "批次号"},
23 {EnName: "weigh", CnName: "二级品重量"}, 23 {EnName: "weigh", CnName: "二级品重量"},
24 } 24 }
25 excelData, err := converter.OpenImportFileFromIoReader(excelImport, importDataCommand.Reader, importDataCommand.FileExt) //excelImport.OpenExcelFromIoReader(importDataCommand.Reader) 25 excelData, err := converter.OpenImportFileFromIoReader(excelImport, importDataCommand.Reader, importDataCommand.FileExt) //excelImport.OpenExcelFromIoReader(importDataCommand.Reader)
@@ -30,15 +30,14 @@ func (srv ExcelDataService) ImportProductRecord(importDataCommand *command.Impor @@ -30,15 +30,14 @@ func (srv ExcelDataService) ImportProductRecord(importDataCommand *command.Impor
30 item := productRecordCommand.BatchAddProductRecordCommand{} 30 item := productRecordCommand.BatchAddProductRecordCommand{}
31 for _, v := range excelData { 31 for _, v := range excelData {
32 item = productRecordCommand.BatchAddProductRecordCommand{ 32 item = productRecordCommand.BatchAddProductRecordCommand{
33 - CreatedDate: v["createdDate"],  
34 - WorkshopName: v["workshopName"],  
35 - LineName: v["lineName"],  
36 - SectionName: v["sectionName"],  
37 - WorkerName: v["workerName"],  
38 - BatchNumber: v["batchNumber"],  
39 - ProductGroupName: v["productGroupName"],  
40 - Weigh: v["weigh"],  
41 - FailReason: "", 33 + CreatedDate: v["createdDate"],
  34 + WorkshopName: v["workshopName"],
  35 + LineName: v["lineName"],
  36 + SectionName: v["sectionName"],
  37 + WorkerName: v["workerName"],
  38 + BatchNumber: v["batchNumber"],
  39 + Weigh: v["weigh"],
  40 + FailReason: "",
42 } 41 }
43 items = append(items, item) 42 items = append(items, item)
44 } 43 }
@@ -4,15 +4,14 @@ import "errors" @@ -4,15 +4,14 @@ import "errors"
4 4
5 // 批量添加生产记录,二级品 5 // 批量添加生产记录,二级品
6 type BatchAddProductRecordCommand struct { 6 type BatchAddProductRecordCommand struct {
7 - CreatedDate string `json:"createdDate"` // 日期  
8 - WorkshopName string `json:"workshopName"` // 车间  
9 - LineName string `json:"lineName"` // 生产线  
10 - SectionName string `json:"sectionName"` // 工段  
11 - WorkerName string `json:"workerName"` // 工人名称  
12 - BatchNumber string `json:"batchNumber"` // 批次  
13 - ProductGroupName string `json:"productGroupName"` // 班组名称  
14 - Weigh string `json:"weigh"` // 重量  
15 - FailReason string `json:"failReason"` // 数据检查失败的原因 7 + CreatedDate string `json:"createdDate"` // 日期
  8 + WorkshopName string `json:"workshopName"` // 车间
  9 + LineName string `json:"lineName"` // 生产线
  10 + SectionName string `json:"sectionName"` // 工段
  11 + WorkerName string `json:"workerName"` // 工人名称
  12 + BatchNumber string `json:"batchNumber"` // 批次
  13 + Weigh string `json:"weigh"` // 重量
  14 + FailReason string `json:"failReason"` // 数据检查失败的原因
16 } 15 }
17 16
18 func (cmd *BatchAddProductRecordCommand) ValidField() error { 17 func (cmd *BatchAddProductRecordCommand) ValidField() error {
@@ -32,10 +31,7 @@ func (cmd *BatchAddProductRecordCommand) ValidField() error { @@ -32,10 +31,7 @@ func (cmd *BatchAddProductRecordCommand) ValidField() error {
32 return errors.New("姓名未填写") 31 return errors.New("姓名未填写")
33 } 32 }
34 if len(cmd.BatchNumber) == 0 { 33 if len(cmd.BatchNumber) == 0 {
35 - return errors.New("批次未填写")  
36 - }  
37 - if len(cmd.ProductGroupName) == 0 {  
38 - return errors.New("班组名称未填写") 34 + return errors.New("批次号未填写")
39 } 35 }
40 if len(cmd.Weigh) == 0 { 36 if len(cmd.Weigh) == 0 {
41 return errors.New("重量未填写") 37 return errors.New("重量未填写")
@@ -550,15 +550,15 @@ func (productRecordService *ProductRecordService) BatchAddProductRecord(operate @@ -550,15 +550,15 @@ func (productRecordService *ProductRecordService) BatchAddProductRecord(operate
550 failRows = append(failRows, param[i]) 550 failRows = append(failRows, param[i])
551 continue 551 continue
552 } 552 }
553 - //获取生产班组  
554 - var productGroup *domain.ProductGroup  
555 - if v, ok := productGroupMap[param[i].ProductGroupName]; ok {  
556 - productGroup = v  
557 - } else {  
558 - param[i].FailReason = "班组不存在"  
559 - failRows = append(failRows, param[i])  
560 - continue  
561 - } 553 + // //获取生产班组
  554 + // var productGroup *domain.ProductGroup
  555 + // if v, ok := productGroupMap[param[i].ProductGroupName]; ok {
  556 + // productGroup = v
  557 + // } else {
  558 + // param[i].FailReason = "班组不存在"
  559 + // failRows = append(failRows, param[i])
  560 + // continue
  561 + // }
562 //检查员工姓名 562 //检查员工姓名
563 var worker *domain.User 563 var worker *domain.User
564 workKey := param[i].WorkshopName + "/" + param[i].WorkerName 564 workKey := param[i].WorkshopName + "/" + param[i].WorkerName
@@ -615,8 +615,8 @@ func (productRecordService *ProductRecordService) BatchAddProductRecord(operate @@ -615,8 +615,8 @@ func (productRecordService *ProductRecordService) BatchAddProductRecord(operate
615 ProductPlanId: productPlanData.ProductPlanId, 615 ProductPlanId: productPlanData.ProductPlanId,
616 PlanProductName: productPlanData.PlanProductName, 616 PlanProductName: productPlanData.PlanProductName,
617 BatchNumber: productPlanData.BatchNumber, 617 BatchNumber: productPlanData.BatchNumber,
618 - ProductGroupId: productGroup.ProductGroupId,  
619 - WorkOn: productGroup.WorkOn, 618 + ProductGroupId: 0,
  619 + WorkOn: productPlanData.WorkOn,
620 }, 620 },
621 Ext: &domain.Ext{ 621 Ext: &domain.Ext{
622 Operator: operateUser, 622 Operator: operateUser,