Browse Source

内陆日期格式兼容

ziwen 2 years ago
parent
commit
4ef9843690
1 changed files with 5 additions and 13 deletions
  1. 5 13
      services/commodity_coal_inland.go

+ 5 - 13
services/commodity_coal_inland.go

@@ -103,7 +103,7 @@ func FileCoalInland() () {
 		}
 	}
 
-	for s, sheet := range xlFile.Sheets {
+	for _, sheet := range xlFile.Sheets {
 		sheetName = sheet.Name
 		fmt.Println("sheetName:",sheetName)
 		var unit string
@@ -169,19 +169,11 @@ func FileCoalInland() () {
 					if k < 18 {
 						var item models.BaseFromCoalmineInlandIndex
 						if k == 0 {
-							if s == 0 {
-								text := cell.String()
-								//fmt.Println(text)
-								t, _ := time.ParseInLocation("01-02-06", text, time.Local)
-								dataTime = t.Format(utils.FormatDate)
-								//fmt.Println(dataTime)
-							} else {
-								text := cell.String()
-								//fmt.Println(text)
-								//t, _ := time.ParseInLocation("01-02-06", text, time.Local)
-								//dataTime = t.Format(utils.FormatDate)
+							text := cell.String()
+							t, _ := time.ParseInLocation("01-02-06", text, time.Local)
+							dataTime = t.Format(utils.FormatDate)
+							if len(text) < 6{
 								dataTime = ExcelDateToDate(text).Format(utils.FormatDate)
-								//fmt.Println(dataTime)
 							}
 						}
 						if k > 0 {