소스 검색

去掉涌益生猪es搜索

xyxie 1 년 전
부모
커밋
84eeebf751
5개의 변경된 파일0개의 추가작업 그리고 185개의 파일을 삭제
  1. 0 11
      logic/edbinfo.go
  2. 0 7
      models/base_from_yongyi.go
  3. 0 15
      services/base_from_yongyi.go
  4. 0 150
      services/elastic/elastic.go
  5. 0 2
      utils/config.go

+ 0 - 11
logic/edbinfo.go

@@ -4,7 +4,6 @@ import (
 	"eta/eta_index_lib/models"
 	"eta/eta_index_lib/services/elastic"
 	"eta/eta_index_lib/utils"
-	"fmt"
 	"strconv"
 )
 
@@ -14,13 +13,3 @@ func UpdateEs(edbInfoId int) {
 	itemInfo, _ := models.GetEdbInfoItemByCondition("AND edb_info_id=?", []interface{}{edbInfoId})
 	elastic.EsAddOrEditEdbInfoData(utils.DATA_INDEX_NAME, strconv.Itoa(itemInfo.EdbInfoId), itemInfo)
 }
-
-// UpdateAllEdbInfoEs 更新所有的指标ES的信息
-func UpdateAllEdbInfoEs() {
-	//添加es
-	list, _ := models.GetEdbInfoItemListByCondition()
-	for _, itemInfo := range list {
-		elastic.EsAddOrEditEdbInfoData(utils.DATA_INDEX_NAME, strconv.Itoa(itemInfo.EdbInfoId), itemInfo)
-	}
-	fmt.Println("修复完成")
-}

+ 0 - 7
models/base_from_yongyi.go

@@ -277,13 +277,6 @@ func (y *BaseFromYongyiIndex) GetByIndexCode(indexCode string) (item *BaseFromYo
 	return
 }
 
-func (y *BaseFromYongyiIndex) GetByIndexId(id int) (item *BaseFromYongyiIndexList, err error) {
-	o := orm.NewOrm()
-	sql := ` SELECT * FROM base_from_yongyi_index WHERE yongyi_index_id=? `
-	err = o.Raw(sql, id).QueryRow(&item)
-	return
-}
-
 func (y *BaseFromYongyiIndex) Add() (lastId int64, err error) {
 	o := orm.NewOrm()
 	lastId, err = o.Insert(y)

+ 0 - 15
services/base_from_yongyi.go

@@ -4,10 +4,8 @@ import (
 	"eta/eta_index_lib/logic"
 	"eta/eta_index_lib/models"
 	"eta/eta_index_lib/services/alarm_msg"
-	"eta/eta_index_lib/services/elastic"
 	"eta/eta_index_lib/utils"
 	"fmt"
-	"strconv"
 	"strings"
 	"time"
 )
@@ -219,7 +217,6 @@ func handleYongyiIndex(req *models.HandleYongyiExcelData) (err error) {
 
 		go func() {
 			indexObj.ModifyIndexMaxAndMinDate(indexCode, dateItem)
-			UpdateEsBaseFromYongyi(int(indexObj.YongyiIndexId))
 		}()
 	}
 
@@ -245,15 +242,3 @@ func handleYongyiIndex(req *models.HandleYongyiExcelData) (err error) {
 	}
 	return
 }
-
-// UpdateEsBaseFromYongyi 更新数据源的es
-func UpdateEsBaseFromYongyi(yongyiIndexId int) (err error) {
-	indexObj := new(models.BaseFromYongyiIndex)
-	//添加es
-	itemInfo, err := indexObj.GetByIndexId(yongyiIndexId)
-	if err == nil {
-		err = elastic.EsAddOrEditBaseFromYongyiIndex(utils.ES_INDEX_BASE_FROM_YONGYI_INDEX, strconv.Itoa(yongyiIndexId), itemInfo)
-		return
-	}
-	return
-}

+ 0 - 150
services/elastic/elastic.go

@@ -5,31 +5,8 @@ import (
 	"eta/eta_index_lib/models"
 	"eta/eta_index_lib/utils"
 	"fmt"
-	"strings"
 )
 
-func EsCreateIndex(indexName, mappingJson string) (err error) {
-	client := utils.EsClient
-
-	//定义表结构
-	exists, err := client.IndexExists(indexName).Do(context.Background()) //<5>
-	if err != nil {
-		return
-	}
-	if !exists {
-		resp, err := client.CreateIndex(indexName).BodyJson(mappingJson).Do(context.Background())
-		//BodyJson(bodyJson).Do(context.Background())
-		if err != nil {
-			fmt.Println("CreateIndex Err:" + err.Error())
-			return err
-		}
-		fmt.Println(resp.Index, resp.ShardsAcknowledged, resp.Acknowledged)
-	} else {
-		fmt.Println(indexName + " 已存在")
-	}
-	return
-}
-
 // EsAddOrEditEdbInfoData 新增/修改es中的指标数据
 func EsAddOrEditEdbInfoData(indexName, docId string, item *models.EdbInfoList) (err error) {
 	defer func() {
@@ -56,130 +33,3 @@ func EsAddOrEditEdbInfoData(indexName, docId string, item *models.EdbInfoList) (
 	}
 	return
 }
-
-// EsAddOrEditBaseFromYongyiIndex 新增/修改es中的原始涌溢指标
-func EsAddOrEditBaseFromYongyiIndex(indexName, docId string, item *models.BaseFromYongyiIndexList) (err error) {
-	defer func() {
-		if err != nil {
-			fmt.Println("EsAddOrEditData Err:", err.Error())
-		}
-	}()
-	client := utils.EsClient
-	if err != nil {
-		return
-	}
-
-	resp, err := client.Index().Index(indexName).Id(docId).BodyJson(item).Do(context.Background())
-	if err != nil {
-		if strings.Contains(err.Error(), "no such index") {
-			//新增index
-			err = CreateEsEditBaseFromYongyiIndex()
-			if err != nil {
-				return
-			}
-			resp, err = client.Index().Index(indexName).Id(docId).BodyJson(item).Do(context.Background())
-			if err != nil {
-				return
-			}
-		} else {
-			fmt.Println("新增失败:", err.Error())
-			return err
-		}
-	}
-	fmt.Println(resp)
-	if resp.Status == 0 {
-		fmt.Println("新增成功", resp.Result)
-		err = nil
-	} else {
-		fmt.Println("AddData", resp.Status, resp.Result)
-	}
-	return
-}
-
-func CreateEsEditBaseFromYongyiIndex() (err error) {
-	indexName := utils.ES_INDEX_BASE_FROM_YONGYI_INDEX
-	mappingJson := `{
-  "mappings": {
-    "dynamic": true,
-    "properties": {
-      "YongyiIndexId": {
-         "type" : "long"
-      },
-      "IndexName": {
-        "type": "text",
-          "fields" : {
-            "keyword" : {
-              "type" : "keyword",
-              "ignore_above" : 256
-            }
-          }
-      },
-      "ClassifyId": {
-         "type" : "long"
-      },
-      "Frequency": {
-        "type": "text",
-          "fields" : {
-            "keyword" : {
-              "type" : "keyword",
-              "ignore_above" : 256
-            }
-          }
-      },
-      "IndexCode": {
-        "type": "text"
-      },
-      "Unit": {
-        "type": "text",
-          "fields" : {
-            "keyword" : {
-              "type" : "keyword",
-              "ignore_above" : 256
-            }
-          }
-      },
-      "CreateTime": {
-          "type" : "text",
-          "fields" : {
-            "keyword" : {
-              "type" : "keyword",
-              "ignore_above" : 256
-            }
-          }
-        },
-      "ModifyTime": {
-          "type" : "text",
-          "fields" : {
-            "keyword" : {
-              "type" : "keyword",
-              "ignore_above" : 256
-            }
-          }
-        },
-      "StartDate": {
-          "type" : "text",
-          "fields" : {
-            "keyword" : {
-              "type" : "keyword",
-              "ignore_above" : 256
-            }
-          }
-        },
-      "EndDate": {
-          "type" : "text",
-          "fields" : {
-            "keyword" : {
-              "type" : "keyword",
-              "ignore_above" : 256
-            }
-          }
-        },
-      "TerminalCode": {
-        "type": "text"
-      }
-    }
-  }
-}`
-	err = EsCreateIndex(indexName, mappingJson)
-	return
-}

+ 0 - 2
utils/config.go

@@ -28,7 +28,6 @@ var (
 
 // DATA_INDEX_NAME 数据指标库ES索引名称
 var DATA_INDEX_NAME string
-var ES_INDEX_BASE_FROM_YONGYI_INDEX string
 
 // 基础配置
 var (
@@ -215,7 +214,6 @@ func init() {
 		ES_USERNAME = config["es_username"]
 		ES_PASSWORD = config["es_password"]
 		DATA_INDEX_NAME = config["data_index_name"]
-		ES_INDEX_BASE_FROM_YONGYI_INDEX = config["es_index_base_from_yongyi_index"]
 	}
 
 	//日志配置