正在显示
1 个修改的文件
包含
28 行增加
和
22 行删除
1 | package web_client | 1 | package web_client |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | - "errors" | ||
5 | - "path/filepath" | ||
6 | "strings" | 4 | "strings" |
7 | 5 | ||
8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" | 6 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" |
@@ -105,18 +103,23 @@ func (controller ExcelDataController) ImportDividendsOrder() { | @@ -105,18 +103,23 @@ func (controller ExcelDataController) ImportDividendsOrder() { | ||
105 | } | 103 | } |
106 | 104 | ||
107 | func importDividendsOrder(controller ExcelDataController) { | 105 | func importDividendsOrder(controller ExcelDataController) { |
108 | - excelFile, fileHeader, err := controller.GetFile("file") | 106 | + // excelFile, fileHeader, err := controller.GetFile("file") |
107 | + // if err != nil { | ||
108 | + // log.Logger.Error("接收文件失败," + err.Error()) | ||
109 | + // controller.Response(nil, err) | ||
110 | + // return | ||
111 | + // } | ||
112 | + // if filepath.Ext(fileHeader.Filename) != ".xlsx" { | ||
113 | + //TODO 判断文件类型 | ||
114 | + // log.Logger.Error("获取到的文件:" + fileHeader.Filename) | ||
115 | + // controller.Response(nil, errors.New("上传到的文件类型错误")) | ||
116 | + // return | ||
117 | + // } | ||
118 | + fileReader, err := controller.GetExcelFile() | ||
109 | if err != nil { | 119 | if err != nil { |
110 | - log.Logger.Error("接收文件失败," + err.Error()) | ||
111 | controller.Response(nil, err) | 120 | controller.Response(nil, err) |
112 | return | 121 | return |
113 | } | 122 | } |
114 | - if filepath.Ext(fileHeader.Filename) != ".xlsx" { | ||
115 | - //TODO 判断文件类型 | ||
116 | - log.Logger.Error("获取到的文件:" + fileHeader.Filename) | ||
117 | - controller.Response(nil, errors.New("上传到的文件类型错误")) | ||
118 | - return | ||
119 | - } | ||
120 | excelImport := excel.NewExcelImport() | 123 | excelImport := excel.NewExcelImport() |
121 | excelImport.RowBegin = 2 //第2行开始读取 | 124 | excelImport.RowBegin = 2 //第2行开始读取 |
122 | excelImport.DataFields = []excel.DataField{ | 125 | excelImport.DataFields = []excel.DataField{ |
@@ -130,7 +133,7 @@ func importDividendsOrder(controller ExcelDataController) { | @@ -130,7 +133,7 @@ func importDividendsOrder(controller ExcelDataController) { | ||
130 | {EnName: "Expense", CnName: "费用"}, | 133 | {EnName: "Expense", CnName: "费用"}, |
131 | {EnName: "CooperationContractNumber", CnName: "项目合约编号"}, | 134 | {EnName: "CooperationContractNumber", CnName: "项目合约编号"}, |
132 | } | 135 | } |
133 | - excelData, err := excelImport.OpenExcelFromIoReader(excelFile) | 136 | + excelData, err := excelImport.OpenExcelFromIoReader(fileReader) |
134 | if err != nil { | 137 | if err != nil { |
135 | log.Logger.Error("解析excel文件失败," + err.Error()) | 138 | log.Logger.Error("解析excel文件失败," + err.Error()) |
136 | controller.Response(nil, err) | 139 | controller.Response(nil, err) |
@@ -174,18 +177,23 @@ func (controller ExcelDataController) ImportDividendsReturnedOrder() { | @@ -174,18 +177,23 @@ func (controller ExcelDataController) ImportDividendsReturnedOrder() { | ||
174 | } | 177 | } |
175 | 178 | ||
176 | func importDividendsReturnedOrder(controller ExcelDataController) { | 179 | func importDividendsReturnedOrder(controller ExcelDataController) { |
177 | - excelFile, fileHeader, err := controller.GetFile("file") | 180 | + // excelFile, fileHeader, err := controller.GetFile("file") |
181 | + // if err != nil { | ||
182 | + // log.Logger.Error("接收文件失败," + err.Error()) | ||
183 | + // controller.Response(nil, err) | ||
184 | + // return | ||
185 | + // } | ||
186 | + // if filepath.Ext(fileHeader.Filename) != ".xlsx" { | ||
187 | + //TODO 判断文件类型 | ||
188 | + // log.Logger.Error("获取到的文件:" + filepath.Ext(fileHeader.Filename)) | ||
189 | + // controller.Response(nil, errors.New("上传的文件类型错误")) | ||
190 | + // return | ||
191 | + // } | ||
192 | + fileReader, err := controller.GetExcelFile() | ||
178 | if err != nil { | 193 | if err != nil { |
179 | - log.Logger.Error("接收文件失败," + err.Error()) | ||
180 | controller.Response(nil, err) | 194 | controller.Response(nil, err) |
181 | return | 195 | return |
182 | } | 196 | } |
183 | - if filepath.Ext(fileHeader.Filename) != ".xlsx" { | ||
184 | - //TODO 判断文件类型 | ||
185 | - log.Logger.Error("获取到的文件:" + filepath.Ext(fileHeader.Filename)) | ||
186 | - controller.Response(nil, errors.New("上传的文件类型错误")) | ||
187 | - return | ||
188 | - } | ||
189 | excelImport := excel.NewExcelImport() | 197 | excelImport := excel.NewExcelImport() |
190 | excelImport.RowBegin = 2 //第2行表头开始读取 | 198 | excelImport.RowBegin = 2 //第2行表头开始读取 |
191 | excelImport.DataFields = []excel.DataField{ | 199 | excelImport.DataFields = []excel.DataField{ |
@@ -199,7 +207,7 @@ func importDividendsReturnedOrder(controller ExcelDataController) { | @@ -199,7 +207,7 @@ func importDividendsReturnedOrder(controller ExcelDataController) { | ||
199 | {EnName: "OrderGoodPrice", CnName: "*退货价格"}, | 207 | {EnName: "OrderGoodPrice", CnName: "*退货价格"}, |
200 | {EnName: "CooperationContractNumber", CnName: "项目合约编号"}, | 208 | {EnName: "CooperationContractNumber", CnName: "项目合约编号"}, |
201 | } | 209 | } |
202 | - excelData, err := excelImport.OpenExcelFromIoReader(excelFile) | 210 | + excelData, err := excelImport.OpenExcelFromIoReader(fileReader) |
203 | if err != nil { | 211 | if err != nil { |
204 | log.Logger.Error("解析excel文件失败," + err.Error()) | 212 | log.Logger.Error("解析excel文件失败," + err.Error()) |
205 | controller.Response(nil, err) | 213 | controller.Response(nil, err) |
@@ -296,12 +304,10 @@ func (controller ExcelDataController) FileImport() { | @@ -296,12 +304,10 @@ func (controller ExcelDataController) FileImport() { | ||
296 | case domain.ImportCompanyUser: | 304 | case domain.ImportCompanyUser: |
297 | data, err = excelService.ImportCompanyUser(cmd) | 305 | data, err = excelService.ImportCompanyUser(cmd) |
298 | case domain.ImportCooperationUser: | 306 | case domain.ImportCooperationUser: |
299 | - // data,err = excelService.ExportCooperationUser() | ||
300 | case domain.ImportDividendsOrders: | 307 | case domain.ImportDividendsOrders: |
301 | importDividendsOrder(controller) | 308 | importDividendsOrder(controller) |
302 | case domain.ImportOrganization: | 309 | case domain.ImportOrganization: |
303 | importDividendsReturnedOrder(controller) | 310 | importDividendsReturnedOrder(controller) |
304 | - | ||
305 | } | 311 | } |
306 | controller.Response(data, err) | 312 | controller.Response(data, err) |
307 | } | 313 | } |
-
请 注册 或 登录 后发表评论