|
@@ -663,9 +663,6 @@ func DelRagReportLlmDoc(vectorKeyList []string, abstractIdList []int) (err error
|
|
|
// @param abstractIdList []int
|
|
|
// @return err error
|
|
|
func DelRagEtaReportAbstract(abstractIdList []int) (err error) {
|
|
|
- vectorKeyList := make([]string, 0)
|
|
|
- newAbstractIdList := make([]int, 0)
|
|
|
-
|
|
|
obj := rag.RagEtaReportAbstract{}
|
|
|
|
|
|
list, err := obj.GetByIdList(abstractIdList)
|
|
@@ -677,6 +674,48 @@ func DelRagEtaReportAbstract(abstractIdList []int) (err error) {
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+ err = delRagEtaReportAbstract(list)
|
|
|
+
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// DelRagEtaReportAbstractByQuestionId
|
|
|
+// @Description: 根据提示词ID删除ETA报告摘要
|
|
|
+// @author: Roc
|
|
|
+// @datetime 2025-04-23 17:36:22
|
|
|
+// @param abstractIdList []int
|
|
|
+// @return err error
|
|
|
+func DelRagEtaReportAbstractByQuestionId(questionId int) (err error) {
|
|
|
+ obj := rag.RagEtaReportAbstract{}
|
|
|
+
|
|
|
+ list, err := obj.GetListByQuestionId(questionId)
|
|
|
+ if err != nil {
|
|
|
+ if !utils.IsErrNoRow(err) {
|
|
|
+ err = errors.New("删除向量库失败,Err:" + err.Error())
|
|
|
+ } else {
|
|
|
+ err = nil
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ err = delRagEtaReportAbstract(list)
|
|
|
+
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// delRagEtaReportAbstract
|
|
|
+// @Description: 删除摘要
|
|
|
+// @author: Roc
|
|
|
+// @datetime 2025-04-24 15:19:19
|
|
|
+// @param list []*rag.RagEtaReportAbstract
|
|
|
+// @return err error
|
|
|
+func delRagEtaReportAbstract(list []*rag.RagEtaReportAbstract) (err error) {
|
|
|
+ obj := rag.RagEtaReportAbstract{}
|
|
|
+
|
|
|
+ vectorKeyList := make([]string, 0)
|
|
|
+ newAbstractIdList := make([]int, 0)
|
|
|
+
|
|
|
if len(list) > 0 {
|
|
|
for _, v := range list {
|
|
|
// 有加入到向量库,那么就加入到待删除的向量库list中
|
|
@@ -686,57 +725,6 @@ func DelRagEtaReportAbstract(abstractIdList []int) (err error) {
|
|
|
newAbstractIdList = append(newAbstractIdList, v.RagEtaReportAbstractId)
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- //if !req.IsSelectAll {
|
|
|
- // list, err := obj.GetByIdList(req.RagEtaReportAbstractIdList)
|
|
|
- // if err != nil {
|
|
|
- // br.Msg = "修改失败"
|
|
|
- // br.ErrMsg = "修改失败,查找问题失败,Err:" + err.Error()
|
|
|
- // if utils.IsErrNoRow(err) {
|
|
|
- // br.Msg = "问题不存在"
|
|
|
- // br.IsSendEmail = false
|
|
|
- // }
|
|
|
- // return
|
|
|
- // }
|
|
|
- // if len(list) > 0 {
|
|
|
- // for _, v := range list {
|
|
|
- // // 有加入到向量库,那么就加入到待删除的向量库list中
|
|
|
- // if v.VectorKey != `` {
|
|
|
- // vectorKeyList = append(vectorKeyList, v.VectorKey)
|
|
|
- // }
|
|
|
- // wechatArticleAbstractIdList = append(wechatArticleAbstractIdList, v.RagEtaReportAbstractId)
|
|
|
- // }
|
|
|
- // }
|
|
|
- //} else {
|
|
|
- // notIdMap := make(map[int]bool)
|
|
|
- // for _, v := range req.NotRagEtaReportAbstractIdList {
|
|
|
- // notIdMap[v] = true
|
|
|
- // }
|
|
|
- //
|
|
|
- // _, list, err := getRagEtaReportAbstractList(req.KeyWord, req.TagId, 0, 100000)
|
|
|
- // if err != nil {
|
|
|
- // br.Msg = "修改失败"
|
|
|
- // br.ErrMsg = "修改失败,查找问题失败,Err:" + err.Error()
|
|
|
- // if utils.IsErrNoRow(err) {
|
|
|
- // br.Msg = "问题不存在"
|
|
|
- // br.IsSendEmail = false
|
|
|
- // }
|
|
|
- // return
|
|
|
- // }
|
|
|
- // if len(list) > 0 {
|
|
|
- // for _, v := range list {
|
|
|
- // if notIdMap[v.RagEtaReportAbstractId] {
|
|
|
- // continue
|
|
|
- // }
|
|
|
- // // 有加入到向量库,那么就加入到待删除的向量库list中
|
|
|
- // if v.VectorKey != `` {
|
|
|
- // vectorKeyList = append(vectorKeyList, v.VectorKey)
|
|
|
- // }
|
|
|
- // wechatArticleAbstractIdList = append(wechatArticleAbstractIdList, v.RagEtaReportAbstractId)
|
|
|
- // }
|
|
|
- // }
|
|
|
- //}
|
|
|
-
|
|
|
// 删除向量库
|
|
|
err = DelRagReportLlmDoc(vectorKeyList, newAbstractIdList)
|
|
|
if err != nil {
|
|
@@ -758,3 +746,46 @@ func DelRagEtaReportAbstract(abstractIdList []int) (err error) {
|
|
|
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+// GetDelAbstractByQuestionIdCacheKey
|
|
|
+// @Description: 获取删除微信文章/ETA报告摘要的缓存key
|
|
|
+// @author: Roc
|
|
|
+// @datetime 2025-04-24 15:44:41
|
|
|
+// @param questionId int
|
|
|
+// @return string
|
|
|
+func GetDelAbstractByQuestionIdCacheKey(questionId int) string {
|
|
|
+ return fmt.Sprintf("%s%d", utils.CACHE_AI_ARTICLE_ABSTRACT_DEL, questionId)
|
|
|
+}
|
|
|
+
|
|
|
+// DelAbstractByQuestionId
|
|
|
+// @Description: 根据提示词ID删除微信文章/报告摘要
|
|
|
+// @author: Roc
|
|
|
+// @datetime 2025-04-24 15:37:28
|
|
|
+// @param questionId int
|
|
|
+func DelAbstractByQuestionId(questionId int) {
|
|
|
+ cacheKey := GetDelAbstractByQuestionIdCacheKey(questionId)
|
|
|
+ if !utils.Rc.SetNX(cacheKey, 1, 30*time.Minute) {
|
|
|
+ utils.FileLog.Error("根据提示词删除摘要失败,提示词ID:%d,系统处理中,请稍后重试!", questionId)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ defer func() {
|
|
|
+ utils.Rc.Delete(cacheKey)
|
|
|
+ }()
|
|
|
+
|
|
|
+ // 删除微信文章摘要
|
|
|
+ err := DelWechatArticleAbstractByQuestionId(questionId)
|
|
|
+ if err != nil {
|
|
|
+ utils.FileLog.Error("根据提示词摘要删除微信文章摘要失败,提示词ID:%d;原因:%s", questionId, err.Error())
|
|
|
+ }
|
|
|
+
|
|
|
+ // 删除ETA报告摘要
|
|
|
+ err = DelRagEtaReportAbstractByQuestionId(questionId)
|
|
|
+ if err != nil {
|
|
|
+ utils.FileLog.Error("根据提示词删除ETA报告摘要失败,提示词ID:%d;原因:%s", questionId, err.Error())
|
|
|
+ }
|
|
|
+
|
|
|
+ //time.Sleep(30 * time.Second)
|
|
|
+
|
|
|
+ return
|
|
|
+}
|