report_approve.go 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094
  1. package report_approve
  2. import (
  3. "encoding/json"
  4. "eta/eta_api/controllers"
  5. "eta/eta_api/models"
  6. "eta/eta_api/models/report_approve"
  7. "eta/eta_api/services"
  8. "eta/eta_api/utils"
  9. "fmt"
  10. "sort"
  11. "strconv"
  12. "strings"
  13. "time"
  14. "github.com/rdlucklib/rdluck_tools/paging"
  15. )
  16. // ReportApproveController 报告审批
  17. type ReportApproveController struct {
  18. controllers.BaseAuthController
  19. }
  20. // List
  21. // @Title 审批列表
  22. // @Description 审批列表
  23. // @Param PageSize query int true "每页数据条数"
  24. // @Param CurrentIndex query int true "当前页页码"
  25. // @Param ListType query int true "列表类型:1-待处理;2-已处理;3-我发起的"
  26. // @Param ReportType query int false "报告类型:1-中文研报;2-英文研报;3-智能研报"
  27. // @Param ClassifyIdFirst query int false "一级分类ID"
  28. // @Param ClassifyIdSecond query int false "二级分类ID"
  29. // @Param ClassifyIdThird query int false "三级级分类ID"
  30. // @Param Keyword query string false "搜索关键词"
  31. // @Param ApproveState query int false "审批状态:1-待审批;2-已审批;3-已驳回;4-已撤回"
  32. // @Param TimeType query int false "时间类型:1-提交时间;2-处理时间;3-审批时间"
  33. // @Param StartTime query string false "开始时间"
  34. // @Param EndTime query string false "结束时间"
  35. // @Param SortField query int false "排序字段:1-提交时间;2-处理时间;3-审批时间"
  36. // @Param SortRule query int false "排序方式: 1-正序; 2-倒序(默认)"
  37. // @Success 200 {object} report_approve.ReportApproveListResp
  38. // @router /list [get]
  39. func (this *ReportApproveController) List() {
  40. br := new(models.BaseResponse).Init()
  41. defer func() {
  42. if br.ErrMsg == "" {
  43. br.IsSendEmail = false
  44. }
  45. this.Data["json"] = br
  46. this.ServeJSON()
  47. }()
  48. sysUser := this.SysUser
  49. if sysUser == nil {
  50. br.Msg = "请登录"
  51. br.ErrMsg = "请登录,SysUser Is Empty"
  52. br.Ret = 408
  53. return
  54. }
  55. params := new(report_approve.ReportApproveListReq)
  56. if e := this.ParseForm(params); e != nil {
  57. br.Msg = "获取失败"
  58. br.ErrMsg = "入参解析失败, Err: " + e.Error()
  59. return
  60. }
  61. if params.ListType != 1 && params.ListType != 2 && params.ListType != 3 {
  62. br.Msg = "列表类型有误"
  63. return
  64. }
  65. // 报告分类
  66. cnClassifyIdName, enClassifyIdName := make(map[int]string), make(map[int]string)
  67. cnClassify, e := models.GetAllClassify()
  68. if e != nil {
  69. br.Msg = "获取失败"
  70. br.ErrMsg = "获取中文分类失败, Err: " + e.Error()
  71. return
  72. }
  73. for _, v := range cnClassify {
  74. cnClassifyIdName[v.Id] = v.ClassifyName
  75. }
  76. enClassify, e := models.GetEnglishClassifies()
  77. if e != nil {
  78. br.Msg = "获取失败"
  79. br.ErrMsg = "获取英文分类失败, Err: " + e.Error()
  80. return
  81. }
  82. enRootIdMap := make(map[int]int) // 英文分类的一级分类ID
  83. for _, v := range enClassify {
  84. enClassifyIdName[v.Id] = v.ClassifyName
  85. enRootIdMap[v.Id] = v.RootId
  86. }
  87. // 分页
  88. var startSize int
  89. if params.PageSize <= 0 {
  90. params.PageSize = utils.PageSize20
  91. }
  92. if params.CurrentIndex <= 0 {
  93. params.CurrentIndex = 1
  94. }
  95. startSize = utils.StartIndex(params.CurrentIndex, params.PageSize)
  96. resp := new(report_approve.ReportApproveListResp)
  97. respTotal := 0
  98. respList := make([]*report_approve.ReportApproveItem, 0)
  99. timeField := map[int]string{1: fmt.Sprintf("a.%s", report_approve.ReportApproveCols.CreateTime), 2: fmt.Sprintf("a.%s", report_approve.ReportApproveRecordCols.ApproveTime), 3: fmt.Sprintf("b.%s", report_approve.ReportApproveCols.ApproveTime)}
  100. mineTimeField := map[int]string{1: fmt.Sprintf("%s", report_approve.ReportApproveCols.CreateTime), 3: fmt.Sprintf("%s", report_approve.ReportApproveCols.ApproveTime)}
  101. orderRules := map[int]string{1: "ASC", 2: "DESC"}
  102. ormList := make([]*report_approve.ReportApproveItemOrm, 0)
  103. // 待处理
  104. if params.ListType == 1 {
  105. cond := fmt.Sprintf(` AND a.%s = ? AND b.%s = ? AND a.%s = ?`, report_approve.ReportApproveRecordCols.State, report_approve.ReportApproveCols.State, report_approve.ReportApproveRecordCols.ApproveUserId)
  106. pars := make([]interface{}, 0)
  107. pars = append(pars, report_approve.ReportApproveStateApproving, report_approve.ReportApproveStateApproving, sysUser.AdminId)
  108. order := ""
  109. // 筛选条件
  110. if params.ReportType > 0 {
  111. cond += fmt.Sprintf(` AND b.%s = ?`, report_approve.ReportApproveCols.ReportType)
  112. pars = append(pars, params.ReportType)
  113. }
  114. if params.ClassifyFirstId > 0 {
  115. cond += fmt.Sprintf(` AND b.%s = ?`, report_approve.ReportApproveCols.ClassifyFirstId)
  116. pars = append(pars, params.ClassifyFirstId)
  117. }
  118. if params.ClassifySecondId > 0 {
  119. cond += fmt.Sprintf(` AND b.%s = ?`, report_approve.ReportApproveCols.ClassifySecondId)
  120. pars = append(pars, params.ClassifySecondId)
  121. }
  122. if params.ClassifyThirdId > 0 {
  123. cond += fmt.Sprintf(` AND b.%s = ?`, report_approve.ReportApproveCols.ClassifyThirdId)
  124. pars = append(pars, params.ClassifyThirdId)
  125. }
  126. if params.TimeType <= 0 {
  127. params.TimeType = 1
  128. }
  129. if params.TimeType == 1 && params.StartTime != "" && params.EndTime != "" {
  130. _, e := time.Parse(utils.FormatDate, params.StartTime)
  131. if e != nil {
  132. br.Msg = "开始时间格式有误"
  133. return
  134. }
  135. _, e = time.Parse(utils.FormatDate, params.EndTime)
  136. if e != nil {
  137. br.Msg = "结束时间格式有误"
  138. return
  139. }
  140. st := fmt.Sprintf("%s %s", params.StartTime, "00:00:00")
  141. ed := fmt.Sprintf("%s %s", params.EndTime, "23:59:59")
  142. cond += fmt.Sprintf(` AND (b.%s BETWEEN ? AND ?)`, report_approve.ReportApproveCols.CreateTime)
  143. pars = append(pars, st, ed)
  144. }
  145. params.Keyword = strings.TrimSpace(params.Keyword)
  146. if params.Keyword != "" {
  147. kw := fmt.Sprint("%", params.Keyword, "%")
  148. cond += fmt.Sprintf(` AND b.%s LIKE ?`, report_approve.ReportApproveCols.ReportTitle)
  149. pars = append(pars, kw)
  150. }
  151. if params.SortField > 0 && params.SortRule > 0 {
  152. orderField := timeField[params.SortField]
  153. if orderField == "" {
  154. br.Msg = "时间排序字段有误"
  155. return
  156. }
  157. orderRule := orderRules[params.SortRule]
  158. if orderRule == "" {
  159. br.Msg = "时间排序方式有误"
  160. return
  161. }
  162. order = fmt.Sprintf("%s %s", orderField, orderRule)
  163. }
  164. total, e := report_approve.GetApprovingReportApproveCount(cond, pars)
  165. if e != nil {
  166. br.Msg = "获取失败"
  167. br.ErrMsg = "GetApprovingReportApproveCount err: " + e.Error()
  168. return
  169. }
  170. respTotal = total
  171. list, e := report_approve.GetApprovingReportApprovePageList(cond, pars, order, startSize, params.PageSize)
  172. if e != nil {
  173. br.Msg = "获取失败"
  174. br.ErrMsg = "GetApprovingReportApprovePageList err: " + e.Error()
  175. return
  176. }
  177. ormList = list
  178. }
  179. // 已处理
  180. if params.ListType == 2 {
  181. cond := fmt.Sprintf(` AND a.%s = ? AND a.%s IN (%s)`, report_approve.ReportApproveRecordCols.ApproveUserId, report_approve.ReportApproveRecordCols.NodeState, utils.GetOrmInReplace(2))
  182. pars := make([]interface{}, 0)
  183. pars = append(pars, sysUser.AdminId, []int{report_approve.ReportApproveStatePass, report_approve.ReportApproveStateRefuse})
  184. order := ""
  185. // 筛选条件
  186. if params.ReportType > 0 {
  187. cond += fmt.Sprintf(` AND b.%s = ?`, report_approve.ReportApproveCols.ReportType)
  188. pars = append(pars, params.ReportType)
  189. }
  190. if params.ClassifyFirstId > 0 {
  191. cond += fmt.Sprintf(` AND b.%s = ?`, report_approve.ReportApproveCols.ClassifyFirstId)
  192. pars = append(pars, params.ClassifyFirstId)
  193. }
  194. if params.ClassifySecondId > 0 {
  195. cond += fmt.Sprintf(` AND b.%s = ?`, report_approve.ReportApproveCols.ClassifySecondId)
  196. pars = append(pars, params.ClassifySecondId)
  197. }
  198. if params.ClassifyThirdId > 0 {
  199. cond += fmt.Sprintf(` AND b.%s = ?`, report_approve.ReportApproveCols.ClassifyThirdId)
  200. pars = append(pars, params.ClassifyThirdId)
  201. }
  202. if params.TimeType > 0 && params.StartTime != "" && params.EndTime != "" {
  203. _, e := time.Parse(utils.FormatDate, params.StartTime)
  204. if e != nil {
  205. br.Msg = "开始时间格式有误"
  206. return
  207. }
  208. _, e = time.Parse(utils.FormatDate, params.EndTime)
  209. if e != nil {
  210. br.Msg = "结束时间格式有误"
  211. return
  212. }
  213. st := fmt.Sprintf("%s %s", params.StartTime, "00:00:00")
  214. ed := fmt.Sprintf("%s %s", params.EndTime, "23:59:59")
  215. cond += fmt.Sprintf(` AND (%s BETWEEN ? AND ?)`, timeField[params.TimeType])
  216. pars = append(pars, st, ed)
  217. }
  218. params.Keyword = strings.TrimSpace(params.Keyword)
  219. if params.Keyword != "" {
  220. kw := fmt.Sprint("%", params.Keyword, "%")
  221. cond += fmt.Sprintf(` AND b.%s LIKE ?`, report_approve.ReportApproveCols.ReportTitle)
  222. pars = append(pars, kw)
  223. }
  224. if params.SortField > 0 && params.SortRule > 0 {
  225. orderField := timeField[params.SortField]
  226. if orderField == "" {
  227. br.Msg = "时间排序字段有误"
  228. return
  229. }
  230. orderRule := orderRules[params.SortRule]
  231. if orderRule == "" {
  232. br.Msg = "时间排序方式有误"
  233. return
  234. }
  235. order = fmt.Sprintf("%s %s", orderField, orderRule)
  236. }
  237. if params.ApproveState > 0 {
  238. cond += fmt.Sprintf(` AND a.%s = ?`, report_approve.ReportApproveRecordCols.State)
  239. pars = append(pars, params.ApproveState)
  240. }
  241. total, e := report_approve.GetApprovedReportApproveCount(cond, pars)
  242. if e != nil {
  243. br.Msg = "获取失败"
  244. br.ErrMsg = "GetApprovedReportApproveCount err: " + e.Error()
  245. return
  246. }
  247. respTotal = total
  248. list, e := report_approve.GetApprovedReportApprovePageList(cond, pars, order, startSize, params.PageSize)
  249. if e != nil {
  250. br.Msg = "获取失败"
  251. br.ErrMsg = "GetApprovedReportApprovePageList err: " + e.Error()
  252. return
  253. }
  254. for _, v := range list {
  255. // 这个时候的状态,用审批状态
  256. v.RecordState = v.NodeState
  257. v.ApproveTime = v.NodeApproveTime
  258. }
  259. ormList = list
  260. }
  261. // 我发起的
  262. if params.ListType == 3 {
  263. cond := fmt.Sprintf(` AND a.%s = ?`, report_approve.ReportApproveCols.ApplyUserId)
  264. pars := make([]interface{}, 0)
  265. pars = append(pars, sysUser.AdminId)
  266. order := ""
  267. // 筛选条件
  268. if params.ReportType > 0 {
  269. cond += fmt.Sprintf(` AND a.%s = ?`, report_approve.ReportApproveCols.ReportType)
  270. pars = append(pars, params.ReportType)
  271. }
  272. if params.ClassifyFirstId > 0 {
  273. cond += fmt.Sprintf(` AND a.%s = ?`, report_approve.ReportApproveCols.ClassifyFirstId)
  274. pars = append(pars, params.ClassifyFirstId)
  275. }
  276. if params.ClassifySecondId > 0 {
  277. cond += fmt.Sprintf(` AND a.%s = ?`, report_approve.ReportApproveCols.ClassifySecondId)
  278. pars = append(pars, params.ClassifySecondId)
  279. }
  280. if params.ClassifyThirdId > 0 {
  281. cond += fmt.Sprintf(` AND a.%s = ?`, report_approve.ReportApproveCols.ClassifyThirdId)
  282. pars = append(pars, params.ClassifyThirdId)
  283. }
  284. if params.TimeType > 0 && params.StartTime != "" && params.EndTime != "" {
  285. _, e := time.Parse(utils.FormatDate, params.StartTime)
  286. if e != nil {
  287. br.Msg = "开始时间格式有误"
  288. return
  289. }
  290. _, e = time.Parse(utils.FormatDate, params.EndTime)
  291. if e != nil {
  292. br.Msg = "结束时间格式有误"
  293. return
  294. }
  295. st := fmt.Sprintf("%s %s", params.StartTime, "00:00:00")
  296. ed := fmt.Sprintf("%s %s", params.EndTime, "23:59:59")
  297. field := mineTimeField[params.TimeType]
  298. if field == "" {
  299. br.Msg = "筛选时间有误"
  300. return
  301. }
  302. cond += fmt.Sprintf(` AND (%s BETWEEN ? AND ?)`, field)
  303. pars = append(pars, st, ed)
  304. }
  305. params.Keyword = strings.TrimSpace(params.Keyword)
  306. if params.Keyword != "" {
  307. kw := fmt.Sprint("%", params.Keyword, "%")
  308. cond += fmt.Sprintf(` AND a.%s LIKE ?`, report_approve.ReportApproveCols.ReportTitle)
  309. pars = append(pars, kw)
  310. }
  311. if params.SortField > 0 && params.SortRule > 0 {
  312. orderField := mineTimeField[params.SortField]
  313. if orderField == "" {
  314. br.Msg = "时间排序字段有误"
  315. return
  316. }
  317. orderRule := orderRules[params.SortRule]
  318. if orderRule == "" {
  319. br.Msg = "时间排序方式有误"
  320. return
  321. }
  322. order = fmt.Sprintf("%s %s", orderField, orderRule)
  323. }
  324. if params.ApproveState > 0 {
  325. cond += fmt.Sprintf(` AND a.%s = ?`, report_approve.ReportApproveRecordCols.State)
  326. pars = append(pars, params.ApproveState)
  327. }
  328. total, e := report_approve.GetApplyReportApproveCount(cond, pars)
  329. if e != nil {
  330. br.Msg = "获取失败"
  331. br.ErrMsg = "GetApplyReportApproveCount err: " + e.Error()
  332. return
  333. }
  334. respTotal = total
  335. list, e := report_approve.GetApplyReportApprovePageList(cond, pars, order, startSize, params.PageSize)
  336. if e != nil {
  337. br.Msg = "获取失败"
  338. br.ErrMsg = "GetApplyReportApprovePageList err: " + e.Error()
  339. return
  340. }
  341. ormList = list
  342. }
  343. // 审批通过的报告显示下载按钮
  344. reportImg := make(map[string]string)
  345. reportPdf := make(map[string]string)
  346. {
  347. var reportIds, enReportIds []int
  348. for _, v := range ormList {
  349. if v.State != report_approve.ReportApproveStatePass {
  350. continue
  351. }
  352. if v.ReportType == report_approve.FlowReportTypeChinese {
  353. reportIds = append(reportIds, v.ReportId)
  354. }
  355. if v.ReportType == report_approve.FlowReportTypeEnglish {
  356. enReportIds = append(enReportIds, v.ReportId)
  357. }
  358. }
  359. if len(reportIds) > 0 {
  360. reports, e := models.GetReportFieldsByIds(reportIds, []string{"id", "detail_img_url", "detail_pdf_url"})
  361. if e != nil {
  362. br.Msg = "获取失败"
  363. br.ErrMsg = fmt.Sprintf("GetReportFieldsByIds, %v", e)
  364. return
  365. }
  366. for _, r := range reports {
  367. k := fmt.Sprintf("%d-%d", report_approve.FlowReportTypeChinese, r.Id)
  368. reportImg[k] = r.DetailImgUrl
  369. reportPdf[k] = r.DetailPdfUrl
  370. }
  371. }
  372. if len(enReportIds) > 0 {
  373. enReports, e := models.GetEnglishReportFieldsByIds(enReportIds, []string{"id", "detail_img_url", "detail_pdf_url"})
  374. if e != nil {
  375. br.Msg = "获取失败"
  376. br.ErrMsg = fmt.Sprintf("GetEnglishReportFieldsByIds, %v", e)
  377. return
  378. }
  379. for _, r := range enReports {
  380. k := fmt.Sprintf("%d-%d", report_approve.FlowReportTypeEnglish, r.Id)
  381. reportImg[k] = r.DetailImgUrl
  382. reportPdf[k] = r.DetailPdfUrl
  383. }
  384. }
  385. }
  386. // 格式化列表
  387. for _, v := range ormList {
  388. t := report_approve.FormatReportApproveOrm2Item(v)
  389. if v.ReportType == report_approve.FlowReportTypeEnglish {
  390. var classifyPath []string
  391. if v.ReportType > 0 {
  392. classifyPath = append(classifyPath, report_approve.FlowReportTypeMap[v.ReportType])
  393. }
  394. if v.ClassifyFirstId > 0 {
  395. classifyPath = append(classifyPath, enClassifyIdName[v.ClassifyFirstId])
  396. }
  397. if v.ClassifySecondId > 0 {
  398. classifyPath = append(classifyPath, enClassifyIdName[v.ClassifySecondId])
  399. }
  400. if v.ClassifyThirdId > 0 {
  401. classifyPath = append(classifyPath, enClassifyIdName[v.ClassifyThirdId])
  402. }
  403. t.ReportClassify = strings.Join(classifyPath, "/")
  404. } else {
  405. //t.ReportClassify = fmt.Sprintf("%s/%s/%s", report_approve.FlowReportTypeMap[v.ReportType], cnClassifyIdName[v.ClassifyFirstId], cnClassifyIdName[v.ClassifySecondId])
  406. var classifyPath []string
  407. if v.ReportType > 0 {
  408. classifyPath = append(classifyPath, report_approve.FlowReportTypeMap[v.ReportType])
  409. }
  410. if v.ClassifyFirstId > 0 {
  411. classifyPath = append(classifyPath, cnClassifyIdName[v.ClassifyFirstId])
  412. }
  413. if v.ClassifySecondId > 0 {
  414. classifyPath = append(classifyPath, cnClassifyIdName[v.ClassifySecondId])
  415. }
  416. if v.ClassifyThirdId > 0 {
  417. classifyPath = append(classifyPath, cnClassifyIdName[v.ClassifyThirdId])
  418. }
  419. t.ReportClassify = strings.Join(classifyPath, "/")
  420. }
  421. k := fmt.Sprintf("%d-%d", t.ReportType, t.ReportId)
  422. t.DetailImgUrl = reportImg[k]
  423. t.DetailPdfUrl = reportPdf[k]
  424. respList = append(respList, t)
  425. }
  426. page := paging.GetPaging(params.CurrentIndex, params.PageSize, respTotal)
  427. resp.Paging = page
  428. resp.List = respList
  429. br.Data = resp
  430. br.Ret = 200
  431. br.Success = true
  432. br.Msg = "获取成功"
  433. }
  434. // Detail
  435. // @Title 审批详情
  436. // @Description 审批详情
  437. // @Param ReportApproveId query int true "审批ID"
  438. // @Success 200 {object} report_approve.ReportApproveDetail
  439. // @router /detail [get]
  440. func (this *ReportApproveController) Detail() {
  441. br := new(models.BaseResponse).Init()
  442. defer func() {
  443. if br.ErrMsg == "" {
  444. br.IsSendEmail = false
  445. }
  446. this.Data["json"] = br
  447. this.ServeJSON()
  448. }()
  449. sysUser := this.SysUser
  450. if sysUser == nil {
  451. br.Msg = "请登录"
  452. br.ErrMsg = "请登录,SysUser Is Empty"
  453. br.Ret = 408
  454. return
  455. }
  456. approveId, _ := this.GetInt("ReportApproveId")
  457. if approveId <= 0 {
  458. br.Msg = "参数有误"
  459. br.ErrMsg = fmt.Sprintf("参数有误, ReportApproveId: %d", approveId)
  460. return
  461. }
  462. approveOb := new(report_approve.ReportApprove)
  463. approveItem, e := approveOb.GetItemById(approveId)
  464. if e != nil {
  465. if e.Error() == utils.ErrNoRow() {
  466. br.Msg = "审批已被删除, 请刷新页面"
  467. return
  468. }
  469. br.Msg = "获取失败"
  470. br.ErrMsg = "获取审批失败, Err: " + e.Error()
  471. return
  472. }
  473. // 审批信息
  474. detail := new(report_approve.ReportApproveDetail)
  475. detail.Approve = new(report_approve.ReportApproveDetailItem)
  476. detail.Approve.ReportApproveId = approveItem.ReportApproveId
  477. detail.Approve.State = approveItem.State
  478. detail.Approve.FlowId = approveItem.FlowId
  479. detail.Approve.FlowVersion = approveItem.FlowVersion
  480. detail.Approve.StartNodeId = approveItem.StartNodeId
  481. detail.Approve.CurrNodeId = approveItem.CurrNodeId
  482. detail.Approve.ApplyUserId = approveItem.ApplyUserId
  483. detail.Approve.ApplyUserName = approveItem.ApplyUserName
  484. detail.Approve.ApproveTime = utils.TimeTransferString(utils.FormatDateTime, approveItem.ApproveTime)
  485. detail.Approve.CreateTime = utils.TimeTransferString(utils.FormatDateTime, approveItem.CreateTime)
  486. detail.Approve.ModifyTime = utils.TimeTransferString(utils.FormatDateTime, approveItem.ModifyTime)
  487. // 审批流
  488. //flowOb := new(report_approve.ReportApproveFlow)
  489. //flowItem, e := flowOb.GetItemById(approveItem.FlowId)
  490. //if e != nil {
  491. // if e.Error() == utils.ErrNoRow() {
  492. // br.Msg = "审批流已被删除, 请刷新页面"
  493. // return
  494. // }
  495. // br.Msg = "获取失败"
  496. // br.ErrMsg = "获取审批流失败, Err: " + e.Error()
  497. // return
  498. //}
  499. //detail.ApproveFlow = report_approve.FormatReportApproveFlow2Item(flowItem)
  500. // 审批节点
  501. nodeOb := new(report_approve.ReportApproveNode)
  502. nodeCond := fmt.Sprintf(` AND %s = ? AND %s = ?`, report_approve.ReportApproveNodeCols.ReportApproveFlowId, report_approve.ReportApproveNodeCols.CurrVersion)
  503. nodePars := make([]interface{}, 0)
  504. nodePars = append(nodePars, approveItem.FlowId, approveItem.FlowVersion)
  505. nodeItems, e := nodeOb.GetItemsByCondition(nodeCond, nodePars, []string{}, "")
  506. if e != nil {
  507. br.Msg = "获取失败"
  508. br.ErrMsg = "获取审批节点失败, Err: " + e.Error()
  509. return
  510. }
  511. // 审批记录
  512. recordOb := new(report_approve.ReportApproveRecord)
  513. recordCond := fmt.Sprintf(` AND %s = ?`, report_approve.ReportApproveRecordCols.ReportApproveId)
  514. recordPars := make([]interface{}, 0)
  515. recordPars = append(recordPars, approveItem.ReportApproveId)
  516. recordItems, e := recordOb.GetItemsByCondition(recordCond, recordPars, []string{}, fmt.Sprintf("%s DESC", report_approve.ReportApproveRecordCols.ApproveTime))
  517. if e != nil {
  518. br.Msg = "获取失败"
  519. br.ErrMsg = "获取审批记录失败, Err: " + e.Error()
  520. return
  521. }
  522. recordMap := make(map[string]*report_approve.ReportApproveRecord)
  523. for _, v := range recordItems {
  524. k := fmt.Sprintf("%d-%d", v.NodeId, v.ApproveUserId)
  525. recordMap[k] = v
  526. }
  527. // 审批流节点详情
  528. detail.ApproveFlowNodes = make([]*report_approve.ReportApproveDetailNodes, 0)
  529. for _, v := range nodeItems {
  530. t := new(report_approve.ReportApproveDetailNodes)
  531. t.ReportApproveNodeId = v.ReportApproveNodeId
  532. t.ReportApproveFlowId = v.ReportApproveFlowId
  533. t.PrevNodeId = v.PrevNodeId
  534. t.NextNodeId = v.NextNodeId
  535. t.NodeType = v.NodeType
  536. t.ApproveType = v.ApproveType
  537. t.Users = make([]*report_approve.ReportApproveDetailNodeUser, 0)
  538. us := make([]*report_approve.ReportApproveNodeUserReq, 0)
  539. if v.Users != "" {
  540. e = json.Unmarshal([]byte(v.Users), &us)
  541. if e != nil {
  542. br.Msg = "获取失败"
  543. br.ErrMsg = "节点用户解析失败, Err: " + e.Error()
  544. return
  545. }
  546. }
  547. for _, vu := range us {
  548. u := new(report_approve.ReportApproveDetailNodeUser)
  549. u.UserType = vu.UserType
  550. u.UserId = vu.UserId
  551. u.UserName = vu.UserName
  552. u.Sort = vu.Sort
  553. // 审批记录
  554. k := fmt.Sprintf("%d-%d", v.ReportApproveNodeId, vu.UserId)
  555. r := recordMap[k]
  556. if r != nil {
  557. u.ApproveRecord = new(report_approve.ReportApproveDetailNodeUserRecord)
  558. u.ApproveRecord.ReportApproveRecordId = r.ReportApproveRecordId
  559. u.ApproveRecord.State = r.State
  560. u.ApproveRecord.ApproveUserId = r.ApproveUserId
  561. u.ApproveRecord.ApproveUserName = r.ApproveUserName
  562. u.ApproveRecord.ApproveRemark = r.ApproveRemark
  563. u.ApproveRecord.ApproveTime = utils.TimeTransferString(utils.FormatDateTime, r.ApproveTime)
  564. }
  565. t.Users = append(t.Users, u)
  566. }
  567. sort.Slice(t.Users, func(k, j int) bool {
  568. return t.Users[k].Sort < t.Users[j].Sort
  569. })
  570. detail.ApproveFlowNodes = append(detail.ApproveFlowNodes, t)
  571. }
  572. // 报告信息
  573. cnClassifyIdName, enClassifyIdName := make(map[int]string), make(map[int]string)
  574. cnClassify, e := models.GetAllClassify()
  575. if e != nil {
  576. br.Msg = "获取失败"
  577. br.ErrMsg = "获取中文分类失败, Err: " + e.Error()
  578. return
  579. }
  580. for _, v := range cnClassify {
  581. cnClassifyIdName[v.Id] = v.ClassifyName
  582. }
  583. enClassify, e := models.GetEnglishClassifies()
  584. if e != nil {
  585. br.Msg = "获取失败"
  586. br.ErrMsg = "获取英文分类失败, Err: " + e.Error()
  587. return
  588. }
  589. enRootIdMap := make(map[int]int) // 英文分类的一级分类ID
  590. for _, v := range enClassify {
  591. enClassifyIdName[v.Id] = v.ClassifyName
  592. enRootIdMap[v.Id] = v.RootId
  593. }
  594. detail.Report = new(report_approve.ReportApproveDetailReport)
  595. detail.Report.ReportType = approveItem.ReportType
  596. detail.Report.ReportId = approveItem.ReportId
  597. detail.Report.ReportTitle = approveItem.ReportTitle
  598. detail.Report.ReportLayout = 1
  599. // 报告分类路由
  600. {
  601. if approveItem.ReportType == report_approve.FlowReportTypeChinese {
  602. reportInfo, e := models.GetReportLayoutByReportId(approveItem.ReportId)
  603. if e != nil {
  604. br.Msg = "获取失败"
  605. br.ErrMsg = "获取报告失败, Err: " + e.Error()
  606. return
  607. }
  608. detail.Report.ReportLayout = reportInfo.ReportLayout
  609. detail.Report.ReportCode = utils.MD5(strconv.Itoa(approveItem.ReportId))
  610. }
  611. if approveItem.ReportType == report_approve.FlowReportTypeEnglish {
  612. detail.Report.ReportCode = utils.MD5(strconv.Itoa(approveItem.ReportId))
  613. }
  614. if approveItem.ReportType == report_approve.FlowReportTypeSmart {
  615. detail.Report.ReportLayout = 2
  616. detail.Report.ReportCode = utils.MD5(fmt.Sprint("smart_", approveItem.ReportId))
  617. }
  618. var classifyPath []string
  619. if approveItem.ReportType > 0 {
  620. classifyPath = append(classifyPath, report_approve.FlowReportTypeMap[approveItem.ReportType])
  621. }
  622. if approveItem.ReportType == report_approve.FlowReportTypeEnglish {
  623. if approveItem.ClassifyFirstId > 0 {
  624. classifyPath = append(classifyPath, enClassifyIdName[approveItem.ClassifyFirstId])
  625. }
  626. if approveItem.ClassifySecondId > 0 {
  627. classifyPath = append(classifyPath, enClassifyIdName[approveItem.ClassifySecondId])
  628. }
  629. if approveItem.ClassifyThirdId > 0 {
  630. classifyPath = append(classifyPath, enClassifyIdName[approveItem.ClassifyThirdId])
  631. }
  632. detail.Report.ReportClassify = strings.Join(classifyPath, "/")
  633. } else {
  634. if approveItem.ClassifyFirstId > 0 {
  635. classifyPath = append(classifyPath, cnClassifyIdName[approveItem.ClassifyFirstId])
  636. }
  637. if approveItem.ClassifySecondId > 0 {
  638. classifyPath = append(classifyPath, cnClassifyIdName[approveItem.ClassifySecondId])
  639. }
  640. if approveItem.ClassifyThirdId > 0 {
  641. classifyPath = append(classifyPath, cnClassifyIdName[approveItem.ClassifyThirdId])
  642. }
  643. detail.Report.ReportClassify = strings.Join(classifyPath, "/")
  644. }
  645. }
  646. br.Data = detail
  647. br.Ret = 200
  648. br.Success = true
  649. br.Msg = "获取成功"
  650. }
  651. // Approve
  652. // @Title 通过审批
  653. // @Description 通过审批
  654. // @Param request body report_approve.ReportApprovePassReq true "type json string"
  655. // @Success 200 string "操作成功"
  656. // @router /approve [post]
  657. func (this *ReportApproveController) Approve() {
  658. br := new(models.BaseResponse).Init()
  659. defer func() {
  660. if br.ErrMsg == "" {
  661. br.IsSendEmail = false
  662. }
  663. this.Data["json"] = br
  664. this.ServeJSON()
  665. }()
  666. sysUser := this.SysUser
  667. if sysUser == nil {
  668. br.Msg = "请登录"
  669. br.ErrMsg = "请登录,SysUser Is Empty"
  670. br.Ret = 408
  671. return
  672. }
  673. var req report_approve.ReportApprovePassReq
  674. if e := json.Unmarshal(this.Ctx.Input.RequestBody, &req); e != nil {
  675. br.Msg = "参数有误"
  676. br.ErrMsg = "参数解析失败, Err: " + e.Error()
  677. return
  678. }
  679. if req.ReportApproveId <= 0 {
  680. br.Msg = "参数有误"
  681. br.ErrMsg = fmt.Sprintf("参数有误, ReportApproveId: %d", req.ReportApproveId)
  682. return
  683. }
  684. approveOb := new(report_approve.ReportApprove)
  685. approveItem, e := approveOb.GetItemById(req.ReportApproveId)
  686. if e != nil {
  687. if e.Error() == utils.ErrNoRow() {
  688. br.Msg = "审批不存在, 请刷新页面"
  689. return
  690. }
  691. br.Msg = "操作失败"
  692. br.ErrMsg = "获取审批信息失败, Err: " + e.Error()
  693. return
  694. }
  695. if approveItem.State != report_approve.ReportApproveStateApproving {
  696. br.Msg = "审批状态有误, 请刷新页面"
  697. br.ErrMsg = fmt.Sprintf("审批状态有误, State: %d", approveItem.State)
  698. return
  699. }
  700. // 校验审批记录和审批
  701. recordOb := new(report_approve.ReportApproveRecord)
  702. recordCond := fmt.Sprintf(` AND %s = ? AND %s = ? AND %s = ?`, report_approve.ReportApproveRecordCols.ReportApproveId, report_approve.ReportApproveRecordCols.ApproveUserId, report_approve.ReportApproveRecordCols.State)
  703. recordPars := make([]interface{}, 0)
  704. recordPars = append(recordPars, approveItem.ReportApproveId, sysUser.AdminId, report_approve.ReportApproveStateApproving)
  705. recordItem, e := recordOb.GetItemByCondition(recordCond, recordPars, "")
  706. if e != nil {
  707. if e.Error() == utils.ErrNoRow() {
  708. br.Msg = "无权审批"
  709. return
  710. }
  711. br.Msg = "操作失败"
  712. br.ErrMsg = "获取审批记录失败, Err: " + e.Error()
  713. return
  714. }
  715. // 通过审批
  716. tips, e := services.PassReportApprove(approveItem, recordItem, sysUser.AdminId, req.ReportUrl)
  717. if e != nil {
  718. br.Msg = "操作失败"
  719. br.ErrMsg = "通过审批失败, Err: " + e.Error()
  720. return
  721. }
  722. if tips != "" {
  723. br.Msg = tips
  724. return
  725. }
  726. br.Ret = 200
  727. br.Success = true
  728. br.Msg = "操作成功"
  729. }
  730. // Refuse
  731. // @Title 驳回审批
  732. // @Description 驳回审批
  733. // @Param request body report_approve.ReportApproveRefuseReq true "type json string"
  734. // @Success 200 string "操作成功"
  735. // @router /refuse [post]
  736. func (this *ReportApproveController) Refuse() {
  737. br := new(models.BaseResponse).Init()
  738. defer func() {
  739. if br.ErrMsg == "" {
  740. br.IsSendEmail = false
  741. }
  742. this.Data["json"] = br
  743. this.ServeJSON()
  744. }()
  745. sysUser := this.SysUser
  746. if sysUser == nil {
  747. br.Msg = "请登录"
  748. br.ErrMsg = "请登录,SysUser Is Empty"
  749. br.Ret = 408
  750. return
  751. }
  752. var req report_approve.ReportApproveRefuseReq
  753. if e := json.Unmarshal(this.Ctx.Input.RequestBody, &req); e != nil {
  754. br.Msg = "参数有误"
  755. br.ErrMsg = "参数解析失败, Err: " + e.Error()
  756. return
  757. }
  758. if req.ReportApproveId <= 0 {
  759. br.Msg = "参数有误"
  760. br.ErrMsg = fmt.Sprintf("参数有误, ReportApproveId: %d", req.ReportApproveId)
  761. return
  762. }
  763. approveOb := new(report_approve.ReportApprove)
  764. approveItem, e := approveOb.GetItemById(req.ReportApproveId)
  765. if e != nil {
  766. if e.Error() == utils.ErrNoRow() {
  767. br.Msg = "审批不存在, 请刷新页面"
  768. return
  769. }
  770. br.Msg = "操作失败"
  771. br.ErrMsg = "获取审批信息失败, Err: " + e.Error()
  772. return
  773. }
  774. if approveItem.State != report_approve.ReportApproveStateApproving {
  775. br.Msg = "审批状态有误, 请刷新页面"
  776. br.ErrMsg = fmt.Sprintf("审批状态有误, State: %d", approveItem.State)
  777. return
  778. }
  779. // 校验审批记录和审批
  780. recordOb := new(report_approve.ReportApproveRecord)
  781. recordCond := fmt.Sprintf(` AND %s = ? AND %s = ? AND %s = ?`, report_approve.ReportApproveRecordCols.ReportApproveId, report_approve.ReportApproveRecordCols.ApproveUserId, report_approve.ReportApproveRecordCols.State)
  782. recordPars := make([]interface{}, 0)
  783. recordPars = append(recordPars, approveItem.ReportApproveId, sysUser.AdminId, report_approve.ReportApproveStateApproving)
  784. recordItem, e := recordOb.GetItemByCondition(recordCond, recordPars, "")
  785. if e != nil {
  786. if e.Error() == utils.ErrNoRow() {
  787. br.Msg = "无权审批"
  788. return
  789. }
  790. br.Msg = "操作失败"
  791. br.ErrMsg = "获取审批记录失败, Err: " + e.Error()
  792. return
  793. }
  794. // 驳回审批
  795. if e = services.RefuseReportApprove(approveItem, recordItem, req.ApproveRemark, sysUser.AdminId); e != nil {
  796. br.Msg = "操作失败"
  797. br.ErrMsg = "驳回审批失败, Err: " + e.Error()
  798. return
  799. }
  800. br.Ret = 200
  801. br.Success = true
  802. br.Msg = "操作成功"
  803. }
  804. // Cancel
  805. // @Title 撤销审批
  806. // @Description 撤销审批
  807. // @Param request body report_approve.ReportApproveCancelReq true "type json string"
  808. // @Success 200 string "操作成功"
  809. // @router /cancel [post]
  810. func (this *ReportApproveController) Cancel() {
  811. br := new(models.BaseResponse).Init()
  812. defer func() {
  813. if br.ErrMsg == "" {
  814. br.IsSendEmail = false
  815. }
  816. this.Data["json"] = br
  817. this.ServeJSON()
  818. }()
  819. sysUser := this.SysUser
  820. if sysUser == nil {
  821. br.Msg = "请登录"
  822. br.ErrMsg = "请登录,SysUser Is Empty"
  823. br.Ret = 408
  824. return
  825. }
  826. var req report_approve.ReportApproveCancelReq
  827. if e := json.Unmarshal(this.Ctx.Input.RequestBody, &req); e != nil {
  828. br.Msg = "参数有误"
  829. br.ErrMsg = "参数解析失败, Err: " + e.Error()
  830. return
  831. }
  832. if req.ReportApproveId <= 0 {
  833. br.Msg = "参数有误"
  834. br.ErrMsg = fmt.Sprintf("参数有误, ReportApproveId: %d", req.ReportApproveId)
  835. return
  836. }
  837. approveOb := new(report_approve.ReportApprove)
  838. approveItem, e := approveOb.GetItemById(req.ReportApproveId)
  839. if e != nil {
  840. if e.Error() == utils.ErrNoRow() {
  841. br.Msg = "审批已被删除, 请刷新页面"
  842. return
  843. }
  844. br.Msg = "操作失败"
  845. br.ErrMsg = "获取审批失败, Err: " + e.Error()
  846. return
  847. }
  848. if approveItem.ApplyUserId != sysUser.AdminId {
  849. br.Msg = "非申请人不可撤销"
  850. return
  851. }
  852. // 撤销审批
  853. e = services.CancelReportApprove(approveItem.ReportType, approveItem.ReportId, approveItem.ReportApproveId, sysUser.AdminId, sysUser.RealName)
  854. if e != nil {
  855. br.Msg = "操作失败"
  856. br.ErrMsg = "撤销审批失败, Err: " + e.Error()
  857. return
  858. }
  859. br.Ret = 200
  860. br.Success = true
  861. br.Msg = "操作成功"
  862. }
  863. // MessageList
  864. // @Title 审批消息列表
  865. // @Description 审批消息列表
  866. // @Param PageSize query int true "每页数据条数"
  867. // @Param CurrentIndex query int true "当前页页码"
  868. // @Success 200 {object} report_approve.ReportApproveMessageListResp
  869. // @router /message/list [get]
  870. func (this *ReportApproveController) MessageList() {
  871. br := new(models.BaseResponse).Init()
  872. defer func() {
  873. if br.ErrMsg == "" {
  874. br.IsSendEmail = false
  875. }
  876. this.Data["json"] = br
  877. this.ServeJSON()
  878. }()
  879. sysUser := this.SysUser
  880. if sysUser == nil {
  881. br.Msg = "请登录"
  882. br.ErrMsg = "请登录,SysUser Is Empty"
  883. br.Ret = 408
  884. return
  885. }
  886. params := new(report_approve.ReportApproveListReq)
  887. if e := this.ParseForm(params); e != nil {
  888. br.Msg = "获取失败"
  889. br.ErrMsg = "入参解析失败, Err: " + e.Error()
  890. return
  891. }
  892. // 分页
  893. var startSize int
  894. if params.PageSize <= 0 {
  895. params.PageSize = utils.PageSize20
  896. }
  897. if params.CurrentIndex <= 0 {
  898. params.CurrentIndex = 1
  899. }
  900. startSize = utils.StartIndex(params.CurrentIndex, params.PageSize)
  901. resp := new(report_approve.ReportApproveMessageListResp)
  902. resp.List = make([]*report_approve.ReportApproveMessageItem, 0)
  903. cond := fmt.Sprintf(` AND %s = ?`, report_approve.ReportApproveMessageCols.ReceiveUserId)
  904. pars := make([]interface{}, 0)
  905. pars = append(pars, sysUser.AdminId)
  906. order := fmt.Sprintf(`%s ASC, %s DESC`, report_approve.ReportApproveMessageCols.IsRead, report_approve.ReportApproveMessageCols.CreateTime)
  907. messageOb := new(report_approve.ReportApproveMessage)
  908. total, e := messageOb.GetCountByCondition(cond, pars)
  909. if e != nil {
  910. br.Msg = "获取失败"
  911. br.ErrMsg = "获取审批消息列表总数失败, Err: " + e.Error()
  912. return
  913. }
  914. list, e := messageOb.GetPageItemsByCondition(cond, pars, []string{}, order, startSize, params.PageSize)
  915. if e != nil {
  916. br.Msg = "获取失败"
  917. br.ErrMsg = "获取审批消息列表失败, Err: " + e.Error()
  918. return
  919. }
  920. for _, v := range list {
  921. t := report_approve.FormatReportApproveMessage2Item(v)
  922. resp.List = append(resp.List, t)
  923. }
  924. // 未读消息数
  925. cond += fmt.Sprintf(` AND %s = ?`, report_approve.ReportApproveMessageCols.IsRead)
  926. pars = append(pars, 0)
  927. unreadTotal, e := messageOb.GetCountByCondition(cond, pars)
  928. if e != nil {
  929. br.Msg = "获取失败"
  930. br.ErrMsg = "获取审批消息列表总数失败, Err: " + e.Error()
  931. return
  932. }
  933. resp.UnreadTotal = unreadTotal
  934. page := paging.GetPaging(params.CurrentIndex, params.PageSize, total)
  935. resp.Paging = page
  936. br.Data = resp
  937. br.Ret = 200
  938. br.Success = true
  939. br.Msg = "获取成功"
  940. }
  941. // MessageRead
  942. // @Title 消息已读
  943. // @Description 消息已读
  944. // @Param request body report_approve.ReportApproveMessageReadReq true "type json string"
  945. // @Success 200 string "操作成功"
  946. // @router /message/read [post]
  947. func (this *ReportApproveController) MessageRead() {
  948. br := new(models.BaseResponse).Init()
  949. defer func() {
  950. if br.ErrMsg == "" {
  951. br.IsSendEmail = false
  952. }
  953. this.Data["json"] = br
  954. this.ServeJSON()
  955. }()
  956. sysUser := this.SysUser
  957. if sysUser == nil {
  958. br.Msg = "请登录"
  959. br.ErrMsg = "请登录,SysUser Is Empty"
  960. br.Ret = 408
  961. return
  962. }
  963. var req report_approve.ReportApproveMessageReadReq
  964. if e := json.Unmarshal(this.Ctx.Input.RequestBody, &req); e != nil {
  965. br.Msg = "参数有误"
  966. br.ErrMsg = "参数解析失败, Err: " + e.Error()
  967. return
  968. }
  969. if req.MessageId <= 0 {
  970. br.Msg = "参数有误"
  971. br.ErrMsg = fmt.Sprintf("参数有误, MessageId: %d", req.MessageId)
  972. return
  973. }
  974. messageOb := new(report_approve.ReportApproveMessage)
  975. messageItem, e := messageOb.GetItemById(req.MessageId)
  976. if e != nil {
  977. if e.Error() == utils.ErrNoRow() {
  978. br.Msg = "消息不存在, 请刷新页面"
  979. return
  980. }
  981. br.Msg = "获取失败"
  982. br.ErrMsg = "获取审批消息失败, Err: " + e.Error()
  983. return
  984. }
  985. messageItem.IsRead = 1
  986. messageItem.ModifyTime = time.Now().Local()
  987. cols := []string{"IsRead", "ModifyTime"}
  988. if e = messageItem.Update(cols); e != nil {
  989. br.Msg = "操作失败"
  990. br.ErrMsg = "更新审批消息已读失败, Err: " + e.Error()
  991. return
  992. }
  993. br.Ret = 200
  994. br.Success = true
  995. br.Msg = "操作成功"
  996. }
  997. // CheckApproveOpen
  998. // @Title 校验分类是否开启审批
  999. // @Description 校验分类是否开启审批
  1000. // @Param request body report_approve.ReportApproveCheckApproveOpenReq true "type json string"
  1001. // @Success 200 string "操作成功"
  1002. // @router /classify/check_open [post]
  1003. func (this *ReportApproveController) CheckApproveOpen() {
  1004. br := new(models.BaseResponse).Init()
  1005. defer func() {
  1006. if br.ErrMsg == "" {
  1007. br.IsSendEmail = false
  1008. }
  1009. this.Data["json"] = br
  1010. this.ServeJSON()
  1011. }()
  1012. sysUser := this.SysUser
  1013. if sysUser == nil {
  1014. br.Msg = "请登录"
  1015. br.ErrMsg = "请登录,SysUser Is Empty"
  1016. br.Ret = 408
  1017. return
  1018. }
  1019. var req report_approve.ReportApproveCheckApproveOpenReq
  1020. if e := json.Unmarshal(this.Ctx.Input.RequestBody, &req); e != nil {
  1021. br.Msg = "参数有误"
  1022. br.ErrMsg = "参数解析失败, Err: " + e.Error()
  1023. return
  1024. }
  1025. // 校验是否开启了审批流
  1026. opening, e := services.CheckReportOpenApprove(req.ReportType, req.ClassifyFirstId, req.ClassifySecondId, req.ClassifyThirdId)
  1027. if e != nil {
  1028. br.Msg = "操作失败"
  1029. br.ErrMsg = "校验报告是否开启审批流失败, Err: " + e.Error()
  1030. return
  1031. }
  1032. br.Data = opening
  1033. br.Ret = 200
  1034. br.Success = true
  1035. br.Msg = "操作成功"
  1036. }