Browse Source

Merge branch 'ETA_1.2.6'

ziwen 1 year ago
parent
commit
4321609a13

+ 63 - 3
controllers/report.go

@@ -3,6 +3,7 @@ package controllers
 import (
 	"encoding/json"
 	"eta/eta_api/models"
+	"eta/eta_api/models/company"
 	"eta/eta_api/services"
 	"eta/eta_api/services/alarm_msg"
 	"eta/eta_api/utils"
@@ -263,7 +264,6 @@ func (this *ReportController) PublishReport() {
 		br.ErrMsg = "参数错误,报告id不可为空"
 		return
 	}
-
 	reportArr := strings.Split(reportIds, ",")
 	tips := ""
 	for _, v := range reportArr {
@@ -289,7 +289,6 @@ func (this *ReportController) PublishReport() {
 		} else {
 			publishTime = time.Now()
 		}
-
 		var tmpErr error
 		if report.HasChapter == 1 && (report.ChapterType == utils.REPORT_TYPE_DAY || report.ChapterType == utils.REPORT_TYPE_WEEK) {
 			// 发布晨周报
@@ -309,6 +308,7 @@ func (this *ReportController) PublishReport() {
 				br.ErrMsg = "报告发布失败, Err:" + tmpErr.Error() + ", report_id:" + strconv.Itoa(report.Id)
 				return
 			}
+
 			go func() {
 				// 生成音频
 				if report.VideoUrl == "" {
@@ -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)
+			}()
 		}
 	}
 	// 发布晨周报部分章节未发布的提示
@@ -378,9 +389,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:      1,
+		AdminId:    this.SysUser.AdminId,
+		AdminName:  this.SysUser.AdminName,
+		CreateTime: time.Now(),
+	}
+	go func() {
+		_, _ = models.AddReportStateRecord(recordItem)
+	}()
 	br.Ret = 200
 	br.Success = true
-	br.Msg = "取消发布成功"
 }
 
 // Delete
@@ -517,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
@@ -602,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)

+ 14 - 0
controllers/sys_role.go

@@ -3,6 +3,7 @@ package controllers
 import (
 	"encoding/json"
 	"eta/eta_api/models"
+	"eta/eta_api/models/company"
 	"eta/eta_api/models/system"
 	"eta/eta_api/services"
 	"eta/eta_api/utils"
@@ -716,6 +717,19 @@ func (this *SysRoleController) SystemConfig() {
 	}
 	list = append(list, osc)
 
+	// 获取审批流设置
+	confKey := "approval_flow"
+	confTmp, e := company.GetConfigDetailByCode(confKey)
+	if e != nil {
+		br.Msg = "获取审批流配置失败"
+		br.ErrMsg = "获取审批流配置失败, Err: " + e.Error()
+		return
+	}
+	list = append(list, system.BusinessConf{
+		ConfKey: "ApprovalFlow",
+		ConfVal: confTmp.ConfigValue,
+	})
+
 	br.Data = list
 	br.Ret = 200
 	br.Success = true

+ 1 - 0
models/db.go

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

+ 3 - 3
models/report.go

@@ -55,7 +55,7 @@ type ReportList struct {
 	Frequency          string                    `description:"频度"`
 	CreateTime         string                    `description:"创建时间"`
 	ModifyTime         time.Time                 `description:"修改时间"`
-	State              int                       `description:"1:未发布,2:已发布"`
+	State              int                       `description:"1:未发布,2:已发布 3:已驳回 4:已审批"`
 	PublishTime        string                    `description:"发布时间"`
 	PrePublishTime     string                    `description:"预发布时间"`
 	Stage              int                       `description:"期数"`
@@ -122,7 +122,7 @@ func GetReportList(condition string, pars []interface{}, companyType string, sta
 	if condition != "" {
 		sql += condition
 	}
-	sql += `ORDER BY state ASC, modify_time DESC LIMIT ?,?`
+	sql += `ORDER BY FIELD(state,3,1,2,4), modify_time DESC LIMIT ?,?`
 	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
 	return
 }
@@ -1049,4 +1049,4 @@ func SetPrePublishReportById(reportId int, prePublishTime string, preMsgSend int
 	sql := `UPDATE report SET pre_publish_time=?, pre_msg_send=? WHERE id = ? and state = 1 `
 	_, err = o.Raw(sql, prePublishTime, preMsgSend, reportId).Exec()
 	return
-}
+}

+ 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 - 1
models/smart_report/smart_report.go

@@ -151,7 +151,7 @@ func (m *SmartReport) GetPageItemsByCondition(condition string, pars []interface
 	if len(fieldArr) == 0 {
 		fields = `*`
 	}
-	order := `ORDER BY create_time DESC`
+	order := `ORDER BY FIELD(state,3,1,2,4), create_time DESC`
 	if orderRule != "" {
 		order = ` ORDER BY ` + orderRule
 	}

+ 0 - 3
services/data/excel/excel_info.go

@@ -92,9 +92,6 @@ func GetExcelInfoOpButton(sysUser *system.Admin, belongUserId, source int) (butt
 	button.CopyButton = true
 	button.DownloadButton = true
 
-	if source == utils.EXCEL_DEFAULT {
-		button.OpButton = true
-	}
 
 	// 1、本用户创建的表格,可编辑、刷新、另存为、下载、删除,删除需二次确认;
 	// 2、管理员角色对所有表格有如上权限;

+ 4 - 1
services/minio.go

@@ -137,6 +137,7 @@ func UploadImgToMinIo(fileName, filePath string) (string, error) {
 	})
 	if err != nil {
 		log.Fatalln(err)
+		return "1", err
 	}
 	bucketName := utils.MinIoBucketname
 	// Check to see if we already own this bucket (which happens if you run this twice)
@@ -145,14 +146,16 @@ func UploadImgToMinIo(fileName, filePath string) (string, error) {
 		log.Printf("We already own %s\n", bucketName)
 	} else {
 		log.Fatalln(err)
+		return "2", err
 	}
-	path := utils.MinIoUpload_Audio_Dir + time.Now().Format("200601/20060102/")
+	path := utils.MinIoUploadDir + time.Now().Format("200601/20060102/")
 	path += fileName
 	// Upload the zip file with FPutObject
 	//contentType := "application/xlsx"
 	_, err = minioClient.FPutObject(ctx, bucketName, path, filePath, minio.PutObjectOptions{})
 	if err != nil {
 		log.Fatalln(err)
+		return "3", err
 	}
 
 	path = utils.MinIoImghost + path