Browse Source

Merge branch 'hotfix/yongyi_week' of eta_server/eta_data_analysis into master

xyxie 3 tháng trước cách đây
mục cha
commit
cc8377557a

+ 9 - 9
services/base_from_yongyi_v2/daily.go

@@ -52,7 +52,7 @@ func HandleYongyiExcelDaily1(f *excelize.File, sheetName string) (indexList []*m
 					if text != "" {
 						// 日期
 						var dateT time.Time
-						dateT, e = time.ParseInLocation("01-2-06", text, time.Local)
+						dateT, e = utils.ParseExcelDateToTime(text)
 						if e != nil {
 							//utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 读取行,时间列失败 Err:%s", sheetName, i, k, e))
 							continue
@@ -198,7 +198,7 @@ func HandleYongyiExcelDaily2(f *excelize.File, sheetName string) (indexList []*m
 					// 日期
 					text = strings.TrimSpace(text)
 					var dateT time.Time
-					dateT, e = time.ParseInLocation("01-2-06", text, time.Local)
+					dateT, e = utils.ParseExcelDateToTime(text)
 					if e != nil {
 						utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 读取行,时间列失败 Err:%s", sheetName, i, k, e))
 						continue
@@ -358,7 +358,7 @@ func HandleYongyiExcelDaily3(f *excelize.File, sheetName string) (indexList []*m
 						break
 					}
 					var dateT time.Time
-					dateT, e = time.ParseInLocation("01-2-06", text, time.Local)
+					dateT, e = utils.ParseExcelDateToTime(text)
 					if e != nil {
 						utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 读取行,时间列失败 Err:%s", sheetName, i, k, e))
 						continue
@@ -478,13 +478,13 @@ func HandleYongyiExcelDaily4(f *excelize.File, sheetName string) (indexList []*m
 							continue
 						}
 					} else {
-						dateT, e = time.ParseInLocation("01-2-06", text, time.Local)
+						dateT, e = utils.ParseExcelDateToTime(text)
 						if e != nil {
-							dateT, e = time.ParseInLocation("2006/1/2", text, time.Local)
-							if e != nil {
-								utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 读取行,时间列失败 Err:%s", sheetName, i, k, e))
-								continue
-							}
+							/*dateT, e = time.ParseInLocation("2006/1/2", text, time.Local)
+							if e != nil {*/
+							utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 读取行,时间列失败 Err:%s", sheetName, i, k, e))
+							continue
+							//}
 						}
 					}
 					dateMap[k] = dateT.Format(utils.FormatDate)

+ 2 - 2
services/base_from_yongyi_v2/week20.go

@@ -561,7 +561,7 @@ func HandleYongyiExcelWeekly15(f *excelize.File, sheetName string) (indexList []
 				if text != "" {
 					text = strings.TrimSpace(text)
 					var dateT time.Time
-					dateT, e = time.ParseInLocation("01-2-06", text, time.Local)
+					dateT, e = utils.ParseExcelDateToTime(text)
 					if e != nil {
 						utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 读取行,时间列失败 Err:%s", sheetName, i, k, e))
 						continue
@@ -938,7 +938,7 @@ func HandleYongyiExcelWeekly18(f *excelize.File, sheetName string) (indexList []
 					// 日期
 					text = strings.TrimSpace(text)
 					var dateT time.Time
-					dateT, e = time.ParseInLocation("01-2-06", text, time.Local)
+					dateT, e = utils.ParseExcelDateToTime(text)
 					if e != nil {
 						utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 读取行,时间列失败 Err:%s", sheetName, i, k, e))
 						continue

+ 11 - 0
utils/common.go

@@ -1330,3 +1330,14 @@ func RangeRand(min, max int64) int64 {
 		return min + result.Int64()
 	}
 }
+
+func ParseExcelDateToTime(text string) (dateT time.Time, e error) {
+	dateT, e = time.ParseInLocation("01-2-06", text, time.Local)
+	if e != nil {
+		dateT, e = time.ParseInLocation("2006/1/2", text, time.Local)
+		if e != nil {
+			return
+		}
+	}
+	return
+}