|
@@ -3,7 +3,6 @@ package controllers
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
"eta/eta_api/models"
|
|
|
- "eta/eta_api/models/company"
|
|
|
"eta/eta_api/models/report_approve"
|
|
|
"eta/eta_api/services"
|
|
|
"eta/eta_api/services/alarm_msg"
|
|
@@ -266,8 +265,7 @@ func (this *ReportController) PublishReport() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- // TODO:根据审批开关及对应分类审批流判断当前报告初始状态
|
|
|
-
|
|
|
+ // 这里实际上不会批量发布了...
|
|
|
reportArr := strings.Split(reportIds, ",")
|
|
|
tips := ""
|
|
|
for _, v := range reportArr {
|
|
@@ -307,28 +305,47 @@ func (this *ReportController) PublishReport() {
|
|
|
br.ErrMsg = "报告内容为空,不需要生成,report_id:" + strconv.Itoa(report.Id)
|
|
|
return
|
|
|
}
|
|
|
- if tmpErr = models.PublishReportById(report.Id, publishTime); tmpErr != nil {
|
|
|
- br.Msg = "报告发布失败"
|
|
|
- br.ErrMsg = "报告发布失败, Err:" + tmpErr.Error() + ", report_id:" + strconv.Itoa(report.Id)
|
|
|
+
|
|
|
+ // 根据审批开关及审批流判断当前报告状态
|
|
|
+ state, e := services.CheckReportCurrState(report_approve.FlowReportTypeChinese, report.ClassifyIdFirst, report.ClassifyIdSecond, models.ReportOperatePublish)
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "操作失败"
|
|
|
+ br.ErrMsg = "校验报告当前状态失败, Err: " + e.Error()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- go func() {
|
|
|
- // 生成音频
|
|
|
- if report.VideoUrl == "" {
|
|
|
- _ = services.CreateVideo(report)
|
|
|
+ if state == models.ReportStatePublished {
|
|
|
+ // 发布报告
|
|
|
+ if tmpErr = models.PublishReportById(report.Id, publishTime); tmpErr != nil {
|
|
|
+ br.Msg = "报告发布失败"
|
|
|
+ br.ErrMsg = "报告发布失败, Err:" + tmpErr.Error() + ", report_id:" + strconv.Itoa(report.Id)
|
|
|
+ return
|
|
|
}
|
|
|
- //// 推送找钢网
|
|
|
- //if utils.RunMode == "release" && (report.ClassifyNameSecond == "知白守黑日评" || report.ClassifyNameSecond == "股债日评") {
|
|
|
- // _ = services.ZhaoGangSend(report)
|
|
|
- //}
|
|
|
- // 更新报告Es
|
|
|
- _ = services.UpdateReportEs(report.Id, 2)
|
|
|
- }()
|
|
|
+ go func() {
|
|
|
+ // 生成音频
|
|
|
+ if report.VideoUrl == "" {
|
|
|
+ _ = services.CreateVideo(report)
|
|
|
+ }
|
|
|
+ //// 推送找钢网
|
|
|
+ //if utils.RunMode == "release" && (report.ClassifyNameSecond == "知白守黑日评" || report.ClassifyNameSecond == "股债日评") {
|
|
|
+ // _ = services.ZhaoGangSend(report)
|
|
|
+ //}
|
|
|
+ // 更新报告Es
|
|
|
+ _ = services.UpdateReportEs(report.Id, 2)
|
|
|
+ }()
|
|
|
+ } else {
|
|
|
+ // 从无审批切换为有审批, 状态重置
|
|
|
+ if e = models.ResetReportById(report.Id, state); tmpErr != nil {
|
|
|
+ br.Msg = "操作失败"
|
|
|
+ br.ErrMsg = fmt.Sprintf("重置报告状态失败, Err: %s, ReportId: %d", e.Error(), report.Id)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
recordItem := &models.ReportStateRecord{
|
|
|
ReportId: vint,
|
|
|
ReportType: 1,
|
|
|
- State: 2,
|
|
|
+ State: state,
|
|
|
AdminId: this.SysUser.AdminId,
|
|
|
AdminName: this.SysUser.AdminName,
|
|
|
CreateTime: time.Now(),
|
|
@@ -382,7 +399,16 @@ func (this *ReportController) PublishCancleReport() {
|
|
|
if reportInfo.MsgIsSend == 1 {
|
|
|
publishTimeNullFlag = false
|
|
|
}
|
|
|
- err = models.PublishCancleReport(req.ReportIds, publishTimeNullFlag)
|
|
|
+
|
|
|
+ // 根据审批开关及审批流判断当前报告状态
|
|
|
+ state, e := services.CheckReportCurrState(report_approve.FlowReportTypeChinese, reportInfo.ClassifyIdFirst, reportInfo.ClassifyIdSecond, models.ReportOperateCancelPublish)
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "操作失败"
|
|
|
+ br.ErrMsg = "校验报告当前状态失败, Err: " + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ err = models.PublishCancelReport(req.ReportIds, state, publishTimeNullFlag)
|
|
|
if err != nil {
|
|
|
br.Msg = "取消发布失败"
|
|
|
br.ErrMsg = "取消发布失败,Err:" + err.Error()
|
|
@@ -393,26 +419,24 @@ func (this *ReportController) PublishCancleReport() {
|
|
|
go services.UpdateReportEs(req.ReportIds, 1)
|
|
|
}
|
|
|
|
|
|
- // TODO:根据审批开关及对应分类审批流判断当前报告初始状态
|
|
|
-
|
|
|
- // 获取审批流设置
|
|
|
- confKey := "approval_flow"
|
|
|
- confTmp, e := company.GetConfigDetailByCode(confKey)
|
|
|
- if e != nil {
|
|
|
- br.Msg = "获取审批流配置失败"
|
|
|
- br.ErrMsg = "获取审批流配置失败, Err: " + e.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- if confTmp.ConfigValue == "1" || confTmp.ConfigValue == "2" || confTmp.ConfigValue == "3" {
|
|
|
- br.Msg = "撤销成功"
|
|
|
- } else {
|
|
|
- br.Msg = "取消发布成功"
|
|
|
- }
|
|
|
+ //// 获取审批流设置
|
|
|
+ //confKey := "approval_flow"
|
|
|
+ //confTmp, e := company.GetConfigDetailByCode(confKey)
|
|
|
+ //if e != nil {
|
|
|
+ // br.Msg = "获取审批流配置失败"
|
|
|
+ // br.ErrMsg = "获取审批流配置失败, Err: " + e.Error()
|
|
|
+ // return
|
|
|
+ //}
|
|
|
+ //if confTmp.ConfigValue == "1" || confTmp.ConfigValue == "2" || confTmp.ConfigValue == "3" {
|
|
|
+ // br.Msg = "撤销成功"
|
|
|
+ //} else {
|
|
|
+ // br.Msg = "取消发布成功"
|
|
|
+ //}
|
|
|
|
|
|
recordItem := &models.ReportStateRecord{
|
|
|
ReportId: req.ReportIds,
|
|
|
ReportType: 1,
|
|
|
- State: 1,
|
|
|
+ State: state,
|
|
|
AdminId: this.SysUser.AdminId,
|
|
|
AdminName: this.SysUser.AdminName,
|
|
|
CreateTime: time.Now(),
|
|
@@ -3344,6 +3368,18 @@ func (this *ReportController) PrePublishReport() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ // 校验是否开启了审批流
|
|
|
+ opening, e := services.CheckReportOpenApprove(report_approve.FlowReportTypeChinese, report.ClassifyIdFirst, report.ClassifyIdSecond)
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "操作失败"
|
|
|
+ br.ErrMsg = "校验报告是否开启审批流失败, Err: " + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if opening {
|
|
|
+ br.Msg = "报告已开启审批流, 不可设置定时发布"
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
var tmpErr error
|
|
|
if tmpErr = models.SetPrePublishReportById(report.Id, req.PrePublishTime, req.PreMsgSend); tmpErr != nil {
|
|
|
br.Msg = "设置定时发布失败"
|