3.7
fxl
2023-03-07 52cffc4ab8e9787a6f233295502c7c9788dddae1
src/main/java/com/hxzkoa/controller/GpsController.java
@@ -22,8 +22,10 @@
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.hxzkoa.json.tb_cojilu;
import com.hxzkoa.json.tb_gps;
import com.hxzkoa.json.tb_realocation;
import com.hxzkoa.json.tb_rtkanchor;
import com.hxzkoa.json.tb_system;
import com.hxzkoa.json.tb_tag;
import com.hxzkoa.services.GpsService;
@@ -37,6 +39,7 @@
import com.hxzkoa.util.ExcelUtils;
import com.hxzkoa.util.ModifyConfig;
import com.hxzkoa.util.PageUtil;
import com.hxzkoa.util.RequestUtils;
import net.sf.json.JSONObject;
@@ -169,7 +172,7 @@
   public String gpsManagement_export(HttpServletRequest request, HttpServletResponse response) {
      String toPage = "forward:/hxzk/GPS/gpsManagement.jsp";
      List<tb_gps> gpsManagementList = gpsService.getGpsManagement();
      String[] rowName = {"序号", "设备编号","纬度","经度","GPS状态","卫星数","海拔高","差分站ID","电量","更新时间"};
      String[] rowName = {"设备编号","卡号"};
      List<Object[]> dataList = objectToArray(gpsManagementList);
      ExcelUtils excel = new ExcelUtils("gps定位", rowName, dataList);
      OutputStream out;
@@ -337,7 +340,6 @@
   @RequestMapping(value = "/getstatusss.do", method = { RequestMethod.POST, RequestMethod.GET })
   public String getstatusss(HttpServletRequest request) {
      String tagid = "8888";
      //System.out.print("执行了");
      String zhuangtai = gpsService.getpersontagid(tagid);
      return zhuangtai;
   }
@@ -345,36 +347,69 @@
   @ResponseBody
   @RequestMapping(value = "/historicalgpsLocation_search.do", method = { RequestMethod.POST, RequestMethod.GET })
   public String historicalgpsLocation_search(HttpServletRequest request) {
      String input = request.getParameter("input");
      String date = request.getParameter("tttt");
      int curPage = 1;
      String input = request.getParameter("input");
      List<Integer> pageList = new ArrayList<Integer>();
      List<tb_gps> historicalLocationList = gpsService.searchRealTimegpsLocation(input,date);
      List<tb_gps> historicalLocationList = gpsService.searchRealTimegpsLocation(input,date,1);
      pageList.add(1);
      JSONObject json = new JSONObject();
      int curPage = 1;
      int count = gpsService.getgpsRealTimeLocationCount2(date,input);
      int minPage = PageUtil.getMinPage2(count);
      json.put("dataList", historicalLocationList);
      json.put("pageList", pageList);
      json.put("pageList", PageUtil.getPage(minPage));
      json.put("curPage", curPage);
      return json.toString();
   }
   
   @ResponseBody
   @RequestMapping(value = "/historicalgpsLocation_searcha.do", method = { RequestMethod.POST, RequestMethod.GET })
   public JSONObject historicalgpsLocation_searcha(HttpServletRequest request) {
      String input = request.getParameter("tagid");
   @RequestMapping(value = "/historicalgpsLocation_search2.do", method = { RequestMethod.POST, RequestMethod.GET })
   public String historicalgpsLocation_search2(HttpServletRequest request) {
      String pageStr = request.getParameter("page");
      String curPageStr = request.getParameter("curPage");
      String date = request.getParameter("date");
      JSONObject json = new JSONObject();
      int aaa = locationService.searchtablenameLocation("tb_gps_track_"+date);
      if (aaa != 0) {
         List<tb_gps> historicalLocationList = gpsService.searchRealTimegpsLocation(input,date);
         json.put("dataList", historicalLocationList);
      String input = request.getParameter("input");
      int count = gpsService.getgpsRealTimeLocationCount2(date,input);
      int minPage = PageUtil.getMinPage2(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 {
         List<tb_gps> abc = new ArrayList<>();
         json.put("dataList", abc);
         page = Integer.parseInt(pageStr);
      }
      return json;
      List<tb_gps> historicalLocationList = gpsService.searchRealTimegpsLocation(input,date,page);
      List<Integer> pageList = PageUtil.getPage(PageUtil.getLocPage(page, curPage), page, minPage);
      JSONObject json = new JSONObject();
      json.put("dataList", historicalLocationList);
      json.put("pageList", pageList);
      json.put("curPage", page);
      return json.toString();
   }
   
// @ResponseBody
// @RequestMapping(value = "/historicalgpsLocation_searcha.do", method = { RequestMethod.POST, RequestMethod.GET })
// public JSONObject historicalgpsLocation_searcha(HttpServletRequest request) {
//    String input = request.getParameter("tagid");
//    String date = request.getParameter("date");
//    JSONObject json = new JSONObject();
//    int aaa = locationService.searchtablenameLocation("tb_gps_track_"+date);
//    if (aaa != 0) {
//       List<tb_gps> historicalLocationList = gpsService.searchRealTimegpsLocation(input,date);
//       json.put("dataList", historicalLocationList);
//    } else {
//       List<tb_gps> abc = new ArrayList<>();
//       json.put("dataList", abc);
//    }
//    return json;
// }
   @ResponseBody
   @RequestMapping(value = "/historicalgpsLocation_export.do", method = { RequestMethod.POST, RequestMethod.GET })
   public String gpshistoricalPower_export(HttpServletRequest request, HttpServletResponse response) {
@@ -384,8 +419,8 @@
      String end = request.getParameter("endtime");
      String date = request.getParameter("date");
      List<tb_gps> historicalLocationList = gpsService.getRealTimegpsLocation(tagid,begin,end,date);
      String[] rowName = {"序号", "设备编号","纬度","经度","GPS状态","卫星数","海拔高","差分站ID","电量","更新时间"};
      List<Object[]> dataList = objectToArray(historicalLocationList);
      String[] rowName = {"序号", "设备编号","纬度","经度","GPS状态","卫星数","海拔高","差分站ID","水平精度因子","差分时间","电量","更新时间"};
      List<Object[]> dataList = objectToArray2(historicalLocationList);
      //System.out.print(dataList.get(0));
      ExcelUtils excel = new ExcelUtils("GPS数据", rowName, dataList);
      OutputStream out;
@@ -431,7 +466,20 @@
         for (int i = 0; i < sensorManagementList.size(); i++) {
            List<String> words = new ArrayList<String>();
            tb_gps gps = (tb_gps) sensorManagementList.get(i);
            words.add(String.valueOf(gps.getId()));
            words.add(gps.getTagid());
            words.add(gps.getCcid());
            String[] array = words.toArray(new String[0]);
            reList.add(array);
         }
         return reList;
      }
      public static List<Object[]> objectToArray2(List<tb_gps> sensorManagementList) {
         List<Object[]> reList = new ArrayList<>();
         for (int i = 0; i < sensorManagementList.size(); i++) {
            List<String> words = new ArrayList<String>();
            tb_gps gps = (tb_gps) sensorManagementList.get(i);
            words.add(gps.getId()+"");
            words.add(gps.getTagid());
            words.add(gps.getGps_weidu());
            words.add(gps.getGsp_jingdu());
@@ -439,6 +487,8 @@
            words.add(gps.getGps_num());
            words.add(gps.getGps_haiba_gao());
            words.add(gps.getGps_chafen_id());
            words.add(gps.getGps_hdop());
            words.add(gps.getGps_chafen_time());
            words.add(gps.getGps_power());
            words.add(gps.getAddtime());
            String[] array = words.toArray(new String[0]);
@@ -446,5 +496,90 @@
         }
         return reList;
      }
      //差分基站
      @RequestMapping(value="tortkanchor.do",method= {RequestMethod.POST,RequestMethod.GET})
      public String tortkanchor(HttpServletRequest request) {
         String toPage = "forward:/hxzk/GPS/rtkanchorManagement.jsp";
         List<tb_rtkanchor> mess = gpsService.findrtkanchor(1);
         request.setAttribute("dataList", mess);
         int curPage = 1;
         int count = gpsService.getrtkanchorManagementCount();
         int minPage = PageUtil.getMinPage(count);
         request.setAttribute("pageList", PageUtil.getPage(minPage));
         request.setAttribute("curPage", curPage);
         return toPage;
      }
      @ResponseBody
      @RequestMapping(value = "/rtkanchor_delete.do", method = { RequestMethod.POST, RequestMethod.GET })
      public void rtkanchor_delete(HttpServletRequest request) {
         String checkValStr = request.getParameter("checkVal");
         checkValStr = checkValStr.replaceAll("\"", "");
         String[] checkVal = checkValStr.split(",");
         gpsService.rtkanchor_delete(checkVal);
      }
      @ResponseBody
      @RequestMapping(value = "/rtkanchor_deletea.do", method = { RequestMethod.POST, RequestMethod.GET })
      public void rtkanchor_deletea(HttpServletRequest request) {
         gpsService.rtkanchor_deletea();
      }
      @ResponseBody
      @RequestMapping(value = "/rtkanchor_search.do", method = { RequestMethod.POST, RequestMethod.GET })
      public String rtkanchor_search(HttpServletRequest request) throws IOException {
         JSONObject json = new JSONObject();
         String input = request.getParameter("input");
         if (("").equals(input) || input == null) {
            String jsonString = RequestUtils.getRequestJsonString(request, Config.getCharset());
            tb_tag tag = (tb_tag) JSONObject.toBean(JSONObject.fromObject(jsonString), tb_tag.class);
            input = tag.getTag_id();
            List<tb_rtkanchor> warningSummaryList = gpsService.findrtkanchor3(input);
            if (warningSummaryList.size()>0){
               json.put("result", warningSummaryList.get(0));
            } else {
               json.put("result", "null");
            }
         } else {
            int curPage = 1;
            List<Integer> pageList = new ArrayList<Integer>();
            List<tb_rtkanchor> warningSummaryList = gpsService.findrtkanchor3(input);
            pageList.add(1);
            json.put("dataList", warningSummaryList);
            json.put("pageList", pageList);
            json.put("curPage", curPage);
         }
         return json.toString();
      }
      @ResponseBody
      @RequestMapping(value = "/rtkanchor_page.do", method = { RequestMethod.POST, RequestMethod.GET })
      public String rtkanchor_page(HttpServletRequest request) {
         String pageStr = request.getParameter("page");
         String curPageStr = request.getParameter("curPage");
         int count = gpsService.getrtkanchorManagementCount();
         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<tb_rtkanchor> labelManagementList = gpsService.findrtkanchor(page);
         List<Integer> 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();
      }
}