作者 Your Name

Merge branch 'dev' into test

... ... @@ -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)
... ... @@ -30,15 +30,14 @@ func (srv ExcelDataService) ImportProductRecord(importDataCommand *command.Impor
item := productRecordCommand.BatchAddProductRecordCommand{}
for _, v := range excelData {
item = productRecordCommand.BatchAddProductRecordCommand{
CreatedDate: v["createdDate"],
WorkshopName: v["workshopName"],
LineName: v["lineName"],
SectionName: v["sectionName"],
WorkerName: v["workerName"],
BatchNumber: v["batchNumber"],
ProductGroupName: v["productGroupName"],
Weigh: v["weigh"],
FailReason: "",
CreatedDate: v["createdDate"],
WorkshopName: v["workshopName"],
LineName: v["lineName"],
SectionName: v["sectionName"],
WorkerName: v["workerName"],
BatchNumber: v["batchNumber"],
Weigh: v["weigh"],
FailReason: "",
}
items = append(items, item)
}
... ...
... ... @@ -4,15 +4,14 @@ import "errors"
// 批量添加生产记录,二级品
type BatchAddProductRecordCommand struct {
CreatedDate string `json:"createdDate"` // 日期
WorkshopName string `json:"workshopName"` // 车间
LineName string `json:"lineName"` // 生产线
SectionName string `json:"sectionName"` // 工段
WorkerName string `json:"workerName"` // 工人名称
BatchNumber string `json:"batchNumber"` // 批次
ProductGroupName string `json:"productGroupName"` // 班组名称
Weigh string `json:"weigh"` // 重量
FailReason string `json:"failReason"` // 数据检查失败的原因
CreatedDate string `json:"createdDate"` // 日期
WorkshopName string `json:"workshopName"` // 车间
LineName string `json:"lineName"` // 生产线
SectionName string `json:"sectionName"` // 工段
WorkerName string `json:"workerName"` // 工人名称
BatchNumber string `json:"batchNumber"` // 批次
Weigh string `json:"weigh"` // 重量
FailReason string `json:"failReason"` // 数据检查失败的原因
}
func (cmd *BatchAddProductRecordCommand) ValidField() error {
... ... @@ -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,
... ...