作者 Your Name

更新导入逻辑

... ... @@ -19,7 +19,7 @@ func (srv ExcelDataService) ImportProductRecord(importDataCommand *command.Impor
{EnName: "lineName", CnName: "线别"},
{EnName: "sectionName", CnName: "工段"},
{EnName: "workerName", CnName: "姓名"},
{EnName: "productGroupName", CnName: "班组"},
{EnName: "batchNumber", CnName: "批次号"},
{EnName: "weigh", CnName: "二级品重量"},
}
excelData, err := converter.OpenImportFileFromIoReader(excelImport, importDataCommand.Reader, importDataCommand.FileExt) //excelImport.OpenExcelFromIoReader(importDataCommand.Reader)
... ... @@ -36,7 +36,6 @@ func (srv ExcelDataService) ImportProductRecord(importDataCommand *command.Impor
SectionName: v["sectionName"],
WorkerName: v["workerName"],
BatchNumber: v["batchNumber"],
ProductGroupName: v["productGroupName"],
Weigh: v["weigh"],
FailReason: "",
}
... ...
... ... @@ -10,7 +10,6 @@ type BatchAddProductRecordCommand struct {
SectionName string `json:"sectionName"` // 工段
WorkerName string `json:"workerName"` // 工人名称
BatchNumber string `json:"batchNumber"` // 批次
ProductGroupName string `json:"productGroupName"` // 班组名称
Weigh string `json:"weigh"` // 重量
FailReason string `json:"failReason"` // 数据检查失败的原因
}
... ... @@ -32,10 +31,7 @@ func (cmd *BatchAddProductRecordCommand) ValidField() error {
return errors.New("姓名未填写")
}
if len(cmd.BatchNumber) == 0 {
return errors.New("批次未填写")
}
if len(cmd.ProductGroupName) == 0 {
return errors.New("班组名称未填写")
return errors.New("批次号未填写")
}
if len(cmd.Weigh) == 0 {
return errors.New("重量未填写")
... ...
... ... @@ -550,15 +550,15 @@ func (productRecordService *ProductRecordService) BatchAddProductRecord(operate
failRows = append(failRows, param[i])
continue
}
//获取生产班组
var productGroup *domain.ProductGroup
if v, ok := productGroupMap[param[i].ProductGroupName]; ok {
productGroup = v
} else {
param[i].FailReason = "班组不存在"
failRows = append(failRows, param[i])
continue
}
// //获取生产班组
// var productGroup *domain.ProductGroup
// if v, ok := productGroupMap[param[i].ProductGroupName]; ok {
// productGroup = v
// } else {
// param[i].FailReason = "班组不存在"
// failRows = append(failRows, param[i])
// continue
// }
//检查员工姓名
var worker *domain.User
workKey := param[i].WorkshopName + "/" + param[i].WorkerName
... ... @@ -615,8 +615,8 @@ func (productRecordService *ProductRecordService) BatchAddProductRecord(operate
ProductPlanId: productPlanData.ProductPlanId,
PlanProductName: productPlanData.PlanProductName,
BatchNumber: productPlanData.BatchNumber,
ProductGroupId: productGroup.ProductGroupId,
WorkOn: productGroup.WorkOn,
ProductGroupId: 0,
WorkOn: productPlanData.WorkOn,
},
Ext: &domain.Ext{
Operator: operateUser,
... ...