Roc 3 tygodni temu
rodzic
commit
3c2a196c63

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

@@ -1368,7 +1368,7 @@ func (this *AiPredictModelIndexController) Run() {
 	}
 
 	// 获取列表
-	list, e := indexOb.GetItemsByCondition(cond, pars, []string{`ai_predict_model_index_id,script_path`}, "")
+	list, e := indexOb.GetItemsByCondition(cond, pars, []string{`ai_predict_model_index_id,ai_predict_model_index_config_id,script_path`}, "")
 	if e != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = fmt.Sprintf("获取列表失败, %v", e)
@@ -1407,7 +1407,7 @@ func (this *AiPredictModelIndexController) Run() {
 	br.Data = indexIdList
 	br.Ret = 200
 	br.Success = true
-	br.Msg = "获取成功"
+	br.Msg = "运行成功"
 }
 
 // getAllSearchDataSource
@@ -1462,3 +1462,7 @@ func getAllSearchDataSource(keyword string, source, subSource int) (list []*data
 
 	return
 }
+
+//func init() {
+//	services.AddIndexTaskToCache(1, `ai_predict_model_run`)
+//}

+ 8 - 8
models/data_manage/index_task.go

@@ -68,32 +68,32 @@ var IndexTaskColumns = struct {
 }
 
 func (m *IndexTask) Create() (err error) {
-	err = global.DbMap[utils.DbNameAI].Create(&m).Error
+	err = global.DbMap[utils.DbNameIndex].Create(&m).Error
 
 	return
 }
 
 func (m *IndexTask) Update(updateCols []string) (err error) {
-	err = global.DbMap[utils.DbNameAI].Select(updateCols).Updates(&m).Error
+	err = global.DbMap[utils.DbNameIndex].Select(updateCols).Updates(&m).Error
 
 	return
 }
 
 func (m *IndexTask) Del() (err error) {
-	err = global.DbMap[utils.DbNameAI].Delete(&m).Error
+	err = global.DbMap[utils.DbNameIndex].Delete(&m).Error
 
 	return
 }
 
 func (m *IndexTask) GetByID(id int) (item *IndexTask, err error) {
-	err = global.DbMap[utils.DbNameAI].Where(fmt.Sprintf("%s = ?", IndexTaskColumns.IndexTaskID), id).First(&item).Error
+	err = global.DbMap[utils.DbNameIndex].Where(fmt.Sprintf("%s = ?", IndexTaskColumns.IndexTaskID), id).First(&item).Error
 
 	return
 }
 
 func (m *IndexTask) GetByCondition(condition string, pars []interface{}) (item *IndexTask, err error) {
 	sqlStr := fmt.Sprintf(`SELECT * FROM %s WHERE 1=1 %s`, m.TableName(), condition)
-	err = global.DbMap[utils.DbNameAI].Raw(sqlStr, pars...).First(&item).Error
+	err = global.DbMap[utils.DbNameIndex].Raw(sqlStr, pars...).First(&item).Error
 
 	return
 }
@@ -104,7 +104,7 @@ func (m *IndexTask) GetListByCondition(field, condition string, pars []interface
 	}
 	sqlStr := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s order by index_task_id desc LIMIT ?,?`, field, m.TableName(), condition)
 	pars = append(pars, startSize, pageSize)
-	err = global.DbMap[utils.DbNameAI].Raw(sqlStr, pars...).Find(&items).Error
+	err = global.DbMap[utils.DbNameIndex].Raw(sqlStr, pars...).Find(&items).Error
 
 	return
 }
@@ -112,7 +112,7 @@ func (m *IndexTask) GetListByCondition(field, condition string, pars []interface
 func (m *IndexTask) GetCountByCondition(condition string, pars []interface{}) (total int, err error) {
 	var intNull sql.NullInt64
 	sqlStr := fmt.Sprintf(`SELECT COUNT(1) total FROM %s WHERE 1=1 %s`, m.TableName(), condition)
-	err = global.DbMap[utils.DbNameAI].Raw(sqlStr, pars...).Scan(&intNull).Error
+	err = global.DbMap[utils.DbNameIndex].Raw(sqlStr, pars...).Scan(&intNull).Error
 	if err == nil && intNull.Valid {
 		total = int(intNull.Int64)
 	}
@@ -128,7 +128,7 @@ func (m *IndexTask) GetCountByCondition(condition string, pars []interface{}) (t
 // @param indexRecordList []*IndexTaskRecord
 // @return err error
 func AddIndexTask(indexTask *IndexTask, indexRecordList []*IndexTaskRecord) (err error) {
-	to := global.DbMap[utils.DbNameAI].Begin()
+	to := global.DbMap[utils.DbNameIndex].Begin()
 	defer func() {
 		if err != nil {
 			_ = to.Rollback()

+ 8 - 8
models/data_manage/index_task_record.go

@@ -44,32 +44,32 @@ var IndexTaskRecordColumns = struct {
 }
 
 func (m *IndexTaskRecord) Create() (err error) {
-	err = global.DbMap[utils.DbNameAI].Create(&m).Error
+	err = global.DbMap[utils.DbNameIndex].Create(&m).Error
 
 	return
 }
 
 func (m *IndexTaskRecord) Update(updateCols []string) (err error) {
-	err = global.DbMap[utils.DbNameAI].Select(updateCols).Updates(&m).Error
+	err = global.DbMap[utils.DbNameIndex].Select(updateCols).Updates(&m).Error
 
 	return
 }
 
 func (m *IndexTaskRecord) Del() (err error) {
-	err = global.DbMap[utils.DbNameAI].Delete(&m).Error
+	err = global.DbMap[utils.DbNameIndex].Delete(&m).Error
 
 	return
 }
 
 func (m *IndexTaskRecord) GetByID(id int) (item *IndexTaskRecord, err error) {
-	err = global.DbMap[utils.DbNameAI].Where(fmt.Sprintf("%s = ?", IndexTaskRecordColumns.IndexTaskRecordID), id).First(&item).Error
+	err = global.DbMap[utils.DbNameIndex].Where(fmt.Sprintf("%s = ?", IndexTaskRecordColumns.IndexTaskRecordID), id).First(&item).Error
 
 	return
 }
 
 func (m *IndexTaskRecord) GetByCondition(condition string, pars []interface{}) (item *IndexTaskRecord, err error) {
 	sqlStr := fmt.Sprintf(`SELECT * FROM %s WHERE 1=1 %s`, m.TableName(), condition)
-	err = global.DbMap[utils.DbNameAI].Raw(sqlStr, pars...).First(&item).Error
+	err = global.DbMap[utils.DbNameIndex].Raw(sqlStr, pars...).First(&item).Error
 
 	return
 }
@@ -79,7 +79,7 @@ func (m *IndexTaskRecord) GetAllListByCondition(field, condition string, pars []
 		field = "*"
 	}
 	sqlStr := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s order by index_task_record_id desc `, field, m.TableName(), condition)
-	err = global.DbMap[utils.DbNameAI].Raw(sqlStr, pars...).Find(&items).Error
+	err = global.DbMap[utils.DbNameIndex].Raw(sqlStr, pars...).Find(&items).Error
 
 	return
 }
@@ -90,7 +90,7 @@ func (m *IndexTaskRecord) GetListByCondition(field, condition string, pars []int
 	}
 	sqlStr := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s order by index_task_record_id desc LIMIT ?,?`, field, m.TableName(), condition)
 	pars = append(pars, startSize, pageSize)
-	err = global.DbMap[utils.DbNameAI].Raw(sqlStr, pars...).Find(&items).Error
+	err = global.DbMap[utils.DbNameIndex].Raw(sqlStr, pars...).Find(&items).Error
 
 	return
 }
@@ -98,7 +98,7 @@ func (m *IndexTaskRecord) GetListByCondition(field, condition string, pars []int
 func (m *IndexTaskRecord) GetCountByCondition(condition string, pars []interface{}) (total int, err error) {
 	var intNull sql.NullInt64
 	sqlStr := fmt.Sprintf(`SELECT COUNT(1) total FROM %s WHERE 1=1 %s`, m.TableName(), condition)
-	err = global.DbMap[utils.DbNameAI].Raw(sqlStr, pars...).Scan(&intNull).Error
+	err = global.DbMap[utils.DbNameIndex].Raw(sqlStr, pars...).Scan(&intNull).Error
 	if err == nil && intNull.Valid {
 		total = int(intNull.Int64)
 	}

+ 4 - 0
services/ai_predict_model_index_config.go

@@ -151,3 +151,7 @@ func addIndexTaskToCache(indexTaskId int, taskType string) {
 		cache.AddIndexTaskRecordOpToCache(item.IndexTaskRecordID, taskType)
 	}
 }
+
+func AddIndexTaskToCache(indexTaskId int, taskType string) {
+	addIndexTaskToCache(indexTaskId, taskType)
+}