|
@@ -278,7 +278,7 @@ func NetDataHandle(req models.HandleFenWeiNetDataReq) error {
|
|
|
return err
|
|
|
}
|
|
|
} else {
|
|
|
- classifyId = classify.ClassifyId
|
|
|
+ classifyId = classify[0].ClassifyId
|
|
|
}
|
|
|
|
|
|
// 保存分类ID
|
|
@@ -312,40 +312,6 @@ func NetDataHandle(req models.HandleFenWeiNetDataReq) error {
|
|
|
|
|
|
indexDataList := make([]*models.BaseFromFenweiData, 0)
|
|
|
for _, indexInfo := range indexInfoList {
|
|
|
- /*
|
|
|
- // 处理分类信息
|
|
|
- var classifyId int
|
|
|
- classify, err := classifyObj.GetByClassifyName(indexInfo.ClassifyName)
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
- if classify == nil {
|
|
|
- classifyId, err = addFenWeiClassify(indexInfo)
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
- } else {
|
|
|
- classifyId = classify.ClassifyId
|
|
|
- }
|
|
|
-
|
|
|
- // 处理指标
|
|
|
- indexCode := GenerateIndexCode(indexInfo.IndexName)
|
|
|
- index, err := models.GetBaseFromFenWeiIndexByIndexName(indexInfo.IndexName)
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
- if index == nil {
|
|
|
- logs.Info("NetDataHandle indexName: ", indexInfo.IndexName)
|
|
|
- indexId, err := addIndex(indexInfo, classifyId, indexCode)
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
- indexInfo.FenweiIndexId = indexId
|
|
|
- } else {
|
|
|
- logs.Info("NetDataHandle exist indexName: ", indexInfo.IndexName)
|
|
|
- indexInfo.FenweiIndexId = index.FenweiIndexId
|
|
|
- }*/
|
|
|
-
|
|
|
// 处理指标数据
|
|
|
indexData, err := handleIndexData(indexInfo, indexIdMap, indexCodeMap)
|
|
|
if err != nil {
|
|
@@ -357,10 +323,14 @@ func NetDataHandle(req models.HandleFenWeiNetDataReq) error {
|
|
|
}
|
|
|
// 批量插入指标数据
|
|
|
logs.Info("NetDataHandle addIndexData indexDataList.size: ", len(indexDataList))
|
|
|
+ if len(indexDataList) == 0 {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
err := models.BatchAddBaseFromFenWeiData(indexDataList)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
+ logs.Info("NetDataHandle addIndexData success")
|
|
|
return nil
|
|
|
}
|
|
|
|
|
@@ -452,13 +422,19 @@ func handleClassify(classify *models.BaseFromFenweiClassify, parentId int, level
|
|
|
classify.Level = level
|
|
|
|
|
|
// 检查当前分类是否已存在
|
|
|
- existingClassify, err := classify.GetByClassifyName(currentClassifyName)
|
|
|
+ existingClassifyList, err := classify.GetByClassifyName(currentClassifyName)
|
|
|
if err != nil {
|
|
|
return 0, err
|
|
|
}
|
|
|
+ var existingClassify *models.BaseFromFenweiClassify
|
|
|
+ for _, item := range existingClassifyList {
|
|
|
+ if item.ParentId == parentId {
|
|
|
+ existingClassify = item
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
// 如果分类存在,且父级ID相同,则递归处理下一级
|
|
|
- if existingClassify != nil && existingClassify.ParentId == parentId {
|
|
|
+ if existingClassify != nil && existingClassify != nil {
|
|
|
// 如果存在且有下一级,则递归处理下一级
|
|
|
if len(classifyArr) > 1 {
|
|
|
nextClassifyName := strings.Join(classifyArr[1:], "-")
|