fxl
2023-05-04 e150655a785de36a65a26a0dc4d3d6d65fe7e9d0
src/main/java/com/hxzkoa/controller/GasController.java
@@ -1,13 +1,27 @@
//
// 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;
@@ -16,49 +30,57 @@
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hxzkoa.json.tb_collector;
import com.hxzkoa.json.tb_gas;
import com.hxzkoa.json.tb_gas_history;
import com.hxzkoa.json.tb_person;
import com.hxzkoa.json.tb_tag;
import com.hxzkoa.services.GasService;
import com.hxzkoa.udp.GetNowTime;
/*import com.hxzkoa.udp.Udp_Receive;*/
import com.hxzkoa.util.Config;
import com.hxzkoa.util.ExcelUtils;
import com.hxzkoa.util.HttpUtil;
import com.hxzkoa.util.ModifyConfig;
import com.hxzkoa.util.PageUtil;
import com.hxzkoa.util.RequestUtils;
import net.sf.json.JSONObject;
@Controller
public class GasController {
   @Autowired
   private GasService gasService;
   @RequestMapping(value = "/sensorManagement.do", method = { RequestMethod.POST, RequestMethod.GET })
   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<tb_gas> sensorManagementList = gasService.getSensorManagement(1);
      List<tb_gas> sensorManagementList = this.gasService.getSensorManagement(1);
      request.setAttribute("sensorManagementList", sensorManagementList);
      List<tb_collector> collectorList = gasService.getcollectorList();
      List<tb_collector> collectorList = this.gasService.getcollectorList();
      request.setAttribute("collectorList", collectorList);
      int curPage = 1;
      int count = gasService.getSensorManagementCount();
      int count = this.gasService.getSensorManagementCount();
      int minPage = PageUtil.getMinPage(count);
      request.setAttribute("pageList", PageUtil.getPage(minPage));
      request.setAttribute("curPage", curPage);
      request.setAttribute("curPage", Integer.valueOf(curPage));
      return toPage;
   }
   @ResponseBody
   @RequestMapping(value = "/sensorManagement_page.do", method = { RequestMethod.POST, RequestMethod.GET })
   @RequestMapping(
         value = {"/sensorManagementsan.do"},
         method = {RequestMethod.POST, RequestMethod.GET}
   )
   public List<tb_gas> sensorManagementsan(HttpServletRequest request) {
      List<tb_gas> 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 = gasService.getSensorManagementCount();
      int count = this.gasService.getSensorManagementCount();
      int minPage = PageUtil.getMinPage(count);
      int curPage = Integer.parseInt(curPageStr);
      int page = 1;
@@ -73,7 +95,8 @@
      } else {
         page = Integer.parseInt(pageStr);
      }
      List<tb_gas> sensorManagementList = gasService.getSensorManagement(page);
      List<tb_gas> sensorManagementList = this.gasService.getSensorManagement(page);
      List<Integer> pageList = PageUtil.getPage(PageUtil.getLocPage(page, curPage), page, minPage);
      JSONObject json = new JSONObject();
      json.put("dataList", sensorManagementList);
@@ -81,41 +104,53 @@
      json.put("curPage", page);
      return json.toString();
   }
   @ResponseBody
   @RequestMapping(value = "/sensorManagement_search.do", method = { RequestMethod.POST, RequestMethod.GET })
   @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<Integer> pageList = new ArrayList<Integer>();
      List<tb_gas> sensorManagementList = gasService.searchSensorManagement(input);
      List<Integer> pageList = new ArrayList();
      List<tb_gas> sensorManagementList = this.gasService.searchSensorManagement(input);
      pageList.add(1);
      JSONObject json = new JSONObject();
      json.put("dataList", sensorManagementList);
      json.put("pageList", pageList);
      json.put("curPage", curPage);
      json.put("curPage", Integer.valueOf(curPage));
      return json.toString();
   }
   @ResponseBody
   @RequestMapping(value = "/sensorManagement_delete.do", method = { RequestMethod.POST, RequestMethod.GET })
   @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(",");
      gasService.sensorManagement_delete(checkVal);
      this.gasService.sensorManagement_delete(checkVal);
   }
   @ResponseBody
   @RequestMapping(value = "/sensorManagement_deleteAll.do", method = { RequestMethod.POST, RequestMethod.GET })
   @RequestMapping(
         value = {"/sensorManagement_deleteAll.do"},
         method = {RequestMethod.POST, RequestMethod.GET}
   )
   public void labelManagement_deleteAll(HttpServletRequest request) {
      gasService.sensorManagement_deleteAll();
      this.gasService.sensorManagement_deleteAll();
   }
   @RequestMapping(value = "/sensorManagement_add.do", method = { RequestMethod.POST, RequestMethod.GET })
   @RequestMapping(
         value = {"/sensorManagement_add.do"},
         method = {RequestMethod.POST, RequestMethod.GET}
   )
   public void sensorManagement_add(HttpServletRequest request) {
      List<tb_collector> macNameList = gasService.getmacName(request.getParameter("gasMacid"));
      String macName = macNameList.get(0).getMacname();
      List<tb_collector> 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"));
@@ -127,18 +162,22 @@
      gas.setY(request.getParameter("gasY"));
      gas.setWei_zhi(macName);
      gas.setId(Integer.parseInt(request.getParameter("gasId")));
      int exist = gasService.sensor_exist(id);
      int exist = this.gasService.sensor_exist(id);
      if (exist > 0) {
         gasService.sensorManagement_modify(gas);
         this.gasService.sensorManagement_modify(gas);
      } else {
         gasService.sensorManagement_add(gas);
      }
         this.gasService.sensorManagement_add(gas);
      }
   }
   @RequestMapping(value = "/sensorManagement_modify.do", method = { RequestMethod.POST, RequestMethod.GET })
   @RequestMapping(
         value = {"/sensorManagement_modify.do"},
         method = {RequestMethod.POST, RequestMethod.GET}
   )
   public void sensorManagement_modify(HttpServletRequest request) {
      List<tb_collector> macNameList = gasService.getmacName(request.getParameter("gasMacid"));
      String macName = macNameList.get(0).getMacname();
      List<tb_collector> 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"));
@@ -149,16 +188,16 @@
      gas.setX(request.getParameter("gasX"));
      gas.setY(request.getParameter("gasY"));
      gas.setWei_zhi(macName);
      gas.setId(Integer.parseInt(request.getParameter("gasId")));
      gasService.sensorManagement_modify(gas);
      gas.setId(Integer.parseInt(request.getParameter("gasId")));
      this.gasService.sensorManagement_modify(gas);
   }
   // 对象转数组
   public static List<Object[]> objectToArray(List<tb_gas> sensorManagementList) {
      List<Object[]> reList = new ArrayList<>();
      for (int i = 0; i < sensorManagementList.size(); i++) {
         List<String> words = new ArrayList<String>();
         tb_gas gas = (tb_gas) sensorManagementList.get(i);
      List<Object[]> reList = new ArrayList();
      for(int i = 0; i < sensorManagementList.size(); ++i) {
         List<String> 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());
@@ -171,70 +210,84 @@
         words.add(gas.getX());
         words.add(gas.getY());
         words.add(gas.getAddtime());
         String[] array = words.toArray(new String[0]);
         String[] array = (String[])words.toArray(new String[0]);
         reList.add(array);
      }
      return reList;
   }
   @ResponseBody
   @RequestMapping(value = "/sensorManagement_export.do", method = { RequestMethod.POST, RequestMethod.GET })
   @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<tb_gas> sensorManagementList = gasService.getSensorManagement();
      String[] rowName = { "设备编号","安装位置","气体类型","浓度值","告警情况","采集仪地址","所在通道","告警阈值","IP地址","  X坐标   ","Y坐标","更新时间"};
      List<tb_gas> sensorManagementList = this.gasService.getSensorManagement();
      String[] rowName = new String[]{"设备编号", "安装位置", "气体类型", "浓度值", "告警情况", "采集仪地址", "所在通道", "告警阈值", "IP地址", "\tX坐标\t", "Y坐标", "更新时间"};
      List<Object[]> dataList = objectToArray(sensorManagementList);
      ExcelUtils excel = new ExcelUtils("传感器管理", rowName, dataList);
      OutputStream out;
      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);
         out = response.getOutputStream();
         OutputStream out = response.getOutputStream();
         excel.export(out);
         out.flush();
         out.close();
      } catch (Exception e) {
         e.printStackTrace();
      } catch (Exception var11) {
         var11.printStackTrace();
      }
      return toPage;
   }
   @RequestMapping(value = "/historicalDetection.do", method = { RequestMethod.POST, RequestMethod.GET })
   @RequestMapping(
         value = {"/historicalDetection.do"},
         method = {RequestMethod.POST, RequestMethod.GET}
   )
   public String historicalDetection(HttpServletRequest request) {
      String toPage = "forward:/hxzk/gas/historicalDetection.jsp";
      List<tb_gas_history> historicalDetectionList = gasService.getHistoricalDetection(1);
      List<tb_gas_history> historicalDetectionList = this.gasService.getHistoricalDetection(1);
      request.setAttribute("historicalDetectionList", historicalDetectionList);
      int curPage = 1;
      int count = gasService.getHistoricalDetectionCount();
      int count = this.gasService.getHistoricalDetectionCount();
      int minPage = PageUtil.getMinPage(count);
      request.setAttribute("pageList", PageUtil.getPage(minPage));
      request.setAttribute("curPage", curPage);
      request.setAttribute("curPage", Integer.valueOf(curPage));
      return toPage;
   }
   @ResponseBody
   @RequestMapping(value = "/historicalDetection_search.do", method = { RequestMethod.POST, RequestMethod.GET })
   @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<Integer> pageList = new ArrayList<Integer>();
      List<tb_gas_history> historicalDetectionList = gasService.searchHistoricalDetection(input);
      List<Integer> pageList = new ArrayList();
      List<tb_gas_history> historicalDetectionList = this.gasService.searchHistoricalDetection(input);
      pageList.add(1);
      JSONObject json = new JSONObject();
      json.put("dataList", historicalDetectionList);
      json.put("pageList", pageList);
      json.put("curPage", curPage);
      json.put("curPage", Integer.valueOf(curPage));
      return json.toString();
   }
   @ResponseBody
   @RequestMapping(value = "/historicalDetection_page.do", method = { RequestMethod.POST, RequestMethod.GET })
   @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 = gasService.getHistoricalDetectionCount();
      int count = this.gasService.getHistoricalDetectionCount();
      int minPage = PageUtil.getMinPage(count);
      int curPage = Integer.parseInt(curPageStr);
      int page = 1;
@@ -249,7 +302,8 @@
      } else {
         page = Integer.parseInt(pageStr);
      }
      List<tb_gas_history> historicalDetectionList = gasService.getHistoricalDetection(page);
      List<tb_gas_history> historicalDetectionList = this.gasService.getHistoricalDetection(page);
      List<Integer> pageList = PageUtil.getPage(PageUtil.getLocPage(page, curPage), page, minPage);
      JSONObject json = new JSONObject();
      json.put("dataList", historicalDetectionList);
@@ -257,28 +311,34 @@
      json.put("curPage", page);
      return json.toString();
   }
   @ResponseBody
   @RequestMapping(value = "/historicalDetection_delete.do", method = { RequestMethod.POST, RequestMethod.GET })
   @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(",");
      gasService.historicalDetection_delete(checkVal);
      this.gasService.historicalDetection_delete(checkVal);
   }
   @ResponseBody
   @RequestMapping(value = "/historicalDetection_deleteAll.do", method = { RequestMethod.POST, RequestMethod.GET })
   @RequestMapping(
         value = {"/historicalDetection_deleteAll.do"},
         method = {RequestMethod.POST, RequestMethod.GET}
   )
   public void historicalDetection_deleteAll(HttpServletRequest request) {
      gasService.historicalDetection_deleteAll();
      this.gasService.historicalDetection_deleteAll();
   }
   // 对象转数组
   public static List<Object[]> hisobjectToArray(List<tb_gas_history> historicalDetectionList) {
      List<Object[]> reList = new ArrayList<>();
      for (int i = 0; i < historicalDetectionList.size(); i++) {
         List<String> words = new ArrayList<String>();
         tb_gas_history gas_history = (tb_gas_history) historicalDetectionList.get(i);
      List<Object[]> reList = new ArrayList();
      for(int i = 0; i < historicalDetectionList.size(); ++i) {
         List<String> 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());
@@ -288,72 +348,84 @@
         words.add(String.valueOf(gas_history.getY()));
         words.add(gas_history.getDeep());
         words.add(gas_history.getAddtime());
         String[] array = words.toArray(new String[0]);
         String[] array = (String[])words.toArray(new String[0]);
         reList.add(array);
      }
      return reList;
   }
   @ResponseBody
   @RequestMapping(value = "/historicalDetection_export.do", method = { RequestMethod.POST, RequestMethod.GET })
   @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<tb_gas_history> historicalDetectionList = gasService.getHistoricalDetection();
      String[] rowName = {"序号","设备通道   ","安装位置","气体类型","告警状态","X坐标","Y坐标","浓度值","添加时间"};
      List<tb_gas_history> historicalDetectionList = this.gasService.getHistoricalDetection();
      String[] rowName = new String[]{"序号", "设备通道\t", "安装位置", "气体类型", "告警状态", "X坐标", "Y坐标", "浓度值", "添加时间"};
      List<Object[]> dataList = hisobjectToArray(historicalDetectionList);
      ExcelUtils excel = new ExcelUtils("传感器管理", rowName, dataList);
      OutputStream out;
      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);
         out = response.getOutputStream();
         OutputStream out = response.getOutputStream();
         excel.export(out);
         out.flush();
         out.close();
      } catch (Exception e) {
         e.printStackTrace();
      } catch (Exception var11) {
         var11.printStackTrace();
      }
      return toPage;
   }
   @RequestMapping(value = "/collectorManagement.do", method = { RequestMethod.POST, RequestMethod.GET })
   @RequestMapping(
         value = {"/collectorManagement.do"},
         method = {RequestMethod.POST, RequestMethod.GET}
   )
   public String collectorManagement(HttpServletRequest request) {
      String toPage = "forward:/hxzk/gas/collectorManagement.jsp";
      List<tb_collector> collectorManagementList = gasService.getCollectorManagement(1);
      List<tb_collector> collectorManagementList = this.gasService.getCollectorManagement(1);
      request.setAttribute("collectorManagementList", collectorManagementList);
      int curPage = 1;
      int count = gasService.getCollectorManagementCount();
      int count = this.gasService.getCollectorManagementCount();
      int minPage = PageUtil.getMinPage(count);
      request.setAttribute("pageList", PageUtil.getPage(minPage));
      request.setAttribute("curPage", curPage);
      request.setAttribute("curPage", Integer.valueOf(curPage));
      return toPage;
   }
   @ResponseBody
   @RequestMapping(value = "/collectorManagement_search.do", method = { RequestMethod.POST, RequestMethod.GET })
   @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<Integer> pageList = new ArrayList<Integer>();
      List<tb_collector> collectorManagementList = gasService.searchCollectorManagement(input);
      List<Integer> pageList = new ArrayList();
      List<tb_collector> collectorManagementList = this.gasService.searchCollectorManagement(input);
      pageList.add(1);
      JSONObject json = new JSONObject();
      json.put("dataList", collectorManagementList);
      json.put("pageList", pageList);
      json.put("curPage", curPage);
      json.put("curPage", Integer.valueOf(curPage));
      return json.toString();
   }
   @ResponseBody
   @RequestMapping(value = "/collectorManagement_page.do", method = { RequestMethod.POST, RequestMethod.GET })
   @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 = gasService.getCollectorManagementCount();
      int count = this.gasService.getCollectorManagementCount();
      int minPage = PageUtil.getMinPage(count);
      int curPage = Integer.parseInt(curPageStr);
      int page = 1;
@@ -368,7 +440,8 @@
      } else {
         page = Integer.parseInt(pageStr);
      }
      List<tb_collector> labelManagementList = gasService.getCollectorManagement(page);
      List<tb_collector> labelManagementList = this.gasService.getCollectorManagement(page);
      List<Integer> pageList = PageUtil.getPage(PageUtil.getLocPage(page, curPage), page, minPage);
      JSONObject json = new JSONObject();
      json.put("dataList", labelManagementList);
@@ -376,23 +449,32 @@
      json.put("curPage", page);
      return json.toString();
   }
   @ResponseBody
   @RequestMapping(value = "/collectorManagement_delete.do", method = { RequestMethod.POST, RequestMethod.GET })
   @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(",");
      gasService.collectorManagement_delete(checkVal);
      this.gasService.collectorManagement_delete(checkVal);
   }
   @ResponseBody
   @RequestMapping(value = "/collectorManagement_deleteAll.do", method = { RequestMethod.POST, RequestMethod.GET })
   @RequestMapping(
         value = {"/collectorManagement_deleteAll.do"},
         method = {RequestMethod.POST, RequestMethod.GET}
   )
   public void collectorManagement_deleteAll(HttpServletRequest request) {
      gasService.collectorManagement_deleteAll();
      this.gasService.collectorManagement_deleteAll();
   }
   @RequestMapping(value = "/collectorManagement_add.do", method = { RequestMethod.POST, RequestMethod.GET })
   @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")));
@@ -402,10 +484,13 @@
      collector.setMacname(request.getParameter("insLoc"));
      collector.setPosx(Integer.parseInt(request.getParameter("coordX")));
      collector.setPosy(Integer.parseInt(request.getParameter("coordY")));
      gasService.collectorManagement_add(collector);
      this.gasService.collectorManagement_add(collector);
   }
   @RequestMapping(value = "/collectorManagement_modify.do", method = { RequestMethod.POST, RequestMethod.GET })
   @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")));
@@ -415,16 +500,16 @@
      collector.setIp(request.getParameter("intId"));
      collector.setMacname(request.getParameter("insLoc"));
      collector.setPosx(Integer.parseInt(request.getParameter("coordX")));
      collector.setPosy(Integer.parseInt(request.getParameter("coordY")));
      gasService.collectorManagement_modify(collector);
      collector.setPosy(Integer.parseInt(request.getParameter("coordY")));
      this.gasService.collectorManagement_modify(collector);
   }
   // 对象转数组
   public static List<Object[]> collectorobjectToArray(List<tb_collector> collectorManagementList) {
      List<Object[]> reList = new ArrayList<>();
      for (int i = 0; i < collectorManagementList.size(); i++) {
         List<String> words = new ArrayList<String>();
         tb_collector collector = (tb_collector) collectorManagementList.get(i);
      List<Object[]> reList = new ArrayList();
      for(int i = 0; i < collectorManagementList.size(); ++i) {
         List<String> 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()));
@@ -434,100 +519,116 @@
         words.add(String.valueOf(collector.getPosx()));
         words.add(String.valueOf(collector.getPosy()));
         words.add(String.valueOf(collector.getAddtime()));
         String[] array = words.toArray(new String[0]);
         String[] array = (String[])words.toArray(new String[0]);
         reList.add(array);
      }
      return reList;
   }
   @ResponseBody
   @RequestMapping(value = "/collectorManagement_export.do", method = { RequestMethod.POST, RequestMethod.GET })
   @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<tb_collector> collectorManagementList = gasService.getCollectorManagement();
      String[] rowName = {"序号","主机地址","起始地址","数据长度","IP地址","安装位置","X坐标","Y坐标","添加时间"};
      List<tb_collector> collectorManagementList = this.gasService.getCollectorManagement();
      String[] rowName = new String[]{"序号", "主机地址", "起始地址", "数据长度", "IP地址", "安装位置", "X坐标", "Y坐标", "添加时间"};
      List<Object[]> dataList = collectorobjectToArray(collectorManagementList);
      ExcelUtils excel = new ExcelUtils("采集仪管理", rowName, dataList);
      OutputStream out;
      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);
         out = response.getOutputStream();
         OutputStream out = response.getOutputStream();
         excel.export(out);
         out.flush();
         out.close();
      } catch (Exception e) {
         e.printStackTrace();
      } catch (Exception var11) {
         var11.printStackTrace();
      }
      return toPage;
   }
   final Logger logger = LoggerFactory.getLogger(getClass());
   @RequestMapping(value = "/collectorManagement_bw.do", method = { RequestMethod.POST, RequestMethod.GET })
   @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());
      logger.info("传入数据IData:" + jsonString);
      tb_collector collector = (tb_collector) JSONObject.toBean(JSONObject.fromObject(jsonString), tb_collector.class);
      gasService.collectorManagement_add(collector);
      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 })
   @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 = gasService.sensor_exist(String.valueOf(gas.getId()));
      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) {
         gasService.sensorManagement_add(gas);
      }
         this.gasService.sensorManagement_add(gas);
      }
   }
   @RequestMapping(value = "/modifyWarning.do", method = { RequestMethod.POST, RequestMethod.GET })
   @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);
      //显示sql
      String sqlString = "UPDATE tb_gas SET status = "+gas.getStatus()+",nong_du="+gas.getNong_du()+",addtime="+GetNowTime.timestamp2()+" WHERE id=" + gas.getId();
      String messageJson =  GetNowTime.timestamp2()+ " 收:"+ sqlString ;
      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")){
         /* Udp_Receive.mysqlMessage.add(messageJson); */
      if (baowenStatus.equals("1")) {
      }
      //
      gasService.modifyWarning(gas);
      this.gasService.modifyWarning(gas);
   }
   @ResponseBody
   @RequestMapping(value = "/getGasLength.do", method = { RequestMethod.POST, RequestMethod.GET })
   @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);
      tb_gas gas = (tb_gas)JSONObject.toBean(JSONObject.fromObject(jsonString), tb_gas.class);
      String ip = gas.getCollect_ip();
      Integer length = gasService.getGasNumber(ip);
      Integer length = this.gasService.getGasNumber(ip);
      json.put("length", length);
      return json.toString();
   }
   @ResponseBody
   @RequestMapping(value = "/getGas.do", method = { RequestMethod.POST, RequestMethod.GET })
   @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);
      tb_gas gas = (tb_gas)JSONObject.toBean(JSONObject.fromObject(jsonString), tb_gas.class);
      String tongdao = gas.getTong_dao();
      String ip = gas.getCollect_ip();
      List<tb_gas> gasList = gasService.getGas(tongdao,ip);
      List<tb_gas> gasList = this.gasService.getGas(tongdao, ip);
      if (gasList.size() > 0) {
         json.put("result", gasList.get(0));
      } else {
         json.put("result", "null");
      }
      return json.toString();
   }
}