作者 庄敏学

导入增加图片字段

@@ -259,7 +259,9 @@ func (srv ExcelDataService) ImportCost(importDataCommand *command.ImportDataComm @@ -259,7 +259,9 @@ func (srv ExcelDataService) ImportCost(importDataCommand *command.ImportDataComm
259 {EnName: "itemName", CnName: "*细项名称"}, 259 {EnName: "itemName", CnName: "*细项名称"},
260 {EnName: "choiceId", CnName: "*节点类型"}, 260 {EnName: "choiceId", CnName: "*节点类型"},
261 {EnName: "text", CnName: "文本(数值)内容"}, 261 {EnName: "text", CnName: "文本(数值)内容"},
262 - {EnName: "image", CnName: "图片"}, 262 + {EnName: "image1", CnName: "图片1"},
  263 + {EnName: "image2", CnName: "图片2"},
  264 + {EnName: "image3", CnName: "图片3"},
263 {EnName: "formula", CnName: "计算公式"}, 265 {EnName: "formula", CnName: "计算公式"},
264 {EnName: "chargePersons", CnName: "*负责人"}, 266 {EnName: "chargePersons", CnName: "*负责人"},
265 {EnName: "target", CnName: "目标值"}, 267 {EnName: "target", CnName: "目标值"},
@@ -308,16 +310,42 @@ func (srv ExcelDataService) ImportCost(importDataCommand *command.ImportDataComm @@ -308,16 +310,42 @@ func (srv ExcelDataService) ImportCost(importDataCommand *command.ImportDataComm
308 }, 310 },
309 } 311 }
310 for key, v := range excelData { 312 for key, v := range excelData {
311 - _, mBytes, err := f.GetPicture(f.GetSheetName(index), "E"+fmt.Sprintf("%v", excelImport.RowBegin+key+1)) 313 + //图片1
  314 + _, mBytes1, err := f.GetPicture(f.GetSheetName(index), "E"+fmt.Sprintf("%v", excelImport.RowBegin+key+1))
312 if err != nil { 315 if err != nil {
313 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "读取图片失败") 316 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "读取图片失败")
314 } 317 }
315 - var ossFile string  
316 - if mBytes != nil {  
317 - ossFile, err = oss.UploadOss(mBytes) 318 + var ossFile []string
  319 + if mBytes1 != nil {
  320 + ossFile1, err := oss.UploadOss(mBytes1)
318 if err != nil { 321 if err != nil {
319 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "上传图片失败") 322 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "上传图片失败")
320 } 323 }
  324 + ossFile = append(ossFile,ossFile1)
  325 + }
  326 + //图片2
  327 + _,mBytes2,err := f.GetPicture(f.GetSheetName(index), "F"+fmt.Sprintf("%v", excelImport.RowBegin+key+1))
  328 + if err != nil {
  329 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "读取图片失败")
  330 + }
  331 + if mBytes2 != nil {
  332 + ossFile2, err := oss.UploadOss(mBytes2)
  333 + if err != nil {
  334 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "上传图片失败")
  335 + }
  336 + ossFile = append(ossFile,ossFile2)
  337 + }
  338 + //图片3
  339 + _,mBytes3,err := f.GetPicture(f.GetSheetName(index), "G"+fmt.Sprintf("%v", excelImport.RowBegin+key+1))
  340 + if err != nil {
  341 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "读取图片失败")
  342 + }
  343 + if mBytes3 != nil {
  344 + ossFile3, err := oss.UploadOss(mBytes3)
  345 + if err != nil {
  346 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "上传图片失败")
  347 + }
  348 + ossFile = append(ossFile,ossFile3)
321 } 349 }
322 //choiceId, err := strconv.Atoi(v["choiceId"]) 350 //choiceId, err := strconv.Atoi(v["choiceId"])
323 choiceId := domain.NodeType{}.GetIdByName(strings.TrimSpace(v["choiceId"])) 351 choiceId := domain.NodeType{}.GetIdByName(strings.TrimSpace(v["choiceId"]))
@@ -354,8 +382,8 @@ func (srv ExcelDataService) ImportCost(importDataCommand *command.ImportDataComm @@ -354,8 +382,8 @@ func (srv ExcelDataService) ImportCost(importDataCommand *command.ImportDataComm
354 YesterdayActual: strings.TrimSpace(v["yesterdayActual"]), 382 YesterdayActual: strings.TrimSpace(v["yesterdayActual"]),
355 Types: importCostCommand.Types, 383 Types: importCostCommand.Types,
356 } 384 }
357 - if ossFile != "" {  
358 - item.Urls = []string{ossFile} 385 + if len(ossFile) >0 {
  386 + item.Urls = ossFile
359 } else { 387 } else {
360 item.Urls = []string{} 388 item.Urls = []string{}
361 } 389 }
@@ -417,7 +445,7 @@ func (srv ExcelDataService) FileImportTemplate(importDataCommand *command.Import @@ -417,7 +445,7 @@ func (srv ExcelDataService) FileImportTemplate(importDataCommand *command.Import
417 domain.ImportDividendsReturnOrders: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210927/object/1632743214_rNHm6ZBXZaC5xKTrsE7M4h45MY6n6Ff3.xlsx", 445 domain.ImportDividendsReturnOrders: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210927/object/1632743214_rNHm6ZBXZaC5xKTrsE7M4h45MY6n6Ff3.xlsx",
418 domain.ImportProducts: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20220120/object/1642670543_cbraNKjNPHcbN6RNBYQBrwhC7BXGbDWp.xlsx", 446 domain.ImportProducts: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20220120/object/1642670543_cbraNKjNPHcbN6RNBYQBrwhC7BXGbDWp.xlsx",
419 domain.ImportDevices: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20220126/object/1643184320_hT6sY5BKHmBa4TynfSGSCGyZ2KTTtzkj.xlsx", 447 domain.ImportDevices: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20220126/object/1643184320_hT6sY5BKHmBa4TynfSGSCGyZ2KTTtzkj.xlsx",
420 - domain.ImportCosts: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20220316/object/1647432062_ewSe5CzD3TKmxQTGtExpxDWZtm3JTs4p.xlsx", 448 + domain.ImportCosts: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20220318/object/1647587204_B5azRmr2TB73jRKWsnFyDe4yxXJWnrDT.xlsx",
421 } 449 }
422 var url string 450 var url string
423 var ok bool 451 var ok bool