ziwen 1 year ago
parent
commit
4f177f9f07
3 changed files with 44 additions and 7 deletions
  1. 27 6
      controllers/report.go
  2. 9 1
      controllers/sys_role.go
  3. 8 0
      models/report.go

+ 27 - 6
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"
@@ -289,7 +290,14 @@ func (this *ReportController) PublishReport() {
 		} else {
 			publishTime = time.Now()
 		}
-
+		// 获取审批流设置
+		confKey := "approval_flow"
+		confTmp, e := company.GetConfigDetailByCode(confKey)
+		if e != nil {
+			br.Msg = "获取审批流配置失败"
+			br.ErrMsg = "获取审批流配置失败, Err: " + e.Error()
+			return
+		}
 		var tmpErr error
 		if report.HasChapter == 1 && (report.ChapterType == utils.REPORT_TYPE_DAY || report.ChapterType == utils.REPORT_TYPE_WEEK) {
 			// 发布晨周报
@@ -304,11 +312,20 @@ 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)
-				return
+			if confTmp.ConfigValue == "1" || confTmp.ConfigValue == "3"{
+				if tmpErr = models.SubmitReportById(report.Id, publishTime); tmpErr != nil {
+					br.Msg = "提交审核失败"
+					br.ErrMsg = "提交审核失败, Err:" + tmpErr.Error() + ", report_id:" + strconv.Itoa(report.Id)
+					return
+				}
+			} else {
+				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 == "" {
@@ -319,7 +336,11 @@ func (this *ReportController) PublishReport() {
 				//	_ = services.ZhaoGangSend(report)
 				//}
 				// 更新报告Es
-				_ = services.UpdateReportEs(report.Id, 2)
+				if report.HasChapter != 1 && (confTmp.ConfigValue == "1" || confTmp.ConfigValue == "3"){
+					_ = services.UpdateReportEs(report.Id, 3)
+				} else {
+					_ = services.UpdateReportEs(report.Id, 2)
+				}
 			}()
 		}
 	}

+ 9 - 1
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"
@@ -717,9 +718,16 @@ 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: conf["ApprovalFlow"],
+		ConfVal: confTmp.ConfigValue,
 	})
 
 	br.Data = list

+ 8 - 0
models/report.go

@@ -1050,3 +1050,11 @@ func SetPrePublishReportById(reportId int, prePublishTime string, preMsgSend int
 	_, err = o.Raw(sql, prePublishTime, preMsgSend, reportId).Exec()
 	return
 }
+
+// 报告提交审核
+func SubmitReportById(reportId int, publishTime time.Time) (err error) {
+	o := orm.NewOrmUsingDB("rddp")
+	sql := `UPDATE report SET state = 3, publish_time = ?, pre_publish_time=null, pre_msg_send=0, modify_time = NOW() WHERE id = ? `
+	_, err = o.Raw(sql, publishTime, reportId).Exec()
+	return
+}