|
@@ -35,47 +35,32 @@ func HandleYongyiExcelDaily1(f *excelize.File, sheetName string) (indexList []*m
|
|
|
// 指标名称
|
|
|
indexMap := make(map[string]*models.YongyiExcelIndex)
|
|
|
|
|
|
- mergeCellMap, err := GetMergeCells(f, sheetName)
|
|
|
- if err != nil {
|
|
|
- err = fmt.Errorf("获取合并单元格失败, sheetName: %s", sheetName)
|
|
|
- return
|
|
|
- }
|
|
|
stopFlag := false
|
|
|
for i, row := range rows {
|
|
|
fmt.Printf("当前第%d行 \n", i)
|
|
|
if stopFlag {
|
|
|
break
|
|
|
}
|
|
|
- currentMergeCells, mergeOk := mergeCellMap[i]
|
|
|
|
|
|
// 首行,表示时间
|
|
|
if i == 0 {
|
|
|
+ dateTmp := ""
|
|
|
for k, text := range row {
|
|
|
fmt.Printf("当前第%d列 \n", k)
|
|
|
- if k > 1 && text != "" {
|
|
|
+ if k > 1 {
|
|
|
text = strings.TrimSpace(text)
|
|
|
- if mergeOk {
|
|
|
- for j, v := range currentMergeCells {
|
|
|
- // 日期
|
|
|
- v = strings.TrimSpace(v)
|
|
|
- var dateT time.Time
|
|
|
- dateT, e = time.ParseInLocation("01-2-06", v, time.Local)
|
|
|
- if e != nil {
|
|
|
- utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 读取行,时间列失败 Err:%s", sheetName, i, k, e))
|
|
|
- continue
|
|
|
- }
|
|
|
- dateMap[j] = dateT.Format(utils.FormatDate)
|
|
|
+ if text != "" {
|
|
|
+ // 日期
|
|
|
+ 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
|
|
|
}
|
|
|
+ dateTmp = dateT.Format(utils.FormatDate)
|
|
|
}
|
|
|
- // 日期
|
|
|
- text = strings.TrimSpace(text)
|
|
|
- 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
|
|
|
- }
|
|
|
- dateMap[k] = dateT.Format(utils.FormatDate)
|
|
|
+
|
|
|
+ dateMap[k] = dateTmp
|
|
|
}
|
|
|
}
|
|
|
} else if i == 1 { //表示表头
|
|
@@ -197,38 +182,19 @@ func HandleYongyiExcelDaily2(f *excelize.File, sheetName string) (indexList []*m
|
|
|
// 指标名称
|
|
|
indexMap := make(map[string]*models.YongyiExcelIndex)
|
|
|
|
|
|
- mergeCellMap, err := GetMergeCells(f, sheetName)
|
|
|
- if err != nil {
|
|
|
- err = fmt.Errorf("获取合并单元格失败, sheetName: %s", sheetName)
|
|
|
- return
|
|
|
- }
|
|
|
stopFlag := false
|
|
|
for i, row := range rows {
|
|
|
fmt.Printf("当前第%d行 \n", i)
|
|
|
if stopFlag {
|
|
|
break
|
|
|
}
|
|
|
- currentMergeCells, mergeOk := mergeCellMap[i]
|
|
|
|
|
|
// 首行,表示时间
|
|
|
if i == 0 {
|
|
|
+ dateTmp := ""
|
|
|
for k, text := range row {
|
|
|
fmt.Printf("当前第%d列 \n", k)
|
|
|
if text != "" {
|
|
|
- text = strings.TrimSpace(text)
|
|
|
- if mergeOk {
|
|
|
- for j, v := range currentMergeCells {
|
|
|
- // 日期
|
|
|
- v = strings.TrimSpace(v)
|
|
|
- var dateT time.Time
|
|
|
- dateT, e = time.ParseInLocation("01-2-06", v, time.Local)
|
|
|
- if e != nil {
|
|
|
- utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 读取行,时间列失败 Err:%s", sheetName, i, k, e))
|
|
|
- continue
|
|
|
- }
|
|
|
- dateMap[j] = dateT.Format(utils.FormatDate)
|
|
|
- }
|
|
|
- }
|
|
|
// 日期
|
|
|
text = strings.TrimSpace(text)
|
|
|
var dateT time.Time
|
|
@@ -237,8 +203,9 @@ func HandleYongyiExcelDaily2(f *excelize.File, sheetName string) (indexList []*m
|
|
|
utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 读取行,时间列失败 Err:%s", sheetName, i, k, e))
|
|
|
continue
|
|
|
}
|
|
|
- dateMap[k] = dateT.Format(utils.FormatDate)
|
|
|
+ dateTmp = dateT.Format(utils.FormatDate)
|
|
|
}
|
|
|
+ dateMap[k] = dateTmp
|
|
|
}
|
|
|
} else if i == 1 { //表示表头
|
|
|
// 处理 index指标表
|