Procházet zdrojové kódy

fix: 报告审批接口同步

hsun před 1 rokem
rodič
revize
637c1477fd

+ 70 - 26
controllers/english_report/report.go

@@ -9,7 +9,6 @@ import (
 	"eta/eta_mobile/models/system"
 	"eta/eta_mobile/services"
 	"eta/eta_mobile/services/alarm_msg"
-	"eta/eta_mobile/services/data"
 	"eta/eta_mobile/utils"
 	"fmt"
 	"github.com/rdlucklib/rdluck_tools/paging"
@@ -87,6 +86,14 @@ func (this *EnglishReportController) Add() {
 		return
 	}
 
+	// 根据审批开关及审批流判断当前报告状态
+	state, e := services.CheckReportCurrState(report_approve.FlowReportTypeEnglish, req.ClassifyIdFirst, req.ClassifyIdSecond, models.ReportOperateAdd)
+	if e != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "校验报告当前状态失败, Err: " + e.Error()
+		return
+	}
+
 	item := new(models.EnglishReport)
 	item.AddType = req.AddType
 	item.ClassifyIdFirst = req.ClassifyIdFirst
@@ -97,7 +104,7 @@ func (this *EnglishReportController) 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)
@@ -339,12 +346,12 @@ func (this *EnglishReportController) Detail() {
 // @Description 获取报告列表
 // @Param   PageSize   query   int  true       "每页数据条数"
 // @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
-// @Param   TimeType     query string true  "筛选的时间类别:publish_time(发布时间),modify_time(更新时间)"
+// @Param   TimeType     query string true  "筛选的时间类别:publish_time(发布时间),modify_time(更新时间);approve_time(审批时间)"
 // @Param   StartDate   query   string  true       "开始时间"
 // @Param   EndDate   query   string  true       "结束时间"
 // @Param   Frequency   query   string  true       "频度"
-// @Param   ClassifyNameFirst   query   string  true       "一级分类名称"
-// @Param   ClassifyNameSecond   query   string  true       "二级分类名称"
+// @Param   ClassifyIdFirst   query   string  true       "一级分类id"
+// @Param   ClassifyIdSecond   query   string  true       "二级分类id"
 // @Param   State   query   int  true       "状态"
 // @Param   KeyWord   query   string  true       "搜索关键词"
 // @Param   PublishSort   query   string  true       "desc:降序,asc 升序(预留)"
@@ -962,15 +969,6 @@ func (this *EnglishReportController) PublishReport() {
 			return
 		}
 
-		// 图表刷新状态
-		refreshResult := data.CheckBatchChartRefreshResult("report", vint, 0)
-		if !refreshResult {
-			br.Msg = "图表刷新未完成,请稍后操作"
-			br.ErrMsg = "图表刷新未完成,请稍后操作"
-			br.IsSendEmail = false
-			return
-		}
-
 		var tmpErr error
 
 		if report.Content == "" {
@@ -985,14 +983,33 @@ func (this *EnglishReportController) PublishReport() {
 		} else {
 			publishTime = time.Now().Format(utils.FormatDateTime)
 		}
-		if tmpErr = models.PublishEnglishReportById(report.Id, publishTime); tmpErr != nil {
-			br.Msg = "报告发布失败"
-			br.ErrMsg = "报告发布失败, Err:" + tmpErr.Error() + ", report_id:" + strconv.Itoa(report.Id)
+
+		// 根据审批开关及审批流判断当前报告状态
+		state, e := services.CheckReportCurrState(report_approve.FlowReportTypeEnglish, report.ClassifyIdFirst, report.ClassifyIdSecond, models.ReportOperatePublish)
+		if e != nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "校验报告当前状态失败, Err: " + e.Error()
 			return
 		}
-		go func() {
-			_ = services.UpdateEnglishReportEs(report.Id, 2)
-		}()
+
+		if state == models.ReportStatePublished {
+			// 发布报告
+			if tmpErr = models.PublishEnglishReportById(report.Id, publishTime); tmpErr != nil {
+				br.Msg = "报告发布失败"
+				br.ErrMsg = "报告发布失败, Err:" + tmpErr.Error() + ", report_id:" + strconv.Itoa(report.Id)
+				return
+			}
+			go func() {
+				_ = services.UpdateEnglishReportEs(report.Id, 2)
+			}()
+		} else {
+			// 从无审批切换为有审批, 状态重置
+			if e = models.ResetEnglishReportById(report.Id, state); tmpErr != nil {
+				br.Msg = "操作失败"
+				br.ErrMsg = fmt.Sprintf("重置英文报告状态失败, Err: %s, ReportId: %d", e.Error(), report.Id)
+				return
+			}
+		}
 	}
 
 	br.Ret = 200
@@ -1065,6 +1082,18 @@ func (this *EnglishReportController) PrePublishReport() {
 		return
 	}
 
+	// 校验是否开启了审批流
+	opening, e := services.CheckReportOpenApprove(report_approve.FlowReportTypeEnglish, 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.SetPrePublishEnglishReportById(report.Id, req.PrePublishTime); tmpErr != nil {
 		br.Msg = "设置定时发布失败"
@@ -1100,7 +1129,22 @@ func (this *EnglishReportController) PublishCancleReport() {
 		br.ErrMsg = "参数错误,报告id不可为空"
 		return
 	}
-	err = models.PublishCancelEnglishReport(req.ReportIds)
+	reportInfo, err := models.GetEnglishReportById(req.ReportIds)
+	if err != nil {
+		br.Msg = "获取报告信息失败"
+		br.ErrMsg = "获取报告信息失败,Err:" + err.Error()
+		return
+	}
+
+	// 根据审批开关及审批流判断当前报告状态
+	state, e := services.CheckReportCurrState(report_approve.FlowReportTypeEnglish, reportInfo.ClassifyIdFirst, reportInfo.ClassifyIdSecond, models.ReportOperateCancelPublish)
+	if e != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "校验报告当前状态失败, Err: " + e.Error()
+		return
+	}
+
+	err = models.PublishCancelEnglishReport(req.ReportIds, state)
 	if err != nil {
 		br.Msg = "取消发布失败"
 		br.ErrMsg = "取消发布失败,Err:" + err.Error()
@@ -1664,11 +1708,11 @@ func (this *EnglishReportController) 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.FlowReportTypeEnglish, reportItem.Id, reportItem.ApproveId, sysUser.AdminId, sysUser.RealName)

+ 153 - 46
controllers/report.go

@@ -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)

+ 1 - 0
models/db.go

@@ -143,6 +143,7 @@ func initReport() {
 		new(ClassifyMenu),         // 报告分类-子目录表
 		new(ClassifyMenuRelation), // 报告分类-子目录关联表
 		new(ReportChapterType),    // 报告章节类型表
+		new(ReportStateRecord),    // 研报状态修改记录表
 	)
 }
 

+ 13 - 5
models/english_report.go

@@ -330,7 +330,7 @@ func GetEnglishReportByCondition(condition string, pars []interface{}) (items []
 	return
 }
 
-// 发布报告
+// PublishEnglishReportById 发布报告
 func PublishEnglishReportById(reportId int, publishTime string) (err error) {
 	o := orm.NewOrmUsingDB("rddp")
 	sql := `UPDATE english_report SET state=2,publish_time=?,pre_publish_time=null,modify_time=NOW() WHERE id = ? `
@@ -338,11 +338,19 @@ func PublishEnglishReportById(reportId int, publishTime string) (err error) {
 	return
 }
 
-// 取消发布报告
-func PublishCancelEnglishReport(reportIds int) (err error) {
+// ResetEnglishReportById 重置报告状态
+func ResetEnglishReportById(reportId, state int) (err error) {
 	o := orm.NewOrmUsingDB("rddp")
-	sql := ` UPDATE english_report SET state=1,pre_publish_time=null WHERE id =?  `
-	_, err = o.Raw(sql, reportIds).Exec()
+	sql := `UPDATE english_report SET state = ?, pre_publish_time = null, modify_time = NOW() WHERE id = ?`
+	_, err = o.Raw(sql, state, reportId).Exec()
+	return
+}
+
+// PublishCancelEnglishReport 取消发布报告
+func PublishCancelEnglishReport(reportIds, state int) (err error) {
+	o := orm.NewOrmUsingDB("rddp")
+	sql := ` UPDATE english_report SET state=?, pre_publish_time=null WHERE id =?  `
+	_, err = o.Raw(sql, state, reportIds).Exec()
 	return
 }
 

+ 22 - 1
models/report.go

@@ -158,6 +158,19 @@ func PublishReport(reportIds string) (err error) {
 	return
 }
 
+// PublishCancelReport 取消发布报告
+func PublishCancelReport(reportId, state int, publishTimeNullFlag bool) (err error) {
+	o := orm.NewOrmUsingDB("rddp")
+	var sql string
+	if publishTimeNullFlag {
+		sql = ` UPDATE report SET state=?, publish_time=null, pre_publish_time=null, pre_msg_send=0 WHERE id =?`
+	} else {
+		sql = ` UPDATE report SET state=?, pre_publish_time=null, pre_msg_send=0 WHERE id =?`
+	}
+	_, err = o.Raw(sql, state, reportId).Exec()
+	return
+}
+
 // 取消发布报告
 func PublishCancleReport(reportIds int, publishTimeNullFlag bool) (err error) {
 	o := orm.NewOrmUsingDB("rddp")
@@ -630,7 +643,7 @@ func PublishReportAndChapter(reportInfo *Report, publishIds string, unPublishIds
 	return
 }
 
-// 发布报告
+// PublishReportById 发布报告
 func PublishReportById(reportId int, publishTime time.Time) (err error) {
 	o := orm.NewOrmUsingDB("rddp")
 	sql := `UPDATE report SET state = 2, publish_time = ?, pre_publish_time=null, pre_msg_send=0, modify_time = NOW() WHERE id = ? `
@@ -638,6 +651,14 @@ func PublishReportById(reportId int, publishTime time.Time) (err error) {
 	return
 }
 
+// ResetReportById 重置报告状态
+func ResetReportById(reportId, state int) (err error) {
+	o := orm.NewOrmUsingDB("rddp")
+	sql := `UPDATE report SET state = ?, pre_publish_time = null, pre_msg_send = 0, modify_time = NOW() WHERE id = ?`
+	_, err = o.Raw(sql, state, reportId).Exec()
+	return
+}
+
 // GetPageReportList 分页获取报告列表
 func GetPageReportList(condition string, pars []interface{}, startSize, pageSize int) (total int, items []*ReportList, err error) {
 	o := orm.NewOrmUsingDB("rddp")

+ 22 - 0
models/report_state_record.go

@@ -0,0 +1,22 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type ReportStateRecord struct {
+	Id         int       `orm:"column(id)" description:"Id"`
+	ReportId   int       // 研报id
+	ReportType int       // 报告类型'报告类型:1中文研报2智能研报'
+	State      int       // 状态:1-未提交 2-待审核 3-驳回 4-审核
+	AdminId    int       // 操作人id
+	AdminName  string    // 操作人姓名
+	CreateTime time.Time // 创建时间
+}
+
+func AddReportStateRecord(item *ReportStateRecord) (lastId int64, err error) {
+	o := orm.NewOrmUsingDB("rddp")
+	lastId, err = o.Insert(item)
+	return
+}

+ 1 - 3
services/report_approve.go

@@ -253,10 +253,8 @@ func CancelReportApprove(reportType, reportId, approveId, sysAdminId int, sysAdm
 	if confApproveType == "" {
 		confApproveType = models.BusinessConfReportApproveTypeEta
 	}
+	// 第三方审批仅修改报告状态
 	if confApproveType == models.BusinessConfReportApproveTypeOther {
-		return
-	}
-	if openApprove && confApproveType == models.BusinessConfReportApproveTypeOther {
 		e = updateReportApproveState(reportType, reportId, 0, models.ReportStateWaitSubmit)
 		if e != nil {
 			err = fmt.Errorf("更新报告审批撤回失败, Err: %s", e.Error())