Преглед изворни кода

研报状态修改记录表

ziwen пре 1 година
родитељ
комит
5a6b51b013
4 измењених фајлова са 95 додато и 2 уклоњено
  1. 49 1
      controllers/report.go
  2. 23 1
      controllers/smart_report/smart_report.go
  3. 1 0
      models/db.go
  4. 22 0
      models/report_state_record.go

+ 49 - 1
controllers/report.go

@@ -321,6 +321,17 @@ func (this *ReportController) PublishReport() {
 				// 更新报告Es
 				_ = services.UpdateReportEs(report.Id, 2)
 			}()
+			recordItem := &models.ReportStateRecord{
+				ReportId:   vint,
+				ReportType: 1,
+				State:      2,
+				AdminId:    this.SysUser.AdminId,
+				AdminName:  this.SysUser.AdminName,
+				CreateTime: time.Now(),
+			}
+			go func() {
+				_, _ = models.AddReportStateRecord(recordItem)
+			}()
 		}
 	}
 	// 发布晨周报部分章节未发布的提示
@@ -386,11 +397,23 @@ func (this *ReportController) PublishCancleReport() {
 		br.ErrMsg = "获取审批流配置失败, Err: " + e.Error()
 		return
 	}
-	if confTmp.ConfigValue == "1" || confTmp.ConfigValue == "2" || confTmp.ConfigValue == "3"{
+	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,
+		AdminId:    this.SysUser.AdminId,
+		AdminName:  this.SysUser.AdminName,
+		CreateTime: time.Now(),
+	}
+	go func() {
+		_, _ = models.AddReportStateRecord(recordItem)
+	}()
 	br.Ret = 200
 	br.Success = true
 }
@@ -529,6 +552,18 @@ func (this *ReportController) Add() {
 		}()
 	}
 
+	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
@@ -614,6 +649,19 @@ func (this *ReportController) Edit() {
 		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

+ 23 - 1
controllers/smart_report/smart_report.go

@@ -127,6 +127,18 @@ func (this *SmartReportController) Add() {
 	}
 	resp := smart_report.FormatSmartReport2Item(item)
 
+	recordItem := &models.ReportStateRecord{
+		ReportId:   item.SmartReportId,
+		ReportType: 2,
+		State:      smart_report.SmartReportStateWaitPublish,
+		AdminId:    this.SysUser.AdminId,
+		AdminName:  this.SysUser.AdminName,
+		CreateTime: time.Now(),
+	}
+	go func() {
+		_, _ = models.AddReportStateRecord(recordItem)
+	}()
+
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "操作成功"
@@ -437,7 +449,17 @@ func (this *SmartReportController) Publish() {
 		br.ErrMsg = "更新研报失败, Err: " + e.Error()
 		return
 	}
-
+	recordItem := &models.ReportStateRecord{
+		ReportId:   req.SmartReportId,
+		ReportType: 2,
+		State:     req.PublishState,
+		AdminId:    this.SysUser.AdminId,
+		AdminName:  this.SysUser.AdminName,
+		CreateTime: time.Now(),
+	}
+	go func() {
+		_, _ = models.AddReportStateRecord(recordItem)
+	}()
 	// 生成音频
 	if req.PublishState == smart_report.SmartReportStatePublished && item.VideoUrl == "" {
 		go smartReportService.SmartReportBuildVideoAndUpdate(item)

+ 1 - 0
models/db.go

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

+ 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
+}