smart_report.go 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. package controllers
  2. import (
  3. "eta/eta_hub/models"
  4. )
  5. // SmartReportController 智能研报
  6. type SmartReportController struct {
  7. BaseAuthController
  8. }
  9. // List
  10. // @Title 报告列表
  11. // @Description 报告列表
  12. // @Param PageSize query int true "每页数据条数"
  13. // @Param CurrentIndex query int true "当前页页码"
  14. // @Param Keyword query string false "搜索关键词"
  15. // @Param State query int false "状态"
  16. // @Success 200 {object} models.SmartReportListResp
  17. // @router /list [get]
  18. func (this *SmartReportController) List() {
  19. br := new(models.BaseResponse).Init()
  20. defer func() {
  21. this.Data["json"] = br
  22. this.ServeJSON()
  23. }()
  24. br.Ret = 301
  25. br.Msg = "智能研报已合并到中文研报,请使用中文研报的接口"
  26. br.ErrMsg = "智能研报已合并到中文研报,请使用中文研报的接口"
  27. return
  28. //type SmartReportListReq struct {
  29. // PageSize int `form:"PageSize"`
  30. // CurrentIndex int `form:"CurrentIndex"`
  31. //}
  32. //params := new(SmartReportListReq)
  33. //if e := this.ParseForm(params); e != nil {
  34. // br.Msg = "获取失败"
  35. // br.ErrMsg = "入参解析失败, Err: " + e.Error()
  36. // return
  37. //}
  38. //
  39. //var condition string
  40. //var pars []interface{}
  41. //keyword := this.GetString("Keyword")
  42. //keyword = strings.TrimSpace(keyword)
  43. //if keyword != "" {
  44. // kw := fmt.Sprint("%", keyword, "%")
  45. // condition += ` AND (title LIKE ? OR author LIKE ? OR admin_real_name LIKE ?) `
  46. // pars = append(pars, kw, kw, kw)
  47. //}
  48. //state, _ := this.GetInt("State")
  49. //if state > 0 {
  50. // condition += ` AND state = ? `
  51. // pars = append(pars, state)
  52. //}
  53. //admindId, _ := this.GetInt("AdminId")
  54. //if admindId > 0 {
  55. // condition += ` AND admin_id = ? `
  56. // pars = append(pars, admindId)
  57. //}
  58. //classifyId, _ := this.GetInt("ClassifyId")
  59. //if classifyId > 0 {
  60. // condition += ` AND (classify_id_first = ? OR classify_id_second = ?) `
  61. // pars = append(pars, classifyId, classifyId)
  62. //}
  63. //
  64. //resp := new(models.SmartReportListResp)
  65. //reportOB := new(models.SmartReport)
  66. //total, e := reportOB.GetCountByCondition(condition, pars)
  67. //if e != nil {
  68. // br.Msg = "获取失败"
  69. // br.ErrMsg = "获取报告总数失败, Err:" + e.Error()
  70. // return
  71. //}
  72. //if total <= 0 {
  73. // page := paging.GetPaging(params.CurrentIndex, params.PageSize, total)
  74. // resp.Paging = page
  75. // br.Ret = 200
  76. // br.Msg = "获取成功"
  77. // br.Data = resp
  78. // return
  79. //}
  80. //
  81. //// 分页列表
  82. //var startSize int
  83. //if params.PageSize <= 0 {
  84. // params.PageSize = utils.PageSize20
  85. //}
  86. //if params.CurrentIndex <= 0 {
  87. // params.CurrentIndex = 1
  88. //}
  89. //startSize = utils.StartIndex(params.CurrentIndex, params.PageSize)
  90. //
  91. //list, e := reportOB.GetPageItemsByCondition(condition, pars, []string{}, "", startSize, params.PageSize)
  92. //if e != nil {
  93. // br.Msg = "获取失败"
  94. // br.ErrMsg = "获取报告分页列表失败, Err:" + e.Error()
  95. // return
  96. //}
  97. //resp.List = make([]*models.SmartReportItem, 0)
  98. //for _, v := range list {
  99. // t := models.FormatSmartReport2Item(v)
  100. // resp.List = append(resp.List, t)
  101. //}
  102. //
  103. //page := paging.GetPaging(params.CurrentIndex, params.PageSize, total)
  104. //resp.Paging = page
  105. //br.Ret = 200
  106. //br.Msg = "获取成功"
  107. //br.Data = resp
  108. }
  109. // Detail
  110. // @Title 详情
  111. // @Description 详情
  112. // @Param SmartReportId query int true "智能研报ID"
  113. // @Success 200 {object} models.SmartReportItem
  114. // @router /detail [get]
  115. func (this *SmartReportController) Detail() {
  116. br := new(models.BaseResponse).Init()
  117. defer func() {
  118. this.Data["json"] = br
  119. this.ServeJSON()
  120. }()
  121. br.Ret = 301
  122. br.Msg = "智能研报已合并到中文研报,请使用中文研报的接口"
  123. br.ErrMsg = "智能研报已合并到中文研报,请使用中文研报的接口"
  124. return
  125. //reportId, _ := this.GetInt("SmartReportId")
  126. //if reportId <= 0 {
  127. // br.Msg = "参数有误"
  128. // br.ErrMsg = "报告ID有误"
  129. // return
  130. //}
  131. //
  132. //ob := new(models.SmartReport)
  133. //item, e := ob.GetItemById(reportId)
  134. //if e != nil {
  135. // if e.Error() == utils.ErrNoRow() {
  136. // br.Msg = "报告已被删除"
  137. // return
  138. // }
  139. // br.Msg = "操作失败"
  140. // br.ErrMsg = "获取研报失败, Err: " + e.Error()
  141. // return
  142. //}
  143. //resp := models.FormatSmartReport2Item(item)
  144. //
  145. //br.Ret = 200
  146. //br.Msg = "获取成功"
  147. //br.Data = resp
  148. }
  149. // Approve
  150. // @Title 审批
  151. // @Description 审批报告
  152. // @Param request body models.SmartReportApproveReq true "type json string"
  153. // @Success 200 string "操作成功"
  154. // @router /approve [post]
  155. func (this *SmartReportController) Approve() {
  156. br := new(models.BaseResponse).Init()
  157. defer func() {
  158. this.Data["json"] = br
  159. this.ServeJSON()
  160. }()
  161. br.Ret = 301
  162. br.Msg = "智能研报已合并到中文研报,请使用中文研报的接口"
  163. br.ErrMsg = "智能研报已合并到中文研报,请使用中文研报的接口"
  164. return
  165. //var req models.SmartReportApproveReq
  166. //err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  167. //if err != nil {
  168. // br.Msg = "参数解析异常!"
  169. // br.ErrMsg = "参数解析失败,Err:" + err.Error()
  170. // return
  171. //}
  172. //if req.ReportId <= 0 {
  173. // br.Msg = "参数错误"
  174. // br.ErrMsg = fmt.Sprintf("参数有误, SmartReportId: %d", req.ReportId)
  175. // return
  176. //}
  177. //
  178. //ob := new(models.SmartReport)
  179. //item, e := ob.GetItemById(req.ReportId)
  180. //if e != nil {
  181. // if e.Error() == utils.ErrNoRow() {
  182. // br.Msg = "报告已被删除"
  183. // return
  184. // }
  185. // br.Msg = "操作失败"
  186. // br.ErrMsg = "获取智能研报失败, Err: " + e.Error()
  187. // return
  188. //}
  189. //if item.State != models.ReportStateWaitApprove {
  190. // br.Msg = "报告状态有误"
  191. // br.ErrMsg = fmt.Sprintf("报告状态有误, State: %d", item.State)
  192. // return
  193. //}
  194. //if item.Content == "" {
  195. // br.Msg = "报告内容为空,请检查内容"
  196. // return
  197. //}
  198. //
  199. //// 校验审批配置
  200. //confMap, e := models.GetBusinessConf()
  201. //if e != nil {
  202. // br.Msg = "操作失败"
  203. // br.ErrMsg = "获取审批配置失败, Err: " + e.Error()
  204. // return
  205. //}
  206. //if confMap[models.BusinessConfIsReportApprove] != "true" {
  207. // br.Msg = "未开启审批, 请开启后重新操作"
  208. // return
  209. //}
  210. //if confMap[models.BusinessConfReportApproveType] != models.BusinessConfReportApproveTypeOther {
  211. // br.Msg = "未开启第三方审批, 请开启后重新操作"
  212. // return
  213. //}
  214. //
  215. //stateMap := map[bool]int{false: models.ReportStateRefused, true: models.ReportStatePass}
  216. //// 驳回
  217. //now := time.Now().Local()
  218. //if !req.Pass {
  219. // cols := []string{"State", "ModifyTime", "ApproveTime"}
  220. // item.State = stateMap[req.Pass]
  221. // item.ModifyTime = now
  222. // item.ApproveTime = now
  223. // if e = item.Update(cols); e != nil {
  224. // br.Msg = "审批失败"
  225. // br.ErrMsg = "报告审批驳回失败, Err: " + e.Error()
  226. // return
  227. // }
  228. //}
  229. //
  230. //// 通过审批
  231. //if req.Pass {
  232. // cols := []string{"State", "ModifyTime", "ApproveTime", "PublishTime"}
  233. // item.State = stateMap[req.Pass]
  234. // item.ModifyTime = now
  235. // item.ApproveTime = now
  236. // item.PublishTime = now
  237. // if e = item.Update(cols); e != nil {
  238. // br.Msg = "审批失败"
  239. // br.ErrMsg = "报告审批通过失败, Err: " + e.Error()
  240. // return
  241. // }
  242. //
  243. // // 写入队列
  244. // var queue models.Report2ImgQueueReq
  245. // queue.ReportType = 2
  246. // queue.ReportCode = item.ReportCode
  247. // _ = utils.Rc.LPush(utils.CACHE_CREATE_REPORT_IMGPDF_QUEUE, queue)
  248. //
  249. // // 更新报告ES
  250. // go func() {
  251. // _ = services.SmartReportElasticUpsert(item.SmartReportId, models.ReportStatePublished)
  252. // }()
  253. //}
  254. //
  255. //// 记录报告变更状态
  256. //go func() {
  257. // recordItem := &models.ReportStateRecord{
  258. // ReportId: req.ReportId,
  259. // ReportType: models.ReportTypeSmart,
  260. // State: item.State,
  261. // CreateTime: time.Now(),
  262. // }
  263. // _, _ = models.AddReportStateRecord(recordItem)
  264. //}()
  265. //
  266. //br.Ret = 200
  267. //br.Msg = "审批成功"
  268. }