| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- package cn.com.lzt.alarm.controller;
- import cn.afterturn.easypoi.entity.vo.NormalExcelConstants;
- import cn.afterturn.easypoi.excel.entity.ExportParams;
- import cn.com.lzt.alarm.service.impl.AlarmServiceImpl;
- import com.alibaba.fastjson.JSONObject;
- import com.daju.common.util.DataPage;
- import com.daju.mix.dao.entity.PDeviceDetailRecord;
- import com.daju.mix.dao.entity.TBAlarm;
- import com.xcgl.device.entity.DeviceEntity;
- import org.jeecgframework.core.common.model.json.DataGrid;
- import org.jeecgframework.core.util.ResourceUtil;
- import org.jeecgframework.tag.core.easyui.TagUtil;
- import org.jeecgframework.web.system.service.SystemService;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Controller;
- import org.springframework.ui.ModelMap;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.servlet.ModelAndView;
- import javax.annotation.Resource;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- /**
- * @author :sahib.kio.m
- * @date :Created in 2021/8/3 上午10:37
- */
- @Controller
- @RequestMapping("/alarmController")
- public class AlarmController {
- @Resource
- private AlarmServiceImpl alarmService;
- @Autowired
- private SystemService systemService;
- @RequestMapping(params = "list")
- public ModelAndView list(HttpServletRequest request) {
- return new ModelAndView("cn/com/lzt/alarm/alarmList");
- }
- @RequestMapping(params = "datagrid")
- public void datagrid(HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
- Map<String, String> param = new HashMap<>();
- for (String key : request.getParameterMap().keySet()){
- param.put(key, request.getParameter(key));
- }
- DataPage result = alarmService.alarmList(param);
- TagUtil.datagrid(response, dataGrid, result);
- }
- @RequestMapping(params = "exportXls")
- public String exportXlsByT(HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid, ModelMap modelMap) {
- modelMap.put(NormalExcelConstants.FILE_NAME, "作业报警");
- modelMap.put(NormalExcelConstants.CLASS, TBAlarm.class);
- modelMap.put(NormalExcelConstants.PARAMS, new ExportParams("作业报警", "导出人:"+ ResourceUtil.getSessionUser().getRealName(),
- "导出信息"));
- Map<String, String> param = new HashMap<String, String>();
- for(String key : request.getParameterMap().keySet()){
- param.put(key, request.getParameter(key));
- }
- List<Map<String, Object>> result = alarmService.alarmList(param).getList();
- List<TBAlarm> list = new ArrayList<>();
- // add-刘梦祥-2021年12月31日10:48:53-(查询所有的用户信息Map<id,realName>)
- String getAllUserInfo = "select id,realname realName from t_s_base_user;";
- List<Map<String,Object>> allUserInfo = systemService.findForJdbc(getAllUserInfo);
- Map<String,String> userInfoList = new HashMap<>();
- if(allUserInfo != null && allUserInfo.size() > 0){
- for (Map<String,Object> userInfoItem : allUserInfo){
- if(userInfoItem.containsKey("id") && userInfoItem.containsKey("realName")){
- if(!userInfoList.containsKey(userInfoItem.get("id").toString())){
- userInfoList.put(userInfoItem.get("id").toString(),userInfoItem.get("realName").toString());
- }
- }
- }
- }
- // add-刘梦祥-2022年10月20日11:39:04-(查询所有的报警来源Map<id,realName>)
- String getAllAlarmFrom = "select typecode,typename from t_s_type where typegroupid in (select id from t_s_typegroup where typegroupcode = 'alarmFrom') ORDER BY typecode;";
- List<Map<String,Object>> allAlarmFrom = systemService.findForJdbc(getAllAlarmFrom);
- Map<String,String> alarmFromList = new HashMap<>();
- if(allAlarmFrom != null && allAlarmFrom.size() > 0){
- for (Map<String,Object> alarmFromItem : allAlarmFrom){
- if(alarmFromItem.containsKey("typecode") && alarmFromItem.containsKey("typename")){
- if(!alarmFromList.containsKey(alarmFromItem.get("typecode").toString())){
- alarmFromList.put(alarmFromItem.get("typecode").toString(),alarmFromItem.get("typename").toString());
- }
- }
- }
- }
- // add-刘梦祥-2022年10月20日11:39:04-(查询所有的报警来源Map<id,realName>)
- String getAllAlarmType = "select typecode,typename from t_s_type where typegroupid in (select id from t_s_typegroup where typegroupcode = 'alarmType') ORDER BY typecode;";
- List<Map<String,Object>> allAlarmType = systemService.findForJdbc(getAllAlarmType);
- Map<String,String> alarmTypeList = new HashMap<>();
- if(allAlarmType != null && allAlarmType.size() > 0){
- for (Map<String,Object> alarmTypeItem : allAlarmType){
- if(alarmTypeItem.containsKey("typecode") && alarmTypeItem.containsKey("typename")){
- if(!alarmTypeList.containsKey(alarmTypeItem.get("typecode").toString())){
- alarmTypeList.put(alarmTypeItem.get("typecode").toString(),alarmTypeItem.get("typename").toString());
- }
- }
- }
- }
- for(Map<String, Object> item : result){
- TBAlarm alarm = JSONObject.parseObject(JSONObject.toJSONString(item), TBAlarm.class);
- alarm.setAlarmUser(userInfoList.get(alarm.getAlarmUser()));
- alarm.setAlarmRecevier(userInfoList.get(alarm.getAlarmRecevier()));
- alarm.setAlarmFrom(alarmFromList.get(alarm.getAlarmFrom()));
- alarm.setAlarmType(alarmTypeList.get(alarm.getAlarmType()));
- list.add(alarm);
- }
- modelMap.put(NormalExcelConstants.DATA_LIST, list);
- return NormalExcelConstants.EASYPOI_EXCEL_VIEW;
- }
- }
|