|
@@ -102,8 +102,6 @@ func (this *SmartReportController) Add() {
|
|
|
}
|
|
|
resp := smart_report.FormatSmartReport2Item(item)
|
|
|
|
|
|
- // TODO:ES操作
|
|
|
-
|
|
|
br.Ret = 200
|
|
|
br.Success = true
|
|
|
br.Msg = "操作成功"
|
|
@@ -200,11 +198,6 @@ func (this *SmartReportController) Edit() {
|
|
|
}
|
|
|
resp := smart_report.FormatSmartReport2Item(item)
|
|
|
|
|
|
- // TODO:ES操作, 更新保存日志
|
|
|
- go func() {
|
|
|
-
|
|
|
- }()
|
|
|
-
|
|
|
br.Ret = 200
|
|
|
br.Success = true
|
|
|
br.Msg = "操作成功"
|
|
@@ -265,9 +258,9 @@ func (this *SmartReportController) Remove() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- // TODO:ES, 报告操作日志
|
|
|
+ // ES更新报告为未发布
|
|
|
go func() {
|
|
|
-
|
|
|
+ _ = smartReportService.SmartReportElasticUpsert(item.SmartReportId, 1)
|
|
|
}()
|
|
|
|
|
|
br.Ret = 200
|
|
@@ -388,9 +381,9 @@ func (this *SmartReportController) Publish() {
|
|
|
go smartReportService.SmartReportBuildVideoAndUpdate(item)
|
|
|
}
|
|
|
|
|
|
- // TODO:ES操作, 操作日志
|
|
|
+ // ES更新报告
|
|
|
go func() {
|
|
|
-
|
|
|
+ _ = smartReportService.SmartReportElasticUpsert(item.SmartReportId, req.PublishState)
|
|
|
}()
|
|
|
|
|
|
br.Ret = 200
|
|
@@ -496,7 +489,7 @@ func (this *SmartReportController) PrePublish() {
|
|
|
// @Description 消息推送
|
|
|
// @Param request body models.SendTemplateMsgReq true "type json string"
|
|
|
// @Success 200 Ret=200 推送成功
|
|
|
-// @router /sendMsg [post]
|
|
|
+// @router /send_msg [post]
|
|
|
func (this *SmartReportController) SendMsg() {
|
|
|
br := new(models.BaseResponse).Init()
|
|
|
defer func() {
|
|
@@ -540,62 +533,32 @@ func (this *SmartReportController) SendMsg() {
|
|
|
}
|
|
|
|
|
|
reportOB := new(smart_report.SmartReport)
|
|
|
-
|
|
|
- report, e := models.GetReportById(req.ReportId)
|
|
|
+ item, e := reportOB.GetItemById(req.SmartReportId)
|
|
|
if e != nil {
|
|
|
- br.Msg = "报告不存在或已被删除, 请刷新页面"
|
|
|
+ if e.Error() == utils.ErrNoRow() {
|
|
|
+ br.Msg = "报告不存在, 请刷新页面"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ br.Msg = "操作失败"
|
|
|
br.ErrMsg = "获取报告失败, Err: " + e.Error()
|
|
|
return
|
|
|
}
|
|
|
- if report.MsgIsSend == 1 && report.ThsMsgIsSend == 1 {
|
|
|
+ if item.MsgIsSend == 1 {
|
|
|
br.Msg = "消息已推送,请勿重复操作"
|
|
|
- br.ErrMsg = "消息已推送,请勿重复操作"
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- // 更新报告发布时间
|
|
|
- videoNameDate := `(` + time.Now().Format("0102") + `)`
|
|
|
- if err = models.UpdateReportPublishTime(req.ReportId, videoNameDate); err != nil {
|
|
|
- br.Msg = "修改报告发布时间失败"
|
|
|
- br.ErrMsg = "修改发布时间失败,Err:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- if err = models.UpdateReportChapterPublishTime(req.ReportId, videoNameDate); err != nil {
|
|
|
- br.Msg = "修改章节发布时间失败"
|
|
|
- br.ErrMsg = "修改发布时间失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- // 可能存在历史数据两个只推了一个所以此处加个判断
|
|
|
- // 推送模板消息
|
|
|
- if report.MsgIsSend == 0 {
|
|
|
- go func() {
|
|
|
- fmt.Println("推送模板消息:", req.ReportId)
|
|
|
- _ = services.SendMiniProgramReportWxMsg(req.ReportId)
|
|
|
- }()
|
|
|
- }
|
|
|
- // 推送客群消息
|
|
|
- if report.ThsMsgIsSend == 0 {
|
|
|
- go func() {
|
|
|
- // 周报无客群消息
|
|
|
- // 2023-3-19 15:19:24 现在开始周报又要推送了
|
|
|
- //if report.HasChapter == 1 && report.ChapterType == utils.REPORT_TYPE_WEEK {
|
|
|
- // return
|
|
|
- //}
|
|
|
- _ = services.SendReportMiniToThs(report)
|
|
|
- }()
|
|
|
- }
|
|
|
-
|
|
|
- // 更新推送消息状态
|
|
|
- if err = models.ModifyReportMsgIsSendV2(req.ReportId); err != nil {
|
|
|
- br.Msg = "推送失败"
|
|
|
- br.ErrMsg = "更新报告消息状态失败, Err:" + err.Error()
|
|
|
+ item.MsgIsSend = 1
|
|
|
+ item.ModifyTime = time.Now().Local()
|
|
|
+ if e = item.Update([]string{"MsgIsSend", "ModifyTime"}); e != nil {
|
|
|
+ br.Msg = "操作失败"
|
|
|
+ br.ErrMsg = "更新报告推送状态失败, Err: " + e.Error()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
br.Ret = 200
|
|
|
br.Success = true
|
|
|
- br.Msg = "推送成功"
|
|
|
+ br.Msg = "操作成功"
|
|
|
br.IsAddLog = true
|
|
|
}
|
|
|
|
|
@@ -942,3 +905,51 @@ func (this *SmartReportController) List() {
|
|
|
br.Msg = "获取成功"
|
|
|
br.Data = resp
|
|
|
}
|
|
|
+
|
|
|
+// DetailImg
|
|
|
+// @Title 生成长图
|
|
|
+// @Description 生成长图
|
|
|
+// @Param SmartReportId query int true "智能研报ID"
|
|
|
+// @Success 200 {object} smart_report.SmartReportSaveContentResp
|
|
|
+// @router /detail_img [get]
|
|
|
+func (this *SmartReportController) DetailImg() {
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ reportId, _ := this.GetInt("SmartReportId", 0)
|
|
|
+ if reportId <= 0 {
|
|
|
+ br.Msg = "参数有误"
|
|
|
+ br.ErrMsg = fmt.Sprintf("参数有误, SmartReportId: %d", reportId)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ reportOB := new(smart_report.SmartReport)
|
|
|
+ _, e := reportOB.GetItemById(reportId)
|
|
|
+ if e != nil {
|
|
|
+ if e.Error() == utils.ErrNoRow() {
|
|
|
+ br.Msg = "报告不存在, 请刷新页面"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ br.Msg = "操作失败"
|
|
|
+ br.ErrMsg = "获取报告失败, Err: " + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // TODO:调用python服务生成长图
|
|
|
+
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "获取成功"
|
|
|
+}
|