|
@@ -432,6 +432,11 @@ func ImportManualData(path string, sysUser *system.Admin) (successCount, failCou
|
|
tmpValue = val
|
|
tmpValue = val
|
|
break
|
|
break
|
|
}
|
|
}
|
|
|
|
+ // 指标名称是空的,说明是空列
|
|
|
|
+ if v.IndexName == `` {
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+
|
|
if !strings.Contains(strings.Join(classifyNameStrList, ","), v.ClassName) {
|
|
if !strings.Contains(strings.Join(classifyNameStrList, ","), v.ClassName) {
|
|
failItem := &models.EdbdataImportFail{
|
|
failItem := &models.EdbdataImportFail{
|
|
ClassifyName: v.ClassName,
|
|
ClassifyName: v.ClassName,
|
|
@@ -812,13 +817,13 @@ func getDataByTemplate1(sheet *xlsx.Sheet, sysUserId int) (indexDataList []Impor
|
|
// @return err error
|
|
// @return err error
|
|
// @return errMsg string
|
|
// @return errMsg string
|
|
func getDataByTemplate2(sheet *xlsx.Sheet, sysUserId int) (indexDataList []ImportManualIndexData, failDataList []*models.EdbdataImportFail, err error, 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)
|
|
indexDataList = make([]ImportManualIndexData, 0)
|
|
failDataList = make([]*models.EdbdataImportFail, 0)
|
|
failDataList = make([]*models.EdbdataImportFail, 0)
|
|
|
|
|
|
//遍历行读取
|
|
//遍历行读取
|
|
maxRow := sheet.MaxRow
|
|
maxRow := sheet.MaxRow
|
|
- fmt.Println("maxRow:", maxRow)
|
|
|
|
|
|
+ //fmt.Println("maxRow:", maxRow)
|
|
|
|
|
|
varietyList := make([]string, 0)
|
|
varietyList := make([]string, 0)
|
|
indexNameList := make([]string, 0)
|
|
indexNameList := make([]string, 0)
|
|
@@ -896,24 +901,19 @@ func getDataByTemplate2(sheet *xlsx.Sheet, sysUserId int) (indexDataList []Impor
|
|
|
|
|
|
// 日期是否异常,异常的话,就跳过,进入下一行数据处理
|
|
// 日期是否异常,异常的话,就跳过,进入下一行数据处理
|
|
var dateErr bool
|
|
var dateErr bool
|
|
|
|
+ var emptyDate bool
|
|
|
|
|
|
// 数据处理
|
|
// 数据处理
|
|
for k, v := range cells {
|
|
for k, v := range cells {
|
|
if k == 0 {
|
|
if k == 0 {
|
|
|
|
+ // 空日期数据
|
|
|
|
+ if v.Value == `` {
|
|
|
|
+ emptyDate = true
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+
|
|
tmpCurrDate, tmpErr := getExcelDate(v.Value)
|
|
tmpCurrDate, tmpErr := getExcelDate(v.Value)
|
|
if tmpErr != nil {
|
|
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
|
|
dateErr = true
|
|
}
|
|
}
|
|
|
|
|
|
@@ -922,7 +922,12 @@ func getDataByTemplate2(sheet *xlsx.Sheet, sysUserId int) (indexDataList []Impor
|
|
}
|
|
}
|
|
key := k - 1
|
|
key := k - 1
|
|
|
|
|
|
- // 日期异常,所以不处理该行了
|
|
|
|
|
|
+ // 空日期数据,那就不处理了,不记录该行错误信息
|
|
|
|
+ if emptyDate {
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 日期异常,所以不处理该行了同时记录该行错误信息
|
|
if dateErr {
|
|
if dateErr {
|
|
var indexName, unit, classifyName, frequency string
|
|
var indexName, unit, classifyName, frequency string
|
|
if key <= maxNameIndex {
|
|
if key <= maxNameIndex {
|