Roc 1 hafta önce
ebeveyn
işleme
7bf93e400c

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

@@ -5,6 +5,7 @@ import (
 	"eta/eta_api/controllers"
 	"eta/eta_api/models"
 	aiPredictModel "eta/eta_api/models/ai_predict_model"
+	"eta/eta_api/models/ai_predict_model/request"
 	"eta/eta_api/models/data_manage"
 	dataSourceModel "eta/eta_api/models/data_source"
 	"eta/eta_api/models/system"
@@ -1130,3 +1131,69 @@ func (this *AiPredictModelIndexController) SearchByEs() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// ScriptPathSave
+// @Title 保存保存标的关联脚本路径标的
+// @Description 保存标的关联脚本路径
+// @Param	request	body request.AiPredictModelIndexSaveScriptPathReq true "type json string"
+// @Success 200 Ret=200 保存成功
+// @router /index/script_path/save [post]
+func (this *AiPredictModelIndexController) ScriptPathSave() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		if br.ErrMsg == "" {
+			br.IsSendEmail = false
+		}
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	var req request.AiPredictModelIndexSaveScriptPathReq
+	if e := json.Unmarshal(this.Ctx.Input.RequestBody, &req); e != nil {
+		br.Msg = "参数解析异常"
+		br.ErrMsg = fmt.Sprintf("参数解析异常, %v", e)
+		return
+	}
+	if req.IndexId < 0 {
+		br.Msg = "参数有误"
+		br.ErrMsg = fmt.Sprintf("标的ID有误, IndexId: %d", req.IndexId)
+		return
+	}
+	req.ScriptPath = strings.TrimSpace(req.ScriptPath)
+	if req.ScriptPath == "" {
+		br.Msg = "标的路径不能为空"
+		br.ErrMsg = fmt.Sprintf("标的路径有误, ScriptPath: %s", req.ScriptPath)
+		return
+	}
+
+	indexOb := new(aiPredictModel.AiPredictModelIndex)
+	indexItem, e := indexOb.GetItemById(req.IndexId)
+	if e != nil {
+		if utils.IsErrNoRow(e) {
+			br.Msg = "标的已被删除,请刷新页面"
+			return
+		}
+		br.Msg = "操作失败"
+		br.ErrMsg = fmt.Sprintf("获取标的失败, %v", e)
+		return
+	}
+
+	indexItem.ScriptPath = req.ScriptPath
+	indexItem.ModifyTime = time.Now()
+	updateCols := []string{indexOb.Cols().ScriptPath, indexOb.Cols().ModifyTime}
+	if e = indexItem.Update(updateCols); e != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = fmt.Sprintf("保存标的失败, %v", e)
+		return
+	}
+
+	br.Ret = 200
+	br.Msg = "操作成功"
+	br.Success = true
+}

+ 213 - 0
controllers/data_manage/ai_predict_model/index_config.go

@@ -0,0 +1,213 @@
+package ai_predict_model
+
+import (
+	"encoding/json"
+	"eta/eta_api/controllers"
+	"eta/eta_api/models"
+	data_manage "eta/eta_api/models/ai_predict_model"
+	"eta/eta_api/models/ai_predict_model/request"
+	"eta/eta_api/models/ai_predict_model/response"
+	"eta/eta_api/utils"
+	"fmt"
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"time"
+)
+
+// AiPredictModelIndexConfigController AI预测模型标的配置项
+type AiPredictModelIndexConfigController struct {
+	controllers.BaseAuthController
+}
+
+// List
+// @Title 列表
+// @Description 列表
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   KeyWord   query   string  true       "搜索关键词"
+// @Success 200 {object} []*data_manage.AiPredictModelIndexConfigView
+// @router /index_config/list [get]
+func (c *AiPredictModelIndexConfigController) List() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		c.Data["json"] = br
+		c.ServeJSON()
+	}()
+
+	sysUser := c.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		return
+	}
+	pageSize, _ := c.GetInt("PageSize")
+	currentIndex, _ := c.GetInt("CurrentIndex")
+
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = utils.StartIndex(currentIndex, pageSize)
+
+	var total int
+	viewList := make([]data_manage.AiPredictModelIndexConfigView, 0)
+
+	var condition string
+	var pars []interface{}
+
+	obj := new(data_manage.AiPredictModelIndexConfig)
+	tmpTotal, list, err := obj.GetPageListByCondition(condition, pars, startSize, pageSize)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	total = tmpTotal
+
+	if list != nil && len(list) > 0 {
+		viewList = list[0].ListToViewList(list)
+	}
+
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp := response.AiPredictModelIndexConfigListResp{
+		List:   viewList,
+		Paging: page,
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// CurrVersion
+// @Title 获取当前版本参数信息
+// @Description 获取当前版本参数信息
+// @Param   IndexId   query   int   true   "标的ID"
+// @Success 200 {object} []*data_manage.AiPredictModelIndexConfigView
+// @router /index_config/detail [get]
+func (c *AiPredictModelIndexConfigController) CurrVersion() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		c.Data["json"] = br
+		c.ServeJSON()
+	}()
+
+	sysUser := c.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		return
+	}
+	indexId, _ := c.GetInt("IndexId")
+	if indexId <= 0 {
+		br.Msg = "标的id不能为空"
+		br.ErrMsg = "标的id不能为空"
+		return
+	}
+
+	// 查询标的情况
+	indexOb := new(data_manage.AiPredictModelIndex)
+	indexItem, e := indexOb.GetItemById(indexId)
+	if e != nil {
+		if utils.IsErrNoRow(e) {
+			br.Msg = "标的已被删除,请刷新页面"
+			return
+		}
+		br.Msg = "获取失败"
+		br.ErrMsg = fmt.Sprintf("获取标的失败, %v", e)
+		return
+	}
+
+	if indexItem.AiPredictModelIndexConfigId <= 0 {
+		br.Msg = "标的默认配置为空"
+		br.IsSendEmail = false
+		return
+	}
+
+	obj := new(data_manage.AiPredictModelIndexConfig)
+	configItem, err := obj.GetById(indexItem.AiPredictModelIndexConfigId)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+
+	br.Data = configItem.ToView()
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+}
+
+// Del
+// @Title 删除问题
+// @Description 删除问题
+// @Param	request	body request.DelConfigReq true "type json string"
+// @Success 200 Ret=200 删除成功
+// @router /index_config/del [post]
+func (c *AiPredictModelIndexConfigController) Del() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		c.Data["json"] = br
+		c.ServeJSON()
+	}()
+	var req request.DelConfigReq
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	if req.AiPredictModelIndexConfigId <= 0 {
+		br.Msg = "配置id不能为空"
+		br.IsSendEmail = false
+		return
+	}
+
+	// 查找配置
+	obj := new(data_manage.AiPredictModelIndexConfig)
+	item, err := obj.GetById(req.AiPredictModelIndexConfigId)
+	if err != nil {
+		br.Msg = "修改失败"
+		br.ErrMsg = "修改失败,查找配置失败,Err:" + err.Error()
+		if utils.IsErrNoRow(err) {
+			br.Msg = "配置不存在"
+			br.IsSendEmail = false
+		}
+		return
+	}
+
+	// 查找是否被标的引用为默认模型
+	{
+		// 查询标的情况
+		indexOb := new(data_manage.AiPredictModelIndex)
+		count, e := indexOb.GetCountByCondition(fmt.Sprintf(` AND %s = ? `, indexOb.Cols().AiPredictModelIndexConfigId), []interface{}{item.AiPredictModelIndexConfigId})
+		if e != nil {
+			br.Msg = "删除失败"
+			br.ErrMsg = fmt.Sprintf("删除失败,根据配置ID获取标的信息失败, %v", e)
+			return
+		}
+
+		if count > 0 {
+			br.Msg = "删除失败,该版本配置正在被使用"
+			br.IsSendEmail = false
+			return
+		}
+	}
+
+	item.IsDeleted = 1
+	item.ModifyTime = time.Now()
+	err = item.Update([]string{"IsDeleted", "ModifyTime"})
+	if err != nil {
+		br.Msg = "删除失败"
+		br.ErrMsg = "删除失败,Err:" + err.Error()
+		return
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = `删除成功`
+}

+ 79 - 69
models/ai_predict_model/ai_predict_model_index.go

@@ -13,24 +13,26 @@ import (
 
 // AiPredictModelIndex AI预测模型标的
 type AiPredictModelIndex struct {
-	AiPredictModelIndexId int       `orm:"column(ai_predict_model_index_id);pk" gorm:"primaryKey"`
-	IndexName             string    `description:"标的名称"`
-	IndexCode             string    `description:"自生成的指标编码"`
-	ClassifyId            int       `description:"分类ID"`
-	ModelFramework        string    `description:"模型框架"`
-	PredictDate           time.Time `description:"预测日期"`
-	PredictValue          float64   `description:"预测值"`
-	PredictFrequency      string    `description:"预测频度"`
-	DirectionAccuracy     string    `description:"方向准确度"`
-	AbsoluteDeviation     string    `description:"绝对偏差"`
-	ExtraConfig           string    `description:"模型参数"`
-	Sort                  int       `description:"排序"`
-	SysUserId             int       `description:"创建人ID"`
-	SysUserRealName       string    `description:"创建人姓名"`
-	LeftMin               string    `description:"图表左侧最小值"`
-	LeftMax               string    `description:"图表左侧最大值"`
-	CreateTime            time.Time `description:"创建时间"`
-	ModifyTime            time.Time `description:"修改时间"`
+	AiPredictModelIndexId       int       `orm:"column(ai_predict_model_index_id);pk" gorm:"primaryKey"`
+	IndexName                   string    `description:"标的名称"`
+	IndexCode                   string    `description:"自生成的指标编码"`
+	ClassifyId                  int       `description:"分类ID"`
+	ModelFramework              string    `description:"模型框架"`
+	PredictDate                 time.Time `description:"预测日期"`
+	PredictValue                float64   `description:"预测值"`
+	PredictFrequency            string    `description:"预测频度"`
+	DirectionAccuracy           string    `description:"方向准确度"`
+	AbsoluteDeviation           string    `description:"绝对偏差"`
+	ExtraConfig                 string    `description:"模型参数"`
+	Sort                        int       `description:"排序"`
+	SysUserId                   int       `description:"创建人ID"`
+	SysUserRealName             string    `description:"创建人姓名"`
+	LeftMin                     string    `description:"图表左侧最小值"`
+	LeftMax                     string    `description:"图表左侧最大值"`
+	CreateTime                  time.Time `description:"创建时间"`
+	ModifyTime                  time.Time `description:"修改时间"`
+	AiPredictModelIndexConfigId int       `gorm:"column:ai_predict_model_index_config_id" description:"标的当前的配置id"`
+	ScriptPath                  string    `gorm:"column:script_path" description:"脚本的路径"`
 }
 
 func (m *AiPredictModelIndex) TableName() string {
@@ -38,44 +40,48 @@ func (m *AiPredictModelIndex) TableName() string {
 }
 
 type AiPredictModelIndexCols struct {
-	PrimaryId         string
-	IndexName         string
-	IndexCode         string
-	ClassifyId        string
-	ModelFramework    string
-	PredictDate       string
-	PredictValue      string
-	DirectionAccuracy string
-	AbsoluteDeviation string
-	ExtraConfig       string
-	Sort              string
-	SysUserId         string
-	SysUserRealName   string
-	LeftMin           string
-	LeftMax           string
-	CreateTime        string
-	ModifyTime        string
+	PrimaryId                   string
+	IndexName                   string
+	IndexCode                   string
+	ClassifyId                  string
+	ModelFramework              string
+	PredictDate                 string
+	PredictValue                string
+	DirectionAccuracy           string
+	AbsoluteDeviation           string
+	ExtraConfig                 string
+	Sort                        string
+	SysUserId                   string
+	SysUserRealName             string
+	LeftMin                     string
+	LeftMax                     string
+	CreateTime                  string
+	ModifyTime                  string
+	AiPredictModelIndexConfigId string
+	ScriptPath                  string
 }
 
 func (m *AiPredictModelIndex) Cols() AiPredictModelIndexCols {
 	return AiPredictModelIndexCols{
-		PrimaryId:         "ai_predict_model_index_id",
-		IndexName:         "index_name",
-		IndexCode:         "index_code",
-		ClassifyId:        "classify_id",
-		ModelFramework:    "model_framework",
-		PredictDate:       "predict_date",
-		PredictValue:      "predict_value",
-		DirectionAccuracy: "direction_accuracy",
-		AbsoluteDeviation: "absolute_deviation",
-		ExtraConfig:       "extra_config",
-		Sort:              "sort",
-		SysUserId:         "sys_user_id",
-		SysUserRealName:   "sys_user_real_name",
-		LeftMin:           "left_min",
-		LeftMax:           "left_max",
-		CreateTime:        "create_time",
-		ModifyTime:        "modify_time",
+		PrimaryId:                   "ai_predict_model_index_id",
+		IndexName:                   "index_name",
+		IndexCode:                   "index_code",
+		ClassifyId:                  "classify_id",
+		ModelFramework:              "model_framework",
+		PredictDate:                 "predict_date",
+		PredictValue:                "predict_value",
+		DirectionAccuracy:           "direction_accuracy",
+		AbsoluteDeviation:           "absolute_deviation",
+		ExtraConfig:                 "extra_config",
+		Sort:                        "sort",
+		SysUserId:                   "sys_user_id",
+		SysUserRealName:             "sys_user_real_name",
+		LeftMin:                     "left_min",
+		LeftMax:                     "left_max",
+		CreateTime:                  "create_time",
+		ModifyTime:                  "modify_time",
+		AiPredictModelIndexConfigId: "ai_predict_model_index_config_id",
+		ScriptPath:                  "script_path",
 	}
 }
 
@@ -185,23 +191,25 @@ func (m *AiPredictModelIndex) GetPageItemsByCondition(condition string, pars []i
 
 // AiPredictModelIndexItem AI预测模型标的信息
 type AiPredictModelIndexItem struct {
-	IndexId           int     `description:"标的ID"`
-	IndexName         string  `description:"标的名称"`
-	IndexCode         string  `description:"自生成的指标编码"`
-	ClassifyId        int     `description:"分类ID"`
-	ClassifyName      string  `description:"分类名称"`
-	ModelFramework    string  `description:"模型框架"`
-	PredictDate       string  `description:"预测日期"`
-	PredictValue      float64 `description:"预测值"`
-	PredictFrequency  string  `description:"预测频度"`
-	DirectionAccuracy string  `description:"方向准确度"`
-	AbsoluteDeviation string  `description:"绝对偏差"`
-	ExtraConfig       string  `description:"模型参数"`
-	SysUserId         int     `description:"创建人ID"`
-	SysUserRealName   string  `description:"创建人姓名"`
-	CreateTime        string  `description:"创建时间"`
-	ModifyTime        string  `description:"修改时间"`
-	SearchText        string  `description:"搜索结果(含高亮)"`
+	IndexId                     int     `description:"标的ID"`
+	IndexName                   string  `description:"标的名称"`
+	IndexCode                   string  `description:"自生成的指标编码"`
+	ClassifyId                  int     `description:"分类ID"`
+	ClassifyName                string  `description:"分类名称"`
+	ModelFramework              string  `description:"模型框架"`
+	PredictDate                 string  `description:"预测日期"`
+	PredictValue                float64 `description:"预测值"`
+	PredictFrequency            string  `description:"预测频度"`
+	DirectionAccuracy           string  `description:"方向准确度"`
+	AbsoluteDeviation           string  `description:"绝对偏差"`
+	ExtraConfig                 string  `description:"模型参数"`
+	SysUserId                   int     `description:"创建人ID"`
+	SysUserRealName             string  `description:"创建人姓名"`
+	CreateTime                  string  `description:"创建时间"`
+	ModifyTime                  string  `description:"修改时间"`
+	SearchText                  string  `description:"搜索结果(含高亮)"`
+	AiPredictModelIndexConfigId int     `gorm:"column:ai_predict_model_index_config_id" description:"标的当前的配置id"`
+	ScriptPath                  string  `gorm:"column:script_path" description:"脚本的路径"`
 }
 
 func (m *AiPredictModelIndex) Format2Item() (item *AiPredictModelIndexItem) {
@@ -219,6 +227,8 @@ func (m *AiPredictModelIndex) Format2Item() (item *AiPredictModelIndexItem) {
 	item.ExtraConfig = m.ExtraConfig
 	item.SysUserId = m.SysUserId
 	item.SysUserRealName = m.SysUserRealName
+	item.AiPredictModelIndexConfigId = m.AiPredictModelIndexConfigId
+	item.ScriptPath = m.ScriptPath
 	item.CreateTime = utils.TimeTransferString(utils.FormatDateTime, m.CreateTime)
 	item.ModifyTime = utils.TimeTransferString(utils.FormatDateTime, m.ModifyTime)
 	return

+ 161 - 0
models/ai_predict_model/ai_predict_model_index_config.go

@@ -0,0 +1,161 @@
+package data_manage
+
+import (
+	"database/sql"
+	"eta/eta_api/global"
+	"eta/eta_api/utils"
+	"fmt"
+	"time"
+)
+
+// AiPredictModelIndexConfig ai预测模型训练配置
+type AiPredictModelIndexConfig struct {
+	AiPredictModelIndexConfigId int       `gorm:"primaryKey;column:ai_predict_model_index_config_id" description:"-"`
+	AiPredictModelIndexId       int       `gorm:"column:ai_predict_model_index_id" description:"ai预测模型id"`
+	TrainStatus                 string    `gorm:"column:train_status" description:"训练状态,枚举值:待训练,训练中,训练成功,训练失败"`
+	Params                      string    `gorm:"column:params" description:"训练参数,json字符串存储,便于以后参数扩展"`
+	TrainMse                    string    `gorm:"column:train_mse" description:"训练集mse"`
+	TrainR2                     string    `gorm:"column:train_r2" description:"训练集r2"`
+	TestMse                     string    `gorm:"column:test_mse" description:"测试集mse"`
+	TestR2                      string    `gorm:"column:test_r2" description:"测试集r2"`
+	Remark                      string    `gorm:"column:remark" description:"训练结果说明"`
+	IsDeleted                   int8      `gorm:"column:is_deleted" description:"是否删除,0:未删除,1:已删除"`
+	ModifyTime                  time.Time `gorm:"column:modify_time" description:"修改时间"`
+	CreateTime                  time.Time `gorm:"column:create_time" description:"创建时间"`
+}
+
+// TableName get sql table name.获取数据库表名
+func (m *AiPredictModelIndexConfig) TableName() string {
+	return "ai_predict_model_index_config"
+}
+
+// AiPredictModelIndexConfigColumns get sql column name.获取数据库列名
+var AiPredictModelIndexConfigColumns = struct {
+	AiPredictModelIndexConfigId string
+	AiPredictModelIndexId       string
+	TrainStatus                 string
+	Params                      string
+	TrainMse                    string
+	TrainR2                     string
+	TestMse                     string
+	TestR2                      string
+	Remark                      string
+	IsDeleted                   string
+	ModifyTime                  string
+	CreateTime                  string
+}{
+	AiPredictModelIndexConfigId: "ai_predict_model_index_config_id",
+	AiPredictModelIndexId:       "ai_predict_model_index_id",
+	TrainStatus:                 "train_status",
+	Params:                      "params",
+	TrainMse:                    "train_mse",
+	TrainR2:                     "train_r2",
+	TestMse:                     "test_mse",
+	TestR2:                      "test_r2",
+	Remark:                      "remark",
+	IsDeleted:                   "is_deleted",
+	ModifyTime:                  "modify_time",
+	CreateTime:                  "create_time",
+}
+
+// AiPredictModelIndexConfigView ai预测模型训练配置
+type AiPredictModelIndexConfigView struct {
+	AiPredictModelIndexConfigId int    `gorm:"primaryKey;column:ai_predict_model_index_config_id" description:"-"`
+	AiPredictModelIndexId       int    `gorm:"column:ai_predict_model_index_id" description:"ai预测模型id"`
+	TrainStatus                 string `gorm:"column:train_status" description:"训练状态,枚举值:待训练,训练中,训练成功,训练失败"`
+	Params                      string `gorm:"column:params" description:"训练参数,json字符串存储,便于以后参数扩展"`
+	TrainMse                    string `gorm:"column:train_mse" description:"训练集mse"`
+	TrainR2                     string `gorm:"column:train_r2" description:"训练集r2"`
+	TestMse                     string `gorm:"column:test_mse" description:"测试集mse"`
+	TestR2                      string `gorm:"column:test_r2" description:"测试集r2"`
+	Remark                      string `gorm:"column:remark" description:"训练结果说明"`
+	IsCurr                      int8   `gorm:"column:is_curr" description:"是否当前版本,0:否,1:是"`
+	ModifyTime                  string `gorm:"column:modify_time" description:"修改时间"`
+	CreateTime                  string `gorm:"column:create_time" description:"创建时间"`
+}
+
+func (m *AiPredictModelIndexConfig) ToView() AiPredictModelIndexConfigView {
+	var modifyTime, createTime string
+
+	if !m.CreateTime.IsZero() {
+		createTime = m.CreateTime.Format(utils.FormatDateTime)
+	}
+	if !m.ModifyTime.IsZero() {
+		modifyTime = m.ModifyTime.Format(utils.FormatDateTime)
+	}
+	return AiPredictModelIndexConfigView{
+		AiPredictModelIndexConfigId: m.AiPredictModelIndexConfigId,
+		AiPredictModelIndexId:       m.AiPredictModelIndexId,
+		TrainStatus:                 m.TrainStatus,
+		Params:                      m.Params,
+		TrainMse:                    m.TrainMse,
+		TrainR2:                     m.TrainR2,
+		TestMse:                     m.TestMse,
+		TestR2:                      m.TestR2,
+		Remark:                      m.Remark,
+		ModifyTime:                  modifyTime,
+		CreateTime:                  createTime,
+	}
+}
+
+func (m *AiPredictModelIndexConfig) ListToViewList(list []*AiPredictModelIndexConfig) (AiPredictModelIndexConfigViewList []AiPredictModelIndexConfigView) {
+	AiPredictModelIndexConfigViewList = make([]AiPredictModelIndexConfigView, 0)
+
+	for _, v := range list {
+		AiPredictModelIndexConfigViewList = append(AiPredictModelIndexConfigViewList, v.ToView())
+	}
+	return
+}
+
+func (m *AiPredictModelIndexConfig) Create() (err error) {
+	err = global.DbMap[utils.DbNameAI].Create(&m).Error
+
+	return
+}
+
+func (m *AiPredictModelIndexConfig) Update(updateCols []string) (err error) {
+	err = global.DbMap[utils.DbNameAI].Select(updateCols).Updates(&m).Error
+
+	return
+}
+
+func (m *AiPredictModelIndexConfig) GetById(id int) (item *AiPredictModelIndexConfig, err error) {
+	err = global.DbMap[utils.DbNameAI].Where(fmt.Sprintf("%s = ?", AiPredictModelIndexConfigColumns.AiPredictModelIndexConfigId), id).First(&item).Error
+
+	return
+}
+
+func (m *AiPredictModelIndexConfig) GetListByCondition(field, condition string, pars []interface{}, startSize, pageSize int) (items []*AiPredictModelIndexConfig, err error) {
+	if field == "" {
+		field = "*"
+	}
+	sqlStr := fmt.Sprintf(`SELECT %s FROM %s WHERE is_deleted=0 %s order by ai_predict_model_index_config_id desc LIMIT ?,?`, field, m.TableName(), condition)
+	pars = append(pars, startSize, pageSize)
+	err = global.DbMap[utils.DbNameAI].Raw(sqlStr, pars...).Find(&items).Error
+
+	return
+}
+
+func (m *AiPredictModelIndexConfig) GetCountByCondition(condition string, pars []interface{}) (total int, err error) {
+	var intNull sql.NullInt64
+	sqlStr := fmt.Sprintf(`SELECT COUNT(1) total FROM %s WHERE is_deleted=0 %s`, m.TableName(), condition)
+	err = global.DbMap[utils.DbNameAI].Raw(sqlStr, pars...).Scan(&intNull).Error
+	if err == nil && intNull.Valid {
+		total = int(intNull.Int64)
+	}
+
+	return
+}
+
+func (m *AiPredictModelIndexConfig) GetPageListByCondition(condition string, pars []interface{}, startSize, pageSize int) (total int, items []*AiPredictModelIndexConfig, err error) {
+
+	total, err = m.GetCountByCondition(condition, pars)
+	if err != nil {
+		return
+	}
+	if total > 0 {
+		items, err = m.GetListByCondition(``, condition, pars, startSize, pageSize)
+	}
+
+	return
+}

+ 6 - 0
models/ai_predict_model/request/index.go

@@ -0,0 +1,6 @@
+package request
+
+type AiPredictModelIndexSaveScriptPathReq struct {
+	IndexId    int    `description:"指标ID"`
+	ScriptPath string `description:"脚本的路径"`
+}

+ 5 - 0
models/ai_predict_model/request/index_config.go

@@ -0,0 +1,5 @@
+package request
+
+type DelConfigReq struct {
+	AiPredictModelIndexConfigId int `description:"配置id"`
+}

+ 11 - 0
models/ai_predict_model/response/index_config.go

@@ -0,0 +1,11 @@
+package response
+
+import (
+	data_manage "eta/eta_api/models/ai_predict_model"
+	"github.com/rdlucklib/rdluck_tools/paging"
+)
+
+type AiPredictModelIndexConfigListResp struct {
+	List   []data_manage.AiPredictModelIndexConfigView
+	Paging *paging.PagingItem `description:"分页数据"`
+}

+ 36 - 0
routers/commentsRouter.go

@@ -358,6 +358,33 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["eta/eta_api/controllers/data_manage/ai_predict_model:AiPredictModelIndexConfigController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers/data_manage/ai_predict_model:AiPredictModelIndexConfigController"],
+        beego.ControllerComments{
+            Method: "Del",
+            Router: `/index_config/del`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["eta/eta_api/controllers/data_manage/ai_predict_model:AiPredictModelIndexConfigController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers/data_manage/ai_predict_model:AiPredictModelIndexConfigController"],
+        beego.ControllerComments{
+            Method: "CurrVersion",
+            Router: `/index_config/detail`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["eta/eta_api/controllers/data_manage/ai_predict_model:AiPredictModelIndexConfigController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers/data_manage/ai_predict_model:AiPredictModelIndexConfigController"],
+        beego.ControllerComments{
+            Method: "List",
+            Router: `/index_config/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["eta/eta_api/controllers/data_manage/ai_predict_model:AiPredictModelIndexController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers/data_manage/ai_predict_model:AiPredictModelIndexController"],
         beego.ControllerComments{
             Method: "SearchByEs",
@@ -421,6 +448,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["eta/eta_api/controllers/data_manage/ai_predict_model:AiPredictModelIndexController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers/data_manage/ai_predict_model:AiPredictModelIndexController"],
+        beego.ControllerComments{
+            Method: "ScriptPathSave",
+            Router: `/index/script_path/save`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["eta/eta_api/controllers/data_manage/correlation:CorrelationChartClassifyController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers/data_manage/correlation:CorrelationChartClassifyController"],
         beego.ControllerComments{
             Method: "AddChartClassify",

+ 1 - 0
routers/router.go

@@ -453,6 +453,7 @@ func init() {
 				&ai_predict_model.AiPredictModelClassifyController{},
 				&ai_predict_model.AiPredictModelIndexController{},
 				&ai_predict_model.AiPredictModelFrameworkController{},
+				&ai_predict_model.AiPredictModelIndexConfigController{},
 			),
 		),
 		web.NSNamespace("/residual_analysis",