Explorar el Código

Merge branch 'bug/5723'

Roc hace 1 mes
padre
commit
888f0e95ac
Se han modificado 1 ficheros con 20 adiciones y 15 borrados
  1. 20 15
      services/data/manual.go

+ 20 - 15
services/data/manual.go

@@ -432,6 +432,11 @@ func ImportManualData(path string, sysUser *system.Admin) (successCount, failCou
 			tmpValue = val
 			break
 		}
+		// 指标名称是空的,说明是空列
+		if v.IndexName == `` {
+			continue
+		}
+
 		if !strings.Contains(strings.Join(classifyNameStrList, ","), v.ClassName) {
 			failItem := &models.EdbdataImportFail{
 				ClassifyName: v.ClassName,
@@ -812,13 +817,13 @@ func getDataByTemplate1(sheet *xlsx.Sheet, sysUserId int) (indexDataList []Impor
 // @return err error
 // @return errMsg string
 func getDataByTemplate2(sheet *xlsx.Sheet, sysUserId int) (indexDataList []ImportManualIndexData, failDataList []*models.EdbdataImportFail, err error, errMsg string) {
-	fmt.Println("sheet name: ", sheet.Name)
+	//fmt.Println("sheet name: ", sheet.Name)
 	indexDataList = make([]ImportManualIndexData, 0)
 	failDataList = make([]*models.EdbdataImportFail, 0)
 
 	//遍历行读取
 	maxRow := sheet.MaxRow
-	fmt.Println("maxRow:", maxRow)
+	//fmt.Println("maxRow:", maxRow)
 
 	varietyList := make([]string, 0)
 	indexNameList := make([]string, 0)
@@ -896,24 +901,19 @@ func getDataByTemplate2(sheet *xlsx.Sheet, sysUserId int) (indexDataList []Impor
 
 		// 日期是否异常,异常的话,就跳过,进入下一行数据处理
 		var dateErr bool
+		var emptyDate bool
 
 		// 数据处理
 		for k, v := range cells {
 			if k == 0 {
+				// 空日期数据
+				if v.Value == `` {
+					emptyDate = true
+					continue
+				}
+
 				tmpCurrDate, tmpErr := getExcelDate(v.Value)
 				if tmpErr != nil {
-					// TODO 错误数据记录
-					//failItem := new(models.EdbdataImportFail)
-					//failItem.SysUserId = strconv.Itoa(sysUser.AdminId)
-					//failItem.ClassifyName = classifyName
-					//failItem.CreateDate = createDate
-					//failItem.SecName = secName
-					//failItem.Close = closeVal
-					//failItem.Remark = "日期格式异常"
-					//failItem.Frequency = frequency
-					//failItem.Unit = unit
-					//failDataList = append(failDataList, failItem)
-					//go utils.SendEmail(utils.APPNAME+"失败提醒", "导入数据 获取分类:Err:"+err.Error(), utils.EmailSendToUsers)
 					dateErr = true
 				}
 
@@ -922,7 +922,12 @@ func getDataByTemplate2(sheet *xlsx.Sheet, sysUserId int) (indexDataList []Impor
 			}
 			key := k - 1
 
-			// 日期异常,所以不处理该行了
+			// 空日期数据,那就不处理了,不记录该行错误信息
+			if emptyDate {
+				continue
+			}
+
+			// 日期异常,所以不处理该行了同时记录该行错误信息
 			if dateErr {
 				var indexName, unit, classifyName, frequency string
 				if key <= maxNameIndex {