Roc 1 年之前
父节点
当前提交
b351280a29

+ 0 - 334
controllers/ai/ai.go

@@ -1,334 +0,0 @@
-package ai
-
-import (
-	"encoding/json"
-	"fmt"
-	"hongze/hz_eta_api/controllers"
-	"hongze/hz_eta_api/models"
-	"hongze/hz_eta_api/models/aimod"
-	"hongze/hz_eta_api/services/aiser"
-	"hongze/hz_eta_api/utils"
-	"strconv"
-	"time"
-)
-
-// AI
-type AiController struct {
-	controllers.BaseAuthController
-}
-
-// @Title 聊天接口
-// @Description 聊天接口
-// @Param	request	body aimod.ChatReq true "type json string"
-// @Success 200 {object} response.ListResp
-// @router /chat [post]
-func (this *AiController) List() {
-	br := new(models.BaseResponse).Init()
-	defer func() {
-		this.Data["json"] = br
-		this.ServeJSON()
-	}()
-
-	var req aimod.ChatReq
-	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
-	if err != nil {
-		br.Msg = "参数解析异常!"
-		br.ErrMsg = "参数解析失败,Err:" + err.Error()
-		return
-	}
-
-	if req.Model == "" {
-		br.Msg = "请选择模型!"
-		br.ErrMsg = "请选择模型!"
-		return
-	}
-
-	if req.Ask == "" {
-		br.Msg = "请输入提问内容!"
-		br.ErrMsg = "请输入提问内容"
-		return
-	}
-
-	if utils.Re == nil {
-		key := "CACHE_CHAT_" + strconv.Itoa(this.SysUser.AdminId)
-		cacheVal, err := utils.Rc.RedisInt(key)
-		fmt.Println("RedisString:", cacheVal, "err:", err)
-		if err != nil && err.Error() != "redigo: nil returned" {
-			br.Msg = "获取数据失败!"
-			br.ErrMsg = "获取数据失败,Err:" + err.Error()
-			return
-		}
-		putVal := 0
-		if cacheVal <= 0 {
-			putVal = utils.AiChatLimit
-		} else {
-			putVal = cacheVal - 1
-		}
-
-		if putVal <= 0 {
-			br.Msg = "您今日50次问答已达上限,请明天再来!"
-			br.ErrMsg = "您今日50次问答已达上限,请明天再来!"
-			return
-		}
-		lastSecond := utils.GetTodayLastSecond()
-		utils.Rc.Put(key, putVal, lastSecond)
-	}
-
-	//根据提问,获取信息
-	askUuid := utils.MD5(req.Ask)
-	chatMode, err := aimod.GetAiChatByAsk(askUuid, req.Model)
-	if err != nil && err.Error() != utils.ErrNoRow() {
-		br.Msg = "获取数据失败!"
-		br.ErrMsg = "获取数据失败,GetAiChatByAsk,Err:" + err.Error()
-		return
-	}
-	resp := new(aimod.ChatResp)
-	var answer string
-	//answerArr := []string{
-	//	"周度数据显示,成品油现货市场价格跟随原油下跌,但近期相对抗跌,裂解价差走扩。批零价差方面汽油收窄,柴油走扩",
-	//	"出口利润在原油下跌海外成品油矛盾更大的情况下汽柴油出口窗口完全关闭",
-	//	"汽油需求在经历五一假期的一段高峰后将回归平稳,总体没有明显矛盾,后期我们担心更多的还是柴油。"}
-	if chatMode != nil && chatMode.Answer != "" {
-		answer = chatMode.Answer
-	} else {
-		//rnd := utils.GetRandInt(0, 3)
-		//if rnd >= 3 {
-		//	rnd = 2
-		//}
-		//answer = answerArr[rnd]
-		var model int
-		if req.Model == "gpt-3.5-turbo" {
-			model = 1
-		} else if req.Model == "gpt-3.5-turbo-16k" {
-			model = 3
-		} else {
-			model = 2
-		}
-		answer, _ = aiser.ChatAutoMsg(req.Ask, model)
-	}
-	resp.Ask = req.Ask
-	resp.Answer = answer
-
-	if req.AiChatTopicId <= 0 { //新增
-		topic := new(aimod.AiChatTopic)
-		topic.TopicName = req.Ask
-		topic.SysUserId = this.SysUser.AdminId
-		topic.SysUserRealName = this.SysUser.RealName
-		topic.CreateTime = time.Now()
-		topic.ModifyTime = time.Now()
-		topicId, err := aimod.AddAiChatTopic(topic)
-		if err != nil {
-			br.Msg = "获取数据失败!"
-			br.ErrMsg = "生成话题失败,Err:" + err.Error()
-			return
-		}
-		resp.AiChatTopicId = int(topicId)
-		chatItem := new(aimod.AiChat)
-		chatItem.AiChatTopicId = resp.AiChatTopicId
-		chatItem.Ask = req.Ask
-		chatItem.AskUuid = utils.MD5(req.Ask)
-		chatItem.Answer = answer
-		chatItem.Model = req.Model
-		chatItem.SysUserId = this.SysUser.AdminId
-		chatItem.SysUserRealName = this.SysUser.RealName
-		chatItem.CreateTime = time.Now()
-		chatItem.ModifyTime = time.Now()
-		_, err = aimod.AddAiChat(chatItem)
-		if err != nil {
-			br.Msg = "获取数据失败!"
-			br.ErrMsg = "生成话题记录失败,Err:" + err.Error()
-			return
-		}
-	} else {
-		resp.AiChatTopicId = req.AiChatTopicId
-		chatItem := new(aimod.AiChat)
-		chatItem.AiChatTopicId = resp.AiChatTopicId
-		chatItem.Ask = req.Ask
-		chatItem.AskUuid = utils.MD5(req.Ask)
-		chatItem.Answer = answer
-		chatItem.Model = req.Model
-		chatItem.SysUserId = this.SysUser.AdminId
-		chatItem.SysUserRealName = this.SysUser.RealName
-		chatItem.CreateTime = time.Now()
-		chatItem.ModifyTime = time.Now()
-		_, err = aimod.AddAiChat(chatItem)
-		if err != nil {
-			br.Msg = "获取数据失败!"
-			br.ErrMsg = "生成话题记录失败,Err:" + err.Error()
-			return
-		}
-	}
-	resp.Model = req.Model
-	br.Ret = 200
-	br.Success = true
-	br.Msg = "获取成功"
-	br.Data = resp
-}
-
-// @Title 获取话题列表
-// @Description 获取话题列表接口
-// @Success 200 {object} aimod.AiChatTopicListResp
-// @router /topic/list [get]
-func (this *AiController) TopicList() {
-	br := new(models.BaseResponse).Init()
-	defer func() {
-		this.Data["json"] = br
-		this.ServeJSON()
-	}()
-
-	sysUser := this.SysUser
-	if sysUser == nil {
-		br.Msg = "请登录"
-		br.ErrMsg = "请登录,SysUser Is Empty"
-		br.Ret = 408
-		return
-	}
-	list, err := aimod.GetAiChatTopicList(sysUser.AdminId)
-	if err != nil {
-		br.Msg = "获取数据失败!"
-		br.ErrMsg = "获取主题记录信息失败,Err:" + err.Error()
-		return
-	}
-	resp := new(aimod.AiChatTopicListResp)
-	resp.List = list
-	br.Ret = 200
-	br.Success = true
-	br.Msg = "获取成功"
-	br.Data = resp
-}
-
-// @Title 获取话题详情
-// @Description 获取话题详情接口
-// @Param   AiChatTopicId   query   int  true       "主题id"
-// @Success 200 {object} aimod.AiChatDetailResp
-// @router /topic/detail [get]
-func (this *AiController) TopicDetail() {
-	br := new(models.BaseResponse).Init()
-	defer func() {
-		this.Data["json"] = br
-		this.ServeJSON()
-	}()
-
-	sysUser := this.SysUser
-	if sysUser == nil {
-		br.Msg = "请登录"
-		br.ErrMsg = "请登录,SysUser Is Empty"
-		br.Ret = 408
-		return
-	}
-
-	aiChatTopicId, _ := this.GetInt("AiChatTopicId")
-	list, err := aimod.GetAiChatList(aiChatTopicId)
-	if err != nil {
-		br.Msg = "获取数据失败!"
-		br.ErrMsg = "获取主题记录信息失败,Err:" + err.Error()
-		return
-	}
-	resp := new(aimod.AiChatDetailResp)
-	resp.List = list
-	br.Ret = 200
-	br.Success = true
-	br.Msg = "获取成功"
-	br.Data = resp
-}
-
-// @Title 删除话题接口
-// @Description 删除话题接口
-// @Param	request	body aimod.TopicDeleteReq true "type json string"
-// @Success Ret=200 删除成功
-// @router /topic/delete [post]
-func (this *AiController) TopicDelete() {
-	br := new(models.BaseResponse).Init()
-	defer func() {
-		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 aimod.TopicDeleteReq
-	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
-	if err != nil {
-		br.Msg = "参数解析异常!"
-		br.ErrMsg = "参数解析失败,Err:" + err.Error()
-		return
-	}
-
-	if req.AiChatTopicId <= 0 {
-		br.Msg = "参数错误!"
-		br.ErrMsg = "参数错误!AiChatTopicId:" + strconv.Itoa(req.AiChatTopicId)
-		return
-	}
-	err = aimod.DeleteTopic(req.AiChatTopicId)
-	if err != nil {
-		br.Msg = "删除失败!"
-		br.ErrMsg = "删除失败,Err:" + err.Error()
-		return
-	}
-	br.Ret = 200
-	br.Success = true
-	br.Msg = "删除成功"
-	br.IsAddLog = true
-}
-
-// @Title 编辑话题接口
-// @Description 编辑话题接口
-// @Param	request	body aimod.TopicEditReq true "type json string"
-// @Success Ret=200 编辑成功
-// @router /topic/edit [post]
-func (this *AiController) TopicEdit() {
-	br := new(models.BaseResponse).Init()
-	defer func() {
-		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 aimod.TopicEditReq
-	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
-	if err != nil {
-		br.Msg = "参数解析异常!"
-		br.ErrMsg = "参数解析失败,Err:" + err.Error()
-		return
-	}
-
-	if req.AiChatTopicId <= 0 {
-		br.Msg = "参数错误!"
-		br.ErrMsg = "参数错误!AiChatTopicId:" + strconv.Itoa(req.AiChatTopicId)
-		return
-	}
-	topic, err := aimod.GetAiChatTopicByTopicName(req.TopicName)
-	if err != nil && err.Error() != utils.ErrNoRow() {
-		br.Msg = "编辑失败!"
-		br.ErrMsg = "获取数据失败!Err:" + err.Error()
-		return
-	}
-	if topic != nil && topic.AiChatTopicId != req.AiChatTopicId {
-		br.Msg = "话题名称已存在,请重新修改!"
-		return
-	}
-
-	err = aimod.EditTopic(req.AiChatTopicId, req.TopicName)
-	if err != nil {
-		br.Msg = "编辑失败!"
-		br.ErrMsg = "编辑失败,Err:" + err.Error()
-		return
-	}
-	br.Ret = 200
-	br.Success = true
-	br.Msg = "编辑成功"
-	br.IsAddLog = true
-}

+ 0 - 147
models/aimod/ai.go

@@ -1,147 +0,0 @@
-package aimod
-
-import (
-	"github.com/beego/beego/v2/client/orm"
-	"time"
-)
-
-type AiChatTopic struct {
-	AiChatTopicId   int `orm:"column(ai_chat_topic_id);pk"`
-	TopicName       string
-	SysUserId       int
-	SysUserRealName string
-	CreateTime      time.Time
-	ModifyTime      time.Time
-}
-
-type AiChat struct {
-	AiChatId        int `orm:"column(ai_chat_id);pk"`
-	AiChatTopicId   int
-	Ask             string
-	AskUuid         string
-	Answer          string
-	Model           string
-	SysUserId       int
-	SysUserRealName string
-	CreateTime      time.Time
-	ModifyTime      time.Time
-}
-
-type ChatReq struct {
-	AiChatTopicId int    `description:"主题id"`
-	Model         string `description:"模型:gpt-3.5-turbo,eta,gpt-3.5-turbo-16k"`
-	Ask           string `description:"提问"`
-}
-
-func GetAiChatByAsk(askUuid, model string) (item *AiChat, err error) {
-	sql := `SELECT * FROM ai_chat WHERE ask_uuid=? AND model =? `
-	o := orm.NewOrmUsingDB("weekly")
-	err = o.Raw(sql, askUuid, model).QueryRow(&item)
-	return
-}
-
-type ChatResp struct {
-	AiChatTopicId int    `description:"主题id"`
-	Ask           string `description:"提问"`
-	Answer        string `description:"回答"`
-	Model         string
-}
-
-// AddAiChatTopic 新增主题
-func AddAiChatTopic(item *AiChatTopic) (lastId int64, err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	lastId, err = o.Insert(item)
-	return
-}
-
-// AddAiChat 新增聊天
-func AddAiChat(item *AiChat) (lastId int64, err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	lastId, err = o.Insert(item)
-	return
-}
-
-type AiChatTopicView struct {
-	AiChatTopicId int    `description:"主题id"`
-	TopicName     string `description:"主题名称"`
-	CreateTime    string `description:"创建时间"`
-	ModifyTime    string `description:"修改时间"`
-}
-
-func GetAiChatTopicList(sysUserId int) (item []*AiChatTopicView, err error) {
-	sql := ` SELECT * FROM ai_chat_topic WHERE sys_user_id=? ORDER BY create_time DESC `
-	o := orm.NewOrmUsingDB("weekly")
-	_, err = o.Raw(sql, sysUserId).QueryRows(&item)
-	return
-}
-
-type AiChatTopicListResp struct {
-	List []*AiChatTopicView
-}
-
-type AiChatView struct {
-	AiChatId      int    `description:"记录id"`
-	AiChatTopicId int    `description:"主题id"`
-	Ask           string `description:"提问"`
-	Answer        string `description:"答案"`
-	Model         string
-	CreateTime    string `description:"创建时间"`
-	ModifyTime    string `description:"修改时间"`
-}
-
-func GetAiChatList(aiChatTopicId int) (item []*AiChatView, err error) {
-	sql := ` SELECT * FROM ai_chat WHERE ai_chat_topic_id=? ORDER BY create_time ASC `
-	o := orm.NewOrmUsingDB("weekly")
-	_, err = o.Raw(sql, aiChatTopicId).QueryRows(&item)
-	return
-}
-
-type AiChatDetailResp struct {
-	List []*AiChatView
-}
-
-type TopicDeleteReq struct {
-	AiChatTopicId int `description:"主题id"`
-}
-
-func DeleteTopic(topicId int) (err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	tx, err := o.Begin()
-	defer func() {
-		if err != nil {
-			tx.Rollback()
-		} else {
-			tx.Commit()
-		}
-	}()
-	sql := ` DELETE FROM ai_chat_topic WHERE  ai_chat_topic_id=? `
-	_, err = tx.Raw(sql, topicId).Exec()
-	if err != nil {
-		return err
-	}
-	sql = ` DELETE FROM ai_chat WHERE  ai_chat_topic_id=? `
-	_, err = tx.Raw(sql, topicId).Exec()
-	if err != nil {
-		return err
-	}
-	return err
-}
-
-type TopicEditReq struct {
-	AiChatTopicId int    `description:"主题id"`
-	TopicName     string `description:"主题名称"`
-}
-
-func GetAiChatTopicByTopicName(topicName string) (item *AiChatTopicView, err error) {
-	sql := ` SELECT * FROM ai_chat_topic WHERE topic_name=? `
-	o := orm.NewOrmUsingDB("weekly")
-	err = o.Raw(sql, topicName).QueryRow(&item)
-	return
-}
-
-func EditTopic(topicId int, topicName string) (err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	sql := ` UPDATE ai_chat_topic SET topic_name=? WHERE  ai_chat_topic_id=? `
-	_, err = o.Raw(sql, topicName, topicId).Exec()
-	return err
-}

+ 0 - 14
models/db.go

@@ -2,7 +2,6 @@ package models
 
 import (
 	_ "github.com/go-sql-driver/mysql"
-	"hongze/hz_eta_api/models/aimod"
 	"hongze/hz_eta_api/models/company"
 	"hongze/hz_eta_api/models/data_manage"
 	future_good2 "hongze/hz_eta_api/models/data_manage/future_good"
@@ -131,9 +130,6 @@ func init() {
 	//多图配置
 	initMultipleGraphConfig()
 
-	//AI 聊天记录
-	initAiChat()
-
 	// 商家配置
 	initBusinessConf()
 }
@@ -178,12 +174,10 @@ func initReport() {
 	orm.RegisterModel(
 		new(Report),
 		new(ReportViewRecord),
-		new(ResearchReport),                      //日报、周报信息
 		new(ChartPermissionSearchKeyWordMapping), //报告分类权限表
 		new(ReportChapter),                       // 报告章节表
 		new(ReportChapterTicker),                 // 晨报章节ticker
 		new(ReportChapterTypePermission),         // 晨周报章节类型权限表
-		new(GroupSendMsg),                        //群发消息
 		new(ChartPermission),                     // 权限表
 		new(YbPcSuncode),
 		new(YbSuncodePars),
@@ -391,14 +385,6 @@ func initMultipleGraphConfig() {
 	)
 }
 
-func initAiChat() {
-	//注册对象
-	orm.RegisterModel(
-		new(aimod.AiChatTopic), //主题
-		new(aimod.AiChat),      //聊天
-	)
-}
-
 // initBusinessConf 商家配置
 func initBusinessConf() {
 	orm.RegisterModel(

+ 0 - 48
models/group_send_msg.go

@@ -1,48 +0,0 @@
-package models
-
-import (
-	"github.com/beego/beego/v2/client/orm"
-	"time"
-)
-
-// GroupSendMsgAddReq 群发消息请求
-type GroupSendMsgAddReq struct {
-	JumpType    int8   `description:"跳转类型,1:h5;2:小程序;3:文字;4-图片"`
-	LinkUrl     string `description:"跳转地址,长度255"`
-	ImgUrl      string `description:"图片地址,长度255"`
-	Title       string `description:"标题,长度64"`
-	Description string `description:"摘要"`
-	Label       string `description:"标签,多个标签用、隔开;长度255"`
-}
-
-// 群发消息
-type GroupSendMsg struct {
-	MsgId       int       `orm:"column(msg_id);pk" description:"消息Id"`
-	JumpType    int8      `description:"跳转类型,1:h5;2:小程序;3:文字;4-图片"`
-	LinkUrl     string    `description:"跳转地址"`
-	ImgUrl      string    `description:"图片地址"`
-	Title       string    `description:"标题"`
-	Description string    `description:"摘要"`
-	Label       string    `description:"标签"`
-	Status      int8      `description:"发送结果,0:待发送,-1发送失败,1发送成功"`
-	Remark      string    `description:"发送失败原因"`
-	CreateTime  time.Time `description:"发送时间"`
-}
-
-// Add 新增群发消息
-func (groupSendMsg *GroupSendMsg) Add() (err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	id, err := o.Insert(groupSendMsg)
-	if err != nil {
-		return
-	}
-	groupSendMsg.MsgId = int(id)
-	return
-}
-
-// Update 修改群发消息
-func (groupSendMsg *GroupSendMsg) Update(cols []string) (err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	_, err = o.Update(groupSendMsg, cols...)
-	return
-}

+ 2 - 2
models/report_chapter_type.go

@@ -142,7 +142,7 @@ func GetEnableReportChapterTypeList(researchType string) (list []*ReportChapterT
 	return
 }
 
-// 晨报周报暂停时间
+// DayWeekReportPauseTime 晨报周报暂停时间
 type DayWeekReportPauseTime struct {
 	ResearchType   string `description:"报告类型 day; week;"`
 	PauseStartTime string `description:"暂停开始时间"`
@@ -313,7 +313,7 @@ func GetReportChapterTypeCount(condition string, pars []interface{}) (count int,
 	return
 }
 
-// GetReportChapterTypeList 获取章节类型列表
+// GetReportChapterTypePageList 获取章节类型列表
 func GetReportChapterTypePageList(condition string, pars []interface{}, startSize, pageSize int) (list []*ReportChapterType, err error) {
 	o := orm.NewOrmUsingDB("weekly")
 	sql := ` SELECT * FROM report_chapter_type WHERE 1 = 1 `

+ 0 - 235
models/research_report.go

@@ -1,243 +1,8 @@
 package models
 
-import (
-	"fmt"
-	"github.com/beego/beego/v2/client/orm"
-	"hongze/hz_eta_api/utils"
-	"strconv"
-	"time"
-)
-
-// ResearchReport 研究报告表(晨报、周报等)结构体
-type ResearchReport struct {
-	ResearchReportId    int       `orm:"column(research_report_id);pk" description:"研究报告id"`
-	ResearchReportName  string    `description:"研究报告名称"`
-	ResearchReportTitle string    `description:"研究报告标题"`
-	ResearchReportImg   string    `description:"报告缩略图URL"`
-	ResearchReportDate  time.Time `description:"报告日期"`
-	Type                string    `description:"报告类型,枚举值:day 晨报  week 周报 twoweek双周报 month 月报;默认:day"`
-	Author              string    `description:"作者"`
-	ReportVariety       string    `description:"研究报告的品种,双周报和月报有标识"`
-	IsHasMenu           int8      `description:"报告是否含有目录"`
-	IsSendedMsg         int8      `description:"是否发送过模板消息"`
-	Periods             int       `description:"期数"`
-	Status              string    `description:"状态,draft:草稿,"`
-	Enabled             int8      `description:"报告状态"`
-	CreatedTime         string    `description:"创建时间"`
-	LastUpdatedTime     time.Time `description:"最近一次更新时间"`
-	Viewers             int       `description:"H5观看用户数"`
-}
-
-// Update 更新数据
-func (researchReport *ResearchReport) Update(updateCols []string) (err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	_, err = o.Update(researchReport, updateCols...)
-	return
-}
-
-type ResearchReportList struct {
-	ResearchReportId    int       `orm:"column(research_report_id);pk" description:"研究报告id"`
-	ResearchReportName  string    `description:"研究报告名称"`
-	ResearchReportTitle string    `description:"研究报告标题"`
-	ResearchReportImg   string    `description:"报告缩略图URL"`
-	ResearchReportDate  time.Time `description:"报告日期"`
-	Type                string    `description:"报告类型,枚举值:day 晨报  week 周报 twoweek双周报 month 月报;默认:day"`
-	Author              string    `description:"作者"`
-	ReportVariety       string    `description:"研究报告的品种,双周报和月报有标识"`
-	IsHasMenu           int8      `description:"报告是否含有目录"`
-	IsSendedMsg         int8      `description:"是否发送过模板消息"`
-	Periods             int       `description:"期数"`
-	Status              string    `description:"状态,draft:草稿,"`
-	Enabled             int8      `description:"报告状态"`
-	CreatedTime         string    `description:"创建时间"`
-	LastUpdatedTime     time.Time `description:"最近一次更新时间"`
-	Viewers             int       `description:"H5观看用户数"`
-	LinkUrl             string    `description:"报告阅读地址"`
-}
-
-// ResearchReport 研究报告表(晨报、周报等)结构体
-type ResearchReportType struct {
-	ResearchReportTypeId    int       `orm:"column(research_report_type_id);pk" description:"报告章节ID"`
-	ResearchReportId        int       `description:"报告ID"`
-	TypeId                  int       `description:"分类ID"`
-	Edit                    int       `description:"是否编辑过"`
-	Trend                   string    `description:"趋势观点"`
-	ResearchReportTypeTitle string    `description:"报告标题"`
-	CreatedTime             string    `description:"创建时间"`
-	LastUpdatedTime         time.Time `description:"最近一次更新时间"`
-}
-
-type ResearchReportTypeContent struct {
-	ResearchReportTypeContentId int       `orm:"column(research_report_type_content_id);pk" description:"章节内容ID"`
-	ResearchReportTypeId        int       `description:"报告章节ID"`
-	Sort                        int       `description:"排序"`
-	ContentType                 string    `description:"内容分类类型"`
-	Content                     string    `description:"内容"`
-	ImgUrl                      string    `description:"图片路径"`
-	CreatedTime                 time.Time `description:"创建时间"`
-	LastUpdatedTime             time.Time `description:"最近一次更新时间"`
-}
-
-type ResearchReportTypeTicker struct {
-	ResearchReportTypeTickerId int       `orm:"column(research_report_type_ticker_id);pk" description:"章节tickerID"`
-	ResearchReportTypeId       int       `description:"报告章节ID"`
-	Sort                       int       `description:"排序"`
-	Ticker                     string    `description:"指标的ticker"`
-	CreatedTime                time.Time `description:"创建时间"`
-	LastUpdatedTime            time.Time `description:"最近一次更新时间"`
-}
-
-func GetResearchReportTypeListByReportIds(reportIds string) (list []*ResearchReportType, err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	sql := ` SELECT * FROM research_report_type WHERE research_report_id IN (` + reportIds + `) ORDER BY created_time ASC,research_report_type_id ASC `
-	_, err = o.Raw(sql).QueryRows(&list)
-	return
-}
-
-func GetResearchReportTypeContentListByReportTypeIds(reportTypeIds string) (list []*ResearchReportTypeContent, err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	sql := ` SELECT * FROM research_report_type_content WHERE research_report_type_id IN (` + reportTypeIds + `) ORDER BY research_report_type_id ASC,sort ASC `
-	_, err = o.Raw(sql).QueryRows(&list)
-	return
-}
-
-func GetResearchReportTypeTickerListByReportTypeIds(reportTypeIds string) (list []*ResearchReportTypeTicker, err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	sql := ` SELECT * FROM research_report_type_ticker WHERE research_report_type_id IN (` + reportTypeIds + `) ORDER BY research_report_type_id ASC,sort ASC `
-	_, err = o.Raw(sql).QueryRows(&list)
-	return
-}
-
-type CreateDayWeekReport struct {
-	Report      *Report
-	ChapterList []*CreateDayWeekReportChapter
-}
-
-type CreateDayWeekReportChapter struct {
-	Chapter    *ReportChapter
-	TickerList []*ReportChapterTicker
-}
-
-// 新增迁移晨周报
-func CreateMigrateNewDayWeekReport(newDayWeekReport *CreateDayWeekReport) (newReportId int, err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	to, err := o.Begin()
-	if err != nil {
-		return
-	}
-	defer func() {
-		if err != nil {
-			_ = to.Rollback()
-		} else {
-			_ = to.Commit()
-		}
-	}()
-
-	// 新增报告
-	reportId, err := to.Insert(newDayWeekReport.Report)
-	if err != nil {
-		fmt.Println("InsertReportErr:" + err.Error())
-		return
-	}
-	// 新增章节
-	for _, chapter := range newDayWeekReport.ChapterList {
-		chapter.Chapter.ReportId = int(reportId)
-		lastChapterId, tmpErr := to.Insert(chapter.Chapter)
-		if tmpErr != nil {
-			err = tmpErr
-			return
-		}
-		// 新增晨报ticker
-		for _, ticker := range chapter.TickerList {
-			ticker.ReportChapterId = int(lastChapterId)
-			if _, tmpErr = to.Insert(ticker); tmpErr != nil {
-				err = tmpErr
-				return
-			}
-		}
-	}
-	// 修改报告code
-	reportCode := utils.MD5(strconv.Itoa(int(reportId)))
-	sql := `UPDATE report SET report_code = ? WHERE id = ? `
-	if _, err = to.Raw(sql, reportCode, reportId).Exec(); err != nil {
-		fmt.Println("UpdateReportCodeErr:" + err.Error())
-	}
-	newReportId = int(reportId)
-
-	return
-}
-
-// 新增迁移其他报告
-func CreateMigrateNewOtherReport(reportInfo *Report, mappingList []*ChartPermissionChapterMapping) (newReportId int, err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	to, err := o.Begin()
-	if err != nil {
-		return
-	}
-	defer func() {
-		if err != nil {
-			_ = to.Rollback()
-		} else {
-			_ = to.Commit()
-		}
-	}()
-
-	// 新增报告
-	reportId, err := to.Insert(reportInfo)
-	if err != nil {
-		fmt.Println("InsertReportErr:" + err.Error())
-		return
-	}
-	// 修改报告code
-	reportCode := utils.MD5(strconv.Itoa(int(reportId)))
-	sql := `UPDATE report SET report_code = ? WHERE id = ? `
-	if _, err = to.Raw(sql, reportCode, reportId).Exec(); err != nil {
-		fmt.Println("UpdateReportCodeErr:" + err.Error())
-		return
-	}
-
-	// 新增权限
-	newReportId = int(reportId)
-	if len(mappingList) > 0 {
-		r := orm.NewOrmUsingDB("weekly")
-		for _, mapping := range mappingList {
-			sql := ` INSERT INTO chart_permission_chapter_mapping (chart_permission_id, report_chapter_type_id,research_type) VALUES(?,?,?) `
-			if _, err = r.Raw(sql, mapping.ChartPermissionId, newReportId, "rddp").Exec(); err != nil {
-				fmt.Println("InsertChartPermissionErr:" + err.Error())
-				return
-			}
-		}
-	}
-
-	return
-}
-
 type ChartPermissionChapterMapping struct {
 	Id                  int    `orm:"column(id);pk"`
 	ChartPermissionId   int    `description:"权限ID"`
 	ReportChapterTypeId int    `description:"report_chapter_type表主键id或research_report表主键id或tactic表主键id"`
 	ResearchType        string `description:"报告类型 week;two_week;tactic;month;other;rddp; "`
 }
-
-func GetChapterPermissionMappingByResearchReportIds(researchReportIds string) (list []*ChartPermissionChapterMapping, err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	sql := ` SELECT * FROM chart_permission_chapter_mapping WHERE report_chapter_type_id IN (` + researchReportIds + `) AND research_type != "rddp" ORDER BY report_chapter_type_id ASC `
-	_, err = o.Raw(sql).QueryRows(&list)
-	return
-}
-
-// GetResearchReportTypeListByReportId 根据报告ID获取报告章节
-func GetResearchReportTypeListByReportId(reportId int) (list []*ResearchReportType, err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	sql := ` SELECT * FROM research_report_type WHERE research_report_id = ? ORDER BY created_time ASC,research_report_type_id ASC `
-	_, err = o.Raw(sql, reportId).QueryRows(&list)
-	return
-}
-
-// GetResearchReportById 主键获取报告
-func GetResearchReportById(reportId int) (item *ResearchReport, err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	sql := `SELECT * FROM research_report WHERE research_report_id = ? LIMIT 1`
-	err = o.Raw(sql, reportId).QueryRow(&item)
-	return
-}

+ 1 - 84
models/wx_user.go

@@ -2,7 +2,6 @@ package models
 
 import (
 	"github.com/beego/beego/v2/client/orm"
-	"github.com/rdlucklib/rdluck_tools/paging"
 	"time"
 )
 
@@ -33,12 +32,6 @@ type WxUser struct {
 	UserLabel           string    `description:"查研观向用户标签"`
 }
 
-func AddWxUser(item *WxUser) (lastId int64, err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	lastId, err = o.Insert(item)
-	return
-}
-
 func GetWxUserByMobile(mobile string) (item *WxUser, err error) {
 	o := orm.NewOrmUsingDB("weekly")
 	sql := `SELECT * FROM wx_user WHERE mobile = ? LIMIT 1`
@@ -46,53 +39,13 @@ func GetWxUserByMobile(mobile string) (item *WxUser, err error) {
 	return
 }
 
-// GetWxUserByMobileCountryCode 根据手机号和区号获取用户信息
-func GetWxUserByMobileCountryCode(mobile, countryCode string) (item *WxUser, err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	sql := `SELECT * FROM wx_user WHERE mobile = ? `
-	sql += ` and country_code in ("","` + countryCode + `") `
-	sql += ` LIMIT 1 `
-	err = o.Raw(sql, mobile).QueryRow(&item)
-	return
-}
-
-func GetWxUserByUserId(userId int) (item *WxUser, err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	sql := `SELECT * FROM wx_user WHERE user_id=? `
-	err = o.Raw(sql, userId).QueryRow(&item)
-	return
-}
-
-// 更新wxUser信息
+// Update 更新wxUser信息
 func (wxUser *WxUser) Update(cols []string) (err error) {
 	o := orm.NewOrmUsingDB("weekly")
 	_, err = o.Update(wxUser, cols...)
 	return
 }
 
-type PotentialUserItem struct {
-	UserId          int       `description:"用户id"`
-	RealName        string    `description:"姓名"`
-	CountryCode     string    `description:"区号,86、852、886等"`
-	Mobile          string    `description:"手机号"`
-	Email           string    `description:"邮箱"`
-	CreatedTime     string    `description:"注册时间"`
-	ApplyMethod     int       `description:"0:未申请,1:已付费客户申请试用,2:非客户申请试用"`
-	CompanyName     string    `description:"客户名称"`
-	ViewTotal       int       `description:"累计阅读次数"`
-	LastViewTime    time.Time `json:"-" description:"最后一次阅读时间"`
-	LastViewTimeStr string    `description:"最后一次阅读时间"`
-	FromType        string    `description:"report:研报,teleconference:电话会"`
-	BusinessCardUrl string    `description:"名片"`
-	Source          int       `description:"来源,1:微信端,2:pc网页端,3:查研观向小程序,4:每日咨询,5:电话会"`
-	IsDeal          int       `description:"是否标记处理,0是未处理,1是已处理"`
-}
-
-type PotentialUserListResp struct {
-	List   []*PotentialUserItem
-	Paging *paging.PagingItem `description:"分页数据"`
-}
-
 // GetWxUserByCompanyIdAndMobile 根据客户ID及手机号获取用户
 func GetWxUserByCompanyIdAndMobile(companyId int, mobile string) (item *WxUser, err error) {
 	o := orm.NewOrmUsingDB("weekly")
@@ -127,39 +80,3 @@ func DeleteWxUserAndRecordByUserId(userId int) (err error) {
 
 	return
 }
-
-// 获取这个公司下面所有用户的手机号
-func SetUserSubscribe(openId string) (err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	sql := ` UPDATE user_record SET subscribe=1,subscribe_time=NOW() WHERE open_id=? `
-	_, err = o.Raw(sql, openId).Exec()
-	return
-}
-
-type WxUserItem struct {
-	UserId              int       `description:"用户id"`
-	OpenId              string    `description:"open_id"`
-	UnionId             string    `description:"union_id"`
-	CompanyId           int       `description:"客户id"`
-	NickName            string    `description:"用户昵称"`
-	RealName            string    `description:"用户实际名称"`
-	Mobile              string    `description:"手机号码"`
-	BindAccount         string    `description:"绑定时的账号"`
-	Email               string    `description:"邮箱"`
-	Headimgurl          string    `description:"用户头像,最后一个数值代表正方形头像大小(有0、46、64、96、132数值可选,0代表640*640正方形头像),用户没有头像时该项为空"`
-	ApplyMethod         int       `description:"0:未申请,1:已付费客户申请试用,2:非客户申请试用"`
-	FirstLogin          int       `description:"是否第一次登陆"`
-	IsFreeLogin         int       `description:"是否免登陆,true:免登陆,false:非免登陆"`
-	LoginTime           time.Time `description:"登录时间"`
-	CreatedTime         time.Time `description:"创建时间"`
-	LastUpdatedTime     time.Time `description:"最近一次修改时间"`
-	SessionKey          string    `description:"微信小程序会话密钥"`
-	CompanyName         string    `description:"公司名称"`
-	IsRegister          int       `description:"是否注册:1:已注册,0:未注册"`
-	CountryCode         string    `description:"手机国家区号"`
-	OutboundMobile      string    `description:"外呼手机号"`
-	OutboundCountryCode string    `description:"外呼手机号区号"`
-	IsMsgOutboundMobile int       `description:"是否弹窗过绑定外呼手机号区号"`
-	IsMaker             int       `description:"是否是决策人"`
-	Source              int
-}

+ 1 - 27
models/yb/price_driven_tag.go

@@ -5,7 +5,7 @@ import (
 	"time"
 )
 
-// VarietyClassify 标签库分类表
+// PriceDrivenTag 标签库分类表
 type PriceDrivenTag struct {
 	Id             int       `orm:"column(id);pk" `
 	VarietyTagId   int       `json:"variety_tag_id" description:"标签ID"`
@@ -20,24 +20,6 @@ func (priceDrivenTag *PriceDrivenTag) TableName() string {
 	return "yb_price_driven_tag"
 }
 
-// Add 新增
-func (priceDrivenTag *PriceDrivenTag) Add() (lastId int64, err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	lastId, err = o.Insert(priceDrivenTag)
-	if err != nil {
-		return
-	}
-	priceDrivenTag.Id = int(lastId)
-	return
-}
-
-// Update 更新
-func (priceDrivenTag *PriceDrivenTag) Update(cols []string) (err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	_, err = o.Update(priceDrivenTag, cols...)
-	return
-}
-
 // GetPriceDrivenTagList 获取价格驱动标签列表
 func GetPriceDrivenTagList() (list []*PriceDrivenTag, err error) {
 	o := orm.NewOrmUsingDB("weekly")
@@ -45,11 +27,3 @@ func GetPriceDrivenTagList() (list []*PriceDrivenTag, err error) {
 	_, err = o.Raw(sql).QueryRows(&list)
 	return
 }
-
-// GetPriceDrivenTagByTagId 通过标签ID获取价格驱动标签
-func GetPriceDrivenTagByTagId(tagId int) (item *PriceDrivenTag, err error) {
-	o := orm.NewOrmUsingDB("weekly")
-	sql := `SELECT * FROM yb_price_driven_tag WHERE variety_tag_id = ? LIMIT 1`
-	err = o.Raw(sql, tagId).QueryRow(&item)
-	return
-}

+ 0 - 45
routers/commentsRouter.go

@@ -7,51 +7,6 @@ import (
 
 func init() {
 
-    beego.GlobalControllerRouter["hongze/hz_eta_api/controllers/ai:AiController"] = append(beego.GlobalControllerRouter["hongze/hz_eta_api/controllers/ai:AiController"],
-        beego.ControllerComments{
-            Method: "List",
-            Router: `/chat`,
-            AllowHTTPMethods: []string{"post"},
-            MethodParams: param.Make(),
-            Filters: nil,
-            Params: nil})
-
-    beego.GlobalControllerRouter["hongze/hz_eta_api/controllers/ai:AiController"] = append(beego.GlobalControllerRouter["hongze/hz_eta_api/controllers/ai:AiController"],
-        beego.ControllerComments{
-            Method: "TopicDelete",
-            Router: `/topic/delete`,
-            AllowHTTPMethods: []string{"post"},
-            MethodParams: param.Make(),
-            Filters: nil,
-            Params: nil})
-
-    beego.GlobalControllerRouter["hongze/hz_eta_api/controllers/ai:AiController"] = append(beego.GlobalControllerRouter["hongze/hz_eta_api/controllers/ai:AiController"],
-        beego.ControllerComments{
-            Method: "TopicDetail",
-            Router: `/topic/detail`,
-            AllowHTTPMethods: []string{"get"},
-            MethodParams: param.Make(),
-            Filters: nil,
-            Params: nil})
-
-    beego.GlobalControllerRouter["hongze/hz_eta_api/controllers/ai:AiController"] = append(beego.GlobalControllerRouter["hongze/hz_eta_api/controllers/ai:AiController"],
-        beego.ControllerComments{
-            Method: "TopicEdit",
-            Router: `/topic/edit`,
-            AllowHTTPMethods: []string{"post"},
-            MethodParams: param.Make(),
-            Filters: nil,
-            Params: nil})
-
-    beego.GlobalControllerRouter["hongze/hz_eta_api/controllers/ai:AiController"] = append(beego.GlobalControllerRouter["hongze/hz_eta_api/controllers/ai:AiController"],
-        beego.ControllerComments{
-            Method: "TopicList",
-            Router: `/topic/list`,
-            AllowHTTPMethods: []string{"get"},
-            MethodParams: param.Make(),
-            Filters: nil,
-            Params: nil})
-
     beego.GlobalControllerRouter["hongze/hz_eta_api/controllers/data_manage/correlation:CorrelationChartClassifyController"] = append(beego.GlobalControllerRouter["hongze/hz_eta_api/controllers/data_manage/correlation:CorrelationChartClassifyController"],
         beego.ControllerComments{
             Method: "AddChartClassify",

+ 0 - 6
routers/router.go

@@ -11,7 +11,6 @@ import (
 	"github.com/beego/beego/v2/server/web"
 	"github.com/beego/beego/v2/server/web/filter/cors"
 	"hongze/hz_eta_api/controllers"
-	"hongze/hz_eta_api/controllers/ai"
 	"hongze/hz_eta_api/controllers/data_manage"
 	"hongze/hz_eta_api/controllers/data_manage/correlation"
 	future_good2 "hongze/hz_eta_api/controllers/data_manage/future_good"
@@ -245,11 +244,6 @@ func init() {
 				&supply_analysis.VarietyController{},
 			),
 		),
-		web.NSNamespace("/ai",
-			web.NSInclude(
-				&ai.AiController{},
-			),
-		),
 		web.NSNamespace("/en_permission",
 			web.NSInclude(
 				&english_report.EnPermissionController{},

+ 0 - 47
services/aiser/ai.go

@@ -1,47 +0,0 @@
-package aiser
-
-import (
-	"encoding/json"
-	"errors"
-	"github.com/rdlucklib/rdluck_tools/http"
-	"hongze/hz_eta_api/utils"
-)
-
-func ChatAutoMsg(prompt string, model int) (result string, err error) {
-	if utils.ChatUrl == `` {
-		err = errors.New("chatGPT服务未配置")
-		return
-	}
-	chatUrl := `http://8.210.169.38:8399/v1/chat/auto_msg`
-	param := make(map[string]interface{})
-	param["Prompt"] = prompt
-	param["Model"] = model
-	postData, err := json.Marshal(param)
-	if err != nil {
-		return result, err
-	}
-
-	utils.FileLogChat.Info("postData:" + string(postData))
-	body, err := http.HttpPost(chatUrl, string(postData), "application/json; charset=utf-8")
-	if err != nil {
-		return result, err
-	}
-	utils.FileLogChat.Info("result:" + string(body))
-
-	resp := new(ChatAutoMsgResp)
-	err = json.Unmarshal(body, &resp)
-	if err != nil {
-		return result, err
-	}
-	if resp.Ret != 200 {
-		return resp.Msg, nil
-	}
-	result = resp.Data
-	return result, nil
-}
-
-type ChatAutoMsgResp struct {
-	Ret  int
-	Data string
-	Msg  string
-}

文件差异内容过多而无法显示
+ 0 - 46
services/data/base_from_smm.go


+ 0 - 489
services/report_sync.go

@@ -1,489 +0,0 @@
-package services
-
-import (
-	"errors"
-	"fmt"
-	"hongze/hz_eta_api/models"
-	"hongze/hz_eta_api/services/alarm_msg"
-	"hongze/hz_eta_api/utils"
-	"html"
-	"regexp"
-	"strconv"
-	"strings"
-	"time"
-)
-
-func AutoSyncOldReport() {
-	defer func() {
-		if err := recover(); err != nil {
-			fmt.Println("[AutoSyncOldReport]", err)
-		}
-	}()
-	for {
-		utils.Rc.Brpop(utils.CACHE_KEY_OLD_REPORT_PUBLISH, func(b []byte) {
-			reportId, _ := strconv.Atoi(string(b))
-			if reportId > 0 {
-				if err := SyncOldReport(reportId); err != nil {
-					fmt.Println("AutoSyncOldReport: ", err.Error(), "reportId: ", reportId)
-				}
-			}
-		})
-	}
-}
-
-// SyncOldReport 同步老后台报告
-func SyncOldReport(reportId int) (err error) {
-	defer func() {
-		if err != nil {
-			utils.FileLog.Error("SyncOldReport, reportId:%s, Err:%s", strconv.Itoa(reportId), err.Error())
-			go alarm_msg.SendAlarmMsg("同步老后台报告失败, 报告ID: "+strconv.Itoa(reportId)+", Err: "+err.Error(), 3)
-		}
-	}()
-	// 查询报告信息
-	if reportId <= 0 {
-		return
-	}
-	reportInfo, e := models.GetResearchReportById(reportId)
-	if e != nil {
-		err = errors.New("报告信息有误" + e.Error())
-		return
-	}
-	if reportInfo.Status != "report" {
-		return
-	}
-	// 20220615-周报不做同步了
-	if reportInfo.Type == utils.REPORT_TYPE_WEEK {
-		return
-	}
-	// 若已存在报告,则后续更新报告信息
-	existReport, e := models.GetNewReportExist(reportId)
-	if e != nil && e.Error() != utils.ErrNoRow() {
-		err = errors.New("获取报告是否已同步失败" + e.Error())
-		return
-	}
-	// 报告分类
-	classifyList, e := models.GetAllClassify()
-	if e != nil {
-		err = errors.New("获取报告分类失败" + e.Error())
-		return
-	}
-	classifyIdName := make(map[int]string, 0)
-	classifyNameId := make(map[string]int, 0)
-	classifyIdParentId := make(map[int]int, 0)
-	classifyLen := len(classifyList)
-	for i := 0; i < classifyLen; i++ {
-		classifyIdName[classifyList[i].Id] = classifyList[i].ClassifyName
-		classifyNameId[classifyList[i].ClassifyName] = classifyList[i].Id
-		classifyIdParentId[classifyList[i].Id] = classifyList[i].ParentId
-	}
-	// 获取报告章节
-	reportTypeList, e := models.GetResearchReportTypeListByReportId(reportId)
-	if e != nil {
-		err = errors.New("获取报告章节失败" + e.Error())
-		return
-	}
-	reportTypeListLen := len(reportTypeList)
-	if reportTypeListLen == 0 {
-		return
-	}
-	// 获取章节内容
-	typeIdArr := make([]string, 0)
-	for i := 0; i < reportTypeListLen; i++ {
-		typeIdArr = append(typeIdArr, strconv.Itoa(reportTypeList[i].ResearchReportTypeId))
-	}
-	typeIdStr := strings.Join(typeIdArr, ",")
-	reportContentList, e := models.GetResearchReportTypeContentListByReportTypeIds(typeIdStr)
-	if e != nil {
-		err = errors.New("获取章节内容失败" + e.Error())
-		return
-	}
-	reportContentListLen := len(reportContentList)
-	if reportContentListLen == 0 {
-		return
-	}
-	// 报告章节内容map
-	reportContentListMap := make(map[int][]*models.ResearchReportTypeContent, 0)
-	for i := 0; i < reportTypeListLen; i++ {
-		rtid := reportTypeList[i].ResearchReportTypeId
-		reportContentMap := make([]*models.ResearchReportTypeContent, 0)
-		for ii := 0; ii < reportContentListLen; ii++ {
-			if rtid == reportContentList[ii].ResearchReportTypeId {
-				reportContentMap = append(reportContentMap, reportContentList[ii])
-			}
-		}
-		reportContentListMap[rtid] = reportContentMap
-	}
-
-	frequencyMap := map[string]string{
-		"day":      "日度",
-		"week":     "周度",
-		"two_week": "双周度",
-		"month":    "月度",
-		"other":    "不定时",
-	}
-	newReport := new(models.Report)
-	newReport.AddType = 1
-	// 标题去掉【】
-	re, _ := regexp.Compile("^【[^】]*】")
-	newTitle := re.ReplaceAllString(reportInfo.ResearchReportName, "")
-	newReport.Title = newTitle
-	newReport.Author = reportInfo.Author
-	newReport.Frequency = frequencyMap[reportInfo.Type]
-	newReport.CreateTime = reportInfo.CreatedTime
-	modifyTime, _ := time.ParseInLocation(utils.FormatDateTime, reportInfo.CreatedTime, time.Local)
-	newReport.ModifyTime = modifyTime
-	newReport.State = 2
-	newReport.PublishTime = reportInfo.ResearchReportDate
-	newReport.Stage = reportInfo.Periods
-	//newReport.MsgIsSend = 1
-	//newReport.ThsMsgIsSend = 1
-	newReport.ReportVersion = 1
-	newReport.OldReportId = reportInfo.ResearchReportId
-	// 判断报告类型
-	newReportId := 0
-	if reportInfo.Type == utils.REPORT_TYPE_DAY || reportInfo.Type == utils.REPORT_TYPE_WEEK {
-		// 晨周报
-		newReport.HasChapter = 1
-		newReport.ChapterType = reportInfo.Type
-		// 章节类型
-		typeList, tmpErr := models.GetReportChapterTypeList()
-		if tmpErr != nil {
-			err = errors.New("获取晨周报章节类型失败" + tmpErr.Error())
-			return
-		}
-		typeIdName := make(map[int]string, 0)
-		typeIdSort := make(map[int]int, 0)
-		for i := 0; i < len(typeList); i++ {
-			typeIdName[typeList[i].ReportChapterTypeId] = typeList[i].ReportChapterTypeName
-			typeIdSort[typeList[i].ReportChapterTypeId] = typeList[i].Sort
-		}
-		// 分类
-		classifyIdFirst := 0
-		classifyNameFirst := ""
-		if reportInfo.Type == utils.REPORT_TYPE_DAY {
-			newReport.ClassifyIdFirst = classifyNameId["晨报"]
-			newReport.ClassifyNameFirst = "晨报"
-			classifyIdFirst = classifyNameId["晨报"]
-			classifyNameFirst = "晨报"
-		} else {
-			newReport.ClassifyIdFirst = classifyNameId["周报"]
-			newReport.ClassifyNameFirst = "周报"
-			classifyIdFirst = classifyNameId["周报"]
-			classifyNameFirst = "周报"
-		}
-
-		// 报告已存在时的更新报告及章节,否则新增
-		if existReport != nil {
-			// 更新报告
-			existReport.Title = newTitle
-			existReport.Author = reportInfo.Author
-			existReport.PublishTime = reportInfo.ResearchReportDate
-			existReport.ModifyTime = time.Now()
-			var updateReportCol, updateChapterCol []string
-			updateReportCol = append(updateReportCol, "Title", "Author", "PublishTime", "ModifyTime")
-			if tmpErr = existReport.UpdateReport(updateReportCol); tmpErr != nil {
-				err = errors.New("更新已存在的报告失败" + tmpErr.Error())
-				return
-			}
-			// 章节
-			existChapterList, tmpErr := models.GetChapterListByReportId(existReport.Id)
-			if tmpErr != nil {
-				err = errors.New("获取已存在的报告章节失败" + tmpErr.Error())
-				return
-			}
-			typeChapterMap := make(map[int]*models.ResearchReportType, 0)
-			for i := 0; i < reportTypeListLen; i++ {
-				typeChapterMap[reportTypeList[i].TypeId] = reportTypeList[i]
-			}
-			for _, exChapter := range existChapterList {
-				chapter := typeChapterMap[exChapter.TypeId]
-				if chapter == nil {
-					continue
-				}
-				// 章节内容
-				chapterContents := ""
-				contentList := reportContentListMap[chapter.ResearchReportTypeId]
-				for _, contents := range contentList {
-					// 2022-08-09加上段落标题
-					if contents.ContentType != "" {
-						chapterContents += `<p><br></p><p style="font-size: 16px; text-align: left;"><strong>`
-						chapterContents += contents.ContentType
-						chapterContents += `</strong></p><p><br></p>`
-					}
-					chapterContents += contents.Content
-				}
-				chapterContents, tmpErr := replaceReportBase64ToImg(chapterContents)
-				if tmpErr != nil {
-					err = errors.New("章节存在base64图片转换失败" + tmpErr.Error())
-					return
-				}
-				contentClean, e := FilterReportContentBr(chapterContents)
-				if e != nil {
-					err = errors.New("内容去除前后空格失败, Err: " + e.Error())
-					return
-				}
-				chapterContents = contentClean
-
-				contentSub, tmpErr := GetReportContentSub(chapterContents)
-				if tmpErr != nil {
-					err = errors.New("解析章节ContentSub失败" + tmpErr.Error())
-					return
-				}
-				exChapter.Title = chapter.ResearchReportTypeTitle
-				exChapter.Content = html.EscapeString(chapterContents)
-				exChapter.ContentSub = html.EscapeString(contentSub)
-				exChapter.ModifyTime = time.Now()
-				updateChapterCol = append(updateChapterCol, "Title", "Content", "ContentSub", "ModifyTime")
-				updateTickerList := make([]*models.ReportChapterTicker, 0)
-				// 晨报数据指标
-				if reportInfo.Type == utils.REPORT_TYPE_DAY {
-					// 获取章节ticker
-					reportTickerList, tmpErr := models.GetResearchReportTypeTickerListByReportTypeIds(typeIdStr)
-					if tmpErr != nil {
-						err = errors.New("获取报告Ticker失败" + tmpErr.Error())
-						return
-					}
-					reportTickerListMap := make(map[int][]*models.ResearchReportTypeTicker, 0)
-					for i := 0; i < len(reportTypeList); i++ {
-						// 报告Ticker
-						tid := reportTypeList[i].ResearchReportTypeId
-						reportTickerMap := make([]*models.ResearchReportTypeTicker, 0)
-						for iii := 0; iii < len(reportTickerList); iii++ {
-							if tid == reportTickerList[iii].ResearchReportTypeId {
-								reportTickerMap = append(reportTickerMap, reportTickerList[iii])
-							}
-						}
-						reportTickerListMap[tid] = reportTickerMap
-					}
-
-					tickerList := reportTickerListMap[chapter.ResearchReportTypeId]
-					for _, ticker := range tickerList {
-						updateTickerList = append(updateTickerList, &models.ReportChapterTicker{
-							Sort:       ticker.Sort,
-							Ticker:     ticker.Ticker,
-							CreateTime: ticker.CreatedTime,
-							UpdateTime: ticker.LastUpdatedTime,
-						})
-					}
-				}
-				// 更新章节
-				if tmpErr = models.UpdateChapterAndTicker(exChapter, updateChapterCol, updateTickerList); tmpErr != nil {
-					err = errors.New("UpdateChapterAndTicker更新已存在的章节失败" + tmpErr.Error())
-					return
-				}
-			}
-		} else {
-			newDayWeekReport := new(models.CreateDayWeekReport)
-			newChapterList := make([]*models.CreateDayWeekReportChapter, 0)
-			for _, chapter := range reportTypeList {
-				chapterAndTicker := new(models.CreateDayWeekReportChapter)
-				tmpTickerList := make([]*models.ReportChapterTicker, 0)
-				chapterContents := ""
-				// 章节内容列表
-				contentList := reportContentListMap[chapter.ResearchReportTypeId]
-				for _, contents := range contentList {
-					// 2022-08-09加上段落标题
-					if contents.ContentType != "" {
-						chapterContents += `<p><br></p><p style="font-size: 16px; text-align: left;"><strong>`
-						chapterContents += contents.ContentType
-						chapterContents += `</strong></p><p><br></p>`
-					}
-					chapterContents += contents.Content
-				}
-				chapterContents, tmpErr := replaceReportBase64ToImg(chapterContents)
-				if tmpErr != nil {
-					err = errors.New("章节存在base64图片转换失败" + tmpErr.Error())
-					return
-				}
-				state := 2
-				if chapterContents == "" {
-					state = 1
-				}
-
-				contentClean, e := FilterReportContentBr(chapterContents)
-				if e != nil {
-					err = errors.New("内容去除前后空格失败, Err: " + e.Error())
-					return
-				}
-				chapterContents = contentClean
-
-				contentSub, tmpErr := GetReportContentSub(chapterContents)
-				if tmpErr != nil {
-					err = errors.New("解析章节ContentSub失败" + tmpErr.Error())
-					return
-				}
-				chapterContents = html.EscapeString(chapterContents)
-				contentSub = html.EscapeString(contentSub)
-
-				chapterAndTicker.Chapter = &models.ReportChapter{
-					ReportType:        reportInfo.Type,
-					ClassifyIdFirst:   classifyIdFirst,
-					ClassifyNameFirst: classifyNameFirst,
-					TypeId:            chapter.TypeId,
-					TypeName:          typeIdName[chapter.TypeId],
-					Sort:              typeIdSort[chapter.TypeId],
-					Title:             chapter.ResearchReportTypeTitle,
-					AddType:           1,
-					Author:            reportInfo.Author,
-					Content:           chapterContents,
-					ContentSub:        contentSub,
-					Stage:             reportInfo.Periods,
-					Trend:             chapter.Trend,
-					IsEdit:            1,
-					PublishState:      state,
-					PublishTime:       chapter.LastUpdatedTime,
-					CreateTime:        chapter.CreatedTime,
-					ModifyTime:        chapter.LastUpdatedTime,
-				}
-				// 晨报数据指标
-				if reportInfo.Type == utils.REPORT_TYPE_DAY {
-					// 获取章节ticker
-					reportTickerList, tmpErr := models.GetResearchReportTypeTickerListByReportTypeIds(typeIdStr)
-					if tmpErr != nil {
-						err = errors.New("获取报告Ticker失败" + tmpErr.Error())
-						return
-					}
-					reportTickerListMap := make(map[int][]*models.ResearchReportTypeTicker, 0)
-					for i := 0; i < len(reportTypeList); i++ {
-						// 报告Ticker
-						tid := reportTypeList[i].ResearchReportTypeId
-						reportTickerMap := make([]*models.ResearchReportTypeTicker, 0)
-						for iii := 0; iii < len(reportTickerList); iii++ {
-							if tid == reportTickerList[iii].ResearchReportTypeId {
-								reportTickerMap = append(reportTickerMap, reportTickerList[iii])
-							}
-						}
-						reportTickerListMap[tid] = reportTickerMap
-					}
-
-					tickerList := reportTickerListMap[chapter.ResearchReportTypeId]
-					for _, ticker := range tickerList {
-						tmpTickerList = append(tmpTickerList, &models.ReportChapterTicker{
-							Sort:       ticker.Sort,
-							Ticker:     ticker.Ticker,
-							CreateTime: ticker.CreatedTime,
-							UpdateTime: ticker.LastUpdatedTime,
-						})
-					}
-				}
-				chapterAndTicker.TickerList = tmpTickerList
-				newChapterList = append(newChapterList, chapterAndTicker)
-			}
-			newDayWeekReport.Report = newReport
-			newDayWeekReport.ChapterList = newChapterList
-			// 新增晨周报
-			newReportId, tmpErr = models.CreateMigrateNewDayWeekReport(newDayWeekReport)
-			if tmpErr != nil {
-				err = errors.New("新增晨周报失败" + tmpErr.Error())
-				return
-			}
-		}
-	} else {
-		// 非晨周报
-		if reportInfo.ReportVariety == "铁矿库存点评" {
-			reportInfo.ReportVariety = "铁矿库存数据点评"
-		}
-		//newReport.Abstract = newTitle
-		newReport.ClassifyIdSecond = classifyNameId[reportInfo.ReportVariety]
-		newReport.ClassifyNameSecond = reportInfo.ReportVariety
-		newReport.ClassifyIdFirst = classifyIdParentId[newReport.ClassifyIdSecond]
-		newReport.ClassifyNameFirst = classifyIdName[newReport.ClassifyIdFirst]
-		// 忽略分类匹配不上的
-		if newReport.ClassifyIdFirst == 0 || newReport.ClassifyIdSecond == 0 || newReport.ClassifyNameFirst == "" || newReport.ClassifyNameSecond == "" {
-			fmt.Printf("分类匹配不上,忽略报告, FirstClassify:%s, SecondClassify:%s", newReport.ClassifyNameFirst, newReport.ClassifyNameSecond)
-			return
-		}
-		reportContents := ""
-		for _, chapter := range reportTypeList {
-			// 章节内容列表
-			contentList := reportContentListMap[chapter.ResearchReportTypeId]
-			for _, contents := range contentList {
-				// 2022-08-09加上段落标题
-				if contents.ContentType != "" {
-					reportContents += `<p><br></p><p style="font-size: 16px; text-align: left;"><strong>`
-					reportContents += contents.ContentType
-					reportContents += `</strong></p><p><br></p>`
-				}
-				reportContents += contents.Content
-			}
-		}
-		reportContents, tmpErr := replaceReportBase64ToImg(reportContents)
-		if tmpErr != nil {
-			err = errors.New("报告存在base64图片转换失败" + tmpErr.Error())
-			return
-		}
-		newReport.State = 2
-		if reportContents == "" {
-			newReport.State = 1
-		}
-
-		contentClean, e := FilterReportContentBr(reportContents)
-		if e != nil {
-			err = errors.New("内容去除前后空格失败, Err: " + e.Error())
-			return
-		}
-		reportContents = contentClean
-
-		reportContentSub, tmpErr := GetReportContentSub(reportContents)
-		if tmpErr != nil {
-			err = errors.New("解析ContentSub失败" + tmpErr.Error())
-			return
-		}
-		newReport.Content = html.EscapeString(reportContents)
-		newReport.ContentSub = html.EscapeString(reportContentSub)
-		// 报告已存在则更新部分字段
-		if existReport != nil {
-			existReport.Title = newTitle
-			existReport.Abstract = newReport.Abstract
-			existReport.Author = newReport.Author
-			existReport.Content = newReport.Content
-			existReport.ContentSub = newReport.ContentSub
-			existReport.PublishTime = reportInfo.ResearchReportDate
-			existReport.ModifyTime = time.Now()
-			existReport.ClassifyIdFirst = newReport.ClassifyIdFirst
-			existReport.ClassifyNameFirst = newReport.ClassifyNameFirst
-			existReport.ClassifyIdSecond = newReport.ClassifyIdSecond
-			existReport.ClassifyNameSecond = newReport.ClassifyNameSecond
-			updateCol := make([]string, 0)
-			updateCol = append(updateCol, "Title", "Abstract", "Author", "Content", "ContentSub", "PublishTime", "ModifyTime", "ClassifyIdFirst", "ClassifyNameFirst", "ClassifyIdSecond", "ClassifyNameSecond")
-			tmpErr = existReport.UpdateReport(updateCol)
-			if tmpErr != nil {
-				err = errors.New("更新报告失败" + tmpErr.Error())
-				return
-			}
-		} else {
-			// 获取非晨周报权限mapping
-			reportPermissionList, tmpErr := models.GetChapterPermissionMappingByResearchReportIds(strconv.Itoa(reportId))
-			if tmpErr != nil {
-				err = errors.New("获取报告权限mapping失败" + tmpErr.Error())
-				return
-			}
-			// 新增非晨周报
-			newReportId, tmpErr = models.CreateMigrateNewOtherReport(newReport, reportPermissionList)
-			if tmpErr != nil {
-				err = errors.New("新增非晨周报失败" + tmpErr.Error())
-				return
-			}
-		}
-	}
-	if existReport != nil {
-		newReportId = existReport.Id
-	}
-	if newReportId == 0 {
-		err = errors.New("同步报告失败")
-		return
-	}
-	if existReport == nil {
-		// 更新音频
-		if e = UpdateReportVideo(newReportId); e != nil {
-			err = errors.New("更新音频失败" + e.Error())
-			return
-		}
-	}
-	// 更新ES
-	if e = UpdateReportEs(newReportId, 2); e != nil {
-		err = errors.New("更新报告ES失败" + e.Error())
-		return
-	}
-	return
-}

+ 0 - 5
services/task.go

@@ -32,18 +32,13 @@ func Task() {
 	//data.GetSmmIndexData()
 	go AutoInsertLogToDB()
 	// TODO:确定晨报在新后台撰写之后打开, 防止误写之后被自动推送
-	//go AutoPublishDayReport()
-	go AutoSyncOldReport()
 
 	//手工数据表格导入后的指标库刷新
 	go ImportManualDataRefresh()
-	//ImportManualDataRefresh()
 
 	//修复用户关注标识
 	//GetWxUsersSubscribe()
 
-	//go UpdateOldTrialUsersManualAuth()
-
 	go AutoInsertAdminOperateRecordToDB()
 
 	// TODO:修复权限

部分文件因为文件数量过多而无法显示