|
@@ -232,6 +232,7 @@ func (this *ReportController) ListReport() {
|
|
|
br.Data = resp
|
|
|
}
|
|
|
|
|
|
+// PublishReport
|
|
|
// @Title 发布报告接口
|
|
|
// @Description 发布报告
|
|
|
// @Param request body models.PublishReq true "type json string"
|
|
@@ -257,6 +258,7 @@ func (this *ReportController) PublishReport() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ // 这里实际上不会批量发布了...
|
|
|
reportArr := strings.Split(reportIds, ",")
|
|
|
tips := ""
|
|
|
for _, v := range reportArr {
|
|
@@ -276,23 +278,12 @@ func (this *ReportController) PublishReport() {
|
|
|
br.Msg = "报告不存在"
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
- // 图表刷新状态
|
|
|
- refreshResult := data.CheckBatchChartRefreshResult("report", vint, 0)
|
|
|
- if !refreshResult {
|
|
|
- br.Msg = "图表刷新未完成,请稍后操作"
|
|
|
- br.ErrMsg = "图表刷新未完成,请稍后操作"
|
|
|
- br.IsSendEmail = false
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
var publishTime time.Time
|
|
|
if report.MsgIsSend == 1 && report.PublishTime != "" { //如果报告曾经发布过,并且已经发送过模版消息,则章节的发布时间为报告的发布时间
|
|
|
publishTime, _ = time.ParseInLocation(utils.FormatDateTime, report.PublishTime, time.Local)
|
|
|
} else {
|
|
|
publishTime = time.Now()
|
|
|
}
|
|
|
-
|
|
|
var tmpErr error
|
|
|
if report.HasChapter == 1 && (report.ChapterType == utils.REPORT_TYPE_DAY || report.ChapterType == utils.REPORT_TYPE_WEEK) {
|
|
|
// 发布晨周报
|
|
@@ -307,22 +298,53 @@ 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
|
|
|
+ }
|
|
|
+ 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
|
|
|
}
|
|
|
- //// 推送找钢网
|
|
|
- //if utils.RunMode == "release" && (report.ClassifyNameSecond == "知白守黑日评" || report.ClassifyNameSecond == "股债日评") {
|
|
|
- // _ = services.ZhaoGangSend(report)
|
|
|
- //}
|
|
|
- // 更新报告Es
|
|
|
- _ = services.UpdateReportEs(report.Id, 2)
|
|
|
+ }
|
|
|
+
|
|
|
+ recordItem := &models.ReportStateRecord{
|
|
|
+ ReportId: vint,
|
|
|
+ ReportType: 1,
|
|
|
+ State: state,
|
|
|
+ AdminId: this.SysUser.AdminId,
|
|
|
+ AdminName: this.SysUser.AdminName,
|
|
|
+ CreateTime: time.Now(),
|
|
|
+ }
|
|
|
+ go func() {
|
|
|
+ _, _ = models.AddReportStateRecord(recordItem)
|
|
|
}()
|
|
|
}
|
|
|
}
|
|
@@ -336,6 +358,7 @@ func (this *ReportController) PublishReport() {
|
|
|
br.Msg = "发布成功"
|
|
|
}
|
|
|
|
|
|
+// PublishCancleReport
|
|
|
// @Title 取消发布报告接口
|
|
|
// @Description 取消发布报告
|
|
|
// @Param request body models.PublishCancelReq true "type json string"
|
|
@@ -369,7 +392,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()
|
|
@@ -380,9 +412,33 @@ func (this *ReportController) PublishCancleReport() {
|
|
|
go services.UpdateReportEs(req.ReportIds, 1)
|
|
|
}
|
|
|
|
|
|
+ //// 获取审批流设置
|
|
|
+ //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: state,
|
|
|
+ AdminId: this.SysUser.AdminId,
|
|
|
+ AdminName: this.SysUser.AdminName,
|
|
|
+ CreateTime: time.Now(),
|
|
|
+ }
|
|
|
+ go func() {
|
|
|
+ _, _ = models.AddReportStateRecord(recordItem)
|
|
|
+ }()
|
|
|
br.Ret = 200
|
|
|
br.Success = true
|
|
|
- br.Msg = "取消发布成功"
|
|
|
}
|
|
|
|
|
|
// @Title 删除报告接口
|
|
@@ -420,6 +476,7 @@ func (this *ReportController) Delete() {
|
|
|
br.Msg = "删除成功"
|
|
|
}
|
|
|
|
|
|
+// Add
|
|
|
// @Title 新增报告接口
|
|
|
// @Description 新增报告
|
|
|
// @Param request body models.AddReq true "type json string"
|
|
@@ -468,6 +525,14 @@ func (this *ReportController) Add() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ // 根据审批开关及审批流判断当前报告状态
|
|
|
+ state, e := services.CheckReportCurrState(report_approve.FlowReportTypeChinese, req.ClassifyIdFirst, req.ClassifyIdSecond, models.ReportOperateAdd)
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "操作失败"
|
|
|
+ br.ErrMsg = "校验报告当前状态失败, Err: " + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
item := new(models.Report)
|
|
|
item.AddType = req.AddType
|
|
|
item.ClassifyIdFirst = req.ClassifyIdFirst
|
|
@@ -478,7 +543,7 @@ func (this *ReportController) Add() {
|
|
|
item.Abstract = req.Abstract
|
|
|
item.Author = req.Author
|
|
|
item.Frequency = req.Frequency
|
|
|
- item.State = req.State
|
|
|
+ item.State = state
|
|
|
item.Content = html.EscapeString(req.Content)
|
|
|
item.Stage = maxStage + 1
|
|
|
item.ContentSub = html.EscapeString(contentSub)
|
|
@@ -493,8 +558,13 @@ func (this *ReportController) Add() {
|
|
|
br.ErrMsg = "保存失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
+ reportCode := utils.MD5(strconv.Itoa(int(newReportId)))
|
|
|
+ //修改唯一编码
|
|
|
+ {
|
|
|
+ go models.ModifyReportCode(newReportId, reportCode)
|
|
|
+ }
|
|
|
|
|
|
- // 处理权限
|
|
|
+ //处理权限
|
|
|
if utils.BusinessCode == utils.BusinessCodeRelease || utils.BusinessCode == utils.BusinessCodeSandbox {
|
|
|
go func() {
|
|
|
permissionItems, e := models.GetPermission(req.ClassifyNameSecond)
|
|
@@ -512,11 +582,18 @@ func (this *ReportController) Add() {
|
|
|
}()
|
|
|
}
|
|
|
|
|
|
- reportCode := utils.MD5(strconv.Itoa(int(newReportId)))
|
|
|
- //修改唯一编码
|
|
|
- {
|
|
|
- go models.ModifyReportCode(newReportId, reportCode)
|
|
|
+ recordItem := &models.ReportStateRecord{
|
|
|
+ ReportId: int(newReportId),
|
|
|
+ ReportType: 1,
|
|
|
+ State: 1,
|
|
|
+ AdminId: this.SysUser.AdminId,
|
|
|
+ AdminName: this.SysUser.AdminName,
|
|
|
+ CreateTime: time.Now(),
|
|
|
}
|
|
|
+ go func() {
|
|
|
+ _, _ = models.AddReportStateRecord(recordItem)
|
|
|
+ }()
|
|
|
+
|
|
|
resp := new(models.AddResp)
|
|
|
resp.ReportId = newReportId
|
|
|
resp.ReportCode = reportCode
|
|
@@ -526,6 +603,7 @@ func (this *ReportController) Add() {
|
|
|
br.Data = resp
|
|
|
}
|
|
|
|
|
|
+// Edit
|
|
|
// @Title 编辑报告接口
|
|
|
// @Description 编辑报告
|
|
|
// @Param request body models.EditReq true "type json string"
|
|
@@ -537,6 +615,14 @@ func (this *ReportController) Edit() {
|
|
|
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 models.EditReq
|
|
|
err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
if err != nil {
|
|
@@ -565,14 +651,6 @@ func (this *ReportController) Edit() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- sysUser := this.SysUser
|
|
|
- if sysUser == nil {
|
|
|
- br.Msg = "请登录"
|
|
|
- br.ErrMsg = "请登录,SysUser Is Empty"
|
|
|
- br.Ret = 408
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
//更新标记key
|
|
|
markStatus, err := services.UpdateReportEditMark(int(req.ReportId), sysUser.AdminId, 1, sysUser.RealName)
|
|
|
if err != nil {
|
|
@@ -596,6 +674,24 @@ func (this *ReportController) Edit() {
|
|
|
stage = report.Stage
|
|
|
}
|
|
|
}
|
|
|
+ if report.State == 2 {
|
|
|
+ br.Msg = "该报告已发布,不允许编辑"
|
|
|
+ br.ErrMsg = "该报告已发布,不允许编辑"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if req.State != report.State {
|
|
|
+ recordItem := &models.ReportStateRecord{
|
|
|
+ ReportId: int(req.ReportId),
|
|
|
+ ReportType: 1,
|
|
|
+ State: req.State,
|
|
|
+ AdminId: this.SysUser.AdminId,
|
|
|
+ AdminName: this.SysUser.AdminName,
|
|
|
+ CreateTime: time.Now(),
|
|
|
+ }
|
|
|
+ go func() {
|
|
|
+ _, _ = models.AddReportStateRecord(recordItem)
|
|
|
+ }()
|
|
|
+ }
|
|
|
|
|
|
item := new(models.Report)
|
|
|
item.ClassifyIdFirst = req.ClassifyIdFirst
|
|
@@ -2571,7 +2667,6 @@ func (this *ReportController) PrePublishReport() {
|
|
|
br.Msg = "发布时间不能为空"
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
if req.PreMsgSend != 0 && req.PreMsgSend != 1 {
|
|
|
br.Msg = "参数错误"
|
|
|
br.ErrMsg = "是否发送模版消息标识错误"
|
|
@@ -2616,6 +2711,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 = "设置定时发布失败"
|
|
@@ -2787,11 +2894,11 @@ func (this *ReportController) CancelApprove() {
|
|
|
br.Msg = "操作成功"
|
|
|
return
|
|
|
}
|
|
|
- if reportItem.ApproveId <= 0 {
|
|
|
- br.Msg = "报告审批不存在"
|
|
|
- br.ErrMsg = fmt.Sprintf("报告审批不存在, ApproveId: %d", reportItem.ApproveId)
|
|
|
- return
|
|
|
- }
|
|
|
+ //if reportItem.ApproveId <= 0 {
|
|
|
+ // br.Msg = "报告审批不存在"
|
|
|
+ // br.ErrMsg = fmt.Sprintf("报告审批不存在, ApproveId: %d", reportItem.ApproveId)
|
|
|
+ // return
|
|
|
+ //}
|
|
|
|
|
|
// 撤销审批
|
|
|
e = services.CancelReportApprove(report_approve.FlowReportTypeChinese, reportItem.Id, reportItem.ApproveId, sysUser.AdminId, sysUser.RealName)
|