AlarmController.java 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. package cn.com.lzt.alarm.controller;
  2. import cn.afterturn.easypoi.entity.vo.NormalExcelConstants;
  3. import cn.afterturn.easypoi.excel.entity.ExportParams;
  4. import cn.com.lzt.alarm.service.impl.AlarmServiceImpl;
  5. import com.alibaba.fastjson.JSONObject;
  6. import com.daju.common.util.DataPage;
  7. import com.daju.mix.dao.entity.PDeviceDetailRecord;
  8. import com.daju.mix.dao.entity.TBAlarm;
  9. import com.xcgl.device.entity.DeviceEntity;
  10. import org.jeecgframework.core.common.model.json.DataGrid;
  11. import org.jeecgframework.core.util.ResourceUtil;
  12. import org.jeecgframework.tag.core.easyui.TagUtil;
  13. import org.jeecgframework.web.system.service.SystemService;
  14. import org.springframework.beans.factory.annotation.Autowired;
  15. import org.springframework.stereotype.Controller;
  16. import org.springframework.ui.ModelMap;
  17. import org.springframework.web.bind.annotation.RequestMapping;
  18. import org.springframework.web.servlet.ModelAndView;
  19. import javax.annotation.Resource;
  20. import javax.servlet.http.HttpServletRequest;
  21. import javax.servlet.http.HttpServletResponse;
  22. import java.util.ArrayList;
  23. import java.util.HashMap;
  24. import java.util.List;
  25. import java.util.Map;
  26. /**
  27. * @author :sahib.kio.m
  28. * @date :Created in 2021/8/3 上午10:37
  29. */
  30. @Controller
  31. @RequestMapping("/alarmController")
  32. public class AlarmController {
  33. @Resource
  34. private AlarmServiceImpl alarmService;
  35. @Autowired
  36. private SystemService systemService;
  37. @RequestMapping(params = "list")
  38. public ModelAndView list(HttpServletRequest request) {
  39. return new ModelAndView("cn/com/lzt/alarm/alarmList");
  40. }
  41. @RequestMapping(params = "datagrid")
  42. public void datagrid(HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
  43. Map<String, String> param = new HashMap<>();
  44. for (String key : request.getParameterMap().keySet()){
  45. param.put(key, request.getParameter(key));
  46. }
  47. DataPage result = alarmService.alarmList(param);
  48. TagUtil.datagrid(response, dataGrid, result);
  49. }
  50. @RequestMapping(params = "exportXls")
  51. public String exportXlsByT(HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid, ModelMap modelMap) {
  52. modelMap.put(NormalExcelConstants.FILE_NAME, "作业报警");
  53. modelMap.put(NormalExcelConstants.CLASS, TBAlarm.class);
  54. modelMap.put(NormalExcelConstants.PARAMS, new ExportParams("作业报警", "导出人:"+ ResourceUtil.getSessionUser().getRealName(),
  55. "导出信息"));
  56. Map<String, String> param = new HashMap<String, String>();
  57. for(String key : request.getParameterMap().keySet()){
  58. param.put(key, request.getParameter(key));
  59. }
  60. List<Map<String, Object>> result = alarmService.alarmList(param).getList();
  61. List<TBAlarm> list = new ArrayList<>();
  62. // add-刘梦祥-2021年12月31日10:48:53-(查询所有的用户信息Map<id,realName>)
  63. String getAllUserInfo = "select id,realname realName from t_s_base_user;";
  64. List<Map<String,Object>> allUserInfo = systemService.findForJdbc(getAllUserInfo);
  65. Map<String,String> userInfoList = new HashMap<>();
  66. if(allUserInfo != null && allUserInfo.size() > 0){
  67. for (Map<String,Object> userInfoItem : allUserInfo){
  68. if(userInfoItem.containsKey("id") && userInfoItem.containsKey("realName")){
  69. if(!userInfoList.containsKey(userInfoItem.get("id").toString())){
  70. userInfoList.put(userInfoItem.get("id").toString(),userInfoItem.get("realName").toString());
  71. }
  72. }
  73. }
  74. }
  75. // add-刘梦祥-2022年10月20日11:39:04-(查询所有的报警来源Map<id,realName>)
  76. String getAllAlarmFrom = "select typecode,typename from t_s_type where typegroupid in (select id from t_s_typegroup where typegroupcode = 'alarmFrom') ORDER BY typecode;";
  77. List<Map<String,Object>> allAlarmFrom = systemService.findForJdbc(getAllAlarmFrom);
  78. Map<String,String> alarmFromList = new HashMap<>();
  79. if(allAlarmFrom != null && allAlarmFrom.size() > 0){
  80. for (Map<String,Object> alarmFromItem : allAlarmFrom){
  81. if(alarmFromItem.containsKey("typecode") && alarmFromItem.containsKey("typename")){
  82. if(!alarmFromList.containsKey(alarmFromItem.get("typecode").toString())){
  83. alarmFromList.put(alarmFromItem.get("typecode").toString(),alarmFromItem.get("typename").toString());
  84. }
  85. }
  86. }
  87. }
  88. // add-刘梦祥-2022年10月20日11:39:04-(查询所有的报警来源Map<id,realName>)
  89. String getAllAlarmType = "select typecode,typename from t_s_type where typegroupid in (select id from t_s_typegroup where typegroupcode = 'alarmType') ORDER BY typecode;";
  90. List<Map<String,Object>> allAlarmType = systemService.findForJdbc(getAllAlarmType);
  91. Map<String,String> alarmTypeList = new HashMap<>();
  92. if(allAlarmType != null && allAlarmType.size() > 0){
  93. for (Map<String,Object> alarmTypeItem : allAlarmType){
  94. if(alarmTypeItem.containsKey("typecode") && alarmTypeItem.containsKey("typename")){
  95. if(!alarmTypeList.containsKey(alarmTypeItem.get("typecode").toString())){
  96. alarmTypeList.put(alarmTypeItem.get("typecode").toString(),alarmTypeItem.get("typename").toString());
  97. }
  98. }
  99. }
  100. }
  101. for(Map<String, Object> item : result){
  102. TBAlarm alarm = JSONObject.parseObject(JSONObject.toJSONString(item), TBAlarm.class);
  103. alarm.setAlarmUser(userInfoList.get(alarm.getAlarmUser()));
  104. alarm.setAlarmRecevier(userInfoList.get(alarm.getAlarmRecevier()));
  105. alarm.setAlarmFrom(alarmFromList.get(alarm.getAlarmFrom()));
  106. alarm.setAlarmType(alarmTypeList.get(alarm.getAlarmType()));
  107. list.add(alarm);
  108. }
  109. modelMap.put(NormalExcelConstants.DATA_LIST, list);
  110. return NormalExcelConstants.EASYPOI_EXCEL_VIEW;
  111. }
  112. }