xyxie hace 1 año
padre
commit
35746e9d4c

+ 2 - 2
services/base_from_yongyi_v2/base.go

@@ -113,13 +113,13 @@ func init() {
 		"育肥栏舍利用率":              {"育肥栏舍利用率", "育肥栏舍利用率", "旬度", "%"},
 		"周度-养殖利润最新":            {"出栏肥猪利润", "周度-养殖利润最新", "周度", "元/头"},
 		"周度-当期、预期成本":           {"", "周度-当期、预期成本", "周度", "元/kg"},
-		"育肥全价料出厂价":             {"育肥全价料出厂均价参考", "育肥全价料出厂价", "周度", "元/吨"},
+		"育肥全价料出厂价":             {"育肥全价料出厂均价参考", "周度-育肥全价料出厂价", "周度", "元/吨"},
 		"周度-成本计算附件":            {"", "周度-成本计算附件", "周度", "元/头"}, //多个单位:元/头,%,kg,元
 		"周度-毛白价差":              {"毛白价差", "周度-毛白价差", "周度", "元/公斤"},
 		"仔猪、母猪":                {"", "仔猪、母猪", "周度", "元/头"},                //多个前缀,仔猪价,二元母猪价
 		"周度-河南屠宰白条成本":          {"河南屠宰白条成本", "周度-河南屠宰白条成本", "周度", "元/kg"}, //多个单位:kg,元/kg,元/头
 		"周度-淘汰母猪价格":            {"淘汰母猪价格", "周度-淘汰母猪价格", "周度", "元/斤"},
-		"鲜销率":                  {"鲜销率", "鲜销率", "周度", "%"},
+		"鲜销率":                  {"鲜销率", "周度-鲜销率", "周度", "%"},
 		"周度-猪肉产品价格":            {"猪肉产品价格", "周度-猪肉产品价格", "周度", "元/公斤"},
 		"周度-屠宰企业日度屠宰量":         {"屠宰企业日度屠宰量", "周度-屠宰企业日度屠宰量", "周度", "头"},
 		"周度-屠宰新2022.10.28":     {"不同规模屠宰厂宰杀量", "周度-屠宰新2022.10.28", "周度", "头"},

+ 19 - 6
services/base_from_yongyi_v2/daily.go

@@ -68,7 +68,7 @@ func HandleYongyiExcelDaily1(f *excelize.File, sheetName string) (indexList []*m
 					var dateT time.Time
 					dateT, e = time.ParseInLocation("01-2-06", text, time.Local)
 					if e != nil {
-						utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 读取行,时间列失败 Err:%s", sheetName, i, k, e))
+						//utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 读取行,时间列失败 Err:%s", sheetName, i, k, e))
 						continue
 					}
 					dateMap[k] = dateT.Format(utils.FormatDate)
@@ -253,7 +253,7 @@ func HandleYongyiExcelDaily2(f *excelize.File, sheetName string) (indexList []*m
 					}
 					_, e := strconv.ParseFloat(text, 64)
 					if e != nil {
-						utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 strconv.ParseFloat Err:%s", sheetName, i, k, e))
+						//utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 strconv.ParseFloat Err:%s", sheetName, i, k, e))
 						continue
 					}
 				}
@@ -470,11 +470,24 @@ func HandleYongyiExcelDaily4(f *excelize.File, sheetName string) (indexList []*m
 				if text != "" {
 					// 日期
 					text = strings.TrimSpace(text)
+					dateSlice := strings.Split(text, "(")
+					if len(dateSlice) > 1 {
+						text = dateSlice[0]
+					}
 					var dateT time.Time
-					dateT, e = time.ParseInLocation("01-2-06", text, time.Local)
-					if e != nil {
-						utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 读取行,时间列失败 Err:%s", sheetName, i, k, e))
-						continue
+					//判断是否是数字,如果是数字,另外单独处理
+					if dateFloat, e := strconv.ParseFloat(text, 64); e == nil {
+						dateT, e = excelize.ExcelDateToTime(dateFloat, false)
+						if e != nil {
+							utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 读取行,时间列失败 Err:%s", sheetName, i, k, e))
+							continue
+						}
+					} else {
+						dateT, e = time.ParseInLocation("01-2-06", 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)
 				}

+ 13 - 10
services/base_from_yongyi_v2/week10.go

@@ -241,7 +241,7 @@ func HandleYongyiExcelWeekly2(f *excelize.File, sheetName string) (indexList []*
 					}
 					_, e := strconv.ParseFloat(text, 64)
 					if e != nil {
-						utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 strconv.ParseFloat Err:%s", sheetName, i, k, e))
+						//utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 strconv.ParseFloat Err:%s", sheetName, i, k, e))
 						continue
 					}
 				}
@@ -525,7 +525,7 @@ func HandleYongyiExcelWeekly4(f *excelize.File, sheetName string) (indexList []*
 					}
 					_, e := strconv.ParseFloat(text, 64)
 					if e != nil {
-						utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 strconv.ParseFloat Err:%s", sheetName, i, k, e))
+						//utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 strconv.ParseFloat Err:%s", sheetName, i, k, e))
 						continue
 					}
 				}
@@ -659,7 +659,7 @@ func HandleYongyiExcelWeekly5(f *excelize.File, sheetName string) (indexList []*
 					}
 					_, e := strconv.ParseFloat(text, 64)
 					if e != nil {
-						utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 strconv.ParseFloat Err:%s", sheetName, i, k, e))
+						//utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 strconv.ParseFloat Err:%s", sheetName, i, k, e))
 						continue
 					}
 				}
@@ -766,10 +766,13 @@ func HandleYongyiExcelWeekly6(f *excelize.File, sheetName string) (indexList []*
 				if k == 0 {
 					text = strings.TrimSpace(text)
 					var dateT time.Time
-					dateT, e = time.ParseInLocation("01/02/2006", text, time.Local)
+					dateT, e = time.ParseInLocation("01-02-06", 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
+						}
 					}
 					date = dateT.Format(utils.FormatDate)
 					fmt.Println(date)
@@ -921,7 +924,7 @@ func HandleYongyiExcelWeekly7(f *excelize.File, sheetName string) (indexList []*
 					}
 					_, e := strconv.ParseFloat(text, 64)
 					if e != nil {
-						utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 strconv.ParseFloat Err:%s", sheetName, i, k, e))
+						//utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 strconv.ParseFloat Err:%s", sheetName, i, k, e))
 						continue
 					}
 				}
@@ -1061,7 +1064,7 @@ func HandleYongyiExcelWeekly8(f *excelize.File, sheetName string) (indexList []*
 					}
 					_, e := strconv.ParseFloat(text, 64)
 					if e != nil {
-						utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 strconv.ParseFloat Err:%s", sheetName, i, k, e))
+						//utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 strconv.ParseFloat Err:%s", sheetName, i, k, e))
 						continue
 					}
 				}
@@ -1190,7 +1193,7 @@ func HandleYongyiExcelWeekly9(f *excelize.File, sheetName string) (indexList []*
 					}
 					_, e := strconv.ParseFloat(text, 64)
 					if e != nil {
-						utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 strconv.ParseFloat Err:%s", sheetName, i, k, e))
+						//utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 strconv.ParseFloat Err:%s", sheetName, i, k, e))
 						continue
 					}
 				}
@@ -1317,7 +1320,7 @@ func HandleYongyiExcelWeekly10(f *excelize.File, sheetName string) (indexList []
 					}
 					_, e := strconv.ParseFloat(text, 64)
 					if e != nil {
-						utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 strconv.ParseFloat Err:%s", sheetName, i, k, e))
+						//utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 strconv.ParseFloat Err:%s", sheetName, i, k, e))
 						continue
 					}
 				}

+ 22 - 11
services/base_from_yongyi_v2/week20.go

@@ -158,7 +158,7 @@ func HandleYongyiExcelWeekly12(f *excelize.File, sheetName string) (indexList []
 		} else if i == 1 {
 			for k, text := range row {
 				fmt.Printf("当前第%d列 \n", k)
-				if k > 1 && text != "" {
+				if text != "" {
 					text = strings.TrimSpace(text)
 					yearMap[k] = text
 				}
@@ -280,10 +280,18 @@ func HandleYongyiExcelWeekly13(f *excelize.File, sheetName string) (indexList []
 					// 日期
 					text = strings.TrimSpace(text)
 					var dateT time.Time
-					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
+					if dateFloat, e := strconv.ParseFloat(text, 64); e == nil {
+						dateT, e = excelize.ExcelDateToTime(dateFloat, false)
+						if e != nil {
+							utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 读取行,时间列失败 Err:%s", sheetName, i, k, e))
+							continue
+						}
+					} else {
+						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
+						}
 					}
 					date = dateT.Format(utils.FormatDate)
 					dateMap[i] = date
@@ -566,7 +574,7 @@ func HandleYongyiExcelWeekly15(f *excelize.File, sheetName string) (indexList []
 			province := ""
 			for k, text := range row {
 				fmt.Printf("当前第%d列 \n", k)
-				if k == 0 {
+				if k == 0 || k == 2 || k == 3 {
 					continue
 				} else if k == 1 {
 					province = strings.TrimSpace(text)
@@ -682,7 +690,7 @@ func HandleYongyiExcelWeekly16(f *excelize.File, sheetName string) (indexList []
 			date := ""
 			for k, text := range row {
 				fmt.Printf("当前第%d列 \n", k)
-				if k == 0 {
+				if k == 0 || k == 2 {
 					continue
 				} else if k == 1 {
 					text = strings.TrimSpace(text)
@@ -795,7 +803,7 @@ func HandleYongyiExcelWeekly17(f *excelize.File, sheetName string) (indexList []
 			namePrefix = "断奶仔猪对应育肥至标猪出栏成本"
 			namePrefixPingin = "yyzx" + utils.GetFirstPingYin(namePrefix)
 			continue
-		} else if i == 1 { //表示表头
+		} else if i == 1 || i == 12 { //表示表头
 			// 处理 index指标表
 			for k, text := range row {
 				if text != "" {
@@ -1039,9 +1047,12 @@ func HandleYongyiExcelWeekly19(f *excelize.File, sheetName string) (indexList []
 					text = strings.TrimSpace(text) //2024.1.12-2024.1.18
 					if mergeOk {
 						for j, v := range currentMergeCells {
+							if v == "" {
+								continue
+							}
 							dateSlice := strings.Split(v, "-")
 							if len(dateSlice) <= 1 {
-								utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 读取行,时间列失败 Err:%s", sheetName, i, k, e))
+								utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 读取行,时间列失败", sheetName, i, k))
 								continue
 							}
 
@@ -1092,7 +1103,7 @@ func HandleYongyiExcelWeekly19(f *excelize.File, sheetName string) (indexList []
 			subName := ""
 			for k, text := range row {
 				fmt.Printf("当前第%d列 \n", k)
-				if k == 0 {
+				if k == 0 || (k >= 5 && k <= 11) {
 					continue
 				} else if k == 1 || k == 2 {
 					text = strings.TrimSpace(text)
@@ -1129,7 +1140,7 @@ func HandleYongyiExcelWeekly19(f *excelize.File, sheetName string) (indexList []
 
 				area, ok2 := areaMap[k]
 				if !ok2 {
-					utils.FileLog.Info(fmt.Sprintf("找不到对应的时间,第%d行,第%d列", i, k))
+					utils.FileLog.Info(fmt.Sprintf("找不到对应的地区,第%d行,第%d列", i, k))
 					continue
 				}
 				area = strings.Replace(area, "本周", "", 1)

+ 2 - 2
services/base_from_yongyi_v2/week30.go

@@ -77,7 +77,7 @@ func HandleYongyiExcelWeekly21(f *excelize.File, sheetName string) (indexList []
 					}
 					_, e := strconv.ParseFloat(text, 64)
 					if e != nil {
-						utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 strconv.ParseFloat Err:%s", sheetName, i, k, e))
+						//	utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 strconv.ParseFloat Err:%s", sheetName, i, k, e))
 						continue
 					}
 				}
@@ -317,7 +317,7 @@ func HandleYongyiExcelWeekly23(f *excelize.File, sheetName string) (indexList []
 					}
 					_, e := strconv.ParseFloat(text, 64)
 					if e != nil {
-						utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 strconv.ParseFloat Err:%s", sheetName, i, k, e))
+						//utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 strconv.ParseFloat Err:%s", sheetName, i, k, e))
 						continue
 					}
 				}

+ 1 - 1
services/base_from_yongyi_v2/week40.go

@@ -572,7 +572,7 @@ func HandleYongyiExcelWeekly35(f *excelize.File, sheetName string) (indexList []
 					}
 					_, e := strconv.ParseFloat(text, 64)
 					if e != nil {
-						utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 strconv.ParseFloat Err:%s", sheetName, i, k, e))
+						//utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 strconv.ParseFloat Err:%s", sheetName, i, k, e))
 						continue
 					}
 				}