|
@@ -5,10 +5,7 @@ import (
|
|
"eta/eta_api/controllers"
|
|
"eta/eta_api/controllers"
|
|
"eta/eta_api/models"
|
|
"eta/eta_api/models"
|
|
"eta/eta_api/models/report_approve"
|
|
"eta/eta_api/models/report_approve"
|
|
- "eta/eta_api/models/smart_report"
|
|
|
|
- "eta/eta_api/models/system"
|
|
|
|
"eta/eta_api/services"
|
|
"eta/eta_api/services"
|
|
- smartReportService "eta/eta_api/services/smart_report"
|
|
|
|
"eta/eta_api/utils"
|
|
"eta/eta_api/utils"
|
|
"fmt"
|
|
"fmt"
|
|
"github.com/rdlucklib/rdluck_tools/paging"
|
|
"github.com/rdlucklib/rdluck_tools/paging"
|
|
@@ -22,11 +19,140 @@ type ReportApproveFlowController struct {
|
|
controllers.BaseAuthController
|
|
controllers.BaseAuthController
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// List
|
|
|
|
+// @Title 报告列表
|
|
|
|
+// @Description 报告列表
|
|
|
|
+// @Param PageSize query int true "每页数据条数"
|
|
|
|
+// @Param CurrentIndex query int true "当前页页码"
|
|
|
|
+// @Param ReportType query int false "报告类型:1-中文研报;2-英文研报;3-智能研报"
|
|
|
|
+// @Param ClassifyIdFirst query int false "一级分类ID"
|
|
|
|
+// @Param ClassifyIdSecond query int false "二级分类ID"
|
|
|
|
+// @Param Keyword query string false "搜索关键词"
|
|
|
|
+// @Param SortRule query int false "排序方式: 1-正序; 2-倒序(默认)"
|
|
|
|
+// @Success 200 {object} report_approve.ReportApproveFlowListResp
|
|
|
|
+// @router /list [get]
|
|
|
|
+func (this *ReportApproveFlowController) List() {
|
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
|
+ defer func() {
|
|
|
|
+ if br.ErrMsg == "" {
|
|
|
|
+ br.IsSendEmail = false
|
|
|
|
+ }
|
|
|
|
+ this.Data["json"] = br
|
|
|
|
+ this.ServeJSON()
|
|
|
|
+ }()
|
|
|
|
+ sysUser := this.SysUser
|
|
|
|
+ if sysUser == nil {
|
|
|
|
+ br.Msg = "请登录"
|
|
|
|
+ br.ErrMsg = "请登录,SysUser Is Empty"
|
|
|
|
+ br.Ret = 408
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ params := new(report_approve.ReportApproveFlowListReq)
|
|
|
|
+ if e := this.ParseForm(params); e != nil {
|
|
|
|
+ br.Msg = "获取失败"
|
|
|
|
+ br.ErrMsg = "入参解析失败, Err: " + e.Error()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var cond, orderRule string
|
|
|
|
+ var pars []interface{}
|
|
|
|
+ // 筛选项
|
|
|
|
+ {
|
|
|
|
+ keyword := strings.TrimSpace(params.Keyword)
|
|
|
|
+ if keyword != "" {
|
|
|
|
+ kw := fmt.Sprint("%", keyword, "%")
|
|
|
|
+ cond += fmt.Sprintf(` AND %s LIKE ?`, report_approve.ReportApproveFlowCols.FlowName)
|
|
|
|
+ pars = append(pars, kw)
|
|
|
|
+ }
|
|
|
|
+ if params.ReportType > 0 && params.ClassifySecondId > 0 {
|
|
|
|
+ cond += fmt.Sprintf(` AND %s = ? AND %s = ?`, report_approve.ReportApproveFlowCols.ReportType, report_approve.ReportApproveFlowCols.ClassifySecondId)
|
|
|
|
+ pars = append(pars, params.ReportType, params.ClassifySecondId)
|
|
|
|
+ }
|
|
|
|
+ if params.SortRule > 0 {
|
|
|
|
+ orderMap := map[int]string{1: "ASC", 2: "DESC"}
|
|
|
|
+ orderRule = fmt.Sprintf("%s %s", report_approve.ReportApproveFlowCols.CreateTime, orderMap[params.SortRule])
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ resp := new(report_approve.ReportApproveFlowListResp)
|
|
|
|
+ flowOb := new(report_approve.ReportApproveFlow)
|
|
|
|
+ total, e := flowOb.GetCountByCondition(cond, pars)
|
|
|
|
+ if e != nil {
|
|
|
|
+ br.Msg = "获取失败"
|
|
|
|
+ br.ErrMsg = "获取审批流总数失败, Err:" + e.Error()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if total <= 0 {
|
|
|
|
+ page := paging.GetPaging(params.CurrentIndex, params.PageSize, total)
|
|
|
|
+ resp.Paging = page
|
|
|
|
+ br.Ret = 200
|
|
|
|
+ br.Success = true
|
|
|
|
+ br.Msg = "获取成功"
|
|
|
|
+ br.Data = resp
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 分页列表
|
|
|
|
+ var startSize int
|
|
|
|
+ if params.PageSize <= 0 {
|
|
|
|
+ params.PageSize = utils.PageSize20
|
|
|
|
+ }
|
|
|
|
+ if params.CurrentIndex <= 0 {
|
|
|
|
+ params.CurrentIndex = 1
|
|
|
|
+ }
|
|
|
|
+ startSize = utils.StartIndex(params.CurrentIndex, params.PageSize)
|
|
|
|
+
|
|
|
|
+ list, e := flowOb.GetPageItemsByCondition(cond, pars, []string{}, orderRule, startSize, params.PageSize)
|
|
|
|
+ if e != nil {
|
|
|
|
+ br.Msg = "获取失败"
|
|
|
|
+ br.ErrMsg = "获取审批流分页列表失败, Err:" + e.Error()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 指标分类
|
|
|
|
+ cnClassifyIdName, enClassifyIdName := make(map[int]string), make(map[int]string)
|
|
|
|
+ cnClassify, e := models.GetAllClassify()
|
|
|
|
+ if e != nil {
|
|
|
|
+ br.Msg = "获取失败"
|
|
|
|
+ br.ErrMsg = "获取中文分类失败, Err: " + e.Error()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ for _, v := range cnClassify {
|
|
|
|
+ cnClassifyIdName[v.Id] = v.ClassifyName
|
|
|
|
+ }
|
|
|
|
+ enClassify, e := models.GetAllEnglishClassify()
|
|
|
|
+ if e != nil {
|
|
|
|
+ br.Msg = "获取失败"
|
|
|
|
+ br.ErrMsg = "获取英文分类失败, Err: " + e.Error()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ for _, v := range enClassify {
|
|
|
|
+ enClassifyIdName[v.Id] = v.ClassifyName
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for _, v := range list {
|
|
|
|
+ t := report_approve.FormatReportApproveFlow2Item(v)
|
|
|
|
+ if v.ReportType == report_approve.FlowReportTypeEnglish {
|
|
|
|
+ t.ReportClassify = fmt.Sprintf("%s/%s/%s", report_approve.FlowReportTypeMap[v.ReportType], enClassifyIdName[v.ClassifyFirstId], enClassifyIdName[v.ClassifySecondId])
|
|
|
|
+ } else {
|
|
|
|
+ t.ReportClassify = fmt.Sprintf("%s/%s/%s", report_approve.FlowReportTypeMap[v.ReportType], cnClassifyIdName[v.ClassifyFirstId], cnClassifyIdName[v.ClassifySecondId])
|
|
|
|
+ }
|
|
|
|
+ resp.List = append(resp.List, t)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ page := paging.GetPaging(params.CurrentIndex, params.PageSize, total)
|
|
|
|
+ resp.Paging = page
|
|
|
|
+ br.Ret = 200
|
|
|
|
+ br.Success = true
|
|
|
|
+ br.Msg = "获取成功"
|
|
|
|
+ br.Data = resp
|
|
|
|
+}
|
|
|
|
+
|
|
// Add
|
|
// Add
|
|
-// @Title 新增
|
|
|
|
-// @Description 新增
|
|
|
|
-// @Param request body smart_report.SmartReportAddReq true "type json string"
|
|
|
|
-// @Success 200 {object} smart_report.SmartReportItem
|
|
|
|
|
|
+// @Title 新增审批流
|
|
|
|
+// @Description 新增审批流
|
|
|
|
+// @Param request body report_approve.ReportApproveFlowAddReq true "type json string"
|
|
|
|
+// @Success 200 {object} report_approve.ReportApproveDetailItem
|
|
// @router /add [post]
|
|
// @router /add [post]
|
|
func (this *ReportApproveFlowController) Add() {
|
|
func (this *ReportApproveFlowController) Add() {
|
|
br := new(models.BaseResponse).Init()
|
|
br := new(models.BaseResponse).Init()
|
|
@@ -44,120 +170,117 @@ func (this *ReportApproveFlowController) Add() {
|
|
br.Ret = 408
|
|
br.Ret = 408
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- var req smart_report.SmartReportAddReq
|
|
|
|
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
|
- if err != nil {
|
|
|
|
- br.Msg = "参数解析异常!"
|
|
|
|
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
|
|
|
+ var req report_approve.ReportApproveFlowAddReq
|
|
|
|
+ if e := json.Unmarshal(this.Ctx.Input.RequestBody, &req); e != nil {
|
|
|
|
+ br.Msg = "参数有误"
|
|
|
|
+ br.ErrMsg = "参数解析失败, Err: " + e.Error()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ req.FlowName = strings.TrimSpace(req.FlowName)
|
|
|
|
+ if req.FlowName == "" {
|
|
|
|
+ br.Msg = "请输入审批流名称"
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- if req.AddType != 1 && req.AddType != 2 {
|
|
|
|
- br.Msg = "请选择新增方式"
|
|
|
|
|
|
+ if len([]rune(req.FlowName)) > 20 {
|
|
|
|
+ br.Msg = "审批流名称最多输入20个字符"
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- if req.ClassifyIdFirst <= 0 || req.ClassifyIdSecond <= 0 {
|
|
|
|
- br.Msg = "请选择分类"
|
|
|
|
|
|
+ reportTypes := []int{report_approve.FlowReportTypeChinese, report_approve.FlowReportTypeEnglish, report_approve.FlowReportTypeSmart}
|
|
|
|
+ if !utils.InArrayByInt(reportTypes, req.ReportType) {
|
|
|
|
+ br.Msg = "审批流报告类型有误"
|
|
|
|
+ br.ErrMsg = fmt.Sprintf("审批流报告类型有误, ReportType: %d", req.ReportType)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- req.Title = strings.TrimSpace(req.Title)
|
|
|
|
- if req.Title == "" {
|
|
|
|
- br.Msg = "请输入标题"
|
|
|
|
|
|
+ if req.ClassifyFirstId <= 0 || req.ClassifySecondId <= 0 {
|
|
|
|
+ br.Msg = "请选择报告分类"
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+ if len(req.Nodes) <= 0 {
|
|
|
|
+ br.Msg = "请添加审批流程"
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ approveTypes := []int{report_approve.NodeApproveTypeRoll, report_approve.NodeApproveTypeAll, report_approve.NodeApproveTypeAny}
|
|
|
|
+ approveUserTypes := []string{report_approve.NodeUserTypeNormal, report_approve.NodeUserTypeRole}
|
|
|
|
+ for _, v := range req.Nodes {
|
|
|
|
+ if !utils.InArrayByInt(approveTypes, v.ApproveType) {
|
|
|
|
+ br.Msg = "审批流类型有误"
|
|
|
|
+ br.ErrMsg = fmt.Sprintf("审批流类型有误, ApproveType: %d", v.ApproveType)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ for _, v2 := range v.Users {
|
|
|
|
+ if !utils.InArrayByStr(approveUserTypes, v2.UserType) {
|
|
|
|
+ br.Msg = "审批流用户类型有误"
|
|
|
|
+ br.ErrMsg = fmt.Sprintf("审批流用户类型有误, UserType: %d", v2.UserType)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
- reportOB := new(smart_report.SmartReport)
|
|
|
|
- stageMax, e := reportOB.GetMaxStageByClassifyId(req.ClassifyIdSecond)
|
|
|
|
- if e != nil {
|
|
|
|
- br.Msg = "操作失败"
|
|
|
|
- br.ErrMsg = "获取期数失败, Err: " + e.Error()
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- stageMax += 1
|
|
|
|
-
|
|
|
|
- item := new(smart_report.SmartReport)
|
|
|
|
- item.AddType = req.AddType
|
|
|
|
- item.ClassifyIdFirst = req.ClassifyIdFirst
|
|
|
|
- item.ClassifyNameFirst = req.ClassifyNameFirst
|
|
|
|
- item.ClassifyIdSecond = req.ClassifyIdSecond
|
|
|
|
- item.ClassifyNameSecond = req.ClassifyNameSecond
|
|
|
|
- item.Title = req.Title
|
|
|
|
- item.Abstract = req.Abstract
|
|
|
|
- item.Author = req.Author
|
|
|
|
- item.Frequency = req.Frequency
|
|
|
|
- item.Stage = stageMax
|
|
|
|
- item.AdminId = sysUser.AdminId
|
|
|
|
- item.AdminRealName = sysUser.RealName
|
|
|
|
- item.LastModifyAdminId = sysUser.AdminId
|
|
|
|
- item.LastModifyAdminName = sysUser.RealName
|
|
|
|
- item.State = smart_report.SmartReportStateWaitPublish
|
|
|
|
- item.CreateTime = time.Now().Local()
|
|
|
|
- item.ModifyTime = time.Now().Local()
|
|
|
|
- // 继承报告
|
|
|
|
- if req.AddType == 2 {
|
|
|
|
- ob := new(smart_report.SmartReport)
|
|
|
|
- cond := ` AND classify_id_first = ? AND classify_id_second = ?`
|
|
|
|
- pars := make([]interface{}, 0)
|
|
|
|
- pars = append(pars, req.ClassifyIdFirst, req.ClassifyIdSecond)
|
|
|
|
- lastReport, e := ob.GetItemByCondition(cond, pars, "stage DESC")
|
|
|
|
|
|
+ // 审批流是否已存在
|
|
|
|
+ {
|
|
|
|
+ flowOb := new(report_approve.ReportApproveFlow)
|
|
|
|
+ existCond := fmt.Sprintf(` AND %s = ? AND %s = ? AND %s = ?`, report_approve.ReportApproveFlowCols.ReportType, report_approve.ReportApproveFlowCols.ClassifyFirstId, report_approve.ReportApproveFlowCols.ClassifySecondId)
|
|
|
|
+ existPars := make([]interface{}, 0)
|
|
|
|
+ existPars = append(existPars, req.ReportType, req.ClassifyFirstId, req.ClassifySecondId)
|
|
|
|
+ exist, e := flowOb.GetItemByCondition(existCond, existPars, "")
|
|
if e != nil && e.Error() != utils.ErrNoRow() {
|
|
if e != nil && e.Error() != utils.ErrNoRow() {
|
|
br.Msg = "获取失败"
|
|
br.Msg = "获取失败"
|
|
- br.ErrMsg = "获取往期研报失败, Err: " + e.Error()
|
|
|
|
|
|
+ br.ErrMsg = "获取审批流是否已存在失败, Err: " + e.Error()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- if lastReport != nil {
|
|
|
|
- item.Content = lastReport.Content
|
|
|
|
- item.ContentSub = lastReport.ContentSub
|
|
|
|
- item.ContentStruct = lastReport.ContentStruct
|
|
|
|
|
|
+ if exist != nil {
|
|
|
|
+ br.Msg = "该分类已有审批流, 请勿重复添加"
|
|
|
|
+ return
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if e = item.Create(); e != nil {
|
|
|
|
- br.Msg = "操作失败"
|
|
|
|
- br.ErrMsg = "新增研报失败, Err: " + e.Error()
|
|
|
|
- return
|
|
|
|
|
|
+
|
|
|
|
+ flowItem := new(report_approve.ReportApproveFlow)
|
|
|
|
+ flowItem.FlowName = req.FlowName
|
|
|
|
+ flowItem.ReportType = req.ReportType
|
|
|
|
+ flowItem.ClassifyFirstId = req.ClassifyFirstId
|
|
|
|
+ flowItem.ClassifySecondId = req.ClassifySecondId
|
|
|
|
+ flowItem.CurrVersion = 1
|
|
|
|
+ flowItem.CreateTime = time.Now().Local()
|
|
|
|
+ flowItem.ModifyTime = time.Now().Local()
|
|
|
|
+
|
|
|
|
+ nodeItems := make([]*report_approve.ReportApproveNode, 0)
|
|
|
|
+ for _, v := range req.Nodes {
|
|
|
|
+ n := new(report_approve.ReportApproveNode)
|
|
|
|
+ n.ApproveType = v.ApproveType
|
|
|
|
+ n.CurrVersion = flowItem.CurrVersion
|
|
|
|
+ j, _ := json.Marshal(v.Users)
|
|
|
|
+ n.Users = string(j)
|
|
|
|
+ n.CreateTime = time.Now().Local()
|
|
|
|
+ nodeItems = append(nodeItems, n)
|
|
}
|
|
}
|
|
- uniqueCode := utils.MD5(fmt.Sprint("smart_", item.SmartReportId))
|
|
|
|
- item.ReportCode = uniqueCode
|
|
|
|
- if e = item.Update([]string{"ReportCode"}); e != nil {
|
|
|
|
|
|
+
|
|
|
|
+ // 新增审批流和节点
|
|
|
|
+ if e := flowItem.CreateFlowAndNodes(flowItem, nodeItems); e != nil {
|
|
br.Msg = "操作失败"
|
|
br.Msg = "操作失败"
|
|
- br.ErrMsg = "更新研报编码失败, Err: " + e.Error()
|
|
|
|
|
|
+ br.ErrMsg = "新增审批流和节点失败, Err: " + e.Error()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- 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(),
|
|
|
|
|
|
+ // 返回详情
|
|
|
|
+ detail, e := report_approve.FormatFlowAndNodesItem2Detail(flowItem, nodeItems)
|
|
|
|
+ if e != nil {
|
|
|
|
+ br.Msg = "获取失败"
|
|
|
|
+ br.ErrMsg = "获取审批详情失败, Err: " + e.Error()
|
|
|
|
+ return
|
|
}
|
|
}
|
|
- go func() {
|
|
|
|
- _, _ = models.AddReportStateRecord(recordItem)
|
|
|
|
- }()
|
|
|
|
-
|
|
|
|
|
|
+ br.Data = detail
|
|
br.Ret = 200
|
|
br.Ret = 200
|
|
br.Success = true
|
|
br.Success = true
|
|
br.Msg = "操作成功"
|
|
br.Msg = "操作成功"
|
|
- br.Data = resp
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-// List
|
|
|
|
-// @Title 报告列表
|
|
|
|
-// @Description 报告列表
|
|
|
|
-// @Param PageSize query int true "每页数据条数"
|
|
|
|
-// @Param CurrentIndex query int true "当前页页码"
|
|
|
|
-// @Param TimeType query string false "筛选的时间类别: publish_time-发布时间, modify_time-更新时间"
|
|
|
|
-// @Param StartDate query string false "开始时间"
|
|
|
|
-// @Param EndDate query string false "结束时间"
|
|
|
|
-// @Param Frequency query string false "频度"
|
|
|
|
-// @Param ClassifyIdFirst query int false "一级分类ID"
|
|
|
|
-// @Param ClassifyIdSecond query int false "二级分类ID"
|
|
|
|
-// @Param State query int false "发布状态: 1-待发布; 2-已发布"
|
|
|
|
-// @Param Keyword query string false "搜索关键词"
|
|
|
|
-// @Success 200 {object} smart_report.SmartReportListResp
|
|
|
|
-// @router /list [get]
|
|
|
|
-func (this *ReportApproveFlowController) List() {
|
|
|
|
|
|
+// Edit
|
|
|
|
+// @Title 编辑审批流
|
|
|
|
+// @Description 编辑审批流
|
|
|
|
+// @Param request body report_approve.ReportApproveFlowEditReq true "type json string"
|
|
|
|
+// @Success 200 {object} report_approve.ReportApproveDetailItem
|
|
|
|
+// @router /edit [post]
|
|
|
|
+func (this *ReportApproveFlowController) Edit() {
|
|
br := new(models.BaseResponse).Init()
|
|
br := new(models.BaseResponse).Init()
|
|
defer func() {
|
|
defer func() {
|
|
if br.ErrMsg == "" {
|
|
if br.ErrMsg == "" {
|
|
@@ -173,151 +296,277 @@ func (this *ReportApproveFlowController) List() {
|
|
br.Ret = 408
|
|
br.Ret = 408
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- type SmartReportListReq struct {
|
|
|
|
- PageSize int `form:"PageSize"`
|
|
|
|
- CurrentIndex int `form:"CurrentIndex"`
|
|
|
|
- TimeType string `form:"TimeType"`
|
|
|
|
- StartDate string `form:"StartDate"`
|
|
|
|
- EndDate string `form:"EndDate"`
|
|
|
|
- Frequency string `form:"Frequency"`
|
|
|
|
- ClassifyIdFirst int `form:"ClassifyIdFirst"`
|
|
|
|
- ClassifyIdSecond int `form:"ClassifyIdSecond"`
|
|
|
|
- State int `form:"State"`
|
|
|
|
- Keyword string `form:"Keyword"`
|
|
|
|
|
|
+ var req report_approve.ReportApproveFlowEditReq
|
|
|
|
+ if e := json.Unmarshal(this.Ctx.Input.RequestBody, &req); e != nil {
|
|
|
|
+ br.Msg = "参数有误"
|
|
|
|
+ br.ErrMsg = "参数解析失败, Err: " + e.Error()
|
|
|
|
+ return
|
|
}
|
|
}
|
|
- params := new(SmartReportListReq)
|
|
|
|
- if e := this.ParseForm(params); e != nil {
|
|
|
|
- br.Msg = "获取失败"
|
|
|
|
- br.ErrMsg = "入参解析失败, Err: " + e.Error()
|
|
|
|
|
|
+ if req.ReportApproveFlowId <= 0 {
|
|
|
|
+ br.Msg = "参数有误"
|
|
|
|
+ br.ErrMsg = fmt.Sprintf("参数有误, ReportApproveFlowId: %d", req.ReportApproveFlowId)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- if params.TimeType == "" {
|
|
|
|
- params.TimeType = "publish_time"
|
|
|
|
|
|
+ req.FlowName = strings.TrimSpace(req.FlowName)
|
|
|
|
+ if req.FlowName == "" {
|
|
|
|
+ br.Msg = "请输入审批流名称"
|
|
|
|
+ return
|
|
}
|
|
}
|
|
- if params.TimeType != "publish_time" && params.TimeType != "modify_time" {
|
|
|
|
- br.Msg = "请选择正确的时间类型"
|
|
|
|
|
|
+ if len([]rune(req.FlowName)) > 20 {
|
|
|
|
+ br.Msg = "审批流名称最多输入20个字符"
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- // 更新时间指的是内容更新时间
|
|
|
|
- if params.TimeType == "modify_time" {
|
|
|
|
- params.TimeType = "content_modify_time"
|
|
|
|
|
|
+ reportTypes := []int{report_approve.FlowReportTypeChinese, report_approve.FlowReportTypeEnglish, report_approve.FlowReportTypeSmart}
|
|
|
|
+ if !utils.InArrayByInt(reportTypes, req.ReportType) {
|
|
|
|
+ br.Msg = "审批流报告类型有误"
|
|
|
|
+ br.ErrMsg = fmt.Sprintf("审批流报告类型有误, ReportType: %d", req.ReportType)
|
|
|
|
+ return
|
|
}
|
|
}
|
|
-
|
|
|
|
- var condition string
|
|
|
|
- var pars []interface{}
|
|
|
|
- // 筛选项
|
|
|
|
- {
|
|
|
|
- keyword := strings.TrimSpace(params.Keyword)
|
|
|
|
- if keyword != "" {
|
|
|
|
- kw := fmt.Sprint("%", keyword, "%")
|
|
|
|
- condition += fmt.Sprintf(` AND (title LIKE ? OR admin_real_name LIKE ? OR last_modify_admin_name LIKE ?)`)
|
|
|
|
- pars = append(pars, kw, kw, kw)
|
|
|
|
|
|
+ if req.ClassifyFirstId <= 0 || req.ClassifySecondId <= 0 {
|
|
|
|
+ br.Msg = "请选择报告分类"
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if len(req.Nodes) <= 0 {
|
|
|
|
+ br.Msg = "请添加审批流程"
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ approveTypes := []int{report_approve.NodeApproveTypeRoll, report_approve.NodeApproveTypeAll, report_approve.NodeApproveTypeAny}
|
|
|
|
+ approveUserTypes := []string{report_approve.NodeUserTypeNormal, report_approve.NodeUserTypeRole}
|
|
|
|
+ for _, v := range req.Nodes {
|
|
|
|
+ if !utils.InArrayByInt(approveTypes, v.ApproveType) {
|
|
|
|
+ br.Msg = "审批流类型有误"
|
|
|
|
+ br.ErrMsg = fmt.Sprintf("审批流类型有误, ApproveType: %d", v.ApproveType)
|
|
|
|
+ return
|
|
}
|
|
}
|
|
- if params.StartDate != "" && params.EndDate != "" {
|
|
|
|
- st := fmt.Sprintf("%s 00:00:00", params.StartDate)
|
|
|
|
- ed := fmt.Sprintf("%s 23:59:59", params.EndDate)
|
|
|
|
- condition += fmt.Sprintf(` AND %s >= ? AND %s <= ?`, params.TimeType, params.TimeType)
|
|
|
|
- pars = append(pars, st, ed)
|
|
|
|
|
|
+ for _, v2 := range v.Users {
|
|
|
|
+ if !utils.InArrayByStr(approveUserTypes, v2.UserType) {
|
|
|
|
+ br.Msg = "审批流用户类型有误"
|
|
|
|
+ br.ErrMsg = fmt.Sprintf("审批流用户类型有误, UserType: %d", v2.UserType)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- if params.Frequency != "" {
|
|
|
|
- condition += ` AND frequency = ?`
|
|
|
|
- pars = append(pars, params.Frequency)
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ flowOb := new(report_approve.ReportApproveFlow)
|
|
|
|
+ flowItem, e := flowOb.GetItemById(req.ReportApproveFlowId)
|
|
|
|
+ if e != nil {
|
|
|
|
+ if e.Error() == utils.ErrNoRow() {
|
|
|
|
+ br.Msg = "审批流已被删除, 请刷新页面"
|
|
|
|
+ return
|
|
}
|
|
}
|
|
- if params.ClassifyIdFirst > 0 {
|
|
|
|
- condition += ` AND classify_id_first = ?`
|
|
|
|
- pars = append(pars, params.ClassifyIdFirst)
|
|
|
|
|
|
+ br.Msg = "操作失败"
|
|
|
|
+ br.ErrMsg = "获取审批流信息失败, Err: " + e.Error()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 审批流是否已存在
|
|
|
|
+ {
|
|
|
|
+ existCond := fmt.Sprintf(` AND %s = ? AND %s = ? AND %s = ? AND %s <> ?`, report_approve.ReportApproveFlowCols.ReportType, report_approve.ReportApproveFlowCols.ClassifyFirstId, report_approve.ReportApproveFlowCols.ClassifySecondId, report_approve.ReportApproveFlowCols.ReportApproveFlowId)
|
|
|
|
+ existPars := make([]interface{}, 0)
|
|
|
|
+ existPars = append(existPars, req.ReportType, req.ClassifyFirstId, req.ClassifySecondId, req.ReportApproveFlowId)
|
|
|
|
+ exist, e := flowOb.GetItemByCondition(existCond, existPars, "")
|
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
|
+ br.Msg = "操作失败"
|
|
|
|
+ br.ErrMsg = "获取审批流是否已存在失败, Err: " + e.Error()
|
|
|
|
+ return
|
|
}
|
|
}
|
|
- if params.ClassifyIdSecond > 0 {
|
|
|
|
- condition += ` AND classify_id_second = ?`
|
|
|
|
- pars = append(pars, params.ClassifyIdSecond)
|
|
|
|
|
|
+ if exist != nil {
|
|
|
|
+ br.Msg = "该分类已有审批流, 请勿重复添加"
|
|
|
|
+ return
|
|
}
|
|
}
|
|
- if params.State > 0 {
|
|
|
|
- condition += ` AND state = ?`
|
|
|
|
- pars = append(pars, params.State)
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 变更了报告分类时, 判断是否允许变更
|
|
|
|
+ if req.ReportType != flowItem.ReportType || req.ClassifyFirstId != flowItem.ClassifyFirstId || req.ClassifySecondId != flowItem.ClassifySecondId {
|
|
|
|
+ checkOk, e := services.CheckReportApproveFlowChange(flowItem.ReportType, flowItem.ClassifyFirstId, flowItem.ClassifySecondId)
|
|
|
|
+ if e != nil {
|
|
|
|
+ br.Msg = "操作失败"
|
|
|
|
+ br.ErrMsg = "校验审批流是否可变更失败, Err: " + e.Error()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if !checkOk {
|
|
|
|
+ br.Msg = "当前有未走完流程的报告, 请走完流程后再做变更!"
|
|
|
|
+ return
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- resp := new(smart_report.SmartReportListResp)
|
|
|
|
- reportOB := new(smart_report.SmartReport)
|
|
|
|
- total, e := reportOB.GetCountByCondition(condition, pars)
|
|
|
|
- if e != nil {
|
|
|
|
- br.Msg = "获取失败"
|
|
|
|
- br.ErrMsg = "获取报告总数失败, Err:" + e.Error()
|
|
|
|
|
|
+ flowItem.FlowName = req.FlowName
|
|
|
|
+ flowItem.ReportType = req.ReportType
|
|
|
|
+ flowItem.ClassifyFirstId = req.ClassifyFirstId
|
|
|
|
+ flowItem.ClassifySecondId = req.ClassifySecondId
|
|
|
|
+ flowItem.CurrVersion += 1
|
|
|
|
+ flowItem.ModifyTime = time.Now().Local()
|
|
|
|
+
|
|
|
|
+ nodeItems := make([]*report_approve.ReportApproveNode, 0)
|
|
|
|
+ for _, v := range req.Nodes {
|
|
|
|
+ n := new(report_approve.ReportApproveNode)
|
|
|
|
+ n.ApproveType = v.ApproveType
|
|
|
|
+ n.CurrVersion = flowItem.CurrVersion
|
|
|
|
+ j, _ := json.Marshal(v.Users)
|
|
|
|
+ n.Users = string(j)
|
|
|
|
+ n.CreateTime = time.Now().Local()
|
|
|
|
+ nodeItems = append(nodeItems, n)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 更新审批流和节点
|
|
|
|
+ if e := flowItem.UpdateFlowAndNodes(flowItem, nodeItems); e != nil {
|
|
|
|
+ br.Msg = "操作失败"
|
|
|
|
+ br.ErrMsg = "更新审批流和节点失败, Err: " + e.Error()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- if total <= 0 {
|
|
|
|
- page := paging.GetPaging(params.CurrentIndex, params.PageSize, total)
|
|
|
|
- resp.Paging = page
|
|
|
|
- br.Ret = 200
|
|
|
|
- br.Success = true
|
|
|
|
- br.Msg = "获取成功"
|
|
|
|
- br.Data = resp
|
|
|
|
|
|
+
|
|
|
|
+ // 返回详情
|
|
|
|
+ detail, e := report_approve.FormatFlowAndNodesItem2Detail(flowItem, nodeItems)
|
|
|
|
+ if e != nil {
|
|
|
|
+ br.Msg = "获取失败"
|
|
|
|
+ br.ErrMsg = "获取审批详情失败, Err: " + e.Error()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+ br.Data = detail
|
|
|
|
+ br.Ret = 200
|
|
|
|
+ br.Success = true
|
|
|
|
+ br.Msg = "操作成功"
|
|
|
|
+}
|
|
|
|
|
|
- // 分页列表
|
|
|
|
- var startSize int
|
|
|
|
- if params.PageSize <= 0 {
|
|
|
|
- params.PageSize = utils.PageSize20
|
|
|
|
|
|
+// Detail
|
|
|
|
+// @Title 审批流详情
|
|
|
|
+// @Description 审批流详情
|
|
|
|
+// @Param ReportApproveFlowId query int true "审批流ID"
|
|
|
|
+// @Success 200 {object} report_approve.ReportApproveDetailItem
|
|
|
|
+// @router /detail [get]
|
|
|
|
+func (this *ReportApproveFlowController) Detail() {
|
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
|
+ defer func() {
|
|
|
|
+ if br.ErrMsg == "" {
|
|
|
|
+ br.IsSendEmail = false
|
|
|
|
+ }
|
|
|
|
+ this.Data["json"] = br
|
|
|
|
+ this.ServeJSON()
|
|
|
|
+ }()
|
|
|
|
+ sysUser := this.SysUser
|
|
|
|
+ if sysUser == nil {
|
|
|
|
+ br.Msg = "请登录"
|
|
|
|
+ br.ErrMsg = "请登录,SysUser Is Empty"
|
|
|
|
+ br.Ret = 408
|
|
|
|
+ return
|
|
}
|
|
}
|
|
- if params.CurrentIndex <= 0 {
|
|
|
|
- params.CurrentIndex = 1
|
|
|
|
|
|
+ flowId, _ := this.GetInt("ReportApproveFlowId")
|
|
|
|
+ if flowId <= 0 {
|
|
|
|
+ br.Msg = "参数有误"
|
|
|
|
+ br.ErrMsg = fmt.Sprintf("参数有误, ReportApproveFlowId: %d", flowId)
|
|
|
|
+ return
|
|
}
|
|
}
|
|
- startSize = utils.StartIndex(params.CurrentIndex, params.PageSize)
|
|
|
|
|
|
|
|
- // 列表查询过滤掉富文本内容
|
|
|
|
- fields := []string{
|
|
|
|
- "smart_report_id", "report_code", "classify_id_first", "classify_name_first", "classify_id_second", "classify_name_second", "add_type",
|
|
|
|
- "title", "abstract", "author", "frequency", "stage", "video_url", "video_name", "video_play_seconds", "video_size", "detail_img_url", "detail_pdf_url",
|
|
|
|
- "admin_id", "admin_real_name", "state", "publish_time", "pre_publish_time", "pre_msg_send", "msg_is_send", "msg_send_time", "create_time", "modify_time",
|
|
|
|
- "last_modify_admin_id", "last_modify_admin_name", "content_modify_time", "pv", "uv",
|
|
|
|
|
|
+ flowOb := new(report_approve.ReportApproveFlow)
|
|
|
|
+ flowItem, e := flowOb.GetItemById(flowId)
|
|
|
|
+ if e != nil {
|
|
|
|
+ if e.Error() == utils.ErrNoRow() {
|
|
|
|
+ br.Msg = "审批流已被删除, 请刷新页面"
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ br.Msg = "获取失败"
|
|
|
|
+ br.ErrMsg = "获取审批流信息失败, Err: " + e.Error()
|
|
|
|
+ return
|
|
}
|
|
}
|
|
- list, e := reportOB.GetPageItemsByCondition(condition, pars, fields, "", startSize, params.PageSize)
|
|
|
|
|
|
+
|
|
|
|
+ // 审批节点
|
|
|
|
+ nodeOb := new(report_approve.ReportApproveNode)
|
|
|
|
+ nodeCond := fmt.Sprintf(` AND %s = ? AND %s = ?`, report_approve.ReportApproveNodeCols.ReportApproveFlowId, report_approve.ReportApproveNodeCols.CurrVersion)
|
|
|
|
+ nodePars := make([]interface{}, 0)
|
|
|
|
+ nodePars = append(nodePars, flowItem.ReportApproveFlowId, flowItem.CurrVersion)
|
|
|
|
+ nodes, e := nodeOb.GetItemsByCondition(nodeCond, nodePars, []string{}, "")
|
|
if e != nil {
|
|
if e != nil {
|
|
br.Msg = "获取失败"
|
|
br.Msg = "获取失败"
|
|
- br.ErrMsg = "获取报告分页列表失败, Err:" + e.Error()
|
|
|
|
|
|
+ br.ErrMsg = "获取审批节点失败, Err: " + e.Error()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
- // 获取系统用户列表-用于匹配编辑中的用户
|
|
|
|
- adminIdName := make(map[int]string)
|
|
|
|
- admins, e := system.GetSysAdminList(``, make([]interface{}, 0), []string{}, "")
|
|
|
|
|
|
+ detail, e := report_approve.FormatFlowAndNodesItem2Detail(flowItem, nodes)
|
|
if e != nil {
|
|
if e != nil {
|
|
br.Msg = "获取失败"
|
|
br.Msg = "获取失败"
|
|
- br.ErrMsg = "获取系统用户列表失败, Err: " + e.Error()
|
|
|
|
|
|
+ br.ErrMsg = "获取审批详情失败, Err: " + e.Error()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- for _, ad := range admins {
|
|
|
|
- adminIdName[ad.AdminId] = ad.RealName
|
|
|
|
|
|
+ br.Data = detail
|
|
|
|
+ br.Ret = 200
|
|
|
|
+ br.Success = true
|
|
|
|
+ br.Msg = "获取成功"
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// Remove
|
|
|
|
+// @Title 删除审批流
|
|
|
|
+// @Description 删除审批流
|
|
|
|
+// @Param request body report_approve.ReportApproveFlowRemoveReq true "type json string"
|
|
|
|
+// @Success 200 string "操作成功"
|
|
|
|
+// @router /remove [post]
|
|
|
|
+func (this *ReportApproveFlowController) Remove() {
|
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
|
+ defer func() {
|
|
|
|
+ if br.ErrMsg == "" {
|
|
|
|
+ br.IsSendEmail = false
|
|
|
|
+ }
|
|
|
|
+ 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 report_approve.ReportApproveFlowRemoveReq
|
|
|
|
+ if e := json.Unmarshal(this.Ctx.Input.RequestBody, &req); e != nil {
|
|
|
|
+ br.Msg = "参数有误"
|
|
|
|
+ br.ErrMsg = "参数解析失败, Err: " + e.Error()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if req.ReportApproveFlowId <= 0 {
|
|
|
|
+ br.Msg = "参数有误"
|
|
|
|
+ br.ErrMsg = fmt.Sprintf("参数有误, ReportApproveFlowId: %d", req.ReportApproveFlowId)
|
|
|
|
+ return
|
|
}
|
|
}
|
|
|
|
|
|
- for _, v := range list {
|
|
|
|
- item := smart_report.FormatSmartReport2Item(v)
|
|
|
|
- mark, e := smartReportService.UpdateSmartReportEditing(v.SmartReportId, 2, sysUser.AdminId, sysUser.RealName, adminIdName)
|
|
|
|
- if e != nil {
|
|
|
|
- br.Msg = "获取失败"
|
|
|
|
- br.ErrMsg = "查询编辑中标记失败, Err:" + e.Error()
|
|
|
|
|
|
+ flowOb := new(report_approve.ReportApproveFlow)
|
|
|
|
+ flowItem, e := flowOb.GetItemById(req.ReportApproveFlowId)
|
|
|
|
+ if e != nil {
|
|
|
|
+ if e.Error() == utils.ErrNoRow() {
|
|
|
|
+ br.Msg = "审批流已被删除, 请刷新页面"
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- if mark.Status == 0 {
|
|
|
|
- item.CanEdit = true
|
|
|
|
- } else {
|
|
|
|
- item.Editor = mark.Editor
|
|
|
|
- }
|
|
|
|
- resp.List = append(resp.List, item)
|
|
|
|
|
|
+ br.Msg = "操作失败"
|
|
|
|
+ br.ErrMsg = "获取审批流信息失败, Err: " + e.Error()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 校验是否允许删除
|
|
|
|
+ checkOk, e := services.CheckReportApproveFlowChange(flowItem.ReportType, flowItem.ClassifyFirstId, flowItem.ClassifySecondId)
|
|
|
|
+ if e != nil {
|
|
|
|
+ br.Msg = "操作失败"
|
|
|
|
+ br.ErrMsg = "校验审批流是否可变更失败, Err: " + e.Error()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if !checkOk {
|
|
|
|
+ br.Msg = "当前有未走完流程的报告, 请走完流程后再做删除!"
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 删除审批流, 保留审批节点, 历史审批回显会用得到
|
|
|
|
+ if e = flowItem.Del(); e != nil {
|
|
|
|
+ br.Msg = "操作失败"
|
|
|
|
+ br.ErrMsg = "删除审批流失败, Err: " + e.Error()
|
|
|
|
+ return
|
|
}
|
|
}
|
|
|
|
|
|
- page := paging.GetPaging(params.CurrentIndex, params.PageSize, total)
|
|
|
|
- resp.Paging = page
|
|
|
|
br.Ret = 200
|
|
br.Ret = 200
|
|
br.Success = true
|
|
br.Success = true
|
|
- br.Msg = "获取成功"
|
|
|
|
- br.Data = resp
|
|
|
|
|
|
+ br.Msg = "操作成功"
|
|
}
|
|
}
|
|
|
|
|
|
// ReportClassifyTree
|
|
// ReportClassifyTree
|
|
// @Title 报告分类树
|
|
// @Title 报告分类树
|
|
// @Description 报告分类树
|
|
// @Description 报告分类树
|
|
|
|
+// @Param ReportApproveFlowId query int false "审批流ID"
|
|
// @Success 200 {object} report_approve.ReportClassifyTreeItem
|
|
// @Success 200 {object} report_approve.ReportClassifyTreeItem
|
|
// @router /report/classify_tree [get]
|
|
// @router /report/classify_tree [get]
|
|
func (this *ReportApproveFlowController) ReportClassifyTree() {
|
|
func (this *ReportApproveFlowController) ReportClassifyTree() {
|
|
@@ -336,8 +585,44 @@ func (this *ReportApproveFlowController) ReportClassifyTree() {
|
|
br.Ret = 408
|
|
br.Ret = 408
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+ flowId, _ := this.GetInt("ReportApproveFlowId")
|
|
|
|
+
|
|
|
|
+ // 获取审批流信息, 用于查询分类是否可选
|
|
|
|
+ var flowKey string
|
|
|
|
+ if flowId > 0 {
|
|
|
|
+ flowOb := new(report_approve.ReportApproveFlow)
|
|
|
|
+ flowItem, e := flowOb.GetItemById(flowId)
|
|
|
|
+ if e != nil {
|
|
|
|
+ if e.Error() == utils.ErrNoRow() {
|
|
|
|
+ br.Msg = "审批流已被删除, 请刷新页面"
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ br.Msg = "获取失败"
|
|
|
|
+ br.ErrMsg = "获取审批流信息失败, Err: " + e.Error()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ flowKey = fmt.Sprintf("%d-%d-%d", flowItem.ReportType, flowItem.ClassifyFirstId, flowItem.ClassifySecondId)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 获取审批流列表
|
|
|
|
+ flowOb := new(report_approve.ReportApproveFlow)
|
|
|
|
+ flows, e := flowOb.GetItemsByCondition(``, make([]interface{}, 0), []string{}, "")
|
|
|
|
+ if e != nil {
|
|
|
|
+ br.Msg = "获取失败"
|
|
|
|
+ br.ErrMsg = "获取审批流列表失败, Err: " + e.Error()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ hasFlowMap := make(map[string]bool)
|
|
|
|
+ for _, v := range flows {
|
|
|
|
+ k := fmt.Sprintf("%d-%d-%d", v.ReportType, v.ClassifyFirstId, v.ClassifySecondId)
|
|
|
|
+ if k == flowKey {
|
|
|
|
+ // 当前审批流对应的分类标记为可选状态
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+ hasFlowMap[k] = true
|
|
|
|
+ }
|
|
|
|
|
|
- resp, cnTree, enTree := make([]*report_approve.ReportClassifyTreeItem, 0), make([]*report_approve.ReportClassifyTreeItem, 0), make([]*report_approve.ReportClassifyTreeItem, 0)
|
|
|
|
|
|
+ resp, cnTree, smartTree, enTree := make([]*report_approve.ReportClassifyTreeItem, 0), make([]*report_approve.ReportClassifyTreeItem, 0), make([]*report_approve.ReportClassifyTreeItem, 0), make([]*report_approve.ReportClassifyTreeItem, 0)
|
|
|
|
|
|
var cnErr, enErr error
|
|
var cnErr, enErr error
|
|
wg := sync.WaitGroup{}
|
|
wg := sync.WaitGroup{}
|
|
@@ -345,7 +630,9 @@ func (this *ReportApproveFlowController) ReportClassifyTree() {
|
|
|
|
|
|
// 中文/智能研报分类
|
|
// 中文/智能研报分类
|
|
go func() {
|
|
go func() {
|
|
- wg.Done()
|
|
|
|
|
|
+ defer func() {
|
|
|
|
+ wg.Done()
|
|
|
|
+ }()
|
|
|
|
|
|
classify, e := models.GetAllClassify()
|
|
classify, e := models.GetAllClassify()
|
|
if e != nil {
|
|
if e != nil {
|
|
@@ -353,11 +640,27 @@ func (this *ReportApproveFlowController) ReportClassifyTree() {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
cnTree = services.GetReportClassifyTreeRecursive(classify, 0)
|
|
cnTree = services.GetReportClassifyTreeRecursive(classify, 0)
|
|
|
|
+ for _, v := range cnTree {
|
|
|
|
+ for _, v2 := range v.Children {
|
|
|
|
+ k := fmt.Sprintf("%d-%d-%d", report_approve.FlowReportTypeChinese, v.ClassifyId, v2.ClassifyId)
|
|
|
|
+ v2.HasFlow = hasFlowMap[k]
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ smartTree = services.GetReportClassifyTreeRecursive(classify, 0)
|
|
|
|
+ for _, v := range smartTree {
|
|
|
|
+ for _, v2 := range v.Children {
|
|
|
|
+ k := fmt.Sprintf("%d-%d-%d", report_approve.FlowReportTypeSmart, v.ClassifyId, v2.ClassifyId)
|
|
|
|
+ v2.HasFlow = hasFlowMap[k]
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}()
|
|
}()
|
|
|
|
|
|
// 英文研报分类
|
|
// 英文研报分类
|
|
go func() {
|
|
go func() {
|
|
- wg.Done()
|
|
|
|
|
|
+ defer func() {
|
|
|
|
+ wg.Done()
|
|
|
|
+ }()
|
|
|
|
|
|
classify, e := models.GetAllEnglishClassify()
|
|
classify, e := models.GetAllEnglishClassify()
|
|
if e != nil {
|
|
if e != nil {
|
|
@@ -365,6 +668,12 @@ func (this *ReportApproveFlowController) ReportClassifyTree() {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
enTree = services.GetReportClassifyTreeRecursive(classify, 0)
|
|
enTree = services.GetReportClassifyTreeRecursive(classify, 0)
|
|
|
|
+ for _, v := range enTree {
|
|
|
|
+ for _, v2 := range v.Children {
|
|
|
|
+ k := fmt.Sprintf("%d-%d-%d", report_approve.FlowReportTypeEnglish, v.ClassifyId, v2.ClassifyId)
|
|
|
|
+ v2.HasFlow = hasFlowMap[k]
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}()
|
|
}()
|
|
|
|
|
|
wg.Wait()
|
|
wg.Wait()
|
|
@@ -391,7 +700,7 @@ func (this *ReportApproveFlowController) ReportClassifyTree() {
|
|
}, &report_approve.ReportClassifyTreeItem{
|
|
}, &report_approve.ReportClassifyTreeItem{
|
|
ClassifyId: report_approve.FlowReportTypeSmart,
|
|
ClassifyId: report_approve.FlowReportTypeSmart,
|
|
ClassifyName: "智能研报",
|
|
ClassifyName: "智能研报",
|
|
- Children: cnTree,
|
|
|
|
|
|
+ Children: smartTree,
|
|
})
|
|
})
|
|
|
|
|
|
br.Data = resp
|
|
br.Data = resp
|