作者 庄敏学

合并分支 'dev' 到 'test'

导入增加图片字段



查看合并请求 !24
... ... @@ -259,7 +259,9 @@ func (srv ExcelDataService) ImportCost(importDataCommand *command.ImportDataComm
{EnName: "itemName", CnName: "*细项名称"},
{EnName: "choiceId", CnName: "*节点类型"},
{EnName: "text", CnName: "文本(数值)内容"},
{EnName: "image", CnName: "图片"},
{EnName: "image1", CnName: "图片1"},
{EnName: "image2", CnName: "图片2"},
{EnName: "image3", CnName: "图片3"},
{EnName: "formula", CnName: "计算公式"},
{EnName: "chargePersons", CnName: "*负责人"},
{EnName: "target", CnName: "目标值"},
... ... @@ -308,16 +310,42 @@ func (srv ExcelDataService) ImportCost(importDataCommand *command.ImportDataComm
},
}
for key, v := range excelData {
_, mBytes, err := f.GetPicture(f.GetSheetName(index), "E"+fmt.Sprintf("%v", excelImport.RowBegin+key+1))
//图片1
_, mBytes1, err := f.GetPicture(f.GetSheetName(index), "E"+fmt.Sprintf("%v", excelImport.RowBegin+key+1))
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "读取图片失败")
}
var ossFile string
if mBytes != nil {
ossFile, err = oss.UploadOss(mBytes)
var ossFile []string
if mBytes1 != nil {
ossFile1, err := oss.UploadOss(mBytes1)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "上传图片失败")
}
ossFile = append(ossFile,ossFile1)
}
//图片2
_,mBytes2,err := f.GetPicture(f.GetSheetName(index), "F"+fmt.Sprintf("%v", excelImport.RowBegin+key+1))
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "读取图片失败")
}
if mBytes2 != nil {
ossFile2, err := oss.UploadOss(mBytes2)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "上传图片失败")
}
ossFile = append(ossFile,ossFile2)
}
//图片3
_,mBytes3,err := f.GetPicture(f.GetSheetName(index), "G"+fmt.Sprintf("%v", excelImport.RowBegin+key+1))
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "读取图片失败")
}
if mBytes3 != nil {
ossFile3, err := oss.UploadOss(mBytes3)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "上传图片失败")
}
ossFile = append(ossFile,ossFile3)
}
//choiceId, err := strconv.Atoi(v["choiceId"])
choiceId := domain.NodeType{}.GetIdByName(strings.TrimSpace(v["choiceId"]))
... ... @@ -354,8 +382,8 @@ func (srv ExcelDataService) ImportCost(importDataCommand *command.ImportDataComm
YesterdayActual: strings.TrimSpace(v["yesterdayActual"]),
Types: importCostCommand.Types,
}
if ossFile != "" {
item.Urls = []string{ossFile}
if len(ossFile) >0 {
item.Urls = ossFile
} else {
item.Urls = []string{}
}
... ... @@ -417,7 +445,7 @@ func (srv ExcelDataService) FileImportTemplate(importDataCommand *command.Import
domain.ImportDividendsReturnOrders: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210927/object/1632743214_rNHm6ZBXZaC5xKTrsE7M4h45MY6n6Ff3.xlsx",
domain.ImportProducts: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20220120/object/1642670543_cbraNKjNPHcbN6RNBYQBrwhC7BXGbDWp.xlsx",
domain.ImportDevices: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20220126/object/1643184320_hT6sY5BKHmBa4TynfSGSCGyZ2KTTtzkj.xlsx",
domain.ImportCosts: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20220316/object/1647432062_ewSe5CzD3TKmxQTGtExpxDWZtm3JTs4p.xlsx",
domain.ImportCosts: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20220318/object/1647587204_B5azRmr2TB73jRKWsnFyDe4yxXJWnrDT.xlsx",
}
var url string
var ok bool
... ...