report_push_status.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "eta/eta_mini_crm/models"
  5. "eta/eta_mini_crm/models/request"
  6. "eta/eta_mini_crm/models/response"
  7. "eta/eta_mini_crm/utils"
  8. "fmt"
  9. "strconv"
  10. "strings"
  11. "time"
  12. "github.com/rdlucklib/rdluck_tools/paging"
  13. )
  14. type ReportPushStatusController struct {
  15. BaseAuthController
  16. }
  17. // List
  18. // @Title pdf研报列表
  19. // @Description pdf研报列表
  20. // @Param PageSize query int true "每页数据条数"
  21. // @Param CurrentIndex query int true "当前页页码,从1开始"
  22. // @Param ClassifyIds query string true "分类id,可多选用英文,隔开"
  23. // @Param ChartPermissionIds query string true "品种id,可多选用英文,隔开"
  24. // @Param PublishStartDate query string true "发布开始时间"
  25. // @Param PublishEndDate query string true "发布结束时间"
  26. // @Param PushStartDate query string true "推送开始时间"
  27. // @Param PushEndDate query string true "推送结束时间"
  28. // @Param KeyWord query string true "报告标题/创建人"
  29. // @Param SelectedIds query string true "选择的报告id, isSelectAll:为true时,反选"
  30. // @Param IsSelectAll query bool true "是否全选"
  31. // @Param SortParam query string true "排序字段"
  32. // @Param SortType query string true "排序方式"
  33. // @Success 200 {object} models.ReportAuthorResp
  34. // @router /list [get]
  35. func (this *ReportPushStatusController) List() {
  36. br := new(models.BaseResponse).Init()
  37. defer func() {
  38. this.Data["json"] = br
  39. this.ServeJSON()
  40. }()
  41. pageSize, _ := this.GetInt("PageSize")
  42. currentIndex, _ := this.GetInt("CurrentIndex")
  43. classifyIds := this.GetString("ClassifyIds")
  44. selectedIds := this.GetString("SelectedIds")
  45. isSelectAll, _ := this.GetBool("IsSelectAll")
  46. chartPermissionIds := this.GetString("ChartPermissionIds")
  47. publishStartDate := this.GetString("PublishStartDate")
  48. publishEndDate := this.GetString("PublishEndDate")
  49. pushStartDate := this.GetString("PushStartDate")
  50. pushEndDate := this.GetString("PushEndDate")
  51. keyWord := this.GetString("KeyWord")
  52. sortParam := this.GetString("SortParam")
  53. sortType := this.GetString("SortType")
  54. if pageSize <= 0 {
  55. pageSize = utils.PageSize20
  56. }
  57. if currentIndex <= 0 {
  58. currentIndex = 1
  59. }
  60. var condition string
  61. var pars []interface{}
  62. if publishStartDate != "" && publishEndDate != "" {
  63. condition += " AND publish_time >= ?"
  64. publishStartTime, err := time.Parse(utils.FormatDate, publishStartDate)
  65. if err != nil {
  66. br.Msg = "日期格式有误"
  67. br.ErrMsg = "日期格式有误,Err:" + err.Error()
  68. return
  69. }
  70. publishStartDateStr := publishStartTime.Format(utils.FormatDateTime)
  71. pars = append(pars, publishStartDateStr)
  72. condition += " AND publish_time <= ?"
  73. publishEndTime, err := time.Parse(utils.FormatDate, publishEndDate)
  74. if err != nil {
  75. br.Msg = "日期格式有误"
  76. br.ErrMsg = "日期格式有误,Err:" + err.Error()
  77. return
  78. }
  79. publishEndTime = publishEndTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
  80. publishEndDateStr := publishEndTime.Format(utils.FormatDateTime)
  81. pars = append(pars, publishEndDateStr)
  82. }
  83. if pushStartDate != "" && pushEndDate != "" {
  84. condition += " AND push_time >= ? "
  85. pushStartTime, err := time.Parse(utils.FormatDate, pushStartDate)
  86. if err != nil {
  87. br.Msg = "日期格式有误"
  88. br.ErrMsg = "日期格式有误,Err:" + err.Error()
  89. return
  90. }
  91. pushStartDateStr := pushStartTime.Format(utils.FormatDateTime)
  92. pars = append(pars, pushStartDateStr)
  93. condition += " AND push_time <= ? "
  94. pushEndTime, err := time.Parse(utils.FormatDate, pushEndDate)
  95. if err != nil {
  96. br.Msg = "日期格式有误"
  97. br.ErrMsg = "日期格式有误,Err:" + err.Error()
  98. return
  99. }
  100. pushEndTime = pushEndTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
  101. pushEndDateStr := pushEndTime.Format(utils.FormatDateTime)
  102. pars = append(pars, pushEndDateStr)
  103. }
  104. if keyWord != "" {
  105. condition += ` AND title like ? `
  106. pars = utils.GetLikeKeywordPars(pars, keyWord, 1)
  107. }
  108. var sortCondition string
  109. if sortParam != "" && sortType != "" {
  110. sortCondition = " ORDER BY "
  111. var param, sort string
  112. switch sortParam {
  113. case "PublishTime":
  114. param = "publish_time"
  115. case "PushTime":
  116. param = "push_time"
  117. }
  118. switch sortType {
  119. case "asc":
  120. sort = " ASC "
  121. case "desc":
  122. sort = " DESC "
  123. }
  124. if param != "" && sort != "" {
  125. sortCondition += param + " " + sort
  126. } else {
  127. sortCondition = ""
  128. }
  129. }
  130. if sortCondition == "" {
  131. sortCondition = ` ORDER BY publish_time DESC `
  132. }
  133. classifyIdList := make([]int, 0)
  134. if classifyIds != "" {
  135. classifyArrStr := strings.Split(classifyIds, ",")
  136. if len(classifyArrStr) > 0 {
  137. for _, v := range classifyArrStr {
  138. tmp, _ := strconv.Atoi(v)
  139. classifyIdList = append(classifyIdList, tmp)
  140. }
  141. }
  142. }
  143. if chartPermissionIds != "" {
  144. idStrs := strings.Split(chartPermissionIds, ",")
  145. idInts := make([]int, 0)
  146. for _, id := range idStrs {
  147. tmp, _ := strconv.Atoi(id)
  148. idInts = append(idInts, tmp)
  149. }
  150. tmpClassifyIds, err := models.GetClassifyIdsListByIds(idInts)
  151. if err != nil {
  152. br.Msg = "获取研报列表失败"
  153. br.ErrMsg = "品种获取分类失败,Err:" + err.Error()
  154. return
  155. }
  156. if len(tmpClassifyIds) == 0 {
  157. resp := new(response.ReportPushStatusResp)
  158. resp.Paging = paging.GetPaging(currentIndex, pageSize, 0)
  159. br.Data = resp
  160. br.Msg = "查询成功"
  161. br.Success = true
  162. br.Ret = 200
  163. return
  164. }
  165. classifyIdList = append(classifyIdList, tmpClassifyIds...)
  166. }
  167. if len(classifyIdList) > 0 {
  168. classifyStrIds := make([]string, 0)
  169. for _, v := range classifyIdList {
  170. classifyStrIds = append(classifyStrIds, strconv.Itoa(v))
  171. }
  172. classifyList, err := models.GetClassifyListByIds(classifyStrIds)
  173. if err != nil {
  174. br.Msg = "获取研报列表失败"
  175. br.ErrMsg = "获取研报分类失败,Err:" + err.Error()
  176. return
  177. }
  178. childClasifyIdList := make([]int, 0)
  179. for _, v := range classifyList {
  180. if v.HasChild == 0 {
  181. childClasifyIdList = append(childClasifyIdList, v.Id)
  182. }
  183. }
  184. condition += ` AND (classify_id_first IN (%s) OR classify_id_second IN (%s) OR classify_id_third IN (%s))`
  185. condition = fmt.Sprintf(condition, utils.GetOrmReplaceHolder(len(childClasifyIdList)), utils.GetOrmReplaceHolder(len(childClasifyIdList)), utils.GetOrmReplaceHolder(len(childClasifyIdList)))
  186. pars = append(pars, childClasifyIdList, childClasifyIdList, childClasifyIdList)
  187. }
  188. if isSelectAll {
  189. if selectedIds != "" {
  190. selectIdStrs := strings.Split(selectedIds, ",")
  191. if len(selectIdStrs) > 0 {
  192. condition += ` AND report_id NOT IN (` + utils.GetOrmReplaceHolder(len(selectIdStrs)) + `)`
  193. pars = append(pars, selectIdStrs)
  194. }
  195. }
  196. } else {
  197. if selectedIds != "" {
  198. selectIdStrs := strings.Split(selectedIds, ",")
  199. if len(selectIdStrs) > 0 {
  200. condition += ` AND report_id IN (` + utils.GetOrmReplaceHolder(len(selectIdStrs)) + `)`
  201. pars = append(pars, selectIdStrs)
  202. }
  203. }
  204. }
  205. startSize := utils.StartIndex(currentIndex, pageSize)
  206. total, err := models.GetReportCountByCondition(condition, pars)
  207. if err != nil {
  208. br.Msg = "获取研报列表失败"
  209. br.ErrMsg = "获取研报列表统计失败,Err:" + err.Error()
  210. return
  211. }
  212. reportList, err := models.GetReportPushStatusListByCondition(condition, sortCondition, pars, startSize, pageSize)
  213. if err != nil {
  214. br.Msg = "获取研报列表失败"
  215. br.ErrMsg = "获取研报列表失败,Err:" + err.Error()
  216. return
  217. }
  218. page := paging.GetPaging(currentIndex, pageSize, total)
  219. resp := new(response.ReportPushStatusResp)
  220. resp.List = reportList
  221. resp.Paging = page
  222. br.Data = resp
  223. br.Msg = "获取成功"
  224. br.Ret = 200
  225. br.Success = true
  226. }
  227. // PushCancel
  228. // @Title 取消推送报告
  229. // @Description 取消推送报告
  230. // @Param request body request.ReportPdfEditReq true "type json string"
  231. // @Success 200 {object} models.ReportAuthorResp
  232. // @router /pushCancel [post]
  233. func (this *ReportPushStatusController) PushCancel() {
  234. br := new(models.BaseResponse).Init()
  235. defer func() {
  236. this.Data["json"] = br
  237. this.ServeJSON()
  238. }()
  239. var req request.ReportPushStatusReq
  240. if err := json.Unmarshal(this.Ctx.Input.RequestBody, &req); err != nil {
  241. br.Msg = "参数错误"
  242. br.ErrMsg = "参数错误,Err:" + err.Error()
  243. return
  244. }
  245. reportPush, err := models.GetReportPushStatusByReportId(req.ReportPushStatusId, 1)
  246. if err != nil && err.Error() != utils.ErrNoRow() {
  247. br.Msg = "推送失败"
  248. br.ErrMsg = "获取推送消息失败,Err:" + err.Error()
  249. return
  250. }
  251. if reportPush != nil {
  252. reportPush.State = 0
  253. reportPush.ModifyTime = time.Now()
  254. err = reportPush.Update([]string{"state", "modify_time"})
  255. if err != nil {
  256. br.Msg = "取消推送失败"
  257. br.ErrMsg = "取消推送失败,Err:" + err.Error()
  258. return
  259. }
  260. }
  261. br.Msg = "取消推送成功"
  262. br.Success = true
  263. br.Ret = 200
  264. }
  265. // Push
  266. // @Title 推送报告
  267. // @Description 推送报告
  268. // @Param request body request.ReportPdfEditReq true "type json string"
  269. // @Success 200 {object} models.ReportAuthorResp
  270. // @router /push [post]
  271. func (this *ReportPushStatusController) Push() {
  272. br := new(models.BaseResponse).Init()
  273. defer func() {
  274. this.Data["json"] = br
  275. this.ServeJSON()
  276. }()
  277. var req request.ReportPushStatusReq
  278. if err := json.Unmarshal(this.Ctx.Input.RequestBody, &req); err != nil {
  279. br.Msg = "参数错误"
  280. br.ErrMsg = "参数错误,Err:" + err.Error()
  281. return
  282. }
  283. reportPush, err := models.GetReportPushStatusByReportId(req.ReportPushStatusId, 0)
  284. if err != nil && err.Error() != utils.ErrNoRow() {
  285. br.Msg = "推送失败"
  286. br.ErrMsg = "获取推送消息失败,Err:" + err.Error()
  287. return
  288. }
  289. if reportPush != nil {
  290. reportPush.State = 1
  291. reportPush.ModifyTime = time.Now()
  292. reportPush.PushTime = time.Now()
  293. err = reportPush.Update([]string{"state", "modify_time", "push_time"})
  294. if err != nil {
  295. br.Msg = "推送失败"
  296. br.ErrMsg = "推送失败,Err:" + err.Error()
  297. return
  298. }
  299. }
  300. br.Msg = "推送成功"
  301. br.Success = true
  302. br.Ret = 200
  303. }
  304. // BatchPush
  305. // @Title 批量推送报告
  306. // @Description 批量推送报告
  307. // @Param request body request.BatchReportModifyPushStatusReq true "type json string"
  308. // @Success 200 {object} models.ReportAuthorResp
  309. // @router /batch/push [post]
  310. func (this *ReportPushStatusController) BatchPush() {
  311. br := new(models.BaseResponse).Init()
  312. defer func() {
  313. this.Data["json"] = br
  314. this.ServeJSON()
  315. }()
  316. var req request.BatchReportModifyPushStatusReq
  317. if err := json.Unmarshal(this.Ctx.Input.RequestBody, &req); err != nil {
  318. br.Msg = "参数错误"
  319. br.ErrMsg = "参数错误,Err:" + err.Error()
  320. return
  321. }
  322. var condition string
  323. var pars []interface{}
  324. condition = ` AND state = 0 `
  325. if req.PublishStartDate != "" && req.PublishEndDate != "" {
  326. condition += " AND publish_time >= ?"
  327. publishStartTime, err := time.Parse(utils.FormatDate, req.PublishStartDate)
  328. if err != nil {
  329. br.Msg = "日期格式有误"
  330. br.ErrMsg = "日期格式有误,Err:" + err.Error()
  331. return
  332. }
  333. publishStartDateStr := publishStartTime.Format(utils.FormatDateTime)
  334. pars = append(pars, publishStartDateStr)
  335. condition += " AND publish_time <= ?"
  336. publishEndTime, err := time.Parse(utils.FormatDate, req.PublishEndDate)
  337. if err != nil {
  338. br.Msg = "日期格式有误"
  339. br.ErrMsg = "日期格式有误,Err:" + err.Error()
  340. return
  341. }
  342. publishEndTime = publishEndTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
  343. publishEndDateStr := publishEndTime.Format(utils.FormatDateTime)
  344. pars = append(pars, publishEndDateStr)
  345. }
  346. if req.PushStartDate != "" && req.PushEndDate != "" {
  347. condition += " AND push_time >= ?"
  348. pushStartTime, err := time.Parse(utils.FormatDate, req.PushStartDate)
  349. if err != nil {
  350. br.Msg = "日期格式有误"
  351. br.ErrMsg = "日期格式有误,Err:" + err.Error()
  352. return
  353. }
  354. pushStartDateStr := pushStartTime.Format(utils.FormatDateTime)
  355. pars = append(pars, pushStartDateStr)
  356. condition += " AND push_time <= ?"
  357. pushEndTime, err := time.Parse(utils.FormatDate, req.PushEndDate)
  358. if err != nil {
  359. br.Msg = "日期格式有误"
  360. br.ErrMsg = "日期格式有误,Err:" + err.Error()
  361. return
  362. }
  363. pushEndTime = pushEndTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
  364. pushEndDateStr := pushEndTime.Format(utils.FormatDateTime)
  365. pars = append(pars, pushEndDateStr)
  366. }
  367. if req.KeyWord != "" {
  368. condition += ` AND title like ? `
  369. pars = utils.GetLikeKeywordPars(pars, req.KeyWord, 1)
  370. }
  371. classifyIdList := make([]int, 0)
  372. classifyIdList = append(classifyIdList, req.ClassifyIds...)
  373. tmpClassifyList, err := models.GetClassifyIdsListByIds(req.ChartPermissionIds)
  374. if err != nil {
  375. br.Msg = "获取研报列表失败"
  376. br.ErrMsg = "品种获取分类失败,Err:" + err.Error()
  377. return
  378. }
  379. classifyIdList = append(classifyIdList, tmpClassifyList...)
  380. if len(classifyIdList) > 0 {
  381. classifyIdList = utils.Unique(classifyIdList)
  382. condition += ` AND (classify_id_first IN (%s) AND classify_id_second IN (%s) AND classify_id_third IN (%s))`
  383. condition = fmt.Sprintf(condition, utils.GetOrmReplaceHolder(len(classifyIdList)), utils.GetOrmReplaceHolder(len(classifyIdList)), utils.GetOrmReplaceHolder(len(classifyIdList)))
  384. pars = append(pars, classifyIdList, classifyIdList, classifyIdList)
  385. }
  386. if req.IsSelectAll {
  387. if len(req.SelectedIds) > 0 {
  388. condition += ` AND report_push_status_id NOT IN (` + utils.GetOrmReplaceHolder(len(req.SelectedIds)) + `)`
  389. pars = append(pars, req.SelectedIds)
  390. }
  391. } else {
  392. if len(req.SelectedIds) > 0 {
  393. condition += ` AND report_push_status_id IN (` + utils.GetOrmReplaceHolder(len(req.SelectedIds)) + `)`
  394. pars = append(pars, req.SelectedIds)
  395. }
  396. }
  397. reportPushStatusIds, err := models.GetReportPushStatusIdListByCondition(condition, pars)
  398. if err != nil {
  399. br.Msg = "批量推送失败"
  400. br.ErrMsg = "查询研报失败,Err:" + err.Error()
  401. return
  402. }
  403. // reportPush, err := models.GetReportPushStatusByIdAndState(reportIds, 0)
  404. // if err != nil {
  405. // br.Msg = "批量推送失败"
  406. // br.ErrMsg = "查询推送状态失败,Err:" + err.Error()
  407. // return
  408. // }
  409. // existReportMap := make(map[int]struct{})
  410. // for _, v := range reportPush {
  411. // existReportMap[v.ReportId] = struct{}{}
  412. // }
  413. // existReportIds := make([]int, 0)
  414. // for _, v := range reportIds {
  415. // if _, ok := existReportMap[v]; ok {
  416. // existReportIds = append(existReportIds, v)
  417. // }
  418. // }
  419. err = models.BatchPushReport(reportPushStatusIds)
  420. if err != nil {
  421. br.Msg = "批量推送失败"
  422. br.ErrMsg = "批量修改推送失败,Err:" + err.Error()
  423. return
  424. }
  425. br.Msg = "推送成功"
  426. br.Success = true
  427. br.Ret = 200
  428. }
  429. // BatchPushCancel
  430. // @Title 批量撤销推送报告
  431. // @Description 批量撤销推送报告
  432. // @Param request body request.BatchReportModifyPushStatusReq true "type json string"
  433. // @Success 200 {object} models.ReportAuthorResp
  434. // @router /batch/pushCancel [post]
  435. func (this *ReportPushStatusController) BatchPushCancel() {
  436. br := new(models.BaseResponse).Init()
  437. defer func() {
  438. this.Data["json"] = br
  439. this.ServeJSON()
  440. }()
  441. var req request.BatchReportModifyPushStatusReq
  442. if err := json.Unmarshal(this.Ctx.Input.RequestBody, &req); err != nil {
  443. br.Msg = "参数错误"
  444. br.ErrMsg = "参数错误,Err:" + err.Error()
  445. return
  446. }
  447. var condition string
  448. var pars []interface{}
  449. condition = ` AND state = 1 `
  450. if req.PublishStartDate != "" && req.PublishEndDate != "" {
  451. condition += " AND publish_time >= ?"
  452. publishStartTime, err := time.Parse(utils.FormatDate, req.PublishStartDate)
  453. if err != nil {
  454. br.Msg = "日期格式有误"
  455. br.ErrMsg = "日期格式有误,Err:" + err.Error()
  456. return
  457. }
  458. publishStartDateStr := publishStartTime.Format(utils.FormatDateTime)
  459. pars = append(pars, publishStartDateStr)
  460. condition += " AND publish_time <= ?"
  461. publishEndTime, err := time.Parse(utils.FormatDate, req.PublishEndDate)
  462. if err != nil {
  463. br.Msg = "日期格式有误"
  464. br.ErrMsg = "日期格式有误,Err:" + err.Error()
  465. return
  466. }
  467. publishEndTime = publishEndTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
  468. publishEndDateStr := publishEndTime.Format(utils.FormatDateTime)
  469. pars = append(pars, publishEndDateStr)
  470. }
  471. if req.PushStartDate != "" && req.PushEndDate != "" {
  472. condition += " AND push_time >= ?"
  473. pushStartTime, err := time.Parse(utils.FormatDate, req.PushStartDate)
  474. if err != nil {
  475. br.Msg = "日期格式有误"
  476. br.ErrMsg = "日期格式有误,Err:" + err.Error()
  477. return
  478. }
  479. pushStartDateStr := pushStartTime.Format(utils.FormatDateTime)
  480. pars = append(pars, pushStartDateStr)
  481. condition += " AND push_time <= ?"
  482. pushEndTime, err := time.Parse(utils.FormatDate, req.PushEndDate)
  483. if err != nil {
  484. br.Msg = "日期格式有误"
  485. br.ErrMsg = "日期格式有误,Err:" + err.Error()
  486. return
  487. }
  488. pushEndTime = pushEndTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
  489. pushEndDateStr := pushEndTime.Format(utils.FormatDateTime)
  490. pars = append(pars, pushEndDateStr)
  491. }
  492. if req.KeyWord != "" {
  493. condition += ` AND title like ? `
  494. pars = utils.GetLikeKeywordPars(pars, req.KeyWord, 1)
  495. }
  496. classifyIdList := make([]int, 0)
  497. classifyIdList = append(classifyIdList, req.ClassifyIds...)
  498. tmpClassifyList, err := models.GetClassifyIdsListByIds(req.ChartPermissionIds)
  499. if err != nil {
  500. br.Msg = "获取研报列表失败"
  501. br.ErrMsg = "品种获取分类失败,Err:" + err.Error()
  502. return
  503. }
  504. classifyIdList = append(classifyIdList, tmpClassifyList...)
  505. if len(classifyIdList) > 0 {
  506. classifyIdList = utils.Unique(classifyIdList)
  507. condition += ` AND (classify_id_first IN (%s) AND classify_id_second IN (%s) AND classify_id_third IN (%s))`
  508. condition = fmt.Sprintf(condition, utils.GetOrmReplaceHolder(len(classifyIdList)), utils.GetOrmReplaceHolder(len(classifyIdList)), utils.GetOrmReplaceHolder(len(classifyIdList)))
  509. pars = append(pars, classifyIdList, classifyIdList, classifyIdList)
  510. }
  511. if req.IsSelectAll {
  512. if len(req.SelectedIds) > 0 {
  513. condition += ` AND report_push_status_id NOT IN (` + utils.GetOrmReplaceHolder(len(req.SelectedIds)) + `)`
  514. pars = append(pars, req.SelectedIds)
  515. }
  516. } else {
  517. if len(req.SelectedIds) > 0 {
  518. condition += ` AND report_push_status_id IN (` + utils.GetOrmReplaceHolder(len(req.SelectedIds)) + `)`
  519. pars = append(pars, req.SelectedIds)
  520. }
  521. }
  522. reportPushStatusIds, err := models.GetReportPushStatusIdListByCondition(condition, pars)
  523. if err != nil {
  524. br.Msg = "批量推送失败"
  525. br.ErrMsg = "查询研报失败,Err:" + err.Error()
  526. return
  527. }
  528. // reportIds, err := models.GetReportIdListByCondition(condition, pars)
  529. // if err != nil {
  530. // br.Msg = "批量推送失败"
  531. // br.ErrMsg = "查询研报失败,Err:" + err.Error()
  532. // return
  533. // }
  534. // reportPush, err := models.GetReportPushStatusByReportIdAndState(reportIds, 1)
  535. // if err != nil {
  536. // br.Msg = "批量推送失败"
  537. // br.ErrMsg = "查询推送状态失败,Err:" + err.Error()
  538. // return
  539. // }
  540. // existReportMap := make(map[int]struct{})
  541. // for _, v := range reportPush {
  542. // existReportMap[v.ReportId] = struct{}{}
  543. // }
  544. // existReportIds := make([]int, 0)
  545. // for _, v := range reportIds {
  546. // if _, ok := existReportMap[v]; ok {
  547. // existReportIds = append(existReportIds, v)
  548. // }
  549. // }
  550. err = models.BatchPushCancelReport(reportPushStatusIds)
  551. if err != nil {
  552. br.Msg = "批量取消推送失败"
  553. br.ErrMsg = "批量修改推送失败,Err:" + err.Error()
  554. return
  555. }
  556. br.Msg = "撤销推送成功"
  557. br.Success = true
  558. br.Ret = 200
  559. }