zwxi hace 10 meses
padre
commit
26bdcb1bff

+ 3 - 1
controllers/report_approve/report_approve.go

@@ -10,6 +10,7 @@ import (
 	"fmt"
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"sort"
+	"strconv"
 	"strings"
 	"time"
 )
@@ -501,6 +502,7 @@ func (this *ReportApproveController) Detail() {
 	detail.Report.ReportType = approveItem.ReportType
 	detail.Report.ReportId = approveItem.ReportId
 	detail.Report.ReportTitle = approveItem.ReportTitle
+	detail.Report.ReportCode = utils.MD5(strconv.Itoa(approveItem.ReportId))
 	// 报告分类路由
 	if approveItem.ReportType == report_approve.FlowReportTypeChinese {
 		detail.Report.ReportClassify = fmt.Sprintf("%s/%s/%s", report_approve.FlowReportTypeMap[approveItem.ReportType], cnClassifyIdName[approveItem.ClassifyFirstId], cnClassifyIdName[approveItem.ClassifySecondId])
@@ -586,7 +588,7 @@ func (this *ReportApproveController) Approve() {
 	}
 
 	// 通过审批
-	tips, e := services.PassReportApprove(approveItem, recordItem, sysUser.AdminId)
+	tips, e := services.PassReportApprove(approveItem, recordItem, sysUser.AdminId, req.ReportUrl)
 	if e != nil {
 		br.Msg = "操作失败"
 		br.ErrMsg = "通过审批失败, Err: " + e.Error()

+ 3 - 1
models/report_approve/report_approve.go

@@ -378,6 +378,7 @@ type ReportApproveDetailReport struct {
 	ReportType     int    `description:"报告类型:1-中文研报;2-英文研报;3-智能研报"`
 	ReportId       int    `description:"报告ID"`
 	ReportTitle    string `description:"报告标题"`
+	ReportCode     string `description:"报告code"`
 	ReportClassify string `description:"报告分类"`
 	//ClassifyFirstId  int    `description:"一级分类ID"`
 	//ClassifySecondId int    `description:"二级分类ID"`
@@ -426,7 +427,8 @@ func (m *ReportApprove) CreateApproveAndRecord(approveItem *ReportApprove, recor
 
 // ReportApprovePassReq 审批通过请求体
 type ReportApprovePassReq struct {
-	ReportApproveId int `description:"审批ID"`
+	ReportApproveId int    `description:"审批ID"`
+	ReportUrl       string `description:"报告URL"`
 }
 
 // ReportApproveRefuseReq 审批驳回请求体

+ 6 - 3
services/report_approve.go

@@ -407,7 +407,7 @@ func updateReportApproveState(reportType, reportId, approveId, state int) (err e
 }
 
 // PassReportApprove 通过审批
-func PassReportApprove(approveItem *report_approve.ReportApprove, recordItem *report_approve.ReportApproveRecord, sysAdminId int) (tips string, err error) {
+func PassReportApprove(approveItem *report_approve.ReportApprove, recordItem *report_approve.ReportApproveRecord, sysAdminId int, reportUrl string) (tips string, err error) {
 	if approveItem == nil {
 		err = fmt.Errorf("审批信息有误")
 		return
@@ -655,7 +655,7 @@ func PassReportApprove(approveItem *report_approve.ReportApprove, recordItem *re
 
 		// 审批通过之后的处理
 		go func() {
-			if e = AfterReportApprovePass(approveItem.ReportType, approveItem.ReportId); e != nil {
+			if e = AfterReportApprovePass(approveItem.ReportType, approveItem.ReportId, reportUrl); e != nil {
 				utils.FileLog.Info(fmt.Sprintf("AfterReportApprovePass err: %s, ReportType: %d, ReportId: %d", e.Error(), approveItem.ReportType, approveItem.ReportId))
 				return
 			}
@@ -795,7 +795,7 @@ func BuildNextNodeRecordAndMsg(approveNodeItem *report_approve.ReportApproveNode
 }
 
 // AfterReportApprovePass 报告审批通过后的处理
-func AfterReportApprovePass(reportType, reportId int) (err error) {
+func AfterReportApprovePass(reportType, reportId int, reportUrl string) (err error) {
 	// 中文研报
 	if reportType == report_approve.FlowReportTypeChinese {
 		report, e := models.GetReportById(reportId)
@@ -842,6 +842,9 @@ func AfterReportApprovePass(reportType, reportId int) (err error) {
 
 		// ES更新报告
 		_ = SmartReportElasticUpsert(item.SmartReportId, models.ReportStatePublished)
+
+		// 生成报告pdf和长图
+		go Report2pdfAndJpeg(reportUrl, item.SmartReportId)
 	}
 	return
 }