Quellcode durchsuchen

fix(修复excel包的使用bug)

Roc vor 3 Jahren
Ursprung
Commit
dd05efa2a9
4 geänderte Dateien mit 42 neuen und 24 gelöschten Zeilen
  1. 1 0
      .gitignore
  2. 15 12
      services/company.go
  3. 13 12
      services/data_source_longzhong.go
  4. 13 0
      utils/config.go

+ 1 - 0
.gitignore

@@ -7,3 +7,4 @@
 /go.sum
 /go.mod
 /hongze_task
+hongze_task

+ 15 - 12
services/company.go

@@ -47,16 +47,17 @@ func ImportCompany() {
 		rows := sheet.MaxRow
 		for i := 0; i < rows; i++ {
 			if i > 2 {
-				row, _ := sheet.Row(i)
-				realName := row.GetCell(1).String()
+				row := sheet.Row(i)
+				cells := row.Cells
+				realName := cells[1].String()
 				realName = strings.Trim(realName, " ")
 				realName = strings.Replace(realName, " ", "", -1)
 
-				mobile := row.GetCell(2).String()
+				mobile := cells[2].String()
 				mobile = strings.Trim(mobile, " ")
 				mobile = strings.Replace(mobile, " ", "", -1)
 				fmt.Println(mobile)
-				companyName := row.GetCell(6).String()
+				companyName := cells[6].String()
 				fmt.Println(companyName)
 				companyName = strings.Trim(companyName, " ")
 				companyName = strings.Replace(companyName, " ", "", -1)
@@ -160,16 +161,17 @@ func ImportCompanyUsers() {
 		rows := sheet.MaxRow
 		for i := 0; i < rows; i++ {
 			if i > 2 {
-				row, _ := sheet.Row(i)
-				realName := row.GetCell(1).String()
+				row := sheet.Row(i)
+				cells := row.Cells
+				realName := cells[1].String()
 				realName = strings.Trim(realName, " ")
 				realName = strings.Replace(realName, " ", "", -1)
 
-				mobile := row.GetCell(2).String()
+				mobile := cells[2].String()
 				mobile = strings.Trim(mobile, " ")
 				mobile = strings.Replace(mobile, " ", "", -1)
 
-				email := row.GetCell(5).String()
+				email := cells[5].String()
 				email = strings.Trim(email, " ")
 				email = strings.Replace(email, " ", "", -1)
 				fmt.Println(mobile)
@@ -220,16 +222,17 @@ func ImportCompanyCreditCode() {
 		rows := sheet.MaxRow
 		for i := 0; i < rows; i++ {
 			if i > 2 {
-				row, _ := sheet.Row(i)
-				companyName := row.GetCell(0).String()
+				row := sheet.Row(i)
+				cells := row.Cells
+				companyName := cells[0].String()
 				companyName = strings.Trim(companyName, " ")
 				companyName = strings.Replace(companyName, " ", "", -1)
 
-				creditCode := row.GetCell(4).String()
+				creditCode := cells[4].String()
 				creditCode = strings.Trim(creditCode, " ")
 				creditCode = strings.Replace(creditCode, " ", "", -1)
 
-				industryName := row.GetCell(5).String()
+				industryName := cells[5].String()
 				industryName = strings.Trim(industryName, " ")
 				industryName = strings.Replace(industryName, " ", "", -1)
 

+ 13 - 12
services/data_source_longzhong.go

@@ -56,17 +56,18 @@ func GetLongZhongTargetInfoByExcel() {
 		//maxCol := v.MaxCol
 		fmt.Println(classifyName, maxRow)
 		for i := 0; i < maxRow; i++ {
-			row, _ := v.Row(i)
+			row := v.Row(i)
 			longzhongClassify := ""
 			if i > 0 {
-				longzhongClassifyNew := row.GetCell(0).String()
+				cells := row.Cells
+				longzhongClassifyNew := cells[0].String()
 				if longzhongClassifyNew != "" {
 					longzhongClassify = longzhongClassifyNew
 				}
-				secName := row.GetCell(1).Value
-				frequency := row.GetCell(2).Value
-				LongzhongId := row.GetCell(3).Value
-				remark := row.GetCell(4).String()
+				secName := cells[1].Value
+				frequency := cells[2].Value
+				LongzhongId := cells[3].Value
+				remark := cells[4].String()
 				item := new(models.DataSourceLongzhong)
 				item.ClassifyId = classifyId
 				item.ClassifyName = classifyName
@@ -581,7 +582,7 @@ func LzExportExcel() {
 			if len(dataList) <= 0 {
 				for n := 0; n < dataMax; n++ {
 					rowIndex := 5 + n
-					row, _ := sheetNew.Row(rowIndex)
+					row:= sheetNew.Row(rowIndex)
 					row.AddCell()
 					row.AddCell()
 					row.AddCell()
@@ -590,7 +591,7 @@ func LzExportExcel() {
 				endRowIndex := 0
 				for rk, dv := range dataList {
 					rowIndex := 5 + rk
-					row, _ := sheetNew.Row(rowIndex)
+					row := sheetNew.Row(rowIndex)
 					row.AddCell().SetValue(dv.Dt)
 					row.AddCell().SetFloat(dv.Close)
 					row.AddCell()
@@ -600,7 +601,7 @@ func LzExportExcel() {
 					dataLen := dataMax - len(dataList)
 					for n := 0; n < dataLen; n++ {
 						rowIndex := (endRowIndex + 1) + n
-						row, _ := sheetNew.Row(rowIndex)
+						row:= sheetNew.Row(rowIndex)
 						row.AddCell()
 						row.AddCell()
 						row.AddCell()
@@ -890,7 +891,7 @@ func LzPriceExportExcel() {
 			if len(dataList) <= 0 {
 				for n := 0; n < dataMax; n++ {
 					rowIndex := 8 + n
-					row,_:= sheetNew.Row(rowIndex)
+					row:= sheetNew.Row(rowIndex)
 					row.AddCell()
 					row.AddCell()
 					row.AddCell()
@@ -901,7 +902,7 @@ func LzPriceExportExcel() {
 				endRowIndex := 0
 				for rk, dv := range dataList {
 					rowIndex := 8 + rk
-					row,_:= sheetNew.Row(rowIndex)
+					row:= sheetNew.Row(rowIndex)
 					row.AddCell().SetValue(dv.PriceDate)
 					row.AddCell().SetFloat(dv.Price)
 					row.AddCell().SetFloat(dv.LowPrice)
@@ -914,7 +915,7 @@ func LzPriceExportExcel() {
 					dataLen := dataMax - len(dataList)
 					for n := 0; n < dataLen; n++ {
 						rowIndex := (endRowIndex + 1) + n
-						row,_:= sheetNew.Row(rowIndex)
+						row:= sheetNew.Row(rowIndex)
 						row.AddCell()
 						row.AddCell()
 						row.AddCell()

+ 13 - 0
utils/config.go

@@ -24,6 +24,19 @@ var (
 	RemindTemplateId string
 )
 
+
+//oss配置
+var (
+	Bucketname       string = "hongze"
+	Endpoint         string
+	Imghost          string = "https://hongze.oss-accelerate.aliyuncs.com/"
+	Upload_dir       string = "static/images/"
+	Upload_Audio_Dir string = "static/audio/"
+
+	AccessKeyId     string = "LTAIFMZYQhS2BTvW"
+	AccessKeySecret string = "12kk1ptCHoGWedhBnKRVW5hRJzq9Fq"
+)
+
 func init() {
 	RunMode = beego.AppConfig.String("run_mode")
 	config, err := beego.AppConfig.GetSection(RunMode)