|
@@ -4,7 +4,7 @@ import (
|
|
"encoding/json"
|
|
"encoding/json"
|
|
"eta/eta_api/controllers"
|
|
"eta/eta_api/controllers"
|
|
"eta/eta_api/models"
|
|
"eta/eta_api/models"
|
|
- data_manage "eta/eta_api/models/ai_predict_model"
|
|
|
|
|
|
+ aiPredictModel "eta/eta_api/models/ai_predict_model"
|
|
"eta/eta_api/models/ai_predict_model/request"
|
|
"eta/eta_api/models/ai_predict_model/request"
|
|
"eta/eta_api/models/ai_predict_model/response"
|
|
"eta/eta_api/models/ai_predict_model/response"
|
|
"eta/eta_api/services"
|
|
"eta/eta_api/services"
|
|
@@ -25,7 +25,7 @@ type AiPredictModelIndexConfigController struct {
|
|
// @Param PageSize query int true "每页数据条数"
|
|
// @Param PageSize query int true "每页数据条数"
|
|
// @Param CurrentIndex query int true "当前页页码,从1开始"
|
|
// @Param CurrentIndex query int true "当前页页码,从1开始"
|
|
// @Param IndexId query int true "标的id"
|
|
// @Param IndexId query int true "标的id"
|
|
-// @Success 200 {object} []*data_manage.AiPredictModelIndexConfigView
|
|
|
|
|
|
+// @Success 200 {object} []*response.AiPredictModelIndexConfigListResp
|
|
// @router /index_config/list [get]
|
|
// @router /index_config/list [get]
|
|
func (c *AiPredictModelIndexConfigController) List() {
|
|
func (c *AiPredictModelIndexConfigController) List() {
|
|
br := new(models.BaseResponse).Init()
|
|
br := new(models.BaseResponse).Init()
|
|
@@ -60,15 +60,15 @@ func (c *AiPredictModelIndexConfigController) List() {
|
|
startSize = utils.StartIndex(currentIndex, pageSize)
|
|
startSize = utils.StartIndex(currentIndex, pageSize)
|
|
|
|
|
|
var total int
|
|
var total int
|
|
- viewList := make([]data_manage.AiPredictModelIndexConfigView, 0)
|
|
|
|
|
|
+ viewList := make([]aiPredictModel.AiPredictModelIndexConfigView, 0)
|
|
|
|
|
|
var condition string
|
|
var condition string
|
|
var pars []interface{}
|
|
var pars []interface{}
|
|
|
|
|
|
- condition += fmt.Sprintf(` AND %s = ? `, data_manage.AiPredictModelIndexConfigColumns.AiPredictModelIndexId)
|
|
|
|
|
|
+ condition += fmt.Sprintf(` AND %s = ? `, aiPredictModel.AiPredictModelIndexConfigColumns.AiPredictModelIndexId)
|
|
pars = append(pars, indexId)
|
|
pars = append(pars, indexId)
|
|
|
|
|
|
- obj := new(data_manage.AiPredictModelIndexConfig)
|
|
|
|
|
|
+ obj := new(aiPredictModel.AiPredictModelIndexConfig)
|
|
tmpTotal, list, err := obj.GetPageListByCondition(condition, pars, startSize, pageSize)
|
|
tmpTotal, list, err := obj.GetPageListByCondition(condition, pars, startSize, pageSize)
|
|
if err != nil {
|
|
if err != nil {
|
|
br.Msg = "获取失败"
|
|
br.Msg = "获取失败"
|
|
@@ -120,7 +120,7 @@ func (c *AiPredictModelIndexConfigController) CurrVersion() {
|
|
}
|
|
}
|
|
|
|
|
|
// 查询标的情况
|
|
// 查询标的情况
|
|
- indexOb := new(data_manage.AiPredictModelIndex)
|
|
|
|
|
|
+ indexOb := new(aiPredictModel.AiPredictModelIndex)
|
|
indexItem, e := indexOb.GetItemById(indexId)
|
|
indexItem, e := indexOb.GetItemById(indexId)
|
|
if e != nil {
|
|
if e != nil {
|
|
if utils.IsErrNoRow(e) {
|
|
if utils.IsErrNoRow(e) {
|
|
@@ -138,7 +138,7 @@ func (c *AiPredictModelIndexConfigController) CurrVersion() {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
- obj := new(data_manage.AiPredictModelIndexConfig)
|
|
|
|
|
|
+ obj := new(aiPredictModel.AiPredictModelIndexConfig)
|
|
configItem, err := obj.GetById(indexItem.AiPredictModelIndexConfigId)
|
|
configItem, err := obj.GetById(indexItem.AiPredictModelIndexConfigId)
|
|
if err != nil {
|
|
if err != nil {
|
|
br.Msg = "获取失败"
|
|
br.Msg = "获取失败"
|
|
@@ -176,7 +176,7 @@ func (c *AiPredictModelIndexConfigController) SetCurr() {
|
|
var req request.DelConfigReq
|
|
var req request.DelConfigReq
|
|
err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
|
|
err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
|
|
// 查找配置
|
|
// 查找配置
|
|
- obj := new(data_manage.AiPredictModelIndexConfig)
|
|
|
|
|
|
+ obj := new(aiPredictModel.AiPredictModelIndexConfig)
|
|
configItem, err := obj.GetById(req.AiPredictModelIndexConfigId)
|
|
configItem, err := obj.GetById(req.AiPredictModelIndexConfigId)
|
|
if err != nil {
|
|
if err != nil {
|
|
br.Msg = "修改失败"
|
|
br.Msg = "修改失败"
|
|
@@ -189,7 +189,7 @@ func (c *AiPredictModelIndexConfigController) SetCurr() {
|
|
}
|
|
}
|
|
|
|
|
|
// 查询标的情况
|
|
// 查询标的情况
|
|
- indexOb := new(data_manage.AiPredictModelIndex)
|
|
|
|
|
|
+ indexOb := new(aiPredictModel.AiPredictModelIndex)
|
|
indexItem, e := indexOb.GetItemById(configItem.AiPredictModelIndexId)
|
|
indexItem, e := indexOb.GetItemById(configItem.AiPredictModelIndexId)
|
|
if e != nil {
|
|
if e != nil {
|
|
br.Msg = "操作失败"
|
|
br.Msg = "操作失败"
|
|
@@ -237,7 +237,7 @@ func (c *AiPredictModelIndexConfigController) Del() {
|
|
}
|
|
}
|
|
|
|
|
|
// 查找配置
|
|
// 查找配置
|
|
- obj := new(data_manage.AiPredictModelIndexConfig)
|
|
|
|
|
|
+ obj := new(aiPredictModel.AiPredictModelIndexConfig)
|
|
item, err := obj.GetById(req.AiPredictModelIndexConfigId)
|
|
item, err := obj.GetById(req.AiPredictModelIndexConfigId)
|
|
if err != nil {
|
|
if err != nil {
|
|
br.Msg = "修改失败"
|
|
br.Msg = "修改失败"
|
|
@@ -252,7 +252,7 @@ func (c *AiPredictModelIndexConfigController) Del() {
|
|
// 查找是否被标的引用为默认模型
|
|
// 查找是否被标的引用为默认模型
|
|
{
|
|
{
|
|
// 查询标的情况
|
|
// 查询标的情况
|
|
- indexOb := new(data_manage.AiPredictModelIndex)
|
|
|
|
|
|
+ indexOb := new(aiPredictModel.AiPredictModelIndex)
|
|
count, e := indexOb.GetCountByCondition(fmt.Sprintf(` AND %s = ? `, indexOb.Cols().AiPredictModelIndexConfigId), []interface{}{item.AiPredictModelIndexConfigId})
|
|
count, e := indexOb.GetCountByCondition(fmt.Sprintf(` AND %s = ? `, indexOb.Cols().AiPredictModelIndexConfigId), []interface{}{item.AiPredictModelIndexConfigId})
|
|
if e != nil {
|
|
if e != nil {
|
|
br.Msg = "删除失败"
|
|
br.Msg = "删除失败"
|
|
@@ -267,7 +267,7 @@ func (c *AiPredictModelIndexConfigController) Del() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if !utils.InArrayByStr([]string{data_manage.TrainStatusSuccess, data_manage.TrainStatusFailed}, item.TrainStatus) {
|
|
|
|
|
|
+ if !utils.InArrayByStr([]string{aiPredictModel.TrainStatusSuccess, aiPredictModel.TrainStatusFailed}, item.TrainStatus) {
|
|
br.Msg = "删除失败,该版本配置正在训练中"
|
|
br.Msg = "删除失败,该版本配置正在训练中"
|
|
br.IsSendEmail = false
|
|
br.IsSendEmail = false
|
|
return
|
|
return
|
|
@@ -291,7 +291,7 @@ func (c *AiPredictModelIndexConfigController) Del() {
|
|
// @Title 获取当前版本的图表信息
|
|
// @Title 获取当前版本的图表信息
|
|
// @Description 获取当前版本的图表信息
|
|
// @Description 获取当前版本的图表信息
|
|
// @Param AiPredictModelIndexConfigId query int true "标的配置ID"
|
|
// @Param AiPredictModelIndexConfigId query int true "标的配置ID"
|
|
-// @Success 200 {object} []*data_manage.AiPredictModelIndexConfigView
|
|
|
|
|
|
+// @Success 200 {object} []*response.AiPredictModelDetailResp
|
|
// @router /index_config/chart/detail [get]
|
|
// @router /index_config/chart/detail [get]
|
|
func (c *AiPredictModelIndexConfigController) ChartDetail() {
|
|
func (c *AiPredictModelIndexConfigController) ChartDetail() {
|
|
br := new(models.BaseResponse).Init()
|
|
br := new(models.BaseResponse).Init()
|
|
@@ -318,7 +318,7 @@ func (c *AiPredictModelIndexConfigController) ChartDetail() {
|
|
// TODO 后面加上数据缓存
|
|
// TODO 后面加上数据缓存
|
|
|
|
|
|
// 查找配置
|
|
// 查找配置
|
|
- obj := new(data_manage.AiPredictModelIndexConfig)
|
|
|
|
|
|
+ obj := new(aiPredictModel.AiPredictModelIndexConfig)
|
|
configItem, err := obj.GetById(indexConfigId)
|
|
configItem, err := obj.GetById(indexConfigId)
|
|
if err != nil {
|
|
if err != nil {
|
|
br.Msg = "修改失败"
|
|
br.Msg = "修改失败"
|
|
@@ -332,7 +332,7 @@ func (c *AiPredictModelIndexConfigController) ChartDetail() {
|
|
|
|
|
|
// 查找是否被标的引用为默认模型
|
|
// 查找是否被标的引用为默认模型
|
|
// 查询标的情况
|
|
// 查询标的情况
|
|
- indexOb := new(data_manage.AiPredictModelIndex)
|
|
|
|
|
|
+ indexOb := new(aiPredictModel.AiPredictModelIndex)
|
|
indexItem, e := indexOb.GetItemByConfigId(configItem.AiPredictModelIndexConfigId)
|
|
indexItem, e := indexOb.GetItemByConfigId(configItem.AiPredictModelIndexConfigId)
|
|
if e != nil {
|
|
if e != nil {
|
|
br.Msg = "获取失败"
|
|
br.Msg = "获取失败"
|
|
@@ -341,13 +341,13 @@ func (c *AiPredictModelIndexConfigController) ChartDetail() {
|
|
}
|
|
}
|
|
|
|
|
|
// 获取标的数据
|
|
// 获取标的数据
|
|
- dailyData := make([]*data_manage.AiPredictModelIndexConfigTrainData, 0)
|
|
|
|
|
|
+ dailyData := make([]*aiPredictModel.AiPredictModelIndexConfigTrainData, 0)
|
|
{
|
|
{
|
|
- dataOb := new(data_manage.AiPredictModelIndexConfigTrainData)
|
|
|
|
- dataCond := fmt.Sprintf(` AND %s = ?`, data_manage.AiPredictModelIndexConfigTrainDataColumns.AiPredictModelIndexConfigId)
|
|
|
|
|
|
+ dataOb := new(aiPredictModel.AiPredictModelIndexConfigTrainData)
|
|
|
|
+ dataCond := fmt.Sprintf(` AND %s = ?`, aiPredictModel.AiPredictModelIndexConfigTrainDataColumns.AiPredictModelIndexConfigId)
|
|
dataPars := make([]interface{}, 0)
|
|
dataPars := make([]interface{}, 0)
|
|
dataPars = append(dataPars, configItem.AiPredictModelIndexConfigId)
|
|
dataPars = append(dataPars, configItem.AiPredictModelIndexConfigId)
|
|
- list, e := dataOb.GetAllListByCondition(dataCond, dataPars, []string{}, fmt.Sprintf("%s DESC", data_manage.AiPredictModelIndexConfigTrainDataColumns.DataTime))
|
|
|
|
|
|
+ list, e := dataOb.GetAllListByCondition(dataCond, dataPars, []string{}, fmt.Sprintf("%s DESC", aiPredictModel.AiPredictModelIndexConfigTrainDataColumns.DataTime))
|
|
if e != nil {
|
|
if e != nil {
|
|
br.Msg = "获取失败"
|
|
br.Msg = "获取失败"
|
|
br.ErrMsg = fmt.Sprintf("获取标的数据失败, %v", e)
|
|
br.ErrMsg = fmt.Sprintf("获取标的数据失败, %v", e)
|
|
@@ -356,7 +356,7 @@ func (c *AiPredictModelIndexConfigController) ChartDetail() {
|
|
|
|
|
|
for _, v := range list {
|
|
for _, v := range list {
|
|
// 日度数据
|
|
// 日度数据
|
|
- if v.Source == data_manage.ModelDataSourceDaily {
|
|
|
|
|
|
+ if v.Source == aiPredictModel.ModelDataSourceDaily {
|
|
dailyData = append(dailyData, v)
|
|
dailyData = append(dailyData, v)
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
@@ -365,7 +365,7 @@ func (c *AiPredictModelIndexConfigController) ChartDetail() {
|
|
|
|
|
|
// 日度图表
|
|
// 日度图表
|
|
if len(dailyData) > 0 {
|
|
if len(dailyData) > 0 {
|
|
- dailyChartDetail, e := services.GetAiPredictConfigChartDetailByData(indexItem.IndexName, configItem, dailyData, data_manage.ModelDataSourceDaily)
|
|
|
|
|
|
+ dailyChartDetail, e := services.GetAiPredictConfigChartDetailByData(indexItem.IndexName, configItem, dailyData, aiPredictModel.ModelDataSourceDaily)
|
|
if e != nil {
|
|
if e != nil {
|
|
br.Msg = "获取失败"
|
|
br.Msg = "获取失败"
|
|
br.ErrMsg = fmt.Sprintf("获取日度图表失败, %v", e)
|
|
br.ErrMsg = fmt.Sprintf("获取日度图表失败, %v", e)
|
|
@@ -413,7 +413,7 @@ func (c *AiPredictModelIndexConfigController) Train() {
|
|
}
|
|
}
|
|
|
|
|
|
// 查询标的情况
|
|
// 查询标的情况
|
|
- indexOb := new(data_manage.AiPredictModelIndex)
|
|
|
|
|
|
+ indexOb := new(aiPredictModel.AiPredictModelIndex)
|
|
indexItem, err := indexOb.GetItemById(req.IndexId)
|
|
indexItem, err := indexOb.GetItemById(req.IndexId)
|
|
if err != nil {
|
|
if err != nil {
|
|
br.Msg = "训练失败,查找标的失败"
|
|
br.Msg = "训练失败,查找标的失败"
|
|
@@ -430,7 +430,7 @@ func (c *AiPredictModelIndexConfigController) Train() {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
- obj := new(data_manage.AiPredictModelIndexConfig)
|
|
|
|
|
|
+ obj := new(aiPredictModel.AiPredictModelIndexConfig)
|
|
|
|
|
|
// 查找当前标的是否存在待训练/训练中的模型
|
|
// 查找当前标的是否存在待训练/训练中的模型
|
|
count, err := services.GetCurrentRunningAiPredictModelIndexCount()
|
|
count, err := services.GetCurrentRunningAiPredictModelIndexCount()
|
|
@@ -445,6 +445,8 @@ func (c *AiPredictModelIndexConfigController) Train() {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ var indexConfig *aiPredictModel.AiPredictModelIndexConfig
|
|
|
|
+
|
|
if req.AiPredictModelIndexConfigId > 0 {
|
|
if req.AiPredictModelIndexConfigId > 0 {
|
|
// 查找配置
|
|
// 查找配置
|
|
item, err := obj.GetById(req.AiPredictModelIndexConfigId)
|
|
item, err := obj.GetById(req.AiPredictModelIndexConfigId)
|
|
@@ -464,7 +466,7 @@ func (c *AiPredictModelIndexConfigController) Train() {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
- if item.TrainStatus != data_manage.TrainStatusFailed {
|
|
|
|
|
|
+ if item.TrainStatus != aiPredictModel.TrainStatusFailed {
|
|
br.Msg = "该模型训练状态异常,不允许重新训练"
|
|
br.Msg = "该模型训练状态异常,不允许重新训练"
|
|
br.ErrMsg = "该模型训练状态异常,不允许重新训练,当前状态:" + item.TrainStatus
|
|
br.ErrMsg = "该模型训练状态异常,不允许重新训练,当前状态:" + item.TrainStatus
|
|
br.IsSendEmail = false
|
|
br.IsSendEmail = false
|
|
@@ -479,12 +481,14 @@ func (c *AiPredictModelIndexConfigController) Train() {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ indexConfig = item
|
|
|
|
+
|
|
} else {
|
|
} else {
|
|
// 新增训练模型
|
|
// 新增训练模型
|
|
- item := &data_manage.AiPredictModelIndexConfig{
|
|
|
|
|
|
+ item := &aiPredictModel.AiPredictModelIndexConfig{
|
|
AiPredictModelIndexConfigId: 0,
|
|
AiPredictModelIndexConfigId: 0,
|
|
AiPredictModelIndexId: indexItem.AiPredictModelIndexId,
|
|
AiPredictModelIndexId: indexItem.AiPredictModelIndexId,
|
|
- TrainStatus: data_manage.TrainStatusWaiting,
|
|
|
|
|
|
+ TrainStatus: aiPredictModel.TrainStatusWaiting,
|
|
Params: string(paramsStrByte),
|
|
Params: string(paramsStrByte),
|
|
TrainMse: "",
|
|
TrainMse: "",
|
|
TrainR2: "",
|
|
TrainR2: "",
|
|
@@ -503,9 +507,11 @@ func (c *AiPredictModelIndexConfigController) Train() {
|
|
br.ErrMsg = "训练失败,Err:" + err.Error()
|
|
br.ErrMsg = "训练失败,Err:" + err.Error()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ indexConfig = item
|
|
}
|
|
}
|
|
|
|
|
|
- indexItem.TrainStatus = data_manage.TrainStatusWaiting
|
|
|
|
|
|
+ indexItem.TrainStatus = aiPredictModel.TrainStatusWaiting
|
|
indexItem.ModifyTime = time.Now()
|
|
indexItem.ModifyTime = time.Now()
|
|
err = indexItem.Update([]string{"train_status", "modify_time"})
|
|
err = indexItem.Update([]string{"train_status", "modify_time"})
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -513,7 +519,9 @@ func (c *AiPredictModelIndexConfigController) Train() {
|
|
br.ErrMsg = "训练失败,Err:" + err.Error()
|
|
br.ErrMsg = "训练失败,Err:" + err.Error()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- // TODO 加入训练任务中
|
|
|
|
|
|
+
|
|
|
|
+ // 加入模型训练任务中
|
|
|
|
+ go services.AddAiModelTrainTask(indexItem, indexConfig, c.SysUser)
|
|
|
|
|
|
br.Ret = 200
|
|
br.Ret = 200
|
|
br.Success = true
|
|
br.Success = true
|