Преглед на файлове

fix:框架详情新增标的名称,标的列表新增通过标的id查询

Roc преди 2 месеца
родител
ревизия
a5b5137d61

+ 32 - 3
controllers/data_manage/ai_predict_model/framework.go

@@ -162,7 +162,7 @@ func (c *AiPredictModelFrameworkController) Add() {
 			nodes = append(nodes, t)
 			num := 1
 			// 响应节点数据
-			td := aiPredictModel.FormatAiPredictModelFrameworkNode2Item(t, num)
+			td := aiPredictModel.FormatAiPredictModelFrameworkNode2Item(t, num, map[int]*aiPredictModel.AiPredictModelIndex{})
 			itemNodes = append(itemNodes, td)
 		}
 	}
@@ -279,7 +279,7 @@ func (c *AiPredictModelFrameworkController) Edit() {
 			nodes = append(nodes, t)
 
 			// 响应节点数据
-			td := aiPredictModel.FormatAiPredictModelFrameworkNode2Item(t, 1)
+			td := aiPredictModel.FormatAiPredictModelFrameworkNode2Item(t, 1, map[int]*aiPredictModel.AiPredictModelIndex{})
 			itemNodes = append(itemNodes, td)
 		}
 	}
@@ -620,6 +620,34 @@ func (c *AiPredictModelFrameworkController) Detail() {
 		return
 	}
 
+	// 模型标的map
+	aiPredictModelIndexMap := make(map[int]*aiPredictModel.AiPredictModelIndex)
+	{
+		aiPredictModelIndexIdList := make([]interface{}, 0)
+		for _, v := range nodes {
+			if v.AiPredictModelIndexId > 0 {
+				aiPredictModelIndexIdList = append(aiPredictModelIndexIdList, v.AiPredictModelIndexId)
+			}
+		}
+
+		if len(aiPredictModelIndexIdList) > 0 {
+			indexObj := aiPredictModel.AiPredictModelIndex{}
+			indexList, e := indexObj.GetItemsByCondition(`ai_predict_model_index_id in (?)`, aiPredictModelIndexIdList, []string{}, "")
+			if e != nil {
+				if e.Error() == utils.ErrNoRow() {
+					br.Msg = "框架不存在, 请刷新页面"
+					return
+				}
+				br.Msg = "获取失败"
+				br.ErrMsg = "获取标的列表失败, Err: " + e.Error()
+				return
+			}
+			for _, v := range indexList {
+				aiPredictModelIndexMap[v.AiPredictModelIndexId] = v
+			}
+		}
+	}
+
 	// 格式化响应数据
 	itemNodes := make([]*aiPredictModel.AiPredictModelFrameworkNodeItem, 0)
 	for _, v := range nodes {
@@ -627,7 +655,8 @@ func (c *AiPredictModelFrameworkController) Detail() {
 			continue
 		}
 		num := 1
-		itemNodes = append(itemNodes, aiPredictModel.FormatAiPredictModelFrameworkNode2Item(v, num))
+
+		itemNodes = append(itemNodes, aiPredictModel.FormatAiPredictModelFrameworkNode2Item(v, num, aiPredictModelIndexMap))
 	}
 	detail := aiPredictModel.FormatAiPredictModelFramework2Item(item, itemNodes)
 

+ 6 - 0
controllers/data_manage/ai_predict_model/index.go

@@ -28,6 +28,7 @@ type AiPredictModelIndexController struct {
 // @Param   PageSize   query   int   true   "每页数据条数"
 // @Param   CurrentIndex   query   int   true   "当前页页码,从1开始"
 // @Param   ClassifyId   query   int   false   "分类id"
+// @Param   AiPredictModelIndexId   query   int   false   "模型标的ID"
 // @Param   Keyword   query   string   false   "搜索关键词"
 // @Success 200 {object} data_manage.ChartListResp
 // @router /index/list [get]
@@ -47,6 +48,7 @@ func (this *AiPredictModelIndexController) List() {
 	pageSize, _ := this.GetInt("PageSize")
 	currentIndex, _ := this.GetInt("CurrentIndex")
 	classifyId, _ := this.GetInt("ClassifyId")
+	indexId, _ := this.GetInt("AiPredictModelIndexId")
 	keyword := this.GetString("KeyWord")
 	keyword = strings.TrimSpace(keyword)
 	resp := new(aiPredictModel.AiPredictModelIndexPageListResp)
@@ -81,6 +83,10 @@ func (this *AiPredictModelIndexController) List() {
 	var cond string
 	var pars []interface{}
 	{
+		if indexId > 0 {
+			cond += fmt.Sprintf(" AND %s = ?", indexOb.Cols().PrimaryId)
+			pars = append(pars, indexId)
+		}
 		if classifyId > 0 {
 			cond += fmt.Sprintf(" AND %s = ?", indexOb.Cols().ClassifyId)
 			pars = append(pars, classifyId)

+ 5 - 1
models/ai_predict_model/ai_predict_model_framework_node.go

@@ -118,12 +118,13 @@ type AiPredictModelFrameworkNodeItem struct {
 	NodeId                        string `description:"节点ID"`
 	NodeName                      string `description:"节点名称"`
 	AiPredictModelIndexId         int    `description:"模型标的ID"`
+	IndexName                     string `description:"模型标的名称"`
 	AiPredictModelNum             int    `description:"分类下的图表数"`
 	CreateTime                    string `description:"创建时间"`
 }
 
 // FormatAiPredictModelFrameworkNode2Item 格式化框架节点信息
-func FormatAiPredictModelFrameworkNode2Item(origin *AiPredictModelFrameworkNode, aiPredictModelNum int) (item *AiPredictModelFrameworkNodeItem) {
+func FormatAiPredictModelFrameworkNode2Item(origin *AiPredictModelFrameworkNode, aiPredictModelNum int, aiPredictModelIndexMap map[int]*AiPredictModelIndex) (item *AiPredictModelFrameworkNodeItem) {
 	if origin == nil {
 		return
 	}
@@ -134,6 +135,9 @@ func FormatAiPredictModelFrameworkNode2Item(origin *AiPredictModelFrameworkNode,
 	item.NodeId = origin.NodeId
 	item.NodeName = origin.NodeName
 	item.AiPredictModelIndexId = origin.AiPredictModelIndexId
+	if aiPredictModelIndex, ok := aiPredictModelIndexMap[origin.AiPredictModelIndexId]; ok {
+		item.IndexName = aiPredictModelIndex.IndexName
+	}
 	item.AiPredictModelNum = aiPredictModelNum
 	item.CreateTime = utils.TimeTransferString(utils.FormatDateTime, origin.CreateTime)
 	return