| | |
| | | package com.hxzkoa.controller; |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.io.OutputStream; |
| | | import java.sql.Date; |
| | | import java.sql.Time; |
| | | import java.sql.Timestamp; |
| | |
| | | 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.RequestParam; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import com.hxzkoa.json.httpsos; |
| | | import com.hxzkoa.json.tb_achor; |
| | |
| | | import com.hxzkoa.json.tb_gps; |
| | | import com.hxzkoa.json.tb_map; |
| | | import com.hxzkoa.json.tb_person; |
| | | import com.hxzkoa.json.tb_qihou; |
| | | import com.hxzkoa.json.tb_realkaoqing; |
| | | import com.hxzkoa.json.tb_realocation; |
| | | import com.hxzkoa.json.tb_realpositoin; |
| | | import com.hxzkoa.json.tb_shipin; |
| | | import com.hxzkoa.json.tb_system; |
| | | import com.hxzkoa.json.tb_tag; |
| | | import com.hxzkoa.json.tb_track; |
| | |
| | | import com.hxzkoa.udp.Udp_Out; |
| | | import com.hxzkoa.util.BytesToHex; |
| | | 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 com.hxzkoa.util.ResourceUtils; |
| | | |
| | | import jxl.Sheet; |
| | | import jxl.Workbook; |
| | | import jxl.read.biff.BiffException; |
| | | import net.sf.json.JSONObject; |
| | | |
| | | |
| | |
| | | @ResponseBody |
| | | public int drawFence_add(HttpServletRequest request) { |
| | | tb_fence fence = new tb_fence(); |
| | | fence.setFloor(request.getParameter("layer")); |
| | | String layer = request.getParameter("layer"); |
| | | if(!layer.equals("百度地图")) { |
| | | Integer layerjj = Integer.parseInt(layer); |
| | | layer = layerjj.toString(); |
| | | } |
| | | fence.setFloor(layer); |
| | | fence.setType(request.getParameter("weilanleixing")); |
| | | fence.setBumen(request.getParameter("guanlianduixiang")); |
| | | fence.setName(request.getParameter("quyumingcheng")); |
| | |
| | | return 0; |
| | | } |
| | | |
| | | @RequestMapping(value = "/sanweiFence.do", method = { RequestMethod.POST, RequestMethod.GET }) |
| | | @ResponseBody |
| | | public int sanweiFence_add(HttpServletRequest request) { |
| | | tb_fence fence = new tb_fence(); |
| | | String layer = request.getParameter("layer"); |
| | | if(!layer.equals("百度地图")) { |
| | | Integer layerjj = Integer.parseInt(layer); |
| | | layer = layerjj.toString(); |
| | | } |
| | | fence.setFloor(layer); |
| | | fence.setType(request.getParameter("weilanleixing")); |
| | | fence.setBumen(request.getParameter("guanlianduixiang")); |
| | | fence.setName(request.getParameter("quyumingcheng")); |
| | | fence.setBaoliu1(request.getParameter("fencegao")); |
| | | String zuobiao =(String) request.getParameter("zuobiao"); |
| | | fence.setZuobiao(zuobiao); |
| | | |
| | | fence.setShape(request.getParameter("xingzhuang")); |
| | | |
| | | String start = "00:00:00"; |
| | | String end = "23:59:59"; |
| | | fence.setStart(start); |
| | | fence.setStop(end); |
| | | |
| | | fence.setColor(request.getParameter("yanse")); |
| | | ZhwService.sanweiFence_add(fence); |
| | | String xieyi = "BSTOCS1,ADDFENCE,"+fence.getFloor()+","+fence.getType()+","+fence.getBumen()+","+fence.getName()+","+fence.getZuobiao()+","+fence.getShape()+","+fence.getStart()+","+fence.getStop()+","+GetNowTime.now()+","+fence.getColor()+",END"; |
| | | Udp_Out.udp_to_cs(xieyi); |
| | | |
| | | String type = request.getParameter("weilanleixing"); |
| | | String name = request.getParameter("quyumingcheng"); |
| | | String floor = request.getParameter("layer"); |
| | | String shape = request.getParameter("xingzhuang"); |
| | | |
| | | if(type.equals("巡检区域")) { |
| | | ZhwService.xunjianSet_add(name); |
| | | } else if (type.equals("定位区域")) { |
| | | String[] zb_list = zuobiao.split(","); |
| | | String zb_inout = ""; |
| | | for (int i=0;i<zb_list.length;i++) { |
| | | zb_inout += zb_list[i]; |
| | | if (i%2==0) { |
| | | zb_inout += ","; |
| | | } else if (i%2==1 && i!=zb_list.length-1) { |
| | | zb_inout += ";"; |
| | | } |
| | | } |
| | | ZhwService.fenceInout_add(name,zb_inout,shape,floor); |
| | | } |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | @RequestMapping(value = "/queryLocation.do", method = { RequestMethod.POST, RequestMethod.GET }) |
| | | public String queryLocation(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
| | | String toPage = "forward:/hxzk/location/queryLocation.jsp"; |
| | |
| | | @RequestMapping(value="/getRealPosition.do", method = { RequestMethod.POST, RequestMethod.GET }) |
| | | @ResponseBody |
| | | public List<tb_realpositoin> getRealPosition(HttpServletRequest request) { |
| | | //从tb_person中取最新更新的[p_tagid,p_x,p_y,p_floor,p_addtime] |
| | | String floor = request.getParameter("floor"); |
| | | // long timeNow = System.currentTimeMillis(); |
| | | // long timeStart = timeNow - 10000; //取10s内最新的一条数据作为当前的实时位置,后期可更改,此处为ms单位 |
| | | long timeStart = 0; |
| | | |
| | | //根据时间筛选出数据 |
| | | List<tb_person> realLocationList = ZhwService.getpersonLocation(floor); |
| | | List<tb_person> personLocationList = new ArrayList<tb_person>(); |
| | | for ( tb_person node : realLocationList) { |
| | | String timeRecent = node.getP_addtiem(); |
| | | Timestamp ts = Timestamp.valueOf(timeRecent); |
| | | long times = ts.getTime(); |
| | | System.out.println("times"+times); |
| | | if (times >= timeStart) { |
| | | personLocationList.add(node); |
| | | } |
| | | } |
| | | |
| | | List<tb_realpositoin> finalPositionList = new ArrayList<tb_realpositoin>(); |
| | | |
| | | //根据每个tagid取tb_tag:[tag_id,state(静止1or运动0),power,status(在线1or离线0),addtime],放入tb_position中 |
| | | for (tb_person node : personLocationList) { |
| | | List<tb_tag> taglist = new ArrayList<tb_tag>(); |
| | | List<tb_person> personlist = new ArrayList<tb_person>(); |
| | | |
| | | for (tb_person node : realLocationList) { |
| | | String tagid = node.getP_tagid(); |
| | | taglist = ZhwService.getRealTagState(tagid); |
| | | personlist = ZhwService.getRealpersonState(tagid); |
| | | |
| | | tb_realpositoin position = new tb_realpositoin(); |
| | | position.setTagid(tagid); |
| | | |
| | | if (personlist.isEmpty()) { |
| | | position.setPower(""); |
| | | position.setLife(""); |
| | | } else { |
| | | position.setPower(personlist.get(0).getP_power()); |
| | | position.setLife(personlist.get(0).getP_online()); |
| | | } |
| | | position.setPower(node.getP_power()); |
| | | position.setLife(node.getP_online()); |
| | | position.setName(node.getP_name()); |
| | | position.setPosx(node.getP_x()); |
| | | position.setPosy(node.getP_y()); |
| | |
| | | position.setTime(node.getP_addtiem()); |
| | | position.setFence(node.getP_fence()); |
| | | position.setSousuo(node.getP_sousuo()); |
| | | position.setShipin(node.getP_shipin()); |
| | | |
| | | finalPositionList.add(position); |
| | | } |
| | |
| | | @RequestMapping(value="/getRealPosition_all.do", method = { RequestMethod.POST, RequestMethod.GET }) |
| | | @ResponseBody |
| | | public List<tb_realpositoin> getRealPosition_all(HttpServletRequest request) { |
| | | //从tb_person中取最新更新的[p_tagid,p_x,p_y,p_floor,p_addtime] |
| | | // long timeNow = System.currentTimeMillis(); |
| | | //long timeStart = timeNow - 10000; //取10s内最新的一条数据作为当前的实时位置,后期可更改,此处为ms单位 |
| | | long timeStart = 0; |
| | | |
| | | //根据时间筛选出数据 |
| | | List<tb_person> realLocationList = ZhwService.getpersonLocation_all(); |
| | | List<tb_person> personLocationList = new ArrayList<tb_person>(); |
| | | for ( tb_person node : realLocationList) { |
| | | String timeRecent = node.getP_addtiem(); |
| | | Timestamp ts = Timestamp.valueOf(timeRecent); |
| | | long times = ts.getTime(); |
| | | System.out.println("times"+times); |
| | | if (times >= timeStart) { |
| | | personLocationList.add(node); |
| | | } |
| | | } |
| | | |
| | | List<tb_realpositoin> finalPositionList = new ArrayList<tb_realpositoin>(); |
| | | |
| | | //根据每个tagid取tb_tag:[tag_id,state(静止1or运动0),power,status(在线1or离线0),addtime],放入tb_position中 |
| | | for (tb_person node : personLocationList) { |
| | | List<tb_tag> taglist = new ArrayList<tb_tag>(); |
| | | |
| | | for (tb_person node : realLocationList) { |
| | | String tagid = node.getP_tagid(); |
| | | taglist = ZhwService.getRealTagState(tagid); |
| | | |
| | | tb_realpositoin position = new tb_realpositoin(); |
| | | position.setTagid(tagid); |
| | | |
| | | if (taglist.isEmpty()) { |
| | | position.setPower(""); |
| | | position.setLife(""); |
| | | } else { |
| | | position.setPower(taglist.get(0).getPower()); |
| | | position.setLife(taglist.get(0).getStatus()); |
| | | } |
| | | position.setPower(node.getP_power()); |
| | | position.setLife(node.getP_online()); |
| | | position.setFloor(node.getP_floor()); |
| | | position.setName(node.getP_name()); |
| | | position.setPosx(node.getP_x()); |
| | |
| | | // Timestamp ts = Timestamp.valueOf(timeRecent); |
| | | // long times = ts.getTime(); |
| | | // if (times >= timeStart) { |
| | | // int jingdu = node.getGsp_jingdu().length(); |
| | | // //System.out.print("执行了"+jingdu); |
| | | if (node.getGsp_jingdu() != null && !node.getGsp_jingdu().equals("00000.000000") && node.getGps_weidu() != null && !node.getGps_weidu().equals("00000.000000")) { |
| | | // String weidu = node.getGps_weidu().substring(0,node.getGps_weidu().length()-1); |
| | | // node.setGps_weidu(weidu); |
| | | // String jingdu2 = node.getGsp_jingdu().substring(0, node.getGsp_jingdu().length()-1); |
| | | // node.setGsp_jingdu(jingdu2); |
| | | finalGPSList.add(node); |
| | | } |
| | | // String weidu = node.getGps_weidu().substring(0,node.getGps_weidu().length()-1); |
| | | // node.setGps_weidu(weidu); |
| | | // String jingdu = node.getGsp_jingdu().substring(0, node.getGsp_jingdu().length()-1); |
| | | // node.setGsp_jingdu(jingdu); |
| | | // finalGPSList.add(node); |
| | | // } |
| | | }; |
| | | return finalGPSList; |
| | |
| | | String map_now = request.getParameter("map_now"); |
| | | String filePath = Config.getMapConfig(); |
| | | ModifyConfig.writeData(filePath,"map_now",map_now); |
| | | System.out.print(ModifyConfig.readData(filePath, "map_now")); |
| | | //System.out.print(ModifyConfig.readData(filePath, "map_now")); |
| | | return "1"; |
| | | } |
| | | |
| | |
| | | // String map = ModifyConfig.readData(filePath, "map_now"); |
| | | // List<String> maplist = new ArrayList<String>(); |
| | | // maplist.add(map); |
| | | // System.out.print("read data"); |
| | | // System.out.print(map); |
| | | // //System.out.print("read data"); |
| | | // //System.out.print(map); |
| | | List<tb_system> systemlist = sysSettingService.getSetting(); |
| | | List<String> maplist = new ArrayList<String>(); |
| | | String map = systemlist.get(0).getYulan_map(); |
| | |
| | | ZhwService.fencegao(tagid); |
| | | } |
| | | |
| | | @ResponseBody |
| | | @RequestMapping(value = "/shipinzhuangtai.do", method = { RequestMethod.POST, RequestMethod.GET }) |
| | | public List<tb_shipin> shipinzhuangtai(HttpServletRequest request){ |
| | | String tagid=request.getParameter("tagid"); |
| | | ZhwService.shipin(tagid); |
| | | List<tb_person> fencename = ZhwService.getfencename(tagid); |
| | | // //System.out.print(fencename.get(0).getP_fencename()); |
| | | List<tb_shipin> id = ZhwService.getshebeiid(fencename.get(0).getP_fencename()); |
| | | // //System.out.print(id.get(0).getShebeiid()); |
| | | List<tb_shipin> bb =null; |
| | | return id; |
| | | } |
| | | |
| | | @RequestMapping(value = "/sousuo.do", method = { RequestMethod.POST, RequestMethod.GET }) |
| | | public void sousuo(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
| | | String tagid = request.getParameter("tagid"); |
| | |
| | | String xieyi = "BSTOCS1,give_up_sousuo,END"; |
| | | Udp_Out.udp_to_cs(xieyi); |
| | | } |
| | | |
| | | @RequestMapping(value = "/qihouManagement.do", method = { RequestMethod.POST, RequestMethod.GET }) |
| | | public String qihouManagement(HttpServletRequest request) { |
| | | String toPage = "forward:/hxzk/qihou.jsp"; |
| | | List<tb_qihou> qihouManagementList = ZhwService.qihoucha(1); |
| | | request.setAttribute("qihouManagementList", qihouManagementList); |
| | | int curPage = 1; |
| | | int count = ZhwService.getqihouManagementCount(); |
| | | int minPage = PageUtil.getMinPage(count); |
| | | request.setAttribute("pageList", PageUtil.getPage(minPage)); |
| | | request.setAttribute("curPage", curPage); |
| | | return toPage; |
| | | } |
| | | |
| | | @RequestMapping(value = "/qihouManagement_add.do", method = { RequestMethod.POST, RequestMethod.GET }) |
| | | public void qihouManagement_add(HttpServletRequest request) throws IOException { |
| | | tb_qihou qihou = new tb_qihou(); |
| | | qihou.setPlace(request.getParameter("place")); |
| | | qihou.setWeather(request.getParameter("weather")); |
| | | qihou.setWd(request.getParameter("wd")); |
| | | qihou.setSd(request.getParameter("sd")); |
| | | ZhwService.qihouzeng(qihou); |
| | | } |
| | | |
| | | @RequestMapping(value = "/qihouManagement_modify.do", method = { RequestMethod.POST, RequestMethod.GET }) |
| | | public void qihouManagement_modify(HttpServletRequest request) { |
| | | tb_qihou qihou = new tb_qihou(); |
| | | String id = request.getParameter("id"); |
| | | qihou.setId(Integer.parseInt(id)); |
| | | qihou.setPlace(request.getParameter("place")); |
| | | qihou.setWeather(request.getParameter("weather")); |
| | | qihou.setWd(request.getParameter("wd")); |
| | | qihou.setSd(request.getParameter("sd")); |
| | | ZhwService.qihougai(qihou); |
| | | } |
| | | |
| | | // @RequestMapping(value = "/labelManagement_modifyAll.do", method = { RequestMethod.POST, RequestMethod.GET }) |
| | | // public void labelManagement_modifyAll(HttpServletRequest request) { |
| | | // tb_tag tag = new tb_tag(); |
| | | // tag.setGaodu(request.getParameter("gaodu")); |
| | | // tag.setSudu(request.getParameter("sudu")); |
| | | // tag.setPinglv(request.getParameter("pinglv")); |
| | | // labelService.labelManagement_modifyAll(tag); |
| | | // String xieyi = "BSTOCS1,ALTERALLTAG,"+tag.getGaodu()+","+tag.getSudu()+","+tag.getPinglv()+",END"; |
| | | // Udp_Out.udp_to_cs(xieyi); |
| | | // // 需要遍历修改 |
| | | // List<tb_tag> labelList = labelService.getLabelManagement(); |
| | | // for (int i = 0; i < labelList.size(); i++) { |
| | | // String tag_id = labelList.get(i).getTag_id(); |
| | | // // 修改标签同时需要修改tb_person 需要先查再改否则覆盖空 |
| | | // List<tb_person> searchPersonManagement = basicInfoService.searchPersonManagement(tag_id); |
| | | // if(searchPersonManagement!=null){ |
| | | // tb_person person = searchPersonManagement.get(0); |
| | | // person.setP_tagid(tag.getTag_id()); |
| | | // person.setP_name(tag.getState()); |
| | | // person.setP_power(tag.getPower()); |
| | | // basicInfoService.personManagement_modify(person); |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | @ResponseBody |
| | | @RequestMapping(value = "/qihouManagement_delete.do", method = { RequestMethod.POST, RequestMethod.GET }) |
| | | public void qihouManagement_delete(HttpServletRequest request) { |
| | | String checkValStr = request.getParameter("checkVal"); |
| | | checkValStr = checkValStr.replaceAll("\"", ""); |
| | | String[] checkVal = checkValStr.split(","); |
| | | ZhwService.qihoudelete(checkVal); |
| | | } |
| | | |
| | | @ResponseBody |
| | | @RequestMapping(value = "/qihouManagement_deleteAll.do", method = { RequestMethod.POST, RequestMethod.GET }) |
| | | public void qihouManagement_deleteAll(HttpServletRequest request) { |
| | | ZhwService.qihoudeleteAll(); |
| | | } |
| | | |
| | | @ResponseBody |
| | | @RequestMapping(value = "/qihouManagement_export.do", method = { RequestMethod.POST, RequestMethod.GET }) |
| | | public String qihouManagement_export(HttpServletRequest request, HttpServletResponse response) { |
| | | String toPage = "forward:/hxzk/qihou.jsp"; |
| | | List<tb_qihou> tb_qihouList = ZhwService.qihoucha(); |
| | | String[] rowName = { "ID", "时间", "地点", "天气", "温度", "湿度" }; |
| | | List<Object[]> dataList = objectToArray_qihouManagement(tb_qihouList); |
| | | 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(); |
| | | excel.export(out); |
| | | out.flush(); |
| | | out.close(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return toPage; |
| | | } |
| | | |
| | | @ResponseBody |
| | | @RequestMapping(value = "/qihouManagement_exportTemplate.do", method = { RequestMethod.POST, RequestMethod.GET }) |
| | | public String qihouManagement_exportTemplate(HttpServletRequest request, HttpServletResponse response) { |
| | | String toPage = "forward:/hxzk/qihou.jsp"; |
| | | List<tb_qihou> qihouTemplateList = ZhwService.qihoucha(1); |
| | | String[] rowName = { "时间", "地点", "天气", "温度", "湿度"}; |
| | | List<Object[]> dataList = objectToArray_qihouManagement2(qihouTemplateList); |
| | | 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(); |
| | | excel.export(out); |
| | | out.flush(); |
| | | out.close(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return toPage; |
| | | } |
| | | |
| | | @ResponseBody |
| | | @RequestMapping(value = "/qihouManagement_page.do", method = { RequestMethod.POST, RequestMethod.GET }) |
| | | public String qihouManagement_page(HttpServletRequest request) { |
| | | String pageStr = request.getParameter("page"); |
| | | String curPageStr = request.getParameter("curPage"); |
| | | int count = ZhwService.getqihouManagementCount(); |
| | | 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_qihou> qihouManagementList = ZhwService.qihoucha(page); |
| | | List<Integer> pageList = PageUtil.getPage(PageUtil.getLocPage(page, curPage), page, minPage); |
| | | JSONObject json = new JSONObject(); |
| | | json.put("dataList", qihouManagementList); |
| | | json.put("pageList", pageList); |
| | | json.put("curPage", page); |
| | | return json.toString(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/uploadqihou.do") |
| | | public String uploadqihou(@RequestParam("file") MultipartFile[] files, HttpServletRequest request) { |
| | | String toPage = "forward:/hxzk/qihou.jsp"; |
| | | String filePath = request.getServletContext().getRealPath("/") + "hxzk\\upload\\"; |
| | | String filename = files[0].getOriginalFilename(); |
| | | try { |
| | | File existFile = new File(filePath); |
| | | if (!existFile.exists()) { |
| | | existFile.mkdir(); |
| | | } |
| | | for (MultipartFile file : files) { |
| | | file.transferTo(new File(filePath + file.getOriginalFilename())); |
| | | //System.out.print(file.getOriginalFilename()); |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | int result = 0; |
| | | String path = filePath + filename; |
| | | // 选取Excel文件得到工作薄 |
| | | Workbook workbook; |
| | | try { |
| | | File file = new File(path); |
| | | workbook = Workbook.getWorkbook(file); |
| | | // 选择工作表,通过Workbook的getSheet方法选择第一个工作表(从0开始) |
| | | Sheet sheet = workbook.getSheet(0); |
| | | int rows = sheet.getRows(); |
| | | // 选择Cell,读取单元格 通过Sheet的getCell方法选择位置为C2的单元格(两个参数都从0开始) |
| | | for (int i = 3; i < rows; i++) { |
| | | // 读取信息,通过Cell的getContents方法读取单元格的值把单元格中的信息以字符的形式读取出来 |
| | | // String status = sheet.getCell(0, i).getContents(); |
| | | String time = sheet.getCell(0, i).getContents(); |
| | | String place = sheet.getCell(1, i).getContents(); |
| | | String weather = sheet.getCell(2, i).getContents(); |
| | | String wd = sheet.getCell(3, i).getContents(); |
| | | String sd = sheet.getCell(4, i).getContents(); |
| | | tb_qihou qihou = new tb_qihou(); |
| | | // tag.setStatus(status); |
| | | qihou.setTime(time); |
| | | qihou.setPlace(place); |
| | | qihou.setWeather(weather); |
| | | qihou.setWd(wd); |
| | | qihou.setSd(sd); |
| | | result = ZhwService.qihouzeng(qihou); |
| | | } |
| | | // 释放资源 |
| | | workbook.close(); |
| | | } catch (BiffException e) { |
| | | e.printStackTrace(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | request.setAttribute("resultList", result); |
| | | List<tb_qihou> qihouManagementList = ZhwService.qihoucha(1); |
| | | request.setAttribute("qihouManagementList", qihouManagementList); |
| | | int curPage = 1; |
| | | int count = ZhwService.getqihouManagementCount(); |
| | | int minPage = PageUtil.getMinPage(count); |
| | | request.setAttribute("pageList", PageUtil.getPage(minPage)); |
| | | request.setAttribute("curPage", curPage); |
| | | File file = new File(path); |
| | | file.delete(); |
| | | return toPage; |
| | | } |
| | | |
| | | @RequestMapping(value="/getRealPositionsan.do", method = { RequestMethod.POST, RequestMethod.GET }) |
| | | @ResponseBody |
| | | public List<tb_realpositoin> getRealPositionsan(HttpServletRequest request) { |
| | | long timeStart = 0; |
| | | |
| | | //根据时间筛选出数据 |
| | | List<tb_person> realLocationList = ZhwService.getpersonLocationsan(); |
| | | for ( tb_person node : realLocationList) { |
| | | Double x = Double.valueOf(node.getP_x()); |
| | | Double y = Double.valueOf(node.getP_y()); |
| | | Double xo = (x-54732)/100; |
| | | Double yo = -(y+10268)/100; |
| | | List<Double> xy = ZhwController.cal2(xo, yo); |
| | | node.setP_x((xy.get(0)).toString()); |
| | | node.setP_y((xy.get(1)).toString()); |
| | | } |
| | | |
| | | List<tb_realpositoin> finalPositionList = new ArrayList<tb_realpositoin>(); |
| | | |
| | | //根据每个tagid取tb_tag:[tag_id,state(静止1or运动0),power,status(在线1or离线0),addtime],放入tb_position中 |
| | | for (tb_person node : realLocationList) { |
| | | String tagid = node.getP_tagid(); |
| | | tb_realpositoin position = new tb_realpositoin(); |
| | | position.setTagid(tagid); |
| | | position.setPower(node.getP_power()); |
| | | position.setLife(node.getP_online()); |
| | | position.setName(node.getP_name()); |
| | | position.setPosx(node.getP_x()); |
| | | position.setPosy(node.getP_y()); |
| | | position.setSos(node.getP_sos()); |
| | | position.setTime(node.getP_addtiem()); |
| | | position.setFence(node.getP_fence()); |
| | | position.setSousuo(node.getP_sousuo()); |
| | | position.setShipin(node.getP_shipin()); |
| | | position.setInkaoqing(node.getP_kaoqing()); |
| | | |
| | | finalPositionList.add(position); |
| | | } |
| | | return finalPositionList; |
| | | } |
| | | |
| | | @RequestMapping(value="/getkaoqinsan.do", method = { RequestMethod.POST, RequestMethod.GET }) |
| | | @ResponseBody |
| | | public List<tb_realkaoqing> getkaoqinsan(HttpServletRequest request) { |
| | | List<tb_realkaoqing> realkaoqingList = ZhwService.getkaoqinsan(); |
| | | return realkaoqingList; |
| | | } |
| | | |
| | | public static List<Object[]> objectToArray_qihouManagement2(List<tb_qihou> tb_qihouList) { |
| | | List<Object[]> reList = new ArrayList<>(); |
| | | for (int i = 0; i < tb_qihouList.size(); i++) { |
| | | List<String> words = new ArrayList<String>(); |
| | | tb_qihou qihou = (tb_qihou) tb_qihouList.get(i); |
| | | words.add(qihou.getTime()); |
| | | words.add(qihou.getPlace()); |
| | | words.add(qihou.getWeather()); |
| | | words.add(qihou.getWd()); |
| | | words.add(qihou.getSd()); |
| | | String[] array = words.toArray(new String[0]); |
| | | reList.add(array); |
| | | } |
| | | return reList; |
| | | } |
| | | |
| | | // tb_qihou 导出表格 对象转数组 |
| | | public static List<Object[]> objectToArray_qihouManagement(List<tb_qihou> tb_qihouList) { |
| | | List<Object[]> reList = new ArrayList<>(); |
| | | for (int i = 0; i < tb_qihouList.size(); i++) { |
| | | List<String> words = new ArrayList<String>(); |
| | | tb_qihou qihou = (tb_qihou) tb_qihouList.get(i); |
| | | words.add(String.valueOf(qihou.getId())); |
| | | words.add(qihou.getTime()); |
| | | words.add(qihou.getPlace()); |
| | | words.add(qihou.getWeather()); |
| | | words.add(qihou.getWd()); |
| | | words.add(qihou.getSd()); |
| | | String[] array = words.toArray(new String[0]); |
| | | reList.add(array); |
| | | } |
| | | return reList; |
| | | } |
| | | |
| | | /** |
| | | * 以K0 + 877为原点 |
| | | * @param px X坐标 |
| | | * @param py y坐标 |
| | | */ |
| | | private static List<Double> cal2(double px, double py) { |
| | | double mx1 = 12738394.2203293; |
| | | double my1 = 4586352.97186441; |
| | | double rx = 1.0439323780911336; |
| | | double ry = 1.0443204318588795; |
| | | |
| | | double mx = mx1 + px * rx; |
| | | double my = my1 + py * ry; |
| | | |
| | | List<Double> xy = new ArrayList<Double>(); |
| | | xy.add(mx); |
| | | xy.add(my); |
| | | return xy; |
| | | } |
| | | } |