EventController.java 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. package com.sooka.sponest.mobile.comprehensive.eventController;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.ruoyi.common.core.constant.HttpStatus;
  4. import com.ruoyi.common.core.utils.SpringUtils;
  5. import com.ruoyi.common.core.utils.StringUtils;
  6. import com.ruoyi.common.core.web.domain.AjaxResult;
  7. import com.ruoyi.common.core.web.page.TableDataInfo;
  8. import com.ruoyi.common.redis.service.RedisService;
  9. import com.ruoyi.common.security.utils.DictUtils;
  10. import com.ruoyi.system.api.domain.SysDictData;
  11. import com.sooka.sponest.comprehensive.api.comprehensiveEvent.domain.ZhsqEvent;
  12. import com.sooka.sponest.comprehensive.api.comprehensiveEvent.service.*;
  13. import org.springframework.web.bind.annotation.*;
  14. import javax.annotation.Resource;
  15. import java.util.HashMap;
  16. import java.util.List;
  17. import java.util.Map;
  18. @RestController
  19. @RequestMapping("/AppComprehensiveEvent")
  20. public class EventController {
  21. @Resource
  22. private RemoteEventService eventService;
  23. @Resource
  24. private RemoteEventTodoService eventTodoService;
  25. @Resource
  26. private RemoteEventCompletedService eventCompletedService;
  27. @Resource
  28. private RemoteEventVerfiedService eventVerfiedService;
  29. @Resource
  30. private RemoteEventDistributeService eventDistributeService;
  31. @Resource
  32. private RemoteEventFileService eventFileService;
  33. /**
  34. * 查询事件列表接口(分页)
  35. * @param pageNum
  36. * @param pageSize
  37. * @return
  38. */
  39. @GetMapping("/event/getList")
  40. public AjaxResult getEventList(@RequestParam("pageNum") String pageNum, @RequestParam("pageSize") String pageSize, @RequestParam("eventType") String eventType) {
  41. TableDataInfo data = new TableDataInfo();
  42. switch (eventType){
  43. case "1":
  44. data = eventService.getList(pageNum,pageSize);
  45. return setLabel(data, "eventState");
  46. case "2":
  47. data = eventTodoService.getList(pageNum,pageSize);
  48. return setLabel(data, "sjczCzzt");
  49. case "3":
  50. data = eventCompletedService.getList(pageNum,pageSize);
  51. return setLabel(data, "eventState");
  52. case "4":
  53. data = eventVerfiedService.getList(pageNum,pageSize);
  54. return setLabel(data, "eventState");
  55. case "5":
  56. data = eventDistributeService.getList(pageNum,pageSize);
  57. return setLabel(data, "sjczCzzt");
  58. case "6":
  59. data = eventFileService.getList(pageNum,pageSize);
  60. return setLabel(data, "eventState");
  61. default:
  62. return AjaxResult.error(500, "参数错误");
  63. }
  64. }
  65. private AjaxResult setLabel(TableDataInfo data, String keys){
  66. if (HttpStatus.SUCCESS == data.getCode()) {
  67. Map<String, Object> eventType1 = DictUtils.getDictCacheToMap("eventType");
  68. List<HashMap<String, Object>> rows = (List<HashMap<String, Object>>) data.getRows();
  69. for (HashMap<String, Object> row : rows) {
  70. row.put("eventStateLabel", eventType1.get(row.get(keys).toString()));
  71. }
  72. return AjaxResult.success(rows);
  73. } else {
  74. return AjaxResult.error(data.getCode(), data.getMsg());
  75. }
  76. }
  77. /**
  78. * 查询事件详情接口
  79. * @param eventId
  80. * @return
  81. */
  82. @GetMapping("/event/edit")
  83. public AjaxResult getEdit(@RequestParam("eventId") String eventId){
  84. AjaxResult result = eventService.getEdit(eventId);
  85. if("200".equals(String.valueOf(result.get("code")))){
  86. HashMap<String, Object> data = (HashMap<String, Object>) result.get("data");
  87. String keys = "zhsqEventType";
  88. List<JSONObject> list = SpringUtils.getBean(RedisService.class).getCacheList(keys);
  89. for (JSONObject map : list) {
  90. if(map.getString("eventTypeId").equals(String.valueOf(data.get("eventTypeId")))){
  91. data.put("eventTypeLabel", map.get("eventTypeName"));
  92. break;
  93. }
  94. }
  95. return AjaxResult.success(data);
  96. }else{
  97. return AjaxResult.error(String.valueOf(result.get("code")), result.get("msg"));
  98. }
  99. }
  100. /**
  101. * 新增事件接口
  102. * @param event
  103. */
  104. @PostMapping("/event/addComprehensiveEvent")
  105. public AjaxResult add(@RequestBody ZhsqEvent event) {
  106. return eventService.add(event);
  107. }
  108. /**
  109. * 修改事件接口
  110. * @param zhsqEvent
  111. * @return
  112. */
  113. @PostMapping("/event/put")
  114. public AjaxResult put(@RequestBody ZhsqEvent zhsqEvent){
  115. return eventService.put(zhsqEvent);
  116. }
  117. /**
  118. * 事件删除接口
  119. * @param id
  120. * @return
  121. */
  122. @GetMapping("/event/del")
  123. public AjaxResult del(@RequestParam("id") List<String> id){
  124. return eventService.del(id.toArray(new String[0]));
  125. }
  126. /**
  127. * 上报事件
  128. * @param eventId
  129. * @return
  130. */
  131. @GetMapping("/event/report/eventId")
  132. public AjaxResult reportEventId(@RequestParam("eventId") String eventId){
  133. return eventService.reportEventId(eventId);
  134. }
  135. /**
  136. * 获取事件日志
  137. */
  138. @GetMapping("/event/eventLog")
  139. public AjaxResult getEventLog(@RequestParam("eventId") String eventId){
  140. return eventService.getEventLog(eventId);
  141. }
  142. }