// // Source code recreated from a .class file by IntelliJ IDEA // (powered by FernFlower decompiler) // package com.hxzkoa.controller; import com.hxzkoa.json.tb_collector; import com.hxzkoa.json.tb_gas; import com.hxzkoa.json.tb_gas_history; import com.hxzkoa.services.GasService; import com.hxzkoa.udp.GetNowTime; import com.hxzkoa.util.Config; import com.hxzkoa.util.ExcelUtils; import com.hxzkoa.util.ModifyConfig; import com.hxzkoa.util.PageUtil; import com.hxzkoa.util.RequestUtils; import java.io.IOException; import java.io.OutputStream; import java.util.ArrayList; import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import net.sf.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; @Controller public class GasController { @Autowired private GasService gasService; final Logger logger = LoggerFactory.getLogger(this.getClass()); public GasController() { } @RequestMapping( value = {"/sensorManagement.do"}, method = {RequestMethod.POST, RequestMethod.GET} ) public String sensorManagement(HttpServletRequest request) { String toPage = "forward:/hxzk/gas/sensorManagement.jsp"; List sensorManagementList = this.gasService.getSensorManagement(1); request.setAttribute("sensorManagementList", sensorManagementList); List collectorList = this.gasService.getcollectorList(); request.setAttribute("collectorList", collectorList); int curPage = 1; int count = this.gasService.getSensorManagementCount(); int minPage = PageUtil.getMinPage(count); request.setAttribute("pageList", PageUtil.getPage(minPage)); request.setAttribute("curPage", Integer.valueOf(curPage)); return toPage; } @ResponseBody @RequestMapping( value = {"/sensorManagementsan.do"}, method = {RequestMethod.POST, RequestMethod.GET} ) public List sensorManagementsan(HttpServletRequest request) { List sensorManagementList = this.gasService.getSensorManagement(); for(int i = 0; i < sensorManagementList.size(); ++i) { ((tb_gas)sensorManagementList.get(i)).setGas_type(((tb_gas)sensorManagementList.get(i)).getGas_type().replace(" ", "")); } return sensorManagementList; } @ResponseBody @RequestMapping( value = {"/sensorManagement_page.do"}, method = {RequestMethod.POST, RequestMethod.GET} ) public String sensorManagement_page(HttpServletRequest request) { String pageStr = request.getParameter("page"); String curPageStr = request.getParameter("curPage"); int count = this.gasService.getSensorManagementCount(); int minPage = PageUtil.getMinPage(count); int curPage = Integer.parseInt(curPageStr); int page = 1; if ("pre".equals(pageStr)) { if (curPage > 1) { page = curPage - 1; } } else if ("next".equals(pageStr)) { if (curPage < minPage) { page = curPage + 1; } } else { page = Integer.parseInt(pageStr); } List sensorManagementList = this.gasService.getSensorManagement(page); List pageList = PageUtil.getPage(PageUtil.getLocPage(page, curPage), page, minPage); JSONObject json = new JSONObject(); json.put("dataList", sensorManagementList); json.put("pageList", pageList); json.put("curPage", page); return json.toString(); } @ResponseBody @RequestMapping( value = {"/sensorManagement_search.do"}, method = {RequestMethod.POST, RequestMethod.GET} ) public String sensorManagement_search(HttpServletRequest request) { String input = request.getParameter("input"); int curPage = 1; List pageList = new ArrayList(); List sensorManagementList = this.gasService.searchSensorManagement(input); pageList.add(1); JSONObject json = new JSONObject(); json.put("dataList", sensorManagementList); json.put("pageList", pageList); json.put("curPage", Integer.valueOf(curPage)); return json.toString(); } @ResponseBody @RequestMapping( value = {"/sensorManagement_delete.do"}, method = {RequestMethod.POST, RequestMethod.GET} ) public void labelManagement_delete(HttpServletRequest request) { String checkValStr = request.getParameter("checkVal"); checkValStr = checkValStr.replaceAll("\"", ""); String[] checkVal = checkValStr.split(","); this.gasService.sensorManagement_delete(checkVal); } @ResponseBody @RequestMapping( value = {"/sensorManagement_deleteAll.do"}, method = {RequestMethod.POST, RequestMethod.GET} ) public void labelManagement_deleteAll(HttpServletRequest request) { this.gasService.sensorManagement_deleteAll(); } @RequestMapping( value = {"/sensorManagement_add.do"}, method = {RequestMethod.POST, RequestMethod.GET} ) public void sensorManagement_add(HttpServletRequest request) { List macNameList = this.gasService.getmacName(request.getParameter("gasMacid")); String macName = ((tb_collector)macNameList.get(0)).getMacname(); String id = request.getParameter("gasId"); tb_gas gas = new tb_gas(); gas.setTong_dao(request.getParameter("gasTd")); gas.setGas_type(request.getParameter("gasType")); gas.setWaring_zhi(request.getParameter("gasThres")); gas.setCollect_ip(request.getParameter("gasMacid")); gas.setIp(request.getParameter("gasIp")); gas.setX(request.getParameter("gasX")); gas.setY(request.getParameter("gasY")); gas.setWei_zhi(macName); gas.setId(Integer.parseInt(request.getParameter("gasId"))); int exist = this.gasService.sensor_exist(id); if (exist > 0) { this.gasService.sensorManagement_modify(gas); } else { this.gasService.sensorManagement_add(gas); } } @RequestMapping( value = {"/sensorManagement_modify.do"}, method = {RequestMethod.POST, RequestMethod.GET} ) public void sensorManagement_modify(HttpServletRequest request) { List macNameList = this.gasService.getmacName(request.getParameter("gasMacid")); String macName = ((tb_collector)macNameList.get(0)).getMacname(); String id = request.getParameter("gasId"); tb_gas gas = new tb_gas(); gas.setTong_dao(request.getParameter("gasTd")); gas.setGas_type(request.getParameter("gasType")); gas.setWaring_zhi(request.getParameter("gasThres")); gas.setCollect_ip(request.getParameter("gasMacid")); gas.setIp(request.getParameter("gasIp")); gas.setX(request.getParameter("gasX")); gas.setY(request.getParameter("gasY")); gas.setWei_zhi(macName); gas.setId(Integer.parseInt(request.getParameter("gasId"))); this.gasService.sensorManagement_modify(gas); } public static List objectToArray(List sensorManagementList) { List reList = new ArrayList(); for(int i = 0; i < sensorManagementList.size(); ++i) { List words = new ArrayList(); tb_gas gas = (tb_gas)sensorManagementList.get(i); words.add(String.valueOf(gas.getId())); words.add(gas.getWei_zhi()); words.add(gas.getGas_type()); words.add(gas.getNong_du()); words.add(gas.getStatus()); words.add(gas.getCollect_ip()); words.add(gas.getTong_dao()); words.add(gas.getWaring_zhi()); words.add(gas.getIp()); words.add(gas.getX()); words.add(gas.getY()); words.add(gas.getAddtime()); String[] array = (String[])words.toArray(new String[0]); reList.add(array); } return reList; } @ResponseBody @RequestMapping( value = {"/sensorManagement_export.do"}, method = {RequestMethod.POST, RequestMethod.GET} ) public String sensorManagement_export(HttpServletRequest request, HttpServletResponse response) { String toPage = "forward:/hxzk/gas/sensorManagement.jsp"; List sensorManagementList = this.gasService.getSensorManagement(); String[] rowName = new String[]{"设备编号", "安装位置", "气体类型", "浓度值", "告警情况", "采集仪地址", "所在通道", "告警阈值", "IP地址", "\tX坐标\t", "Y坐标", "更新时间"}; List dataList = objectToArray(sensorManagementList); ExcelUtils excel = new ExcelUtils("传感器管理", rowName, dataList); try { String fileName = "Excel-" + String.valueOf(System.currentTimeMillis()).substring(4, 13) + ".xls"; String headStr = "attachment; filename=\"" + fileName + "\""; response.setContentType("APPLICATION/OCTET-STREAM"); response.setHeader("Content-Disposition", headStr); OutputStream out = response.getOutputStream(); excel.export(out); out.flush(); out.close(); } catch (Exception var11) { var11.printStackTrace(); } return toPage; } @RequestMapping( value = {"/historicalDetection.do"}, method = {RequestMethod.POST, RequestMethod.GET} ) public String historicalDetection(HttpServletRequest request) { String toPage = "forward:/hxzk/gas/historicalDetection.jsp"; List historicalDetectionList = this.gasService.getHistoricalDetection(1); request.setAttribute("historicalDetectionList", historicalDetectionList); int curPage = 1; int count = this.gasService.getHistoricalDetectionCount(); int minPage = PageUtil.getMinPage(count); request.setAttribute("pageList", PageUtil.getPage(minPage)); request.setAttribute("curPage", Integer.valueOf(curPage)); return toPage; } @ResponseBody @RequestMapping( value = {"/historicalDetection_search.do"}, method = {RequestMethod.POST, RequestMethod.GET} ) public String historicalDetection_search(HttpServletRequest request) { String input = request.getParameter("input"); int curPage = 1; List pageList = new ArrayList(); List historicalDetectionList = this.gasService.searchHistoricalDetection(input); pageList.add(1); JSONObject json = new JSONObject(); json.put("dataList", historicalDetectionList); json.put("pageList", pageList); json.put("curPage", Integer.valueOf(curPage)); return json.toString(); } @ResponseBody @RequestMapping( value = {"/historicalDetection_page.do"}, method = {RequestMethod.POST, RequestMethod.GET} ) public String historicalDetection_page(HttpServletRequest request) { String pageStr = request.getParameter("page"); String curPageStr = request.getParameter("curPage"); int count = this.gasService.getHistoricalDetectionCount(); int minPage = PageUtil.getMinPage(count); int curPage = Integer.parseInt(curPageStr); int page = 1; if ("pre".equals(pageStr)) { if (curPage > 1) { page = curPage - 1; } } else if ("next".equals(pageStr)) { if (curPage < minPage) { page = curPage + 1; } } else { page = Integer.parseInt(pageStr); } List historicalDetectionList = this.gasService.getHistoricalDetection(page); List pageList = PageUtil.getPage(PageUtil.getLocPage(page, curPage), page, minPage); JSONObject json = new JSONObject(); json.put("dataList", historicalDetectionList); json.put("pageList", pageList); json.put("curPage", page); return json.toString(); } @ResponseBody @RequestMapping( value = {"/historicalDetection_delete.do"}, method = {RequestMethod.POST, RequestMethod.GET} ) public void historicalDetection_delete(HttpServletRequest request) { String checkValStr = request.getParameter("checkVal"); checkValStr = checkValStr.replaceAll("\"", ""); String[] checkVal = checkValStr.split(","); this.gasService.historicalDetection_delete(checkVal); } @ResponseBody @RequestMapping( value = {"/historicalDetection_deleteAll.do"}, method = {RequestMethod.POST, RequestMethod.GET} ) public void historicalDetection_deleteAll(HttpServletRequest request) { this.gasService.historicalDetection_deleteAll(); } public static List hisobjectToArray(List historicalDetectionList) { List reList = new ArrayList(); for(int i = 0; i < historicalDetectionList.size(); ++i) { List words = new ArrayList(); tb_gas_history gas_history = (tb_gas_history)historicalDetectionList.get(i); words.add(String.valueOf(gas_history.getId())); words.add(gas_history.getMacid()); words.add(gas_history.getName()); words.add(gas_history.getType()); words.add(gas_history.getWaring()); words.add(String.valueOf(gas_history.getX())); words.add(String.valueOf(gas_history.getY())); words.add(gas_history.getDeep()); words.add(gas_history.getAddtime()); String[] array = (String[])words.toArray(new String[0]); reList.add(array); } return reList; } @ResponseBody @RequestMapping( value = {"/historicalDetection_export.do"}, method = {RequestMethod.POST, RequestMethod.GET} ) public String historicalDetection_export(HttpServletRequest request, HttpServletResponse response) { String toPage = "forward:/hxzk/gas/historicalDetection.jsp"; List historicalDetectionList = this.gasService.getHistoricalDetection(); String[] rowName = new String[]{"序号", "设备通道\t", "安装位置", "气体类型", "告警状态", "X坐标", "Y坐标", "浓度值", "添加时间"}; List dataList = hisobjectToArray(historicalDetectionList); ExcelUtils excel = new ExcelUtils("传感器管理", rowName, dataList); try { String fileName = "Excel-" + String.valueOf(System.currentTimeMillis()).substring(4, 13) + ".xls"; String headStr = "attachment; filename=\"" + fileName + "\""; response.setContentType("APPLICATION/OCTET-STREAM"); response.setHeader("Content-Disposition", headStr); OutputStream out = response.getOutputStream(); excel.export(out); out.flush(); out.close(); } catch (Exception var11) { var11.printStackTrace(); } return toPage; } @RequestMapping( value = {"/collectorManagement.do"}, method = {RequestMethod.POST, RequestMethod.GET} ) public String collectorManagement(HttpServletRequest request) { String toPage = "forward:/hxzk/gas/collectorManagement.jsp"; List collectorManagementList = this.gasService.getCollectorManagement(1); request.setAttribute("collectorManagementList", collectorManagementList); int curPage = 1; int count = this.gasService.getCollectorManagementCount(); int minPage = PageUtil.getMinPage(count); request.setAttribute("pageList", PageUtil.getPage(minPage)); request.setAttribute("curPage", Integer.valueOf(curPage)); return toPage; } @ResponseBody @RequestMapping( value = {"/collectorManagement_search.do"}, method = {RequestMethod.POST, RequestMethod.GET} ) public String collectorManagement_search(HttpServletRequest request) { String input = request.getParameter("input"); int curPage = 1; List pageList = new ArrayList(); List collectorManagementList = this.gasService.searchCollectorManagement(input); pageList.add(1); JSONObject json = new JSONObject(); json.put("dataList", collectorManagementList); json.put("pageList", pageList); json.put("curPage", Integer.valueOf(curPage)); return json.toString(); } @ResponseBody @RequestMapping( value = {"/collectorManagement_page.do"}, method = {RequestMethod.POST, RequestMethod.GET} ) public String collectorManagement_page(HttpServletRequest request) { String pageStr = request.getParameter("page"); String curPageStr = request.getParameter("curPage"); int count = this.gasService.getCollectorManagementCount(); int minPage = PageUtil.getMinPage(count); int curPage = Integer.parseInt(curPageStr); int page = 1; if ("pre".equals(pageStr)) { if (curPage > 1) { page = curPage - 1; } } else if ("next".equals(pageStr)) { if (curPage < minPage) { page = curPage + 1; } } else { page = Integer.parseInt(pageStr); } List labelManagementList = this.gasService.getCollectorManagement(page); List pageList = PageUtil.getPage(PageUtil.getLocPage(page, curPage), page, minPage); JSONObject json = new JSONObject(); json.put("dataList", labelManagementList); json.put("pageList", pageList); json.put("curPage", page); return json.toString(); } @ResponseBody @RequestMapping( value = {"/collectorManagement_delete.do"}, method = {RequestMethod.POST, RequestMethod.GET} ) public void collectorManagement_delete(HttpServletRequest request) { String checkValStr = request.getParameter("checkVal"); checkValStr = checkValStr.replaceAll("\"", ""); String[] checkVal = checkValStr.split(","); this.gasService.collectorManagement_delete(checkVal); } @ResponseBody @RequestMapping( value = {"/collectorManagement_deleteAll.do"}, method = {RequestMethod.POST, RequestMethod.GET} ) public void collectorManagement_deleteAll(HttpServletRequest request) { this.gasService.collectorManagement_deleteAll(); } @RequestMapping( value = {"/collectorManagement_add.do"}, method = {RequestMethod.POST, RequestMethod.GET} ) public void collectorManagement_add(HttpServletRequest request) { tb_collector collector = new tb_collector(); collector.setMacid(Integer.parseInt(request.getParameter("hostId"))); collector.setStartip(Integer.parseInt(request.getParameter("startId"))); collector.setDatlenth(Integer.parseInt(request.getParameter("dataLength"))); collector.setIp(request.getParameter("intId")); collector.setMacname(request.getParameter("insLoc")); collector.setPosx(Integer.parseInt(request.getParameter("coordX"))); collector.setPosy(Integer.parseInt(request.getParameter("coordY"))); this.gasService.collectorManagement_add(collector); } @RequestMapping( value = {"/collectorManagement_modify.do"}, method = {RequestMethod.POST, RequestMethod.GET} ) public void collectorManagement_modify(HttpServletRequest request) { tb_collector collector = new tb_collector(); collector.setId(Integer.parseInt(request.getParameter("id"))); collector.setMacid(Integer.parseInt(request.getParameter("hostId"))); collector.setStartip(Integer.parseInt(request.getParameter("startId"))); collector.setDatlenth(Integer.parseInt(request.getParameter("dataLength"))); collector.setIp(request.getParameter("intId")); collector.setMacname(request.getParameter("insLoc")); collector.setPosx(Integer.parseInt(request.getParameter("coordX"))); collector.setPosy(Integer.parseInt(request.getParameter("coordY"))); this.gasService.collectorManagement_modify(collector); } public static List collectorobjectToArray(List collectorManagementList) { List reList = new ArrayList(); for(int i = 0; i < collectorManagementList.size(); ++i) { List words = new ArrayList(); tb_collector collector = (tb_collector)collectorManagementList.get(i); words.add(String.valueOf(collector.getId())); words.add(String.valueOf(collector.getMacid())); words.add(String.valueOf(collector.getStartip())); words.add(String.valueOf(collector.getDatlenth())); words.add(collector.getIp()); words.add(collector.getMacname()); words.add(String.valueOf(collector.getPosx())); words.add(String.valueOf(collector.getPosy())); words.add(String.valueOf(collector.getAddtime())); String[] array = (String[])words.toArray(new String[0]); reList.add(array); } return reList; } @ResponseBody @RequestMapping( value = {"/collectorManagement_export.do"}, method = {RequestMethod.POST, RequestMethod.GET} ) public String collectorManagement_export(HttpServletRequest request, HttpServletResponse response) { String toPage = "forward:/hxzk/gas/collectorManagement.jsp"; List collectorManagementList = this.gasService.getCollectorManagement(); String[] rowName = new String[]{"序号", "主机地址", "起始地址", "数据长度", "IP地址", "安装位置", "X坐标", "Y坐标", "添加时间"}; List dataList = collectorobjectToArray(collectorManagementList); ExcelUtils excel = new ExcelUtils("采集仪管理", rowName, dataList); try { String fileName = "Excel-" + String.valueOf(System.currentTimeMillis()).substring(4, 13) + ".xls"; String headStr = "attachment; filename=\"" + fileName + "\""; response.setContentType("APPLICATION/OCTET-STREAM"); response.setHeader("Content-Disposition", headStr); OutputStream out = response.getOutputStream(); excel.export(out); out.flush(); out.close(); } catch (Exception var11) { var11.printStackTrace(); } return toPage; } @RequestMapping( value = {"/collectorManagement_bw.do"}, method = {RequestMethod.POST, RequestMethod.GET} ) public void collectorManagement_bw(HttpServletRequest request) throws IOException { String jsonString = RequestUtils.getRequestJsonString(request, Config.getCharset()); this.logger.info("传入数据IData:" + jsonString); tb_collector collector = (tb_collector)JSONObject.toBean(JSONObject.fromObject(jsonString), tb_collector.class); this.gasService.collectorManagement_add(collector); } @RequestMapping( value = {"/sensorManagement_bw.do"}, method = {RequestMethod.POST, RequestMethod.GET} ) public void sensorManagement_bw(HttpServletRequest request) throws IOException { String jsonString = RequestUtils.getRequestJsonString(request, Config.getCharset()); tb_gas gas = (tb_gas)JSONObject.toBean(JSONObject.fromObject(jsonString), tb_gas.class); int exist = this.gasService.sensor_exist(String.valueOf(gas.getId())); if (exist == 0) { this.gasService.sensorManagement_add(gas); } } @RequestMapping( value = {"/modifyWarning.do"}, method = {RequestMethod.POST, RequestMethod.GET} ) public void modifyWarning(HttpServletRequest request) throws IOException { String jsonString = RequestUtils.getRequestJsonString(request, Config.getCharset()); tb_gas gas = (tb_gas)JSONObject.toBean(JSONObject.fromObject(jsonString), tb_gas.class); String sqlString = "UPDATE tb_gas SET status = " + gas.getStatus() + ",nong_du=" + gas.getNong_du() + ",addtime=" + GetNowTime.timestamp2() + " WHERE id=" + gas.getId(); (new StringBuilder()).append(GetNowTime.timestamp2()).append(" 收:").append(sqlString).toString(); String BaowenPath = Config.getBaowenConfig(); String baowenStatus = ModifyConfig.readData(BaowenPath, "baowenSwitch"); if (baowenStatus.equals("1")) { } this.gasService.modifyWarning(gas); } @ResponseBody @RequestMapping( value = {"/getGasLength.do"}, method = {RequestMethod.POST, RequestMethod.GET} ) public String getGasLength(HttpServletRequest request) throws IOException { JSONObject json = new JSONObject(); String jsonString = RequestUtils.getRequestJsonString(request, Config.getCharset()); tb_gas gas = (tb_gas)JSONObject.toBean(JSONObject.fromObject(jsonString), tb_gas.class); String ip = gas.getCollect_ip(); Integer length = this.gasService.getGasNumber(ip); json.put("length", length); return json.toString(); } @ResponseBody @RequestMapping( value = {"/getGas.do"}, method = {RequestMethod.POST, RequestMethod.GET} ) public String getGas(HttpServletRequest request) throws IOException { JSONObject json = new JSONObject(); String jsonString = RequestUtils.getRequestJsonString(request, Config.getCharset()); tb_gas gas = (tb_gas)JSONObject.toBean(JSONObject.fromObject(jsonString), tb_gas.class); String tongdao = gas.getTong_dao(); String ip = gas.getCollect_ip(); List gasList = this.gasService.getGas(tongdao, ip); if (gasList.size() > 0) { json.put("result", gasList.get(0)); } else { json.put("result", "null"); } return json.toString(); } }