正在显示
4 个修改的文件
包含
58 行增加
和
3 行删除
1 | +package service | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/linmadan/egglib-go/core/application" | ||
5 | + "github.com/linmadan/egglib-go/utils/excel" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/ecelData/command" | ||
7 | + productRecordCommand "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productRecord/command" | ||
8 | + productRecordService "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productRecord/service" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils/converter" | ||
10 | +) | ||
11 | + | ||
12 | +// ImportProductCapacities 导入产能数据 | ||
13 | +func (srv ExcelDataService) ImportProductCapacities(importDataCommand *command.ImportDataCommand) (interface{}, error) { | ||
14 | + excelImport := excel.NewExcelImport() | ||
15 | + excelImport.RowBegin = 3 //第二行开始读取 | ||
16 | + excelImport.DataFields = []excel.DataField{ | ||
17 | + {EnName: "RecordDate", CnName: "日期"}, | ||
18 | + {EnName: "WorkshopName", CnName: "车间"}, | ||
19 | + {EnName: "LineName", CnName: "线别"}, | ||
20 | + {EnName: "SectionName", CnName: "工段"}, | ||
21 | + {EnName: "WorkOn", CnName: "班别"}, | ||
22 | + {EnName: "WorkerName", CnName: "姓名"}, | ||
23 | + {EnName: "BatchNumber", CnName: "批次号"}, | ||
24 | + {EnName: "Weigh", CnName: "产量(kg)"}, | ||
25 | + } | ||
26 | + excelData, err := converter.OpenImportFileFromIoReader(excelImport, importDataCommand.Reader, importDataCommand.FileExt) //excelImport.OpenExcelFromIoReader(importDataCommand.Reader) | ||
27 | + if err != nil { | ||
28 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
29 | + } | ||
30 | + items := make([]productRecordCommand.BatchAddProductCapacitiesCmd, 0, len(excelData)) | ||
31 | + item := productRecordCommand.BatchAddProductCapacitiesCmd{} | ||
32 | + for _, v := range excelData { | ||
33 | + item = productRecordCommand.BatchAddProductCapacitiesCmd{ | ||
34 | + RecordDate: v["RecordDate"], | ||
35 | + WorkshopName: v["WorkshopName"], | ||
36 | + LineName: v["LineName"], | ||
37 | + SectionName: v["SectionName"], | ||
38 | + WorkerName: v["WorkerName"], | ||
39 | + BatchNumber: v["BatchNumber"], | ||
40 | + WorkOn: v["WorkOn"], | ||
41 | + Weigh: v["Weigh"], | ||
42 | + FailReason: "", | ||
43 | + } | ||
44 | + items = append(items, item) | ||
45 | + } | ||
46 | + | ||
47 | + svr := productRecordService.NewProductRecordService(nil) | ||
48 | + failRows, err := svr.BatchAddProductCapacities(importDataCommand.Operator, items) | ||
49 | + if err != nil { | ||
50 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
51 | + } | ||
52 | + return srv.importResultWithHeader(excelImport.DataFields, failRows, len(items)), nil | ||
53 | +} |
@@ -9,7 +9,7 @@ import ( | @@ -9,7 +9,7 @@ import ( | ||
9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils/converter" | 9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils/converter" |
10 | ) | 10 | ) |
11 | 11 | ||
12 | -// ImportProductRecord 导入生产记录 | 12 | +// ImportProductRecord 导入二级品生产记录 |
13 | func (srv ExcelDataService) ImportProductRecord(importDataCommand *command.ImportDataCommand) (interface{}, error) { | 13 | func (srv ExcelDataService) ImportProductRecord(importDataCommand *command.ImportDataCommand) (interface{}, error) { |
14 | excelImport := excel.NewExcelImport() | 14 | excelImport := excel.NewExcelImport() |
15 | excelImport.RowBegin = 3 //第二行开始读取 | 15 | excelImport.RowBegin = 3 //第二行开始读取 |
@@ -64,6 +64,8 @@ func (controller *ExcelDataController) FileImport() { | @@ -64,6 +64,8 @@ func (controller *ExcelDataController) FileImport() { | ||
64 | data, err = excelService.ImportProductRecord(cmd) | 64 | data, err = excelService.ImportProductRecord(cmd) |
65 | case "ImportAttendance": | 65 | case "ImportAttendance": |
66 | data, err = excelService.ImportDataAttendance(cmd) | 66 | data, err = excelService.ImportDataAttendance(cmd) |
67 | + case "ImportProductCapacities": | ||
68 | + data, err = excelService.ImportDataAttendance(cmd) | ||
67 | default: | 69 | default: |
68 | err = application.ThrowError(application.BUSINESS_ERROR, fmt.Sprintf("导入不存在 Code:%v", cmd.Code)) | 70 | err = application.ThrowError(application.BUSINESS_ERROR, fmt.Sprintf("导入不存在 Code:%v", cmd.Code)) |
69 | } | 71 | } |
@@ -132,7 +132,7 @@ func (controller *ProductRecordController) SearchWorkshopProductRecord() { | @@ -132,7 +132,7 @@ func (controller *ProductRecordController) SearchWorkshopProductRecord() { | ||
132 | // 产能管理 添加产能 | 132 | // 产能管理 添加产能 |
133 | func (controller *ProductRecordController) CreateProductCapacities() { | 133 | func (controller *ProductRecordController) CreateProductCapacities() { |
134 | productRecordService := service.NewProductRecordService(nil) | 134 | productRecordService := service.NewProductRecordService(nil) |
135 | - saveCommand := &command.SaveProductRecordCmd{} | 135 | + saveCommand := &command.SaveProductCapacitiesCmd{} |
136 | controller.Unmarshal(saveCommand) | 136 | controller.Unmarshal(saveCommand) |
137 | operateInfo := ParseOperateInfo(controller.BaseController) | 137 | operateInfo := ParseOperateInfo(controller.BaseController) |
138 | data, err := productRecordService.SaveProductCapacities(operateInfo, saveCommand) | 138 | data, err := productRecordService.SaveProductCapacities(operateInfo, saveCommand) |
@@ -142,7 +142,7 @@ func (controller *ProductRecordController) CreateProductCapacities() { | @@ -142,7 +142,7 @@ func (controller *ProductRecordController) CreateProductCapacities() { | ||
142 | // 产能管理 编辑产能 | 142 | // 产能管理 编辑产能 |
143 | func (controller *ProductRecordController) UpdateProductCapacities() { | 143 | func (controller *ProductRecordController) UpdateProductCapacities() { |
144 | productRecordService := service.NewProductRecordService(nil) | 144 | productRecordService := service.NewProductRecordService(nil) |
145 | - saveCommand := &command.SaveProductRecordCmd{} | 145 | + saveCommand := &command.SaveProductCapacitiesCmd{} |
146 | controller.Unmarshal(saveCommand) | 146 | controller.Unmarshal(saveCommand) |
147 | productRecordId, _ := controller.GetInt(":productRecordId") | 147 | productRecordId, _ := controller.GetInt(":productRecordId") |
148 | saveCommand.ProductRecordId = productRecordId | 148 | saveCommand.ProductRecordId = productRecordId |
-
请 注册 或 登录 后发表评论